summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRobert Ellison <[email protected]>2009-02-27 00:21:07 -0700
committerRobert Ellison <[email protected]>2009-02-27 10:11:37 -0700
commit17c7852bf93c4d4edf0c2cf0bdc553d399e2f51a (patch)
treea0f785f93d14db417db45937753f25b5a2b9e97a /src
parent026465b9b1aebab98b6d519b75fe96d0ca9f4f51 (diff)
i965: texture fixes: bordered textures, fallback rendering
i965 doesn't natively support GL_CLAMP; it treats it like GL_CLAMP_TO_EDGE, which fails conformance tests. This fix adds a clause to the check_fallbacks() test to check whether GL_CLAMP is in use on any enabled 2D texture. If so, and if strict conformance is required (via INTEL_STRICT_CONFORMANCE), a software fallback is mandated. In addition, validate textures *before* checking for fallbacks, rather than after; otherwise, the texture state is never validated and can't be trusted. (In particular, if texturing is enabled and the sampler would access any level beyond level 0 of a texture, the sampler will segfault, because texture validation sets the firstLevel and lastLevel fields of a texture object so that the valid levels will be mapped and accessed correctly. If texture validation doesn't occur, only level 0 is accessed correctly, and that only because firstLevel and lastLevel happen to be set to 0.)
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index 3ca953da37b..7ab1ece2630 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -194,6 +194,9 @@ static GLboolean check_fallbacks( struct brw_context *brw,
GLcontext *ctx = &brw->intel.ctx;
GLuint i;
+ /* If we don't require strict OpenGL conformance, never
+ * use fallbacks.
+ */
if (!brw->intel.strict_conformance)
return GL_FALSE;
@@ -230,13 +233,31 @@ static GLboolean check_fallbacks( struct brw_context *brw,
}
}
-
if (ctx->Point.SmoothFlag) {
for (i = 0; i < nr_prims; i++)
if (prim[i].mode == GL_POINTS)
return GL_TRUE;
}
+
+ /* BRW hardware doesn't handle GL_CLAMP texturing correctly;
+ * brw_wm_sampler_state:translate_wrap_mode() treats GL_CLAMP
+ * as GL_CLAMP_TO_EDGE instead. If we're using GL_CLAMP, and
+ * we want strict conformance, force the fallback.
+ * Right now, we only do this for 2D textures.
+ */
+ {
+ int u;
+ for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) {
+ if (ctx->Texture.Unit[u].Enabled) {
+ if (ctx->Texture.Unit[u].CurrentTex[TEXTURE_2D_INDEX]->WrapS == GL_CLAMP ||
+ ctx->Texture.Unit[u].CurrentTex[TEXTURE_2D_INDEX]->WrapT == GL_CLAMP) {
+ return GL_TRUE;
+ }
+ }
+ }
+ }
+ /* Nothing stopping us from the fast path now */
return GL_FALSE;
}
@@ -261,11 +282,18 @@ static GLboolean brw_try_draw_prims( GLcontext *ctx,
if (ctx->NewState)
_mesa_update_state( ctx );
+ /* We have to validate the textures *before* checking for fallbacks;
+ * otherwise, the software fallback won't be able to rely on the
+ * texture state, the firstLevel and lastLevel fields won't be
+ * set in the intel texture object (they'll both be 0), and the
+ * software fallback will segfault if it attempts to access any
+ * texture level other than level 0.
+ */
+ brw_validate_textures( brw );
+
if (check_fallbacks(brw, prim, nr_prims))
return GL_FALSE;
- brw_validate_textures( brw );
-
/* Bind all inputs, derive varying and size information:
*/
brw_merge_inputs( brw, arrays );