anv/cmd_buffer: Pack the 3DSTATE_VF packet on-demand

This commit is contained in:
Jason Ekstrand
2015-11-16 16:29:33 -08:00
parent 34d55d69cf
commit 0508046dc8
4 changed files with 12 additions and 16 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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

View File

@@ -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);
}