[Mesa-dev] [PATCH 3/6] glcpp: Test a non-function-like macro using the token paste operator

2011-09-30 Thread Carl Worth
Apparently we never implemented this, (but we've got a GLSL 1.30 test
in piglit that is exercising this case).
---
 .../tests/097-paste-with-non-function-macro.c  |3 +++
 .../097-paste-with-non-function-macro.c.expected   |4 
 2 files changed, 7 insertions(+), 0 deletions(-)
 create mode 100644 src/glsl/glcpp/tests/097-paste-with-non-function-macro.c
 create mode 100644 
src/glsl/glcpp/tests/097-paste-with-non-function-macro.c.expected

diff --git a/src/glsl/glcpp/tests/097-paste-with-non-function-macro.c 
b/src/glsl/glcpp/tests/097-paste-with-non-function-macro.c
new file mode 100644
index 000..0f46835
--- /dev/null
+++ b/src/glsl/glcpp/tests/097-paste-with-non-function-macro.c
@@ -0,0 +1,3 @@
+#define PASTE_MACRO one ## token
+PASTE_MACRO
+
diff --git a/src/glsl/glcpp/tests/097-paste-with-non-function-macro.c.expected 
b/src/glsl/glcpp/tests/097-paste-with-non-function-macro.c.expected
new file mode 100644
index 000..af92187
--- /dev/null
+++ b/src/glsl/glcpp/tests/097-paste-with-non-function-macro.c.expected
@@ -0,0 +1,4 @@
+
+onetoken
+
+
-- 
1.7.6.3

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] A few fixes for the preprocessor for GLSL 1.30

2011-09-30 Thread Carl Worth
Eric recentl mentioned to me that when setting the following
environment variables with current master mesa:

MESA_GL_VERSION_OVERRIDE=3.0
MESA_GLSL_VERSION_OVERRIDE=130

that 8 piglit preprocessor tests start to fail.

I've investigated all of these failures and am here attaching a patch
series for review that fixes 5 of them. In the testing I've done, I
don't see any changes from this patch series other than the desired
piglit fixes. But, of course, I'd be happy for any review.

For the remaining three failures, I believe the tests themselves are
broken and should be fixed. These fall into two case:

1. feature-macros/gl_gragment_precision_high.{frag,vert}

   In these tests, the actual preprocessor functionality being tested,
   (that a directive of #version 130 causes the
   GL_FRAGMENT_PRECISION_HIGH macro to be pre-defined), is working fine.

   The tests are failing due to the following code:

float f() { return 0; }

   Our implementation does not currently do implicit promotion here,
   so compilation fails with a type error:

error: `return' with wrong type int, in function `f' returning
float

   The GLSL specification is not explicit on whether this promotion
   should be happening, but other implementations appear to do it. So
   perhaps the promotion should be added to our implementation.

   Meanwhile, the test could legitimately be fixed to remove the type
   error which is a side issue from what the test is actually trying
   to do.

2. if/if-arg-must-be-defined-02.frag

   This test is trying to elicit an undefined macro error with
   something like the following code:

#if 1
...
#elif UNDEFINED_MACRO
...
#endif

   I propose changing the test to use #if 0 instead, in which case
   the current implementation would pass. It's not actually desirable
   to generate an error in the above case. Consider a use of a
   possibly undefined macro:

#if PERHAPS_UNDEFINED  5
...
#endif

   In order to protect this use, the user might add something like the
   following (or similar with #ifndef):

#if ! defined PERHAPS_UNDEFINED
... deal with it ...
#elif PERHAPS_UNDEFINED
...
#endif

   In this case, the user's expectation is to get no error with this
   code. Yet this is precisly the formulation the current test case
   uses to elicit the error.

I'll be glad to push changes to piglit to fix these cases unless
someone can argue aginst that.

Thanks,

-Carl
-- 
carl.d.wo...@intel.com

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 6/6] glcpp: Add a test for #elif with an undefined macro.

2011-09-30 Thread Carl Worth
As written, this test correctly raises an error for #elif being used
with an undefined macro (and not as an argument to defined). If the
preceding #if were '#if 1' then this diagnositc would correctly be
hidden. That allows code such as the following to not raise an error:

#ifndef MAYBE_UNDEFINED
#elif MAYBE_UNDEFINED  5
...
#endif

So this test case is working as expected already. We add it here just
to improve test coverage.
---
 src/glsl/glcpp/tests/098-elif-undefined.c  |3 +++
 src/glsl/glcpp/tests/098-elif-undefined.c.expected |5 +
 2 files changed, 8 insertions(+), 0 deletions(-)
 create mode 100644 src/glsl/glcpp/tests/098-elif-undefined.c
 create mode 100644 src/glsl/glcpp/tests/098-elif-undefined.c.expected

diff --git a/src/glsl/glcpp/tests/098-elif-undefined.c 
b/src/glsl/glcpp/tests/098-elif-undefined.c
new file mode 100644
index 000..52a331c
--- /dev/null
+++ b/src/glsl/glcpp/tests/098-elif-undefined.c
@@ -0,0 +1,3 @@
+#if 0
+#elif UNDEFINED_MACRO
+#endif
diff --git a/src/glsl/glcpp/tests/098-elif-undefined.c.expected 
b/src/glsl/glcpp/tests/098-elif-undefined.c.expected
new file mode 100644
index 000..de967ea
--- /dev/null
+++ b/src/glsl/glcpp/tests/098-elif-undefined.c.expected
@@ -0,0 +1,5 @@
+0:2(22): preprocessor error: syntax error, unexpected IDENTIFIER
+0:1(7): preprocessor error: Unterminated #if
+
+
+
-- 
1.7.6.3

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 5/6] glcpp: Raise error if defining any macro containing two consecutive underscores

2011-09-30 Thread Carl Worth
The specification reserves any macro name containing two consecutive
underscores, (anywhere within the name). Previously, we only raised
this error for macro names that started with two underscores.

Fix the implementation to check for two underscores anywhere, and also
update the corresponding 086-reserved-macro-names test.

This also fixes the following two piglit tests:

spec/glsl-1.30/preprocessor/reserved/double-underscore-02.frag
spec/glsl-1.30/preprocessor/reserved/double-underscore-03.frag
---
 src/glsl/glcpp/glcpp-parse.y   |4 ++--
 src/glsl/glcpp/tests/086-reserved-macro-names.c|1 +
 .../tests/086-reserved-macro-names.c.expected  |5 -
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index ff9fa7a..17941a9 100644
--- a/src/glsl/glcpp/glcpp-parse.y
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -1663,8 +1663,8 @@ _check_for_reserved_macro_name (glcpp_parser_t *parser, 
YYLTYPE *loc,
/* According to the GLSL specification, macro names starting with __
 * or GL_ are reserved for future use.  So, don't allow them.
 */
-   if (strncmp(identifier, __, 2) == 0) {
-   glcpp_error (loc, parser, Macro names starting with \__\ are 
reserved.\n);
+   if (strstr(identifier, __)) {
+   glcpp_error (loc, parser, Macro names containing \__\ are 
reserved.\n);
}
if (strncmp(identifier, GL_, 3) == 0) {
glcpp_error (loc, parser, Macro names starting with \GL_\ 
are reserved.\n);
diff --git a/src/glsl/glcpp/tests/086-reserved-macro-names.c 
b/src/glsl/glcpp/tests/086-reserved-macro-names.c
index fd0c29f..a6b7201 100644
--- a/src/glsl/glcpp/tests/086-reserved-macro-names.c
+++ b/src/glsl/glcpp/tests/086-reserved-macro-names.c
@@ -1,2 +1,3 @@
 #define __BAD reserved
 #define GL_ALSO_BAD() also reserved
+#define THIS__TOO__IS__BAD reserved
diff --git a/src/glsl/glcpp/tests/086-reserved-macro-names.c.expected 
b/src/glsl/glcpp/tests/086-reserved-macro-names.c.expected
index 6a9df68..d8aa9f0 100644
--- a/src/glsl/glcpp/tests/086-reserved-macro-names.c.expected
+++ b/src/glsl/glcpp/tests/086-reserved-macro-names.c.expected
@@ -1,7 +1,10 @@
-0:1(10): preprocessor error: Macro names starting with __ are reserved.
+0:1(10): preprocessor error: Macro names containing __ are reserved.
 
 0:2(9): preprocessor error: Macro names starting with GL_ are reserved.
 
+0:3(9): preprocessor error: Macro names containing __ are reserved.
+
+
 
 
 
-- 
1.7.6.3

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] i965 Gen6: Implement gl_ClipVertex.

2011-09-30 Thread Kenneth Graunke
On 09/27/2011 11:05 AM, Paul Berry wrote:
 This patch implements proper support for gl_ClipVertex by causing the
 new VS backend to populate the clip distance VUE slots using
 VERT_RESULT_CLIP_VERTEX when appropriate, and by using the
 untransformed clip planes in ctx-Transform.EyeUserPlane rather than
 the transformed clip planes in ctx-Transform._ClipUserPlane.
 
 When fixed functionality is in use the driver needs to do the old
 behavior (clip based on VERT_RESULT_HPOS and
 ctx-Transform._ClipUserPlane).  This happens automatically because we
 use the old VS backend for fixed functionality.
 
 Fixes the following Piglit tests on i965 Gen6:
 - vs-clip-vertex-const-accept
 - vs-clip-vertex-const-reject
 - vs-clip-vertex-different-from-position
 - vs-clip-vertex-equal-to-position
 - vs-clip-vertex-homogeneity
 - vs-clip-based-on-position
 - vs-clip-based-on-position-homogeneity
 - clip-plane-transformation clipvert_pos
 - clip-plane-transformation pos_clipvert
 - clip-plane-transformation pos
 ---
  src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp |   31 ++-
  src/mesa/drivers/dri/i965/brw_vs.c |8 +-
  2 files changed, 36 insertions(+), 3 deletions(-)
 
 diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp 
 b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
 index e5eda22..f335a86 100644
 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
 +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
 @@ -553,7 +553,16 @@ vec4_visitor::setup_uniform_clipplane_values()
   this-userplane[compacted_clipplane_index] = dst_reg(UNIFORM, 
 this-uniforms);
   this-userplane[compacted_clipplane_index].type = 
 BRW_REGISTER_TYPE_F;
   for (int j = 0; j  4; ++j) {
 -c-prog_data.param[this-uniforms * 4 + j] = 
 ctx-Transform._ClipUserPlane[i][j];
 +/* For fixed functionality shaders, we need to clip based on
 + * ctx-Transform._ClipUserPlane (which has been transformed by
 + * Mesa core into clip coordinates).  For user-supplied vertex
 + * shaders, we need to use the untransformed clip planes in
 + * ctx-Transform.EyeUserPlane.  Since vec4_visitor is currently
 + * only used for user-supplied vertex shaders, we can hardcode
 + * this to EyeUserPlane for now.
 + */
 +c-prog_data.param[this-uniforms * 4 + j]
 +   = ctx-Transform.EyeUserPlane[i][j];

So, we trade support for fixed function clipping for gl_ClipVertex
clipping?  That seems really unfortunate.  I know we don't use the new
VS backend for fixed function today, but we will.

Couldn't you just do:
const bool clip_vertex = c-prog_data.outputs_written 
BITFIELD64_BIT(VERT_RESULT_CLIP_VERTEX);

c-prog_data.param[this-uniforms * 4 + j] =
   clip_vertex ? ctx-Transform.EyeUserPlane[i][j]
   : ctx-Transform._ClipUserPlane[i][j];

...or is outputs_written not available at this point in time?

Yeah, I know it's untested, and untested code = broken code, and all
that, but...if you already know what you need to do...why not just do it?

   }
   ++compacted_clipplane_index;
   ++this-uniforms;
 @@ -1840,9 +1849,27 @@ vec4_visitor::emit_clip_distances(struct brw_reg reg, 
 int offset)
return;
 }
  
 +   /* From the GLSL 1.30 spec, section 7.1 (Vertex Shader Special Variables):
 +*
 +* If a linked set of shaders forming the vertex stage contains no
 +* static write to gl_ClipVertex or gl_ClipDistance, but the
 +* application has requested clipping against user clip planes through
 +* the API, then the coordinate written to gl_Position is used for
 +* comparison against the user clip planes.
 +*
 +* This function is only called if the shader didn't write to
 +* gl_ClipDistance.  Accordingly, we use gl_ClipVertex to perform clipping
 +* if the user wrote to it; otherwise we use gl_Position.
 +*/
 +   gl_vert_result clip_vertex = VERT_RESULT_CLIP_VERTEX;
 +   if (!(c-prog_data.outputs_written
 +  BITFIELD64_BIT(VERT_RESULT_CLIP_VERTEX))) {
 +  clip_vertex = VERT_RESULT_HPOS;
 +   }
 +
 for (int i = 0; i + offset  c-key.nr_userclip  i  4; ++i) {
emit(DP4(dst_reg(brw_writemask(reg, 1  i)),
 -   src_reg(output_reg[VERT_RESULT_HPOS]),
 +   src_reg(output_reg[clip_vertex]),
 src_reg(this-userplane[i + offset])));
 }
  }
 diff --git a/src/mesa/drivers/dri/i965/brw_vs.c 
 b/src/mesa/drivers/dri/i965/brw_vs.c
 index 93c6838..4fd260f 100644
 --- a/src/mesa/drivers/dri/i965/brw_vs.c
 +++ b/src/mesa/drivers/dri/i965/brw_vs.c
 @@ -137,11 +137,17 @@ brw_compute_vue_map(struct brw_vue_map *vue_map,
 /* The hardware doesn't care about the rest of the vertex outputs, so just
  * assign them contiguously.  Don't reassign outputs that already have a
  * slot.
 +*
 +* Also, don't assign a slot for 

[Mesa-dev] [PATCH] mesa: Respect GL_RASTERIZER_DISCARD for various meta-type operations.

2011-09-30 Thread Eric Anholt
From the EXT_transform_feedback spec:

Primitives can be optionally discarded before rasterization by calling
Enable and Disable with RASTERIZER_DISCARD_EXT. When enabled, primitives
are discared right before the rasterization stage, but after the optional
transform feedback stage. When disabled, primitives are passed through to
the rasterization stage to be processed normally. RASTERIZER_DISCARD_EXT
applies to the DrawPixels, CopyPixels, Bitmap, Clear and Accum commands as
well.

And the GL 3.2 spec says it applies to ClearBuffer* as well.
---
 src/mesa/main/accum.c   |3 +++
 src/mesa/main/clear.c   |   16 +++-
 src/mesa/main/drawpix.c |   11 +++
 3 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/src/mesa/main/accum.c b/src/mesa/main/accum.c
index 6a83930..d7ed3a8 100644
--- a/src/mesa/main/accum.c
+++ b/src/mesa/main/accum.c
@@ -97,6 +97,9 @@ _mesa_Accum( GLenum op, GLfloat value )
   return;
}
 
+   if (ctx-TransformFeedback.RasterDiscard)
+  return;
+
if (ctx-RenderMode == GL_RENDER) {
   ctx-Driver.Accum(ctx, op, value);
}
diff --git a/src/mesa/main/clear.c b/src/mesa/main/clear.c
index 301fe69..c35675f 100644
--- a/src/mesa/main/clear.c
+++ b/src/mesa/main/clear.c
@@ -200,6 +200,9 @@ _mesa_Clear( GLbitfield mask )
ctx-DrawBuffer-_Ymin = ctx-DrawBuffer-_Ymax)
   return;
 
+   if (ctx-TransformFeedback.RasterDiscard)
+  return;
+
if (ctx-RenderMode == GL_RENDER) {
   GLbitfield bufferMask;
 
@@ -328,7 +331,7 @@ _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const 
GLint *value)
  drawbuffer);
  return;
   }
-  else {
+  else if (!ctx-TransformFeedback.RasterDiscard) {
  /* Save current stencil clear value, set to 'value', do the
   * stencil clear and restore the clear value.
   * XXX in the future we may have a new ctx-Driver.ClearBuffer()
@@ -352,7 +355,7 @@ _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const 
GLint *value)
 drawbuffer);
 return;
  }
- else if (mask) {
+ else if (mask  !ctx-TransformFeedback.RasterDiscard) {
 union gl_color_union clearSave;
 
 /* save color */
@@ -403,7 +406,7 @@ _mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const 
GLuint *value)
 drawbuffer);
 return;
  }
- else if (mask) {
+ else if (mask  !ctx-TransformFeedback.RasterDiscard) {
 union gl_color_union clearSave;
 
 /* save color */
@@ -452,7 +455,7 @@ _mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const 
GLfloat *value)
  drawbuffer);
  return;
   }
-  else {
+  else if (!ctx-TransformFeedback.RasterDiscard) {
  /* Save current depth clear value, set to 'value', do the
   * depth clear and restore the clear value.
   * XXX in the future we may have a new ctx-Driver.ClearBuffer()
@@ -477,7 +480,7 @@ _mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const 
GLfloat *value)
 drawbuffer);
 return;
  }
- else if (mask) {
+ else if (mask  !ctx-TransformFeedback.RasterDiscard) {
 union gl_color_union clearSave;
 
 /* save color */
@@ -528,6 +531,9 @@ _mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer,
   return;
}
 
+   if (ctx-TransformFeedback.RasterDiscard)
+  return;
+
if (ctx-NewState) {
   _mesa_update_state( ctx );
}
diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c
index b7e2c36..412cc15 100644
--- a/src/mesa/main/drawpix.c
+++ b/src/mesa/main/drawpix.c
@@ -80,6 +80,10 @@ _mesa_DrawPixels( GLsizei width, GLsizei height,
   goto end;  /* the error code was recorded */
}
 
+   if (ctx-TransformFeedback.RasterDiscard) {
+  goto end;
+   }
+
if (!ctx-Current.RasterPosValid) {
   goto end;  /* no-op, not an error */
}
@@ -188,6 +192,10 @@ _mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, 
GLsizei height,
   goto end;
}
 
+   if (ctx-TransformFeedback.RasterDiscard) {
+  goto end;
+   }
+
if (!ctx-Current.RasterPosValid || width == 0 || height == 0) {
   goto end; /* no-op, not an error */
}
@@ -242,6 +250,9 @@ _mesa_Bitmap( GLsizei width, GLsizei height,
   return;
}
 
