summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2012-08-17 08:16:23 -0600
committerBrian Paul <[email protected]>2012-08-18 07:40:10 -0600
commit5b542681dc05b8b9eba677ee74323ac0ff85a5f0 (patch)
treef564e80ddc80d6b30d9a865f3305996283bdecd0 /src/mesa/state_tracker
parentd65eb02537813ad1f469fa3d597726fcb5a76bb0 (diff)
st/mesa: fix sampler view counting
In the past, when we called pipe::set_sampler_views(n) the drivers set samplers [n..MAX] to NULL. We no longer do that. The state tracker code was already trying to set unused sampler views to NULL to cover that case, but the logic was broken and unnoticed until now. This patch fixes it. Strictly speaking, this patch shouldn't be necessary. Drivers should simply ignore unused samplers and sampler views. But some drivers like llvmpipe (and others?) count those things and they figure into state validation. That could be fixed in the future. Fixes http://bugs.freedesktop.org/show_bug.cgi?id=53617 Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_atom_texture.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index 6e2efd960dd..df05e83c2d4 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -265,7 +265,7 @@ update_textures(struct st_context *st,
{
const GLuint old_max = *num_textures;
GLbitfield samplers_used = prog->SamplersUsed;
- GLuint unit;
+ GLuint unit, new_count;
if (samplers_used == 0x0 && old_max == 0)
return;
@@ -294,9 +294,16 @@ update_textures(struct st_context *st,
pipe_sampler_view_reference(&(sampler_views[unit]), sampler_view);
}
+ /* Ex: if old_max = 3 and *num_textures = 1, we need to pass an
+ * array of views={X, NULL, NULL} to unref the old texture views
+ * at positions [1] and [2].
+ */
+ new_count = MAX2(*num_textures, old_max);
+ assert(new_count <= max_units);
+
cso_set_sampler_views(st->cso_context,
shader_stage,
- MIN2(*num_textures, max_units),
+ new_count,
sampler_views);
}