anv/pipeline: Use a per-VB struct instead of separate arrays

Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
This commit is contained in:
Jason Ekstrand
2018-07-02 12:44:49 -07:00
parent 6db20229ab
commit 32f4feb5a0
4 changed files with 11 additions and 8 deletions

View File

@@ -1407,7 +1407,7 @@ anv_pipeline_init(struct anv_pipeline *pipeline,
const VkVertexInputBindingDescription *desc = const VkVertexInputBindingDescription *desc =
&vi_info->pVertexBindingDescriptions[i]; &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 /* Step rate is programmed per vertex element (attribute), not
* binding. Set up a map of which bindings step per instance, for * 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) { switch (desc->inputRate) {
default: default:
case VK_VERTEX_INPUT_RATE_VERTEX: case VK_VERTEX_INPUT_RATE_VERTEX:
pipeline->instancing_enable[desc->binding] = false; pipeline->vb[desc->binding].instanced = false;
break; break;
case VK_VERTEX_INPUT_RATE_INSTANCE: case VK_VERTEX_INPUT_RATE_INSTANCE:
pipeline->instancing_enable[desc->binding] = true; pipeline->vb[desc->binding].instanced = true;
break; break;
} }
} }

View File

@@ -2383,8 +2383,11 @@ struct anv_pipeline {
struct anv_state blend_state; struct anv_state blend_state;
uint32_t vb_used; uint32_t vb_used;
uint32_t binding_stride[MAX_VBS]; struct anv_pipeline_vertex_binding {
bool instancing_enable[MAX_VBS]; uint32_t stride;
bool instanced;
} vb[MAX_VBS];
bool primitive_restart; bool primitive_restart;
uint32_t topology; uint32_t topology;

View File

@@ -2517,7 +2517,7 @@ genX(cmd_buffer_flush_state)(struct anv_cmd_buffer *cmd_buffer)
#if GEN_GEN >= 8 #if GEN_GEN >= 8
.MemoryObjectControlState = GENX(MOCS), .MemoryObjectControlState = GENX(MOCS),
#else #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 /* Our implementation of VK_KHR_multiview uses instancing to draw
* the different views. If the client asks for instancing, we * the different views. If the client asks for instancing, we
* need to use the Instance Data Step Rate to ensure that 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 #endif
.AddressModifyEnable = true, .AddressModifyEnable = true,
.BufferPitch = pipeline->binding_stride[vb], .BufferPitch = pipeline->vb[vb].stride,
.BufferStartingAddress = anv_address_add(buffer->address, offset), .BufferStartingAddress = anv_address_add(buffer->address, offset),
#if GEN_GEN >= 8 #if GEN_GEN >= 8

View File

@@ -154,7 +154,7 @@ emit_vertex_input(struct anv_pipeline *pipeline,
* VERTEX_BUFFER_STATE which we emit later. * VERTEX_BUFFER_STATE which we emit later.
*/ */
anv_batch_emit(&pipeline->batch, GENX(3DSTATE_VF_INSTANCING), vfi) { 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; vfi.VertexElementIndex = slot;
/* Our implementation of VK_KHR_multiview uses instancing to draw /* Our implementation of VK_KHR_multiview uses instancing to draw
* the different views. If the client asks for instancing, we * the different views. If the client asks for instancing, we