+   if (ctx-TransformFeedback.RasterDiscard)
+  return;
+
if (ctx-RenderMode == GL_RENDER) {
   /* Truncate, to satisfy conformance tests (matches SGI's OpenGL). */
   if (width  0  height  0) {
-- 
1.7.6.3

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] A few fixes for the preprocessor for GLSL 1.30

2011-09-30 Thread Kenneth Graunke
On 09/29/2011 11:00 PM, Carl Worth wrote:
 Eric recentl mentioned to me that when setting the following
 environment variables with current master mesa:
 
   MESA_GL_VERSION_OVERRIDE=3.0
   MESA_GLSL_VERSION_OVERRIDE=130
 
 that 8 piglit preprocessor tests start to fail.
 
 I've investigated all of these failures and am here attaching a patch
 series for review that fixes 5 of them. In the testing I've done, I
 don't see any changes from this patch series other than the desired
 piglit fixes. But, of course, I'd be happy for any review.

For the series:
Reviewed-by: Kenneth Graunke kenn...@whitecape.org

Thanks for fixing these, Carl!

 For the remaining three failures, I believe the tests themselves are
 broken and should be fixed. These fall into two case:
 
 1. feature-macros/gl_gragment_precision_high.{frag,vert}
 
In these tests, the actual preprocessor functionality being tested,
(that a directive of #version 130 causes the
GL_FRAGMENT_PRECISION_HIGH macro to be pre-defined), is working fine.
 
The tests are failing due to the following code:
 
   float f() { return 0; }
 
Our implementation does not currently do implicit promotion here,
so compilation fails with a type error:
 
   error: `return' with wrong type int, in function `f' returning
   float
 
The GLSL specification is not explicit on whether this promotion
should be happening, but other implementations appear to do it. So
perhaps the promotion should be added to our implementation.

Odd.  I could've sworn that was allowed (it would make sense), but
you're right: the spec never explicitly allows that, so strictly, it's
forbidden.

GLSL 4.20 and the GL_ARB_shading_language_420pack extension explicitly
add this functionality to the shading language, so we can add it then.

I guess we could technically add GL_ARB_shading_language_420pack support
now, since it only requires GLSL 1.30...it's essentially an extension
that backports some new front-end functionality and clarifications to
older versions of GLSL.

In any case, I'm in favor of changing the test to 0.0 instead of 0.

Meanwhile, the test could legitimately be fixed to remove the type
error which is a side issue from what the test is actually trying
to do.
 
 2. if/if-arg-must-be-defined-02.frag
 
This test is trying to elicit an undefined macro error with
something like the following code:
 
   #if 1
   ...
   #elif UNDEFINED_MACRO
   ...
   #endif
 
I propose changing the test to use #if 0 instead, in which case
the current implementation would pass. It's not actually desirable
to generate an error in the above case. Consider a use of a
possibly undefined macro:

I agree with your analysis here.  I am in favor of changing the test to
#if 0, as you suggest.

   #if PERHAPS_UNDEFINED  5
   ...
   #endif
 
In order to protect this use, the user might add something like the
following (or similar with #ifndef):
 
   #if ! defined PERHAPS_UNDEFINED
   ... deal with it ...
   #elif PERHAPS_UNDEFINED
   ...
   #endif
 
In this case, the user's expectation is to get no error with this
code. Yet this is precisly the formulation the current test case
uses to elicit the error.
 
 I'll be glad to push changes to piglit to fix these cases unless
 someone can argue aginst that.

Nope, sounds good to me.  Thanks!

 Thanks,
 
 -Carl
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 5/6] glcpp: Raise error if defining any macro containing two consecutive underscores

2011-09-30 Thread Eric Anholt
On Thu, 29 Sep 2011 23:00:29 -0700, Carl Worth cwo...@cworth.org wrote:
 The specification reserves any macro name containing two consecutive
 underscores, (anywhere within the name). Previously, we only raised
 this error for macro names that started with two underscores.
 
 Fix the implementation to check for two underscores anywhere, and also
 update the corresponding 086-reserved-macro-names test.
 
 This also fixes the following two piglit tests:
 
   spec/glsl-1.30/preprocessor/reserved/double-underscore-02.frag
   spec/glsl-1.30/preprocessor/reserved/double-underscore-03.frag
 ---
  src/glsl/glcpp/glcpp-parse.y   |4 ++--
  src/glsl/glcpp/tests/086-reserved-macro-names.c|1 +
  .../tests/086-reserved-macro-names.c.expected  |5 -
  3 files changed, 7 insertions(+), 3 deletions(-)
 
 diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
 index ff9fa7a..17941a9 100644
 --- a/src/glsl/glcpp/glcpp-parse.y
 +++ b/src/glsl/glcpp/glcpp-parse.y
 @@ -1663,8 +1663,8 @@ _check_for_reserved_macro_name (glcpp_parser_t *parser, 
 YYLTYPE *loc,
   /* According to the GLSL specification, macro names starting with __
* or GL_ are reserved for future use.  So, don't allow them.
*/
 - if (strncmp(identifier, __, 2) == 0) {
 - glcpp_error (loc, parser, Macro names starting with \__\ are 
 reserved.\n);
 + if (strstr(identifier, __)) {
 + glcpp_error (loc, parser, Macro names containing \__\ are 
 reserved.\n);
   }
   if (strncmp(identifier, GL_, 3) == 0) {
   glcpp_error (loc, parser, Macro names starting with \GL_\ 
 are reserved.\n);

Confirmed that this isn't new with 1.30 -- there's text for it back to
1.10 even.

Reviewed-by: Eric Anholt e...@anholt.net


pgpNcxP8cnxGi.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/4] st/mesa: implement AllocTextureImageBuffer() driver hook

2011-09-30 Thread Eric Anholt
On Thu, 29 Sep 2011 20:54:42 -0600, Brian Paul bri...@vmware.com wrote:
 On 09/29/2011 08:37 PM, Eric Anholt wrote:
  On Thu, 29 Sep 2011 14:24:46 -0600, Brian Paulbrian.e.p...@gmail.com  
  wrote:
  From: Brian Paulbri...@vmware.com
 
  This hasn't been needed so far since none of the core Mesa code paths
  that call ctx-Driver.AllocTextureImageBuffer() are used with the
  state tracker.  That will change in upcoming patches.
  Note that this function duplicates some code seen in the st_TexImage()
  function.  That can be cleaned up later.
 
  I'll note that I found it useful within our driver to have
  AllocTextureImageBuffer succeed even if there was data that hadn't been
  Free()d.
 
  If in general Alloc just freed existing memory (or reused it if it was
  well-sized already), we wouldn't need to be so careful about
  FreeTextureImageBuffer()ing in mipmap gen or teximage.  Just a thought.
 
 I'd rather leave it as-is for now.  I'll revisit this in the future, 
 no doubt.
 
 BTW, one thing I have in the back of my mind is to someday try to 
 remove the Alloc/FreeTextureImageBuffer() hooks and instead use a 
 (de)allocator system based on complete mipmaps (see 
 GL_EXT_texture_storage).  I have a patch for that extension that I'm 
 sitting on until after the current batch of changes is finished.

I'm very interested!


pgphmxJd9Jf5C.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] i965: Enable faster workaround-free math on Ivybridge.

2011-09-30 Thread Kenneth Graunke
According to the documentation, Ivybridge's math instruction works in
SIMD16 mode for the fragment shader, and no longer forbids align16 mode
for the vertex shader.

The documentation claims that SIMD16 mode isn't supported for INT DIV,
but empirical evidence shows that it works fine.  Presumably the note
is trying to warn us that the variant that returns both quotient and
remainder in (dst, dst + 1) doesn't work in SIMD16 mode since dst + 1
would be sechalf(dst), trashing half your results.  Since we don't use
that variant, we don't care and can just enable SIMD16 everywhere.

The documentation also still claims that source modifiers and
conditional modifiers aren't supported, but empirical evidence and
study of the simulator both show that they work just fine.

Goodbye workarounds.  Math just works now.

Signed-off-by: Kenneth Graunke kenn...@whitecape.org
---
 src/mesa/drivers/dri/i965/brw_eu_emit.c |   29 +++-
 src/mesa/drivers/dri/i965/brw_fs.cpp|6 +++-
 src/mesa/drivers/dri/i965/brw_fs.h  |7 ++
 src/mesa/drivers/dri/i965/brw_fs_emit.cpp   |   31 ++-
 src/mesa/drivers/dri/i965/brw_vec4.h|4 +++
 src/mesa/drivers/dri/i965/brw_vec4_emit.cpp |   19 ++-
 6 files changed, 80 insertions(+), 16 deletions(-)

Requires my INT DIV patch series to apply cleanly.

diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c 
b/src/mesa/drivers/dri/i965/brw_eu_emit.c
index 5c8d63d..258ffbf 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c
@@ -1496,11 +1496,14 @@ void brw_math( struct brw_compile *p,
   assert(src.file == BRW_GENERAL_REGISTER_FILE);
 
   assert(dest.hstride == BRW_HORIZONTAL_STRIDE_1);
-  assert(src.hstride == BRW_HORIZONTAL_STRIDE_1);
+  if (intel-gen == 6)
+assert(src.hstride == BRW_HORIZONTAL_STRIDE_1);
 
-  /* Source modifiers are ignored for extended math instructions. */
-  assert(!src.negate);
-  assert(!src.abs);
+  /* Source modifiers are ignored for extended math instructions on Gen6. 
*/
+  if (intel-gen == 6) {
+assert(!src.negate);
+assert(!src.abs);
+  }
 
   if (function == BRW_MATH_FUNCTION_INT_DIV_QUOTIENT ||
  function == BRW_MATH_FUNCTION_INT_DIV_REMAINDER ||
@@ -1560,8 +1563,10 @@ void brw_math2(struct brw_compile *p,
assert(src1.file == BRW_GENERAL_REGISTER_FILE);
 
assert(dest.hstride == BRW_HORIZONTAL_STRIDE_1);
-   assert(src0.hstride == BRW_HORIZONTAL_STRIDE_1);
-   assert(src1.hstride == BRW_HORIZONTAL_STRIDE_1);
+   if (intel-gen == 6) {
+  assert(src0.hstride == BRW_HORIZONTAL_STRIDE_1);
+  assert(src1.hstride == BRW_HORIZONTAL_STRIDE_1);
+   }
 
if (function == BRW_MATH_FUNCTION_INT_DIV_QUOTIENT ||
function == BRW_MATH_FUNCTION_INT_DIV_REMAINDER ||
@@ -1573,11 +1578,13 @@ void brw_math2(struct brw_compile *p,
   assert(src1.type == BRW_REGISTER_TYPE_F);
}
 
-   /* Source modifiers are ignored for extended math instructions. */
-   assert(!src0.negate);
-   assert(!src0.abs);
-   assert(!src1.negate);
-   assert(!src1.abs);
+   /* Source modifiers are ignored for extended math instructions on Gen6. */
+   if (intel-gen == 6) {
+  assert(!src0.negate);
+  assert(!src0.abs);
+  assert(!src1.negate);
+  assert(!src1.abs);
+   }
 
/* Math is the same ISA format as other opcodes, except that CondModifier
 * becomes FC[3:0] and ThreadCtrl becomes FC[5:4].
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 2000180..e3c3d85 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -554,7 +554,7 @@ fs_visitor::emit_math(enum opcode opcode, fs_reg dst, 
fs_reg src)
 * The hardware ignores source modifiers (negate and abs) on math
 * instructions, so we also move to a temp to set those up.
 */
-   if (intel-gen = 6  (src.file == UNIFORM ||
+   if (intel-gen == 6  (src.file == UNIFORM ||
   src.abs ||
   src.negate)) {
   fs_reg expanded = fs_reg(this, glsl_type::float_type);
@@ -588,7 +588,9 @@ fs_visitor::emit_math(enum opcode opcode, fs_reg dst, 
fs_reg src0, fs_reg src1)
   return NULL;
}
 
-   if (intel-gen = 6) {
+   if (intel-gen = 7) {
+  inst = emit(opcode, dst, src0, src1);
+   } else if (intel-gen == 6) {
   /* Can't do hstride == 0 args to gen6 math, so expand it out.
*
* The hardware ignores source modifiers (negate and abs) on math
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h 
b/src/mesa/drivers/dri/i965/brw_fs.h
index 56181a3..27b3c22 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -489,6 +489,13 @@ public:
void generate_linterp(fs_inst *inst, struct brw_reg dst,
 struct brw_reg *src);
void generate_tex(fs_inst *inst, struct brw_reg dst, 

Re: [Mesa-dev] [PATCH 2/2] i965 Gen6: Implement gl_ClipVertex.

2011-09-30 Thread Paul Berry
On 29 September 2011 23:16, Kenneth Graunke kenn...@whitecape.org wrote:

 On 09/27/2011 11:05 AM, Paul Berry wrote:
  This patch implements proper support for gl_ClipVertex by causing the
  new VS backend to populate the clip distance VUE slots using
  VERT_RESULT_CLIP_VERTEX when appropriate, and by using the
  untransformed clip planes in ctx-Transform.EyeUserPlane rather than
  the transformed clip planes in ctx-Transform._ClipUserPlane.
 
  When fixed functionality is in use the driver needs to do the old
  behavior (clip based on VERT_RESULT_HPOS and
  ctx-Transform._ClipUserPlane).  This happens automatically because we
  use the old VS backend for fixed functionality.
 
  Fixes the following Piglit tests on i965 Gen6:
  - vs-clip-vertex-const-accept
  - vs-clip-vertex-const-reject
  - vs-clip-vertex-different-from-position
  - vs-clip-vertex-equal-to-position
  - vs-clip-vertex-homogeneity
  - vs-clip-based-on-position
  - vs-clip-based-on-position-homogeneity
  - clip-plane-transformation clipvert_pos
  - clip-plane-transformation pos_clipvert
  - clip-plane-transformation pos
  ---
   src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp |   31
 ++-
   src/mesa/drivers/dri/i965/brw_vs.c |8 +-
   2 files changed, 36 insertions(+), 3 deletions(-)
 
  diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
 b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
  index e5eda22..f335a86 100644
  --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
  +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
  @@ -553,7 +553,16 @@ vec4_visitor::setup_uniform_clipplane_values()
this-userplane[compacted_clipplane_index] = dst_reg(UNIFORM,
 this-uniforms);
this-userplane[compacted_clipplane_index].type =
 BRW_REGISTER_TYPE_F;
for (int j = 0; j  4; ++j) {
  -c-prog_data.param[this-uniforms * 4 + j] =
 ctx-Transform._ClipUserPlane[i][j];
  +/* For fixed functionality shaders, we need to clip based on
  + * ctx-Transform._ClipUserPlane (which has been transformed
 by
  + * Mesa core into clip coordinates).  For user-supplied
 vertex
  + * shaders, we need to use the untransformed clip planes in
  + * ctx-Transform.EyeUserPlane.  Since vec4_visitor is
 currently
  + * only used for user-supplied vertex shaders, we can
 hardcode
  + * this to EyeUserPlane for now.
  + */
  +c-prog_data.param[this-uniforms * 4 + j]
  +   = ctx-Transform.EyeUserPlane[i][j];

 So, we trade support for fixed function clipping for gl_ClipVertex
 clipping?  That seems really unfortunate.  I know we don't use the new
 VS backend for fixed function today, but we will.


My intention was never to give up support for fixed function clipping.  I
just don't know how to tell, from within the vertex shader backend, whether
the shader we're compiling is an application-defined GLSL shader or Mesa's
built-in fixed function vertex shader.  Since at the moment we use the old
VS backend for fixed function, and the new VS backend for
application-defined GLSL shaders, I figured I could dodge the question for
now by putting the fixed-function logic in the old VS backend and the
non-fixed-function logic in the new VS backend.  Unfortunately your eyes
were too sharp for me to get away with that dodge :)



 Couldn't you just do:
 const bool clip_vertex = c-prog_data.outputs_written 
 BITFIELD64_BIT(VERT_RESULT_CLIP_VERTEX);

 c-prog_data.param[this-uniforms * 4 + j] =
clip_vertex ? ctx-Transform.EyeUserPlane[i][j]
   : ctx-Transform._ClipUserPlane[i][j];

 ...or is outputs_written not available at this point in time?


Yes, outputs_written is available at this point in time.  But I'm not
certain whether this code would be correct.  The question hinges on how we
interpret a subtle ambiguity in the GLSL 1.30 spec: what happens in the case
where clipping is in use, but the application-supplied vertex shader doesn't
write to either gl_ClipVertex or gl_ClipDistance?  Accompany me, if you
dare, into ambiguous spec land:

GL 2.1, GL 3.0, GLSL 1.10, and GLSL 1.20 all say that the behavior is
undefined if the vertex shader writes to neither gl_ClipVertex nor
gl_ClipDistance.  But GLSL 1.30 says this: If a linked set of shaders
forming the vertex stage contains no static write to gl_ClipVertex or
gl_ClipDistance, but the application has requested clipping against user
clip planes through the API, then the coordinate written to gl_Position is
used for comparison against the user clip planes.  The subtle ambiguity is:
when using gl_Position for comparison against the user clip planes, should
we transform it from clip coordinates to eye coordinates before comparing it
with the user clip planes?  Or equivalently, should we transform the user
clip planes from eye coordinates to clip coordinates before comparing them
with gl_Position?  (The second, equivalent 

Re: [Mesa-dev] [RFC PATCH] automake: add support to src/glsl/

2011-09-30 Thread Dan Nicholson
Hi Matt,

On Sat, Sep 24, 2011 at 6:06 PM, Matt Turner matts...@gmail.com wrote:
 Signed-off-by: Matt Turner matts...@gmail.com
 ---
 The last discussion about using automake ([RFC] Convert mesa to 
 automake/libtool)
 ended without anything happening, probably because the branch wasn't ready.

 This patch is an attempt to get the ball rolling again. Without ripping out
 the entire existing build system in one swat, it attempts to gradually replace
 it directory by directory with automake.

 The patch has a few problems currently, and a few things that can possibly be
 done better:
        - Mainly, that building libmesa.a currently fails.
        - Not sure how to handle shared/static dricore options.
        - libtool defines VERSION (-DVERSION=...), which screws up the VERSION
          token in glsl_lexer.ll and glsl_parser.yy. I trivially renamed it.
        - libralloc.la can probably be combined into libglslcore.la, and not
          have to be added to every _LDADD line.
        - The rules for flex and bison can probably be eliminated by using
          YFLAGS and LFLAGS. I tried, but ylwrap gave me some error.

 I also killed off what looks to be a stray autogen.sh in src/glsl/.

 Please give it a test.

Sorry for not replying sooner. I've been too busy to attend to my
rapidly growing inbox.

I agree wholeheartedly with the change to automake, although I think
eventually you need Brian's buy in. Despite its flaws, the custom
Makefile system has worked for a lot of years. That said, I think some
of the issues can be conquered with documentation and education. I
also think the best feature of the current system, the static
configuration templates in configs/, can be emulated under autotools.

Anyway, I haven't looked closely at the patch, but I would echo
Gaetan's sentiment to start at the root Makefile.am and work down. I
did some work on this before I got busy. The commits are not really
clean, but you can get them in the automake branch in ~dbn/mesa.git on
annarchy. I think there's definitely a way to move along piecemeal
with a few suggestions:

- Don't feel the need to completely transform a whole Makefile in one
shot. This patch works on a fairly standalone piece, but once you get
into the intertwined parts you either end up with a megacommit or find
a way to work with smaller pieces. You can use the -local automake
targets to point to the existing rules instead of changing to the
automatic rules immediately.

- Some of the current make variables are constructed in
configs/default and configs/autoconf right now. You'll either need to
expand those in each Makefile you convert or just continue to source
$(top_builddir)/configs/current for a while.

- The default targets in the old Makefiles need to be changed to all
so the the root automaked Makefile calls the right thing when
descending.

I'm sure there's a ton of other gotchas. Anyway, I hope to get back to
this sometime.

--
Dan
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [RFC PATCH] automake: add support to src/glsl/

2011-09-30 Thread Dan Nicholson
On Sat, Sep 24, 2011 at 6:06 PM, Matt Turner matts...@gmail.com wrote:
 Signed-off-by: Matt Turner matts...@gmail.com
 ---
 The last discussion about using automake ([RFC] Convert mesa to 
 automake/libtool)
 ended without anything happening, probably because the branch wasn't ready.

 This patch is an attempt to get the ball rolling again. Without ripping out
 the entire existing build system in one swat, it attempts to gradually replace
 it directory by directory with automake.

 The patch has a few problems currently, and a few things that can possibly be
 done better:
        - Mainly, that building libmesa.a currently fails.
        - Not sure how to handle shared/static dricore options.
        - libtool defines VERSION (-DVERSION=...), which screws up the VERSION
          token in glsl_lexer.ll and glsl_parser.yy. I trivially renamed it.
        - libralloc.la can probably be combined into libglslcore.la, and not
          have to be added to every _LDADD line.
        - The rules for flex and bison can probably be eliminated by using
          YFLAGS and LFLAGS. I tried, but ylwrap gave me some error.

 I also killed off what looks to be a stray autogen.sh in src/glsl/.

 Please give it a test.

 Thanks,
 Matt

  configure.ac            |   10 ++
  src/glsl/Makefile       |  235 
 ---
  src/glsl/Makefile.am    |  146 +
  src/glsl/autogen.sh     |   12 ---
  src/glsl/glsl_lexer.ll  |    4 +-
  src/glsl/glsl_parser.yy |    6 +-
  6 files changed, 161 insertions(+), 252 deletions(-)
  delete mode 100644 src/glsl/Makefile
  create mode 100644 src/glsl/Makefile.am
  delete mode 100755 src/glsl/autogen.sh

 diff --git a/configure.ac b/configure.ac
 index b2606bf..fd1082d 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -17,6 +17,13 @@ AC_INIT([Mesa],[mesa_version],
  AC_CONFIG_AUX_DIR([bin])
  AC_CANONICAL_HOST

 +# Initialize Automake
 +AM_INIT_AUTOMAKE([foreign dist-bzip2])
 +AM_MAINTAINER_MODE
 +
 +# Initialize libtool
 +AC_PROG_LIBTOOL
 +
  dnl Save user CFLAGS and CXXFLAGS so one can override the default ones
  USER_CFLAGS=$CFLAGS
  USER_CXXFLAGS=$CXXFLAGS
 @@ -2010,3 +2017,6 @@ echo         PYTHON2:         $PYTHON2
  echo 
  echo         Run '${MAKE-make}' to build Mesa
  echo 
 +
 +AC_CONFIG_FILES([src/glsl/Makefile])
 +AC_OUTPUT

Just a quick note that there are already AC_CONFIG_FILES and AC_OUTPUT
calls in configure.ac, so you should be able to use those.

--
Dan
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [RFC PATCH] automake: add support to src/glsl/

2011-09-30 Thread Dan Nicholson
On Sun, Sep 25, 2011 at 12:06 PM, Gaetan Nadon mems...@videotron.ca wrote:
 On Sat, 2011-09-24 at 21:06 -0400, Matt Turner wrote:

 The patch has a few problems currently, and a few things that can possibly
 be
 done better:
 - Mainly, that building libmesa.a currently fails.
 - Not sure how to handle shared/static dricore options.
 - libtool defines VERSION (-DVERSION=...), which screws up the
 VERSION
   token in glsl_lexer.ll and glsl_parser.yy. I trivially renamed it.
 - libralloc.la can probably be combined into libglslcore.la, and not
   have to be added to every _LDADD line.
 - The rules for flex and bison can probably be eliminated by using
   YFLAGS and LFLAGS. I tried, but ylwrap gave me some error.

 I had a quick look, configure.ac is huge and has a big impact on Makefiles.
 I think it should be reviewed and cleaned-up to understand how it affects
 makefiles.

 Just a few examples of statements to investigate. Not that they are bad, but
 they may be needed because there was no automake and they could possibly
 conflict.

 AC_CHECK_PROGS([MAKE], [gmake make])

 AC_PATH_PROG([MKDEP], [makedepend])
     Can 'makedepend' impact the dependencies automake generates?

 AC_PATH_PROG([FLEX], [flex])
 AC_PATH_PROG([BISON], [bison])
     Some platforms have different names. The rules in the automake make file
 may not work if configure.ac does not use AC_PROG_YACC and AC_PROG_LEX
 This is the configuration in xorg:

 AC_PROG_YACC
 AC_PATH_PROG([YACC_INST], $YACC)
 if test ! -f $srcdir/gram.c; then
    if test -z $YACC_INST; then
   AC_MSG_ERROR([yacc not found - unable to compile gram.y])
    fi
 fi
 AC_PROG_LEX

 test x$INSTALL = x$ac_install_sh  INSTALL='$(MINSTALL)'
     On some platforms, this may result in a different install program being
 used whether the makefile is from mesa or automake.

 There is a 'configuration' file. How will the automake makefiles take that
 into account.

 It looks like there are 'conflicts' between mesa makefiles and automake
 which is expected due to the size of the project. Some preparation work
 should be done upfront to make both system coexist and then have automake
 gradually replace mesa makefiles. This would be useful work anyway.

Just a quick note that there are a lot of custom things in the current
configure.ac to make things work better with the current system. Until
that system is completely gone, a lot of the hacks in here need to
remain. So, I'd suggest leaving configure.ac mostly as is unless
there's a specific thing that's breaking automake. You can certainly
clean up a lot of things in there if automake is used through the
whole tree, but that's a ways off.

--
Dan
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] mesa: add _NEW_CURRENT_ATTRIB in _mesa_program_state_flags()

2011-09-30 Thread Brian Paul

On 09/30/2011 12:51 AM, Eric Anholt wrote:

On Thu, 29 Sep 2011 20:44:14 -0600, Brian Paulbrian.e.p...@gmail.com  wrote:

From: Brian Paulbri...@vmware.com

If color material mode is enabled, constant buffer entries related
to the material coefficients will depend on glColor.  So add
_NEW_CURRENT_ATTRIB to the bitset returned for material-related
constants in _mesa_program_state_flags().

This fixes a bug exercised by the new piglit draw-arrays-colormaterial
test.
---
  src/mesa/program/prog_statevars.c |5 -
  1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/mesa/program/prog_statevars.c 
b/src/mesa/program/prog_statevars.c
index 6aa2409..504944c 100644
--- a/src/mesa/program/prog_statevars.c
+++ b/src/mesa/program/prog_statevars.c
@@ -664,10 +664,13 @@ _mesa_program_state_flags(const gl_state_index 
state[STATE_LENGTH])
  {
 switch (state[0]) {
 case STATE_MATERIAL:
+   case STATE_LIGHTPROD:
+  /* these can be effected by glColor when colormaterial mode is used */
+  return _NEW_LIGHT | _NEW_CURRENT_ATTRIB;
+
 case STATE_LIGHT:
 case STATE_LIGHTMODEL_AMBIENT:
 case STATE_LIGHTMODEL_SCENECOLOR:
-   case STATE_LIGHTPROD:
return _NEW_LIGHT;


Don't SCENECOLOR and AMBIENT, and PROD rely on it, since they also hit
ctx-Light.Material.Attrib[]?  I think STATE_LIGHT is the only
exception.


Yes, SCENECOLOR depends on material coefficients, but 
LIGHTMODEL_AMBIENT does not.  I'll fix that and commit.


-Brian
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] mesa: Respect GL_RASTERIZER_DISCARD for various meta-type operations.

2011-09-30 Thread Brian Paul

On 09/30/2011 12:41 AM, Eric Anholt wrote:

 From the EXT_transform_feedback spec:

 Primitives can be optionally discarded before rasterization by calling
 Enable and Disable with RASTERIZER_DISCARD_EXT. When enabled, primitives
 are discared right before the rasterization stage, but after the optional
 transform feedback stage. When disabled, primitives are passed through to
 the rasterization stage to be processed normally. RASTERIZER_DISCARD_EXT
 applies to the DrawPixels, CopyPixels, Bitmap, Clear and Accum commands as
 well.

And the GL 3.2 spec says it applies to ClearBuffer* as well.



Reviewed-by: Brian Paul bri...@vmware.com
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 41263] [r600g] glCopyTexImage2D selects a texture format that involves fallback to software

2011-09-30 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=41263

Marek Olšák mar...@gmail.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED

--- Comment #11 from Marek Olšák mar...@gmail.com 2011-09-30 08:43:31 PDT ---
The patch has been committed. Closing.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [RFC PATCH] automake: add support to src/glsl/

2011-09-30 Thread Jeremy Huddleston
 So the original complaint, that he is forced to accept the GPLv3
 to use autoconf seems a little confused.
 
 From the 2.62 release notes at 
 http://lists.gnu.org/archive/html/autotools-announce/2008-04/msg2.html:
 
 
 Meanwhile, several source files within the Autoconf project are under
 GPLv3+, as described in COPYINGv3; these files are used for building
 and installing Autoconf, but are not present in the installed
 programs.  The entire Autoconf project will move to GPLv3+ when the
 exception statements have been reformulated in terms of the Additional
 Permissions as described in section 7 of GPLv3.
 
 
 That alone means no 2.62 for me while I'm doing Apple-fu.
 
 The GPL only applies to redistribution, not use.
 
 _Users_ of autoconf (like you, as a Mesa dev), _projects_ that use
 autoconf (like Mesa), _restributors_ of autoconf-using projects, and
 _end-users_ of such projects do not need to accept the GPL at all,
 v3 or otherwise, and are not affected by its terms.

In order for me to *use* autoconf in our build system, I need to *use* the 
version that we build/ship.

 So unless you're sending copies of autoconf _itself_ (not Mesa) to
 other people,

We are distributing autoconf.  Apple's autoconf is stuck at 2.61 and not able 
to go up.  When building mesa in our build system, we use our autoconf.  
Furthermore, as stated before by Alan, I'm restricted from *using* GPLv3 
software.  I direct you to public statements from Apple by people who are paid 
to make public statements.  I just do what the lawyers say and no amount of 
arguing about the license will change it.

With my personal hat on, I use GPLv3 software, I contribute patches to GPLv3 
projects, but I will never release software as GPLv3 because of the headaches 
it causes.

 the version of GPL used in autoconf simply does not
 apply to you.  [Again, see below for more detail]

It applies to us in what version of autoconf we can redistribute and thus which 
version we can use.

 As the GPLv3 is widely used, I think this is an issue that will
 come up again, so it's worth some discussion.
 
 It's not that simple.  We should not thrust acceptance of a new
 license down our users throats.  The existence of GPLv3 is what
 prompted Gentoo to add support to portage to allow users to block
 installing packages based on license.  Clearly it's not just one or
 two companies that are afraid of it.
 
 Again, using autoconf _does not require users to accept the GPLv3,
 nor does it place them under any restrictions due to the GPL[v3]_.
 
 ...

 Maybe I'm wrong somewhere, but _please_ point out _where_, rather than
 using vague handwaving.


I'm not trying to handwave.  I'm just repeating to you what I've been told 
and the reasons for it.  I understand that you disagree with those reasons, but 
IANAL and am not qualified to respond to these points in detail on behalf of 
Apple.  I wish I could give you the answers you seek, but that kind of 
statement is well above my pay grade.

--Jeremy

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] mesa: Remove unused tnl items from dd_functions

2011-09-30 Thread Chad Versace
Remove NeedValidate and ValidateTnlModule.

Signed-off-by: Chad Versace c...@chad-versace.us
---
 src/mesa/drivers/common/driverfuncs.c |2 --
 src/mesa/main/dd.h|   19 ---
 2 files changed, 0 insertions(+), 21 deletions(-)

diff --git a/src/mesa/drivers/common/driverfuncs.c 
b/src/mesa/drivers/common/driverfuncs.c
index 3e28969..33da934 100644
--- a/src/mesa/drivers/common/driverfuncs.c
+++ b/src/mesa/drivers/common/driverfuncs.c
@@ -200,8 +200,6 @@ _mesa_init_driver_functions(struct dd_function_table 
*driver)
_mesa_init_sampler_object_functions(driver);
 
/* TL stuff */
-   driver-NeedValidate = GL_FALSE;
-   driver-ValidateTnlModule = NULL;
driver-CurrentExecPrimitive = 0;
driver-CurrentSavePrimitive = 0;
driver-NeedFlush = 0;
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 720e4f5..1ccba50 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -815,25 +815,6 @@ struct dd_function_table {
/*@{*/
 
/**
-* Bitmask of state changes that require the current TL module to be
-* validated, using ValidateTnlModule() below.
-*/
-   GLuint NeedValidate;
-
-   /**
-* Validate the current TL module. 
-*
-* This is called directly after UpdateState() when a state change that has
-* occurred matches the dd_function_table::NeedValidate bitmask above.  This
-* ensures all computed values are up to date, thus allowing the driver to
-* decide if the current TL module needs to be swapped out.
-*
-* This must be non-NULL if a driver installs a custom TL module and sets
-* the dd_function_table::NeedValidate bitmask, but may be NULL otherwise.
-*/
-   void (*ValidateTnlModule)( struct gl_context *ctx, GLuint new_state );
-
-   /**
 * Set by the driver-supplied TL engine.  
 *
 * Set to PRIM_OUTSIDE_BEGIN_END when outside glBegin()/glEnd().
-- 
1.7.6.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] mesa: Remove unused tnl items from dd_functions

2011-09-30 Thread Eric Anholt
On Fri, 30 Sep 2011 10:45:27 -0700, Chad Versace c...@chad-versace.us wrote:
 Remove NeedValidate and ValidateTnlModule.
 
 Signed-off-by: Chad Versace c...@chad-versace.us

Reviewed-by: Eric Anholt e...@anholt.net


pgp9WRcTbtcJh.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] meta: fix GetTexImage() for compressed luminance, l/a, intensity formats

2011-09-30 Thread Eric Anholt
On Thu, 29 Sep 2011 20:22:28 -0600, Brian Paul brian.e.p...@gmail.com wrote:
 From: Brian Paul bri...@vmware.com
 
 The GL spec says that luminance values are returned as (l, 0, 0, 1),
 L/A values as (l, 0, 0, a) and intensity values as (i, 0, 0, 1).
 Use the pixel transfer scale controls to implement that.
 This fixes a few failures in the new piglit getteximage-formats
 test when getting a compressed L or L/A image.
 ---
  src/mesa/drivers/common/meta.c |   24 ++--
  src/mesa/main/pixel.c  |2 +-
  src/mesa/main/pixel.h  |9 +
  3 files changed, 32 insertions(+), 3 deletions(-)
 
 diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
 index 0291368..148097a 100644
 --- a/src/mesa/drivers/common/meta.c
 +++ b/src/mesa/drivers/common/meta.c
 @@ -49,6 +49,7 @@
  #include main/macros.h
  #include main/matrix.h
  #include main/mipmap.h
 +#include main/pixel.h
  #include main/pbo.h
  #include main/polygon.h
  #include main/readpix.h
 @@ -3235,8 +3236,27 @@ decompress_texture_image(struct gl_context *ctx,
 }
  
 /* read pixels from renderbuffer */
 -   ctx-Pack.RowLength = destRowLength;
 -   _mesa_ReadPixels(0, 0, width, height, destFormat, destType, dest);
 +   {
 +  GLenum baseTexFormat = _mesa_base_tex_format(ctx, 
 texImage-InternalFormat);

(aka texImage-_BaseFormat)

Looks fine.  I'm not really into the indenting of blocks like this for
non-control-flow, but no substantive complaints.


pgp9NgcIobfBI.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] A few fixes for the preprocessor for GLSL 1.30

2011-09-30 Thread Carl Worth
On Thu, 29 Sep 2011 23:43:49 -0700, Kenneth Graunke kenn...@whitecape.org 
wrote:
 For the series:
 Reviewed-by: Kenneth Graunke kenn...@whitecape.org
 
 Thanks for fixing these, Carl!

No problem. Thanks to you (and Eric) for the review.

  I'll be glad to push changes to piglit to fix these cases unless
  someone can argue aginst that.
 
 Nope, sounds good to me.  Thanks!

OK. I pushed the mesa changes seen here, and the obvious piglit patches
as discussed.

Do please continue to let me know if the preprocessor goes wrong again
in the future.

-Carl

-- 
carl.d.wo...@intel.com


pgp08wF41cVS1.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] A few fixes for the preprocessor for GLSL 1.30

2011-09-30 Thread Ian Romanick

On 09/29/2011 11:00 PM, Carl Worth wrote:

Eric recentl mentioned to me that when setting the following
environment variables with current master mesa:

MESA_GL_VERSION_OVERRIDE=3.0
MESA_GLSL_VERSION_OVERRIDE=130

that 8 piglit preprocessor tests start to fail.

I've investigated all of these failures and am here attaching a patch
series for review that fixes 5 of them. In the testing I've done, I
don't see any changes from this patch series other than the desired
piglit fixes. But, of course, I'd be happy for any review.

For the remaining three failures, I believe the tests themselves are
broken and should be fixed. These fall into two case:

1. feature-macros/gl_gragment_precision_high.{frag,vert}

In these tests, the actual preprocessor functionality being tested,
(that a directive of #version 130 causes the
GL_FRAGMENT_PRECISION_HIGH macro to be pre-defined), is working fine.

The tests are failing due to the following code:

float f() { return 0; }

Our implementation does not currently do implicit promotion here,
so compilation fails with a type error:

error: `return' with wrong type int, in function `f' returning
float

The GLSL specification is not explicit on whether this promotion
should be happening, but other implementations appear to do it. So
perhaps the promotion should be added to our implementation.


It is not allowed until a much later GLSL version.


Meanwhile, the test could legitimately be fixed to remove the type
error which is a side issue from what the test is actually trying
to do.


The test should be fixed to return 0.0.


2. if/if-arg-must-be-defined-02.frag


Neither this test nor if-arg-must-be-defined-01 produce the desired 
result on NVIDIA's blob or AMD's blob.  I'd be curious to know what it 
does on Apple's implementation.


In any case, the test quotes specific language from the GLSL spec that 
explicitly forbids this behavior, so I'm somewhat reluctant to deviate 
from the spec'ed behavior.



This test is trying to elicit an undefined macro error with
something like the following code:

#if 1
...
#elif UNDEFINED_MACRO
...
#endif

I propose changing the test to use #if 0 instead, in which case
the current implementation would pass. It's not actually desirable
to generate an error in the above case. Consider a use of a
possibly undefined macro:

#if PERHAPS_UNDEFINED  5
...
#endif

In order to protect this use, the user might add something like the
following (or similar with #ifndef):

#if ! defined PERHAPS_UNDEFINED
... deal with it ...
#elif PERHAPS_UNDEFINED
...
#endif

In this case, the user's expectation is to get no error with this
code. Yet this is precisly the formulation the current test case
uses to elicit the error.

I'll be glad to push changes to piglit to fix these cases unless
someone can argue aginst that.

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] A few fixes for the preprocessor for GLSL 1.30

2011-09-30 Thread Ian Romanick

On 09/30/2011 12:18 PM, Ian Romanick wrote:

On 09/29/2011 11:00 PM, Carl Worth wrote:

2. if/if-arg-must-be-defined-02.frag


Neither this test nor if-arg-must-be-defined-01 produce the desired
result on NVIDIA's blob or AMD's blob. I'd be curious to know what it
does on Apple's implementation.

In any case, the test quotes specific language from the GLSL spec that
explicitly forbids this behavior, so I'm somewhat reluctant to deviate
from the spec'ed behavior.


Though, it turns out that this deviates from what C99 specifies. 
Specifically, the ISO/IEC 9899:TC2 Committee Draft dated May 6, 2005 says:


After all replacements due to macro expansion and the defined unary
operator have been performed, all remaining identifiers are replaced
with the pp-number 0...

I've submitted a GLSL spec bug.

In the mean time, I'd suggest leaving the tests and our implementation 
as-is.

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] mesa: Remove unused tnl items from dd_functions

2011-09-30 Thread Ian Romanick

On 09/30/2011 10:45 AM, Chad Versace wrote:

Remove NeedValidate and ValidateTnlModule.

Signed-off-by: Chad Versacec...@chad-versace.us


Reviewed-by: Ian Romanick ian.d.roman...@intel.com

Hurray for not being locked into a fixed core/driver interface!


---
  src/mesa/drivers/common/driverfuncs.c |2 --
  src/mesa/main/dd.h|   19 ---
  2 files changed, 0 insertions(+), 21 deletions(-)

diff --git a/src/mesa/drivers/common/driverfuncs.c 
b/src/mesa/drivers/common/driverfuncs.c
index 3e28969..33da934 100644
--- a/src/mesa/drivers/common/driverfuncs.c
+++ b/src/mesa/drivers/common/driverfuncs.c
@@ -200,8 +200,6 @@ _mesa_init_driver_functions(struct dd_function_table 
*driver)
 _mesa_init_sampler_object_functions(driver);

 /* TL stuff */
-   driver-NeedValidate = GL_FALSE;
-   driver-ValidateTnlModule = NULL;
 driver-CurrentExecPrimitive = 0;
 driver-CurrentSavePrimitive = 0;
 driver-NeedFlush = 0;
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 720e4f5..1ccba50 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -815,25 +815,6 @@ struct dd_function_table {
 /*@{*/

 /**
-* Bitmask of state changes that require the current TL module to be
-* validated, using ValidateTnlModule() below.
-*/
-   GLuint NeedValidate;
-
-   /**
-* Validate the current TL module.
-*
-* This is called directly after UpdateState() when a state change that has
-* occurred matches the dd_function_table::NeedValidate bitmask above.  This
-* ensures all computed values are up to date, thus allowing the driver to
-* decide if the current TL module needs to be swapped out.
-*
-* This must be non-NULL if a driver installs a custom TL module and sets
-* the dd_function_table::NeedValidate bitmask, but may be NULL otherwise.
-*/
-   void (*ValidateTnlModule)( struct gl_context *ctx, GLuint new_state );
-
-   /**
  * Set by the driver-supplied TL engine.
  *
  * Set to PRIM_OUTSIDE_BEGIN_END when outside glBegin()/glEnd().


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 11/15] mesa: Make _mesa_GetActiveAttribARB use the attributes in the shader IR

2011-09-30 Thread Ian Romanick

On 09/29/2011 04:42 PM, Kenneth Graunke wrote:

On 09/29/2011 10:52 AM, Ian Romanick wrote:

From: Ian Romanickian.d.roman...@intel.com

Instead of relying on the mirror in the Mesa IR assembly shader, just
use the variables actually stored in the GLSL IR.  This will be a bit
slower, but nobody cares about the performance of glGetActiveAttrib.

Signed-off-by: Ian Romanickian.d.roman...@intel.com
---
  src/glsl/program.h |3 ++
  src/mesa/main/shader_query.cpp |   49 ++-
  2 files changed, 40 insertions(+), 12 deletions(-)

diff --git a/src/glsl/program.h b/src/glsl/program.h
index 437ca14..5a68d66 100644
--- a/src/glsl/program.h
+++ b/src/glsl/program.h
@@ -26,6 +26,9 @@
  extern void
  link_shaders(struct gl_context *ctx, struct gl_shader_program *prog);

+extern unsigned
+count_attribute_slots(const glsl_type *t);


Not seeing this used anywhere...?


  extern void
  linker_error(gl_shader_program *prog, const char *fmt, ...)
 PRINTFLIKE(2, 3);
diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index 7959201..84b25cd 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -33,6 +33,7 @@
  #include ir.h
  #include shaderobj.h
  #include program/hash_table.h
+#include ../glsl/program.h

  extern C {
  #include shaderapi.h
@@ -94,30 +95,54 @@ _mesa_GetActiveAttribARB(GLhandleARB program, GLuint index,
   GLenum * type, GLcharARB * name)
  {
 GET_CURRENT_CONTEXT(ctx);
-   const struct gl_program_parameter_list *attribs = NULL;
 struct gl_shader_program *shProg;

 shProg = _mesa_lookup_shader_program_err(ctx, program, 
glGetActiveAttrib);
 if (!shProg)
return;

-   if (shProg-VertexProgram)
-  attribs = shProg-VertexProgram-Base.Attributes;
+   if (!shProg-LinkStatus) {
+  _mesa_error(ctx, GL_INVALID_VALUE,
+  glGetActiveAttrib(program not linked));
+  return;
+   }

-   if (!attribs || index= attribs-NumParameters) {
-  _mesa_error(ctx, GL_INVALID_VALUE, glGetActiveAttrib(index));
+   if (shProg-_LinkedShaders[MESA_SHADER_VERTEX] == NULL) {
+  _mesa_error(ctx, GL_INVALID_VALUE, glGetActiveAttrib(no vertex 
shader));
return;
 }

-   _mesa_copy_string(name, maxLength, length,
- attribs-Parameters[index].Name);
+   exec_list *const ir = shProg-_LinkedShaders[MESA_SHADER_VERTEX]-ir;
+   unsigned i = 0;
+
+   foreach_list(node, ir) {
+  const ir_variable *const var = ((ir_instruction *) node)-as_variable();
+
+  if (var == NULL
+ || var-mode != ir_var_in
+ || var-location == -1
+ || var-location  VERT_ATTRIB_GENERIC0)
+continue;
+
+  if (i == index) {
+_mesa_copy_string(name, maxLength, length, var-name);

-   if (size)
-  *size = attribs-Parameters[index].Size
- / _mesa_sizeof_glsl_type(attribs-Parameters[index].DataType);
+if (size)
+   *size = (var-type-is_array()) ? var-type-length : 1;


I was concerned that structs might be possible here, but then found this
text in the GLSL 1.20 spec: Attribute variables cannot be declared as
arrays or structures.

I'm having trouble finding how arrays happen, but clearly they must, or
else size would be irrelevant.


Attribute arrays were added in GLSL 1.50, so we can't encounter them yet:

Vertex shader inputs can only be float, floating-point vectors,
matrices, signed and unsigned integers and integer vectors. Vertex
shader inputs can also form arrays of these types, but not
structures.


Looks good to me.
Reviewed-by: Kenneth Graunkekenn...@whitecape.org


-   if (type)
-  *type = attribs-Parameters[index].DataType;
+if (type)
+   *type = var-type-gl_type;
+
+return;
+  }
+
+  i++;
+   }
+
+   /* If the loop did not return early, the caller must have asked for
+* an index that did not exit.  Set an error.
+*/
+   _mesa_error(ctx, GL_INVALID_VALUE, glGetActiveAttrib(index));
  }

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] A few fixes for the preprocessor for GLSL 1.30

2011-09-30 Thread Carl Worth
On Fri, 30 Sep 2011 12:32:13 -0700, Ian Romanick i...@freedesktop.org wrote:
  In any case, the test quotes specific language from the GLSL spec that
  explicitly forbids this behavior, so I'm somewhat reluctant to deviate
  from the spec'ed behavior.

We're not deviating from what is specified.

We do raise an error when an undefined macro is used within an #if or
#elif (other than as an argument to defined).

The only difference between our implementation and the original test is
that is that the test expected us to flag this error when the condition
was irrelevant, such as this:

#if 0
...
#elif UNDEFINED_MACRO
...
#endif

And that is not actually explicitly called out by the spec.

 Though, it turns out that this deviates from what C99 specifies. 
 Specifically, the ISO/IEC 9899:TC2 Committee Draft dated May 6, 2005 says:
 
  After all replacements due to macro expansion and the defined unary
  operator have been performed, all remaining identifiers are replaced
  with the pp-number 0...

Yes, I noticed this was different when I did the original
implementation. It wasn't hard to do what the GLSL specification says.

 I've submitted a GLSL spec bug.

OK. If GLSL should align better with C99 then that's a good plan.

-Carl


pgpMt0VJkoTqe.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] i965: Fix swizzle related assertion

2011-09-30 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

As innocuous as it seemed, ebca47a basically broke the world (e.g.,
200 piglit regressions).  In vec4_visitor::emit_block_move,
src-swizzle was expected to be BRW_SWIZZLE_NOOP before setting it to
a swizzle that would replicate the existing channels of the source
type to a vec4 (e.g., .xyyy for a vec2).

The original assertion seems to have been a little bogus.  In addition
to being BRW_SWIZZLE_NOOP, src-swizzle might already be a swizzle
that would replicate the existing channels of the source type to a
vec4.  In other words, it might already have the value that we're
about to assign to it.

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
---
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index 5815e31..9420684 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -1472,7 +1472,8 @@ vec4_visitor::emit_block_move(dst_reg *dst, src_reg *src,
dst-writemask = (1  type-vector_elements) - 1;
 
/* Do we need to worry about swizzling a swizzle? */
-   assert(src-swizzle == BRW_SWIZZLE_NOOP);
+   assert(src-swizzle == BRW_SWIZZLE_NOOP
+ || src-swizzle == swizzle_for_size(type-vector_elements));
src-swizzle = swizzle_for_size(type-vector_elements);
 
vec4_instruction *inst = emit(MOV(*dst, *src));
-- 
1.7.6

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 00/13] Clean up shader attribute handling v2

2011-09-30 Thread Ian Romanick
A couple of the patches from the original series have already been
pushed.  A bunch of the others earned some feedback, and these have
been reworked.  The primary changes in v2 are:

 - Fix some bad squash-merging related to patch 2.

 - Delete the post-link symbol table because it is full of lies (patch
   01/13).

 - Add and use string_to_uint_map (patch 04/13, 06/13, and 07/13)
   instead of the crazy casting of hash_table data pointers to / from
   intptr_t.

The patches that already have Ken's Reviewed-by listed are unchanged
from v1.

 src/glsl/linker.cpp|  146 +-
 src/mesa/main/mtypes.h |   13 +-
 src/mesa/main/shader_query.cpp |  239 
 src/mesa/main/shaderapi.c  |  145 +-
 src/mesa/main/shaderapi.h  |4 +
 src/mesa/main/shaderobj.c  |   11 +-
 src/mesa/program/hash_table.c  |   25 +++
 src/mesa/program/hash_table.h  |   94 +++-
 src/mesa/program/ir_to_mesa.cpp|9 -
 src/mesa/program/prog_parameter.c  |   22 ---
 src/mesa/program/prog_parameter.h  |4 -
 src/mesa/program/program.c |5 -
 src/mesa/program/string_to_uint_map.cpp|   42 +
 src/mesa/sources.mak   |6 +-
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |   11 --
 15 files changed, 496 insertions(+), 280 deletions(-)

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 01/13] glsl: Delete symbol table in post-link shaders

2011-09-30 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

The symbol table in the linked shaders may contain references to
variables that were removed (e.g., unused uniforms).  Since it may
contain junk, there is no possible valid use.  Delete it and set the
pointer to NULL.

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/linker.cpp |8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index d802a0a..6d40dd2 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1831,6 +1831,14 @@ done:
 
   /* Retain any live IR, but trash the rest. */
   reparent_ir(prog-_LinkedShaders[i]-ir, prog-_LinkedShaders[i]-ir);
+
+  /* The symbol table in the linked shaders may contain references to
+   * variables that were removed (e.g., unused uniforms).  Since it may
+   * contain junk, there is no possible valid use.  Delete it and set the
+   * pointer to NULL.
+   */
+  delete prog-_LinkedShaders[i]-symbols;
+  prog-_LinkedShaders[i]-symbols = NULL;
}
 
ralloc_free(mem_ctx);
-- 
1.7.6

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 02/13] mesa: Move _mesa_GetAttribLocationARB to shader_query.cpp

2011-09-30 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

This allows querying the linked shader itself rather than the Mesa IR.
This is the first step towards removing gl_program::Attributes.

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
---
 src/mesa/main/shader_query.cpp |   88 
 src/mesa/main/shaderapi.c  |   41 --
 src/mesa/sources.mak   |3 +-
 3 files changed, 90 insertions(+), 42 deletions(-)
 create mode 100644 src/mesa/main/shader_query.cpp

diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
new file mode 100644
index 000..d5c1546
--- /dev/null
+++ b/src/mesa/main/shader_query.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright © 2011 Intel Corporation
+ *
+ * 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 (including the next
+ * paragraph) 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
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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.
+ */
+
+/**
+ * \file shader_query.cpp
+ * C-to-C++ bridge functions to query GLSL shader data
+ *
+ * \author Ian Romanick ian.d.roman...@intel.com
+ */
+
+#include main/core.h
+#include glsl_symbol_table.h
+#include ir.h
+#include shaderobj.h
+
+extern C {
+#include shaderapi.h
+}
+
+GLint GLAPIENTRY
+_mesa_GetAttribLocationARB(GLhandleARB program, const GLcharARB * name)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_shader_program *const shProg =
+  _mesa_lookup_shader_program_err(ctx, program, glGetAttribLocation);
+
+   if (!shProg) {
+  return -1;
+   }
+
+   if (!shProg-LinkStatus) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  glGetAttribLocation(program not linked));
+  return -1;
+   }
+
+   if (!name)
+  return -1;
+
+   /* Not having a vertex shader is not an error.
+*/
+   if (shProg-_LinkedShaders[MESA_SHADER_VERTEX] == NULL)
+  return -1;
+
+   exec_list *ir = shProg-_LinkedShaders[MESA_SHADER_VERTEX]-ir;
+   foreach_list(node, ir) {
+  const ir_variable *const var = ((ir_instruction *) node)-as_variable();
+
+  /* The extra check against VERT_ATTRIB_GENERIC0 is because
+   * glGetAttribLocation cannot be used on conventional attributes.
+   *
+   * From page 95 of the OpenGL 3.0 spec:
+   *
+   * If name is not an active attribute, if name is a conventional
+   * attribute, or if an error occurs, -1 will be returned.
+   */
+  if (var == NULL
+ || var-mode != ir_var_in
+ || var-location == -1
+ || var-location  VERT_ATTRIB_GENERIC0)
+continue;
+
+  if (strcmp(var-name, name) == 0)
+return var-location - VERT_ATTRIB_GENERIC0;
+   }
+
+   return -1;
+}
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 3ce14d1..49e65e8 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -324,39 +324,6 @@ attach_shader(struct gl_context *ctx, GLuint program, 
GLuint shader)
 }
 
 
