From 88027da710de947edfa0fa878cb0cf881468bab7 Mon Sep 17 00:00:00 2001 From: Frank Binns Date: Tue, 23 Apr 2024 08:46:39 +0100 Subject: [PATCH] pvr: implement VK_(EXT|KHR)_vertex_attribute_divisor Signed-off-by: Frank Binns Signed-off-by: Simon Perretta Co-authored-by: Simon Perretta Acked-by: Erik Faye-Lund Part-of: --- docs/features.txt | 4 ++-- src/imagination/vulkan/pvr_device.c | 11 +++++++++++ src/imagination/vulkan/pvr_pipeline.c | 6 ++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/docs/features.txt b/docs/features.txt index e93f61ec0ad..778ef6d8368 100644 --- a/docs/features.txt +++ b/docs/features.txt @@ -526,7 +526,7 @@ Vulkan 1.4 -- all DONE: anv, hk, lvp, nvk, panvk/v10+, radv/gfx8+, tu/a7xx+, vn VK_KHR_shader_expect_assume DONE (anv, dzn, hasvk, lvp, nvk, panvk, pvr, radv, tu, v3dv, vn) VK_KHR_shader_float_controls2 DONE (anv, lvp, nvk, panvk/v10+, radv, tu, vn) VK_KHR_shader_subgroup_rotate DONE (anv, lvp, nvk, panvk, radv, tu, vn) - VK_KHR_vertex_attribute_divisor DONE (anv, lvp, nvk, panvk, radv, tu, v3dv, vn) + VK_KHR_vertex_attribute_divisor DONE (anv, lvp, nvk, panvk, pvr, radv, tu, v3dv, vn) VK_EXT_host_image_copy DONE (anv, lvp, nvk/Turing+, panvk, radv/gfx10+, tu, vn) VK_EXT_pipeline_protected_access DONE (anv/gfx12+, vn) VK_EXT_pipeline_robustness DONE (anv, lvp, nvk, panvk, radv, v3dv, tu, vn) @@ -669,7 +669,7 @@ Khronos extensions that are not part of any Vulkan version: VK_EXT_surface_maintenance1 DONE (anv, hk, lvp, nvk, radv, tu, v3dv, vn) VK_EXT_swapchain_maintenance1 DONE (anv, hk, lvp, nvk, radv, tu, v3dv, vn) VK_EXT_transform_feedback DONE (anv, hasvk, hk, lvp, nvk, radv, tu, vn) - VK_EXT_vertex_attribute_divisor DONE (anv, dzn, hasvk, hk, lvp, nvk, panvk, radv, tu, v3dv, vn) + VK_EXT_vertex_attribute_divisor DONE (anv, dzn, hasvk, hk, lvp, nvk, panvk, pvr, radv, tu, v3dv, vn) VK_EXT_vertex_input_dynamic_state DONE (anv, hk, lvp, nvk, panvk, radv, tu, vn) VK_EXT_ycbcr_image_arrays DONE (anv, hasvk, hk, lvp, nvk, panvk/v10+, radv, vn) VK_EXT_zero_initialize_device_memory DONE (lvp, nvk, radv) diff --git a/src/imagination/vulkan/pvr_device.c b/src/imagination/vulkan/pvr_device.c index 259742d5e59..c203ebab94d 100644 --- a/src/imagination/vulkan/pvr_device.c +++ b/src/imagination/vulkan/pvr_device.c @@ -189,6 +189,7 @@ static void pvr_physical_device_get_supported_extensions( .KHR_swapchain = PVR_USE_WSI_PLATFORM, .KHR_timeline_semaphore = true, .KHR_uniform_buffer_standard_layout = true, + .KHR_vertex_attribute_divisor = true, .KHR_zero_initialize_workgroup_memory = false, .EXT_depth_clamp_zero_one = true, .EXT_external_memory_dma_buf = true, @@ -200,6 +201,7 @@ static void pvr_physical_device_get_supported_extensions( .EXT_scalar_block_layout = true, .EXT_texel_buffer_alignment = false, .EXT_tooling_info = true, + .EXT_vertex_attribute_divisor = true, }; } @@ -306,6 +308,11 @@ static void pvr_physical_device_get_supported_features( /* VK_KHR_present_wait2 */ .presentWait2 = PVR_USE_WSI_PLATFORM, + /* Vulkan 1.4 / VK_EXT_vertex_attribute_divisor / + VK_KHR_vertex_attribute_divisor */ + .vertexAttributeInstanceRateDivisor = true, + .vertexAttributeInstanceRateZeroDivisor = true, + /* Vulkan 1.3 / VK_KHR_zero_initialize_workgroup_memory */ .shaderZeroInitializeWorkgroupMemory = false, }; @@ -538,6 +545,10 @@ static bool pvr_physical_device_get_properties( .storageTexelBufferOffsetSingleTexelAlignment = true, .uniformTexelBufferOffsetAlignmentBytes = PVR_TEXEL_BUFFER_OFFSET_ALIGNMENT, .uniformTexelBufferOffsetSingleTexelAlignment = false, + + /* Vulkan 1.4 / VK_EXT_vertex_attribute_divisor / VK_KHR_vertex_attribute_divisor */ + .maxVertexAttribDivisor = UINT32_MAX, + .supportsNonZeroFirstInstance = true, }; if (PVR_HAS_FEATURE(dev_info, gpu_multicore_support)) { diff --git a/src/imagination/vulkan/pvr_pipeline.c b/src/imagination/vulkan/pvr_pipeline.c index 4e0b1628f3b..2065da24030 100644 --- a/src/imagination/vulkan/pvr_pipeline.c +++ b/src/imagination/vulkan/pvr_pipeline.c @@ -1414,11 +1414,9 @@ static void pvr_graphics_pipeline_setup_vertex_dma( */ dma_desc->binding_index = attribute->binding; - /* We don't currently support VK_EXT_vertex_attribute_divisor so no - * repeating of instance-rate vertex attributes needed. We should always - * move on to the next vertex attribute. - */ dma_desc->divisor = 1; + if (binding->inputRate == VK_VERTEX_INPUT_RATE_INSTANCE) + dma_desc->divisor = vi->bindings[attribute->binding].divisor; /* Will be used to generate PDS code that takes care of robust buffer * access, and later on by the driver to write the correct robustness