From acbb0d86f71c950e29df70e357ae08e5ca903a49 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Thu, 10 Mar 2022 16:21:34 -0600 Subject: [PATCH] panvk: Implement VK_EXT_vertex_attribute_divisor Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/ci/deqp-panfrost-g52-vk.toml | 1 + src/panfrost/vulkan/panvk_device.c | 8 ++++++++ src/panfrost/vulkan/panvk_vX_pipeline.c | 12 ++++++++++++ 3 files changed, 21 insertions(+) diff --git a/src/panfrost/ci/deqp-panfrost-g52-vk.toml b/src/panfrost/ci/deqp-panfrost-g52-vk.toml index c9a918157ef..73b27f56434 100644 --- a/src/panfrost/ci/deqp-panfrost-g52-vk.toml +++ b/src/panfrost/ci/deqp-panfrost-g52-vk.toml @@ -7,6 +7,7 @@ include = [ "dEQP-VK.api.buffer_view.*", "dEQP-VK.api.copy_and_blit.core.*", "dEQP-VK.compute.builtin_var.*", + "dEQP-VK.draw.renderpass.instanced.draw_indexed_vk_*", "dEQP-VK.glsl.builtin.function.integer.usubborrow.*", "dEQP-VK.glsl.builtin.precision.frexp.*", "dEQP-VK.glsl.builtin.precision.ldexp.*", diff --git a/src/panfrost/vulkan/panvk_device.c b/src/panfrost/vulkan/panvk_device.c index d1ce47e7cc0..c790fc87910 100644 --- a/src/panfrost/vulkan/panvk_device.c +++ b/src/panfrost/vulkan/panvk_device.c @@ -152,6 +152,7 @@ panvk_get_device_extensions(const struct panvk_physical_device *device, #endif .EXT_custom_border_color = true, .EXT_index_type_uint8 = true, + .EXT_vertex_attribute_divisor = true, }; } @@ -702,6 +703,13 @@ panvk_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, properties->maxMemoryAllocationSize = 0xFFFFFFFFull; break; } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_PROPERTIES_EXT: { + VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT *properties = + (VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT *)ext; + /* We have to restrict this a bit for multiview */ + properties->maxVertexAttribDivisor = UINT32_MAX / (16 * 2048); + break; + } default: break; } diff --git a/src/panfrost/vulkan/panvk_vX_pipeline.c b/src/panfrost/vulkan/panvk_vX_pipeline.c index 32b64f3de58..2af769ae28f 100644 --- a/src/panfrost/vulkan/panvk_vX_pipeline.c +++ b/src/panfrost/vulkan/panvk_vX_pipeline.c @@ -875,6 +875,10 @@ panvk_pipeline_builder_parse_vertex_input(struct panvk_pipeline_builder *builder const VkPipelineVertexInputStateCreateInfo *info = builder->create_info.gfx->pVertexInputState; + const VkPipelineVertexInputDivisorStateCreateInfoEXT *div_info = + vk_find_struct_const(info->pNext, + PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT); + for (unsigned i = 0; i < info->vertexBindingDescriptionCount; i++) { const VkVertexInputBindingDescription *desc = &info->pVertexBindingDescriptions[i]; @@ -895,6 +899,14 @@ panvk_pipeline_builder_parse_vertex_input(struct panvk_pipeline_builder *builder attribs->attrib[desc->location].offset = desc->offset; } + if (div_info) { + for (unsigned i = 0; i < div_info->vertexBindingDivisorCount; i++) { + const VkVertexInputBindingDivisorDescriptionEXT *div = + &div_info->pVertexBindingDivisors[i]; + attribs->buf[div->binding].instance_divisor = div->divisor; + } + } + const struct pan_shader_info *vs = &builder->shaders[MESA_SHADER_VERTEX]->info;