-static GLint
-get_attrib_location(struct gl_context *ctx, GLuint program, const GLchar *name)
-{
-   struct gl_shader_program *shProg
-  = _mesa_lookup_shader_program_err(ctx, program, glGetAttribLocation);
-
-   if (!shProg) {
-  return -1;
-   }
-
-   if (!shProg-LinkStatus) {
-  _mesa_error(ctx, GL_INVALID_OPERATION,
-  glGetAttribLocation(program not linked));
-  return -1;
-   }
-
-   if (!name)
-  return -1;
-
-   if (shProg-VertexProgram) {
-  const struct gl_program_parameter_list *attribs =
- shProg-VertexProgram-Base.Attributes;
-  if (attribs) {
- GLint i = _mesa_lookup_parameter_index(attribs, -1, name);
- if (i = 0) {
-return attribs-Parameters[i].StateIndexes[0];
- }
-  }
-   }
-   return -1;
-}
-
-
 static void
 bind_attrib_location(struct gl_context *ctx, GLuint program, GLuint index,
  const GLchar *name)
@@ -1316,14 +1283,6 @@ _mesa_GetAttachedShaders(GLuint program, GLsizei 
maxCount,
 }
 
 
-GLint GLAPIENTRY
-_mesa_GetAttribLocationARB(GLhandleARB program, const GLcharARB * name)
-{

[Mesa-dev] [PATCH 03/13] mesa: Add hash_table_replace

2011-09-30 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

hash_table_replace doesn't use get_node to avoid having to hash the key twice.

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
Reviewed-by: Kenneth Graunke kenn...@whitecape.org
---
 src/mesa/program/hash_table.c |   25 +
 src/mesa/program/hash_table.h |   15 +++
 2 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/src/mesa/program/hash_table.c b/src/mesa/program/hash_table.c
index 2b09462..dc8563a 100644
--- a/src/mesa/program/hash_table.c
+++ b/src/mesa/program/hash_table.c
@@ -150,6 +150,31 @@ hash_table_insert(struct hash_table *ht, void *data, const 
void *key)
 }
 
 void
