mesa: Update vertex texture code after gallium changes.
authorMichal Krol <michal@vmware.com>
Tue, 1 Dec 2009 10:19:33 +0000 (11:19 +0100)
committerMichal Krol <michal@vmware.com>
Tue, 1 Dec 2009 10:21:21 +0000 (11:21 +0100)
src/mesa/drivers/dri/i965/brw_context.c
src/mesa/main/context.c
src/mesa/main/get.c
src/mesa/main/get_gen.py
src/mesa/main/mtypes.h
src/mesa/state_tracker/st_atom_sampler.c
src/mesa/state_tracker/st_atom_texture.c
src/mesa/state_tracker/st_extensions.c

index 48685c087b82b95a01ad0f786ff8fe78cd3956e5..8bdda60697b9f6e63cddbc390a887edaf8c9973d 100644 (file)
@@ -111,6 +111,7 @@ GLboolean brwCreateContext( const __GLcontextModes *mesaVis,
    ctx->Const.MaxTextureUnits = MIN2(ctx->Const.MaxTextureCoordUnits,
                                      ctx->Const.MaxTextureImageUnits);
    ctx->Const.MaxVertexTextureImageUnits = 0; /* no vertex shader textures */
+   ctx->Const.MaxCombinedTextureImageUnits = 0;
 
    /* Mesa limits textures to 4kx4k; it would be nice to fix that someday
     */
index b5bf46718f7b0379da85bd69db22601c1c1273d5..03fc57e6654ff065c81d3fd48f9ac212279efc7b 100644 (file)
@@ -575,6 +575,7 @@ _mesa_init_constants(GLcontext *ctx)
 
 #if FEATURE_ARB_vertex_shader
    ctx->Const.MaxVertexTextureImageUnits = MAX_VERTEX_TEXTURE_IMAGE_UNITS;
+   ctx->Const.MaxCombinedTextureImageUnits = MAX_COMBINED_TEXTURE_IMAGE_UNITS;
    ctx->Const.MaxVarying = MAX_VARYING;
 #endif
 
index 6c5ce02913589aa8fb76533ff9f6f486c02c8bcb..e8932f83b6a29bf841b6f4539d748bc52557b8b9 100644 (file)
@@ -1876,7 +1876,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
          break;
       case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB:
          CHECK_EXT1(ARB_vertex_shader, "GetBooleanv");
-         params[0] = INT_TO_BOOLEAN(MAX_COMBINED_TEXTURE_IMAGE_UNITS);
+         params[0] = INT_TO_BOOLEAN(ctx->Const.MaxCombinedTextureImageUnits);
          break;
       case GL_CURRENT_PROGRAM:
          CHECK_EXT1(ARB_shader_objects, "GetBooleanv");
@@ -3711,7 +3711,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
          break;
       case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB:
          CHECK_EXT1(ARB_vertex_shader, "GetFloatv");
-         params[0] = (GLfloat)(MAX_COMBINED_TEXTURE_IMAGE_UNITS);
+         params[0] = (GLfloat)(ctx->Const.MaxCombinedTextureImageUnits);
          break;
       case GL_CURRENT_PROGRAM:
          CHECK_EXT1(ARB_shader_objects, "GetFloatv");
@@ -5546,7 +5546,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
          break;
       case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB:
          CHECK_EXT1(ARB_vertex_shader, "GetIntegerv");
-         params[0] = MAX_COMBINED_TEXTURE_IMAGE_UNITS;
+         params[0] = ctx->Const.MaxCombinedTextureImageUnits;
          break;
       case GL_CURRENT_PROGRAM:
          CHECK_EXT1(ARB_shader_objects, "GetIntegerv");
@@ -7382,7 +7382,7 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
          break;
       case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB:
          CHECK_EXT1(ARB_vertex_shader, "GetInteger64v");
-         params[0] = (GLint64)(MAX_COMBINED_TEXTURE_IMAGE_UNITS);
+         params[0] = (GLint64)(ctx->Const.MaxCombinedTextureImageUnits);
          break;
       case GL_CURRENT_PROGRAM:
          CHECK_EXT1(ARB_shader_objects, "GetInteger64v");
index 930c3362faee20333cd70d8f52c128a2100da51c..a29962d33487879c1cfc8661088c264160cd21e8 100644 (file)
@@ -1006,7 +1006,7 @@ StateVars = [
        ( "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB", GLint,
          ["ctx->Const.MaxVertexTextureImageUnits"], "", ["ARB_vertex_shader"] ),
        ( "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB", GLint,
-         ["MAX_COMBINED_TEXTURE_IMAGE_UNITS"], "", ["ARB_vertex_shader"] ),
+         ["ctx->Const.MaxCombinedTextureImageUnits"], "", ["ARB_vertex_shader"] ),
 
        # GL_ARB_shader_objects
        # Actually, this token isn't part of GL_ARB_shader_objects, but is
index 881d233ca3d858aa9a5251f4cf9552ac604e2cd8..5f012448275e79fe90a2e54277e7279c2499cb80 100644 (file)
@@ -2319,6 +2319,7 @@ struct gl_constants
    GLuint MaxTextureCoordUnits;
    GLuint MaxTextureImageUnits;
    GLuint MaxVertexTextureImageUnits;
+   GLuint MaxCombinedTextureImageUnits;
    GLuint MaxTextureUnits;           /**< = MIN(CoordUnits, ImageUnits) */
    GLfloat MaxTextureMaxAnisotropy;  /**< GL_EXT_texture_filter_anisotropic */
    GLfloat MaxTextureLodBias;        /**< GL_EXT_texture_lod_bias */
index 6611956ae83ce77a9474a00633bd4c110770d102..d6e3a3e5610021f85b4bdc9f98ddc3446cd9ca57 100644 (file)
@@ -229,14 +229,23 @@ update_samplers(struct st_context *st)
 
          /*printf("%s su=%u non-null\n", __FUNCTION__, su);*/
          cso_single_sampler(st->cso_context, su, sampler);
+         if (su < st->ctx->Const.MaxVertexTextureImageUnits) {
+            cso_single_vertex_sampler(st->cso_context, su, sampler);
+         }
       }
       else {
          /*printf("%s su=%u null\n", __FUNCTION__, su);*/
          cso_single_sampler(st->cso_context, su, NULL);
+         if (su < st->ctx->Const.MaxVertexTextureImageUnits) {
+            cso_single_vertex_sampler(st->cso_context, su, NULL);
+         }
       }
    }
 
    cso_single_sampler_done(st->cso_context);
