summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2012-04-27 13:52:56 -0700
committerEric Anholt <[email protected]>2012-07-20 10:43:28 -0700
commitf609cf782ab5e90ddf045dc4b0da8cebf99be0d1 (patch)
tree7f54da76e408a733a9bb82e8242ada78fb6063f4 /src/mesa
parentb3c093c79c2ec49c36af37aa290d5ae452149f6e (diff)
glsl: Merge the lists of uniform blocks into the linked shader program.
This attempts error-checking, but the layout isn't done yet. Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/mtypes.h34
-rw-r--r--src/mesa/program/ir_to_mesa.cpp6
2 files changed, 40 insertions, 0 deletions
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index b39a8dcd75b..3d59dc68ec1 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2216,6 +2216,15 @@ struct gl_shader
*/
unsigned num_uniform_components;
+ /**
+ * This shader's uniform block information.
+ *
+ * The offsets of the variables are assigned only for shaders in a program's
+ * _LinkedShaders[].
+ */
+ struct gl_uniform_block *UniformBlocks;
+ unsigned NumUniformBlocks;
+
struct exec_list *ir;
struct glsl_symbol_table *symbols;
@@ -2254,6 +2263,19 @@ struct gl_uniform_block
/** Array of supplemental information about UBO ir_variables. */
struct gl_uniform_buffer_variable *Uniforms;
GLuint NumUniforms;
+
+ /**
+ * Index (GL_UNIFORM_BLOCK_BINDING) into ctx->UniformBufferBindings[] to use
+ * with glBindBufferBase to bind a buffer object to this uniform block. When
+ * updated in the program, _NEW_BUFFER_OBJECT will be set.
+ */
+ GLuint Binding;
+
+ /**
+ * Minimum size of a buffer object to back this uniform buffer
+ * (GL_UNIFORM_BLOCK_DATA_SIZE).
+ */
+ GLuint UniformBufferSize;
};
/**
@@ -2338,6 +2360,18 @@ struct gl_shader_program
unsigned NumUserUniformStorage;
struct gl_uniform_storage *UniformStorage;
+ struct gl_uniform_block *UniformBlocks;
+ unsigned NumUniformBlocks;
+
+ /**
+ * Indices into the _LinkedShaders's UniformBlocks[] array for each stage
+ * they're used in, or -1.
+ *
+ * This is used to maintain the Binding values of the stage's UniformBlocks[]
+ * and to answer the GL_UNIFORM_BLOCK_REFERENCED_BY_*_SHADER queries.
+ */
+ int *UniformBlockStageIndex[MESA_SHADER_TYPES];
+
/**
* Map of active uniform names to locations
*
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 8a4f31162e1..baa317204c4 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -3115,6 +3115,12 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader)
}
}
+ if (shader->UniformBlocks)
+ ralloc_free(shader->UniformBlocks);
+ shader->NumUniformBlocks = state->num_uniform_blocks;
+ shader->UniformBlocks = state->uniform_blocks;
+ ralloc_steal(shader, shader->UniformBlocks);
+
/* Retain any live IR, but trash the rest. */
reparent_ir(shader->ir, shader->ir);