Eric Anholt | 21 Jul 2012 00:33
Gravatar

Last big core UBO support dump.

I've managed to get the lowering pass working sufficiently to get the same set
of tests passing on i965, and the problems seem tractable enough to go with
that.  I'm hoping to finish up UBOs by the end of the month.  Here are my
remaining core changes other than that lowering pass.

There are a couple of oglconform failures related to the core support that I
haven't dealt with yet.  It expects to be able to declare a structure type
without declaring a variable.  I need to spend a bit more time with the spec,
and maybe just some experimenting on other drivers, to see if this is correct.
Also, it complains about the offset of variable 13 in one of the awful
make-random-variables-in-a-uniform-block tests.  We also don't check block
size against limits yet, but it's not in an oglconform or piglit test currently.

As usual, the WIP stuff is in the "ubo" branch of my mesa tree.
Eric Anholt | 21 Jul 2012 00:33
Gravatar

[PATCH 03/11] mesa: Add support for glUniformBlockBinding() and the API to get it back.

Fixes piglit ARB_uniform_buffer_object/uniformbufferbinding.
---
 src/mesa/main/uniforms.c |   95 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)

diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index ccbd753..940cb07 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
 <at>  <at>  -41,6 +41,7  <at>  <at> 
 #include "main/shaderapi.h"
 #include "main/shaderobj.h"
 #include "main/uniforms.h"
+#include "main/enums.h"
 #include "ir_uniform.h"
 #include "glsl_types.h"

 <at>  <at>  -583,6 +584,98  <at>  <at>  _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) {
(Continue reading)

Kenneth Graunke | 31 Jul 2012 10:16

Re: [PATCH 03/11] mesa: Add support for glUniformBlockBinding() and the API to get it back.

On 07/20/2012 03:33 PM, Eric Anholt wrote:
> Fixes piglit ARB_uniform_buffer_object/uniformbufferbinding.
> ---
>  src/mesa/main/uniforms.c |   95 ++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 95 insertions(+)
> 
> diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
> index ccbd753..940cb07 100644
> --- a/src/mesa/main/uniforms.c
> +++ b/src/mesa/main/uniforms.c
>  <at>  <at>  -41,6 +41,7  <at>  <at> 
>  #include "main/shaderapi.h"
>  #include "main/shaderobj.h"
>  #include "main/uniforms.h"
> +#include "main/enums.h"
>  #include "ir_uniform.h"
>  #include "glsl_types.h"
>  
>  <at>  <at>  -583,6 +584,98  <at>  <at>  _mesa_GetUniformIndices(GLuint program,
>     }
>  }
>  
> +static void GLAPIENTRY
> +_mesa_UniformBlockBinding(GLuint program,
> +			  GLuint uniformBlockIndex,
> +			  GLuint uniformBlockBinding)
> +{
> +   GET_CURRENT_CONTEXT(ctx);
> +   struct gl_shader_program *shProg;
> +
(Continue reading)

Eric Anholt | 31 Jul 2012 19:28
Gravatar

Re: [PATCH 03/11] mesa: Add support for glUniformBlockBinding() and the API to get it back.

Kenneth Graunke <kenneth <at> whitecape.org> writes:

> On 07/20/2012 03:33 PM, Eric Anholt wrote:
>> Fixes piglit ARB_uniform_buffer_object/uniformbufferbinding.
>> ---
>>  src/mesa/main/uniforms.c |   95 ++++++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 95 insertions(+)
>> 
>> diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
>> index ccbd753..940cb07 100644
>> --- a/src/mesa/main/uniforms.c
>> +++ b/src/mesa/main/uniforms.c
>>  <at>  <at>  -41,6 +41,7  <at>  <at> 
>>  #include "main/shaderapi.h"
>>  #include "main/shaderobj.h"
>>  #include "main/uniforms.h"
>> +#include "main/enums.h"
>>  #include "ir_uniform.h"
>>  #include "glsl_types.h"
>>  
>>  <at>  <at>  -583,6 +584,98  <at>  <at>  _mesa_GetUniformIndices(GLuint program,
>>     }
>>  }
>>  
>> +static void GLAPIENTRY
>> +_mesa_UniformBlockBinding(GLuint program,
>> +			  GLuint uniformBlockIndex,
>> +			  GLuint uniformBlockBinding)
>> +{
>> +   GET_CURRENT_CONTEXT(ctx);
(Continue reading)

Eric Anholt | 21 Jul 2012 00:33
Gravatar

[PATCH 01/11] mesa: Add support for glGetProgramiv pnames for UBOs.

Fixes piglit ARB_uniform_buffer_object/getprogramiv.
---
 src/mesa/main/shaderapi.c |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 6927368..f381915 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
 <at>  <at>  -542,6 +542,25  <at>  <at>  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;
+
+      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:
(Continue reading)

Brian Paul | 21 Jul 2012 00:44
Favicon

Re: [PATCH 01/11] mesa: Add support for glGetProgramiv pnames for UBOs.

On 07/20/2012 04:33 PM, Eric Anholt wrote:
> Fixes piglit ARB_uniform_buffer_object/getprogramiv.
> ---
>   src/mesa/main/shaderapi.c |   19 +++++++++++++++++++
>   1 file changed, 19 insertions(+)
>
> diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
> index 6927368..f381915 100644
> --- a/src/mesa/main/shaderapi.c
> +++ b/src/mesa/main/shaderapi.c
>  <at>  <at>  -542,6 +542,25  <at>  <at>  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;
> +
> +      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;
> +   }
(Continue reading)

