anv: Handle vertex buffer sizes in anv_CmdBindVertexBuffers2
There's no good reason to defer figuring out the size until we emit the packet. We know everything when the bind happens. Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17564>
This commit is contained in:
parent
1faba01c2b
commit
36417bd05b
|
@ -99,7 +99,6 @@ const struct anv_dynamic_state default_dynamic_state = {
|
|||
.depth_bounds_test_enable = 0,
|
||||
.stencil_test_enable = 0,
|
||||
.dyn_vbo_stride = 0,
|
||||
.dyn_vbo_size = 0,
|
||||
.color_writes = 0xff,
|
||||
.raster_discard = 0,
|
||||
.depth_bias_enable = 0,
|
||||
|
@ -208,7 +207,6 @@ anv_dynamic_state_copy(struct anv_dynamic_state *dest,
|
|||
}
|
||||
|
||||
ANV_CMP_COPY(dyn_vbo_stride, ANV_CMD_DIRTY_DYNAMIC_VERTEX_INPUT_BINDING_STRIDE);
|
||||
ANV_CMP_COPY(dyn_vbo_size, ANV_CMD_DIRTY_DYNAMIC_VERTEX_INPUT_BINDING_STRIDE);
|
||||
|
||||
ANV_CMP_COPY(raster_discard, ANV_CMD_DIRTY_DYNAMIC_RASTERIZER_DISCARD_ENABLE);
|
||||
ANV_CMP_COPY(depth_bias_enable, ANV_CMD_DIRTY_DYNAMIC_DEPTH_BIAS_ENABLE);
|
||||
|
@ -1183,17 +1181,26 @@ void anv_CmdBindVertexBuffers2(
|
|||
/* We have to defer setting up vertex buffer since we need the buffer
|
||||
* stride from the pipeline. */
|
||||
|
||||
if (pSizes)
|
||||
cmd_buffer->state.gfx.dynamic.dyn_vbo_size = true;
|
||||
if (pStrides)
|
||||
cmd_buffer->state.gfx.dynamic.dyn_vbo_stride = true;
|
||||
|
||||
assert(firstBinding + bindingCount <= MAX_VBS);
|
||||
for (uint32_t i = 0; i < bindingCount; i++) {
|
||||
vb[firstBinding + i].buffer = anv_buffer_from_handle(pBuffers[i]);
|
||||
vb[firstBinding + i].offset = pOffsets[i];
|
||||
vb[firstBinding + i].size = pSizes ? pSizes[i] : 0;
|
||||
vb[firstBinding + i].stride = pStrides ? pStrides[i] : 0;
|
||||
ANV_FROM_HANDLE(anv_buffer, buffer, pBuffers[i]);
|
||||
|
||||
if (buffer == NULL) {
|
||||
vb[firstBinding + i] = (struct anv_vertex_binding) {
|
||||
.buffer = NULL,
|
||||
};
|
||||
} else {
|
||||
vb[firstBinding + i] = (struct anv_vertex_binding) {
|
||||
.buffer = buffer,
|
||||
.offset = pOffsets[i],
|
||||
.size = vk_buffer_range(&buffer->vk, pOffsets[i],
|
||||
pSizes ? pSizes[i] : VK_WHOLE_SIZE),
|
||||
.stride = pStrides ? pStrides[i] : 0,
|
||||
};
|
||||
}
|
||||
cmd_buffer->state.gfx.vb_dirty |= 1 << (firstBinding + i);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2727,7 +2727,6 @@ struct anv_dynamic_state {
|
|||
bool primitive_restart_enable;
|
||||
VkLogicOp logic_op;
|
||||
bool dyn_vbo_stride;
|
||||
bool dyn_vbo_size;
|
||||
|
||||
/* Bitfield, one bit per render target */
|
||||
uint8_t color_writes;
|
||||
|
|
|
@ -3761,20 +3761,12 @@ genX(cmd_buffer_flush_state)(struct anv_cmd_buffer *cmd_buffer)
|
|||
* stride/size that was setup in the pipeline object.
|
||||
*/
|
||||
bool dynamic_stride = cmd_buffer->state.gfx.dynamic.dyn_vbo_stride;
|
||||
bool dynamic_size = cmd_buffer->state.gfx.dynamic.dyn_vbo_size;
|
||||
|
||||
struct GENX(VERTEX_BUFFER_STATE) state;
|
||||
if (buffer) {
|
||||
uint32_t stride = dynamic_stride ?
|
||||
cmd_buffer->state.vertex_bindings[vb].stride : pipeline->vb[vb].stride;
|
||||
/* From the Vulkan spec (vkCmdBindVertexBuffers2):
|
||||
*
|
||||
* "If pname:pSizes is not NULL then pname:pSizes[i] specifies
|
||||
* the bound size of the vertex buffer starting from the corresponding
|
||||
* elements of pname:pBuffers[i] plus pname:pOffsets[i]."
|
||||
*/
|
||||
UNUSED uint32_t size = dynamic_size ?
|
||||
cmd_buffer->state.vertex_bindings[vb].size : buffer->vk.size - offset;
|
||||
UNUSED uint32_t size = cmd_buffer->state.vertex_bindings[vb].size;
|
||||
|
||||
#if GFX_VER <= 7
|
||||
bool per_instance = pipeline->vb[vb].instanced;
|
||||
|
|
Loading…
Reference in New Issue