anv: Implement VK_EXT_vertex_attribute_divisor
authorJason Ekstrand <jason.ekstrand@intel.com>
Mon, 2 Jul 2018 19:57:44 +0000 (12:57 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Mon, 9 Jul 2018 22:37:51 +0000 (15:37 -0700)
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
src/intel/vulkan/anv_device.c
src/intel/vulkan/anv_extensions.py
src/intel/vulkan/anv_pipeline.c

index a8b0bd2fc3ed9977aa189fe416bba4b57902f44a..04fd6a829ed60081abc4bba2ccb0faad589769b2 100644 (file)
@@ -1140,6 +1140,14 @@ void anv_GetPhysicalDeviceProperties2(
          break;
       }
 
+      case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_PROPERTIES_EXT: {
+         VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT *props =
+            (VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT *)ext;
+         /* We have to restrict this a bit for multiview */
+         props->maxVertexAttribDivisor = UINT32_MAX / 16;
+         break;
+      }
+
       default:
          anv_debug_ignored_stype(ext->sType);
          break;
index 13c06f3c3cb6d0f8dd49744ac2dc7eecdaa00e46..418618d20215f9ebf8115d4141c32f4d5e503370 100644 (file)
@@ -122,6 +122,7 @@ EXTENSIONS = [
               'device->has_context_priority'),
     Extension('VK_EXT_shader_viewport_index_layer',       1, True),
     Extension('VK_EXT_shader_stencil_export',             1, 'device->info.gen >= 9'),
+    Extension('VK_EXT_vertex_attribute_divisor',          2, True),
 ]
 
 class VkVersion:
index e8489e72394464a50f634b92ae2ed260fe45ebcb..95a686f7833c4e4ed09ec407e8c6d64f03f00f73 100644 (file)
@@ -33,6 +33,7 @@
 #include "compiler/brw_nir.h"
 #include "anv_nir.h"
 #include "spirv/nir_spirv.h"
+#include "vk_util.h"
 
 /* Needed for SWIZZLE macros */
 #include "program/prog_instruction.h"
@@ -1425,6 +1426,17 @@ anv_pipeline_init(struct anv_pipeline *pipeline,
       pipeline->vb[desc->binding].instance_divisor = 1;
    }
 
+   const VkPipelineVertexInputDivisorStateCreateInfoEXT *vi_div_state =
+      vk_find_struct_const(vi_info->pNext,
+                           PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT);
+   if (vi_div_state) {
+      for (uint32_t i = 0; i < vi_div_state->vertexBindingDivisorCount; i++) {
+         const VkVertexInputBindingDivisorDescriptionEXT *desc =
+            &vi_div_state->pVertexBindingDivisors[i];
+
+         pipeline->vb[desc->binding].instance_divisor = desc->divisor;
+      }
+   }
 
    /* Our implementation of VK_KHR_multiview uses instancing to draw the
     * different views.  If the client asks for instancing, we need to multiply