diff options
Diffstat (limited to 'mesalib/src/mesa')
-rw-r--r-- | mesalib/src/mesa/drivers/common/meta.h | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/main/attrib.c | 1 | ||||
-rw-r--r-- | mesalib/src/mesa/main/buffers.c | 29 | ||||
-rw-r--r-- | mesalib/src/mesa/main/enable.c | 14 | ||||
-rw-r--r-- | mesalib/src/mesa/main/extensions.c | 1 | ||||
-rw-r--r-- | mesalib/src/mesa/main/get.c | 1 | ||||
-rw-r--r-- | mesalib/src/mesa/main/mtypes.h | 30 | ||||
-rw-r--r-- | mesalib/src/mesa/main/pixelstore.c | 559 | ||||
-rw-r--r-- | mesalib/src/mesa/main/teximage.c | 22 | ||||
-rw-r--r-- | mesalib/src/mesa/program/ir_to_mesa.cpp | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_fbo.c | 9 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_texture.c | 6 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_texture.c | 21 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_texture.h | 3 | ||||
-rw-r--r-- | mesalib/src/mesa/swrast/s_context.h | 5 | ||||
-rw-r--r-- | mesalib/src/mesa/swrast/s_fragprog.c | 6 | ||||
-rw-r--r-- | mesalib/src/mesa/swrast/s_span.c | 7 | ||||
-rw-r--r-- | mesalib/src/mesa/swrast/s_texfilter.c | 38 | ||||
-rw-r--r-- | mesalib/src/mesa/swrast/s_texture.c | 23 | ||||
-rw-r--r-- | mesalib/src/mesa/swrast/s_triangle.c | 5 |
20 files changed, 404 insertions, 380 deletions
diff --git a/mesalib/src/mesa/drivers/common/meta.h b/mesalib/src/mesa/drivers/common/meta.h index 9d634ae56..3c917924a 100644 --- a/mesalib/src/mesa/drivers/common/meta.h +++ b/mesalib/src/mesa/drivers/common/meta.h @@ -26,6 +26,8 @@ #ifndef META_H #define META_H +#include "main/mtypes.h" + /** * \name Flags for meta operations * \{ diff --git a/mesalib/src/mesa/main/attrib.c b/mesalib/src/mesa/main/attrib.c index d38a1a466..2f391c5a8 100644 --- a/mesalib/src/mesa/main/attrib.c +++ b/mesalib/src/mesa/main/attrib.c @@ -1352,7 +1352,6 @@ copy_pixelstore(struct gl_context *ctx, dst->SkipImages = src->SkipImages; dst->SwapBytes = src->SwapBytes; dst->LsbFirst = src->LsbFirst; - dst->ClientStorage = src->ClientStorage; dst->Invert = src->Invert; _mesa_reference_buffer_object(ctx, &dst->BufferObj, src->BufferObj); } diff --git a/mesalib/src/mesa/main/buffers.c b/mesalib/src/mesa/main/buffers.c index a75c9c2e7..adea0f5f7 100644 --- a/mesalib/src/mesa/main/buffers.c +++ b/mesalib/src/mesa/main/buffers.c @@ -381,6 +381,7 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers, { struct gl_framebuffer *fb = ctx->DrawBuffer; GLbitfield mask[MAX_DRAW_BUFFERS]; + GLuint buf; if (!destMask) { /* compute destMask values now */ @@ -410,13 +411,10 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers, destMask0 &= ~(1 << bufIndex); } fb->ColorDrawBuffer[0] = buffers[0]; - if (fb->_NumColorDrawBuffers != count) { - updated_drawbuffers(ctx); - fb->_NumColorDrawBuffers = count; - } + fb->_NumColorDrawBuffers = count; } else { - GLuint buf, count = 0; + GLuint count = 0; for (buf = 0; buf < n; buf++ ) { if (destMask[buf]) { GLint bufIndex = _mesa_ffs(destMask[buf]) - 1; @@ -436,21 +434,22 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers, } fb->ColorDrawBuffer[buf] = buffers[buf]; } - /* set remaining outputs to -1 (GL_NONE) */ - while (buf < ctx->Const.MaxDrawBuffers) { - if (fb->_ColorDrawBufferIndexes[buf] != -1) { - updated_drawbuffers(ctx); - fb->_ColorDrawBufferIndexes[buf] = -1; - } - fb->ColorDrawBuffer[buf] = GL_NONE; - buf++; - } fb->_NumColorDrawBuffers = count; } + /* set remaining outputs to -1 (GL_NONE) */ + for (buf = fb->_NumColorDrawBuffers; buf < ctx->Const.MaxDrawBuffers; buf++) { + if (fb->_ColorDrawBufferIndexes[buf] != -1) { + updated_drawbuffers(ctx); + fb->_ColorDrawBufferIndexes[buf] = -1; + } + } + for (buf = n; buf < ctx->Const.MaxDrawBuffers; buf++) { + fb->ColorDrawBuffer[buf] = GL_NONE; + } + if (fb->Name == 0) { /* also set context drawbuffer state */ - GLuint buf; for (buf = 0; buf < ctx->Const.MaxDrawBuffers; buf++) { if (ctx->Color.DrawBuffer[buf] != fb->ColorDrawBuffer[buf]) { updated_drawbuffers(ctx); diff --git a/mesalib/src/mesa/main/enable.c b/mesalib/src/mesa/main/enable.c index ba24ca77c..23b6a9480 100644 --- a/mesalib/src/mesa/main/enable.c +++ b/mesalib/src/mesa/main/enable.c @@ -295,12 +295,14 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) } break; #if FEATURE_userclip - case GL_CLIP_PLANE0: - case GL_CLIP_PLANE1: - case GL_CLIP_PLANE2: - case GL_CLIP_PLANE3: - case GL_CLIP_PLANE4: - case GL_CLIP_PLANE5: + case GL_CLIP_DISTANCE0: + case GL_CLIP_DISTANCE1: + case GL_CLIP_DISTANCE2: + case GL_CLIP_DISTANCE3: + case GL_CLIP_DISTANCE4: + case GL_CLIP_DISTANCE5: + case GL_CLIP_DISTANCE6: + case GL_CLIP_DISTANCE7: { const GLuint p = cap - GL_CLIP_PLANE0; diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c index 81bbca240..57b51d856 100644 --- a/mesalib/src/mesa/main/extensions.c +++ b/mesalib/src/mesa/main/extensions.c @@ -260,7 +260,6 @@ static const struct extension extension_table[] = { { "GL_AMD_draw_buffers_blend", o(ARB_draw_buffers_blend), GL, 2009 }, { "GL_AMD_seamless_cubemap_per_texture", o(AMD_seamless_cubemap_per_texture), GL, 2009 }, { "GL_AMD_shader_stencil_export", o(ARB_shader_stencil_export), GL, 2009 }, - { "GL_APPLE_client_storage", o(APPLE_client_storage), GL, 2002 }, { "GL_APPLE_object_purgeable", o(APPLE_object_purgeable), GL, 2006 }, { "GL_APPLE_packed_pixels", o(APPLE_packed_pixels), GL, 2002 }, { "GL_APPLE_vertex_array_object", o(APPLE_vertex_array_object), GL, 2002 }, diff --git a/mesalib/src/mesa/main/get.c b/mesalib/src/mesa/main/get.c index 45b27777a..827906900 100644 --- a/mesalib/src/mesa/main/get.c +++ b/mesalib/src/mesa/main/get.c @@ -888,7 +888,6 @@ static const struct value_desc values[] = { { GL_UNPACK_SWAP_BYTES, CONTEXT_BOOL(Unpack.SwapBytes), NO_EXTRA }, { GL_UNPACK_SKIP_IMAGES_EXT, CONTEXT_INT(Unpack.SkipImages), NO_EXTRA }, { GL_UNPACK_IMAGE_HEIGHT_EXT, CONTEXT_INT(Unpack.ImageHeight), NO_EXTRA }, - { GL_UNPACK_CLIENT_STORAGE_APPLE, CONTEXT_BOOL(Unpack.ClientStorage), NO_EXTRA }, { GL_ZOOM_X, CONTEXT_FLOAT(Pixel.ZoomX), NO_EXTRA }, { GL_ZOOM_Y, CONTEXT_FLOAT(Pixel.ZoomY), NO_EXTRA }, diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h index 42831d773..cdb02b782 100644 --- a/mesalib/src/mesa/main/mtypes.h +++ b/mesalib/src/mesa/main/mtypes.h @@ -214,7 +214,9 @@ typedef enum VERT_RESULT_BFC0 = 13, VERT_RESULT_BFC1 = 14, VERT_RESULT_EDGE = 15, - VERT_RESULT_VAR0 = 16, /**< shader varying */ + VERT_RESULT_CLIP_DIST0 = 16, + VERT_RESULT_CLIP_DIST1 = 17, + VERT_RESULT_VAR0 = 18, /**< shader varying */ VERT_RESULT_MAX = (VERT_RESULT_VAR0 + MAX_VARYING) } gl_vert_result; @@ -312,7 +314,9 @@ typedef enum FRAG_ATTRIB_TEX7 = 11, FRAG_ATTRIB_FACE = 12, /**< front/back face */ FRAG_ATTRIB_PNTC = 13, /**< sprite/point coord */ - FRAG_ATTRIB_VAR0 = 14, /**< shader varying */ + FRAG_ATTRIB_CLIP_DIST0 = 14, + FRAG_ATTRIB_CLIP_DIST1 = 15, + FRAG_ATTRIB_VAR0 = 16, /**< shader varying */ FRAG_ATTRIB_MAX = (FRAG_ATTRIB_VAR0 + MAX_VARYING) } gl_frag_attrib; @@ -329,8 +333,8 @@ typedef enum static INLINE int _mesa_vert_result_to_frag_attrib(gl_vert_result vert_result) { - if (vert_result >= VERT_RESULT_VAR0) - return vert_result - VERT_RESULT_VAR0 + FRAG_ATTRIB_VAR0; + if (vert_result >= VERT_RESULT_CLIP_DIST0) + return vert_result - VERT_RESULT_CLIP_DIST0 + FRAG_ATTRIB_CLIP_DIST0; else if (vert_result <= VERT_RESULT_TEX7) return vert_result; else @@ -351,8 +355,8 @@ _mesa_frag_attrib_to_vert_result(gl_frag_attrib frag_attrib) { if (frag_attrib <= FRAG_ATTRIB_TEX7) return frag_attrib; - else if (frag_attrib >= FRAG_ATTRIB_VAR0) - return frag_attrib - FRAG_ATTRIB_VAR0 + VERT_RESULT_VAR0; + else if (frag_attrib >= FRAG_ATTRIB_CLIP_DIST0) + return frag_attrib - FRAG_ATTRIB_CLIP_DIST0 + VERT_RESULT_CLIP_DIST0; else return -1; } @@ -1254,11 +1258,6 @@ struct gl_texture_image GLuint HeightLog2; /**< = log2(Height2) */ GLuint DepthLog2; /**< = log2(Depth2) */ GLuint MaxLog2; /**< = MAX(WidthLog2, HeightLog2) */ - GLfloat WidthScale; /**< used for mipmap LOD computation */ - GLfloat HeightScale; /**< used for mipmap LOD computation */ - GLfloat DepthScale; /**< used for mipmap LOD computation */ - GLboolean IsClientData; /**< Data owned by client? */ - GLboolean _IsPowerOfTwo; /**< Are all dimensions powers of two? */ struct gl_texture_object *TexObject; /**< Pointer back to parent object */ GLuint Level; /**< Which mipmap level am I? */ @@ -1559,7 +1558,6 @@ struct gl_pixelstore_attrib GLint SkipImages; GLboolean SwapBytes; GLboolean LsbFirst; - GLboolean ClientStorage; /**< GL_APPLE_client_storage */ GLboolean Invert; /**< GL_MESA_pack_invert */ struct gl_buffer_object *BufferObj; /**< GL_ARB_pixel_buffer_object */ }; @@ -1882,6 +1880,7 @@ struct gl_vertex_program struct gl_program Base; /**< base class */ GLboolean IsNVProgram; /**< is this a GL_NV_vertex_program program? */ GLboolean IsPositionInvariant; + GLboolean UsesClipDistance; }; @@ -2167,6 +2166,11 @@ struct gl_shader_program GLenum OutputType; /**< GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP */ } Geom; + /** Vertex shader state - copied into gl_vertex_program at link time */ + struct { + GLboolean UsesClipDistance; /**< True if gl_ClipDistance is written to. */ + } Vert; + /* post-link info: */ struct gl_vertex_program *VertexProgram; /**< Linked vertex program */ struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */ @@ -2241,6 +2245,7 @@ struct gl_shader_compiler_options GLboolean EmitNoMainReturn; /**< Emit CONT/RET opcodes? */ GLboolean EmitNoNoise; /**< Emit NOISE opcodes? */ GLboolean EmitNoPow; /**< Emit POW opcodes? */ + GLboolean LowerClipDistance; /**< Lower gl_ClipDistance from float[8] to vec4[2]? */ /** * \name Forms of indirect addressing the driver cannot do. @@ -2862,7 +2867,6 @@ struct gl_extensions /* vendor extensions */ GLboolean AMD_conservative_depth; GLboolean AMD_seamless_cubemap_per_texture; - GLboolean APPLE_client_storage; GLboolean APPLE_packed_pixels; GLboolean APPLE_vertex_array_object; GLboolean APPLE_object_purgeable; diff --git a/mesalib/src/mesa/main/pixelstore.c b/mesalib/src/mesa/main/pixelstore.c index f07115e6d..d957950ed 100644 --- a/mesalib/src/mesa/main/pixelstore.c +++ b/mesalib/src/mesa/main/pixelstore.c @@ -1,284 +1,275 @@ -/*
- * Mesa 3-D graphics library
- * Version: 7.1
- *
- * Copyright (C) 1999-2008 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.
- */
-
-/**
- * \file pixelstore.c
- * glPixelStore functions.
- */
-
-
-#include "glheader.h"
-#include "bufferobj.h"
-#include "context.h"
-#include "pixelstore.h"
-#include "mfeatures.h"
-#include "mtypes.h"
-
-
-void GLAPIENTRY
-_mesa_PixelStorei( GLenum pname, GLint param )
-{
- /* NOTE: this call can't be compiled into the display list */
- GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
-
- switch (pname) {
- case GL_PACK_SWAP_BYTES:
- if (param == (GLint)ctx->Pack.SwapBytes)
- return;
- FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
- ctx->Pack.SwapBytes = param ? GL_TRUE : GL_FALSE;
- break;
- case GL_PACK_LSB_FIRST:
- if (param == (GLint)ctx->Pack.LsbFirst)
- return;
- FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
- ctx->Pack.LsbFirst = param ? GL_TRUE : GL_FALSE;
- break;
- case GL_PACK_ROW_LENGTH:
- if (param<0) {
- _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
- return;
- }
- if (ctx->Pack.RowLength == param)
- return;
- FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
- ctx->Pack.RowLength = param;
- break;
- case GL_PACK_IMAGE_HEIGHT:
- if (param<0) {
- _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
- return;
- }
- if (ctx->Pack.ImageHeight == param)
- return;
- FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
- ctx->Pack.ImageHeight = param;
- break;
- case GL_PACK_SKIP_PIXELS:
- if (param<0) {
- _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
- return;
- }
- if (ctx->Pack.SkipPixels == param)
- return;
- FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
- ctx->Pack.SkipPixels = param;
- break;
- case GL_PACK_SKIP_ROWS:
- if (param<0) {
- _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
- return;
- }
- if (ctx->Pack.SkipRows == param)
- return;
- FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
- ctx->Pack.SkipRows = param;
- break;
- case GL_PACK_SKIP_IMAGES:
- if (param<0) {
- _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
- return;
- }
- if (ctx->Pack.SkipImages == param)
- return;
- FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
- ctx->Pack.SkipImages = param;
- break;
- case GL_PACK_ALIGNMENT:
- if (param!=1 && param!=2 && param!=4 && param!=8) {
- _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
- return;
- }
- if (ctx->Pack.Alignment == param)
- return;
- FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
- ctx->Pack.Alignment = param;
- break;
- case GL_PACK_INVERT_MESA:
- if (!ctx->Extensions.MESA_pack_invert) {
- _mesa_error( ctx, GL_INVALID_ENUM, "glPixelstore(pname)" );
- return;
- }
- if (ctx->Pack.Invert == param)
- return;
- FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
- ctx->Pack.Invert = param;
- break;
-
- case GL_UNPACK_SWAP_BYTES:
- if (param == (GLint)ctx->Unpack.SwapBytes)
- return;
- if ((GLint)ctx->Unpack.SwapBytes == param)
- return;
- FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
- ctx->Unpack.SwapBytes = param ? GL_TRUE : GL_FALSE;
- break;
- case GL_UNPACK_LSB_FIRST:
- if (param == (GLint)ctx->Unpack.LsbFirst)
- return;
- if ((GLint)ctx->Unpack.LsbFirst == param)
- return;
- FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
- ctx->Unpack.LsbFirst = param ? GL_TRUE : GL_FALSE;
- break;
- case GL_UNPACK_ROW_LENGTH:
- if (param<0) {
- _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
- return;
- }
- if (ctx->Unpack.RowLength == param)
- return;
- FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
- ctx->Unpack.RowLength = param;
- break;
- case GL_UNPACK_IMAGE_HEIGHT:
- if (param<0) {
- _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
- return;
- }
- if (ctx->Unpack.ImageHeight == param)
- return;
-
- FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
- ctx->Unpack.ImageHeight = param;
- break;
- case GL_UNPACK_SKIP_PIXELS:
- if (param<0) {
- _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
- return;
- }
- if (ctx->Unpack.SkipPixels == param)
- return;
- FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
- ctx->Unpack.SkipPixels = param;
- break;
- case GL_UNPACK_SKIP_ROWS:
- if (param<0) {
- _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
- return;
- }
- if (ctx->Unpack.SkipRows == param)
- return;
- FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
- ctx->Unpack.SkipRows = param;
- break;
- case GL_UNPACK_SKIP_IMAGES:
- if (param < 0) {
- _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
- return;
- }
- if (ctx->Unpack.SkipImages == param)
- return;
- FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
- ctx->Unpack.SkipImages = param;
- break;
- case GL_UNPACK_ALIGNMENT:
- if (param!=1 && param!=2 && param!=4 && param!=8) {
- _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore" );
- return;
- }
- if (ctx->Unpack.Alignment == param)
- return;
- FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
- ctx->Unpack.Alignment = param;
- break;
- case GL_UNPACK_CLIENT_STORAGE_APPLE:
- if (param == (GLint)ctx->Unpack.ClientStorage)
- return;
- FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
- ctx->Unpack.ClientStorage = param ? GL_TRUE : GL_FALSE;
- break;
- default:
- _mesa_error( ctx, GL_INVALID_ENUM, "glPixelStore" );
- return;
- }
-}
-
-
-void GLAPIENTRY
-_mesa_PixelStoref( GLenum pname, GLfloat param )
-{
- _mesa_PixelStorei( pname, (GLint) param );
-}
-
-
-
-/**
- * Initialize the context's pixel store state.
- */
-void
-_mesa_init_pixelstore( struct gl_context *ctx )
-{
- /* Pixel transfer */
- ctx->Pack.Alignment = 4;
- ctx->Pack.RowLength = 0;
- ctx->Pack.ImageHeight = 0;
- ctx->Pack.SkipPixels = 0;
- ctx->Pack.SkipRows = 0;
- ctx->Pack.SkipImages = 0;
- ctx->Pack.SwapBytes = GL_FALSE;
- ctx->Pack.LsbFirst = GL_FALSE;
- ctx->Pack.ClientStorage = GL_FALSE;
- ctx->Pack.Invert = GL_FALSE;
-#if FEATURE_EXT_pixel_buffer_object
- _mesa_reference_buffer_object(ctx, &ctx->Pack.BufferObj,
- ctx->Shared->NullBufferObj);
-#endif
- ctx->Unpack.Alignment = 4;
- ctx->Unpack.RowLength = 0;
- ctx->Unpack.ImageHeight = 0;
- ctx->Unpack.SkipPixels = 0;
- ctx->Unpack.SkipRows = 0;
- ctx->Unpack.SkipImages = 0;
- ctx->Unpack.SwapBytes = GL_FALSE;
- ctx->Unpack.LsbFirst = GL_FALSE;
- ctx->Unpack.ClientStorage = GL_FALSE;
- ctx->Unpack.Invert = GL_FALSE;
-#if FEATURE_EXT_pixel_buffer_object
- _mesa_reference_buffer_object(ctx, &ctx->Unpack.BufferObj,
- ctx->Shared->NullBufferObj);
-#endif
-
- /*
- * _mesa_unpack_image() returns image data in this format. When we
- * execute image commands (glDrawPixels(), glTexImage(), etc) from
- * within display lists we have to be sure to set the current
- * unpacking parameters to these values!
- */
- ctx->DefaultPacking.Alignment = 1;
- ctx->DefaultPacking.RowLength = 0;
- ctx->DefaultPacking.SkipPixels = 0;
- ctx->DefaultPacking.SkipRows = 0;
- ctx->DefaultPacking.ImageHeight = 0;
- ctx->DefaultPacking.SkipImages = 0;
- ctx->DefaultPacking.SwapBytes = GL_FALSE;
- ctx->DefaultPacking.LsbFirst = GL_FALSE;
- ctx->DefaultPacking.ClientStorage = GL_FALSE;
- ctx->DefaultPacking.Invert = GL_FALSE;
-#if FEATURE_EXT_pixel_buffer_object
- _mesa_reference_buffer_object(ctx, &ctx->DefaultPacking.BufferObj,
- ctx->Shared->NullBufferObj);
-#endif
-}
+/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 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. + */ + +/** + * \file pixelstore.c + * glPixelStore functions. + */ + + +#include "glheader.h" +#include "bufferobj.h" +#include "context.h" +#include "pixelstore.h" +#include "mfeatures.h" +#include "mtypes.h" + + +void GLAPIENTRY +_mesa_PixelStorei( GLenum pname, GLint param ) +{ + /* NOTE: this call can't be compiled into the display list */ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + switch (pname) { + case GL_PACK_SWAP_BYTES: + if (param == (GLint)ctx->Pack.SwapBytes) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Pack.SwapBytes = param ? GL_TRUE : GL_FALSE; + break; + case GL_PACK_LSB_FIRST: + if (param == (GLint)ctx->Pack.LsbFirst) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Pack.LsbFirst = param ? GL_TRUE : GL_FALSE; + break; + case GL_PACK_ROW_LENGTH: + if (param<0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + return; + } + if (ctx->Pack.RowLength == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Pack.RowLength = param; + break; + case GL_PACK_IMAGE_HEIGHT: + if (param<0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + return; + } + if (ctx->Pack.ImageHeight == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Pack.ImageHeight = param; + break; + case GL_PACK_SKIP_PIXELS: + if (param<0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + return; + } + if (ctx->Pack.SkipPixels == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Pack.SkipPixels = param; + break; + case GL_PACK_SKIP_ROWS: + if (param<0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + return; + } + if (ctx->Pack.SkipRows == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Pack.SkipRows = param; + break; + case GL_PACK_SKIP_IMAGES: + if (param<0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + return; + } + if (ctx->Pack.SkipImages == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Pack.SkipImages = param; + break; + case GL_PACK_ALIGNMENT: + if (param!=1 && param!=2 && param!=4 && param!=8) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + return; + } + if (ctx->Pack.Alignment == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Pack.Alignment = param; + break; + case GL_PACK_INVERT_MESA: + if (!ctx->Extensions.MESA_pack_invert) { + _mesa_error( ctx, GL_INVALID_ENUM, "glPixelstore(pname)" ); + return; + } + if (ctx->Pack.Invert == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Pack.Invert = param; + break; + + case GL_UNPACK_SWAP_BYTES: + if (param == (GLint)ctx->Unpack.SwapBytes) + return; + if ((GLint)ctx->Unpack.SwapBytes == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Unpack.SwapBytes = param ? GL_TRUE : GL_FALSE; + break; + case GL_UNPACK_LSB_FIRST: + if (param == (GLint)ctx->Unpack.LsbFirst) + return; + if ((GLint)ctx->Unpack.LsbFirst == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Unpack.LsbFirst = param ? GL_TRUE : GL_FALSE; + break; + case GL_UNPACK_ROW_LENGTH: + if (param<0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + return; + } + if (ctx->Unpack.RowLength == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Unpack.RowLength = param; + break; + case GL_UNPACK_IMAGE_HEIGHT: + if (param<0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + return; + } + if (ctx->Unpack.ImageHeight == param) + return; + + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Unpack.ImageHeight = param; + break; + case GL_UNPACK_SKIP_PIXELS: + if (param<0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + return; + } + if (ctx->Unpack.SkipPixels == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Unpack.SkipPixels = param; + break; + case GL_UNPACK_SKIP_ROWS: + if (param<0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + return; + } + if (ctx->Unpack.SkipRows == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Unpack.SkipRows = param; + break; + case GL_UNPACK_SKIP_IMAGES: + if (param < 0) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" ); + return; + } + if (ctx->Unpack.SkipImages == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Unpack.SkipImages = param; + break; + case GL_UNPACK_ALIGNMENT: + if (param!=1 && param!=2 && param!=4 && param!=8) { + _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore" ); + return; + } + if (ctx->Unpack.Alignment == param) + return; + FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); + ctx->Unpack.Alignment = param; + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glPixelStore" ); + return; + } +} + + +void GLAPIENTRY +_mesa_PixelStoref( GLenum pname, GLfloat param ) +{ + _mesa_PixelStorei( pname, (GLint) param ); +} + + + +/** + * Initialize the context's pixel store state. + */ +void +_mesa_init_pixelstore( struct gl_context *ctx ) +{ + /* Pixel transfer */ + ctx->Pack.Alignment = 4; + ctx->Pack.RowLength = 0; + ctx->Pack.ImageHeight = 0; + ctx->Pack.SkipPixels = 0; + ctx->Pack.SkipRows = 0; + ctx->Pack.SkipImages = 0; + ctx->Pack.SwapBytes = GL_FALSE; + ctx->Pack.LsbFirst = GL_FALSE; + ctx->Pack.Invert = GL_FALSE; +#if FEATURE_EXT_pixel_buffer_object + _mesa_reference_buffer_object(ctx, &ctx->Pack.BufferObj, + ctx->Shared->NullBufferObj); +#endif + ctx->Unpack.Alignment = 4; + ctx->Unpack.RowLength = 0; + ctx->Unpack.ImageHeight = 0; + ctx->Unpack.SkipPixels = 0; + ctx->Unpack.SkipRows = 0; + ctx->Unpack.SkipImages = 0; + ctx->Unpack.SwapBytes = GL_FALSE; + ctx->Unpack.LsbFirst = GL_FALSE; + ctx->Unpack.Invert = GL_FALSE; +#if FEATURE_EXT_pixel_buffer_object + _mesa_reference_buffer_object(ctx, &ctx->Unpack.BufferObj, + ctx->Shared->NullBufferObj); +#endif + + /* + * _mesa_unpack_image() returns image data in this format. When we + * execute image commands (glDrawPixels(), glTexImage(), etc) from + * within display lists we have to be sure to set the current + * unpacking parameters to these values! + */ + ctx->DefaultPacking.Alignment = 1; + ctx->DefaultPacking.RowLength = 0; + ctx->DefaultPacking.SkipPixels = 0; + ctx->DefaultPacking.SkipRows = 0; + ctx->DefaultPacking.ImageHeight = 0; + ctx->DefaultPacking.SkipImages = 0; + ctx->DefaultPacking.SwapBytes = GL_FALSE; + ctx->DefaultPacking.LsbFirst = GL_FALSE; + ctx->DefaultPacking.Invert = GL_FALSE; +#if FEATURE_EXT_pixel_buffer_object + _mesa_reference_buffer_object(ctx, &ctx->DefaultPacking.BufferObj, + ctx->Shared->NullBufferObj); +#endif +} diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c index fa00183ac..65fe23cac 100644 --- a/mesalib/src/mesa/main/teximage.c +++ b/mesalib/src/mesa/main/teximage.c @@ -610,7 +610,7 @@ _mesa_free_texture_image_data(struct gl_context *ctx, { (void) ctx; - if (texImage->Data && !texImage->IsClientData) { + if (texImage->Data) { /* free the old texture data */ _mesa_free_texmemory(texImage->Data); } @@ -1159,13 +1159,6 @@ _mesa_init_teximage_fields(struct gl_context *ctx, GLenum target, img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2); - if ((width == 1 || _mesa_is_pow_two(img->Width2)) && - (height == 1 || _mesa_is_pow_two(img->Height2)) && - (depth == 1 || _mesa_is_pow_two(img->Depth2))) - img->_IsPowerOfTwo = GL_TRUE; - else - img->_IsPowerOfTwo = GL_FALSE; - /* RowStride and ImageOffsets[] describe how to address texels in 'Data' */ img->RowStride = width; /* Allocate the ImageOffsets array and initialize to typical values. @@ -1179,19 +1172,6 @@ _mesa_init_teximage_fields(struct gl_context *ctx, GLenum target, img->ImageOffsets[i] = i * width * height; } - /* Compute Width/Height/DepthScale for mipmap lod computation */ - if (target == GL_TEXTURE_RECTANGLE_NV) { - /* scale = 1.0 since texture coords directly map to texels */ - img->WidthScale = 1.0; - img->HeightScale = 1.0; - img->DepthScale = 1.0; - } - else { - img->WidthScale = (GLfloat) img->Width; - img->HeightScale = (GLfloat) img->Height; - img->DepthScale = (GLfloat) img->Depth; - } - img->TexFormat = format; } diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp index 5e565e4ed..7b2c69fdb 100644 --- a/mesalib/src/mesa/program/ir_to_mesa.cpp +++ b/mesalib/src/mesa/program/ir_to_mesa.cpp @@ -3291,6 +3291,8 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) switch (prog->_LinkedShaders[i]->Type) { case GL_VERTEX_SHADER: + ((struct gl_vertex_program *)linked_prog)->UsesClipDistance + = prog->Vert.UsesClipDistance; _mesa_reference_vertprog(ctx, &prog->VertexProgram, (struct gl_vertex_program *)linked_prog); ok = ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB, diff --git a/mesalib/src/mesa/state_tracker/st_cb_fbo.c b/mesalib/src/mesa/state_tracker/st_cb_fbo.c index d43f67ac9..05139ec5a 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_fbo.c +++ b/mesalib/src/mesa/state_tracker/st_cb_fbo.c @@ -47,6 +47,7 @@ #include "st_context.h" #include "st_cb_fbo.h" #include "st_cb_flush.h" +#include "st_cb_texture.h" #include "st_format.h" #include "st_texture.h" #include "st_manager.h" @@ -340,15 +341,17 @@ st_render_texture(struct gl_context *ctx, struct pipe_context *pipe = st->pipe; struct st_renderbuffer *strb; struct gl_renderbuffer *rb; - struct pipe_resource *pt = st_get_texobj_resource(att->Texture); + struct pipe_resource *pt; struct st_texture_object *stObj; const struct gl_texture_image *texImage; struct pipe_surface surf_tmpl; - /* When would this fail? Perhaps assert? */ - if (!pt) + if (!st_finalize_texture(ctx, pipe, att->Texture)) return; + pt = st_get_texobj_resource(att->Texture); + assert(pt); + /* get pointer to texture image we're rendeing to */ texImage = _mesa_get_attachment_teximage(att); diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c index 97c1fabd5..e744a9f0d 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_texture.c +++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c @@ -577,8 +577,7 @@ st_TexImage(struct gl_context * ctx, */ if (stObj->pt) { if (level > (GLint) stObj->pt->last_level || - !st_texture_match_image(stObj->pt, &stImage->base, - stImage->base.Face, stImage->base.Level)) { + !st_texture_match_image(stObj->pt, &stImage->base)) { DBG("release it\n"); pipe_resource_reference(&stObj->pt, NULL); assert(!stObj->pt); @@ -611,8 +610,7 @@ st_TexImage(struct gl_context * ctx, * in its own buffer. */ if (stObj->pt && - st_texture_match_image(stObj->pt, &stImage->base, - stImage->base.Face, stImage->base.Level)) { + st_texture_match_image(stObj->pt, &stImage->base)) { pipe_resource_reference(&stImage->pt, stObj->pt); assert(stImage->pt); diff --git a/mesalib/src/mesa/state_tracker/st_texture.c b/mesalib/src/mesa/state_tracker/st_texture.c index c5dc7dcc4..c18268829 100644 --- a/mesalib/src/mesa/state_tracker/st_texture.c +++ b/mesalib/src/mesa/state_tracker/st_texture.c @@ -170,8 +170,7 @@ st_gl_texture_dims_to_pipe_dims(GLenum texture, */ GLboolean st_texture_match_image(const struct pipe_resource *pt, - const struct gl_texture_image *image, - GLuint face, GLuint level) + const struct gl_texture_image *image) { GLuint ptWidth, ptHeight, ptDepth, ptLayers; @@ -192,9 +191,9 @@ st_texture_match_image(const struct pipe_resource *pt, /* Test if this image's size matches what's expected in the * established texture. */ - if (ptWidth != u_minify(pt->width0, level) || - ptHeight != u_minify(pt->height0, level) || - ptDepth != u_minify(pt->depth0, level) || + if (ptWidth != u_minify(pt->width0, image->Level) || + ptHeight != u_minify(pt->height0, image->Level) || + ptDepth != u_minify(pt->depth0, image->Level) || ptLayers != pt->array_size) return GL_FALSE; @@ -366,9 +365,15 @@ st_texture_image_copy(struct pipe_context *pipe, struct pipe_box src_box; GLuint i; - assert(u_minify(src->width0, srcLevel) == width); - assert(u_minify(src->height0, srcLevel) == height); - assert(u_minify(src->depth0, srcLevel) == depth); + if (u_minify(src->width0, srcLevel) != width || + u_minify(src->height0, srcLevel) != height || + u_minify(src->depth0, srcLevel) != depth) { + /* The source image size doesn't match the destination image size. + * This can happen in some degenerate situations such as rendering to a + * cube map face which was set up with mismatched texture sizes. + */ + return; + } src_box.x = 0; src_box.y = 0; diff --git a/mesalib/src/mesa/state_tracker/st_texture.h b/mesalib/src/mesa/state_tracker/st_texture.h index 50b7284e7..dd3bc7310 100644 --- a/mesalib/src/mesa/state_tracker/st_texture.h +++ b/mesalib/src/mesa/state_tracker/st_texture.h @@ -184,8 +184,7 @@ st_gl_texture_dims_to_pipe_dims(GLenum texture, */ extern GLboolean st_texture_match_image(const struct pipe_resource *pt, - const struct gl_texture_image *image, - GLuint face, GLuint level); + const struct gl_texture_image *image); /* Return a pointer to an image within a texture. Return image stride as * well. diff --git a/mesalib/src/mesa/swrast/s_context.h b/mesalib/src/mesa/swrast/s_context.h index 8357483a2..1e0bfc0f9 100644 --- a/mesalib/src/mesa/swrast/s_context.h +++ b/mesalib/src/mesa/swrast/s_context.h @@ -139,11 +139,12 @@ struct swrast_texture_image { struct gl_texture_image Base; -#if 0 + GLboolean _IsPowerOfTwo; /**< Are all dimensions powers of two? */ + /** used for mipmap LOD computation */ GLfloat WidthScale, HeightScale, DepthScale; - GLboolean _IsPowerOfTwo; /**< Are all dimensions powers of two? */ +#if 0 GLubyte *Data; /**< The actual texture data in malloc'd memory */ GLint TexelSize; /**< bytes per texel block */ diff --git a/mesalib/src/mesa/swrast/s_fragprog.c b/mesalib/src/mesa/swrast/s_fragprog.c index b6bfeaed4..9513b1c46 100644 --- a/mesalib/src/mesa/swrast/s_fragprog.c +++ b/mesalib/src/mesa/swrast/s_fragprog.c @@ -103,8 +103,10 @@ fetch_texel_deriv( struct gl_context *ctx, const GLfloat texcoord[4], if (texObj) { const struct gl_texture_image *texImg = texObj->Image[0][texObj->BaseLevel]; - const GLfloat texW = (GLfloat) texImg->WidthScale; - const GLfloat texH = (GLfloat) texImg->HeightScale; + const struct swrast_texture_image *swImg = + swrast_texture_image_const(texImg); + const GLfloat texW = (GLfloat) swImg->WidthScale; + const GLfloat texH = (GLfloat) swImg->HeightScale; GLfloat lambda; GLfloat rgba[4]; diff --git a/mesalib/src/mesa/swrast/s_span.c b/mesalib/src/mesa/swrast/s_span.c index 16ff7ff02..4631ff3d5 100644 --- a/mesalib/src/mesa/swrast/s_span.c +++ b/mesalib/src/mesa/swrast/s_span.c @@ -490,6 +490,9 @@ interpolate_texcoords(struct gl_context *ctx, SWspan *span) if (obj) { const struct gl_texture_image *img = obj->Image[0][obj->BaseLevel]; + const struct swrast_texture_image *swImg = + swrast_texture_image_const(img); + needLambda = (obj->Sampler.MinFilter != obj->Sampler.MagFilter) || ctx->FragmentProgram._Current; /* LOD is calculated directly in the ansiotropic filter, we can @@ -499,8 +502,8 @@ interpolate_texcoords(struct gl_context *ctx, SWspan *span) obj->Sampler.MinFilter == GL_LINEAR_MIPMAP_LINEAR) { needLambda = GL_FALSE; } - texW = img->WidthScale; - texH = img->HeightScale; + texW = swImg->WidthScale; + texH = swImg->HeightScale; } else { /* using a fragment program */ diff --git a/mesalib/src/mesa/swrast/s_texfilter.c b/mesalib/src/mesa/swrast/s_texfilter.c index a7a190ab6..dd3761986 100644 --- a/mesalib/src/mesa/swrast/s_texfilter.c +++ b/mesalib/src/mesa/swrast/s_texfilter.c @@ -159,11 +159,12 @@ linear_texel_locations(GLenum wrapMode, GLint size, GLfloat s, GLint *i0, GLint *i1, GLfloat *weight) { + const struct swrast_texture_image *swImg = swrast_texture_image_const(img); GLfloat u; switch (wrapMode) { case GL_REPEAT: u = s * size - 0.5F; - if (img->_IsPowerOfTwo) { + if (swImg->_IsPowerOfTwo) { *i0 = IFLOOR(u) & (size - 1); *i1 = (*i0 + 1) & (size - 1); } @@ -285,6 +286,7 @@ nearest_texel_location(GLenum wrapMode, const struct gl_texture_image *img, GLint size, GLfloat s) { + const struct swrast_texture_image *swImg = swrast_texture_image_const(img); GLint i; switch (wrapMode) { @@ -292,7 +294,7 @@ nearest_texel_location(GLenum wrapMode, /* s limited to [0,1) */ /* i limited to [0,size-1] */ i = IFLOOR(s * size); - if (img->_IsPowerOfTwo) + if (swImg->_IsPowerOfTwo) i &= (size - 1); else i = REMAINDER(i, size); @@ -1173,7 +1175,7 @@ sample_2d_linear_repeat(struct gl_context *ctx, ASSERT(tObj->Sampler.WrapS == GL_REPEAT); ASSERT(tObj->Sampler.WrapT == GL_REPEAT); ASSERT(img->Border == 0); - ASSERT(img->_IsPowerOfTwo); + ASSERT(swImg->_IsPowerOfTwo); linear_repeat_texel_location(width, texcoord[0], &i0, &i1, &wi); linear_repeat_texel_location(height, texcoord[1], &j0, &j1, &wj); @@ -1320,10 +1322,11 @@ sample_linear_2d(struct gl_context *ctx, { GLuint i; struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel]; + const struct swrast_texture_image *swImg = swrast_texture_image_const(image); (void) lambda; if (tObj->Sampler.WrapS == GL_REPEAT && tObj->Sampler.WrapT == GL_REPEAT && - image->_IsPowerOfTwo && + swImg->_IsPowerOfTwo && image->Border == 0) { for (i = 0; i < n; i++) { sample_2d_linear_repeat(ctx, tObj, image, texcoords[i], rgba[i]); @@ -1352,6 +1355,7 @@ opt_sample_rgb_2d(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { const struct gl_texture_image *img = tObj->Image[0][tObj->BaseLevel]; + const struct swrast_texture_image *swImg = swrast_texture_image_const(img); const GLfloat width = (GLfloat) img->Width; const GLfloat height = (GLfloat) img->Height; const GLint colMask = img->Width - 1; @@ -1364,7 +1368,7 @@ opt_sample_rgb_2d(struct gl_context *ctx, ASSERT(tObj->Sampler.WrapT==GL_REPEAT); ASSERT(img->Border==0); ASSERT(img->TexFormat == MESA_FORMAT_RGB888); - ASSERT(img->_IsPowerOfTwo); + ASSERT(swImg->_IsPowerOfTwo); for (k=0; k<n; k++) { GLint i = IFLOOR(texcoords[k][0] * width) & colMask; @@ -1394,6 +1398,7 @@ opt_sample_rgba_2d(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { const struct gl_texture_image *img = tObj->Image[0][tObj->BaseLevel]; + const struct swrast_texture_image *swImg = swrast_texture_image_const(img); const GLfloat width = (GLfloat) img->Width; const GLfloat height = (GLfloat) img->Height; const GLint colMask = img->Width - 1; @@ -1406,7 +1411,7 @@ opt_sample_rgba_2d(struct gl_context *ctx, ASSERT(tObj->Sampler.WrapT==GL_REPEAT); ASSERT(img->Border==0); ASSERT(img->TexFormat == MESA_FORMAT_RGBA8888); - ASSERT(img->_IsPowerOfTwo); + ASSERT(swImg->_IsPowerOfTwo); for (i = 0; i < n; i++) { const GLint col = IFLOOR(texcoords[i][0] * width) & colMask; @@ -1429,13 +1434,14 @@ sample_lambda_2d(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { const struct gl_texture_image *tImg = tObj->Image[0][tObj->BaseLevel]; + const struct swrast_texture_image *swImg = swrast_texture_image_const(tImg); GLuint minStart, minEnd; /* texels with minification */ GLuint magStart, magEnd; /* texels with magnification */ const GLboolean repeatNoBorderPOT = (tObj->Sampler.WrapS == GL_REPEAT) && (tObj->Sampler.WrapT == GL_REPEAT) && (tImg->Border == 0 && (tImg->Width == tImg->RowStride)) - && tImg->_IsPowerOfTwo; + && swImg->_IsPowerOfTwo; ASSERT(lambda != NULL); compute_min_mag_ranges(tObj, n, lambda, @@ -1579,8 +1585,10 @@ sample_2d_ewa(struct gl_context *ctx, const struct gl_texture_image *img = tObj->Image[0][level]; const struct gl_texture_image *mostDetailedImage = tObj->Image[0][tObj->BaseLevel]; - GLfloat tex_u=-0.5 + texcoord[0] * mostDetailedImage->WidthScale * scaling; - GLfloat tex_v=-0.5 + texcoord[1] * mostDetailedImage->HeightScale * scaling; + const struct swrast_texture_image *swImg = + swrast_texture_image_const(mostDetailedImage); + GLfloat tex_u=-0.5 + texcoord[0] * swImg->WidthScale * scaling; + GLfloat tex_v=-0.5 + texcoord[1] * swImg->HeightScale * scaling; GLfloat ux = dudx * scaling; GLfloat vx = dvdx * scaling; @@ -1787,6 +1795,7 @@ sample_lambda_2d_aniso(struct gl_context *ctx, const GLfloat lambda_iso[], GLfloat rgba[][4]) { const struct gl_texture_image *tImg = tObj->Image[0][tObj->BaseLevel]; + const struct swrast_texture_image *swImg = swrast_texture_image_const(tImg); const GLfloat maxEccentricity = tObj->Sampler.MaxAnisotropy * tObj->Sampler.MaxAnisotropy; @@ -1829,8 +1838,8 @@ sample_lambda_2d_aniso(struct gl_context *ctx, create_filter_table(); } - texW = tImg->WidthScale; - texH = tImg->HeightScale; + texW = swImg->WidthScale; + texH = swImg->HeightScale; for (i = 0; i < n; i++) { const GLfloat invQ = (q == 0.0F) ? 1.0F : (1.0F / q); @@ -3634,17 +3643,20 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx, else { /* check for a few optimized cases */ const struct gl_texture_image *img = t->Image[0][t->BaseLevel]; + const struct swrast_texture_image *swImg = + swrast_texture_image_const(img); + ASSERT(t->Sampler.MinFilter == GL_NEAREST); if (t->Sampler.WrapS == GL_REPEAT && t->Sampler.WrapT == GL_REPEAT && - img->_IsPowerOfTwo && + swImg->_IsPowerOfTwo && img->Border == 0 && img->TexFormat == MESA_FORMAT_RGB888) { return &opt_sample_rgb_2d; } else if (t->Sampler.WrapS == GL_REPEAT && t->Sampler.WrapT == GL_REPEAT && - img->_IsPowerOfTwo && + swImg->_IsPowerOfTwo && img->Border == 0 && img->TexFormat == MESA_FORMAT_RGBA8888) { return &opt_sample_rgba_2d; diff --git a/mesalib/src/mesa/swrast/s_texture.c b/mesalib/src/mesa/swrast/s_texture.c index 7e3fc2806..aa073753f 100644 --- a/mesalib/src/mesa/swrast/s_texture.c +++ b/mesalib/src/mesa/swrast/s_texture.c @@ -67,6 +67,7 @@ _swrast_alloc_texture_image_buffer(struct gl_context *ctx, gl_format format, GLsizei width, GLsizei height, GLsizei depth) { + struct swrast_texture_image *swImg = swrast_texture_image(texImage); GLuint bytes = _mesa_format_image_size(format, width, height, depth); /* This _should_ be true (revisit if these ever fail) */ @@ -77,6 +78,26 @@ _swrast_alloc_texture_image_buffer(struct gl_context *ctx, assert(!texImage->Data); texImage->Data = _mesa_align_malloc(bytes, 512); + if ((width == 1 || _mesa_is_pow_two(texImage->Width2)) && + (height == 1 || _mesa_is_pow_two(texImage->Height2)) && + (depth == 1 || _mesa_is_pow_two(texImage->Depth2))) + swImg->_IsPowerOfTwo = GL_TRUE; + else + swImg->_IsPowerOfTwo = GL_FALSE; + + /* Compute Width/Height/DepthScale for mipmap lod computation */ + if (texImage->TexObject->Target == GL_TEXTURE_RECTANGLE_NV) { + /* scale = 1.0 since texture coords directly map to texels */ + swImg->WidthScale = 1.0; + swImg->HeightScale = 1.0; + swImg->DepthScale = 1.0; + } + else { + swImg->WidthScale = (GLfloat) texImage->Width; + swImg->HeightScale = (GLfloat) texImage->Height; + swImg->DepthScale = (GLfloat) texImage->Depth; + } + return texImage->Data != NULL; } @@ -88,7 +109,7 @@ void _swrast_free_texture_image_buffer(struct gl_context *ctx, struct gl_texture_image *texImage) { - if (texImage->Data && !texImage->IsClientData) { + if (texImage->Data) { _mesa_align_free(texImage->Data); } diff --git a/mesalib/src/mesa/swrast/s_triangle.c b/mesalib/src/mesa/swrast/s_triangle.c index 8a9671aa0..77bd2a359 100644 --- a/mesalib/src/mesa/swrast/s_triangle.c +++ b/mesalib/src/mesa/swrast/s_triangle.c @@ -1038,11 +1038,14 @@ _swrast_choose_triangle( struct gl_context *ctx ) /* Ugh, we do a _lot_ of tests to pick the best textured tri func */ const struct gl_texture_object *texObj2D; const struct gl_texture_image *texImg; + const struct swrast_texture_image *swImg; GLenum minFilter, magFilter, envMode; gl_format format; texObj2D = ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; texImg = texObj2D ? texObj2D->Image[0][texObj2D->BaseLevel] : NULL; + swImg = swrast_texture_image_const(texImg); + format = texImg ? texImg->TexFormat : MESA_FORMAT_NONE; minFilter = texObj2D ? texObj2D->Sampler.MinFilter : GL_NONE; magFilter = texObj2D ? texObj2D->Sampler.MagFilter : GL_NONE; @@ -1057,7 +1060,7 @@ _swrast_choose_triangle( struct gl_context *ctx ) && texObj2D->Sampler.WrapS == GL_REPEAT && texObj2D->Sampler.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) |