+   if (st->ctx->Const.MaxVertexTextureImageUnits > 0) {
+      cso_single_vertex_sampler_done(st->cso_context);
+   }
 }
 
 
index 4d4f97da7ed37b87717ca854cb5bfc9bf925de47..0b68447d2122364daf4ab5402ddfac344faba5af 100644 (file)
@@ -32,6 +32,8 @@
   */
  
 
+#include "main/macros.h"
+
 #include "st_context.h"
 #include "st_atom.h"
 #include "st_texture.h"
@@ -99,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);
+   }
 }
 
 
index 57fe72d76a7c19dd45fa8f06a93f29a4ddc703be..ef3cbc53ee0c85d401bf866aa5dfc365c797d3a9 100644 (file)
@@ -92,6 +92,10 @@ void st_init_limits(struct st_context *st)
       = _min(screen->get_param(screen, PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS),
              MAX_VERTEX_TEXTURE_IMAGE_UNITS);
 
+   c->MaxCombinedTextureImageUnits
+      = _min(screen->get_param(screen, PIPE_CAP_MAX_COMBINED_SAMPLERS),
+             MAX_COMBINED_TEXTURE_IMAGE_UNITS);
+
    c->MaxTextureCoordUnits
       = _min(c->MaxTextureImageUnits, MAX_TEXTURE_COORD_UNITS);