+hash_table_replace(struct hash_table *ht, void *data, const void *key)
+{
+const unsigned hash_value = (*ht-hash)(key);
+const unsigned bucket = hash_value % ht-num_buckets;
+struct node *node;
+struct hash_node *hn;
+
+foreach(node,  ht-buckets[bucket]) {
+   hn = (struct hash_node *) node;
+
+   if ((*ht-compare)(hn-key, key) == 0) {
+ hn-data = data;
+ return;
+   }
+}
+
+hn = calloc(1, sizeof(*hn));
+
+hn-data = data;
+hn-key = key;
+
+insert_at_head( ht-buckets[bucket],  hn-link);
+}
+
+void
 hash_table_remove(struct hash_table *ht, const void *key)
 {
struct node *node = (struct node *) get_node(ht, key);
diff --git a/src/mesa/program/hash_table.h b/src/mesa/program/hash_table.h
index 746939c..e7ab067 100644
--- a/src/mesa/program/hash_table.h
+++ b/src/mesa/program/hash_table.h
@@ -93,11 +93,26 @@ extern void *hash_table_find(struct hash_table *ht, const 
void *key);
  * If \c key is already in the hash table, it will be added again.  Future
  * calls to \c hash_table_find and \c hash_table_remove will return or remove,
  * repsectively, the most recently added instance of \c key.
+ *
+ * \sa hash_table_replace
  */
 extern void hash_table_insert(struct hash_table *ht, void *data,
 const void *key);
 
 /**
+ * Add an element to a hash table with replacement
+ *
+ * \warning
+ * If \c key is already in the hash table, \c data will \b replace the most
+ * recently inserted \c data (see the warning in \c hash_table_insert) for
+ * that key.
+ *
+ * \sa hash_table_insert
+ */
+extern void hash_table_replace(struct hash_table *ht, void *data,
+const void *key);
+
+/**
  * Remove a specific element from a hash table.
  */
 extern void hash_table_remove(struct hash_table *ht, const void *key);
-- 
1.7.6

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 05/13] mesa: Move _mesa_BindAttribLocationARB to shader_query.cpp

