Mesa (gallium-0.2): gallium: check vertex shaders for samplers/ texture usage as we do for fragment shaders
Brian Paul
brianp at kemper.freedesktop.org
Thu Dec 4 17:00:15 UTC 2008
Module: Mesa
Branch: gallium-0.2
Commit: 9271662ae9acda08ed6e444d1ee18384eebf8987
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9271662ae9acda08ed6e444d1ee18384eebf8987
Author: Brian <brian.paul at tungstengraphics.com>
Date: Tue Dec 2 20:10:32 2008 -0700
gallium: check vertex shaders for samplers/texture usage as we do for fragment shaders
---
src/mesa/state_tracker/st_atom_sampler.c | 20 +++++++++++++-------
src/mesa/state_tracker/st_atom_texture.c | 20 ++++++++++++++------
2 files changed, 27 insertions(+), 13 deletions(-)
diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c
index cef61fb..d7b9043 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -121,24 +121,30 @@ gl_filter_to_img_filter(GLenum filter)
static void
update_samplers(struct st_context *st)
{
- const struct st_fragment_program *fs = st->fp;
+ 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_samplers = 0;
- /*printf("%s samplers used = 0x%x\n", __FUNCTION__, fs->Base.Base.SamplersUsed);*/
-
/* loop over sampler units (aka tex image units) */
for (su = 0; su < st->ctx->Const.MaxTextureImageUnits; su++) {
struct pipe_sampler_state *sampler = st->state.samplers + su;
memset(sampler, 0, sizeof(*sampler));
- if (fs->Base.Base.SamplersUsed & (1 << su)) {
- GLuint texUnit = fs->Base.Base.SamplerUnits[su];
- const struct gl_texture_object *texobj
- = st->ctx->Texture.Unit[texUnit]._Current;
+ if (samplersUsed & (1 << su)) {
+ struct gl_texture_object *texobj;
+ 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);
}
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index fb03766..18ffc08 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -44,22 +44,30 @@
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);*/
-
+ /* loop over sampler units (aka tex image units) */
for (su = 0; su < st->ctx->Const.MaxTextureCoordUnits; 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);
More information about the mesa-commit
mailing list