Eric Anholt | 26 Jul 2012 18:24
Gravatar

[PATCH] mesa: Add support for glGetProgramiv pnames for UBOs.

Fixes piglit ARB_uniform_buffer_object/getprogramiv.

v2: Add extension checks.
---

Since there were only two cases, I didn't use goto on this patch.

 src/mesa/main/shaderapi.c |   29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 7c97a63..9926c08 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
 <at>  <at>  -544,6 +544,35  <at>  <at>  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: {
+      if (!ctx->Extensions.ARB_uniform_buffer_object) {
+         _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname)");
+         return;
+      }
+
+      unsigned i;
+      GLint max_len = 0;
+
+      for (i = 0; i < shProg->NumUniformBlocks; i++) {
+	 /* Add one for the terminating NUL character.
+	  */
(Continue reading)

Brian Paul | 26 Jul 2012 18:26
Favicon

Re: [PATCH] mesa: Add support for glGetProgramiv pnames for UBOs.

On 07/26/2012 10:24 AM, Eric Anholt wrote:
> Fixes piglit ARB_uniform_buffer_object/getprogramiv.
>
> v2: Add extension checks.
> ---
>
> Since there were only two cases, I didn't use goto on this patch.
>
>   src/mesa/main/shaderapi.c |   29 +++++++++++++++++++++++++++++
>   1 file changed, 29 insertions(+)
>
> diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
> index 7c97a63..9926c08 100644
> --- a/src/mesa/main/shaderapi.c
> +++ b/src/mesa/main/shaderapi.c
>  <at>  <at>  -544,6 +544,35  <at>  <at>  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: {
> +      if (!ctx->Extensions.ARB_uniform_buffer_object) {
> +         _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname)");
> +         return;
> +      }
> +
> +      unsigned i;
> +      GLint max_len = 0;

Declarations after code will blow up with MSVC.

(Continue reading)

Eric Anholt | 26 Jul 2012 19:02
Gravatar

Re: [PATCH] mesa: Add support for glGetProgramiv pnames for UBOs.

Brian Paul <brianp <at> vmware.com> writes:

> On 07/26/2012 10:24 AM, Eric Anholt wrote:
>> Fixes piglit ARB_uniform_buffer_object/getprogramiv.
>>
>> v2: Add extension checks.
>> ---
>>
>> Since there were only two cases, I didn't use goto on this patch.
>>
>>   src/mesa/main/shaderapi.c |   29 +++++++++++++++++++++++++++++
>>   1 file changed, 29 insertions(+)
>>
>> diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
>> index 7c97a63..9926c08 100644
>> --- a/src/mesa/main/shaderapi.c
>> +++ b/src/mesa/main/shaderapi.c
>>  <at>  <at>  -544,6 +544,35  <at>  <at>  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: {
>> +      if (!ctx->Extensions.ARB_uniform_buffer_object) {
>> +         _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname)");
>> +         return;
>> +      }
>> +
>> +      unsigned i;
>> +      GLint max_len = 0;
>
(Continue reading)

Eric Anholt | 21 Jul 2012 00:33
Gravatar

[PATCH 04/11] mesa: Add support for getting active uniform block names.

Fixes piglit ARB_uniform_buffer_object/getactiveuniformblockname.
---
 src/mesa/main/uniforms.c |   47 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index 940cb07..3236d6e 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
 <at>  <at>  -668,6 +668,10  <at>  <at>  _mesa_GetActiveUniformBlockiv(GLuint program,
       params[0] = block->Binding;
       return;

+   case GL_UNIFORM_BLOCK_NAME_LENGTH:
+      params[0] = strlen(block->Name) + 1;
+      return;
+
    default:
       _mesa_error(ctx, GL_INVALID_ENUM,
 		  "glGetActiveUniformBlockiv(pname 0x%x (%s))",
 <at>  <at>  -676,6 +680,48  <at>  <at>  _mesa_GetActiveUniformBlockiv(GLuint program,
    }
 }

+static void GLAPIENTRY
+_mesa_GetActiveUniformBlockName(GLuint program,
+				GLuint uniformBlockIndex,
+				GLsizei bufSize,
+				GLsizei *length,
+				GLchar *uniformBlockName)
(Continue reading)

Eric Anholt | 21 Jul 2012 00:33
Gravatar

[PATCH 05/11] mesa: Add support for most of the other pnames of glGetActiveUniformBlockiv().

---
 src/mesa/main/uniforms.c |   30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index 3236d6e..6652251 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
 <at>  <at>  -643,6 +643,7  <at>  <at>  _mesa_GetActiveUniformBlockiv(GLuint program,
    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");
 <at>  <at>  -668,10 +669,39  <at>  <at>  _mesa_GetActiveUniformBlockiv(GLuint program,
       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;
(Continue reading)

Eric Anholt | 21 Jul 2012 00:33
Gravatar

[PATCH 02/11] glsl: Incorporate all UBO language changes into GLSL 1.40.

---
 src/glsl/glsl_parser.yy |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index b2533c8..0ed424d 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
 <at>  <at>  -291,6 +291,10  <at>  <at>  version_statement:
 			       state->version_string,
 			       state->supported_version_string);
 	   }
+
+	   if (state->language_version >= 140) {
+	      state->ARB_uniform_buffer_object_enable = true;
+	   }
 	}
 	;

--

-- 
1.7.10.4
Ian Romanick | 21 Jul 2012 01:13

Re: [PATCH 02/11] glsl: Incorporate all UBO language changes into GLSL 1.40.

On 07/20/2012 03:33 PM, Eric Anholt wrote:
> ---
>   src/glsl/glsl_parser.yy |    4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
> index b2533c8..0ed424d 100644
> --- a/src/glsl/glsl_parser.yy
> +++ b/src/glsl/glsl_parser.yy
>  <at>  <at>  -291,6 +291,10  <at>  <at>  version_statement:
>   			       state->version_string,
>   			       state->supported_version_string);
>   	   }
> +
> +	   if (state->language_version >= 140) {
> +	      state->ARB_uniform_buffer_object_enable = true;
> +	   }

