summaryrefslogtreecommitdiff
path: root/src/mesa/main/texenvprogram.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main/texenvprogram.c')
-rw-r--r--src/mesa/main/texenvprogram.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c
index 2f90a34220..48abf51d89 100644
--- a/src/mesa/main/texenvprogram.c
+++ b/src/mesa/main/texenvprogram.c
@@ -38,6 +38,21 @@
#include "texenvprogram.h"
+/*
+ * Note on texture units:
+ *
+ * The number of texture units supported by fixed-function fragment
+ * processing is MAX_TEXTURE_COORD_UNITS, not MAX_TEXTURE_IMAGE_UNITS.
+ * That's because there's a one-to-one correspondence between texture
+ * coordinates and samplers in fixed-function processing.
+ *
+ * Since fixed-function vertex processing is limited to MAX_TEXTURE_COORD_UNITS
+ * sets of texcoords, so is fixed-function fragment processing.
+ *
+ * We can safely use ctx->Const.MaxTextureUnits for loop bounds.
+ */
+
+
struct texenvprog_cache_item
{
GLuint hash;
@@ -50,13 +65,13 @@ struct texenvprog_cache_item
/**
* Up to nine instructions per tex unit, plus fog, specular color.
*/
-#define MAX_INSTRUCTIONS ((MAX_TEXTURE_UNITS * 9) + 12)
+#define MAX_INSTRUCTIONS ((MAX_TEXTURE_COORD_UNITS * 9) + 12)
#define DISASSEM (MESA_VERBOSE & VERBOSE_DISASSEM)
struct mode_opt {
- GLubyte Source:4;
- GLubyte Operand:3;
+ GLuint Source:4;
+ GLuint Operand:3;
};
struct state_key {
@@ -313,7 +328,7 @@ static void make_state_key( GLcontext *ctx, struct state_key *key )
memset(key, 0, sizeof(*key));
- for (i=0;i<MAX_TEXTURE_UNITS;i++) {
+ for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
GLenum format;
@@ -416,7 +431,7 @@ struct texenv_fragment_program {
GLbitfield temp_in_use; /**< Tracks temporary regs which are in use. */
GLboolean error;
- struct ureg src_texture[MAX_TEXTURE_UNITS];
+ struct ureg src_texture[MAX_TEXTURE_COORD_UNITS];
/* Reg containing each texture unit's sampled texture color,
* else undef.
*/
@@ -1201,7 +1216,7 @@ create_new_program(GLcontext *ctx, struct state_key *key,
p.program->Base.InputsRead = 0;
p.program->Base.OutputsWritten = 1 << FRAG_RESULT_COLR;
- for (unit = 0; unit < MAX_TEXTURE_UNITS; unit++)
+ for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++)
p.src_texture[unit] = undef;
p.src_previous = undef;