turnip: Allow nested CP_COND_REG_EXEC

This ends up being needed for moving tile loads into the draw cs.

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16826>
This commit is contained in:
Danylo Piliaiev 2022-04-13 20:37:38 +03:00 committed by Marge Bot
parent a92fad45e9
commit ecabd3b5a9
4 changed files with 24 additions and 15 deletions

View File

@ -160,7 +160,7 @@ tu_emit_cache_flush_ccu(struct tu_cmd_buffer *cmd_buffer,
assert(ccu_state != TU_CMD_CCU_UNKNOWN);
/* It's unsafe to flush inside condition because we clear flush_bits */
assert(!cs->cond_flags);
assert(!cs->cond_stack_depth);
/* Changing CCU state must involve invalidating the CCU. In sysmem mode,
* the CCU may also contain data that we haven't flushed out yet, so we

View File

@ -376,9 +376,9 @@ tu_cs_reserve_space(struct tu_cs *cs, uint32_t reserved_size)
tu_cs_add_entry(cs);
}
if (cs->cond_flags) {
for (uint32_t i = 0; i < cs->cond_stack_depth; i++) {
/* Subtract one here to account for the DWORD field itself. */
*cs->cond_dwords = cs->cur - cs->cond_dwords - 1;
*cs->cond_dwords[i] = cs->cur - cs->cond_dwords[i] - 1;
/* space for CP_COND_REG_EXEC in next bo */
reserved_size += 3;
@ -390,14 +390,16 @@ tu_cs_reserve_space(struct tu_cs *cs, uint32_t reserved_size)
if (result != VK_SUCCESS)
return result;
/* if inside a condition, emit a new CP_COND_REG_EXEC */
if (cs->cond_flags) {
if (cs->cond_stack_depth) {
cs->reserved_end = cs->cur + reserved_size;
}
/* Re-emit CP_COND_REG_EXECs */
for (uint32_t i = 0; i < cs->cond_stack_depth; i++) {
tu_cs_emit_pkt7(cs, CP_COND_REG_EXEC, 2);
tu_cs_emit(cs, cs->cond_flags);
tu_cs_emit(cs, cs->cond_flags[i]);
cs->cond_dwords = cs->cur;
cs->cond_dwords[i] = cs->cur;
/* Emit dummy DWORD field here */
tu_cs_emit(cs, CP_COND_REG_EXEC_1_DWORDS(0));

View File

@ -290,16 +290,18 @@ static inline void
tu_cond_exec_start(struct tu_cs *cs, uint32_t cond_flags)
{
assert(cs->mode == TU_CS_MODE_GROW);
assert(!cs->cond_flags && cond_flags);
assert(cs->cond_stack_depth < TU_COND_EXEC_STACK_SIZE);
tu_cs_emit_pkt7(cs, CP_COND_REG_EXEC, 2);
tu_cs_emit(cs, cond_flags);
cs->cond_flags = cond_flags;
cs->cond_dwords = cs->cur;
cs->cond_flags[cs->cond_stack_depth] = cond_flags;
cs->cond_dwords[cs->cond_stack_depth] = cs->cur;
/* Emit dummy DWORD field here */
tu_cs_emit(cs, CP_COND_REG_EXEC_1_DWORDS(0));
cs->cond_stack_depth++;
}
#define CP_COND_EXEC_0_RENDER_MODE_GMEM \
(CP_COND_REG_EXEC_0_MODE(RENDER_MODE) | CP_COND_REG_EXEC_0_GMEM)
@ -309,11 +311,13 @@ tu_cond_exec_start(struct tu_cs *cs, uint32_t cond_flags)
static inline void
tu_cond_exec_end(struct tu_cs *cs)
{
assert(cs->cond_flags);
assert(cs->cond_stack_depth > 0);
cs->cond_stack_depth--;
cs->cond_flags = 0;
cs->cond_flags[cs->cond_stack_depth] = 0;
/* Subtract one here to account for the DWORD field itself. */
*cs->cond_dwords = cs->cur - cs->cond_dwords - 1;
*cs->cond_dwords[cs->cond_stack_depth] =
cs->cur - cs->cond_dwords[cs->cond_stack_depth] - 1;
}
#define fd_reg_pair tu_reg_value

View File

@ -764,6 +764,8 @@ enum tu_cs_mode
TU_CS_MODE_SUB_STREAM,
};
#define TU_COND_EXEC_STACK_SIZE 4
struct tu_cs
{
uint32_t *start;
@ -787,8 +789,9 @@ struct tu_cs
struct tu_bo *refcount_bo;
/* state for cond_exec_start/cond_exec_end */
uint32_t cond_flags;
uint32_t *cond_dwords;
uint32_t cond_stack_depth;
uint32_t cond_flags[TU_COND_EXEC_STACK_SIZE];
uint32_t *cond_dwords[TU_COND_EXEC_STACK_SIZE];
};
struct tu_device_memory