diff options
author | Marek Olšák <[email protected]> | 2016-08-12 02:33:41 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2016-08-17 14:15:33 +0200 |
commit | 7cd256ce7e4bad680bb77d033cf5dd662abab2dd (patch) | |
tree | 3b4a190876c076129e01792f0e3f4a087a820988 /src/gallium/drivers/softpipe | |
parent | 1ac23a9359556091b12ed1345737084e3a2f6ae3 (diff) |
gallium: change pipe_sampler_view::first_element/last_element -> offset/size
This is required by OpenGL. Our hardware supports this.
Example: Bind RGBA32F with offset = 4 bytes.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97305
Acked-by: Ilia Mirkin <[email protected]>
Acked-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/gallium/drivers/softpipe')
-rw-r--r-- | src/gallium/drivers/softpipe/sp_state_sampler.c | 8 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_tex_sample.c | 13 |
2 files changed, 12 insertions, 9 deletions
diff --git a/src/gallium/drivers/softpipe/sp_state_sampler.c b/src/gallium/drivers/softpipe/sp_state_sampler.c index 0d5149c1df4..f8247434356 100644 --- a/src/gallium/drivers/softpipe/sp_state_sampler.c +++ b/src/gallium/drivers/softpipe/sp_state_sampler.c @@ -240,11 +240,9 @@ prepare_shader_sampling( img_stride[0] = 0; /* everything specified in number of elements here. */ - width0 = view->u.buf.last_element - view->u.buf.first_element + 1; - addr = (uint8_t *)addr + view->u.buf.first_element * - view_blocksize; - assert(view->u.buf.first_element <= view->u.buf.last_element); - assert(view->u.buf.last_element * view_blocksize < res->width0); + width0 = view->u.buf.size / view_blocksize; + addr = (uint8_t *)addr + view->u.buf.offset; + assert(view->u.buf.offset + view->u.buf.size <= res->width0); } } else { diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c index 5998681c0fc..c457f896e49 100644 --- a/src/gallium/drivers/softpipe/sp_tex_sample.c +++ b/src/gallium/drivers/softpipe/sp_tex_sample.c @@ -3192,7 +3192,7 @@ sp_get_dims(const struct sp_sampler_view *sp_sview, const struct pipe_resource *texture = view->texture; if (view->target == PIPE_BUFFER) { - dims[0] = (view->u.buf.last_element - view->u.buf.first_element) + 1; + dims[0] = view->u.buf.size / util_format_get_blocksize(view->format); /* the other values are undefined, but let's avoid potential valgrind * warnings. */ @@ -3264,17 +3264,22 @@ sp_get_texels(const struct sp_sampler_view *sp_sview, const int width = u_minify(texture->width0, level); const int height = u_minify(texture->height0, level); const int depth = u_minify(texture->depth0, level); + unsigned elem_size, first_element, last_element; addr.value = 0; addr.bits.level = level; switch (sp_sview->base.target) { case PIPE_BUFFER: + elem_size = util_format_get_blocksize(sp_sview->base.format); + first_element = sp_sview->base.u.buf.offset / elem_size; + last_element = (sp_sview->base.u.buf.offset + + sp_sview->base.u.buf.size) / elem_size - 1; for (j = 0; j < TGSI_QUAD_SIZE; j++) { const int x = CLAMP(v_i[j] + offset[0] + - sp_sview->base.u.buf.first_element, - sp_sview->base.u.buf.first_element, - sp_sview->base.u.buf.last_element); + first_element, + first_element, + last_element); tx = get_texel_2d_no_border(sp_sview, addr, x, 0); for (c = 0; c < 4; c++) { rgba[c][j] = tx[c]; |