X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fstate_tracker%2Fst_atom_texture.c;h=0b68447d2122364daf4ab5402ddfac344faba5af;hb=3e18bad36d90255dca6cb519eb7ecfc540c292c1;hp=fb03766ff599cc4f0a9c59691a82eaac12105325;hpb=3059ceb7f8128f00846f261f1927f5ec72d5dd15;p=mesa.git diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c index fb03766ff59..0b68447d212 100644 --- a/src/mesa/state_tracker/st_atom_texture.c +++ b/src/mesa/state_tracker/st_atom_texture.c @@ -32,34 +32,43 @@ */ +#include "main/macros.h" + #include "st_context.h" #include "st_atom.h" #include "st_texture.h" #include "st_cb_texture.h" #include "pipe/p_context.h" -#include "pipe/p_inlines.h" #include "cso_cache/cso_context.h" static void update_textures(struct st_context *st) { + struct gl_vertex_program *vprog = st->ctx->VertexProgram._Current; struct gl_fragment_program *fprog = st->ctx->FragmentProgram._Current; + const GLbitfield samplersUsed = (vprog->Base.SamplersUsed | + fprog->Base.SamplersUsed); GLuint su; st->state.num_textures = 0; - /*printf("%s samplers used = 0x%x\n", __FUNCTION__, fprog->Base.SamplersUsed);*/ - - for (su = 0; su < st->ctx->Const.MaxTextureCoordUnits; su++) { + /* loop over sampler units (aka tex image units) */ + for (su = 0; su < st->ctx->Const.MaxTextureImageUnits; su++) { struct pipe_texture *pt = NULL; - if (fprog->Base.SamplersUsed & (1 << su)) { - const GLuint texUnit = fprog->Base.SamplerUnits[su]; - struct gl_texture_object *texObj - = st->ctx->Texture.Unit[texUnit]._Current; + if (samplersUsed & (1 << su)) { + struct gl_texture_object *texObj; struct st_texture_object *stObj; GLboolean flush, retval; + GLuint texUnit; + + if (fprog->Base.SamplersUsed & (1 << su)) + texUnit = fprog->Base.SamplerUnits[su]; + else + texUnit = vprog->Base.SamplerUnits[su]; + + texObj = st->ctx->Texture.Unit[texUnit]._Current; if (!texObj) { texObj = st_get_default_texture(st); @@ -92,6 +101,12 @@ update_textures(struct st_context *st) cso_set_sampler_textures(st->cso_context, st->state.num_textures, st->state.sampler_texture); + if (st->ctx->Const.MaxVertexTextureImageUnits > 0) { + cso_set_vertex_sampler_textures(st->cso_context, + MIN2(st->state.num_textures, + st->ctx->Const.MaxVertexTextureImageUnits), + st->state.sampler_texture); + } }