diff options
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/arrayobj.c | 6 | ||||
-rw-r--r-- | src/mesa/main/attrib.c | 5 | ||||
-rw-r--r-- | src/mesa/main/bufferobj.c | 2 | ||||
-rw-r--r-- | src/mesa/main/config.h | 53 | ||||
-rw-r--r-- | src/mesa/main/context.c | 20 | ||||
-rw-r--r-- | src/mesa/main/enable.c | 148 | ||||
-rw-r--r-- | src/mesa/main/ffvertex_prog.c | 44 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 37 | ||||
-rw-r--r-- | src/mesa/main/points.c | 2 | ||||
-rw-r--r-- | src/mesa/main/rastpos.c | 2 | ||||
-rw-r--r-- | src/mesa/main/texenvprogram.c | 23 | ||||
-rw-r--r-- | src/mesa/main/texstate.c | 11 |
12 files changed, 210 insertions, 143 deletions
diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c index 14612393176..f3f482f8c87 100644 --- a/src/mesa/main/arrayobj.c +++ b/src/mesa/main/arrayobj.c @@ -142,7 +142,7 @@ _mesa_initialize_array_object( GLcontext *ctx, obj->Index.StrideB = 0; obj->Index.Ptr = NULL; obj->Index.Enabled = GL_FALSE; - for (i = 0; i < MAX_TEXTURE_UNITS; i++) { + for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) { obj->TexCoord[i].Size = 4; obj->TexCoord[i].Type = GL_FLOAT; obj->TexCoord[i].Stride = 0; @@ -181,7 +181,7 @@ _mesa_initialize_array_object( GLcontext *ctx, obj->SecondaryColor.BufferObj = ctx->Array.NullBufferObj; obj->FogCoord.BufferObj = ctx->Array.NullBufferObj; obj->Index.BufferObj = ctx->Array.NullBufferObj; - for (i = 0; i < MAX_TEXTURE_UNITS; i++) { + for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) { obj->TexCoord[i].BufferObj = ctx->Array.NullBufferObj; } obj->EdgeFlag.BufferObj = ctx->Array.NullBufferObj; @@ -335,7 +335,7 @@ _mesa_DeleteVertexArraysAPPLE(GLsizei n, const GLuint *ids) unbind_buffer_object( ctx, obj->SecondaryColor.BufferObj ); unbind_buffer_object( ctx, obj->FogCoord.BufferObj ); unbind_buffer_object( ctx, obj->Index.BufferObj ); - for (i = 0; i < MAX_TEXTURE_UNITS; i++) { + for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) { unbind_buffer_object( ctx, obj->TexCoord[i].BufferObj ); } unbind_buffer_object( ctx, obj->EdgeFlag.BufferObj ); diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index dc85da2518f..825c841ee21 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -1,8 +1,9 @@ /* * Mesa 3-D graphics library - * Version: 7.2 + * Version: 7.3 * * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -224,7 +225,7 @@ _mesa_PushAttrib(GLbitfield mask) attr->SampleAlphaToOne = ctx->Multisample.SampleAlphaToOne; attr->SampleCoverage = ctx->Multisample.SampleCoverage; attr->SampleCoverageInvert = ctx->Multisample.SampleCoverageInvert; - for (i=0; i<MAX_TEXTURE_UNITS; i++) { + for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { attr->Texture[i] = ctx->Texture.Unit[i].Enabled; attr->TexGen[i] = ctx->Texture.Unit[i].TexGenEnabled; attr->TextureColorTable[i] = ctx->Texture.Unit[i].ColorTableEnabled; diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 190e6ab5641..016543da01f 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -808,7 +808,7 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids) unbind(ctx, &ctx->Array.ArrayObj->FogCoord.BufferObj, bufObj); unbind(ctx, &ctx->Array.ArrayObj->Index.BufferObj, bufObj); unbind(ctx, &ctx->Array.ArrayObj->EdgeFlag.BufferObj, bufObj); - for (j = 0; j < MAX_TEXTURE_UNITS; j++) { + for (j = 0; j < MAX_TEXTURE_COORD_UNITS; j++) { unbind(ctx, &ctx->Array.ArrayObj->TexCoord[j].BufferObj, bufObj); } for (j = 0; j < VERT_ATTRIB_MAX; j++) { diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h index ec7e156ebd8..c3feffda986 100644 --- a/src/mesa/main/config.h +++ b/src/mesa/main/config.h @@ -1,13 +1,9 @@ -/** - * \file config.h - * Tunable configuration parameters. - */ - /* * Mesa 3-D graphics library - * Version: 7.1 + * Version: 7.3 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * Copyright (C) 2008 VMware, Inc. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -27,6 +23,10 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/** + * \file config.h + * Tunable configuration parameters. + */ #ifndef MESA_CONFIG_H_INCLUDED #define MESA_CONFIG_H_INCLUDED @@ -115,27 +115,28 @@ /** Maximum number of layers in a 1D or 2D array texture - GL_MESA_texture_array */ #define MAX_ARRAY_TEXTURE_LAYERS 64 -/** Number of texture units - GL_ARB_multitexture - * This needs to be the larger of MAX_TEXTURE_COORD_UNITS and - * MAX_TEXTURE_IMAGE_UNITS seen below, since MAX_TEXTURE_UNITS is used - * to dimension some arrays that store both coord and image data. -*/ -#define MAX_TEXTURE_UNITS 8 - -/*@}*/ +/** + * Max number of texture coordinate units. This mainly just applies to + * the fixed-function vertex code. This will be difficult to raise above + * eight because of various vertex attribute bitvectors. + */ +#define MAX_TEXTURE_COORD_UNITS 8 +/** + * Max number of texture image units. Also determines number of texture + * samplers in shaders. + */ +#define MAX_TEXTURE_IMAGE_UNITS 16 /** - * \name Separate numbers of texture coordinates and texture image units. - * - * These values will eventually replace most instances of MAX_TEXTURE_UNITS. - * We should always have MAX_TEXTURE_COORD_UNITS <= MAX_TEXTURE_IMAGE_UNITS. - * And, GL_MAX_TEXTURE_UNITS <= MAX_TEXTURE_COORD_UNITS. + * Larger of MAX_TEXTURE_COORD_UNITS and MAX_TEXTURE_IMAGE_UNITS. + * This value is only used for dimensioning arrays. + * Either MAX_TEXTURE_COORD_UNITS or MAX_TEXTURE_IMAGE_UNITS (or the + * corresponding ctx->Const.MaxTextureCoord/ImageUnits fields) should be + * used almost everywhere else. */ -/*@{*/ -#define MAX_TEXTURE_COORD_UNITS 8 -#define MAX_TEXTURE_IMAGE_UNITS 8 -/*@}*/ +#define MAX_TEXTURE_UNITS ((MAX_TEXTURE_COORD_UNITS > MAX_TEXTURE_IMAGE_UNITS) ? MAX_TEXTURE_COORD_UNITS : MAX_TEXTURE_IMAGE_UNITS) + /** * Maximum viewport/image width. Must accomodate all texture sizes too. @@ -190,7 +191,7 @@ #define MAX_PROGRAM_ADDRESS_REGS 2 #define MAX_UNIFORMS 256 /**< number of vec4 uniforms */ #define MAX_VARYING 8 /**< number of float[4] vectors */ -#define MAX_SAMPLERS 8 +#define MAX_SAMPLERS MAX_TEXTURE_IMAGE_UNITS #define MAX_PROGRAM_INPUTS 32 #define MAX_PROGRAM_OUTPUTS 32 /*@}*/ @@ -218,8 +219,8 @@ /** For GL_ARB_vertex_shader */ /*@{*/ #define MAX_VERTEX_ATTRIBS 16 -#define MAX_VERTEX_TEXTURE_IMAGE_UNITS MAX_TEXTURE_UNITS -#define MAX_COMBINED_TEXTURE_IMAGE_UNITS (MAX_TEXTURE_IMAGE_UNITS + MAX_VERTEX_TEXTURE_IMAGE_UNITS) +#define MAX_VERTEX_TEXTURE_IMAGE_UNITS MAX_TEXTURE_IMAGE_UNITS +#define MAX_COMBINED_TEXTURE_IMAGE_UNITS MAX_TEXTURE_IMAGE_UNITS /*@}*/ diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 61c0861cbd4..ea52b26f0f7 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1,14 +1,9 @@ -/** - * \file context.c - * Mesa context/visual/framebuffer management functions. - * \author Brian Paul - */ - /* * Mesa 3-D graphics library - * Version: 7.1 + * Version: 7.3 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * Copyright (C) 2008 VMware, Inc. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -28,6 +23,11 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/** + * \file context.c + * Mesa context/visual/framebuffer management functions. + * \author Brian Paul + */ /** * \mainpage Mesa Main Module @@ -870,9 +870,6 @@ _mesa_init_constants(GLcontext *ctx) assert(MAX_TEXTURE_LEVELS >= MAX_3D_TEXTURE_LEVELS); assert(MAX_TEXTURE_LEVELS >= MAX_CUBE_TEXTURE_LEVELS); - assert(MAX_TEXTURE_UNITS >= MAX_TEXTURE_COORD_UNITS); - assert(MAX_TEXTURE_UNITS >= MAX_TEXTURE_IMAGE_UNITS); - /* Constants, may be overriden (usually only reduced) by device drivers */ ctx->Const.MaxTextureLevels = MAX_TEXTURE_LEVELS; ctx->Const.Max3DTextureLevels = MAX_3D_TEXTURE_LEVELS; @@ -963,6 +960,9 @@ check_context_limits(GLcontext *ctx) assert(ctx->Const.MaxTextureUnits <= MAX_TEXTURE_IMAGE_UNITS); assert(ctx->Const.MaxTextureUnits <= MAX_TEXTURE_COORD_UNITS); + /* number of coord units cannot be greater than number of image units */ + assert(ctx->Const.MaxTextureCoordUnits <= ctx->Const.MaxTextureImageUnits); + assert(ctx->Const.MaxViewportWidth <= MAX_WIDTH); assert(ctx->Const.MaxViewportHeight <= MAX_WIDTH); diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 248df1badca..72ed50808c5 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -201,6 +201,26 @@ _mesa_DisableClientState( GLenum cap ) } + +/** + * Return pointer to current texture unit for setting/getting coordinate + * state. + * Note that we'll set GL_INVALID_OPERATION if the active texture unit is + * higher than the number of supported coordinate units. And we'll return NULL. + */ +static struct gl_texture_unit * +get_texcoord_unit(GLcontext *ctx) +{ + if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glEnable/Disable(texcoord unit)"); + return NULL; + } + else { + return &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + } +} + + /** * Helper function to enable or disable a texture target. */ @@ -612,54 +632,62 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state) return; } break; - case GL_TEXTURE_GEN_Q: { - GLuint unit = ctx->Texture.CurrentUnit; - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - GLuint newenabled = texUnit->TexGenEnabled & ~Q_BIT; - if (state) - newenabled |= Q_BIT; - if (texUnit->TexGenEnabled == newenabled) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->TexGenEnabled = newenabled; + case GL_TEXTURE_GEN_Q: + { + struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); + if (texUnit) { + GLuint newenabled = texUnit->TexGenEnabled & ~Q_BIT; + if (state) + newenabled |= Q_BIT; + if (texUnit->TexGenEnabled == newenabled) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->TexGenEnabled = newenabled; + } + } break; - } - case GL_TEXTURE_GEN_R: { - GLuint unit = ctx->Texture.CurrentUnit; - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - GLuint newenabled = texUnit->TexGenEnabled & ~R_BIT; - if (state) - newenabled |= R_BIT; - if (texUnit->TexGenEnabled == newenabled) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->TexGenEnabled = newenabled; + case GL_TEXTURE_GEN_R: + { + struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); + if (texUnit) { + GLuint newenabled = texUnit->TexGenEnabled & ~R_BIT; + if (state) + newenabled |= R_BIT; + if (texUnit->TexGenEnabled == newenabled) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->TexGenEnabled = newenabled; + } + } break; - } - case GL_TEXTURE_GEN_S: { - GLuint unit = ctx->Texture.CurrentUnit; - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - GLuint newenabled = texUnit->TexGenEnabled & ~S_BIT; - if (state) - newenabled |= S_BIT; - if (texUnit->TexGenEnabled == newenabled) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->TexGenEnabled = newenabled; + case GL_TEXTURE_GEN_S: + { + struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); + if (texUnit) { + GLuint newenabled = texUnit->TexGenEnabled & ~S_BIT; + if (state) + newenabled |= S_BIT; + if (texUnit->TexGenEnabled == newenabled) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->TexGenEnabled = newenabled; + } + } break; - } - case GL_TEXTURE_GEN_T: { - GLuint unit = ctx->Texture.CurrentUnit; - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - GLuint newenabled = texUnit->TexGenEnabled & ~T_BIT; - if (state) - newenabled |= T_BIT; - if (texUnit->TexGenEnabled == newenabled) - return; - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texUnit->TexGenEnabled = newenabled; + case GL_TEXTURE_GEN_T: + { + struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); + if (texUnit) { + GLuint newenabled = texUnit->TexGenEnabled & ~T_BIT; + if (state) + newenabled |= T_BIT; + if (texUnit->TexGenEnabled == newenabled) + return; + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + texUnit->TexGenEnabled = newenabled; + } + } break; - } /* * CLIENT STATE!!! @@ -1155,28 +1183,36 @@ _mesa_IsEnabled( GLenum cap ) return is_texture_enabled(ctx, TEXTURE_3D_BIT); case GL_TEXTURE_GEN_Q: { - const struct gl_texture_unit *texUnit; - texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE; + const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); + if (texUnit) { + return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE; + } } + return GL_FALSE; case GL_TEXTURE_GEN_R: { - const struct gl_texture_unit *texUnit; - texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE; + const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); + if (texUnit) { + return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE; + } } + return GL_FALSE; case GL_TEXTURE_GEN_S: { - const struct gl_texture_unit *texUnit; - texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE; + const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); + if (texUnit) { + return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE; + } } + return GL_FALSE; case GL_TEXTURE_GEN_T: { - const struct gl_texture_unit *texUnit; - texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE; + const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); + if (texUnit) { + return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE; + } } + return GL_FALSE; /* * CLIENT STATE!!! diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c index ec0a5e3896d..d70b78f2586 100644 --- a/src/mesa/main/ffvertex_prog.c +++ b/src/mesa/main/ffvertex_prog.c @@ -26,7 +26,7 @@ **************************************************************************/ /** - * \file ffvertex_prog. + * \file ffvertex_prog.c * * Create a vertex program to execute the current fixed function T&L pipeline. * \author Keith Whitwell @@ -101,6 +101,7 @@ static GLuint translate_fog_mode( GLenum mode ) } } + #define TXG_NONE 0 #define TXG_OBJ_LINEAR 1 #define TXG_EYE_LINEAR 2 @@ -145,6 +146,7 @@ tnl_get_per_vertex_materials(GLcontext *ctx) return mask; } + /** * Should fog be computed per-vertex? */ @@ -159,6 +161,7 @@ tnl_get_per_vertex_fog(GLcontext *ctx) #endif } + static GLboolean check_active_shininess( GLcontext *ctx, const struct state_key *key, GLuint side ) @@ -176,8 +179,6 @@ static GLboolean check_active_shininess( GLcontext *ctx, return GL_FALSE; } - - static void make_state_key( GLcontext *ctx, struct state_key *key ) @@ -278,7 +279,7 @@ static void make_state_key( GLcontext *ctx, struct state_key *key ) ctx->Texture._EnabledUnits) key->texture_enabled_global = 1; - for (i = 0; i < MAX_TEXTURE_UNITS; i++) { + for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) { struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i]; if (texUnit->_ReallyEnabled) @@ -410,11 +411,13 @@ static struct ureg swizzle( struct ureg reg, int x, int y, int z, int w ) return reg; } + static struct ureg swizzle1( struct ureg reg, int x ) { return swizzle(reg, x, x, x, x); } + static struct ureg get_temp( struct tnl_program *p ) { int bit = _mesa_ffs( ~p->temp_in_use ); @@ -430,6 +433,7 @@ static struct ureg get_temp( struct tnl_program *p ) return make_ureg(PROGRAM_TEMPORARY, bit-1); } + static struct ureg reserve_temp( struct tnl_program *p ) { struct ureg temp = get_temp( p ); @@ -437,6 +441,7 @@ static struct ureg reserve_temp( struct tnl_program *p ) return temp; } + static void release_temp( struct tnl_program *p, struct ureg reg ) { if (reg.file == PROGRAM_TEMPORARY) { @@ -493,6 +498,7 @@ static struct ureg register_input( struct tnl_program *p, GLuint input ) } } + /** * \param input one of VERT_RESULT_x tokens. */ @@ -502,6 +508,7 @@ static struct ureg register_output( struct tnl_program *p, GLuint output ) return make_ureg(PROGRAM_OUTPUT, output); } + static struct ureg register_const4f( struct tnl_program *p, GLfloat s0, GLfloat s1, @@ -531,6 +538,7 @@ static GLboolean is_undef( struct ureg reg ) return reg.file == PROGRAM_UNDEFINED; } + static struct ureg get_identity_param( struct tnl_program *p ) { if (is_undef(p->identity)) @@ -571,6 +579,7 @@ static void emit_arg( struct prog_src_register *src, ASSERT(src->Index == reg.idx); } + static void emit_dst( struct prog_dst_register *dst, struct ureg reg, GLuint mask ) { @@ -586,6 +595,7 @@ static void emit_dst( struct prog_dst_register *dst, ASSERT(dst->Index == reg.idx); } + static void debug_insn( struct prog_instruction *inst, const char *fn, GLuint line ) { @@ -696,6 +706,7 @@ static void emit_matrix_transform_vec4( struct tnl_program *p, emit_op2(p, OPCODE_DP4, dest, WRITEMASK_W, src, mat[3]); } + /* This version is much easier to implement if writemasks are not * supported natively on the target or (like SSE), the target doesn't * have a clean/obvious dotproduct implementation. @@ -721,6 +732,7 @@ static void emit_transpose_matrix_transform_vec4( struct tnl_program *p, release_temp(p, tmp); } + static void emit_matrix_transform_vec3( struct tnl_program *p, struct ureg dest, const struct ureg *mat, @@ -748,6 +760,7 @@ static void emit_normalize_vec3( struct tnl_program *p, #endif } + static void emit_passthrough( struct tnl_program *p, GLuint input, GLuint output ) @@ -756,6 +769,7 @@ static void emit_passthrough( struct tnl_program *p, emit_op1(p, OPCODE_MOV, out, 0, register_input(p, input)); } + static struct ureg get_eye_position( struct tnl_program *p ) { if (is_undef(p->eye_position)) { @@ -803,7 +817,6 @@ static struct ureg get_eye_position_z( struct tnl_program *p ) } - static struct ureg get_eye_position_normalized( struct tnl_program *p ) { if (is_undef(p->eye_position_normalized)) { @@ -865,7 +878,6 @@ static struct ureg get_transformed_normal( struct tnl_program *p ) } - static void build_hpos( struct tnl_program *p ) { struct ureg pos = register_input( p, VERT_ATTRIB_POS ); @@ -891,7 +903,9 @@ static GLuint material_attrib( GLuint side, GLuint property ) side); } -/* Get a bitmask of which material values vary on a per-vertex basis. + +/** + * Get a bitmask of which material values vary on a per-vertex basis. */ static void set_material_flags( struct tnl_program *p ) { @@ -927,7 +941,9 @@ static struct ureg get_material( struct tnl_program *p, GLuint side, MAT_BIT_FRONT_AMBIENT | \ MAT_BIT_FRONT_DIFFUSE) << (side)) -/* Either return a precalculated constant value or emit code to + +/** + * Either return a precalculated constant value or emit code to * calculate these values dynamically in the case where material calls * are present between begin/end pairs. * @@ -970,6 +986,7 @@ static struct ureg get_lightprod( struct tnl_program *p, GLuint light, return register_param4(p, STATE_LIGHTPROD, light, side, property); } + static struct ureg calculate_light_attenuation( struct tnl_program *p, GLuint i, struct ureg VPpli, @@ -1226,7 +1243,6 @@ static void build_lighting( struct tnl_program *p ) struct ureg res0, res1; GLuint mask0, mask1; - if (count == nr_lights) { if (separate) { mask0 = WRITEMASK_XYZ; @@ -1247,7 +1263,6 @@ static void build_lighting( struct tnl_program *p ) res1 = _col1; } - if (!is_undef(att)) { /* light is attenuated by distance */ emit_op1(p, OPCODE_LIT, lit, 0, dots); @@ -1320,7 +1335,6 @@ static void build_lighting( struct tnl_program *p ) emit_op3(p, OPCODE_MAD, res0, mask0, swizzle1(lit,Y), diffuse, _bfc0); emit_op3(p, OPCODE_MAD, res1, mask1, swizzle1(lit,Z), specular, _bfc1); - /* restore negate flag for next lighting */ dots = negate(dots); @@ -1395,6 +1409,7 @@ static void build_fog( struct tnl_program *p ) emit_op1(p, useabs ? OPCODE_ABS : OPCODE_MOV, fog, WRITEMASK_X, input); } } + static void build_reflect_texgen( struct tnl_program *p, struct ureg dest, @@ -1414,6 +1429,7 @@ static void build_reflect_texgen( struct tnl_program *p, release_temp(p, tmp); } + static void build_sphere_texgen( struct tnl_program *p, struct ureg dest, GLuint writemask ) @@ -1461,7 +1477,7 @@ static void build_texture_transform( struct tnl_program *p ) { GLuint i, j; - for (i = 0; i < MAX_TEXTURE_UNITS; i++) { + for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) { if (!(p->state->fragprog_inputs_read & FRAG_BIT_TEX(i))) continue; @@ -1524,10 +1540,8 @@ static void build_texture_transform( struct tnl_program *p ) case TXG_NONE: copy_mask |= WRITEMASK_X << j; } - } - if (sphere_mask) { build_sphere_texgen(p, out_texgen, sphere_mask); } @@ -1610,6 +1624,7 @@ static void build_atten_pointsize( struct tnl_program *p ) release_temp(p, ut); } + /** * Emit constant point size. */ @@ -1620,6 +1635,7 @@ static void build_constant_pointsize( struct tnl_program *p ) emit_op1(p, OPCODE_MOV, out, WRITEMASK_X, state_size); } + /** * Pass-though per-vertex point size, from user's point size array. */ diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 2a48b7c5179..a17bf9c7b0c 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1,15 +1,9 @@ -/** - * \file mtypes.h - * Main Mesa data structures. - * - * Please try to mark derived values with a leading underscore ('_'). - */ - /* * Mesa 3-D graphics library * Version: 7.3 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 VMware, Inc. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -29,7 +23,12 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - +/** + * \file mtypes.h + * Main Mesa data structures. + * + * Please try to mark derived values with a leading underscore ('_'). + */ #ifndef TYPES_H #define TYPES_H @@ -641,7 +640,7 @@ struct gl_current_attrib GLfloat RasterColor[4]; GLfloat RasterSecondaryColor[4]; GLfloat RasterIndex; - GLfloat RasterTexCoords[MAX_TEXTURE_COORD_UNITS][4]; + GLfloat RasterTexCoords[MAX_TEXTURE_UNITS][4]; GLboolean RasterPosValid; /*@}*/ }; @@ -725,10 +724,10 @@ struct gl_enable_attrib GLboolean SampleCoverage; /* GL_ARB_multisample */ GLboolean SampleCoverageInvert; /* GL_ARB_multisample */ GLboolean RasterPositionUnclipped; /* GL_IBM_rasterpos_clip */ - GLuint Texture[MAX_TEXTURE_IMAGE_UNITS]; - GLuint TexGen[MAX_TEXTURE_COORD_UNITS]; + GLuint Texture[MAX_TEXTURE_UNITS]; + GLuint TexGen[MAX_TEXTURE_UNITS]; /* SGI_texture_color_table */ - GLboolean TextureColorTable[MAX_TEXTURE_IMAGE_UNITS]; + GLboolean TextureColorTable[MAX_TEXTURE_UNITS]; /* GL_ARB_vertex_program / GL_NV_vertex_program */ GLboolean VertexProgram; GLboolean VertexProgramPointSize; @@ -1071,7 +1070,7 @@ struct gl_point_attrib GLfloat Threshold; /**< GL_EXT_point_parameters */ GLboolean _Attenuated; /**< True if Params != [1, 0, 0] */ GLboolean PointSprite; /**< GL_NV/ARB_point_sprite */ - GLboolean CoordReplace[MAX_TEXTURE_COORD_UNITS]; /**< GL_ARB_point_sprite */ + GLboolean CoordReplace[MAX_TEXTURE_UNITS]; /**< GL_ARB_point_sprite */ GLenum SpriteRMode; /**< GL_NV_point_sprite (only!) */ GLenum SpriteOrigin; /**< GL_ARB_point_sprite */ }; @@ -1559,7 +1558,7 @@ struct gl_texture_attrib * name multitexture */ /**@{*/ - GLuint CurrentUnit; /**< Active texture unit */ + GLuint CurrentUnit; /**< Active texture unit [0, MaxTextureImageUnits-1] */ GLbitfield _EnabledUnits; /**< one bit set for each really-enabled unit */ GLbitfield _EnabledCoordUnits; /**< one bit per enabled coordinate unit */ GLbitfield _GenFlags; /**< for texgen */ @@ -1876,7 +1875,7 @@ struct gl_program GLbitfield OutputsWritten; /**< Bitmask of which output regs are written to */ GLbitfield InputFlags[MAX_PROGRAM_INPUTS]; /**< PROG_PARAM_BIT_x flags */ GLbitfield OutputFlags[MAX_PROGRAM_OUTPUTS]; /**< PROG_PARAM_BIT_x flags */ - GLbitfield TexturesUsed[MAX_TEXTURE_IMAGE_UNITS]; /**< TEXTURE_x_BIT bitmask */ + GLbitfield TexturesUsed[MAX_TEXTURE_UNITS]; /**< TEXTURE_x_BIT bitmask */ GLbitfield SamplersUsed; /**< Bitfield of which samplers are used */ GLbitfield ShadowSamplers; /**< Texture units used for shadow sampling. */ @@ -2473,9 +2472,9 @@ struct gl_constants GLint MaxTextureRectSize; /* GL_NV_texture_rectangle */ GLuint MaxTextureCoordUnits; GLuint MaxTextureImageUnits; - GLuint MaxTextureUnits; /* = MIN(CoordUnits, ImageUnits) */ - GLfloat MaxTextureMaxAnisotropy; /* GL_EXT_texture_filter_anisotropic */ - GLfloat MaxTextureLodBias; /* GL_EXT_texture_lod_bias */ + GLuint MaxTextureUnits; /**< = MIN(CoordUnits, ImageUnits) */ + GLfloat MaxTextureMaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */ + GLfloat MaxTextureLodBias; /**< GL_EXT_texture_lod_bias */ GLuint MaxArrayLockSize; GLint SubPixelBits; GLfloat MinPointSize, MaxPointSize; /* aliased */ @@ -2951,7 +2950,7 @@ struct __GLcontextRec struct gl_matrix_stack ModelviewMatrixStack; struct gl_matrix_stack ProjectionMatrixStack; struct gl_matrix_stack ColorMatrixStack; - struct gl_matrix_stack TextureMatrixStack[MAX_TEXTURE_COORD_UNITS]; + struct gl_matrix_stack TextureMatrixStack[MAX_TEXTURE_UNITS]; struct gl_matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES]; struct gl_matrix_stack *CurrentStack; /**< Points to one of the above stacks */ /*@}*/ diff --git a/src/mesa/main/points.c b/src/mesa/main/points.c index 1fe697033f1..4c8fc1f72e0 100644 --- a/src/mesa/main/points.c +++ b/src/mesa/main/points.c @@ -257,7 +257,7 @@ _mesa_init_point(GLcontext *ctx) ctx->Point.PointSprite = GL_FALSE; /* GL_ARB/NV_point_sprite */ ctx->Point.SpriteRMode = GL_ZERO; /* GL_NV_point_sprite (only!) */ ctx->Point.SpriteOrigin = GL_UPPER_LEFT; /* GL_ARB_point_sprite */ - for (i = 0; i < MAX_TEXTURE_UNITS; i++) { + for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) { ctx->Point.CoordReplace[i] = GL_FALSE; /* GL_ARB/NV_point_sprite */ } } diff --git a/src/mesa/main/rastpos.c b/src/mesa/main/rastpos.c index 9842172f460..9f309d6ab84 100644 --- a/src/mesa/main/rastpos.c +++ b/src/mesa/main/rastpos.c @@ -500,7 +500,7 @@ void _mesa_init_rastpos( GLcontext * ctx ) ASSIGN_4V( ctx->Current.RasterColor, 1.0, 1.0, 1.0, 1.0 ); ASSIGN_4V( ctx->Current.RasterSecondaryColor, 0.0, 0.0, 0.0, 1.0 ); ctx->Current.RasterIndex = 1.0; - for (i=0; i<MAX_TEXTURE_UNITS; i++) + for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) ASSIGN_4V( ctx->Current.RasterTexCoords[i], 0.0, 0.0, 0.0, 1.0 ); ctx->Current.RasterPosValid = GL_TRUE; } diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index bd33cb4e055..48abf51d890 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,7 +65,7 @@ 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) @@ -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; diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index f0193770412..29955d76cbe 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -81,7 +81,7 @@ _mesa_copy_texture_state( const GLcontext *src, GLcontext *dst ) dst->Texture.SharedPalette = src->Texture.SharedPalette; /* per-unit state */ - for (i = 0; i < src->Const.MaxTextureUnits; i++) { + for (i = 0; i < src->Const.MaxTextureImageUnits; i++) { dst->Texture.Unit[i].Enabled = src->Texture.Unit[i].Enabled; dst->Texture.Unit[i].EnvMode = src->Texture.Unit[i].EnvMode; COPY_4V(dst->Texture.Unit[i].EnvColor, src->Texture.Unit[i].EnvColor); @@ -307,8 +307,7 @@ _mesa_ActiveTextureARB(GLenum texture) _mesa_debug(ctx, "glActiveTexture %s\n", _mesa_lookup_enum_by_nr(texture)); - /* XXX error-check against max(coordunits, imageunits) */ - if (texUnit >= ctx->Const.MaxTextureUnits) { + if (texUnit >= ctx->Const.MaxTextureImageUnits) { _mesa_error(ctx, GL_INVALID_ENUM, "glActiveTexture(texture)"); return; } @@ -369,7 +368,7 @@ update_texture_matrices( GLcontext *ctx ) ctx->Texture._TexMatEnabled = 0; - for (i=0; i < ctx->Const.MaxTextureUnits; i++) { + for (i=0; i < ctx->Const.MaxTextureCoordUnits; i++) { if (_math_matrix_is_dirty(ctx->TextureMatrixStack[i].Top)) { _math_matrix_analyse( ctx->TextureMatrixStack[i].Top ); @@ -491,7 +490,7 @@ update_texture_state( GLcontext *ctx ) /* * Update texture unit state. */ - for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { + for (unit = 0; unit < ctx->Const.MaxTextureImageUnits; unit++) { struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; GLbitfield enableBits; @@ -621,7 +620,7 @@ update_texture_state( GLcontext *ctx ) } /* Setup texgen for those texture coordinate sets that are in use */ - for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { + for (unit = 0; unit < ctx->Const.MaxTextureCoordUnits; unit++) { struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; if (!(ctx->Texture._EnabledCoordUnits & (1 << unit))) |