2011-09-30 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

This just folds bind_attrib_location into _mesa_BindAttribLocationARB
and moves the resulting function function to the other source file.
More changes are coming soon.

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
Reviewed-by: Kenneth Graunke kenn...@whitecape.org
---
 src/mesa/main/shader_query.cpp |   42 
 src/mesa/main/shaderapi.c  |   52 
 2 files changed, 42 insertions(+), 52 deletions(-)

diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index d5c1546..b754b1f 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -37,6 +37,48 @@ extern C {
 #include shaderapi.h
 }
 
+void GLAPIENTRY
+_mesa_BindAttribLocationARB(GLhandleARB program, GLuint index,
+const GLcharARB *name)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   const GLint size = -1; /* unknown size */
+   GLint i;
+   GLenum datatype = GL_FLOAT_VEC4;
+
+   struct gl_shader_program *const shProg =
+  _mesa_lookup_shader_program_err(ctx, program, glBindAttribLocation);
+   if (!shProg)
+  return;
+
+   if (!name)
+  return;
+
+   if (strncmp(name, gl_, 3) == 0) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  glBindAttribLocation(illegal name));
+  return;
+   }
+
+   if (index = ctx-Const.VertexProgram.MaxAttribs) {
+  _mesa_error(ctx, GL_INVALID_VALUE, glBindAttribLocation(index));
+  return;
+   }
+
+   /* this will replace the current value if it's already in the list */
+   i = _mesa_add_attribute(shProg-Attributes, name, size, datatype, index);
+   if (i  0) {
+  _mesa_error(ctx, GL_OUT_OF_MEMORY, glBindAttribLocation);
+  return;
+   }
+
+   /*
+* Note that this attribute binding won't go into effect until
+* glLinkProgram is called again.
+*/
+}
+
 GLint GLAPIENTRY
 _mesa_GetAttribLocationARB(GLhandleARB program, const GLcharARB * name)
 {
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 49e65e8..7079754 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -325,49 +325,6 @@ attach_shader(struct gl_context *ctx, GLuint program, 
GLuint shader)
 
 
 static void
-bind_attrib_location(struct gl_context *ctx, GLuint program, GLuint index,
- const GLchar *name)
-{
-   struct gl_shader_program *shProg;
-   const GLint size = -1; /* unknown size */
-   GLint i;
-   GLenum datatype = GL_FLOAT_VEC4;
-
-   shProg = _mesa_lookup_shader_program_err(ctx, program,
-glBindAttribLocation);
-   if (!shProg) {
-  return;
-   }
-
-   if (!name)
-  return;
-
-   if (strncmp(name, gl_, 3) == 0) {
-  _mesa_error(ctx, GL_INVALID_OPERATION,
-  glBindAttribLocation(illegal name));
-  return;
-   }
-
-   if (index = ctx-Const.VertexProgram.MaxAttribs) {
-  _mesa_error(ctx, GL_INVALID_VALUE, glBindAttribLocation(index));
-  return;
-   }
-
-   /* this will replace the current value if it's already in the list */
-   i = _mesa_add_attribute(shProg-Attributes, name, size, datatype, index);
-   if (i  0) {
-  _mesa_error(ctx, GL_OUT_OF_MEMORY, glBindAttribLocation);
-  return;
-   }
-
-   /*
-* Note that this attribute binding won't go into effect until
-* glLinkProgram is called again.
-*/
-}
-
-
-static void
 bind_frag_data_location(struct gl_context *ctx, GLuint program,
 GLuint colorNumber, const GLchar *name)
 {
@@ -1128,15 +1085,6 @@ _mesa_AttachShader(GLuint program, GLuint shader)
 }
 
 
-void GLAPIENTRY
-_mesa_BindAttribLocationARB(GLhandleARB program, GLuint index,
-const GLcharARB *name)
-{
-   GET_CURRENT_CONTEXT(ctx);
-   bind_attrib_location(ctx, program, index, name);
-}
-
-
 /* GL_EXT_gpu_shader4, GL3 */
 void GLAPIENTRY
 _mesa_BindFragDataLocation(GLuint program, GLuint colorNumber,
-- 
1.7.6

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 04/13] mesa: Add string_to_uint_map facade class

2011-09-30 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
---
 src/mesa/program/hash_table.h   |   79 ++-
 src/mesa/program/string_to_uint_map.cpp |   42 
 src/mesa/sources.mak|3 +-
 3 files changed, 122 insertions(+), 2 deletions(-)
 create mode 100644 src/mesa/program/string_to_uint_map.cpp

diff --git a/src/mesa/program/hash_table.h b/src/mesa/program/hash_table.h
index e7ab067..bfe221b 100644
--- a/src/mesa/program/hash_table.h
+++ b/src/mesa/program/hash_table.h
@@ -31,7 +31,13 @@
 #ifndef HASH_TABLE_H
 #define HASH_TABLE_H
 
+#include string.h
+#include stdint.h
+#include limits.h
+#include assert.h
+
 struct hash_table;
+struct string_to_uint_map;
 
 typedef unsigned (*hash_func_t)(const void *key);
 typedef int (*hash_compare_func_t)(const void *key1, const void *key2);
@@ -171,7 +177,78 @@ hash_table_call_foreach(struct hash_table *ht,
 void *closure),
void *closure);
 
+struct string_to_uint_map *
+string_to_uint_map_ctor();
+
+void
+string_to_uint_map_dtor(struct string_to_uint_map *);
+
+
 #ifdef __cplusplus
 }
-#endif
+
+/**
+ * Map from a string (name) to an unsigned integer value
+ *
+ * \note
+ * Because of the way this class interacts with the \c hash_table
+ * implementation, values of \c UINT_MAX cannot be stored in the map.
+ */
+struct string_to_uint_map {
+public:
+   string_to_uint_map()
+   {
+  this-ht = hash_table_ctor(0, hash_table_string_hash,
+hash_table_string_compare);
+   }
+
+   ~string_to_uint_map()
+   {
+  hash_table_dtor(this-ht);
+   }
+
+   /**
+* Get the value associated with a particular key
+*
+* \return
+* If \c key is found in the map, \c true is returned.  Otherwise \c false
+* is returned.
+*
+* \note
+* If \c key is not found in the table, \c value is not modified.
+*/
+   bool get(unsigned value, const char *key)
+   {
+  const intptr_t v =
+(intptr_t) hash_table_find(this-ht, (const void *) key);
+
+  if (v == 0)
+return false;
+
+  value = (unsigned)(v - 1);
+  return true;
+   }
+
+   void put(unsigned value, const char *key)
+   {
+  /* The low-level hash table structure returns NULL if key is not in the
+   * hash table.  However, users of this map might want to store zero as a
+   * valid value in the table.  Bias the value by +1 so that a
+   * user-specified zero is stored as 1.  This enables ::get to tell the
+   * difference between a user-specified zero (returned as 1 by
+   * hash_table_find) and the key not in the table (returned as 0 by
+   * hash_table_find).
+   *
+   * The net effect is that we can't store UINT_MAX in the table.  This is
+   * because UINT_MAX+1 = 0.
+   */
+  assert(value != UINT_MAX);
+  hash_table_replace(ht, (void *) (intptr_t) (value + 1), key);
+   }
+
+private:
+   struct hash_table *ht;
+};
+
+#endif /* __cplusplus */
 #endif /* HASH_TABLE_H */
diff --git a/src/mesa/program/string_to_uint_map.cpp 
b/src/mesa/program/string_to_uint_map.cpp
new file mode 100644
index 000..cfa73ab
--- /dev/null
+++ b/src/mesa/program/string_to_uint_map.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright © 2011 Intel Corporation
+ *
+ * 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 (including the next
+ * paragraph) 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
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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.
+ */
+
+/**
+ * \file string_to_uint_map.cpp
+ * \brief Dumb wrapprs so that C code can create and destroy maps.
+ *
+ * \author Ian Romanick ian.d.roman...@intel.com
+ */
+#include hash_table.h
+
+extern C struct string_to_uint_map *
+string_to_uint_map_ctor()
+{
+   return new string_to_uint_map;
+}
+
+extern C void
+string_to_uint_map_dtor(struct string_to_uint_map *map)
+{
+   delete map;
+}
diff --git a/src/mesa/sources.mak b/src/mesa/sources.mak
index e473b49..f29213e 100644
--- 

[Mesa-dev] [PATCH 06/13] mesa: Add gl_shader_program::AttributeBindings

2011-09-30 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

This currently mirrors the state tracking
gl_shader_program::Attributes, but I'm working towards eliminating
that.

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
---
 src/mesa/main/mtypes.h |   11 ++-
 src/mesa/main/shader_query.cpp |5 +
 src/mesa/main/shaderobj.c  |9 +
 3 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 70f33ff..b9296a8 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2146,8 +2146,17 @@ struct gl_shader_program
GLuint NumShaders;  /** number of attached shaders */
struct gl_shader **Shaders; /** List of attached the shaders */
 
-   /** User-defined attribute bindings (glBindAttribLocation) */
+   /**
+* User-defined attribute bindings
+*
+* These are set via \c glBindAttribLocation and are used to direct the
+* GLSL linker.  These are \b not the values used in the compiled shader,
+* and they are \b not the values returned by \c glGetAttribLocation.
+*
+* \sa gl_program::Attributes
+*/
struct gl_program_parameter_list *Attributes;
+   struct string_to_uint_map *AttributeBindings;
 
/** Transform feedback varyings */
struct {
diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index b754b1f..424610d 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -32,6 +32,7 @@
 #include glsl_symbol_table.h
 #include ir.h
 #include shaderobj.h
+#include program/hash_table.h
 
