X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fswrast%2Fs_triangle.c;h=1ab0e19f922860013e6aae57381dea6db7d88e51;hb=19119517ce00f7710c6cd627c75e7eef765021c2;hp=a2e8433e27145b35e12d9ee7e156ff59b280d689;hpb=4df482086ebf0663c708b089d8d8d22de0ef972c;p=mesa.git diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c index a2e8433e271..1ab0e19f922 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" @@ -43,8 +44,9 @@ #include "s_triangle.h" -/* - * Just used for feedback mode. +/** + * Test if a triangle should be culled. Used for feedback and selection mode. + * \return GL_TRUE if the triangle is to be culled, GL_FALSE otherwise. */ GLboolean _swrast_culltriangle( GLcontext *ctx, @@ -52,16 +54,17 @@ _swrast_culltriangle( GLcontext *ctx, const SWvertex *v1, const SWvertex *v2 ) { + SWcontext *swrast = SWRAST_CONTEXT(ctx); GLfloat ex = v1->attrib[FRAG_ATTRIB_WPOS][0] - v0->attrib[FRAG_ATTRIB_WPOS][0]; GLfloat ey = v1->attrib[FRAG_ATTRIB_WPOS][1] - v0->attrib[FRAG_ATTRIB_WPOS][1]; GLfloat fx = v2->attrib[FRAG_ATTRIB_WPOS][0] - v0->attrib[FRAG_ATTRIB_WPOS][0]; GLfloat fy = v2->attrib[FRAG_ATTRIB_WPOS][1] - v0->attrib[FRAG_ATTRIB_WPOS][1]; GLfloat c = ex*fy-ey*fx; - if (c * SWRAST_CONTEXT(ctx)->_BackfaceCullSign > 0) - return 0; + if (c * swrast->_BackfaceSign * swrast->_BackfaceCullSign <= 0.0F) + return GL_FALSE; - return 1; + return GL_TRUE; } @@ -131,7 +134,8 @@ _swrast_culltriangle( GLcontext *ctx, #define SETUP_CODE \ struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0]; \ - struct gl_texture_object *obj = ctx->Texture.Unit[0].Current2D; \ + struct gl_texture_object *obj = \ + ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \ const GLint b = obj->BaseLevel; \ const GLfloat twidth = (GLfloat) obj->Image[0][b]->Width; \ const GLfloat theight = (GLfloat) obj->Image[0][b]->Height; \ @@ -182,7 +186,8 @@ _swrast_culltriangle( GLcontext *ctx, #define SETUP_CODE \ struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0]; \ - struct gl_texture_object *obj = ctx->Texture.Unit[0].Current2D; \ + struct gl_texture_object *obj = \ + ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \ const GLint b = obj->BaseLevel; \ const GLfloat twidth = (GLfloat) obj->Image[0][b]->Width; \ const GLfloat theight = (GLfloat) obj->Image[0][b]->Height; \ @@ -263,10 +268,7 @@ affine_span(GLcontext *ctx, SWspan *span, struct affine_info *info) { 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; + const GLuint texEnableSave = ctx->Texture._EnabledCoordUnits; /* Instead of defining a function for each mode, a test is done * between the outer and inner loops. This is to reduce code size @@ -396,6 +398,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._EnabledCoordUnits = 0x0; + span->intTex[0] -= FIXED_HALF; span->intTex[1] -= FIXED_HALF; switch (info->filter) { @@ -501,7 +506,7 @@ affine_span(GLcontext *ctx, SWspan *span, _swrast_write_rgba_span(ctx, span); /* re-enable texture units */ - ctx->Texture._EnabledUnits = texEnableSave; + ctx->Texture._EnabledCoordUnits = texEnableSave; #undef SPAN_NEAREST #undef SPAN_LINEAR @@ -523,7 +528,8 @@ affine_span(GLcontext *ctx, SWspan *span, #define SETUP_CODE \ struct affine_info info; \ struct gl_texture_unit *unit = ctx->Texture.Unit+0; \ - struct gl_texture_object *obj = unit->Current2D; \ + struct gl_texture_object *obj = \ + ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \ const GLint b = obj->BaseLevel; \ const GLfloat twidth = (GLfloat) obj->Image[0][b]->Width; \ const GLfloat theight = (GLfloat) obj->Image[0][b]->Height; \ @@ -660,8 +666,8 @@ fast_persp_span(GLcontext *ctx, SWspan *span, GLfloat tex_coord[3], tex_step[3]; GLchan *dest = span->array->rgba[0]; - const GLuint savedTexEnable = ctx->Texture._EnabledUnits; - ctx->Texture._EnabledUnits = 0; + const GLuint texEnableSave = ctx->Texture._EnabledCoordUnits; + ctx->Texture._EnabledCoordUnits = 0; tex_coord[0] = span->attrStart[FRAG_ATTRIB_TEX0][0] * (info->smask + 1); tex_step[0] = span->attrStepX[FRAG_ATTRIB_TEX0][0] * (info->smask + 1); @@ -774,7 +780,7 @@ fast_persp_span(GLcontext *ctx, SWspan *span, #undef SPAN_LINEAR /* restore state */ - ctx->Texture._EnabledUnits = savedTexEnable; + ctx->Texture._EnabledCoordUnits = texEnableSave; } @@ -793,7 +799,8 @@ fast_persp_span(GLcontext *ctx, SWspan *span, #define SETUP_CODE \ struct persp_info info; \ const struct gl_texture_unit *unit = ctx->Texture.Unit+0; \ - const struct gl_texture_object *obj = unit->Current2D; \ + struct gl_texture_object *obj = \ + ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \ const GLint b = obj->BaseLevel; \ info.texture = (const GLchan *) obj->Image[0][b]->Data; \ info.twidth_log2 = obj->Image[0][b]->WidthLog2; \ @@ -1017,7 +1024,7 @@ _swrast_choose_triangle( GLcontext *ctx ) ctx->Depth.Test && ctx->Depth.Mask == GL_FALSE && ctx->Depth.Func == GL_LESS && - !ctx->Stencil.Enabled) { + !ctx->Stencil._Enabled) { if ((rgbmode && ctx->Color.ColorMask[0] == 0 && ctx->Color.ColorMask[1] == 0 && @@ -1049,7 +1056,8 @@ _swrast_choose_triangle( GLcontext *ctx ) const struct gl_texture_image *texImg; GLenum minFilter, magFilter, envMode; GLint format; - texObj2D = ctx->Texture.Unit[0].Current2D; + texObj2D = ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; + texImg = texObj2D ? texObj2D->Image[0][texObj2D->BaseLevel] : NULL; format = texImg ? texImg->TexFormat->MesaFormat : -1; minFilter = texObj2D ? texObj2D->MinFilter : (GLenum) 0; @@ -1063,6 +1071,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 @@ -1070,7 +1079,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