X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fstate_tracker%2Fst_atom_texture.c;h=df05e83c2d48fc87624bf7f21c24e50c9d168fa2;hb=9785ae0973cc206afc36dbc7d5b9553f92d06b47;hp=6e2efd960ddd1f6252685c79d87aeccebab4dfc4;hpb=f3c3aff6efed49b7740a144f767c713cb22561e2;p=mesa.git 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); }