 extern C {
 #include shaderapi.h
@@ -67,6 +68,10 @@ _mesa_BindAttribLocationARB(GLhandleARB program, GLuint 
index,
}
 
/* this will replace the current value if it's already in the list */
+   /* Add VERT_ATTRIB_GENERIC0 because that's how the linker differentiates
+* between built-in attributes and user-defined attributes.
+*/
+   shProg-AttributeBindings-put(index + VERT_ATTRIB_GENERIC0, name);
i = _mesa_add_attribute(shProg-Attributes, name, size, datatype, index);
if (i  0) {
   _mesa_error(ctx, GL_OUT_OF_MEMORY, glBindAttribLocation);
diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index f128648..322f429 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -38,6 +38,7 @@
 #include program/program.h
 #include program/prog_parameter.h
 #include program/prog_uniform.h
+#include program/hash_table.h
 #include ralloc.h
 
 /**/
@@ -239,6 +240,9 @@ _mesa_init_shader_program(struct gl_context *ctx, struct 
gl_shader_program *prog
prog-Type = GL_SHADER_PROGRAM_MESA;
prog-RefCount = 1;
prog-Attributes = _mesa_new_parameter_list();
+
+   prog-AttributeBindings = string_to_uint_map_ctor();
+
 #if FEATURE_ARB_geometry_shader4
prog-Geom.VerticesOut = 0;
prog-Geom.InputType = GL_TRIANGLES;
@@ -312,6 +316,11 @@ _mesa_free_shader_program_data(struct gl_context *ctx,
   shProg-Attributes = NULL;
}
 
+   if (shProg-AttributeBindings) {
+  string_to_uint_map_dtor(shProg-AttributeBindings);
+  shProg-AttributeBindings = NULL;
+   }
+
/* detach shaders */
for (i = 0; i  shProg-NumShaders; i++) {
   _mesa_reference_shader(ctx, shProg-Shaders[i], NULL);
-- 
1.7.6

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 07/13] linker: Use gl_shader_program::AttributeBindings for attrib locations

2011-09-30 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
---
 src/glsl/linker.cpp |  138 +++---
 1 files changed, 64 insertions(+), 74 deletions(-)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 6d40dd2..9463f53 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1298,71 +1298,6 @@ assign_attribute_or_color_locations(gl_shader_program 
*prog,
 
invalidate_variable_locations(sh, direction, generic_base);
 
-   if ((target_index == MESA_SHADER_VERTEX)  (prog-Attributes != NULL)) {
-  for (unsigned i = 0; i  prog-Attributes-NumParameters; i++) {
-ir_variable *const var =
-   sh-symbols-get_variable(prog-Attributes-Parameters[i].Name);
-
-/* Note: attributes that occupy multiple slots, such as arrays or
- * matrices, may appear in the attrib array multiple times.
- */
-if ((var == NULL) || (var-location != -1))
-   continue;
-
-/* From page 61 of the OpenGL 4.0 spec:
- *
- * LinkProgram will fail if the attribute bindings assigned by
- * BindAttribLocation do not leave not enough space to assign a
- * location for an active matrix attribute or an active attribute
- * array, both of which require multiple contiguous generic
- * attributes.
- *
- * Previous versions of the spec contain similar language but omit the
- * bit about attribute arrays.
- *
- * Page 61 of the OpenGL 4.0 spec also says:
- *
- * It is possible for an application to bind more than one
- * attribute name to the same location. This is referred to as
- * aliasing. This will only work if only one of the aliased
- * attributes is active in the executable program, or if no path
- * through the shader consumes more than one attribute of a set
- * of attributes aliased to the same location. A link error can
- * occur if the linker determines that every path through the
- * shader consumes multiple aliased attributes, but
- * implementations are not required to generate an error in this
- * case.
- *
- * These two paragraphs are either somewhat contradictory, or I don't
- * fully understand one or both of them.
- */
-/* FINISHME: The code as currently written does not support attribute
- * FINISHME: location aliasing (see comment above).
- */
-const int attr = prog-Attributes-Parameters[i].StateIndexes[0];
-const unsigned slots = count_attribute_slots(var-type);
-
-/* Mask representing the contiguous slots that will be used by this
- * attribute.
- */
-const unsigned use_mask = (1  slots) - 1;
-
-/* Generate a link error if the set of bits requested for this
- * attribute overlaps any previously allocated bits.
- */
-if ((~(use_mask  attr)  used_locations) != used_locations) {
-   linker_error(prog,
-insufficient contiguous attribute locations 
-available for vertex shader input `%s',
-var-name);
-   return false;
-}
-
-var-location = VERT_ATTRIB_GENERIC0 + attr;
-used_locations |= (use_mask  attr);
-  }
-   }
-
/* Temporary storage for the set of attributes that need locations assigned.
 */
struct temp_attr {
@@ -1389,28 +1324,83 @@ assign_attribute_or_color_locations(gl_shader_program 
*prog,
 continue;
 
   if (var-explicit_location) {
-const unsigned slots = count_attribute_slots(var-type);
-const unsigned use_mask = (1  slots) - 1;
-const int attr = var-location - generic_base;
-
 if ((var-location = (int)(max_index + generic_base))
 || (var-location  0)) {
linker_error(prog,
 invalid explicit location %d specified for `%s'\n,
-(var-location  0) ? var-location : attr,
+(var-location  0)
+? var-location : var-location - generic_base,
 var-name);
return false;
-} else if (var-location = generic_base) {
-   used_locations |= (use_mask  attr);
+}
+  } else if (target_index == MESA_SHADER_VERTEX) {
+unsigned binding;
+
+if (prog-AttributeBindings-get(binding, var-name)) {
+   assert(binding = VERT_ATTRIB_GENERIC0);
+   var-location = binding;
 }
   }
 
   /* The location was explicitly assigned, nothing to do here.
*/
-  if (var-location != -1)
+  const unsigned slots = count_attribute_slots(var-type);
+  if (var-location != -1) {
+if (var-location = generic_base) {
+   

[Mesa-dev] [PATCH 08/13] mesa: Move _mesa_GetActiveAttribARB to shader_query.cpp

2011-09-30 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

This just folds get_active_attrib into _mesa_GetActiveAttribARB
and moves the resulting function function to the other source file.
More changes are coming soon.

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
Reviewed-by: Kenneth Graunke kenn...@whitecape.org
---
 src/mesa/main/shader_query.cpp |   32 ++
 src/mesa/main/shaderapi.c  |   42 
 2 files changed, 32 insertions(+), 42 deletions(-)

diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index 424610d..6e81564 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -84,6 +84,38 @@ _mesa_BindAttribLocationARB(GLhandleARB program, GLuint 
index,
 */
 }
 
+void GLAPIENTRY
+_mesa_GetActiveAttribARB(GLhandleARB program, GLuint index,
+ GLsizei maxLength, GLsizei * length, GLint * size,
+ GLenum * type, GLcharARB * name)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   const struct gl_program_parameter_list *attribs = NULL;
+   struct gl_shader_program *shProg;
+
+   shProg = _mesa_lookup_shader_program_err(ctx, program, glGetActiveAttrib);
+   if (!shProg)
+  return;
+
+   if (shProg-VertexProgram)
+  attribs = shProg-VertexProgram-Base.Attributes;
+
+   if (!attribs || index = attribs-NumParameters) {
+  _mesa_error(ctx, GL_INVALID_VALUE, glGetActiveAttrib(index));
+  return;
+   }
+
+   _mesa_copy_string(name, maxLength, length,
+ attribs-Parameters[index].Name);
+
+   if (size)
+  *size = attribs-Parameters[index].Size
+ / _mesa_sizeof_glsl_type(attribs-Parameters[index].DataType);
+
+   if (type)
+  *type = attribs-Parameters[index].DataType;
+}
+
 GLint GLAPIENTRY
 _mesa_GetAttribLocationARB(GLhandleARB program, const GLcharARB * name)
 {
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 7079754..b13ec45 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -481,38 +481,6 @@ detach_shader(struct gl_context *ctx, GLuint program, 
GLuint shader)
 }
 
 
-static void
-get_active_attrib(struct gl_context *ctx, GLuint program, GLuint index,
-  GLsizei maxLength, GLsizei *length, GLint *size,
-  GLenum *type, GLchar *nameOut)
-{
-   const struct gl_program_parameter_list *attribs = NULL;
-   struct gl_shader_program *shProg;
-
-   shProg = _mesa_lookup_shader_program_err(ctx, program, glGetActiveAttrib);
-   if (!shProg)
-  return;
-
-   if (shProg-VertexProgram)
-  attribs = shProg-VertexProgram-Base.Attributes;
-
-   if (!attribs || index = attribs-NumParameters) {
-  _mesa_error(ctx, GL_INVALID_VALUE, glGetActiveAttrib(index));
-  return;
-   }
-
-   _mesa_copy_string(nameOut, maxLength, length,
- attribs-Parameters[index].Name);
-
-   if (size)
-  *size = attribs-Parameters[index].Size
- / _mesa_sizeof_glsl_type(attribs-Parameters[index].DataType);
-
-   if (type)
-  *type = attribs-Parameters[index].DataType;
-}
-
-
 /**
  * Return list of shaders attached to shader program.
  */
@@ -1204,16 +1172,6 @@ _mesa_DetachShader(GLuint program, GLuint shader)
 
 
 void GLAPIENTRY
-_mesa_GetActiveAttribARB(GLhandleARB program, GLuint index,
- GLsizei maxLength, GLsizei * length, GLint * size,
- GLenum * type, GLcharARB * name)
-{
-   GET_CURRENT_CONTEXT(ctx);
-   get_active_attrib(ctx, program, index, maxLength, length, size, type, name);
-}
-
-
-void GLAPIENTRY
 _mesa_GetAttachedObjectsARB(GLhandleARB container, GLsizei maxCount,
 GLsizei * count, GLhandleARB * obj)
 {
-- 
1.7.6

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 09/13] mesa: Make _mesa_GetActiveAttribARB use the attributes in the shader IR

2011-09-30 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

Instead of relying on the mirror in the Mesa IR assembly shader, just
use the variables actually stored in the GLSL IR.  This will be a bit
slower, but nobody cares about the performance of glGetActiveAttrib.

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
Reviewed-by: Kenneth Graunke kenn...@whitecape.org
---
 src/mesa/main/shader_query.cpp |   51 +--
 1 files changed, 38 insertions(+), 13 deletions(-)

diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index 6e81564..3a40a24 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -33,6 +33,7 @@
 #include ir.h
 #include shaderobj.h
 #include program/hash_table.h
+#include ../glsl/program.h
 
 extern C {
 #include shaderapi.h
@@ -85,35 +86,59 @@ _mesa_BindAttribLocationARB(GLhandleARB program, GLuint 
index,
 }
 
 void GLAPIENTRY
-_mesa_GetActiveAttribARB(GLhandleARB program, GLuint index,
+_mesa_GetActiveAttribARB(GLhandleARB program, GLuint desired_index,
  GLsizei maxLength, GLsizei * length, GLint * size,
  GLenum * type, GLcharARB * name)
 {
GET_CURRENT_CONTEXT(ctx);
-   const struct gl_program_parameter_list *attribs = NULL;
struct gl_shader_program *shProg;
 
shProg = _mesa_lookup_shader_program_err(ctx, program, glGetActiveAttrib);
if (!shProg)
   return;
 
-   if (shProg-VertexProgram)
-  attribs = shProg-VertexProgram-Base.Attributes;
+   if (!shProg-LinkStatus) {
+  _mesa_error(ctx, GL_INVALID_VALUE,
+  glGetActiveAttrib(program not linked));
+  return;
+   }
 
-   if (!attribs || index = attribs-NumParameters) {
-  _mesa_error(ctx, GL_INVALID_VALUE, glGetActiveAttrib(index));
+   if (shProg-_LinkedShaders[MESA_SHADER_VERTEX] == NULL) {
+  _mesa_error(ctx, GL_INVALID_VALUE, glGetActiveAttrib(no vertex 
shader));
   return;
}
 
-   _mesa_copy_string(name, maxLength, length,
- attribs-Parameters[index].Name);
+   exec_list *const ir = shProg-_LinkedShaders[MESA_SHADER_VERTEX]-ir;
+   unsigned current_index = 0;
+
+   foreach_list(node, ir) {
+  const ir_variable *const var = ((ir_instruction *) node)-as_variable();
+
+  if (var == NULL
+ || var-mode != ir_var_in
+ || var-location == -1
+ || var-location  VERT_ATTRIB_GENERIC0)
+continue;
+
+  if (current_index == desired_index) {
+_mesa_copy_string(name, maxLength, length, var-name);
+
+if (size)
+   *size = (var-type-is_array()) ? var-type-length : 1;
 
-   if (size)
-  *size = attribs-Parameters[index].Size
- / _mesa_sizeof_glsl_type(attribs-Parameters[index].DataType);
+if (type)
+   *type = var-type-gl_type;
 
-   if (type)
-  *type = attribs-Parameters[index].DataType;
+return;
+  }
+
+  current_index++;
+   }
+
+   /* If the loop did not return early, the caller must have asked for
+* an index that did not exit.  Set an error.
+*/
+   _mesa_error(ctx, GL_INVALID_VALUE, glGetActiveAttrib(index));
 }
 
 GLint GLAPIENTRY
-- 
1.7.6

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 10/13] mesa: Remove unused gl_shader_program::Attributes

2011-09-30 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
Reviewed-by: Kenneth Graunke kenn...@whitecape.org
---
 src/mesa/main/mtypes.h |1 -
 src/mesa/main/shader_query.cpp |9 ++---
 src/mesa/main/shaderobj.c  |6 --
 3 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index b9296a8..ef5e9c9 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2155,7 +2155,6 @@ struct gl_shader_program
 *
 * \sa gl_program::Attributes
 */
-   struct gl_program_parameter_list *Attributes;
struct string_to_uint_map *AttributeBindings;
 
/** Transform feedback varyings */
diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index 3a40a24..636ab0f 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -68,16 +68,11 @@ _mesa_BindAttribLocationARB(GLhandleARB program, GLuint 
index,
   return;
}
 
-   /* this will replace the current value if it's already in the list */
-   /* Add VERT_ATTRIB_GENERIC0 because that's how the linker differentiates
+   /* Replace the current value if it's already in the list.  Add
+* VERT_ATTRIB_GENERIC0 because that's how the linker differentiates
 * between built-in attributes and user-defined attributes.
 */
shProg-AttributeBindings-put(index + VERT_ATTRIB_GENERIC0, name);
-   i = _mesa_add_attribute(shProg-Attributes, name, size, datatype, index);
-   if (i  0) {
-  _mesa_error(ctx, GL_OUT_OF_MEMORY, glBindAttribLocation);
-  return;
-   }
 
/*
 * Note that this attribute binding won't go into effect until
diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index 322f429..1eba756 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -239,7 +239,6 @@ _mesa_init_shader_program(struct gl_context *ctx, struct 
gl_shader_program *prog
 {
prog-Type = GL_SHADER_PROGRAM_MESA;
prog-RefCount = 1;
-   prog-Attributes = _mesa_new_parameter_list();
 
prog-AttributeBindings = string_to_uint_map_ctor();
 
@@ -311,11 +310,6 @@ _mesa_free_shader_program_data(struct gl_context *ctx,
 
_mesa_clear_shader_program_data(ctx, shProg);
 
-   if (shProg-Attributes) {
-  _mesa_free_parameter_list(shProg-Attributes);
-  shProg-Attributes = NULL;
-   }
-
if (shProg-AttributeBindings) {
   string_to_uint_map_dtor(shProg-AttributeBindings);
   shProg-AttributeBindings = NULL;
-- 
1.7.6

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 13/13] mesa: Remove unused gl_program::Attributes

2011-09-30 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
Reviewed-by: Kenneth Graunke kenn...@whitecape.org
---
 src/mesa/main/mtypes.h |5 -
 src/mesa/main/shader_query.cpp |4 
 src/mesa/program/ir_to_mesa.cpp|9 -
 src/mesa/program/program.c |5 -
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |   11 ---
 5 files changed, 0 insertions(+), 34 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index ef5e9c9..c5fcd34 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1834,9 +1834,6 @@ struct gl_program
/** Numbered local parameters */
GLfloat LocalParams[MAX_PROGRAM_LOCAL_PARAMS][4];
 
-   /** Vertex program user-defined attributes */
-   struct gl_program_parameter_list *Attributes;
-
/** Map from sampler unit to texture unit (set by glUniform1i()) */
GLubyte SamplerUnits[MAX_SAMPLERS];
/** Which texture target is being sampled (TEXTURE_1D/2D/3D/etc_INDEX) */
@@ -2152,8 +2149,6 @@ struct gl_shader_program
 * These are set via \c glBindAttribLocation and are used to direct the
 * GLSL linker.  These are \b not the values used in the compiled shader,
 * and they are \b not the values returned by \c glGetAttribLocation.
-*
-* \sa gl_program::Attributes
 */
struct string_to_uint_map *AttributeBindings;
 
diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index e532a29..bd873a4 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -45,10 +45,6 @@ _mesa_BindAttribLocationARB(GLhandleARB program, GLuint 
index,
 {
GET_CURRENT_CONTEXT(ctx);
 
-   const GLint size = -1; /* unknown size */
-   GLint i;
-   GLenum datatype = GL_FLOAT_VEC4;
-
struct gl_shader_program *const shProg =
   _mesa_lookup_shader_program_err(ctx, program, glBindAttribLocation);
if (!shProg)
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 5992e20..60550fc 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -1556,14 +1556,6 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir)
  entry = new(mem_ctx) variable_storage(var,
PROGRAM_INPUT,
var-location);
- if (this-prog-Target == GL_VERTEX_PROGRAM_ARB 
- var-location = VERT_ATTRIB_GENERIC0) {
-_mesa_add_attribute(this-prog-Attributes,
-var-name,
-_mesa_sizeof_glsl_type(var-type-gl_type),
-var-type-gl_type,
-var-location - VERT_ATTRIB_GENERIC0);
- }
  break;
   case ir_var_out:
 assert(var-location != -1);
@@ -3045,7 +3037,6 @@ get_mesa_program(struct gl_context *ctx,
if (!prog)
   return NULL;
prog-Parameters = _mesa_new_parameter_list();
-   prog-Attributes = _mesa_new_parameter_list();
v.ctx = ctx;
v.prog = prog;
v.shader_program = shader_program;
diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c
index bdab304..4d6c60b 100644
--- a/src/mesa/program/program.c
+++ b/src/mesa/program/program.c
@@ -394,9 +394,6 @@ _mesa_delete_program(struct gl_context *ctx, struct 
gl_program *prog)
if (prog-Parameters) {
   _mesa_free_parameter_list(prog-Parameters);
}
-   if (prog-Attributes) {
-  _mesa_free_parameter_list(prog-Attributes);
-   }
 
free(prog);
 }
@@ -519,8 +516,6 @@ _mesa_clone_program(struct gl_context *ctx, const struct 
gl_program *prog)
if (prog-Parameters)
   clone-Parameters = _mesa_clone_parameter_list(prog-Parameters);
memcpy(clone-LocalParams, prog-LocalParams, sizeof(clone-LocalParams));
-   if (prog-Attributes)
-  clone-Attributes = _mesa_clone_parameter_list(prog-Attributes);
memcpy(clone-LocalParams, prog-LocalParams, sizeof(clone-LocalParams));
clone-IndirectRegisterFiles = prog-IndirectRegisterFiles;
clone-NumInstructions = prog-NumInstructions;
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index b8ca2c1..d8ef8a3 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -1933,14 +1933,6 @@ glsl_to_tgsi_visitor::visit(ir_dereference_variable *ir)
  entry = new(mem_ctx) variable_storage(var,
PROGRAM_INPUT,
var-location);
- if (this-prog-Target == GL_VERTEX_PROGRAM_ARB 
- var-location = VERT_ATTRIB_GENERIC0) {
-_mesa_add_attribute(this-prog-Attributes,
-var-name,
-_mesa_sizeof_glsl_type(var-type-gl_type),
-

[Mesa-dev] [PATCH 12/13] mesa: Determine GL_ACTIVE_ATTRIBUTE_MAX_LENGTH by walking the GLSL IR.

2011-09-30 Thread Ian Romanick
From: Ian Romanick ian.d.roman...@intel.com

Signed-off-by: Ian Romanick ian.d.roman...@intel.com
Reviewed-by: Kenneth Graunke kenn...@whitecape.org
---
 src/mesa/main/shader_query.cpp|   29 +
 src/mesa/main/shaderapi.c |8 +---
 src/mesa/main/shaderapi.h |2 ++
 src/mesa/program/prog_parameter.c |   22 --
 src/mesa/program/prog_parameter.h |4 
 5 files changed, 32 insertions(+), 33 deletions(-)

diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index e9e6dbf..e532a29 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -212,3 +212,32 @@ _mesa_count_active_attribs(struct gl_shader_program 
*shProg)
 
return i;
 }
+
+
+size_t
+_mesa_longest_attribute_name_length(struct gl_shader_program *shProg)
+{
+   if (!shProg-LinkStatus
+   || shProg-_LinkedShaders[MESA_SHADER_VERTEX] == NULL) {
+  return 0;
+   }
+
+   exec_list *const ir = shProg-_LinkedShaders[MESA_SHADER_VERTEX]-ir;
+   size_t longest = 0;
+
+   foreach_list(node, ir) {
+  const ir_variable *const var = ((ir_instruction *) node)-as_variable();
+
+  if (var == NULL
+ || var-mode != ir_var_in
+ || var-location == -1
+ || var-location  VERT_ATTRIB_GENERIC0)
+continue;
+
+  const size_t len = strlen(var-name);
+  if (len = longest)
+longest = len + 1;
+   }
+
+   return longest;
+}
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 657de66..9e0ed9c 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -538,7 +538,6 @@ get_handle(struct gl_context *ctx, GLenum pname)
 static void
 get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint 
*params)
 {
-   const struct gl_program_parameter_list *attribs;
struct gl_shader_program *shProg
   = _mesa_lookup_shader_program(ctx, program);
 
@@ -547,11 +546,6 @@ get_programiv(struct gl_context *ctx, GLuint program, 
GLenum pname, GLint *param
   return;
}
 
-   if (shProg-VertexProgram)
-  attribs = shProg-VertexProgram-Base.Attributes;
-   else
-  attribs = NULL;
-
switch (pname) {
case GL_DELETE_STATUS:
   *params = shProg-DeletePending;
@@ -572,7 +566,7 @@ get_programiv(struct gl_context *ctx, GLuint program, 
GLenum pname, GLint *param
   *params = _mesa_count_active_attribs(shProg);
   break;
case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
-  *params = _mesa_longest_parameter_name(attribs, PROGRAM_INPUT) + 1;
+  *params = _mesa_longest_attribute_name_length(shProg);
   break;
case GL_ACTIVE_UNIFORMS:
   *params = shProg-Uniforms ? shProg-Uniforms-NumUniforms : 0;
diff --git a/src/mesa/main/shaderapi.h b/src/mesa/main/shaderapi.h
index 9674724..bec448d 100644
--- a/src/mesa/main/shaderapi.h
+++ b/src/mesa/main/shaderapi.h
@@ -53,6 +53,8 @@ _mesa_init_shader_dispatch(struct _glapi_table *exec);
 extern unsigned
 _mesa_count_active_attribs(struct gl_shader_program *shProg);
 
+extern size_t
+_mesa_longest_attribute_name_length(struct gl_shader_program *shProg);
 
 extern void GLAPIENTRY
 _mesa_AttachObjectARB(GLhandleARB, GLhandleARB);
diff --git a/src/mesa/program/prog_parameter.c 
b/src/mesa/program/prog_parameter.c
index 49b3ffb..2018fa5 100644
--- a/src/mesa/program/prog_parameter.c
+++ b/src/mesa/program/prog_parameter.c
@@ -640,28 +640,6 @@ _mesa_combine_parameter_lists(const struct 
gl_program_parameter_list *listA,
 }
 
 
-
-/**
- * Find longest name of all uniform parameters in list.
- */
-GLuint
-_mesa_longest_parameter_name(const struct gl_program_parameter_list *list,
- gl_register_file type)
-{
-   GLuint i, maxLen = 0;
-   if (!list)
-  return 0;
-   for (i = 0; i  list-NumParameters; i++) {
-  if (list-Parameters[i].Type == type) {
- GLuint len = strlen(list-Parameters[i].Name);
- if (len  maxLen)
-maxLen = len;
-  }
-   }
-   return maxLen;
-}
-
-
 /**
  * Count the number of parameters in the last that match the given type.
  */
diff --git a/src/mesa/program/prog_parameter.h 
b/src/mesa/program/prog_parameter.h
index 4c2773a..341397e 100644
--- a/src/mesa/program/prog_parameter.h
+++ b/src/mesa/program/prog_parameter.h
@@ -174,10 +174,6 @@ _mesa_lookup_parameter_constant(const struct 
gl_program_parameter_list *list,
 GLint *posOut, GLuint *swizzleOut);
 
 extern GLuint
-_mesa_longest_parameter_name(const struct gl_program_parameter_list *list,
- gl_register_file type);
-
-extern GLuint
 _mesa_num_parameters_of_type(const struct gl_program_parameter_list *list,
  gl_register_file type);
 
-- 
1.7.6

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] i965 Gen6: Implement gl_ClipVertex.

2011-09-30 Thread Eric Anholt
On Fri, 30 Sep 2011 01:09:32 -0700, Paul Berry stereotype...@gmail.com wrote:
Non-text part: multipart/mixed
Non-text part: multipart/alternative
 On 29 September 2011 23:16, Kenneth Graunke kenn...@whitecape.org wrote:
 
  On 09/27/2011 11:05 AM, Paul Berry wrote:
  So, we trade support for fixed function clipping for gl_ClipVertex
  clipping?  That seems really unfortunate.  I know we don't use the new
  VS backend for fixed function today, but we will.
 
 
 My intention was never to give up support for fixed function clipping.  I
 just don't know how to tell, from within the vertex shader backend, whether
 the shader we're compiling is an application-defined GLSL shader or Mesa's
 built-in fixed function vertex shader.  Since at the moment we use the old
 VS backend for fixed function, and the new VS backend for
 application-defined GLSL shaders, I figured I could dodge the question for
 now by putting the fixed-function logic in the old VS backend and the
 non-fixed-function logic in the new VS backend.  Unfortunately your eyes
 were too sharp for me to get away with that dodge :)

ctx-Shader.CurrentVertexProgram is the vertex shader, if enabled.

If not, ctx-VertexProgram._Enabled tells us if a vertex program is in
use, and ctx-VertexProgram.Current is that program.

Otherwise, you're in fixed function.

ctx-VertexProgram._Current points at one of those three.


pgpBmk8oC2U5K.pgp
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] r200/r300/r600: remove dangling radeon_tex_getimage.c symlinks.

2011-09-30 Thread Paul Berry
Commit d1fda903 (radeon: Drop mapping we were doing around
glGetTexImage()) removed the common Radeon source file
radeon_tex_getimage.c, and pulled it out of the r200, r300, r600, and
radeon makefiles.  But it left behind the symlinks that were being
used to share that file among the four directories.

This patch removes the dangling symlinks.
---
 src/mesa/drivers/dri/r200/radeon_tex_getimage.c |1 -
 src/mesa/drivers/dri/r300/radeon_tex_getimage.c |1 -
 src/mesa/drivers/dri/r600/radeon_tex_getimage.c |1 -
 3 files changed, 0 insertions(+), 3 deletions(-)
 delete mode 12 src/mesa/drivers/dri/r200/radeon_tex_getimage.c
 delete mode 12 src/mesa/drivers/dri/r300/radeon_tex_getimage.c
 delete mode 12 src/mesa/drivers/dri/r600/radeon_tex_getimage.c

diff --git a/src/mesa/drivers/dri/r200/radeon_tex_getimage.c 
b/src/mesa/drivers/dri/r200/radeon_tex_getimage.c
deleted file mode 12
index d9836d7..000
--- a/src/mesa/drivers/dri/r200/radeon_tex_getimage.c
+++ /dev/null
@@ -1 +0,0 @@
-../radeon/radeon_tex_getimage.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/r300/radeon_tex_getimage.c 
b/src/mesa/drivers/dri/r300/radeon_tex_getimage.c
deleted file mode 12
index d9836d7..000
--- a/src/mesa/drivers/dri/r300/radeon_tex_getimage.c
+++ /dev/null
@@ -1 +0,0 @@
-../radeon/radeon_tex_getimage.c
\ No newline at end of file
diff --git a/src/mesa/drivers/dri/r600/radeon_tex_getimage.c 
b/src/mesa/drivers/dri/r600/radeon_tex_getimage.c
deleted file mode 12
index d9836d7..000
--- a/src/mesa/drivers/dri/r600/radeon_tex_getimage.c
+++ /dev/null
@@ -1 +0,0 @@
-../radeon/radeon_tex_getimage.c
\ No newline at end of file
-- 
1.7.6.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 00/13] Clean up shader attribute handling v2

2011-09-30 Thread Kenneth Graunke
On 09/30/2011 04:44 PM, Ian Romanick wrote:
 A couple of the patches from the original series have already been
 pushed.  A bunch of the others earned some feedback, and these have
 been reworked.  The primary changes in v2 are:
 
  - Fix some bad squash-merging related to patch 2.
 
  - Delete the post-link symbol table because it is full of lies (patch
01/13).
 
  - Add and use string_to_uint_map (patch 04/13, 06/13, and 07/13)
instead of the crazy casting of hash_table data pointers to / from
intptr_t.
 
 The patches that already have Ken's Reviewed-by listed are unchanged
 from v1.

For the series:
Reviewed-by: Kenneth Graunke kenn...@whitecape.org

Thanks, Ian.

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] configure: replace pkg-config calls $(PKG_CONFIG) in the makefiles.

2011-09-30 Thread Stéphane Marchesin
Us poor souls who cross compile mesa want to be able to specify which 
pkg-config to pick, or at least just change one place.
---
 configs/default   |1 +
 configs/freebsd-dri   |4 ++--
 configs/linux-dri |   16 
 configs/linux-dri-xcb |   10 +-
 configs/linux-egl |4 ++--
 configs/linux-llvm|2 +-
 src/egl/wayland/wayland-drm/Makefile  |4 ++--
 src/gallium/state_trackers/dri/drm/Makefile   |2 +-
 src/gallium/state_trackers/egl/Makefile   |6 +++---
 src/gallium/state_trackers/va/Makefile|2 +-
 src/gallium/state_trackers/vdpau/Makefile |2 +-
 src/gallium/state_trackers/xorg/Makefile  |8 
 src/gallium/state_trackers/xorg/xvmc/Makefile |2 +-
 src/gallium/targets/Makefile.xorg |2 +-
 src/gallium/targets/dri-nouveau/Makefile  |2 +-
 src/gallium/targets/va-r300/Makefile  |2 +-
 src/gallium/targets/va-r600/Makefile  |2 +-
 src/gallium/targets/vdpau-r300/Makefile   |2 +-
 src/gallium/targets/vdpau-r600/Makefile   |2 +-
 src/gallium/targets/xorg-i915/Makefile|2 +-
 src/gallium/targets/xorg-i965/Makefile|2 +-
 src/gallium/targets/xorg-nouveau/Makefile |4 ++--
 src/gallium/targets/xorg-r300/Makefile|2 +-
 src/gallium/targets/xorg-r600/Makefile|2 +-
 src/gallium/targets/xvmc-nouveau/Makefile |2 +-
 src/gallium/targets/xvmc-r300/Makefile|2 +-
 src/gallium/targets/xvmc-r600/Makefile|2 +-
 src/gallium/winsys/g3dvl/dri/Makefile |2 +-
 src/gallium/winsys/i915/drm/Makefile  |4 ++--
 src/gallium/winsys/i965/drm/Makefile  |4 ++--
 src/gallium/winsys/nouveau/drm/Makefile   |4 ++--
 src/gallium/winsys/radeon/drm/Makefile|2 +-
 src/gallium/winsys/svga/drm/Makefile  |4 ++--
 src/mesa/drivers/dri/i915/Makefile|2 +-
 34 files changed, 58 insertions(+), 57 deletions(-)

diff --git a/configs/default b/configs/default
index 4366611..2b1bf9b 100644
--- a/configs/default
+++ b/configs/default
@@ -40,6 +40,7 @@ MKDEP_OPTIONS = -fdepend
 MAKE = make
 FLEX = flex
 BISON = bison
+PKG_CONFIG = pkg-config
 
 # Use MINSTALL for installing libraries, INSTALL for everything else
 MINSTALL = $(SHELL) $(TOP)/bin/minstall
diff --git a/configs/freebsd-dri b/configs/freebsd-dri
index c4169b8..9e810c4 100644
--- a/configs/freebsd-dri
+++ b/configs/freebsd-dri
@@ -32,8 +32,8 @@ MESA_ASM_SOURCES =
 # Library/program dependencies
 MESA_MODULES  = $(TOP)/src/mesa/libmesa.a
 
-LIBDRM_CFLAGS = `pkg-config --cflags libdrm`
-LIBDRM_LIB = `pkg-config --libs libdrm`
+LIBDRM_CFLAGS = `$(PKG_CONFIG) --cflags libdrm`
+LIBDRM_LIB = `$(PKG_CONFIG) --libs libdrm`
 DRI_LIB_DEPS = $(MESA_MODULES) -L/usr/local/lib -lm -pthread -lexpat 
$(LIBDRM_LIB)
 GL_LIB_DEPS = -L/usr/local/lib -lX11 -lXext -lXxf86vm -lXdamage -lXfixes \
-lm -pthread $(LIBDRM_LIB)
diff --git a/configs/linux-dri b/configs/linux-dri
index 26c73cc..a3e9bab 100644
--- a/configs/linux-dri
+++ b/configs/linux-dri
@@ -44,8 +44,8 @@ EXTRA_LIB_PATH=-L/usr/X11R6/lib
 
 MESA_MODULES  = $(TOP)/src/mesa/libmesa.a
 
-LIBDRM_CFLAGS = $(shell pkg-config --cflags libdrm)
-LIBDRM_LIB = $(shell pkg-config --libs libdrm)
+LIBDRM_CFLAGS = $(shell $(PKG_CONFIG) --cflags libdrm)
+LIBDRM_LIB = $(shell $(PKG_CONFIG) --libs libdrm)
 DRI_LIB_DEPS  = $(MESA_MODULES) $(EXTRA_LIB_PATH) -lm -lpthread -lexpat -ldl 
$(LIBDRM_LIB)
 GL_LIB_DEPS   = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lXdamage -lXfixes \
-lm -lpthread -ldl $(LIBDRM_LIB)
@@ -64,13 +64,13 @@ GALLIUM_STATE_TRACKERS_DIRS = egl
 
 DRI_DIRS = i915 i965 nouveau r200 r300 r600 radeon swrast
 
-INTEL_LIBS = $(shell pkg-config --libs libdrm_intel)
-INTEL_CFLAGS = $(shell pkg-config --cflags libdrm_intel)
+INTEL_LIBS = $(shell $(PKG_CONFIG) --libs libdrm_intel)
+INTEL_CFLAGS = $(shell $(PKG_CONFIG) --cflags libdrm_intel)
 
-NOUVEAU_LIBS = $(shell pkg-config --libs libdrm_nouveau)
-NOUVEAU_CFLAGS = $(shell pkg-config --cflags libdrm_nouveau)
+NOUVEAU_LIBS = $(shell $(PKG_CONFIG) --libs libdrm_nouveau)
+NOUVEAU_CFLAGS = $(shell $(PKG_CONFIG) --cflags libdrm_nouveau)
 
-LIBDRM_RADEON_LIBS = $(shell pkg-config --libs libdrm_radeon)
-LIBDRM_RADEON_CFLAGS = $(shell pkg-config --cflags libdrm_radeon)
+LIBDRM_RADEON_LIBS = $(shell $(PKG_CONFIG) --libs libdrm_radeon)
+LIBDRM_RADEON_CFLAGS = $(shell $(PKG_CONFIG) --cflags libdrm_radeon)
 RADEON_CFLAGS = -DHAVE_LIBDRM_RADEON=1 $(LIBDRM_RADEON_CFLAGS)
 RADEON_LDFLAGS = $(LIBDRM_RADEON_LIBS)
diff --git a/configs/linux-dri-xcb b/configs/linux-dri-xcb
index a845f71..6968beb 100644
--- a/configs/linux-dri-xcb
+++ b/configs/linux-dri-xcb
@@ -25,7 +25,7 @@ DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L 
-D_SVID_SOURCE \
 

Re: [Mesa-dev] [PATCH 2/2] i965 Gen6: Implement gl_ClipVertex.

2011-09-30 Thread Paul Berry
On 30 September 2011 10:04, Eric Anholt e...@anholt.net wrote:

 On Fri, 30 Sep 2011 01:09:32 -0700, Paul Berry stereotype...@gmail.com
 wrote:
 Non-text part: multipart/mixed
 Non-text part: multipart/alternative
  On 29 September 2011 23:16, Kenneth Graunke kenn...@whitecape.org
 wrote:
 
   On 09/27/2011 11:05 AM, Paul Berry wrote:
   So, we trade support for fixed function clipping for gl_ClipVertex
   clipping?  That seems really unfortunate.  I know we don't use the new
   VS backend for fixed function today, but we will.
  
 
  My intention was never to give up support for fixed function clipping.  I
  just don't know how to tell, from within the vertex shader backend,
 whether
  the shader we're compiling is an application-defined GLSL shader or
 Mesa's
  built-in fixed function vertex shader.  Since at the moment we use the
 old
  VS backend for fixed function, and the new VS backend for
  application-defined GLSL shaders, I figured I could dodge the question
 for
  now by putting the fixed-function logic in the old VS backend and the
  non-fixed-function logic in the new VS backend.  Unfortunately your eyes
  were too sharp for me to get away with that dodge :)

 ctx-Shader.CurrentVertexProgram is the vertex shader, if enabled.

 If not, ctx-VertexProgram._Enabled tells us if a vertex program is in
 use, and ctx-VertexProgram.Current is that program.

 Otherwise, you're in fixed function.

 ctx-VertexProgram._Current points at one of those three.


Ok, thanks.  I'll send out a v2 patch that is more future proof.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 0/9] Various patches to the g3dvl stack

2011-09-30 Thread Mike Lothian
Hi

I'm always using the latest git

I've raised https://bugs.freedesktop.org/show_bug.cgi?id=41375

I've attached the logs and a picture, if you'd like the video let me
know it's 29MB to too big to attach to bugzilla me thinks

Cheers

Mike

On 22 September 2011 20:11, ★ Emeric emeric.gra...@gmail.com wrote:
 Hi,
 First : make sure you are using last git repository.
 Then, make a bug report on the mesa bugzilla, describe what happen, and if
 you can please join a picture of the render.
 Regards,
 Emeric

 2011/9/16 Mike Lothian m...@fireburn.co.uk

 2011/9/14 Christian König deathsim...@vodafone.de:
  Am Montag, den 12.09.2011, 23:39 +0200 schrieb Emeric Grange:
  Hi,
  Here is a series of small patches to the g3dvl video decoding stack.
  Most of these are extracted from my GSoC 2011 work and are not related
  to VP8 decoding (http://cgit.freedesktop.org/~emericg/mesa-vp8/).
 
  The third and fourth patches are only useful for codecs that use more
  than 2 reference surfaces or a variable number of reference surfaces.
 
  The sixth patch adds short functions description to the VDPAU state
  tracker. I just used the official VDPAU API documentation from :
  ftp://download.nvidia.com/XFree86/vdpau/doxygen/html/index.html.
 
  The ninth patch adds support for the mplayer2 VDPAU output. So far
  only mplayer and mplayer2 are working with the VDPAU state tracker,
  and I was not able to a run gstreamer based media player or xbmc with
  it, however the errors encountered are not from the state tracker.
 
  These are my first patches sent so please bear with me, and hopefully
  I didn't do any mistakes.
  They looked good enough to me, and since no of the other devs complained
  I pushed them a minute ago.
 
  Thanks,
  Christian.
 
 
  ___
  mesa-dev mailing list
  mesa-dev@lists.freedesktop.org
  http://lists.freedesktop.org/mailman/listinfo/mesa-dev
 

 Even with all the work going into g3dvl lately on my Radeon 4200 I
 still get garbled video with VDPAU


___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/5] mesa: use loop in pop_texture_group() to restore 4 combiner terms

2011-09-30 Thread Brian Paul
From: Brian Paul bri...@vmware.com

There's four combiner terms (not 3) with GL_NV_texture_env_combine4.
Use a loop to make the code a little more compact.
---
 src/mesa/main/attrib.c |   37 +
 1 files changed, 13 insertions(+), 24 deletions(-)

diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 6f427e0..82d7259 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -733,30 +733,19 @@ pop_texture_group(struct gl_context *ctx, struct 
texture_state *texstate)
unit-Combine.ModeRGB);
   _mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA,
unit-Combine.ModeA);
-  _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB,
-   unit-Combine.SourceRGB[0]);
-  _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB,
-   unit-Combine.SourceRGB[1]);
-  _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB,
-   unit-Combine.SourceRGB[2]);
-  _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA,
-   unit-Combine.SourceA[0]);
-  _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA,
-   unit-Combine.SourceA[1]);
-  _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA,
-   unit-Combine.SourceA[2]);
-  _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB,
-   unit-Combine.OperandRGB[0]);
-  _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB,
-   unit-Combine.OperandRGB[1]);
-  _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB,
-   unit-Combine.OperandRGB[2]);
-  _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA,
-   unit-Combine.OperandA[0]);
-  _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA,
-   unit-Combine.OperandA[1]);
-  _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA,
-   unit-Combine.OperandA[2]);
+  {
+ GLuint i;
+ for (i = 0; i  MAX_COMBINER_TERMS; i++) {
+_mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB + i,
+  unit-Combine.SourceRGB[i]);
+_mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA + i,
+  unit-Combine.SourceA[i]);
+_mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB + i,
+  unit-Combine.OperandRGB[i]);
+_mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA + i,
+  unit-Combine.OperandA[i]);
+ }
+  }
   _mesa_TexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE,
