diff options
author | marha <marha@users.sourceforge.net> | 2010-03-07 13:28:57 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2010-03-07 13:28:57 +0000 |
commit | 14b1cb8d5a27ec9716d3f790fce95f0469e35605 (patch) | |
tree | 6c94dc9f37b19b995bec603141442b1b93e8c9d2 /mesalib/src/mesa/swrast | |
parent | 93c85587c691f9b91e7c2d8bda50f453e0f6674d (diff) | |
download | vcxsrv-14b1cb8d5a27ec9716d3f790fce95f0469e35605.tar.gz vcxsrv-14b1cb8d5a27ec9716d3f790fce95f0469e35605.tar.bz2 vcxsrv-14b1cb8d5a27ec9716d3f790fce95f0469e35605.zip |
Updated to Mesa 7.7
Diffstat (limited to 'mesalib/src/mesa/swrast')
-rw-r--r-- | mesalib/src/mesa/swrast/NOTES | 55 | ||||
-rw-r--r-- | mesalib/src/mesa/swrast/s_atifragshader.c | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/swrast/s_clear.c | 8 | ||||
-rw-r--r-- | mesalib/src/mesa/swrast/s_depth.c | 50 | ||||
-rw-r--r-- | mesalib/src/mesa/swrast/s_depth.h | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/swrast/s_fragprog.c | 12 | ||||
-rw-r--r-- | mesalib/src/mesa/swrast/s_imaging.c | 196 | ||||
-rw-r--r-- | mesalib/src/mesa/swrast/s_readpix.c | 34 | ||||
-rw-r--r-- | mesalib/src/mesa/swrast/s_span.c | 11 | ||||
-rw-r--r-- | mesalib/src/mesa/swrast/s_texfilter.c | 64 | ||||
-rw-r--r-- | mesalib/src/mesa/swrast/s_texstore.c | 601 | ||||
-rw-r--r-- | mesalib/src/mesa/swrast/s_triangle.c | 199 | ||||
-rw-r--r-- | mesalib/src/mesa/swrast/swrast.h | 54 |
13 files changed, 229 insertions, 1059 deletions
diff --git a/mesalib/src/mesa/swrast/NOTES b/mesalib/src/mesa/swrast/NOTES deleted file mode 100644 index f906e41b9..000000000 --- a/mesalib/src/mesa/swrast/NOTES +++ /dev/null @@ -1,55 +0,0 @@ -INTRODUCTION - -Mesa's native software rasterizer. This module provides the fallback -paths for rasterization operations and states that aren't accelerated -in hardware drivers, and as the full rasterization engine in software -drivers. - -The swrast module 'stands alone', relying only on interfaces to core -mesa and it's own driver interface. It knows nothing about the tnl or -other modules, allowing it to be used for fallback paths in future tnl -schemes without modification. - -As well as providing triangle/line/point rasterization functionality, -the module provides implementations of the pixel operations -(ReadPixels, etc), and texture operations (CopyTexSubImage) which may -be plugged in to the core Mesa driver interface where accelerated -versions of these operations are unavailable. - - -STATE - -To create and destroy the module: - - GLboolean _swrast_CreateContext( GLcontext *ctx ); - void _swrast_DestroyContext( GLcontext *ctx ); - -This module tracks state changes internally and maintains derived -values based on the current state. For this to work, the driver -ensure the following funciton is called whenever the state changes and -the swsetup module is 'awake': - - void _swrast_InvalidateState( GLcontext *ctx, GLuint new_state ); - -There is no explicit call to put the swrast module to sleep. - - -CUSTOMIZATION - - void (*choose_point)( GLcontext * ); - void (*choose_line)( GLcontext * ); - void (*choose_triangle)( GLcontext * ); - -Drivers may add additional triangle/line/point functions to swrast by -overriding these functions. It is necessary for the driver to be very -careful that it doesn't return an inappropriate function, eg a -rasterization function in feedback mode. See the X11 driver for -examples. - -DRIVER INTERFACE - -The swrast device driver provides swrast primarily with span- and -pixel- level interfaces to a framebuffer, with a few additional hooks -for locking and setting the read buffer. - -See the definition of struct swrast_device_driver in swrast.h.
\ No newline at end of file diff --git a/mesalib/src/mesa/swrast/s_atifragshader.c b/mesalib/src/mesa/swrast/s_atifragshader.c index 5fefae6c4..e88ff1912 100644 --- a/mesalib/src/mesa/swrast/s_atifragshader.c +++ b/mesalib/src/mesa/swrast/s_atifragshader.c @@ -279,7 +279,7 @@ handle_sample_op(GLcontext * ctx, struct atifs_machine *machine, /* sample from unit idx using texinst->src as coords */ GLuint swizzle = texinst->swizzle; GLuint coord_source = texinst->src; - GLfloat tex_coords[4]; + GLfloat tex_coords[4] = { 0 }; if (coord_source >= GL_TEXTURE0_ARB && coord_source <= GL_TEXTURE7_ARB) { coord_source -= GL_TEXTURE0_ARB; diff --git a/mesalib/src/mesa/swrast/s_clear.c b/mesalib/src/mesa/swrast/s_clear.c index 35080fd39..002718ded 100644 --- a/mesalib/src/mesa/swrast/s_clear.c +++ b/mesalib/src/mesa/swrast/s_clear.c @@ -24,6 +24,7 @@ #include "main/glheader.h" #include "main/colormac.h" +#include "main/formats.h" #include "main/macros.h" #include "main/imports.h" #include "main/mtypes.h" @@ -211,9 +212,6 @@ clear_ci_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) ASSERT(!ctx->Visual.rgbMode); - ASSERT((ctx->Color.IndexMask & ((1 << rb->IndexBits) - 1)) - == (GLuint) ((1 << rb->IndexBits) - 1)); - ASSERT(rb->PutMonoRow); /* setup clear value */ @@ -264,8 +262,8 @@ clear_color_buffers(GLcontext *ctx) } else { struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0]; - const GLuint indexBits = (1 << rb->IndexBits) - 1; - if ((ctx->Color.IndexMask & indexBits) == indexBits) { + const GLuint indexMask = (1 << _mesa_get_format_bits(rb->Format, GL_INDEX_BITS)) - 1; + if ((ctx->Color.IndexMask & indexMask) == indexMask) { masking = GL_FALSE; } else { diff --git a/mesalib/src/mesa/swrast/s_depth.c b/mesalib/src/mesa/swrast/s_depth.c index 7086cae0c..c37a54eb3 100644 --- a/mesalib/src/mesa/swrast/s_depth.c +++ b/mesalib/src/mesa/swrast/s_depth.c @@ -25,6 +25,7 @@ #include "main/glheader.h" #include "main/context.h" +#include "main/formats.h" #include "main/macros.h" #include "main/imports.h" #include "main/fbobject.h" @@ -497,6 +498,43 @@ depth_test_span32( GLcontext *ctx, GLuint n, return passed; } +/* Apply ARB_depth_clamp to span of fragments. */ +void +_swrast_depth_clamp_span( GLcontext *ctx, SWspan *span ) +{ + struct gl_framebuffer *fb = ctx->DrawBuffer; + struct gl_renderbuffer *rb = fb->_DepthBuffer; + const GLuint count = span->end; + GLuint *zValues = span->array->z; + GLuint min, max; + GLfloat min_f, max_f; + int i; + + if (ctx->Viewport.Near < ctx->Viewport.Far) { + min_f = ctx->Viewport.Near; + max_f = ctx->Viewport.Far; + } else { + min_f = ctx->Viewport.Far; + max_f = ctx->Viewport.Near; + } + + if (rb->DataType == GL_UNSIGNED_SHORT) { + CLAMPED_FLOAT_TO_USHORT(min, min_f); + CLAMPED_FLOAT_TO_USHORT(max, max_f); + } else { + assert(rb->DataType == GL_UNSIGNED_INT); + min = FLOAT_TO_UINT(min_f); + max = FLOAT_TO_UINT(max_f); + } + + for (i = 0; i < count; i++) { + if (zValues[i] < min) + zValues[i] = min; + if (zValues[i] > max) + zValues[i] = max; + } +} + /* @@ -1272,12 +1310,16 @@ void _swrast_read_depth_span_uint( GLcontext *ctx, struct gl_renderbuffer *rb, GLint n, GLint x, GLint y, GLuint depth[] ) { + GLuint depthBits; + if (!rb) { /* really only doing this to prevent FP exceptions later */ _mesa_bzero(depth, n * sizeof(GLuint)); return; } + depthBits = _mesa_get_format_bits(rb->Format, GL_DEPTH_BITS); + ASSERT(rb->_BaseFormat == GL_DEPTH_COMPONENT); if (y < 0 || y >= (GLint) rb->Height || @@ -1309,8 +1351,8 @@ _swrast_read_depth_span_uint( GLcontext *ctx, struct gl_renderbuffer *rb, if (rb->DataType == GL_UNSIGNED_INT) { rb->GetRow(ctx, rb, n, x, y, depth); - if (rb->DepthBits < 32) { - GLuint shift = 32 - rb->DepthBits; + if (depthBits < 32) { + GLuint shift = 32 - depthBits; GLint i; for (i = 0; i < n; i++) { GLuint z = depth[i]; @@ -1322,14 +1364,14 @@ _swrast_read_depth_span_uint( GLcontext *ctx, struct gl_renderbuffer *rb, GLushort temp[MAX_WIDTH]; GLint i; rb->GetRow(ctx, rb, n, x, y, temp); - if (rb->DepthBits == 16) { + if (depthBits == 16) { for (i = 0; i < n; i++) { GLuint z = temp[i]; depth[i] = (z << 16) | z; } } else { - GLuint shift = 16 - rb->DepthBits; + GLuint shift = 16 - depthBits; for (i = 0; i < n; i++) { GLuint z = temp[i]; depth[i] = (z << (shift + 16)) | (z << shift); /* XXX lsb bits? */ diff --git a/mesalib/src/mesa/swrast/s_depth.h b/mesalib/src/mesa/swrast/s_depth.h index 368862568..7eae36674 100644 --- a/mesalib/src/mesa/swrast/s_depth.h +++ b/mesalib/src/mesa/swrast/s_depth.h @@ -33,6 +33,8 @@ extern GLuint _swrast_depth_test_span( GLcontext *ctx, SWspan *span); +extern void +_swrast_depth_clamp_span( GLcontext *ctx, SWspan *span ); extern GLboolean _swrast_depth_bounds_test( GLcontext *ctx, SWspan *span ); diff --git a/mesalib/src/mesa/swrast/s_fragprog.c b/mesalib/src/mesa/swrast/s_fragprog.c index 77a77f0bc..a22d34415 100644 --- a/mesalib/src/mesa/swrast/s_fragprog.c +++ b/mesalib/src/mesa/swrast/s_fragprog.c @@ -190,7 +190,7 @@ run_program(GLcontext *ctx, SWspan *span, GLuint start, GLuint end) { SWcontext *swrast = SWRAST_CONTEXT(ctx); const struct gl_fragment_program *program = ctx->FragmentProgram._Current; - const GLbitfield outputsWritten = program->Base.OutputsWritten; + const GLbitfield64 outputsWritten = program->Base.OutputsWritten; struct gl_program_machine *machine = &swrast->FragProgMachine; GLuint i; @@ -201,7 +201,7 @@ run_program(GLcontext *ctx, SWspan *span, GLuint start, GLuint end) if (_mesa_execute_program(ctx, &program->Base, machine)) { /* Store result color */ - if (outputsWritten & (1 << FRAG_RESULT_COLOR)) { + if (outputsWritten & BITFIELD64_BIT(FRAG_RESULT_COLOR)) { COPY_4V(span->array->attribs[FRAG_ATTRIB_COL0][i], machine->Outputs[FRAG_RESULT_COLOR]); } @@ -212,7 +212,7 @@ run_program(GLcontext *ctx, SWspan *span, GLuint start, GLuint end) */ GLuint buf; for (buf = 0; buf < ctx->DrawBuffer->_NumColorDrawBuffers; buf++) { - if (outputsWritten & (1 << (FRAG_RESULT_DATA0 + buf))) { + if (outputsWritten & BITFIELD64_BIT(FRAG_RESULT_DATA0 + buf)) { COPY_4V(span->array->attribs[FRAG_ATTRIB_COL0 + buf][i], machine->Outputs[FRAG_RESULT_DATA0 + buf]); } @@ -220,7 +220,7 @@ run_program(GLcontext *ctx, SWspan *span, GLuint start, GLuint end) } /* Store result depth/z */ - if (outputsWritten & (1 << FRAG_RESULT_DEPTH)) { + if (outputsWritten & BITFIELD64_BIT(FRAG_RESULT_DEPTH)) { const GLfloat depth = machine->Outputs[FRAG_RESULT_DEPTH][2]; if (depth <= 0.0) span->array->z[i] = 0; @@ -256,12 +256,12 @@ _swrast_exec_fragment_program( GLcontext *ctx, SWspan *span ) run_program(ctx, span, 0, span->end); - if (program->Base.OutputsWritten & (1 << FRAG_RESULT_COLOR)) { + if (program->Base.OutputsWritten & BITFIELD64_BIT(FRAG_RESULT_COLOR)) { span->interpMask &= ~SPAN_RGBA; span->arrayMask |= SPAN_RGBA; } - if (program->Base.OutputsWritten & (1 << FRAG_RESULT_DEPTH)) { + if (program->Base.OutputsWritten & BITFIELD64_BIT(FRAG_RESULT_DEPTH)) { span->interpMask &= ~SPAN_Z; span->arrayMask |= SPAN_Z; } diff --git a/mesalib/src/mesa/swrast/s_imaging.c b/mesalib/src/mesa/swrast/s_imaging.c deleted file mode 100644 index 3578b713f..000000000 --- a/mesalib/src/mesa/swrast/s_imaging.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2005 Brian Paul 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"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * 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. - */ - -/* KW: Moved these here to remove knowledge of swrast from core mesa. - * Should probably pull the entire software implementation of these - * extensions into either swrast or a sister module. - */ - -#include "main/glheader.h" -#include "main/colortab.h" -#include "main/convolve.h" -#include "s_context.h" -#include "s_span.h" - - -void -_swrast_CopyColorTable( GLcontext *ctx, - GLenum target, GLenum internalformat, - GLint x, GLint y, GLsizei width) -{ - GLchan data[MAX_WIDTH][4]; - struct gl_buffer_object *bufferSave; - - if (!ctx->ReadBuffer->_ColorReadBuffer) { - /* no readbuffer - OK */ - return; - } - - if (width > MAX_WIDTH) - width = MAX_WIDTH; - - swrast_render_start(ctx); - - /* read the data from framebuffer */ - _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer, - width, x, y, CHAN_TYPE, data ); - - swrast_render_finish(ctx); - - /* save PBO binding */ - bufferSave = ctx->Unpack.BufferObj; - ctx->Unpack.BufferObj = ctx->Shared->NullBufferObj; - - _mesa_ColorTable(target, internalformat, width, GL_RGBA, CHAN_TYPE, data); - - /* restore PBO binding */ - ctx->Unpack.BufferObj = bufferSave; -} - - -void -_swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start, - GLint x, GLint y, GLsizei width) -{ - GLchan data[MAX_WIDTH][4]; - struct gl_buffer_object *bufferSave; - - if (!ctx->ReadBuffer->_ColorReadBuffer) { - /* no readbuffer - OK */ - return; - } - - if (width > MAX_WIDTH) - width = MAX_WIDTH; - - swrast_render_start(ctx); - - /* read the data from framebuffer */ - _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer, - width, x, y, CHAN_TYPE, data ); - - swrast_render_finish(ctx); - - /* save PBO binding */ - bufferSave = ctx->Unpack.BufferObj; - ctx->Unpack.BufferObj = ctx->Shared->NullBufferObj; - - _mesa_ColorSubTable(target, start, width, GL_RGBA, CHAN_TYPE, data); - - /* restore PBO binding */ - ctx->Unpack.BufferObj = bufferSave; -} - - -void -_swrast_CopyConvolutionFilter1D(GLcontext *ctx, GLenum target, - GLenum internalFormat, - GLint x, GLint y, GLsizei width) -{ - GLchan rgba[MAX_CONVOLUTION_WIDTH][4]; - struct gl_buffer_object *bufferSave; - - if (!ctx->ReadBuffer->_ColorReadBuffer) { - /* no readbuffer - OK */ - return; - } - - swrast_render_start(ctx); - - /* read the data from framebuffer */ - _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer, - width, x, y, CHAN_TYPE, rgba ); - - swrast_render_finish(ctx); - - /* save PBO binding */ - bufferSave = ctx->Unpack.BufferObj; - ctx->Unpack.BufferObj = ctx->Shared->NullBufferObj; - - /* store as convolution filter */ - _mesa_ConvolutionFilter1D(target, internalFormat, width, - GL_RGBA, CHAN_TYPE, rgba); - - /* restore PBO binding */ - ctx->Unpack.BufferObj = bufferSave; -} - - -void -_swrast_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target, - GLenum internalFormat, - GLint x, GLint y, GLsizei width, GLsizei height) -{ - struct gl_pixelstore_attrib packSave; - GLchan rgba[MAX_CONVOLUTION_HEIGHT][MAX_CONVOLUTION_WIDTH][4]; - GLint i; - struct gl_buffer_object *bufferSave; - - if (!ctx->ReadBuffer->_ColorReadBuffer) { - /* no readbuffer - OK */ - return; - } - - swrast_render_start(ctx); - - /* read pixels from framebuffer */ - for (i = 0; i < height; i++) { - _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer, - width, x, y + i, CHAN_TYPE, rgba[i] ); - } - - swrast_render_finish(ctx); - - /* - * HACK: save & restore context state so we can store this as a - * convolution filter via the GL api. Doesn't call any callbacks - * hanging off ctx->Unpack statechanges. - */ - - packSave = ctx->Unpack; /* save pixel packing params */ - - ctx->Unpack.Alignment = 1; - ctx->Unpack.RowLength = MAX_CONVOLUTION_WIDTH; - ctx->Unpack.SkipPixels = 0; - ctx->Unpack.SkipRows = 0; - ctx->Unpack.ImageHeight = 0; - ctx->Unpack.SkipImages = 0; - ctx->Unpack.SwapBytes = GL_FALSE; - ctx->Unpack.LsbFirst = GL_FALSE; - ctx->Unpack.BufferObj = ctx->Shared->NullBufferObj; - ctx->NewState |= _NEW_PACKUNPACK; - - /* save PBO binding */ - bufferSave = ctx->Unpack.BufferObj; - ctx->Unpack.BufferObj = ctx->Shared->NullBufferObj; - - _mesa_ConvolutionFilter2D(target, internalFormat, width, height, - GL_RGBA, CHAN_TYPE, rgba); - - /* restore PBO binding */ - ctx->Unpack.BufferObj = bufferSave; - - ctx->Unpack = packSave; /* restore pixel packing params */ - ctx->NewState |= _NEW_PACKUNPACK; -} diff --git a/mesalib/src/mesa/swrast/s_readpix.c b/mesalib/src/mesa/swrast/s_readpix.c index 48b9408d2..44a11cd6d 100644 --- a/mesalib/src/mesa/swrast/s_readpix.c +++ b/mesalib/src/mesa/swrast/s_readpix.c @@ -29,6 +29,7 @@ #include "main/convolve.h" #include "main/context.h" #include "main/feedback.h" +#include "main/formats.h" #include "main/image.h" #include "main/macros.h" #include "main/imports.h" @@ -107,7 +108,7 @@ read_depth_pixels( GLcontext *ctx, && !biasOrScale && !packing->SwapBytes) { /* Special case: directly read 16-bit unsigned depth values. */ GLint j; - ASSERT(rb->InternalFormat == GL_DEPTH_COMPONENT16); + ASSERT(rb->Format == MESA_FORMAT_Z16); ASSERT(rb->DataType == GL_UNSIGNED_SHORT); for (j = 0; j < height; j++, y++) { void *dest =_mesa_image_address2d(packing, pixels, width, height, @@ -119,8 +120,12 @@ read_depth_pixels( GLcontext *ctx, && !biasOrScale && !packing->SwapBytes) { /* Special case: directly read 24-bit unsigned depth values. */ GLint j; - ASSERT(rb->InternalFormat == GL_DEPTH_COMPONENT24); - ASSERT(rb->DataType == GL_UNSIGNED_INT); + ASSERT(rb->Format == MESA_FORMAT_X8_Z24 || + rb->Format == MESA_FORMAT_S8_Z24 || + rb->Format == MESA_FORMAT_Z24_X8 || + rb->Format == MESA_FORMAT_Z24_S8); + ASSERT(rb->DataType == GL_UNSIGNED_INT || + rb->DataType == GL_UNSIGNED_INT_24_8); for (j = 0; j < height; j++, y++) { GLuint *dest = (GLuint *) _mesa_image_address2d(packing, pixels, width, height, @@ -128,9 +133,18 @@ read_depth_pixels( GLcontext *ctx, GLint k; rb->GetRow(ctx, rb, width, x, y, dest); /* convert range from 24-bit to 32-bit */ - for (k = 0; k < width; k++) { - /* Note: put MSByte of 24-bit value into LSByte */ - dest[k] = (dest[k] << 8) | ((dest[k] >> 16) & 0xff); + if (rb->Format == MESA_FORMAT_X8_Z24 || + rb->Format == MESA_FORMAT_S8_Z24) { + for (k = 0; k < width; k++) { + /* Note: put MSByte of 24-bit value into LSByte */ + dest[k] = (dest[k] << 8) | ((dest[k] >> 16) & 0xff); + } + } + else { + for (k = 0; k < width; k++) { + /* Note: fill in LSByte by replication */ + dest[k] = dest[k] | ((dest[k] >> 8) & 0xff); + } } } } @@ -138,7 +152,7 @@ read_depth_pixels( GLcontext *ctx, && !biasOrScale && !packing->SwapBytes) { /* Special case: directly read 32-bit unsigned depth values. */ GLint j; - ASSERT(rb->InternalFormat == GL_DEPTH_COMPONENT32); + ASSERT(rb->Format == MESA_FORMAT_Z32); ASSERT(rb->DataType == GL_UNSIGNED_INT); for (j = 0; j < height; j++, y++) { void *dest = _mesa_image_address2d(packing, pixels, width, height, @@ -555,15 +569,15 @@ _swrast_ReadPixels( GLcontext *ctx, SWcontext *swrast = SWRAST_CONTEXT(ctx); struct gl_pixelstore_attrib clippedPacking = *packing; + if (ctx->NewState) + _mesa_update_state(ctx); + /* 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. */ swrast_render_start(ctx); - if (ctx->NewState) - _mesa_update_state(ctx); - if (swrast->NewState) _swrast_validate_derived( ctx ); diff --git a/mesalib/src/mesa/swrast/s_span.c b/mesalib/src/mesa/swrast/s_span.c index 0e2793b47..d36c8132f 100644 --- a/mesalib/src/mesa/swrast/s_span.c +++ b/mesalib/src/mesa/swrast/s_span.c @@ -885,6 +885,9 @@ _swrast_write_index_span( GLcontext *ctx, SWspan *span) if (!(span->arrayMask & SPAN_Z)) _swrast_span_interpolate_z(ctx, span); + if (ctx->Transform.DepthClamp) + _swrast_depth_clamp_span(ctx, span); + if (ctx->Stencil._Enabled) { if (!_swrast_stencil_and_ztest_span(ctx, span)) { span->arrayMask = origArrayMask; @@ -901,7 +904,6 @@ _swrast_write_index_span( GLcontext *ctx, SWspan *span) } } -#if FEATURE_ARB_occlusion_query if (ctx->Query.CurrentOcclusionObject) { /* update count of 'passed' fragments */ struct gl_query_object *q = ctx->Query.CurrentOcclusionObject; @@ -909,7 +911,6 @@ _swrast_write_index_span( GLcontext *ctx, SWspan *span) for (i = 0; i < span->end; i++) q->Result += span->array->mask[i]; } -#endif /* we have to wait until after occlusion to do this test */ if (ctx->Color.IndexMask == 0) { @@ -1355,6 +1356,10 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span) if (ctx->Stencil._Enabled || ctx->Depth.Test) { if (!(span->arrayMask & SPAN_Z)) _swrast_span_interpolate_z(ctx, span); + + if (ctx->Transform.DepthClamp) + _swrast_depth_clamp_span(ctx, span); + if (ctx->Stencil._Enabled) { /* Combined Z/stencil tests */ if (!_swrast_stencil_and_ztest_span(ctx, span)) { @@ -1373,7 +1378,6 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span) } } -#if FEATURE_ARB_occlusion_query if (ctx->Query.CurrentOcclusionObject) { /* update count of 'passed' fragments */ struct gl_query_object *q = ctx->Query.CurrentOcclusionObject; @@ -1381,7 +1385,6 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span) for (i = 0; i < span->end; i++) q->Result += span->array->mask[i]; } -#endif /* We had to wait until now to check for glColorMask(0,0,0,0) because of * the occlusion test. diff --git a/mesalib/src/mesa/swrast/s_texfilter.c b/mesalib/src/mesa/swrast/s_texfilter.c index efe6f2347..0bb988e3e 100644 --- a/mesalib/src/mesa/swrast/s_texfilter.c +++ b/mesalib/src/mesa/swrast/s_texfilter.c @@ -745,7 +745,7 @@ get_border_color(const struct gl_texture_object *tObj, const struct gl_texture_image *img, GLfloat rgba[4]) { - switch (img->TexFormat->BaseFormat) { + switch (img->_BaseFormat) { case GL_RGB: rgba[0] = tObj->BorderColor[0]; rgba[1] = tObj->BorderColor[1]; @@ -1152,7 +1152,7 @@ sample_2d_linear_repeat(GLcontext *ctx, ASSERT(tObj->WrapS == GL_REPEAT); ASSERT(tObj->WrapT == GL_REPEAT); ASSERT(img->Border == 0); - ASSERT(img->TexFormat->BaseFormat != GL_COLOR_INDEX); + ASSERT(img->_BaseFormat != GL_COLOR_INDEX); ASSERT(img->_IsPowerOfTwo); linear_repeat_texel_location(width, texcoord[0], &i0, &i1, &wi); @@ -1343,17 +1343,17 @@ opt_sample_rgb_2d(GLcontext *ctx, ASSERT(tObj->WrapS==GL_REPEAT); ASSERT(tObj->WrapT==GL_REPEAT); ASSERT(img->Border==0); - ASSERT(img->TexFormat->MesaFormat==MESA_FORMAT_RGB); + ASSERT(img->TexFormat == MESA_FORMAT_RGB888); ASSERT(img->_IsPowerOfTwo); for (k=0; k<n; k++) { GLint i = IFLOOR(texcoords[k][0] * width) & colMask; GLint j = IFLOOR(texcoords[k][1] * height) & rowMask; GLint pos = (j << shift) | i; - GLchan *texel = ((GLchan *) img->Data) + 3*pos; - rgba[k][RCOMP] = CHAN_TO_FLOAT(texel[0]); - rgba[k][GCOMP] = CHAN_TO_FLOAT(texel[1]); - rgba[k][BCOMP] = CHAN_TO_FLOAT(texel[2]); + GLubyte *texel = ((GLubyte *) img->Data) + 3*pos; + rgba[k][RCOMP] = UBYTE_TO_FLOAT(texel[2]); + rgba[k][GCOMP] = UBYTE_TO_FLOAT(texel[1]); + rgba[k][BCOMP] = UBYTE_TO_FLOAT(texel[0]); } } @@ -1384,18 +1384,18 @@ opt_sample_rgba_2d(GLcontext *ctx, ASSERT(tObj->WrapS==GL_REPEAT); ASSERT(tObj->WrapT==GL_REPEAT); ASSERT(img->Border==0); - ASSERT(img->TexFormat->MesaFormat==MESA_FORMAT_RGBA); + ASSERT(img->TexFormat == MESA_FORMAT_RGBA8888); ASSERT(img->_IsPowerOfTwo); for (i = 0; i < n; i++) { const GLint col = IFLOOR(texcoords[i][0] * width) & colMask; const GLint row = IFLOOR(texcoords[i][1] * height) & rowMask; const GLint pos = (row << shift) | col; - const GLchan *texel = ((GLchan *) img->Data) + (pos << 2); /* pos*4 */ - rgba[i][RCOMP] = CHAN_TO_FLOAT(texel[0]); - rgba[i][GCOMP] = CHAN_TO_FLOAT(texel[1]); - rgba[i][BCOMP] = CHAN_TO_FLOAT(texel[2]); - rgba[i][ACOMP] = CHAN_TO_FLOAT(texel[3]); + const GLuint texel = *((GLuint *) img->Data + pos); + rgba[i][RCOMP] = UBYTE_TO_FLOAT( (texel >> 24) ); + rgba[i][GCOMP] = UBYTE_TO_FLOAT( (texel >> 16) & 0xff ); + rgba[i][BCOMP] = UBYTE_TO_FLOAT( (texel >> 8) & 0xff ); + rgba[i][ACOMP] = UBYTE_TO_FLOAT( (texel ) & 0xff ); } } @@ -1414,7 +1414,7 @@ sample_lambda_2d(GLcontext *ctx, const GLboolean repeatNoBorderPOT = (tObj->WrapS == GL_REPEAT) && (tObj->WrapT == GL_REPEAT) && (tImg->Border == 0 && (tImg->Width == tImg->RowStride)) - && (tImg->TexFormat->BaseFormat != GL_COLOR_INDEX) + && (tImg->_BaseFormat != GL_COLOR_INDEX) && tImg->_IsPowerOfTwo; ASSERT(lambda != NULL); @@ -1427,12 +1427,12 @@ sample_lambda_2d(GLcontext *ctx, switch (tObj->MinFilter) { case GL_NEAREST: if (repeatNoBorderPOT) { - switch (tImg->TexFormat->MesaFormat) { - case MESA_FORMAT_RGB: + switch (tImg->TexFormat) { + case MESA_FORMAT_RGB888: opt_sample_rgb_2d(ctx, tObj, m, texcoords + minStart, NULL, rgba + minStart); break; - case MESA_FORMAT_RGBA: + case MESA_FORMAT_RGBA8888: opt_sample_rgba_2d(ctx, tObj, m, texcoords + minStart, NULL, rgba + minStart); break; @@ -1484,12 +1484,12 @@ sample_lambda_2d(GLcontext *ctx, switch (tObj->MagFilter) { case GL_NEAREST: if (repeatNoBorderPOT) { - switch (tImg->TexFormat->MesaFormat) { - case MESA_FORMAT_RGB: + switch (tImg->TexFormat) { + case MESA_FORMAT_RGB888: opt_sample_rgb_2d(ctx, tObj, m, texcoords + magStart, NULL, rgba + magStart); break; - case MESA_FORMAT_RGBA: + case MESA_FORMAT_RGBA8888: opt_sample_rgba_2d(ctx, tObj, m, texcoords + magStart, NULL, rgba + magStart); break; @@ -1905,8 +1905,12 @@ choose_cube_face(const struct gl_texture_object *texObj, } } - newCoord[0] = ( sc / ma + 1.0F ) * 0.5F; - newCoord[1] = ( tc / ma + 1.0F ) * 0.5F; + { + const float ima = 1.0F / ma; + newCoord[0] = ( sc * ima + 1.0F ) * 0.5F; + newCoord[1] = ( tc * ima + 1.0F ) * 0.5F; + } + return (const struct gl_texture_image **) texObj->Image[face]; } @@ -2148,7 +2152,7 @@ sample_nearest_rect(GLcontext *ctx, ASSERT(tObj->WrapT == GL_CLAMP || tObj->WrapT == GL_CLAMP_TO_EDGE || tObj->WrapT == GL_CLAMP_TO_BORDER); - ASSERT(img->TexFormat->BaseFormat != GL_COLOR_INDEX); + ASSERT(img->_BaseFormat != GL_COLOR_INDEX); for (i = 0; i < n; i++) { GLint row, col; @@ -2182,7 +2186,7 @@ sample_linear_rect(GLcontext *ctx, ASSERT(tObj->WrapT == GL_CLAMP || tObj->WrapT == GL_CLAMP_TO_EDGE || tObj->WrapT == GL_CLAMP_TO_BORDER); - ASSERT(img->TexFormat->BaseFormat != GL_COLOR_INDEX); + ASSERT(img->_BaseFormat != GL_COLOR_INDEX); for (i = 0; i < n; i++) { GLint i0, j0, i1, j1; @@ -2969,8 +2973,8 @@ sample_depth_texture( GLcontext *ctx, (void) lambda; - ASSERT(img->TexFormat->BaseFormat == GL_DEPTH_COMPONENT || - img->TexFormat->BaseFormat == GL_DEPTH_STENCIL_EXT); + ASSERT(img->_BaseFormat == GL_DEPTH_COMPONENT || + img->_BaseFormat == GL_DEPTH_STENCIL_EXT); ASSERT(tObj->Target == GL_TEXTURE_1D || tObj->Target == GL_TEXTURE_2D || @@ -3133,7 +3137,7 @@ null_sample_func( GLcontext *ctx, rgba[i][RCOMP] = 0; rgba[i][GCOMP] = 0; rgba[i][BCOMP] = 0; - rgba[i][ACOMP] = CHAN_MAX; + rgba[i][ACOMP] = 1.0; } } @@ -3150,7 +3154,7 @@ _swrast_choose_texture_sample_func( GLcontext *ctx, } else { const GLboolean needLambda = (GLboolean) (t->MinFilter != t->MagFilter); - const GLenum format = t->Image[0][t->BaseLevel]->TexFormat->BaseFormat; + const GLenum format = t->Image[0][t->BaseLevel]->_BaseFormat; switch (t->Target) { case GL_TEXTURE_1D: @@ -3185,14 +3189,14 @@ _swrast_choose_texture_sample_func( GLcontext *ctx, t->WrapT == GL_REPEAT && img->_IsPowerOfTwo && img->Border == 0 && - img->TexFormat->MesaFormat == MESA_FORMAT_RGB) { + img->TexFormat == MESA_FORMAT_RGB888) { return &opt_sample_rgb_2d; } else if (t->WrapS == GL_REPEAT && t->WrapT == GL_REPEAT && img->_IsPowerOfTwo && img->Border == 0 && - img->TexFormat->MesaFormat == MESA_FORMAT_RGBA) { + img->TexFormat == MESA_FORMAT_RGBA8888) { return &opt_sample_rgba_2d; } else { diff --git a/mesalib/src/mesa/swrast/s_texstore.c b/mesalib/src/mesa/swrast/s_texstore.c deleted file mode 100644 index f9ff9ad6a..000000000 --- a/mesalib/src/mesa/swrast/s_texstore.c +++ /dev/null @@ -1,601 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * Copyright (C) 1999-2006 Brian Paul 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"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * 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. - */ - -/* - * Authors: - * Brian Paul - */ - - -/* - * The functions in this file are mostly related to software texture fallbacks. - * This includes texture image transfer/packing and texel fetching. - * Hardware drivers will likely override most of this. - */ - - - -#include "main/glheader.h" -#include "main/imports.h" -#include "main/colormac.h" -#include "main/context.h" -#include "main/convolve.h" -#include "main/image.h" -#include "main/macros.h" -#include "main/mipmap.h" -#include "main/texformat.h" -#include "main/teximage.h" -#include "main/texstore.h" - -#include "s_context.h" -#include "s_depth.h" -#include "s_span.h" - - -/** - * Read an RGBA image from the frame buffer. - * This is used by glCopyTex[Sub]Image[12]D(). - * \param x window source x - * \param y window source y - * \param width image width - * \param height image height - * \param type datatype for returned GL_RGBA image - * \return pointer to image - */ -static GLvoid * -read_color_image( GLcontext *ctx, GLint x, GLint y, GLenum type, - GLsizei width, GLsizei height ) -{ - struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer; - const GLint pixelSize = _mesa_bytes_per_pixel(GL_RGBA, type); - const GLint stride = width * pixelSize; - GLint row; - GLubyte *image, *dst; - - image = (GLubyte *) _mesa_malloc(width * height * pixelSize); - if (!image) - return NULL; - - swrast_render_start(ctx); - - dst = image; - for (row = 0; row < height; row++) { - _swrast_read_rgba_span(ctx, rb, width, x, y + row, type, dst); - dst += stride; - } - - swrast_render_finish(ctx); - - return image; -} - - -/** - * As above, but read data from depth buffer. Returned as GLuints. - * \sa read_color_image - */ -static GLuint * -read_depth_image( GLcontext *ctx, GLint x, GLint y, - GLsizei width, GLsizei height ) -{ - struct gl_renderbuffer *rb = ctx->ReadBuffer->_DepthBuffer; - GLuint *image, *dst; - GLint i; - - image = (GLuint *) _mesa_malloc(width * height * sizeof(GLuint)); - if (!image) - return NULL; - - swrast_render_start(ctx); - - dst = image; - for (i = 0; i < height; i++) { - _swrast_read_depth_span_uint(ctx, rb, width, x, y + i, dst); - dst += width; - } - - swrast_render_finish(ctx); - - return image; -} - - -/** - * As above, but read data from depth+stencil buffers. - */ -static GLuint * -read_depth_stencil_image(GLcontext *ctx, GLint x, GLint y, - GLsizei width, GLsizei height) -{ - struct gl_renderbuffer *depthRb = ctx->ReadBuffer->_DepthBuffer; - struct gl_renderbuffer *stencilRb = ctx->ReadBuffer->_StencilBuffer; - GLuint *image, *dst; - GLint i; - - ASSERT(depthRb); - ASSERT(stencilRb); - - image = (GLuint *) _mesa_malloc(width * height * sizeof(GLuint)); - if (!image) - return NULL; - - swrast_render_start(ctx); - - /* read from depth buffer */ - dst = image; - if (depthRb->DataType == GL_UNSIGNED_INT) { - for (i = 0; i < height; i++) { - _swrast_get_row(ctx, depthRb, width, x, y + i, dst, sizeof(GLuint)); - dst += width; - } - } - else { - GLushort z16[MAX_WIDTH]; - ASSERT(depthRb->DataType == GL_UNSIGNED_SHORT); - for (i = 0; i < height; i++) { - GLint j; - _swrast_get_row(ctx, depthRb, width, x, y + i, z16, sizeof(GLushort)); - /* convert GLushorts to GLuints */ - for (j = 0; j < width; j++) { - dst[j] = z16[j]; - } - dst += width; - } - } - - /* put depth values into bits 0xffffff00 */ - if (ctx->ReadBuffer->Visual.depthBits == 24) { - GLint j; - for (j = 0; j < width * height; j++) { - image[j] <<= 8; - } - } - else if (ctx->ReadBuffer->Visual.depthBits == 16) { - GLint j; - for (j = 0; j < width * height; j++) { - image[j] = (image[j] << 16) | (image[j] & 0xff00); - } - } - else { - /* this handles arbitrary depthBits >= 12 */ - const GLint rShift = ctx->ReadBuffer->Visual.depthBits; - const GLint lShift = 32 - rShift; - GLint j; - for (j = 0; j < width * height; j++) { - GLuint z = (image[j] << lShift); - image[j] = z | (z >> rShift); - } - } - - /* read stencil values and interleave into image array */ - dst = image; - for (i = 0; i < height; i++) { - GLstencil stencil[MAX_WIDTH]; - GLint j; - ASSERT(8 * sizeof(GLstencil) == stencilRb->StencilBits); - _swrast_get_row(ctx, stencilRb, width, x, y + i, - stencil, sizeof(GLstencil)); - for (j = 0; j < width; j++) { - dst[j] = (dst[j] & 0xffffff00) | (stencil[j] & 0xff); - } - dst += width; - } - - swrast_render_finish(ctx); - - return image; -} - - -static GLboolean -is_depth_format(GLenum format) -{ - switch (format) { - case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16: - case GL_DEPTH_COMPONENT24: - case GL_DEPTH_COMPONENT32: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -static GLboolean -is_depth_stencil_format(GLenum format) -{ - switch (format) { - case GL_DEPTH_STENCIL_EXT: - case GL_DEPTH24_STENCIL8_EXT: - return GL_TRUE; - default: - return GL_FALSE; - } -} - - -/* - * Fallback for Driver.CopyTexImage1D(). - */ -void -_swrast_copy_teximage1d( GLcontext *ctx, GLenum target, GLint level, - GLenum internalFormat, - GLint x, GLint y, GLsizei width, GLint border ) -{ - struct gl_texture_unit *texUnit; - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - - texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - texObj = _mesa_select_tex_object(ctx, texUnit, target); - ASSERT(texObj); - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - ASSERT(texImage); - - ASSERT(ctx->Driver.TexImage1D); - - if (is_depth_format(internalFormat)) { - /* read depth image from framebuffer */ - GLuint *image = read_depth_image(ctx, x, y, width, 1); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage1D"); - return; - } - /* call glTexImage1D to redefine the texture */ - ctx->Driver.TexImage1D(ctx, target, level, internalFormat, - width, border, - GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, image, - &ctx->DefaultPacking, texObj, texImage); - _mesa_free(image); - } - else if (is_depth_stencil_format(internalFormat)) { - /* read depth/stencil image from framebuffer */ - GLuint *image = read_depth_stencil_image(ctx, x, y, width, 1); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage1D"); - return; - } - /* call glTexImage1D to redefine the texture */ - ctx->Driver.TexImage1D(ctx, target, level, internalFormat, - width, border, - GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, - image, &ctx->DefaultPacking, texObj, texImage); - _mesa_free(image); - } - else { - /* read RGBA image from framebuffer */ - const GLenum format = GL_RGBA; - const GLenum type = ctx->ReadBuffer->_ColorReadBuffer->DataType; - GLvoid *image = read_color_image(ctx, x, y, type, width, 1); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage1D"); - return; - } - /* call glTexImage1D to redefine the texture */ - ctx->Driver.TexImage1D(ctx, target, level, internalFormat, - width, border, format, type, image, - &ctx->DefaultPacking, texObj, texImage); - _mesa_free(image); - } - - /* GL_SGIS_generate_mipmap */ - if (level == texObj->BaseLevel && texObj->GenerateMipmap) { - ctx->Driver.GenerateMipmap(ctx, target, texObj); - } -} - - -/** - * Fallback for Driver.CopyTexImage2D(). - * - * We implement CopyTexImage by reading the image from the framebuffer - * then passing it to the ctx->Driver.TexImage2D() function. - * - * Device drivers should try to implement direct framebuffer->texture copies. - */ -void -_swrast_copy_teximage2d( GLcontext *ctx, GLenum target, GLint level, - GLenum internalFormat, - GLint x, GLint y, GLsizei width, GLsizei height, - GLint border ) -{ - struct gl_texture_unit *texUnit; - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - - texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - texObj = _mesa_select_tex_object(ctx, texUnit, target); - ASSERT(texObj); - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - ASSERT(texImage); - - ASSERT(ctx->Driver.TexImage2D); - - if (is_depth_format(internalFormat)) { - /* read depth image from framebuffer */ - GLuint *image = read_depth_image(ctx, x, y, width, height); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage2D"); - return; - } - /* call glTexImage2D to redefine the texture */ - ctx->Driver.TexImage2D(ctx, target, level, internalFormat, - width, height, border, - GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, image, - &ctx->DefaultPacking, texObj, texImage); - _mesa_free(image); - } - else if (is_depth_stencil_format(internalFormat)) { - GLuint *image = read_depth_stencil_image(ctx, x, y, width, height); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage2D"); - return; - } - /* call glTexImage2D to redefine the texture */ - ctx->Driver.TexImage2D(ctx, target, level, internalFormat, - width, height, border, - GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, - image, &ctx->DefaultPacking, texObj, texImage); - _mesa_free(image); - } - else { - /* read RGBA image from framebuffer */ - const GLenum format = GL_RGBA; - const GLenum type = ctx->ReadBuffer->_ColorReadBuffer->DataType; - GLvoid *image = read_color_image(ctx, x, y, type, width, height); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage2D"); - return; - } - /* call glTexImage2D to redefine the texture */ - ctx->Driver.TexImage2D(ctx, target, level, internalFormat, - width, height, border, format, type, image, - &ctx->DefaultPacking, texObj, texImage); - _mesa_free(image); - } - - /* GL_SGIS_generate_mipmap */ - if (level == texObj->BaseLevel && texObj->GenerateMipmap) { - ctx->Driver.GenerateMipmap(ctx, target, texObj); - } -} - - -/* - * Fallback for Driver.CopyTexSubImage1D(). - */ -void -_swrast_copy_texsubimage1d( GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLint x, GLint y, GLsizei width ) -{ - struct gl_texture_unit *texUnit; - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - - texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - texObj = _mesa_select_tex_object(ctx, texUnit, target); - ASSERT(texObj); - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - ASSERT(texImage); - - ASSERT(ctx->Driver.TexImage1D); - - if (texImage->_BaseFormat == GL_DEPTH_COMPONENT) { - /* read depth image from framebuffer */ - GLuint *image = read_depth_image(ctx, x, y, width, 1); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage1D"); - return; - } - - /* call glTexSubImage1D to redefine the texture */ - ctx->Driver.TexSubImage1D(ctx, target, level, xoffset, width, - GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, image, - &ctx->DefaultPacking, texObj, texImage); - _mesa_free(image); - } - else if (texImage->_BaseFormat == GL_DEPTH_STENCIL_EXT) { - /* read depth/stencil image from framebuffer */ - GLuint *image = read_depth_stencil_image(ctx, x, y, width, 1); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage1D"); - return; - } - /* call glTexImage1D to redefine the texture */ - ctx->Driver.TexSubImage1D(ctx, target, level, xoffset, width, - GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, - image, &ctx->DefaultPacking, texObj, texImage); - _mesa_free(image); - } - else { - /* read RGBA image from framebuffer */ - const GLenum format = GL_RGBA; - const GLenum type = ctx->ReadBuffer->_ColorReadBuffer->DataType; - GLvoid *image = read_color_image(ctx, x, y, type, width, 1); - if (!image) { - _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage1D" ); - return; - } - /* now call glTexSubImage1D to do the real work */ - ctx->Driver.TexSubImage1D(ctx, target, level, xoffset, width, - format, type, image, - &ctx->DefaultPacking, texObj, texImage); - _mesa_free(image); - } - - /* GL_SGIS_generate_mipmap */ - if (level == texObj->BaseLevel && texObj->GenerateMipmap) { - ctx->Driver.GenerateMipmap(ctx, target, texObj); - } -} - - -/** - * Fallback for Driver.CopyTexSubImage2D(). - * - * Read the image from the framebuffer then hand it - * off to ctx->Driver.TexSubImage2D(). - */ -void -_swrast_copy_texsubimage2d( GLcontext *ctx, - GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint x, GLint y, GLsizei width, GLsizei height ) -{ - struct gl_texture_unit *texUnit; - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - - texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - texObj = _mesa_select_tex_object(ctx, texUnit, target); - ASSERT(texObj); - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - ASSERT(texImage); - - ASSERT(ctx->Driver.TexImage2D); - - if (texImage->_BaseFormat == GL_DEPTH_COMPONENT) { - /* read depth image from framebuffer */ - GLuint *image = read_depth_image(ctx, x, y, width, height); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage2D"); - return; - } - /* call glTexImage2D to redefine the texture */ - ctx->Driver.TexSubImage2D(ctx, target, level, - xoffset, yoffset, width, height, - GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, image, - &ctx->DefaultPacking, texObj, texImage); - _mesa_free(image); - } - else if (texImage->_BaseFormat == GL_DEPTH_STENCIL_EXT) { - /* read depth/stencil image from framebuffer */ - GLuint *image = read_depth_stencil_image(ctx, x, y, width, height); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage2D"); - return; - } - /* call glTexImage2D to redefine the texture */ - ctx->Driver.TexSubImage2D(ctx, target, level, - xoffset, yoffset, width, height, - GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, - image, &ctx->DefaultPacking, texObj, texImage); - _mesa_free(image); - } - else { - /* read RGBA image from framebuffer */ - const GLenum format = GL_RGBA; - const GLenum type = ctx->ReadBuffer->_ColorReadBuffer->DataType; - GLvoid *image = read_color_image(ctx, x, y, type, width, height); - if (!image) { - _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage2D" ); - return; - } - /* now call glTexSubImage2D to do the real work */ - ctx->Driver.TexSubImage2D(ctx, target, level, - xoffset, yoffset, width, height, - format, type, image, - &ctx->DefaultPacking, texObj, texImage); - _mesa_free(image); - } - - /* GL_SGIS_generate_mipmap */ - if (level == texObj->BaseLevel && texObj->GenerateMipmap) { - ctx->Driver.GenerateMipmap(ctx, target, texObj); - } -} - - -/* - * Fallback for Driver.CopyTexSubImage3D(). - */ -void -_swrast_copy_texsubimage3d( GLcontext *ctx, - GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint x, GLint y, GLsizei width, GLsizei height ) -{ - struct gl_texture_unit *texUnit; - struct gl_texture_object *texObj; - struct gl_texture_image *texImage; - - texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - texObj = _mesa_select_tex_object(ctx, texUnit, target); - ASSERT(texObj); - texImage = _mesa_select_tex_image(ctx, texObj, target, level); - ASSERT(texImage); - - ASSERT(ctx->Driver.TexImage3D); - - if (texImage->_BaseFormat == GL_DEPTH_COMPONENT) { - /* read depth image from framebuffer */ - GLuint *image = read_depth_image(ctx, x, y, width, height); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage3D"); - return; - } - /* call glTexImage3D to redefine the texture */ - ctx->Driver.TexSubImage3D(ctx, target, level, - xoffset, yoffset, zoffset, width, height, 1, - GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, image, - &ctx->DefaultPacking, texObj, texImage); - _mesa_free(image); - } - else if (texImage->_BaseFormat == GL_DEPTH_STENCIL_EXT) { - /* read depth/stencil image from framebuffer */ - GLuint *image = read_depth_stencil_image(ctx, x, y, width, height); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage3D"); - return; - } - /* call glTexImage3D to redefine the texture */ - ctx->Driver.TexSubImage3D(ctx, target, level, - xoffset, yoffset, zoffset, width, height, 1, - GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, - image, &ctx->DefaultPacking, texObj, texImage); - _mesa_free(image); - } - else { - /* read RGBA image from framebuffer */ - const GLenum format = GL_RGBA; - const GLenum type = ctx->ReadBuffer->_ColorReadBuffer->DataType; - GLvoid *image = read_color_image(ctx, x, y, type, width, height); - if (!image) { - _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage3D" ); - return; - } - /* now call glTexSubImage3D to do the real work */ - ctx->Driver.TexSubImage3D(ctx, target, level, - xoffset, yoffset, zoffset, width, height, 1, - format, type, image, - &ctx->DefaultPacking, texObj, texImage); - _mesa_free(image); - } - - /* GL_SGIS_generate_mipmap */ - if (level == texObj->BaseLevel && texObj->GenerateMipmap) { - ctx->Driver.GenerateMipmap(ctx, target, texObj); - } -} diff --git a/mesalib/src/mesa/swrast/s_triangle.c b/mesalib/src/mesa/swrast/s_triangle.c index 1ab0e19f9..5bec60669 100644 --- a/mesalib/src/mesa/swrast/s_triangle.c +++ b/mesalib/src/mesa/swrast/s_triangle.c @@ -134,22 +134,24 @@ _swrast_culltriangle( GLcontext *ctx, #define SETUP_CODE \ struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0]; \ - struct gl_texture_object *obj = \ + const 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; \ - const GLint twidth_log2 = obj->Image[0][b]->WidthLog2; \ - const GLchan *texture = (const GLchan *) obj->Image[0][b]->Data; \ - const GLint smask = obj->Image[0][b]->Width - 1; \ - const GLint tmask = obj->Image[0][b]->Height - 1; \ + const struct gl_texture_image *texImg = \ + obj->Image[0][obj->BaseLevel]; \ + 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 GLint smask = texImg->Width - 1; \ + const GLint tmask = texImg->Height - 1; \ + ASSERT(texImg->TexFormat == MESA_FORMAT_RGB888); \ if (!rb || !texture) { \ return; \ } #define RENDER_SPAN( span ) \ GLuint i; \ - GLchan rgb[MAX_WIDTH][3]; \ + GLubyte rgb[MAX_WIDTH][3]; \ span.intTex[0] -= FIXED_HALF; /* off-by-one error? */ \ span.intTex[1] -= FIXED_HALF; \ for (i = 0; i < span.end; i++) { \ @@ -157,9 +159,9 @@ _swrast_culltriangle( GLcontext *ctx, 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]; \ + rgb[i][RCOMP] = texture[pos+2]; \ rgb[i][GCOMP] = texture[pos+1]; \ - rgb[i][BCOMP] = texture[pos+2]; \ + rgb[i][BCOMP] = texture[pos+0]; \ span.intTex[0] += span.intTexStep[0]; \ span.intTex[1] += span.intTexStep[1]; \ } \ @@ -186,22 +188,24 @@ _swrast_culltriangle( GLcontext *ctx, #define SETUP_CODE \ struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0]; \ - struct gl_texture_object *obj = \ + const 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; \ - const GLint twidth_log2 = obj->Image[0][b]->WidthLog2; \ - const GLchan *texture = (const GLchan *) obj->Image[0][b]->Data; \ - const GLint smask = obj->Image[0][b]->Width - 1; \ - const GLint tmask = obj->Image[0][b]->Height - 1; \ + const struct gl_texture_image *texImg = \ + obj->Image[0][obj->BaseLevel]; \ + 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 GLint smask = texImg->Width - 1; \ + const GLint tmask = texImg->Height - 1; \ + ASSERT(texImg->TexFormat == MESA_FORMAT_RGB888); \ if (!rb || !texture) { \ return; \ } #define RENDER_SPAN( span ) \ GLuint i; \ - GLchan rgb[MAX_WIDTH][3]; \ + GLubyte rgb[MAX_WIDTH][3]; \ span.intTex[0] -= FIXED_HALF; /* off-by-one error? */ \ span.intTex[1] -= FIXED_HALF; \ for (i = 0; i < span.end; i++) { \ @@ -211,9 +215,9 @@ _swrast_culltriangle( GLcontext *ctx, 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]; \ + rgb[i][RCOMP] = texture[pos+2]; \ rgb[i][GCOMP] = texture[pos+1]; \ - rgb[i][BCOMP] = texture[pos+2]; \ + rgb[i][BCOMP] = texture[pos+0]; \ zRow[i] = z; \ span.array->mask[i] = 1; \ } \ @@ -276,25 +280,29 @@ affine_span(GLcontext *ctx, SWspan *span, * unused variables (for instance tf,sf,ti,si in case of GL_NEAREST). */ -#define NEAREST_RGB \ - sample[RCOMP] = tex00[RCOMP]; \ - sample[GCOMP] = tex00[GCOMP]; \ - sample[BCOMP] = tex00[BCOMP]; \ - sample[ACOMP] = CHAN_MAX +#define NEAREST_RGB \ + sample[RCOMP] = tex00[2]; \ + sample[GCOMP] = tex00[1]; \ + sample[BCOMP] = tex00[0]; \ + sample[ACOMP] = CHAN_MAX; #define LINEAR_RGB \ - sample[RCOMP] = ilerp_2d(sf, tf, tex00[0], tex01[0], tex10[0], tex11[0]);\ + sample[RCOMP] = ilerp_2d(sf, tf, tex00[2], tex01[2], tex10[2], tex11[2]);\ sample[GCOMP] = ilerp_2d(sf, tf, tex00[1], tex01[1], tex10[1], tex11[1]);\ - sample[BCOMP] = ilerp_2d(sf, tf, tex00[2], tex01[2], tex10[2], tex11[2]);\ + sample[BCOMP] = ilerp_2d(sf, tf, tex00[0], tex01[0], tex10[0], tex11[0]);\ sample[ACOMP] = CHAN_MAX; -#define NEAREST_RGBA COPY_CHAN4(sample, tex00) +#define NEAREST_RGBA \ + sample[RCOMP] = tex00[3]; \ + sample[GCOMP] = tex00[2]; \ + sample[BCOMP] = tex00[1]; \ + sample[ACOMP] = tex00[0]; #define LINEAR_RGBA \ - sample[RCOMP] = ilerp_2d(sf, tf, tex00[0], tex01[0], tex10[0], tex11[0]);\ - sample[GCOMP] = ilerp_2d(sf, tf, tex00[1], tex01[1], tex10[1], tex11[1]);\ - sample[BCOMP] = ilerp_2d(sf, tf, tex00[2], tex01[2], tex10[2], tex11[2]);\ - sample[ACOMP] = ilerp_2d(sf, tf, tex00[3], tex01[3], tex10[3], tex11[3]) + sample[RCOMP] = ilerp_2d(sf, tf, tex00[3], tex01[3], tex10[3], tex11[3]);\ + sample[GCOMP] = ilerp_2d(sf, tf, tex00[2], tex01[2], tex10[2], tex11[2]);\ + sample[BCOMP] = ilerp_2d(sf, tf, tex00[1], tex01[1], tex10[1], tex11[1]);\ + sample[ACOMP] = ilerp_2d(sf, tf, tex00[0], tex01[0], tex10[0], tex11[0]) #define MODULATE \ dest[RCOMP] = span->red * (sample[RCOMP] + 1u) >> (FIXED_SHIFT + 8); \ @@ -345,7 +353,11 @@ affine_span(GLcontext *ctx, SWspan *span, dest[2] = sample[2]; \ dest[3] = FixedToInt(span->alpha); -#define NEAREST_RGBA_REPLACE COPY_CHAN4(dest, tex00) +#define NEAREST_RGBA_REPLACE \ + dest[RCOMP] = tex00[3]; \ + dest[GCOMP] = tex00[2]; \ + dest[BCOMP] = tex00[1]; \ + dest[ACOMP] = tex00[0] #define SPAN_NEAREST(DO_TEX, COMPS) \ for (i = 0; i < span->end; i++) { \ @@ -406,7 +418,7 @@ affine_span(GLcontext *ctx, SWspan *span, switch (info->filter) { case GL_NEAREST: switch (info->format) { - case GL_RGB: + case MESA_FORMAT_RGB888: switch (info->envmode) { case GL_MODULATE: SPAN_NEAREST(NEAREST_RGB;MODULATE,3); @@ -426,7 +438,7 @@ affine_span(GLcontext *ctx, SWspan *span, return; } break; - case GL_RGBA: + case MESA_FORMAT_RGBA8888: switch(info->envmode) { case GL_MODULATE: SPAN_NEAREST(NEAREST_RGBA;MODULATE,4); @@ -455,7 +467,7 @@ affine_span(GLcontext *ctx, SWspan *span, span->intTex[0] -= FIXED_HALF; span->intTex[1] -= FIXED_HALF; switch (info->format) { - case GL_RGB: + case MESA_FORMAT_RGB888: switch (info->envmode) { case GL_MODULATE: SPAN_LINEAR(LINEAR_RGB;MODULATE,3); @@ -475,7 +487,7 @@ affine_span(GLcontext *ctx, SWspan *span, return; } break; - case GL_RGBA: + case MESA_FORMAT_RGBA8888: switch (info->envmode) { case GL_MODULATE: SPAN_LINEAR(LINEAR_RGBA;MODULATE,4); @@ -528,18 +540,22 @@ 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 = \ + const 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; \ - info.texture = (const GLchan *) obj->Image[0][b]->Data; \ - info.twidth_log2 = obj->Image[0][b]->WidthLog2; \ - info.smask = obj->Image[0][b]->Width - 1; \ - info.tmask = obj->Image[0][b]->Height - 1; \ - info.format = obj->Image[0][b]->_BaseFormat; \ + const struct gl_texture_image *texImg = \ + obj->Image[0][obj->BaseLevel]; \ + const GLfloat twidth = (GLfloat) texImg->Width; \ + const GLfloat theight = (GLfloat) texImg->Height; \ + info.texture = (const GLchan *) texImg->Data; \ + info.twidth_log2 = texImg->WidthLog2; \ + info.smask = texImg->Width - 1; \ + info.tmask = texImg->Height - 1; \ + info.format = texImg->TexFormat; \ info.filter = obj->MinFilter; \ info.envmode = unit->EnvMode; \ + info.er = 0; \ + info.eg = 0; \ + info.eb = 0; \ span.arrayMask |= SPAN_RGBA; \ \ if (info.envmode == GL_BLEND) { \ @@ -555,25 +571,17 @@ affine_span(GLcontext *ctx, SWspan *span, } \ \ switch (info.format) { \ - case GL_ALPHA: \ - case GL_LUMINANCE: \ - case GL_INTENSITY: \ - info.tbytesline = obj->Image[0][b]->Width; \ - break; \ - case GL_LUMINANCE_ALPHA: \ - info.tbytesline = obj->Image[0][b]->Width * 2; \ + case MESA_FORMAT_RGB888: \ + info.tbytesline = texImg->Width * 3; \ break; \ - case GL_RGB: \ - info.tbytesline = obj->Image[0][b]->Width * 3; \ - break; \ - case GL_RGBA: \ - info.tbytesline = obj->Image[0][b]->Width * 4; \ + case MESA_FORMAT_RGBA8888: \ + info.tbytesline = texImg->Width * 4; \ break; \ default: \ _mesa_problem(NULL, "Bad texture format in affine_texture_triangle");\ return; \ } \ - info.tsize = obj->Image[0][b]->Height * info.tbytesline; + info.tsize = texImg->Height * info.tbytesline; #define RENDER_SPAN( span ) affine_span(ctx, &span, &info); @@ -680,7 +688,7 @@ fast_persp_span(GLcontext *ctx, SWspan *span, switch (info->filter) { case GL_NEAREST: switch (info->format) { - case GL_RGB: + case MESA_FORMAT_RGB888: switch (info->envmode) { case GL_MODULATE: SPAN_NEAREST(NEAREST_RGB;MODULATE,3); @@ -700,7 +708,7 @@ fast_persp_span(GLcontext *ctx, SWspan *span, return; } break; - case GL_RGBA: + case MESA_FORMAT_RGBA8888: switch(info->envmode) { case GL_MODULATE: SPAN_NEAREST(NEAREST_RGBA;MODULATE,4); @@ -727,7 +735,7 @@ fast_persp_span(GLcontext *ctx, SWspan *span, case GL_LINEAR: switch (info->format) { - case GL_RGB: + case MESA_FORMAT_RGB888: switch (info->envmode) { case GL_MODULATE: SPAN_LINEAR(LINEAR_RGB;MODULATE,3); @@ -747,7 +755,7 @@ fast_persp_span(GLcontext *ctx, SWspan *span, return; } break; - case GL_RGBA: + case MESA_FORMAT_RGBA8888: switch (info->envmode) { case GL_MODULATE: SPAN_LINEAR(LINEAR_RGBA;MODULATE,4); @@ -799,16 +807,20 @@ fast_persp_span(GLcontext *ctx, SWspan *span, #define SETUP_CODE \ struct persp_info info; \ const struct gl_texture_unit *unit = ctx->Texture.Unit+0; \ - struct gl_texture_object *obj = \ + const 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; \ - info.smask = obj->Image[0][b]->Width - 1; \ - info.tmask = obj->Image[0][b]->Height - 1; \ - info.format = obj->Image[0][b]->_BaseFormat; \ + const struct gl_texture_image *texImg = \ + obj->Image[0][obj->BaseLevel]; \ + info.texture = (const GLchan *) texImg->Data; \ + info.twidth_log2 = texImg->WidthLog2; \ + info.smask = texImg->Width - 1; \ + info.tmask = texImg->Height - 1; \ + info.format = texImg->TexFormat; \ info.filter = obj->MinFilter; \ info.envmode = unit->EnvMode; \ + info.er = 0; \ + info.eg = 0; \ + info.eb = 0; \ \ if (info.envmode == GL_BLEND) { \ /* potential off-by-one error here? (1.0f -> 2048 -> 0) */ \ @@ -823,25 +835,17 @@ fast_persp_span(GLcontext *ctx, SWspan *span, } \ \ switch (info.format) { \ - case GL_ALPHA: \ - case GL_LUMINANCE: \ - case GL_INTENSITY: \ - info.tbytesline = obj->Image[0][b]->Width; \ - break; \ - case GL_LUMINANCE_ALPHA: \ - info.tbytesline = obj->Image[0][b]->Width * 2; \ - break; \ - case GL_RGB: \ - info.tbytesline = obj->Image[0][b]->Width * 3; \ + case MESA_FORMAT_RGB888: \ + info.tbytesline = texImg->Width * 3; \ break; \ - case GL_RGBA: \ - info.tbytesline = obj->Image[0][b]->Width * 4; \ + case MESA_FORMAT_RGBA8888: \ + info.tbytesline = texImg->Width * 4; \ break; \ default: \ _mesa_problem(NULL, "Bad texture format in persp_textured_triangle");\ return; \ } \ - info.tsize = obj->Image[0][b]->Height * info.tbytesline; + info.tsize = texImg->Height * info.tbytesline; #define RENDER_SPAN( span ) \ span.interpMask &= ~SPAN_RGBA; \ @@ -883,7 +887,7 @@ fast_persp_span(GLcontext *ctx, SWspan *span, return; \ } #define RENDER_SPAN( span ) \ - if (rb->DepthBits <= 16) { \ + if (rb->Format == MESA_FORMAT_Z16) { \ GLuint i; \ const GLushort *zRow = (const GLushort *) \ rb->GetPointer(ctx, rb, span.x, span.y); \ @@ -1055,19 +1059,20 @@ _swrast_choose_triangle( GLcontext *ctx ) const struct gl_texture_object *texObj2D; const struct gl_texture_image *texImg; GLenum minFilter, magFilter, envMode; - GLint format; + gl_format format; 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; - magFilter = texObj2D ? texObj2D->MagFilter : (GLenum) 0; + 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; /* 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 @@ -1075,7 +1080,7 @@ _swrast_choose_triangle( GLcontext *ctx ) && texImg->_IsPowerOfTwo && texImg->Border == 0 && texImg->Width == texImg->RowStride - && (format == MESA_FORMAT_RGB || format == MESA_FORMAT_RGBA) + && (format == MESA_FORMAT_RGB888 || format == MESA_FORMAT_RGBA8888) && minFilter == magFilter && ctx->Light.Model.ColorControl == GL_SINGLE_COLOR && !swrast->_FogEnabled @@ -1083,7 +1088,7 @@ _swrast_choose_triangle( GLcontext *ctx ) && ctx->Texture.Unit[0].EnvMode != GL_COMBINE4_NV) { if (ctx->Hint.PerspectiveCorrection==GL_FASTEST) { if (minFilter == GL_NEAREST - && format == MESA_FORMAT_RGB + && format == MESA_FORMAT_RGB888 && (envMode == GL_REPLACE || envMode == GL_DECAL) && ((swrast->_RasterMask == (DEPTH_BIT | TEXTURE_BIT) && ctx->Depth.Func == GL_LESS @@ -1102,7 +1107,15 @@ _swrast_choose_triangle( GLcontext *ctx ) #if CHAN_BITS != 8 USE(general_triangle); #else - USE(affine_textured_triangle); + if (format == MESA_FORMAT_RGBA8888 && !_mesa_little_endian()) { + /* We only handle RGBA8888 correctly on little endian + * in the optimized code above. + */ + USE(general_triangle); + } + else { + USE(affine_textured_triangle); + } #endif } } diff --git a/mesalib/src/mesa/swrast/swrast.h b/mesalib/src/mesa/swrast/swrast.h index c319ca62f..c183b315b 100644 --- a/mesalib/src/mesa/swrast/swrast.h +++ b/mesalib/src/mesa/swrast/swrast.h @@ -207,60 +207,6 @@ extern void _swrast_print_vertex( GLcontext *ctx, const SWvertex *v ); -/* - * Imaging fallbacks (a better solution should be found, perhaps - * moving all the imaging fallback code to a new module) - */ -extern void -_swrast_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target, - GLenum internalFormat, - GLint x, GLint y, GLsizei width, - GLsizei height); -extern void -_swrast_CopyConvolutionFilter1D(GLcontext *ctx, GLenum target, - GLenum internalFormat, - GLint x, GLint y, GLsizei width); -extern void -_swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start, - GLint x, GLint y, GLsizei width); -extern void -_swrast_CopyColorTable( GLcontext *ctx, - GLenum target, GLenum internalformat, - GLint x, GLint y, GLsizei width); - - -/* - * Texture fallbacks. Could also live in a new module - * with the rest of the texture store fallbacks? - */ -extern void -_swrast_copy_teximage1d(GLcontext *ctx, GLenum target, GLint level, - GLenum internalFormat, - GLint x, GLint y, GLsizei width, GLint border); - -extern void -_swrast_copy_teximage2d(GLcontext *ctx, GLenum target, GLint level, - GLenum internalFormat, - GLint x, GLint y, GLsizei width, GLsizei height, - GLint border); - - -extern void -_swrast_copy_texsubimage1d(GLcontext *ctx, GLenum target, GLint level, - GLint xoffset, GLint x, GLint y, GLsizei width); - -extern void -_swrast_copy_texsubimage2d(GLcontext *ctx, - GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint x, GLint y, GLsizei width, GLsizei height); - -extern void -_swrast_copy_texsubimage3d(GLcontext *ctx, - GLenum target, GLint level, - GLint xoffset, GLint yoffset, GLint zoffset, - GLint x, GLint y, GLsizei width, GLsizei height); - extern void _swrast_eject_texture_images(GLcontext *ctx); |