Do we need something to prevent

#extension GL_ARB_uniform_buffer_object: disable

from making dumb things happen?

>   	}
>   	;
>
>
Eric Anholt | 23 Jul 2012 18:03
Gravatar

Re: [PATCH 02/11] glsl: Incorporate all UBO language changes into GLSL 1.40.

Ian Romanick <idr <at> freedesktop.org> writes:

> On 07/20/2012 03:33 PM, Eric Anholt wrote:
>> ---
>>   src/glsl/glsl_parser.yy |    4 ++++
>>   1 file changed, 4 insertions(+)
>>
>> diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
>> index b2533c8..0ed424d 100644
>> --- a/src/glsl/glsl_parser.yy
>> +++ b/src/glsl/glsl_parser.yy
>>  <at>  <at>  -291,6 +291,10  <at>  <at>  version_statement:
>>   			       state->version_string,
>>   			       state->supported_version_string);
>>   	   }
>> +
>> +	   if (state->language_version >= 140) {
>> +	      state->ARB_uniform_buffer_object_enable = true;
>> +	   }
>
> Do we need something to prevent
>
> #extension GL_ARB_uniform_buffer_object: disable
>
> from making dumb things happen?

I had thought about that briefly, and decided that if you really go out
of your way to do that, the behavior you end up with is probably sort of
like what you meant, but seriously what were you thinking?
(Continue reading)

