From 0508046dc839a2ebd2800f169b45f2d3243dcda6 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Mon, 16 Nov 2015 16:29:33 -0800 Subject: [PATCH] anv/cmd_buffer: Pack the 3DSTATE_VF packet on-demand --- src/vulkan/anv_cmd_buffer.c | 2 +- src/vulkan/anv_private.h | 3 +-- src/vulkan/gen8_cmd_buffer.c | 17 ++++++++++------- src/vulkan/gen8_pipeline.c | 6 ------ 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/vulkan/anv_cmd_buffer.c b/src/vulkan/anv_cmd_buffer.c index c0de376da25..1a37d8124d9 100644 --- a/src/vulkan/anv_cmd_buffer.c +++ b/src/vulkan/anv_cmd_buffer.c @@ -113,7 +113,6 @@ anv_dynamic_state_copy(struct anv_dynamic_state *dest, static void anv_cmd_state_init(struct anv_cmd_state *state) { - memset(&state->state_vf, 0, sizeof(state->state_vf)); memset(&state->descriptors, 0, sizeof(state->descriptors)); memset(&state->push_constants, 0, sizeof(state->push_constants)); @@ -122,6 +121,7 @@ anv_cmd_state_init(struct anv_cmd_state *state) state->descriptors_dirty = 0; state->push_constants_dirty = 0; state->pipeline = NULL; + state->restart_index = UINT32_MAX; state->dynamic = default_dynamic_state; state->gen7.index_buffer = NULL; diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index a8ed5e8a7e2..55f562d06b8 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -918,7 +918,7 @@ struct anv_cmd_state { struct anv_framebuffer * framebuffer; struct anv_render_pass * pass; struct anv_subpass * subpass; - uint32_t state_vf[2]; + uint32_t restart_index; struct anv_vertex_binding vertex_bindings[MAX_VBS]; struct anv_descriptor_set * descriptors[MAX_SETS]; struct anv_push_constants * push_constants[VK_SHADER_STAGE_NUM]; @@ -1151,7 +1151,6 @@ struct anv_pipeline { struct { uint32_t sf[4]; - uint32_t vf[2]; uint32_t raster[5]; uint32_t wm_depth_stencil[3]; } gen8; diff --git a/src/vulkan/gen8_cmd_buffer.c b/src/vulkan/gen8_cmd_buffer.c index 2e4a618bad1..9a3e3b5e061 100644 --- a/src/vulkan/gen8_cmd_buffer.c +++ b/src/vulkan/gen8_cmd_buffer.c @@ -283,8 +283,10 @@ gen8_cmd_buffer_flush_state(struct anv_cmd_buffer *cmd_buffer) if (cmd_buffer->state.dirty & (ANV_CMD_DIRTY_PIPELINE | ANV_CMD_DIRTY_INDEX_BUFFER)) { - anv_batch_emit_merge(&cmd_buffer->batch, - cmd_buffer->state.state_vf, pipeline->gen8.vf); + anv_batch_emit(&cmd_buffer->batch, GEN8_3DSTATE_VF, + .IndexedDrawCutIndexEnable = pipeline->primitive_restart, + .CutIndex = cmd_buffer->state.restart_index, + ); } cmd_buffer->state.vb_dirty &= ~vb_emit; @@ -396,19 +398,20 @@ void gen8_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, + static const uint32_t restart_index_for_type[] = { + [VK_INDEX_TYPE_UINT16] = UINT16_MAX, + [VK_INDEX_TYPE_UINT32] = UINT32_MAX, }; - GEN8_3DSTATE_VF_pack(NULL, cmd_buffer->state.state_vf, &vf); - cmd_buffer->state.dirty |= ANV_CMD_DIRTY_INDEX_BUFFER; + cmd_buffer->state.restart_index = restart_index_for_type[indexType]; anv_batch_emit(&cmd_buffer->batch, GEN8_3DSTATE_INDEX_BUFFER, .IndexFormat = vk_to_gen_index_type[indexType], .MemoryObjectControlState = GEN8_MOCS, .BufferStartingAddress = { buffer->bo, buffer->offset + offset }, .BufferSize = buffer->size - offset); + + cmd_buffer->state.dirty |= ANV_CMD_DIRTY_INDEX_BUFFER; } static VkResult diff --git a/src/vulkan/gen8_pipeline.c b/src/vulkan/gen8_pipeline.c index 81bc254b3f7..9d4ee9927cf 100644 --- a/src/vulkan/gen8_pipeline.c +++ b/src/vulkan/gen8_pipeline.c @@ -83,12 +83,6 @@ emit_ia_state(struct anv_pipeline *pipeline, const VkPipelineInputAssemblyStateCreateInfo *info, const struct anv_graphics_pipeline_create_info *extra) { - struct GEN8_3DSTATE_VF vf = { - GEN8_3DSTATE_VF_header, - .IndexedDrawCutIndexEnable = pipeline->primitive_restart - }; - GEN8_3DSTATE_VF_pack(NULL, pipeline->gen8.vf, &vf); - anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_VF_TOPOLOGY, .PrimitiveTopologyType = pipeline->topology); } -- 2.30.2