1  unit-Combine.ScaleShiftRGB);
   _mesa_TexEnvi(GL_TEXTURE_ENV, GL_ALPHA_SCALE,
-- 
1.7.3.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/5] mesa: use !! to simplify some _mesa_set_enable() calls in attrib.c

2011-09-30 Thread Brian Paul
From: Brian Paul bri...@vmware.com

---
 src/mesa/main/attrib.c |   68 +--
 1 files changed, 25 insertions(+), 43 deletions(-)

diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 82d7259..df7116e 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -497,7 +497,7 @@ pop_enable_group(struct gl_context *ctx, const struct 
gl_enable_attrib *enable)
   const GLuint mask = 1  i;
   if ((ctx-Transform.ClipPlanesEnabled  mask) != (enable-ClipPlanes  
mask))
  _mesa_set_enable(ctx, (GLenum) (GL_CLIP_PLANE0 + i),
-  (GLboolean) ((enable-ClipPlanes  mask) ? GL_TRUE : 
GL_FALSE));
+  !!(enable-ClipPlanes  mask));
}
 
TEST_AND_UPDATE(ctx-Light.ColorMaterialEnabled, enable-ColorMaterial,
@@ -620,38 +620,31 @@ pop_enable_group(struct gl_context *ctx, const struct 
gl_enable_attrib *enable)
   if (ctx-Texture.Unit[i].Enabled != enabled) {
  _mesa_ActiveTextureARB(GL_TEXTURE0 + i);
 
- _mesa_set_enable(ctx, GL_TEXTURE_1D,
-  (enabled  TEXTURE_1D_BIT) ? GL_TRUE : GL_FALSE);
- _mesa_set_enable(ctx, GL_TEXTURE_2D,
-  (enabled  TEXTURE_2D_BIT) ? GL_TRUE : GL_FALSE);
- _mesa_set_enable(ctx, GL_TEXTURE_3D,
-  (enabled  TEXTURE_3D_BIT) ? GL_TRUE : GL_FALSE);
+ _mesa_set_enable(ctx, GL_TEXTURE_1D, !!(enabled  TEXTURE_1D_BIT));
+ _mesa_set_enable(ctx, GL_TEXTURE_2D, !!(enabled  TEXTURE_2D_BIT));
+ _mesa_set_enable(ctx, GL_TEXTURE_3D, !!(enabled  TEXTURE_3D_BIT));
  if (ctx-Extensions.NV_texture_rectangle) {
 _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE_ARB,
- (enabled  TEXTURE_RECT_BIT) ? GL_TRUE : 
GL_FALSE);
+ !!(enabled  TEXTURE_RECT_BIT));
  }
  if (ctx-Extensions.ARB_texture_cube_map) {
 _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP,
- (enabled  TEXTURE_CUBE_BIT) ? GL_TRUE : 
GL_FALSE);
+ !!(enabled  TEXTURE_CUBE_BIT));
  }
  if (ctx-Extensions.MESA_texture_array) {
 _mesa_set_enable(ctx, GL_TEXTURE_1D_ARRAY_EXT,
-   (enabled  TEXTURE_1D_ARRAY_BIT) ? GL_TRUE : 
GL_FALSE);
+ !!(enabled  TEXTURE_1D_ARRAY_BIT));
 _mesa_set_enable(ctx, GL_TEXTURE_2D_ARRAY_EXT,
-   (enabled  TEXTURE_2D_ARRAY_BIT) ? GL_TRUE : 
GL_FALSE);
+ !!(enabled  TEXTURE_2D_ARRAY_BIT));
  }
   }
 
   if (ctx-Texture.Unit[i].TexGenEnabled != genEnabled) {
  _mesa_ActiveTextureARB(GL_TEXTURE0 + i);
- _mesa_set_enable(ctx, GL_TEXTURE_GEN_S,
-  (genEnabled  S_BIT) ? GL_TRUE : GL_FALSE);
- _mesa_set_enable(ctx, GL_TEXTURE_GEN_T,
-  (genEnabled  T_BIT) ? GL_TRUE : GL_FALSE);
- _mesa_set_enable(ctx, GL_TEXTURE_GEN_R,
-  (genEnabled  R_BIT) ? GL_TRUE : GL_FALSE);
- _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q,
-  (genEnabled  Q_BIT) ? GL_TRUE : GL_FALSE);
+ _mesa_set_enable(ctx, GL_TEXTURE_GEN_S, !!(genEnabled  S_BIT));
+ _mesa_set_enable(ctx, GL_TEXTURE_GEN_T, !!(genEnabled  T_BIT));
+ _mesa_set_enable(ctx, GL_TEXTURE_GEN_R, !!(genEnabled  R_BIT));
+ _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, !!(genEnabled  Q_BIT));
   }
}
 
