mesa: Add state and getters for the GL_ARB_uniform_buffer_object maximums.
authorEric Anholt <eric@anholt.net>
Thu, 14 Jun 2012 16:55:26 +0000 (09:55 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 21 Jun 2012 17:57:51 +0000 (10:57 -0700)
Fixes piglit GL_ARB_uniform_buffer_object/minmax.

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/main/context.c
src/mesa/main/get.c
src/mesa/main/mtypes.h

index 3bcedecd9baa1e13a100f1a91b8596eec2731011..643476b941d2892dd88171c7cbd22a773d6200d1 100644 (file)
@@ -542,6 +542,9 @@ init_program_limits(GLenum type, struct gl_program_constants *prog)
    prog->MediumInt.RangeMax = 24;
    prog->MediumInt.Precision = 0;
    prog->LowInt = prog->HighInt = prog->MediumInt;
+
+   prog->MaxUniformBlocks = 12;
+   prog->MaxCombinedUniformComponents = prog->MaxUniformComponents;
 }
 
 
@@ -653,6 +656,12 @@ _mesa_init_constants(struct gl_context *ctx)
    ctx->Const.MaxTransformFeedbackSeparateComponents = 4 * MAX_FEEDBACK_ATTRIBS;
    ctx->Const.MaxTransformFeedbackInterleavedComponents = 4 * MAX_FEEDBACK_ATTRIBS;
 
+   /** GL_ARB_uniform_buffer_object */
+   ctx->Const.MaxCombinedUniformBlocks = 36;
+   ctx->Const.MaxUniformBufferBindings = 36;
+   ctx->Const.MaxUniformBlockSize = 16384;
+   ctx->Const.UniformBufferOffsetAlignment = 1;
+
    /* GL 3.2: hard-coded for now: */
    ctx->Const.ProfileMask = GL_CONTEXT_COMPATIBILITY_PROFILE_BIT;
 
index 8dc47306f90516d8f29720bccbec0e37e8f2aec1..4ac3689ae4affb012a669e7fe3651c2ad91fb7b9 100644 (file)
@@ -289,6 +289,12 @@ static const int extra_ARB_sampler_objects[] = {
    EXTRA_END
 };
 
+static const int extra_ARB_uniform_buffer_object_and_geometry_shader[] = {
+   EXT(ARB_uniform_buffer_object),
+   EXT(ARB_geometry_shader4),
+   EXTRA_END
+};
+
 
 EXTRA_EXT(ARB_ES2_compatibility);
 EXTRA_EXT(ARB_texture_cube_map);
@@ -335,6 +341,7 @@ EXTRA_EXT(EXT_framebuffer_sRGB);
 EXTRA_EXT(ARB_texture_buffer_object);
 EXTRA_EXT(OES_EGL_image_external);
 EXTRA_EXT(ARB_blend_func_extended);
+EXTRA_EXT(ARB_uniform_buffer_object);
 
 static const int
 extra_ARB_vertex_program_ARB_fragment_program_NV_vertex_program[] = {
@@ -1321,6 +1328,29 @@ static const struct value_desc values[] = {
 
    { GL_MAX_DUAL_SOURCE_DRAW_BUFFERS, CONTEXT_INT(Const.MaxDualSourceDrawBuffers), extra_ARB_blend_func_extended },
 
+   /* GL_ARB_uniform_buffer_object */
+   { GL_MAX_VERTEX_UNIFORM_BLOCKS, CONTEXT_INT(Const.VertexProgram.MaxUniformBlocks),
+     extra_ARB_uniform_buffer_object },
+   { GL_MAX_FRAGMENT_UNIFORM_BLOCKS, CONTEXT_INT(Const.FragmentProgram.MaxUniformBlocks),
+     extra_ARB_uniform_buffer_object },
+   { GL_MAX_GEOMETRY_UNIFORM_BLOCKS, CONTEXT_INT(Const.GeometryProgram.MaxUniformBlocks),
+     extra_ARB_uniform_buffer_object_and_geometry_shader },
+   { GL_MAX_COMBINED_UNIFORM_BLOCKS, CONTEXT_INT(Const.MaxCombinedUniformBlocks),
+     extra_ARB_uniform_buffer_object },
+   { GL_MAX_UNIFORM_BLOCK_SIZE, CONTEXT_INT(Const.MaxUniformBlockSize),
+     extra_ARB_uniform_buffer_object },
+   { GL_MAX_UNIFORM_BUFFER_BINDINGS, CONTEXT_INT(Const.MaxUniformBufferBindings),
+     extra_ARB_uniform_buffer_object },
+
+   { GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS, CONTEXT_INT(Const.VertexProgram.MaxCombinedUniformComponents),
+     extra_ARB_uniform_buffer_object },
+   { GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS, CONTEXT_INT(Const.FragmentProgram.MaxCombinedUniformComponents),
+     extra_ARB_uniform_buffer_object },
+   { GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS, CONTEXT_INT(Const.GeometryProgram.MaxCombinedUniformComponents),
+     extra_ARB_uniform_buffer_object_and_geometry_shader },
+   { GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, CONTEXT_INT(Const.UniformBufferOffsetAlignment),
+     extra_ARB_uniform_buffer_object },
+
 #endif /* FEATURE_GL */
 };
 
index d52ab151aa4c538c919c432b394f28956bfd73a7..53e52807d95d0d3d5bd8a839f33c112cbfeba91b 100644 (file)
@@ -2709,6 +2709,9 @@ struct gl_program_constants
    /* ES 2.0 and GL_ARB_ES2_compatibility */
    struct gl_precision LowFloat, MediumFloat, HighFloat;
    struct gl_precision LowInt, MediumInt, HighInt;
+   /* GL_ARB_uniform_buffer_object */
+   GLuint MaxUniformBlocks;
+   GLuint MaxCombinedUniformComponents;
 };
 
 
@@ -2774,6 +2777,15 @@ struct gl_constants
    GLuint MaxVertexVaryingComponents;   /**< Between vert and geom shader */
    GLuint MaxGeometryVaryingComponents; /**< Between geom and frag shader */
 
+   /** @{
+    * GL_ARB_uniform_buffer_object
+    */
+   GLuint MaxCombinedUniformBlocks;
+   GLuint MaxUniformBufferBindings;
+   GLuint MaxUniformBlockSize;
+   GLuint UniformBufferOffsetAlignment;
+   /** @} */
+
    /** GL_ARB_geometry_shader4 */
    GLuint MaxGeometryOutputVertices;
    GLuint MaxGeometryTotalOutputComponents;