anv/pipeline: Use a per-VB struct instead of separate arrays
authorJason Ekstrand <jason.ekstrand@intel.com>
Mon, 2 Jul 2018 19:44:49 +0000 (12:44 -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_pipeline.c
src/intel/vulkan/anv_private.h
src/intel/vulkan/genX_cmd_buffer.c
src/intel/vulkan/genX_pipeline.c

index 1565fe7a7a35a5919007fc8dc226876bf3de5f57..f0bf80a1cf072303b6054665b52591b056d0919c 100644 (file)
@@ -1407,7 +1407,7 @@ anv_pipeline_init(struct anv_pipeline *pipeline,
       const VkVertexInputBindingDescription *desc =
          &vi_info->pVertexBindingDescriptions[i];
 
-      pipeline->binding_stride[desc->binding] = desc->stride;
+      pipeline->vb[desc->binding].stride = desc->stride;
 
       /* Step rate is programmed per vertex element (attribute), not
        * binding. Set up a map of which bindings step per instance, for
@@ -1415,10 +1415,10 @@ anv_pipeline_init(struct anv_pipeline *pipeline,
       switch (desc->inputRate) {
       default:
       case VK_VERTEX_INPUT_RATE_VERTEX:
-         pipeline->instancing_enable[desc->binding] = false;
+         pipeline->vb[desc->binding].instanced = false;
          break;
       case VK_VERTEX_INPUT_RATE_INSTANCE:
-         pipeline->instancing_enable[desc->binding] = true;
+         pipeline->vb[desc->binding].instanced = true;
          break;
       }
    }
index 1763b81fbc2f47f5b4e10e66ab2249b0ed9b2a53..ae763e4e2eb05b13ec78010de5607c2235dd14ee 100644 (file)
@@ -2383,8 +2383,11 @@ struct anv_pipeline {
    struct anv_state                             blend_state;
 
    uint32_t                                     vb_used;
-   uint32_t                                     binding_stride[MAX_VBS];
-   bool                                         instancing_enable[MAX_VBS];
+   struct anv_pipeline_vertex_binding {
+      uint32_t                                  stride;
+      bool                                      instanced;
+   } vb[MAX_VBS];
+
    bool                                         primitive_restart;
    uint32_t                                     topology;
 
index 8bb08a45d03b5649b817569fabd5eacd501ad78e..7033e978144502d2d6b718ba2f7685a96b565a6c 100644 (file)
@@ -2517,7 +2517,7 @@ genX(cmd_buffer_flush_state)(struct anv_cmd_buffer *cmd_buffer)
 #if GEN_GEN >= 8
             .MemoryObjectControlState = GENX(MOCS),
 #else
-            .BufferAccessType = pipeline->instancing_enable[vb] ? INSTANCEDATA : VERTEXDATA,
+            .BufferAccessType = pipeline->vb[vb].instanced ? INSTANCEDATA : VERTEXDATA,
             /* Our implementation of VK_KHR_multiview uses instancing to draw
              * the different views.  If the client asks for instancing, we
              * need to use the Instance Data Step Rate to ensure that we
@@ -2528,7 +2528,7 @@ genX(cmd_buffer_flush_state)(struct anv_cmd_buffer *cmd_buffer)
 #endif
 
             .AddressModifyEnable = true,
-            .BufferPitch = pipeline->binding_stride[vb],
+            .BufferPitch = pipeline->vb[vb].stride,
             .BufferStartingAddress = anv_address_add(buffer->address, offset),
 
 #if GEN_GEN >= 8
index 70097e462850cebe759b66166c7860a8c188a1cf..f4a455cce6762fd7b66073cd3c7e7e1f1eba76db 100644 (file)
@@ -154,7 +154,7 @@ emit_vertex_input(struct anv_pipeline *pipeline,
        * VERTEX_BUFFER_STATE which we emit later.
        */
       anv_batch_emit(&pipeline->batch, GENX(3DSTATE_VF_INSTANCING), vfi) {
-         vfi.InstancingEnable = pipeline->instancing_enable[desc->binding];
+         vfi.InstancingEnable = pipeline->vb[desc->binding].instanced;
          vfi.VertexElementIndex = slot;
          /* Our implementation of VK_KHR_multiview uses instancing to draw
           * the different views.  If the client asks for instancing, we