@@ -674,25 +667,22 @@ pop_texture_group(struct gl_context *ctx, struct 
texture_state *texstate)
   GLuint tgt;
 
   _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + u);
-  _mesa_set_enable(ctx, GL_TEXTURE_1D,
-   (unit-Enabled  TEXTURE_1D_BIT) ? GL_TRUE : GL_FALSE);
-  _mesa_set_enable(ctx, GL_TEXTURE_2D,
-   (unit-Enabled  TEXTURE_2D_BIT) ? GL_TRUE : GL_FALSE);
-  _mesa_set_enable(ctx, GL_TEXTURE_3D,
-   (unit-Enabled  TEXTURE_3D_BIT) ? GL_TRUE : GL_FALSE);
+  _mesa_set_enable(ctx, GL_TEXTURE_1D, !!(unit-Enabled  TEXTURE_1D_BIT));
+  _mesa_set_enable(ctx, GL_TEXTURE_2D, !!(unit-Enabled  TEXTURE_2D_BIT));
+  _mesa_set_enable(ctx, GL_TEXTURE_3D, !!(unit-Enabled  TEXTURE_3D_BIT));
   if (ctx-Extensions.ARB_texture_cube_map) {
  _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP_ARB,
- (unit-Enabled  TEXTURE_CUBE_BIT) ? GL_TRUE : GL_FALSE);
+  !!(unit-Enabled  TEXTURE_CUBE_BIT));
   }
   if (ctx-Extensions.NV_texture_rectangle) {
  _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE_NV,
- (unit-Enabled  TEXTURE_RECT_BIT) ? GL_TRUE : GL_FALSE);
+  !!(unit-Enabled  TEXTURE_RECT_BIT));
   }
   if (ctx-Extensions.MESA_texture_array) {
  _mesa_set_enable(ctx, GL_TEXTURE_1D_ARRAY_EXT,
- 

[Mesa-dev] [PATCH 3/5] r600: include version.h for _mesa_override_glsl_version() prototype

2011-09-30 Thread Brian Paul
From: Brian Paul bri...@vmware.com

---
 src/mesa/drivers/dri/r600/r600_context.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/r600/r600_context.c 
b/src/mesa/drivers/dri/r600/r600_context.c
index c2f9cbd..19d69c6 100644
--- a/src/mesa/drivers/dri/r600/r600_context.c
+++ b/src/mesa/drivers/dri/r600/r600_context.c
@@ -46,6 +46,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
SOFTWARE.
 #include main/texobj.h
 #include main/points.h
 #include main/mfeatures.h
+#include main/version.h
 
 #include swrast/swrast.h
 #include swrast_setup/swrast_setup.h
-- 
1.7.3.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 0/2] MapBufferRange improvements

2011-09-30 Thread Ben Widawsky
This patch is a respin of the mesa specific parts on the last
non-blocking series. This goes on top of the libdrm and kernel changes
and assumes that libdrm has some non-blocking style mapping. (There are
also piglit tests for this in the last series).

v2:
removed error checks, though I'm a bit worried about vbo calls per comment
Fixed bug where flush happened regardless of explicit flush

Ben Widawsky (2):
  i965: Cleanup MapRangeBuffer
  i965: Add calls to nonblocking maps

 src/mesa/drivers/dri/intel/intel_buffer_objects.c |  126 ++---
 src/mesa/drivers/dri/intel/intel_buffer_objects.h |   12 ++-
 2 files changed, 69 insertions(+), 69 deletions(-)

-- 
1.7.6.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 1/2] i965: Cleanup MapRangeBuffer

2011-09-30 Thread Ben Widawsky
Clean the code up, and always use a BO when creating a new buffer. I've
not seen any regressions but haven't yet tried this on  Gen6.

Cc: Chad Versace c...@chad-versace.us
Cc: Eric Anholt e...@anholt.net
Signed-off-by: Ben Widawsky b...@bwidawsk.net
---
 src/mesa/drivers/dri/intel/intel_buffer_objects.c |  104 +
 src/mesa/drivers/dri/intel/intel_buffer_objects.h |4 +-
 2 files changed, 44 insertions(+), 64 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.c 
b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
index c52afbd..fdbffe3 100644
--- a/src/mesa/drivers/dri/intel/intel_buffer_objects.c
+++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
@@ -314,6 +314,9 @@ intel_bufferobj_map_range(struct gl_context * ctx,
   intel_obj-sys_buffer = NULL;
}
 
+   if (intel_obj-buffer == NULL)
+  goto error_out;
+
/* If the mapping is synchronized with other GL operations, flush
 * the batchbuffer so that GEM knows about the buffer access for later
 * syncing.
@@ -322,11 +325,6 @@ intel_bufferobj_map_range(struct gl_context * ctx,
drm_intel_bo_references(intel-batch.bo, intel_obj-buffer))
   intel_flush(ctx);
 
-   if (intel_obj-buffer == NULL) {
-  obj-Pointer = NULL;
-  return NULL;
-   }
-
/* If the user doesn't care about existing buffer contents and mapping
 * would cause us to block, then throw out the old buffer.
 */
@@ -344,36 +342,30 @@ intel_bufferobj_map_range(struct gl_context * ctx,
 */
if ((access  GL_MAP_INVALIDATE_RANGE_BIT) 
drm_intel_bo_busy(intel_obj-buffer)) {
-  if (access  GL_MAP_FLUSH_EXPLICIT_BIT) {
-intel_obj-range_map_buffer = malloc(length);
-obj-Pointer = intel_obj-range_map_buffer;
-  } else {
-intel_obj-range_map_bo = drm_intel_bo_alloc(intel-bufmgr,
- range map,
- length, 64);
-if (!(access  GL_MAP_READ_BIT)) {
-   drm_intel_gem_bo_map_gtt(intel_obj-range_map_bo);
-   intel_obj-mapped_gtt = GL_TRUE;
-} else {
-   drm_intel_bo_map(intel_obj-range_map_bo,
-(access  GL_MAP_WRITE_BIT) != 0);
-   intel_obj-mapped_gtt = GL_FALSE;
-}
-obj-Pointer = intel_obj-range_map_bo-virtual;
-  }
-  return obj-Pointer;
-   }
-
-   if (!(access  GL_MAP_READ_BIT)) {
+  intel_obj-range_map_bo = drm_intel_bo_alloc(intel-bufmgr,
+  range map,
+  length, 64);
+  drm_intel_gem_bo_map_gtt(intel_obj-range_map_bo);
+  intel_obj-mapped_gtt = true;
+  obj-Pointer = intel_obj-range_map_bo-virtual;
+   } else if (!(access  GL_MAP_READ_BIT)) { /* Write only */
   drm_intel_gem_bo_map_gtt(intel_obj-buffer);
-  intel_obj-mapped_gtt = GL_TRUE;
-   } else {
+  intel_obj-mapped_gtt = true;
+  obj-Pointer = intel_obj-buffer-virtual + offset;
+   } else { /* R/W or RO */
   drm_intel_bo_map(intel_obj-buffer, (access  GL_MAP_WRITE_BIT) != 0);
-  intel_obj-mapped_gtt = GL_FALSE;
+  intel_obj-mapped_gtt = false;
+  obj-Pointer = intel_obj-buffer-virtual + offset;
}
 
-   obj-Pointer = intel_obj-buffer-virtual + offset;
+   if (!(access  GL_MAP_FLUSH_EXPLICIT_BIT))
+  intel_obj-needs_flush_at_unmap = true;
+
return obj-Pointer;
+
+error_out:
+  obj-Pointer = NULL;
+  return NULL;
 }
 
 /* Ideally we'd use a BO to avoid taking up cache space for the temporary
@@ -388,27 +380,23 @@ intel_bufferobj_flush_mapped_range(struct gl_context *ctx,
 {
struct intel_context *intel = intel_context(ctx);
struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
-   drm_intel_bo *temp_bo;
 
-   /* Unless we're in the range map using a temporary system buffer,
-* there's no work to do.
-*/
-   if (intel_obj-range_map_buffer == NULL)
-  return;
+   if (intel_obj-needs_flush_at_unmap)
+  return 0;
 
if (length == 0)
   return;
 
-   temp_bo = drm_intel_bo_alloc(intel-bufmgr, range map flush, length, 64);
-
-   drm_intel_bo_subdata(temp_bo, 0, length, intel_obj-range_map_buffer);
-
-   intel_emit_linear_blit(intel,
- intel_obj-buffer, obj-Offset + offset,
- temp_bo, 0,
- length);
+   if (!intel_obj-range_map_bo) {
+  intel_batchbuffer_emit_mi_flush(intel);
+   } else {
+  intel_emit_linear_blit(intel,
+intel_obj-buffer, obj-Offset + offset,
+intel_obj-range_map_bo, 0,
+length);
 
-   drm_intel_bo_unreference(temp_bo);
+  drm_intel_bo_unreference(intel_obj-range_map_bo);
+   }
 }
 
 
@@ -425,15 +413,6 @@ intel_bufferobj_unmap(struct gl_context * ctx, struct 
gl_buffer_object *obj)
assert(obj-Pointer);
if 

[Mesa-dev] [PATCH v2 2/2] i965: Add calls to nonblocking maps

2011-09-30 Thread Ben Widawsky
When mapping a range of a buffer that has the UNSYNCHRONIZED_BIT, and is
only writable, we can take some shortcuts and let people shoot their
feet.

Cc: Eric Anholt e...@anholt.net
Signed-off-by: Ben Widawsky b...@bwidawsk.net
---
 src/mesa/drivers/dri/intel/intel_buffer_objects.c |   34 ++--
 src/mesa/drivers/dri/intel/intel_buffer_objects.h |8 -
 2 files changed, 31 insertions(+), 11 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.c 
b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
index fdbffe3..6cdcdda 100644
--- a/src/mesa/drivers/dri/intel/intel_buffer_objects.c
+++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
@@ -346,15 +346,21 @@ intel_bufferobj_map_range(struct gl_context * ctx,
   range map,
   length, 64);
   drm_intel_gem_bo_map_gtt(intel_obj-range_map_bo);
-  intel_obj-mapped_gtt = true;
+  intel_obj-mapped_type = BO_MAP_TYPE_GTT;
   obj-Pointer = intel_obj-range_map_bo-virtual;
} else if (!(access  GL_MAP_READ_BIT)) { /* Write only */
-  drm_intel_gem_bo_map_gtt(intel_obj-buffer);
-  intel_obj-mapped_gtt = true;
-  obj-Pointer = intel_obj-buffer-virtual + offset;
+  if (access  GL_MAP_UNSYNCHRONIZED_BIT) {
+drm_intel_gem_bo_map_nonblocking(intel_obj-buffer);
+intel_obj-mapped_type = BO_MAP_TYPE_NONBLOCKING;
+obj-Pointer = intel_obj-buffer-virtual + offset;
+  } else {
+drm_intel_gem_bo_map_gtt(intel_obj-buffer);
+intel_obj-mapped_type = BO_MAP_TYPE_GTT;
+obj-Pointer = intel_obj-buffer-virtual + offset;
+  }
} else { /* R/W or RO */
   drm_intel_bo_map(intel_obj-buffer, (access  GL_MAP_WRITE_BIT) != 0);
-  intel_obj-mapped_gtt = false;
+  intel_obj-mapped_type = BO_MAP_TYPE_CPU;
   obj-Pointer = intel_obj-buffer-virtual + offset;
}
 
@@ -414,10 +420,12 @@ intel_bufferobj_unmap(struct gl_context * ctx, struct 
gl_buffer_object *obj)
if (intel_obj-sys_buffer != NULL) {
   /* always keep the mapping around. */
} else if (intel_obj-range_map_bo != NULL) {
-  if (intel_obj-mapped_gtt) {
+  switch (intel_obj-mapped_type) {
+  case BO_MAP_TYPE_GTT:
 drm_intel_gem_bo_unmap_gtt(intel_obj-range_map_bo);
-  } else {
-drm_intel_bo_unmap(intel_obj-range_map_bo);
+break;
+  default:
+return GL_FALSE;
   }
 
   if (intel_obj-needs_flush_at_unmap) {
@@ -436,10 +444,16 @@ intel_bufferobj_unmap(struct gl_context * ctx, struct 
gl_buffer_object *obj)
*/
   intel_obj-range_map_bo = NULL;
} else if (intel_obj-buffer != NULL) {
-  if (intel_obj-mapped_gtt) {
+  switch (intel_obj-mapped_type) {
+  case BO_MAP_TYPE_GTT:
 drm_intel_gem_bo_unmap_gtt(intel_obj-buffer);
-  } else {
+break;
+  case BO_MAP_TYPE_CPU:
 drm_intel_bo_unmap(intel_obj-buffer);
+break;
+  case BO_MAP_TYPE_NONBLOCKING:
+drm_intel_gem_bo_unmap_nonblocking(intel_obj-buffer);
+break;
   }
}
 
diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.h 
b/src/mesa/drivers/dri/intel/intel_buffer_objects.h
index 24a1636..fd43bd5 100644
--- a/src/mesa/drivers/dri/intel/intel_buffer_objects.h
+++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.h
@@ -33,6 +33,12 @@
 struct intel_context;
 struct gl_buffer_object;
 
+enum {
+   BO_MAP_TYPE_NONE=0,
+   BO_MAP_TYPE_GTT,
+   BO_MAP_TYPE_CPU,
+   BO_MAP_TYPE_NONBLOCKING
+};
 
 /**
  * Intel vertex/pixel buffer object, derived from Mesa's gl_buffer_object.
@@ -48,8 +54,8 @@ struct intel_buffer_object
 
drm_intel_bo *range_map_bo;
bool needs_flush_at_unmap;
+   int mapped_type;
 
-   GLboolean mapped_gtt;
GLboolean source;
 };
 
-- 
1.7.6.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/5] mesa: use loop in pop_texture_group() to restore 4 combiner terms

2011-09-30 Thread Kenneth Graunke
On 09/30/2011 08:14 PM, Brian Paul wrote:
 From: Brian Paul bri...@vmware.com
 
 There's four combiner terms (not 3) with GL_NV_texture_env_combine4.
 Use a loop to make the code a little more compact.
 ---
  src/mesa/main/attrib.c |   37 +
  1 files changed, 13 insertions(+), 24 deletions(-)

For patches 1-3:
Reviewed-by: Kenneth Graunke kenn...@whitecape.org

For patch 5:
Acked-by: Kenneth Graunke kenn...@whitecape.org

I'm not familiar enough with the code to review patch 4.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev