aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-09-01 08:06:37 +0200
committermarha <marha@users.sourceforge.net>2011-09-01 08:06:37 +0200
commit746359d2f7e675a0bfc48a4ba6f8200cace98df2 (patch)
treebe9e3cd02e43b69c70432036c3c6f90c11a4be7f
parentd14fe6598b87092374b1be6eb655153d270c3066 (diff)
downloadvcxsrv-746359d2f7e675a0bfc48a4ba6f8200cace98df2.tar.gz
vcxsrv-746359d2f7e675a0bfc48a4ba6f8200cace98df2.tar.bz2
vcxsrv-746359d2f7e675a0bfc48a4ba6f8200cace98df2.zip
mesa git update 1 Sep 2011
-rw-r--r--mesalib/Android.mk4
-rw-r--r--mesalib/src/glsl/ir_optimization.h13
-rw-r--r--mesalib/src/glsl/lower_instructions.cpp125
-rw-r--r--mesalib/src/mesa/drivers/dri/Android.mk9
-rw-r--r--mesalib/src/mesa/main/colormac.h484
-rw-r--r--mesalib/src/mesa/main/config.h716
-rw-r--r--mesalib/src/mesa/main/formats.c2
-rw-r--r--mesalib/src/mesa/main/mtypes.h6
-rw-r--r--mesalib/src/mesa/main/texfetch_tmp.h97
-rw-r--r--mesalib/src/mesa/program/ir_to_mesa.cpp10
-rw-r--r--mesalib/src/mesa/state_tracker/st_extensions.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp8
-rw-r--r--mesalib/src/mesa/swrast/s_context.c22
-rw-r--r--mesalib/src/mesa/swrast/s_readpix.c4
14 files changed, 785 insertions, 717 deletions
diff --git a/mesalib/Android.mk b/mesalib/Android.mk
index 7c7c55a11..a5c9ebc5f 100644
--- a/mesalib/Android.mk
+++ b/mesalib/Android.mk
@@ -23,7 +23,7 @@
# BOARD_GPU_DRIVERS should be defined. The valid values are
#
-# classic drivers: i965
+# classic drivers: i915 i965
# gallium drivers: swrast i915g nouveau r300g r600g vmwgfx
#
# The main target is libGLES_mesa. For each classic driver enabled, a DRI
@@ -36,7 +36,7 @@ MESA_PYTHON2 := python
DRM_TOP := external/drm
DRM_GRALLOC_TOP := hardware/drm_gralloc
-classic_drivers := i965
+classic_drivers := i915 i965
gallium_drivers := swrast i915g nouveau r300g r600g vmwgfx
MESA_GPU_DRIVERS := $(strip $(BOARD_GPU_DRIVERS))
diff --git a/mesalib/src/glsl/ir_optimization.h b/mesalib/src/glsl/ir_optimization.h
index f7808bdda..48448d4a1 100644
--- a/mesalib/src/glsl/ir_optimization.h
+++ b/mesalib/src/glsl/ir_optimization.h
@@ -29,12 +29,13 @@
*/
/* Operations for lower_instructions() */
-#define SUB_TO_ADD_NEG 0x01
-#define DIV_TO_MUL_RCP 0x02
-#define EXP_TO_EXP2 0x04
-#define POW_TO_EXP2 0x08
-#define LOG_TO_LOG2 0x10
-#define MOD_TO_FRACT 0x20
+#define SUB_TO_ADD_NEG 0x01
+#define DIV_TO_MUL_RCP 0x02
+#define EXP_TO_EXP2 0x04
+#define POW_TO_EXP2 0x08
+#define LOG_TO_LOG2 0x10
+#define MOD_TO_FRACT 0x20
+#define INT_DIV_TO_MUL_RCP 0x40
bool do_common_optimization(exec_list *ir, bool linked, unsigned max_unroll_iterations);
diff --git a/mesalib/src/glsl/lower_instructions.cpp b/mesalib/src/glsl/lower_instructions.cpp
index 23aa19bde..d79eb0a7f 100644
--- a/mesalib/src/glsl/lower_instructions.cpp
+++ b/mesalib/src/glsl/lower_instructions.cpp
@@ -32,6 +32,7 @@
* Currently supported transformations:
* - SUB_TO_ADD_NEG
* - DIV_TO_MUL_RCP
+ * - INT_DIV_TO_MUL_RCP
* - EXP_TO_EXP2
* - POW_TO_EXP2
* - LOG_TO_LOG2
@@ -47,8 +48,8 @@
* want to recognize add(op0, neg(op1)) or the other way around to
* produce a subtract anyway.
*
- * DIV_TO_MUL_RCP:
- * ---------------
+ * DIV_TO_MUL_RCP and INT_DIV_TO_MUL_RCP:
+ * --------------------------------------
* Breaks an ir_unop_div expression down to op0 * (rcp(op1)).
*
* Many GPUs don't have a divide instruction (945 and 965 included),
@@ -56,6 +57,10 @@
* reciprocal. By breaking the operation down, constant reciprocals
* can get constant folded.
*
+ * DIV_TO_MUL_RCP only lowers floating point division; INT_DIV_TO_MUL_RCP
+ * handles the integer case, converting to and from floating point so that
+ * RCP is possible.
+ *
* EXP_TO_EXP2 and LOG_TO_LOG2:
* ----------------------------
* Many GPUs don't have a base e log or exponent instruction, but they
@@ -95,6 +100,7 @@ private:
void sub_to_add_neg(ir_expression *);
void div_to_mul_rcp(ir_expression *);
+ void int_div_to_mul_rcp(ir_expression *);
void mod_to_fract(ir_expression *);
void exp_to_exp2(ir_expression *);
void pow_to_exp2(ir_expression *);
@@ -127,60 +133,67 @@ lower_instructions_visitor::sub_to_add_neg(ir_expression *ir)
void
lower_instructions_visitor::div_to_mul_rcp(ir_expression *ir)
{
- if (!ir->operands[1]->type->is_integer()) {
- /* New expression for the 1.0 / op1 */
- ir_rvalue *expr;
- expr = new(ir) ir_expression(ir_unop_rcp,
- ir->operands[1]->type,
- ir->operands[1],
- NULL);
-
- /* op0 / op1 -> op0 * (1.0 / op1) */
- ir->operation = ir_binop_mul;
- ir->operands[1] = expr;
+ assert(ir->operands[1]->type->is_float());
+
+ /* New expression for the 1.0 / op1 */
+ ir_rvalue *expr;
+ expr = new(ir) ir_expression(ir_unop_rcp,
+ ir->operands[1]->type,
+ ir->operands[1]);
+
+ /* op0 / op1 -> op0 * (1.0 / op1) */
+ ir->operation = ir_binop_mul;
+ ir->operands[1] = expr;
+
+ this->progress = true;
+}
+
+void
+lower_instructions_visitor::int_div_to_mul_rcp(ir_expression *ir)
+{
+ assert(ir->operands[1]->type->is_integer());
+
+ /* Be careful with integer division -- we need to do it as a
+ * float and re-truncate, since rcp(n > 1) of an integer would
+ * just be 0.
+ */
+ ir_rvalue *op0, *op1;
+ const struct glsl_type *vec_type;
+
+ vec_type = glsl_type::get_instance(GLSL_TYPE_FLOAT,
+ ir->operands[1]->type->vector_elements,
+ ir->operands[1]->type->matrix_columns);
+
+ if (ir->operands[1]->type->base_type == GLSL_TYPE_INT)
+ op1 = new(ir) ir_expression(ir_unop_i2f, vec_type, ir->operands[1], NULL);
+ else
+ op1 = new(ir) ir_expression(ir_unop_u2f, vec_type, ir->operands[1], NULL);
+
+ op1 = new(ir) ir_expression(ir_unop_rcp, op1->type, op1, NULL);
+
+ vec_type = glsl_type::get_instance(GLSL_TYPE_FLOAT,
+ ir->operands[0]->type->vector_elements,
+ ir->operands[0]->type->matrix_columns);
+
+ if (ir->operands[0]->type->base_type == GLSL_TYPE_INT)
+ op0 = new(ir) ir_expression(ir_unop_i2f, vec_type, ir->operands[0], NULL);
+ else
+ op0 = new(ir) ir_expression(ir_unop_u2f, vec_type, ir->operands[0], NULL);
+
+ vec_type = glsl_type::get_instance(GLSL_TYPE_FLOAT,
+ ir->type->vector_elements,
+ ir->type->matrix_columns);
+
+ op0 = new(ir) ir_expression(ir_binop_mul, vec_type, op0, op1);
+
+ if (ir->operands[1]->type->base_type == GLSL_TYPE_INT) {
+ ir->operation = ir_unop_f2i;
+ ir->operands[0] = op0;
} else {
- /* Be careful with integer division -- we need to do it as a
- * float and re-truncate, since rcp(n > 1) of an integer would
- * just be 0.
- */
- ir_rvalue *op0, *op1;
- const struct glsl_type *vec_type;
-
- vec_type = glsl_type::get_instance(GLSL_TYPE_FLOAT,
- ir->operands[1]->type->vector_elements,
- ir->operands[1]->type->matrix_columns);
-
- if (ir->operands[1]->type->base_type == GLSL_TYPE_INT)
- op1 = new(ir) ir_expression(ir_unop_i2f, vec_type, ir->operands[1], NULL);
- else
- op1 = new(ir) ir_expression(ir_unop_u2f, vec_type, ir->operands[1], NULL);
-
- op1 = new(ir) ir_expression(ir_unop_rcp, op1->type, op1, NULL);
-
- vec_type = glsl_type::get_instance(GLSL_TYPE_FLOAT,
- ir->operands[0]->type->vector_elements,
- ir->operands[0]->type->matrix_columns);
-
- if (ir->operands[0]->type->base_type == GLSL_TYPE_INT)
- op0 = new(ir) ir_expression(ir_unop_i2f, vec_type, ir->operands[0], NULL);
- else
- op0 = new(ir) ir_expression(ir_unop_u2f, vec_type, ir->operands[0], NULL);
-
- vec_type = glsl_type::get_instance(GLSL_TYPE_FLOAT,
- ir->type->vector_elements,
- ir->type->matrix_columns);
-
- op0 = new(ir) ir_expression(ir_binop_mul, vec_type, op0, op1);
-
- if (ir->operands[1]->type->base_type == GLSL_TYPE_INT) {
- ir->operation = ir_unop_f2i;
- ir->operands[0] = op0;
- } else {
- ir->operation = ir_unop_i2u;
- ir->operands[0] = new(ir) ir_expression(ir_unop_f2i, op0);
- }
- ir->operands[1] = NULL;
+ ir->operation = ir_unop_i2u;
+ ir->operands[0] = new(ir) ir_expression(ir_unop_f2i, op0);
}
+ ir->operands[1] = NULL;
this->progress = true;
}
@@ -265,7 +278,9 @@ lower_instructions_visitor::visit_leave(ir_expression *ir)
break;
case ir_binop_div:
- if (lowering(DIV_TO_MUL_RCP))
+ if (ir->operands[1]->type->is_integer() && lowering(INT_DIV_TO_MUL_RCP))
+ int_div_to_mul_rcp(ir);
+ else if (ir->operands[1]->type->is_float() && lowering(DIV_TO_MUL_RCP))
div_to_mul_rcp(ir);
break;
diff --git a/mesalib/src/mesa/drivers/dri/Android.mk b/mesalib/src/mesa/drivers/dri/Android.mk
index b8ccd0c1b..577f66408 100644
--- a/mesalib/src/mesa/drivers/dri/Android.mk
+++ b/mesalib/src/mesa/drivers/dri/Android.mk
@@ -31,6 +31,11 @@ include $(LOCAL_PATH)/common/Makefile.sources
MESA_DRI_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/dri
MESA_DRI_MODULE_UNSTRIPPED_PATH := $(TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)/dri
+MESA_DRI_CFLAGS := \
+ -DFEATURE_GL=1 \
+ -DFEATURE_ES1=1 \
+ -DFEATURE_ES2=1
+
MESA_DRI_C_INCLUDES := \
$(addprefix $(MESA_TOP)/, $(mesa_dri_common_INCLUDES)) \
$(DRM_TOP) \
@@ -55,6 +60,10 @@ MESA_DRI_SHARED_LIBRARIES := \
SUBDIRS := common
+ifneq ($(filter i915, $(MESA_GPU_DRIVERS)),)
+ SUBDIRS += i915
+endif
+
ifneq ($(filter i965, $(MESA_GPU_DRIVERS)),)
SUBDIRS += i965
endif
diff --git a/mesalib/src/mesa/main/colormac.h b/mesalib/src/mesa/main/colormac.h
index ebad20fc4..d308c48b6 100644
--- a/mesalib/src/mesa/main/colormac.h
+++ b/mesalib/src/mesa/main/colormac.h
@@ -1,239 +1,245 @@
-/*
- * Mesa 3-D graphics library
- * Version: 7.3
- *
- * 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 colormac.h
- * Color-related macros
- */
-
-
-#ifndef COLORMAC_H
-#define COLORMAC_H
-
-
-#include "config.h"
-#include "macros.h"
-#include "mtypes.h"
-
-
-/** \def BYTE_TO_CHAN
- * Convert from GLbyte to GLchan */
-
-/** \def UBYTE_TO_CHAN
- * Convert from GLubyte to GLchan */
-
-/** \def SHORT_TO_CHAN
- * Convert from GLshort to GLchan */
-
-/** \def USHORT_TO_CHAN
- * Convert from GLushort to GLchan */
-
-/** \def INT_TO_CHAN
- * Convert from GLint to GLchan */
-
-/** \def UINT_TO_CHAN
- * Convert from GLuint to GLchan */
-
-/** \def CHAN_TO_UBYTE
- * Convert from GLchan to GLubyte */
-
-/** \def CHAN_TO_FLOAT
- * Convert from GLchan to GLfloat */
-
-/** \def CLAMPED_FLOAT_TO_CHAN
- * Convert from GLclampf to GLchan */
-
-/** \def UNCLAMPED_FLOAT_TO_CHAN
- * Convert from GLfloat to GLchan */
-
-/** \def COPY_CHAN4
- * Copy a GLchan[4] array */
-
-#if CHAN_BITS == 8
-
-#define BYTE_TO_CHAN(b) ((b) < 0 ? 0 : (GLchan) (b))
-#define UBYTE_TO_CHAN(b) (b)
-#define SHORT_TO_CHAN(s) ((s) < 0 ? 0 : (GLchan) ((s) >> 7))
-#define USHORT_TO_CHAN(s) ((GLchan) ((s) >> 8))
-#define INT_TO_CHAN(i) ((i) < 0 ? 0 : (GLchan) ((i) >> 23))
-#define UINT_TO_CHAN(i) ((GLchan) ((i) >> 24))
-
-#define CHAN_TO_UBYTE(c) (c)
-#define CHAN_TO_FLOAT(c) UBYTE_TO_FLOAT(c)
-
-#define CLAMPED_FLOAT_TO_CHAN(c, f) CLAMPED_FLOAT_TO_UBYTE(c, f)
-#define UNCLAMPED_FLOAT_TO_CHAN(c, f) UNCLAMPED_FLOAT_TO_UBYTE(c, f)
-
-#define COPY_CHAN4(DST, SRC) COPY_4UBV(DST, SRC)
-
-#elif CHAN_BITS == 16
-
-#define BYTE_TO_CHAN(b) ((b) < 0 ? 0 : (((GLchan) (b)) * 516))
-#define UBYTE_TO_CHAN(b) ((((GLchan) (b)) << 8) | ((GLchan) (b)))
-#define SHORT_TO_CHAN(s) ((s) < 0 ? 0 : (GLchan) (s))
-#define USHORT_TO_CHAN(s) (s)
-#define INT_TO_CHAN(i) ((i) < 0 ? 0 : (GLchan) ((i) >> 15))
-#define UINT_TO_CHAN(i) ((GLchan) ((i) >> 16))
-
-#define CHAN_TO_UBYTE(c) ((c) >> 8)
-#define CHAN_TO_FLOAT(c) ((GLfloat) ((c) * (1.0 / CHAN_MAXF)))
-
-#define CLAMPED_FLOAT_TO_CHAN(c, f) CLAMPED_FLOAT_TO_USHORT(c, f)
-#define UNCLAMPED_FLOAT_TO_CHAN(c, f) UNCLAMPED_FLOAT_TO_USHORT(c, f)
-
-#define COPY_CHAN4(DST, SRC) COPY_4V(DST, SRC)
-
-#elif CHAN_BITS == 32
-
-/* XXX floating-point color channels not fully thought-out */
-#define BYTE_TO_CHAN(b) ((GLfloat) ((b) * (1.0F / 127.0F)))
-#define UBYTE_TO_CHAN(b) ((GLfloat) ((b) * (1.0F / 255.0F)))
-#define SHORT_TO_CHAN(s) ((GLfloat) ((s) * (1.0F / 32767.0F)))
-#define USHORT_TO_CHAN(s) ((GLfloat) ((s) * (1.0F / 65535.0F)))
-#define INT_TO_CHAN(i) ((GLfloat) ((i) * (1.0F / 2147483647.0F)))
-#define UINT_TO_CHAN(i) ((GLfloat) ((i) * (1.0F / 4294967295.0F)))
-
-#define CHAN_TO_UBYTE(c) FLOAT_TO_UBYTE(c)
-#define CHAN_TO_FLOAT(c) (c)
-
-#define CLAMPED_FLOAT_TO_CHAN(c, f) c = (f)
-#define UNCLAMPED_FLOAT_TO_CHAN(c, f) c = (f)
-
-#define COPY_CHAN4(DST, SRC) COPY_4V(DST, SRC)
-
-#else
-
-#error unexpected CHAN_BITS size
-
-#endif
-
-
-/**
- * Convert 3 channels at once.
- *
- * \param dst pointer to destination GLchan[3] array.
- * \param f pointer to source GLfloat[3] array.
- *
- * \sa #UNCLAMPED_FLOAT_TO_CHAN.
- */
-#define UNCLAMPED_FLOAT_TO_RGB_CHAN(dst, f) \
-do { \
- UNCLAMPED_FLOAT_TO_CHAN((dst)[0], (f)[0]); \
- UNCLAMPED_FLOAT_TO_CHAN((dst)[1], (f)[1]); \
- UNCLAMPED_FLOAT_TO_CHAN((dst)[2], (f)[2]); \
-} while (0)
-
-
-/**
- * Convert 4 channels at once.
- *
- * \param dst pointer to destination GLchan[4] array.
- * \param f pointer to source GLfloat[4] array.
- *
- * \sa #UNCLAMPED_FLOAT_TO_CHAN.
- */
-#define UNCLAMPED_FLOAT_TO_RGBA_CHAN(dst, f) \
-do { \
- UNCLAMPED_FLOAT_TO_CHAN((dst)[0], (f)[0]); \
- UNCLAMPED_FLOAT_TO_CHAN((dst)[1], (f)[1]); \
- UNCLAMPED_FLOAT_TO_CHAN((dst)[2], (f)[2]); \
- UNCLAMPED_FLOAT_TO_CHAN((dst)[3], (f)[3]); \
-} while (0)
-
-
-
-/**
- * \name Generic color packing macros. All inputs should be GLubytes.
- *
- * \todo We may move these into texstore.h at some point.
- */
-/*@{*/
-
-#define PACK_COLOR_8888( X, Y, Z, W ) \
- (((X) << 24) | ((Y) << 16) | ((Z) << 8) | (W))
-
-#define PACK_COLOR_8888_REV( X, Y, Z, W ) \
- (((W) << 24) | ((Z) << 16) | ((Y) << 8) | (X))
-
-#define PACK_COLOR_888( X, Y, Z ) \
- (((X) << 16) | ((Y) << 8) | (Z))
-
-#define PACK_COLOR_565( X, Y, Z ) \
- ((((X) & 0xf8) << 8) | (((Y) & 0xfc) << 3) | (((Z) & 0xf8) >> 3))
-
-#define PACK_COLOR_565_REV( X, Y, Z ) \
- (((X) & 0xf8) | ((Y) & 0xe0) >> 5 | (((Y) & 0x1c) << 11) | (((Z) & 0xf8) << 5))
-
-#define PACK_COLOR_5551( R, G, B, A ) \
- ((((R) & 0xf8) << 8) | (((G) & 0xf8) << 3) | (((B) & 0xf8) >> 2) | \
- ((A) ? 1 : 0))
-
-#define PACK_COLOR_1555( A, B, G, R ) \
- ((((B) & 0xf8) << 7) | (((G) & 0xf8) << 2) | (((R) & 0xf8) >> 3) | \
- ((A) ? 0x8000 : 0))
-
-#define PACK_COLOR_1555_REV( A, B, G, R ) \
- ((((B) & 0xf8) >> 1) | (((G) & 0xc0) >> 6) | (((G) & 0x38) << 10) | (((R) & 0xf8) << 5) | \
- ((A) ? 0x80 : 0))
-
-#define PACK_COLOR_2101010_UB( A, B, G, R ) \
- (((B) << 22) | ((G) << 12) | ((R) << 2) | \
- (((A) & 0xc0) << 24))
-
-#define PACK_COLOR_2101010_US( A, B, G, R ) \
- ((((B) >> 6) << 20) | (((G) >> 6) << 10) | ((R) >> 6) | \
- (((A) >> 14) << 30))
-
-#define PACK_COLOR_4444( R, G, B, A ) \
- ((((R) & 0xf0) << 8) | (((G) & 0xf0) << 4) | ((B) & 0xf0) | ((A) >> 4))
-
-#define PACK_COLOR_4444_REV( R, G, B, A ) \
- ((((B) & 0xf0) << 8) | (((A) & 0xf0) << 4) | ((R) & 0xf0) | ((G) >> 4))
-
-#define PACK_COLOR_44( L, A ) \
- (((L) & 0xf0) | (((A) & 0xf0) >> 4))
-
-#define PACK_COLOR_88( L, A ) \
- (((L) << 8) | (A))
-
-#define PACK_COLOR_88_REV( L, A ) \
- (((A) << 8) | (L))
-
-#define PACK_COLOR_1616( L, A ) \
- (((L) << 16) | (A))
-
-#define PACK_COLOR_1616_REV( L, A ) \
- (((A) << 16) | (L))
-
-#define PACK_COLOR_332( R, G, B ) \
- (((R) & 0xe0) | (((G) & 0xe0) >> 3) | (((B) & 0xc0) >> 6))
-
-#define PACK_COLOR_233( B, G, R ) \
- (((B) & 0xc0) | (((G) & 0xe0) >> 2) | (((R) & 0xe0) >> 5))
-
-/*@}*/
-
-
-#endif /* COLORMAC_H */
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.3
+ *
+ * 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 colormac.h
+ * Color-related macros
+ */
+
+
+#ifndef COLORMAC_H
+#define COLORMAC_H
+
+
+#include "config.h"
+#include "macros.h"
+#include "mtypes.h"
+
+
+/** \def BYTE_TO_CHAN
+ * Convert from GLbyte to GLchan */
+
+/** \def UBYTE_TO_CHAN
+ * Convert from GLubyte to GLchan */
+
+/** \def SHORT_TO_CHAN
+ * Convert from GLshort to GLchan */
+
+/** \def USHORT_TO_CHAN
+ * Convert from GLushort to GLchan */
+
+/** \def INT_TO_CHAN
+ * Convert from GLint to GLchan */
+
+/** \def UINT_TO_CHAN
+ * Convert from GLuint to GLchan */
+
+/** \def CHAN_TO_UBYTE
+ * Convert from GLchan to GLubyte */
+
+/** \def CHAN_TO_FLOAT
+ * Convert from GLchan to GLfloat */
+
+/** \def CLAMPED_FLOAT_TO_CHAN
+ * Convert from GLclampf to GLchan */
+
+/** \def UNCLAMPED_FLOAT_TO_CHAN
+ * Convert from GLfloat to GLchan */
+
+/** \def COPY_CHAN4
+ * Copy a GLchan[4] array */
+
+#if CHAN_BITS == 8
+
+#define BYTE_TO_CHAN(b) ((b) < 0 ? 0 : (GLchan) (b))
+#define UBYTE_TO_CHAN(b) (b)
+#define SHORT_TO_CHAN(s) ((s) < 0 ? 0 : (GLchan) ((s) >> 7))
+#define USHORT_TO_CHAN(s) ((GLchan) ((s) >> 8))
+#define INT_TO_CHAN(i) ((i) < 0 ? 0 : (GLchan) ((i) >> 23))
+#define UINT_TO_CHAN(i) ((GLchan) ((i) >> 24))
+
+#define CHAN_TO_UBYTE(c) (c)
+#define CHAN_TO_USHORT(c) (((c) << 8) | (c))
+#define CHAN_TO_SHORT(c) (((c) << 7) | ((c) >> 1))
+#define CHAN_TO_FLOAT(c) UBYTE_TO_FLOAT(c)
+
+#define CLAMPED_FLOAT_TO_CHAN(c, f) CLAMPED_FLOAT_TO_UBYTE(c, f)
+#define UNCLAMPED_FLOAT_TO_CHAN(c, f) UNCLAMPED_FLOAT_TO_UBYTE(c, f)
+
+#define COPY_CHAN4(DST, SRC) COPY_4UBV(DST, SRC)
+
+#elif CHAN_BITS == 16
+
+#define BYTE_TO_CHAN(b) ((b) < 0 ? 0 : (((GLchan) (b)) * 516))
+#define UBYTE_TO_CHAN(b) ((((GLchan) (b)) << 8) | ((GLchan) (b)))
+#define SHORT_TO_CHAN(s) ((s) < 0 ? 0 : (GLchan) (s))
+#define USHORT_TO_CHAN(s) (s)
+#define INT_TO_CHAN(i) ((i) < 0 ? 0 : (GLchan) ((i) >> 15))
+#define UINT_TO_CHAN(i) ((GLchan) ((i) >> 16))
+
+#define CHAN_TO_UBYTE(c) ((c) >> 8)
+#define CHAN_TO_USHORT(c) (c)
+#define CHAN_TO_SHORT(c) ((c) >> 1)
+#define CHAN_TO_FLOAT(c) ((GLfloat) ((c) * (1.0 / CHAN_MAXF)))
+
+#define CLAMPED_FLOAT_TO_CHAN(c, f) CLAMPED_FLOAT_TO_USHORT(c, f)
+#define UNCLAMPED_FLOAT_TO_CHAN(c, f) UNCLAMPED_FLOAT_TO_USHORT(c, f)
+
+#define COPY_CHAN4(DST, SRC) COPY_4V(DST, SRC)
+
+#elif CHAN_BITS == 32
+
+/* XXX floating-point color channels not fully thought-out */
+#define BYTE_TO_CHAN(b) ((GLfloat) ((b) * (1.0F / 127.0F)))
+#define UBYTE_TO_CHAN(b) ((GLfloat) ((b) * (1.0F / 255.0F)))
+#define SHORT_TO_CHAN(s) ((GLfloat) ((s) * (1.0F / 32767.0F)))
+#define USHORT_TO_CHAN(s) ((GLfloat) ((s) * (1.0F / 65535.0F)))
+#define INT_TO_CHAN(i) ((GLfloat) ((i) * (1.0F / 2147483647.0F)))
+#define UINT_TO_CHAN(i) ((GLfloat) ((i) * (1.0F / 4294967295.0F)))
+
+#define CHAN_TO_UBYTE(c) FLOAT_TO_UBYTE(c)
+#define CHAN_TO_USHORT(c) ((GLushort) (CLAMP((c), 0.0f, 1.0f) * 65535.0))
+#define CHAN_TO_SHORT(c) ((GLshort) (CLAMP((c), 0.0f, 1.0f) * 32767.0))
+#define CHAN_TO_FLOAT(c) (c)
+
+#define CLAMPED_FLOAT_TO_CHAN(c, f) c = (f)
+#define UNCLAMPED_FLOAT_TO_CHAN(c, f) c = (f)
+
+#define COPY_CHAN4(DST, SRC) COPY_4V(DST, SRC)
+
+#else
+
+#error unexpected CHAN_BITS size
+
+#endif
+
+
+/**
+ * Convert 3 channels at once.
+ *
+ * \param dst pointer to destination GLchan[3] array.
+ * \param f pointer to source GLfloat[3] array.
+ *
+ * \sa #UNCLAMPED_FLOAT_TO_CHAN.
+ */
+#define UNCLAMPED_FLOAT_TO_RGB_CHAN(dst, f) \
+do { \
+ UNCLAMPED_FLOAT_TO_CHAN((dst)[0], (f)[0]); \
+ UNCLAMPED_FLOAT_TO_CHAN((dst)[1], (f)[1]); \
+ UNCLAMPED_FLOAT_TO_CHAN((dst)[2], (f)[2]); \
+} while (0)
+
+
+/**
+ * Convert 4 channels at once.
+ *
+ * \param dst pointer to destination GLchan[4] array.
+ * \param f pointer to source GLfloat[4] array.
+ *
+ * \sa #UNCLAMPED_FLOAT_TO_CHAN.
+ */
+#define UNCLAMPED_FLOAT_TO_RGBA_CHAN(dst, f) \
+do { \
+ UNCLAMPED_FLOAT_TO_CHAN((dst)[0], (f)[0]); \
+ UNCLAMPED_FLOAT_TO_CHAN((dst)[1], (f)[1]); \
+ UNCLAMPED_FLOAT_TO_CHAN((dst)[2], (f)[2]); \
+ UNCLAMPED_FLOAT_TO_CHAN((dst)[3], (f)[3]); \
+} while (0)
+
+
+
+/**
+ * \name Generic color packing macros. All inputs should be GLubytes.
+ *
+ * \todo We may move these into texstore.h at some point.
+ */
+/*@{*/
+
+#define PACK_COLOR_8888( X, Y, Z, W ) \
+ (((X) << 24) | ((Y) << 16) | ((Z) << 8) | (W))
+
+#define PACK_COLOR_8888_REV( X, Y, Z, W ) \
+ (((W) << 24) | ((Z) << 16) | ((Y) << 8) | (X))
+
+#define PACK_COLOR_888( X, Y, Z ) \
+ (((X) << 16) | ((Y) << 8) | (Z))
+
+#define PACK_COLOR_565( X, Y, Z ) \
+ ((((X) & 0xf8) << 8) | (((Y) & 0xfc) << 3) | (((Z) & 0xf8) >> 3))
+
+#define PACK_COLOR_565_REV( X, Y, Z ) \
+ (((X) & 0xf8) | ((Y) & 0xe0) >> 5 | (((Y) & 0x1c) << 11) | (((Z) & 0xf8) << 5))
+
+#define PACK_COLOR_5551( R, G, B, A ) \
+ ((((R) & 0xf8) << 8) | (((G) & 0xf8) << 3) | (((B) & 0xf8) >> 2) | \
+ ((A) ? 1 : 0))
+
+#define PACK_COLOR_1555( A, B, G, R ) \
+ ((((B) & 0xf8) << 7) | (((G) & 0xf8) << 2) | (((R) & 0xf8) >> 3) | \
+ ((A) ? 0x8000 : 0))
+
+#define PACK_COLOR_1555_REV( A, B, G, R ) \
+ ((((B) & 0xf8) >> 1) | (((G) & 0xc0) >> 6) | (((G) & 0x38) << 10) | (((R) & 0xf8) << 5) | \
+ ((A) ? 0x80 : 0))
+
+#define PACK_COLOR_2101010_UB( A, B, G, R ) \
+ (((B) << 22) | ((G) << 12) | ((R) << 2) | \
+ (((A) & 0xc0) << 24))
+
+#define PACK_COLOR_2101010_US( A, B, G, R ) \
+ ((((B) >> 6) << 20) | (((G) >> 6) << 10) | ((R) >> 6) | \
+ (((A) >> 14) << 30))
+
+#define PACK_COLOR_4444( R, G, B, A ) \
+ ((((R) & 0xf0) << 8) | (((G) & 0xf0) << 4) | ((B) & 0xf0) | ((A) >> 4))
+
+#define PACK_COLOR_4444_REV( R, G, B, A ) \
+ ((((B) & 0xf0) << 8) | (((A) & 0xf0) << 4) | ((R) & 0xf0) | ((G) >> 4))
+
+#define PACK_COLOR_44( L, A ) \
+ (((L) & 0xf0) | (((A) & 0xf0) >> 4))
+
+#define PACK_COLOR_88( L, A ) \
+ (((L) << 8) | (A))
+
+#define PACK_COLOR_88_REV( L, A ) \
+ (((A) << 8) | (L))
+
+#define PACK_COLOR_1616( L, A ) \
+ (((L) << 16) | (A))
+
+#define PACK_COLOR_1616_REV( L, A ) \
+ (((A) << 16) | (L))
+
+#define PACK_COLOR_332( R, G, B ) \
+ (((R) & 0xe0) | (((G) & 0xe0) >> 3) | (((B) & 0xc0) >> 6))
+
+#define PACK_COLOR_233( B, G, R ) \
+ (((B) & 0xc0) | (((G) & 0xe0) >> 2) | (((R) & 0xe0) >> 5))
+
+/*@}*/
+
+
+#endif /* COLORMAC_H */
diff --git a/mesalib/src/mesa/main/config.h b/mesalib/src/mesa/main/config.h
index a12f7f4f3..91aef90b7 100644
--- a/mesalib/src/mesa/main/config.h
+++ b/mesalib/src/mesa/main/config.h
@@ -1,358 +1,358 @@
-/*
- * Mesa 3-D graphics library
- * Version: 7.5
- *
- * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
- * Copyright (C) 2008 VMware, Inc. 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 config.h
- * Tunable configuration parameters.
- */
-
-#ifndef MESA_CONFIG_H_INCLUDED
-#define MESA_CONFIG_H_INCLUDED
-
-
-/**
- * \name OpenGL implementation limits
- */
-/*@{*/
-
-/** Maximum modelview matrix stack depth */
-#define MAX_MODELVIEW_STACK_DEPTH 32
-
-/** Maximum projection matrix stack depth */
-#define MAX_PROJECTION_STACK_DEPTH 32
-
-/** Maximum texture matrix stack depth */
-#define MAX_TEXTURE_STACK_DEPTH 10
-
-/** Maximum color matrix stack depth */
-#define MAX_COLOR_STACK_DEPTH 4
-
-/** Maximum attribute stack depth */
-#define MAX_ATTRIB_STACK_DEPTH 16
-
-/** Maximum client attribute stack depth */
-#define MAX_CLIENT_ATTRIB_STACK_DEPTH 16
-
-/** Maximum recursion depth of display list calls */
-#define MAX_LIST_NESTING 64
-
-/** Maximum number of lights */
-#define MAX_LIGHTS 8
-
-/** Maximum user-defined clipping planes */
-#define MAX_CLIP_PLANES 6
-
-/** Maximum pixel map lookup table size */
-#define MAX_PIXEL_MAP_TABLE 256
-
-/** Maximum number of auxillary color buffers */
-#define MAX_AUX_BUFFERS 1
-
-/** Maximum order (degree) of curves */
-#ifdef AMIGA
-# define MAX_EVAL_ORDER 12
-#else
-# define MAX_EVAL_ORDER 30
-#endif
-
-/** Maximum Name stack depth */
-#define MAX_NAME_STACK_DEPTH 64
-
-/** Minimum point size */
-#define MIN_POINT_SIZE 1.0
-/** Maximum point size */
-#define MAX_POINT_SIZE 60.0
-/** Point size granularity */
-#define POINT_SIZE_GRANULARITY 0.1
-
-/** Minimum line width */
-#define MIN_LINE_WIDTH 1.0
-/** Maximum line width */
-#define MAX_LINE_WIDTH 10.0
-/** Line width granularity */
-#define LINE_WIDTH_GRANULARITY 0.1
-
-/** Max texture palette / color table size */
-#define MAX_COLOR_TABLE_SIZE 256
-
-/** Max memory to allow for a single texture image (in megabytes) */
-#define MAX_TEXTURE_MBYTES 1024
-
-/** Number of 1D/2D texture mipmap levels */
-#define MAX_TEXTURE_LEVELS 15
-
-/** Number of 3D texture mipmap levels */
-#define MAX_3D_TEXTURE_LEVELS 15
-
-/** Number of cube texture mipmap levels - GL_ARB_texture_cube_map */
-#define MAX_CUBE_TEXTURE_LEVELS 15
-
-/** Maximum rectangular texture size - GL_NV_texture_rectangle */
-#define MAX_TEXTURE_RECT_SIZE 16384
-
-/** Maximum number of layers in a 1D or 2D array texture - GL_MESA_texture_array */
-#define MAX_ARRAY_TEXTURE_LAYERS 64
-
-/**
- * Max number of texture coordinate units. This mainly just applies to
- * the fixed-function vertex code. This will be difficult to raise above
- * eight because of various vertex attribute bitvectors.
- */
-#define MAX_TEXTURE_COORD_UNITS 8
-
-/**
- * Max number of texture image units. Also determines number of texture
- * samplers in shaders.
- */
-#define MAX_TEXTURE_IMAGE_UNITS 16
-
-/**
- * Larger of MAX_TEXTURE_COORD_UNITS and MAX_TEXTURE_IMAGE_UNITS.
- * This value is only used for dimensioning arrays.
- * Either MAX_TEXTURE_COORD_UNITS or MAX_TEXTURE_IMAGE_UNITS (or the
- * corresponding ctx->Const.MaxTextureCoord/ImageUnits fields) should be
- * used almost everywhere else.
- */
-#define MAX_TEXTURE_UNITS ((MAX_TEXTURE_COORD_UNITS > MAX_TEXTURE_IMAGE_UNITS) ? MAX_TEXTURE_COORD_UNITS : MAX_TEXTURE_IMAGE_UNITS)
-
-
-/**
- * Maximum viewport/image width. Must accomodate all texture sizes too.
- */
-
-#ifndef MAX_WIDTH
-# define MAX_WIDTH 16384
-#endif
-/** Maximum viewport/image height */
-#ifndef MAX_HEIGHT
-# define MAX_HEIGHT 16384
-#endif
-
-/* XXX: hack to prevent stack overflow on windows until all temporary arrays
- * [MAX_WIDTH] are allocated from the heap */
-#ifdef WIN32
-#undef MAX_TEXTURE_LEVELS
-#undef MAX_3D_TEXTURE_LEVELS
-#undef MAX_CUBE_TEXTURE_LEVELS
-#undef MAX_TEXTURE_RECT_SIZE
-#undef MAX_WIDTH
-#undef MAX_HEIGHT
-#define MAX_TEXTURE_LEVELS 13
-#define MAX_3D_TEXTURE_LEVELS 9
-#define MAX_CUBE_TEXTURE_LEVELS 13
-#define MAX_TEXTURE_RECT_SIZE 4096
-#define MAX_WIDTH 4096
-#define MAX_HEIGHT 4096
-#endif
-
-/** Maxmimum size for CVA. May be overridden by the drivers. */
-#define MAX_ARRAY_LOCK_SIZE 3000
-
-/** Subpixel precision for antialiasing, window coordinate snapping */
-#define SUB_PIXEL_BITS 4
-
-/** Size of histogram tables */
-#define HISTOGRAM_TABLE_SIZE 256
-
-/** Max convolution filter width */
-#define MAX_CONVOLUTION_WIDTH 9
-/** Max convolution filter height */
-#define MAX_CONVOLUTION_HEIGHT 9
-
-/** For GL_ARB_texture_compression */
-#define MAX_COMPRESSED_TEXTURE_FORMATS 25
-
-/** For GL_EXT_texture_filter_anisotropic */
-#define MAX_TEXTURE_MAX_ANISOTROPY 16.0
-
-/** For GL_EXT_texture_lod_bias (typically MAX_TEXTURE_LEVELS - 1) */
-#define MAX_TEXTURE_LOD_BIAS 14.0
-
-/** For any program target/extension */
-/*@{*/
-#define MAX_PROGRAM_INSTRUCTIONS (16 * 1024)
-
-/**
- * Per-program constants (power of two)
- *
- * \c MAX_PROGRAM_LOCAL_PARAMS and \c MAX_UNIFORMS are just the assembly shader
- * and GLSL shader names for the same thing. They should \b always have the
- * same value. Each refers to the number of vec4 values supplied as
- * per-program parameters.
- */
-/*@{*/
-#define MAX_PROGRAM_LOCAL_PARAMS 1024
-#define MAX_UNIFORMS 1024
-/*@}*/
-
-/**
- * Per-context constants (power of two)
- *
- * \note
- * This value should always be less than or equal to \c MAX_PROGRAM_LOCAL_PARAMS
- * and \c MAX_VERTEX_PROGRAM_PARAMS. Otherwise some applications will make
- * incorrect assumptions.
- */
-#define MAX_PROGRAM_ENV_PARAMS 256
-
-#define MAX_PROGRAM_MATRICES 8
-#define MAX_PROGRAM_MATRIX_STACK_DEPTH 4
-#define MAX_PROGRAM_CALL_DEPTH 8
-#define MAX_PROGRAM_TEMPS 256
-#define MAX_PROGRAM_ADDRESS_REGS 2
-#define MAX_VARYING 16 /**< number of float[4] vectors */
-#define MAX_SAMPLERS MAX_TEXTURE_IMAGE_UNITS
-#define MAX_PROGRAM_INPUTS 32
-#define MAX_PROGRAM_OUTPUTS 64
-/*@}*/
-
-/** For GL_ARB_vertex_program */
-/*@{*/
-#define MAX_VERTEX_PROGRAM_ADDRESS_REGS 1
-#define MAX_VERTEX_PROGRAM_PARAMS MAX_UNIFORMS
-/*@}*/
-
-/** For GL_ARB_fragment_program */
-/*@{*/
-#define MAX_FRAGMENT_PROGRAM_ADDRESS_REGS 0
-/*@}*/
-
-/** For GL_NV_vertex_program */
-/*@{*/
-#define MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS 128
-#define MAX_NV_VERTEX_PROGRAM_TEMPS 12
-#define MAX_NV_VERTEX_PROGRAM_PARAMS 96
-#define MAX_NV_VERTEX_PROGRAM_INPUTS 16
-#define MAX_NV_VERTEX_PROGRAM_OUTPUTS 15
-/*@}*/
-
-/** For GL_NV_fragment_program */
-/*@{*/
-#define MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS 1024 /* 72 for GL_ARB_f_p */
-#define MAX_NV_FRAGMENT_PROGRAM_TEMPS 96
-#define MAX_NV_FRAGMENT_PROGRAM_PARAMS 64
-#define MAX_NV_FRAGMENT_PROGRAM_INPUTS 12
-#define MAX_NV_FRAGMENT_PROGRAM_OUTPUTS 3
-#define MAX_NV_FRAGMENT_PROGRAM_WRITE_ONLYS 2
-/*@}*/
-
-
-/** For GL_ARB_vertex_shader */
-/*@{*/
-#define MAX_VERTEX_GENERIC_ATTRIBS 16
-#define MAX_VERTEX_TEXTURE_IMAGE_UNITS MAX_TEXTURE_IMAGE_UNITS
-#define MAX_COMBINED_TEXTURE_IMAGE_UNITS (MAX_VERTEX_TEXTURE_IMAGE_UNITS + \
- MAX_TEXTURE_IMAGE_UNITS)
-/*@}*/
-
-
-/** For GL_ARB_draw_buffers */
-/*@{*/
-#define MAX_DRAW_BUFFERS 8
-/*@}*/
-
-
-/** For GL_EXT_framebuffer_object */
-/*@{*/
-#define MAX_COLOR_ATTACHMENTS 8
-/*@}*/
-
-/** For GL_ATI_envmap_bump - support bump mapping on first 8 units */
-#define SUPPORTED_ATI_BUMP_UNITS 0xff
-
-/** For GL_EXT_transform_feedback */
-#define MAX_FEEDBACK_ATTRIBS 32
-
-/** For GL_ARB_geometry_shader4 */
-/*@{*/
-#define MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 8
-#define MAX_GEOMETRY_VARYING_COMPONENTS 32
-#define MAX_VERTEX_VARYING_COMPONENTS 32
-#define MAX_GEOMETRY_UNIFORM_COMPONENTS 512
-#define MAX_GEOMETRY_OUTPUT_VERTICES 256
-#define MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 1024
-/*@}*/
-
-
-/**
- * \name Mesa-specific parameters
- */
-/*@{*/
-
-
-/**
- * If non-zero use GLdouble for walking triangle edges, for better accuracy.
- */
-#define TRIANGLE_WALK_DOUBLE 0
-
-
-/**
- * Bits per depth buffer value (max is 32).
- */
-#ifndef DEFAULT_SOFTWARE_DEPTH_BITS
-#define DEFAULT_SOFTWARE_DEPTH_BITS 16
-#endif
-/** Depth buffer data type */
-#if DEFAULT_SOFTWARE_DEPTH_BITS <= 16
-#define DEFAULT_SOFTWARE_DEPTH_TYPE GLushort
-#else
-#define DEFAULT_SOFTWARE_DEPTH_TYPE GLuint
-#endif
-
-
-/**
- * Bits per stencil value: 8
- */
-#define STENCIL_BITS 8
-
-
-/**
- * Bits per color channel: 8, 16 or 32
- */
-#ifndef CHAN_BITS
-#define CHAN_BITS 8
-#endif
-
-
-/*
- * Color channel component order
- *
- * \note Changes will almost certainly cause problems at this time.
- */
-#define RCOMP 0
-#define GCOMP 1
-#define BCOMP 2
-#define ACOMP 3
-
-
-/**
- * Maximum number of temporary vertices required for clipping.
- *
- * Used in array_cache and tnl modules.
- */
-#define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1)
-
-
-#endif /* MESA_CONFIG_H_INCLUDED */
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.5
+ *
+ * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
+ * Copyright (C) 2008 VMware, Inc. 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 config.h
+ * Tunable configuration parameters.
+ */
+
+#ifndef MESA_CONFIG_H_INCLUDED
+#define MESA_CONFIG_H_INCLUDED
+
+
+/**
+ * \name OpenGL implementation limits
+ */
+/*@{*/
+
+/** Maximum modelview matrix stack depth */
+#define MAX_MODELVIEW_STACK_DEPTH 32
+
+/** Maximum projection matrix stack depth */
+#define MAX_PROJECTION_STACK_DEPTH 32
+
+/** Maximum texture matrix stack depth */
+#define MAX_TEXTURE_STACK_DEPTH 10
+
+/** Maximum color matrix stack depth */
+#define MAX_COLOR_STACK_DEPTH 4
+
+/** Maximum attribute stack depth */
+#define MAX_ATTRIB_STACK_DEPTH 16
+
+/** Maximum client attribute stack depth */
+#define MAX_CLIENT_ATTRIB_STACK_DEPTH 16
+
+/** Maximum recursion depth of display list calls */
+#define MAX_LIST_NESTING 64
+
+/** Maximum number of lights */
+#define MAX_LIGHTS 8
+
+/** Maximum user-defined clipping planes */
+#define MAX_CLIP_PLANES 6
+
+/** Maximum pixel map lookup table size */
+#define MAX_PIXEL_MAP_TABLE 256
+
+/** Maximum number of auxillary color buffers */
+#define MAX_AUX_BUFFERS 1
+
+/** Maximum order (degree) of curves */
+#ifdef AMIGA
+# define MAX_EVAL_ORDER 12
+#else
+# define MAX_EVAL_ORDER 30
+#endif
+
+/** Maximum Name stack depth */
+#define MAX_NAME_STACK_DEPTH 64
+
+/** Minimum point size */
+#define MIN_POINT_SIZE 1.0
+/** Maximum point size */
+#define MAX_POINT_SIZE 60.0
+/** Point size granularity */
+#define POINT_SIZE_GRANULARITY 0.1
+
+/** Minimum line width */
+#define MIN_LINE_WIDTH 1.0
+/** Maximum line width */
+#define MAX_LINE_WIDTH 10.0
+/** Line width granularity */
+#define LINE_WIDTH_GRANULARITY 0.1
+
+/** Max texture palette / color table size */
+#define MAX_COLOR_TABLE_SIZE 256
+
+/** Max memory to allow for a single texture image (in megabytes) */
+#define MAX_TEXTURE_MBYTES 1024
+
+/** Number of 1D/2D texture mipmap levels */
+#define MAX_TEXTURE_LEVELS 15
+
+/** Number of 3D texture mipmap levels */
+#define MAX_3D_TEXTURE_LEVELS 15
+
+/** Number of cube texture mipmap levels - GL_ARB_texture_cube_map */
+#define MAX_CUBE_TEXTURE_LEVELS 15
+
+/** Maximum rectangular texture size - GL_NV_texture_rectangle */
+#define MAX_TEXTURE_RECT_SIZE 16384
+
+/** Maximum number of layers in a 1D or 2D array texture - GL_MESA_texture_array */
+#define MAX_ARRAY_TEXTURE_LAYERS 64
+
+/**
+ * Max number of texture coordinate units. This mainly just applies to
+ * the fixed-function vertex code. This will be difficult to raise above
+ * eight because of various vertex attribute bitvectors.
+ */
+#define MAX_TEXTURE_COORD_UNITS 8
+
+/**
+ * Max number of texture image units. Also determines number of texture
+ * samplers in shaders.
+ */
+#define MAX_TEXTURE_IMAGE_UNITS 16
+
+/**
+ * Larger of MAX_TEXTURE_COORD_UNITS and MAX_TEXTURE_IMAGE_UNITS.
+ * This value is only used for dimensioning arrays.
+ * Either MAX_TEXTURE_COORD_UNITS or MAX_TEXTURE_IMAGE_UNITS (or the
+ * corresponding ctx->Const.MaxTextureCoord/ImageUnits fields) should be
+ * used almost everywhere else.
+ */
+#define MAX_TEXTURE_UNITS ((MAX_TEXTURE_COORD_UNITS > MAX_TEXTURE_IMAGE_UNITS) ? MAX_TEXTURE_COORD_UNITS : MAX_TEXTURE_IMAGE_UNITS)
+
+
+/**
+ * Maximum viewport/image width. Must accomodate all texture sizes too.
+ */
+
+#ifndef MAX_WIDTH
+# define MAX_WIDTH 16384
+#endif
+/** Maximum viewport/image height */
+#ifndef MAX_HEIGHT
+# define MAX_HEIGHT 16384
+#endif
+
+/* XXX: hack to prevent stack overflow on windows until all temporary arrays
+ * [MAX_WIDTH] are allocated from the heap */
+#ifdef WIN32
+#undef MAX_TEXTURE_LEVELS
+#undef MAX_3D_TEXTURE_LEVELS
+#undef MAX_CUBE_TEXTURE_LEVELS
+#undef MAX_TEXTURE_RECT_SIZE
+#undef MAX_WIDTH
+#undef MAX_HEIGHT
+#define MAX_TEXTURE_LEVELS 13
+#define MAX_3D_TEXTURE_LEVELS 9
+#define MAX_CUBE_TEXTURE_LEVELS 13
+#define MAX_TEXTURE_RECT_SIZE 4096
+#define MAX_WIDTH 4096
+#define MAX_HEIGHT 4096
+#endif
+
+/** Maxmimum size for CVA. May be overridden by the drivers. */
+#define MAX_ARRAY_LOCK_SIZE 3000
+
+/** Subpixel precision for antialiasing, window coordinate snapping */
+#define SUB_PIXEL_BITS 4
+
+/** Size of histogram tables */
+#define HISTOGRAM_TABLE_SIZE 256
+
+/** Max convolution filter width */
+#define MAX_CONVOLUTION_WIDTH 9
+/** Max convolution filter height */
+#define MAX_CONVOLUTION_HEIGHT 9
+
+/** For GL_ARB_texture_compression */
+#define MAX_COMPRESSED_TEXTURE_FORMATS 25
+
+/** For GL_EXT_texture_filter_anisotropic */
+#define MAX_TEXTURE_MAX_ANISOTROPY 16.0
+
+/** For GL_EXT_texture_lod_bias (typically MAX_TEXTURE_LEVELS - 1) */
+#define MAX_TEXTURE_LOD_BIAS 14.0
+
+/** For any program target/extension */
+/*@{*/
+#define MAX_PROGRAM_INSTRUCTIONS (16 * 1024)
+
+/**
+ * Per-program constants (power of two)
+ *
+ * \c MAX_PROGRAM_LOCAL_PARAMS and \c MAX_UNIFORMS are just the assembly shader
+ * and GLSL shader names for the same thing. They should \b always have the
+ * same value. Each refers to the number of vec4 values supplied as
+ * per-program parameters.
+ */
+/*@{*/
+#define MAX_PROGRAM_LOCAL_PARAMS 4096
+#define MAX_UNIFORMS 4096
+/*@}*/
+
+/**
+ * Per-context constants (power of two)
+ *
+ * \note
+ * This value should always be less than or equal to \c MAX_PROGRAM_LOCAL_PARAMS
+ * and \c MAX_VERTEX_PROGRAM_PARAMS. Otherwise some applications will make
+ * incorrect assumptions.
+ */
+#define MAX_PROGRAM_ENV_PARAMS 256
+
+#define MAX_PROGRAM_MATRICES 8
+#define MAX_PROGRAM_MATRIX_STACK_DEPTH 4
+#define MAX_PROGRAM_CALL_DEPTH 8
+#define MAX_PROGRAM_TEMPS 256
+#define MAX_PROGRAM_ADDRESS_REGS 2
+#define MAX_VARYING 16 /**< number of float[4] vectors */
+#define MAX_SAMPLERS MAX_TEXTURE_IMAGE_UNITS
+#define MAX_PROGRAM_INPUTS 32
+#define MAX_PROGRAM_OUTPUTS 64
+/*@}*/
+
+/** For GL_ARB_vertex_program */
+/*@{*/
+#define MAX_VERTEX_PROGRAM_ADDRESS_REGS 1
+#define MAX_VERTEX_PROGRAM_PARAMS MAX_UNIFORMS
+/*@}*/
+
+/** For GL_ARB_fragment_program */
+/*@{*/
+#define MAX_FRAGMENT_PROGRAM_ADDRESS_REGS 0
+/*@}*/
+
+/** For GL_NV_vertex_program */
+/*@{*/
+#define MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS 128
+#define MAX_NV_VERTEX_PROGRAM_TEMPS 12
+#define MAX_NV_VERTEX_PROGRAM_PARAMS 96
+#define MAX_NV_VERTEX_PROGRAM_INPUTS 16
+#define MAX_NV_VERTEX_PROGRAM_OUTPUTS 15
+/*@}*/
+
+/** For GL_NV_fragment_program */
+/*@{*/
+#define MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS 1024 /* 72 for GL_ARB_f_p */
+#define MAX_NV_FRAGMENT_PROGRAM_TEMPS 96
+#define MAX_NV_FRAGMENT_PROGRAM_PARAMS 64
+#define MAX_NV_FRAGMENT_PROGRAM_INPUTS 12
+#define MAX_NV_FRAGMENT_PROGRAM_OUTPUTS 3
+#define MAX_NV_FRAGMENT_PROGRAM_WRITE_ONLYS 2
+/*@}*/
+
+
+/** For GL_ARB_vertex_shader */
+/*@{*/
+#define MAX_VERTEX_GENERIC_ATTRIBS 16
+#define MAX_VERTEX_TEXTURE_IMAGE_UNITS MAX_TEXTURE_IMAGE_UNITS
+#define MAX_COMBINED_TEXTURE_IMAGE_UNITS (MAX_VERTEX_TEXTURE_IMAGE_UNITS + \
+ MAX_TEXTURE_IMAGE_UNITS)
+/*@}*/
+
+
+/** For GL_ARB_draw_buffers */
+/*@{*/
+#define MAX_DRAW_BUFFERS 8
+/*@}*/
+
+
+/** For GL_EXT_framebuffer_object */
+/*@{*/
+#define MAX_COLOR_ATTACHMENTS 8
+/*@}*/
+
+/** For GL_ATI_envmap_bump - support bump mapping on first 8 units */
+#define SUPPORTED_ATI_BUMP_UNITS 0xff
+
+/** For GL_EXT_transform_feedback */
+#define MAX_FEEDBACK_ATTRIBS 32
+
+/** For GL_ARB_geometry_shader4 */
+/*@{*/
+#define MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 8
+#define MAX_GEOMETRY_VARYING_COMPONENTS 32
+#define MAX_VERTEX_VARYING_COMPONENTS 32
+#define MAX_GEOMETRY_UNIFORM_COMPONENTS 512
+#define MAX_GEOMETRY_OUTPUT_VERTICES 256
+#define MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 1024
+/*@}*/
+
+
+/**
+ * \name Mesa-specific parameters
+ */
+/*@{*/
+
+
+/**
+ * If non-zero use GLdouble for walking triangle edges, for better accuracy.
+ */
+#define TRIANGLE_WALK_DOUBLE 0
+
+
+/**
+ * Bits per depth buffer value (max is 32).
+ */
+#ifndef DEFAULT_SOFTWARE_DEPTH_BITS
+#define DEFAULT_SOFTWARE_DEPTH_BITS 16
+#endif
+/** Depth buffer data type */
+#if DEFAULT_SOFTWARE_DEPTH_BITS <= 16
+#define DEFAULT_SOFTWARE_DEPTH_TYPE GLushort
+#else
+#define DEFAULT_SOFTWARE_DEPTH_TYPE GLuint
+#endif
+
+
+/**
+ * Bits per stencil value: 8
+ */
+#define STENCIL_BITS 8
+
+
+/**
+ * Bits per color channel: 8, 16 or 32
+ */
+#ifndef CHAN_BITS
+#define CHAN_BITS 8
+#endif
+
+
+/*
+ * Color channel component order
+ *
+ * \note Changes will almost certainly cause problems at this time.
+ */
+#define RCOMP 0
+#define GCOMP 1
+#define BCOMP 2
+#define ACOMP 3
+
+
+/**
+ * Maximum number of temporary vertices required for clipping.
+ *
+ * Used in array_cache and tnl modules.
+ */
+#define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1)
+
+
+#endif /* MESA_CONFIG_H_INCLUDED */
diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c
index 65c08f024..c0fcf9cd4 100644
--- a/mesalib/src/mesa/main/formats.c
+++ b/mesalib/src/mesa/main/formats.c
@@ -47,7 +47,7 @@ struct gl_format_info
GLenum BaseFormat;
/**
- * Logical data type: one of GL_UNSIGNED_NORMALIZED, GL_SIGNED_NORMALED,
+ * Logical data type: one of GL_UNSIGNED_NORMALIZED, GL_SIGNED_NORMALIZED,
* GL_UNSIGNED_INT, GL_INT, GL_FLOAT.
*/
GLenum DataType;
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index f2eb889fe..44ebf0a53 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -2266,11 +2266,6 @@ struct gl_shader_compiler_options
/** Driver-selectable options: */
GLboolean EmitCondCodes; /**< Use condition codes? */
GLboolean EmitNVTempInitialization; /**< 0-fill NV temp registers */
- /**
- * Attempts to flatten all ir_if (OPCODE_IF) for GPUs that can't
- * support control flow.
- */
- GLboolean EmitNoIfs;
GLboolean EmitNoLoops;
GLboolean EmitNoFunctions;
GLboolean EmitNoCont; /**< Emit CONT opcode? */
@@ -2288,6 +2283,7 @@ struct gl_shader_compiler_options
GLboolean EmitNoIndirectUniform; /**< No indirect addressing of constants */
/*@}*/
+ GLuint MaxIfDepth; /**< Maximum nested IF blocks */
GLuint MaxUnrollIterations;
struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */
diff --git a/mesalib/src/mesa/main/texfetch_tmp.h b/mesalib/src/mesa/main/texfetch_tmp.h
index 548d50c8e..dbed3dba9 100644
--- a/mesalib/src/mesa/main/texfetch_tmp.h
+++ b/mesalib/src/mesa/main/texfetch_tmp.h
@@ -792,9 +792,12 @@ static void FETCH(f_rgb565_rev)( const struct gl_texture_image *texImage,
static void store_texel_rgb565_rev(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
- const GLubyte *rgba = (const GLubyte *) texel;
+ const GLchan *rgba = (const GLchan *) texel;
GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_565(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP]);
+ GLushort p = PACK_COLOR_565(CHAN_TO_UBYTE(rgba[RCOMP]),
+ CHAN_TO_UBYTE(rgba[GCOMP]),
+ CHAN_TO_UBYTE(rgba[BCOMP]));
+ *dst = (p >> 8) | (p << 8); /* byte swap */
}
#endif
@@ -817,9 +820,12 @@ static void FETCH(f_argb4444)( const struct gl_texture_image *texImage,
static void store_texel_argb4444(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
- const GLubyte *rgba = (const GLubyte *) texel;
+ const GLchan *rgba = (const GLchan *) texel;
GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_4444(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+ *dst = PACK_COLOR_4444(CHAN_TO_UBYTE(rgba[ACOMP]),
+ CHAN_TO_UBYTE(rgba[RCOMP]),
+ CHAN_TO_UBYTE(rgba[GCOMP]),
+ CHAN_TO_UBYTE(rgba[BCOMP]));
}
#endif
@@ -841,9 +847,12 @@ static void FETCH(f_argb4444_rev)( const struct gl_texture_image *texImage,
static void store_texel_argb4444_rev(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
- const GLubyte *rgba = (const GLubyte *) texel;
+ const GLchan *rgba = (const GLchan *) texel;
GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_4444(rgba[ACOMP], rgba[BCOMP], rgba[GCOMP], rgba[RCOMP]);
+ *dst = PACK_COLOR_4444(CHAN_TO_UBYTE(rgba[GCOMP]),
+ CHAN_TO_UBYTE(rgba[BCOMP]),
+ CHAN_TO_UBYTE(rgba[ACOMP]),
+ CHAN_TO_UBYTE(rgba[RCOMP]));
}
#endif
@@ -939,9 +948,13 @@ static void FETCH(f_argb2101010)( const struct gl_texture_image *texImage,
static void store_texel_argb2101010(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
- const GLubyte *rgba = (const GLubyte *) texel;
+ const GLchan *rgba = (const GLchan *) texel;
GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_2101010_UB(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+ GLushort r = CHAN_TO_USHORT(rgba[RCOMP]);
+ GLushort g = CHAN_TO_USHORT(rgba[GCOMP]);
+ GLushort b = CHAN_TO_USHORT(rgba[BCOMP]);
+ GLushort a = CHAN_TO_USHORT(rgba[ACOMP]);
+ *dst = PACK_COLOR_2101010_US(a, r, g, b);
}
#endif
@@ -963,9 +976,11 @@ static void FETCH(f_rg88)( const struct gl_texture_image *texImage,
static void store_texel_rg88(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
- const GLubyte *rgba = (const GLubyte *) texel;
+ const GLchan *rgba = (const GLubyte *) texel;
GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_88(rgba[RCOMP], rgba[GCOMP]);
+ GLubyte r = CHAN_TO_UBYTE(rgba[RCOMP]);
+ GLubyte g = CHAN_TO_UBYTE(rgba[GCOMP]);
+ *dst = PACK_COLOR_88(g, r);
}
#endif
@@ -1083,9 +1098,9 @@ static void FETCH(f_r16)(const struct gl_texture_image *texImage,
static void store_texel_r16(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
- const GLushort *rgba = (const GLushort *) texel;
+ const GLchan *rgba = (const GLchan *) texel;
GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = rgba[RCOMP];
+ *dst = CHAN_TO_USHORT(rgba[RCOMP]);
}
#endif
@@ -1131,9 +1146,11 @@ static void FETCH(f_rg1616)( const struct gl_texture_image *texImage,
static void store_texel_rg1616(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
- const GLubyte *rgba = (const GLubyte *) texel;
- GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = PACK_COLOR_1616(rgba[RCOMP], rgba[GCOMP]);
+ const GLchan *rgba = (const GLchan *) texel;
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ GLushort r = CHAN_TO_USHORT(rgba[RCOMP]);
+ GLushort g = CHAN_TO_USHORT(rgba[GCOMP]);
+ *dst = PACK_COLOR_1616(g, r);
}
#endif
@@ -1179,9 +1196,11 @@ static void FETCH(f_al1616)( const struct gl_texture_image *texImage,
static void store_texel_al1616(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
- const GLushort *rgba = (const GLushort *) texel;
+ const GLchan *rgba = (const GLchan *) texel;
GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
- *dst = PACK_COLOR_1616(rgba[ACOMP], rgba[RCOMP]);
+ GLushort l = CHAN_TO_USHORT(rgba[RCOMP]);
+ GLushort a = CHAN_TO_USHORT(rgba[ACOMP]);
+ *dst = PACK_COLOR_1616(a, l);
}
#endif
@@ -1276,9 +1295,9 @@ static void FETCH(f_a16)( const struct gl_texture_image *texImage,
static void store_texel_a16(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
- const GLushort *rgba = (const GLushort *) texel;
+ const GLchan *rgba = (const GLchan *) texel;
GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
- *dst = rgba[ACOMP];
+ *dst = CHAN_TO_USHORT(rgba[ACOMP]);
}
#endif
@@ -1995,10 +2014,10 @@ static void
store_texel_signed_rg1616(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
- const GLshort *rgba = (const GLshort *) texel;
+ const GLchan *rgba = (const GLchan *) texel;
GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 2);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[GCOMP];
+ dst[0] = CHAN_TO_SHORT(rgba[RCOMP]);
+ dst[1] = CHAN_TO_SHORT(rgba[GCOMP]);
}
#endif
@@ -2021,10 +2040,10 @@ static void
store_texel_signed_al1616(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
- const GLshort *rgba = (const GLshort *) texel;
+ const GLchan *rgba = (const GLchan *) texel;
GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 2);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[ACOMP];
+ dst[0] = CHAN_TO_SHORT(rgba[RCOMP]);
+ dst[1] = CHAN_TO_SHORT(rgba[ACOMP]);
}
#endif
@@ -2047,11 +2066,11 @@ static void
store_texel_signed_rgb_16(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
- const GLshort *rgba = (const GLshort *) texel;
+ const GLchan *rgba = (const GLchan *) texel;
GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 3);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[GCOMP];
- dst[2] = rgba[BCOMP];
+ dst[0] = CHAN_TO_SHORT(rgba[RCOMP]);
+ dst[1] = CHAN_TO_SHORT(rgba[GCOMP]);
+ dst[2] = CHAN_TO_SHORT(rgba[BCOMP]);
}
#endif
@@ -2074,12 +2093,12 @@ static void
store_texel_signed_rgba_16(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
- const GLshort *rgba = (const GLshort *) texel;
+ const GLchan *rgba = (const GLchan *) texel;
GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 4);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[GCOMP];
- dst[2] = rgba[BCOMP];
- dst[3] = rgba[ACOMP];
+ dst[0] = CHAN_TO_SHORT(rgba[RCOMP]);
+ dst[1] = CHAN_TO_SHORT(rgba[GCOMP]);
+ dst[2] = CHAN_TO_SHORT(rgba[BCOMP]);
+ dst[3] = CHAN_TO_SHORT(rgba[ACOMP]);
}
#endif
@@ -2103,12 +2122,12 @@ static void
store_texel_rgba_16(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
- const GLushort *rgba = (const GLushort *) texel;
+ const GLchan *rgba = (const GLchan *) texel;
GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 4);
- dst[0] = rgba[RCOMP];
- dst[1] = rgba[GCOMP];
- dst[2] = rgba[BCOMP];
- dst[3] = rgba[ACOMP];
+ dst[0] = CHAN_TO_USHORT(rgba[RCOMP]);
+ dst[1] = CHAN_TO_USHORT(rgba[GCOMP]);
+ dst[2] = CHAN_TO_USHORT(rgba[BCOMP]);
+ dst[3] = CHAN_TO_USHORT(rgba[ACOMP]);
}
#endif
diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp
index 6820e4c6b..9813c4ae8 100644
--- a/mesalib/src/mesa/program/ir_to_mesa.cpp
+++ b/mesalib/src/mesa/program/ir_to_mesa.cpp
@@ -3119,7 +3119,7 @@ get_mesa_program(struct gl_context *ctx,
switch (mesa_inst->Opcode) {
case OPCODE_IF:
- if (options->EmitNoIfs) {
+ if (options->MaxIfDepth == 0) {
linker_warning(shader_program,
"Couldn't flatten if-statement. "
"This will likely result in software "
@@ -3232,7 +3232,7 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
/* Lowering */
do_mat_op_to_vec(ir);
lower_instructions(ir, (MOD_TO_FRACT | DIV_TO_MUL_RCP | EXP_TO_EXP2
- | LOG_TO_LOG2
+ | LOG_TO_LOG2 | INT_DIV_TO_MUL_RCP
| ((options->EmitNoPow) ? POW_TO_EXP2 : 0)));
progress = do_lower_jumps(ir, true, true, options->EmitNoMainReturn, options->EmitNoCont, options->EmitNoLoops) || progress;
@@ -3241,10 +3241,10 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
progress = lower_quadop_vector(ir, true) || progress;
- if (options->EmitNoIfs) {
+ if (options->MaxIfDepth == 0)
progress = lower_discard(ir) || progress;
- progress = lower_if_to_cond_assign(ir) || progress;
- }
+
+ progress = lower_if_to_cond_assign(ir, options->MaxIfDepth) || progress;
if (options->EmitNoNoise)
progress = lower_noise(ir) || progress;
diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c
index 8e9009340..322dbbfd5 100644
--- a/mesalib/src/mesa/state_tracker/st_extensions.c
+++ b/mesalib/src/mesa/state_tracker/st_extensions.c
@@ -173,7 +173,7 @@ void st_init_limits(struct st_context *st)
options->EmitNoNoise = TRUE;
/* TODO: make these more fine-grained if anyone needs it */
- options->EmitNoIfs = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH);
+ options->MaxIfDepth = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH);
options->EmitNoLoops = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH);
options->EmitNoFunctions = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_SUBROUTINES);
options->EmitNoMainReturn = !screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_SUBROUTINES);
diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 3fbb0cdd2..e2857edf3 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -4982,7 +4982,7 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
/* Lowering */
do_mat_op_to_vec(ir);
lower_instructions(ir, (MOD_TO_FRACT | DIV_TO_MUL_RCP | EXP_TO_EXP2
- | LOG_TO_LOG2
+ | LOG_TO_LOG2 | INT_DIV_TO_MUL_RCP
| ((options->EmitNoPow) ? POW_TO_EXP2 : 0)));
progress = do_lower_jumps(ir, true, true, options->EmitNoMainReturn, options->EmitNoCont, options->EmitNoLoops) || progress;
@@ -4991,10 +4991,10 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
progress = lower_quadop_vector(ir, false) || progress;
- if (options->EmitNoIfs) {
+ if (options->MaxIfDepth == 0)
progress = lower_discard(ir) || progress;
- progress = lower_if_to_cond_assign(ir) || progress;
- }
+
+ progress = lower_if_to_cond_assign(ir, options->MaxIfDepth) || progress;
if (options->EmitNoNoise)
progress = lower_noise(ir) || progress;
diff --git a/mesalib/src/mesa/swrast/s_context.c b/mesalib/src/mesa/swrast/s_context.c
index 792b528ee..df213357f 100644
--- a/mesalib/src/mesa/swrast/s_context.c
+++ b/mesalib/src/mesa/swrast/s_context.c
@@ -688,6 +688,24 @@ _swrast_allow_pixel_fog( struct gl_context *ctx, GLboolean value )
}
+/**
+ * Initialize native program limits by copying the logical limits.
+ * See comments in init_program_limits() in context.c
+ */
+static void
+init_program_native_limits(struct gl_program_constants *prog)
+{
+ prog->MaxNativeInstructions = prog->MaxInstructions;
+ prog->MaxNativeAluInstructions = prog->MaxAluInstructions;
+ prog->MaxNativeTexInstructions = prog->MaxTexInstructions;
+ prog->MaxNativeTexIndirections = prog->MaxTexIndirections;
+ prog->MaxNativeAttribs = prog->MaxAttribs;
+ prog->MaxNativeTemps = prog->MaxTemps;
+ prog->MaxNativeAddressRegs = prog->MaxAddressRegs;
+ prog->MaxNativeParameters = prog->MaxParameters;
+}
+
+
GLboolean
_swrast_CreateContext( struct gl_context *ctx )
{
@@ -769,6 +787,10 @@ _swrast_CreateContext( struct gl_context *ctx )
return GL_FALSE;
}
+ init_program_native_limits(&ctx->Const.VertexProgram);
+ init_program_native_limits(&ctx->Const.GeometryProgram);
+ init_program_native_limits(&ctx->Const.FragmentProgram);
+
ctx->swrast_context = swrast;
return GL_TRUE;
diff --git a/mesalib/src/mesa/swrast/s_readpix.c b/mesalib/src/mesa/swrast/s_readpix.c
index 66ca39293..6eec2fc78 100644
--- a/mesalib/src/mesa/swrast/s_readpix.c
+++ b/mesalib/src/mesa/swrast/s_readpix.c
@@ -332,7 +332,7 @@ read_rgba_pixels( struct gl_context *ctx,
/* width should never be > MAX_WIDTH since we did clipping earlier */
ASSERT(width <= MAX_WIDTH);
- do {
+ {
const GLint dstStride
= _mesa_image_row_stride(packing, width, format, type);
GLfloat (*rgba)[4] = swrast->SpanArrays->attribs[FRAG_ATTRIB_COL0];
@@ -359,7 +359,7 @@ read_rgba_pixels( struct gl_context *ctx,
dst += dstStride;
}
- } while (0);
+ }
}