uint32_t gmem_a,
bool resolve)
{
- const uint32_t space = 14 + 6;
- struct tu_cond_exec_state state;
-
- VkResult result = tu_cond_exec_start(cmd->device, cs, &state,
- CP_COND_REG_EXEC_0_MODE(RENDER_MODE) |
- CP_COND_REG_EXEC_0_GMEM,
- space);
- if (result != VK_SUCCESS) {
- cmd->record_result = result;
- return;
- }
+ tu_cond_exec_start(cs, CP_COND_EXEC_0_RENDER_MODE_GMEM);
tu6_emit_blit_info(cmd, cs,
cmd->state.framebuffer->attachments[a].attachment,
cmd->state.pass->attachments[gmem_a].gmem_offset, resolve);
tu6_emit_blit(cmd, cs);
- tu_cond_exec_end(cs, &state);
+ tu_cond_exec_end(cs);
}
static void
tu6_emit_predicated_blit(cmd, cs, a, gmem_a, true);
- const struct tu_framebuffer *fb = cmd->state.framebuffer;
- const uint32_t space = 25 + 66 * fb->layers + 17;
- struct tu_cond_exec_state state;
-
- VkResult result = tu_cond_exec_start(cmd->device, cs, &state,
- CP_COND_REG_EXEC_0_MODE(RENDER_MODE) |
- CP_COND_REG_EXEC_0_SYSMEM,
- space);
- if (result != VK_SUCCESS) {
- cmd->record_result = result;
- return;
- }
-
+ tu_cond_exec_start(cs, CP_COND_EXEC_0_RENDER_MODE_SYSMEM);
tu6_emit_sysmem_resolve(cmd, cs, a, gmem_a);
- tu_cond_exec_end(cs, &state);
+ tu_cond_exec_end(cs);
}
static void
tu_cs_add_entry(cs);
}
+ if (cs->cond_flags) {
+ /* Subtract one here to account for the DWORD field itself. */
+ *cs->cond_dwords = cs->cur - cs->cond_dwords - 1;
+
+ /* space for CP_COND_REG_EXEC in next bo */
+ reserved_size += 3;
+ }
+
/* switch to a new BO */
uint32_t new_size = MAX2(cs->next_bo_size, reserved_size);
VkResult result = tu_cs_add_bo(cs, new_size);
if (result != VK_SUCCESS)
return result;
+ /* if inside a condition, emit a new CP_COND_REG_EXEC */
+ if (cs->cond_flags) {
+ cs->reserved_end = cs->cur + reserved_size;
+
+ tu_cs_emit_pkt7(cs, CP_COND_REG_EXEC, 2);
+ tu_cs_emit(cs, cs->cond_flags);
+
+ cs->cond_dwords = cs->cur;
+
+ /* Emit dummy DWORD field here */
+ tu_cs_emit(cs, CP_COND_REG_EXEC_1_DWORDS(0));
+ }
+
/* double the size for the next bo */
new_size <<= 1;
if (cs->next_bo_size < new_size)
/* Helpers for bracketing a large sequence of commands of unknown size inside
* a CP_COND_REG_EXEC packet.
*/
-
-struct tu_cond_exec_state {
- uint32_t *dword_ptr;
- uint32_t max_dwords;
-};
-
-static inline VkResult
-tu_cond_exec_start(struct tu_device *dev, struct tu_cs *cs,
- struct tu_cond_exec_state *state,
- uint32_t condition, uint32_t max_dwords)
+static inline void
+tu_cond_exec_start(struct tu_cs *cs, uint32_t cond_flags)
{
- /* Reserve enough space so that both the condition packet and the actual
- * condition will fit in the same IB.
- */
- VkResult result = tu_cs_reserve_space(cs, max_dwords + 3);
- if (result != VK_SUCCESS)
- return result;
+ assert(cs->mode == TU_CS_MODE_GROW);
+ assert(!cs->cond_flags && cond_flags);
- state->max_dwords = max_dwords;
tu_cs_emit_pkt7(cs, CP_COND_REG_EXEC, 2);
- tu_cs_emit(cs, condition);
- state->dword_ptr = cs->cur;
+ tu_cs_emit(cs, cond_flags);
+
+ cs->cond_flags = cond_flags;
+ cs->cond_dwords = cs->cur;
+
/* Emit dummy DWORD field here */
tu_cs_emit(cs, CP_COND_REG_EXEC_1_DWORDS(0));
-
- return VK_SUCCESS;
}
+#define CP_COND_EXEC_0_RENDER_MODE_GMEM \
+ (CP_COND_REG_EXEC_0_MODE(RENDER_MODE) | CP_COND_REG_EXEC_0_GMEM)
+#define CP_COND_EXEC_0_RENDER_MODE_SYSMEM \
+ (CP_COND_REG_EXEC_0_MODE(RENDER_MODE) | CP_COND_REG_EXEC_0_SYSMEM)
static inline void
-tu_cond_exec_end(struct tu_cs *cs, struct tu_cond_exec_state *state)
+tu_cond_exec_end(struct tu_cs *cs)
{
+ assert(cs->cond_flags);
+
+ cs->cond_flags = 0;
/* Subtract one here to account for the DWORD field itself. */
- uint32_t actual_dwords = cs->cur - state->dword_ptr - 1;
- assert(actual_dwords <= state->max_dwords);
- *state->dword_ptr = actual_dwords;
+ *cs->cond_dwords = cs->cur - cs->cond_dwords - 1;
}
#define fd_reg_pair tu_reg_value
const struct tu_subpass *subpass = cmd->state.subpass;
struct tu_cs *cs = &cmd->draw_cs;
- /* Note: reserving space here should never fail because we allocated
- * enough above.
- */
- struct tu_cond_exec_state state;
- VkResult result =
- tu_cond_exec_start(cmd->device, cs, &state,
- CP_COND_REG_EXEC_0_MODE(RENDER_MODE) |
- CP_COND_REG_EXEC_0_GMEM,
- rectCount * (3 + attachmentCount * 15));
- if (result != VK_SUCCESS) {
- cmd->record_result = result;
- return;
- }
+ tu_cond_exec_start(cs, CP_COND_EXEC_0_RENDER_MODE_GMEM);
for (unsigned i = 0; i < rectCount; i++) {
unsigned x1 = pRects[i].rect.offset.x;
}
}
- tu_cond_exec_end(cs, &state);
-
- uint32_t clear_count = 3;
- for (unsigned j = 0; j < rectCount; j++)
- clear_count += 18 + 66 * pRects[j].layerCount + 17;
+ tu_cond_exec_end(cs);
- result =
- tu_cond_exec_start(cmd->device, cs, &state,
- CP_COND_REG_EXEC_0_MODE(RENDER_MODE) |
- CP_COND_REG_EXEC_0_SYSMEM,
- attachmentCount * clear_count);
-
- if (result != VK_SUCCESS) {
- cmd->record_result = result;
- return;
- }
+ tu_cond_exec_start(cs, CP_COND_EXEC_0_RENDER_MODE_SYSMEM);
for (unsigned i = 0; i < rectCount; i++) {
for (unsigned j = 0; j < attachmentCount; j++) {
}
}
- tu_cond_exec_end(cs, &state);
+ tu_cond_exec_end(cs);
}
struct tu_bo **bos;
uint32_t bo_count;
uint32_t bo_capacity;
+
+ /* state for cond_exec_start/cond_exec_end */
+ uint32_t cond_flags;
+ uint32_t *cond_dwords;
};
struct tu_device_memory