aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/main')
-rw-r--r--mesalib/src/mesa/main/attrib.c1
-rw-r--r--mesalib/src/mesa/main/buffers.c29
-rw-r--r--mesalib/src/mesa/main/enable.c14
-rw-r--r--mesalib/src/mesa/main/extensions.c1
-rw-r--r--mesalib/src/mesa/main/get.c1
-rw-r--r--mesalib/src/mesa/main/mtypes.h30
-rw-r--r--mesalib/src/mesa/main/pixelstore.c559
-rw-r--r--mesalib/src/mesa/main/teximage.c22
8 files changed, 315 insertions, 342 deletions
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;
}