/*
* Mesa 3-D graphics library
- * Version: 7.3
*
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
*/
#include "main/glheader.h"
#include "main/context.h"
-#include "main/colormac.h"
#include "main/imports.h"
#include "main/macros.h"
#include "main/mtypes.h"
+#include "main/state.h"
+#include "main/samplerobj.h"
+#include "main/stencil.h"
+#include "main/teximage.h"
#include "program/prog_instruction.h"
#include "s_aatriangle.h"
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 ex = v1->attrib[VARYING_SLOT_POS][0] - v0->attrib[VARYING_SLOT_POS][0];
+ GLfloat ey = v1->attrib[VARYING_SLOT_POS][1] - v0->attrib[VARYING_SLOT_POS][1];
+ GLfloat fx = v2->attrib[VARYING_SLOT_POS][0] - v0->attrib[VARYING_SLOT_POS][0];
+ GLfloat fy = v2->attrib[VARYING_SLOT_POS][1] - v0->attrib[VARYING_SLOT_POS][1];
GLfloat c = ex*fy-ey*fx;
if (c * swrast->_BackfaceSign * swrast->_BackfaceCullSign <= 0.0F)
#define NAME flat_rgba_triangle
#define INTERP_Z 1
#define SETUP_CODE \
- ASSERT(ctx->Texture._EnabledCoordUnits == 0);\
- ASSERT(ctx->Light.ShadeModel==GL_FLAT); \
+ assert(ctx->Texture._EnabledCoordUnits == 0);\
+ assert(ctx->Light.ShadeModel==GL_FLAT); \
span.interpMask |= SPAN_RGBA; \
span.red = ChanToFixed(v2->color[0]); \
span.green = ChanToFixed(v2->color[1]); \
#define SETUP_CODE \
{ \
/* texturing must be off */ \
- ASSERT(ctx->Texture._EnabledCoordUnits == 0); \
- ASSERT(ctx->Light.ShadeModel==GL_SMOOTH); \
+ assert(ctx->Texture._EnabledCoordUnits == 0); \
+ assert(ctx->Light.ShadeModel==GL_SMOOTH); \
}
#define RENDER_SPAN( span ) _swrast_write_rgba_span(ctx, &span);
#include "s_tritemp.h"
const struct gl_texture_object *obj = \
ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \
const struct gl_texture_image *texImg = \
- obj->Image[0][obj->BaseLevel]; \
+ _mesa_base_tex_image(obj); \
+ const struct swrast_texture_image *swImg = \
+ swrast_texture_image_const(texImg); \
const GLfloat twidth = (GLfloat) texImg->Width; \
const GLfloat theight = (GLfloat) texImg->Height; \
const GLint twidth_log2 = texImg->WidthLog2; \
- const GLubyte *texture = (const GLubyte *) texImg->Data; \
+ const GLubyte *texture = (const GLubyte *) swImg->ImageSlices[0]; \
const GLint smask = texImg->Width - 1; \
const GLint tmask = texImg->Height - 1; \
- ASSERT(texImg->TexFormat == MESA_FORMAT_RGB888); \
+ assert(texImg->TexFormat == MESA_FORMAT_BGR_UNORM8); \
if (!rb || !texture) { \
return; \
}
#define RENDER_SPAN( span ) \
GLuint i; \
- GLubyte rgb[MAX_WIDTH][3]; \
+ GLubyte (*rgba)[4] = swrast->SpanArrays->rgba8; \
span.intTex[0] -= FIXED_HALF; /* off-by-one error? */ \
span.intTex[1] -= FIXED_HALF; \
for (i = 0; i < span.end; i++) { \
GLint t = FixedToInt(span.intTex[1]) & tmask; \
GLint pos = (t << twidth_log2) + s; \
pos = pos + pos + pos; /* multiply by 3 */ \
- rgb[i][RCOMP] = texture[pos+2]; \
- rgb[i][GCOMP] = texture[pos+1]; \
- rgb[i][BCOMP] = texture[pos+0]; \
+ rgba[i][RCOMP] = texture[pos+2]; \
+ rgba[i][GCOMP] = texture[pos+1]; \
+ rgba[i][BCOMP] = texture[pos+0]; \
+ rgba[i][ACOMP] = 0xff; \
span.intTex[0] += span.intTexStep[0]; \
span.intTex[1] += span.intTexStep[1]; \
} \
- rb->PutRowRGB(ctx, rb, span.end, span.x, span.y, rgb, NULL);
+ _swrast_put_row(ctx, rb, GL_UNSIGNED_BYTE, span.end, \
+ span.x, span.y, rgba, NULL);
#include "s_tritemp.h"
const struct gl_texture_object *obj = \
ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \
const struct gl_texture_image *texImg = \
- obj->Image[0][obj->BaseLevel]; \
+ _mesa_base_tex_image(obj); \
+ const struct swrast_texture_image *swImg = \
+ swrast_texture_image_const(texImg); \
const GLfloat twidth = (GLfloat) texImg->Width; \
const GLfloat theight = (GLfloat) texImg->Height; \
const GLint twidth_log2 = texImg->WidthLog2; \
- const GLubyte *texture = (const GLubyte *) texImg->Data; \
+ const GLubyte *texture = (const GLubyte *) swImg->ImageSlices[0]; \
const GLint smask = texImg->Width - 1; \
const GLint tmask = texImg->Height - 1; \
- ASSERT(texImg->TexFormat == MESA_FORMAT_RGB888); \
+ assert(texImg->TexFormat == MESA_FORMAT_BGR_UNORM8); \
if (!rb || !texture) { \
return; \
}
#define RENDER_SPAN( span ) \
GLuint i; \
- GLubyte rgb[MAX_WIDTH][3]; \
+ GLubyte (*rgba)[4] = swrast->SpanArrays->rgba8; \
+ GLubyte *mask = swrast->SpanArrays->mask; \
span.intTex[0] -= FIXED_HALF; /* off-by-one error? */ \
span.intTex[1] -= FIXED_HALF; \
for (i = 0; i < span.end; i++) { \
GLint t = FixedToInt(span.intTex[1]) & tmask; \
GLint pos = (t << twidth_log2) + s; \
pos = pos + pos + pos; /* multiply by 3 */ \
- rgb[i][RCOMP] = texture[pos+2]; \
- rgb[i][GCOMP] = texture[pos+1]; \
- rgb[i][BCOMP] = texture[pos+0]; \
+ rgba[i][RCOMP] = texture[pos+2]; \
+ rgba[i][GCOMP] = texture[pos+1]; \
+ rgba[i][BCOMP] = texture[pos+0]; \
+ rgba[i][ACOMP] = 0xff; \
zRow[i] = z; \
- span.array->mask[i] = 1; \
+ mask[i] = 1; \
} \
else { \
- span.array->mask[i] = 0; \
+ mask[i] = 0; \
} \
span.intTex[0] += span.intTexStep[0]; \
span.intTex[1] += span.intTexStep[1]; \
span.z += span.zStep; \
} \
- rb->PutRowRGB(ctx, rb, span.end, span.x, span.y, rgb, span.array->mask);
+ _swrast_put_row(ctx, rb, GL_UNSIGNED_BYTE, \
+ span.end, span.x, span.y, rgba, mask);
#include "s_tritemp.h"
};
-static INLINE GLint
+static inline GLint
ilerp(GLint t, GLint a, GLint b)
{
return a + ((t * (b - a)) >> FIXED_SHIFT);
}
-static INLINE GLint
+static inline GLint
ilerp_2d(GLint ia, GLint ib, GLint v00, GLint v10, GLint v01, GLint v11)
{
const GLint temp0 = ilerp(ia, v00, v10);
* textures with GL_REPLACE, GL_MODULATE, GL_BLEND, GL_DECAL or GL_ADD
* texture env modes.
*/
-static INLINE void
+static inline void
affine_span(struct gl_context *ctx, SWspan *span,
struct affine_info *info)
{
switch (info->filter) {
case GL_NEAREST:
switch (info->format) {
- case MESA_FORMAT_RGB888:
+ case MESA_FORMAT_BGR_UNORM8:
switch (info->envmode) {
case GL_MODULATE:
SPAN_NEAREST(NEAREST_RGB;MODULATE,3);
return;
}
break;
- case MESA_FORMAT_RGBA8888:
+ case MESA_FORMAT_A8B8G8R8_UNORM:
switch(info->envmode) {
case GL_MODULATE:
SPAN_NEAREST(NEAREST_RGBA;MODULATE,4);
span->intTex[0] -= FIXED_HALF;
span->intTex[1] -= FIXED_HALF;
switch (info->format) {
- case MESA_FORMAT_RGB888:
+ case MESA_FORMAT_BGR_UNORM8:
switch (info->envmode) {
case GL_MODULATE:
SPAN_LINEAR(LINEAR_RGB;MODULATE,3);
return;
}
break;
- case MESA_FORMAT_RGBA8888:
+ case MESA_FORMAT_A8B8G8R8_UNORM:
switch (info->envmode) {
case GL_MODULATE:
SPAN_LINEAR(LINEAR_RGBA;MODULATE,4);
break;
}
span->interpMask &= ~SPAN_RGBA;
- ASSERT(span->arrayMask & SPAN_RGBA);
+ assert(span->arrayMask & SPAN_RGBA);
_swrast_write_rgba_span(ctx, span);
#define SETUP_CODE \
struct affine_info info; \
- struct gl_texture_unit *unit = ctx->Texture.Unit+0; \
+ struct gl_fixedfunc_texture_unit *unit = ctx->Texture.FixedFuncUnit+0; \
const struct gl_texture_object *obj = \
ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \
const struct gl_texture_image *texImg = \
- obj->Image[0][obj->BaseLevel]; \
+ _mesa_base_tex_image(obj); \
+ const struct swrast_texture_image *swImg = \
+ swrast_texture_image_const(texImg); \
const GLfloat twidth = (GLfloat) texImg->Width; \
const GLfloat theight = (GLfloat) texImg->Height; \
- info.texture = (const GLchan *) texImg->Data; \
+ info.texture = (const GLchan *) swImg->ImageSlices[0]; \
info.twidth_log2 = texImg->WidthLog2; \
info.smask = texImg->Width - 1; \
info.tmask = texImg->Height - 1; \
info.format = texImg->TexFormat; \
- info.filter = obj->MinFilter; \
+ info.filter = obj->Sampler.MinFilter; \
info.envmode = unit->EnvMode; \
info.er = 0; \
info.eg = 0; \
} \
\
switch (info.format) { \
- case MESA_FORMAT_RGB888: \
+ case MESA_FORMAT_BGR_UNORM8: \
info.tbytesline = texImg->Width * 3; \
break; \
- case MESA_FORMAT_RGBA8888: \
+ case MESA_FORMAT_A8B8G8R8_UNORM: \
info.tbytesline = texImg->Width * 4; \
break; \
default: \
};
-static INLINE void
+static inline void
fast_persp_span(struct gl_context *ctx, SWspan *span,
struct persp_info *info)
{
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);
- tex_coord[1] = span->attrStart[FRAG_ATTRIB_TEX0][1] * (info->tmask + 1);
- tex_step[1] = span->attrStepX[FRAG_ATTRIB_TEX0][1] * (info->tmask + 1);
- /* span->attrStart[FRAG_ATTRIB_TEX0][2] only if 3D-texturing, here only 2D */
- tex_coord[2] = span->attrStart[FRAG_ATTRIB_TEX0][3];
- tex_step[2] = span->attrStepX[FRAG_ATTRIB_TEX0][3];
+ tex_coord[0] = span->attrStart[VARYING_SLOT_TEX0][0] * (info->smask + 1);
+ tex_step[0] = span->attrStepX[VARYING_SLOT_TEX0][0] * (info->smask + 1);
+ tex_coord[1] = span->attrStart[VARYING_SLOT_TEX0][1] * (info->tmask + 1);
+ tex_step[1] = span->attrStepX[VARYING_SLOT_TEX0][1] * (info->tmask + 1);
+ /* span->attrStart[VARYING_SLOT_TEX0][2] only if 3D-texturing, here only 2D */
+ tex_coord[2] = span->attrStart[VARYING_SLOT_TEX0][3];
+ tex_step[2] = span->attrStepX[VARYING_SLOT_TEX0][3];
switch (info->filter) {
case GL_NEAREST:
switch (info->format) {
- case MESA_FORMAT_RGB888:
+ case MESA_FORMAT_BGR_UNORM8:
switch (info->envmode) {
case GL_MODULATE:
SPAN_NEAREST(NEAREST_RGB;MODULATE,3);
return;
}
break;
- case MESA_FORMAT_RGBA8888:
+ case MESA_FORMAT_A8B8G8R8_UNORM:
switch(info->envmode) {
case GL_MODULATE:
SPAN_NEAREST(NEAREST_RGBA;MODULATE,4);
case GL_LINEAR:
switch (info->format) {
- case MESA_FORMAT_RGB888:
+ case MESA_FORMAT_BGR_UNORM8:
switch (info->envmode) {
case GL_MODULATE:
SPAN_LINEAR(LINEAR_RGB;MODULATE,3);
return;
}
break;
- case MESA_FORMAT_RGBA8888:
+ case MESA_FORMAT_A8B8G8R8_UNORM:
switch (info->envmode) {
case GL_MODULATE:
SPAN_LINEAR(LINEAR_RGBA;MODULATE,4);
break;
}
- ASSERT(span->arrayMask & SPAN_RGBA);
+ assert(span->arrayMask & SPAN_RGBA);
_swrast_write_rgba_span(ctx, span);
#undef SPAN_NEAREST
#define SETUP_CODE \
struct persp_info info; \
- const struct gl_texture_unit *unit = ctx->Texture.Unit+0; \
+ const struct gl_fixedfunc_texture_unit *unit = ctx->Texture.FixedFuncUnit+0; \
const struct gl_texture_object *obj = \
ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; \
const struct gl_texture_image *texImg = \
- obj->Image[0][obj->BaseLevel]; \
- info.texture = (const GLchan *) texImg->Data; \
+ _mesa_base_tex_image(obj); \
+ const struct swrast_texture_image *swImg = \
+ swrast_texture_image_const(texImg); \
+ info.texture = (const GLchan *) swImg->ImageSlices[0]; \
info.twidth_log2 = texImg->WidthLog2; \
info.smask = texImg->Width - 1; \
info.tmask = texImg->Height - 1; \
info.format = texImg->TexFormat; \
- info.filter = obj->MinFilter; \
+ info.filter = obj->Sampler.MinFilter; \
info.envmode = unit->EnvMode; \
info.er = 0; \
info.eg = 0; \
} \
\
switch (info.format) { \
- case MESA_FORMAT_RGB888: \
+ case MESA_FORMAT_BGR_UNORM8: \
info.tbytesline = texImg->Width * 3; \
break; \
- case MESA_FORMAT_RGBA8888: \
+ case MESA_FORMAT_A8B8G8R8_UNORM: \
info.tbytesline = texImg->Width * 4; \
break; \
default: \
/*
* Special tri function for occlusion testing
*/
-#define NAME occlusion_zless_triangle
+#define NAME occlusion_zless_16_triangle
#define INTERP_Z 1
#define SETUP_CODE \
- struct gl_renderbuffer *rb = ctx->DrawBuffer->_DepthBuffer; \
+ struct gl_renderbuffer *rb = \
+ ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer; \
struct gl_query_object *q = ctx->Query.CurrentOcclusionObject; \
- ASSERT(ctx->Depth.Test); \
- ASSERT(!ctx->Depth.Mask); \
- ASSERT(ctx->Depth.Func == GL_LESS); \
+ assert(ctx->Depth.Test); \
+ assert(!ctx->Depth.Mask); \
+ assert(ctx->Depth.Func == GL_LESS); \
+ assert(rb->Format == MESA_FORMAT_Z_UNORM16); \
if (!q) { \
return; \
}
#define RENDER_SPAN( span ) \
- if (rb->Format == MESA_FORMAT_Z16) { \
+ { \
GLuint i; \
const GLushort *zRow = (const GLushort *) \
- rb->GetPointer(ctx, rb, span.x, span.y); \
+ _swrast_pixel_address(rb, span.x, span.y); \
for (i = 0; i < span.end; i++) { \
GLuint z = FixedToDepth(span.z); \
if (z < zRow[i]) { \
} \
span.z += span.zStep; \
} \
- } \
- else { \
- GLuint i; \
- const GLuint *zRow = (const GLuint *) \
- rb->GetPointer(ctx, rb, span.x, span.y); \
- for (i = 0; i < span.end; i++) { \
- if ((GLuint)span.z < zRow[i]) { \
- q->Result++; \
- } \
- span.z += span.zStep; \
- } \
}
#include "s_tritemp.h"
COPY_CHAN4( cSave[1], ncv1->color );
COPY_CHAN4( cSave[2], ncv2->color );
/* sum v0 */
- rSum = CHAN_TO_FLOAT(ncv0->color[0]) + ncv0->attrib[FRAG_ATTRIB_COL1][0];
- gSum = CHAN_TO_FLOAT(ncv0->color[1]) + ncv0->attrib[FRAG_ATTRIB_COL1][1];
- bSum = CHAN_TO_FLOAT(ncv0->color[2]) + ncv0->attrib[FRAG_ATTRIB_COL1][2];
+ rSum = CHAN_TO_FLOAT(ncv0->color[0]) + ncv0->attrib[VARYING_SLOT_COL1][0];
+ gSum = CHAN_TO_FLOAT(ncv0->color[1]) + ncv0->attrib[VARYING_SLOT_COL1][1];
+ bSum = CHAN_TO_FLOAT(ncv0->color[2]) + ncv0->attrib[VARYING_SLOT_COL1][2];
UNCLAMPED_FLOAT_TO_CHAN(ncv0->color[0], rSum);
UNCLAMPED_FLOAT_TO_CHAN(ncv0->color[1], gSum);
UNCLAMPED_FLOAT_TO_CHAN(ncv0->color[2], bSum);
/* sum v1 */
- rSum = CHAN_TO_FLOAT(ncv1->color[0]) + ncv1->attrib[FRAG_ATTRIB_COL1][0];
- gSum = CHAN_TO_FLOAT(ncv1->color[1]) + ncv1->attrib[FRAG_ATTRIB_COL1][1];
- bSum = CHAN_TO_FLOAT(ncv1->color[2]) + ncv1->attrib[FRAG_ATTRIB_COL1][2];
+ rSum = CHAN_TO_FLOAT(ncv1->color[0]) + ncv1->attrib[VARYING_SLOT_COL1][0];
+ gSum = CHAN_TO_FLOAT(ncv1->color[1]) + ncv1->attrib[VARYING_SLOT_COL1][1];
+ bSum = CHAN_TO_FLOAT(ncv1->color[2]) + ncv1->attrib[VARYING_SLOT_COL1][2];
UNCLAMPED_FLOAT_TO_CHAN(ncv1->color[0], rSum);
UNCLAMPED_FLOAT_TO_CHAN(ncv1->color[1], gSum);
UNCLAMPED_FLOAT_TO_CHAN(ncv1->color[2], bSum);
/* sum v2 */
- rSum = CHAN_TO_FLOAT(ncv2->color[0]) + ncv2->attrib[FRAG_ATTRIB_COL1][0];
- gSum = CHAN_TO_FLOAT(ncv2->color[1]) + ncv2->attrib[FRAG_ATTRIB_COL1][1];
- bSum = CHAN_TO_FLOAT(ncv2->color[2]) + ncv2->attrib[FRAG_ATTRIB_COL1][2];
+ rSum = CHAN_TO_FLOAT(ncv2->color[0]) + ncv2->attrib[VARYING_SLOT_COL1][0];
+ gSum = CHAN_TO_FLOAT(ncv2->color[1]) + ncv2->attrib[VARYING_SLOT_COL1][1];
+ bSum = CHAN_TO_FLOAT(ncv2->color[2]) + ncv2->attrib[VARYING_SLOT_COL1][2];
UNCLAMPED_FLOAT_TO_CHAN(ncv2->color[0], rSum);
UNCLAMPED_FLOAT_TO_CHAN(ncv2->color[1], gSum);
UNCLAMPED_FLOAT_TO_CHAN(ncv2->color[2], bSum);
}
if (ctx->RenderMode==GL_RENDER) {
+ struct gl_renderbuffer *depthRb =
+ ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
if (ctx->Polygon.SmoothFlag) {
_swrast_set_aa_triangle_function(ctx);
- ASSERT(swrast->Triangle);
+ assert(swrast->Triangle);
return;
}
ctx->Depth.Test &&
ctx->Depth.Mask == GL_FALSE &&
ctx->Depth.Func == GL_LESS &&
- !ctx->Stencil._Enabled) {
- if (ctx->Color.ColorMask[0][0] == 0 &&
- ctx->Color.ColorMask[0][1] == 0 &&
- ctx->Color.ColorMask[0][2] == 0 &&
- ctx->Color.ColorMask[0][3] == 0) {
- USE(occlusion_zless_triangle);
+ !_mesa_stencil_is_enabled(ctx) &&
+ depthRb &&
+ depthRb->Format == MESA_FORMAT_Z_UNORM16) {
+ if (GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 0) == 0 &&
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 1) == 0 &&
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 2) == 0 &&
+ GET_COLORMASK_BIT(ctx->Color.ColorMask, 0, 3) == 0) {
+ USE(occlusion_zless_16_triangle);
return;
}
}
* needs to be interpolated.
*/
if (ctx->Texture._EnabledCoordUnits ||
- ctx->FragmentProgram._Current ||
- ctx->ATIFragmentShader._Enabled ||
- NEED_SECONDARY_COLOR(ctx) ||
+ _swrast_use_fragment_program(ctx) ||
+ _mesa_ati_fragment_shader_enabled(ctx) ||
+ _mesa_need_secondary_color(ctx) ||
swrast->_FogEnabled) {
/* Ugh, we do a _lot_ of tests to pick the best textured tri func */
const struct gl_texture_object *texObj2D;
+ const struct gl_sampler_object *samp;
const struct gl_texture_image *texImg;
+ const struct swrast_texture_image *swImg;
GLenum minFilter, magFilter, envMode;
- gl_format format;
+ mesa_format format;
texObj2D = ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX];
+ if (ctx->Texture.Unit[0].Sampler)
+ samp = ctx->Texture.Unit[0].Sampler;
+ else if (texObj2D)
+ samp = &texObj2D->Sampler;
+ else
+ samp = NULL;
+
+ texImg = texObj2D ? _mesa_base_tex_image(texObj2D) : NULL;
+ swImg = swrast_texture_image_const(texImg);
- texImg = texObj2D ? texObj2D->Image[0][texObj2D->BaseLevel] : NULL;
format = texImg ? texImg->TexFormat : MESA_FORMAT_NONE;
- minFilter = texObj2D ? texObj2D->MinFilter : GL_NONE;
- magFilter = texObj2D ? texObj2D->MagFilter : GL_NONE;
- envMode = ctx->Texture.Unit[0].EnvMode;
+ minFilter = texObj2D ? samp->MinFilter : GL_NONE;
+ magFilter = texObj2D ? samp->MagFilter : GL_NONE;
+ envMode = ctx->Texture.FixedFuncUnit[0].EnvMode;
/* First see if we can use an optimized 2-D texture function */
if (ctx->Texture._EnabledCoordUnits == 0x1
- && !ctx->FragmentProgram._Current
- && !ctx->ATIFragmentShader._Enabled
- && ctx->Texture._EnabledUnits == 0x1
- && ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT
- && texObj2D->WrapS == GL_REPEAT
- && texObj2D->WrapT == GL_REPEAT
+ && !_swrast_use_fragment_program(ctx)
+ && !_mesa_ati_fragment_shader_enabled(ctx)
+ && ctx->Texture._MaxEnabledTexImageUnit == 0
+ && ctx->Texture.Unit[0]._Current->Target == GL_TEXTURE_2D
+ && samp->WrapS == GL_REPEAT
+ && samp->WrapT == GL_REPEAT
&& texObj2D->_Swizzle == SWIZZLE_NOOP
- && texImg->_IsPowerOfTwo
+ && swImg->_IsPowerOfTwo
&& texImg->Border == 0
- && texImg->Width == texImg->RowStride
- && (format == MESA_FORMAT_RGB888 || format == MESA_FORMAT_RGBA8888)
+ && (_mesa_format_row_stride(format, texImg->Width) ==
+ swImg->RowStride)
+ && (format == MESA_FORMAT_BGR_UNORM8 || format == MESA_FORMAT_A8B8G8R8_UNORM)
&& 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_COMBINE4_NV) {
+ && ctx->Texture.FixedFuncUnit[0].EnvMode != GL_COMBINE_EXT
+ && ctx->Texture.FixedFuncUnit[0].EnvMode != GL_COMBINE4_NV) {
if (ctx->Hint.PerspectiveCorrection==GL_FASTEST) {
if (minFilter == GL_NEAREST
- && format == MESA_FORMAT_RGB888
+ && format == MESA_FORMAT_BGR_UNORM8
&& (envMode == GL_REPLACE || envMode == GL_DECAL)
&& ((swrast->_RasterMask == (DEPTH_BIT | TEXTURE_BIT)
&& ctx->Depth.Func == GL_LESS
#if CHAN_BITS != 8
USE(general_triangle);
#else
- if (format == MESA_FORMAT_RGBA8888 && !_mesa_little_endian()) {
+ if (format == MESA_FORMAT_A8B8G8R8_UNORM && !_mesa_little_endian()) {
/* We only handle RGBA8888 correctly on little endian
* in the optimized code above.
*/
}
}
else {
- ASSERT(!swrast->_FogEnabled);
- ASSERT(!NEED_SECONDARY_COLOR(ctx));
+ assert(!swrast->_FogEnabled);
+ assert(!_mesa_need_secondary_color(ctx));
if (ctx->Light.ShadeModel==GL_SMOOTH) {
/* smooth shaded, no texturing, stippled or some raster ops */
#if CHAN_BITS != 8