anv: don't attempt to memcpy if allocation fails
Based on git history thhese appears to be a subset of `anv_batch_emit_batch`, so I've structured the code similarly, if `anv_batch_emit_dwords` returns `nullptr`, we just move on without copying the memory. CID: 1665339 CID: 1664814 Reviewed-by: Iván Briano <ivan.briano@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37534>
This commit is contained in:
@@ -144,12 +144,14 @@ cmd_buffer_flush_compute_state(struct anv_cmd_buffer *cmd_buffer)
|
||||
#define anv_batch_emit_cs(batch, cmd, field) ({ \
|
||||
void *__dst = anv_batch_emit_dwords( \
|
||||
batch, __anv_cmd_length(cmd)); \
|
||||
memcpy(__dst, \
|
||||
&comp_state->shader->cmd_data[ \
|
||||
comp_state->shader->field.offset], \
|
||||
4 * __anv_cmd_length(cmd)); \
|
||||
VG(VALGRIND_CHECK_MEM_IS_DEFINED( \
|
||||
__dst, __anv_cmd_length(cmd) * 4)); \
|
||||
if (__dst != NULL) { \
|
||||
memcpy(__dst, \
|
||||
&comp_state->shader->cmd_data[ \
|
||||
comp_state->shader->field.offset], \
|
||||
4 * __anv_cmd_length(cmd)); \
|
||||
VG(VALGRIND_CHECK_MEM_IS_DEFINED( \
|
||||
__dst, __anv_cmd_length(cmd) * 4)); \
|
||||
} \
|
||||
__dst; \
|
||||
})
|
||||
|
||||
|
||||
@@ -3575,19 +3575,23 @@ cmd_buffer_gfx_state_emission(struct anv_cmd_buffer *cmd_buffer)
|
||||
#define anv_batch_emit_gfx(batch, cmd, name) ({ \
|
||||
void *__dst = anv_batch_emit_dwords( \
|
||||
batch, __anv_cmd_length(cmd)); \
|
||||
memcpy(__dst, hw_state->packed.name, \
|
||||
4 * __anv_cmd_length(cmd)); \
|
||||
VG(VALGRIND_CHECK_MEM_IS_DEFINED( \
|
||||
__dst, __anv_cmd_length(cmd) * 4)); \
|
||||
if (__dst != NULL) { \
|
||||
memcpy(__dst, hw_state->packed.name, \
|
||||
4 * __anv_cmd_length(cmd)); \
|
||||
VG(VALGRIND_CHECK_MEM_IS_DEFINED( \
|
||||
__dst, __anv_cmd_length(cmd) * 4)); \
|
||||
} \
|
||||
__dst; \
|
||||
})
|
||||
#define anv_batch_emit_gfx_variable(batch, name) do { \
|
||||
void *__dst = anv_batch_emit_dwords( \
|
||||
batch, hw_state->packed.name##_len); \
|
||||
memcpy(__dst, hw_state->packed.name, \
|
||||
4 * hw_state->packed.name##_len); \
|
||||
VG(VALGRIND_CHECK_MEM_IS_DEFINED( \
|
||||
__dst, 4 * hw_state->packed.name##_len)); \
|
||||
if (__dst != NULL) { \
|
||||
memcpy(__dst, hw_state->packed.name, \
|
||||
4 * hw_state->packed.name##_len); \
|
||||
VG(VALGRIND_CHECK_MEM_IS_DEFINED( \
|
||||
__dst, 4 * hw_state->packed.name##_len)); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
if (IS_DIRTY(URB)) {
|
||||
|
||||
Reference in New Issue
Block a user