anv: add a new execution mode for secondary command buffers

This change adds a call/return execution mode for secondary command
buffer rather than the existing copy into the primary batch mode.

v2: Rework convention to avoid burning an ALU register (Jason)

v3: Use anv_address_add() (Jason)

v4: Move command emissions to anv_batch_chain.c (Jason)

v5: Also move last MI_BBS emission in secondary command buffer to
    anv_batch_chain.c (Jason)

v6: Fix end secondary command buffer end (Jason)

v7: Refactor anv_batch_address() to remove additional emit functions

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2775>
This commit is contained in:
Lionel Landwerlin
2020-04-04 13:22:24 +03:00
parent a96d92a689
commit 34a0ce58c7
2 changed files with 68 additions and 5 deletions

View File

@@ -1592,9 +1592,16 @@ struct anv_batch_bo {
struct anv_reloc_list relocs;
};
struct anv_address {
struct anv_bo *bo;
uint32_t offset;
};
struct anv_batch {
const VkAllocationCallbacks * alloc;
struct anv_address start_addr;
void * start;
void * end;
void * next;
@@ -1621,6 +1628,7 @@ void *anv_batch_emit_dwords(struct anv_batch *batch, int num_dwords);
void anv_batch_emit_batch(struct anv_batch *batch, struct anv_batch *other);
uint64_t anv_batch_emit_reloc(struct anv_batch *batch,
void *location, struct anv_bo *bo, uint32_t offset);
struct anv_address anv_batch_address(struct anv_batch *batch, void *batch_location);
static inline VkResult
anv_batch_set_error(struct anv_batch *batch, VkResult error)
@@ -1637,11 +1645,6 @@ anv_batch_has_error(struct anv_batch *batch)
return batch->status != VK_SUCCESS;
}
struct anv_address {
struct anv_bo *bo;
uint32_t offset;
};
#define ANV_NULL_ADDRESS ((struct anv_address) { NULL, 0 })
static inline bool
@@ -2824,6 +2827,7 @@ enum anv_cmd_buffer_exec_mode {
ANV_CMD_BUFFER_EXEC_MODE_GROW_AND_EMIT,
ANV_CMD_BUFFER_EXEC_MODE_CHAIN,
ANV_CMD_BUFFER_EXEC_MODE_COPY_AND_CHAIN,
ANV_CMD_BUFFER_EXEC_MODE_CALL_AND_RETURN,
};
struct anv_cmd_buffer {
@@ -2873,6 +2877,8 @@ struct anv_cmd_buffer {
struct anv_cmd_state state;
struct anv_address return_addr;
/* Set by SetPerformanceMarkerINTEL, written into queries by CmdBeginQuery */
uint64_t intel_perf_marker;
};