Skip to content
Snippets Groups Projects
Commit 9b51dcf1 authored by Gert Wollny's avatar Gert Wollny Committed by Juan A. Suárez
Browse files

softpipe/buffer: load only as many components as the the buffer resource type provides


Otherwise we risk to read past the end of the buffer.

In addition, change the loop counters to unsigned to be consistent
with the types.

Fixes: afa8707b
    softpipe: add SSBO/shader atomics support.

Signed-off-by: default avatarGert Wollny <gert.wollny@collabora.com>
Reviewed-by: default avatarDave Airlie <airlied@redhat.com>
(cherry picked from commit 865b9dda)
parent 914ac06e
No related branches found
No related tags found
No related merge requests found
......@@ -55,7 +55,8 @@ sp_tgsi_load(const struct tgsi_buffer *buffer,
struct pipe_shader_buffer *bview;
struct softpipe_resource *spr;
unsigned width;
int c, j;
unsigned ncomp;
unsigned c, j;
unsigned char *data_ptr;
const struct util_format_description *format_desc = util_format_description(PIPE_FORMAT_R32_UINT);
......@@ -63,6 +64,8 @@ sp_tgsi_load(const struct tgsi_buffer *buffer,
goto fail_write_all_zero;
bview = &sp_buf->sp_bview[params->unit];
ncomp = util_format_get_nr_components(bview->buffer->format);
spr = softpipe_resource(bview->buffer);
if (!spr)
goto fail_write_all_zero;
......@@ -88,7 +91,7 @@ sp_tgsi_load(const struct tgsi_buffer *buffer,
continue;
}
data_ptr = (unsigned char *)spr->data + bview->buffer_offset + s_coord;
for (c = 0; c < 4; c++) {
for (c = 0; c < ncomp; c++) {
format_desc->fetch_rgba_uint(sdata, data_ptr, 0, 0);
((uint32_t *)rgba[c])[j] = sdata[0];
data_ptr += 4;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment