vulkan: Fix some extension support related validation errors.

This commit is contained in:
squidbus 2024-09-26 21:05:21 -07:00
parent ebebafed64
commit fbf1a267b0
4 changed files with 11 additions and 3 deletions

View File

@ -233,6 +233,7 @@ void DefineEntryPoint(const IR::Program& program, EmitContext& ctx, Id main) {
ctx.AddExecutionMode(main, spv::ExecutionMode::OriginUpperLeft); ctx.AddExecutionMode(main, spv::ExecutionMode::OriginUpperLeft);
} }
if (info.has_discard) { if (info.has_discard) {
ctx.AddExtension("SPV_EXT_demote_to_helper_invocation");
ctx.AddCapability(spv::Capability::DemoteToHelperInvocationEXT); ctx.AddCapability(spv::Capability::DemoteToHelperInvocationEXT);
} }
if (info.stores.Get(IR::Attribute::Depth)) { if (info.stores.Get(IR::Attribute::Depth)) {

View File

@ -95,7 +95,8 @@ Buffer::Buffer(const Vulkan::Instance& instance_, Vulkan::Scheduler& scheduler_,
// Create buffer object. // Create buffer object.
const vk::BufferCreateInfo buffer_ci = { const vk::BufferCreateInfo buffer_ci = {
.size = size_bytes, .size = size_bytes,
.usage = flags, // When maintenance5 is not supported, use all flags since we can't add flags to views.
.usage = instance->IsMaintenance5Supported() ? flags : AllFlags,
}; };
VmaAllocationInfo alloc_info{}; VmaAllocationInfo alloc_info{};
buffer.Create(buffer_ci, usage, &alloc_info); buffer.Create(buffer_ci, usage, &alloc_info);
@ -119,7 +120,7 @@ vk::BufferView Buffer::View(u32 offset, u32 size, bool is_written, AmdGpu::DataF
: vk::BufferUsageFlagBits2KHR::eUniformTexelBuffer, : vk::BufferUsageFlagBits2KHR::eUniformTexelBuffer,
}; };
const vk::BufferViewCreateInfo view_ci = { const vk::BufferViewCreateInfo view_ci = {
.pNext = &usage_flags, .pNext = instance->IsMaintenance5Supported() ? &usage_flags : nullptr,
.buffer = buffer.buffer, .buffer = buffer.buffer,
.format = Vulkan::LiverpoolToVK::SurfaceFormat(dfmt, nfmt), .format = Vulkan::LiverpoolToVK::SurfaceFormat(dfmt, nfmt),
.offset = offset, .offset = offset,

View File

@ -262,7 +262,7 @@ bool Instance::CreateDevice() {
const bool robustness = add_extension(VK_EXT_ROBUSTNESS_2_EXTENSION_NAME); const bool robustness = add_extension(VK_EXT_ROBUSTNESS_2_EXTENSION_NAME);
const bool topology_restart = const bool topology_restart =
add_extension(VK_EXT_PRIMITIVE_TOPOLOGY_LIST_RESTART_EXTENSION_NAME); add_extension(VK_EXT_PRIMITIVE_TOPOLOGY_LIST_RESTART_EXTENSION_NAME);
const bool maintenance5 = add_extension(VK_KHR_MAINTENANCE_5_EXTENSION_NAME); maintenance5 = add_extension(VK_KHR_MAINTENANCE_5_EXTENSION_NAME);
// These extensions are promoted by Vulkan 1.3, but for greater compatibility we use Vulkan 1.2 // These extensions are promoted by Vulkan 1.3, but for greater compatibility we use Vulkan 1.2
// with extensions. // with extensions.

View File

@ -138,6 +138,11 @@ public:
return null_descriptor; return null_descriptor;
} }
/// Returns true when VK_KHR_maintenance5 is supported.
bool IsMaintenance5Supported() const {
return maintenance5;
}
/// Returns the vendor ID of the physical device /// Returns the vendor ID of the physical device
u32 GetVendorID() const { u32 GetVendorID() const {
return properties.vendorID; return properties.vendorID;
@ -280,6 +285,7 @@ private:
bool color_write_en{}; bool color_write_en{};
bool vertex_input_dynamic_state{}; bool vertex_input_dynamic_state{};
bool null_descriptor{}; bool null_descriptor{};
bool maintenance5{};
u64 min_imported_host_pointer_alignment{}; u64 min_imported_host_pointer_alignment{};
u32 subgroup_size{}; u32 subgroup_size{};
bool tooling_info{}; bool tooling_info{};