From dde7cb962860e72e1bf3175069767358cc5b3f3c Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 9 Jan 2009 15:43:17 -0800 Subject: Track two sets of back-face stencil state Track separate back-face stencil state for OpenGL 2.0 / GL_ATI_separate_stencil and GL_EXT_stencil_two_side. This allows all three to be enabled in a driver. One set of state is set via the 2.0 or ATI functions and is used when STENCIL_TEST_TWO_SIDE_EXT is disabled. The other is set by StencilFunc and StencilOp when the active stencil face is set to BACK. The GL_EXT_stencil_two_side spec has more details. http://opengl.org/registry/specs/EXT/stencil_two_side.txt --- src/mesa/swrast/s_stencil.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/mesa/swrast') diff --git a/src/mesa/swrast/s_stencil.c b/src/mesa/swrast/s_stencil.c index c925922463e..2e84ddec71f 100644 --- a/src/mesa/swrast/s_stencil.c +++ b/src/mesa/swrast/s_stencil.c @@ -997,10 +997,12 @@ stencil_and_ztest_pixels( GLcontext *ctx, SWspan *span, GLuint face ) GLboolean _swrast_stencil_and_ztest_span(GLcontext *ctx, SWspan *span) { + const GLuint face = (span->facing == 0) ? 0 : ctx->Stencil._BackFace; + if (span->arrayMask & SPAN_XY) - return stencil_and_ztest_pixels(ctx, span, span->facing); + return stencil_and_ztest_pixels(ctx, span, face); else - return stencil_and_ztest_span(ctx, span, span->facing); + return stencil_and_ztest_span(ctx, span, face); } -- cgit v1.2.3 From 2d508c1d5c53dc475e5262593dd4dac5575a6b08 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 23 Jan 2009 17:30:54 -0700 Subject: swrast: updates for GL_NV_texture_env_combine4 --- src/mesa/swrast/s_texcombine.c | 131 ++++++++++++++++++++++++++++++++++++----- src/mesa/swrast/s_triangle.c | 3 +- 2 files changed, 117 insertions(+), 17 deletions(-) (limited to 'src/mesa/swrast') diff --git a/src/mesa/swrast/s_texcombine.c b/src/mesa/swrast/s_texcombine.c index 632d650007e..df6efad66c1 100644 --- a/src/mesa/swrast/s_texcombine.c +++ b/src/mesa/swrast/s_texcombine.c @@ -1,8 +1,9 @@ /* * Mesa 3-D graphics library - * Version: 6.5.1 + * Version: 7.5 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * 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"), @@ -66,9 +67,9 @@ texture_combine( const GLcontext *ctx, GLuint unit, GLuint n, GLchan (*rgba)[4] ) { const struct gl_texture_unit *textureUnit = &(ctx->Texture.Unit[unit]); - const GLchan (*argRGB [3])[4]; - const GLchan (*argA [3])[4]; - const GLuint RGBshift = textureUnit->_CurrentCombine->ScaleShiftRGB; + const GLchan (*argRGB [4])[4]; + const GLchan (*argA [4])[4]; + const GLint RGBshift = textureUnit->_CurrentCombine->ScaleShiftRGB; const GLuint Ashift = textureUnit->_CurrentCombine->ScaleShiftA; #if CHAN_TYPE == GL_FLOAT const GLchan RGBmult = (GLfloat) (1 << RGBshift); @@ -80,7 +81,7 @@ texture_combine( const GLcontext *ctx, GLuint unit, GLuint n, static const GLchan zero[4] = { 0, 0, 0, 0 }; const GLuint numColorArgs = textureUnit->_CurrentCombine->_NumArgsRGB; const GLuint numAlphaArgs = textureUnit->_CurrentCombine->_NumArgsA; - GLchan ccolor[3][MAX_WIDTH][4]; + GLchan ccolor[4][MAX_WIDTH][4]; GLuint i, j; ASSERT(ctx->Extensions.EXT_texture_env_combine || @@ -98,7 +99,7 @@ texture_combine( const GLcontext *ctx, GLuint unit, GLuint n, */ /* - * Do operand setup for up to 3 operands. Loop over the terms. + * Do operand setup for up to 4 operands. Loop over the terms. */ for (j = 0; j < numColorArgs; j++) { const GLenum srcRGB = textureUnit->_CurrentCombine->SourceRGB[j]; @@ -295,7 +296,36 @@ texture_combine( const GLcontext *ctx, GLuint unit, GLuint n, } break; case GL_ADD: - { + if (textureUnit->EnvMode == GL_COMBINE4_NV) { + /* (a * b) + (c * d) */ + const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0]; + const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1]; + const GLchan (*arg2)[4] = (const GLchan (*)[4]) argRGB[2]; + const GLchan (*arg3)[4] = (const GLchan (*)[4]) argRGB[3]; + for (i = 0; i < n; i++) { +#if CHAN_TYPE == GL_FLOAT + rgba[i][RCOMP] = (arg0[i][RCOMP] * arg1[i][RCOMP] + + arg2[i][RCOMP] * arg3[i][RCOMP]) * RGBmult; + rgba[i][GCOMP] = (arg0[i][GCOMP] * arg1[i][GCOMP] + + arg2[i][GCOMP] * arg3[i][GCOMP]) * RGBmult; + rgba[i][BCOMP] = (arg0[i][BCOMP] * arg1[i][BCOMP] + + arg2[i][BCOMP] * arg3[i][BCOMP]) * RGBmult; +#else + const GLint shift = CHAN_BITS - RGBshift; + GLint r = (PROD(arg0[i][RCOMP], arg1[i][RCOMP]) >> shift) + + (PROD(arg2[i][RCOMP], arg3[i][RCOMP]) >> shift); + GLint g = (PROD(arg0[i][GCOMP], arg1[i][GCOMP]) >> shift) + + (PROD(arg2[i][GCOMP], arg3[i][GCOMP]) >> shift); + GLint b = (PROD(arg0[i][BCOMP], arg1[i][BCOMP]) >> shift) + + (PROD(arg2[i][BCOMP], arg3[i][BCOMP]) >> shift); + rgba[i][RCOMP] = (GLchan) MIN2(r, CHAN_MAX); + rgba[i][GCOMP] = (GLchan) MIN2(g, CHAN_MAX); + rgba[i][BCOMP] = (GLchan) MIN2(b, CHAN_MAX); +#endif + } + } + else { + /* 2-term addition */ const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0]; const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1]; for (i = 0; i < n; i++) { @@ -315,7 +345,37 @@ texture_combine( const GLcontext *ctx, GLuint unit, GLuint n, } break; case GL_ADD_SIGNED: - { + if (textureUnit->EnvMode == GL_COMBINE4_NV) { + /* (a * b) + (c * d) - 0.5 */ + const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0]; + const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1]; + const GLchan (*arg2)[4] = (const GLchan (*)[4]) argRGB[2]; + const GLchan (*arg3)[4] = (const GLchan (*)[4]) argRGB[3]; + for (i = 0; i < n; i++) { +#if CHAN_TYPE == GL_FLOAT + rgba[i][RCOMP] = (arg0[i][RCOMP] + arg1[i][RCOMP] * + arg2[i][RCOMP] + arg3[i][RCOMP] - 0.5) * RGBmult; + rgba[i][GCOMP] = (arg0[i][GCOMP] + arg1[i][GCOMP] * + arg2[i][GCOMP] + arg3[i][GCOMP] - 0.5) * RGBmult; + rgba[i][BCOMP] = (arg0[i][BCOMP] + arg1[i][BCOMP] * + arg2[i][BCOMP] + arg3[i][BCOMP] - 0.5) * RGBmult; +#else + GLint r = (((PROD(arg0[i][RCOMP], arg1[i][RCOMP]) + + PROD(arg2[i][RCOMP], arg3[i][RCOMP])) >> CHAN_BITS) - half) + << RGBshift; + GLint g = (((PROD(arg0[i][GCOMP], arg1[i][GCOMP]) + + PROD(arg2[i][GCOMP], arg3[i][GCOMP])) >> CHAN_BITS) - half) + << RGBshift; + GLint b = (((PROD(arg0[i][BCOMP], arg1[i][BCOMP]) + + PROD(arg2[i][BCOMP], arg3[i][BCOMP])) >> CHAN_BITS) - half) + << RGBshift; + rgba[i][RCOMP] = (GLchan) CLAMP(r, 0, CHAN_MAX); + rgba[i][GCOMP] = (GLchan) CLAMP(g, 0, CHAN_MAX); + rgba[i][BCOMP] = (GLchan) CLAMP(b, 0, CHAN_MAX); +#endif + } + } + else { const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0]; const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1]; for (i = 0; i < n; i++) { @@ -324,9 +384,9 @@ texture_combine( const GLcontext *ctx, GLuint unit, GLuint n, rgba[i][GCOMP] = (arg0[i][GCOMP] + arg1[i][GCOMP] - 0.5) * RGBmult; rgba[i][BCOMP] = (arg0[i][BCOMP] + arg1[i][BCOMP] - 0.5) * RGBmult; #else - GLint r = (GLint) arg0[i][RCOMP] + (GLint) arg1[i][RCOMP] -half; - GLint g = (GLint) arg0[i][GCOMP] + (GLint) arg1[i][GCOMP] -half; - GLint b = (GLint) arg0[i][BCOMP] + (GLint) arg1[i][BCOMP] -half; + GLint r = (GLint) arg0[i][RCOMP] + (GLint) arg1[i][RCOMP] - half; + GLint g = (GLint) arg0[i][GCOMP] + (GLint) arg1[i][GCOMP] - half; + GLint b = (GLint) arg0[i][BCOMP] + (GLint) arg1[i][BCOMP] - half; r = (r < 0) ? 0 : r << RGBshift; g = (g < 0) ? 0 : g << RGBshift; b = (b < 0) ? 0 : b << RGBshift; @@ -573,9 +633,28 @@ texture_combine( const GLcontext *ctx, GLuint unit, GLuint n, } break; case GL_ADD: - { + if (textureUnit->EnvMode == GL_COMBINE4_NV) { + /* (a * b) + (c * d) */ + const GLchan (*arg0)[4] = (const GLchan (*)[4]) argA[0]; + const GLchan (*arg1)[4] = (const GLchan (*)[4]) argA[1]; + const GLchan (*arg2)[4] = (const GLchan (*)[4]) argA[2]; + const GLchan (*arg3)[4] = (const GLchan (*)[4]) argA[3]; + for (i = 0; i < n; i++) { +#if CHAN_TYPE == GL_FLOAT + rgba[i][ACOMP] = (arg0[i][ACOMP] * arg1[i][ACOMP] + + arg2[i][ACOMP] * arg3[i][ACOMP]) * Amult; +#else + const GLint shift = CHAN_BITS - Ashift; + GLint a = (PROD(arg0[i][ACOMP], arg1[i][ACOMP]) >> shift) + + (PROD(arg2[i][ACOMP], arg3[i][ACOMP]) >> shift); + rgba[i][ACOMP] = (GLchan) MIN2(a, CHAN_MAX); +#endif + } + } + else { + /* two-term add */ const GLchan (*arg0)[4] = (const GLchan (*)[4]) argA[0]; - const GLchan (*arg1)[4] = (const GLchan (*)[4]) argA[1]; + const GLchan (*arg1)[4] = (const GLchan (*)[4]) argA[1]; for (i = 0; i < n; i++) { #if CHAN_TYPE == GL_FLOAT rgba[i][ACOMP] = (arg0[i][ACOMP] + arg1[i][ACOMP]) * Amult; @@ -587,7 +666,27 @@ texture_combine( const GLcontext *ctx, GLuint unit, GLuint n, } break; case GL_ADD_SIGNED: - { + if (textureUnit->EnvMode == GL_COMBINE4_NV) { + /* (a * b) + (c * d) - 0.5 */ + const GLchan (*arg0)[4] = (const GLchan (*)[4]) argA[0]; + const GLchan (*arg1)[4] = (const GLchan (*)[4]) argA[1]; + const GLchan (*arg2)[4] = (const GLchan (*)[4]) argA[2]; + const GLchan (*arg3)[4] = (const GLchan (*)[4]) argA[3]; + for (i = 0; i < n; i++) { +#if CHAN_TYPE == GL_FLOAT + rgba[i][ACOMP] = (arg0[i][ACOMP] * arg1[i][ACOMP] + + arg2[i][ACOMP] * arg3[i][ACOMP] - + 0.5) * Amult; +#else + GLint a = (((PROD(arg0[i][ACOMP], arg1[i][ACOMP]) + + PROD(arg2[i][ACOMP], arg3[i][ACOMP])) >> CHAN_BITS) - half) + << Ashift; + rgba[i][ACOMP] = (GLchan) CLAMP(a, 0, CHAN_MAX); +#endif + } + } + else { + /* a + b - 0.5 */ const GLchan (*arg0)[4] = (const GLchan (*)[4]) argA[0]; const GLchan (*arg1)[4] = (const GLchan (*)[4]) argA[1]; for (i = 0; i < n; i++) { @@ -596,7 +695,7 @@ texture_combine( const GLcontext *ctx, GLuint unit, GLuint n, #else GLint a = (GLint) arg0[i][ACOMP] + (GLint) arg1[i][ACOMP] -half; a = (a < 0) ? 0 : a << Ashift; - rgba[i][ACOMP] = (GLchan) MIN2(a, CHAN_MAX); + rgba[i][ACOMP] = (GLchan) CLAMP(a, 0, CHAN_MAX); #endif } } diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c index a2e8433e271..5d232487f30 100644 --- a/src/mesa/swrast/s_triangle.c +++ b/src/mesa/swrast/s_triangle.c @@ -1070,7 +1070,8 @@ _swrast_choose_triangle( GLcontext *ctx ) && minFilter == magFilter && ctx->Light.Model.ColorControl == GL_SINGLE_COLOR && !swrast->_FogEnabled - && ctx->Texture.Unit[0].EnvMode != GL_COMBINE_EXT) { + && ctx->Texture.Unit[0].EnvMode != GL_COMBINE_EXT + && ctx->Texture.Unit[0].EnvMode != GL_COMBINE4_NV) { if (ctx->Hint.PerspectiveCorrection==GL_FASTEST) { if (minFilter == GL_NEAREST && format == MESA_FORMAT_RGB -- cgit v1.2.3 From be1a76f88f4c3482e61e0a048a0b28b6b628f223 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 28 Jan 2009 09:16:11 -0700 Subject: mesa: if texObj is NULL in fetch_texel_*(), return black. --- src/mesa/swrast/s_fragprog.c | 52 +++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 20 deletions(-) (limited to 'src/mesa/swrast') diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c index 525cf9d7245..45ba91ff86d 100644 --- a/src/mesa/swrast/s_fragprog.c +++ b/src/mesa/swrast/s_fragprog.c @@ -40,20 +40,26 @@ static void fetch_texel_lod( GLcontext *ctx, const GLfloat texcoord[4], GLfloat lambda, GLuint unit, GLfloat color[4] ) { - GLchan rgba[4]; - SWcontext *swrast = SWRAST_CONTEXT(ctx); const struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current; - if (texObj) + if (texObj) { + SWcontext *swrast = SWRAST_CONTEXT(ctx); + GLchan rgba[4]; + lambda = CLAMP(lambda, texObj->MinLod, texObj->MaxLod); - /* XXX use a float-valued TextureSample routine here!!! */ - swrast->TextureSample[unit](ctx, texObj, 1, (const GLfloat (*)[4]) texcoord, - &lambda, &rgba); - color[0] = CHAN_TO_FLOAT(rgba[0]); - color[1] = CHAN_TO_FLOAT(rgba[1]); - color[2] = CHAN_TO_FLOAT(rgba[2]); - color[3] = CHAN_TO_FLOAT(rgba[3]); + /* XXX use a float-valued TextureSample routine here!!! */ + swrast->TextureSample[unit](ctx, texObj, 1, + (const GLfloat (*)[4]) texcoord, + &lambda, &rgba); + color[0] = CHAN_TO_FLOAT(rgba[0]); + color[1] = CHAN_TO_FLOAT(rgba[1]); + color[2] = CHAN_TO_FLOAT(rgba[2]); + color[3] = CHAN_TO_FLOAT(rgba[3]); + } + else { + color[0] = color[1] = color[2] = color[3] = 0.0F; + } } @@ -69,13 +75,14 @@ fetch_texel_deriv( GLcontext *ctx, const GLfloat texcoord[4], { SWcontext *swrast = SWRAST_CONTEXT(ctx); const struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current; - GLfloat lambda; - GLchan rgba[4]; if (texObj) { - const struct gl_texture_image *texImg = texObj->Image[0][texObj->BaseLevel]; + const struct gl_texture_image *texImg = + texObj->Image[0][texObj->BaseLevel]; const GLfloat texW = (GLfloat) texImg->WidthScale; const GLfloat texH = (GLfloat) texImg->HeightScale; + GLfloat lambda; + GLchan rgba[4]; lambda = _swrast_compute_lambda(texdx[0], texdy[0], /* ds/dx, ds/dy */ texdx[1], texdy[1], /* dt/dx, dt/dy */ @@ -85,14 +92,19 @@ fetch_texel_deriv( GLcontext *ctx, const GLfloat texcoord[4], 1.0F / texcoord[3]) + lodBias; lambda = CLAMP(lambda, texObj->MinLod, texObj->MaxLod); - } - swrast->TextureSample[unit](ctx, texObj, 1, (const GLfloat (*)[4]) texcoord, - &lambda, &rgba); - color[0] = CHAN_TO_FLOAT(rgba[0]); - color[1] = CHAN_TO_FLOAT(rgba[1]); - color[2] = CHAN_TO_FLOAT(rgba[2]); - color[3] = CHAN_TO_FLOAT(rgba[3]); + /* XXX use a float-valued TextureSample routine here!!! */ + swrast->TextureSample[unit](ctx, texObj, 1, + (const GLfloat (*)[4]) texcoord, + &lambda, &rgba); + color[0] = CHAN_TO_FLOAT(rgba[0]); + color[1] = CHAN_TO_FLOAT(rgba[1]); + color[2] = CHAN_TO_FLOAT(rgba[2]); + color[3] = CHAN_TO_FLOAT(rgba[3]); + } + else { + color[0] = color[1] = color[2] = color[3] = 0.0F; + } } -- cgit v1.2.3 From 54c62ba5c36f3e2b279151f5df851d2ceee15319 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 28 Jan 2009 10:31:05 -0700 Subject: mesa: implement texture swizzling in swrast And enable GL_EXT_texture_swizzle for software drivers. --- src/mesa/main/extensions.c | 1 + src/mesa/swrast/s_fragprog.c | 39 +++++++++++++++++++++++++++++++-------- src/mesa/swrast/s_texcombine.c | 39 +++++++++++++++++++++++++++++++++++++++ src/mesa/swrast/s_triangle.c | 2 ++ 4 files changed, 73 insertions(+), 8 deletions(-) (limited to 'src/mesa/swrast') diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 053f3697d70..86144c42ad8 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -274,6 +274,7 @@ _mesa_enable_sw_extensions(GLcontext *ctx) #if FEATURE_EXT_texture_sRGB ctx->Extensions.EXT_texture_sRGB = GL_TRUE; #endif + ctx->Extensions.EXT_texture_swizzle = GL_TRUE; ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE; ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE; ctx->Extensions.MESA_pack_invert = GL_TRUE; diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c index 45ba91ff86d..58ef91ec010 100644 --- a/src/mesa/swrast/s_fragprog.c +++ b/src/mesa/swrast/s_fragprog.c @@ -32,6 +32,35 @@ #include "s_span.h" +/** + * Apply texture object's swizzle (X/Y/Z/W/0/1) to incoming 'texel' + * and return results in 'colorOut'. + */ +static INLINE void +swizzle_texel(const GLchan texel[4], GLfloat colorOut[4], GLuint swizzle) +{ + if (swizzle == SWIZZLE_NOOP) { + colorOut[0] = CHAN_TO_FLOAT(texel[0]); + colorOut[1] = CHAN_TO_FLOAT(texel[1]); + colorOut[2] = CHAN_TO_FLOAT(texel[2]); + colorOut[3] = CHAN_TO_FLOAT(texel[3]); + } + else { + GLfloat vector[6]; + vector[SWIZZLE_X] = CHAN_TO_FLOAT(texel[0]); + vector[SWIZZLE_Y] = CHAN_TO_FLOAT(texel[1]); + vector[SWIZZLE_Z] = CHAN_TO_FLOAT(texel[2]); + vector[SWIZZLE_W] = CHAN_TO_FLOAT(texel[3]); + vector[SWIZZLE_ZERO] = 0.0F; + vector[SWIZZLE_ONE] = 1.0F; + colorOut[0] = vector[GET_SWZ(swizzle, 0)]; + colorOut[1] = vector[GET_SWZ(swizzle, 1)]; + colorOut[2] = vector[GET_SWZ(swizzle, 2)]; + colorOut[3] = vector[GET_SWZ(swizzle, 3)]; + } +} + + /** * Fetch a texel with given lod. * Called via machine->FetchTexelLod() @@ -52,10 +81,7 @@ fetch_texel_lod( GLcontext *ctx, const GLfloat texcoord[4], GLfloat lambda, swrast->TextureSample[unit](ctx, texObj, 1, (const GLfloat (*)[4]) texcoord, &lambda, &rgba); - color[0] = CHAN_TO_FLOAT(rgba[0]); - color[1] = CHAN_TO_FLOAT(rgba[1]); - color[2] = CHAN_TO_FLOAT(rgba[2]); - color[3] = CHAN_TO_FLOAT(rgba[3]); + swizzle_texel(rgba, color, texObj->_Swizzle); } else { color[0] = color[1] = color[2] = color[3] = 0.0F; @@ -97,10 +123,7 @@ fetch_texel_deriv( GLcontext *ctx, const GLfloat texcoord[4], swrast->TextureSample[unit](ctx, texObj, 1, (const GLfloat (*)[4]) texcoord, &lambda, &rgba); - color[0] = CHAN_TO_FLOAT(rgba[0]); - color[1] = CHAN_TO_FLOAT(rgba[1]); - color[2] = CHAN_TO_FLOAT(rgba[2]); - color[3] = CHAN_TO_FLOAT(rgba[3]); + swizzle_texel(rgba, color, texObj->_Swizzle); } else { color[0] = color[1] = color[2] = color[3] = 0.0F; diff --git a/src/mesa/swrast/s_texcombine.c b/src/mesa/swrast/s_texcombine.c index df6efad66c1..1b8775bf300 100644 --- a/src/mesa/swrast/s_texcombine.c +++ b/src/mesa/swrast/s_texcombine.c @@ -31,6 +31,7 @@ #include "main/imports.h" #include "main/macros.h" #include "main/pixel.h" +#include "shader/prog_instruction.h" #include "s_context.h" #include "s_texcombine.h" @@ -815,6 +816,36 @@ texture_combine( const GLcontext *ctx, GLuint unit, GLuint n, #undef PROD +/** + * Apply X/Y/Z/W/0/1 swizzle to an array of colors/texels. + * See GL_EXT_texture_swizzle. + */ +static void +swizzle_texels(GLuint swizzle, GLuint count, GLchan (*texels)[4]) +{ + const GLuint swzR = GET_SWZ(swizzle, 0); + const GLuint swzG = GET_SWZ(swizzle, 1); + const GLuint swzB = GET_SWZ(swizzle, 2); + const GLuint swzA = GET_SWZ(swizzle, 3); + GLchan vector[6]; + GLuint i; + + vector[SWIZZLE_ZERO] = 0; + vector[SWIZZLE_ONE] = CHAN_MAX; + + for (i = 0; i < count; i++) { + vector[SWIZZLE_X] = texels[i][0]; + vector[SWIZZLE_Y] = texels[i][1]; + vector[SWIZZLE_Z] = texels[i][2]; + vector[SWIZZLE_W] = texels[i][3]; + texels[i][RCOMP] = vector[swzR]; + texels[i][GCOMP] = vector[swzG]; + texels[i][BCOMP] = vector[swzB]; + texels[i][ACOMP] = vector[swzA]; + } +} + + /** * Apply a conventional OpenGL texture env mode (REPLACE, ADD, BLEND, * MODULATE, or DECAL) to an array of fragments. @@ -1241,9 +1272,15 @@ _swrast_texture_span( GLcontext *ctx, SWspan *span ) _mesa_lookup_rgba_float(&texUnit->ColorTable, span->end, texels); #endif } + + /* GL_EXT_texture_swizzle */ + if (curObj->_Swizzle != SWIZZLE_NOOP) { + swizzle_texels(curObj->_Swizzle, span->end, texels); + } } } + /* * OK, now apply the texture (aka texture combine/blend). * We modify the span->color.rgba values. @@ -1262,6 +1299,8 @@ _swrast_texture_span( GLcontext *ctx, SWspan *span ) const GLchan (*texels)[4] = (const GLchan (*)[4]) (swrast->TexelBuffer + unit * (span->end * 4 * sizeof(GLchan))); + + texture_apply( ctx, texUnit, span->end, (CONST GLchan (*)[4]) primary_rgba, texels, span->array->rgba ); diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c index 5d232487f30..063130714c0 100644 --- a/src/mesa/swrast/s_triangle.c +++ b/src/mesa/swrast/s_triangle.c @@ -35,6 +35,7 @@ #include "main/imports.h" #include "main/macros.h" #include "main/texformat.h" +#include "shader/prog_instruction.h" #include "s_aatriangle.h" #include "s_context.h" @@ -1063,6 +1064,7 @@ _swrast_choose_triangle( GLcontext *ctx ) && ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT && texObj2D->WrapS == GL_REPEAT && texObj2D->WrapT == GL_REPEAT + && texObj2D->_Swizzle == SWIZZLE_NOOP && texImg->_IsPowerOfTwo && texImg->Border == 0 && texImg->Width == texImg->RowStride -- cgit v1.2.3 From 26da28c995557c8b913e5ccfe31b31dc32e6c735 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 28 Jan 2009 16:49:28 -0700 Subject: mesa: remove GL_SGIX_shadow, GL_SGIX_shadow_ambient and GL_SGIX_depth_texture Everyone should be using the newer/better ARB versions of these extensions. --- docs/relnotes-7.5.html | 2 + src/mesa/main/attrib.c | 12 ++--- src/mesa/main/extensions.c | 7 +-- src/mesa/main/mtypes.h | 7 +-- src/mesa/main/texobj.c | 8 +--- src/mesa/main/texparam.c | 82 +++++---------------------------- src/mesa/main/texstate.c | 10 ---- src/mesa/shader/prog_statevars.c | 10 ++-- src/mesa/swrast/s_texfilter.c | 99 +--------------------------------------- 9 files changed, 29 insertions(+), 208 deletions(-) (limited to 'src/mesa/swrast') diff --git a/docs/relnotes-7.5.html b/docs/relnotes-7.5.html index ef8759ba6a7..621bd4afacf 100644 --- a/docs/relnotes-7.5.html +++ b/docs/relnotes-7.5.html @@ -48,6 +48,8 @@ including GL_ATI_separate_stencil, GL_EXT_stencil_two_side and OpenGL 2.0

