[Mesa-dev] [PATCH 2/3] anv/pipeline: Add a per-VB instance divisor

Jason Ekstrand jason at jlekstrand.net
Mon Jul 2 21:57:28 UTC 2018


---
 src/intel/vulkan/anv_pipeline.c    | 8 ++++++++
 src/intel/vulkan/anv_private.h     | 1 +
 src/intel/vulkan/genX_cmd_buffer.c | 7 +------
 src/intel/vulkan/genX_pipeline.c   | 8 ++------
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c
index 1f9afb50894..d175275350e 100644
--- a/src/intel/vulkan/anv_pipeline.c
+++ b/src/intel/vulkan/anv_pipeline.c
@@ -1420,6 +1420,14 @@ anv_pipeline_init(struct anv_pipeline *pipeline,
          pipeline->vb[desc->binding].instanced = true;
          break;
       }
+
+      /* 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 repeat the client's
+       * per-instance data once for each view.
+       */
+      pipeline->vb[desc->binding].instance_divisor =
+         anv_subpass_view_count(pipeline->subpass);
    }
 
    const VkPipelineInputAssemblyStateCreateInfo *ia_info =
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 0620d6f96e1..50583279621 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -2386,6 +2386,7 @@ struct anv_pipeline {
    struct anv_pipeline_vertex_binding {
       uint32_t                                  stride;
       bool                                      instanced;
+      uint32_t                                  instance_divisor;
    } vb[MAX_VBS];
 
    bool                                         primitive_restart;
diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c
index 426299d5c8d..6ea6a2ba901 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -2518,12 +2518,7 @@ genX(cmd_buffer_flush_state)(struct anv_cmd_buffer *cmd_buffer)
             .MemoryObjectControlState = GENX(MOCS),
 #else
             .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
-             * repeat the client's per-instance data once for each view.
-             */
-            .InstanceDataStepRate = anv_subpass_view_count(pipeline->subpass),
+            .InstanceDataStepRate = pipeline->vb[vb].instance_divisor,
             .VertexBufferMemoryObjectControlState = GENX(MOCS),
 #endif
 
diff --git a/src/intel/vulkan/genX_pipeline.c b/src/intel/vulkan/genX_pipeline.c
index c38dbe206f4..738f0374d40 100644
--- a/src/intel/vulkan/genX_pipeline.c
+++ b/src/intel/vulkan/genX_pipeline.c
@@ -156,12 +156,8 @@ emit_vertex_input(struct anv_pipeline *pipeline,
       anv_batch_emit(&pipeline->batch, GENX(3DSTATE_VF_INSTANCING), vfi) {
          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
-          * need to use the Instance Data Step Rate to ensure that we
-          * repeat the client's per-instance data once for each view.
-          */
-         vfi.InstanceDataStepRate = anv_subpass_view_count(pipeline->subpass);
+         vfi.InstanceDataStepRate =
+            pipeline->vb[desc->binding].instance_divisor;
       }
 #endif
    }
-- 
2.17.1



More information about the mesa-dev mailing list