anv: share some code between vkCmdDrawIndirectCount and vkCmdDrawIndexedIndirectCount
Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11975>
This commit is contained in:

committed by
Marge Bot

parent
dcfc4bb89a
commit
8250f2ae29
@@ -4371,12 +4371,15 @@ void genX(CmdDrawIndexedIndirect)(
|
|||||||
static struct mi_value
|
static struct mi_value
|
||||||
prepare_for_draw_count_predicate(struct anv_cmd_buffer *cmd_buffer,
|
prepare_for_draw_count_predicate(struct anv_cmd_buffer *cmd_buffer,
|
||||||
struct mi_builder *b,
|
struct mi_builder *b,
|
||||||
struct anv_address count_address,
|
struct anv_buffer *count_buffer,
|
||||||
const bool conditional_render_enabled)
|
uint64_t countBufferOffset)
|
||||||
{
|
{
|
||||||
|
struct anv_address count_address =
|
||||||
|
anv_address_add(count_buffer->address, countBufferOffset);
|
||||||
|
|
||||||
struct mi_value ret = mi_imm(0);
|
struct mi_value ret = mi_imm(0);
|
||||||
|
|
||||||
if (conditional_render_enabled) {
|
if (cmd_buffer->state.conditional_render_enabled) {
|
||||||
#if GFX_VERx10 >= 75
|
#if GFX_VERx10 >= 75
|
||||||
ret = mi_new_gpr(b);
|
ret = mi_new_gpr(b);
|
||||||
mi_store(b, mi_value_ref(b, ret), mi_mem32(count_address));
|
mi_store(b, mi_value_ref(b, ret), mi_mem32(count_address));
|
||||||
@@ -4452,6 +4455,24 @@ emit_draw_count_predicate_with_conditional_render(
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void
|
||||||
|
emit_draw_count_predicate_cond(struct anv_cmd_buffer *cmd_buffer,
|
||||||
|
struct mi_builder *b,
|
||||||
|
uint32_t draw_index,
|
||||||
|
struct mi_value max)
|
||||||
|
{
|
||||||
|
#if GFX_VERx10 >= 75
|
||||||
|
if (cmd_buffer->state.conditional_render_enabled) {
|
||||||
|
emit_draw_count_predicate_with_conditional_render(
|
||||||
|
cmd_buffer, b, draw_index, mi_value_ref(b, max));
|
||||||
|
} else {
|
||||||
|
emit_draw_count_predicate(cmd_buffer, b, draw_index);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
emit_draw_count_predicate(cmd_buffer, b, draw_index);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void genX(CmdDrawIndirectCount)(
|
void genX(CmdDrawIndirectCount)(
|
||||||
VkCommandBuffer commandBuffer,
|
VkCommandBuffer commandBuffer,
|
||||||
VkBuffer _buffer,
|
VkBuffer _buffer,
|
||||||
@@ -4475,25 +4496,14 @@ void genX(CmdDrawIndirectCount)(
|
|||||||
|
|
||||||
struct mi_builder b;
|
struct mi_builder b;
|
||||||
mi_builder_init(&b, &cmd_buffer->device->info, &cmd_buffer->batch);
|
mi_builder_init(&b, &cmd_buffer->device->info, &cmd_buffer->batch);
|
||||||
struct anv_address count_address =
|
|
||||||
anv_address_add(count_buffer->address, countBufferOffset);
|
|
||||||
struct mi_value max =
|
struct mi_value max =
|
||||||
prepare_for_draw_count_predicate(cmd_buffer, &b, count_address,
|
prepare_for_draw_count_predicate(cmd_buffer, &b,
|
||||||
cmd_state->conditional_render_enabled);
|
count_buffer, countBufferOffset);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < maxDrawCount; i++) {
|
for (uint32_t i = 0; i < maxDrawCount; i++) {
|
||||||
struct anv_address draw = anv_address_add(buffer->address, offset);
|
struct anv_address draw = anv_address_add(buffer->address, offset);
|
||||||
|
|
||||||
#if GFX_VERx10 >= 75
|
emit_draw_count_predicate_cond(cmd_buffer, &b, i, max);
|
||||||
if (cmd_state->conditional_render_enabled) {
|
|
||||||
emit_draw_count_predicate_with_conditional_render(
|
|
||||||
cmd_buffer, &b, i, mi_value_ref(&b, max));
|
|
||||||
} else {
|
|
||||||
emit_draw_count_predicate(cmd_buffer, &b, i);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
emit_draw_count_predicate(cmd_buffer, &b, i);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (vs_prog_data->uses_firstvertex ||
|
if (vs_prog_data->uses_firstvertex ||
|
||||||
vs_prog_data->uses_baseinstance)
|
vs_prog_data->uses_baseinstance)
|
||||||
@@ -4546,25 +4556,14 @@ void genX(CmdDrawIndexedIndirectCount)(
|
|||||||
|
|
||||||
struct mi_builder b;
|
struct mi_builder b;
|
||||||
mi_builder_init(&b, &cmd_buffer->device->info, &cmd_buffer->batch);
|
mi_builder_init(&b, &cmd_buffer->device->info, &cmd_buffer->batch);
|
||||||
struct anv_address count_address =
|
|
||||||
anv_address_add(count_buffer->address, countBufferOffset);
|
|
||||||
struct mi_value max =
|
struct mi_value max =
|
||||||
prepare_for_draw_count_predicate(cmd_buffer, &b, count_address,
|
prepare_for_draw_count_predicate(cmd_buffer, &b,
|
||||||
cmd_state->conditional_render_enabled);
|
count_buffer, countBufferOffset);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < maxDrawCount; i++) {
|
for (uint32_t i = 0; i < maxDrawCount; i++) {
|
||||||
struct anv_address draw = anv_address_add(buffer->address, offset);
|
struct anv_address draw = anv_address_add(buffer->address, offset);
|
||||||
|
|
||||||
#if GFX_VERx10 >= 75
|
emit_draw_count_predicate_cond(cmd_buffer, &b, i, max);
|
||||||
if (cmd_state->conditional_render_enabled) {
|
|
||||||
emit_draw_count_predicate_with_conditional_render(
|
|
||||||
cmd_buffer, &b, i, mi_value_ref(&b, max));
|
|
||||||
} else {
|
|
||||||
emit_draw_count_predicate(cmd_buffer, &b, i);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
emit_draw_count_predicate(cmd_buffer, &b, i);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* TODO: We need to stomp base vertex to 0 somehow */
|
/* TODO: We need to stomp base vertex to 0 somehow */
|
||||||
if (vs_prog_data->uses_firstvertex ||
|
if (vs_prog_data->uses_firstvertex ||
|
||||||
|
Reference in New Issue
Block a user