Changes

    +
  • Remove support for GL_SGIX_shadow, GL_SGIX_shadow_ambient and +GL_SGIX_depth_texture extensions. Superseded by the ARB versions.
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index 825c841ee21..3be7fd5a2d6 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -820,15 +820,9 @@ pop_texture_group(GLcontext *ctx, struct texture_state *texstate) _mesa_TexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT, obj->MaxAnisotropy); } - if (ctx->Extensions.SGIX_shadow) { - _mesa_TexParameteri(target, GL_TEXTURE_COMPARE_SGIX, - obj->CompareFlag); - _mesa_TexParameteri(target, GL_TEXTURE_COMPARE_OPERATOR_SGIX, - obj->CompareOperator); - } - if (ctx->Extensions.SGIX_shadow_ambient) { - _mesa_TexParameterf(target, GL_SHADOW_AMBIENT_SGIX, - obj->ShadowAmbient); + if (ctx->Extensions.ARB_shadow_ambient) { + _mesa_TexParameterf(target, GL_TEXTURE_COMPARE_FAIL_VALUE_ARB, + obj->CompareFailValue); } } diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 86144c42ad8..4ebdb5d9aea 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -62,7 +62,7 @@ static const struct { { OFF, "GL_ARB_shading_language_100", F(ARB_shading_language_100) }, { OFF, "GL_ARB_shading_language_120", F(ARB_shading_language_120) }, { OFF, "GL_ARB_shadow", F(ARB_shadow) }, - { OFF, "GL_ARB_shadow_ambient", F(SGIX_shadow_ambient) }, + { OFF, "GL_ARB_shadow_ambient", F(ARB_shadow_ambient) }, { OFF, "GL_ARB_texture_border_clamp", F(ARB_texture_border_clamp) }, { OFF, "GL_ARB_texture_compression", F(ARB_texture_compression) }, { OFF, "GL_ARB_texture_cube_map", F(ARB_texture_cube_map) }, @@ -170,8 +170,6 @@ static const struct { { ON, "GL_SGIS_texture_edge_clamp", F(SGIS_texture_edge_clamp) }, { ON, "GL_SGIS_texture_lod", F(SGIS_texture_lod) }, { OFF, "GL_SGIX_depth_texture", F(ARB_depth_texture) }, - { OFF, "GL_SGIX_shadow", F(SGIX_shadow) }, - { OFF, "GL_SGIX_shadow_ambient", F(SGIX_shadow_ambient) }, { OFF, "GL_SUN_multi_draw_arrays", F(EXT_multi_draw_arrays) }, { OFF, "GL_S3_s3tc", F(S3_s3tc) }, }; @@ -214,6 +212,7 @@ _mesa_enable_sw_extensions(GLcontext *ctx) ctx->Extensions.ARB_shading_language_120 = GL_FALSE; /* not quite done */ #endif ctx->Extensions.ARB_shadow = GL_TRUE; + ctx->Extensions.ARB_shadow_ambient = GL_TRUE; ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; ctx->Extensions.ARB_texture_cube_map = GL_TRUE; ctx->Extensions.ARB_texture_env_combine = GL_TRUE; @@ -302,8 +301,6 @@ _mesa_enable_sw_extensions(GLcontext *ctx) ctx->Extensions.SGI_texture_color_table = GL_TRUE; ctx->Extensions.SGIS_generate_mipmap = GL_TRUE; ctx->Extensions.SGIS_texture_edge_clamp = GL_TRUE; - ctx->Extensions.SGIX_shadow = GL_TRUE; - ctx->Extensions.SGIX_shadow_ambient = GL_TRUE; #if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program ctx->Extensions.EXT_gpu_program_parameters = GL_TRUE; #endif diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 8ab0d26f45d..da243eceacf 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1433,11 +1433,9 @@ struct gl_texture_object GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */ GLint MaxLevel; /**< max mipmap level, OpenGL 1.2 */ GLfloat MaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */ - GLboolean CompareFlag; /**< GL_SGIX_shadow */ - GLenum CompareOperator; /**< GL_SGIX_shadow */ - GLfloat ShadowAmbient; /**< GL_ARB_shadow_ambient */ GLenum CompareMode; /**< GL_ARB_shadow */ GLenum CompareFunc; /**< GL_ARB_shadow */ + GLfloat CompareFailValue; /**< GL_ARB_shadow_ambient */ GLenum _Function; /**< Comparison function derived from * \c CompareOperator, \c CompareMode, and * \c CompareFunc. @@ -2563,6 +2561,7 @@ struct gl_extensions GLboolean ARB_shading_language_100; GLboolean ARB_shading_language_120; GLboolean ARB_shadow; + GLboolean ARB_shadow_ambient; /* or GL_ARB_shadow_ambient */ GLboolean ARB_texture_border_clamp; GLboolean ARB_texture_compression; GLboolean ARB_texture_cube_map; @@ -2660,8 +2659,6 @@ struct gl_extensions GLboolean SGIS_generate_mipmap; GLboolean SGIS_texture_edge_clamp; GLboolean SGIS_texture_lod; - GLboolean SGIX_shadow; - GLboolean SGIX_shadow_ambient; /* or GL_ARB_shadow_ambient */ GLboolean TDFX_texture_compression_FXT1; GLboolean S3_s3tc; /*@}*/ diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index fad39a06347..4e6cf439fc1 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -134,12 +134,10 @@ _mesa_initialize_texture_object( struct gl_texture_object *obj, obj->BaseLevel = 0; obj->MaxLevel = 1000; obj->MaxAnisotropy = 1.0; - obj->CompareFlag = GL_FALSE; /* SGIX_shadow */ - obj->CompareOperator = GL_TEXTURE_LEQUAL_R_SGIX; /* SGIX_shadow */ obj->CompareMode = GL_NONE; /* ARB_shadow */ obj->CompareFunc = GL_LEQUAL; /* ARB_shadow */ + obj->CompareFailValue = 0.0F; /* ARB_shadow_ambient */ obj->DepthMode = GL_LUMINANCE; /* ARB_depth_texture */ - obj->ShadowAmbient = 0.0F; /* ARB/SGIX_shadow_ambient */ obj->Swizzle[0] = GL_RED; obj->Swizzle[1] = GL_GREEN; obj->Swizzle[2] = GL_BLUE; @@ -248,11 +246,9 @@ _mesa_copy_texture_object( struct gl_texture_object *dest, dest->BaseLevel = src->BaseLevel; dest->MaxLevel = src->MaxLevel; dest->MaxAnisotropy = src->MaxAnisotropy; - dest->CompareFlag = src->CompareFlag; - dest->CompareOperator = src->CompareOperator; - dest->ShadowAmbient = src->ShadowAmbient; dest->CompareMode = src->CompareMode; dest->CompareFunc = src->CompareFunc; + dest->CompareFailValue = src->CompareFailValue; dest->DepthMode = src->DepthMode; dest->_MaxLevel = src->_MaxLevel; dest->_MaxLambda = src->_MaxLambda; diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c index 41c914e5b32..f610fa8dda4 100644 --- a/src/mesa/main/texparam.c +++ b/src/mesa/main/texparam.c @@ -260,30 +260,6 @@ set_tex_parameteri(GLcontext *ctx, texObj->MaxLevel = params[0]; return; - case GL_TEXTURE_COMPARE_SGIX: - if (ctx->Extensions.SGIX_shadow) { - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texObj->CompareFlag = params[0] ? GL_TRUE : GL_FALSE; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glTexParameter(pname=GL_TEXTURE_COMPARE_SGIX)"); - } - return; - - case GL_TEXTURE_COMPARE_OPERATOR_SGIX: - if (ctx->Extensions.SGIX_shadow && - (params[0] == GL_TEXTURE_LEQUAL_R_SGIX || - params[0] == GL_TEXTURE_GEQUAL_R_SGIX)) { - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texObj->CompareOperator = params[0]; - } - else { - _mesa_error(ctx, GL_INVALID_ENUM, - "glTexParameter(GL_TEXTURE_COMPARE_OPERATOR_SGIX)"); - } - return; - case GL_GENERATE_MIPMAP_SGIS: if (ctx->Extensions.SGIS_generate_mipmap) { FLUSH_VERTICES(ctx, _NEW_TEXTURE); @@ -454,14 +430,14 @@ set_tex_parameterf(GLcontext *ctx, } return; - case GL_SHADOW_AMBIENT_SGIX: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */ - if (ctx->Extensions.SGIX_shadow_ambient) { + case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: + if (ctx->Extensions.ARB_shadow_ambient) { FLUSH_VERTICES(ctx, _NEW_TEXTURE); - texObj->ShadowAmbient = CLAMP(params[0], 0.0F, 1.0F); + texObj->CompareFailValue = CLAMP(params[0], 0.0F, 1.0F); } else { _mesa_error(ctx, GL_INVALID_ENUM, - "glTexParameter(pname=GL_SHADOW_AMBIENT_SGIX)"); + "glTexParameter(pname=GL_TEXTURE_COMPARE_FAIL_VALUE_ARB)"); } return; @@ -512,8 +488,6 @@ _mesa_TexParameterf(GLenum target, GLenum pname, GLfloat param) case GL_TEXTURE_WRAP_R: case GL_TEXTURE_BASE_LEVEL: case GL_TEXTURE_MAX_LEVEL: - case GL_TEXTURE_COMPARE_SGIX: - case GL_TEXTURE_COMPARE_OPERATOR_SGIX: case GL_GENERATE_MIPMAP_SGIS: case GL_TEXTURE_COMPARE_MODE_ARB: case GL_TEXTURE_COMPARE_FUNC_ARB: @@ -556,8 +530,6 @@ _mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params) case GL_TEXTURE_WRAP_R: case GL_TEXTURE_BASE_LEVEL: case GL_TEXTURE_MAX_LEVEL: - case GL_TEXTURE_COMPARE_SGIX: - case GL_TEXTURE_COMPARE_OPERATOR_SGIX: case GL_GENERATE_MIPMAP_SGIS: case GL_TEXTURE_COMPARE_MODE_ARB: case GL_TEXTURE_COMPARE_FUNC_ARB: @@ -613,7 +585,7 @@ _mesa_TexParameteri(GLenum target, GLenum pname, GLint param) case GL_TEXTURE_PRIORITY: case GL_TEXTURE_MAX_ANISOTROPY_EXT: case GL_TEXTURE_LOD_BIAS: - case GL_SHADOW_AMBIENT_SGIX: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */ + case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: { GLfloat fparam = (GLfloat) param; /* convert int param to float */ @@ -662,7 +634,7 @@ _mesa_TexParameteriv(GLenum target, GLenum pname, const GLint *params) case GL_TEXTURE_PRIORITY: case GL_TEXTURE_MAX_ANISOTROPY_EXT: case GL_TEXTURE_LOD_BIAS: - case GL_SHADOW_AMBIENT_SGIX: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */ + case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: { /* convert int param to float */ GLfloat fparam = (GLfloat) params[0]; @@ -1060,23 +1032,9 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) else error = GL_TRUE; break; - case GL_TEXTURE_COMPARE_SGIX: - if (ctx->Extensions.SGIX_shadow) { - *params = (GLfloat) obj->CompareFlag; - } - else - error = GL_TRUE; - break; - case GL_TEXTURE_COMPARE_OPERATOR_SGIX: - if (ctx->Extensions.SGIX_shadow) { - *params = (GLfloat) obj->CompareOperator; - } - else - error = GL_TRUE; - break; - case GL_SHADOW_AMBIENT_SGIX: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */ - if (ctx->Extensions.SGIX_shadow_ambient) { - *params = obj->ShadowAmbient; + case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: + if (ctx->Extensions.ARB_shadow_ambient) { + *params = obj->CompareFailValue; } else error = GL_TRUE; @@ -1248,25 +1206,9 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params ) error = GL_TRUE; } break; - case GL_TEXTURE_COMPARE_SGIX: - if (ctx->Extensions.SGIX_shadow) { - *params = (GLint) obj->CompareFlag; - } - else { - error = GL_TRUE; - } - break; - case GL_TEXTURE_COMPARE_OPERATOR_SGIX: - if (ctx->Extensions.SGIX_shadow) { - *params = (GLint) obj->CompareOperator; - } - else { - error = GL_TRUE; - } - break; - case GL_SHADOW_AMBIENT_SGIX: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */ - if (ctx->Extensions.SGIX_shadow_ambient) { - *params = (GLint) FLOAT_TO_INT(obj->ShadowAmbient); + case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: + if (ctx->Extensions.ARB_shadow_ambient) { + *params = (GLint) FLOAT_TO_INT(obj->CompareFailValue); } else { error = GL_TRUE; diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 7cddec0bcec..f7a4d8b323b 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -404,16 +404,6 @@ update_texture_compare_function(GLcontext *ctx, */ tObj->_Function = GL_NONE; } - else if (tObj->CompareFlag) { - /* GL_SGIX_shadow */ - if (tObj->CompareOperator == GL_TEXTURE_LEQUAL_R_SGIX) { - tObj->_Function = GL_LEQUAL; - } - else { - ASSERT(tObj->CompareOperator == GL_TEXTURE_GEQUAL_R_SGIX); - tObj->_Function = GL_GEQUAL; - } - } else if (tObj->CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB) { /* GL_ARB_shadow */ tObj->_Function = tObj->CompareFunc; diff --git a/src/mesa/shader/prog_statevars.c b/src/mesa/shader/prog_statevars.c index 615826b2106..3ce60427bf4 100644 --- a/src/mesa/shader/prog_statevars.c +++ b/src/mesa/shader/prog_statevars.c @@ -493,10 +493,10 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[], const struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current; if (texObj) { - value[0] = texObj->ShadowAmbient; - value[1] = texObj->ShadowAmbient; - value[2] = texObj->ShadowAmbient; - value[3] = texObj->ShadowAmbient; + value[0] = + value[1] = + value[2] = + value[3] = texObj->CompareFailValue; } } return; @@ -777,7 +777,7 @@ append_token(char *dst, gl_state_index k) append(dst, "PCMbias"); break; case STATE_SHADOW_AMBIENT: - append(dst, "ShadowAmbient"); + append(dst, "CompareFailValue"); break; default: /* probably STATE_INTERNAL_DRIVER+i (driver private state) */ diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c index a095b255ab5..8d72018cf4f 100644 --- a/src/mesa/swrast/s_texfilter.c +++ b/src/mesa/swrast/s_texfilter.c @@ -2826,7 +2826,7 @@ sample_depth_texture( GLcontext *ctx, tObj->Target == GL_TEXTURE_1D_ARRAY_EXT || tObj->Target == GL_TEXTURE_2D_ARRAY_EXT); - UNCLAMPED_FLOAT_TO_CHAN(ambient, tObj->ShadowAmbient); + UNCLAMPED_FLOAT_TO_CHAN(ambient, tObj->CompareFailValue); /* XXXX if tObj->MinFilter != tObj->MagFilter, we're ignoring lambda */ @@ -3156,103 +3156,6 @@ sample_depth_texture( GLcontext *ctx, } -#if 0 -/* - * Experimental depth texture sampling function. - */ -static void -sample_depth_texture2(const GLcontext *ctx, - const struct gl_texture_unit *texUnit, - GLuint n, const GLfloat texcoords[][4], - GLchan texel[][4]) -{ - const struct gl_texture_object *texObj = texUnit->_Current; - const GLint baseLevel = texObj->BaseLevel; - const struct gl_texture_image *texImage = texObj->Image[0][baseLevel]; - const GLuint width = texImage->Width; - const GLuint height = texImage->Height; - GLchan ambient; - GLboolean lequal, gequal; - - if (texObj->Target != GL_TEXTURE_2D) { - _mesa_problem(ctx, "only 2-D depth textures supported at this time"); - return; - } - - if (texObj->MinFilter != texObj->MagFilter) { - _mesa_problem(ctx, "mipmapped depth textures not supported at this time"); - return; - } - - /* XXX the GL_SGIX_shadow extension spec doesn't say what to do if - * GL_TEXTURE_COMPARE_SGIX == GL_TRUE but the current texture object - * isn't a depth texture. - */ - if (texImage->TexFormat->BaseFormat != GL_DEPTH_COMPONENT) { - _mesa_problem(ctx,"GL_TEXTURE_COMPARE_SGIX enabled with non-depth texture"); - return; - } - - UNCLAMPED_FLOAT_TO_CHAN(ambient, tObj->ShadowAmbient); - - if (texObj->CompareOperator == GL_TEXTURE_LEQUAL_R_SGIX) { - lequal = GL_TRUE; - gequal = GL_FALSE; - } - else { - lequal = GL_FALSE; - gequal = GL_TRUE; - } - - { - GLuint i; - for (i = 0; i < n; i++) { - const GLint K = 3; - GLint col, row, ii, jj, imin, imax, jmin, jmax, samples, count; - GLfloat w; - GLchan lum; - col = nearest_texel_location(texObj->WrapS, img, width, - texcoords[i][0]); - row = nearest_texel_location(texObj->WrapT, img, height, - texcoords[i][1]); - - imin = col - K; - imax = col + K; - jmin = row - K; - jmax = row + K; - - if (imin < 0) imin = 0; - if (imax >= width) imax = width - 1; - if (jmin < 0) jmin = 0; - if (jmax >= height) jmax = height - 1; - - samples = (imax - imin + 1) * (jmax - jmin + 1); - count = 0; - for (jj = jmin; jj <= jmax; jj++) { - for (ii = imin; ii <= imax; ii++) { - GLfloat depthSample; - texImage->FetchTexelf(texImage, ii, jj, 0, &depthSample); - if ((depthSample <= r[i] && lequal) || - (depthSample >= r[i] && gequal)) { - count++; - } - } - } - - w = (GLfloat) count / (GLfloat) samples; - w = CHAN_MAXF - w * (CHAN_MAXF - (GLfloat) ambient); - lum = (GLint) w; - - texel[i][RCOMP] = lum; - texel[i][GCOMP] = lum; - texel[i][BCOMP] = lum; - texel[i][ACOMP] = CHAN_MAX; - } - } -} -#endif - - /** * We use this function when a texture object is in an "incomplete" state. * When a fragment program attempts to sample an incomplete texture we -- cgit v1.2.3 From 81ca8b93f212d1946c70660041ce97d98f352608 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 29 Jan 2009 15:56:19 -0700 Subject: swrast: replace macro with inline function --- src/mesa/swrast/s_context.h | 15 ++++++++++++++- src/mesa/swrast/s_fog.c | 4 ++-- src/mesa/swrast/s_texcombine.c | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) (limited to 'src/mesa/swrast') diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h index a511d1c9a17..46a5fa24f85 100644 --- a/src/mesa/swrast/s_context.h +++ b/src/mesa/swrast/s_context.h @@ -238,7 +238,20 @@ extern void _swrast_update_texture_samplers(GLcontext *ctx); -#define SWRAST_CONTEXT(ctx) ((SWcontext *)ctx->swrast_context) +/** Return SWcontext for the given GLcontext */ +static INLINE SWcontext * +SWRAST_CONTEXT(GLcontext *ctx) +{ + return (SWcontext *) ctx->swrast_context; +} + +/** const version of above */ +static INLINE const SWcontext * +CONST_SWRAST_CONTEXT(const GLcontext *ctx) +{ + return (const SWcontext *) ctx->swrast_context; +} + #define RENDER_START(SWctx, GLctx) \ do { \ diff --git a/src/mesa/swrast/s_fog.c b/src/mesa/swrast/s_fog.c index b9ba265db6d..77ed0cfef96 100644 --- a/src/mesa/swrast/s_fog.c +++ b/src/mesa/swrast/s_fog.c @@ -164,7 +164,7 @@ else { \ void _swrast_fog_rgba_span( const GLcontext *ctx, SWspan *span ) { - const SWcontext *swrast = SWRAST_CONTEXT(ctx); + const SWcontext *swrast = CONST_SWRAST_CONTEXT(ctx); GLfloat rFog, gFog, bFog; ASSERT(swrast->_FogEnabled); @@ -283,7 +283,7 @@ _swrast_fog_rgba_span( const GLcontext *ctx, SWspan *span ) void _swrast_fog_ci_span( const GLcontext *ctx, SWspan *span ) { - const SWcontext *swrast = SWRAST_CONTEXT(ctx); + const SWcontext *swrast = CONST_SWRAST_CONTEXT(ctx); const GLuint fogIndex = (GLuint) ctx->Fog.Index; GLuint *index = span->array->index; diff --git a/src/mesa/swrast/s_texcombine.c b/src/mesa/swrast/s_texcombine.c index 1b8775bf300..38b5633887f 100644 --- a/src/mesa/swrast/s_texcombine.c +++ b/src/mesa/swrast/s_texcombine.c @@ -87,7 +87,7 @@ texture_combine( const GLcontext *ctx, GLuint unit, GLuint n, ASSERT(ctx->Extensions.EXT_texture_env_combine || ctx->Extensions.ARB_texture_env_combine); - ASSERT(SWRAST_CONTEXT(ctx)->_AnyTextureCombine); + ASSERT(CONST_SWRAST_CONTEXT(ctx)->_AnyTextureCombine); /* printf("modeRGB 0x%x modeA 0x%x srcRGB1 0x%x srcA1 0x%x srcRGB2 0x%x srcA2 0x%x\n", -- cgit v1.2.3 From 2d5b86be25a7ccb729e746aa5e1bdd537d76df68 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 29 Jan 2009 16:05:39 -0700 Subject: swrast: replace RENDER_START/FINISH macros with inline functions --- src/mesa/swrast/s_accum.c | 8 ++++---- src/mesa/swrast/s_bitmap.c | 9 ++++----- src/mesa/swrast/s_blit.c | 5 ++--- src/mesa/swrast/s_buffers.c | 6 ++---- src/mesa/swrast/s_context.h | 35 ++++++++++++++++++++++------------- src/mesa/swrast/s_copypix.c | 4 ++-- src/mesa/swrast/s_drawpix.c | 10 +++++----- src/mesa/swrast/s_imaging.c | 20 ++++++++------------ src/mesa/swrast/s_readpix.c | 12 ++++++------ src/mesa/swrast/s_texstore.c | 15 ++++++--------- 10 files changed, 61 insertions(+), 63 deletions(-) (limited to 'src/mesa/swrast') diff --git a/src/mesa/swrast/s_accum.c b/src/mesa/swrast/s_accum.c index ff741777e75..c6c7dbf5cf0 100644 --- a/src/mesa/swrast/s_accum.c +++ b/src/mesa/swrast/s_accum.c @@ -550,7 +550,7 @@ _swrast_Accum(GLcontext *ctx, GLenum op, GLfloat value) SWcontext *swrast = SWRAST_CONTEXT(ctx); GLint xpos, ypos, width, height; - if (SWRAST_CONTEXT(ctx)->NewState) + if (swrast->NewState) _swrast_validate_derived( ctx ); if (!ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer) { @@ -558,9 +558,9 @@ _swrast_Accum(GLcontext *ctx, GLenum op, GLfloat value) return; } - RENDER_START(swrast, ctx); + swrast_render_start(ctx); - /* Compute region after calling RENDER_START so that we know the + /* Compute region after calling swrast_render_start() so that we know the * drawbuffer's size/bounds are up to date. */ xpos = ctx->DrawBuffer->_Xmin; @@ -595,5 +595,5 @@ _swrast_Accum(GLcontext *ctx, GLenum op, GLfloat value) break; } - RENDER_FINISH(swrast, ctx); + swrast_render_finish(ctx); } diff --git a/src/mesa/swrast/s_bitmap.c b/src/mesa/swrast/s_bitmap.c index 35b34e654ff..5e7822cf323 100644 --- a/src/mesa/swrast/s_bitmap.c +++ b/src/mesa/swrast/s_bitmap.c @@ -50,7 +50,6 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py, const struct gl_pixelstore_attrib *unpack, const GLubyte *bitmap ) { - SWcontext *swrast = SWRAST_CONTEXT(ctx); GLint row, col; GLuint count = 0; SWspan span; @@ -61,7 +60,7 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py, if (!bitmap) return; - RENDER_START(swrast,ctx); + swrast_render_start(ctx); if (SWRAST_CONTEXT(ctx)->NewState) _swrast_validate_derived( ctx ); @@ -132,7 +131,7 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py, } } - RENDER_FINISH(swrast,ctx); + swrast_render_finish(ctx); _mesa_unmap_bitmap_pbo(ctx, unpack); } @@ -157,7 +156,7 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py, ASSERT(ctx->RenderMode == GL_RENDER); ASSERT(bitmap); - RENDER_START(swrast,ctx); + swrast_render_start(ctx); if (SWRAST_CONTEXT(ctx)->NewState) _swrast_validate_derived( ctx ); @@ -224,6 +223,6 @@ _swrast_Bitmap( GLcontext *ctx, GLint px, GLint py, } } - RENDER_FINISH(swrast,ctx); + swrast_render_finish(ctx); } #endif diff --git a/src/mesa/swrast/s_blit.c b/src/mesa/swrast/s_blit.c index bc4b2ac6251..0e32cb8f653 100644 --- a/src/mesa/swrast/s_blit.c +++ b/src/mesa/swrast/s_blit.c @@ -737,7 +737,6 @@ _swrast_BlitFramebuffer(GLcontext *ctx, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) { - SWcontext *swrast = SWRAST_CONTEXT(ctx); static const GLint buffers[3] = { GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, @@ -753,7 +752,7 @@ _swrast_BlitFramebuffer(GLcontext *ctx, return; } - RENDER_START(swrast, ctx); + swrast_render_start(ctx); if (srcX1 - srcX0 == dstX1 - dstX0 && srcY1 - srcY0 == dstY1 - dstY0 && @@ -789,5 +788,5 @@ _swrast_BlitFramebuffer(GLcontext *ctx, } } - RENDER_FINISH(swrast, ctx); + swrast_render_finish(ctx); } diff --git a/src/mesa/swrast/s_buffers.c b/src/mesa/swrast/s_buffers.c index 9e87d6d4857..af475ad8cb5 100644 --- a/src/mesa/swrast/s_buffers.c +++ b/src/mesa/swrast/s_buffers.c @@ -307,8 +307,6 @@ clear_color_buffers(GLcontext *ctx) void _swrast_Clear(GLcontext *ctx, GLbitfield buffers) { - SWcontext *swrast = SWRAST_CONTEXT(ctx); - #ifdef DEBUG_FOO { const GLbitfield legalBits = @@ -327,7 +325,7 @@ _swrast_Clear(GLcontext *ctx, GLbitfield buffers) } #endif - RENDER_START(swrast,ctx); + swrast_render_start(ctx); /* do software clearing here */ if (buffers) { @@ -347,5 +345,5 @@ _swrast_Clear(GLcontext *ctx, GLbitfield buffers) } } - RENDER_FINISH(swrast,ctx); + swrast_render_finish(ctx); } diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h index 46a5fa24f85..cdd6fa5048d 100644 --- a/src/mesa/swrast/s_context.h +++ b/src/mesa/swrast/s_context.h @@ -253,19 +253,28 @@ CONST_SWRAST_CONTEXT(const GLcontext *ctx) } -#define RENDER_START(SWctx, GLctx) \ - do { \ - if ((SWctx)->Driver.SpanRenderStart) { \ - (*(SWctx)->Driver.SpanRenderStart)(GLctx); \ - } \ - } while (0) - -#define RENDER_FINISH(SWctx, GLctx) \ - do { \ - if ((SWctx)->Driver.SpanRenderFinish) { \ - (*(SWctx)->Driver.SpanRenderFinish)(GLctx); \ - } \ - } while (0) +/** + * Called prior to framebuffer reading/writing. + * For drivers that rely on swrast for fallback rendering, this is the + * driver's opportunity to map renderbuffers and textures. + */ +static INLINE void +swrast_render_start(GLcontext *ctx) +{ + SWcontext *swrast = SWRAST_CONTEXT(ctx); + if (swrast->Driver.SpanRenderStart) + swrast->Driver.SpanRenderStart(ctx); +} + + +/** Called after framebuffer reading/writing */ +static INLINE void +swrast_render_finish(GLcontext *ctx) +{ + SWcontext *swrast = SWRAST_CONTEXT(ctx); + if (swrast->Driver.SpanRenderFinish) + swrast->Driver.SpanRenderFinish(ctx); +} diff --git a/src/mesa/swrast/s_copypix.c b/src/mesa/swrast/s_copypix.c index fc5990b261c..5ecfb1e90a9 100644 --- a/src/mesa/swrast/s_copypix.c +++ b/src/mesa/swrast/s_copypix.c @@ -899,7 +899,7 @@ _swrast_CopyPixels( GLcontext *ctx, GLint destx, GLint desty, GLenum type ) { SWcontext *swrast = SWRAST_CONTEXT(ctx); - RENDER_START(swrast,ctx); + swrast_render_start(ctx); if (swrast->NewState) _swrast_validate_derived( ctx ); @@ -928,5 +928,5 @@ _swrast_CopyPixels( GLcontext *ctx, } } - RENDER_FINISH(swrast,ctx); + swrast_render_finish(ctx); } diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index 7af3e3dad1c..2fc9fd0d503 100644 --- a/src/mesa/swrast/s_drawpix.c +++ b/src/mesa/swrast/s_drawpix.c @@ -830,7 +830,7 @@ _swrast_DrawPixels( GLcontext *ctx, { SWcontext *swrast = SWRAST_CONTEXT(ctx); - RENDER_START(swrast,ctx); + swrast_render_start(ctx); if (ctx->NewState) _mesa_update_state(ctx); @@ -840,7 +840,7 @@ _swrast_DrawPixels( GLcontext *ctx, pixels = _mesa_map_drawpix_pbo(ctx, unpack, pixels); if (!pixels) { - RENDER_FINISH(swrast,ctx); + swrast_render_finish(ctx); return; } @@ -879,7 +879,7 @@ _swrast_DrawPixels( GLcontext *ctx, /* don't return yet, clean-up */ } - RENDER_FINISH(swrast,ctx); + swrast_render_finish(ctx); _mesa_unmap_drapix_pbo(ctx, unpack); } @@ -904,7 +904,7 @@ _swrast_DrawDepthPixelsMESA( GLcontext *ctx, if (swrast->NewState) _swrast_validate_derived( ctx ); - RENDER_START(swrast,ctx); + swrast_render_start(ctx); switch (colorFormat) { case GL_COLOR_INDEX: @@ -933,6 +933,6 @@ _swrast_DrawDepthPixelsMESA( GLcontext *ctx, _mesa_problem(ctx, "unexpected format in glDrawDepthPixelsMESA"); } - RENDER_FINISH(swrast,ctx); + swrast_render_finish(ctx); } #endif diff --git a/src/mesa/swrast/s_imaging.c b/src/mesa/swrast/s_imaging.c index 591857c3423..d6be3aa022e 100644 --- a/src/mesa/swrast/s_imaging.c +++ b/src/mesa/swrast/s_imaging.c @@ -39,7 +39,6 @@ _swrast_CopyColorTable( GLcontext *ctx, GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width) { - SWcontext *swrast = SWRAST_CONTEXT(ctx); GLchan data[MAX_WIDTH][4]; struct gl_buffer_object *bufferSave; @@ -51,13 +50,13 @@ _swrast_CopyColorTable( GLcontext *ctx, if (width > MAX_WIDTH) width = MAX_WIDTH; - RENDER_START( swrast, ctx ); + swrast_render_start(ctx); /* read the data from framebuffer */ _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer, width, x, y, CHAN_TYPE, data ); - RENDER_FINISH(swrast,ctx); + swrast_render_finish(ctx); /* save PBO binding */ bufferSave = ctx->Unpack.BufferObj; @@ -74,7 +73,6 @@ void _swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start, GLint x, GLint y, GLsizei width) { - SWcontext *swrast = SWRAST_CONTEXT(ctx); GLchan data[MAX_WIDTH][4]; struct gl_buffer_object *bufferSave; @@ -86,13 +84,13 @@ _swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start, if (width > MAX_WIDTH) width = MAX_WIDTH; - RENDER_START( swrast, ctx ); + swrast_render_start(ctx); /* read the data from framebuffer */ _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer, width, x, y, CHAN_TYPE, data ); - RENDER_FINISH(swrast,ctx); + swrast_render_finish(ctx); /* save PBO binding */ bufferSave = ctx->Unpack.BufferObj; @@ -110,7 +108,6 @@ _swrast_CopyConvolutionFilter1D(GLcontext *ctx, GLenum target, GLenum internalFormat, GLint x, GLint y, GLsizei width) { - SWcontext *swrast = SWRAST_CONTEXT(ctx); GLchan rgba[MAX_CONVOLUTION_WIDTH][4]; struct gl_buffer_object *bufferSave; @@ -119,13 +116,13 @@ _swrast_CopyConvolutionFilter1D(GLcontext *ctx, GLenum target, return; } - RENDER_START( swrast, ctx ); + swrast_render_start(ctx); /* read the data from framebuffer */ _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer, width, x, y, CHAN_TYPE, rgba ); - RENDER_FINISH( swrast, ctx ); + swrast_render_finish(ctx); /* save PBO binding */ bufferSave = ctx->Unpack.BufferObj; @@ -145,7 +142,6 @@ _swrast_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height) { - SWcontext *swrast = SWRAST_CONTEXT(ctx); struct gl_pixelstore_attrib packSave; GLchan rgba[MAX_CONVOLUTION_HEIGHT][MAX_CONVOLUTION_WIDTH][4]; GLint i; @@ -156,7 +152,7 @@ _swrast_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target, return; } - RENDER_START(swrast,ctx); + swrast_render_start(ctx); /* read pixels from framebuffer */ for (i = 0; i < height; i++) { @@ -164,7 +160,7 @@ _swrast_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target, width, x, y + i, CHAN_TYPE, rgba[i] ); } - RENDER_FINISH(swrast,ctx); + swrast_render_finish(ctx); /* * HACK: save & restore context state so we can store this as a diff --git a/src/mesa/swrast/s_readpix.c b/src/mesa/swrast/s_readpix.c index f2630451707..e901fc6b5dc 100644 --- a/src/mesa/swrast/s_readpix.c +++ b/src/mesa/swrast/s_readpix.c @@ -555,11 +555,11 @@ _swrast_ReadPixels( GLcontext *ctx, SWcontext *swrast = SWRAST_CONTEXT(ctx); struct gl_pixelstore_attrib clippedPacking = *packing; - /* Need to do RENDER_START before clipping or anything else since this - * is where a driver may grab the hw lock and get an updated window - * size. + /* Need to do swrast_render_start() before clipping or anything else + * since this is where a driver may grab the hw lock and get an updated + * window size. */ - RENDER_START(swrast, ctx); + swrast_render_start(ctx); if (ctx->NewState) _mesa_update_state(ctx); @@ -570,7 +570,7 @@ _swrast_ReadPixels( GLcontext *ctx, /* Do all needed clipping here, so that we can forget about it later */ if (!_mesa_clip_readpixels(ctx, &x, &y, &width, &height, &clippedPacking)) { /* The ReadPixels region is totally outside the window bounds */ - RENDER_FINISH(swrast, ctx); + swrast_render_finish(ctx); return; } @@ -614,7 +614,7 @@ _swrast_ReadPixels( GLcontext *ctx, /* don't return yet, clean-up */ } - RENDER_FINISH(swrast, ctx); + swrast_render_finish(ctx); _mesa_unmap_readpix_pbo(ctx, &clippedPacking); } diff --git a/src/mesa/swrast/s_texstore.c b/src/mesa/swrast/s_texstore.c index 16b00b9fa1c..f9ff9ad6a42 100644 --- a/src/mesa/swrast/s_texstore.c +++ b/src/mesa/swrast/s_texstore.c @@ -67,7 +67,6 @@ static GLvoid * read_color_image( GLcontext *ctx, GLint x, GLint y, GLenum type, GLsizei width, GLsizei height ) { - SWcontext *swrast = SWRAST_CONTEXT(ctx); struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer; const GLint pixelSize = _mesa_bytes_per_pixel(GL_RGBA, type); const GLint stride = width * pixelSize; @@ -78,7 +77,7 @@ read_color_image( GLcontext *ctx, GLint x, GLint y, GLenum type, if (!image) return NULL; - RENDER_START(swrast, ctx); + swrast_render_start(ctx); dst = image; for (row = 0; row < height; row++) { @@ -86,7 +85,7 @@ read_color_image( GLcontext *ctx, GLint x, GLint y, GLenum type, dst += stride; } - RENDER_FINISH(swrast, ctx); + swrast_render_finish(ctx); return image; } @@ -101,7 +100,6 @@ read_depth_image( GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height ) { struct gl_renderbuffer *rb = ctx->ReadBuffer->_DepthBuffer; - SWcontext *swrast = SWRAST_CONTEXT(ctx); GLuint *image, *dst; GLint i; @@ -109,7 +107,7 @@ read_depth_image( GLcontext *ctx, GLint x, GLint y, if (!image) return NULL; - RENDER_START(swrast, ctx); + swrast_render_start(ctx); dst = image; for (i = 0; i < height; i++) { @@ -117,7 +115,7 @@ read_depth_image( GLcontext *ctx, GLint x, GLint y, dst += width; } - RENDER_FINISH(swrast, ctx); + swrast_render_finish(ctx); return image; } @@ -132,7 +130,6 @@ read_depth_stencil_image(GLcontext *ctx, GLint x, GLint y, { struct gl_renderbuffer *depthRb = ctx->ReadBuffer->_DepthBuffer; struct gl_renderbuffer *stencilRb = ctx->ReadBuffer->_StencilBuffer; - SWcontext *swrast = SWRAST_CONTEXT(ctx); GLuint *image, *dst; GLint i; @@ -143,7 +140,7 @@ read_depth_stencil_image(GLcontext *ctx, GLint x, GLint y, if (!image) return NULL; - RENDER_START(swrast, ctx); + swrast_render_start(ctx); /* read from depth buffer */ dst = image; @@ -205,7 +202,7 @@ read_depth_stencil_image(GLcontext *ctx, GLint x, GLint y, dst += width; } - RENDER_FINISH(swrast, ctx); + swrast_render_finish(ctx); return image; } -- cgit v1.2.3 From 92ced46eaf1f389108ed8d3d788498d799f0b385 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 2 Feb 2009 07:48:10 -0700 Subject: mesa: move code after decls. Fixes Window build failure. --- src/mesa/swrast/s_triangle.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/mesa/swrast') diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c index 063130714c0..0598052f50c 100644 --- a/src/mesa/swrast/s_triangle.c +++ b/src/mesa/swrast/s_triangle.c @@ -266,9 +266,6 @@ affine_span(GLcontext *ctx, SWspan *span, GLchan sample[4]; /* the filtered texture sample */ const GLuint texEnableSave = ctx->Texture._EnabledUnits; - /* Disable tex units so they're not re-applied in swrast_write_rgba_span */ - ctx->Texture._EnabledUnits = 0x0; - /* Instead of defining a function for each mode, a test is done * between the outer and inner loops. This is to reduce code size * and complexity. Observe that an optimizing compiler kills @@ -397,6 +394,9 @@ affine_span(GLcontext *ctx, SWspan *span, GLuint i; GLchan *dest = span->array->rgba[0]; + /* Disable tex units so they're not re-applied in swrast_write_rgba_span */ + ctx->Texture._EnabledUnits = 0x0; + span->intTex[0] -= FIXED_HALF; span->intTex[1] -= FIXED_HALF; switch (info->filter) { -- cgit v1.2.3 From 8962bac0a1e422afcd034f4ce00d45d8f3df46bf Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 4 Feb 2009 10:45:04 -0700 Subject: swrast: add minor comments --- src/mesa/swrast/s_span.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/mesa/swrast') diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index 7f9cc64bb29..ab7b82b19d9 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -1311,6 +1311,7 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span) /* Do the alpha test */ if (ctx->Color.AlphaEnabled) { if (!_swrast_alpha_test(ctx, span)) { + /* all fragments failed test */ goto end; } } @@ -1323,6 +1324,7 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span) if (ctx->Stencil.Enabled && fb->Visual.stencilBits > 0) { /* Combined Z/stencil tests */ if (!_swrast_stencil_and_ztest_span(ctx, span)) { + /* all fragments failed test */ goto end; } } @@ -1331,6 +1333,7 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span) ASSERT(ctx->Depth.Test); ASSERT(span->arrayMask & SPAN_Z); if (!_swrast_depth_test_span(ctx, span)) { + /* all fragments failed test */ goto end; } } @@ -1350,6 +1353,7 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span) * the occlusion test. */ if (colorMask == 0x0) { + /* no colors to write */ goto end; } -- cgit v1.2.3 From 1df62651b2e9a8d0afd790738e2695a16ade1eeb Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 6 Feb 2009 10:47:31 -0700 Subject: swrast: return (0,0,0,1) when sampling incomplete textures, not (0,0,0,0) Fixes piglit shaders/fp-incomplete-tex test. --- src/mesa/swrast/s_fragprog.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/mesa/swrast') diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c index 58ef91ec010..bbb784c46e8 100644 --- a/src/mesa/swrast/s_fragprog.c +++ b/src/mesa/swrast/s_fragprog.c @@ -84,7 +84,8 @@ fetch_texel_lod( GLcontext *ctx, const GLfloat texcoord[4], GLfloat lambda, swizzle_texel(rgba, color, texObj->_Swizzle); } else { - color[0] = color[1] = color[2] = color[3] = 0.0F; + color[0] = color[1] = color[2] = 0.0F; + color[3] = 1.0F; } } @@ -126,7 +127,8 @@ fetch_texel_deriv( GLcontext *ctx, const GLfloat texcoord[4], swizzle_texel(rgba, color, texObj->_Swizzle); } else { - color[0] = color[1] = color[2] = color[3] = 0.0F; + color[0] = color[1] = color[2] = 0.0F; + color[3] = 1.0F; } } -- cgit v1.2.3 From 71e64fc30b4f57bd93daf004bc04af7181391f4d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 9 Feb 2009 09:54:33 -0700 Subject: swrast: fix typo: s/drapix/drawpix/ --- src/mesa/swrast/s_drawpix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/swrast') diff --git a/src/mesa/swrast/s_drawpix.c b/src/mesa/swrast/s_drawpix.c index 2fc9fd0d503..700f76d4bc4 100644 --- a/src/mesa/swrast/s_drawpix.c +++ b/src/mesa/swrast/s_drawpix.c @@ -881,7 +881,7 @@ _swrast_DrawPixels( GLcontext *ctx, swrast_render_finish(ctx); - _mesa_unmap_drapix_pbo(ctx, unpack); + _mesa_unmap_drawpix_pbo(ctx, unpack); } -- cgit v1.2.3 From 88f3656ea7ae57d22141225db0c5d90ceab420dd Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 9 Feb 2009 12:43:09 -0700 Subject: swrast: use ASSIGN_4V() macro --- src/mesa/swrast/s_fragprog.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/mesa/swrast') diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c index bbb784c46e8..c6601f5593d 100644 --- a/src/mesa/swrast/s_fragprog.c +++ b/src/mesa/swrast/s_fragprog.c @@ -84,8 +84,7 @@ fetch_texel_lod( GLcontext *ctx, const GLfloat texcoord[4], GLfloat lambda, swizzle_texel(rgba, color, texObj->_Swizzle); } else { - color[0] = color[1] = color[2] = 0.0F; - color[3] = 1.0F; + ASSIGN_4V(color, 0.0F, 0.0F, 0.0F, 1.0F); } } @@ -127,8 +126,7 @@ fetch_texel_deriv( GLcontext *ctx, const GLfloat texcoord[4], swizzle_texel(rgba, color, texObj->_Swizzle); } else { - color[0] = color[1] = color[2] = 0.0F; - color[3] = 1.0F; + ASSIGN_4V(color, 0.0F, 0.0F, 0.0F, 1.0F); } } -- cgit v1.2.3