nvk: Don't re-initialize cond rendering operand B

We can initialize this just once from the CPU side instead of
overwriting it each time using the copy engine.

This is a 5% performance improvement on the Sascha Willems
conditionalrender demo with all rendering disabled (607 fps -> 638 fps)

Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37187>
This commit is contained in:
Mel Henning 2025-09-04 15:26:39 -04:00 committed by Marge Bot
parent 966a1b5380
commit 4d8e2f7768

View file

@ -4864,14 +4864,19 @@ nvk_CmdBeginConditionalRenderingEXT(VkCommandBuffer commandBuffer,
vk_command_buffer_set_error(&cmd->vk, result);
return;
}
/* Zero-initialize the beginning of the buffer. As an invariant, the bytes
* for operand B are always zero
*/
assert(cmd->cond_render_mem->mem->size_B > 32);
memset(cmd->cond_render_mem->mem->map, 0x00, 32);
}
const uint64_t tmp_addr = cmd->cond_render_mem->mem->va->addr;
/* Frustratingly, the u64s are not packed together */
const uint64_t operand_a_addr = tmp_addr + 0;
const uint64_t operand_b_addr = tmp_addr + 16;
struct nv_push *p = nvk_cmd_buffer_push(cmd, 29);
struct nv_push *p = nvk_cmd_buffer_push(cmd, 20);
P_MTHD(p, NV90B5, LINE_LENGTH_IN);
P_NV90B5_LINE_LENGTH_IN(p, 1);
@ -4903,31 +4908,6 @@ nvk_CmdBeginConditionalRenderingEXT(VkCommandBuffer commandBuffer,
.remap_enable = REMAP_ENABLE_TRUE,
});
/* Copy zero into operand B */
P_MTHD(p, NV90B5, OFFSET_OUT_UPPER);
P_NV90B5_OFFSET_OUT_UPPER(p, operand_b_addr >> 32);
P_NV90B5_OFFSET_OUT_LOWER(p, operand_b_addr & 0xffffffff);
P_IMMD(p, NV90B5, SET_REMAP_CONST_A, 0);
P_IMMD(p, NV90B5, SET_REMAP_COMPONENTS, {
.dst_x = DST_X_CONST_A,
.dst_y = DST_Y_CONST_A,
.dst_z = DST_Z_NO_WRITE,
.dst_w = DST_W_NO_WRITE,
.component_size = COMPONENT_SIZE_FOUR,
.num_src_components = NUM_SRC_COMPONENTS_ONE,
.num_dst_components = NUM_DST_COMPONENTS_TWO,
});
P_IMMD(p, NV90B5, LAUNCH_DMA, {
.data_transfer_type = DATA_TRANSFER_TYPE_PIPELINED,
.multi_line_enable = MULTI_LINE_ENABLE_FALSE,
.flush_enable = FLUSH_ENABLE_TRUE,
.src_memory_layout = SRC_MEMORY_LAYOUT_PITCH,
.dst_memory_layout = DST_MEMORY_LAYOUT_PITCH,
.remap_enable = REMAP_ENABLE_TRUE,
});
/* Compare the operands */
P_MTHD(p, NV9097, SET_RENDER_ENABLE_A);
P_NV9097_SET_RENDER_ENABLE_A(p, tmp_addr >> 32);