summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/softpipe
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2014-07-10 09:37:39 -0600
committerBrian Paul <[email protected]>2014-07-10 10:59:40 -0600
commitc45b9b572159983a20cf771016c3528a423643e1 (patch)
treeb740caded7372a566f2fbf98cc1cd4a0aad3f7a6 /src/gallium/drivers/softpipe
parentfaa6b0cdc30c327871d7639ca3f1da5057d90d0a (diff)
softpipe: fix sp_get_dims() for PIPE_BUFFER
Before, we were checking the level against view->u.tex.last_level but level is not valid for buffers. Plus, the aliasing of the view->u.tex view->u.buf members (a union) caused the level checking arithmetic to be totally wrong. The net effect is we always returned early for PIPE_BUFFER size queries. This fixes the piglit "textureSize 140 fs samplerBuffer" test. Reviewed-by: Roland Scheidegger <[email protected]>
Diffstat (limited to 'src/gallium/drivers/softpipe')
-rw-r--r--src/gallium/drivers/softpipe/sp_tex_sample.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c
index 8565a01822a..2d597664013 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.c
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
@@ -2907,14 +2907,21 @@ sp_get_dims(struct sp_sampler_view *sp_sview, int level,
const struct pipe_sampler_view *view = &sp_sview->base;
const struct pipe_resource *texture = view->texture;
+ if (texture->target == PIPE_BUFFER) {
+ dims[0] = (view->u.buf.last_element - view->u.buf.first_element) + 1;
+ /* the other values are undefined, but let's avoid potential valgrind
+ * warnings.
+ */
+ dims[1] = dims[2] = dims[3] = 0;
+ return;
+ }
+
/* undefined according to EXT_gpu_program */
level += view->u.tex.first_level;
if (level > view->u.tex.last_level)
return;
- if (texture->target != PIPE_BUFFER)
- dims[3] = view->u.tex.last_level - view->u.tex.first_level + 1;
-
+ dims[3] = view->u.tex.last_level - view->u.tex.first_level + 1;
dims[0] = u_minify(texture->width0, level);
switch(texture->target) {
@@ -2939,9 +2946,6 @@ sp_get_dims(struct sp_sampler_view *sp_sview, int level,
dims[1] = u_minify(texture->height0, level);
dims[2] = (view->u.tex.last_layer - view->u.tex.first_layer + 1) / 6;
break;
- case PIPE_BUFFER:
- dims[0] /= util_format_get_blocksize(view->format);
- return;
default:
assert(!"unexpected texture target in sp_get_dims()");
return;