aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src')
-rw-r--r--mesalib/src/SConscript5
-rw-r--r--mesalib/src/glsl/link_uniforms.cpp2
-rw-r--r--mesalib/src/glsl/linker.cpp2
-rw-r--r--mesalib/src/glsl/s_expression.cpp36
-rw-r--r--mesalib/src/glu/sgi/SConscript16
-rw-r--r--mesalib/src/mesa/main/arrayobj.c41
-rw-r--r--mesalib/src/mesa/main/arrayobj.h207
-rw-r--r--mesalib/src/mesa/main/bufferobj.c44
-rw-r--r--mesalib/src/mesa/main/bufferobj.h3
-rw-r--r--mesalib/src/mesa/main/dd.h8
-rw-r--r--mesalib/src/mesa/main/mtypes.h14
-rw-r--r--mesalib/src/mesa/main/shaderobj.c2
-rw-r--r--mesalib/src/mesa/main/state.c126
-rw-r--r--mesalib/src/mesa/main/texformat.c14
-rw-r--r--mesalib/src/mesa/main/texgetimage.c6
-rw-r--r--mesalib/src/mesa/main/teximage.h9
-rw-r--r--mesalib/src/mesa/main/texstore.c4
-rw-r--r--mesalib/src/mesa/main/varray.c2
-rw-r--r--mesalib/src/mesa/program/register_allocate.c10
-rw-r--r--mesalib/src/mesa/program/register_allocate.h2
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_fbo.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_texture.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_format.c34
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp6
25 files changed, 311 insertions, 288 deletions
diff --git a/mesalib/src/SConscript b/mesalib/src/SConscript
index 0a30838de..ba6be0be1 100644
--- a/mesalib/src/SConscript
+++ b/mesalib/src/SConscript
@@ -22,10 +22,11 @@ SConscript('mesa/SConscript')
SConscript('mapi/vgapi/SConscript')
if not env['embedded']:
- if env['platform'] not in ['windows', 'darwin']:
+ if env['platform'] not in ['windows', 'darwin', 'haiku']:
SConscript('glx/SConscript')
- if env['platform'] not in ['darwin']:
+ if env['platform'] not in ['darwin', 'haiku']:
SConscript('egl/main/SConscript')
+ if env['platform'] not in ['darwin']:
SConscript('glu/sgi/SConscript')
if env['gles']:
diff --git a/mesalib/src/glsl/link_uniforms.cpp b/mesalib/src/glsl/link_uniforms.cpp
index 02f57d911..d51850c21 100644
--- a/mesalib/src/glsl/link_uniforms.cpp
+++ b/mesalib/src/glsl/link_uniforms.cpp
@@ -287,7 +287,7 @@ private:
this->uniforms[id].sampler = ~0;
}
- this->uniforms[id].name = strdup(name);
+ this->uniforms[id].name = ralloc_strdup(this->uniforms, name);
this->uniforms[id].type = base_type;
this->uniforms[id].initialized = 0;
this->uniforms[id].num_driver_storage = 0;
diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp
index 0d85aeee6..adedfe6f3 100644
--- a/mesalib/src/glsl/linker.cpp
+++ b/mesalib/src/glsl/linker.cpp
@@ -1984,7 +1984,7 @@ store_tfeedback_info(struct gl_context *ctx, struct gl_shader_program *prog,
separate_attribs_mode ? num_tfeedback_decls : 1;
prog->LinkedTransformFeedback.Varyings =
- rzalloc_array(prog->LinkedTransformFeedback.Varyings,
+ rzalloc_array(prog,
struct gl_transform_feedback_varying_info,
num_tfeedback_decls);
diff --git a/mesalib/src/glsl/s_expression.cpp b/mesalib/src/glsl/s_expression.cpp
index e704a3be2..57de9d334 100644
--- a/mesalib/src/glsl/s_expression.cpp
+++ b/mesalib/src/glsl/s_expression.cpp
@@ -23,6 +23,7 @@
*/
#include <assert.h>
+#include <limits>
#include "s_expression.h"
s_symbol::s_symbol(const char *str, size_t n)
@@ -64,21 +65,28 @@ read_atom(void *ctx, const char *&src, char *&symbol_buffer)
if (n == 0)
return NULL; // no atom
- // Check if the atom is a number.
- char *float_end = NULL;
- double f = glsl_strtod(src, &float_end);
- if (float_end != src) {
- char *int_end = NULL;
- int i = strtol(src, &int_end, 10);
- // If strtod matched more characters, it must have a decimal part
- if (float_end > int_end)
- expr = new(ctx) s_float(f);
- else
- expr = new(ctx) s_int(i);
+ // Check for the special symbol '+INF', which means +Infinity. Note: C99
+ // requires strtod to parse '+INF' as +Infinity, but we still support some
+ // non-C99-compliant compilers (e.g. MSVC).
+ if (n == 4 && strncmp(src, "+INF", 4) == 0) {
+ expr = new(ctx) s_float(std::numeric_limits<float>::infinity());
} else {
- // Not a number; return a symbol.
- symbol_buffer[n] = '\0';
- expr = new(ctx) s_symbol(symbol_buffer, n);
+ // Check if the atom is a number.
+ char *float_end = NULL;
+ double f = glsl_strtod(src, &float_end);
+ if (float_end != src) {
+ char *int_end = NULL;
+ int i = strtol(src, &int_end, 10);
+ // If strtod matched more characters, it must have a decimal part
+ if (float_end > int_end)
+ expr = new(ctx) s_float(f);
+ else
+ expr = new(ctx) s_int(i);
+ } else {
+ // Not a number; return a symbol.
+ symbol_buffer[n] = '\0';
+ expr = new(ctx) s_symbol(symbol_buffer, n);
+ }
}
src += n;
diff --git a/mesalib/src/glu/sgi/SConscript b/mesalib/src/glu/sgi/SConscript
index 94c74267f..97405d869 100644
--- a/mesalib/src/glu/sgi/SConscript
+++ b/mesalib/src/glu/sgi/SConscript
@@ -122,12 +122,18 @@ else:
])
target = 'glu'
-glu = env.SharedLibrary(
- target = target,
- source = sources
-)
+if env['platform'] == 'haiku':
+ glu = env.StaticLibrary(
+ target = target,
+ source = sources
+ )
+else:
+ glu = env.SharedLibrary(
+ target = target,
+ source = sources
+ )
+ env.Alias('glu', env.InstallSharedLibrary(glu, version=(1, 3, 0)))
-env.Alias('glu', env.InstallSharedLibrary(glu, version=(1, 3, 0)))
if env['platform'] == 'windows':
glu = env.FindIxes(glu, 'LIBPREFIX', 'LIBSUFFIX')
diff --git a/mesalib/src/mesa/main/arrayobj.c b/mesalib/src/mesa/main/arrayobj.c
index 29bfed8f5..328774543 100644
--- a/mesalib/src/mesa/main/arrayobj.c
+++ b/mesalib/src/mesa/main/arrayobj.c
@@ -280,15 +280,26 @@ remove_array_object( struct gl_context *ctx, struct gl_array_object *obj )
/**
- * Helper for update_arrays().
- * \return min(current min, array->_MaxElement).
+ * Helper for _mesa_update_array_object_max_element().
+ * \return min(arrayObj->VertexAttrib[*]._MaxElement).
*/
static GLuint
-update_min(GLuint min, struct gl_client_array *array)
+compute_max_element(struct gl_array_object *arrayObj, GLbitfield64 enabled)
{
- assert(array->Enabled);
- _mesa_update_array_max_element(array);
- return MIN2(min, array->_MaxElement);
+ GLuint min = ~((GLuint)0);
+
+ while (enabled) {
+ struct gl_client_array *client_array;
+ GLint attrib = ffsll(enabled) - 1;
+ enabled ^= BITFIELD64_BIT(attrib);
+
+ client_array = &arrayObj->VertexAttrib[attrib];
+ assert(client_array->Enabled);
+ _mesa_update_array_max_element(client_array);
+ min = MIN2(min, client_array->_MaxElement);
+ }
+
+ return min;
}
@@ -299,17 +310,19 @@ void
_mesa_update_array_object_max_element(struct gl_context *ctx,
struct gl_array_object *arrayObj)
{
- GLbitfield64 enabled = arrayObj->_Enabled;
- GLuint min = ~0u;
-
- while (enabled) {
- GLint attrib = ffsll(enabled) - 1;
- enabled &= ~BITFIELD64_BIT(attrib);
- min = update_min(min, &arrayObj->VertexAttrib[attrib]);
+ GLbitfield64 enabled;
+
+ if (!ctx->VertexProgram._Current ||
+ ctx->VertexProgram._Current == ctx->VertexProgram._TnlProgram) {
+ enabled = _mesa_array_object_get_enabled_ff(arrayObj);
+ } else if (ctx->VertexProgram._Current->IsNVProgram) {
+ enabled = _mesa_array_object_get_enabled_nv(arrayObj);
+ } else {
+ enabled = _mesa_array_object_get_enabled_arb(arrayObj);
}
/* _MaxElement is one past the last legal array element */
- arrayObj->_MaxElement = min;
+ arrayObj->_MaxElement = compute_max_element(arrayObj, enabled);
}
diff --git a/mesalib/src/mesa/main/arrayobj.h b/mesalib/src/mesa/main/arrayobj.h
index 44f771417..717c7916e 100644
--- a/mesalib/src/mesa/main/arrayobj.h
+++ b/mesalib/src/mesa/main/arrayobj.h
@@ -1,85 +1,122 @@
-/*
- * Mesa 3-D graphics library
- * Version: 7.6
- *
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
- * (C) Copyright IBM Corporation 2006
- * Copyright (C) 2009 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 OR IBM 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.
- */
-
-#ifndef ARRAYOBJ_H
-#define ARRAYOBJ_H
-
-#include "glheader.h"
-
-struct gl_context;
-
-/**
- * \file arrayobj.h
- * Functions for the GL_APPLE_vertex_array_object extension.
- *
- * \author Ian Romanick <idr@us.ibm.com>
- * \author Brian Paul
- */
-
-/*
- * Internal functions
- */
-
-extern struct gl_array_object *
-_mesa_new_array_object( struct gl_context *ctx, GLuint name );
-
-extern void
-_mesa_delete_array_object( struct gl_context *ctx, struct gl_array_object *obj );
-
-extern void
-_mesa_reference_array_object(struct gl_context *ctx,
- struct gl_array_object **ptr,
- struct gl_array_object *arrayObj);
-
-extern void
-_mesa_initialize_array_object( struct gl_context *ctx,
- struct gl_array_object *obj, GLuint name );
-
-
-extern void
-_mesa_update_array_object_max_element(struct gl_context *ctx,
- struct gl_array_object *arrayObj);
-
-
-/*
- * API functions
- */
-
-
-void GLAPIENTRY _mesa_BindVertexArray( GLuint id );
-
-void GLAPIENTRY _mesa_BindVertexArrayAPPLE( GLuint id );
-
-void GLAPIENTRY _mesa_DeleteVertexArraysAPPLE(GLsizei n, const GLuint *ids);
-
-void GLAPIENTRY _mesa_GenVertexArrays(GLsizei n, GLuint *arrays);
-
-void GLAPIENTRY _mesa_GenVertexArraysAPPLE(GLsizei n, GLuint *buffer);
-
-GLboolean GLAPIENTRY _mesa_IsVertexArrayAPPLE( GLuint id );
-
-#endif /* ARRAYOBJ_H */
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.6
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ * (C) Copyright IBM Corporation 2006
+ * Copyright (C) 2009 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 OR IBM 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.
+ */
+
+#ifndef ARRAYOBJ_H
+#define ARRAYOBJ_H
+
+#include "glheader.h"
+#include "mtypes.h"
+
+struct gl_context;
+
+/**
+ * \file arrayobj.h
+ * Functions for the GL_APPLE_vertex_array_object extension.
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ * \author Brian Paul
+ */
+
+/*
+ * Internal functions
+ */
+
+extern struct gl_array_object *
+_mesa_new_array_object( struct gl_context *ctx, GLuint name );
+
+extern void
+_mesa_delete_array_object( struct gl_context *ctx, struct gl_array_object *obj );
+
+extern void
+_mesa_reference_array_object(struct gl_context *ctx,
+ struct gl_array_object **ptr,
+ struct gl_array_object *arrayObj);
+
+extern void
+_mesa_initialize_array_object( struct gl_context *ctx,
+ struct gl_array_object *obj, GLuint name );
+
+
+extern void
+_mesa_update_array_object_max_element(struct gl_context *ctx,
+ struct gl_array_object *arrayObj);
+
+/** Returns the bitmask of all enabled arrays in fixed function mode.
+ *
+ * In fixed function mode only the traditional fixed function arrays
+ * are available.
+ */
+static inline GLbitfield64
+_mesa_array_object_get_enabled_ff(const struct gl_array_object *arrayObj)
+{
+ return arrayObj->_Enabled & VERT_BIT_FF_ALL;
+}
+
+/** Returns the bitmask of all enabled arrays in nv shader mode.
+ *
+ * In nv shader mode, the nv generic arrays take precedence over
+ * the legacy arrays.
+ */
+static inline GLbitfield64
+_mesa_array_object_get_enabled_nv(const struct gl_array_object *arrayObj)
+{
+ GLbitfield64 enabled = arrayObj->_Enabled;
+ return enabled & ~(VERT_BIT_FF_NVALIAS & (enabled >> VERT_ATTRIB_GENERIC0));
+}
+
+/** Returns the bitmask of all enabled arrays in arb/glsl shader mode.
+ *
+ * In arb/glsl shader mode all the fixed function and the arb/glsl generic
+ * arrays are available. Only the first generic array takes
+ * precedence over the legacy position array.
+ */
+static inline GLbitfield64
+_mesa_array_object_get_enabled_arb(const struct gl_array_object *arrayObj)
+{
+ GLbitfield64 enabled = arrayObj->_Enabled;
+ return enabled & ~(VERT_BIT_POS & (enabled >> VERT_ATTRIB_GENERIC0));
+}
+
+
+/*
+ * API functions
+ */
+
+
+void GLAPIENTRY _mesa_BindVertexArray( GLuint id );
+
+void GLAPIENTRY _mesa_BindVertexArrayAPPLE( GLuint id );
+
+void GLAPIENTRY _mesa_DeleteVertexArraysAPPLE(GLsizei n, const GLuint *ids);
+
+void GLAPIENTRY _mesa_GenVertexArrays(GLsizei n, GLuint *arrays);
+
+void GLAPIENTRY _mesa_GenVertexArraysAPPLE(GLsizei n, GLuint *buffer);
+
+GLboolean GLAPIENTRY _mesa_IsVertexArrayAPPLE( GLuint id );
+
+#endif /* ARRAYOBJ_H */
diff --git a/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c
index 5f8071f58..5b6db78d8 100644
--- a/mesalib/src/mesa/main/bufferobj.c
+++ b/mesalib/src/mesa/main/bufferobj.c
@@ -49,13 +49,6 @@
/*#define BOUNDS_CHECK*/
-#if FEATURE_OES_mapbuffer
-#define DEFAULT_ACCESS GL_MAP_WRITE_BIT
-#else
-#define DEFAULT_ACCESS (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)
-#endif
-
-
/**
* Used as a placeholder for buffer objects between glGenBuffers() and
* glBindBuffer() so that glIsBuffer() can work correctly.
@@ -122,6 +115,30 @@ get_buffer(struct gl_context *ctx, GLenum target)
}
+static inline GLenum
+default_access_mode(const struct gl_context *ctx)
+{
+ /* Table 2.6 on page 31 (page 44 of the PDF) of the OpenGL 1.5 spec says:
+ *
+ * Name Type Initial Value Legal Values
+ * ... ... ... ...
+ * BUFFER_ACCESS enum READ_WRITE READ_ONLY, WRITE_ONLY
+ * READ_WRITE
+ *
+ * However, table 6.8 in the GL_OES_mapbuffer extension says:
+ *
+ * Get Value Type Get Command Value Description
+ * --------- ---- ----------- ----- -----------
+ * BUFFER_ACCESS_OES Z1 GetBufferParameteriv WRITE_ONLY_OES buffer map flag
+ *
+ * The difference is because GL_OES_mapbuffer only supports mapping buffers
+ * write-only.
+ */
+ return (ctx->API == API_OPENGLES)
+ ? GL_MAP_WRITE_BIT : (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT);
+}
+
+
/**
* Convert a GLbitfield describing the mapped buffer access flags
* into one of GL_READ_WRITE, GL_READ_ONLY, or GL_WRITE_ONLY.
@@ -213,7 +230,7 @@ _mesa_new_buffer_object( struct gl_context *ctx, GLuint name, GLenum target )
(void) ctx;
obj = MALLOC_STRUCT(gl_buffer_object);
- _mesa_initialize_buffer_object(obj, name, target);
+ _mesa_initialize_buffer_object(ctx, obj, name, target);
return obj;
}
@@ -311,7 +328,8 @@ _mesa_reference_buffer_object_(struct gl_context *ctx,
* Initialize a buffer object to default values.
*/
void
-_mesa_initialize_buffer_object( struct gl_buffer_object *obj,
+_mesa_initialize_buffer_object( struct gl_context *ctx,
+ struct gl_buffer_object *obj,
GLuint name, GLenum target )
{
(void) target;
@@ -321,7 +339,7 @@ _mesa_initialize_buffer_object( struct gl_buffer_object *obj,
obj->RefCount = 1;
obj->Name = name;
obj->Usage = GL_STATIC_DRAW_ARB;
- obj->AccessFlags = DEFAULT_ACCESS;
+ obj->AccessFlags = default_access_mode(ctx);
}
@@ -740,7 +758,7 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids)
if (_mesa_bufferobj_mapped(bufObj)) {
/* if mapped, unmap it now */
ctx->Driver.UnmapBuffer(ctx, bufObj);
- bufObj->AccessFlags = DEFAULT_ACCESS;
+ bufObj->AccessFlags = default_access_mode(ctx);
bufObj->Pointer = NULL;
}
@@ -900,7 +918,7 @@ _mesa_BufferDataARB(GLenum target, GLsizeiptrARB size,
if (_mesa_bufferobj_mapped(bufObj)) {
/* Unmap the existing buffer. We'll replace it now. Not an error. */
ctx->Driver.UnmapBuffer(ctx, bufObj);
- bufObj->AccessFlags = DEFAULT_ACCESS;
+ bufObj->AccessFlags = default_access_mode(ctx);
ASSERT(bufObj->Pointer == NULL);
}
@@ -1119,7 +1137,7 @@ _mesa_UnmapBufferARB(GLenum target)
#endif
status = ctx->Driver.UnmapBuffer( ctx, bufObj );
- bufObj->AccessFlags = DEFAULT_ACCESS;
+ bufObj->AccessFlags = default_access_mode(ctx);
ASSERT(bufObj->Pointer == NULL);
ASSERT(bufObj->Offset == 0);
ASSERT(bufObj->Length == 0);
diff --git a/mesalib/src/mesa/main/bufferobj.h b/mesalib/src/mesa/main/bufferobj.h
index c0d5a641a..a7ce37928 100644
--- a/mesalib/src/mesa/main/bufferobj.h
+++ b/mesalib/src/mesa/main/bufferobj.h
@@ -71,7 +71,8 @@ extern struct gl_buffer_object *
_mesa_lookup_bufferobj(struct gl_context *ctx, GLuint buffer);
extern void
-_mesa_initialize_buffer_object( struct gl_buffer_object *obj,
+_mesa_initialize_buffer_object( struct gl_context *ctx,
+ struct gl_buffer_object *obj,
GLuint name, GLenum target );
extern void
diff --git a/mesalib/src/mesa/main/dd.h b/mesalib/src/mesa/main/dd.h
index 24f3d4ca5..8393f328f 100644
--- a/mesalib/src/mesa/main/dd.h
+++ b/mesalib/src/mesa/main/dd.h
@@ -460,7 +460,8 @@ struct dd_function_table {
* \param texImage the texture image
* \param slice the 3D image slice or array texture slice
* \param x, y, w, h region of interest
- * \param mode bitmask of GL_MAP_READ_BIT, GL_MAP_WRITE_BIT
+ * \param mode bitmask of GL_MAP_READ_BIT, GL_MAP_WRITE_BIT and
+ * GL_MAP_INVALIDATE_RANGE_BIT (if writing)
* \param mapOut returns start of mapping of region of interest
* \param rowStrideOut returns row stride (in bytes)
*/
@@ -489,6 +490,11 @@ struct dd_function_table {
GLsizei levels, GLsizei width,
GLsizei height, GLsizei depth);
+ /**
+ * Map a renderbuffer into user space.
+ * \param mode bitmask of GL_MAP_READ_BIT, GL_MAP_WRITE_BIT and
+ * GL_MAP_INVALIDATE_RANGE_BIT (if writing)
+ */
void (*MapRenderbuffer)(struct gl_context *ctx,
struct gl_renderbuffer *rb,
GLuint x, GLuint y, GLuint w, GLuint h,
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index 9fdabf98c..f8ef01d4e 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -199,19 +199,23 @@ typedef enum
#define VERT_BIT_GENERIC0 BITFIELD64_BIT(VERT_ATTRIB_GENERIC0)
#define VERT_BIT(i) BITFIELD64_BIT(i)
-#define VERT_BIT_ALL (BITFIELD64_BIT(VERT_ATTRIB_MAX) - 1)
+#define VERT_BIT_ALL BITFIELD64_RANGE(0, VERT_ATTRIB_MAX)
#define VERT_BIT_FF(i) VERT_BIT(i)
-#define VERT_BIT_FF_ALL (BITFIELD64_BIT(VERT_ATTRIB_FF_MAX) - 1)
+#define VERT_BIT_FF_ALL BITFIELD64_RANGE(0, VERT_ATTRIB_FF_MAX)
#define VERT_BIT_TEX(i) VERT_BIT(VERT_ATTRIB_TEX(i))
#define VERT_BIT_TEX_ALL \
- ((BITFIELD64_BIT(VERT_ATTRIB_TEX_MAX) - 1) << VERT_ATTRIB_TEX(0))
+ BITFIELD64_RANGE(VERT_ATTRIB_TEX(0), VERT_ATTRIB_TEX_MAX)
+#define VERT_BIT_FF_NVALIAS \
+ BITFIELD64_RANGE(VERT_ATTRIB_POS, VERT_ATTRIB_TEX(VERT_ATTRIB_TEX_MAX))
+
#define VERT_BIT_GENERIC_NV(i) VERT_BIT(VERT_ATTRIB_GENERIC_NV(i))
#define VERT_BIT_GENERIC_NV_ALL \
- ((BITFIELD64_BIT(VERT_ATTRIB_GENERIC_NV_MAX) - 1) << (VERT_ATTRIB_GENERIC_NV(0)))
+ BITFIELD64_RANGE(VERT_ATTRIB_GENERIC_NV(0), VERT_ATTRIB_GENERIC_NV_MAX)
+
#define VERT_BIT_GENERIC(i) VERT_BIT(VERT_ATTRIB_GENERIC(i))
#define VERT_BIT_GENERIC_ALL \
- ((BITFIELD64_BIT(VERT_ATTRIB_GENERIC_MAX) - 1) << (VERT_ATTRIB_GENERIC(0)))
+ BITFIELD64_RANGE(VERT_ATTRIB_GENERIC(0), VERT_ATTRIB_GENERIC_MAX)
/*@}*/
diff --git a/mesalib/src/mesa/main/shaderobj.c b/mesalib/src/mesa/main/shaderobj.c
index de66851e9..36f208d6c 100644
--- a/mesalib/src/mesa/main/shaderobj.c
+++ b/mesalib/src/mesa/main/shaderobj.c
@@ -35,6 +35,7 @@
#include "main/mfeatures.h"
#include "main/mtypes.h"
#include "main/shaderobj.h"
+#include "main/uniforms.h"
#include "program/program.h"
#include "program/prog_parameter.h"
#include "program/hash_table.h"
@@ -276,6 +277,7 @@ _mesa_clear_shader_program_data(struct gl_context *ctx,
struct gl_shader_program *shProg)
{
if (shProg->UniformStorage) {
+ _mesa_uniform_detach_all_driver_storage(shProg->UniformStorage);
ralloc_free(shProg->UniformStorage);
shProg->NumUserUniformStorage = 0;
shProg->UniformStorage = NULL;
diff --git a/mesalib/src/mesa/main/state.c b/mesalib/src/mesa/main/state.c
index b910543e2..adbb0c32b 100644
--- a/mesalib/src/mesa/main/state.c
+++ b/mesalib/src/mesa/main/state.c
@@ -63,130 +63,6 @@ update_separate_specular(struct gl_context *ctx)
/**
- * Helper for update_arrays().
- * \return min(current min, array->_MaxElement).
- */
-static GLuint
-update_min(GLuint min, struct gl_client_array *array)
-{
- _mesa_update_array_max_element(array);
- return MIN2(min, array->_MaxElement);
-}
-
-
-/**
- * Update ctx->Array._MaxElement (the max legal index into all enabled arrays).
- * Need to do this upon new array state or new buffer object state.
- */
-static void
-update_arrays( struct gl_context *ctx )
-{
- struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
- GLuint i, min = ~0;
-
- /* find min of _MaxElement values for all enabled arrays.
- * Note that the generic arrays always take precedence over
- * the legacy arrays.
- */
-
- /* 0 */
- if (ctx->VertexProgram._Current
- && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC0]);
- }
- else if (arrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_POS]);
- }
-
- /* 1 */
- if (ctx->VertexProgram._Enabled
- && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC1].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC1]);
- }
- /* no conventional vertex weight array */
-
- /* 2 */
- if (ctx->VertexProgram._Enabled
- && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC2].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC2]);
- }
- else if (arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_NORMAL]);
- }
-
- /* 3 */
- if (ctx->VertexProgram._Enabled
- && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC3].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC3]);
- }
- else if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR0]);
- }
-
- /* 4 */
- if (ctx->VertexProgram._Enabled
- && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC4].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC4]);
- }
- else if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR1]);
- }
-
- /* 5 */
- if (ctx->VertexProgram._Enabled
- && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC5].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC5]);
- }
- else if (arrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_FOG]);
- }
-
- /* 6 */
- if (ctx->VertexProgram._Enabled
- && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC6].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC6]);
- }
- else if (arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX]);
- }
-
- /* 7 */
- if (ctx->VertexProgram._Enabled
- && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC7].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC7]);
- }
-
- /* 8..15 */
- for (i = 0; i < VERT_ATTRIB_TEX_MAX; i++) {
- if (ctx->VertexProgram._Enabled
- && arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC8 + i].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC8 + i]);
- }
- else if (i < ctx->Const.MaxTextureCoordUnits
- && arrayObj->VertexAttrib[VERT_ATTRIB_TEX(i)].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_TEX(i)]);
- }
- }
-
- /* 16..31 */
- if (ctx->VertexProgram._Current) {
- for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++) {
- if (arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(i)].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(i)]);
- }
- }
- }
-
- if (arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled) {
- min = update_min(min, &arrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG]);
- }
-
- /* _MaxElement is one past the last legal array element */
- arrayObj->_MaxElement = min;
-}
-
-
-/**
* Update the following fields:
* ctx->VertexProgram._Enabled
* ctx->FragmentProgram._Enabled
@@ -690,7 +566,7 @@ _mesa_update_state_locked( struct gl_context *ctx )
}
if (new_state & (_NEW_ARRAY | _NEW_PROGRAM | _NEW_BUFFER_OBJECT))
- update_arrays( ctx );
+ _mesa_update_array_object_max_element(ctx, ctx->Array.ArrayObj);
out:
new_prog_state |= update_program_constants(ctx);
diff --git a/mesalib/src/mesa/main/texformat.c b/mesalib/src/mesa/main/texformat.c
index 7e60541c3..259eb9044 100644
--- a/mesalib/src/mesa/main/texformat.c
+++ b/mesalib/src/mesa/main/texformat.c
@@ -323,6 +323,7 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
case GL_ALPHA16F_ARB:
RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_FLOAT16);
RETURN_IF_SUPPORTED(MESA_FORMAT_ALPHA_FLOAT32);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT16);
RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
break;
case GL_ALPHA32F_ARB:
@@ -334,6 +335,7 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
case GL_LUMINANCE16F_ARB:
RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_FLOAT16);
RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_FLOAT32);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT16);
RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
break;
case GL_LUMINANCE32F_ARB:
@@ -345,6 +347,7 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
case GL_LUMINANCE_ALPHA16F_ARB:
RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16);
RETURN_IF_SUPPORTED(MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT16);
RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
break;
case GL_LUMINANCE_ALPHA32F_ARB:
@@ -356,6 +359,7 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
case GL_INTENSITY16F_ARB:
RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_FLOAT16);
RETURN_IF_SUPPORTED(MESA_FORMAT_INTENSITY_FLOAT32);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT16);
RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
break;
case GL_INTENSITY32F_ARB:
@@ -786,21 +790,31 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
switch (internalFormat) {
case GL_R16F:
RETURN_IF_SUPPORTED(MESA_FORMAT_R_FLOAT16);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RG_FLOAT16);
RETURN_IF_SUPPORTED(MESA_FORMAT_R_FLOAT32);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RG_FLOAT32);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT16);
RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
break;
case GL_R32F:
RETURN_IF_SUPPORTED(MESA_FORMAT_R_FLOAT32);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RG_FLOAT32);
RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_R_FLOAT16);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RG_FLOAT16);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT16);
break;
case GL_RG16F:
RETURN_IF_SUPPORTED(MESA_FORMAT_RG_FLOAT16);
RETURN_IF_SUPPORTED(MESA_FORMAT_RG_FLOAT32);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT16);
RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
break;
case GL_RG32F:
RETURN_IF_SUPPORTED(MESA_FORMAT_RG_FLOAT32);
RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT32);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RG_FLOAT16);
+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FLOAT16);
break;
default:
diff --git a/mesalib/src/mesa/main/texgetimage.c b/mesalib/src/mesa/main/texgetimage.c
index f848aa89d..8c85c1e54 100644
--- a/mesalib/src/mesa/main/texgetimage.c
+++ b/mesalib/src/mesa/main/texgetimage.c
@@ -837,6 +837,9 @@ _mesa_GetnTexImageARB( GLenum target, GLint level, GLenum format,
texObj = _mesa_get_current_tex_object(ctx, target);
texImage = _mesa_select_tex_image(ctx, texObj, target, level);
+ if (_mesa_is_zero_size_texture(texImage))
+ return;
+
if (MESA_VERBOSE & (VERBOSE_API | VERBOSE_TEXTURE)) {
_mesa_debug(ctx, "glGetTexImage(tex %u) format = %s, w=%d, h=%d,"
" dstFmt=0x%x, dstType=0x%x\n",
@@ -970,6 +973,9 @@ _mesa_GetnCompressedTexImageARB(GLenum target, GLint level, GLsizei bufSize,
texObj = _mesa_get_current_tex_object(ctx, target);
texImage = _mesa_select_tex_image(ctx, texObj, target, level);
+ if (_mesa_is_zero_size_texture(texImage))
+ return;
+
if (MESA_VERBOSE & (VERBOSE_API | VERBOSE_TEXTURE)) {
_mesa_debug(ctx,
"glGetCompressedTexImage(tex %u) format = %s, w=%d, h=%d\n",
diff --git a/mesalib/src/mesa/main/teximage.h b/mesalib/src/mesa/main/teximage.h
index 12af0e6d6..e2bdaca01 100644
--- a/mesalib/src/mesa/main/teximage.h
+++ b/mesalib/src/mesa/main/teximage.h
@@ -44,7 +44,14 @@ _mesa_is_cube_face(GLenum target)
target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB);
}
-
+/** Is any of the dimensions of given texture equal to zero? */
+static inline GLboolean
+_mesa_is_zero_size_texture(const struct gl_texture_image *texImage)
+{
+ return (texImage->Width == 0 ||
+ texImage->Height == 0 ||
+ texImage->Depth == 0);
+}
/** \name Internal functions */
/*@{*/
diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c
index a9c64cede..600dab302 100644
--- a/mesalib/src/mesa/main/texstore.c
+++ b/mesalib/src/mesa/main/texstore.c
@@ -4404,7 +4404,7 @@ get_read_write_mode(GLenum userFormat, gl_format texFormat)
&& _mesa_get_format_base_format(texFormat) == GL_DEPTH_STENCIL)
return GL_MAP_READ_BIT | GL_MAP_WRITE_BIT;
else
- return GL_MAP_WRITE_BIT;
+ return GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT;
}
@@ -4805,7 +4805,7 @@ _mesa_store_compressed_texsubimage2d(struct gl_context *ctx,
/* Map dest texture buffer */
ctx->Driver.MapTextureImage(ctx, texImage, 0,
xoffset, yoffset, width, height,
- GL_MAP_WRITE_BIT,
+ GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT,
&dstMap, &dstRowStride);
if (dstMap) {
diff --git a/mesalib/src/mesa/main/varray.c b/mesalib/src/mesa/main/varray.c
index 540e8963c..9078d1161 100644
--- a/mesalib/src/mesa/main/varray.c
+++ b/mesalib/src/mesa/main/varray.c
@@ -555,7 +555,7 @@ get_vertex_array_attrib(struct gl_context *ctx, GLuint index, GLenum pname,
case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB:
return array->BufferObj->Name;
case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
- if (ctx->Extensions.EXT_gpu_shader4) {
+ if (ctx->VersionMajor >= 3 || ctx->Extensions.EXT_gpu_shader4) {
return array->Integer;
}
goto error;
diff --git a/mesalib/src/mesa/program/register_allocate.c b/mesalib/src/mesa/program/register_allocate.c
index f5b5174fc..f08c9d28d 100644
--- a/mesalib/src/mesa/program/register_allocate.c
+++ b/mesalib/src/mesa/program/register_allocate.c
@@ -154,13 +154,19 @@ struct ra_graph {
unsigned int stack_count;
};
+/**
+ * Creates a set of registers for the allocator.
+ *
+ * mem_ctx is a ralloc context for the allocator. The reg set may be freed
+ * using ralloc_free().
+ */
struct ra_regs *
-ra_alloc_reg_set(unsigned int count)
+ra_alloc_reg_set(void *mem_ctx, unsigned int count)
{
unsigned int i;
struct ra_regs *regs;
- regs = rzalloc(NULL, struct ra_regs);
+ regs = rzalloc(mem_ctx, struct ra_regs);
regs->count = count;
regs->regs = rzalloc_array(regs, struct ra_reg, count);
diff --git a/mesalib/src/mesa/program/register_allocate.h b/mesalib/src/mesa/program/register_allocate.h
index ee2e58a47..00b851ec2 100644
--- a/mesalib/src/mesa/program/register_allocate.h
+++ b/mesalib/src/mesa/program/register_allocate.h
@@ -36,7 +36,7 @@ struct ra_regs;
* registers, such as aligned register pairs that conflict with the
* two real registers from which they are composed.
*/
-struct ra_regs *ra_alloc_reg_set(unsigned int count);
+struct ra_regs *ra_alloc_reg_set(void *mem_ctx, unsigned int count);
unsigned int ra_alloc_reg_class(struct ra_regs *regs);
void ra_add_reg_conflict(struct ra_regs *regs,
unsigned int r1, unsigned int r2);
diff --git a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
index 6d95d57c1..6534a4347 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -58,7 +58,7 @@ st_bufferobj_alloc(struct gl_context *ctx, GLuint name, GLenum target)
if (!st_obj)
return NULL;
- _mesa_initialize_buffer_object(&st_obj->Base, name, target);
+ _mesa_initialize_buffer_object(ctx, &st_obj->Base, name, target);
return &st_obj->Base;
}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_fbo.c b/mesalib/src/mesa/state_tracker/st_cb_fbo.c
index ec40a2b70..911e321a5 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_fbo.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_fbo.c
@@ -688,6 +688,8 @@ st_MapRenderbuffer(struct gl_context *ctx,
usage |= PIPE_TRANSFER_READ;
if (mode & GL_MAP_WRITE_BIT)
usage |= PIPE_TRANSFER_WRITE;
+ if (mode & GL_MAP_INVALIDATE_RANGE_BIT)
+ usage |= PIPE_TRANSFER_DISCARD_RANGE;
/* Note: y=0=bottom of buffer while y2=0=top of buffer.
* 'invert' will be true for window-system buffers and false for
diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c
index ad4f23c7e..5cd9a4c94 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c
@@ -189,6 +189,8 @@ st_MapTextureImage(struct gl_context *ctx,
pipeMode |= PIPE_TRANSFER_READ;
if (mode & GL_MAP_WRITE_BIT)
pipeMode |= PIPE_TRANSFER_WRITE;
+ if (mode & GL_MAP_INVALIDATE_RANGE_BIT)
+ pipeMode |= PIPE_TRANSFER_DISCARD_RANGE;
map = st_texture_image_map(st, stImage, slice, pipeMode, x, y, w, h);
if (map) {
diff --git a/mesalib/src/mesa/state_tracker/st_format.c b/mesalib/src/mesa/state_tracker/st_format.c
index 5f9ae9129..620910ddb 100644
--- a/mesalib/src/mesa/state_tracker/st_format.c
+++ b/mesalib/src/mesa/state_tracker/st_format.c
@@ -839,6 +839,15 @@ struct format_mapping
PIPE_FORMAT_S8_UINT_Z24_UNORM, \
0
+#define DEFAULT_SNORM8_RGBA_FORMATS \
+ PIPE_FORMAT_R8G8B8A8_SNORM, \
+ 0
+
+#define DEFAULT_UNORM16_RGBA_FORMATS \
+ PIPE_FORMAT_R16G16B16A16_UNORM, \
+ DEFAULT_RGBA_FORMATS
+
+
/**
* This table maps OpenGL texture format enums to Gallium pipe_format enums.
* Multiple GL enums might map to multiple pipe_formats.
@@ -1145,54 +1154,55 @@ static const struct format_mapping format_map[] = {
/* R, RG formats */
{
{ GL_RED, GL_R8, 0 },
- { PIPE_FORMAT_R8_UNORM, 0 }
+ { PIPE_FORMAT_R8_UNORM, PIPE_FORMAT_R8G8_UNORM, DEFAULT_RGBA_FORMATS }
},
{
{ GL_RG, GL_RG8, 0 },
- { PIPE_FORMAT_R8G8_UNORM, 0 }
+ { PIPE_FORMAT_R8G8_UNORM, DEFAULT_RGBA_FORMATS }
},
{
{ GL_R16, 0 },
- { PIPE_FORMAT_R16_UNORM, 0 }
+ { PIPE_FORMAT_R16_UNORM, PIPE_FORMAT_R16G16_UNORM,
+ DEFAULT_UNORM16_RGBA_FORMATS }
},
{
{ GL_RG16, 0 },
- { PIPE_FORMAT_R16G16_UNORM, 0 }
+ { PIPE_FORMAT_R16G16_UNORM, DEFAULT_UNORM16_RGBA_FORMATS }
},
/* compressed R, RG formats */
{
{ GL_COMPRESSED_RED, GL_COMPRESSED_RED_RGTC1, 0 },
- { PIPE_FORMAT_RGTC1_UNORM, PIPE_FORMAT_R8_UNORM, 0 }
+ { PIPE_FORMAT_RGTC1_UNORM, PIPE_FORMAT_R8_UNORM, DEFAULT_RGBA_FORMATS }
},
{
{ GL_COMPRESSED_SIGNED_RED_RGTC1, 0 },
- { PIPE_FORMAT_RGTC1_SNORM, 0 }
+ { PIPE_FORMAT_RGTC1_SNORM, DEFAULT_SNORM8_RGBA_FORMATS }
},
{
{ GL_COMPRESSED_RG, GL_COMPRESSED_RG_RGTC2, 0 },
- { PIPE_FORMAT_RGTC2_UNORM, PIPE_FORMAT_R8G8_UNORM, 0 }
+ { PIPE_FORMAT_RGTC2_UNORM, PIPE_FORMAT_R8G8_UNORM, DEFAULT_RGBA_FORMATS }
},
{
{ GL_COMPRESSED_SIGNED_RG_RGTC2, 0 },
- { PIPE_FORMAT_RGTC2_SNORM, 0 }
+ { PIPE_FORMAT_RGTC2_SNORM, DEFAULT_SNORM8_RGBA_FORMATS }
},
{
{ GL_COMPRESSED_LUMINANCE, GL_COMPRESSED_LUMINANCE_LATC1_EXT, 0 },
- { PIPE_FORMAT_LATC1_UNORM, PIPE_FORMAT_L8_UNORM, 0 }
+ { PIPE_FORMAT_LATC1_UNORM, PIPE_FORMAT_L8_UNORM, DEFAULT_RGBA_FORMATS }
},
{
{ GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT, 0 },
- { PIPE_FORMAT_LATC1_SNORM, 0 }
+ { PIPE_FORMAT_LATC1_SNORM, DEFAULT_SNORM8_RGBA_FORMATS }
},
{
{ GL_COMPRESSED_LUMINANCE_ALPHA, GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT,
GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI, 0 },
- { PIPE_FORMAT_LATC2_UNORM, PIPE_FORMAT_L8A8_UNORM, 0 }
+ { PIPE_FORMAT_LATC2_UNORM, PIPE_FORMAT_L8A8_UNORM, DEFAULT_RGBA_FORMATS }
},
{
{ GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT, 0 },
- { PIPE_FORMAT_LATC2_SNORM, 0 }
+ { PIPE_FORMAT_LATC2_SNORM, DEFAULT_SNORM8_RGBA_FORMATS }
},
/* ETC1 */
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 dc841ff97..92dffe258 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -357,7 +357,7 @@ public:
/** List of immediate_storage */
exec_list immediates;
- int num_immediates;
+ unsigned num_immediates;
/** List of function_entry */
exec_list function_signatures;
@@ -3645,6 +3645,7 @@ get_pixel_transfer_visitor(struct st_fragment_program *fp,
v->indirect_addr_temps = original->indirect_addr_temps;
v->indirect_addr_consts = original->indirect_addr_consts;
memcpy(&v->immediates, &original->immediates, sizeof(v->immediates));
+ v->num_immediates = original->num_immediates;
/*
* Get initial pixel color from the texture.
@@ -3775,6 +3776,7 @@ get_bitmap_visitor(struct st_fragment_program *fp,
v->indirect_addr_temps = original->indirect_addr_temps;
v->indirect_addr_consts = original->indirect_addr_consts;
memcpy(&v->immediates, &original->immediates, sizeof(v->immediates));
+ v->num_immediates = original->num_immediates;
/* TEX tmp0, fragment.texcoord[0], texture[0], 2D; */
coord = st_src_reg(PROGRAM_INPUT, FRAG_ATTRIB_TEX0, glsl_type::vec2_type);
@@ -4679,8 +4681,10 @@ st_translate_program(
i = 0;
foreach_iter(exec_list_iterator, iter, program->immediates) {
immediate_storage *imm = (immediate_storage *)iter.get();
+ assert(i < program->num_immediates);
t->immediates[i++] = emit_immediate(t, imm->values, imm->type, imm->size);
}
+ assert(i == program->num_immediates);
/* texture samplers */
for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) {