Eric Anholt | 21 Jul 2012 00:33
Gravatar

[PATCH 08/11] glsl: Add support for default layout qualifiers for uniforms.

I ended up having to add rallocing of the ast_type_qualifier in order
to avoid pulling in ast.h for glsl_parser_extras.h, because I wanted
to track an ast_type_qualifier in the state.

Fixes piglit ARB_uniform_buffer_object/row-major.
---
 src/glsl/ast.h                  |   23 ++++++++++++++++
 src/glsl/ast_type.cpp           |   45 ++++++++++++++++++++++++++++++
 src/glsl/glsl_parser.yy         |   58 ++++++++++++++-------------------------
 src/glsl/glsl_parser_extras.cpp |    4 +++
 src/glsl/glsl_parser_extras.h   |    7 +++++
 5 files changed, 99 insertions(+), 38 deletions(-)

diff --git a/src/glsl/ast.h b/src/glsl/ast.h
index de3f2df..5074782 100644
--- a/src/glsl/ast.h
+++ b/src/glsl/ast.h
 <at>  <at>  -338,6 +338,25  <at>  <at>  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);
+
(Continue reading)

Eric Anholt | 21 Jul 2012 00:33
Gravatar

[PATCH 06/11] mesa: Add support for GL_ARB_ubo's glGetActiveUniformName().

This is like a stripped-down version of glGetActiveUniform that just
returns the name, since the other return values (type and size) of
that function are now meant to be handled with
glGetActiveUniformsiv().

Fixes piglit ARB_uniform_buffer_object/getactiveuniformname
---
 src/mesa/main/uniforms.c |   39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index 6652251..b5aaa1b 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
 <at>  <at>  -752,6 +752,44  <at>  <at>  _mesa_GetActiveUniformBlockName(GLuint program,
    }
 }

+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;
+   }
(Continue reading)

Eric Anholt | 21 Jul 2012 00:33
Gravatar

[PATCH 09/11] glsl: Assign array and matrix stride values according to std140 layout.

---
 src/glsl/link_uniforms.cpp |   19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index d7ef5d4..1baa46c 100644
--- a/src/glsl/link_uniforms.cpp
+++ b/src/glsl/link_uniforms.cpp
 <at>  <at>  -328,10 +328,21  <at>  <at>  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;
(Continue reading)

Eric Anholt | 21 Jul 2012 00:33
Gravatar

[PATCH 07/11] glsl: Merge UBO layout qualifiers in a qualifier list.

Yes, you get to say things like "layout(row_major, column_major)" and
get column major.

Part of fixing piglit ARB_uniform_buffer_object/row_major.
---
 src/glsl/glsl_parser.yy |   24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 0ed424d..2787721 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
 <at>  <at>  -1106,13 +1106,35  <at>  <at>  layout_qualifier_id_list:
 	layout_qualifier_id
 	| layout_qualifier_id_list ',' layout_qualifier_id
 	{
-	   if (($1.flags.i & $3.flags.i) != 0) {
+	   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
(Continue reading)

Eric Anholt | 21 Jul 2012 00:33
Gravatar

[PATCH 10/11] mesa: Return -1 for glGetUniformLocation on UBOs.

Fixes piglit ARB_uniform_buffer_object/getuniformlocation.
---
 src/mesa/main/uniforms.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index b5aaa1b..f43d0fb 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
 <at>  <at>  -522,6 +522,16  <at>  <at>  _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);
 }

--

-- 
1.7.10.4
Eric Anholt | 21 Jul 2012 00:33
Gravatar

[PATCH 11/11] glsl: Reject linking shaders with too many uniform blocks.

