#include "texstate.h"
#include "texenvprogram.h"
#include "mtypes.h"
-#include "math/m_xform.h"\r
+#include "math/m_xform.h"
#include "shaderobjects.h"
}
}
}
-\r
-\r
-static void\r
-texture_override( struct gl_texture_object *texObj, GLuint textureBit, GLcontext *ctx,\r
- GLbitfield enableBits, struct gl_texture_unit *texUnit )\r
-{\r
- if (!texUnit->_ReallyEnabled && (enableBits & textureBit)) {\r
- if (!texObj->Complete) {\r
- _mesa_test_texobj_completeness(ctx, texObj);\r
- }\r
- if (texObj->Complete) {\r
- texUnit->_ReallyEnabled = textureBit;\r
- texUnit->_Current = texObj;\r
- }\r
- }\r
+
+
+/**
+ * Helper function for determining which texture object (1D, 2D, cube, etc)
+ * should actually be used.
+ */
+static void
+texture_override(GLcontext *ctx,
+ struct gl_texture_unit *texUnit, GLbitfield enableBits,
+ struct gl_texture_object *texObj, GLuint textureBit)
+{
+ if (!texUnit->_ReallyEnabled && (enableBits & textureBit)) {
+ if (!texObj->Complete) {
+ _mesa_test_texobj_completeness(ctx, texObj);
+ }
+ if (texObj->Complete) {
+ texUnit->_ReallyEnabled = textureBit;
+ texUnit->_Current = texObj;
+ }
+ }
}
+
/**
* \note This routine refers to derived texture matrix values to
* compute the ENABLE_TEXMAT flags, but is only called on
static void
update_texture_state( GLcontext *ctx )
{
- GLuint unit;\r
- struct gl2_program_intf **prog = ctx->ShaderObjects.CurrentProgram;\r
- GLbitfield progteximageusage[MAX_TEXTURE_IMAGE_UNITS];\r
+ GLuint unit;
+ struct gl2_program_intf **prog = ctx->ShaderObjects.CurrentProgram;
+ GLbitfield progteximageusage[MAX_TEXTURE_IMAGE_UNITS];
ctx->NewState |= _NEW_TEXTURE; /* TODO: only set this if there are
* actual changes.
ctx->Texture._EnabledUnits = 0;
ctx->Texture._GenFlags = 0;
ctx->Texture._TexMatEnabled = 0;
- ctx->Texture._TexGenEnabled = 0;\r
-\r
- /*\r
- * Grab texture image usage state from shader program. It must be grabbed every time\r
- * uniform sampler changes, so maybe there is a better place to perform these rather\r
- * expensive computations.\r
- */\r
- if (ctx->ShaderObjects._FragmentShaderPresent) {\r
- (**prog).GetTextureImageUsage (prog, progteximageusage);\r
+ ctx->Texture._TexGenEnabled = 0;
+
+ /*
+ * Grab texture image usage state from shader program. It must be
+ * grabbed every time uniform sampler changes, so maybe there is a
+ * better place to perform these rather expensive computations.
+ */
+ if (ctx->ShaderObjects._FragmentShaderPresent) {
+ (**prog).GetTextureImageUsage (prog, progteximageusage);
}
- /* Update texture unit state.
- * XXX this loop should probably be broken into separate loops for
- * texture coord units and texture image units.
+ /*
+ * Update texture unit state.
*/
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
texUnit->_ReallyEnabled = 0;
texUnit->_GenFlags = 0;
- /* Get the bitmask of texture enables */\r
- if (ctx->ShaderObjects._FragmentShaderPresent) {\r
+ /* Get the bitmask of texture enables */
+ if (ctx->ShaderObjects._FragmentShaderPresent) {
enableBits = progteximageusage[unit];
- }\r
+ }
else if (ctx->FragmentProgram._Enabled) {
enableBits = ctx->FragmentProgram.Current->TexturesUsed[unit];
}
/* Look for the highest-priority texture target that's enabled and
* complete. That's the one we'll use for texturing. If we're using
* a fragment program we're guaranteed that bitcount(enabledBits) <= 1.
- */\r
- texture_override(texUnit->CurrentCubeMap, TEXTURE_CUBE_BIT, ctx, enableBits, texUnit);\r
- texture_override(texUnit->Current3D, TEXTURE_3D_BIT, ctx, enableBits, texUnit);
- texture_override(texUnit->CurrentRect, TEXTURE_RECT_BIT, ctx, enableBits, texUnit);\r
- texture_override(texUnit->Current2D, TEXTURE_2D_BIT, ctx, enableBits, texUnit);
- texture_override(texUnit->Current1D, TEXTURE_1D_BIT, ctx, enableBits, texUnit);
+ */
+ texture_override(ctx, texUnit, enableBits,
+ texUnit->CurrentCubeMap, TEXTURE_CUBE_BIT);
+ texture_override(ctx, texUnit, enableBits,
+ texUnit->Current3D, TEXTURE_3D_BIT);
+ texture_override(ctx, texUnit, enableBits,
+ texUnit->CurrentRect, TEXTURE_RECT_BIT);
+ texture_override(ctx, texUnit, enableBits,
+ texUnit->Current2D, TEXTURE_2D_BIT);
+ texture_override(ctx, texUnit, enableBits,
+ texUnit->Current1D, TEXTURE_1D_BIT);
if (!texUnit->_ReallyEnabled) {
continue;
texUnit->_CurrentCombine = & texUnit->Combine;
}
else {
- GLenum format = texUnit->_Current->Image[0][0]->_BaseFormat;
+ const struct gl_texture_object *texObj = texUnit->_Current;
+ GLenum format = texObj->Image[0][texObj->BaseLevel]->_BaseFormat;
if (format == GL_COLOR_INDEX) {
format = GL_RGBA; /* a bit of a hack */
}
else if (format == GL_DEPTH_COMPONENT
|| format == GL_DEPTH_STENCIL_EXT) {
- format = texUnit->_Current->DepthMode;
+ format = texObj->DepthMode;
}
calculate_derived_texenv(&texUnit->_EnvMode, texUnit->EnvMode, format);
texUnit->_CurrentCombine = & texUnit->_EnvMode;
ctx->Texture._EnabledCoordUnits = ctx->Texture._EnabledUnits;
/* Fragment programs may need texture coordinates but not the
* corresponding texture images.
- */\r
- if (ctx->ShaderObjects.CurrentProgram != NULL) {\r
- ctx->Texture._EnabledCoordUnits |= (1 << ctx->Const.MaxTextureCoordUnits) - 1;\r
+ */
+ if (ctx->ShaderObjects.CurrentProgram != NULL) {
+ ctx->Texture._EnabledCoordUnits |= (1 << ctx->Const.MaxTextureCoordUnits) - 1;
}
else if (ctx->FragmentProgram._Enabled) {
ctx->Texture._EnabledCoordUnits |=