[Mesa-dev] [PATCH 1/2] radv: check CS space in radv_emit_write_data_packet()
Bas Nieuwenhuizen
bas at basnieuwenhuizen.nl
Fri Jul 27 11:07:48 UTC 2018
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
for the series
On Fri, Jul 27, 2018 at 11:28 AM, Samuel Pitoiset
<samuel.pitoiset at gmail.com> wrote:
> This wasn't wrong but it looks better to me like this. It's
> only used for debugging purposes (ie. RADV_TRACE_FILE).
>
> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
> ---
> src/amd/vulkan/radv_cmd_buffer.c | 26 ++++++++++++--------------
> 1 file changed, 12 insertions(+), 14 deletions(-)
>
> diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c
> index f9f57a1065..131ea18b15 100644
> --- a/src/amd/vulkan/radv_cmd_buffer.c
> +++ b/src/amd/vulkan/radv_cmd_buffer.c
> @@ -429,9 +429,13 @@ radv_cmd_buffer_upload_data(struct radv_cmd_buffer *cmd_buffer,
> }
>
> static void
> -radv_emit_write_data_packet(struct radeon_cmdbuf *cs, uint64_t va,
> +radv_emit_write_data_packet(struct radv_cmd_buffer *cmd_buffer, uint64_t va,
> unsigned count, const uint32_t *data)
> {
> + struct radeon_cmdbuf *cs = cmd_buffer->cs;
> +
> + radeon_check_space(cmd_buffer->device->ws, cs, 4 + count);
> +
> radeon_emit(cs, PKT3(PKT3_WRITE_DATA, 2 + count, 0));
> radeon_emit(cs, S_370_DST_SEL(V_370_MEM_ASYNC) |
> S_370_WR_CONFIRM(1) |
> @@ -451,10 +455,12 @@ void radv_cmd_buffer_trace_emit(struct radv_cmd_buffer *cmd_buffer)
> if (cmd_buffer->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)
> va += 4;
>
> - MAYBE_UNUSED unsigned cdw_max = radeon_check_space(cmd_buffer->device->ws, cmd_buffer->cs, 7);
> -
> ++cmd_buffer->state.trace_id;
> - radv_emit_write_data_packet(cs, va, 1, &cmd_buffer->state.trace_id);
> + radv_emit_write_data_packet(cmd_buffer, va, 1,
> + &cmd_buffer->state.trace_id);
> +
> + radeon_check_space(cmd_buffer->device->ws, cs, 2);
> +
> radeon_emit(cs, PKT3(PKT3_NOP, 0, 0));
> radeon_emit(cs, AC_ENCODE_TRACE_POINT(cmd_buffer->state.trace_id));
> }
> @@ -493,7 +499,6 @@ radv_save_pipeline(struct radv_cmd_buffer *cmd_buffer,
> struct radv_pipeline *pipeline, enum ring_type ring)
> {
> struct radv_device *device = cmd_buffer->device;
> - struct radeon_cmdbuf *cs = cmd_buffer->cs;
> uint32_t data[2];
> uint64_t va;
>
> @@ -510,13 +515,10 @@ radv_save_pipeline(struct radv_cmd_buffer *cmd_buffer,
> assert(!"invalid ring type");
> }
>
> - MAYBE_UNUSED unsigned cdw_max = radeon_check_space(device->ws,
> - cmd_buffer->cs, 6);
> -
> data[0] = (uintptr_t)pipeline;
> data[1] = (uintptr_t)pipeline >> 32;
>
> - radv_emit_write_data_packet(cs, va, 2, data);
> + radv_emit_write_data_packet(cmd_buffer, va, 2, data);
> }
>
> void radv_set_descriptor_set(struct radv_cmd_buffer *cmd_buffer,
> @@ -540,22 +542,18 @@ radv_save_descriptors(struct radv_cmd_buffer *cmd_buffer,
> struct radv_descriptor_state *descriptors_state =
> radv_get_descriptors_state(cmd_buffer, bind_point);
> struct radv_device *device = cmd_buffer->device;
> - struct radeon_cmdbuf *cs = cmd_buffer->cs;
> uint32_t data[MAX_SETS * 2] = {};
> uint64_t va;
> unsigned i;
> va = radv_buffer_get_va(device->trace_bo) + 24;
>
> - MAYBE_UNUSED unsigned cdw_max = radeon_check_space(device->ws,
> - cmd_buffer->cs, 4 + MAX_SETS * 2);
> -
> for_each_bit(i, descriptors_state->valid) {
> struct radv_descriptor_set *set = descriptors_state->sets[i];
> data[i * 2] = (uintptr_t)set;
> data[i * 2 + 1] = (uintptr_t)set >> 32;
> }
>
> - radv_emit_write_data_packet(cs, va, MAX_SETS * 2, data);
> + radv_emit_write_data_packet(cmd_buffer, va, MAX_SETS * 2, data);
> }
>
> struct radv_userdata_info *
> --
> 2.18.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list