aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-09-26 17:04:30 +0200
committermarha <marha@users.sourceforge.net>2011-09-26 17:04:30 +0200
commit873965b49f283ad028dd4e0e5b7e93a758c84993 (patch)
tree84122d76cb641b54ea85cee9b631fb51c25052b5 /mesalib/src
parentc1e6c7428a8d2c1b60ffac7df7a3f56c300fa983 (diff)
downloadvcxsrv-873965b49f283ad028dd4e0e5b7e93a758c84993.tar.gz
vcxsrv-873965b49f283ad028dd4e0e5b7e93a758c84993.tar.bz2
vcxsrv-873965b49f283ad028dd4e0e5b7e93a758c84993.zip
fontconfig libX11 libXext libXft libXmu mesa git update 26 sep 2011
Diffstat (limited to 'mesalib/src')
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format.c44
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format.h34
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_math.h16
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_rect.c329
-rw-r--r--mesalib/src/glsl/Android.mk1
-rw-r--r--mesalib/src/glsl/Makefile1
-rw-r--r--mesalib/src/glsl/SConscript1
-rw-r--r--mesalib/src/glsl/ast_function.cpp1
-rw-r--r--mesalib/src/glsl/ast_to_hir.cpp1
-rw-r--r--mesalib/src/glsl/glsl_parser_extras.cpp2
-rw-r--r--mesalib/src/glsl/ir_hierarchical_visitor.h3
-rw-r--r--mesalib/src/glsl/ir_hv_accept.cpp21
-rw-r--r--mesalib/src/glsl/ir_optimization.h1
-rw-r--r--mesalib/src/glsl/ir_reader.cpp5
-rw-r--r--mesalib/src/glsl/ir_variable.cpp8
-rw-r--r--mesalib/src/glsl/linker.cpp8
-rw-r--r--mesalib/src/mesa/drivers/common/meta.h2
-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
-rw-r--r--mesalib/src/mesa/program/ir_to_mesa.cpp2
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_fbo.c9
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_texture.c6
-rw-r--r--mesalib/src/mesa/state_tracker/st_texture.c21
-rw-r--r--mesalib/src/mesa/state_tracker/st_texture.h3
-rw-r--r--mesalib/src/mesa/swrast/s_context.h5
-rw-r--r--mesalib/src/mesa/swrast/s_fragprog.c6
-rw-r--r--mesalib/src/mesa/swrast/s_span.c7
-rw-r--r--mesalib/src/mesa/swrast/s_texfilter.c38
-rw-r--r--mesalib/src/mesa/swrast/s_texture.c23
-rw-r--r--mesalib/src/mesa/swrast/s_triangle.c5
36 files changed, 693 insertions, 567 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_format.c b/mesalib/src/gallium/auxiliary/util/u_format.c
index 700382a0f..9bf42583e 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format.c
+++ b/mesalib/src/gallium/auxiliary/util/u_format.c
@@ -432,6 +432,50 @@ util_format_translate(enum pipe_format dst_format,
* TODO: Add a special case for formats that are mere swizzles of each other
*/
+ if (src_format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS ||
+ dst_format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS) {
+ float *tmp_z = NULL;
+ uint8_t *tmp_s = NULL;
+
+ assert(x_step == 1);
+ assert(y_step == 1);
+
+ if (src_format_desc->unpack_z_float &&
+ dst_format_desc->pack_z_float) {
+ tmp_z = MALLOC(width * sizeof *tmp_z);
+ }
+
+ if (src_format_desc->unpack_s_8uscaled &&
+ dst_format_desc->pack_s_8uscaled) {
+ tmp_s = MALLOC(width * sizeof *tmp_s);
+ }
+
+ while (height--) {
+ if (tmp_z) {
+ src_format_desc->unpack_z_float(tmp_z, 0, src_row, src_stride, width, 1);
+ dst_format_desc->pack_z_float(dst_row, dst_stride, tmp_z, 0, width, 1);
+ }
+
+ if (tmp_s) {
+ src_format_desc->unpack_s_8uscaled(tmp_s, 0, src_row, src_stride, width, 1);
+ dst_format_desc->pack_s_8uscaled(dst_row, dst_stride, tmp_s, 0, width, 1);
+ }
+
+ dst_row += dst_step;
+ src_row += src_step;
+ }
+
+ if (tmp_s) {
+ FREE(tmp_s);
+ }
+
+ if (tmp_z) {
+ FREE(tmp_z);
+ }
+
+ return;
+ }
+
if (util_format_fits_8unorm(src_format_desc) ||
util_format_fits_8unorm(dst_format_desc)) {
unsigned tmp_stride;
diff --git a/mesalib/src/gallium/auxiliary/util/u_format.h b/mesalib/src/gallium/auxiliary/util/u_format.h
index 2eb3e1b80..98528ea59 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format.h
+++ b/mesalib/src/gallium/auxiliary/util/u_format.h
@@ -411,6 +411,27 @@ util_format_is_s3tc(enum pipe_format format)
}
static INLINE boolean
+util_format_is_srgb(enum pipe_format format)
+{
+ const struct util_format_description *desc = util_format_description(format);
+ return desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB;
+}
+
+static INLINE boolean
+util_format_has_depth(const struct util_format_description *desc)
+{
+ return desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS &&
+ desc->swizzle[0] != UTIL_FORMAT_SWIZZLE_NONE;
+}
+
+static INLINE boolean
+util_format_has_stencil(const struct util_format_description *desc)
+{
+ return desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS &&
+ desc->swizzle[1] != UTIL_FORMAT_SWIZZLE_NONE;
+}
+
+static INLINE boolean
util_format_is_depth_or_stencil(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
@@ -420,10 +441,11 @@ util_format_is_depth_or_stencil(enum pipe_format format)
return FALSE;
}
- return desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS ? TRUE : FALSE;
+ return util_format_has_depth(desc) ||
+ util_format_has_stencil(desc);
}
-static INLINE boolean
+static INLINE boolean
util_format_is_depth_and_stencil(enum pipe_format format)
{
const struct util_format_description *desc = util_format_description(format);
@@ -433,12 +455,8 @@ util_format_is_depth_and_stencil(enum pipe_format format)
return FALSE;
}
- if (desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS) {
- return FALSE;
- }
-
- return (desc->swizzle[0] != UTIL_FORMAT_SWIZZLE_NONE &&
- desc->swizzle[1] != UTIL_FORMAT_SWIZZLE_NONE) ? TRUE : FALSE;
+ return util_format_has_depth(desc) &&
+ util_format_has_stencil(desc);
}
diff --git a/mesalib/src/gallium/auxiliary/util/u_math.h b/mesalib/src/gallium/auxiliary/util/u_math.h
index 46d932293..c74c1da76 100644
--- a/mesalib/src/gallium/auxiliary/util/u_math.h
+++ b/mesalib/src/gallium/auxiliary/util/u_math.h
@@ -424,6 +424,22 @@ unsigned ffs( unsigned u )
#endif
+/* Destructively loop over all of the bits in a mask as in:
+ *
+ * while (mymask) {
+ * int i = u_bit_scan(&mymask);
+ * ... process element i
+ * }
+ *
+ */
+static INLINE int u_bit_scan(unsigned *mask)
+{
+ int i = ffs(*mask) - 1;
+ *mask &= ~(1 << i);
+ return i;
+}
+
+
/**
* Return float bits.
*/
diff --git a/mesalib/src/gallium/auxiliary/util/u_rect.c b/mesalib/src/gallium/auxiliary/util/u_rect.c
index b11fff791..59bebbcb7 100644
--- a/mesalib/src/gallium/auxiliary/util/u_rect.c
+++ b/mesalib/src/gallium/auxiliary/util/u_rect.c
@@ -1,164 +1,165 @@
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * 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, sub license, 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 (including the
- * next paragraph) 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 NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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.
- *
- **************************************************************************/
-
-/**
- * Rectangle-related helper functions.
- */
-
-
-#include "util/u_format.h"
-#include "util/u_rect.h"
-#include "util/u_pack_color.h"
-
-
-/**
- * Copy 2D rect from one place to another.
- * Position and sizes are in pixels.
- * src_stride may be negative to do vertical flip of pixels from source.
- */
-void
-util_copy_rect(ubyte * dst,
- enum pipe_format format,
- unsigned dst_stride,
- unsigned dst_x,
- unsigned dst_y,
- unsigned width,
- unsigned height,
- const ubyte * src,
- int src_stride,
- unsigned src_x,
- unsigned src_y)
-{
- unsigned i;
- int src_stride_pos = src_stride < 0 ? -src_stride : src_stride;
- int blocksize = util_format_get_blocksize(format);
- int blockwidth = util_format_get_blockwidth(format);
- int blockheight = util_format_get_blockheight(format);
-
- assert(blocksize > 0);
- assert(blockwidth > 0);
- assert(blockheight > 0);
-
- dst_x /= blockwidth;
- dst_y /= blockheight;
- width = (width + blockwidth - 1)/blockwidth;
- height = (height + blockheight - 1)/blockheight;
- src_x /= blockwidth;
- src_y /= blockheight;
-
- dst += dst_x * blocksize;
- src += src_x * blocksize;
- dst += dst_y * dst_stride;
- src += src_y * src_stride_pos;
- width *= blocksize;
-
- if (width == dst_stride && width == src_stride)
- memcpy(dst, src, height * width);
- else {
- for (i = 0; i < height; i++) {
- memcpy(dst, src, width);
- dst += dst_stride;
- src += src_stride;
- }
- }
-}
-
-void
-util_fill_rect(ubyte * dst,
- enum pipe_format format,
- unsigned dst_stride,
- unsigned dst_x,
- unsigned dst_y,
- unsigned width,
- unsigned height,
- union util_color *uc)
-{
- unsigned i, j;
- unsigned width_size;
- int blocksize = util_format_get_blocksize(format);
- int blockwidth = util_format_get_blockwidth(format);
- int blockheight = util_format_get_blockheight(format);
-
- assert(blocksize > 0);
- assert(blockwidth > 0);
- assert(blockheight > 0);
-
- dst_x /= blockwidth;
- dst_y /= blockheight;
- width = (width + blockwidth - 1)/blockwidth;
- height = (height + blockheight - 1)/blockheight;
-
- dst += dst_x * blocksize;
- dst += dst_y * dst_stride;
- width_size = width * blocksize;
-
- switch (blocksize) {
- case 1:
- if(dst_stride == width_size)
- memset(dst, uc->ub, height * width_size);
- else {
- for (i = 0; i < height; i++) {
- memset(dst, uc->ub, width_size);
- dst += dst_stride;
- }
- }
- break;
- case 2:
- for (i = 0; i < height; i++) {
- uint16_t *row = (uint16_t *)dst;
- for (j = 0; j < width; j++)
- *row++ = uc->us;
- dst += dst_stride;
- }
- break;
- case 4:
- for (i = 0; i < height; i++) {
- uint32_t *row = (uint32_t *)dst;
- for (j = 0; j < width; j++)
- *row++ = uc->ui;
- dst += dst_stride;
- }
- break;
- case 8:
- case 12:
- case 16:
- case 24:
- case 32:
- for (i = 0; i < height; i++) {
- ubyte *row = dst;
- for (j = 0; j < width; j++) {
- memcpy(row, uc, blocksize);
- row += blocksize;
- }
- dst += dst_stride;
- }
- break;
- default:
- assert(0);
- break;
- }
-}
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * 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, sub license, 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 (including the
+ * next paragraph) 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 NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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.
+ *
+ **************************************************************************/
+
+/**
+ * Rectangle-related helper functions.
+ */
+
+
+#include "util/u_format.h"
+#include "util/u_rect.h"
+#include "util/u_pack_color.h"
+
+
+/**
+ * Copy 2D rect from one place to another.
+ * Position and sizes are in pixels.
+ * src_stride may be negative to do vertical flip of pixels from source.
+ */
+void
+util_copy_rect(ubyte * dst,
+ enum pipe_format format,
+ unsigned dst_stride,
+ unsigned dst_x,
+ unsigned dst_y,
+ unsigned width,
+ unsigned height,
+ const ubyte * src,
+ int src_stride,
+ unsigned src_x,
+ unsigned src_y)
+{
+ unsigned i;
+ int src_stride_pos = src_stride < 0 ? -src_stride : src_stride;
+ int blocksize = util_format_get_blocksize(format);
+ int blockwidth = util_format_get_blockwidth(format);
+ int blockheight = util_format_get_blockheight(format);
+
+ assert(blocksize > 0);
+ assert(blockwidth > 0);
+ assert(blockheight > 0);
+
+ dst_x /= blockwidth;
+ dst_y /= blockheight;
+ width = (width + blockwidth - 1)/blockwidth;
+ height = (height + blockheight - 1)/blockheight;
+ src_x /= blockwidth;
+ src_y /= blockheight;
+
+ dst += dst_x * blocksize;
+ src += src_x * blocksize;
+ dst += dst_y * dst_stride;
+ src += src_y * src_stride_pos;
+ width *= blocksize;
+
+ if (width == dst_stride && width == src_stride)
+ memcpy(dst, src, height * width);
+ else {
+ for (i = 0; i < height; i++) {
+ memcpy(dst, src, width);
+ dst += dst_stride;
+ src += src_stride;
+ }
+ }
+}
+
+void
+util_fill_rect(ubyte * dst,
+ enum pipe_format format,
+ unsigned dst_stride,
+ unsigned dst_x,
+ unsigned dst_y,
+ unsigned width,
+ unsigned height,
+ union util_color *uc)
+{
+ const struct util_format_description *desc = util_format_description(format);
+ unsigned i, j;
+ unsigned width_size;
+ int blocksize = desc->block.bits / 8;
+ int blockwidth = desc->block.width;
+ int blockheight = desc->block.height;
+
+ assert(blocksize > 0);
+ assert(blockwidth > 0);
+ assert(blockheight > 0);
+
+ dst_x /= blockwidth;
+ dst_y /= blockheight;
+ width = (width + blockwidth - 1)/blockwidth;
+ height = (height + blockheight - 1)/blockheight;
+
+ dst += dst_x * blocksize;
+ dst += dst_y * dst_stride;
+ width_size = width * blocksize;
+
+ switch (blocksize) {
+ case 1:
+ if(dst_stride == width_size)
+ memset(dst, uc->ub, height * width_size);
+ else {
+ for (i = 0; i < height; i++) {
+ memset(dst, uc->ub, width_size);
+ dst += dst_stride;
+ }
+ }
+ break;
+ case 2:
+ for (i = 0; i < height; i++) {
+ uint16_t *row = (uint16_t *)dst;
+ for (j = 0; j < width; j++)
+ *row++ = uc->us;
+ dst += dst_stride;
+ }
+ break;
+ case 4:
+ for (i = 0; i < height; i++) {
+ uint32_t *row = (uint32_t *)dst;
+ for (j = 0; j < width; j++)
+ *row++ = uc->ui;
+ dst += dst_stride;
+ }
+ break;
+ case 8:
+ case 12:
+ case 16:
+ case 24:
+ case 32:
+ for (i = 0; i < height; i++) {
+ ubyte *row = dst;
+ for (j = 0; j < width; j++) {
+ memcpy(row, uc, blocksize);
+ row += blocksize;
+ }
+ dst += dst_stride;
+ }
+ break;
+ default:
+ assert(0);
+ break;
+ }
+}
diff --git a/mesalib/src/glsl/Android.mk b/mesalib/src/glsl/Android.mk
index d0b3ff3be..9bf4ff782 100644
--- a/mesalib/src/glsl/Android.mk
+++ b/mesalib/src/glsl/Android.mk
@@ -70,6 +70,7 @@ CXX_SOURCES = \
loop_analysis.cpp \
loop_controls.cpp \
loop_unroll.cpp \
+ lower_clip_distance.cpp \
lower_discard.cpp \
lower_if_to_cond_assign.cpp \
lower_instructions.cpp \
diff --git a/mesalib/src/glsl/Makefile b/mesalib/src/glsl/Makefile
index 00b7b9164..b2efb2abc 100644
--- a/mesalib/src/glsl/Makefile
+++ b/mesalib/src/glsl/Makefile
@@ -56,6 +56,7 @@ CXX_SOURCES = \
loop_analysis.cpp \
loop_controls.cpp \
loop_unroll.cpp \
+ lower_clip_distance.cpp \
lower_discard.cpp \
lower_if_to_cond_assign.cpp \
lower_instructions.cpp \
diff --git a/mesalib/src/glsl/SConscript b/mesalib/src/glsl/SConscript
index 1da58a91f..b4786c5e5 100644
--- a/mesalib/src/glsl/SConscript
+++ b/mesalib/src/glsl/SConscript
@@ -67,6 +67,7 @@ glsl_sources = [
'loop_analysis.cpp',
'loop_controls.cpp',
'loop_unroll.cpp',
+ 'lower_clip_distance.cpp',
'lower_discard.cpp',
'lower_if_to_cond_assign.cpp',
'lower_instructions.cpp',
diff --git a/mesalib/src/glsl/ast_function.cpp b/mesalib/src/glsl/ast_function.cpp
index ca45934a4..fc0d7497d 100644
--- a/mesalib/src/glsl/ast_function.cpp
+++ b/mesalib/src/glsl/ast_function.cpp
@@ -117,6 +117,7 @@ match_function_by_name(exec_list *instructions, const char *name,
/* The current shader doesn't contain a matching function or signature.
* Before giving up, look for the prototype in the built-in functions.
*/
+ _mesa_glsl_initialize_functions(state);
for (unsigned i = 0; i < state->num_builtins_to_link; i++) {
ir_function *builtin;
builtin = state->builtins_to_link[i]->symbols->get_function(name);
diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp
index ce29d5a87..91a223160 100644
--- a/mesalib/src/glsl/ast_to_hir.cpp
+++ b/mesalib/src/glsl/ast_to_hir.cpp
@@ -60,7 +60,6 @@ void
_mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state)
{
_mesa_glsl_initialize_variables(instructions, state);
- _mesa_glsl_initialize_functions(state);
state->symbols->language_version = state->language_version;
diff --git a/mesalib/src/glsl/glsl_parser_extras.cpp b/mesalib/src/glsl/glsl_parser_extras.cpp
index 8faddc578..a9075b2b1 100644
--- a/mesalib/src/glsl/glsl_parser_extras.cpp
+++ b/mesalib/src/glsl/glsl_parser_extras.cpp
@@ -52,6 +52,8 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *ctx,
this->error = false;
this->loop_or_switch_nesting = NULL;
+ this->num_builtins_to_link = 0;
+
/* Set default language version and extensions */
this->language_version = 110;
this->es_shader = false;
diff --git a/mesalib/src/glsl/ir_hierarchical_visitor.h b/mesalib/src/glsl/ir_hierarchical_visitor.h
index dc177f5eb..bba046db4 100644
--- a/mesalib/src/glsl/ir_hierarchical_visitor.h
+++ b/mesalib/src/glsl/ir_hierarchical_visitor.h
@@ -178,6 +178,7 @@ void visit_tree(ir_instruction *ir,
void (*callback)(class ir_instruction *ir, void *data),
void *data);
-ir_visitor_status visit_list_elements(ir_hierarchical_visitor *v, exec_list *l);
+ir_visitor_status visit_list_elements(ir_hierarchical_visitor *v, exec_list *l,
+ bool statement_list = true);
#endif /* IR_HIERARCHICAL_VISITOR_H */
diff --git a/mesalib/src/glsl/ir_hv_accept.cpp b/mesalib/src/glsl/ir_hv_accept.cpp
index d33fc85bf..0e78fda81 100644
--- a/mesalib/src/glsl/ir_hv_accept.cpp
+++ b/mesalib/src/glsl/ir_hv_accept.cpp
@@ -30,7 +30,13 @@
*/
/**
- * Process a list of nodes using a hierarchical vistor
+ * Process a list of nodes using a hierarchical vistor.
+ *
+ * If statement_list is true (the default), this is a list of statements, so
+ * v->base_ir will be set to point to each statement just before iterating
+ * over it, and restored after iteration is complete. If statement_list is
+ * false, this is a list that appears inside a statement (e.g. a parameter
+ * list), so v->base_ir will be left alone.
*
* \warning
* This function will operate correctly if a node being processed is removed
@@ -38,19 +44,22 @@
* processed, some of the added nodes may not be processed.
*/
ir_visitor_status
-visit_list_elements(ir_hierarchical_visitor *v, exec_list *l)
+visit_list_elements(ir_hierarchical_visitor *v, exec_list *l,
+ bool statement_list)
{
ir_instruction *prev_base_ir = v->base_ir;
foreach_list_safe(n, l) {
ir_instruction *const ir = (ir_instruction *) n;
- v->base_ir = ir;
+ if (statement_list)
+ v->base_ir = ir;
ir_visitor_status s = ir->accept(v);
if (s != visit_continue)
return s;
}
- v->base_ir = prev_base_ir;
+ if (statement_list)
+ v->base_ir = prev_base_ir;
return visit_continue;
}
@@ -129,7 +138,7 @@ ir_function::accept(ir_hierarchical_visitor *v)
if (s != visit_continue)
return (s == visit_continue_with_parent) ? visit_continue : s;
- s = visit_list_elements(v, &this->signatures);
+ s = visit_list_elements(v, &this->signatures, false);
return (s == visit_stop) ? s : v->visit_leave(this);
}
@@ -317,7 +326,7 @@ ir_call::accept(ir_hierarchical_visitor *v)
if (s != visit_continue)
return (s == visit_continue_with_parent) ? visit_continue : s;
- s = visit_list_elements(v, &this->actual_parameters);
+ s = visit_list_elements(v, &this->actual_parameters, false);
if (s == visit_stop)
return s;
diff --git a/mesalib/src/glsl/ir_optimization.h b/mesalib/src/glsl/ir_optimization.h
index 48448d4a1..af80e26b9 100644
--- a/mesalib/src/glsl/ir_optimization.h
+++ b/mesalib/src/glsl/ir_optimization.h
@@ -69,6 +69,7 @@ bool lower_noise(exec_list *instructions);
bool lower_variable_index_to_cond_assign(exec_list *instructions,
bool lower_input, bool lower_output, bool lower_temp, bool lower_uniform);
bool lower_quadop_vector(exec_list *instructions, bool dont_lower_swz);
+bool lower_clip_distance(exec_list *instructions);
bool optimize_redundant_jumps(exec_list *instructions);
ir_rvalue *
diff --git a/mesalib/src/glsl/ir_reader.cpp b/mesalib/src/glsl/ir_reader.cpp
index 2d0bccb78..afb06b3be 100644
--- a/mesalib/src/glsl/ir_reader.cpp
+++ b/mesalib/src/glsl/ir_reader.cpp
@@ -79,7 +79,8 @@ _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions,
void
ir_reader::read(exec_list *instructions, const char *src, bool scan_for_protos)
{
- s_expression *expr = s_expression::read_expression(mem_ctx, src);
+ void *sx_mem_ctx = ralloc_context(NULL);
+ s_expression *expr = s_expression::read_expression(sx_mem_ctx, src);
if (expr == NULL) {
ir_read_error(NULL, "couldn't parse S-Expression.");
return;
@@ -92,7 +93,7 @@ ir_reader::read(exec_list *instructions, const char *src, bool scan_for_protos)
}
read_instructions(instructions, expr, NULL);
- ralloc_free(expr);
+ ralloc_free(sx_mem_ctx);
if (debug)
validate_ir_tree(instructions);
diff --git a/mesalib/src/glsl/ir_variable.cpp b/mesalib/src/glsl/ir_variable.cpp
index e0b6f38f1..58be64bfa 100644
--- a/mesalib/src/glsl/ir_variable.cpp
+++ b/mesalib/src/glsl/ir_variable.cpp
@@ -621,9 +621,9 @@ generate_130_vs_variables(exec_list *instructions,
const glsl_type *const clip_distance_array_type =
glsl_type::get_array_instance(glsl_type::float_type, 0);
- /* FINISHME: gl_ClipDistance needs a real location assigned. */
add_variable(instructions, state->symbols,
- "gl_ClipDistance", clip_distance_array_type, ir_var_out, -1);
+ "gl_ClipDistance", clip_distance_array_type, ir_var_out,
+ VERT_RESULT_CLIP_DIST0);
}
@@ -841,9 +841,9 @@ generate_130_fs_variables(exec_list *instructions,
const glsl_type *const clip_distance_array_type =
glsl_type::get_array_instance(glsl_type::float_type, 0);
- /* FINISHME: gl_ClipDistance needs a real location assigned. */
add_variable(instructions, state->symbols,
- "gl_ClipDistance", clip_distance_array_type, ir_var_in, -1);
+ "gl_ClipDistance", clip_distance_array_type, ir_var_in,
+ FRAG_ATTRIB_CLIP_DIST0);
}
static void
diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp
index 195f58f29..d802a0a9b 100644
--- a/mesalib/src/glsl/linker.cpp
+++ b/mesalib/src/glsl/linker.cpp
@@ -244,7 +244,9 @@ count_attribute_slots(const glsl_type *t)
/**
- * Verify that a vertex shader executable meets all semantic requirements
+ * Verify that a vertex shader executable meets all semantic requirements.
+ *
+ * Also sets prog->Vert.UsesClipDistance as a side effect.
*
* \param shader Vertex shader executable to be verified
*/
@@ -279,6 +281,7 @@ validate_vertex_shader_executable(struct gl_shader_program *prog,
"and `gl_ClipDistance'\n");
return false;
}
+ prog->Vert.UsesClipDistance = clip_distance.variable_found();
}
return true;
@@ -1743,6 +1746,9 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
if (!prog->LinkStatus)
goto done;
+ if (ctx->ShaderCompilerOptions[i].LowerClipDistance)
+ lower_clip_distance(prog->_LinkedShaders[i]->ir);
+
while (do_common_optimization(prog->_LinkedShaders[i]->ir, true, 32))
;
}
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)