aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesalib/configure.ac3
-rw-r--r--mesalib/src/glsl/ast.h23
-rw-r--r--mesalib/src/glsl/ast_type.cpp45
-rw-r--r--mesalib/src/glsl/glsl_parser.yy65
-rw-r--r--mesalib/src/glsl/glsl_parser_extras.cpp18
-rw-r--r--mesalib/src/glsl/glsl_parser_extras.h24
-rw-r--r--mesalib/src/glsl/link_uniforms.cpp19
-rw-r--r--mesalib/src/glsl/linker.cpp34
-rw-r--r--mesalib/src/mesa/Makefile.am5
-rw-r--r--mesalib/src/mesa/main/getstring.c10
-rw-r--r--mesalib/src/mesa/main/shaderapi.c29
-rw-r--r--mesalib/src/mesa/main/uniforms.c221
-rw-r--r--mesalib/src/mesa/osmesa.pc.in12
-rw-r--r--mesalib/src/mesa/program/ir_to_mesa.cpp2
14 files changed, 431 insertions, 79 deletions
diff --git a/mesalib/configure.ac b/mesalib/configure.ac
index 47b918720..b01b1921b 100644
--- a/mesalib/configure.ac
+++ b/mesalib/configure.ac
@@ -2118,7 +2118,6 @@ AC_SUBST([GALLIUM_MAKE_DIRS])
AM_CONDITIONAL(HAVE_X11_DRIVER, echo "$DRIVER_DIRS" | grep 'x11' >/dev/null 2>&1)
AM_CONDITIONAL(HAVE_DRI_DRIVER, echo "$DRIVER_DIRS" | grep 'dri' >/dev/null 2>&1)
-AM_CONDITIONAL(HAVE_OSMESA_DRIVER, echo "$DRIVER_DIRS" | grep 'osmesa' >/dev/null 2>&1)
AM_CONDITIONAL(HAVE_X86_ASM, echo "$DEFINES" | grep 'X86_ASM' >/dev/null 2>&1)
AM_CONDITIONAL(HAVE_X86_64_ASM, echo "$DEFINES" | grep 'X86_64_ASM' >/dev/null 2>&1)
@@ -2186,7 +2185,7 @@ AC_CONFIG_FILES([configs/current
src/mesa/drivers/osmesa/Makefile
src/mesa/drivers/x11/Makefile
src/mesa/gl.pc
- src/mesa/osmesa.pc])
+ src/mesa/drivers/osmesa/osmesa.pc])
dnl Sort the dirs alphabetically
GALLIUM_TARGET_DIRS=`echo $GALLIUM_TARGET_DIRS|tr " " "\n"|sort -u|tr "\n" " "`
diff --git a/mesalib/src/glsl/ast.h b/mesalib/src/glsl/ast.h
index de3f2dfeb..50747822d 100644
--- a/mesalib/src/glsl/ast.h
+++ b/mesalib/src/glsl/ast.h
@@ -338,6 +338,25 @@ enum {
};
struct ast_type_qualifier {
+ /* Callers of this ralloc-based new need not call delete. It's
+ * easier to just ralloc_free 'ctx' (or any of its ancestors). */
+ static void* operator new(size_t size, void *ctx)
+ {
+ void *node;
+
+ node = rzalloc_size(ctx, size);
+ assert(node != NULL);
+
+ return node;
+ }
+
+ /* If the user *does* call delete, that's OK, we will just
+ * ralloc_free in that case. */
+ static void operator delete(void *table)
+ {
+ ralloc_free(table);
+ }
+
union {
struct {
unsigned invariant:1;
@@ -424,6 +443,10 @@ struct ast_type_qualifier {
* returned string is undefined but not null.
*/
const char *interpolation_string() const;
+
+ bool merge_qualifier(YYLTYPE *loc,
+ _mesa_glsl_parse_state *state,
+ ast_type_qualifier q);
};
class ast_declarator_list;
diff --git a/mesalib/src/glsl/ast_type.cpp b/mesalib/src/glsl/ast_type.cpp
index 6c44f8c41..29493e2f6 100644
--- a/mesalib/src/glsl/ast_type.cpp
+++ b/mesalib/src/glsl/ast_type.cpp
@@ -71,3 +71,48 @@ ast_type_qualifier::interpolation_string() const
else
return NULL;
}
+
+bool
+ast_type_qualifier::merge_qualifier(YYLTYPE *loc,
+ _mesa_glsl_parse_state *state,
+ ast_type_qualifier q)
+{
+ ast_type_qualifier ubo_mat_mask;
+ ubo_mat_mask.flags.i = 0;
+ ubo_mat_mask.flags.q.row_major = 1;
+ ubo_mat_mask.flags.q.column_major = 1;
+
+ ast_type_qualifier ubo_layout_mask;
+ ubo_layout_mask.flags.i = 0;
+ ubo_layout_mask.flags.q.std140 = 1;
+ ubo_layout_mask.flags.q.packed = 1;
+ ubo_layout_mask.flags.q.shared = 1;
+
+ /* Uniform block layout qualifiers get to overwrite each
+ * other (rightmost having priority), while all other
+ * qualifiers currently don't allow duplicates.
+ */
+
+ if ((this->flags.i & q.flags.i & ~(ubo_mat_mask.flags.i |
+ ubo_layout_mask.flags.i)) != 0) {
+ _mesa_glsl_error(loc, state,
+ "duplicate layout qualifiers used\n");
+ return false;
+ }
+
+ if ((q.flags.i & ubo_mat_mask.flags.i) != 0)
+ this->flags.i &= ~ubo_mat_mask.flags.i;
+ if ((q.flags.i & ubo_layout_mask.flags.i) != 0)
+ this->flags.i &= ~ubo_layout_mask.flags.i;
+
+ this->flags.i |= q.flags.i;
+
+ if (q.flags.q.explicit_location)
+ this->location = q.location;
+
+ if (q.flags.q.explicit_index)
+ this->index = q.index;
+
+ return true;
+}
+
diff --git a/mesalib/src/glsl/glsl_parser.yy b/mesalib/src/glsl/glsl_parser.yy
index f61d6b8dd..04c64f096 100644
--- a/mesalib/src/glsl/glsl_parser.yy
+++ b/mesalib/src/glsl/glsl_parser.yy
@@ -29,6 +29,7 @@
#include "ast.h"
#include "glsl_parser_extras.h"
#include "glsl_types.h"
+#include "main/context.h"
#define YYLEX_PARAM state->scanner
@@ -259,19 +260,25 @@ version_statement:
switch ($2) {
case 100:
state->es_shader = true;
- supported = state->Const.GLSL_100ES;
+ supported = state->ctx->API == API_OPENGLES2 ||
+ state->ctx->Extensions.ARB_ES2_compatibility;
break;
case 110:
- supported = state->Const.GLSL_110;
- break;
case 120:
- supported = state->Const.GLSL_120;
- break;
+ /* FINISHME: Once the OpenGL 3.0 'forward compatible' context or
+ * the OpenGL 3.2 Core context is supported, this logic will need
+ * change. Older versions of GLSL are no longer supported
+ * outside the compatibility contexts of 3.x.
+ */
case 130:
- supported = state->Const.GLSL_130;
- break;
case 140:
- supported = state->Const.GLSL_140;
+ case 150:
+ case 330:
+ case 400:
+ case 410:
+ case 420:
+ supported = _mesa_is_desktop_gl(state->ctx) &&
+ ((unsigned) $2) <= state->ctx->Const.GLSLVersion;
break;
default:
supported = false;
@@ -291,6 +298,10 @@ version_statement:
state->version_string,
state->supported_version_string);
}
+
+ if (state->language_version >= 140) {
+ state->ARB_uniform_buffer_object_enable = true;
+ }
}
;
@@ -301,7 +312,7 @@ pragma_statement:
| PRAGMA_OPTIMIZE_OFF EOL
| PRAGMA_INVARIANT_ALL EOL
{
- if (state->language_version < 120 && !state->Const.GLSL_100ES) {
+ if (state->language_version == 110) {
_mesa_glsl_warning(& @1, state,
"pragma `invariant(all)' not supported in %s",
state->version_string);
@@ -1102,20 +1113,10 @@ layout_qualifier_id_list:
layout_qualifier_id
| layout_qualifier_id_list ',' layout_qualifier_id
{
- if (($1.flags.i & $3.flags.i) != 0) {
- _mesa_glsl_error(& @3, state,
- "duplicate layout qualifiers used\n");
+ $$ = $1;
+ if (!$$.merge_qualifier(& @3, state, $3)) {
YYERROR;
}
-
- $$ = $1;
- $$.flags.i |= $3.flags.i;
-
- if ($3.flags.q.explicit_location)
- $$.location = $3.location;
-
- if ($3.flags.q.explicit_index)
- $$.index = $3.index;
}
;
@@ -1905,6 +1906,7 @@ external_declaration:
function_definition { $$ = $1; }
| declaration { $$ = $1; }
| pragma_statement { $$ = NULL; }
+ | layout_defaults { $$ = NULL; }
;
function_definition:
@@ -1925,14 +1927,18 @@ uniform_block:
UNIFORM NEW_IDENTIFIER '{' member_list '}' ';'
{
void *ctx = state;
- ast_type_qualifier no_qual;
- memset(&no_qual, 0, sizeof(no_qual));
- $$ = new(ctx) ast_uniform_block(no_qual, $2, $4);
+ $$ = new(ctx) ast_uniform_block(*state->default_uniform_qualifier,
+ $2, $4);
}
| layout_qualifier UNIFORM NEW_IDENTIFIER '{' member_list '}' ';'
{
void *ctx = state;
- $$ = new(ctx) ast_uniform_block($1, $3, $5);
+
+ ast_type_qualifier qual = *state->default_uniform_qualifier;
+ if (!qual.merge_qualifier(& @1, state, $1)) {
+ YYERROR;
+ }
+ $$ = new(ctx) ast_uniform_block(qual, $3, $5);
}
;
@@ -1986,3 +1992,12 @@ member_declaration:
$$->declarations.push_degenerate_list_at_head(& $3->link);
}
;
+
+layout_defaults:
+ layout_qualifier UNIFORM ';'
+ {
+ if (!state->default_uniform_qualifier->merge_qualifier(& @1, state,
+ $1)) {
+ YYERROR;
+ }
+ }
diff --git a/mesalib/src/glsl/glsl_parser_extras.cpp b/mesalib/src/glsl/glsl_parser_extras.cpp
index 7a9b22197..09e1e590d 100644
--- a/mesalib/src/glsl/glsl_parser_extras.cpp
+++ b/mesalib/src/glsl/glsl_parser_extras.cpp
@@ -85,23 +85,11 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
this->Const.MaxDrawBuffers = ctx->Const.MaxDrawBuffers;
- /* Note: Once the OpenGL 3.0 'forward compatible' context or the OpenGL 3.2
- * Core context is supported, this logic will need change. Older versions of
- * GLSL are no longer supported outside the compatibility contexts of 3.x.
- */
- this->Const.GLSL_100ES = (ctx->API == API_OPENGLES2)
- || ctx->Extensions.ARB_ES2_compatibility;
- bool is_desktop_gl = _mesa_is_desktop_gl(ctx);
- this->Const.GLSL_110 = is_desktop_gl;
- this->Const.GLSL_120 = is_desktop_gl && (ctx->Const.GLSLVersion >= 120);
- this->Const.GLSL_130 = is_desktop_gl && (ctx->Const.GLSLVersion >= 130);
- this->Const.GLSL_140 = is_desktop_gl && (ctx->Const.GLSLVersion >= 140);
-
const unsigned lowest_version =
(ctx->API == API_OPENGLES2) || ctx->Extensions.ARB_ES2_compatibility
? 100 : 110;
const unsigned highest_version =
- is_desktop_gl ? ctx->Const.GLSLVersion : 100;
+ _mesa_is_desktop_gl(ctx) ? ctx->Const.GLSLVersion : 100;
char *supported = ralloc_strdup(this, "");
for (unsigned ver = lowest_version; ver <= highest_version; ver += 10) {
@@ -119,6 +107,10 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
if (ctx->Const.ForceGLSLExtensionsWarn)
_mesa_glsl_process_extension("all", NULL, "warn", NULL, this);
+
+ this->default_uniform_qualifier = new(this) ast_type_qualifier();
+ this->default_uniform_qualifier->flags.q.shared = 1;
+ this->default_uniform_qualifier->flags.q.column_major = 1;
}
const char *
diff --git a/mesalib/src/glsl/glsl_parser_extras.h b/mesalib/src/glsl/glsl_parser_extras.h
index fc5d11cb9..c0a96c730 100644
--- a/mesalib/src/glsl/glsl_parser_extras.h
+++ b/mesalib/src/glsl/glsl_parser_extras.h
@@ -92,6 +92,13 @@ struct _mesa_glsl_parse_state {
enum _mesa_glsl_parser_targets target;
/**
+ * Default uniform layout qualifiers tracked during parsing.
+ * Currently affects uniform blocks and uniform buffer variables in
+ * those blocks.
+ */
+ class ast_type_qualifier *default_uniform_qualifier;
+
+ /**
* Printable list of GLSL versions supported by the current context
*
* \note
@@ -122,23 +129,6 @@ struct _mesa_glsl_parse_state {
/* ARB_draw_buffers */
unsigned MaxDrawBuffers;
-
- /**
- * Set of GLSL versions supported by the current context
- *
- * Knowing that version X is supported doesn't mean that versions before
- * X are also supported. Version 1.00 is only supported in an ES2
- * context or when GL_ARB_ES2_compatibility is supported. In an OpenGL
- * 3.0 "forward compatible" context, GLSL 1.10 and 1.20 are \b not
- * supported.
- */
- /*@{*/
- unsigned GLSL_100ES:1;
- unsigned GLSL_110:1;
- unsigned GLSL_120:1;
- unsigned GLSL_130:1;
- unsigned GLSL_140:1;
- /*@}*/
} Const;
/**
diff --git a/mesalib/src/glsl/link_uniforms.cpp b/mesalib/src/glsl/link_uniforms.cpp
index d7ef5d4d2..1baa46c5d 100644
--- a/mesalib/src/glsl/link_uniforms.cpp
+++ b/mesalib/src/glsl/link_uniforms.cpp
@@ -328,10 +328,21 @@ private:
this->uniforms[id].offset = this->ubo_byte_offset;
this->ubo_byte_offset += type->std140_size(ubo_var->RowMajor);
- this->uniforms[id].array_stride = 0;
- this->uniforms[id].matrix_stride = 0;
- this->uniforms[id].row_major = base_type->is_matrix() &&
- ubo_var->RowMajor;
+ if (type->is_array()) {
+ this->uniforms[id].array_stride =
+ align(type->fields.array->std140_size(ubo_var->RowMajor), 16);
+ } else {
+ this->uniforms[id].array_stride = 0;
+ }
+
+ if (type->is_matrix() ||
+ (type->is_array() && type->fields.array->is_matrix())) {
+ this->uniforms[id].matrix_stride = 16;
+ this->uniforms[id].row_major = ubo_var->RowMajor;
+ } else {
+ this->uniforms[id].matrix_stride = 0;
+ this->uniforms[id].row_major = false;
+ }
} else {
this->uniforms[id].block_index = -1;
this->uniforms[id].offset = -1;
diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp
index bfdde4023..34ce13372 100644
--- a/mesalib/src/glsl/linker.cpp
+++ b/mesalib/src/glsl/linker.cpp
@@ -2324,6 +2324,12 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
0 /* FINISHME: Geometry shaders. */
};
+ const unsigned max_uniform_blocks[MESA_SHADER_TYPES] = {
+ ctx->Const.VertexProgram.MaxUniformBlocks,
+ ctx->Const.FragmentProgram.MaxUniformBlocks,
+ ctx->Const.GeometryProgram.MaxUniformBlocks,
+ };
+
for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
struct gl_shader *sh = prog->_LinkedShaders[i];
@@ -2348,6 +2354,34 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
}
}
+ unsigned blocks[MESA_SHADER_TYPES] = {0};
+ unsigned total_uniform_blocks = 0;
+
+ for (unsigned i = 0; i < prog->NumUniformBlocks; i++) {
+ for (unsigned j = 0; j < MESA_SHADER_TYPES; j++) {
+ if (prog->UniformBlockStageIndex[j][i] != -1) {
+ blocks[j]++;
+ total_uniform_blocks++;
+ }
+ }
+
+ if (total_uniform_blocks > ctx->Const.MaxCombinedUniformBlocks) {
+ linker_error(prog, "Too many combined uniform blocks (%d/%d)",
+ prog->NumUniformBlocks,
+ ctx->Const.MaxCombinedUniformBlocks);
+ } else {
+ for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
+ if (blocks[i] > max_uniform_blocks[i]) {
+ linker_error(prog, "Too many %s uniform blocks (%d/%d)",
+ shader_names[i],
+ blocks[i],
+ max_uniform_blocks[i]);
+ break;
+ }
+ }
+ }
+ }
+
return prog->LinkStatus;
}
diff --git a/mesalib/src/mesa/Makefile.am b/mesalib/src/mesa/Makefile.am
index 2ec57ea91..bb70ed6ea 100644
--- a/mesalib/src/mesa/Makefile.am
+++ b/mesalib/src/mesa/Makefile.am
@@ -140,12 +140,7 @@ all-local: libmesa.la libmesagallium.la
CLEANFILES += libmesa.a libmesagallium.a
pkgconfigdir = $(libdir)/pkgconfig
-
-if HAVE_OSMESA_DRIVER
-pkgconfig_DATA = osmesa.pc
-else
pkgconfig_DATA = gl.pc
-endif
# Emacs tags
tags:
diff --git a/mesalib/src/mesa/main/getstring.c b/mesalib/src/mesa/main/getstring.c
index c6f400af5..1734fb3f5 100644
--- a/mesalib/src/mesa/main/getstring.c
+++ b/mesalib/src/mesa/main/getstring.c
@@ -56,6 +56,16 @@ shading_language_version(struct gl_context *ctx)
return (const GLubyte *) "1.30";
case 140:
return (const GLubyte *) "1.40";
+ case 150:
+ return (const GLubyte *) "1.50";
+ case 330:
+ return (const GLubyte *) "3.30";
+ case 400:
+ return (const GLubyte *) "4.00";
+ case 410:
+ return (const GLubyte *) "4.10";
+ case 420:
+ return (const GLubyte *) "4.20";
default:
_mesa_problem(ctx,
"Invalid GLSL version in shading_language_version()");
diff --git a/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c
index 7c97a6359..caeb9657e 100644
--- a/mesalib/src/mesa/main/shaderapi.c
+++ b/mesalib/src/mesa/main/shaderapi.c
@@ -544,6 +544,35 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *param
*params = shProg->Geom.OutputType;
break;
#endif
+ case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: {
+ unsigned i;
+ GLint max_len = 0;
+
+ if (!ctx->Extensions.ARB_uniform_buffer_object) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname)");
+ return;
+ }
+
+ for (i = 0; i < shProg->NumUniformBlocks; i++) {
+ /* Add one for the terminating NUL character.
+ */
+ const GLint len = strlen(shProg->UniformBlocks[i].Name) + 1;
+
+ if (len > max_len)
+ max_len = len;
+ }
+
+ *params = max_len;
+ break;
+ }
+ case GL_ACTIVE_UNIFORM_BLOCKS:
+ if (!ctx->Extensions.ARB_uniform_buffer_object) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname)");
+ return;
+ }
+
+ *params = shProg->NumUniformBlocks;
+ break;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname)");
return;
diff --git a/mesalib/src/mesa/main/uniforms.c b/mesalib/src/mesa/main/uniforms.c
index ccbd753db..f43d0fbee 100644
--- a/mesalib/src/mesa/main/uniforms.c
+++ b/mesalib/src/mesa/main/uniforms.c
@@ -41,6 +41,7 @@
#include "main/shaderapi.h"
#include "main/shaderobj.h"
#include "main/uniforms.h"
+#include "main/enums.h"
#include "ir_uniform.h"
#include "glsl_types.h"
@@ -521,6 +522,16 @@ _mesa_GetUniformLocationARB(GLhandleARB programObj, const GLcharARB *name)
if (index == GL_INVALID_INDEX)
return -1;
+ /* From the GL_ARB_uniform_buffer_object spec:
+ *
+ * "The value -1 will be returned if <name> does not correspond to an
+ * active uniform variable name in <program>, if <name> is associated
+ * with a named uniform block, or if <name> starts with the reserved
+ * prefix "gl_"."
+ */
+ if (shProg->UniformStorage[index].block_index != -1)
+ return -1;
+
return _mesa_uniform_merge_location_offset(index, offset);
}
@@ -583,6 +594,212 @@ _mesa_GetUniformIndices(GLuint program,
}
}
+static void GLAPIENTRY
+_mesa_UniformBlockBinding(GLuint program,
+ GLuint uniformBlockIndex,
+ GLuint uniformBlockBinding)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_shader_program *shProg;
+
+ if (!ctx->Extensions.ARB_uniform_buffer_object) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glUniformBlockBinding");
+ return;
+ }
+
+ shProg = _mesa_lookup_shader_program_err(ctx, program,
+ "glUniformBlockBinding");
+ if (!shProg)
+ return;
+
+ if (uniformBlockIndex >= shProg->NumUniformBlocks) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glUniformBlockBinding(block index %d >= %d)",
+ uniformBlockIndex, shProg->NumUniformBlocks);
+ return;
+ }
+
+ if (uniformBlockBinding >= ctx->Const.MaxUniformBufferBindings) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glUniformBlockBinding(block binding %d >= %d)",
+ uniformBlockBinding, ctx->Const.MaxUniformBufferBindings);
+ return;
+ }
+
+ if (shProg->UniformBlocks[uniformBlockIndex].Binding !=
+ uniformBlockBinding) {
+ int i;
+
+ FLUSH_VERTICES(ctx, _NEW_BUFFER_OBJECT);
+ shProg->UniformBlocks[uniformBlockIndex].Binding = uniformBlockBinding;
+
+ for (i = 0; i < MESA_SHADER_TYPES; i++) {
+ int stage_index = shProg->UniformBlockStageIndex[i][uniformBlockIndex];
+
+ if (stage_index != -1) {
+ struct gl_shader *sh = shProg->_LinkedShaders[i];
+ sh->UniformBlocks[stage_index].Binding = uniformBlockBinding;
+ }
+ }
+ }
+}
+
+static void GLAPIENTRY
+_mesa_GetActiveUniformBlockiv(GLuint program,
+ GLuint uniformBlockIndex,
+ GLenum pname,
+ GLint *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_shader_program *shProg;
+ struct gl_uniform_block *block;
+ unsigned i;
+
+ if (!ctx->Extensions.ARB_uniform_buffer_object) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetActiveUniformBlockiv");
+ return;
+ }
+
+ shProg = _mesa_lookup_shader_program_err(ctx, program,
+ "glGetActiveUniformBlockiv");
+ if (!shProg)
+ return;
+
+ if (uniformBlockIndex >= shProg->NumUniformBlocks) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetActiveUniformBlockiv(block index %d >= %d)",
+ uniformBlockIndex, shProg->NumUniformBlocks);
+ return;
+ }
+
+ block = &shProg->UniformBlocks[uniformBlockIndex];
+
+ switch (pname) {
+ case GL_UNIFORM_BLOCK_BINDING:
+ params[0] = block->Binding;
+ return;
+
+ case GL_UNIFORM_BLOCK_DATA_SIZE:
+ params[0] = block->UniformBufferSize;
+ return;
+
+ case GL_UNIFORM_BLOCK_NAME_LENGTH:
+ params[0] = strlen(block->Name) + 1;
+ return;
+
+ case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
+ params[0] = block->NumUniforms;
+ return;
+
+ case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
+ for (i = 0; i < block->NumUniforms; i++) {
+ unsigned offset;
+ params[i] = _mesa_get_uniform_location(ctx, shProg,
+ block->Uniforms[i].Name,
+ &offset);
+ }
+ return;
+
+ case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
+ params[0] = shProg->UniformBlockStageIndex[MESA_SHADER_VERTEX][uniformBlockIndex] != -1;
+ return;
+
+ case GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER:
+ params[0] = shProg->UniformBlockStageIndex[MESA_SHADER_GEOMETRY][uniformBlockIndex] != -1;
+ return;
+
+ case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
+ params[0] = shProg->UniformBlockStageIndex[MESA_SHADER_FRAGMENT][uniformBlockIndex] != -1;
+ return;
+
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetActiveUniformBlockiv(pname 0x%x (%s))",
+ pname, _mesa_lookup_enum_by_nr(pname));
+ return;
+ }
+}
+
+static void GLAPIENTRY
+_mesa_GetActiveUniformBlockName(GLuint program,
+ GLuint uniformBlockIndex,
+ GLsizei bufSize,
+ GLsizei *length,
+ GLchar *uniformBlockName)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_shader_program *shProg;
+ struct gl_uniform_block *block;
+
+ if (!ctx->Extensions.ARB_uniform_buffer_object) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetActiveUniformBlockiv");
+ return;
+ }
+
+ if (bufSize < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetActiveUniformBlockName(bufSize %d < 0)",
+ bufSize);
+ return;
+ }
+
+ shProg = _mesa_lookup_shader_program_err(ctx, program,
+ "glGetActiveUniformBlockiv");
+ if (!shProg)
+ return;
+
+ if (uniformBlockIndex >= shProg->NumUniformBlocks) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetActiveUniformBlockiv(block index %d >= %d)",
+ uniformBlockIndex, shProg->NumUniformBlocks);
+ return;
+ }
+
+ block = &shProg->UniformBlocks[uniformBlockIndex];
+
+ if (uniformBlockName) {
+ _mesa_copy_string(uniformBlockName, bufSize, length, block->Name);
+ }
+}
+
+static void GLAPIENTRY
+_mesa_GetActiveUniformName(GLuint program, GLuint uniformIndex,
+ GLsizei bufSize, GLsizei *length,
+ GLchar *uniformName)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_shader_program *shProg;
+
+ if (!ctx->Extensions.ARB_uniform_buffer_object) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetActiveUniformBlockiv");
+ return;
+ }
+
+ if (bufSize < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetActiveUniformName(bufSize %d < 0)",
+ bufSize);
+ return;
+ }
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetActiveUniformName");
+
+ if (!shProg)
+ return;
+
+ if (uniformIndex >= shProg->NumUserUniformStorage) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveUniform(index)");
+ return;
+ }
+
+ if (uniformName) {
+ _mesa_copy_string(uniformName, bufSize, length,
+ shProg->UniformStorage[uniformIndex].name);
+ }
+}
+
/**
* Plug in shader uniform-related functions into API dispatch table.
*/
@@ -644,6 +861,10 @@ _mesa_init_shader_uniform_dispatch(struct _glapi_table *exec)
SET_GetUniformBlockIndex(exec, _mesa_GetUniformBlockIndex);
SET_GetUniformIndices(exec, _mesa_GetUniformIndices);
SET_GetActiveUniformsiv(exec, _mesa_GetActiveUniformsiv);
+ SET_GetActiveUniformBlockiv(exec, _mesa_GetActiveUniformBlockiv);
+ SET_GetActiveUniformBlockName(exec, _mesa_GetActiveUniformBlockName);
+ SET_GetActiveUniformName(exec, _mesa_GetActiveUniformName);
+ SET_UniformBlockBinding(exec, _mesa_UniformBlockBinding);
#endif /* FEATURE_GL */
}
diff --git a/mesalib/src/mesa/osmesa.pc.in b/mesalib/src/mesa/osmesa.pc.in
deleted file mode 100644
index 307255ffc..000000000
--- a/mesalib/src/mesa/osmesa.pc.in
+++ /dev/null
@@ -1,12 +0,0 @@
-prefix=@prefix@
-exec_prefix=${prefix}
-libdir=@libdir@
-includedir=@includedir@
-
-Name: osmesa
-Description: Mesa Off-screen Rendering library
-Requires: @OSMESA_PC_REQ@
-Version: @PACKAGE_VERSION@
-Libs: -L${libdir} -l@OSMESA_LIB@
-Libs.private: @OSMESA_PC_LIB_PRIV@
-Cflags: -I${includedir}
diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp
index baa317204..255a8a76a 100644
--- a/mesalib/src/mesa/program/ir_to_mesa.cpp
+++ b/mesalib/src/mesa/program/ir_to_mesa.cpp
@@ -334,7 +334,7 @@ dst_reg address_reg = dst_reg(PROGRAM_ADDRESS, WRITEMASK_X);
static int
swizzle_for_size(int size)
{
- int size_swizzles[4] = {
+ static const int size_swizzles[4] = {
MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, SWIZZLE_X, SWIZZLE_X),
MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Y, SWIZZLE_Y),
MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_Z),