Part of fixing piglit maxblocks.
---
 src/glsl/linker.cpp |   34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index bfdde40..f4e578f 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
 <at>  <at>  -2324,6 +2324,12  <at>  <at>  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];

 <at>  <at>  -2348,6 +2354,34  <at>  <at>  check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
       }
    }

+   unsigned blocks[] = {0, 0, 0};
+   unsigned total_uniform_blocks = 0;
+
+   for (unsigned i = 0; i < prog->NumUniformBlocks; i++) {
(Continue reading)

Brian Paul | 21 Jul 2012 00:49
Favicon

Re: [PATCH 11/11] glsl: Reject linking shaders with too many uniform blocks.

On 07/20/2012 04:33 PM, Eric Anholt wrote:
> Part of fixing piglit maxblocks.
> ---
>   src/glsl/linker.cpp |   34 ++++++++++++++++++++++++++++++++++
>   1 file changed, 34 insertions(+)
>
> diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
> index bfdde40..f4e578f 100644
> --- a/src/glsl/linker.cpp
> +++ b/src/glsl/linker.cpp
>  <at>  <at>  -2324,6 +2324,12  <at>  <at>  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];
>
>  <at>  <at>  -2348,6 +2354,34  <at>  <at>  check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
>         }
>      }
>
> +   unsigned blocks[] = {0, 0, 0};

Should that be:
(Continue reading)

Ian Romanick | 21 Jul 2012 01:15

Re: [PATCH 11/11] glsl: Reject linking shaders with too many uniform blocks.

On 07/20/2012 03:49 PM, Brian Paul wrote:
> On 07/20/2012 04:33 PM, Eric Anholt wrote:
>> Part of fixing piglit maxblocks.
>> ---
>>   src/glsl/linker.cpp |   34 ++++++++++++++++++++++++++++++++++
>>   1 file changed, 34 insertions(+)
>>
>> diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
>> index bfdde40..f4e578f 100644
>> --- a/src/glsl/linker.cpp
>> +++ b/src/glsl/linker.cpp
>>  <at>  <at>  -2324,6 +2324,12  <at>  <at>  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];
>>
>>  <at>  <at>  -2348,6 +2354,34  <at>  <at>  check_resources(struct gl_context *ctx, struct
>> gl_shader_program *prog)
>>         }
>>      }
>>
(Continue reading)

Eric Anholt | 26 Jul 2012 18:17
Gravatar

Re: [PATCH 11/11] glsl: Reject linking shaders with too many uniform blocks.

Brian Paul <brianp <at> vmware.com> writes:

> On 07/20/2012 04:33 PM, Eric Anholt wrote:
>> Part of fixing piglit maxblocks.
>> ---
>>   src/glsl/linker.cpp |   34 ++++++++++++++++++++++++++++++++++
>>   1 file changed, 34 insertions(+)
>>
>> diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
>> index bfdde40..f4e578f 100644
>> --- a/src/glsl/linker.cpp
>> +++ b/src/glsl/linker.cpp
>>  <at>  <at>  -2324,6 +2324,12  <at>  <at>  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];
>>
>>  <at>  <at>  -2348,6 +2354,34  <at>  <at>  check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
>>         }
>>      }
>>
>> +   unsigned blocks[] = {0, 0, 0};
(Continue reading)

Brian Paul | 26 Jul 2012 18:27
Favicon

Re: [PATCH 11/11] glsl: Reject linking shaders with too many uniform blocks.

On 07/26/2012 10:17 AM, Eric Anholt wrote:
> Brian Paul<brianp <at> vmware.com>  writes:
>
>> On 07/20/2012 04:33 PM, Eric Anholt wrote:
>>> Part of fixing piglit maxblocks.
>>> ---
>>>    src/glsl/linker.cpp |   34 ++++++++++++++++++++++++++++++++++
>>>    1 file changed, 34 insertions(+)
>>>
>>> diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
>>> index bfdde40..f4e578f 100644
>>> --- a/src/glsl/linker.cpp
>>> +++ b/src/glsl/linker.cpp
>>>  <at>  <at>  -2324,6 +2324,12  <at>  <at>  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];
>>>
>>>  <at>  <at>  -2348,6 +2354,34  <at>  <at>  check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
>>>          }
>>>       }
>>>
(Continue reading)


Gmane