[Mesa-dev] [PATCH] i965: Use RED for depth texture formats rather than INTENSITY.

2013-11-26 Thread Kenneth Graunke
While looking through the documentation, I found this in the Sandybridge
PRM (Volume 4, Part 1, Page 140):
"Use of sample_c with SURFTYPE_CUBE surfaces is undefined with the
 following surface formats: I24X8_UNORM, L24X8_UNORM, A24X8_UNORM,
 I32_FLOAT, L32_FLOAT, A32_FLOAT."

I haven't observed this to be true, but it suggests that we may want to
use other formats.

We already perform DEPTH_TEXTURE_MODE swizzling in the shaders, and
don't rely on the surface format to splat things appropriately.  So
using RED should work just as well as INTENSITY.

A few notes about the formats:
- R24_UNORM_X8_TYPELESS has the exact same properties as I24X8_UNORM.
- R16_UNORM and R32_FLOAT are additionally supported as a render target,
  while the old I16_UNORM/I32_FLOAT formats are not.
- R32_FLOAT_X8X24_TYPELESS is not supported as a render target, while
  the old format (R32G32_FLOAT) was.  However, it shares the same
  properties as the formats we use for Z24, so it should suffice.

This makes translate_tex_format and brw_blorp_surface_info::set
a bit more similar.

No Piglit or oglconform changes on Sandybridge.

Signed-off-by: Kenneth Graunke 
---
 src/mesa/drivers/dri/i965/brw_surface_formats.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

I found the text, wrote the patch, and tested it, so I figured I'd
send it out...but it doesn't seem to do anything useful, either...

diff --git a/src/mesa/drivers/dri/i965/brw_surface_formats.c 
b/src/mesa/drivers/dri/i965/brw_surface_formats.c
index 91e73d5..6b17553 100644
--- a/src/mesa/drivers/dri/i965/brw_surface_formats.c
+++ b/src/mesa/drivers/dri/i965/brw_surface_formats.c
@@ -695,17 +695,17 @@ translate_tex_format(struct brw_context *brw,
switch( mesa_format ) {
 
case MESA_FORMAT_Z16:
-  return BRW_SURFACEFORMAT_I16_UNORM;
+  return BRW_SURFACEFORMAT_R16_UNORM;
 
case MESA_FORMAT_S8_Z24:
case MESA_FORMAT_X8_Z24:
-  return BRW_SURFACEFORMAT_I24X8_UNORM;
+  return BRW_SURFACEFORMAT_R24_UNORM_X8_TYPELESS;
 
case MESA_FORMAT_Z32_FLOAT:
-  return BRW_SURFACEFORMAT_I32_FLOAT;
+  return BRW_SURFACEFORMAT_R32_FLOAT;
 
case MESA_FORMAT_Z32_FLOAT_X24S8:
-  return BRW_SURFACEFORMAT_R32G32_FLOAT;
+  return BRW_SURFACEFORMAT_R32_FLOAT_X8X24_TYPELESS;
 
case MESA_FORMAT_RGBA_FLOAT32:
   /* The value of this BRW_SURFACEFORMAT is 0, which tricks the
-- 
1.8.4.4

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


Re: [Mesa-dev] [PATCH] Fixed memory leak.

2013-11-26 Thread Siavash

I'll fix this issue in v2 series of patches, thanks again!


Hi, I'm an outsider (for everyone who might have not noticed), I
started following the list because I'm interested in the newbie
projects, too.
I think this free should be called regardless of new_data being null,
as this doesn't imply there wasn't any in the original object.
So, I believe it should be:

if( bufObj->Data )
   _mesa_align_free( bufObj->Data );

if( new_data ) {
   bufObj->Data = new_data;
...


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


[Mesa-dev] [PATCH] Modified _mesa_align_free to have consistent behavior

2013-11-26 Thread Siavash Eliasi
This avoids accidental dereferencing of an invalid memory address by 
_mesa_align_free when passed pointer is NULL.

Also cleaned up different places where it was used, to avoid double check of 
passed pointer.

Now it is safe to pass NULL pointer to this function and expect same behavior 
like free().


Best Regards,
Siavash Eliasi.

Siavash Eliasi (1):
  Modified _mesa_align_free to have consistent behavior when dealing
with NULL memory address.

 src/mesa/main/imports.c|  7 +--
 src/mesa/math/m_matrix.c   | 13 +
 src/mesa/program/prog_parameter.c  |  3 +--
 src/mesa/state_tracker/st_cb_texture.c |  6 ++
 src/mesa/swrast/s_texture.c|  7 +++
 src/mesa/tnl/t_vertex.c|  6 ++
 src/mesa/vbo/vbo_exec_api.c|  9 -
 7 files changed, 22 insertions(+), 29 deletions(-)

-- 
1.8.4.2

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


[Mesa-dev] [PATCH] Modified _mesa_align_free to have consistent behavior when dealing with NULL memory address.

2013-11-26 Thread Siavash Eliasi
---
 src/mesa/main/imports.c|  7 +--
 src/mesa/math/m_matrix.c   | 13 +
 src/mesa/program/prog_parameter.c  |  3 +--
 src/mesa/state_tracker/st_cb_texture.c |  6 ++
 src/mesa/swrast/s_texture.c|  7 +++
 src/mesa/tnl/t_vertex.c|  6 ++
 src/mesa/vbo/vbo_exec_api.c|  9 -
 7 files changed, 22 insertions(+), 29 deletions(-)

diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index 277e947..edfc0d1 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -177,6 +177,9 @@ _mesa_align_free(void *ptr)
 #elif defined(_WIN32) && defined(_MSC_VER)
_aligned_free(ptr);
 #else
+   if (ptr == NULL)
+  return;
+
void **cubbyHole = (void **) ((char *) ptr - sizeof(void *));
void *realAddr = *cubbyHole;
free(realAddr);
@@ -199,8 +202,8 @@ _mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t 
newSize,
if (newBuf && oldBuffer && copySize > 0) {
   memcpy(newBuf, oldBuffer, copySize);
}
-   if (oldBuffer)
-  _mesa_align_free(oldBuffer);
+
+   _mesa_align_free(oldBuffer);
return newBuf;
 #endif
 }
diff --git a/src/mesa/math/m_matrix.c b/src/mesa/math/m_matrix.c
index 2902315..274f969 100644
--- a/src/mesa/math/m_matrix.c
+++ b/src/mesa/math/m_matrix.c
@@ -1488,14 +1488,11 @@ _math_matrix_ctr( GLmatrix *m )
 void
 _math_matrix_dtr( GLmatrix *m )
 {
-   if (m->m) {
-  _mesa_align_free( m->m );
-  m->m = NULL;
-   }
-   if (m->inv) {
-  _mesa_align_free( m->inv );
-  m->inv = NULL;
-   }
+   _mesa_align_free( m->m );
+   m->m = NULL;
+
+   _mesa_align_free( m->inv );
+   m->inv = NULL;
 }
 
 /*@}*/
diff --git a/src/mesa/program/prog_parameter.c 
b/src/mesa/program/prog_parameter.c
index 4d9cf08..54531d2 100644
--- a/src/mesa/program/prog_parameter.c
+++ b/src/mesa/program/prog_parameter.c
@@ -83,8 +83,7 @@ _mesa_free_parameter_list(struct gl_program_parameter_list 
*paramList)
   free((void *)paramList->Parameters[i].Name);
}
free(paramList->Parameters);
-   if (paramList->ParameterValues)
-  _mesa_align_free(paramList->ParameterValues);
+   _mesa_align_free(paramList->ParameterValues);
free(paramList);
 }
 
diff --git a/src/mesa/state_tracker/st_cb_texture.c 
b/src/mesa/state_tracker/st_cb_texture.c
index faa9ee3..f33d3cf 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -175,10 +175,8 @@ st_FreeTextureImageBuffer(struct gl_context *ctx,
   pipe_resource_reference(&stImage->pt, NULL);
}
 
-   if (stImage->TexData) {
-  _mesa_align_free(stImage->TexData);
-  stImage->TexData = NULL;
-   }
+   _mesa_align_free(stImage->TexData);
+   stImage->TexData = NULL;
 }
 
 
diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index 27803c5..c08a4e9 100644
--- a/src/mesa/swrast/s_texture.c
+++ b/src/mesa/swrast/s_texture.c
@@ -164,10 +164,9 @@ _swrast_free_texture_image_buffer(struct gl_context *ctx,
   struct gl_texture_image *texImage)
 {
struct swrast_texture_image *swImage = swrast_texture_image(texImage);
-   if (swImage->Buffer) {
-  _mesa_align_free(swImage->Buffer);
-  swImage->Buffer = NULL;
-   }
+
+   _mesa_align_free(swImage->Buffer);
+   swImage->Buffer = NULL;
 
free(swImage->ImageSlices);
swImage->ImageSlices = NULL;
diff --git a/src/mesa/tnl/t_vertex.c b/src/mesa/tnl/t_vertex.c
index c7a745e..8c4195e 100644
--- a/src/mesa/tnl/t_vertex.c
+++ b/src/mesa/tnl/t_vertex.c
@@ -546,10 +546,8 @@ void _tnl_free_vertices( struct gl_context *ctx )
   struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
   struct tnl_clipspace_fastpath *fp, *tmp;
 
-  if (vtx->vertex_buf) {
- _mesa_align_free(vtx->vertex_buf);
- vtx->vertex_buf = NULL;
-  }
+  _mesa_align_free(vtx->vertex_buf);
+  vtx->vertex_buf = NULL;
 
   for (fp = vtx->fastpath ; fp ; fp = tmp) {
  tmp = fp->next;
diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
index 600398c..f3c41e0 100644
--- a/src/mesa/vbo/vbo_exec_api.c
+++ b/src/mesa/vbo/vbo_exec_api.c
@@ -989,11 +989,10 @@ void vbo_use_buffer_objects(struct gl_context *ctx)
 
/* Make sure this func is only used once */
assert(exec->vtx.bufferobj == ctx->Shared->NullBufferObj);
-   if (exec->vtx.buffer_map) {
-  _mesa_align_free(exec->vtx.buffer_map);
-  exec->vtx.buffer_map = NULL;
-  exec->vtx.buffer_ptr = NULL;
-   }
+
+   _mesa_align_free(exec->vtx.buffer_map);
+   exec->vtx.buffer_map = NULL;
+   exec->vtx.buffer_ptr = NULL;
 
/* Allocate a real buffer object now */
_mesa_reference_buffer_object(ctx, &exec->vtx.bufferobj, NULL);
-- 
1.8.4.2

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


Re: [Mesa-dev] [PATCH 2/2] i965/hsw: Apply non-msrt fast color clear w/a to all HSW GTs

2013-11-26 Thread Kenneth Graunke
On 11/26/2013 05:34 PM, Chad Versace wrote:
> Pre-patch, the workaround was applied to only HSW GT3. However, the
> workaround also fixes render corruption on the HSW GT1 Chromebook,
> codenamed Falco.
> 
> CC: Anuj Phogat 
> CC: Paul Berry 
> OTC-Tracker: CHRMOS-812
> Signed-off-by: Chad Versace 
> ---
>  src/mesa/drivers/dri/i965/brw_blorp_clear.cpp | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp 
> b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
> index 63d83d7..2620ce6 100644
> --- a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
> @@ -265,7 +265,7 @@ brw_blorp_clear_params::brw_blorp_clear_params(struct 
> brw_context *brw,
>x_align *= 16;
>y_align *= 32;
>  
> -  if (brw->is_haswell && brw->gt == 3) {
> +  if (brw->is_haswell) {
>   /* From BSpec: 3D-Media-GPGPU Engine > 3D Pipeline > Pixel > Pixel
>* Backend > MCS Buffer for Render Target(s) [DevIVB+] > Table 
> "Color
>* Clear of Non-MultiSampled Render Target Restrictions":
> @@ -275,8 +275,8 @@ brw_blorp_clear_params::brw_blorp_clear_params(struct 
> brw_context *brw,
>*   y_align values computed above are the relevant entries in the
>*   referred table.
>*
> -  * Note: An older BSpec documented the above restriction for only
> -  * HSW GT3.
> +  * Note: An older BSpec documented the above restriction for only 
> HSW
> +  * GT3. However, the restriction also fixes corruption on HSW GT1.
>*/
>   x0 = ROUND_DOWN_TO(x0, 2 * x_align);
>   y0 = ROUND_DOWN_TO(y0, 2 * y_align);
> 

Personally I would drop the "Note: An older BSpec documented the above
restriction for only HSW GT3." comment.  It wasn't in the public docs,
and the older internal docs you're talking to have been revised.  So I
don't think it'll be terribly interesting in the future.

I would be fine with applying this to all Gen7 platforms, as Paul
mentioned...it's documented as necessary, a minimal cost, and could save
headaches in the future.  But it may also be superfluous, so I'm okay
with your patch as is.

I would squash patches 1 and 2.  It makes sense to update the comments
saying "Hey, this applies more broadly" at the same time you fix the
code to apply it more broadly. :)

With or without any changes, both patches are:
Reviewed-by: Kenneth Graunke 

Also I agree with Paul:
Cc: mesa-sta...@lists.freedesktop.org
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] Enable ARB_map_buffer_alignment in all drivers - first try

2013-11-26 Thread Timothy Arceri
Hi Thomas,

Looks like Siavash Eliasi beat you to it.

But here is some quick feedback. You seem to have made the same mistake
with your case statements [1]
Also you shouldn't attach the patch to your email but should use
git-send-email there is a link to more info on the Newbie page ;)

As for the remaining Newbie tasks it looks like work has been started on
those [2] but the ARB_clear_buffer_object work hasn't been tested so you
could have a go at writing the piglit tests this would give you a good
understanding on the spec and what the extension is meant to do from
there you might be able to fix up any issues with the patch. 

[1]http://lists.freedesktop.org/archives/mesa-dev/2013-November/049054.html
[2]http://lists.freedesktop.org/archives/mesa-dev/2013-November/048944.html

On Tue, 2013-11-26 at 19:48 +, Thomas Prescher wrote:
> Hi,
> 
> today I read an article on phoronix
> (http://www.phoronix.com/scan.php?page=news_item&px=MTUyNDY) which
> linked to a wiki page (http://wiki.freedesktop.org/dri/NewbieProjects/)
> where easy projects to start with were listed. I gave it a shot and
> tried to implement the ARB_map_buffer_alignment extensions for all
> drivers. Long story short, here is the patch I've created. I'm not
> completely sure whether everything I did was what the creator of the
> wiki page had in mind. I am especially unsure about the last item. Ofc
> it would be very great iff one of you  guys can provide some feedback :)
> 
> -Thomas
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


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


Re: [Mesa-dev] [PATCH 2/2] i965/hsw: Apply non-msrt fast color clear w/a to all HSW GTs

2013-11-26 Thread Paul Berry
On 26 November 2013 17:34, Chad Versace wrote:

> Pre-patch, the workaround was applied to only HSW GT3. However, the
> workaround also fixes render corruption on the HSW GT1 Chromebook,
> codenamed Falco.
>
> CC: Anuj Phogat 
> CC: Paul Berry 
> OTC-Tracker: CHRMOS-812
> Signed-off-by: Chad Versace 
> ---
>  src/mesa/drivers/dri/i965/brw_blorp_clear.cpp | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
> b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
> index 63d83d7..2620ce6 100644
> --- a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
> @@ -265,7 +265,7 @@ brw_blorp_clear_params::brw_blorp_clear_params(struct
> brw_context *brw,
>x_align *= 16;
>y_align *= 32;
>
> -  if (brw->is_haswell && brw->gt == 3) {
> +  if (brw->is_haswell) {
>

Ok, I'll ask the obvious question: if the bspec says that this extra
rectangle alignment code is needed for IVB, VLVT, and HSW, why are we doing
it for just HSW?

I suspect that in truth, the extra rectangle alignment is only needed for
HSW (This is based in part on the fact that fast clears have been working
fine on IVB for a long time without this bug fix), so the patch will
probably work fine as written.  But the performance cost of applying the
extra alignment to IVB is minuscule, and if it saves us from having to
track down and re-fix this bug one more time, it will be worth it.

On the other hand, there's some appeal to limiting the scope of the bug fix
to just the hardware that's been experiencing problems.

I'll leave it up to you.  Either way, the series is:

Reviewed-by: Paul Berry 

Note: Personally I'd prefer to see the two patches squashed together, but I
won't be a stickler about that.

Oh, one other question: was it a deliberate decision not to mark this as a
candidate for cherry-picking back to the 10.0 and 9.2 branches?  At first
blush it seems worth cherry-picking to me.


>   /* From BSpec: 3D-Media-GPGPU Engine > 3D Pipeline > Pixel >
> Pixel
>* Backend > MCS Buffer for Render Target(s) [DevIVB+] > Table
> "Color
>* Clear of Non-MultiSampled Render Target Restrictions":
> @@ -275,8 +275,8 @@ brw_blorp_clear_params::brw_blorp_clear_params(struct
> brw_context *brw,
>*   y_align values computed above are the relevant entries in
> the
>*   referred table.
>*
> -  * Note: An older BSpec documented the above restriction for only
> -  * HSW GT3.
> +  * Note: An older BSpec documented the above restriction for
> only HSW
> +  * GT3. However, the restriction also fixes corruption on HSW
> GT1.
>*/
>   x0 = ROUND_DOWN_TO(x0, 2 * x_align);
>   y0 = ROUND_DOWN_TO(y0, 2 * y_align);
> --
> 1.8.4
>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] Fwd: [PATCH] Fixed memory leak.

2013-11-26 Thread Mario Rugiero
Sorry, I accidentally sent my mail to Alex instead of the list.

-- Forwarded message --
From: Mario Rugiero 
Date: 2013/11/26
Subject: Re: [Mesa-dev] [PATCH] Fixed memory leak.
To: Alex Deucher 


Hi, I'm an outsider (for everyone who might have not noticed), I started
following the list because I'm interested in the newbie projects, too.
I think this free should be called regardless of new_data being null, as
this doesn't imply there wasn't any in the original object.
So, I believe it should be:

if( bufObj->Data )
   _mesa_align_free( bufObj->Data );

if( new_data ) {
   bufObj->Data = new_data;
...


2013/11/26 Alex Deucher 

> On Tue, Nov 26, 2013 at 1:22 PM, Siavash Eliasi 
> wrote:
>
> In general, when you fix problems in prior patches, you should
> integrate the fix into the original patch(es) where the problems were,
> update the commit message to note what bugs were fixed and then
> re-send the patch set.  That prevents broken commits from getting into
> the git tree even if they are fixed in a later commit. You can use git
> rebase -i to integrate your fixes.
>
> Alex
>
> > ---
> >  src/mesa/main/bufferobj.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
> > index 5581a5d..e68d96d 100644
> > --- a/src/mesa/main/bufferobj.c
> > +++ b/src/mesa/main/bufferobj.c
> > @@ -420,6 +420,8 @@ _mesa_buffer_data( struct gl_context *ctx, GLenum
> target, GLsizeiptrARB size,
> >
> > new_data = _mesa_align_malloc( size,
> ctx->Const.MinMapBufferAlignment );
> > if (new_data) {
> > +  _mesa_align_free( bufObj->Data );
> > +
> >bufObj->Data = (GLubyte *) new_data;
> >bufObj->Size = size;
> >bufObj->Usage = usage;
> > --
> > 1.8.4.2
> >
> > ___
> > mesa-dev mailing list
> > mesa-dev@lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 0/2] i965/hsw: Fix fast color bug on ChromeOS Falco

2013-11-26 Thread Chad Versace
Google disabled fast color clears for all hardware because it causes corruption
on Haswell. This patch series fixes it so that Google can re-enable fast clears.

Chad Versace (2):
  i965/blorp: Update language for fast color clear non-msrt restriction
  i965/hsw: Apply non-msrt fast color clear w/a to all HSW GTs

 src/mesa/drivers/dri/i965/brw_blorp_clear.cpp | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

-- 
1.8.4

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


[Mesa-dev] [PATCH 2/2] i965/hsw: Apply non-msrt fast color clear w/a to all HSW GTs

2013-11-26 Thread Chad Versace
Pre-patch, the workaround was applied to only HSW GT3. However, the
workaround also fixes render corruption on the HSW GT1 Chromebook,
codenamed Falco.

CC: Anuj Phogat 
CC: Paul Berry 
OTC-Tracker: CHRMOS-812
Signed-off-by: Chad Versace 
---
 src/mesa/drivers/dri/i965/brw_blorp_clear.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp 
b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
index 63d83d7..2620ce6 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
@@ -265,7 +265,7 @@ brw_blorp_clear_params::brw_blorp_clear_params(struct 
brw_context *brw,
   x_align *= 16;
   y_align *= 32;
 
-  if (brw->is_haswell && brw->gt == 3) {
+  if (brw->is_haswell) {
  /* From BSpec: 3D-Media-GPGPU Engine > 3D Pipeline > Pixel > Pixel
   * Backend > MCS Buffer for Render Target(s) [DevIVB+] > Table "Color
   * Clear of Non-MultiSampled Render Target Restrictions":
@@ -275,8 +275,8 @@ brw_blorp_clear_params::brw_blorp_clear_params(struct 
brw_context *brw,
   *   y_align values computed above are the relevant entries in the
   *   referred table.
   *
-  * Note: An older BSpec documented the above restriction for only
-  * HSW GT3.
+  * Note: An older BSpec documented the above restriction for only HSW
+  * GT3. However, the restriction also fixes corruption on HSW GT1.
   */
  x0 = ROUND_DOWN_TO(x0, 2 * x_align);
  y0 = ROUND_DOWN_TO(y0, 2 * y_align);
-- 
1.8.4

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


[Mesa-dev] [PATCH 1/2] i965/blorp: Update language for fast color clear non-msrt restriction

2013-11-26 Thread Chad Versace
In an older BSpec, the restriction was documented for HSW GT3. The
current BSpec lists the restriction in a table for IVB, HSW, and VLVT.
Only the gods know to which hardware the restriction really applies.

CC: Paul Berry 
CC: Anuj Phogat 
Signed-off-by: Chad Versace 
---
 src/mesa/drivers/dri/i965/brw_blorp_clear.cpp | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp 
b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
index 02ec273..63d83d7 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
@@ -267,11 +267,16 @@ brw_blorp_clear_params::brw_blorp_clear_params(struct 
brw_context *brw,
 
   if (brw->is_haswell && brw->gt == 3) {
  /* From BSpec: 3D-Media-GPGPU Engine > 3D Pipeline > Pixel > Pixel
-  * Backend > MCS Buffer for Render Target(s) [DevIVB+]:
-  * [DevHSW:GT3]: Clear rectangle must be aligned to two times the
-  * number of pixels in the table shown below...
-  * x_align, y_align values computed above are the relevant entries
-  * in the referred table.
+  * Backend > MCS Buffer for Render Target(s) [DevIVB+] > Table "Color
+  * Clear of Non-MultiSampled Render Target Restrictions":
+  *
+  *   [IVB, VLVT, HSW]: Clear rectangle must be aligned to two times
+  *   the number of pixels in the table shown below...  x_align,
+  *   y_align values computed above are the relevant entries in the
+  *   referred table.
+  *
+  * Note: An older BSpec documented the above restriction for only
+  * HSW GT3.
   */
  x0 = ROUND_DOWN_TO(x0, 2 * x_align);
  y0 = ROUND_DOWN_TO(y0, 2 * y_align);
-- 
1.8.4

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


[Mesa-dev] [PATCH] i965: Properly reject __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS when __DRI2_ROBUSTNESS is not enabled

2013-11-26 Thread Ian Romanick
From: Ian Romanick 

Only allow __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS in brwCreateContext if
intelInitScreen2 also enabled __DRI2_ROBUSTNESS (thereby enabling
GLX_ARB_create_context).

This fixes a regression in the piglit test
"glx/GLX_ARB_create_context/invalid flag"

Signed-off-by: Ian Romanick 
Reported-by: Paul Berry 
Cc: "10.0" 
---
The patch that causes the regression (9b1c686) hasn't been picked to
10.0 yet, so this patch should get squashed with it when they're both
picked.

 src/mesa/drivers/dri/i965/brw_context.c  | 13 ++---
 src/mesa/drivers/dri/i965/intel_screen.c |  4 +++-
 src/mesa/drivers/dri/i965/intel_screen.h |  5 +
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index 67ac01c..948f3bd 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -558,9 +558,16 @@ brwCreateContext(gl_api api,
struct dd_function_table functions;
struct gl_config visual;
 
-   if (flags & ~(__DRI_CTX_FLAG_DEBUG
- | __DRI_CTX_FLAG_FORWARD_COMPATIBLE
- | __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS)) {
+   /* Only allow the __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS flag if the kernel
+* provides us with context reset notifications.
+*/
+   uint32_t allowed_flags = __DRI_CTX_FLAG_DEBUG
+  | __DRI_CTX_FLAG_FORWARD_COMPATIBLE;
+
+   if (/*false &&*/ screen->has_context_reset_notification)
+  allowed_flags |= __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS;
+
+   if (flags & ~allowed_flags) {
   *dri_ctx_error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
   return false;
}
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c 
b/src/mesa/drivers/dri/i965/intel_screen.c
index 051c000..39c2f35 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -1344,7 +1344,9 @@ __DRIconfig **intelInitScreen2(__DRIscreen *psp)
 
const int ret = drmIoctl(psp->fd, DRM_IOCTL_I915_GET_RESET_STATS, &stats);
 
-   psp->extensions = (ret == -1 && errno == EINVAL)
+   intelScreen->has_context_reset_notification = (ret != -1 || errno != 
EINVAL);
+
+   psp->extensions = !intelScreen->has_context_reset_notification
   ? intelScreenExtensions : intelRobustScreenExtensions;
 
return (const __DRIconfig**) intel_screen_make_configs(psp);
diff --git a/src/mesa/drivers/dri/i965/intel_screen.h 
b/src/mesa/drivers/dri/i965/intel_screen.h
index 2e3043e..924e1f2 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.h
+++ b/src/mesa/drivers/dri/i965/intel_screen.h
@@ -50,6 +50,11 @@ struct intel_screen
 
bool hw_has_swizzling;
 
+   /**
+* Does the kernel support context reset notifications?
+*/
+   bool has_context_reset_notification;
+
dri_bufmgr *bufmgr;
 
/**
-- 
1.8.1.4

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


[Mesa-dev] [PATCH 2/3] Revert "i965: Move brw_emit_query_begin() to the render ring prelude."

2013-11-26 Thread Kenneth Graunke
This reverts commit a4bf7f6b6e612626c4e4fc21507ac213a7ba4b00.
It breaks occlusion queries on Gen4-5.  Doing this right will likely
require larger changes, which should be done at a future date.

Some Piglit tests still passed due to other bugs; fixing those revealed
this problem.

Signed-off-by: Kenneth Graunke 
Cc: Eric Anholt 

Conflicts:
src/mesa/drivers/dri/i965/intel_batchbuffer.c
---
 src/mesa/drivers/dri/i965/brw_draw_upload.c   | 2 ++
 src/mesa/drivers/dri/i965/intel_batchbuffer.c | 8 +---
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c 
b/src/mesa/drivers/dri/i965/brw_draw_upload.c
index 89404b0..57b81df 100644
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
@@ -614,6 +614,8 @@ static void brw_emit_vertices(struct brw_context *brw)
 
brw_prepare_vertices(brw);
 
+   brw_emit_query_begin(brw);
+
nr_elements = brw->vb.nr_enabled + brw->vs.prog_data->uses_vertexid;
 
/* If the VS doesn't read any inputs (calculating vertex position from
diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c 
b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
index 25aacd9..6b25c02 100644
--- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
@@ -182,13 +182,7 @@ do_batch_dump(struct brw_context *brw)
 void
 intel_batchbuffer_emit_render_ring_prelude(struct brw_context *brw)
 {
-   /* Without hardware contexts, we need to capture the pipeline statistics
-* registers at the start and end of each render ring batch, so we can see
-* what that batch contributed.  Emit state packets to write them to a BO.
-*/
-   brw_emit_query_begin(brw);
-
-   /* We may also need to enable and snapshot OA counters. */
+   /* We may need to enable and snapshot OA counters. */
brw_perf_monitor_new_batch(brw);
 }
 
-- 
1.8.4.2

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


[Mesa-dev] [PATCH 3/3] i965: Fix BRW_BATCH_STRUCT to specify RENDER_RING, not UNKNOWN_RING.

2013-11-26 Thread Kenneth Graunke
I missed this in the boolean -> enum conversion.  C cheerfully casts
false -> 0 -> UNKNOWN_RING.  On Gen4-5, this causes the render ring
prelude hook to get called in the middle of the batch, which is crazy.

BRW_BATCH_STRUCT is not used on Gen6+.

Fixes regressions since 395a32717df494353703f3581edcd3ba380f16d6
("i965: Introduce an UNKNOWN_RING state.").

Fixes "fips -v glxgears" on Ironlake.

Signed-off-by: Kenneth Graunke 
Cc: Eric Anholt 
---
 src/mesa/drivers/dri/i965/brw_state.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_state.h 
b/src/mesa/drivers/dri/i965/brw_state.h
index 2a4b23c..3f7831c 100644
--- a/src/mesa/drivers/dri/i965/brw_state.h
+++ b/src/mesa/drivers/dri/i965/brw_state.h
@@ -173,8 +173,8 @@ void brw_destroy_caches( struct brw_context *brw );
 /***
  * brw_state_batch.c
  */
-#define BRW_BATCH_STRUCT(brw, s) intel_batchbuffer_data(brw, (s), \
-   sizeof(*(s)), false)
+#define BRW_BATCH_STRUCT(brw, s) \
+   intel_batchbuffer_data(brw, (s), sizeof(*(s)), RENDER_RING)
 
 void *brw_state_batch(struct brw_context *brw,
  enum state_struct_type type,
-- 
1.8.4.2

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


[Mesa-dev] [PATCH 1/3] i965: Fix OACONTROL assertion failures on Ironlake.

2013-11-26 Thread Kenneth Graunke
I guarded half of the callers to start/stop_oa_counters with generation
checks, but missed the other half (which were added later).  OACONTROL
doesn't exist on Ironlake, so we better not write it.  Also, there's no
need---Ironlake's performance counters are always running.

This patch moves the generation checks into start/stop_oa_counters,
rather than requiring the caller to do them.

Fixes assertion failures in Piglit's AMD_performance_monitor/measure.

Signed-off-by: Kenneth Graunke 
Cc: Eric Anholt 
---
 src/mesa/drivers/dri/i965/brw_performance_monitor.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

These are not candidates for 10.0 since AMD_performance_monitor support
landed after the branch point.  They're bug fixes for master only.

diff --git a/src/mesa/drivers/dri/i965/brw_performance_monitor.c 
b/src/mesa/drivers/dri/i965/brw_performance_monitor.c
index 9bddd8e..ff3cb97 100644
--- a/src/mesa/drivers/dri/i965/brw_performance_monitor.c
+++ b/src/mesa/drivers/dri/i965/brw_performance_monitor.c
@@ -642,6 +642,8 @@ start_oa_counters(struct brw_context *brw)
 
/* Pick the counter format which gives us all the counters. */
switch (brw->gen) {
+   case 5:
+  return; /* Ironlake counters are always running. */
case 6:
   counter_format = 1; /* 0b001 */
   break;
@@ -667,6 +669,10 @@ start_oa_counters(struct brw_context *brw)
 static void
 stop_oa_counters(struct brw_context *brw)
 {
+   /* Ironlake counters never stop. */
+   if (brw->gen == 5)
+  return;
+
BEGIN_BATCH(3);
OUT_BATCH(MI_LOAD_REGISTER_IMM | (3 - 2));
OUT_BATCH(OACONTROL);
@@ -1367,8 +1373,7 @@ brw_perf_monitor_new_batch(struct brw_context *brw)
if (brw->perfmon.oa_users == 0)
   return;
 
-   if (brw->gen >= 6)
-  start_oa_counters(brw);
+   start_oa_counters(brw);
 
/* Make sure bookend_bo has enough space for a pair of snapshots.
 * If not, "wrap" the BO: gather up any results so far, and start from
@@ -1405,8 +1410,7 @@ brw_perf_monitor_finish_batch(struct brw_context *brw)
 
emit_bookend_snapshot(brw);
 
-   if (brw->gen >= 6)
-  stop_oa_counters(brw);
+   stop_oa_counters(brw);
 }
 
 
/**/
-- 
1.8.4.2

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


Re: [Mesa-dev] [PATCH 1/8] mesa: Add missing checks for GL_TEXTURE_CUBE_MAP_ARRAY

2013-11-26 Thread Dave Airlie
On Wed, Nov 27, 2013 at 9:54 AM, Ian Romanick  wrote:
> From: Ian Romanick 
>
> That enum requires GL_ARB_texture_cube_map_array, and it is only
> available on desktop GL.  It looks like this has been an un-noticed
> issue since GL_ARB_texture_cube_map_array support was added in commit
> e0e7e295.
>

Looks good to me,

Reviewed-by: Dave Airlie 

> Since this just adds a missing error check, it's arguable that this
> should not be included in stable branches.  Opinions?

and can't see the point of stable for it.

>
>  src/mesa/main/texobj.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
> index abd30c5..c110f50 100644
> --- a/src/mesa/main/texobj.c
> +++ b/src/mesa/main/texobj.c
> @@ -1205,7 +1205,8 @@ target_enum_to_index(struct gl_context *ctx, GLenum 
> target)
>return _mesa_is_gles(ctx) && ctx->Extensions.OES_EGL_image_external
>   ? TEXTURE_EXTERNAL_INDEX : -1;
> case GL_TEXTURE_CUBE_MAP_ARRAY:
> -  return TEXTURE_CUBE_ARRAY_INDEX;
> +  return _mesa_is_desktop_gl(ctx) && 
> ctx->Extensions.ARB_texture_cube_map_array
> + ? TEXTURE_CUBE_ARRAY_INDEX : -1;
> case GL_TEXTURE_2D_MULTISAMPLE:
>return _mesa_is_desktop_gl(ctx) && 
> ctx->Extensions.ARB_texture_multisample
>   ? TEXTURE_2D_MULTISAMPLE_INDEX: -1;
> --
> 1.8.1.4
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 6/8] mesa: Use a single enable for GL_EXT_texture_array and GL_MESA_texture_array

2013-11-26 Thread Ian Romanick
From: Ian Romanick 

Every driver that enables one also enables the other.  The difference
between the two is MESA adds support for fixed-function and assembly
fragment shaders, but EXT only adds support for GLSL.  The MESA
extension was created back when Mesa did not support GLSL.

Signed-off-by: Ian Romanick 
---
 src/mesa/drivers/dri/i965/intel_extensions.c |  1 -
 src/mesa/main/attrib.c   |  6 +++---
 src/mesa/main/enable.c   |  4 ++--
 src/mesa/main/extensions.c   |  3 +--
 src/mesa/main/get.c  |  5 ++---
 src/mesa/main/get_hash_params.py |  6 +++---
 src/mesa/main/mtypes.h   |  1 -
 src/mesa/main/texgetimage.c  |  3 +--
 src/mesa/main/teximage.c | 29 
 src/mesa/main/texobj.c   |  8 ++--
 src/mesa/main/texparam.c | 10 +++---
 src/mesa/main/texstorage.c   |  6 ++
 src/mesa/program/program_parse_extra.c   |  2 +-
 src/mesa/state_tracker/st_extensions.c   |  1 -
 14 files changed, 28 insertions(+), 57 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c 
b/src/mesa/drivers/dri/i965/intel_extensions.c
index ab27d43..d9bec71 100644
--- a/src/mesa/drivers/dri/i965/intel_extensions.c
+++ b/src/mesa/drivers/dri/i965/intel_extensions.c
@@ -228,7 +228,6 @@ intelInitExtensions(struct gl_context *ctx)
ctx->Extensions.ATI_separate_stencil = true;
ctx->Extensions.ATI_texture_env_combine3 = true;
ctx->Extensions.MESA_pack_invert = true;
-   ctx->Extensions.MESA_texture_array = true;
ctx->Extensions.MESA_ycbcr_texture = true;
ctx->Extensions.NV_conditional_render = true;
ctx->Extensions.NV_primitive_restart = true;
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index c9332bd..718eb83 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -641,7 +641,7 @@ pop_enable_group(struct gl_context *ctx, const struct 
gl_enable_attrib *enable)
 _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP,
  !!(enabled & TEXTURE_CUBE_BIT));
  }
- if (ctx->Extensions.MESA_texture_array) {
+ if (ctx->Extensions.EXT_texture_array) {
 _mesa_set_enable(ctx, GL_TEXTURE_1D_ARRAY_EXT,
  !!(enabled & TEXTURE_1D_ARRAY_BIT));
 _mesa_set_enable(ctx, GL_TEXTURE_2D_ARRAY_EXT,
@@ -688,7 +688,7 @@ pop_texture_group(struct gl_context *ctx, struct 
texture_state *texstate)
  _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE_NV,
   !!(unit->Enabled & TEXTURE_RECT_BIT));
   }
-  if (ctx->Extensions.MESA_texture_array) {
+  if (ctx->Extensions.EXT_texture_array) {
  _mesa_set_enable(ctx, GL_TEXTURE_1D_ARRAY_EXT,
   !!(unit->Enabled & TEXTURE_1D_ARRAY_BIT));
  _mesa_set_enable(ctx, GL_TEXTURE_2D_ARRAY_EXT,
@@ -768,7 +768,7 @@ pop_texture_group(struct gl_context *ctx, struct 
texture_state *texstate)
  }
  else if ((obj->Target == GL_TEXTURE_1D_ARRAY_EXT ||
obj->Target == GL_TEXTURE_2D_ARRAY_EXT) &&
-  !ctx->Extensions.MESA_texture_array) {
+  !ctx->Extensions.EXT_texture_array) {
 continue;
  }
  else if (obj->Target == GL_TEXTURE_CUBE_MAP_ARRAY &&
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index c047f5d..869c8a2 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -938,7 +938,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, 
GLboolean state)
   case GL_TEXTURE_1D_ARRAY_EXT:
  if (ctx->API != API_OPENGL_COMPAT)
 goto invalid_enum_error;
- CHECK_EXTENSION(MESA_texture_array, cap);
+ CHECK_EXTENSION(EXT_texture_array, cap);
  if (!enable_texture(ctx, state, TEXTURE_1D_ARRAY_BIT)) {
 return;
  }
@@ -947,7 +947,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, 
GLboolean state)
   case GL_TEXTURE_2D_ARRAY_EXT:
  if (ctx->API != API_OPENGL_COMPAT)
 goto invalid_enum_error;
- CHECK_EXTENSION(MESA_texture_array, cap);
+ CHECK_EXTENSION(EXT_texture_array, cap);
  if (!enable_texture(ctx, state, TEXTURE_2D_ARRAY_BIT)) {
 return;
  }
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 42da905..04d1828 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -321,7 +321,7 @@ static const struct extension extension_table[] = {
{ "GL_IBM_texture_mirrored_repeat", o(dummy_true),  
GLL,1998 },
{ "GL_INGR_blend_func_separate",o(EXT_blend_func_separate), 
GLL,1999 },
{ "GL_MESA_pack_invert",o(MESA_pack_invert),
 

[Mesa-dev] [PATCH 4/8] mesa: Silence GCC warning in count_tex_size

2013-11-26 Thread Ian Romanick
From: Ian Romanick 

main/texobj.c: In function 'count_tex_size':
main/texobj.c:886:23: warning: unused parameter 'key' [-Wunused-parameter]

Signed-off-by: Ian Romanick 
---
 src/mesa/main/texobj.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 012e873..6468962 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -889,6 +889,8 @@ count_tex_size(GLuint key, void *data, void *userData)
   (const struct gl_texture_object *) data;
GLuint *total = (GLuint *) userData;
 
+   (void) key;
+
*total = *total + texture_size(texObj);
 }
 
-- 
1.8.1.4

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


[Mesa-dev] [PATCH 3/8] mesa: Silence GCC warning in _mesa_test_texobj_completeness

2013-11-26 Thread Ian Romanick
From: Ian Romanick 

main/texobj.c: In function '_mesa_test_texobj_completeness':
main/texobj.c:553:34: warning: comparison between signed and unsigned integer 
expressions [-Wsign-compare]
main/texobj.c:553:193: warning: comparison between signed and unsigned integer 
expressions [-Wsign-compare]
main/texobj.c:553:254: warning: signed and unsigned type in conditional 
expression [-Wsign-compare]
main/texobj.c:553:148: warning: signed and unsigned type in conditional 
expression [-Wsign-compare]

Signed-off-by: Ian Romanick 
---
 src/mesa/main/texobj.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 4c3d468..012e873 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -552,7 +552,7 @@ _mesa_test_texobj_completeness( const struct gl_context 
*ctx,
 
t->_MaxLevel = MIN3(t->MaxLevel,
/* 'p' in the GL spec */
-   baseLevel + baseImage->MaxNumLevels - 1,
+   (int) (baseLevel + baseImage->MaxNumLevels - 1),
/* 'q' in the GL spec */
maxLevels - 1);
 
-- 
1.8.1.4

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


[Mesa-dev] [PATCH 7/8] mesa: Remove support for GL_MESA_texture_array

2013-11-26 Thread Ian Romanick
From: Ian Romanick 

This extension enabled the use of texture array with fixed-function and
assembly fragment shaders.  No applications are known to use this
extension.

Signed-off-by: Ian Romanick 
---
 docs/relnotes/10.1.html|  6 +-
 docs/specs/MESA_texture_array.spec |  2 +-
 src/mesa/main/attrib.c | 17 ++---
 src/mesa/main/enable.c | 19 ---
 src/mesa/main/extensions.c |  1 -
 src/mesa/program/program_parse_extra.c |  9 -
 6 files changed, 8 insertions(+), 46 deletions(-)

diff --git a/docs/relnotes/10.1.html b/docs/relnotes/10.1.html
index 1b8ea22..dfb0969 100644
--- a/docs/relnotes/10.1.html
+++ b/docs/relnotes/10.1.html
@@ -54,7 +54,11 @@ TBD.
 
 Changes
 
-TBD.
+
+Removed support for the GL_MESA_texture_array extension.  This extension
+  enabled the use of texture array with fixed-function and assembly fragment
+  shaders.  No applications are known to use this extension.
+
 
 
 
diff --git a/docs/specs/MESA_texture_array.spec 
b/docs/specs/MESA_texture_array.spec
index b146821..3e3e82c 100644
--- a/docs/specs/MESA_texture_array.spec
+++ b/docs/specs/MESA_texture_array.spec
@@ -16,7 +16,7 @@ IP Status
 
 Status
 
-Shipping in Mesa 7.1
+DEPRECATED - Support removed in Mesa 10.1.
 
 Version
 
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 718eb83..ca67fd4 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -641,12 +641,6 @@ pop_enable_group(struct gl_context *ctx, const struct 
gl_enable_attrib *enable)
 _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP,
  !!(enabled & TEXTURE_CUBE_BIT));
  }
- if (ctx->Extensions.EXT_texture_array) {
-_mesa_set_enable(ctx, GL_TEXTURE_1D_ARRAY_EXT,
- !!(enabled & TEXTURE_1D_ARRAY_BIT));
-_mesa_set_enable(ctx, GL_TEXTURE_2D_ARRAY_EXT,
- !!(enabled & TEXTURE_2D_ARRAY_BIT));
- }
   }
 
   if (ctx->Texture.Unit[i].TexGenEnabled != genEnabled) {
@@ -688,12 +682,6 @@ pop_texture_group(struct gl_context *ctx, struct 
texture_state *texstate)
  _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE_NV,
   !!(unit->Enabled & TEXTURE_RECT_BIT));
   }
-  if (ctx->Extensions.EXT_texture_array) {
- _mesa_set_enable(ctx, GL_TEXTURE_1D_ARRAY_EXT,
-  !!(unit->Enabled & TEXTURE_1D_ARRAY_BIT));
- _mesa_set_enable(ctx, GL_TEXTURE_2D_ARRAY_EXT,
-  !!(unit->Enabled & TEXTURE_2D_ARRAY_BIT));
-  }
   _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, unit->EnvMode);
   _mesa_TexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, unit->EnvColor);
   _mesa_TexGeni(GL_S, GL_TEXTURE_GEN_MODE, unit->GenS.Mode);
@@ -766,9 +754,8 @@ pop_texture_group(struct gl_context *ctx, struct 
texture_state *texstate)
   !ctx->Extensions.NV_texture_rectangle) {
 continue;
  }
- else if ((obj->Target == GL_TEXTURE_1D_ARRAY_EXT ||
-   obj->Target == GL_TEXTURE_2D_ARRAY_EXT) &&
-  !ctx->Extensions.EXT_texture_array) {
+ else if (obj->Target == GL_TEXTURE_1D_ARRAY_EXT ||
+  obj->Target == GL_TEXTURE_2D_ARRAY_EXT) {
 continue;
  }
  else if (obj->Target == GL_TEXTURE_CUBE_MAP_ARRAY &&
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 869c8a2..bb4a23c 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -934,25 +934,6 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, 
GLboolean state)
ctx->ATIFragmentShader.Enabled = state;
 break;
 
-  /* GL_MESA_texture_array */
-  case GL_TEXTURE_1D_ARRAY_EXT:
- if (ctx->API != API_OPENGL_COMPAT)
-goto invalid_enum_error;
- CHECK_EXTENSION(EXT_texture_array, cap);
- if (!enable_texture(ctx, state, TEXTURE_1D_ARRAY_BIT)) {
-return;
- }
- break;
-
-  case GL_TEXTURE_2D_ARRAY_EXT:
- if (ctx->API != API_OPENGL_COMPAT)
-goto invalid_enum_error;
- CHECK_EXTENSION(EXT_texture_array, cap);
- if (!enable_texture(ctx, state, TEXTURE_2D_ARRAY_BIT)) {
-return;
- }
- break;
-
   case GL_TEXTURE_CUBE_MAP_SEAMLESS:
  if (!_mesa_is_desktop_gl(ctx))
 goto invalid_enum_error;
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 04d1828..77b5504 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -321,7 +321,6 @@ static const struct extension extension_table[] = {
{ "GL_IBM_texture_mirrored_repeat", o(dummy_true),  
GLL,1998 },
{ "GL_INGR_blend_func_separate",o(EXT_blend_func_separate), 
GLL,1999 },
{ "GL_MESA_pack_inver

[Mesa-dev] [PATCH 5/8] mesa: Minor clean-up of target_enum_to_index

2013-11-26 Thread Ian Romanick
From: Ian Romanick 

Constify the gl_context parameter, and remove suffixes from enums that
have non-suffix versions.

Signed-off-by: Ian Romanick 
---
 src/mesa/main/texobj.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 6468962..e88c706 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -1173,7 +1173,7 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures)
  * \return TEXTURE_x_INDEX or -1 if target is invalid
  */
 static GLint
-target_enum_to_index(struct gl_context *ctx, GLenum target)
+target_enum_to_index(const struct gl_context *ctx, GLenum target)
 {
switch (target) {
case GL_TEXTURE_1D:
@@ -1182,24 +1182,24 @@ target_enum_to_index(struct gl_context *ctx, GLenum 
target)
   return TEXTURE_2D_INDEX;
case GL_TEXTURE_3D:
   return ctx->API != API_OPENGLES ? TEXTURE_3D_INDEX : -1;
-   case GL_TEXTURE_CUBE_MAP_ARB:
+   case GL_TEXTURE_CUBE_MAP:
   return ctx->Extensions.ARB_texture_cube_map
  ? TEXTURE_CUBE_INDEX : -1;
-   case GL_TEXTURE_RECTANGLE_NV:
+   case GL_TEXTURE_RECTANGLE:
   return _mesa_is_desktop_gl(ctx) && ctx->Extensions.NV_texture_rectangle
  ? TEXTURE_RECT_INDEX : -1;
-   case GL_TEXTURE_1D_ARRAY_EXT:
+   case GL_TEXTURE_1D_ARRAY:
   return _mesa_is_desktop_gl(ctx)
  && (ctx->Extensions.EXT_texture_array
  || ctx->Extensions.MESA_texture_array)
  ? TEXTURE_1D_ARRAY_INDEX : -1;
-   case GL_TEXTURE_2D_ARRAY_EXT:
+   case GL_TEXTURE_2D_ARRAY:
   return (_mesa_is_desktop_gl(ctx)
   && (ctx->Extensions.EXT_texture_array
   || ctx->Extensions.MESA_texture_array))
  || _mesa_is_gles3(ctx)
  ? TEXTURE_2D_ARRAY_INDEX : -1;
-   case GL_TEXTURE_BUFFER_ARB:
+   case GL_TEXTURE_BUFFER:
   return ctx->API == API_OPENGL_CORE &&
  ctx->Extensions.ARB_texture_buffer_object ?
  TEXTURE_BUFFER_INDEX : -1;
-- 
1.8.1.4

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


[Mesa-dev] [PATCH 2/8] mesa: Add missing API check for GL_TEXTURE_3D

2013-11-26 Thread Ian Romanick
From: Ian Romanick 

There are no 3D textures in OpenGL ES 1.x.

Signed-off-by: Ian Romanick 
Cc: "9.1 9.2 10.0" 
---
Since this just adds a missing error check, it's arguable that this
should not be included in stable branches.  Opinions?

 src/mesa/main/texobj.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index c110f50..4c3d468 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -1179,7 +1179,7 @@ target_enum_to_index(struct gl_context *ctx, GLenum 
target)
case GL_TEXTURE_2D:
   return TEXTURE_2D_INDEX;
case GL_TEXTURE_3D:
-  return TEXTURE_3D_INDEX;
+  return ctx->API != API_OPENGLES ? TEXTURE_3D_INDEX : -1;
case GL_TEXTURE_CUBE_MAP_ARB:
   return ctx->Extensions.ARB_texture_cube_map
  ? TEXTURE_CUBE_INDEX : -1;
-- 
1.8.1.4

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


[Mesa-dev] [PATCH 8/8] mesa: Remove GL_MESA_texture_array cruft from gl.h

2013-11-26 Thread Ian Romanick
From: Ian Romanick 

glext.h has had all the necessary bits for years.

Signed-off-by: Ian Romanick 
---
 include/GL/gl.h | 33 -
 1 file changed, 33 deletions(-)

diff --git a/include/GL/gl.h b/include/GL/gl.h
index b484b96..48343f6 100644
--- a/include/GL/gl.h
+++ b/include/GL/gl.h
@@ -2078,39 +2078,6 @@ typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) 
(GLenum target, const GLsh
 #endif /* GL_MESA_packed_depth_stencil */
 
 
-#ifndef GL_MESA_texture_array
-#define GL_MESA_texture_array 1
-
-/* GL_MESA_texture_array uses the same enum values as GL_EXT_texture_array.
- */
-#ifndef GL_EXT_texture_array
-
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glFramebufferTextureLayerEXT(GLenum target,
-GLenum attachment, GLuint texture, GLint level, GLint layer);
-#endif /* GL_GLEXT_PROTOTYPES */
-
-#if 0
-/* (temporarily) disabled because of collision with typedef in glext.h
- * that happens if apps include both gl.h and glext.h
- */
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target,
-GLenum attachment, GLuint texture, GLint level, GLint layer);
-#endif
-
-#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18
-#define GL_PROXY_TEXTURE_1D_ARRAY_EXT   0x8C19
-#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A
-#define GL_PROXY_TEXTURE_2D_ARRAY_EXT   0x8C1B
-#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C
-#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D
-#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4
-#endif
-
-#endif
-
-
 #ifndef GL_ATI_blend_equation_separate
 #define GL_ATI_blend_equation_separate 1
 
-- 
1.8.1.4

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


[Mesa-dev] [PATCH 1/8] mesa: Add missing checks for GL_TEXTURE_CUBE_MAP_ARRAY

2013-11-26 Thread Ian Romanick
From: Ian Romanick 

That enum requires GL_ARB_texture_cube_map_array, and it is only
available on desktop GL.  It looks like this has been an un-noticed
issue since GL_ARB_texture_cube_map_array support was added in commit
e0e7e295.

Signed-off-by: Ian Romanick 
Cc: Dave Airlie 
Cc: "9.1 9.2 10.0" 
---
Since this just adds a missing error check, it's arguable that this
should not be included in stable branches.  Opinions?

 src/mesa/main/texobj.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index abd30c5..c110f50 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -1205,7 +1205,8 @@ target_enum_to_index(struct gl_context *ctx, GLenum 
target)
   return _mesa_is_gles(ctx) && ctx->Extensions.OES_EGL_image_external
  ? TEXTURE_EXTERNAL_INDEX : -1;
case GL_TEXTURE_CUBE_MAP_ARRAY:
-  return TEXTURE_CUBE_ARRAY_INDEX;
+  return _mesa_is_desktop_gl(ctx) && 
ctx->Extensions.ARB_texture_cube_map_array
+ ? TEXTURE_CUBE_ARRAY_INDEX : -1;
case GL_TEXTURE_2D_MULTISAMPLE:
   return _mesa_is_desktop_gl(ctx) && 
ctx->Extensions.ARB_texture_multisample
  ? TEXTURE_2D_MULTISAMPLE_INDEX: -1;
-- 
1.8.1.4

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


[Mesa-dev] [PATCH 1/2] glsl: extract function for record comparisons

2013-11-26 Thread Grigori Goronzy
---
 src/glsl/glsl_types.cpp | 61 +++--
 src/glsl/glsl_types.h   |  7 ++
 2 files changed, 41 insertions(+), 27 deletions(-)

diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
index f740130..6c9727e 100644
--- a/src/glsl/glsl_types.cpp
+++ b/src/glsl/glsl_types.cpp
@@ -447,6 +447,39 @@ glsl_type::get_array_instance(const glsl_type *base, 
unsigned array_size)
 }
 
 
+bool
+glsl_type::record_compare(const glsl_type *b) const
+{
+   if (this->length != b->length)
+  return false;
+
+   if (this->interface_packing != b->interface_packing)
+  return false;
+
+   for (unsigned i = 0; i < this->length; i++) {
+  if (this->fields.structure[i].type != b->fields.structure[i].type)
+return false;
+  if (strcmp(this->fields.structure[i].name,
+b->fields.structure[i].name) != 0)
+return false;
+  if (this->fields.structure[i].row_major
+ != b->fields.structure[i].row_major)
+return false;
+  if (this->fields.structure[i].location
+  != b->fields.structure[i].location)
+ return false;
+  if (this->fields.structure[i].interpolation
+  != b->fields.structure[i].interpolation)
+ return false;
+  if (this->fields.structure[i].centroid
+  != b->fields.structure[i].centroid)
+ return false;
+   }
+
+   return true;
+}
+
+
 int
 glsl_type::record_key_compare(const void *a, const void *b)
 {
@@ -459,33 +492,7 @@ glsl_type::record_key_compare(const void *a, const void *b)
if (strcmp(key1->name, key2->name) != 0)
   return 1;
 
-   if (key1->length != key2->length)
-  return 1;
-
-   if (key1->interface_packing != key2->interface_packing)
-  return 1;
-
-   for (unsigned i = 0; i < key1->length; i++) {
-  if (key1->fields.structure[i].type != key2->fields.structure[i].type)
-return 1;
-  if (strcmp(key1->fields.structure[i].name,
-key2->fields.structure[i].name) != 0)
-return 1;
-  if (key1->fields.structure[i].row_major
- != key2->fields.structure[i].row_major)
-return 1;
-  if (key1->fields.structure[i].location
-  != key2->fields.structure[i].location)
- return 1;
-  if (key1->fields.structure[i].interpolation
-  != key2->fields.structure[i].interpolation)
- return 1;
-  if (key1->fields.structure[i].centroid
-  != key2->fields.structure[i].centroid)
- return 1;
-   }
-
-   return 0;
+   return !key1->record_compare(key2);
 }
 
 
diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h
index 96eee5e..dcc98e0 100644
--- a/src/glsl/glsl_types.h
+++ b/src/glsl/glsl_types.h
@@ -542,6 +542,13 @@ struct glsl_type {
 */
int sampler_coordinate_components() const;
 
+   /**
+* Compare a record type against another record type.
+*
+* This is useful for matching record types declared across shader stages.
+*/
+   bool record_compare(const glsl_type *b) const;
+
 private:
/**
 * ralloc context for all glsl_type allocations
-- 
1.8.1.2

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


[Mesa-dev] [PATCH 2/2] glsl: match unnamed record types across stages

2013-11-26 Thread Grigori Goronzy
Unnamed record types are assigned to separate types per stage, e.g.

uniform struct { ... } a;

if defined in both vertex and fragment shader, will result in two
separate types of different name. When linking the shader, this
results in a type conflict. However, there is no reason why this
should not be allowed according to GLSL specifications. Compare and
match record types when linking shader stages to avoid this conflict.
---
 src/glsl/linker.cpp | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 1366077..c60753c 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -609,6 +609,10 @@ cross_validate_globals(struct gl_shader_program *prog,
  if (var->type->length != 0) {
 existing->type = var->type;
  }
+   } else if (var->type->is_record()
+  && existing->type->is_record()
+  && existing->type->record_compare(var->type)) {
+ existing->type = var->type;
   } else {
  linker_error(prog, "%s `%s' declared as type "
   "`%s' and type `%s'\n",
-- 
1.8.1.2

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


Re: [Mesa-dev] [PATCH 7/9] mesa: Fill out ARB_texture_view entry points

2013-11-26 Thread Courtney Goeltzenleuchter
With these changes, what needs to happen to commit these changes to master?

Thanks,
Courtney


On Mon, Nov 25, 2013 at 6:01 PM, Courtney Goeltzenleuchter <
court...@lunarg.com> wrote:

> While incorporating Brian's comments I did some refactoring to consolidate
> multiple uses of next_mimap_level_size into one shared helper function.
> That adds another commit to the stream. I thought it was big enough now
> that I should post the branch to make it easier to use.
>
> I've posted the updated stream, including the next_mipmap_level_size
> refactoring on github here:
> https://github.com/courtney-lunarg/mesa/tree/texture_view-rc5
>
> Courtney
>
> --
> Courtney Goeltzenleuchter
> LunarG
>
>


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


Re: [Mesa-dev] radeonsi: always set the scanout flag?

2013-11-26 Thread Marek Olšák
Does the attached patch fix the issue for you?

Marek

On Tue, Nov 26, 2013 at 9:20 AM, Axel Davy  wrote:
> Hi,
>
> When importing an handle (src/gallium/drivers/radeon/r600_texture.c),
> the RADEON_SURF_SCANOUT flag is always set on SI.
>
> The code is associated with a comment: /* always set the scanout flags on SI
> */
>
> I was getting bad tiling mode on Wayland with my radeonsi card, and recent
> Mesa,
> and I discovered that setting this flag there was causing my tiling issue.
>
> I think one possible reason for this code is X dri2, since the DDX allocates
> the buffers with this flag.
>
> Could this flag be passed via buffer_get_tiling?
>
> If not, then there would probably need to force this flag when creating a
> resource on SI.
> But ideally, if it makes a performance difference, we would like to be able
> to control that
> with Wayland when allocating the buffers.
>
> Axel Davy
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
From 1f042c9e7ba105445d149e49de5f9bb60209ee01 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= 
Date: Tue, 26 Nov 2013 22:59:31 +0100
Subject: [PATCH] winsys/radeon: pass the scanout flag between Mesa drivers in
 different processes

If we assume that all buffers allocated by the DDX are scanout, a new flag
that says "this is not scanout" has to be added to support the non-scanout
buffers and maintain backward compatibility.
---
 src/gallium/drivers/r300/r300_state.c |  2 +-
 src/gallium/drivers/r300/r300_texture.c   |  5 +++--
 src/gallium/drivers/radeon/r600_texture.c |  9 +
 src/gallium/winsys/radeon/drm/radeon_drm_bo.c | 12 ++--
 src/gallium/winsys/radeon/drm/radeon_winsys.h |  6 --
 5 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
index 6840e8b..048672c 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -844,7 +844,7 @@ static void r300_tex_set_tiling_flags(struct r300_context *r300,
 r300->rws->buffer_set_tiling(tex->buf, r300->cs,
 tex->tex.microtile, tex->tex.macrotile[level],
 0, 0, 0, 0, 0,
-tex->tex.stride_in_bytes[0]);
+tex->tex.stride_in_bytes[0], false);
 
 tex->surface_level = level;
 }
diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c
index b7fb081..4ea69dc 100644
--- a/src/gallium/drivers/r300/r300_texture.c
+++ b/src/gallium/drivers/r300/r300_texture.c
@@ -1060,7 +1060,7 @@ r300_texture_create_object(struct r300_screen *rscreen,
 rws->buffer_set_tiling(tex->buf, NULL,
 tex->tex.microtile, tex->tex.macrotile[0],
 0, 0, 0, 0, 0,
-tex->tex.stride_in_bytes[0]);
+tex->tex.stride_in_bytes[0], false);
 
 return tex;
 
@@ -1115,7 +1115,8 @@ struct pipe_resource *r300_texture_from_handle(struct pipe_screen *screen,
 if (!buffer)
 return NULL;
 
-rws->buffer_get_tiling(buffer, µtile, ¯otile, NULL, NULL, NULL, NULL, NULL);
+rws->buffer_get_tiling(buffer, µtile, ¯otile, NULL, NULL, NULL,
+   NULL, NULL, NULL);
 
 /* Enforce a microtiled zbuffer. */
 if (util_format_is_depth_or_stencil(base->format) &&
diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c
index 12f412d..bd1d4c8 100644
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -253,7 +253,8 @@ static boolean r600_texture_get_handle(struct pipe_screen* screen,
    surface->tile_split,
    surface->stencil_tile_split,
    surface->mtilea,
-   surface->level[0].pitch_bytes);
+   surface->level[0].pitch_bytes,
+   (surface->flags & RADEON_SURF_SCANOUT) != 0);
 
 	return rscreen->ws->buffer_get_handle(resource->buf,
 		surface->level[0].pitch_bytes, whandle);
@@ -760,6 +761,7 @@ struct pipe_resource *r600_texture_from_handle(struct pipe_screen *screen,
 	unsigned array_mode;
 	enum radeon_bo_layout micro, macro;
 	struct radeon_surface surface;
+	bool scanout;
 	int r;
 
 	/* Support only 2D textures without mipmaps */
@@ -775,7 +777,7 @@ struct pipe_resource *r600_texture_from_handle(struct pipe_screen *screen,
    &surface.bankw, &surface.bankh,
    &surface.tile_split,
    &surface.stencil_tile_split,
-   &surface.mtilea);
+   &surface.mtilea, &scanout);
 
 	if (macro == RADEON_LAYOUT_TILED)
 		array_mode = RADEON_SURF_MODE_2D;
@@ -789,8 +791,7 @@ struct pipe_resource *r600_texture_from_handle(struct pipe_screen *screen,
 		return NULL;
 	}
 
-	/* always set the scanout flags on SI */
-	if (rscreen->chip_class >= SI)
+	if (scanout)
 		surface.flags |= RADEON_SURF_SCANOUT;
 
 	return (struct pipe

Re: [Mesa-dev] [PATCH v2 2/5] meta: fix meta clear of layered framebuffers

2013-11-26 Thread Paul Berry
On 20 November 2013 14:29, Paul Berry  wrote:

> From section 4.4.7 (Layered Framebuffers) of the GLSL 3.2 spec:
>
> When the Clear or ClearBuffer* commands are used to clear a
> layered framebuffer attachment, all layers of the attachment are
> cleared.
>
> This patch fixes meta clears to properly clear all layers of a layered
> framebuffer attachment.  We accomplish this by adding a geometry
> shader to the meta clear program which sets gl_Layer to a uniform
> value.  When clearing a layered framebuffer, we execute in a loop,
> setting the uniform to point to each layer in turn.
>
> Cc: "10.0" 
>

I had previously asked for us *not* to cherry-pick this back to stable,
because it caused bug 71870 to turn into a crash.

That issue has now been addressed by commit 2714ca8 (i965/gs: Properly skip
GS binding table upload when no GS active.)  Once commit 2714ca8 has been
cherry-picked to 10.0, it should be safe to cherry pick this commit
(068a073) to 10.0.


> ---
>  src/mesa/drivers/common/meta.c | 51
> +++---
>  1 file changed, 48 insertions(+), 3 deletions(-)
>
> diff --git a/src/mesa/drivers/common/meta.c
> b/src/mesa/drivers/common/meta.c
> index 99b02ba..0c05cc0 100644
> --- a/src/mesa/drivers/common/meta.c
> +++ b/src/mesa/drivers/common/meta.c
> @@ -241,9 +241,11 @@ struct clear_state
> GLuint VBO;
> GLuint ShaderProg;
> GLint ColorLocation;
> +   GLint LayerLocation;
>
> GLuint IntegerShaderProg;
> GLint IntegerColorLocation;
> +   GLint IntegerLayerLocation;
>  };
>
>
> @@ -2145,6 +2147,19 @@ meta_glsl_clear_init(struct gl_context *ctx, struct
> clear_state *clear)
>"{\n"
>"   gl_Position = position;\n"
>"}\n";
> +   const char *gs_source =
> +  "#version 150\n"
> +  "layout(triangles) in;\n"
> +  "layout(triangle_strip, max_vertices = 4) out;\n"
> +  "uniform int layer;\n"
> +  "void main()\n"
> +  "{\n"
> +  "  for (int i = 0; i < 3; i++) {\n"
> +  "gl_Layer = layer;\n"
> +  "gl_Position = gl_in[i].gl_Position;\n"
> +  "EmitVertex();\n"
> +  "  }\n"
> +  "}\n";
> const char *fs_source =
>"#ifdef GL_ES\n"
>"precision highp float;\n"
> @@ -2154,7 +2169,7 @@ meta_glsl_clear_init(struct gl_context *ctx, struct
> clear_state *clear)
>"{\n"
>"   gl_FragColor = color;\n"
>"}\n";
> -   GLuint vs, fs;
> +   GLuint vs, gs = 0, fs;
> bool has_integer_textures;
>
> if (clear->ArrayObj != 0)
> @@ -2176,6 +2191,12 @@ meta_glsl_clear_init(struct gl_context *ctx, struct
> clear_state *clear)
> _mesa_ShaderSource(vs, 1, &vs_source, NULL);
> _mesa_CompileShader(vs);
>
> +   if (_mesa_has_geometry_shaders(ctx)) {
> +  gs = _mesa_CreateShaderObjectARB(GL_GEOMETRY_SHADER);
> +  _mesa_ShaderSource(gs, 1, &gs_source, NULL);
> +  _mesa_CompileShader(gs);
> +   }
> +
> fs = _mesa_CreateShaderObjectARB(GL_FRAGMENT_SHADER);
> _mesa_ShaderSource(fs, 1, &fs_source, NULL);
> _mesa_CompileShader(fs);
> @@ -2183,6 +2204,8 @@ meta_glsl_clear_init(struct gl_context *ctx, struct
> clear_state *clear)
> clear->ShaderProg = _mesa_CreateProgramObjectARB();
> _mesa_AttachShader(clear->ShaderProg, fs);
> _mesa_DeleteObjectARB(fs);
> +   if (gs != 0)
> +  _mesa_AttachShader(clear->ShaderProg, gs);
> _mesa_AttachShader(clear->ShaderProg, vs);
> _mesa_DeleteObjectARB(vs);
> _mesa_BindAttribLocation(clear->ShaderProg, 0, "position");
> @@ -2190,6 +2213,10 @@ meta_glsl_clear_init(struct gl_context *ctx, struct
> clear_state *clear)
>
> clear->ColorLocation = _mesa_GetUniformLocation(clear->ShaderProg,
>   "color");
> +   if (gs != 0) {
> +  clear->LayerLocation = _mesa_GetUniformLocation(clear->ShaderProg,
> + "layer");
> +   }
>
> has_integer_textures = _mesa_is_gles3(ctx) ||
>(_mesa_is_desktop_gl(ctx) && ctx->Const.GLSLVersion >= 130);
> @@ -2227,6 +2254,8 @@ meta_glsl_clear_init(struct gl_context *ctx, struct
> clear_state *clear)
>clear->IntegerShaderProg = _mesa_CreateProgramObjectARB();
>_mesa_AttachShader(clear->IntegerShaderProg, fs);
>_mesa_DeleteObjectARB(fs);
> +  if (gs != 0)
> + _mesa_AttachShader(clear->IntegerShaderProg, gs);
>_mesa_AttachShader(clear->IntegerShaderProg, vs);
>_mesa_DeleteObjectARB(vs);
>_mesa_BindAttribLocation(clear->IntegerShaderProg, 0, "position");
> @@ -2240,7 +2269,13 @@ meta_glsl_clear_init(struct gl_context *ctx, struct
> clear_state *clear)
>
>clear->IntegerColorLocation =
>  _mesa_GetUniformLocation(clear->IntegerShaderProg, "color");
> +  if (gs != 0) {
> + clear->IntegerLayerLocation =
> +_mesa_GetUniformLocation(clear->IntegerShaderProg, "layer");
> +  }
> }
> +   if (gs != 0)
> +  _mesa_DeleteObjectARB(gs)

Re: [Mesa-dev] [Mesa-stable] [PATCH] glsl: Initialize _mesa_glsl_parse_state::atomic_counter_offsets before using it.

2013-11-26 Thread Ian Romanick
On 11/26/2013 12:50 PM, Francisco Jerez wrote:
> Cc: Ian Romanick 

Reviewed-by: Ian Romanick 

> Cc: "10.0" 
> ---
>  src/glsl/glsl_parser_extras.cpp | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
> index f401f03..d76d94b 100644
> --- a/src/glsl/glsl_parser_extras.cpp
> +++ b/src/glsl/glsl_parser_extras.cpp
> @@ -191,6 +191,8 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct 
> gl_context *_ctx,
> this->gs_input_prim_type = GL_POINTS;
> this->gs_input_size = 0;
> this->out_qualifier = new(this) ast_type_qualifier();
> +   memset(this->atomic_counter_offsets, 0,
> +  sizeof(this->atomic_counter_offsets));
>  }
>  
>  /**
> 

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


[Mesa-dev] [PATCH] glsl: Initialize _mesa_glsl_parse_state::atomic_counter_offsets before using it.

2013-11-26 Thread Francisco Jerez
Cc: Ian Romanick 
Cc: "10.0" 
---
 src/glsl/glsl_parser_extras.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index f401f03..d76d94b 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -191,6 +191,8 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct 
gl_context *_ctx,
this->gs_input_prim_type = GL_POINTS;
this->gs_input_size = 0;
this->out_qualifier = new(this) ast_type_qualifier();
+   memset(this->atomic_counter_offsets, 0,
+  sizeof(this->atomic_counter_offsets));
 }
 
 /**
-- 
1.8.3.4

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


Re: [Mesa-dev] [PATCH 08/11] mesa: Implement the GL entry points defined by ARB_shader_image_load_store.

2013-11-26 Thread Francisco Jerez
Fredrik Höglund  writes:
>[...]
>> +}
>> +
>> +void GLAPIENTRY
>> +_mesa_MemoryBarrier(GLbitfield barriers)
>> +{
>> +   GET_CURRENT_CONTEXT(ctx);
>> +
>> +   if (ctx->Driver.MemoryBarrier)
>> +  ctx->Driver.MemoryBarrier(ctx, barriers);
>> +}
>
> Is this the best place to implement this entry point?
> It's not specific to ARB_shader_image_load_store.

Right.  It's also going to be used for shader storage blocks, which we
don't support yet -- right now it's only going to have an effect on
shader images, though I'm fine with moving the definition somewhere else
now, if you have a better suggestion.  Any ideas?


pgp9aXc4ndftZ.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 08/11] mesa: Implement the GL entry points defined by ARB_shader_image_load_store.

2013-11-26 Thread Fredrik Höglund
On Monday 25 November 2013, Francisco Jerez wrote:
> ---
>  src/mapi/glapi/gen/gl_genexec.py |   1 +
>  src/mesa/Makefile.sources|   1 +
>  src/mesa/main/shaderimage.c  | 457 
> +++
>  src/mesa/main/shaderimage.h  |  42 
>  4 files changed, 501 insertions(+)
>  create mode 100644 src/mesa/main/shaderimage.c
>  create mode 100644 src/mesa/main/shaderimage.h
> 
> diff --git a/src/mapi/glapi/gen/gl_genexec.py 
> b/src/mapi/glapi/gen/gl_genexec.py
> index 3ce190f..334a4bf 100644
> --- a/src/mapi/glapi/gen/gl_genexec.py
> +++ b/src/mapi/glapi/gen/gl_genexec.py
> @@ -107,6 +107,7 @@ header = """/**
>  #include "main/varray.h"
>  #include "main/viewport.h"
>  #include "main/shaderapi.h"
> +#include "main/shaderimage.h"
>  #include "main/uniforms.h"
>  #include "main/syncobj.h"
>  #include "main/formatquery.h"
> diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
> index a84f8a7..7c67145 100644
> --- a/src/mesa/Makefile.sources
> +++ b/src/mesa/Makefile.sources
> @@ -81,6 +81,7 @@ MAIN_FILES = \
>   $(SRCDIR)main/scissor.c \
>   $(SRCDIR)main/set.c \
>   $(SRCDIR)main/shaderapi.c \
> + $(SRCDIR)main/shaderimage.c \
>   $(SRCDIR)main/shaderobj.c \
>   $(SRCDIR)main/shader_query.cpp \
>   $(SRCDIR)main/shared.c \
> diff --git a/src/mesa/main/shaderimage.c b/src/mesa/main/shaderimage.c
> new file mode 100644
> index 000..627366b
> --- /dev/null
> +++ b/src/mesa/main/shaderimage.c
> @@ -0,0 +1,457 @@
> +/*
> + * Copyright 2013 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.
> + *
> + * Authors:
> + *Francisco Jerez 
> + */
> +
> +#include 
> +
> +#include "shaderimage.h"
> +#include "mtypes.h"
> +#include "formats.h"
> +#include "errors.h"
> +#include "context.h"
> +#include "texobj.h"
> +
> +/*
> + * Define endian-invariant aliases for some mesa formats that are
> + * defined in terms of their channel layout from LSB to MSB in a
> + * 32-bit word.  The actual byte offsets matter here because the user
> + * is allowed to bit-cast one format into another and get predictable
> + * results.
> + */
> +#ifdef MESA_BIG_ENDIAN
> +# define MESA_FORMAT_RGBA_8 MESA_FORMAT_RGBA
> +# define MESA_FORMAT_RG_16 MESA_FORMAT_RG1616
> +# define MESA_FORMAT_RG_8 MESA_FORMAT_RG88
> +# define MESA_FORMAT_SIGNED_RGBA_8 MESA_FORMAT_SIGNED_RGBA
> +# define MESA_FORMAT_SIGNED_RG_16 MESA_FORMAT_SIGNED_RG1616
> +# define MESA_FORMAT_SIGNED_RG_8 MESA_FORMAT_SIGNED_RG88
> +#else
> +# define MESA_FORMAT_RGBA_8 MESA_FORMAT_RGBA_REV
> +# define MESA_FORMAT_RG_16 MESA_FORMAT_GR1616
> +# define MESA_FORMAT_RG_8 MESA_FORMAT_GR88
> +# define MESA_FORMAT_SIGNED_RGBA_8 MESA_FORMAT_SIGNED_RGBA_REV
> +# define MESA_FORMAT_SIGNED_RG_16 MESA_FORMAT_SIGNED_GR1616
> +# define MESA_FORMAT_SIGNED_RG_8 MESA_FORMAT_SIGNED_RG88_REV
> +#endif
> +
> +static gl_format
> +get_image_format(GLenum format)
> +{
> +   switch (format) {
> +   case GL_RGBA32F:
> +  return MESA_FORMAT_RGBA_FLOAT32;
> +
> +   case GL_RGBA16F:
> +  return MESA_FORMAT_RGBA_FLOAT16;
> +
> +   case GL_RG32F:
> +  return MESA_FORMAT_RG_FLOAT32;
> +
> +   case GL_RG16F:
> +  return MESA_FORMAT_RG_FLOAT16;
> +
> +   case GL_R11F_G11F_B10F:
> +  return MESA_FORMAT_R11_G11_B10_FLOAT;
> +
> +   case GL_R32F:
> +  return MESA_FORMAT_R_FLOAT32;
> +
> +   case GL_R16F:
> +  return MESA_FORMAT_R_FLOAT16;
> +
> +   case GL_RGBA32UI:
> +  return MESA_FORMAT_RGBA_UINT32;
> +
> +   case GL_RGBA16UI:
> +  return MESA_FORMAT_RGBA_UINT16;
> +
> +   case GL_RGB10_A2UI:
> +  return MESA_FORMAT_ABGR2101010_UINT;
> +
> +   case GL_RGBA8UI:
> +  return MESA_FORMAT_RGBA_UINT8;
> +
> +   case GL_RG32UI:
> +  return MESA_FORMAT_RG_UINT32;
> +
> +   case GL_RG16UI:
> +  return MESA_FORMAT_RG_UINT16;
> +
> +   case GL_RG8UI:
> +  retu

Re: [Mesa-dev] [PATCH 02/23] glsl: Add image type to the GLSL IR.

2013-11-26 Thread Francisco Jerez
Chris Forbes  writes:

> Do you have a suite of piglit tests for this extension?
>
Nope, not yet.

> On Wed, Nov 27, 2013 at 8:01 AM, Chris Forbes  wrote:
>> Sounds pretty reasonable.
>>
>> Is this a sensible direction for samplers to go in eventually as well?
>>
>> -- Chris
>>
>> On Wed, Nov 27, 2013 at 7:51 AM, Francisco Jerez  
>> wrote:
>>> Hi Chris,
>>>
>>> Chris Forbes  writes:
>>>
 @@ -618,6 +637,9 @@ glsl_type::component_slots() const
 case GLSL_TYPE_ARRAY:
return this->length * this->fields.array->component_
 slots();

 +   case GLSL_TYPE_IMAGE:
 +  return 1;

 Why is an image type one component, whereas the other opaque types are
 zero at this level?

>>>
>>> It seemed to simplify things to treat image variables as any other
>>> integer scalar rather than pretending that they have no storage here.
>>>
>>> Representing them as indices stored in an unsigned integer will make
>>> things like dynamic array indexing, structure member selection and
>>> non-inlined function calls [if we ever support that] trivial.  It also
>>> matches the way the GL API is designed: Images [unlike atomic counters]
>>> are assigned a one-component location in the default uniform block, and
>>> they can be set using glUniform1i().
>>>
>>> Note that this change is orthogonal to image uniforms being accounted in
>>> the MAX_*_UNIFORM_COMPONENTS calculation or not.  I haven't found any
>>> clear reference to that in the spec, other than:
>>>
>>> [from the GL 4.4 specification, section 7.6]
>>>
>>> | The implementation-dependent amount of storage available for uniform
>>> | variables, except for subroutine uniforms and atomic counters, in the
>>> | default uniform block accessed by a shader for a particular shader
>>> | stage can be queried by calling GetIntegerv with pname as specified in
>>> | table 7.4 for that stage.
>>>
>>> [table 7.4 just lists the MAX_*_UNIFORM_COMPONENTS queries]
>>>
>>> | [...] For uniforms with boolean, integer, or floating-point
>>> | components, [...] a scalar uniform will consume no more than 1
>>> | component.
>>>
>>> [from section 7.11]
>>>
>>> | [...] The value of an image uniform is an integer specifying the image
>>> | unit accessed.
>>>
>>> So it seems to me that counting them against MAX_*_UNIFORM_COMPONENTS
>>> matches the spec wording and it might be necessary for hardware that
>>> keeps this representation of images as integer scalars internally and
>>> has a limited amount of uniform storage in the default block.
>>>
>>> Thanks.
>>>


 On Tue, Nov 26, 2013 at 9:02 PM, Francisco Jerez  
 wrote:
> ---
>  src/glsl/ast_to_hir.cpp  |  1 +
>  src/glsl/glsl_types.cpp  | 23 +++
>  src/glsl/glsl_types.h| 22 ++
>  src/glsl/ir_clone.cpp|  1 +
>  src/glsl/link_uniform_initializers.cpp   |  1 +
>  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp |  1 +
>  src/mesa/program/ir_to_mesa.cpp  |  2 ++
>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp   |  1 +
>  8 files changed, 52 insertions(+)
>
> diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
> index 43cf497..e7c4ff4 100644
> --- a/src/glsl/ast_to_hir.cpp
> +++ b/src/glsl/ast_to_hir.cpp
> @@ -948,6 +948,7 @@ do_comparison(void *mem_ctx, int operation, ir_rvalue 
> *op0, ir_rvalue *op1)
> case GLSL_TYPE_ERROR:
> case GLSL_TYPE_VOID:
> case GLSL_TYPE_SAMPLER:
> +   case GLSL_TYPE_IMAGE:
> case GLSL_TYPE_INTERFACE:
> case GLSL_TYPE_ATOMIC_UINT:
>/* I assume a comparison of a struct containing a sampler just
> diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
> index f740130..e24417d 100644
> --- a/src/glsl/glsl_types.cpp
> +++ b/src/glsl/glsl_types.cpp
> @@ -80,6 +80,24 @@ glsl_type::glsl_type(GLenum gl_type,
> memset(& fields, 0, sizeof(fields));
>  }
>
> +glsl_type::glsl_type(GLenum gl_type,
> +enum glsl_image_dim dim, bool array,
> +glsl_base_type type, const char *name) :
> +   gl_type(gl_type),
> +   base_type(GLSL_TYPE_IMAGE),
> +   sampler_dimensionality(0), sampler_shadow(0),
> +   sampler_array(0), sampler_type(0), interface_packing(0),
> +   vector_elements(1), matrix_columns(1),
> +   length(0), fields()
> +{
> +   init_ralloc_type_ctx();
> +   assert(name != NULL);
> +   this->name = ralloc_strdup(this->mem_ctx, name);
> +   fields.image.type = type;
> +   fields.image.dimension = dim;
> +   fields.image.array = array;
> +}
> +
>  glsl_type::glsl_type(const glsl_struct_field *fields, unsigned 
> num_fields,
>  const char *name) :
> gl_type(0),
> @@ -172,6 +190,7 @@ bool
>  glsl_type::contains

Re: [Mesa-dev] [PATCH 02/23] glsl: Add image type to the GLSL IR.

2013-11-26 Thread Francisco Jerez
Chris Forbes  writes:

> Sounds pretty reasonable.
>
> Is this a sensible direction for samplers to go in eventually as well?
>
That's my suspicion...  It will definitely make variable sampler array
indexing for ARB_gpu_shader5 easier.

> -- Chris
>
> On Wed, Nov 27, 2013 at 7:51 AM, Francisco Jerez  
> wrote:
>> Hi Chris,
>>
>> Chris Forbes  writes:
>>
>>> @@ -618,6 +637,9 @@ glsl_type::component_slots() const
>>> case GLSL_TYPE_ARRAY:
>>>return this->length * this->fields.array->component_
>>> slots();
>>>
>>> +   case GLSL_TYPE_IMAGE:
>>> +  return 1;
>>>
>>> Why is an image type one component, whereas the other opaque types are
>>> zero at this level?
>>>
>>
>> It seemed to simplify things to treat image variables as any other
>> integer scalar rather than pretending that they have no storage here.
>>
>> Representing them as indices stored in an unsigned integer will make
>> things like dynamic array indexing, structure member selection and
>> non-inlined function calls [if we ever support that] trivial.  It also
>> matches the way the GL API is designed: Images [unlike atomic counters]
>> are assigned a one-component location in the default uniform block, and
>> they can be set using glUniform1i().
>>
>> Note that this change is orthogonal to image uniforms being accounted in
>> the MAX_*_UNIFORM_COMPONENTS calculation or not.  I haven't found any
>> clear reference to that in the spec, other than:
>>
>> [from the GL 4.4 specification, section 7.6]
>>
>> | The implementation-dependent amount of storage available for uniform
>> | variables, except for subroutine uniforms and atomic counters, in the
>> | default uniform block accessed by a shader for a particular shader
>> | stage can be queried by calling GetIntegerv with pname as specified in
>> | table 7.4 for that stage.
>>
>> [table 7.4 just lists the MAX_*_UNIFORM_COMPONENTS queries]
>>
>> | [...] For uniforms with boolean, integer, or floating-point
>> | components, [...] a scalar uniform will consume no more than 1
>> | component.
>>
>> [from section 7.11]
>>
>> | [...] The value of an image uniform is an integer specifying the image
>> | unit accessed.
>>
>> So it seems to me that counting them against MAX_*_UNIFORM_COMPONENTS
>> matches the spec wording and it might be necessary for hardware that
>> keeps this representation of images as integer scalars internally and
>> has a limited amount of uniform storage in the default block.
>>
>> Thanks.
>>
>>>
>>>
>>> On Tue, Nov 26, 2013 at 9:02 PM, Francisco Jerez  
>>> wrote:
 ---
  src/glsl/ast_to_hir.cpp  |  1 +
  src/glsl/glsl_types.cpp  | 23 +++
  src/glsl/glsl_types.h| 22 ++
  src/glsl/ir_clone.cpp|  1 +
  src/glsl/link_uniform_initializers.cpp   |  1 +
  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp |  1 +
  src/mesa/program/ir_to_mesa.cpp  |  2 ++
  src/mesa/state_tracker/st_glsl_to_tgsi.cpp   |  1 +
  8 files changed, 52 insertions(+)

 diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
 index 43cf497..e7c4ff4 100644
 --- a/src/glsl/ast_to_hir.cpp
 +++ b/src/glsl/ast_to_hir.cpp
 @@ -948,6 +948,7 @@ do_comparison(void *mem_ctx, int operation, ir_rvalue 
 *op0, ir_rvalue *op1)
 case GLSL_TYPE_ERROR:
 case GLSL_TYPE_VOID:
 case GLSL_TYPE_SAMPLER:
 +   case GLSL_TYPE_IMAGE:
 case GLSL_TYPE_INTERFACE:
 case GLSL_TYPE_ATOMIC_UINT:
/* I assume a comparison of a struct containing a sampler just
 diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
 index f740130..e24417d 100644
 --- a/src/glsl/glsl_types.cpp
 +++ b/src/glsl/glsl_types.cpp
 @@ -80,6 +80,24 @@ glsl_type::glsl_type(GLenum gl_type,
 memset(& fields, 0, sizeof(fields));
  }

 +glsl_type::glsl_type(GLenum gl_type,
 +enum glsl_image_dim dim, bool array,
 +glsl_base_type type, const char *name) :
 +   gl_type(gl_type),
 +   base_type(GLSL_TYPE_IMAGE),
 +   sampler_dimensionality(0), sampler_shadow(0),
 +   sampler_array(0), sampler_type(0), interface_packing(0),
 +   vector_elements(1), matrix_columns(1),
 +   length(0), fields()
 +{
 +   init_ralloc_type_ctx();
 +   assert(name != NULL);
 +   this->name = ralloc_strdup(this->mem_ctx, name);
 +   fields.image.type = type;
 +   fields.image.dimension = dim;
 +   fields.image.array = array;
 +}
 +
  glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
  const char *name) :
 gl_type(0),
 @@ -172,6 +190,7 @@ bool
  glsl_type::contains_opaque() const {
 switch (base_type) {
 case GLSL_TYPE_SAMPLER:
 +   case GLSL_TYPE_IMAGE:
 case GLSL_TYPE_ATOMIC_UINT:

Re: [Mesa-dev] [PATCH 02/23] glsl: Add image type to the GLSL IR.

2013-11-26 Thread Chris Forbes
Do you have a suite of piglit tests for this extension?

On Wed, Nov 27, 2013 at 8:01 AM, Chris Forbes  wrote:
> Sounds pretty reasonable.
>
> Is this a sensible direction for samplers to go in eventually as well?
>
> -- Chris
>
> On Wed, Nov 27, 2013 at 7:51 AM, Francisco Jerez  
> wrote:
>> Hi Chris,
>>
>> Chris Forbes  writes:
>>
>>> @@ -618,6 +637,9 @@ glsl_type::component_slots() const
>>> case GLSL_TYPE_ARRAY:
>>>return this->length * this->fields.array->component_
>>> slots();
>>>
>>> +   case GLSL_TYPE_IMAGE:
>>> +  return 1;
>>>
>>> Why is an image type one component, whereas the other opaque types are
>>> zero at this level?
>>>
>>
>> It seemed to simplify things to treat image variables as any other
>> integer scalar rather than pretending that they have no storage here.
>>
>> Representing them as indices stored in an unsigned integer will make
>> things like dynamic array indexing, structure member selection and
>> non-inlined function calls [if we ever support that] trivial.  It also
>> matches the way the GL API is designed: Images [unlike atomic counters]
>> are assigned a one-component location in the default uniform block, and
>> they can be set using glUniform1i().
>>
>> Note that this change is orthogonal to image uniforms being accounted in
>> the MAX_*_UNIFORM_COMPONENTS calculation or not.  I haven't found any
>> clear reference to that in the spec, other than:
>>
>> [from the GL 4.4 specification, section 7.6]
>>
>> | The implementation-dependent amount of storage available for uniform
>> | variables, except for subroutine uniforms and atomic counters, in the
>> | default uniform block accessed by a shader for a particular shader
>> | stage can be queried by calling GetIntegerv with pname as specified in
>> | table 7.4 for that stage.
>>
>> [table 7.4 just lists the MAX_*_UNIFORM_COMPONENTS queries]
>>
>> | [...] For uniforms with boolean, integer, or floating-point
>> | components, [...] a scalar uniform will consume no more than 1
>> | component.
>>
>> [from section 7.11]
>>
>> | [...] The value of an image uniform is an integer specifying the image
>> | unit accessed.
>>
>> So it seems to me that counting them against MAX_*_UNIFORM_COMPONENTS
>> matches the spec wording and it might be necessary for hardware that
>> keeps this representation of images as integer scalars internally and
>> has a limited amount of uniform storage in the default block.
>>
>> Thanks.
>>
>>>
>>>
>>> On Tue, Nov 26, 2013 at 9:02 PM, Francisco Jerez  
>>> wrote:
 ---
  src/glsl/ast_to_hir.cpp  |  1 +
  src/glsl/glsl_types.cpp  | 23 +++
  src/glsl/glsl_types.h| 22 ++
  src/glsl/ir_clone.cpp|  1 +
  src/glsl/link_uniform_initializers.cpp   |  1 +
  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp |  1 +
  src/mesa/program/ir_to_mesa.cpp  |  2 ++
  src/mesa/state_tracker/st_glsl_to_tgsi.cpp   |  1 +
  8 files changed, 52 insertions(+)

 diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
 index 43cf497..e7c4ff4 100644
 --- a/src/glsl/ast_to_hir.cpp
 +++ b/src/glsl/ast_to_hir.cpp
 @@ -948,6 +948,7 @@ do_comparison(void *mem_ctx, int operation, ir_rvalue 
 *op0, ir_rvalue *op1)
 case GLSL_TYPE_ERROR:
 case GLSL_TYPE_VOID:
 case GLSL_TYPE_SAMPLER:
 +   case GLSL_TYPE_IMAGE:
 case GLSL_TYPE_INTERFACE:
 case GLSL_TYPE_ATOMIC_UINT:
/* I assume a comparison of a struct containing a sampler just
 diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
 index f740130..e24417d 100644
 --- a/src/glsl/glsl_types.cpp
 +++ b/src/glsl/glsl_types.cpp
 @@ -80,6 +80,24 @@ glsl_type::glsl_type(GLenum gl_type,
 memset(& fields, 0, sizeof(fields));
  }

 +glsl_type::glsl_type(GLenum gl_type,
 +enum glsl_image_dim dim, bool array,
 +glsl_base_type type, const char *name) :
 +   gl_type(gl_type),
 +   base_type(GLSL_TYPE_IMAGE),
 +   sampler_dimensionality(0), sampler_shadow(0),
 +   sampler_array(0), sampler_type(0), interface_packing(0),
 +   vector_elements(1), matrix_columns(1),
 +   length(0), fields()
 +{
 +   init_ralloc_type_ctx();
 +   assert(name != NULL);
 +   this->name = ralloc_strdup(this->mem_ctx, name);
 +   fields.image.type = type;
 +   fields.image.dimension = dim;
 +   fields.image.array = array;
 +}
 +
  glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
  const char *name) :
 gl_type(0),
 @@ -172,6 +190,7 @@ bool
  glsl_type::contains_opaque() const {
 switch (base_type) {
 case GLSL_TYPE_SAMPLER:
 +   case GLSL_TYPE_IMAGE:
 case GLSL_TYPE_ATOMIC_UINT:
return true;

Re: [Mesa-dev] [PATCH 02/23] glsl: Add image type to the GLSL IR.

2013-11-26 Thread Chris Forbes
Sounds pretty reasonable.

Is this a sensible direction for samplers to go in eventually as well?

-- Chris

On Wed, Nov 27, 2013 at 7:51 AM, Francisco Jerez  wrote:
> Hi Chris,
>
> Chris Forbes  writes:
>
>> @@ -618,6 +637,9 @@ glsl_type::component_slots() const
>> case GLSL_TYPE_ARRAY:
>>return this->length * this->fields.array->component_
>> slots();
>>
>> +   case GLSL_TYPE_IMAGE:
>> +  return 1;
>>
>> Why is an image type one component, whereas the other opaque types are
>> zero at this level?
>>
>
> It seemed to simplify things to treat image variables as any other
> integer scalar rather than pretending that they have no storage here.
>
> Representing them as indices stored in an unsigned integer will make
> things like dynamic array indexing, structure member selection and
> non-inlined function calls [if we ever support that] trivial.  It also
> matches the way the GL API is designed: Images [unlike atomic counters]
> are assigned a one-component location in the default uniform block, and
> they can be set using glUniform1i().
>
> Note that this change is orthogonal to image uniforms being accounted in
> the MAX_*_UNIFORM_COMPONENTS calculation or not.  I haven't found any
> clear reference to that in the spec, other than:
>
> [from the GL 4.4 specification, section 7.6]
>
> | The implementation-dependent amount of storage available for uniform
> | variables, except for subroutine uniforms and atomic counters, in the
> | default uniform block accessed by a shader for a particular shader
> | stage can be queried by calling GetIntegerv with pname as specified in
> | table 7.4 for that stage.
>
> [table 7.4 just lists the MAX_*_UNIFORM_COMPONENTS queries]
>
> | [...] For uniforms with boolean, integer, or floating-point
> | components, [...] a scalar uniform will consume no more than 1
> | component.
>
> [from section 7.11]
>
> | [...] The value of an image uniform is an integer specifying the image
> | unit accessed.
>
> So it seems to me that counting them against MAX_*_UNIFORM_COMPONENTS
> matches the spec wording and it might be necessary for hardware that
> keeps this representation of images as integer scalars internally and
> has a limited amount of uniform storage in the default block.
>
> Thanks.
>
>>
>>
>> On Tue, Nov 26, 2013 at 9:02 PM, Francisco Jerez  
>> wrote:
>>> ---
>>>  src/glsl/ast_to_hir.cpp  |  1 +
>>>  src/glsl/glsl_types.cpp  | 23 +++
>>>  src/glsl/glsl_types.h| 22 ++
>>>  src/glsl/ir_clone.cpp|  1 +
>>>  src/glsl/link_uniform_initializers.cpp   |  1 +
>>>  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp |  1 +
>>>  src/mesa/program/ir_to_mesa.cpp  |  2 ++
>>>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp   |  1 +
>>>  8 files changed, 52 insertions(+)
>>>
>>> diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
>>> index 43cf497..e7c4ff4 100644
>>> --- a/src/glsl/ast_to_hir.cpp
>>> +++ b/src/glsl/ast_to_hir.cpp
>>> @@ -948,6 +948,7 @@ do_comparison(void *mem_ctx, int operation, ir_rvalue 
>>> *op0, ir_rvalue *op1)
>>> case GLSL_TYPE_ERROR:
>>> case GLSL_TYPE_VOID:
>>> case GLSL_TYPE_SAMPLER:
>>> +   case GLSL_TYPE_IMAGE:
>>> case GLSL_TYPE_INTERFACE:
>>> case GLSL_TYPE_ATOMIC_UINT:
>>>/* I assume a comparison of a struct containing a sampler just
>>> diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
>>> index f740130..e24417d 100644
>>> --- a/src/glsl/glsl_types.cpp
>>> +++ b/src/glsl/glsl_types.cpp
>>> @@ -80,6 +80,24 @@ glsl_type::glsl_type(GLenum gl_type,
>>> memset(& fields, 0, sizeof(fields));
>>>  }
>>>
>>> +glsl_type::glsl_type(GLenum gl_type,
>>> +enum glsl_image_dim dim, bool array,
>>> +glsl_base_type type, const char *name) :
>>> +   gl_type(gl_type),
>>> +   base_type(GLSL_TYPE_IMAGE),
>>> +   sampler_dimensionality(0), sampler_shadow(0),
>>> +   sampler_array(0), sampler_type(0), interface_packing(0),
>>> +   vector_elements(1), matrix_columns(1),
>>> +   length(0), fields()
>>> +{
>>> +   init_ralloc_type_ctx();
>>> +   assert(name != NULL);
>>> +   this->name = ralloc_strdup(this->mem_ctx, name);
>>> +   fields.image.type = type;
>>> +   fields.image.dimension = dim;
>>> +   fields.image.array = array;
>>> +}
>>> +
>>>  glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
>>>  const char *name) :
>>> gl_type(0),
>>> @@ -172,6 +190,7 @@ bool
>>>  glsl_type::contains_opaque() const {
>>> switch (base_type) {
>>> case GLSL_TYPE_SAMPLER:
>>> +   case GLSL_TYPE_IMAGE:
>>> case GLSL_TYPE_ATOMIC_UINT:
>>>return true;
>>> case GLSL_TYPE_ARRAY:
>>> @@ -618,6 +637,9 @@ glsl_type::component_slots() const
>>> case GLSL_TYPE_ARRAY:
>>>return this->length * this->fields.array->component_slots();
>>>
>>> +   case GLSL_TYPE_IMAGE:
>>> +  return 1;

Re: [Mesa-dev] [PATCH] Fixed memory leak.

2013-11-26 Thread Alex Deucher
On Tue, Nov 26, 2013 at 1:22 PM, Siavash Eliasi  wrote:

In general, when you fix problems in prior patches, you should
integrate the fix into the original patch(es) where the problems were,
update the commit message to note what bugs were fixed and then
re-send the patch set.  That prevents broken commits from getting into
the git tree even if they are fixed in a later commit. You can use git
rebase -i to integrate your fixes.

Alex

> ---
>  src/mesa/main/bufferobj.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
> index 5581a5d..e68d96d 100644
> --- a/src/mesa/main/bufferobj.c
> +++ b/src/mesa/main/bufferobj.c
> @@ -420,6 +420,8 @@ _mesa_buffer_data( struct gl_context *ctx, GLenum target, 
> GLsizeiptrARB size,
>
> new_data = _mesa_align_malloc( size, ctx->Const.MinMapBufferAlignment );
> if (new_data) {
> +  _mesa_align_free( bufObj->Data );
> +
>bufObj->Data = (GLubyte *) new_data;
>bufObj->Size = size;
>bufObj->Usage = usage;
> --
> 1.8.4.2
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 02/23] glsl: Add image type to the GLSL IR.

2013-11-26 Thread Francisco Jerez
Hi Chris,

Chris Forbes  writes:

> @@ -618,6 +637,9 @@ glsl_type::component_slots() const
> case GLSL_TYPE_ARRAY:
>return this->length * this->fields.array->component_
> slots();
>
> +   case GLSL_TYPE_IMAGE:
> +  return 1;
>
> Why is an image type one component, whereas the other opaque types are
> zero at this level?
>

It seemed to simplify things to treat image variables as any other
integer scalar rather than pretending that they have no storage here.

Representing them as indices stored in an unsigned integer will make
things like dynamic array indexing, structure member selection and
non-inlined function calls [if we ever support that] trivial.  It also
matches the way the GL API is designed: Images [unlike atomic counters]
are assigned a one-component location in the default uniform block, and
they can be set using glUniform1i().

Note that this change is orthogonal to image uniforms being accounted in
the MAX_*_UNIFORM_COMPONENTS calculation or not.  I haven't found any
clear reference to that in the spec, other than:

[from the GL 4.4 specification, section 7.6]

| The implementation-dependent amount of storage available for uniform
| variables, except for subroutine uniforms and atomic counters, in the
| default uniform block accessed by a shader for a particular shader
| stage can be queried by calling GetIntegerv with pname as specified in
| table 7.4 for that stage.

[table 7.4 just lists the MAX_*_UNIFORM_COMPONENTS queries]

| [...] For uniforms with boolean, integer, or floating-point
| components, [...] a scalar uniform will consume no more than 1
| component.

[from section 7.11]

| [...] The value of an image uniform is an integer specifying the image
| unit accessed.

So it seems to me that counting them against MAX_*_UNIFORM_COMPONENTS
matches the spec wording and it might be necessary for hardware that
keeps this representation of images as integer scalars internally and
has a limited amount of uniform storage in the default block.

Thanks.

>
>
> On Tue, Nov 26, 2013 at 9:02 PM, Francisco Jerez  
> wrote:
>> ---
>>  src/glsl/ast_to_hir.cpp  |  1 +
>>  src/glsl/glsl_types.cpp  | 23 +++
>>  src/glsl/glsl_types.h| 22 ++
>>  src/glsl/ir_clone.cpp|  1 +
>>  src/glsl/link_uniform_initializers.cpp   |  1 +
>>  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp |  1 +
>>  src/mesa/program/ir_to_mesa.cpp  |  2 ++
>>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp   |  1 +
>>  8 files changed, 52 insertions(+)
>>
>> diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
>> index 43cf497..e7c4ff4 100644
>> --- a/src/glsl/ast_to_hir.cpp
>> +++ b/src/glsl/ast_to_hir.cpp
>> @@ -948,6 +948,7 @@ do_comparison(void *mem_ctx, int operation, ir_rvalue 
>> *op0, ir_rvalue *op1)
>> case GLSL_TYPE_ERROR:
>> case GLSL_TYPE_VOID:
>> case GLSL_TYPE_SAMPLER:
>> +   case GLSL_TYPE_IMAGE:
>> case GLSL_TYPE_INTERFACE:
>> case GLSL_TYPE_ATOMIC_UINT:
>>/* I assume a comparison of a struct containing a sampler just
>> diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
>> index f740130..e24417d 100644
>> --- a/src/glsl/glsl_types.cpp
>> +++ b/src/glsl/glsl_types.cpp
>> @@ -80,6 +80,24 @@ glsl_type::glsl_type(GLenum gl_type,
>> memset(& fields, 0, sizeof(fields));
>>  }
>>
>> +glsl_type::glsl_type(GLenum gl_type,
>> +enum glsl_image_dim dim, bool array,
>> +glsl_base_type type, const char *name) :
>> +   gl_type(gl_type),
>> +   base_type(GLSL_TYPE_IMAGE),
>> +   sampler_dimensionality(0), sampler_shadow(0),
>> +   sampler_array(0), sampler_type(0), interface_packing(0),
>> +   vector_elements(1), matrix_columns(1),
>> +   length(0), fields()
>> +{
>> +   init_ralloc_type_ctx();
>> +   assert(name != NULL);
>> +   this->name = ralloc_strdup(this->mem_ctx, name);
>> +   fields.image.type = type;
>> +   fields.image.dimension = dim;
>> +   fields.image.array = array;
>> +}
>> +
>>  glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
>>  const char *name) :
>> gl_type(0),
>> @@ -172,6 +190,7 @@ bool
>>  glsl_type::contains_opaque() const {
>> switch (base_type) {
>> case GLSL_TYPE_SAMPLER:
>> +   case GLSL_TYPE_IMAGE:
>> case GLSL_TYPE_ATOMIC_UINT:
>>return true;
>> case GLSL_TYPE_ARRAY:
>> @@ -618,6 +637,9 @@ glsl_type::component_slots() const
>> case GLSL_TYPE_ARRAY:
>>return this->length * this->fields.array->component_slots();
>>
>> +   case GLSL_TYPE_IMAGE:
>> +  return 1;
>> +
>> case GLSL_TYPE_SAMPLER:
>> case GLSL_TYPE_ATOMIC_UINT:
>> case GLSL_TYPE_VOID:
>> @@ -908,6 +930,7 @@ glsl_type::count_attribute_slots() const
>>return this->length * this->fields.array->count_attribute_slots();
>>
>> case GLSL_TYPE_SAMPLER:
>> +   case GLSL_TYPE_IMAGE:
>> case GLSL_TYP

Re: [Mesa-dev] [PATCH 11/17] Modified _mesa_buffer_data to use _mesa_align_malloc.

2013-11-26 Thread Siavash Eliasi
Now I understand why _mesa_realloc is not appropriate to use here. From 
spec:


glBufferData creates a new data store for the buffer object currently 
bound to target. Any pre-existing data store is deleted. The new data 
store is created with the specified size in bytes and usage.
If data is NULL, a data store of the specified size is still created, 
but its contents remain uninitialized and thus undefined.



Best regards,
Siavash Eliasi.

On 11/26/2013 09:34 AM, Siavash Eliasi wrote:
Yes I think you are right, I guess *_mesa_align_realloc* is the 
correct function which should be used here.


What do you think Ian?


Best regards,
Siavash Eliasi.


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


Re: [Mesa-dev] [PATCH 3/3] gallium/cso: fix sampler / sampler_view counts

2013-11-26 Thread Jose Fonseca
Series looks good to me. Thanks for the cleanup.

Jose

- Original Message -
> From: Roland Scheidegger 
> 
> Now that it is possible to query drivers for the max sampler view it should
> be safe to increase this without crashing.
> Not entirely convinced this really works correctly though if state trackers
> using non-linked sampler / sampler_views use this.
> ---
>  src/gallium/auxiliary/cso_cache/cso_context.c |   27
>  +++--
>  1 file changed, 16 insertions(+), 11 deletions(-)
> 
> diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c
> b/src/gallium/auxiliary/cso_cache/cso_context.c
> index 23d3245..33adee8 100644
> --- a/src/gallium/auxiliary/cso_cache/cso_context.c
> +++ b/src/gallium/auxiliary/cso_cache/cso_context.c
> @@ -67,10 +67,10 @@ struct sampler_info
> void *samplers_saved[PIPE_MAX_SAMPLERS];
> unsigned nr_samplers_saved;
>  
> -   struct pipe_sampler_view *views[PIPE_MAX_SAMPLERS];
> +   struct pipe_sampler_view *views[PIPE_MAX_SHADER_SAMPLER_VIEWS];
> unsigned nr_views;
>  
> -   struct pipe_sampler_view *views_saved[PIPE_MAX_SAMPLERS];
> +   struct pipe_sampler_view *views_saved[PIPE_MAX_SHADER_SAMPLER_VIEWS];
> unsigned nr_views_saved;
>  };
>  
> @@ -306,17 +306,22 @@ void cso_release_all( struct cso_context *ctx )
>ctx->pipe->bind_rasterizer_state( ctx->pipe, NULL );
>  
>{
> - static struct pipe_sampler_view *views[PIPE_MAX_SAMPLERS] = { NULL
> };
> + static struct pipe_sampler_view
> *views[PIPE_MAX_SHADER_SAMPLER_VIEWS] = { NULL };
>   static void *zeros[PIPE_MAX_SAMPLERS] = { NULL };
>   struct pipe_screen *scr = ctx->pipe->screen;
>   unsigned sh;
>   for (sh = 0; sh < PIPE_SHADER_TYPES; sh++) {
> -int max = scr->get_shader_param(scr, sh,
> -  PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS);
> -assert(max <= PIPE_MAX_SAMPLERS);
> -if (max > 0) {
> -   ctx->pipe->bind_sampler_states(ctx->pipe, sh, 0, max, zeros);
> -   ctx->pipe->set_sampler_views(ctx->pipe, sh, 0, max, views);
> +int maxsam = scr->get_shader_param(scr, sh,
> +
> PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS);
> +int maxview = scr->get_shader_param(scr, sh,
> +
> PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS);
> +assert(maxsam <= PIPE_MAX_SAMPLERS);
> +assert(maxview <= PIPE_MAX_SHADER_SAMPLER_VIEWS);
> +if (maxsam > 0) {
> +   ctx->pipe->bind_sampler_states(ctx->pipe, sh, 0, maxsam,
> zeros);
> +}
> +if (maxview > 0) {
> +   ctx->pipe->set_sampler_views(ctx->pipe, sh, 0, maxview,
> views);
>  }
>   }
>}
> @@ -330,10 +335,10 @@ void cso_release_all( struct cso_context *ctx )
>   ctx->pipe->set_stream_output_targets(ctx->pipe, 0, NULL, 0);
> }
>  
> -   /* free fragment samplers, views */
> +   /* free fragment sampler views */
> for (shader = 0; shader < Elements(ctx->samplers); shader++) {
>struct sampler_info *info = &ctx->samplers[shader];
> -  for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
> +  for (i = 0; i < PIPE_MAX_SHADER_SAMPLER_VIEWS; i++) {
>   pipe_sampler_view_reference(&info->views[i], NULL);
>   pipe_sampler_view_reference(&info->views_saved[i], NULL);
>}
> --
> 1.7.9.5
> 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 11/17] Modified _mesa_buffer_data to use _mesa_align_malloc.

2013-11-26 Thread Siavash Eliasi

Fixed memory leak, thanks for the heads up!

http://lists.freedesktop.org/archives/mesa-dev/2013-November/049178.html


Best Regards,
Siavash Eliasi.

On 11/26/2013 01:14 AM, Aaron Watry wrote:

On Sun, Nov 24, 2013 at 11:36 PM, Siavash Eliasi
 wrote:

---
  src/mesa/main/bufferobj.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index b27f592..5581a5d 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -416,9 +416,9 @@ _mesa_buffer_data( struct gl_context *ctx, GLenum target, 
GLsizeiptrARB size,
  {
 void * new_data;

-   (void) ctx; (void) target;
+   (void) target;

-   new_data = _mesa_realloc( bufObj->Data, bufObj->Size, size );
+   new_data = _mesa_align_malloc( size, ctx->Const.MinMapBufferAlignment );

realloc can be used to either allocate a new buffer or re-allocate an
existing buffer (which may or may not return a different pointer).

Given that, I think that this will leak the old buffer (if one has
already been allocated).  From looking at the rest of the surrounding
code in the patch, we don't preserve the existing buffer contents, so
I guess I'd just FREE(bufObj->Data)  within the following if block
before assigning bufObj->Data = newdata;

--Aaron


 if (new_data) {
bufObj->Data = (GLubyte *) new_data;
bufObj->Size = size;
--
1.8.4.2

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


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


[Mesa-dev] [PATCH] Fixed memory leak.

2013-11-26 Thread Siavash Eliasi
---
 src/mesa/main/bufferobj.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 5581a5d..e68d96d 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -420,6 +420,8 @@ _mesa_buffer_data( struct gl_context *ctx, GLenum target, 
GLsizeiptrARB size,
 
new_data = _mesa_align_malloc( size, ctx->Const.MinMapBufferAlignment );
if (new_data) {
+  _mesa_align_free( bufObj->Data );
+
   bufObj->Data = (GLubyte *) new_data;
   bufObj->Size = size;
   bufObj->Usage = usage;
-- 
1.8.4.2

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


Re: [Mesa-dev] [PATCH 3/3] gallium/cso: fix sampler / sampler_view counts

2013-11-26 Thread Marek Olšák
In the future, we won't have to save all the sampler views anyway.
Note that cso_context only saves the states it needs to save meta ops.
It doesn't save the clip state and it also doesn't save all vertex
buffers except for the first one, because only the first one needs to
be saved and restored for certain meta ops. Even though it's currently
hardcoded to be the first vertex buffer slot, it can be changed to
anything, e.g. the last one = 15. The users of cso_context are
required to call cso_get_aux_vertex_buffer_slot() to get the slot
index for meta ops and are only allowed to bind resources to that
slot, because the other slots are not saved. We will probably do
something like that for sampler views and sampler states too, and the
nr_views variable will be removed.

Marek

On Tue, Nov 26, 2013 at 3:44 PM, Roland Scheidegger  wrote:
> Am 26.11.2013 06:24, schrieb Zack Rusin:
>> The entire series looks good to me.
>>
>>> Now that it is possible to query drivers for the max sampler view it should
>>> be safe to increase this without crashing.
>>> Not entirely convinced this really works correctly though if state trackers
>>> using non-linked sampler / sampler_views use this.
>>
>> I'm not sure if I get this. What would be the problem in that case?
>>
>
> It looked to me like the code isn't really prepared for this, though
> actually I guess it would be more of a problem with not updating all
> views or samplers from 0 to count rather than different number of views
> / samplers. (The code stores the "count" paramater as nr_views etc. and
> will then save/restore views based on nr_views starting at zero).
> In any case this change shouldn't make it worse.
>
> Roland
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 3/3] gallium/cso: fix sampler / sampler_view counts

2013-11-26 Thread Roland Scheidegger
Am 26.11.2013 06:24, schrieb Zack Rusin:
> The entire series looks good to me.
> 
>> Now that it is possible to query drivers for the max sampler view it should
>> be safe to increase this without crashing.
>> Not entirely convinced this really works correctly though if state trackers
>> using non-linked sampler / sampler_views use this.
> 
> I'm not sure if I get this. What would be the problem in that case?
> 

It looked to me like the code isn't really prepared for this, though
actually I guess it would be more of a problem with not updating all
views or samplers from 0 to count rather than different number of views
/ samplers. (The code stores the "count" paramater as nr_views etc. and
will then save/restore views based on nr_views starting at zero).
In any case this change shouldn't make it worse.

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


Re: [Mesa-dev] [PATCH] intel: Track known prime buffers for re-use

2013-11-26 Thread Keith Packard
Daniel Vetter  writes:

> The kernel actually doesn't bother with this, i.e. an open on an flink
> name will always create a new handle. Given that it was a major pita to
> get the prime reimporting going (due to a pile of funny lifetime issues
> around reference loops and some assorted locking fun) I'm not volunteering
> to fix this ;-) And I also think that a piece of userspace which both
> flink-opens and prime imports on the same buffer gets both pieces.

That seems pretty dangerous to me -- you'll end up with aliases to the
same buffer this way if user space isn't careful.

I bet you check duplicate buffer usage by pointer and not ID though,
which means user space will get errors when this happens. That's not
terrible, but it isn't great either as there's this nasty call to
exit(1) when the execbuffers fails...

> Otoh this can't hurt either, so if you want to stick with this hunk maybe
> add a small comment saying that the kernel lies. Or just remove it. Either
> way:

Not being able to test it is a bit sub-optimal; the duplicate handle
case for prime was well tested by the time I submitted that patch...

> Reviewed-by: Daniel Vetter 

thanks.

> Aside: I think drm is the only subsystem that goes out of it's way to
> ensure a unique relationship between dmabuf and other handles and
> underlying objects. If you throw v4l into the mix (e.g. by building a
> gstreamer pipe that feeds into an egl image or so) I expect some fun to
> happen. Otoh no open-source v4l driver for intel socs, so lalala ;-)

Some kind of standard of conduct is clearly needed here - not letting
user space know they've got aliasing going on is pretty mean.

-- 
keith.pack...@intel.com


pgplDH2IGYe13.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] R600/SI: Implement spilling of SGPRs v4

2013-11-26 Thread Michel Dänzer
On Mon, 2013-11-25 at 23:32 -0500, Tom Stellard wrote:
> From: Tom Stellard 
> 
> SGPRs are spilled into VGPRs using the {READ,WRITE}LANE_B32 instructions.
> 
> v2:
>   - Fix encoding of Lane Mask
>   - Use correct register flags, so we don't overwrite the low dword
> when restoring multi-dword registers.
> 
> v3:
>   - Register spilling seems to hang the GPU, so replace all shaders
> that need spilling with a dummy shader.
> 
> v4:
>   - Fix *LANE definitions
>   - Change destination reg class for 32-bit SMRD instructions
> 
> https://bugs.freedesktop.org/show_bug.cgi?id=71285
> 
> NOTE: This is a candidate for the 3.4 branch.

Tested-by: Michel Dänzer 


-- 
Earthling Michel Dänzer|  http://www.amd.com
Libre software enthusiast  |Mesa and X developer

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


Re: [Mesa-dev] [PATCH] R600/SI: Implement spilling of SGPRs v4

2013-11-26 Thread Christian König

Am 26.11.2013 05:32, schrieb Tom Stellard:

From: Tom Stellard 

SGPRs are spilled into VGPRs using the {READ,WRITE}LANE_B32 instructions.

v2:
   - Fix encoding of Lane Mask
   - Use correct register flags, so we don't overwrite the low dword
 when restoring multi-dword registers.

v3:
   - Register spilling seems to hang the GPU, so replace all shaders
 that need spilling with a dummy shader.

v4:
   - Fix *LANE definitions
   - Change destination reg class for 32-bit SMRD instructions

https://bugs.freedesktop.org/show_bug.cgi?id=71285




[SNIP]

  
-defm S_LOAD_DWORD : SMRD_Helper <0x00, "S_LOAD_DWORD", SReg_64, SReg_32>;

+// We are using the SGPR_32 and not the SReg_32 register class for 32-bit
+// SMRD instructions, because the SGPR_32 register class does not include M0
+// and writing to M0 from an SMRD instruction will hang the GPU.
+defm S_LOAD_DWORD : SMRD_Helper <0x00, "S_LOAD_DWORD", SReg_64, SGPR_32>;
  defm S_LOAD_DWORDX2 : SMRD_Helper <0x01, "S_LOAD_DWORDX2", SReg_64, SReg_64>;
  defm S_LOAD_DWORDX4 : SMRD_Helper <0x02, "S_LOAD_DWORDX4", SReg_64, SReg_128>;
  defm S_LOAD_DWORDX8 : SMRD_Helper <0x03, "S_LOAD_DWORDX8", SReg_64, SReg_256>;
  defm S_LOAD_DWORDX16 : SMRD_Helper <0x04, "S_LOAD_DWORDX16", SReg_64, 
SReg_512>;
  
  defm S_BUFFER_LOAD_DWORD : SMRD_Helper <

-  0x08, "S_BUFFER_LOAD_DWORD", SReg_128, SReg_32
+  0x08, "S_BUFFER_LOAD_DWORD", SReg_128, SGPR_32
  >;


This change looks like it might want to go into a separate patch, apart 
from that the patch is:


Reviewed-by: Christian König 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] intel: Track known prime buffers for re-use

2013-11-26 Thread Daniel Vetter
On Mon, Nov 25, 2013 at 01:22:41PM -0800, Keith Packard wrote:
> If the application sends us a file descriptor pointing at a prime
> buffer that we've already got, we have to re-use the same bo_gem
> structure or chaos will result.
> 
> Track the set of all known prime objects and look to see if the kernel
> has returned one of those for a new file descriptor.
> 
> Also checks for prime buffers in the flink case.
> 
> Signed-off-by: Keith Packard 
> ---
>  intel/intel_bufmgr_gem.c | 50 
> +---
>  1 file changed, 43 insertions(+), 7 deletions(-)
> 
> diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
> index df6fcec..2b7fe07 100644
> --- a/intel/intel_bufmgr_gem.c
> +++ b/intel/intel_bufmgr_gem.c
> @@ -149,6 +149,8 @@ struct _drm_intel_bo_gem {
>  
>   /**
>* Kenel-assigned global name for this object
> + *
> + * List contains both flink named and prime fd'd objects
>*/
>   unsigned int global_name;
>   drmMMListHead name_list;
> @@ -862,10 +864,6 @@ drm_intel_bo_gem_create_from_name(drm_intel_bufmgr 
> *bufmgr,
>   }
>   }
>  
> - bo_gem = calloc(1, sizeof(*bo_gem));
> - if (!bo_gem)
> - return NULL;
> -
>   VG_CLEAR(open_arg);
>   open_arg.name = handle;
>   ret = drmIoctl(bufmgr_gem->fd,
> @@ -874,9 +872,26 @@ drm_intel_bo_gem_create_from_name(drm_intel_bufmgr 
> *bufmgr,
>   if (ret != 0) {
>   DBG("Couldn't reference %s handle 0x%08x: %s\n",
>   name, handle, strerror(errno));
> - free(bo_gem);
>   return NULL;
>   }
> +/* Now see if someone has used a prime handle to get this
> + * object from the kernel before by looking through the list
> + * again for a matching gem_handle
> + */
> + for (list = bufmgr_gem->named.next;
> +  list != &bufmgr_gem->named;
> +  list = list->next) {
> + bo_gem = DRMLISTENTRY(drm_intel_bo_gem, list, name_list);
> + if (bo_gem->gem_handle == open_arg.handle) {
> + drm_intel_gem_bo_reference(&bo_gem->bo);
> + return &bo_gem->bo;
> + }
> + }

The kernel actually doesn't bother with this, i.e. an open on an flink
name will always create a new handle. Given that it was a major pita to
get the prime reimporting going (due to a pile of funny lifetime issues
around reference loops and some assorted locking fun) I'm not volunteering
to fix this ;-) And I also think that a piece of userspace which both
flink-opens and prime imports on the same buffer gets both pieces.

Otoh this can't hurt either, so if you want to stick with this hunk maybe
add a small comment saying that the kernel lies. Or just remove it. Either
way:

Reviewed-by: Daniel Vetter 

Aside: I think drm is the only subsystem that goes out of it's way to
ensure a unique relationship between dmabuf and other handles and
underlying objects. If you throw v4l into the mix (e.g. by building a
gstreamer pipe that feeds into an egl image or so) I expect some fun to
happen. Otoh no open-source v4l driver for intel socs, so lalala ;-)

> +
> + bo_gem = calloc(1, sizeof(*bo_gem));
> + if (!bo_gem)
> + return NULL;
> +
>   bo_gem->bo.size = open_arg.size;
>   bo_gem->bo.offset = 0;
>   bo_gem->bo.virtual = NULL;
> @@ -2451,8 +2466,25 @@ drm_intel_bo_gem_create_from_prime(drm_intel_bufmgr 
> *bufmgr, int prime_fd, int s
>   uint32_t handle;
>   drm_intel_bo_gem *bo_gem;
>   struct drm_i915_gem_get_tiling get_tiling;
> + drmMMListHead *list;
>  
>   ret = drmPrimeFDToHandle(bufmgr_gem->fd, prime_fd, &handle);
> +
> + /*
> +  * See if the kernel has already returned this buffer to us. Just as
> +  * for named buffers, we must not create two bo's pointing at the same
> +  * kernel object
> +  */
> + for (list = bufmgr_gem->named.next;
> +  list != &bufmgr_gem->named;
> +  list = list->next) {
> + bo_gem = DRMLISTENTRY(drm_intel_bo_gem, list, name_list);
> + if (bo_gem->gem_handle == handle) {
> + drm_intel_gem_bo_reference(&bo_gem->bo);
> + return &bo_gem->bo;
> + }
> + }
> +
>   if (ret) {
> fprintf(stderr,"ret is %d %d\n", ret, errno);
>   return NULL;
> @@ -2487,8 +2519,8 @@ drm_intel_bo_gem_create_from_prime(drm_intel_bufmgr 
> *bufmgr, int prime_fd, int s
>   bo_gem->has_error = false;
>   bo_gem->reusable = false;
>  
> - DRMINITLISTHEAD(&bo_gem->name_list);
>   DRMINITLISTHEAD(&bo_gem->vma_list);
> + DRMLISTADDTAIL(&bo_gem->name_list, &bufmgr_gem->named);
>  
>   VG_CLEAR(get_tiling);
>   get_tiling.handle = bo_gem->gem_handle;
> @@ -2513,6 +2545,9 @@ drm_intel_bo_gem_export_to_prime(drm_intel_bo *bo, int 
> *prime_fd)
>   drm_intel_bufmgr_gem *bufmgr_gem = (drm_inte

[Mesa-dev] [PATCH] i965: Always reserve binding table space for at least one render target.

2013-11-26 Thread Kenneth Graunke
In brw_update_renderbuffer_surfaces(), if there are no color draw
buffers, we always set up a null render target at surface index 0 so we
have something to use with the FB write marking the end of thread.

However, when we recently began computing surface indexes dynamically,
we failed to reserve space for it.  This meant that the first texture
would be assigned surface index 0, and our closing FB write would
clobber the texture.

Fixes Piglit's EXT_packed_depth_stencil/fbo-blit-d24s8 test on Gen4-5,
which regressed as of commit 4e5306453da6a1c076309e543ec92d999e02f67a
("i965/fs: Dynamically set up the WM binding table offsets.")

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=70605
Signed-off-by: Kenneth Graunke 
Cc: Eric Anholt 
Cc: "10.0" mesa-sta...@lists.freedesktop.org
---
 src/mesa/drivers/dri/i965/brw_fs.cpp | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

This works on 9.2, and fails on 10.0-rc2, so this fix absolutely must land
before the final 10.0 release (in keeping with our "no known regressions"
policy).

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 261f906..b96a0c2 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -3181,8 +3181,11 @@ fs_visitor::assign_binding_table_offsets()
 {
uint32_t next_binding_table_offset = 0;
 
+   /* If there are no color regions, we still perform an FB write to a null
+* renderbuffer, which we place at surface index 0.
+*/
c->prog_data.binding_table.render_target_start = next_binding_table_offset;
-   next_binding_table_offset += c->key.nr_color_regions;
+   next_binding_table_offset += MAX2(c->key.nr_color_regions, 1);
 
assign_common_binding_table_offsets(next_binding_table_offset);
 }
-- 
1.8.4.2

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


Re: [Mesa-dev] [PATCH 03/23] glsl: Add helper methods to glsl_type for dealing with images.

2013-11-26 Thread Pohjolainen, Topi
On Tue, Nov 26, 2013 at 12:02:19AM -0800, Francisco Jerez wrote:
> Add predicates to query if a GLSL type is or contains an image.
> Rename sampler_coordinate_components() to coordinate_components() and
> fix it to support calculating the number of coordinate dimensions of
> image types as well as sampler types.
> ---
>  src/glsl/builtin_functions.cpp|  2 +-
>  src/glsl/glsl_types.cpp   | 95 
> +--
>  src/glsl/glsl_types.h | 19 ++-
>  src/glsl/tests/sampler_types_test.cpp |  2 +-
>  4 files changed, 88 insertions(+), 30 deletions(-)
> 
> diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp
> index 8cb75e5..a1a338d 100644
> --- a/src/glsl/builtin_functions.cpp
> +++ b/src/glsl/builtin_functions.cpp
> @@ -3488,7 +3488,7 @@ builtin_builder::_texture(ir_texture_opcode opcode,
> ir_texture *tex = new(mem_ctx) ir_texture(opcode);
> tex->set_sampler(var_ref(s), return_type);
>  
> -   const int coord_size = sampler_type->sampler_coordinate_components();
> +   const int coord_size = sampler_type->coordinate_components();
>  
> if (coord_size == coord_type->vector_elements) {
>tex->coordinate = var_ref(P);
> diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
> index e24417d..8a6b531 100644
> --- a/src/glsl/glsl_types.cpp
> +++ b/src/glsl/glsl_types.cpp
> @@ -236,6 +236,21 @@ glsl_type::sampler_index() const
> }
>  }
>  
> +bool
> +glsl_type::contains_image() const
> +{
> +   if (this->is_array()) {
> +  return this->fields.array->contains_image();
> +   } else if (this->is_record()) {
> +  for (unsigned int i = 0; i < this->length; i++) {
> +  if (this->fields.structure[i].type->contains_image())
> + return true;
> +  }
> +  return false;
> +   } else {
> +  return this->is_image();
> +   }
> +}
>  
>  const glsl_type *glsl_type::get_base_type() const
>  {
> @@ -943,36 +958,64 @@ glsl_type::count_attribute_slots() const
>  }
>  
>  int
> -glsl_type::sampler_coordinate_components() const
> +glsl_type::coordinate_components() const
>  {
> -   assert(is_sampler());
> -
> int size;
>  
> -   switch (sampler_dimensionality) {
> -   case GLSL_SAMPLER_DIM_1D:
> -   case GLSL_SAMPLER_DIM_BUF:
> -  size = 1;
> -  break;
> -   case GLSL_SAMPLER_DIM_2D:
> -   case GLSL_SAMPLER_DIM_RECT:
> -   case GLSL_SAMPLER_DIM_MS:
> -   case GLSL_SAMPLER_DIM_EXTERNAL:
> -  size = 2;
> -  break;
> -   case GLSL_SAMPLER_DIM_3D:
> -   case GLSL_SAMPLER_DIM_CUBE:
> -  size = 3;
> -  break;
> -   default:
> -  assert(!"Should not get here.");
> -  size = 1;
> -  break;
> -   }
> +   if (is_sampler()) {
> +  switch (sampler_dimensionality) {
> +  case GLSL_SAMPLER_DIM_1D:
> +  case GLSL_SAMPLER_DIM_BUF:
> + size = 1;
> + break;
> +  case GLSL_SAMPLER_DIM_2D:
> +  case GLSL_SAMPLER_DIM_RECT:
> +  case GLSL_SAMPLER_DIM_MS:
> +  case GLSL_SAMPLER_DIM_EXTERNAL:
> + size = 2;
> + break;
> +  case GLSL_SAMPLER_DIM_3D:
> +  case GLSL_SAMPLER_DIM_CUBE:
> + size = 3;
> + break;
> +  default:
> + assert(!"Should not get here.");
> + size = 1;
> + break;
> +  }
> +
> +  /* Array textures need an additional component for the array
> +   * index. */
> +  if (sampler_array)
> + size += 1;
> +
> +   } else if (is_image()) {
> +  switch (fields.image.dimension) {
> +  case GLSL_IMAGE_DIM_1D:
> +  case GLSL_IMAGE_DIM_BUFFER:
> + size = 1;
> + break;
> +  case GLSL_IMAGE_DIM_2D:
> +  case GLSL_IMAGE_DIM_RECT:
> +  case GLSL_IMAGE_DIM_MS:
> + size = 2;
> + break;
> +  case GLSL_IMAGE_DIM_3D:
> +  case GLSL_IMAGE_DIM_CUBE:
> + size = 3;
> + break;
> +  default:
> + unreachable();
> +  }
> +
> +  /* Array textures need an additional component for the array
> +   * index. */
> +  if (fields.image.array)
> + size += 1;
>  
> -   /* Array textures need an additional component for the array index. */
> -   if (sampler_array)
> -  size += 1;
> +   } else {
> +  unreachable();
> +   }

I was thinking if it were clearer having the sampler and image cases handled by
separate members. They seem to have very little in common and the specific logic
for both is invoked from different code paths anyway:

For sampler the invocation is above in "builtin_builder::_texture()" and for
the image in "image_builtin_builder::create_signature()" (introduced by the
patch number 19).

>  
> return size;
>  }
> diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h
> index ea65bcd..e7b6dd8 100644
> --- a/src/glsl/glsl_types.h
> +++ b/src/glsl/glsl_types.h
> @@ -419,6 +419,20 @@ struct glsl_type {
> gl_texture_index sampler_index() const;
>  
> /**
> +* Query whether or not type is an image, or for struct and array
>

[Mesa-dev] radeonsi: always set the scanout flag?

2013-11-26 Thread Axel Davy

Hi,

When importing an handle (src/gallium/drivers/radeon/r600_texture.c),
the RADEON_SURF_SCANOUT flag is always set on SI.

The code is associated with a comment: /* always set the scanout flags 
on SI */


I was getting bad tiling mode on Wayland with my radeonsi card, and 
recent Mesa,

and I discovered that setting this flag there was causing my tiling issue.

I think one possible reason for this code is X dri2, since the DDX 
allocates

the buffers with this flag.

Could this flag be passed via buffer_get_tiling?

If not, then there would probably need to force this flag when creating 
a resource on SI.
But ideally, if it makes a performance difference, we would like to be 
able to control that

with Wayland when allocating the buffers.

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


Re: [Mesa-dev] [PATCH 02/23] glsl: Add image type to the GLSL IR.

2013-11-26 Thread Chris Forbes
@@ -618,6 +637,9 @@ glsl_type::component_slots() const
case GLSL_TYPE_ARRAY:
   return this->length * this->fields.array->component_
slots();

+   case GLSL_TYPE_IMAGE:
+  return 1;

Why is an image type one component, whereas the other opaque types are
zero at this level?



On Tue, Nov 26, 2013 at 9:02 PM, Francisco Jerez  wrote:
> ---
>  src/glsl/ast_to_hir.cpp  |  1 +
>  src/glsl/glsl_types.cpp  | 23 +++
>  src/glsl/glsl_types.h| 22 ++
>  src/glsl/ir_clone.cpp|  1 +
>  src/glsl/link_uniform_initializers.cpp   |  1 +
>  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp |  1 +
>  src/mesa/program/ir_to_mesa.cpp  |  2 ++
>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp   |  1 +
>  8 files changed, 52 insertions(+)
>
> diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
> index 43cf497..e7c4ff4 100644
> --- a/src/glsl/ast_to_hir.cpp
> +++ b/src/glsl/ast_to_hir.cpp
> @@ -948,6 +948,7 @@ do_comparison(void *mem_ctx, int operation, ir_rvalue 
> *op0, ir_rvalue *op1)
> case GLSL_TYPE_ERROR:
> case GLSL_TYPE_VOID:
> case GLSL_TYPE_SAMPLER:
> +   case GLSL_TYPE_IMAGE:
> case GLSL_TYPE_INTERFACE:
> case GLSL_TYPE_ATOMIC_UINT:
>/* I assume a comparison of a struct containing a sampler just
> diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
> index f740130..e24417d 100644
> --- a/src/glsl/glsl_types.cpp
> +++ b/src/glsl/glsl_types.cpp
> @@ -80,6 +80,24 @@ glsl_type::glsl_type(GLenum gl_type,
> memset(& fields, 0, sizeof(fields));
>  }
>
> +glsl_type::glsl_type(GLenum gl_type,
> +enum glsl_image_dim dim, bool array,
> +glsl_base_type type, const char *name) :
> +   gl_type(gl_type),
> +   base_type(GLSL_TYPE_IMAGE),
> +   sampler_dimensionality(0), sampler_shadow(0),
> +   sampler_array(0), sampler_type(0), interface_packing(0),
> +   vector_elements(1), matrix_columns(1),
> +   length(0), fields()
> +{
> +   init_ralloc_type_ctx();
> +   assert(name != NULL);
> +   this->name = ralloc_strdup(this->mem_ctx, name);
> +   fields.image.type = type;
> +   fields.image.dimension = dim;
> +   fields.image.array = array;
> +}
> +
>  glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
>  const char *name) :
> gl_type(0),
> @@ -172,6 +190,7 @@ bool
>  glsl_type::contains_opaque() const {
> switch (base_type) {
> case GLSL_TYPE_SAMPLER:
> +   case GLSL_TYPE_IMAGE:
> case GLSL_TYPE_ATOMIC_UINT:
>return true;
> case GLSL_TYPE_ARRAY:
> @@ -618,6 +637,9 @@ glsl_type::component_slots() const
> case GLSL_TYPE_ARRAY:
>return this->length * this->fields.array->component_slots();
>
> +   case GLSL_TYPE_IMAGE:
> +  return 1;
> +
> case GLSL_TYPE_SAMPLER:
> case GLSL_TYPE_ATOMIC_UINT:
> case GLSL_TYPE_VOID:
> @@ -908,6 +930,7 @@ glsl_type::count_attribute_slots() const
>return this->length * this->fields.array->count_attribute_slots();
>
> case GLSL_TYPE_SAMPLER:
> +   case GLSL_TYPE_IMAGE:
> case GLSL_TYPE_ATOMIC_UINT:
> case GLSL_TYPE_VOID:
> case GLSL_TYPE_ERROR:
> diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h
> index 96eee5e..ea65bcd 100644
> --- a/src/glsl/glsl_types.h
> +++ b/src/glsl/glsl_types.h
> @@ -53,6 +53,7 @@ enum glsl_base_type {
> GLSL_TYPE_FLOAT,
> GLSL_TYPE_BOOL,
> GLSL_TYPE_SAMPLER,
> +   GLSL_TYPE_IMAGE,
> GLSL_TYPE_ATOMIC_UINT,
> GLSL_TYPE_STRUCT,
> GLSL_TYPE_INTERFACE,
> @@ -72,6 +73,16 @@ enum glsl_sampler_dim {
> GLSL_SAMPLER_DIM_MS
>  };
>
> +enum glsl_image_dim {
> +   GLSL_IMAGE_DIM_1D,
> +   GLSL_IMAGE_DIM_2D,
> +   GLSL_IMAGE_DIM_3D,
> +   GLSL_IMAGE_DIM_RECT,
> +   GLSL_IMAGE_DIM_CUBE,
> +   GLSL_IMAGE_DIM_BUFFER,
> +   GLSL_IMAGE_DIM_MS
> +};
> +
>  enum glsl_interface_packing {
> GLSL_INTERFACE_PACKING_STD140,
> GLSL_INTERFACE_PACKING_SHARED,
> @@ -152,6 +163,12 @@ struct glsl_type {
>const struct glsl_type *array;/**< Type of array elements. 
> */
>const struct glsl_type *parameters;   /**< Parameters to function. 
> */
>struct glsl_struct_field *structure;  /**< List of struct fields. 
> */
> +
> +  struct {
> + glsl_base_type type; /**< Image data type as seen by the shader. */
> + glsl_image_dim dimension; /**< Base dimensionality of this image. */
> + bool array; /**< True if this is an array image type. */
> +  } image;
> } fields;
>
> /**
> @@ -562,6 +579,11 @@ private:
>  enum glsl_sampler_dim dim, bool shadow, bool array,
>  unsigned type, const char *name);
>
> +   /** Constructor for image types */
> +   glsl_type(GLenum gl_type,
> +enum glsl_image_dim dim, bool array,
> +glsl_base_type type, const char *name);
> +
> /** Constructor for record types */

[Mesa-dev] [PATCH 23/23] mesa: Handle binding of uniforms to image units with glUniform*().

2013-11-26 Thread Francisco Jerez
---
 src/mesa/main/uniform_query.cpp | 36 
 1 file changed, 36 insertions(+)

diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index 88ad476..fec45be 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -686,6 +686,9 @@ _mesa_uniform(struct gl_context *ctx, struct 
gl_shader_program *shProg,
case GLSL_TYPE_SAMPLER:
   match = (basicType == GLSL_TYPE_INT);
   break;
+   case GLSL_TYPE_IMAGE:
+  match = (type == GL_INT);
+  break;
default:
   match = (basicType == uni->type->base_type);
   break;
@@ -735,6 +738,22 @@ _mesa_uniform(struct gl_context *ctx, struct 
gl_shader_program *shProg,
   }
}
 
+   if (uni->type->is_image()) {
+  int i;
+
+  for (i = 0; i < count; i++) {
+ const int unit = ((GLint *) values)[i];
+
+ /* check that the image unit is legal */
+ if (unit < 0 || unit >= (int)ctx->Const.MaxImageUnits) {
+_mesa_error(ctx, GL_INVALID_VALUE,
+"glUniform1i(invalid image unit index for uniform %d)",
+location);
+return;
+ }
+  }
+   }
+
/* Page 82 (page 96 of the PDF) of the OpenGL 2.1 spec says:
 *
 * "When loading N elements starting at an arbitrary position k in a
@@ -830,6 +849,23 @@ _mesa_uniform(struct gl_context *ctx, struct 
gl_shader_program *shProg,
 }
   }
}
+
+   /* If the uniform is an image, update the mapping from image
+* uniforms to image units present in the shader data structure.
+*/
+   if (uni->type->is_image()) {
+  int i, j;
+
+  for (i = 0; i < MESA_SHADER_TYPES; i++) {
+if (uni->image[i].active) {
+struct gl_shader *sh = shProg->_LinkedShaders[i];
+
+for (j = 0; j < count; j++)
+   sh->ImageUnits[uni->image[i].index + offset + j] =
+  ((GLint *) values)[j];
+ }
+  }
+   }
 }
 
 /**
-- 
1.8.3.4

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


[Mesa-dev] [PATCH 22/23] glsl/linker: Propagate image uniform access qualifiers to the driver.

2013-11-26 Thread Francisco Jerez
---
 src/glsl/link_uniforms.cpp | 35 +++
 1 file changed, 35 insertions(+)

diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index 5780bb2..0aa66d3 100644
--- a/src/glsl/link_uniforms.cpp
+++ b/src/glsl/link_uniforms.cpp
@@ -751,6 +751,40 @@ link_assign_uniform_block_offsets(struct gl_shader *shader)
}
 }
 
+/**
+ * Scan the program for image uniforms and store image unit access
+ * information into the gl_shader data structure.
+ */
+static void
+link_set_image_access_qualifiers(struct gl_shader_program *prog)
+{
+   for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
+  gl_shader *sh = prog->_LinkedShaders[i];
+
+  if (sh == NULL)
+continue;
+
+  foreach_list(node, sh->ir) {
+ir_variable *var = ((ir_instruction *) node)->as_variable();
+
+ if (var && var->mode == ir_var_uniform &&
+ var->type->contains_image()) {
+unsigned id;
+bool found = prog->UniformHash->get(id, var->name);
+assert(found);
+const gl_uniform_storage *storage = &prog->UniformStorage[id];
+const unsigned index = storage->image[i].index;
+const GLenum access = (var->image.read_only ? GL_READ_ONLY :
+   var->image.write_only ? GL_WRITE_ONLY :
+   GL_READ_WRITE);
+
+for (unsigned j = 0; j < MAX2(1, storage->array_elements); ++j)
+   sh->ImageAccess[index + j] = access;
+ }
+  }
+   }
+}
+
 void
 link_assign_uniform_locations(struct gl_shader_program *prog)
 {
@@ -895,6 +929,7 @@ link_assign_uniform_locations(struct gl_shader_program 
*prog)
prog->NumUserUniformStorage = num_user_uniforms;
prog->UniformStorage = uniforms;
 
+   link_set_image_access_qualifiers(prog);
link_set_uniform_initializers(prog);
 
return;
-- 
1.8.3.4

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


[Mesa-dev] [PATCH 21/23] glsl/linker: Assign image uniform indices.

2013-11-26 Thread Francisco Jerez
---
 src/glsl/link_uniforms.cpp | 24 +++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index c75a38c..5780bb2 100644
--- a/src/glsl/link_uniforms.cpp
+++ b/src/glsl/link_uniforms.cpp
@@ -374,6 +374,7 @@ public:
   this->shader_samplers_used = 0;
   this->shader_shadow_samplers = 0;
   this->next_sampler = 0;
+  this->next_image = 0;
   memset(this->targets, 0, sizeof(this->targets));
}
 
@@ -470,6 +471,24 @@ private:
   }
}
 
+   void handle_images(const glsl_type *base_type,
+  struct gl_uniform_storage *uniform)
+   {
+  if (base_type->is_image()) {
+ uniform->image[shader_type].index = this->next_image;
+ uniform->image[shader_type].active = true;
+
+ /* Increment the image index by 1 for non-arrays and by the
+  * number of array elements for arrays.
+  */
+ this->next_image += MAX2(1, uniform->array_elements);
+
+  } else {
+ uniform->image[shader_type].index = ~0;
+ uniform->image[shader_type].active = false;
+  }
+   }
+
virtual void visit_field(const glsl_type *type, const char *name,
 bool row_major)
{
@@ -505,8 +524,9 @@ private:
 base_type = type;
   }
 
-  /* This assigns sampler uniforms to sampler units. */
+  /* This assigns uniform indices to sampler and image uniforms. */
   handle_samplers(base_type, &this->uniforms[id]);
+  handle_images(base_type, &this->uniforms[id]);
 
   /* If there is already storage associated with this uniform, it means
* that it was set while processing an earlier shader stage.  For
@@ -564,6 +584,7 @@ private:
 
struct gl_uniform_storage *uniforms;
unsigned next_sampler;
+   unsigned next_image;
 
 public:
union gl_constant_value *values;
@@ -767,6 +788,7 @@ link_assign_uniform_locations(struct gl_shader_program 
*prog)
* types cannot have initializers."
*/
   memset(sh->SamplerUnits, 0, sizeof(sh->SamplerUnits));
+  memset(sh->ImageUnits, 0, sizeof(sh->ImageUnits));
 
   link_update_uniform_buffer_variables(sh);
 
-- 
1.8.3.4

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


[Mesa-dev] [PATCH 05/23] glsl: Add gl_uniform_storage fields to keep track of image uniform indices.

2013-11-26 Thread Francisco Jerez
---
 src/glsl/ir_uniform.h | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/src/glsl/ir_uniform.h b/src/glsl/ir_uniform.h
index 13faab7..0704061 100644
--- a/src/glsl/ir_uniform.h
+++ b/src/glsl/ir_uniform.h
@@ -118,6 +118,25 @@ struct gl_uniform_storage {
   bool active;
} sampler[MESA_SHADER_TYPES];
 
+   struct {
+  /**
+   * Base image index
+   *
+   * If \c ::base_type is \c GLSL_TYPE_IMAGE, this represents the
+   * index of this image.  If \c ::array_elements is not zero, the
+   * array will use indices \c index through \c index + \c
+   * ::array_elements - 1, inclusive.
+   *
+   * Note that the index may be different in each shader stage.
+   */
+  uint8_t index;
+
+  /**
+   * Whether this image is used in this shader stage.
+   */
+  bool active;
+   } image[MESA_SHADER_TYPES];
+
/**
 * Storage used by the driver for the uniform
 */
-- 
1.8.3.4

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


[Mesa-dev] [PATCH 08/23] glsl/parser: Handle the early_fragment_tests input layout qualifier.

2013-11-26 Thread Francisco Jerez
---
 src/glsl/glsl_parser.yy | 61 ++---
 src/glsl/glsl_parser_extras.cpp |  1 +
 src/glsl/glsl_parser_extras.h   |  2 ++
 3 files changed, 42 insertions(+), 22 deletions(-)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 44c332d..e436b16 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -1295,6 +1295,15 @@ layout_qualifier_id:
  }
   }
 
+  /* Layout qualifiers for ARB_shader_image_load_store. */
+  if (state->ARB_shader_image_load_store_enable ||
+  state->is_version(420, 0)) {
+ if (!$$.flags.i &&
+ match_layout_qualifier($1, "early_fragment_tests", state) == 0) {
+$$.flags.q.early_fragment_tests = 1;
+ }
+  }
+
   if (!$$.flags.i) {
  _mesa_glsl_error(& @1, state, "unrecognized layout identifier "
   "`%s'", $1);
@@ -2373,31 +2382,39 @@ layout_defaults:
| layout_qualifier IN_TOK ';'
{
   void *ctx = state;
+  ast_type_qualifier qualifier = $1;
+
   $$ = NULL;
-  if (state->target != geometry_shader) {
- _mesa_glsl_error(& @1, state,
-  "input layout qualifiers only valid in "
-  "geometry shaders");
-  } else if (!$1.flags.q.prim_type) {
- _mesa_glsl_error(& @1, state,
-  "input layout qualifiers must specify a primitive"
-  " type");
-  } else {
- /* Make sure this is a valid input primitive type. */
- switch ($1.prim_type) {
- case GL_POINTS:
- case GL_LINES:
- case GL_LINES_ADJACENCY:
- case GL_TRIANGLES:
- case GL_TRIANGLES_ADJACENCY:
-$$ = new(ctx) ast_gs_input_layout(@1, $1.prim_type);
-break;
- default:
-_mesa_glsl_error(&@1, state,
- "invalid geometry shader input primitive type");
-break;
+
+  if (state->target == geometry_shader) {
+ if (qualifier.flags.q.prim_type) {
+/* Make sure this is a valid input primitive type. */
+switch (qualifier.prim_type) {
+case GL_POINTS:
+case GL_LINES:
+case GL_LINES_ADJACENCY:
+case GL_TRIANGLES:
+case GL_TRIANGLES_ADJACENCY:
+   $$ = new(ctx) ast_gs_input_layout(@1, qualifier.prim_type);
+   break;
+default:
+   _mesa_glsl_error(&@1, state,
+"invalid geometry shader input primitive 
type");
+   break;
+}
+
+qualifier.flags.q.prim_type = 0;
  }
   }
+
+  if (qualifier.flags.q.early_fragment_tests) {
+ state->early_fragment_tests = true;
+ qualifier.flags.q.early_fragment_tests = 0;
+  }
+
+  if (qualifier.flags.i) {
+ _mesa_glsl_error(&@1, state, "invalid input layout qualifier");
+  }
}
 
| layout_qualifier OUT_TOK ';'
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 3719f5c..1c82a1d 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -191,6 +191,7 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct 
gl_context *_ctx,
this->gs_input_prim_type = GL_POINTS;
this->gs_input_size = 0;
this->out_qualifier = new(this) ast_type_qualifier();
+   this->early_fragment_tests = false;
 }
 
 /**
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index d7cff89..ba02166 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -376,6 +376,8 @@ struct _mesa_glsl_parse_state {
 */
unsigned gs_input_size;
 
+   bool early_fragment_tests;
+
/** Atomic counter offsets by binding */
unsigned atomic_counter_offsets[MAX_COMBINED_ATOMIC_BUFFERS];
 };
-- 
1.8.3.4

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


[Mesa-dev] [PATCH 02/23] glsl: Add image type to the GLSL IR.

2013-11-26 Thread Francisco Jerez
---
 src/glsl/ast_to_hir.cpp  |  1 +
 src/glsl/glsl_types.cpp  | 23 +++
 src/glsl/glsl_types.h| 22 ++
 src/glsl/ir_clone.cpp|  1 +
 src/glsl/link_uniform_initializers.cpp   |  1 +
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp |  1 +
 src/mesa/program/ir_to_mesa.cpp  |  2 ++
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp   |  1 +
 8 files changed, 52 insertions(+)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 43cf497..e7c4ff4 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -948,6 +948,7 @@ do_comparison(void *mem_ctx, int operation, ir_rvalue *op0, 
ir_rvalue *op1)
case GLSL_TYPE_ERROR:
case GLSL_TYPE_VOID:
case GLSL_TYPE_SAMPLER:
+   case GLSL_TYPE_IMAGE:
case GLSL_TYPE_INTERFACE:
case GLSL_TYPE_ATOMIC_UINT:
   /* I assume a comparison of a struct containing a sampler just
diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
index f740130..e24417d 100644
--- a/src/glsl/glsl_types.cpp
+++ b/src/glsl/glsl_types.cpp
@@ -80,6 +80,24 @@ glsl_type::glsl_type(GLenum gl_type,
memset(& fields, 0, sizeof(fields));
 }
 
+glsl_type::glsl_type(GLenum gl_type,
+enum glsl_image_dim dim, bool array,
+glsl_base_type type, const char *name) :
+   gl_type(gl_type),
+   base_type(GLSL_TYPE_IMAGE),
+   sampler_dimensionality(0), sampler_shadow(0),
+   sampler_array(0), sampler_type(0), interface_packing(0),
+   vector_elements(1), matrix_columns(1),
+   length(0), fields()
+{
+   init_ralloc_type_ctx();
+   assert(name != NULL);
+   this->name = ralloc_strdup(this->mem_ctx, name);
+   fields.image.type = type;
+   fields.image.dimension = dim;
+   fields.image.array = array;
+}
+
 glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields,
 const char *name) :
gl_type(0),
@@ -172,6 +190,7 @@ bool
 glsl_type::contains_opaque() const {
switch (base_type) {
case GLSL_TYPE_SAMPLER:
+   case GLSL_TYPE_IMAGE:
case GLSL_TYPE_ATOMIC_UINT:
   return true;
case GLSL_TYPE_ARRAY:
@@ -618,6 +637,9 @@ glsl_type::component_slots() const
case GLSL_TYPE_ARRAY:
   return this->length * this->fields.array->component_slots();
 
+   case GLSL_TYPE_IMAGE:
+  return 1;
+
case GLSL_TYPE_SAMPLER:
case GLSL_TYPE_ATOMIC_UINT:
case GLSL_TYPE_VOID:
@@ -908,6 +930,7 @@ glsl_type::count_attribute_slots() const
   return this->length * this->fields.array->count_attribute_slots();
 
case GLSL_TYPE_SAMPLER:
+   case GLSL_TYPE_IMAGE:
case GLSL_TYPE_ATOMIC_UINT:
case GLSL_TYPE_VOID:
case GLSL_TYPE_ERROR:
diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h
index 96eee5e..ea65bcd 100644
--- a/src/glsl/glsl_types.h
+++ b/src/glsl/glsl_types.h
@@ -53,6 +53,7 @@ enum glsl_base_type {
GLSL_TYPE_FLOAT,
GLSL_TYPE_BOOL,
GLSL_TYPE_SAMPLER,
+   GLSL_TYPE_IMAGE,
GLSL_TYPE_ATOMIC_UINT,
GLSL_TYPE_STRUCT,
GLSL_TYPE_INTERFACE,
@@ -72,6 +73,16 @@ enum glsl_sampler_dim {
GLSL_SAMPLER_DIM_MS
 };
 
+enum glsl_image_dim {
+   GLSL_IMAGE_DIM_1D,
+   GLSL_IMAGE_DIM_2D,
+   GLSL_IMAGE_DIM_3D,
+   GLSL_IMAGE_DIM_RECT,
+   GLSL_IMAGE_DIM_CUBE,
+   GLSL_IMAGE_DIM_BUFFER,
+   GLSL_IMAGE_DIM_MS
+};
+
 enum glsl_interface_packing {
GLSL_INTERFACE_PACKING_STD140,
GLSL_INTERFACE_PACKING_SHARED,
@@ -152,6 +163,12 @@ struct glsl_type {
   const struct glsl_type *array;/**< Type of array elements. */
   const struct glsl_type *parameters;   /**< Parameters to function. */
   struct glsl_struct_field *structure;  /**< List of struct fields. */
+
+  struct {
+ glsl_base_type type; /**< Image data type as seen by the shader. */
+ glsl_image_dim dimension; /**< Base dimensionality of this image. */
+ bool array; /**< True if this is an array image type. */
+  } image;
} fields;
 
/**
@@ -562,6 +579,11 @@ private:
 enum glsl_sampler_dim dim, bool shadow, bool array,
 unsigned type, const char *name);
 
+   /** Constructor for image types */
+   glsl_type(GLenum gl_type,
+enum glsl_image_dim dim, bool array,
+glsl_base_type type, const char *name);
+
/** Constructor for record types */
glsl_type(const glsl_struct_field *fields, unsigned num_fields,
 const char *name);
diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp
index 40ed33a..ed26aae 100644
--- a/src/glsl/ir_clone.cpp
+++ b/src/glsl/ir_clone.cpp
@@ -398,6 +398,7 @@ ir_constant::clone(void *mem_ctx, struct hash_table *ht) 
const
}
 
case GLSL_TYPE_SAMPLER:
+   case GLSL_TYPE_IMAGE:
case GLSL_TYPE_ATOMIC_UINT:
case GLSL_TYPE_VOID:
case GLSL_TYPE_ERROR:
diff --git a/src/glsl/link_uniform_initializers.cpp 
b/src/glsl/link_uniform_initializers.cpp
index 786aaf0..f02978c 100644
--- a

[Mesa-dev] [PATCH 06/23] glsl/ast: Keep track of type qualifiers defined by ARB_shader_image_load_store.

2013-11-26 Thread Francisco Jerez
---
 src/glsl/ast.h| 32 +++-
 src/glsl/ast_type.cpp |  5 +
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/src/glsl/ast.h b/src/glsl/ast.h
index 5c214b6..b750bb7 100644
--- a/src/glsl/ast.h
+++ b/src/glsl/ast.h
@@ -413,12 +413,23 @@ struct ast_type_qualifier {
 unsigned prim_type:1;
 unsigned max_vertices:1;
 /** \} */
+
+/** \name Layout and memory qualifiers for 
ARB_shader_image_load_store. */
+/** \{ */
+unsigned early_fragment_tests:1;
+unsigned explicit_image_format:1;
+unsigned coherent:1;
+unsigned _volatile:1;
+unsigned _restrict:1;
+unsigned read_only:1;
+unsigned write_only:1;
+/** \} */
   }
   /** \brief Set of flags, accessed by name. */
   q;
 
   /** \brief Set of flags, accessed as a bitmask. */
-  unsigned i;
+  uint64_t i;
} flags;
 
/** Precision of the type (highp/medium/lowp). */
@@ -463,6 +474,25 @@ struct ast_type_qualifier {
int offset;
 
/**
+* Image format specified with an ARB_shader_image_load_store
+* layout qualifier.
+*
+* \note
+* This field is only valid if \c explicit_image_format is set.
+*/
+   GLenum image_format;
+
+   /**
+* Base type of the data read from or written to this image.  Only
+* the following enumerants are allowed: GLSL_TYPE_UINT,
+* GLSL_TYPE_INT, GLSL_TYPE_FLOAT.
+*
+* \note
+* This field is only valid if \c explicit_image_format is set.
+*/
+   glsl_base_type image_base_type;
+
+   /**
 * Return true if and only if an interpolation qualifier is present.
 */
bool has_interpolation() const;
diff --git a/src/glsl/ast_type.cpp b/src/glsl/ast_type.cpp
index 2b088bf..64c6758 100644
--- a/src/glsl/ast_type.cpp
+++ b/src/glsl/ast_type.cpp
@@ -180,6 +180,11 @@ ast_type_qualifier::merge_qualifier(YYLTYPE *loc,
if (q.precision != ast_precision_none)
   this->precision = q.precision;
 
+   if (q.flags.q.explicit_image_format) {
+  this->image_format = q.image_format;
+  this->image_base_type = q.image_base_type;
+   }
+
return true;
 }
 
-- 
1.8.3.4

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


[Mesa-dev] [PATCH 16/23] glsl: Add built-in types defined by ARB_shader_image_load_store.

2013-11-26 Thread Francisco Jerez
---
 src/glsl/builtin_type_macros.h | 34 
 src/glsl/builtin_types.cpp | 70 ++
 2 files changed, 104 insertions(+)

diff --git a/src/glsl/builtin_type_macros.h b/src/glsl/builtin_type_macros.h
index 263fd83..4795ad9 100644
--- a/src/glsl/builtin_type_macros.h
+++ b/src/glsl/builtin_type_macros.h
@@ -110,6 +110,40 @@ DECL_TYPE(sampler2DRectShadow,
GL_SAMPLER_2D_RECT_SHADOW,GLSL_SAMPLER
 
 DECL_TYPE(samplerExternalOES, GL_SAMPLER_EXTERNAL_OES,  
GLSL_SAMPLER_DIM_EXTERNAL, 0, 0, GLSL_TYPE_FLOAT)
 
+DECL_TYPE(image1D, GL_IMAGE_1D,
GLSL_IMAGE_DIM_1D, 0, GLSL_TYPE_FLOAT);
+DECL_TYPE(image2D, GL_IMAGE_2D,
GLSL_IMAGE_DIM_2D, 0, GLSL_TYPE_FLOAT);
+DECL_TYPE(image3D, GL_IMAGE_3D,
GLSL_IMAGE_DIM_3D, 0, GLSL_TYPE_FLOAT);
+DECL_TYPE(image2DRect, GL_IMAGE_2D_RECT,   
GLSL_IMAGE_DIM_RECT,   0, GLSL_TYPE_FLOAT);
+DECL_TYPE(imageCube,   GL_IMAGE_CUBE,  
GLSL_IMAGE_DIM_CUBE,   0, GLSL_TYPE_FLOAT);
+DECL_TYPE(imageBuffer, GL_IMAGE_BUFFER,
GLSL_IMAGE_DIM_BUFFER, 0, GLSL_TYPE_FLOAT);
+DECL_TYPE(image1DArray,GL_IMAGE_1D_ARRAY,  
GLSL_IMAGE_DIM_1D, 1, GLSL_TYPE_FLOAT);
+DECL_TYPE(image2DArray,GL_IMAGE_2D_ARRAY,  
GLSL_IMAGE_DIM_2D, 1, GLSL_TYPE_FLOAT);
+DECL_TYPE(imageCubeArray,  GL_IMAGE_CUBE_MAP_ARRAY,
GLSL_IMAGE_DIM_CUBE,   1, GLSL_TYPE_FLOAT);
+DECL_TYPE(image2DMS,   GL_IMAGE_2D_MULTISAMPLE,
GLSL_IMAGE_DIM_MS, 0, GLSL_TYPE_FLOAT);
+DECL_TYPE(image2DMSArray,  GL_IMAGE_2D_MULTISAMPLE_ARRAY,  
GLSL_IMAGE_DIM_MS, 1, GLSL_TYPE_FLOAT);
+DECL_TYPE(iimage1D,GL_INT_IMAGE_1D,
GLSL_IMAGE_DIM_1D, 0, GLSL_TYPE_INT);
+DECL_TYPE(iimage2D,GL_INT_IMAGE_2D,
GLSL_IMAGE_DIM_2D, 0, GLSL_TYPE_INT);
+DECL_TYPE(iimage3D,GL_INT_IMAGE_3D,
GLSL_IMAGE_DIM_3D, 0, GLSL_TYPE_INT);
+DECL_TYPE(iimage2DRect,GL_INT_IMAGE_2D_RECT,   
GLSL_IMAGE_DIM_RECT,   0, GLSL_TYPE_INT);
+DECL_TYPE(iimageCube,  GL_INT_IMAGE_CUBE,  
GLSL_IMAGE_DIM_CUBE,   0, GLSL_TYPE_INT);
+DECL_TYPE(iimageBuffer,GL_INT_IMAGE_BUFFER,
GLSL_IMAGE_DIM_BUFFER, 0, GLSL_TYPE_INT);
+DECL_TYPE(iimage1DArray,   GL_INT_IMAGE_1D_ARRAY,  
GLSL_IMAGE_DIM_1D, 1, GLSL_TYPE_INT);
+DECL_TYPE(iimage2DArray,   GL_INT_IMAGE_2D_ARRAY,  
GLSL_IMAGE_DIM_2D, 1, GLSL_TYPE_INT);
+DECL_TYPE(iimageCubeArray, GL_INT_IMAGE_CUBE_MAP_ARRAY,
GLSL_IMAGE_DIM_CUBE,   1, GLSL_TYPE_INT);
+DECL_TYPE(iimage2DMS,  GL_INT_IMAGE_2D_MULTISAMPLE,
GLSL_IMAGE_DIM_MS, 0, GLSL_TYPE_INT);
+DECL_TYPE(iimage2DMSArray, GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY,  
GLSL_IMAGE_DIM_MS, 1, GLSL_TYPE_INT);
+DECL_TYPE(uimage1D,GL_UNSIGNED_INT_IMAGE_1D,   
GLSL_IMAGE_DIM_1D, 0, GLSL_TYPE_UINT);
+DECL_TYPE(uimage2D,GL_UNSIGNED_INT_IMAGE_2D,   
GLSL_IMAGE_DIM_2D, 0, GLSL_TYPE_UINT);
+DECL_TYPE(uimage3D,GL_UNSIGNED_INT_IMAGE_3D,   
GLSL_IMAGE_DIM_3D, 0, GLSL_TYPE_UINT);
+DECL_TYPE(uimage2DRect,GL_UNSIGNED_INT_IMAGE_2D_RECT,  
GLSL_IMAGE_DIM_RECT,   0, GLSL_TYPE_UINT);
+DECL_TYPE(uimageCube,  GL_UNSIGNED_INT_IMAGE_CUBE, 
GLSL_IMAGE_DIM_CUBE,   0, GLSL_TYPE_UINT);
+DECL_TYPE(uimageBuffer,GL_UNSIGNED_INT_IMAGE_BUFFER,   
GLSL_IMAGE_DIM_BUFFER, 0, GLSL_TYPE_UINT);
+DECL_TYPE(uimage1DArray,   GL_UNSIGNED_INT_IMAGE_1D_ARRAY, 
GLSL_IMAGE_DIM_1D, 1, GLSL_TYPE_UINT);
+DECL_TYPE(uimage2DArray,   GL_UNSIGNED_INT_IMAGE_2D_ARRAY, 
GLSL_IMAGE_DIM_2D, 1, GLSL_TYPE_UINT);
+DECL_TYPE(uimageCubeArray, GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY,   
GLSL_IMAGE_DIM_CUBE,   1, GLSL_TYPE_UINT);
+DECL_TYPE(uimage2DMS,  GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE,   
GLSL_IMAGE_DIM_MS, 0, GLSL_TYPE_UINT);
+DECL_TYPE(uimage2DMSArray, GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY, 
GLSL_IMAGE_DIM_MS, 1, GLSL_TYPE_UINT);
+
 DECL_TYPE(atomic_uint, GL_UNSIGNED_INT_ATOMIC_COUNTER, GLSL_TYPE_ATOMIC_UINT, 
1, 1)
 
 STRUCT_TYPE(gl_DepthRangeParameters)
diff --git a/src/glsl/builtin_types.cpp b/src/glsl/builtin_types.cpp
index 92e3860..dd42ecb 100644
--- a/src/glsl/builtin_types.cpp
+++ b/src/glsl/builtin_types.cpp
@@ -204,6 +204,40 @@ const static struct builtin_type_versions {
 
T(struct_gl_DepthRangeParameters,  110, 100)
 
+   T(image1D, 420, 999)
+   T(image2D, 420, 999)
+   T(image3D, 420, 999)
+   T(image2DRect,

[Mesa-dev] [PATCH 19/23] glsl: Add image built-in function generator.

2013-11-26 Thread Francisco Jerez
Because of the combinatorial explosion of different image built-ins
with different image dimensionalities and base data types, enumerating
all the 242 possibilities would be annoying and a waste of .text
space.  Instead use a special path in the built-in builder that loops
over all the known image types.
---
 src/glsl/builtin_functions.cpp | 378 +
 1 file changed, 378 insertions(+)

diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp
index a1a338d..760e264 100644
--- a/src/glsl/builtin_functions.cpp
+++ b/src/glsl/builtin_functions.cpp
@@ -334,12 +334,20 @@ shader_atomic_counters(const _mesa_glsl_parse_state 
*state)
return state->ARB_shader_atomic_counters_enable;
 }
 
+static bool
+shader_image_load_store(const _mesa_glsl_parse_state *state)
+{
+   return state->ARB_shader_image_load_store_enable;
+}
+
 /** @} */
 
 
/**/
 
 namespace {
 
+class image_builtin_builder;
+
 /**
  * builtin_builder: A singleton object representing the core of the built-in
  * function module.
@@ -406,6 +414,13 @@ private:
/** Create a new function and add the given signatures. */
void add_function(const char *name, ...);
 
+   /**
+* Create a new function calling \param func for each known image
+* type to generate its signatures.
+*/
+   void add_image_function(const char *name,
+   const image_builtin_builder &func);
+
ir_function_signature *new_sig(const glsl_type *return_type,
   builtin_available_predicate avail,
   int num_params, ...);
@@ -569,6 +584,11 @@ private:
ir_function_signature *_atomic_op(const char *intrinsic,
  builtin_available_predicate avail);
 
+   ir_function_signature *_memory_barrier_intrinsic(
+  builtin_available_predicate avail);
+   ir_function_signature *_memory_barrier(
+  builtin_available_predicate avail);
+
 #undef B0
 #undef B1
 #undef B2
@@ -576,6 +596,171 @@ private:
 #undef BA1
 #undef BA2
/** @} */
+
+   friend class image_builtin_builder;
+};
+
+/**
+ * Functor that generates image load, store or atomic built-in
+ * signatures given some settings.
+ */
+class image_builtin_builder
+{
+public:
+   image_builtin_builder(builtin_builder &bld)
+  : bld(bld),
+_emit_stub(false),
+_intrinsic_name(NULL),
+_has_return(false),
+_has_arguments(0),
+_has_vector_data_type(false),
+_has_float_data_type(false),
+_read_only(false),
+_write_only(false)
+   {
+   }
+
+   /**
+* Build a stub function that calls \c intrinsic_name forwarding
+* arguments and return type.
+*/
+   image_builtin_builder &
+   emit_stub(const char *intrinsic_name)
+   {
+  _emit_stub = true;
+  _intrinsic_name = intrinsic_name;
+  return *this;
+   }
+
+   image_builtin_builder &
+   has_return()
+   {
+  _has_return = true;
+  return *this;
+   }
+
+   image_builtin_builder &
+   has_arguments(unsigned n)
+   {
+  _has_arguments = n;
+  return *this;
+   }
+
+   image_builtin_builder &
+   has_vector_data_type()
+   {
+  _has_vector_data_type = true;
+  return *this;
+   }
+
+   image_builtin_builder &
+   has_float_data_type()
+   {
+  _has_float_data_type = true;
+  return *this;
+   }
+
+   image_builtin_builder &
+   read_only()
+   {
+  _read_only = true;
+  return *this;
+   }
+
+   image_builtin_builder &
+   write_only()
+   {
+  _write_only = true;
+  return *this;
+   }
+
+   /**
+* Generate the image built-in.
+*/
+   ir_function_signature *
+   operator()(const glsl_type *image_type) const
+   {
+  if (image_type->fields.image.type == GLSL_TYPE_FLOAT &&
+  !_has_float_data_type)
+ return NULL;
+
+  ir_function_signature *sig = create_signature(image_type);
+
+  if (_emit_stub) {
+ ir_factory body(&sig->body, bld.mem_ctx);
+ ir_function *f = bld.shader->symbols->get_function(_intrinsic_name);
+
+ if (_has_return) {
+ir_variable *ret_val =
+   body.make_temp(sig->return_type, "_ret_val");
+body.emit(bld.call(f, ret_val, sig->parameters));
+body.emit(ret(ret_val));
+ } else {
+body.emit(bld.call(f, NULL, sig->parameters));
+ }
+
+ sig->is_defined = true;
+
+  } else {
+ sig->is_intrinsic = true;
+  }
+
+  return sig;
+   }
+
+private:
+   ir_function_signature *
+   create_signature(const glsl_type *image_type) const
+   {
+  const glsl_type *data_type =
+ glsl_type::get_instance(image_type->fields.image.type,
+ (_has_vector_data_type ? 4 : 1), 1);
+  const glsl_type *ret_type = (_has_return ? data_type :
+   glsl_type::void_type);
+
+

[Mesa-dev] [PATCH 14/23] glsl/ast: Forbid declaration of image variables in structures and uniform blocks.

2013-11-26 Thread Francisco Jerez
Aggregating images inside uniform blocks is explicitly disallowed by
the standard, aggregating them inside structures is not (as of GL
4.4), but there is a similar problem as with atomic counters: image
uniform declarations require either a "writeonly" memory qualifier or
an explicit format qualifier, which are explicitly forbidden in
structure member declarations.  In the resolution of Khronos bug
#10903 the same wording applied to atomic counters was decided to mean
that they're not allowed inside structures -- Rejecting image member
declarations within structures seems the most reasonable option for
now.
---
 src/glsl/ast_to_hir.cpp | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 1d13a2c..b421b81 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -4693,6 +4693,16 @@ ast_process_structure_or_interface_block(exec_list 
*instructions,
  "uniform block");
  }
 
+ if (field_type->contains_image()) {
+/* FINISHME: Same problem as with atomic counters.
+ * FINISHME: Request clarification from Khronos and add
+ * FINISHME: spec quotation here.
+ */
+YYLTYPE loc = decl_list->get_location();
+_mesa_glsl_error(&loc, state,
+ "image in structure or uniform block");
+ }
+
  const struct ast_type_qualifier *const qual =
 & decl_list->type->qualifier;
  if (qual->flags.q.std140 ||
-- 
1.8.3.4

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


[Mesa-dev] [PATCH 03/23] glsl: Add helper methods to glsl_type for dealing with images.

2013-11-26 Thread Francisco Jerez
Add predicates to query if a GLSL type is or contains an image.
Rename sampler_coordinate_components() to coordinate_components() and
fix it to support calculating the number of coordinate dimensions of
image types as well as sampler types.
---
 src/glsl/builtin_functions.cpp|  2 +-
 src/glsl/glsl_types.cpp   | 95 +--
 src/glsl/glsl_types.h | 19 ++-
 src/glsl/tests/sampler_types_test.cpp |  2 +-
 4 files changed, 88 insertions(+), 30 deletions(-)

diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp
index 8cb75e5..a1a338d 100644
--- a/src/glsl/builtin_functions.cpp
+++ b/src/glsl/builtin_functions.cpp
@@ -3488,7 +3488,7 @@ builtin_builder::_texture(ir_texture_opcode opcode,
ir_texture *tex = new(mem_ctx) ir_texture(opcode);
tex->set_sampler(var_ref(s), return_type);
 
-   const int coord_size = sampler_type->sampler_coordinate_components();
+   const int coord_size = sampler_type->coordinate_components();
 
if (coord_size == coord_type->vector_elements) {
   tex->coordinate = var_ref(P);
diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
index e24417d..8a6b531 100644
--- a/src/glsl/glsl_types.cpp
+++ b/src/glsl/glsl_types.cpp
@@ -236,6 +236,21 @@ glsl_type::sampler_index() const
}
 }
 
+bool
+glsl_type::contains_image() const
+{
+   if (this->is_array()) {
+  return this->fields.array->contains_image();
+   } else if (this->is_record()) {
+  for (unsigned int i = 0; i < this->length; i++) {
+if (this->fields.structure[i].type->contains_image())
+   return true;
+  }
+  return false;
+   } else {
+  return this->is_image();
+   }
+}
 
 const glsl_type *glsl_type::get_base_type() const
 {
@@ -943,36 +958,64 @@ glsl_type::count_attribute_slots() const
 }
 
 int
-glsl_type::sampler_coordinate_components() const
+glsl_type::coordinate_components() const
 {
-   assert(is_sampler());
-
int size;
 
-   switch (sampler_dimensionality) {
-   case GLSL_SAMPLER_DIM_1D:
-   case GLSL_SAMPLER_DIM_BUF:
-  size = 1;
-  break;
-   case GLSL_SAMPLER_DIM_2D:
-   case GLSL_SAMPLER_DIM_RECT:
-   case GLSL_SAMPLER_DIM_MS:
-   case GLSL_SAMPLER_DIM_EXTERNAL:
-  size = 2;
-  break;
-   case GLSL_SAMPLER_DIM_3D:
-   case GLSL_SAMPLER_DIM_CUBE:
-  size = 3;
-  break;
-   default:
-  assert(!"Should not get here.");
-  size = 1;
-  break;
-   }
+   if (is_sampler()) {
+  switch (sampler_dimensionality) {
+  case GLSL_SAMPLER_DIM_1D:
+  case GLSL_SAMPLER_DIM_BUF:
+ size = 1;
+ break;
+  case GLSL_SAMPLER_DIM_2D:
+  case GLSL_SAMPLER_DIM_RECT:
+  case GLSL_SAMPLER_DIM_MS:
+  case GLSL_SAMPLER_DIM_EXTERNAL:
+ size = 2;
+ break;
+  case GLSL_SAMPLER_DIM_3D:
+  case GLSL_SAMPLER_DIM_CUBE:
+ size = 3;
+ break;
+  default:
+ assert(!"Should not get here.");
+ size = 1;
+ break;
+  }
+
+  /* Array textures need an additional component for the array
+   * index. */
+  if (sampler_array)
+ size += 1;
+
+   } else if (is_image()) {
+  switch (fields.image.dimension) {
+  case GLSL_IMAGE_DIM_1D:
+  case GLSL_IMAGE_DIM_BUFFER:
+ size = 1;
+ break;
+  case GLSL_IMAGE_DIM_2D:
+  case GLSL_IMAGE_DIM_RECT:
+  case GLSL_IMAGE_DIM_MS:
+ size = 2;
+ break;
+  case GLSL_IMAGE_DIM_3D:
+  case GLSL_IMAGE_DIM_CUBE:
+ size = 3;
+ break;
+  default:
+ unreachable();
+  }
+
+  /* Array textures need an additional component for the array
+   * index. */
+  if (fields.image.array)
+ size += 1;
 
-   /* Array textures need an additional component for the array index. */
-   if (sampler_array)
-  size += 1;
+   } else {
+  unreachable();
+   }
 
return size;
 }
diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h
index ea65bcd..e7b6dd8 100644
--- a/src/glsl/glsl_types.h
+++ b/src/glsl/glsl_types.h
@@ -419,6 +419,20 @@ struct glsl_type {
gl_texture_index sampler_index() const;
 
/**
+* Query whether or not type is an image, or for struct and array
+* types, contains an image.
+*/
+   bool contains_image() const;
+
+   /**
+* Query whether or not a type is an image
+*/
+   bool is_image() const
+   {
+  return base_type == GLSL_TYPE_IMAGE;
+   }
+
+   /**
 * Query whether or not a type is an array
 */
bool is_array() const
@@ -548,7 +562,8 @@ struct glsl_type {
}
 
/**
-* Return the number of coordinate components needed for this sampler type.
+* Return the number of coordinate components needed for this
+* sampler or image type.
 *
 * This is based purely on the sampler's dimensionality.  For example, this
 * returns 1 for sampler1D, and 3 for sampler2DArray.
@@ -557,7 +572,7 @@ struct glsl_type {
 * a texturing built-in

[Mesa-dev] [PATCH 15/23] glsl/ast: Generalize some sampler variable restrictions to all opaque types.

2013-11-26 Thread Francisco Jerez
No opaque types may be statically initialized in the shader, all
opaque variables must be declared uniform or be part of an "in"
function parameter declaration, no opaque types may be used as the
return type of a function.
---
 src/glsl/ast_to_hir.cpp | 45 ++---
 1 file changed, 26 insertions(+), 19 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index b421b81..f5c9148 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -2639,9 +2639,15 @@ process_initializer(ir_variable *var, ast_declaration 
*decl,
"cannot initialize uniforms");
}
 
-   if (var->type->is_sampler()) {
+   /* From section 4.1.7 of the GLSL 4.40 spec:
+*
+*"Opaque variables [...] are initialized only through the
+* OpenGL API; they cannot be declared with an initializer in a
+* shader."
+*/
+   if (var->type->contains_opaque()) {
   _mesa_glsl_error(& initializer_loc, state,
-  "cannot initialize samplers");
+  "cannot initialize opaque variable");
}
 
if ((var->mode == ir_var_shader_in) && (state->current_function == NULL)) {
@@ -3392,15 +3398,15 @@ ast_declarator_list::hir(exec_list *instructions,
   ", integer and sampler types");
   }
 
-  /* From page 17 (page 23 of the PDF) of the GLSL 1.20 spec:
+  /* From section 4.1.7 of the GLSL 4.40 spec:
*
-   *"[Sampler types] can only be declared as function
-   *parameters or uniform variables (see Section 4.3.5
-   *"Uniform")".
+   *"[Opaque types] can only be declared as function
+   * parameters or uniform-qualified variables."
*/
-  if (var_type->contains_sampler() &&
+  if (var_type->contains_opaque() &&
   !this->type->qualifier.flags.q.uniform) {
- _mesa_glsl_error(&loc, state, "samplers must be declared uniform");
+ _mesa_glsl_error(&loc, state,
+  "opaque variables must be declared uniform");
   }
 
   /* Process the initializer and add its instructions to a temporary
@@ -3594,15 +3600,16 @@ ast_parameter_declarator::hir(exec_list *instructions,
apply_type_qualifier_to_variable(& this->type->qualifier, var, state, & loc,
true);
 
-   /* From page 17 (page 23 of the PDF) of the GLSL 1.20 spec:
+   /* From section 4.1.7 of the GLSL 4.40 spec:
 *
-*"Samplers cannot be treated as l-values; hence cannot be used
-*as out or inout function parameters, nor can they be assigned
-*into."
+*   "Opaque variables cannot be treated as l-values; hence cannot
+*be used as out or inout function parameters, nor can they be
+*assigned into."
 */
if ((var->mode == ir_var_function_inout || var->mode == ir_var_function_out)
-   && type->contains_sampler()) {
-  _mesa_glsl_error(&loc, state, "out and inout parameters cannot contain 
samplers");
+   && type->contains_opaque()) {
+  _mesa_glsl_error(&loc, state, "out and inout parameters cannot "
+   "contain opaque variables");
   type = glsl_type::error_type;
}
 
@@ -3757,15 +3764,15 @@ ast_function::hir(exec_list *instructions,
   "sized", name);
}
 
-   /* From page 17 (page 23 of the PDF) of the GLSL 1.20 spec:
+   /* From section 4.1.7 of the GLSL 4.40 spec:
 *
-*"[Sampler types] can only be declared as function parameters
-*or uniform variables (see Section 4.3.5 "Uniform")".
+*"[Opaque types] can only be declared as function parameters
+* or uniform-qualified variables."
 */
-   if (return_type->contains_sampler()) {
+   if (return_type->contains_opaque()) {
   YYLTYPE loc = this->get_location();
   _mesa_glsl_error(&loc, state,
-   "function `%s' return type can't contain a sampler",
+   "function `%s' return type can't contain an opaque 
type",
name);
}
 
-- 
1.8.3.4

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


[Mesa-dev] [PATCH 17/23] glcpp: Add built-in define for ARB_shader_image_load_store.

2013-11-26 Thread Francisco Jerez
---
 src/glsl/glcpp/glcpp-parse.y | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index 7edc274..69947c5 100644
--- a/src/glsl/glcpp/glcpp-parse.y
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -1260,6 +1260,9 @@ glcpp_parser_create (const struct gl_extensions 
*extensions, int api)
 
  if (extensions->ARB_shader_atomic_counters)
 add_builtin_define(parser, "GL_ARB_shader_atomic_counters", 1);
+
+ if (extensions->ARB_shader_image_load_store)
+add_builtin_define(parser, "GL_ARB_shader_image_load_store", 
1);
   }
}
 
-- 
1.8.3.4

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


[Mesa-dev] [PATCH 20/23] glsl/linker: Count and check image resources.

2013-11-26 Thread Francisco Jerez
---
 src/glsl/link_uniforms.cpp | 13 +++-
 src/glsl/linker.cpp| 50 ++
 2 files changed, 62 insertions(+), 1 deletion(-)

diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index 0a15739..c75a38c 100644
--- a/src/glsl/link_uniforms.cpp
+++ b/src/glsl/link_uniforms.cpp
@@ -240,7 +240,8 @@ class count_uniform_size : public program_resource_visitor {
 public:
count_uniform_size(struct string_to_uint_map *map)
   : num_active_uniforms(0), num_values(0), num_shader_samplers(0),
-   num_shader_uniform_components(0), is_ubo_var(false), map(map)
+num_shader_images(0), num_shader_uniform_components(0),
+is_ubo_var(false), map(map)
{
   /* empty */
}
@@ -248,6 +249,7 @@ public:
void start_shader()
{
   this->num_shader_samplers = 0;
+  this->num_shader_images = 0;
   this->num_shader_uniform_components = 0;
}
 
@@ -277,6 +279,11 @@ public:
unsigned num_shader_samplers;
 
/**
+* Number of images used
+*/
+   unsigned num_shader_images;
+
+   /**
 * Number of uniforms used in the current shader
 */
unsigned num_shader_uniform_components;
@@ -303,6 +310,9 @@ private:
   if (type->contains_sampler()) {
 this->num_shader_samplers +=
type->is_array() ? type->array_size() : 1;
+  } else if (type->contains_image()) {
+ this->num_shader_images += values;
+ this->num_shader_uniform_components += values;
   } else {
 /* Accumulate the total number of uniform slots used by this shader.
  * Note that samplers do not count against this limit because they
@@ -782,6 +792,7 @@ link_assign_uniform_locations(struct gl_shader_program 
*prog)
   }
 
   sh->num_samplers = uniform_size.num_shader_samplers;
+  sh->NumImages = uniform_size.num_shader_images;
   sh->num_uniform_components = uniform_size.num_shader_uniform_components;
 
   sh->num_combined_uniform_components = sh->num_uniform_components;
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index fac186a..86a0cae 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1980,6 +1980,55 @@ check_resources(struct gl_context *ctx, struct 
gl_shader_program *prog)
}
 }
 
+/**
+ * Validate shader image resources.
+ */
+static void
+check_image_resources(struct gl_context *ctx, struct gl_shader_program *prog)
+{
+   STATIC_ASSERT(MESA_SHADER_TYPES == 3);
+   static const char *const shader_names[MESA_SHADER_TYPES] = {
+  "vertex", "geometry", "fragment"
+   };
+   const unsigned max_images[MESA_SHADER_TYPES] = {
+  ctx->Const.VertexProgram.MaxImageUniforms,
+  ctx->Const.GeometryProgram.MaxImageUniforms,
+  ctx->Const.FragmentProgram.MaxImageUniforms
+   };
+   unsigned total_image_units = 0;
+   unsigned fragment_outputs = 0;
+
+   if (!ctx->Extensions.ARB_shader_image_load_store)
+  return;
+
+   for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
+  struct gl_shader *sh = prog->_LinkedShaders[i];
+
+  if (sh) {
+ if (sh->NumImages > max_images[i])
+linker_error(prog, "Too many %s shader image uniforms",
+ shader_names[i]);
+
+ total_image_units += sh->NumImages;
+
+ if (i == MESA_SHADER_FRAGMENT) {
+foreach_list(node, sh->ir) {
+   ir_variable *var = ((ir_instruction *)node)->as_variable();
+   if (var && var->mode == ir_var_shader_out)
+  fragment_outputs += var->type->count_attribute_slots();
+}
+ }
+  }
+   }
+
+   if (total_image_units > ctx->Const.MaxCombinedImageUniforms)
+  linker_error(prog, "Too many combined image uniforms");
+
+   if (total_image_units + fragment_outputs >
+   ctx->Const.MaxCombinedImageUnitsAndFragmentOutputs)
+  linker_error(prog, "Too many combined image uniforms and fragment 
outputs");
+}
+
 void
 link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
 {
@@ -2367,6 +2416,7 @@ link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog)
store_fragdepth_layout(prog);
 
check_resources(ctx, prog);
+   check_image_resources(ctx, prog);
link_check_atomic_counter_resources(ctx, prog);
 
if (!prog->LinkStatus)
-- 
1.8.3.4

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


[Mesa-dev] [PATCH 13/23] glsl/ast: Make sure that image argument qualifiers match the function prototype.

2013-11-26 Thread Francisco Jerez
---
 src/glsl/ir.cpp | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index ae690ea..b8b0979 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -1709,7 +1709,12 @@ ir_function_signature::qualifiers_match(exec_list 
*params)
   if (a->read_only != b->read_only ||
  !modes_match(a->mode, b->mode) ||
  a->interpolation != b->interpolation ||
- a->centroid != b->centroid) {
+ a->centroid != b->centroid ||
+  a->image.read_only != b->image.read_only ||
+  a->image.write_only != b->image.write_only ||
+  a->image.coherent != b->image.coherent ||
+  a->image._volatile != b->image._volatile ||
+  a->image._restrict != b->image._restrict) {
 
 /* parameter a's qualifiers don't match */
 return a->name;
-- 
1.8.3.4

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


[Mesa-dev] [PATCH 18/23] glsl: Add built-in constants for ARB_shader_image_load_store.

2013-11-26 Thread Francisco Jerez
---
 src/glsl/builtin_variables.cpp  | 19 +++
 src/glsl/glsl_parser_extras.cpp |  8 
 src/glsl/glsl_parser_extras.h   |  9 +
 3 files changed, 36 insertions(+)

diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp
index d57324c..47a6b39 100644
--- a/src/glsl/builtin_variables.cpp
+++ b/src/glsl/builtin_variables.cpp
@@ -658,6 +658,25 @@ builtin_variable_generator::generate_constants()
   add_const("gl_MaxTessControlAtomicCounters", 0);
   add_const("gl_MaxTessEvaluationAtomicCounters", 0);
}
+
+   if (state->ARB_shader_image_load_store_enable) {
+  add_const("gl_MaxImageUnits",
+state->Const.MaxImageUnits);
+  add_const("gl_MaxCombinedImageUnitsAndFragmentOutputs",
+state->Const.MaxCombinedImageUnitsAndFragmentOutputs);
+  add_const("gl_MaxImageSamples",
+state->Const.MaxImageSamples);
+  add_const("gl_MaxVertexImageUniforms",
+state->Const.MaxVertexImageUniforms);
+  add_const("gl_MaxTessControlImageUniforms", 0);
+  add_const("gl_MaxTessEvaluationImageUniforms", 0);
+  add_const("gl_MaxGeometryImageUniforms",
+state->Const.MaxGeometryImageUniforms);
+  add_const("gl_MaxFragmentImageUniforms",
+state->Const.MaxFragmentImageUniforms);
+  add_const("gl_MaxCombinedImageUniforms",
+state->Const.MaxCombinedImageUniforms);
+   }
 }
 
 
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 1c82a1d..ad138ac 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -124,6 +124,14 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct 
gl_context *_ctx,
this->Const.MaxCombinedAtomicCounters = 
ctx->Const.MaxCombinedAtomicCounters;
this->Const.MaxAtomicBufferBindings = ctx->Const.MaxAtomicBufferBindings;
 
+   this->Const.MaxImageUnits = ctx->Const.MaxImageUnits;
+   this->Const.MaxCombinedImageUnitsAndFragmentOutputs = 
ctx->Const.MaxCombinedImageUnitsAndFragmentOutputs;
+   this->Const.MaxImageSamples = ctx->Const.MaxImageSamples;
+   this->Const.MaxVertexImageUniforms = 
ctx->Const.VertexProgram.MaxImageUniforms;
+   this->Const.MaxGeometryImageUniforms = 
ctx->Const.GeometryProgram.MaxImageUniforms;
+   this->Const.MaxFragmentImageUniforms = 
ctx->Const.FragmentProgram.MaxImageUniforms;
+   this->Const.MaxCombinedImageUniforms = ctx->Const.MaxCombinedImageUniforms;
+
this->current_function = NULL;
this->toplevel_ir = NULL;
this->found_return = false;
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index ba02166..8e76f44 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -256,6 +256,15 @@ struct _mesa_glsl_parse_state {
   unsigned MaxFragmentAtomicCounters;
   unsigned MaxCombinedAtomicCounters;
   unsigned MaxAtomicBufferBindings;
+
+  /* ARB_shader_image_load_store */
+  unsigned MaxImageUnits;
+  unsigned MaxCombinedImageUnitsAndFragmentOutputs;
+  unsigned MaxImageSamples;
+  unsigned MaxVertexImageUniforms;
+  unsigned MaxGeometryImageUniforms;
+  unsigned MaxFragmentImageUniforms;
+  unsigned MaxCombinedImageUniforms;
} Const;
 
/**
-- 
1.8.3.4

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


[Mesa-dev] [PATCH 12/23] glsl/ast: Verify that function calls don't discard image format qualifiers.

2013-11-26 Thread Francisco Jerez
---
 src/glsl/ast_function.cpp | 58 +++
 1 file changed, 58 insertions(+)

diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp
index 2707522..48003da1 100644
--- a/src/glsl/ast_function.cpp
+++ b/src/glsl/ast_function.cpp
@@ -93,6 +93,57 @@ prototype_string(const glsl_type *return_type, const char 
*name,
return str;
 }
 
+static bool
+verify_image_parameter(YYLTYPE *loc, _mesa_glsl_parse_state *state,
+   const ir_variable *formal, const ir_variable *actual)
+{
+   /**
+* From the ARB_shader_image_load_store specification:
+*
+* "The values of image variables qualified with coherent,
+*  volatile, restrict, readonly, or writeonly may not be passed
+*  to functions whose formal parameters lack such
+*  qualifiers. [...] It is legal to have additional qualifiers
+*  on a formal parameter, but not to have fewer."
+*/
+   if (actual->image.coherent && !formal->image.coherent) {
+  _mesa_glsl_error(loc, state,
+   "function call parameter `%s' drops "
+   "`coherent' qualifier", formal->name);
+  return false;
+   }
+
+   if (actual->image._volatile && !formal->image._volatile) {
+  _mesa_glsl_error(loc, state,
+   "function call parameter `%s' drops "
+   "`volatile' qualifier", formal->name);
+  return false;
+   }
+
+   if (actual->image._restrict && !formal->image._restrict) {
+  _mesa_glsl_error(loc, state,
+   "function call parameter `%s' drops "
+   "`restrict' qualifier", formal->name);
+  return false;
+   }
+
+   if (actual->image.read_only && !formal->image.read_only) {
+  _mesa_glsl_error(loc, state,
+   "function call parameter `%s' drops "
+   "`readonly' qualifier", formal->name);
+  return false;
+   }
+
+   if (actual->image.write_only && !formal->image.write_only) {
+  _mesa_glsl_error(loc, state,
+   "function call parameter `%s' drops "
+   "`writeonly' qualifier", formal->name);
+  return false;
+   }
+
+   return true;
+}
+
 /**
  * Verify that 'out' and 'inout' actual parameters are lvalues.  Also, verify
  * that 'const_in' formal parameters (an extension in our IR) correspond to
@@ -180,6 +231,13 @@ verify_parameter_modes(_mesa_glsl_parse_state *state,
 }
   }
 
+  if (formal->type->is_image() &&
+  actual->variable_referenced()) {
+ if (!verify_image_parameter(&loc, state, formal,
+ actual->variable_referenced()))
+return false;
+  }
+
   actual_ir_node  = actual_ir_node->next;
   actual_ast_node = actual_ast_node->next;
}
-- 
1.8.3.4

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


[Mesa-dev] [PATCH 04/23] glsl: Add image memory and layout qualifiers to ir_variable.

2013-11-26 Thread Francisco Jerez
---
 src/glsl/ir.cpp   |  2 +-
 src/glsl/ir.h | 14 ++
 src/glsl/ir_clone.cpp |  1 +
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index 297..ae690ea 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -1587,7 +1587,7 @@ ir_variable::ir_variable(const struct glsl_type *type, 
const char *name,
: max_array_access(0), max_ifc_array_access(NULL),
  read_only(false), centroid(false), invariant(false),
  how_declared(ir_var_declared_normally), mode(mode),
- interpolation(INTERP_QUALIFIER_NONE), atomic()
+ interpolation(INTERP_QUALIFIER_NONE), atomic(), image()
 {
this->ir_type = ir_type_variable;
this->type = type;
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index 4f775da..0bf8a12 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -694,6 +694,20 @@ public:
} atomic;
 
/**
+* ARB_shader_image_load_store qualifiers.
+*/
+   struct {
+  bool read_only;
+  bool write_only;
+  bool coherent;
+  bool _volatile;
+  bool _restrict;
+
+  /** Image internal format if specified explicitly, otherwise GL_NONE. */
+  GLenum format;
+   } image;
+
+   /**
 * Built-in state that backs this uniform
 *
 * Once set at variable creation, \c state_slots must remain invariant.
diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp
index ed26aae..afa8075 100644
--- a/src/glsl/ir_clone.cpp
+++ b/src/glsl/ir_clone.cpp
@@ -59,6 +59,7 @@ ir_variable::clone(void *mem_ctx, struct hash_table *ht) const
var->binding = this->binding;
var->atomic.buffer_index = this->atomic.buffer_index;
var->atomic.offset = this->atomic.offset;
+   var->image = this->image;
var->warn_extension = this->warn_extension;
var->origin_upper_left = this->origin_upper_left;
var->pixel_center_integer = this->pixel_center_integer;
-- 
1.8.3.4

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


[Mesa-dev] [PATCH 07/23] glsl/lexer: Add new tokens for ARB_shader_image_load_store.

2013-11-26 Thread Francisco Jerez
---
 src/glsl/glsl_lexer.ll  | 75 +
 src/glsl/glsl_parser.yy | 20 +++--
 2 files changed, 56 insertions(+), 39 deletions(-)

diff --git a/src/glsl/glsl_lexer.ll b/src/glsl/glsl_lexer.ll
index 822d70d..8c76c2d 100644
--- a/src/glsl/glsl_lexer.ll
+++ b/src/glsl/glsl_lexer.ll
@@ -337,6 +337,51 @@ samplerExternalOES {
 return IDENTIFIER;
}
 
+   /* keywords available with ARB_shader_image_load_store */
+image1D KEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, IMAGE1D);
+image2D KEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, IMAGE2D);
+image3D KEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, IMAGE3D);
+image2DRect KEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, IMAGE2DRECT);
+imageCube   KEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, IMAGECUBE);
+imageBuffer KEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, IMAGEBUFFER);
+image1DArrayKEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, IMAGE1DARRAY);
+image2DArrayKEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, IMAGE2DARRAY);
+imageCubeArray  KEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, IMAGECUBEARRAY);
+image2DMS   KEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, IMAGE2DMS);
+image2DMSArray  KEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, IMAGE2DMSARRAY);
+iimage1DKEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, IIMAGE1D);
+iimage2DKEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, IIMAGE2D);
+iimage3DKEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, IIMAGE3D);
+iimage2DRectKEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, IIMAGE2DRECT);
+iimageCube  KEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, IIMAGECUBE);
+iimageBufferKEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, IIMAGEBUFFER);
+iimage1DArray   KEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, IIMAGE1DARRAY);
+iimage2DArray   KEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, IIMAGE2DARRAY);
+iimageCubeArray KEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, IIMAGECUBEARRAY);
+iimage2DMS  KEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, IIMAGE2DMS);
+iimage2DMSArray KEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, IIMAGE2DMSARRAY);
+uimage1DKEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, UIMAGE1D);
+uimage2DKEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, UIMAGE2D);
+uimage3DKEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, UIMAGE3D);
+uimage2DRectKEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, UIMAGE2DRECT);
+uimageCube  KEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, UIMAGECUBE);
+uimageBufferKEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, UIMAGEBUFFER);
+uimage1DArray   KEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, UIMAGE1DARRAY);
+uimage2DArray   KEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, UIMAGE2DARRAY);
+uimageCubeArray KEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, UIMAGECUBEARRAY);
+uimage2DMS  KEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, UIMAGE2DMS);
+uimage2DMSArray KEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, UIMAGE2DMSARRAY);
+image1DShadow   KEYWORD(130, 300, 0, 0, IMAGE1DSHADOW);
+image2DShadow   KEYWORD(130, 300, 0, 0, IMAGE2DSHADOW);
+image1DArrayShadow  KEYWORD(130, 300, 0, 0, IMAGE1DARRAYSHADOW);
+image2DArrayShadow  KEYWORD(130, 300, 0, 0, IMAGE2DARRAYSHADOW);
+
+coherent   KEYWORD_WITH_ALT(420, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, COHERENT);
+volatile   KEYWORD_WITH_ALT(110, 100, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, VOLATILE);
+restrict   KEYWORD_WITH_ALT(420, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, RESTRICT);
+readonly   KEYWORD_WITH_ALT(420, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, READONLY);
+writeonly  KEYWORD_WITH_ALT(420, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_en

[Mesa-dev] [PATCH 10/23] glsl/parser: Handle image built-in types.

2013-11-26 Thread Francisco Jerez
---
 src/glsl/glsl_parser.yy | 33 +
 1 file changed, 33 insertions(+)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index e207510..b5a1157 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -1805,6 +1805,39 @@ basic_type_specifier_nonarray:
| SAMPLER2DMSARRAY   { $$ = "sampler2DMSArray"; }
| ISAMPLER2DMSARRAY  { $$ = "isampler2DMSArray"; }
| USAMPLER2DMSARRAY  { $$ = "usampler2DMSArray"; }
+   | IMAGE1D{ $$ = "image1D"; }
+   | IMAGE2D{ $$ = "image2D"; }
+   | IMAGE3D{ $$ = "image3D"; }
+   | IMAGE2DRECT{ $$ = "image2DRect"; }
+   | IMAGECUBE  { $$ = "imageCube"; }
+   | IMAGEBUFFER{ $$ = "imageBuffer"; }
+   | IMAGE1DARRAY   { $$ = "image1DArray"; }
+   | IMAGE2DARRAY   { $$ = "image2DArray"; }
+   | IMAGECUBEARRAY { $$ = "imageCubeArray"; }
+   | IMAGE2DMS  { $$ = "image2DMS"; }
+   | IMAGE2DMSARRAY { $$ = "image2DMSArray"; }
+   | IIMAGE1D   { $$ = "iimage1D"; }
+   | IIMAGE2D   { $$ = "iimage2D"; }
+   | IIMAGE3D   { $$ = "iimage3D"; }
+   | IIMAGE2DRECT   { $$ = "iimage2DRect"; }
+   | IIMAGECUBE { $$ = "iimageCube"; }
+   | IIMAGEBUFFER   { $$ = "iimageBuffer"; }
+   | IIMAGE1DARRAY  { $$ = "iimage1DArray"; }
+   | IIMAGE2DARRAY  { $$ = "iimage2DArray"; }
+   | IIMAGECUBEARRAY{ $$ = "iimageCubeArray"; }
+   | IIMAGE2DMS { $$ = "iimage2DMS"; }
+   | IIMAGE2DMSARRAY{ $$ = "iimage2DMSArray"; }
+   | UIMAGE1D   { $$ = "uimage1D"; }
+   | UIMAGE2D   { $$ = "uimage2D"; }
+   | UIMAGE3D   { $$ = "uimage3D"; }
+   | UIMAGE2DRECT   { $$ = "uimage2DRect"; }
+   | UIMAGECUBE { $$ = "uimageCube"; }
+   | UIMAGEBUFFER   { $$ = "uimageBuffer"; }
+   | UIMAGE1DARRAY  { $$ = "uimage1DArray"; }
+   | UIMAGE2DARRAY  { $$ = "uimage2DArray"; }
+   | UIMAGECUBEARRAY{ $$ = "uimageCubeArray"; }
+   | UIMAGE2DMS { $$ = "uimage2DMS"; }
+   | UIMAGE2DMSARRAY{ $$ = "uimage2DMSArray"; }
| ATOMIC_UINT{ $$ = "atomic_uint"; }
;
 
-- 
1.8.3.4

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


[Mesa-dev] [PATCH 11/23] glsl/ast: Validate and apply memory qualifiers to image variables.

2013-11-26 Thread Francisco Jerez
---
 src/glsl/ast_to_hir.cpp | 51 +
 1 file changed, 51 insertions(+)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index e7c4ff4..1d13a2c 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -2154,6 +2154,54 @@ validate_explicit_location(const struct 
ast_type_qualifier *qual,
 }
 
 static void
+apply_image_qualifier_to_variable(const struct ast_type_qualifier *qual,
+  ir_variable *var,
+  struct _mesa_glsl_parse_state *state,
+  YYLTYPE *loc)
+{
+   const glsl_type *base_type =
+  (var->type->is_array() ? var->type->element_type() : var->type);
+
+   if (base_type->is_image()) {
+  if (var->mode != ir_var_uniform &&
+  var->mode != ir_var_function_in) {
+ _mesa_glsl_error(loc, state, "image variables may only be declared as 
"
+  "function parameters or uniform-qualified "
+  "global variables");
+  }
+
+  var->image.read_only |= qual->flags.q.read_only;
+  var->image.write_only |= qual->flags.q.write_only;
+  var->image.coherent |= qual->flags.q.coherent;
+  var->image._volatile |= qual->flags.q._volatile;
+  var->image._restrict |= qual->flags.q._restrict;
+  var->read_only = true;
+
+  if (qual->flags.q.explicit_image_format) {
+ if (var->mode == ir_var_function_in) {
+_mesa_glsl_error(loc, state, "format qualifiers cannot be "
+ "used on image function parameters");
+ }
+
+ if (qual->image_base_type != base_type->fields.image.type) {
+_mesa_glsl_error(loc, state, "format qualifier doesn't match the "
+ "base data type of the image");
+ }
+
+ var->image.format = qual->image_format;
+  } else {
+ if (var->mode == ir_var_uniform && !qual->flags.q.write_only) {
+_mesa_glsl_error(loc, state, "uniforms not qualified with "
+ "`writeonly' must have a format layout "
+ "qualifier");
+ }
+
+ var->image.format = GL_NONE;
+  }
+   }
+}
+
+static void
 apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
 ir_variable *var,
 struct _mesa_glsl_parse_state *state,
@@ -2429,6 +2477,9 @@ apply_type_qualifier_to_variable(const struct 
ast_type_qualifier *qual,
if (qual->flags.q.row_major || qual->flags.q.column_major) {
   validate_matrix_layout_for_type(state, loc, var->type, var);
}
+
+   if (var->type->contains_image())
+  apply_image_qualifier_to_variable(qual, var, state, loc);
 }
 
 /**
-- 
1.8.3.4

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


[Mesa-dev] [PATCH 01/23] glsl: Add ARB_shader_image_load_store extension enables.

2013-11-26 Thread Francisco Jerez
---
 src/glsl/glsl_parser_extras.cpp | 1 +
 src/glsl/glsl_parser_extras.h   | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index f401f03..3719f5c 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -541,6 +541,7 @@ static const _mesa_glsl_extension 
_mesa_glsl_supported_extensions[] = {
EXT(ARB_texture_gather, true,  false, ARB_texture_gather),
EXT(ARB_shader_atomic_counters, true,  false, 
ARB_shader_atomic_counters),
EXT(ARB_sample_shading, true,  false, ARB_sample_shading),
+   EXT(ARB_shader_image_load_store,true,  false, 
ARB_shader_image_load_store),
 };
 
 #undef EXT
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index d232bb3..d7cff89 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -356,6 +356,8 @@ struct _mesa_glsl_parse_state {
bool EXT_shader_integer_mix_warn;
bool ARB_shader_atomic_counters_enable;
bool ARB_shader_atomic_counters_warn;
+   bool ARB_shader_image_load_store_enable;
+   bool ARB_shader_image_load_store_warn;
/*@}*/
 
/** Extensions supported by the OpenGL implementation. */
-- 
1.8.3.4

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


[Mesa-dev] [PATCH 09/23] glsl/parser: Handle image memory qualifiers.

2013-11-26 Thread Francisco Jerez
---
 src/glsl/glsl_parser.yy | 83 +
 1 file changed, 83 insertions(+)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index e436b16..e207510 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -1298,6 +1298,63 @@ layout_qualifier_id:
   /* Layout qualifiers for ARB_shader_image_load_store. */
   if (state->ARB_shader_image_load_store_enable ||
   state->is_version(420, 0)) {
+ if (!$$.flags.i) {
+struct {
+   const char *name;
+   GLenum format;
+   glsl_base_type base_type;
+} map[] = {
+   { "rgba32f", GL_RGBA32F, GLSL_TYPE_FLOAT },
+   { "rgba16f", GL_RGBA16F, GLSL_TYPE_FLOAT },
+   { "rg32f", GL_RG32F, GLSL_TYPE_FLOAT },
+   { "rg16f", GL_RG16F, GLSL_TYPE_FLOAT },
+   { "r11f_g11f_b10f", GL_R11F_G11F_B10F, GLSL_TYPE_FLOAT },
+   { "r32f", GL_R32F, GLSL_TYPE_FLOAT },
+   { "r16f", GL_R16F, GLSL_TYPE_FLOAT },
+   { "rgba32ui", GL_RGBA32UI, GLSL_TYPE_UINT },
+   { "rgba16ui", GL_RGBA16UI, GLSL_TYPE_UINT },
+   { "rgb10_a2ui", GL_RGB10_A2UI, GLSL_TYPE_UINT },
+   { "rgba8ui", GL_RGBA8UI, GLSL_TYPE_UINT },
+   { "rg32ui", GL_RG32UI, GLSL_TYPE_UINT },
+   { "rg16ui", GL_RG16UI, GLSL_TYPE_UINT },
+   { "rg8ui", GL_RG8UI, GLSL_TYPE_UINT },
+   { "r32ui", GL_R32UI, GLSL_TYPE_UINT },
+   { "r16ui", GL_R16UI, GLSL_TYPE_UINT },
+   { "r8ui", GL_R8UI, GLSL_TYPE_UINT },
+   { "rgba32i", GL_RGBA32I, GLSL_TYPE_INT },
+   { "rgba16i", GL_RGBA16I, GLSL_TYPE_INT },
+   { "rgba8i", GL_RGBA8I, GLSL_TYPE_INT },
+   { "rg32i", GL_RG32I, GLSL_TYPE_INT },
+   { "rg16i", GL_RG16I, GLSL_TYPE_INT },
+   { "rg8i", GL_RG8I, GLSL_TYPE_INT },
+   { "r32i", GL_R32I, GLSL_TYPE_INT },
+   { "r16i", GL_R16I, GLSL_TYPE_INT },
+   { "r8i", GL_R8I, GLSL_TYPE_INT },
+   { "rgba16", GL_RGBA16, GLSL_TYPE_FLOAT },
+   { "rgb10_a2", GL_RGB10_A2, GLSL_TYPE_FLOAT },
+   { "rgba8", GL_RGBA8, GLSL_TYPE_FLOAT },
+   { "rg16", GL_RG16, GLSL_TYPE_FLOAT },
+   { "rg8", GL_RG8, GLSL_TYPE_FLOAT },
+   { "r16", GL_R16, GLSL_TYPE_FLOAT },
+   { "r8", GL_R8, GLSL_TYPE_FLOAT },
+   { "rgba16_snorm", GL_RGBA16_SNORM, GLSL_TYPE_FLOAT },
+   { "rgba8_snorm", GL_RGBA8_SNORM, GLSL_TYPE_FLOAT },
+   { "rg16_snorm", GL_RG16_SNORM, GLSL_TYPE_FLOAT },
+   { "rg8_snorm", GL_RG8_SNORM, GLSL_TYPE_FLOAT },
+   { "r16_snorm", GL_R16_SNORM, GLSL_TYPE_FLOAT },
+   { "r8_snorm", GL_R8_SNORM, GLSL_TYPE_FLOAT }
+};
+
+for (unsigned i = 0; i < Elements(map); i++) {
+   if (match_layout_qualifier($1, map[i].name, state) == 0) {
+  $$.flags.q.explicit_image_format = 1;
+  $$.image_format = map[i].format;
+  $$.image_base_type = map[i].base_type;
+  break;
+   }
+}
+ }
+
  if (!$$.flags.i &&
  match_layout_qualifier($1, "early_fragment_tests", state) == 0) {
 $$.flags.q.early_fragment_tests = 1;
@@ -1615,6 +1672,32 @@ storage_qualifier:
   memset(& $$, 0, sizeof($$));
   $$.flags.q.uniform = 1;
}
+   | COHERENT
+   {
+  memset(& $$, 0, sizeof($$));
+  $$.flags.q.coherent = 1;
+   }
+   | VOLATILE
+   {
+  memset(& $$, 0, sizeof($$));
+  $$.flags.q._volatile = 1;
+   }
+   | RESTRICT
+   {
+  STATIC_ASSERT(sizeof($$.flags.q) <= sizeof($$.flags.i));
+  memset(& $$, 0, sizeof($$));
+  $$.flags.q._restrict = 1;
+   }
+   | READONLY
+   {
+  memset(& $$, 0, sizeof($$));
+  $$.flags.q.read_only = 1;
+   }
+   | WRITEONLY
+   {
+  memset(& $$, 0, sizeof($$));
+  $$.flags.q.write_only = 1;
+   }
;
 
 type_specifier:
-- 
1.8.3.4

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