vk/vulkan.h: Remove the explicit primitive restart index

Unfortunately, this requires some non-trivial changes to the driver.  Now
that the primitive restart index isn't given explicitly by the client, we
always use ~0 for everything like D3D does.  Unfortunately, our hardware is
awesome and a 32-bit version of ~0 doesn't match any 16-bit values.  This
means, we have to set it to either UINT16_MAX or UINT32_MAX depending on
the size of the index type.  Since we get the index type from
CmdBindIndexBuffer and the rest of the VF packet from the pipeline, we need
to lazy-emit the VF packet.
This commit is contained in:
Jason Ekstrand 2015-07-07 15:11:56 -07:00
parent d6b840beff
commit 7fbed521bb
5 changed files with 23 additions and 6 deletions

View File

@ -1452,7 +1452,6 @@ typedef struct {
VkPrimitiveTopology topology;
bool32_t disableVertexReuse;
bool32_t primitiveRestartEnable;
uint32_t primitiveRestartIndex;
} VkPipelineIaStateCreateInfo;
typedef struct {

View File

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

View File

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

View File

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

View File

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