diff --git a/include/vulkan/vulkan.h b/include/vulkan/vulkan.h index 7a11f96a9b3..4e2d8dfc7cc 100644 --- a/include/vulkan/vulkan.h +++ b/include/vulkan/vulkan.h @@ -1452,7 +1452,6 @@ typedef struct { VkPrimitiveTopology topology; bool32_t disableVertexReuse; bool32_t primitiveRestartEnable; - uint32_t primitiveRestartIndex; } VkPipelineIaStateCreateInfo; typedef struct { diff --git a/src/vulkan/device.c b/src/vulkan/device.c index 60d6910577e..11b820dc2ce 100644 --- a/src/vulkan/device.c +++ b/src/vulkan/device.c @@ -2227,6 +2227,7 @@ VkResult anv_CreateCommandBuffer( cmd_buffer->vp_state = NULL; cmd_buffer->cb_state = NULL; cmd_buffer->ds_state = NULL; + memset(&cmd_buffer->state_vf, 0, sizeof(cmd_buffer->state_vf)); memset(&cmd_buffer->descriptors, 0, sizeof(cmd_buffer->descriptors)); result = anv_batch_bo_create(device, &cmd_buffer->last_batch_bo); @@ -2716,6 +2717,14 @@ void anv_CmdBindIndexBuffer( [VK_INDEX_TYPE_UINT32] = INDEX_DWORD, }; + struct GEN8_3DSTATE_VF vf = { + GEN8_3DSTATE_VF_header, + .CutIndex = (indexType == VK_INDEX_TYPE_UINT16) ? UINT16_MAX : UINT32_MAX, + }; + GEN8_3DSTATE_VF_pack(NULL, cmd_buffer->state_vf, &vf); + + cmd_buffer->dirty |= ANV_CMD_BUFFER_INDEX_BUFFER_DIRTY; + anv_batch_emit(&cmd_buffer->batch, GEN8_3DSTATE_INDEX_BUFFER, .IndexFormat = vk_to_gen_index_type[indexType], .MemoryObjectControlState = GEN8_MOCS, @@ -3181,6 +3190,11 @@ anv_cmd_buffer_flush_state(struct anv_cmd_buffer *cmd_buffer) .ColorCalcStatePointerValid = true); } + if (cmd_buffer->dirty & (ANV_CMD_BUFFER_PIPELINE_DIRTY | ANV_CMD_BUFFER_INDEX_BUFFER_DIRTY)) { + anv_batch_emit_merge(&cmd_buffer->batch, + cmd_buffer->state_vf, pipeline->state_vf); + } + cmd_buffer->vb_dirty &= ~vb_emit; cmd_buffer->dirty = 0; } diff --git a/src/vulkan/meta.c b/src/vulkan/meta.c index b782279e7b9..6c1f57a6956 100644 --- a/src/vulkan/meta.c +++ b/src/vulkan/meta.c @@ -38,7 +38,6 @@ anv_device_init_meta_clear_state(struct anv_device *device) .topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP, .disableVertexReuse = false, .primitiveRestartEnable = false, - .primitiveRestartIndex = 0 }; /* We don't use a vertex shader for clearing, but instead build and pass @@ -314,7 +313,6 @@ anv_device_init_meta_blit_state(struct anv_device *device) .topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP, .disableVertexReuse = false, .primitiveRestartEnable = false, - .primitiveRestartIndex = 0 }; /* We don't use a vertex shader for clearing, but instead build and pass diff --git a/src/vulkan/pipeline.c b/src/vulkan/pipeline.c index 5003156e914..f0f578706e9 100644 --- a/src/vulkan/pipeline.c +++ b/src/vulkan/pipeline.c @@ -146,9 +146,12 @@ emit_ia_state(struct anv_pipeline *pipeline, if (extra && extra->use_rectlist) topology = _3DPRIM_RECTLIST; - anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_VF, - .IndexedDrawCutIndexEnable = info->primitiveRestartEnable, - .CutIndex = info->primitiveRestartIndex); + struct GEN8_3DSTATE_VF vf = { + GEN8_3DSTATE_VF_header, + .IndexedDrawCutIndexEnable = info->primitiveRestartEnable, + }; + GEN8_3DSTATE_VF_pack(NULL, pipeline->state_vf, &vf); + anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_VF_TOPOLOGY, .PrimitiveTopologyType = topology); } diff --git a/src/vulkan/private.h b/src/vulkan/private.h index cb290ffea99..e0b18eaeddf 100644 --- a/src/vulkan/private.h +++ b/src/vulkan/private.h @@ -642,6 +642,7 @@ struct anv_buffer { #define ANV_CMD_BUFFER_DS_DIRTY (1 << 3) #define ANV_CMD_BUFFER_CB_DIRTY (1 << 4) #define ANV_CMD_BUFFER_VP_DIRTY (1 << 5) +#define ANV_CMD_BUFFER_INDEX_BUFFER_DIRTY (1 << 6) struct anv_vertex_binding { struct anv_buffer * buffer; @@ -687,6 +688,7 @@ struct anv_cmd_buffer { struct anv_dynamic_ds_state * ds_state; struct anv_dynamic_vp_state * vp_state; struct anv_dynamic_cb_state * cb_state; + uint32_t state_vf[GEN8_3DSTATE_VF_length]; struct anv_vertex_binding vertex_bindings[MAX_VBS]; struct anv_descriptor_set_binding descriptors[MAX_SETS]; }; @@ -746,6 +748,7 @@ struct anv_pipeline { uint32_t binding_stride[MAX_VBS]; uint32_t state_sf[GEN8_3DSTATE_SF_length]; + uint32_t state_vf[GEN8_3DSTATE_VF_length]; uint32_t state_raster[GEN8_3DSTATE_RASTER_length]; uint32_t state_wm_depth_stencil[GEN8_3DSTATE_WM_DEPTH_STENCIL_length];