summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2006-01-26 04:05:53 +0000
committerBrian Paul <[email protected]>2006-01-26 04:05:53 +0000
commit398cb30c72cbc44723801d3e87b6b8571dfdebac (patch)
treef5300db42fa6ecea064414519d89ef7f09f9ab65
parentf67bb30314cfb6067230290f21328427124a9900 (diff)
Added _swrast_validate_texture_images() to make sure all textures have
data resident for software rasterization. Relies on new swrast driver function: ValidateTextureImage()
-rw-r--r--src/mesa/swrast/s_context.c42
-rw-r--r--src/mesa/swrast/s_context.h7
2 files changed, 49 insertions, 0 deletions
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index 9d283b0589e..a1fb2d27f22 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -368,6 +368,45 @@ _swrast_validate_blend_func( GLcontext *ctx, GLuint n,
}
+/**
+ * Make sure we have texture image data for all the textures we may need
+ * for subsequent rendering.
+ */
+static void
+_swrast_validate_texture_images(GLcontext *ctx)
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLuint u;
+
+ if (!swrast->ValidateTextureImage || !ctx->Texture._EnabledUnits) {
+ /* no textures enabled, or no way to validate images! */
+ return;
+ }
+
+ for (u = 0; u < ctx->Const.MaxTextureImageUnits; u++) {
+ if (ctx->Texture.Unit[u]._ReallyEnabled) {
+ struct gl_texture_object *texObj = ctx->Texture.Unit[u]._Current;
+ ASSERT(texObj);
+ if (texObj) {
+ GLuint numFaces = (texObj->Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
+ GLuint face;
+ for (face = 0; face < numFaces; face++) {
+ GLuint lvl;
+ for (lvl = texObj->BaseLevel; lvl <= texObj->_MaxLevel; lvl++) {
+ struct gl_texture_image *texImg = texObj->Image[face][lvl];
+ if (texImg && !texImg->Data) {
+ swrast->ValidateTextureImage(ctx, texObj, face, lvl);
+ ASSERT(texObj->Image[face][lvl]->Data);
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+
+
static void
_swrast_sleep( GLcontext *ctx, GLbitfield new_state )
{
@@ -452,6 +491,9 @@ _swrast_validate_derived( GLcontext *ctx )
if (swrast->NewState & _NEW_TEXTURE)
_swrast_update_texture_samplers( ctx );
+ if (swrast->NewState & (_NEW_TEXTURE | _NEW_PROGRAM))
+ _swrast_validate_texture_images( ctx );
+
swrast->NewState = 0;
swrast->StateChanges = 0;
swrast->InvalidateState = _swrast_invalidate_state;
diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h
index 5cfe7627a5d..821faa62812 100644
--- a/src/mesa/swrast/s_context.h
+++ b/src/mesa/swrast/s_context.h
@@ -226,6 +226,11 @@ typedef void (*swrast_tri_func)( GLcontext *ctx, const SWvertex *,
const SWvertex *, const SWvertex *);
+typedef void (*validate_texture_image_func)(GLcontext *ctx,
+ struct gl_texture_object *texObj,
+ GLuint face, GLuint level);
+
+
/** \defgroup Bitmasks
* Bitmasks to indicate which rasterization options are enabled
* (RasterMask)
@@ -354,6 +359,8 @@ typedef struct
*/
GLchan *TexelBuffer;
+ validate_texture_image_func ValidateTextureImage;
+
} SWcontext;