summaryrefslogtreecommitdiff
path: root/src/mesa/main/texstate.c
diff options
context:
space:
mode:
authorMichal Krol <mjkrol@gmail.org>2006-03-14 11:23:16 +0000
committerMichal Krol <mjkrol@gmail.org>2006-03-14 11:23:16 +0000
commit8af48fc4d62798dbcc00bcfbbd8bc8f3b47982c7 (patch)
treed663fe97399b7564f5f8e21b6a3f695c004babc8 /src/mesa/main/texstate.c
parente9484e40858ffd4474571b27136e7ea0f2b682db (diff)
More GLSL code:
- add texture sampling support; - fix assembly codegen bugs;
Diffstat (limited to 'src/mesa/main/texstate.c')
-rw-r--r--src/mesa/main/texstate.c107
1 files changed, 44 insertions, 63 deletions
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 428d0a0d01..a8cb8a7bcf 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -39,7 +39,8 @@
#include "texstate.h"
#include "texenvprogram.h"
#include "mtypes.h"
-#include "math/m_xform.h"
+#include "math/m_xform.h"
+#include "shaderobjects.h"
@@ -2765,7 +2766,22 @@ update_texture_matrices( GLcontext *ctx )
}
}
}
-
+
+
+static void
+texture_override( struct gl_texture_object *texObj, GLuint textureBit, GLcontext *ctx,
+ GLbitfield enableBits, struct gl_texture_unit *texUnit )
+{
+ 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
@@ -2778,7 +2794,9 @@ update_texture_matrices( GLcontext *ctx )
static void
update_texture_state( GLcontext *ctx )
{
- GLuint unit;
+ 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.
@@ -2787,7 +2805,16 @@ update_texture_state( GLcontext *ctx )
ctx->Texture._EnabledUnits = 0;
ctx->Texture._GenFlags = 0;
ctx->Texture._TexMatEnabled = 0;
- ctx->Texture._TexGenEnabled = 0;
+ 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 (prog != NULL) {
+ (**prog).GetTextureImageUsage (prog, progteximageusage);
+ }
/* Update texture unit state.
* XXX this loop should probably be broken into separate loops for
@@ -2801,8 +2828,11 @@ update_texture_state( GLcontext *ctx )
texUnit->_ReallyEnabled = 0;
texUnit->_GenFlags = 0;
- /* Get the bitmask of texture enables */
- if (ctx->FragmentProgram._Enabled) {
+ /* Get the bitmask of texture enables */
+ if (prog != NULL) {
+ enableBits = progteximageusage[unit];
+ }
+ else if (ctx->FragmentProgram._Enabled) {
enableBits = ctx->FragmentProgram.Current->TexturesUsed[unit];
}
else {
@@ -2814,61 +2844,12 @@ update_texture_state( GLcontext *ctx )
/* 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.
- */
- if (enableBits & TEXTURE_CUBE_BIT) {
- struct gl_texture_object *texObj = texUnit->CurrentCubeMap;
- if (!texObj->Complete) {
- _mesa_test_texobj_completeness(ctx, texObj);
- }
- if (texObj->Complete) {
- texUnit->_ReallyEnabled = TEXTURE_CUBE_BIT;
- texUnit->_Current = texObj;
- }
- }
-
- if (!texUnit->_ReallyEnabled && (enableBits & TEXTURE_3D_BIT)) {
- struct gl_texture_object *texObj = texUnit->Current3D;
- if (!texObj->Complete) {
- _mesa_test_texobj_completeness(ctx, texObj);
- }
- if (texObj->Complete) {
- texUnit->_ReallyEnabled = TEXTURE_3D_BIT;
- texUnit->_Current = texObj;
- }
- }
-
- if (!texUnit->_ReallyEnabled && (enableBits & TEXTURE_RECT_BIT)) {
- struct gl_texture_object *texObj = texUnit->CurrentRect;
- if (!texObj->Complete) {
- _mesa_test_texobj_completeness(ctx, texObj);
- }
- if (texObj->Complete) {
- texUnit->_ReallyEnabled = TEXTURE_RECT_BIT;
- texUnit->_Current = texObj;
- }
- }
-
- if (!texUnit->_ReallyEnabled && (enableBits & TEXTURE_2D_BIT)) {
- struct gl_texture_object *texObj = texUnit->Current2D;
- if (!texObj->Complete) {
- _mesa_test_texobj_completeness(ctx, texObj);
- }
- if (texObj->Complete) {
- texUnit->_ReallyEnabled = TEXTURE_2D_BIT;
- texUnit->_Current = texObj;
- }
- }
-
- if (!texUnit->_ReallyEnabled && (enableBits & TEXTURE_1D_BIT)) {
- struct gl_texture_object *texObj = texUnit->Current1D;
- if (!texObj->Complete) {
- _mesa_test_texobj_completeness(ctx, texObj);
- }
- if (texObj->Complete) {
- texUnit->_ReallyEnabled = TEXTURE_1D_BIT;
- texUnit->_Current = texObj;
- }
- }
+ */
+ texture_override(texUnit->CurrentCubeMap, TEXTURE_CUBE_BIT, ctx, enableBits, texUnit);
+ texture_override(texUnit->Current3D, TEXTURE_3D_BIT, ctx, enableBits, texUnit);
+ texture_override(texUnit->CurrentRect, TEXTURE_RECT_BIT, ctx, enableBits, texUnit);
+ texture_override(texUnit->Current2D, TEXTURE_2D_BIT, ctx, enableBits, texUnit);
+ texture_override(texUnit->Current1D, TEXTURE_1D_BIT, ctx, enableBits, texUnit);
if (!texUnit->_ReallyEnabled) {
continue;
@@ -2967,8 +2948,8 @@ update_texture_state( GLcontext *ctx )
/* Fragment programs may need texture coordinates but not the
* corresponding texture images.
*/
- if (ctx->ShaderObjects.CurrentProgram != NULL) {
- ctx->Texture._EnabledCoordUnits |= (1 << 8) - 1;
+ if (prog != NULL) {
+ ctx->Texture._EnabledCoordUnits |= (1 << ctx->Const.MaxTextureCoordUnits) - 1;
}
else if (ctx->FragmentProgram._Enabled) {
ctx->Texture._EnabledCoordUnits |=