[Mesa-dev] [PATCH v3] radeon: Use upload manager for buffer downloads

2014-03-05 Thread Niels Ole Salscheider
Using DMA for reads is much faster.

Signed-off-by: Niels Ole Salscheider 
---
 src/gallium/drivers/radeon/r600_buffer_common.c | 74 +++--
 1 file changed, 56 insertions(+), 18 deletions(-)

diff --git a/src/gallium/drivers/radeon/r600_buffer_common.c 
b/src/gallium/drivers/radeon/r600_buffer_common.c
index 340ebb2..90ca8cb 100644
--- a/src/gallium/drivers/radeon/r600_buffer_common.c
+++ b/src/gallium/drivers/radeon/r600_buffer_common.c
@@ -260,6 +260,42 @@ static void *r600_buffer_transfer_map(struct pipe_context 
*ctx,
/* At this point, the buffer is always idle (we checked it 
above). */
usage |= PIPE_TRANSFER_UNSYNCHRONIZED;
}
+   /* Using DMA for larger reads is much faster */
+   else if ((usage & PIPE_TRANSFER_READ) &&
+!(usage & PIPE_TRANSFER_WRITE) &&
+(rbuffer->domains == RADEON_DOMAIN_VRAM)) {
+   unsigned offset;
+   struct r600_resource *staging = NULL;
+
+   u_upload_alloc(rctx->uploader, 0,
+  box->width + (box->x % 
R600_MAP_BUFFER_ALIGNMENT),
+  &offset, (struct pipe_resource**)&staging, 
(void**)&data);
+
+   if (staging) {
+   data += box->x % R600_MAP_BUFFER_ALIGNMENT;
+
+   /* Copy the staging buffer into the original one. */
+   if (rctx->dma_copy(ctx, (struct pipe_resource*)staging, 
0,
+box->x % 
R600_MAP_BUFFER_ALIGNMENT,
+0, 0, resource, level, box)) {
+   rctx->rings.gfx.flush(rctx, 0);
+   if (rctx->rings.dma.cs)
+   rctx->rings.dma.flush(rctx, 0);
+
+   /* Wait for any offloaded CS flush to complete
+* to avoid busy-waiting in the winsys. */
+   rctx->ws->cs_sync_flush(rctx->rings.gfx.cs);
+   if (rctx->rings.dma.cs)
+   
rctx->ws->cs_sync_flush(rctx->rings.dma.cs);
+
+   rctx->ws->buffer_wait(staging->buf, 
RADEON_USAGE_WRITE);
+   return r600_buffer_get_transfer(ctx, resource, 
level, usage, box,
+   ptransfer, 
data, staging, offset);
+   } else {
+   pipe_resource_reference((struct 
pipe_resource**)&staging, NULL);
+   }
+   }
+   }
 
data = r600_buffer_map_sync_with_rings(rctx, rbuffer, usage);
if (!data) {
@@ -279,24 +315,26 @@ static void r600_buffer_transfer_unmap(struct 
pipe_context *ctx,
struct r600_resource *rbuffer = r600_resource(transfer->resource);
 
if (rtransfer->staging) {
-   struct pipe_resource *dst, *src;
-   unsigned soffset, doffset, size;
-   struct pipe_box box;
-
-   dst = transfer->resource;
-   src = &rtransfer->staging->b.b;
-   size = transfer->box.width;
-   doffset = transfer->box.x;
-   soffset = rtransfer->offset + transfer->box.x % 
R600_MAP_BUFFER_ALIGNMENT;
-
-   u_box_1d(soffset, size, &box);
-
-   /* Copy the staging buffer into the original one. */
-   if (!(size % 4) && !(doffset % 4) && !(soffset % 4) &&
-   rctx->dma_copy(ctx, dst, 0, doffset, 0, 0, src, 0, &box)) {
-   /* DONE. */
-   } else {
-   ctx->resource_copy_region(ctx, dst, 0, doffset, 0, 0, 
src, 0, &box);
+   if (rtransfer->transfer.usage & PIPE_TRANSFER_WRITE) {
+   struct pipe_resource *dst, *src;
+   unsigned soffset, doffset, size;
+   struct pipe_box box;
+
+   dst = transfer->resource;
+   src = &rtransfer->staging->b.b;
+   size = transfer->box.width;
+   doffset = transfer->box.x;
+   soffset = rtransfer->offset + transfer->box.x % 
R600_MAP_BUFFER_ALIGNMENT;
+
+   u_box_1d(soffset, size, &box);
+
+   /* Copy the staging buffer into the original one. */
+   if (!(size % 4) && !(doffset % 4) && !(soffset % 4) &&
+   rctx->dma_copy(ctx, dst, 0, doffset, 0, 0, src, 0, 
&box)) {
+   /* DONE. */
+   } else {
+   ctx->resource_copy_region(ctx, dst, 0, doffset, 
0, 0, src, 0, &box);
+   }
}
pipe_resource_reference((struct 
pipe_resource**)&rtransfer->staging, NULL);
}
--

Re: [Mesa-dev] [PATCH v2] radeon: Use upload manager for buffer downloads

2014-03-05 Thread Niels Ole Salscheider
On Tuesday 04 March 2014, 23:43:01, Marek Olšák wrote:
> You check for streamout and CP DMA support, but you don't use
> resource_copy_region if DMA is not supported. The CP DMA and
> streamout-based buffer copying is only used by resource_copy_region.

Oh, right. I initially used resource_copy_region as a fallback and forgot to 
remove these checks. I have sent an updated patch to the list.

> The last parameter of buffer_wait should be RADEON_USAGE_WRITE (you're
> waiting for the last write to the staging buffer), but that parameter
> is not used by the winsys yet.
> 
> Other than those two, the patch looks good.
> 
> CP DMA != async DMA (dma_copy). CP DMA is actually a feature of the
> graphics ring.
> 
> Marek
> 
> On Tue, Mar 4, 2014 at 6:23 PM, Niels Ole Salscheider
> 
>  wrote:
> > Using DMA for reads is much faster.
> > 
> > Signed-off-by: Niels Ole Salscheider 
> > ---
> > 
> >  src/gallium/drivers/radeon/r600_buffer_common.c | 78
> >  +++-- 1 file changed, 60 insertions(+), 18
> >  deletions(-)
> > 
> > diff --git a/src/gallium/drivers/radeon/r600_buffer_common.c
> > b/src/gallium/drivers/radeon/r600_buffer_common.c index 340ebb2..ed3a08c
> > 100644
> > --- a/src/gallium/drivers/radeon/r600_buffer_common.c
> > +++ b/src/gallium/drivers/radeon/r600_buffer_common.c
> > @@ -260,6 +260,46 @@ static void *r600_buffer_transfer_map(struct
> > pipe_context *ctx,> 
> > /* At this point, the buffer is always idle (we checked it
> > above). */
> > usage |= PIPE_TRANSFER_UNSYNCHRONIZED;
> > 
> > }
> > 
> > +   /* Using DMA for larger reads is much faster */
> > +   else if ((usage & PIPE_TRANSFER_READ) &&
> > +!(usage & PIPE_TRANSFER_WRITE) &&
> > +(rbuffer->domains == RADEON_DOMAIN_VRAM) &&
> > +(rscreen->has_cp_dma ||
> > + (rscreen->has_streamout &&
> > +  /* The buffer range must be aligned to 4 with
> > streamout. */ +  box->x % 4 == 0 && box->width % 4 ==
> > 0))) {
> > +   unsigned offset;
> > +   struct r600_resource *staging = NULL;
> > +
> > +   u_upload_alloc(rctx->uploader, 0,
> > +  box->width + (box->x %
> > R600_MAP_BUFFER_ALIGNMENT), +  &offset,
> > (struct pipe_resource**)&staging, (void**)&data); +
> > +   if (staging) {
> > +   data += box->x % R600_MAP_BUFFER_ALIGNMENT;
> > +
> > +   /* Copy the staging buffer into the original one.
> > */ +   if (rctx->dma_copy(ctx, (struct
> > pipe_resource*)staging, 0, + 
> >   box->x % R600_MAP_BUFFER_ALIGNMENT, +  
> >  0, 0, resource, level, box)) { +
> >   rctx->rings.gfx.flush(rctx, 0);
> > +   if (rctx->rings.dma.cs)
> > +   rctx->rings.dma.flush(rctx, 0);
> > +
> > +   /* Wait for any offloaded CS flush to
> > complete +* to avoid busy-waiting in the
> > winsys. */ +  
> > rctx->ws->cs_sync_flush(rctx->rings.gfx.cs); +   
> >if (rctx->rings.dma.cs)
> > +  
> > rctx->ws->cs_sync_flush(rctx->rings.dma.cs); +
> > +   rctx->ws->buffer_wait(staging->buf,
> > RADEON_USAGE_READ); +   return
> > r600_buffer_get_transfer(ctx, resource, level, usage, box, + 
> >  ptransfer, data,
> > staging, offset); +   } else {
> > +   pipe_resource_reference((struct
> > pipe_resource**)&staging, NULL); +   }
> > +   }
> > +   }
> > 
> > data = r600_buffer_map_sync_with_rings(rctx, rbuffer, usage);
> > if (!data) {
> > 
> > @@ -279,24 +319,26 @@ static void r600_buffer_transfer_unmap(struct
> > pipe_context *ctx,> 
> > struct r600_resource *rbuffer = r600_resource(transfer->resource);
> > 
> > if (rtransfer->staging) {
> > 
> > -   struct pipe_resource *dst, *src;
> > -   unsigned soffset, doffset, size;
> > -   struct pipe_box box;
> > -
> > -   dst = transfer->resource;
> > -   src = &rtransfer->staging->b.b;
> > -   size = transfer->box.width;
> > -   doffset = transfer->box.x;
> > -   soffset = rtransfer->offset + transfer->box.x %
> > R600_MAP_BUFFER_ALIGNMENT; -
> > -   u_box_1d(soffset, size, &box);
> > -
> > -   /* Copy the staging buffer into the original one. */
> > -   if (!(size % 4) && !(doffset % 4) && !(soffset % 4) &&

Re: [Mesa-dev] [PATCH] gallium/tgsi: correct typo propagated from NV_vertex_program1_1

2014-03-05 Thread Erik Faye-Lund
On Thu, Feb 6, 2014 at 5:09 PM, Erik Faye-Lund  wrote:
> In the specification text of NV_vertex_program1_1, the upper
> limit of the RCC instruction is written as 1.884467e+19 in
> scientific notation, but as 0x5F80 in binary. But the binary
> version translates to 1.84467e+19 rather than 1.884467e+19 in
> scientific notation.
>
> Since the lower-limit equals 2^-64 and the binary version equals
> 2^+64, let's assume the value in scientific notation is a typo
> and implement this using the value from the binary version
> instead.
>
> Signed-off-by: Erik Faye-Lund 
> ---
>
> I've also e-mailed NVIDIA's contact as listed in the specification,
> but I haven't gotten any reply yet.

I just thought I'd follow up now that I got a reply: my suspicion was
indeed right, and they'll push out an updated spec at some point
soon-ish. So yeah, this was the right thing to do.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 02/20] automake: silence folder creation

2014-03-05 Thread Erik Faye-Lund
On Tue, Mar 4, 2014 at 10:12 PM, Emil Velikov  wrote:
> There is little gain in printing whenever a folder is created.
>
> Signed-off-by: Emil Velikov 
> ---
>  src/gallium/auxiliary/Makefile.am | 8 
>  src/glsl/Makefile.am  | 4 ++--
>  src/mesa/Makefile.am  | 4 ++--
>  src/mesa/drivers/dri/Makefile.am  | 2 +-
>  4 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/src/gallium/auxiliary/Makefile.am 
> b/src/gallium/auxiliary/Makefile.am
> index 2d2d8d4..afeeef9 100644
> --- a/src/gallium/auxiliary/Makefile.am
> +++ b/src/gallium/auxiliary/Makefile.am
> @@ -32,17 +32,17 @@ libgallium_la_SOURCES += \
>  endif
>
>  indices/u_indices_gen.c: $(srcdir)/indices/u_indices_gen.py
> -   $(MKDIR_P) indices
> +   @$(MKDIR_P) indices
> $(AM_V_GEN) $(PYTHON2) $< > $@

I tend to prefer $(AM_V_at) in cases like this, because it makes it
show up again in verbose builds.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 04/20] automake: make install-lib-links less chatty

2014-03-05 Thread Erik Faye-Lund
On Tue, Mar 4, 2014 at 10:12 PM, Emil Velikov  wrote:
> There is little point in echoing everything that the script does
> to stdout. Wrap it in AM_V_GEN so that a reasonable message is
> printed as a indication of it's invocation.
>
> Signed-off-by: Emil Velikov 
> ---
>  install-lib-links.mk | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/install-lib-links.mk b/install-lib-links.mk
> index 73d9e14..9dd4c30 100644
> --- a/install-lib-links.mk
> +++ b/install-lib-links.mk
> @@ -4,7 +4,7 @@
>  all-local : .libs/install-mesa-links
>
>  .libs/install-mesa-links : $(lib_LTLIBRARIES)
> -   $(MKDIR_P) $(top_builddir)/$(LIB_DIR)
> +   $(AM_V_GEN)$(MKDIR_P) $(top_builddir)/$(LIB_DIR);   \

GEN for a directory, really? Why not $(AM_V_at)?
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 00/12] Last of the API changes for ARB_separate_shader_objects

2014-03-05 Thread Ian Romanick
This is the last set of core API changes for
ARB_separate_shader_objects.  The next set of patches will just be in
the linker and compiler.

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


[Mesa-dev] [PATCH 01/12] glsl: Rewrite unrolled link_invalidate_variable_locations calls as a loop

2014-03-05 Thread Ian Romanick
From: Ian Romanick 

Signed-off-by: Ian Romanick 
---
 src/glsl/linker.cpp | 15 ---
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index f6b2661..3bf2789 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -2303,17 +2303,10 @@ link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog)
}
 
/* Mark all generic shader inputs and outputs as unpaired. */
-   if (prog->_LinkedShaders[MESA_SHADER_VERTEX] != NULL) {
-  link_invalidate_variable_locations(
-prog->_LinkedShaders[MESA_SHADER_VERTEX]->ir);
-   }
-   if (prog->_LinkedShaders[MESA_SHADER_GEOMETRY] != NULL) {
-  link_invalidate_variable_locations(
-prog->_LinkedShaders[MESA_SHADER_GEOMETRY]->ir);
-   }
-   if (prog->_LinkedShaders[MESA_SHADER_FRAGMENT] != NULL) {
-  link_invalidate_variable_locations(
-prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->ir);
+   for (unsigned i = MESA_SHADER_VERTEX; i <= MESA_SHADER_FRAGMENT; i++) {
+  if (prog->_LinkedShaders[i] != NULL) {
+ link_invalidate_variable_locations(prog->_LinkedShaders[i]->ir);
+  }
}
 
/* FINISHME: The value of the max_attribute_index parameter is
-- 
1.8.1.4

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


[Mesa-dev] [PATCH 02/12] glsl: Fix typo

2014-03-05 Thread Ian Romanick
From: Ian Romanick 

Remove extra "any" and re-word-wrap the comment.

Signed-off-by: Ian Romanick 
---
 src/glsl/lower_packed_varyings.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/glsl/lower_packed_varyings.cpp 
b/src/glsl/lower_packed_varyings.cpp
index c23d180..8c1b885 100644
--- a/src/glsl/lower_packed_varyings.cpp
+++ b/src/glsl/lower_packed_varyings.cpp
@@ -199,8 +199,8 @@ private:
 
/**
 * Number of generic varying slots which are used by this shader.  This is
-* used to allocate temporary intermediate data structures.  If any any
-* varying used by this shader has a location greater than or equal to
+* used to allocate temporary intermediate data structures.  If any varying
+* used by this shader has a location greater than or equal to
 * location_base + locations_used, an assertion will fire.
 */
const unsigned locations_used;
-- 
1.8.1.4

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


[Mesa-dev] [PATCH 06/12] mesa/sso: Add gl_pipeline_object parameter to _mesa_use_shader_program

2014-03-05 Thread Ian Romanick
From: Gregory Hainaut 

Extend use_shader_program to support a different target. Allow to reuse the
function to update the pipeline state. Note I bypass the flush when target
isn't current. Maybe it would be better to create a new UseProgramStages
driver function

This was originally included in another patch, but it was split out by
Ian Romanick.

Reviewed-by: Ian Romanick 
---
 src/mesa/drivers/common/meta.c |  9 ++---
 src/mesa/main/shaderapi.c  | 27 ---
 src/mesa/main/shaderapi.h  |  3 ++-
 3 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index a274895..e98046b 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -895,16 +895,19 @@ _mesa_meta_end(struct gl_context *ctx)
 
   if (ctx->Extensions.ARB_vertex_shader) {
 _mesa_use_shader_program(ctx, GL_VERTEX_SHADER,
-  save->Shader[MESA_SHADER_VERTEX]);
+  save->Shader[MESA_SHADER_VERTEX],
+  ctx->_Shader);
   }
 
   if (_mesa_has_geometry_shaders(ctx))
 _mesa_use_shader_program(ctx, GL_GEOMETRY_SHADER_ARB,
- save->Shader[MESA_SHADER_GEOMETRY]);
+  save->Shader[MESA_SHADER_GEOMETRY],
+  ctx->_Shader);
 
   if (ctx->Extensions.ARB_fragment_shader)
 _mesa_use_shader_program(ctx, GL_FRAGMENT_SHADER,
- save->Shader[MESA_SHADER_FRAGMENT]);
+  save->Shader[MESA_SHADER_FRAGMENT],
+  ctx->_Shader);
 
   _mesa_reference_shader_program(ctx, &ctx->_Shader->ActiveProgram,
 save->ActiveShader);
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 2a39df5..392f66f 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -989,17 +989,21 @@ _mesa_active_program(struct gl_context *ctx, struct 
gl_shader_program *shProg,
  */
 static void
 use_shader_program(struct gl_context *ctx, GLenum type,
-  struct gl_shader_program *shProg)
+   struct gl_shader_program *shProg,
+   struct gl_pipeline_object *shTarget)
 {
struct gl_shader_program **target;
gl_shader_stage stage = _mesa_shader_enum_to_shader_stage(type);
 
-   target = &ctx->_Shader->CurrentProgram[stage];
+   target = &shTarget->CurrentProgram[stage];
if ((shProg == NULL) || (shProg->_LinkedShaders[stage] == NULL))
   shProg = NULL;
 
if (*target != shProg) {
-  FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
+  /* Program is current, flush it */
+  if (shTarget == ctx->_Shader) {
+ FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
+  }
 
   /* If the shader is also bound as the current rendering shader, unbind
* it from that binding point as well.  This ensures that the correct
@@ -1035,10 +1039,10 @@ use_shader_program(struct gl_context *ctx, GLenum type,
 void
 _mesa_use_program(struct gl_context *ctx, struct gl_shader_program *shProg)
 {
-   use_shader_program(ctx, GL_VERTEX_SHADER, shProg);
-   use_shader_program(ctx, GL_GEOMETRY_SHADER_ARB, shProg);
-   use_shader_program(ctx, GL_FRAGMENT_SHADER, shProg);
-   use_shader_program(ctx, GL_COMPUTE_SHADER, shProg);
+   use_shader_program(ctx, GL_VERTEX_SHADER, shProg, &ctx->Shader);
+   use_shader_program(ctx, GL_GEOMETRY_SHADER_ARB, shProg, &ctx->Shader);
+   use_shader_program(ctx, GL_FRAGMENT_SHADER, shProg, &ctx->Shader);
+   use_shader_program(ctx, GL_COMPUTE_SHADER, shProg, &ctx->Shader);
_mesa_active_program(ctx, shProg, "glUseProgram");
 
if (ctx->Driver.UseProgram)
@@ -1798,9 +1802,10 @@ _mesa_ProgramParameteri(GLuint program, GLenum pname, 
GLint value)
 
 void
 _mesa_use_shader_program(struct gl_context *ctx, GLenum type,
-struct gl_shader_program *shProg)
+ struct gl_shader_program *shProg,
+ struct gl_pipeline_object *shTarget)
 {
-   use_shader_program(ctx, type, shProg);
+   use_shader_program(ctx, type, shProg, shTarget);
 
if (ctx->Driver.UseProgram)
   ctx->Driver.UseProgram(ctx, shProg);
@@ -1852,10 +1857,10 @@ _mesa_UseShaderProgramEXT(GLenum type, GLuint program)
   /* Attach shader state to the binding point */
   _mesa_reference_pipeline_object(ctx, &ctx->_Shader, &ctx->Shader);
   /* Update the program */
-  _mesa_use_shader_program(ctx, type, shProg);
+  _mesa_use_shader_program(ctx, type, shProg, ctx->_Shader);
} else {
   /* Must be done first: detach the progam */
-  _mesa_use_shader_program(ctx, type, shProg);
+  _mesa_use_shader_program(ctx, type, shProg, ctx->_Shader);
 
   /* Nothing remains current */
   if (!ctx->Shader.CurrentProgram[MES

[Mesa-dev] [PATCH 12/12] mesa/sso: Implement ValidateProgramPipeline

2014-03-05 Thread Ian Romanick
From: Gregory Hainaut 

Implementation note:
I don't use context for ralloc (don't know how).

The check on PROGRAM_SEPARABLE flags is also done when the pipeline
isn't bound.  It doesn't make any sense in a DSA style API.

Maybe we could replace _mesa_validate_program by
_mesa_validate_program_pipeline.  For example we could recreate a dummy
pipeline object.  However the new function checks also the
TEXTURE_IMAGE_UNIT number not sure of the impact.

V2:
Fix memory leak with ralloc_strdup
Formatting improvement

V3 (idr):
* Actually fix the leak of the InfoLog. :)
* Directly generate logs in to gl_pipeline_object::InfoLog via
  ralloc_asprintf isntead of using a temporary buffer.
* Split out from previous uber patch.
* Change spec references to include section numbers, etc.
* Fix a bug in checking that a different program isn't active in a stage
  between two stages that have the same program.  Specifically,

 if (pipe->CurrentVertexProgram->Name == pipe->CurrentGeometryProgram->Name &&
 pipe->CurrentGeometryProgram->Name != pipe->CurrentVertexProgram->Name)

should have been

 if (pipe->CurrentVertexProgram->Name == pipe->CurrentFragmentProgram->Name &&
 pipe->CurrentGeometryProgram->Name != pipe->CurrentVertexProgram->Name)

v4 (idr): Rework to use CurrentProgram array in loops.

Reviewed-by: Ian Romanick 
---
 src/mesa/main/context.c |  10 +++
 src/mesa/main/mtypes.h  |   2 +
 src/mesa/main/pipelineobj.c | 191 +++-
 src/mesa/main/pipelineobj.h |   3 +
 4 files changed, 203 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 9b2537d..e1fb21f 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1799,6 +1799,7 @@ shader_linked_or_absent(struct gl_context *ctx,
  * Prior to drawing anything with glBegin, glDrawArrays, etc. this function
  * is called to see if it's valid to render.  This involves checking that
  * the current shader is valid and the framebuffer is complete.
+ * It also check the current pipeline object is valid if any.
  * If an error is detected it'll be recorded here.
  * \return GL_TRUE if OK to render, GL_FALSE if not
  */
@@ -1850,6 +1851,15 @@ _mesa_valid_to_render(struct gl_context *ctx, const char 
*where)
   }
}
 
+   /* A pipeline object is bound */
+   if (ctx->_Shader->Name && !ctx->_Shader->Validated) {
+  /* Error message will be printed inside _mesa_validate_program_pipeline.
+   */
+  if (!_mesa_validate_program_pipeline(ctx, ctx->_Shader, GL_TRUE)) {
+ return GL_FALSE;
+  }
+   }
+
if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
   _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
   "%s(incomplete framebuffer)", where);
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index edb5034..604b1c6 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2815,6 +2815,8 @@ struct gl_pipeline_object
 
GLboolean EverBound; /**< Has the pipeline object been 
created */
 
+   GLboolean Validated; /**< Pipeline Validation status */
+
GLchar *InfoLog;
 };
 
diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
index 3db97c0..d371e88 100644
--- a/src/mesa/main/pipelineobj.c
+++ b/src/mesa/main/pipelineobj.c
@@ -589,9 +589,7 @@ _mesa_GetProgramPipelineiv(GLuint pipeline, GLenum pname, 
GLint *params)
   *params = pipe->InfoLog ? strlen(pipe->InfoLog) + 1 : 0;
   return;
case GL_VALIDATE_STATUS:
-  /* FINISHME: Implement validation status.
-   */
-  *params = 0;
+  *params = pipe->Validated;
   return;
case GL_VERTEX_SHADER:
   *params = pipe->CurrentProgram[MESA_SHADER_VERTEX]
@@ -622,11 +620,198 @@ _mesa_GetProgramPipelineiv(GLuint pipeline, GLenum 
pname, GLint *params)
 }
 
 /**
+ * Determines whether every stage in a linked program is active in the
+ * specified pipeline.
+ */
+static bool
+program_stages_all_active(struct gl_pipeline_object *pipe,
+  const struct gl_shader_program *prog)
+{
+   unsigned i;
+   bool status = true;
+
+   if (!prog)
+  return true;
+
+   for (i = 0; i < MESA_SHADER_STAGES; i++) {
+  if (prog->_LinkedShaders[i]) {
+ if (pipe->CurrentProgram[i]) {
+if (prog->Name != pipe->CurrentProgram[i]->Name) {
+   status = false;
+}
+ } else {
+status = false;
+ }
+  }
+   }
+
+   if (!status) {
+  pipe->InfoLog = ralloc_asprintf(pipe,
+  "Program %d is not active for all "
+  "shaders that was linked",
+  prog->Name);
+   }
+
+   return status;
+}
+
+extern GLboolean
+_mesa_validate_program_pipeline(struct gl_context* ctx,
+struct gl_pipeline_object *pipe,
+GLboolean IsBound)

[Mesa-dev] [PATCH 08/12] mesa/sso: Implement _mesa_BindProgramPipeline

2014-03-05 Thread Ian Romanick
From: Gregory Hainaut 

Test become green in piglit:

The updated ext_transform_feedback-api-errors:useprogstage_noactive 
useprogstage_active bind_pipeline
arb_separate_shader_object-GetProgramPipelineiv
arb_separate_shader_object-IsProgramPipeline

For the moment I reuse Driver.UseProgram but I guess it will be better
to create a UseProgramStages functions. Opinion is welcome

V2: formatting & rename

V3 (idr):
* Change spec references to core OpenGL versions instead of issues in the
  extension spec.

Reviewed-by: Ian Romanick 
---
 src/mesa/main/pipelineobj.c | 69 +
 1 file changed, 69 insertions(+)

diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
index 7149578..d1f4d04 100644
--- a/src/mesa/main/pipelineobj.c
+++ b/src/mesa/main/pipelineobj.c
@@ -382,6 +382,75 @@ _mesa_ActiveShaderProgram(GLuint pipeline, GLuint program)
 void GLAPIENTRY
 _mesa_BindProgramPipeline(GLuint pipeline)
 {
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_pipeline_object *newObj = NULL;
+
+   /* Rebinding the same pipeline object: no change.
+*/
+   if (ctx->_Shader->Name == pipeline)
+  return;
+
+   /* Section 2.17.2 (Transform Feedback Primitive Capture) of the OpenGL 4.1
+* spec says:
+*
+* "The error INVALID_OPERATION is generated:
+*
+*  ...
+*
+* - by BindProgramPipeline if the current transform feedback
+*   object is active and not paused;
+*/
+   if (_mesa_is_xfb_active_and_unpaused(ctx)) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+"glBindProgramPipeline(transform feedback active)");
+  return;
+   }
+
+   /* Get pointer to new pipeline object (newObj)
+*/
+   if (pipeline) {
+  /* non-default pipeline object */
+  newObj = lookup_pipeline_object(ctx, pipeline);
+  if (!newObj) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBindProgramPipeline(non-gen name)");
+ return;
+  }
+
+  /* Object is created by any Pipeline call but glGenProgramPipelines,
+   * glIsProgramPipeline and GetProgramPipelineInfoLog
+   */
+  newObj->EverBound = GL_TRUE;
+   }
+
+   /* First bind the Pipeline to pipeline binding point */
+   _mesa_reference_pipeline_object(ctx, &ctx->Pipeline.Current, newObj);
+
+   /* Section 2.11.3 (Program Objects) of the OpenGL 4.1 spec says:
+*
+* "If there is a current program object established by UseProgram,
+* that program is considered current for all stages. Otherwise, if
+* there is a bound program pipeline object (see section 2.11.4), the
+* program bound to the appropriate stage of the pipeline object is
+* considered current."
+*/
+   if (&ctx->Shader != ctx->_Shader) {
+  if (pipeline) {
+ /* Bound the pipeline to the current program and
+  * restore the pipeline state
+  */
+ _mesa_reference_pipeline_object(ctx, &ctx->_Shader, newObj);
+  } else {
+ /* Unbind the pipeline */
+ _mesa_reference_pipeline_object(ctx, &ctx->_Shader,
+ ctx->Pipeline.Default);
+  }
+
+  FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
+
+  if (ctx->Driver.UseProgram)
+ ctx->Driver.UseProgram(ctx, NULL);
+   }
 }
 
 /**
-- 
1.8.1.4

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


[Mesa-dev] [PATCH 04/12] mesa/sso: rename Shader to the pointer _Shader

2014-03-05 Thread Ian Romanick
From: Gregory Hainaut 

Basically a sed but shaderapi.c and get.c.
get.c => GL_CURRENT_PROGAM always refer to the "old" UseProgram behavior
shaderapi.c => the old api stil update the Shader object directly

V2: formatting improvement

V3 (idr):
* Rebase fixes after a block of code was moved from ir_to_mesa.cpp to
  shaderapi.c.
* Trivial reformatting.

Reviewed-by: Ian Romanick 
---
 src/mesa/drivers/common/meta.c   |  6 +--
 src/mesa/drivers/dri/i965/brw_gs.c   |  2 +-
 src/mesa/drivers/dri/i965/brw_gs_surface_state.c |  4 +-
 src/mesa/drivers/dri/i965/brw_shader.cpp |  4 +-
 src/mesa/drivers/dri/i965/brw_vec4_gs.c  |  2 +-
 src/mesa/drivers/dri/i965/brw_vs.c   |  4 +-
 src/mesa/drivers/dri/i965/brw_vs_surface_state.c |  4 +-
 src/mesa/drivers/dri/i965/brw_wm.c   |  2 +-
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c |  2 +-
 src/mesa/drivers/dri/i965/gen6_sol.c |  6 +--
 src/mesa/drivers/dri/i965/gen6_vs_state.c|  2 +-
 src/mesa/drivers/dri/i965/gen6_wm_state.c|  2 +-
 src/mesa/drivers/dri/i965/gen7_vs_state.c|  2 +-
 src/mesa/drivers/dri/i965/gen7_wm_state.c|  2 +-
 src/mesa/main/api_validate.c | 10 ++--
 src/mesa/main/context.c  |  6 +--
 src/mesa/main/ff_fragment_shader.cpp |  8 +--
 src/mesa/main/get.c  | 12 +
 src/mesa/main/shaderapi.c| 36 +++--
 src/mesa/main/state.c| 14 ++---
 src/mesa/main/texstate.c |  6 +--
 src/mesa/main/transformfeedback.c|  4 +-
 src/mesa/main/uniform_query.cpp  |  4 +-
 src/mesa/main/uniforms.c | 66 
 src/mesa/program/ir_to_mesa.cpp  |  6 +--
 src/mesa/state_tracker/st_atom_clip.c|  2 +-
 src/mesa/state_tracker/st_atom_constbuf.c|  6 +--
 src/mesa/state_tracker/st_cb_drawpixels.c|  2 +-
 src/mesa/state_tracker/st_draw.c |  2 +-
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp   |  2 +-
 src/mesa/state_tracker/st_program.c  |  2 +-
 src/mesa/swrast/s_fragprog.c |  2 +-
 32 files changed, 124 insertions(+), 110 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index cde34f9..f67d8e8 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -538,10 +538,10 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
 
   for (i = 0; i < MESA_SHADER_STAGES; i++) {
  _mesa_reference_shader_program(ctx, &save->Shader[i],
- ctx->Shader.CurrentProgram[i]);
+ ctx->_Shader->CurrentProgram[i]);
   }
   _mesa_reference_shader_program(ctx, &save->ActiveShader,
- ctx->Shader.ActiveProgram);
+ ctx->_Shader->ActiveProgram);
 
   _mesa_UseProgram(0);
}
@@ -889,7 +889,7 @@ _mesa_meta_end(struct gl_context *ctx)
 _mesa_use_shader_program(ctx, GL_FRAGMENT_SHADER,
  save->Shader[MESA_SHADER_FRAGMENT]);
 
-  _mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram,
+  _mesa_reference_shader_program(ctx, &ctx->_Shader->ActiveProgram,
 save->ActiveShader);
 
   for (i = 0; i < MESA_SHADER_STAGES; i++)
diff --git a/src/mesa/drivers/dri/i965/brw_gs.c 
b/src/mesa/drivers/dri/i965/brw_gs.c
index bd5bf14..ddfb296 100644
--- a/src/mesa/drivers/dri/i965/brw_gs.c
+++ b/src/mesa/drivers/dri/i965/brw_gs.c
@@ -187,7 +187,7 @@ static void populate_key(struct brw_context *brw,
   /* BRW_NEW_TRANSFORM_FEEDBACK */
   if (_mesa_is_xfb_active_and_unpaused(ctx)) {
  const struct gl_shader_program *shaderprog =
-ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX];
+ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX];
  const struct gl_transform_feedback_info *linked_xfb_info =
 &shaderprog->LinkedTransformFeedback;
  int i;
diff --git a/src/mesa/drivers/dri/i965/brw_gs_surface_state.c 
b/src/mesa/drivers/dri/i965/brw_gs_surface_state.c
index 0795e56..26a3fa8 100644
--- a/src/mesa/drivers/dri/i965/brw_gs_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_gs_surface_state.c
@@ -70,7 +70,7 @@ brw_upload_gs_ubo_surfaces(struct brw_context *brw)
 
/* _NEW_PROGRAM */
struct gl_shader_program *prog =
-  ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY];
+  ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY];
 
if (!prog)
   return;
@@ -95,7 +95,7 @@ brw_upload_gs_abo_surfaces(struct brw_context *brw)
struct gl_context *ctx = &brw->ctx;
/* _NEW_PROGRAM */
struct gl_shader_program *prog =
-  ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY];
+  ctx

[Mesa-dev] [PATCH 05/12] meta/sso: Update meta to save and restore SSO state.

2014-03-05 Thread Ian Romanick
From: Gregory Hainaut 

save and restore _Shader/Pipeline binding point. Rational we don't want any
conflict when the program will be unattached.

V2: formatting improvement

V3 (idr):
* Build fix.  The original patch added calls to _mesa_use_shader_program
  with 4 parameters, but the fourth parameter isn't added to that
  function until a much later patch.  Just drop that parameter for now.

Reviewed-by: Ian Romanick 
---
 src/mesa/drivers/common/meta.c | 18 ++
 src/mesa/drivers/common/meta.h |  2 ++
 2 files changed, 20 insertions(+)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index f67d8e8..a274895 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -53,6 +53,7 @@
 #include "main/mipmap.h"
 #include "main/multisample.h"
 #include "main/objectlabel.h"
+#include "main/pipelineobj.h"
 #include "main/pixel.h"
 #include "main/pbo.h"
 #include "main/polygon.h"
@@ -536,6 +537,14 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
  _mesa_set_enable(ctx, GL_FRAGMENT_SHADER_ATI, GL_FALSE);
   }
 
+  if (ctx->Extensions.ARB_separate_shader_objects) {
+ /* Warning it must be done before _mesa_UseProgram call */
+ _mesa_reference_pipeline_object(ctx, &save->_Shader, ctx->_Shader);
+ _mesa_reference_pipeline_object(ctx, &save->Pipeline,
+ ctx->Pipeline.Current);
+ _mesa_BindProgramPipeline(0);
+  }
+
   for (i = 0; i < MESA_SHADER_STAGES; i++) {
  _mesa_reference_shader_program(ctx, &save->Shader[i],
  ctx->_Shader->CurrentProgram[i]);
@@ -876,6 +885,14 @@ _mesa_meta_end(struct gl_context *ctx)
   save->ATIFragmentShaderEnabled);
   }
 
+  /* Warning it must be done before _mesa_use_shader_program call */
+  if (ctx->Extensions.ARB_separate_shader_objects) {
+ _mesa_reference_pipeline_object(ctx, &ctx->_Shader, save->_Shader);
+ _mesa_reference_pipeline_object(ctx, &ctx->Pipeline.Current,
+ save->Pipeline);
+ _mesa_reference_pipeline_object(ctx, &save->Pipeline, NULL);
+  }
+
   if (ctx->Extensions.ARB_vertex_shader) {
 _mesa_use_shader_program(ctx, GL_VERTEX_SHADER,
   save->Shader[MESA_SHADER_VERTEX]);
@@ -895,6 +912,7 @@ _mesa_meta_end(struct gl_context *ctx)
   for (i = 0; i < MESA_SHADER_STAGES; i++)
  _mesa_reference_shader_program(ctx, &save->Shader[i], NULL);
   _mesa_reference_shader_program(ctx, &save->ActiveShader, NULL);
+  _mesa_reference_pipeline_object(ctx, &save->_Shader, NULL);
}
 
if (state & MESA_META_STENCIL_TEST) {
diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
index fcf45c4..0ae455a 100644
--- a/src/mesa/drivers/common/meta.h
+++ b/src/mesa/drivers/common/meta.h
@@ -121,6 +121,8 @@ struct save_state
GLboolean ATIFragmentShaderEnabled;
struct gl_shader_program *Shader[MESA_SHADER_STAGES];
struct gl_shader_program *ActiveShader;
+   struct gl_pipeline_object   *_Shader;
+   struct gl_pipeline_object   *Pipeline;
 
/** MESA_META_STENCIL_TEST */
struct gl_stencil_attrib Stencil;
-- 
1.8.1.4

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


[Mesa-dev] [PATCH 03/12] mesa/sso: replace Shader binding point with _Shader

2014-03-05 Thread Ian Romanick
From: Gregory Hainaut 

To avoid NULL pointer check a default pipeline object is installed in
_Shader when no program is current

The spec say that UseProgram/UseShaderProgramEXT/ActiveProgramEXT got an
higher priority over the pipeline object. When default program is
uninstall, the pipeline is used if any was bound.

Note: A careful rename need to be done now...

V2: formating improvement

V3 (idr):
* Build fix.  The original patch added calls to _mesa_use_shader_program with
  4 parameters, but the fourth parameter isn't added to that function until a
  much later patch.  Just drop that parameter for now.
* Trivial reformatting.
* Updated comment of gl_context::_Shader

Reviewed-by: Ian Romanick 
---
 src/mesa/main/mtypes.h  | 15 
 src/mesa/main/pipelineobj.c |  8 
 src/mesa/main/shaderapi.c   | 91 +++--
 3 files changed, 111 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index d05649c..8a03afd 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2824,6 +2824,9 @@ struct gl_pipeline_shader_state
/** Currently bound pipeline object. See _mesa_BindProgramPipeline() */
struct gl_pipeline_object *Current;
 
+   /* Default Object to ensure that _Shader is never NULL */
+   struct gl_pipeline_object *Default;
+
/** Pipeline objects */
struct _mesa_HashTable *Objects;
 };
@@ -4131,6 +4134,18 @@ struct gl_context
 
struct gl_pipeline_shader_state Pipeline; /**< GLSL pipeline shader object 
state */
struct gl_pipeline_object Shader; /**< GLSL shader object state */
+
+   /**
+* Current active shader pipeline state
+*
+* Almost all internal users want ::_Shader instead of ::Shader.  The
+* exceptions are bits of legacy GLSL API that do not know about separate
+* shader objects.
+*
+* Points to ::Shader, ::Pipeline.Current, or ::Pipeline.Default.
+*/
+   struct gl_pipeline_object *_Shader;
+
struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_STAGES];
 
struct gl_query_state Query;  /**< occlusion, timer queries */
diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
index 27012df..849c781 100644
--- a/src/mesa/main/pipelineobj.c
+++ b/src/mesa/main/pipelineobj.c
@@ -94,6 +94,10 @@ _mesa_init_pipeline(struct gl_context *ctx)
ctx->Pipeline.Objects = _mesa_NewHashTable();
 
ctx->Pipeline.Current = NULL;
+
+   /* Install a default Pipeline */
+   ctx->Pipeline.Default = _mesa_new_pipeline_object(ctx, 0);
+   _mesa_reference_pipeline_object(ctx, &ctx->_Shader, ctx->Pipeline.Default);
 }
 
 
@@ -117,6 +121,10 @@ _mesa_free_pipeline_data(struct gl_context *ctx)
 {
_mesa_HashDeleteAll(ctx->Pipeline.Objects, delete_pipelineobj_cb, ctx);
_mesa_DeleteHashTable(ctx->Pipeline.Objects);
+
+   _mesa_reference_pipeline_object(ctx, &ctx->_Shader, NULL);
+   _mesa_delete_pipeline_object(ctx, ctx->Pipeline.Default);
+
 }
 
 /**
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 5060cbb..71b2ef5 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -44,6 +44,7 @@
 #include "main/hash.h"
 #include "main/hash_table.h"
 #include "main/mtypes.h"
+#include "main/pipelineobj.h"
 #include "main/shaderapi.h"
 #include "main/shaderobj.h"
 #include "main/transformfeedback.h"
@@ -144,6 +145,8 @@ _mesa_free_shader_state(struct gl_context *ctx)
_mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram, NULL);
 
/* Extended for ARB_separate_shader_objects */
+   _mesa_reference_pipeline_object(ctx, &ctx->_Shader, NULL);
+
assert(ctx->Shader.RefCount == 1);
mtx_destroy(&ctx->Shader.Mutex);
 }
@@ -1541,7 +1544,29 @@ _mesa_UseProgram(GLhandleARB program)
   shProg = NULL;
}
 
-   _mesa_use_program(ctx, shProg);
+   /*
+* The executable code for an individual shader stage is taken from the
+* current program for that stage.  If there is a current program object
+* for any shader stage or for uniform updates established by UseProgram,
+* UseShaderProgramEXT, or ActiveProgramEXT, the current program for that
+* stage (if any) is considered current.  Otherwise, if there is a bound
+* program pipeline object ...
+*/
+   if (program) {
+  /* Attach shader state to the binding point */
+  _mesa_reference_pipeline_object(ctx, &ctx->_Shader, &ctx->Shader);
+  /* Update the program */
+  _mesa_use_program(ctx, shProg);
+   } else {
+  /* Must be done first: detach the progam */
+  _mesa_use_program(ctx, shProg);
+  /* Unattach shader_state binding point */
+  _mesa_reference_pipeline_object(ctx, &ctx->_Shader, 
ctx->Pipeline.Default);
+  /* If a pipeline was bound, rebind it */
+  if (ctx->Pipeline.Current) {
+ _mesa_BindProgramPipeline(ctx->Pipeline.Current->Name);
+  }
+   }
 }
 
 
@@ -1815,7 +1840,39 @@ _mesa_UseShaderProgramEXT(GLenum type, GLuint program)
   }
}
 
-   _mes

[Mesa-dev] [PATCH 09/12] mesa/sso: Implement GL_PROGRAM_PIPELINE_BINDING for glGet

2014-03-05 Thread Ian Romanick
From: Gregory Hainaut 

Reviewed-by: Ian Romanick 
---
 src/mesa/main/get.c  | 9 +
 src/mesa/main/get_hash_params.py | 3 +++
 2 files changed, 12 insertions(+)

diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 6e061e4..8a509c4 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -387,6 +387,7 @@ EXTRA_EXT(ARB_texture_cube_map_array);
 EXTRA_EXT(ARB_texture_buffer_range);
 EXTRA_EXT(ARB_texture_multisample);
 EXTRA_EXT(ARB_texture_gather);
+EXTRA_EXT(ARB_separate_shader_objects);
 EXTRA_EXT(ARB_shader_atomic_counters);
 EXTRA_EXT(ARB_draw_indirect);
 EXTRA_EXT(ARB_shader_image_load_store);
@@ -1014,6 +1015,14 @@ find_custom_value(struct gl_context *ctx, const struct 
value_desc *d, union valu
case GL_DRAW_INDIRECT_BUFFER_BINDING:
   v->value_int = ctx->DrawIndirectBuffer->Name;
   break;
+   /* GL_ARB_separate_shader_objects */
+   case GL_PROGRAM_PIPELINE_BINDING:
+  if (ctx->Pipeline.Current) {
+ v->value_int = ctx->Pipeline.Current->Name;
+  } else {
+ v->value_int = 0;
+  }
+  break;
}
 }
 
diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
index 674d003..06d0bba 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -726,6 +726,9 @@ descriptor=[
   [ "MAX_PROGRAM_TEXTURE_GATHER_OFFSET", 
"CONTEXT_INT(Const.MaxProgramTextureGatherOffset), extra_ARB_texture_gather"],
   [ "MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB", 
"CONTEXT_INT(Const.MaxProgramTextureGatherComponents), 
extra_ARB_texture_gather"],
 
+# GL_ARB_separate_shader_objects
+  [ "PROGRAM_PIPELINE_BINDING", "LOC_CUSTOM, TYPE_INT, 
GL_PROGRAM_PIPELINE_BINDING, extra_ARB_separate_shader_objects" ],
+
 # GL_ARB_shader_atomic_counters
   [ "ATOMIC_COUNTER_BUFFER_BINDING", "LOC_CUSTOM, TYPE_INT, 0, 
extra_ARB_shader_atomic_counters" ],
   [ "MAX_ATOMIC_COUNTER_BUFFER_BINDINGS", 
"CONTEXT_INT(Const.MaxAtomicBufferBindings), extra_ARB_shader_atomic_counters" 
],
-- 
1.8.1.4

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


[Mesa-dev] [PATCH 11/12] mesa/sso: Add _mesa_sampler_uniforms_pipeline_are_valid

2014-03-05 Thread Ian Romanick
From: Gregory Hainaut 

This is much like _mesa_sampler_uniforms_are_valid, but it operates
across an entire pipeline object.

This function differs from _mesa_sampler_uniforms_are_valid in that it
directly creates the gl_pipeline_object::InfoLog instead of writing to
some temporary buffer.

This was originally included in another patch, but it was split out by
Ian Romanick.

Reviewed-by: Ian Romanick 
---
 src/mesa/main/uniform_query.cpp | 77 +
 src/mesa/main/uniforms.h|  2 ++
 2 files changed, 79 insertions(+)

diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index 7b375c0..35acabb 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -1088,3 +1088,80 @@ _mesa_sampler_uniforms_are_valid(const struct 
gl_shader_program *shProg,
 
return true;
 }
+
+extern "C" bool
+_mesa_sampler_uniforms_pipeline_are_valid(struct gl_pipeline_object *pipeline)
+{
+   /* Section 2.11.11 (Shader Execution), subheading "Validation," of the
+* OpenGL 4.1 spec says:
+*
+* "[INVALID_OPERATION] is generated by any command that transfers
+* vertices to the GL if:
+*
+* ...
+*
+* - Any two active samplers in the current program object are of
+*   different types, but refer to the same texture image unit.
+*
+* - The number of active samplers in the program exceeds the
+*   maximum number of texture image units allowed."
+*/
+   unsigned active_samplers = 0;
+   const struct gl_shader_program **shProg =
+  (const struct gl_shader_program **) pipeline->CurrentProgram;
+
+   const glsl_type *unit_types[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
+   memset(unit_types, 0, sizeof(unit_types));
+
+   for (unsigned idx = 0; idx < ARRAY_SIZE(shProg); idx++) {
+  if (!shProg[idx])
+ continue;
+
+  for (unsigned i = 0; i < shProg[idx]->NumUserUniformStorage; i++) {
+ const struct gl_uniform_storage *const storage =
+&shProg[idx]->UniformStorage[i];
+ const glsl_type *const t = (storage->type->is_array())
+? storage->type->fields.array : storage->type;
+
+ if (!t->is_sampler())
+continue;
+
+ active_samplers++;
+
+ const unsigned count = MAX2(1, storage->type->array_size());
+ for (unsigned j = 0; j < count; j++) {
+const unsigned unit = storage->storage[j].i;
+
+/* The types of the samplers associated with a particular texture
+ * unit must be an exact match.  Page 74 (page 89 of the PDF) of
+ * the OpenGL 3.3 core spec says:
+ *
+ * "It is not allowed to have variables of different sampler
+ * types pointing to the same texture image unit within a
+ * program object."
+ */
+if (unit_types[unit] == NULL) {
+   unit_types[unit] = t;
+} else if (unit_types[unit] != t) {
+   pipeline->InfoLog =
+  ralloc_asprintf(pipeline,
+  "Texture unit %d is accessed both as %s "
+  "and %s",
+  unit, unit_types[unit]->name, t->name);
+   return false;
+}
+ }
+  }
+   }
+
+   if (active_samplers > MAX_COMBINED_TEXTURE_IMAGE_UNITS) {
+  pipeline->InfoLog =
+ ralloc_asprintf(pipeline,
+ "the number of active samplers %d exceed the "
+ "maximum %d",
+ active_samplers, MAX_COMBINED_TEXTURE_IMAGE_UNITS);
+  return false;
+   }
+
+   return true;
+}
diff --git a/src/mesa/main/uniforms.h b/src/mesa/main/uniforms.h
index bd50fd9..af955c17 100644
--- a/src/mesa/main/uniforms.h
+++ b/src/mesa/main/uniforms.h
@@ -300,6 +300,8 @@ _mesa_update_shader_textures_used(struct gl_shader_program 
*shProg,
 extern bool
 _mesa_sampler_uniforms_are_valid(const struct gl_shader_program *shProg,
 char *errMsg, size_t errMsgLength);
+extern bool
+_mesa_sampler_uniforms_pipeline_are_valid(struct gl_pipeline_object *);
 
 extern const struct gl_program_parameter *
 get_uniform_parameter(struct gl_shader_program *shProg, GLint index);
-- 
1.8.1.4

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


[Mesa-dev] [PATCH 07/12] mesa/sso: Implement _mesa_UseProgramStages

2014-03-05 Thread Ian Romanick
From: Gregory Hainaut 

Now arb_separate_shader_object-GetProgramPipelineiv should pass.

V3 (idr):
* Change spec references to core OpenGL versions instead of issues in
  the extension spec.
* Split out from previous uber patch.

v4 (idr): Use _mesa_has_geometry_shaders in _mesa_UseProgramStages to
detect availability of geometry shaders.

Reviewed-by: Ian Romanick 
---
 src/mesa/main/pipelineobj.c | 115 
 1 file changed, 115 insertions(+)

diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
index 849c781..7149578 100644
--- a/src/mesa/main/pipelineobj.c
+++ b/src/mesa/main/pipelineobj.c
@@ -222,6 +222,121 @@ _mesa_reference_pipeline_object_(struct gl_context *ctx,
 void GLAPIENTRY
 _mesa_UseProgramStages(GLuint pipeline, GLbitfield stages, GLuint program)
 {
+   GET_CURRENT_CONTEXT(ctx);
+
+   struct gl_pipeline_object *pipe = lookup_pipeline_object(ctx, pipeline);
+   struct gl_shader_program *shProg = NULL;
+
+   if (!pipe) {
+  _mesa_error(ctx, GL_INVALID_OPERATION, "glUseProgramStages(pipeline)");
+  return;
+   }
+
+   /* Object is created by any Pipeline call but glGenProgramPipelines,
+* glIsProgramPipeline and GetProgramPipelineInfoLog
+*/
+   pipe->EverBound = GL_TRUE;
+
+   /* Section 2.11.4 (Program Pipeline Objects) of the OpenGL 4.1 spec says:
+*
+* "If stages is not the special value ALL_SHADER_BITS, and has a bit
+* set that is not recognized, the error INVALID_VALUE is generated."
+*
+* NOT YET SUPPORTED:
+* GL_TESS_CONTROL_SHADER_BIT
+* GL_TESS_EVALUATION_SHADER_BIT
+*/
+   GLbitfield any_valid_stages = GL_VERTEX_SHADER_BIT | GL_FRAGMENT_SHADER_BIT;
+   if (_mesa_has_geometry_shaders(ctx))
+  any_valid_stages |= GL_GEOMETRY_SHADER_BIT;
+
+   if (stages != GL_ALL_SHADER_BITS && (stages  & ~any_valid_stages) != 0) {
+  _mesa_error(ctx, GL_INVALID_VALUE, "glUseProgramStages(Stages)");
+  return;
+   }
+
+   /* Section 2.17.2 (Transform Feedback Primitive Capture) of the OpenGL 4.1
+* spec says:
+*
+* "The error INVALID_OPERATION is generated:
+*
+*  ...
+*
+* - by UseProgramStages if the program pipeline object it refers
+*   to is current and the current transform feedback object is
+*   active and not paused;
+*/
+   if (ctx->_Shader == pipe) {
+  if (_mesa_is_xfb_active_and_unpaused(ctx)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+   "glUseProgramStages(transform feedback active)");
+ return;
+  }
+   }
+
+   if (program) {
+  /* Section 2.11.1 (Shader Objects) of the OpenGL 3.1 spec (and probably
+   * earlier) says:
+   *
+   * "Commands that accept shader or program object names will
+   * generate the error INVALID_VALUE if the provided name is not the
+   * name of either a shader or program object and INVALID_OPERATION
+   * if the provided name identifies an object that is not the
+   * expected type."
+   */
+  struct gl_shader *sh = _mesa_lookup_shader(ctx, program);
+  if (sh != NULL) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+   "glUseProgramStages(progam is a shader object)");
+ return;
+  }
+
+  shProg = _mesa_lookup_shader_program(ctx, program);
+  if (shProg == NULL) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+   "glUseProgramStages(progam is not a program object)");
+ return;
+  }
+
+  /* Section 2.11.4 (Program Pipeline Objects) of the OpenGL 4.1 spec
+   * says:
+   *
+   * "If the program object named by program was linked without the
+   * PROGRAM_SEPARABLE parameter set, or was not linked successfully,
+   * the error INVALID_OPERATION is generated and the corresponding
+   * shader stages in the pipeline program pipeline object are not
+   * modified."
+   */
+  if (!shProg->LinkStatus) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glUseProgramStages(program not linked)");
+ return;
+  }
+
+  if (!shProg->SeparateShader) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glUseProgramStages(program wasn't linked with the "
+ "PROGRAM_SEPARABLE flag)");
+ return;
+  }
+   }
+
+   /* Section 2.11.4 (Program Pipeline Objects) of the OpenGL 4.1 spec
+* says:
+*
+* "If UseProgramStages is called with program set to zero or with a
+* program object that contains no executable code for the given
+* stages, it is as if the pipeline object has no programmable stage
+* configured for the indicated shader stages."
+*/
+   if ((stages & GL_VERTEX_SHADER_BIT) != 0)
+  _mesa_use_shader_program(ctx, GL_VERTEX_SHADER, shProg, pipe);
+
+   if ((stages & GL_FRAGMENT_SHADER_BIT) != 0)
+  _mesa_use_shader_program(

[Mesa-dev] [PATCH 10/12] mesa/sso: Add gl_pipeline_object::InfoLog support

2014-03-05 Thread Ian Romanick
From: Gregory Hainaut 

V2 (idr):
* Keep the behavior of other info logs in Mesa: and empty info log
  reports a GL_INFO_LOG_LENGTH of zero.
* Use a NULL pointer to denote an empty info log.
* Split out from previous uber patch.

Reviewed-by: Ian Romanick 
---
 src/mesa/main/mtypes.h  |  2 ++
 src/mesa/main/pipelineobj.c | 25 ++---
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 8a03afd..edb5034 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2814,6 +2814,8 @@ struct gl_pipeline_object
GLbitfield Flags;/**< Mask of GLSL_x flags */
 
GLboolean EverBound; /**< Has the pipeline object been 
created */
+
+   GLchar *InfoLog;
 };
 
 /**
diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
index d1f4d04..3db97c0 100644
--- a/src/mesa/main/pipelineobj.c
+++ b/src/mesa/main/pipelineobj.c
@@ -80,6 +80,7 @@ _mesa_new_pipeline_object(struct gl_context *ctx, GLuint name)
   mtx_init(&obj->Mutex, mtx_plain);
   obj->RefCount = 1;
   obj->Flags = _mesa_get_shader_flags();
+  obj->InfoLog = NULL;
}
 
return obj;
@@ -585,9 +586,7 @@ _mesa_GetProgramPipelineiv(GLuint pipeline, GLenum pname, 
GLint *params)
   *params = pipe->ActiveProgram ? pipe->ActiveProgram->Name : 0;
   return;
case GL_INFO_LOG_LENGTH:
-  /* FINISHME: Implement the info log.
-   */
-  *params = 0;
+  *params = pipe->InfoLog ? strlen(pipe->InfoLog) + 1 : 0;
   return;
case GL_VALIDATE_STATUS:
   /* FINISHME: Implement validation status.
@@ -634,4 +633,24 @@ void GLAPIENTRY
 _mesa_GetProgramPipelineInfoLog(GLuint pipeline, GLsizei bufSize,
 GLsizei *length, GLchar *infoLog)
 {
+   GET_CURRENT_CONTEXT(ctx);
+
+   struct gl_pipeline_object *pipe = lookup_pipeline_object(ctx, pipeline);
+
+   if (!pipe) {
+  _mesa_error(ctx, GL_INVALID_VALUE,
+  "glGetProgramPipelineInfoLog(pipeline)");
+  return;
+   }
+
+   if (bufSize < 0) {
+  _mesa_error(ctx, GL_INVALID_VALUE,
+  "glGetProgramPipelineInfoLog(bufSize)");
+  return;
+   }
+
+   if (pipe->InfoLog)
+  _mesa_copy_string(infoLog, bufSize, length, pipe->InfoLog);
+   else
+  *length = 0;
 }
-- 
1.8.1.4

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


[Mesa-dev] [PATCH] nv50, nvc0: choose storage type after ms has been initialized

2014-03-05 Thread Ilia Mirkin
Signed-off-by: Ilia Mirkin 
---

Noticed by inspection, untested. Would be interesting to see if this fixes
anything.

 src/gallium/drivers/nouveau/nv50/nv50_miptree.c | 4 ++--
 src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c 
b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c
index 513d8f9..6c6ef4e 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c
@@ -329,13 +329,13 @@ nv50_miptree_create(struct pipe_screen *pscreen,
if (pt->bind & PIPE_BIND_LINEAR)
   pt->flags |= NOUVEAU_RESOURCE_FLAG_LINEAR;
 
-   bo_config.nv50.memtype = nv50_mt_choose_storage_type(mt, TRUE);
-
if (!nv50_miptree_init_ms_mode(mt)) {
   FREE(mt);
   return NULL;
}
 
+   bo_config.nv50.memtype = nv50_mt_choose_storage_type(mt, TRUE);
+
if (unlikely(pt->flags & NV50_RESOURCE_FLAG_VIDEO)) {
   nv50_miptree_init_layout_video(mt);
   if (pt->flags & NV50_RESOURCE_FLAG_NOALLOC) {
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c 
b/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c
index 79c9390..59b9028 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c
@@ -277,13 +277,13 @@ nvc0_miptree_create(struct pipe_screen *pscreen,
if (pt->bind & PIPE_BIND_LINEAR)
   pt->flags |= NOUVEAU_RESOURCE_FLAG_LINEAR;
 
-   bo_config.nvc0.memtype = nvc0_mt_choose_storage_type(mt, compressed);
-
if (!nvc0_miptree_init_ms_mode(mt)) {
   FREE(mt);
   return NULL;
}
 
+   bo_config.nvc0.memtype = nvc0_mt_choose_storage_type(mt, compressed);
+
if (unlikely(pt->flags & NVC0_RESOURCE_FLAG_VIDEO)) {
   nvc0_miptree_init_layout_video(mt);
} else
-- 
1.8.3.2

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


Re: [Mesa-dev] [PATCH 02/20] automake: silence folder creation

2014-03-05 Thread Emil Velikov
On 05/03/14 10:11, Erik Faye-Lund wrote:
> On Tue, Mar 4, 2014 at 10:12 PM, Emil Velikov  
> wrote:
>> There is little gain in printing whenever a folder is created.
>>
>> Signed-off-by: Emil Velikov 
>> ---
>>  src/gallium/auxiliary/Makefile.am | 8 
>>  src/glsl/Makefile.am  | 4 ++--
>>  src/mesa/Makefile.am  | 4 ++--
>>  src/mesa/drivers/dri/Makefile.am  | 2 +-
>>  4 files changed, 9 insertions(+), 9 deletions(-)
>>
>> diff --git a/src/gallium/auxiliary/Makefile.am 
>> b/src/gallium/auxiliary/Makefile.am
>> index 2d2d8d4..afeeef9 100644
>> --- a/src/gallium/auxiliary/Makefile.am
>> +++ b/src/gallium/auxiliary/Makefile.am
>> @@ -32,17 +32,17 @@ libgallium_la_SOURCES += \
>>  endif
>>
>>  indices/u_indices_gen.c: $(srcdir)/indices/u_indices_gen.py
>> -   $(MKDIR_P) indices
>> +   @$(MKDIR_P) indices
>> $(AM_V_GEN) $(PYTHON2) $< > $@
> 
> I tend to prefer $(AM_V_at) in cases like this, because it makes it
> show up again in verbose builds.
> 
Good point, will do
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] clover: Fix building with latest llvm

2014-03-05 Thread Marek Olšák
Same here. I'll try to make clean in the LLVM tree.

Marek

On Wed, Mar 5, 2014 at 3:52 AM, Michel Dänzer  wrote:
> On Mit, 2014-03-05 at 00:43 +0100, Marek Olšák wrote:
>> I'm not an automake expect, but this might need to be done for gallivm
>> too. It currently fails to compile with latest LLVM.
>
> I was having trouble with that as well, because the output of
> llvm-config didn't contain -std=c++11. I had to make clean in the LLVM
> tree to fix that, then touch configure in the Mesa tree so the Mesa
> build files were re-generated correctly.
>
>
> --
> 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


[Mesa-dev] [Bug 71547] compilation failure :#error "SSE4.1 instruction set not enabled"

2014-03-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=71547

--- Comment #6 from David "okias" Heidelberger  ---
Patch [1] tested on amd64, with both SSE4.1 enabled and -mno-sse4.1.

Both passed correctly without additional tweaking.

Thank you Matt

Tested-by: David Heidelberger 

[1] http://lists.freedesktop.org/archives/mesa-dev/2014-March/055362.html

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 04/20] automake: make install-lib-links less chatty

2014-03-05 Thread Emil Velikov
On 05/03/14 10:13, Erik Faye-Lund wrote:
> On Tue, Mar 4, 2014 at 10:12 PM, Emil Velikov  
> wrote:
>> There is little point in echoing everything that the script does
>> to stdout. Wrap it in AM_V_GEN so that a reasonable message is
>> printed as a indication of it's invocation.
>>
>> Signed-off-by: Emil Velikov 
>> ---
>>  install-lib-links.mk | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/install-lib-links.mk b/install-lib-links.mk
>> index 73d9e14..9dd4c30 100644
>> --- a/install-lib-links.mk
>> +++ b/install-lib-links.mk
>> @@ -4,7 +4,7 @@
>>  all-local : .libs/install-mesa-links
>>
>>  .libs/install-mesa-links : $(lib_LTLIBRARIES)
>> -   $(MKDIR_P) $(top_builddir)/$(LIB_DIR)
>> +   $(AM_V_GEN)$(MKDIR_P) $(top_builddir)/$(LIB_DIR);   \
> 
> GEN for a directory, really? Why not $(AM_V_at)?
> 
Notice the trailing backspace, which will wrap the whole script in GEN.
One could use AM_V_at for the folder and AM_V_GEN (or other) for the
link/copy. IMHO the latter may be an overkill but meh...

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


Re: [Mesa-dev] [PATCH 04/20] automake: make install-lib-links less chatty

2014-03-05 Thread Erik Faye-Lund
On Wed, Mar 5, 2014 at 12:42 PM, Emil Velikov  wrote:
> On 05/03/14 10:13, Erik Faye-Lund wrote:
>> On Tue, Mar 4, 2014 at 10:12 PM, Emil Velikov  
>> wrote:
>>> There is little point in echoing everything that the script does
>>> to stdout. Wrap it in AM_V_GEN so that a reasonable message is
>>> printed as a indication of it's invocation.
>>>
>>> Signed-off-by: Emil Velikov 
>>> ---
>>>  install-lib-links.mk | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/install-lib-links.mk b/install-lib-links.mk
>>> index 73d9e14..9dd4c30 100644
>>> --- a/install-lib-links.mk
>>> +++ b/install-lib-links.mk
>>> @@ -4,7 +4,7 @@
>>>  all-local : .libs/install-mesa-links
>>>
>>>  .libs/install-mesa-links : $(lib_LTLIBRARIES)
>>> -   $(MKDIR_P) $(top_builddir)/$(LIB_DIR)
>>> +   $(AM_V_GEN)$(MKDIR_P) $(top_builddir)/$(LIB_DIR);   \
>>
>> GEN for a directory, really? Why not $(AM_V_at)?
>>
> Notice the trailing backspace, which will wrap the whole script in GEN.
> One could use AM_V_at for the folder and AM_V_GEN (or other) for the
> link/copy. IMHO the latter may be an overkill but meh...

Right, I missed that, thanks. Makes sense to me, and I agree that it's overkill.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 75212] Mesa selects wrong DRI driver

2014-03-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=75212

Eero Tamminen  changed:

   What|Removed |Added

 Status|RESOLVED|VERIFIED

--- Comment #4 from Eero Tamminen  ---
Right, I used --disable-dri3, and libudev-dev was forced only for DRI3.

Next problem with b959fd9674938e127a34d42d34b903e3a9ae7ad9 is that alhtough it
checks for libudev-dev, it doesn't check that it's for right architecture.
Everything builds fine, but programs can crash on same system due to assert in
loader because there was libudev-dev for 64-bit, but there was no libudev for
32-bit (if you were building for 32-bit).

That's easier to debug than Mesa using wrong driver/SW rendering, so verifying.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 08/20] gallium/targets: drop link generation for non DRI targets

2014-03-05 Thread Emil Velikov
On 05/03/14 07:55, Christian König wrote:
> Am 04.03.2014 22:12, schrieb Emil Velikov:
>> All three (xvmc, vdpau and omx) do not have an alternative loading
>> similar to the dri modules. Thus one needs to explicitly install
>> them in order to use/test them.
> 
> It's not mainline yet, but at least I'm using
> VDPAU_DRIVER_PATH=.../mesa/lib/gallium for quite a while now. So I would
> like to keep that.
> 
My initial plan was to keep the vdpau libs if the patch was merged in
the official repo. Either way, I did not know that it had any users but
me, so I guess we can keep those for a little longer :)

-Emil
> Christian.
> 
>>
>> Signed-off-by: Emil Velikov 
>> ---
>>   src/gallium/targets/r600/omx/Makefile.am   | 6 --
>>   src/gallium/targets/r600/vdpau/Makefile.am | 6 --
>>   src/gallium/targets/r600/xvmc/Makefile.am  | 6 --
>>   src/gallium/targets/radeonsi/omx/Makefile.am   | 6 --
>>   src/gallium/targets/radeonsi/vdpau/Makefile.am | 6 --
>>   src/gallium/targets/vdpau-nouveau/Makefile.am  | 6 --
>>   src/gallium/targets/xvmc-nouveau/Makefile.am   | 6 --
>>   7 files changed, 42 deletions(-)
>>
>> diff --git a/src/gallium/targets/r600/omx/Makefile.am
>> b/src/gallium/targets/r600/omx/Makefile.am
>> index 3aef9e1..98b064f 100644
>> --- a/src/gallium/targets/r600/omx/Makefile.am
>> +++ b/src/gallium/targets/r600/omx/Makefile.am
>> @@ -70,9 +70,3 @@ libomx_r600_la_LINK = $(LINK) $(libomx_r600_la_LDFLAGS)
>>   # Mention a dummy pure C file to trigger generation of the $(LINK)
>> variable
>>   nodist_EXTRA_libomx_r600_la_SOURCES = dummy-c.c
>>   endif
>> -
>> -# Provide compatibility with scripts for the old Mesa build system for
>> -# a while by putting a link to the driver into /lib of the build tree.
>> -all-local: libomx_r600.la
>> -$(MKDIR_P) $(top_builddir)/$(LIB_DIR)/gallium
>> -ln -f .libs/libomx_r600.so* $(top_builddir)/$(LIB_DIR)/gallium/
>> diff --git a/src/gallium/targets/r600/vdpau/Makefile.am
>> b/src/gallium/targets/r600/vdpau/Makefile.am
>> index 509b954..f4ecfcc 100644
>> --- a/src/gallium/targets/r600/vdpau/Makefile.am
>> +++ b/src/gallium/targets/r600/vdpau/Makefile.am
>> @@ -51,9 +51,3 @@ if HAVE_MESA_LLVM
>>   libvdpau_r600_la_LDFLAGS += $(LLVM_LDFLAGS)
>>   libvdpau_r600_la_LIBADD += $(LLVM_LIBS)
>>   endif
>> -
>> -# Provide compatibility with scripts for the old Mesa build system for
>> -# a while by putting a link to the driver into /lib of the build tree.
>> -all-local: libvdpau_r600.la
>> -$(MKDIR_P) $(top_builddir)/$(LIB_DIR)/gallium
>> -ln -f .libs/libvdpau_r600.so* $(top_builddir)/$(LIB_DIR)/gallium/
>> diff --git a/src/gallium/targets/r600/xvmc/Makefile.am
>> b/src/gallium/targets/r600/xvmc/Makefile.am
>> index 7fe9b1a..6e71ffa 100644
>> --- a/src/gallium/targets/r600/xvmc/Makefile.am
>> +++ b/src/gallium/targets/r600/xvmc/Makefile.am
>> @@ -54,9 +54,3 @@ libXvMCr600_la_LINK = $(LINK) $(libXvMCr600_la_LDFLAGS)
>>   # Mention a dummy pure C file to trigger generation of the $(LINK)
>> variable
>>   nodist_EXTRA_libXvMCr600_la_SOURCES = dummy-c.c
>>   endif
>> -
>> -# Provide compatibility with scripts for the old Mesa build system for
>> -# a while by putting a link to the driver into /lib of the build tree.
>> -all-local: libXvMCr600.la
>> -$(MKDIR_P) $(top_builddir)/$(LIB_DIR)/gallium
>> -ln -f .libs/libXvMCr600.so* $(top_builddir)/$(LIB_DIR)/gallium/
>> diff --git a/src/gallium/targets/radeonsi/omx/Makefile.am
>> b/src/gallium/targets/radeonsi/omx/Makefile.am
>> index 0d47912..14e9dbb 100644
>> --- a/src/gallium/targets/radeonsi/omx/Makefile.am
>> +++ b/src/gallium/targets/radeonsi/omx/Makefile.am
>> @@ -65,9 +65,3 @@ nodist_EXTRA_libomx_radeonsi_la_SOURCES = dummy-cpp.cpp
>>   libomx_radeonsi_la_LDFLAGS += $(LLVM_LDFLAGS)
>>   libomx_radeonsi_la_LIBADD += $(LLVM_LIBS)
>>   endif
>> -
>> -# Provide compatibility with scripts for the old Mesa build system for
>> -# a while by putting a link to the driver into /lib of the build tree.
>> -all-local: libomx_radeonsi.la
>> -$(MKDIR_P) $(top_builddir)/$(LIB_DIR)/gallium
>> -ln -f .libs/libomx_radeonsi.so* $(top_builddir)/$(LIB_DIR)/gallium/
>> diff --git a/src/gallium/targets/radeonsi/vdpau/Makefile.am
>> b/src/gallium/targets/radeonsi/vdpau/Makefile.am
>> index 54d65b3..1d56bb3 100644
>> --- a/src/gallium/targets/radeonsi/vdpau/Makefile.am
>> +++ b/src/gallium/targets/radeonsi/vdpau/Makefile.am
>> @@ -48,9 +48,3 @@ if HAVE_MESA_LLVM
>>   libvdpau_radeonsi_la_LDFLAGS += $(LLVM_LDFLAGS)
>>   libvdpau_radeonsi_la_LIBADD += $(LLVM_LIBS)
>>   endif
>> -
>> -# Provide compatibility with scripts for the old Mesa build system for
>> -# a while by putting a link to the driver into /lib of the build tree.
>> -all-local: libvdpau_radeonsi.la
>> -$(MKDIR_P) $(top_builddir)/$(LIB_DIR)/gallium
>> -ln -f .libs/libvdpau_radeonsi.so*
>> $(top_builddir)/$(LIB_DIR)/gallium/
>> diff --git a/src/gallium/targets/vdpau-nouveau/Makefile.am
>> b/src/gallium/targets/vdpau-nouve

Re: [Mesa-dev] [PATCH v3] radeon: Use upload manager for buffer downloads

2014-03-05 Thread Marek Olšák
Thanks. I'm going to push this shortly.

Marek

On Wed, Mar 5, 2014 at 9:05 AM, Niels Ole Salscheider
 wrote:
> Using DMA for reads is much faster.
>
> Signed-off-by: Niels Ole Salscheider 
> ---
>  src/gallium/drivers/radeon/r600_buffer_common.c | 74 
> +++--
>  1 file changed, 56 insertions(+), 18 deletions(-)
>
> diff --git a/src/gallium/drivers/radeon/r600_buffer_common.c 
> b/src/gallium/drivers/radeon/r600_buffer_common.c
> index 340ebb2..90ca8cb 100644
> --- a/src/gallium/drivers/radeon/r600_buffer_common.c
> +++ b/src/gallium/drivers/radeon/r600_buffer_common.c
> @@ -260,6 +260,42 @@ static void *r600_buffer_transfer_map(struct 
> pipe_context *ctx,
> /* At this point, the buffer is always idle (we checked it 
> above). */
> usage |= PIPE_TRANSFER_UNSYNCHRONIZED;
> }
> +   /* Using DMA for larger reads is much faster */
> +   else if ((usage & PIPE_TRANSFER_READ) &&
> +!(usage & PIPE_TRANSFER_WRITE) &&
> +(rbuffer->domains == RADEON_DOMAIN_VRAM)) {
> +   unsigned offset;
> +   struct r600_resource *staging = NULL;
> +
> +   u_upload_alloc(rctx->uploader, 0,
> +  box->width + (box->x % 
> R600_MAP_BUFFER_ALIGNMENT),
> +  &offset, (struct pipe_resource**)&staging, 
> (void**)&data);
> +
> +   if (staging) {
> +   data += box->x % R600_MAP_BUFFER_ALIGNMENT;
> +
> +   /* Copy the staging buffer into the original one. */
> +   if (rctx->dma_copy(ctx, (struct 
> pipe_resource*)staging, 0,
> +box->x % 
> R600_MAP_BUFFER_ALIGNMENT,
> +0, 0, resource, level, box)) 
> {
> +   rctx->rings.gfx.flush(rctx, 0);
> +   if (rctx->rings.dma.cs)
> +   rctx->rings.dma.flush(rctx, 0);
> +
> +   /* Wait for any offloaded CS flush to complete
> +* to avoid busy-waiting in the winsys. */
> +   rctx->ws->cs_sync_flush(rctx->rings.gfx.cs);
> +   if (rctx->rings.dma.cs)
> +   
> rctx->ws->cs_sync_flush(rctx->rings.dma.cs);
> +
> +   rctx->ws->buffer_wait(staging->buf, 
> RADEON_USAGE_WRITE);
> +   return r600_buffer_get_transfer(ctx, 
> resource, level, usage, box,
> +   ptransfer, 
> data, staging, offset);
> +   } else {
> +   pipe_resource_reference((struct 
> pipe_resource**)&staging, NULL);
> +   }
> +   }
> +   }
>
> data = r600_buffer_map_sync_with_rings(rctx, rbuffer, usage);
> if (!data) {
> @@ -279,24 +315,26 @@ static void r600_buffer_transfer_unmap(struct 
> pipe_context *ctx,
> struct r600_resource *rbuffer = r600_resource(transfer->resource);
>
> if (rtransfer->staging) {
> -   struct pipe_resource *dst, *src;
> -   unsigned soffset, doffset, size;
> -   struct pipe_box box;
> -
> -   dst = transfer->resource;
> -   src = &rtransfer->staging->b.b;
> -   size = transfer->box.width;
> -   doffset = transfer->box.x;
> -   soffset = rtransfer->offset + transfer->box.x % 
> R600_MAP_BUFFER_ALIGNMENT;
> -
> -   u_box_1d(soffset, size, &box);
> -
> -   /* Copy the staging buffer into the original one. */
> -   if (!(size % 4) && !(doffset % 4) && !(soffset % 4) &&
> -   rctx->dma_copy(ctx, dst, 0, doffset, 0, 0, src, 0, &box)) 
> {
> -   /* DONE. */
> -   } else {
> -   ctx->resource_copy_region(ctx, dst, 0, doffset, 0, 0, 
> src, 0, &box);
> +   if (rtransfer->transfer.usage & PIPE_TRANSFER_WRITE) {
> +   struct pipe_resource *dst, *src;
> +   unsigned soffset, doffset, size;
> +   struct pipe_box box;
> +
> +   dst = transfer->resource;
> +   src = &rtransfer->staging->b.b;
> +   size = transfer->box.width;
> +   doffset = transfer->box.x;
> +   soffset = rtransfer->offset + transfer->box.x % 
> R600_MAP_BUFFER_ALIGNMENT;
> +
> +   u_box_1d(soffset, size, &box);
> +
> +   /* Copy the staging buffer into the original one. */
> +   if (!(size % 4) && !(doffset % 4) && !(soffset % 4) &&
> +   rctx->dma_copy(ctx, dst, 0, doffset, 0, 0, src, 
> 0, &box))

[Mesa-dev] [PATCH] automake: make clean the correct git_sha1.h.tmp

2014-03-05 Thread Emil Velikov
When building out of tree, the file ends up dangling which
may result in a binary with the old git sha.

Signed-off-by: Emil Velikov 
---
 src/mesa/Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/Makefile.am b/src/mesa/Makefile.am
index ffe6599..16ac148 100644
--- a/src/mesa/Makefile.am
+++ b/src/mesa/Makefile.am
@@ -70,7 +70,7 @@ BUILT_SOURCES = \
 CLEANFILES = \
$(BUILT_SOURCES) \
$(BUILDDIR)program/program_parse.tab.h \
-   git_sha1.h.tmp
+   $(BUILDDIR)main/git_sha1.h.tmp
 
 GET_HASH_GEN = main/get_hash_generator.py
 
-- 
1.9.0

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


[Mesa-dev] [Bug 75797] New: EGL application crashes with BadDrawable at SwapBuffers

2014-03-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=75797

  Priority: medium
Bug ID: 75797
  Assignee: mesa-dev@lists.freedesktop.org
   Summary: EGL application crashes with BadDrawable at
SwapBuffers
  Severity: normal
Classification: Unclassified
OS: All
  Reporter: scampa.giova...@gmail.com
  Hardware: Other
Status: NEW
   Version: unspecified
 Component: EGL
   Product: Mesa

Created attachment 95167
  --> https://bugs.freedesktop.org/attachment.cgi?id=95167&action=edit
Test case

If you create two X windows, make one EGL context current to the first one and
then to the second one, then clear and swap the second one, you will get an X
error at swap buffers time.

After debugging, I found that the glClear is optimized away because the
gl_framebuffer has Width and Height == 0, despite the glViewport call that
invalidated the drawable. Thus intel_prepare_render() is never reached (the
viewport is already initialized in the second MakeCurrent call) and we never
query X for the DRI2 buffers for the second window.

X logs include
[107772.804] (EE) intel(0): [DRI2] DRI2SwapBuffers: drawable has no back or
front?


Test case attached. This is 100% reproducible here.

Mesa is befbda56a246f77797bdf13fc005353441db2879, from Feb 22, master branch.
Driver is i965 DRI, on a GM45 card.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/2] glapi: replace 'user' with 'context' in u_current.[ch] code

2014-03-05 Thread Brian Paul
To make the functions more understandable.
---
 src/mapi/glapi/glapi.c |2 +-
 src/mapi/mapi_glapi.c  |2 +-
 src/mapi/u_current.c   |   32 
 src/mapi/u_current.h   |   20 ++--
 4 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/src/mapi/glapi/glapi.c b/src/mapi/glapi/glapi.c
index 3a0b638..231bdad 100644
--- a/src/mapi/glapi/glapi.c
+++ b/src/mapi/glapi/glapi.c
@@ -54,7 +54,7 @@ _glapi_check_multithread(void)
 void
 _glapi_set_context(void *context)
 {
-   u_current_set_user((const void *) context);
+   u_current_set_context((const void *) context);
 }
 
 void
diff --git a/src/mapi/mapi_glapi.c b/src/mapi/mapi_glapi.c
index 925caf3..d345f2a 100644
--- a/src/mapi/mapi_glapi.c
+++ b/src/mapi/mapi_glapi.c
@@ -58,7 +58,7 @@ _glapi_check_multithread(void)
 void
 _glapi_set_context(void *context)
 {
-   u_current_set_user((const void *) context);
+   u_current_set_context((const void *) context);
 }
 
 void
diff --git a/src/mapi/u_current.c b/src/mapi/u_current.c
index 0721338..72190fe 100644
--- a/src/mapi/u_current.c
+++ b/src/mapi/u_current.c
@@ -103,18 +103,18 @@ __thread struct mapi_table *u_current_table
 __attribute__((tls_model("initial-exec")))
 = (struct mapi_table *) table_noop_array;
 
-__thread void *u_current_user
+__thread void *u_current_context
 __attribute__((tls_model("initial-exec")));
 
 #else
 
 struct mapi_table *u_current_table =
(struct mapi_table *) table_noop_array;
-void *u_current_user;
+void *u_current_context;
 
 #ifdef THREADS
 struct u_tsd u_current_table_tsd;
-static struct u_tsd u_current_user_tsd;
+static struct u_tsd u_current_context_tsd;
 static int ThreadSafe;
 #endif /* THREADS */
 
@@ -127,7 +127,7 @@ u_current_destroy(void)
 {
 #if defined(THREADS) && defined(_WIN32)
u_tsd_destroy(&u_current_table_tsd);
-   u_tsd_destroy(&u_current_user_tsd);
+   u_tsd_destroy(&u_current_context_tsd);
 #endif
 }
 
@@ -138,7 +138,7 @@ static void
 u_current_init_tsd(void)
 {
u_tsd_init(&u_current_table_tsd);
-   u_tsd_init(&u_current_user_tsd);
+   u_tsd_init(&u_current_context_tsd);
 }
 
 /**
@@ -169,7 +169,7 @@ u_current_init(void)
else if (knownID != u_thread_self()) {
   ThreadSafe = 1;
   u_current_set(NULL);
-  u_current_set_user(NULL);
+  u_current_set_context(NULL);
}
u_mutex_unlock(ThreadCheckMutex);
 }
@@ -191,17 +191,17 @@ u_current_init(void)
  * void from the real context pointer type.
  */
 void
-u_current_set_user(const void *ptr)
+u_current_set_context(const void *ptr)
 {
u_current_init();
 
 #if defined(GLX_USE_TLS)
-   u_current_user = (void *) ptr;
+   u_current_context = (void *) ptr;
 #elif defined(THREADS)
-   u_tsd_set(&u_current_user_tsd, (void *) ptr);
-   u_current_user = (ThreadSafe) ? NULL : (void *) ptr;
+   u_tsd_set(&u_current_context_tsd, (void *) ptr);
+   u_current_context = (ThreadSafe) ? NULL : (void *) ptr;
 #else
-   u_current_user = (void *) ptr;
+   u_current_context = (void *) ptr;
 #endif
 }
 
@@ -211,16 +211,16 @@ u_current_set_user(const void *ptr)
  * void to the real context pointer type.
  */
 void *
-u_current_get_user_internal(void)
+u_current_get_context_internal(void)
 {
 #if defined(GLX_USE_TLS)
-   return u_current_user;
+   return u_current_context;
 #elif defined(THREADS)
return (ThreadSafe)
-  ? u_tsd_get(&u_current_user_tsd)
-  : u_current_user;
+  ? u_tsd_get(&u_current_context_tsd)
+  : u_current_context;
 #else
-   return u_current_user;
+   return u_current_context;
 #endif
 }
 
diff --git a/src/mapi/u_current.h b/src/mapi/u_current.h
index f9cffd8..6709af2 100644
--- a/src/mapi/u_current.h
+++ b/src/mapi/u_current.h
@@ -11,14 +11,14 @@
 
 #ifdef GLX_USE_TLS
 #define u_current_table _glapi_tls_Dispatch
-#define u_current_user _glapi_tls_Context
+#define u_current_context _glapi_tls_Context
 #else
 #define u_current_table _glapi_Dispatch
-#define u_current_user _glapi_Context
+#define u_current_context _glapi_Context
 #endif
 
 #define u_current_get_internal _glapi_get_dispatch
-#define u_current_get_user_internal _glapi_get_context
+#define u_current_get_context_internal _glapi_get_context
 
 #define u_current_table_tsd _gl_DispatchTSD
 
@@ -33,13 +33,13 @@ struct mapi_table;
 extern __thread struct mapi_table *u_current_table
 __attribute__((tls_model("initial-exec")));
 
-extern __thread void *u_current_user
+extern __thread void *u_current_context
 __attribute__((tls_model("initial-exec")));
 
 #else /* GLX_USE_TLS */
 
 extern struct mapi_table *u_current_table;
-extern void *u_current_user;
+extern void *u_current_context;
 
 #endif /* GLX_USE_TLS */
 
@@ -58,10 +58,10 @@ struct mapi_table *
 u_current_get_internal(void);
 
 void
-u_current_set_user(const void *ptr);
+u_current_set_context(const void *ptr);
 
 void *
-u_current_get_user_internal(void);
+u_current_get_context_internal(void);
 
 static INLINE const struct mapi_table *
 u_current_get(void)
@@ -75,12 +75,12 @@

[Mesa-dev] [PATCH 2/2] glapi: rename u_current dispatch table functions

2014-03-05 Thread Brian Paul
Put "table" in the names to make things more understandable.
---
 src/mapi/entry.c   |4 ++--
 src/mapi/glapi/glapi.c |2 +-
 src/mapi/mapi.c|2 +-
 src/mapi/mapi_glapi.c  |2 +-
 src/mapi/u_current.c   |6 +++---
 src/mapi/u_current.h   |   10 +-
 6 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/mapi/entry.c b/src/mapi/entry.c
index 128f011..b6e8db2 100644
--- a/src/mapi/entry.c
+++ b/src/mapi/entry.c
@@ -36,7 +36,7 @@
 #ifdef MAPI_MODE_BRIDGE
 #define ENTRY_CURRENT_TABLE_GET "_glapi_get_dispatch"
 #else
-#define ENTRY_CURRENT_TABLE_GET U_STRINGIFY(u_current_get_internal)
+#define ENTRY_CURRENT_TABLE_GET U_STRINGIFY(u_current_get_table_internal)
 #endif
 
 #if defined(USE_X86_ASM) && defined(__GNUC__)
@@ -57,7 +57,7 @@ entry_current_get(void)
 #ifdef MAPI_MODE_BRIDGE
return GET_DISPATCH();
 #else
-   return u_current_get();
+   return u_current_get_table();
 #endif
 }
 
diff --git a/src/mapi/glapi/glapi.c b/src/mapi/glapi/glapi.c
index 231bdad..194b9ee 100644
--- a/src/mapi/glapi/glapi.c
+++ b/src/mapi/glapi/glapi.c
@@ -60,5 +60,5 @@ _glapi_set_context(void *context)
 void
 _glapi_set_dispatch(struct _glapi_table *dispatch)
 {
-   u_current_set((const struct mapi_table *) dispatch);
+   u_current_set_table((const struct mapi_table *) dispatch);
 }
diff --git a/src/mapi/mapi.c b/src/mapi/mapi.c
index 56f209b..6f1b35f 100644
--- a/src/mapi/mapi.c
+++ b/src/mapi/mapi.c
@@ -186,5 +186,5 @@ mapi_table_fill(struct mapi_table *tbl, const mapi_proc 
*procs)
 void
 mapi_table_make_current(const struct mapi_table *tbl)
 {
-   u_current_set(tbl);
+   u_current_set_table(tbl);
 }
diff --git a/src/mapi/mapi_glapi.c b/src/mapi/mapi_glapi.c
index d345f2a..7b0903b 100644
--- a/src/mapi/mapi_glapi.c
+++ b/src/mapi/mapi_glapi.c
@@ -64,7 +64,7 @@ _glapi_set_context(void *context)
 void
 _glapi_set_dispatch(struct _glapi_table *dispatch)
 {
-   u_current_set((const struct mapi_table *) dispatch);
+   u_current_set_table((const struct mapi_table *) dispatch);
 }
 
 /**
diff --git a/src/mapi/u_current.c b/src/mapi/u_current.c
index 72190fe..76dae91 100644
--- a/src/mapi/u_current.c
+++ b/src/mapi/u_current.c
@@ -168,7 +168,7 @@ u_current_init(void)
}
else if (knownID != u_thread_self()) {
   ThreadSafe = 1;
-  u_current_set(NULL);
+  u_current_set_table(NULL);
   u_current_set_context(NULL);
}
u_mutex_unlock(ThreadCheckMutex);
@@ -230,7 +230,7 @@ u_current_get_context_internal(void)
  * table (__glapi_noop_table).
  */
 void
-u_current_set(const struct mapi_table *tbl)
+u_current_set_table(const struct mapi_table *tbl)
 {
u_current_init();
 
@@ -253,7 +253,7 @@ u_current_set(const struct mapi_table *tbl)
  * Return pointer to current dispatch table for calling thread.
  */
 struct mapi_table *
-u_current_get_internal(void)
+u_current_get_table_internal(void)
 {
 #if defined(GLX_USE_TLS)
return u_current_table;
diff --git a/src/mapi/u_current.h b/src/mapi/u_current.h
index 6709af2..72708d4 100644
--- a/src/mapi/u_current.h
+++ b/src/mapi/u_current.h
@@ -17,7 +17,7 @@
 #define u_current_context _glapi_Context
 #endif
 
-#define u_current_get_internal _glapi_get_dispatch
+#define u_current_get_table_internal _glapi_get_dispatch
 #define u_current_get_context_internal _glapi_get_context
 
 #define u_current_table_tsd _gl_DispatchTSD
@@ -52,10 +52,10 @@ void
 u_current_destroy(void);
 
 void
-u_current_set(const struct mapi_table *tbl);
+u_current_set_table(const struct mapi_table *tbl);
 
 struct mapi_table *
-u_current_get_internal(void);
+u_current_get_table_internal(void);
 
 void
 u_current_set_context(const void *ptr);
@@ -64,13 +64,13 @@ void *
 u_current_get_context_internal(void);
 
 static INLINE const struct mapi_table *
-u_current_get(void)
+u_current_get_table(void)
 {
 #ifdef GLX_USE_TLS
return u_current_table;
 #else
return (likely(u_current_table) ?
- u_current_table : u_current_get_internal());
+ u_current_table : u_current_get_table_internal());
 #endif
 }
 
-- 
1.7.10.4

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


[Mesa-dev] [Bug 70410] egl-static/Makefile: linking fails with llvm >= 3.4

2014-03-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=70410

--- Comment #20 from Laurent carlier  ---
Patch increase size a lot. Linking failure is fixed when enable-shared-llvm
option isn't enabled. Something is weird somewhere

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] mesa: remove remaining uses of _glthread_GetID()

2014-03-05 Thread Jose Fonseca


- Original Message -
> It was really only used in the radeon driver for a debug printf.
> And evidently, libGL.so referenced it just to work around some sort
> of linker issue.
> 
> This patch removes the two calls to the function and the function
> itself.
> 
> Fixes undefined _glthread_GetID symbol in libGL reported by 'nm'.
> Though, the missing symbol doesn't cause any issues on my system but
> it does cause glxinfo to fail on one of our test systems.
> ---
>  src/glx/glxcurrent.c |   10 --
>  src/mapi/glapi/glapi.h   |4 
>  src/mapi/mapi_glapi.c|6 --
>  src/mapi/u_thread.h  |4 ++--
>  src/mesa/drivers/dri/common/dri_test.c   |6 --
>  src/mesa/drivers/dri/radeon/radeon_fbo.c |3 +--
>  6 files changed, 3 insertions(+), 30 deletions(-)
> 
> diff --git a/src/glx/glxcurrent.c b/src/glx/glxcurrent.c
> index a6884cf..2e5111b 100644
> --- a/src/glx/glxcurrent.c
> +++ b/src/glx/glxcurrent.c
> @@ -213,16 +213,6 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
> struct glx_context *gc = (struct glx_context *) gc_user;
> struct glx_context *oldGC = __glXGetCurrentContext();
>  
> -   /* XXX: If this is left out, then libGL ends up not having this
> -* symbol, and drivers using it fail to load.  Compare the
> -* implementation of this symbol to _glapi_noop_enable_warnings(),
> -* though, which gets into the library despite no callers, the same
> -* prototypes, and the same compile flags to the files containing
> -* them.  Moving the definition to glapi_nop.c gets it into the
> -* library, though.
> -*/
> -   (void)_glthread_GetID();
> -
> /* Make sure that the new context has a nonzero ID.  In the request,
>  * a zero context ID is used only to mean that we bind to no current
>  * context.
> diff --git a/src/mapi/glapi/glapi.h b/src/mapi/glapi/glapi.h
> index dcf91a7..7c22985 100644
> --- a/src/mapi/glapi/glapi.h
> +++ b/src/mapi/glapi/glapi.h
> @@ -168,10 +168,6 @@ _GLAPI_EXPORT struct _glapi_table *
>  _glapi_create_table_from_handle(void *handle, const char *symbol_prefix);
>  
>  
> -_GLAPI_EXPORT unsigned long
> -_glthread_GetID(void);
> -
> -
>  /*
>   * These stubs are kept so that the old DRI drivers still load.
>   */
> diff --git a/src/mapi/mapi_glapi.c b/src/mapi/mapi_glapi.c
> index 7b9f1ae..925caf3 100644
> --- a/src/mapi/mapi_glapi.c
> +++ b/src/mapi/mapi_glapi.c
> @@ -222,12 +222,6 @@ _glapi_get_proc_name(unsigned int offset)
> return stub ? stub_get_name(stub) : NULL;
>  }
>  
> -unsigned long
> -_glthread_GetID(void)
> -{
> -   return u_thread_self();
> -}
> -
>  void
>  _glapi_noop_enable_warnings(unsigned char enable)
>  {
> diff --git a/src/mapi/u_thread.h b/src/mapi/u_thread.h
> index 3e18358..0fc9392 100644
> --- a/src/mapi/u_thread.h
> +++ b/src/mapi/u_thread.h
> @@ -101,8 +101,8 @@ u_thread_self(void)
>  * So for now, we side-step this mess and use Windows thread primitives
>  * directly here.
>  *
> -* FIXME: On the other hand, u_thread_self() and _glthread_GetID() are
> bad
> -* abstractions.  Even with pthreads, there is no guarantee that
> +* FIXME: On the other hand, u_thread_self() is a bad
> +* abstraction.  Even with pthreads, there is no guarantee that
>  * pthread_self() will return numeric IDs -- we should be using
>  * pthread_equal() instead of assuming we can compare thread ids...
>  */
> diff --git a/src/mesa/drivers/dri/common/dri_test.c
> b/src/mesa/drivers/dri/common/dri_test.c
> index 3573285..7ab50d9 100644
> --- a/src/mesa/drivers/dri/common/dri_test.c
> +++ b/src/mesa/drivers/dri/common/dri_test.c
> @@ -76,12 +76,6 @@ _glapi_get_dispatch_table_size(void)
>   return 0;
>  }
>  
> -PUBLIC unsigned long
> -_glthread_GetID(void)
> -{
> -   return 0;
> -}
> -
>  #ifndef NO_MAIN
>  int main(int argc, char** argv)
>  {
> diff --git a/src/mesa/drivers/dri/radeon/radeon_fbo.c
> b/src/mesa/drivers/dri/radeon/radeon_fbo.c
> index 537ab49..12ad438 100644
> --- a/src/mesa/drivers/dri/radeon/radeon_fbo.c
> +++ b/src/mesa/drivers/dri/radeon/radeon_fbo.c
> @@ -783,8 +783,7 @@ radeon_render_texture(struct gl_context * ctx,
> return;
> }
>  
> -   DBG("Begin render texture tid %lx tex=%u w=%d h=%d refcount=%d\n",
> -   _glthread_GetID(),
> +   DBG("Begin render texture tex=%u w=%d h=%d refcount=%d\n",
> att->Texture->Name, newImage->Width, newImage->Height,
> rb->RefCount);
>  
> --
> 1.7.10.4
> 

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


[Mesa-dev] [PATCH] mesa: fix unpack_ubyte_ARGB4444_REV()

2014-03-05 Thread Brian Paul
This was overlooked in 7cc9df4b8a1c.  Spotted by Chia-I Wu.
---
 src/mesa/main/format_unpack.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
index d8bf57d..f9c42e7 100644
--- a/src/mesa/main/format_unpack.c
+++ b/src/mesa/main/format_unpack.c
@@ -2738,10 +2738,10 @@ unpack_ubyte_ARGB_REV(const void *src, GLubyte 
dst[][4], GLuint n)
const GLushort *s = ((const GLushort *) src);
GLuint i;
for (i = 0; i < n; i++) {
-  dst[i][RCOMP] = EXPAND_4_8((s[i]  ) & 0xf);
-  dst[i][GCOMP] = EXPAND_4_8((s[i] >> 12) & 0xf);
-  dst[i][BCOMP] = EXPAND_4_8((s[i] >>  8) & 0xf);
-  dst[i][ACOMP] = EXPAND_4_8((s[i] >>  4) & 0xf);
+  dst[i][RCOMP] = EXPAND_4_8((s[i] >>  4) & 0xf);
+  dst[i][GCOMP] = EXPAND_4_8((s[i] >>  8) & 0xf);
+  dst[i][BCOMP] = EXPAND_4_8((s[i] >> 12) & 0xf);
+  dst[i][ACOMP] = EXPAND_4_8((s[i]  ) & 0xf);
}
 }
 
-- 
1.7.10.4

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


Re: [Mesa-dev] [PATCH] mesa: fix packing/unpacking for MESA_FORMAT_A4R4G4B4_UNORM

2014-03-05 Thread Brian Paul

On 03/04/2014 08:17 PM, Chia-I Wu wrote:

On Wed, Mar 5, 2014 at 12:10 AM, Brian Paul  wrote:

Spotted by Chia-I Wu.

unpack_ubyte_ARGB_REV() needs the same care too.  With that fixed,
this patch is

Reviewed-by: Chia-I Wu 


I missed that function in the original patch.  Follow-up patch posted...

Thanks.

-Brian


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


Re: [Mesa-dev] [PATCH] mesa: fix packing/unpacking for MESA_FORMAT_A4R4G4B4_UNORM

2014-03-05 Thread Brian Paul

On 03/05/2014 09:02 AM, Brian Paul wrote:

On 03/04/2014 08:17 PM, Chia-I Wu wrote:

On Wed, Mar 5, 2014 at 12:10 AM, Brian Paul  wrote:

Spotted by Chia-I Wu.

unpack_ubyte_ARGB_REV() needs the same care too.  With that fixed,
this patch is

Reviewed-by: Chia-I Wu 


I missed that function in the original patch.  Follow-up patch posted...


I guess I didn't push the original patch yet so I'll squash the two 
patches before pushing.


-Brian


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


[Mesa-dev] Overflow of intel vertex buffer

2014-03-05 Thread Hodek, Roman
Hello all!

While debugging an application crash, we found a problem in mesa i915 buffer
allocation, and we think we at least have a workaround for this.

In more detail, the vertex buffers used in src/mesa/drivers/dri/i915/*.c, which
are pointed to by intel->prim.vb, usually have a size of INTEL_VB_SIZE
(alloc'ed by intel_get_prim_space() in intel_tris.c). And
intel->prim.current_offset is the offset where next data will be written.

Shortly before the crash we're hunting, we see in the debugger that
'current_offset' is greater than INTEL_VB_SIZE. Soon afterwards, some data
after the buffer are overwritten, and something else segfaults.

We can not say yet why 'current_offset' is wrong, but we suspect the alignments
like

  intel->prim.current_offset = intel->prim.start_offset =
ALIGN(intel->prim.start_offset, 128);

in e.g. intel_flush_prim() could be the cause. (Any better ideas on this?)

Anyway, to work around the most obvious problem, we modified the function
intel_get_current_max() in intel_render.c (patch below) to check for an
overflow, and reserve some space at the end, just to be sure. This at least
avoids the crashes we observe, and generally seems to increase robustness at
this spot.

Nevertheless it would be interesting what the root cause of the problem is...
any hints?

Roman


PS: please keep me in Cc:, I'm non subscribed to this list; thanks!



diff -u -ur mesa-10.0.3/src/mesa/drivers/dri/i915/intel_render.c
mesa-10.0.3-fix/src/mesa/drivers/dri/i915/intel_render.c
--- mesa-10.0.3/src/mesa/drivers/dri/i915/intel_render.c2014-02-03
18:42:39.0 +0100
+++ mesa-10.0.3-fix/src/mesa/drivers/dri/i915/intel_render.c2014-03-05
09:53:10.534481511 +0100
@@ -140,10 +140,16 @@
if (intel->intelScreen->no_vbo) {
   ret = intel_batchbuffer_space(intel);
   ret = ret <= INTEL_NO_VBO_STATE_RESERVED ? 0 : ret -
INTEL_NO_VBO_STATE_RESERVED;
-   } else
-  ret = (INTEL_VB_SIZE - intel->prim.current_offset);
-
-   return ret / (intel->vertex_size * 4);
+   } else {
+  if (INTEL_VB_SIZE > intel->prim.current_offset)
+ ret = (INTEL_VB_SIZE - intel->prim.current_offset);
+  else
+ ret = 0;
+   }
+   ret /= (intel->vertex_size * 4);
+   if (ret > 4)
+  ret -= 4; // don't fill buffer to the end!
+   return ret;
 }

 #define LOCAL_VARS struct intel_context *intel = intel_context(ctx)
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] nv50, nvc0: choose storage type after ms has been initialized

2014-03-05 Thread Ilia Mirkin
On Wed, Mar 5, 2014 at 5:37 AM, Ilia Mirkin  wrote:
> Signed-off-by: Ilia Mirkin 
> ---
>
> Noticed by inspection, untested. Would be interesting to see if this fixes
> anything.

I noticed that the nvc0 bit is bogus -- mt->ms_x/y aren't used to
determine ms there (it does log2(samples) directly). Emil tested this
out on nv96, and it looks like it started throwing a
RT_STORAGE_TYPE_MISMATCH trap for a few tests. I'll investigate... but
as is, we're always using the *_MS1 storage type on nv50+.

Withdrawn for now.

>
>  src/gallium/drivers/nouveau/nv50/nv50_miptree.c | 4 ++--
>  src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c | 4 ++--
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c 
> b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c
> index 513d8f9..6c6ef4e 100644
> --- a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c
> +++ b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c
> @@ -329,13 +329,13 @@ nv50_miptree_create(struct pipe_screen *pscreen,
> if (pt->bind & PIPE_BIND_LINEAR)
>pt->flags |= NOUVEAU_RESOURCE_FLAG_LINEAR;
>
> -   bo_config.nv50.memtype = nv50_mt_choose_storage_type(mt, TRUE);
> -
> if (!nv50_miptree_init_ms_mode(mt)) {
>FREE(mt);
>return NULL;
> }
>
> +   bo_config.nv50.memtype = nv50_mt_choose_storage_type(mt, TRUE);
> +
> if (unlikely(pt->flags & NV50_RESOURCE_FLAG_VIDEO)) {
>nv50_miptree_init_layout_video(mt);
>if (pt->flags & NV50_RESOURCE_FLAG_NOALLOC) {
> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c 
> b/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c
> index 79c9390..59b9028 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c
> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c
> @@ -277,13 +277,13 @@ nvc0_miptree_create(struct pipe_screen *pscreen,
> if (pt->bind & PIPE_BIND_LINEAR)
>pt->flags |= NOUVEAU_RESOURCE_FLAG_LINEAR;
>
> -   bo_config.nvc0.memtype = nvc0_mt_choose_storage_type(mt, compressed);
> -
> if (!nvc0_miptree_init_ms_mode(mt)) {
>FREE(mt);
>return NULL;
> }
>
> +   bo_config.nvc0.memtype = nvc0_mt_choose_storage_type(mt, compressed);
> +
> if (unlikely(pt->flags & NVC0_RESOURCE_FLAG_VIDEO)) {
>nvc0_miptree_init_layout_video(mt);
> } else
> --
> 1.8.3.2
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 03/12] mesa/sso: replace Shader binding point with _Shader

2014-03-05 Thread Eric Anholt
Ian Romanick  writes:

> From: Gregory Hainaut 
>
> To avoid NULL pointer check a default pipeline object is installed in
> _Shader when no program is current
>
> The spec say that UseProgram/UseShaderProgramEXT/ActiveProgramEXT got an
> higher priority over the pipeline object. When default program is
> uninstall, the pipeline is used if any was bound.
>
> Note: A careful rename need to be done now...
>
> V2: formating improvement
>
> V3 (idr):
> * Build fix.  The original patch added calls to _mesa_use_shader_program with
>   4 parameters, but the fourth parameter isn't added to that function until a
>   much later patch.  Just drop that parameter for now.
> * Trivial reformatting.
> * Updated comment of gl_context::_Shader
>
> Reviewed-by: Ian Romanick 
> ---
>  src/mesa/main/mtypes.h  | 15 
>  src/mesa/main/pipelineobj.c |  8 
>  src/mesa/main/shaderapi.c   | 91 
> +++--
>  3 files changed, 111 insertions(+), 3 deletions(-)
>
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index d05649c..8a03afd 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -2824,6 +2824,9 @@ struct gl_pipeline_shader_state
> /** Currently bound pipeline object. See _mesa_BindProgramPipeline() */
> struct gl_pipeline_object *Current;
>  
> +   /* Default Object to ensure that _Shader is never NULL */
> +   struct gl_pipeline_object *Default;
> +
> /** Pipeline objects */
> struct _mesa_HashTable *Objects;
>  };
> @@ -4131,6 +4134,18 @@ struct gl_context
>  
> struct gl_pipeline_shader_state Pipeline; /**< GLSL pipeline shader 
> object state */
> struct gl_pipeline_object Shader; /**< GLSL shader object state */
> +
> +   /**
> +* Current active shader pipeline state
> +*
> +* Almost all internal users want ::_Shader instead of ::Shader.  The
> +* exceptions are bits of legacy GLSL API that do not know about separate
> +* shader objects.
> +*
> +* Points to ::Shader, ::Pipeline.Current, or ::Pipeline.Default.
> +*/
> +   struct gl_pipeline_object *_Shader;
> +
> struct gl_shader_compiler_options 
> ShaderCompilerOptions[MESA_SHADER_STAGES];
>  
> struct gl_query_state Query;  /**< occlusion, timer queries */
> diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
> index 27012df..849c781 100644
> --- a/src/mesa/main/pipelineobj.c
> +++ b/src/mesa/main/pipelineobj.c
> @@ -94,6 +94,10 @@ _mesa_init_pipeline(struct gl_context *ctx)
> ctx->Pipeline.Objects = _mesa_NewHashTable();
>  
> ctx->Pipeline.Current = NULL;
> +
> +   /* Install a default Pipeline */
> +   ctx->Pipeline.Default = _mesa_new_pipeline_object(ctx, 0);
> +   _mesa_reference_pipeline_object(ctx, &ctx->_Shader, 
> ctx->Pipeline.Default);
>  }
>  
>  
> @@ -117,6 +121,10 @@ _mesa_free_pipeline_data(struct gl_context *ctx)
>  {
> _mesa_HashDeleteAll(ctx->Pipeline.Objects, delete_pipelineobj_cb, ctx);
> _mesa_DeleteHashTable(ctx->Pipeline.Objects);
> +
> +   _mesa_reference_pipeline_object(ctx, &ctx->_Shader, NULL);
> +   _mesa_delete_pipeline_object(ctx, ctx->Pipeline.Default);
> +
>  }
>  
>  /**
> diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
> index 5060cbb..71b2ef5 100644
> --- a/src/mesa/main/shaderapi.c
> +++ b/src/mesa/main/shaderapi.c
> @@ -44,6 +44,7 @@
>  #include "main/hash.h"
>  #include "main/hash_table.h"
>  #include "main/mtypes.h"
> +#include "main/pipelineobj.h"
>  #include "main/shaderapi.h"
>  #include "main/shaderobj.h"
>  #include "main/transformfeedback.h"
> @@ -144,6 +145,8 @@ _mesa_free_shader_state(struct gl_context *ctx)
> _mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram, NULL);
>  
> /* Extended for ARB_separate_shader_objects */
> +   _mesa_reference_pipeline_object(ctx, &ctx->_Shader, NULL);
> +
> assert(ctx->Shader.RefCount == 1);
> mtx_destroy(&ctx->Shader.Mutex);
>  }
> @@ -1541,7 +1544,29 @@ _mesa_UseProgram(GLhandleARB program)
>shProg = NULL;
> }
>  
> -   _mesa_use_program(ctx, shProg);
> +   /*
> +* The executable code for an individual shader stage is taken from the
> +* current program for that stage.  If there is a current program object
> +* for any shader stage or for uniform updates established by UseProgram,
> +* UseShaderProgramEXT, or ActiveProgramEXT, the current program for that
> +* stage (if any) is considered current.  Otherwise, if there is a bound
> +* program pipeline object ...
> +*/

This is a spec citation, and it would be nice to see it formatted like
one in the 3 places it's quoted in the file.

> +   if (program) {
> +  /* Attach shader state to the binding point */
> +  _mesa_reference_pipeline_object(ctx, &ctx->_Shader, &ctx->Shader);
> +  /* Update the program */
> +  _mesa_use_program(ctx, shProg);
> +   } else {
> +  /* Must be done first: detach the progam */
> +  _mesa_use_program(ctx, shProg);
> +

Re: [Mesa-dev] [PATCH 07/12] mesa/sso: Implement _mesa_UseProgramStages

2014-03-05 Thread Eric Anholt
Ian Romanick  writes:

> From: Gregory Hainaut 
>
> Now arb_separate_shader_object-GetProgramPipelineiv should pass.
>
> V3 (idr):
> * Change spec references to core OpenGL versions instead of issues in
>   the extension spec.
> * Split out from previous uber patch.
>
> v4 (idr): Use _mesa_has_geometry_shaders in _mesa_UseProgramStages to
> detect availability of geometry shaders.
>
> Reviewed-by: Ian Romanick 
> ---
>  src/mesa/main/pipelineobj.c | 115 
> 
>  1 file changed, 115 insertions(+)
>
> diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
> index 849c781..7149578 100644
> --- a/src/mesa/main/pipelineobj.c
> +++ b/src/mesa/main/pipelineobj.c

> +   GLbitfield any_valid_stages = GL_VERTEX_SHADER_BIT | 
> GL_FRAGMENT_SHADER_BIT;
> +   if (_mesa_has_geometry_shaders(ctx))
> +  any_valid_stages |= GL_GEOMETRY_SHADER_BIT;
> +
> +   if (stages != GL_ALL_SHADER_BITS && (stages  & ~any_valid_stages) != 0) {

Weird double space before &.

> +  _mesa_error(ctx, GL_INVALID_VALUE, "glUseProgramStages(Stages)");
> +  return;
> +   }

> +   if (program) {
> +  /* Section 2.11.1 (Shader Objects) of the OpenGL 3.1 spec (and probably
> +   * earlier) says:
> +   *
> +   * "Commands that accept shader or program object names will
> +   * generate the error INVALID_VALUE if the provided name is not the
> +   * name of either a shader or program object and INVALID_OPERATION
> +   * if the provided name identifies an object that is not the
> +   * expected type."
> +   */
> +  struct gl_shader *sh = _mesa_lookup_shader(ctx, program);
> +  if (sh != NULL) {
> + _mesa_error(ctx, GL_INVALID_OPERATION,
> +   "glUseProgramStages(progam is a shader object)");
> + return;
> +  }

This block could get dropped into the shProg == NULL case below, right?
The code confused me as is.

> +
> +  shProg = _mesa_lookup_shader_program(ctx, program);
> +  if (shProg == NULL) {
> + _mesa_error(ctx, GL_INVALID_VALUE,
> +   "glUseProgramStages(progam is not a program object)");
> + return;
> +  }


> +   /* Section 2.11.4 (Program Pipeline Objects) of the OpenGL 4.1 spec
> +* says:
> +*
> +* "If UseProgramStages is called with program set to zero or with a
> +* program object that contains no executable code for the given
> +* stages, it is as if the pipeline object has no programmable stage
> +* configured for the indicated shader stages."
> +*/
> +   if ((stages & GL_VERTEX_SHADER_BIT) != 0)
> +  _mesa_use_shader_program(ctx, GL_VERTEX_SHADER, shProg, pipe);
> +
> +   if ((stages & GL_FRAGMENT_SHADER_BIT) != 0)
> +  _mesa_use_shader_program(ctx, GL_FRAGMENT_SHADER, shProg, pipe);
> +
> +   if ((stages & GL_GEOMETRY_SHADER_BIT) != 0)
> +  _mesa_use_shader_program(ctx, GL_GEOMETRY_SHADER, shProg, pipe);
>  }

The spec cite here doesn't seem to be explaining the code it's next to,
to me.


pgpQVqnX5dP4Y.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 03/12] mesa/sso: replace Shader binding point with _Shader

2014-03-05 Thread Eric Anholt
Ian Romanick  writes:

> From: Gregory Hainaut 
>
> To avoid NULL pointer check a default pipeline object is installed in
> _Shader when no program is current


> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index d05649c..8a03afd 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -2824,6 +2824,9 @@ struct gl_pipeline_shader_state
> /** Currently bound pipeline object. See _mesa_BindProgramPipeline() */
> struct gl_pipeline_object *Current;
>  
> +   /* Default Object to ensure that _Shader is never NULL */
> +   struct gl_pipeline_object *Default;
> +
> /** Pipeline objects */
> struct _mesa_HashTable *Objects;
>  };
> @@ -4131,6 +4134,18 @@ struct gl_context
>  
> struct gl_pipeline_shader_state Pipeline; /**< GLSL pipeline shader 
> object state */
> struct gl_pipeline_object Shader; /**< GLSL shader object state */
> +
> +   /**
> +* Current active shader pipeline state
> +*
> +* Almost all internal users want ::_Shader instead of ::Shader.  The
> +* exceptions are bits of legacy GLSL API that do not know about separate
> +* shader objects.
> +*
> +* Points to ::Shader, ::Pipeline.Current, or ::Pipeline.Default.
> +*/
> +   struct gl_pipeline_object *_Shader;
> +

Let's see if I followed:

It points to Shader when there is a GLSL shader program bound to any
stage, it points to Pipeline.Default when all stages are not bound to a
GLSL shader but no SSO pipeline is bound, and it points to
Pipeline.Current when there are no GLSL shader programs individually
bound, but there is a SSO pipeline bound.

Is that right?  If so, baking some of that into the comments here would
be really useful.


pgpTu8dPJg0iC.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 12/12] mesa/sso: Implement ValidateProgramPipeline

2014-03-05 Thread Eric Anholt
Ian Romanick  writes:

> From: Gregory Hainaut 
>
> Implementation note:
> I don't use context for ralloc (don't know how).
>
> The check on PROGRAM_SEPARABLE flags is also done when the pipeline
> isn't bound.  It doesn't make any sense in a DSA style API.
>
> Maybe we could replace _mesa_validate_program by
> _mesa_validate_program_pipeline.  For example we could recreate a dummy
> pipeline object.  However the new function checks also the
> TEXTURE_IMAGE_UNIT number not sure of the impact.
>
> V2:
> Fix memory leak with ralloc_strdup
> Formatting improvement
>
> V3 (idr):
> * Actually fix the leak of the InfoLog. :)
> * Directly generate logs in to gl_pipeline_object::InfoLog via
>   ralloc_asprintf isntead of using a temporary buffer.
> * Split out from previous uber patch.
> * Change spec references to include section numbers, etc.
> * Fix a bug in checking that a different program isn't active in a stage
>   between two stages that have the same program.  Specifically,
>
>  if (pipe->CurrentVertexProgram->Name == pipe->CurrentGeometryProgram->Name &&
>  pipe->CurrentGeometryProgram->Name != pipe->CurrentVertexProgram->Name)
>
> should have been
>
>  if (pipe->CurrentVertexProgram->Name == pipe->CurrentFragmentProgram->Name &&
>  pipe->CurrentGeometryProgram->Name != pipe->CurrentVertexProgram->Name)
>
> v4 (idr): Rework to use CurrentProgram array in loops.
>
> Reviewed-by: Ian Romanick 

> diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
> index 3db97c0..d371e88 100644
> --- a/src/mesa/main/pipelineobj.c
> +++ b/src/mesa/main/pipelineobj.c

> +   /* Section 2.11.11 (Shader Execution), subheading "Validation," of the
> +* OpenGL 4.1 spec says:
> +*
> +* "[INVALID_OPERATION] is generated by any command that transfers
> +* vertices to the GL if:
> +*
> +* ...
> +*
> +* - Any two active samplers in the current program object are of
> +*   different types, but refer to the same texture image unit.
> +*
> +* - The number of active samplers in the program exceeds the
> +*   maximum number of texture image units allowed."
> +*/
> +   if (!_mesa_sampler_uniforms_pipeline_are_valid(pipe))
> +  goto err;
> +
> +   pipe->Validated = GL_TRUE;
> +   return GL_TRUE;

What ensures that the sampler validate will be redone when sampler
uniforms change?


pgpAzohzUVDZN.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 00/12] Last of the API changes for ARB_separate_shader_objects

2014-03-05 Thread Eric Anholt
Ian Romanick  writes:

> This is the last set of core API changes for
> ARB_separate_shader_objects.  The next set of patches will just be in
> the linker and compiler.

Assuming my clarification restatement of the comment about ctx->Shader
wasn't misinformed, all the uncommented patches (or patches with obvious
fixes) are:

Reviewed-by: Eric Anholt 


pgpDifKaihPTd.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] gallium/util: Fix memory leak

2014-03-05 Thread Marek Olšák
Reviewed-by: Marek Olšák 

Marek

On Wed, Mar 5, 2014 at 12:20 AM, Aaron Watry  wrote:
> Fix a leaked vertex shader in u_blitter.c
>
> Signed-off-by: Aaron Watry 
>
> CC: "10.1" 
> ---
>  src/gallium/auxiliary/util/u_blitter.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/src/gallium/auxiliary/util/u_blitter.c 
> b/src/gallium/auxiliary/util/u_blitter.c
> index 95e7fb6..66b511e 100644
> --- a/src/gallium/auxiliary/util/u_blitter.c
> +++ b/src/gallium/auxiliary/util/u_blitter.c
> @@ -364,6 +364,8 @@ void util_blitter_destroy(struct blitter_context *blitter)
> pipe->delete_vs_state(pipe, ctx->vs);
> if (ctx->vs_pos_only)
>pipe->delete_vs_state(pipe, ctx->vs_pos_only);
> +   if (ctx->vs_layered)
> +  pipe->delete_vs_state(pipe, ctx->vs_layered);
> pipe->delete_vertex_elements_state(pipe, ctx->velem_state);
> for (i = 0; i < 4; i++) {
>if (ctx->velem_state_readbuf[i]) {
> --
> 1.8.3.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] [Bug 75814] New: Heap-buffer-overflow WRITE in memcpy_texture

2014-03-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=75814

  Priority: medium
Bug ID: 75814
  Assignee: mesa-dev@lists.freedesktop.org
   Summary: Heap-buffer-overflow WRITE in memcpy_texture
  Severity: normal
Classification: Unclassified
OS: All
  Reporter: infe...@chromium.org
  Hardware: Other
Status: NEW
   Version: unspecified
 Component: Other
   Product: Mesa

I am running into this when launching chrome built with AddressSanitizer memory
debugging tool on Ubuntu Saucy.

=
==3110==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60318101
at pc 0x4897f6 bp 0x7fff8f1918e0 sp 0x7fff8f191098
WRITE of size 4 at 0x60318101 thread T0 (content_shell)
#0 0x4897f5 in __interceptor_memcpy
/usr/local/google/work/chromium/src/third_party/llvm/projects/compiler-rt/lib/asan/asan_interceptors.cc:374
#1 0x7f3481c6a9f5 in memcpy /usr/include/x86_64-linux-gnu/bits/string3.h:51
#2 0x7f3481c6a9f5 in memcpy_texture
/build/buildd/mesa-9.2.1/build/dri/src/mesa/libdricore/../../../../../src/mesa/main/texstore.c:960
#3 0x7f3481c6fd84 in _mesa_texstore_memcpy
/build/buildd/mesa-9.2.1/build/dri/src/mesa/libdricore/../../../../../src/mesa/main/texstore.c:3855
#4 0x7f3481c6fd84 in _mesa_texstore
/build/buildd/mesa-9.2.1/build/dri/src/mesa/libdricore/../../../../../src/mesa/main/texstore.c:3874
#5 0x7f3481c70051 in store_texsubimage
/build/buildd/mesa-9.2.1/build/dri/src/mesa/libdricore/../../../../../src/mesa/main/texstore.c:4022
#6 0x7f348169f179 in st_TexSubImage
/build/buildd/mesa-9.2.1/build/dri/src/mesa/libdricore/../../../../../src/mesa/state_tracker/st_cb_texture.c:789
#7 0x7f348169fc02 in st_TexImage
/build/buildd/mesa-9.2.1/build/dri/src/mesa/libdricore/../../../../../src/mesa/state_tracker/st_cb_texture.c:813
#8 0x7f3481c5e8eb in teximage
/build/buildd/mesa-9.2.1/build/dri/src/mesa/libdricore/../../../../../src/mesa/main/teximage.c:3166
#9 0x7f3481c5fb5f in _mesa_TexImage2D
/build/buildd/mesa-9.2.1/build/dri/src/mesa/libdricore/../../../../../src/mesa/main/teximage.c:3205
#10 0x85ca65e in gfx::(anonymous namespace)::CustomTexImage2D(unsigned int,
int, int, int, int, int, unsigned int, unsigned int, void const*)
/b/build/slave/ASAN_Release/build/src/out/Release/../../ui/gl/gl_gl_api_implementation.cc:131
#11 0x85faba4 in gfx::GLApiBase::glTexImage2DFn(unsigned int, int, int,
int, int, int, unsigned int, unsigned int, void const*)
/b/build/slave/ASAN_Release/build/src/out/Release/gen/ui/gl/gl_bindings_autogen_gl.cc:3283
#12 0x84fa97e in
gpu::gles2::TextureManager::CreateDefaultAndBlackTextures(unsigned int,
unsigned int*)
/b/build/slave/ASAN_Release/build/src/out/Release/../../gpu/command_buffer/service/texture_manager.cc:922
#13 0x84f975e in gpu::gles2::TextureManager::Initialize()
/b/build/slave/ASAN_Release/build/src/out/Release/../../gpu/command_buffer/service/texture_manager.cc:881
#14 0x83c6f4a in
gpu::gles2::ContextGroup::Initialize(gpu::gles2::GLES2Decoder*,
gpu::gles2::DisallowedFeatures const&)
/b/build/slave/ASAN_Release/build/src/out/Release/../../gpu/command_buffer/service/context_group.cc:240
#15 0x83f3500 in
gpu::gles2::GLES2DecoderImpl::Initialize(scoped_refptr const&,
scoped_refptr const&, bool, gfx::Size const&,
gpu::gles2::DisallowedFeatures const&, std::vector >
const&)
/b/build/slave/ASAN_Release/build/src/out/Release/../../gpu/command_buffer/service/gles2_cmd_decoder.cc:2257
#16 0x7fd1a2e in
content::GpuCommandBufferStub::OnInitialize(base::FileDescriptor,
IPC::Message*)
/b/build/slave/ASAN_Release/build/src/out/Release/../../content/common/gpu/gpu_command_buffer_stub.cc:499
#17 0x7fe1018 in DispatchToMethod
/b/build/slave/ASAN_Release/build/src/out/Release/../../base/tuple.h:803
#18 0x7fe1018 in bool IPC::SyncMessageSchema,
Tuple2
>::DispatchDelayReplyWithSendParams(bool,
Tuple1 const&, IPC::Message const*,
content::GpuCommandBufferStub*, void
(content::GpuCommandBufferStub::*)(base::FileDescriptor, IPC::Message*))
/b/build/slave/ASAN_Release/build/src/out/Release/../../ipc/ipc_message_utils.h:845
#19 0x7fce175 in DispatchDelayReply
/b/build/slave/ASAN_Release/build/src/out/Release/../../content/common/gpu/gpu_messages.h:507
#20 0x7fce175 in
content::GpuCommandBufferStub::OnMessageReceived(IPC::Message const&)
/b/build/slave/ASAN_Release/build/src/out/Release/../../content/common/gpu/gpu_command_buffer_stub.cc:188
#21 0x7f8a613 in content::MessageRouter::RouteMessage(IPC::Message const&)
/b/build/slave/ASAN_Release/build/src/out/Release/../../content/common/message_router.cc:49
#22 0x7fb741f in content::GpuChannel::HandleMessage()
/b/build/slave/ASAN_Release/build/src/out/Release/../../content/common/gpu/gpu_channel.cc:753
#23 0x68df68 in Run
/b/build/slave/ASAN_Release/build/src/out/Release/../../base/callback.h:40

Re: [Mesa-dev] [PATCH] mesa: fix unpack_ubyte_ARGB4444_REV()

2014-03-05 Thread Anuj Phogat
On Wed, Mar 5, 2014 at 8:02 AM, Brian Paul  wrote:
> This was overlooked in 7cc9df4b8a1c.  Spotted by Chia-I Wu.
> ---
>  src/mesa/main/format_unpack.c |8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
> index d8bf57d..f9c42e7 100644
> --- a/src/mesa/main/format_unpack.c
> +++ b/src/mesa/main/format_unpack.c
> @@ -2738,10 +2738,10 @@ unpack_ubyte_ARGB_REV(const void *src, GLubyte 
> dst[][4], GLuint n)
> const GLushort *s = ((const GLushort *) src);
> GLuint i;
> for (i = 0; i < n; i++) {
> -  dst[i][RCOMP] = EXPAND_4_8((s[i]  ) & 0xf);
> -  dst[i][GCOMP] = EXPAND_4_8((s[i] >> 12) & 0xf);
> -  dst[i][BCOMP] = EXPAND_4_8((s[i] >>  8) & 0xf);
> -  dst[i][ACOMP] = EXPAND_4_8((s[i] >>  4) & 0xf);
> +  dst[i][RCOMP] = EXPAND_4_8((s[i] >>  4) & 0xf);
> +  dst[i][GCOMP] = EXPAND_4_8((s[i] >>  8) & 0xf);
> +  dst[i][BCOMP] = EXPAND_4_8((s[i] >> 12) & 0xf);
> +  dst[i][ACOMP] = EXPAND_4_8((s[i]  ) & 0xf);
> }
>  }
>
> --
> 1.7.10.4
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev

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


[Mesa-dev] [PATCH 1/2] glapi: use 'Mesa' in error messages

2014-03-05 Thread Brian Paul
A user would have no idea what "_glthread_" is.  This removes the
last remaining instance of the _glthread_ string in Mesa.
---
 src/mapi/u_thread.h |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mapi/u_thread.h b/src/mapi/u_thread.h
index 0fc9392..78f2269 100644
--- a/src/mapi/u_thread.h
+++ b/src/mapi/u_thread.h
@@ -57,9 +57,9 @@
 /*
  * Error messages
  */
-#define INIT_TSD_ERROR "_glthread_: failed to allocate key for thread specific 
data"
-#define GET_TSD_ERROR "_glthread_: failed to get thread specific data"
-#define SET_TSD_ERROR "_glthread_: thread failed to set thread specific data"
+#define INIT_TSD_ERROR "Mesa: failed to allocate key for thread specific data"
+#define GET_TSD_ERROR "Mesa: failed to get thread specific data"
+#define SET_TSD_ERROR "Mesa: thread failed to set thread specific data"
 
 
 /*
-- 
1.7.10.4

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


[Mesa-dev] [PATCH 2/2] glapi: remove u_mutex wrapper code, use c99 thread mutexes directly

2014-03-05 Thread Brian Paul
---
 src/mapi/mapi.c  |   10 +-
 src/mapi/stub.c  |6 +++---
 src/mapi/u_current.c |6 +++---
 src/mapi/u_execmem.c |6 +++---
 src/mapi/u_thread.h  |   10 --
 5 files changed, 14 insertions(+), 24 deletions(-)

diff --git a/src/mapi/mapi.c b/src/mapi/mapi.c
index 56f209b..8d0baca 100644
--- a/src/mapi/mapi.c
+++ b/src/mapi/mapi.c
@@ -72,15 +72,15 @@ get_stub(const char *name, const struct mapi_stub *alias)
 void
 mapi_init(const char *spec)
 {
-   u_mutex_declare_static(mutex);
+   static mtx_t mutex = _MTX_INITIALIZER_NP;
const char *p;
int ver, count;
 
-   u_mutex_lock(mutex);
+   mtx_lock(&mutex);
 
/* already initialized */
if (mapi_num_stubs) {
-  u_mutex_unlock(mutex);
+  mtx_unlock(&mutex);
   return;
}
 
@@ -90,7 +90,7 @@ mapi_init(const char *spec)
/* parse version string */
ver = atoi(p);
if (ver != 1) {
-  u_mutex_unlock(mutex);
+  mtx_unlock(&mutex);
   return;
}
p += strlen(p) + 1;
@@ -115,7 +115,7 @@ mapi_init(const char *spec)
 
mapi_num_stubs = count;
 
-   u_mutex_unlock(mutex);
+   mtx_unlock(&mutex);
 }
 
 /**
diff --git a/src/mapi/stub.c b/src/mapi/stub.c
index acd2c0a..b5db597 100644
--- a/src/mapi/stub.c
+++ b/src/mapi/stub.c
@@ -126,11 +126,11 @@ stub_add_dynamic(const char *name)
 struct mapi_stub *
 stub_find_dynamic(const char *name, int generate)
 {
-   u_mutex_declare_static(dynamic_mutex);
+   static mtx_t dynamic_mutex = _MTX_INITIALIZER_NP PTHREAD_MUTEX_INITIALIZER;
struct mapi_stub *stub = NULL;
int count, i;

-   u_mutex_lock(dynamic_mutex);
+   mtx_lock(&dynamic_mutex);
 
if (generate)
   assert(!stub_find_public(name));
@@ -147,7 +147,7 @@ stub_find_dynamic(const char *name, int generate)
if (generate && !stub)
  stub = stub_add_dynamic(name);
 
-   u_mutex_unlock(dynamic_mutex);
+   mtx_unlock(&dynamic_mutex);
 
return stub;
 }
diff --git a/src/mapi/u_current.c b/src/mapi/u_current.c
index 0721338..9c3537a 100644
--- a/src/mapi/u_current.c
+++ b/src/mapi/u_current.c
@@ -144,7 +144,7 @@ u_current_init_tsd(void)
 /**
  * Mutex for multithread check.
  */
-u_mutex_declare_static(ThreadCheckMutex);
+static mtx_t ThreadCheckMutex = _MTX_INITIALIZER_NP;
 
 /**
  * We should call this periodically from a function such as glXMakeCurrent
@@ -159,7 +159,7 @@ u_current_init(void)
if (ThreadSafe)
   return;
 
-   u_mutex_lock(ThreadCheckMutex);
+   mtx_lock(&ThreadCheckMutex);
if (firstCall) {
   u_current_init_tsd();
 
@@ -171,7 +171,7 @@ u_current_init(void)
   u_current_set(NULL);
   u_current_set_user(NULL);
}
-   u_mutex_unlock(ThreadCheckMutex);
+   mtx_unlock(&ThreadCheckMutex);
 }
 
 #else
diff --git a/src/mapi/u_execmem.c b/src/mapi/u_execmem.c
index 3573652..ac1cae0 100644
--- a/src/mapi/u_execmem.c
+++ b/src/mapi/u_execmem.c
@@ -39,7 +39,7 @@
 
 #define EXEC_MAP_SIZE (4*1024)
 
-u_mutex_declare_static(exec_mutex);
+static mtx_t exec_mutex = _MTX_INITIALIZER_NP;
 
 static unsigned int head = 0;
 
@@ -123,7 +123,7 @@ u_execmem_alloc(unsigned int size)
 {
void *addr = NULL;
 
-   u_mutex_lock(exec_mutex);
+   mtx_lock(&exec_mutex);
 
if (!init_map())
   goto bail;
@@ -137,7 +137,7 @@ u_execmem_alloc(unsigned int size)
head += size;
 
 bail:
-   u_mutex_unlock(exec_mutex);
+   mtx_unlock(&exec_mutex);
 
return addr;
 }
diff --git a/src/mapi/u_thread.h b/src/mapi/u_thread.h
index 78f2269..57c3b07 100644
--- a/src/mapi/u_thread.h
+++ b/src/mapi/u_thread.h
@@ -79,16 +79,6 @@ struct u_tsd {
unsigned initMagic;
 };
 
-typedef mtx_t u_mutex;
-
-#define u_mutex_declare_static(name) \
-   static u_mutex name = _MTX_INITIALIZER_NP
-
-#define u_mutex_init(name)mtx_init(&(name), mtx_plain)
-#define u_mutex_destroy(name) mtx_destroy(&(name))
-#define u_mutex_lock(name)(void) mtx_lock(&(name))
-#define u_mutex_unlock(name)  (void) mtx_unlock(&(name))
-
 
 static INLINE unsigned long
 u_thread_self(void)
-- 
1.7.10.4

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


[Mesa-dev] [PATCH] glsl: fix compiler warnings in link_uniforms.cpp

2014-03-05 Thread Brian Paul
With a non-debug build, gcc has two complaints:
1. 'found' var not used.  Silence with '(void) found;'
2. 'id' not initialized.  It's assigned by the UniformHash->get()
   call, actually.  But init it to zero to silence gcc.
---
 src/glsl/link_uniforms.cpp |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index 1cf376d..1c451e7 100644
--- a/src/glsl/link_uniforms.cpp
+++ b/src/glsl/link_uniforms.cpp
@@ -775,9 +775,10 @@ link_set_image_access_qualifiers(struct gl_shader_program 
*prog)
 
  if (var && var->data.mode == ir_var_uniform &&
  var->type->contains_image()) {
-unsigned id;
+unsigned id = 0;
 bool found = prog->UniformHash->get(id, var->name);
 assert(found);
+(void) found;
 const gl_uniform_storage *storage = &prog->UniformStorage[id];
 const unsigned index = storage->image[i].index;
 const GLenum access = (var->data.image.read_only ? GL_READ_ONLY :
-- 
1.7.10.4

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


[Mesa-dev] [PATCH 2/2] i965: Use the render cache tracker in more places to skip mi_flush()es.

2014-03-05 Thread Eric Anholt
Now you can call the blit functions without worrying about flushing either
too much or too little.
---
 src/mesa/drivers/dri/i965/intel_blit.c   |  8 +---
 src/mesa/drivers/dri/i965/intel_buffer_objects.c | 20 
 2 files changed, 5 insertions(+), 23 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_blit.c 
b/src/mesa/drivers/dri/i965/intel_blit.c
index d482272..992a603 100644
--- a/src/mesa/drivers/dri/i965/intel_blit.c
+++ b/src/mesa/drivers/dri/i965/intel_blit.c
@@ -431,7 +431,7 @@ intelEmitCopyBlit(struct brw_context *brw,
 
ADVANCE_BATCH_TILED(dst_y_tiled, src_y_tiled);
 
-   intel_batchbuffer_emit_mi_flush(brw);
+   brw_render_cache_set_add_bo(brw, dst_buffer);
 
return true;
 }
@@ -515,7 +515,7 @@ intelEmitImmediateColorExpandBlit(struct brw_context *brw,
 
intel_batchbuffer_data(brw, src_bits, dwords * 4, BLT_RING);
 
-   intel_batchbuffer_emit_mi_flush(brw);
+   brw_render_cache_set_add_bo(brw, dst_buffer);
 
return true;
 }
@@ -568,6 +568,8 @@ intel_emit_linear_blit(struct brw_context *brw,
   if (!ok)
  _mesa_problem(ctx, "Failed to linear blit %dx%d\n", size, 1);
}
+
+   brw_render_cache_set_add_bo(brw, dst_bo);
 }
 
 /**
@@ -633,5 +635,5 @@ intel_miptree_set_alpha_to_one(struct brw_context *brw,
OUT_BATCH(0x); /* white, but only alpha gets written */
ADVANCE_BATCH_TILED(dst_y_tiled, false);
 
-   intel_batchbuffer_emit_mi_flush(brw);
+   brw_render_cache_set_add_bo(brw, region->bo);
 }
diff --git a/src/mesa/drivers/dri/i965/intel_buffer_objects.c 
b/src/mesa/drivers/dri/i965/intel_buffer_objects.c
index e6124dc..288bff4 100644
--- a/src/mesa/drivers/dri/i965/intel_buffer_objects.c
+++ b/src/mesa/drivers/dri/i965/intel_buffer_objects.c
@@ -515,12 +515,6 @@ intel_bufferobj_unmap(struct gl_context * ctx, struct 
gl_buffer_object *obj,
assert(intel_obj);
assert(obj->Mappings[index].Pointer);
if (intel_obj->range_map_buffer[index] != NULL) {
-  /* Since we've emitted some blits to buffers that will (likely) be used
-   * in rendering operations in other cache domains in this batch, emit a
-   * flush.  Once again, we wish for a domain tracker in libdrm to cover
-   * usage inside of a batchbuffer.
-   */
-  intel_batchbuffer_emit_mi_flush(brw);
   _mesa_align_free(intel_obj->range_map_buffer[index]);
   intel_obj->range_map_buffer[index] = NULL;
} else if (intel_obj->range_map_bo[index] != NULL) {
@@ -536,13 +530,6 @@ intel_bufferobj_unmap(struct gl_context * ctx, struct 
gl_buffer_object *obj,
   intel_bufferobj_mark_gpu_usage(intel_obj, obj->Mappings[index].Offset,
  obj->Mappings[index].Length);
 
-  /* Since we've emitted some blits to buffers that will (likely) be used
-   * in rendering operations in other cache domains in this batch, emit a
-   * flush.  Once again, we wish for a domain tracker in libdrm to cover
-   * usage inside of a batchbuffer.
-   */
-  intel_batchbuffer_emit_mi_flush(brw);
-
   drm_intel_bo_unreference(intel_obj->range_map_bo[index]);
   intel_obj->range_map_bo[index] = NULL;
} else if (intel_obj->buffer != NULL) {
@@ -607,13 +594,6 @@ intel_bufferobj_copy_subdata(struct gl_context *ctx,
intel_emit_linear_blit(brw,
  dst_bo, write_offset,
  src_bo, read_offset, size);
-
-   /* Since we've emitted some blits to buffers that will (likely) be used
-* in rendering operations in other cache domains in this batch, emit a
-* flush.  Once again, we wish for a domain tracker in libdrm to cover
-* usage inside of a batchbuffer.
-*/
-   intel_batchbuffer_emit_mi_flush(brw);
 }
 
 void
-- 
1.9.0

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


[Mesa-dev] [PATCH 1/2] i965: Fix render-to-texture in non-FinishRenderTexture cases.

2014-03-05 Thread Eric Anholt
We've had several problems now with FinishRenderTexture not getting called
enough, and we're ready to just give up on it ever doing what we need.  In
particular, an upcoming Steam title had rendering bugs that could be fixed
by always_flush_cache=true.

Instead of hoping Mesa core can figure out when we need to flush our
caches, just track what BOs we've rendered to in a set, and when we render
from a BO in that set, emit a flush and clear the set.

There's some overhead to keeping this set, but most of that is just
hashing the pointer -- it turns out our set never even gets very large,
because cache flushes are so common (even on cairo-gl).

No statistically significant performance difference in cairo-gl (n=100),
despite spending ~.5% CPU in these set operations.

v1: (Original patch by Eric Anholt.)
v2: (Changes by Ken Graunke.)
  - Rebase forward from May 7th 2013 -> March 4th 2014.
  - Drop the FinishRenderTexture hook entirely; after rebasing the
patch, the hook was just an empty function.
  - Move the brw_render_cache_set_clear() call from
intel_batchbuffer_emit_flush() to brw_emit_pipe_control_flush().
In theory, this could catch more cases where we've flushed.
  - Consider stencil as a possible texturing source.
v3: (changes by anholt):
  - Move set_clear() back to emit_mi_flush() -- it means we can drop
more forced flushes from the code.  In the previous location, it
wouldn't have been called when we wanted pre-gen6.
  - Move the set clear from batch init to reset -- it should be empty at
the start of every batch, since the kernel handled any inter-batch
flush for us.

Signed-off-by: Eric Anholt 
Signed-off-by: Kenneth Graunke 
---
 src/mesa/drivers/dri/i965/brw_context.c   |  4 +-
 src/mesa/drivers/dri/i965/brw_context.h   |  7 +++
 src/mesa/drivers/dri/i965/brw_draw.c  | 30 +---
 src/mesa/drivers/dri/i965/brw_misc_state.c|  5 ++
 src/mesa/drivers/dri/i965/intel_batchbuffer.c |  4 ++
 src/mesa/drivers/dri/i965/intel_fbo.c | 66 +++
 src/mesa/drivers/dri/i965/intel_fbo.h |  4 ++
 src/mesa/main/set.c   |  6 +++
 8 files changed, 99 insertions(+), 27 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index 1441b46..026b3aa 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -698,6 +698,8 @@ brwCreateContext(gl_api api,
/* Reinitialize the context point state.  It depends on ctx->Const values. 
*/
_mesa_init_point(ctx);
 
+   intel_fbo_init(brw);
+
intel_batchbuffer_init(brw);
 
if (brw->gen >= 6) {
@@ -721,8 +723,6 @@ brwCreateContext(gl_api api,
 
intelInitExtensions(ctx);
 
-   intel_fbo_init(brw);
-
brw_init_surface_formats(brw);
 
if (brw->is_g4x || brw->gen >= 5) {
diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
b/src/mesa/drivers/dri/i965/brw_context.h
index dbb30f2..734d273 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1030,6 +1030,13 @@ struct brw_context
drm_intel_context *hw_ctx;
 
/**
+* Set of drm_intel_bo * that have been rendered to within this batchbuffer
+* and would need flushing before being used from another cache domain that
+* isn't coherent with it (i.e. the sampler).
+*/
+   struct set *render_cache;
+
+   /**
 * Number of resets observed in the system at context creation.
 *
 * This is tracked in the context so that we can determine that another
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c 
b/src/mesa/drivers/dri/i965/brw_draw.c
index bc887fe..11a0361 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -297,8 +297,8 @@ static void brw_merge_inputs( struct brw_context *brw,
 /*
  * \brief Resolve buffers before drawing.
  *
- * Resolve the depth buffer's HiZ buffer and resolve the depth buffer of each
- * enabled depth texture.
+ * Resolve the depth buffer's HiZ buffer, resolve the depth buffer of each
+ * enabled depth texture, and flush the render cache for any dirty textures.
  *
  * (In the future, this will also perform MSAA resolves).
  */
@@ -314,9 +314,7 @@ brw_predraw_resolve_buffers(struct brw_context *brw)
if (depth_irb)
   intel_renderbuffer_resolve_hiz(brw, depth_irb);
 
-   /* Resolve depth buffer of each enabled depth texture, and color buffer of
-* each fast-clear-enabled color texture.
-*/
+   /* Resolve depth buffer and render cache of each enabled texture. */
for (int i = 0; i < ctx->Const.MaxCombinedTextureImageUnits; i++) {
   if (!ctx->Texture.Unit[i]._ReallyEnabled)
 continue;
@@ -325,6 +323,7 @@ brw_predraw_resolve_buffers(struct brw_context *brw)
 continue;
   intel_miptree_all_slices_resolve_depth(brw, tex_obj->mt);
   intel_miptree_resolve_color(brw, tex_obj->mt);
+  brw_render_cache_set_check_flush(brw

Re: [Mesa-dev] [PATCH 2/2] i965: Use the render cache tracker in more places to skip mi_flush()es.

2014-03-05 Thread Kenneth Graunke
On 03/05/2014 04:17 PM, Eric Anholt wrote:
> Now you can call the blit functions without worrying about flushing either
> too much or too little.
> ---
>  src/mesa/drivers/dri/i965/intel_blit.c   |  8 +---
>  src/mesa/drivers/dri/i965/intel_buffer_objects.c | 20 
>  2 files changed, 5 insertions(+), 23 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/intel_blit.c 
> b/src/mesa/drivers/dri/i965/intel_blit.c
> index d482272..992a603 100644
> --- a/src/mesa/drivers/dri/i965/intel_blit.c
> +++ b/src/mesa/drivers/dri/i965/intel_blit.c
> @@ -431,7 +431,7 @@ intelEmitCopyBlit(struct brw_context *brw,
>  
> ADVANCE_BATCH_TILED(dst_y_tiled, src_y_tiled);
>  
> -   intel_batchbuffer_emit_mi_flush(brw);
> +   brw_render_cache_set_add_bo(brw, dst_buffer);
>  
> return true;
>  }
> @@ -515,7 +515,7 @@ intelEmitImmediateColorExpandBlit(struct brw_context *brw,
>  
> intel_batchbuffer_data(brw, src_bits, dwords * 4, BLT_RING);
>  
> -   intel_batchbuffer_emit_mi_flush(brw);
> +   brw_render_cache_set_add_bo(brw, dst_buffer);
>  
> return true;
>  }
> @@ -568,6 +568,8 @@ intel_emit_linear_blit(struct brw_context *brw,
>if (!ok)
>   _mesa_problem(ctx, "Failed to linear blit %dx%d\n", size, 1);
> }
> +
> +   brw_render_cache_set_add_bo(brw, dst_bo);
>  }
>  
>  /**
> @@ -633,5 +635,5 @@ intel_miptree_set_alpha_to_one(struct brw_context *brw,
> OUT_BATCH(0x); /* white, but only alpha gets written */
> ADVANCE_BATCH_TILED(dst_y_tiled, false);
>  
> -   intel_batchbuffer_emit_mi_flush(brw);
> +   brw_render_cache_set_add_bo(brw, region->bo);
>  }
> diff --git a/src/mesa/drivers/dri/i965/intel_buffer_objects.c 
> b/src/mesa/drivers/dri/i965/intel_buffer_objects.c
> index e6124dc..288bff4 100644
> --- a/src/mesa/drivers/dri/i965/intel_buffer_objects.c
> +++ b/src/mesa/drivers/dri/i965/intel_buffer_objects.c
> @@ -515,12 +515,6 @@ intel_bufferobj_unmap(struct gl_context * ctx, struct 
> gl_buffer_object *obj,
> assert(intel_obj);
> assert(obj->Mappings[index].Pointer);
> if (intel_obj->range_map_buffer[index] != NULL) {
> -  /* Since we've emitted some blits to buffers that will (likely) be used
> -   * in rendering operations in other cache domains in this batch, emit a
> -   * flush.  Once again, we wish for a domain tracker in libdrm to cover
> -   * usage inside of a batchbuffer.
> -   */
> -  intel_batchbuffer_emit_mi_flush(brw);
>_mesa_align_free(intel_obj->range_map_buffer[index]);
>intel_obj->range_map_buffer[index] = NULL;
> } else if (intel_obj->range_map_bo[index] != NULL) {
> @@ -536,13 +530,6 @@ intel_bufferobj_unmap(struct gl_context * ctx, struct 
> gl_buffer_object *obj,
>intel_bufferobj_mark_gpu_usage(intel_obj, obj->Mappings[index].Offset,
>   obj->Mappings[index].Length);
>  
> -  /* Since we've emitted some blits to buffers that will (likely) be used
> -   * in rendering operations in other cache domains in this batch, emit a
> -   * flush.  Once again, we wish for a domain tracker in libdrm to cover
> -   * usage inside of a batchbuffer.
> -   */
> -  intel_batchbuffer_emit_mi_flush(brw);
> -
>drm_intel_bo_unreference(intel_obj->range_map_bo[index]);
>intel_obj->range_map_bo[index] = NULL;
> } else if (intel_obj->buffer != NULL) {
> @@ -607,13 +594,6 @@ intel_bufferobj_copy_subdata(struct gl_context *ctx,
> intel_emit_linear_blit(brw,
> dst_bo, write_offset,
> src_bo, read_offset, size);
> -
> -   /* Since we've emitted some blits to buffers that will (likely) be used
> -* in rendering operations in other cache domains in this batch, emit a
> -* flush.  Once again, we wish for a domain tracker in libdrm to cover
> -* usage inside of a batchbuffer.
> -*/
> -   intel_batchbuffer_emit_mi_flush(brw);
>  }
>  
>  void
> 

I really like the idea of this patch, but we probably need to add
set_check() operations somewhere.  Buffer objects used as TexBOs and
UBOs get accessed via the sampler, and I don't see how they'd get the
flushes they need.

--Ken



signature.asc
Description: OpenPGP digital signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] i965: Fix render-to-texture in non-FinishRenderTexture cases.

2014-03-05 Thread Kenneth Graunke
On 03/05/2014 04:17 PM, Eric Anholt wrote:
> We've had several problems now with FinishRenderTexture not getting called
> enough, and we're ready to just give up on it ever doing what we need.  In
> particular, an upcoming Steam title had rendering bugs that could be fixed
> by always_flush_cache=true.
> 
> Instead of hoping Mesa core can figure out when we need to flush our
> caches, just track what BOs we've rendered to in a set, and when we render
> from a BO in that set, emit a flush and clear the set.
> 
> There's some overhead to keeping this set, but most of that is just
> hashing the pointer -- it turns out our set never even gets very large,
> because cache flushes are so common (even on cairo-gl).
> 
> No statistically significant performance difference in cairo-gl (n=100),
> despite spending ~.5% CPU in these set operations.
> 
> v1: (Original patch by Eric Anholt.)
> v2: (Changes by Ken Graunke.)
>   - Rebase forward from May 7th 2013 -> March 4th 2014.
>   - Drop the FinishRenderTexture hook entirely; after rebasing the
> patch, the hook was just an empty function.
>   - Move the brw_render_cache_set_clear() call from
> intel_batchbuffer_emit_flush() to brw_emit_pipe_control_flush().
> In theory, this could catch more cases where we've flushed.
>   - Consider stencil as a possible texturing source.
> v3: (changes by anholt):
>   - Move set_clear() back to emit_mi_flush() -- it means we can drop
> more forced flushes from the code.  In the previous location, it
> wouldn't have been called when we wanted pre-gen6.
>   - Move the set clear from batch init to reset -- it should be empty at
> the start of every batch, since the kernel handled any inter-batch
> flush for us.
> 
> Signed-off-by: Eric Anholt 
> Signed-off-by: Kenneth Graunke 
> ---
>  src/mesa/drivers/dri/i965/brw_context.c   |  4 +-
>  src/mesa/drivers/dri/i965/brw_context.h   |  7 +++
>  src/mesa/drivers/dri/i965/brw_draw.c  | 30 +---
>  src/mesa/drivers/dri/i965/brw_misc_state.c|  5 ++
>  src/mesa/drivers/dri/i965/intel_batchbuffer.c |  4 ++
>  src/mesa/drivers/dri/i965/intel_fbo.c | 66 
> +++
>  src/mesa/drivers/dri/i965/intel_fbo.h |  4 ++
>  src/mesa/main/set.c   |  6 +++
>  8 files changed, 99 insertions(+), 27 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
> b/src/mesa/drivers/dri/i965/brw_context.c
> index 1441b46..026b3aa 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -698,6 +698,8 @@ brwCreateContext(gl_api api,
> /* Reinitialize the context point state.  It depends on ctx->Const 
> values. */
> _mesa_init_point(ctx);
>  
> +   intel_fbo_init(brw);
> +
> intel_batchbuffer_init(brw);
>  
> if (brw->gen >= 6) {
> @@ -721,8 +723,6 @@ brwCreateContext(gl_api api,
>  
> intelInitExtensions(ctx);
>  
> -   intel_fbo_init(brw);
> -
> brw_init_surface_formats(brw);
>  
> if (brw->is_g4x || brw->gen >= 5) {
> diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
> b/src/mesa/drivers/dri/i965/brw_context.h
> index dbb30f2..734d273 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.h
> +++ b/src/mesa/drivers/dri/i965/brw_context.h
> @@ -1030,6 +1030,13 @@ struct brw_context
> drm_intel_context *hw_ctx;
>  
> /**
> +* Set of drm_intel_bo * that have been rendered to within this 
> batchbuffer
> +* and would need flushing before being used from another cache domain 
> that
> +* isn't coherent with it (i.e. the sampler).
> +*/
> +   struct set *render_cache;
> +
> +   /**
>  * Number of resets observed in the system at context creation.
>  *
>  * This is tracked in the context so that we can determine that another
> diff --git a/src/mesa/drivers/dri/i965/brw_draw.c 
> b/src/mesa/drivers/dri/i965/brw_draw.c
> index bc887fe..11a0361 100644
> --- a/src/mesa/drivers/dri/i965/brw_draw.c
> +++ b/src/mesa/drivers/dri/i965/brw_draw.c
> @@ -297,8 +297,8 @@ static void brw_merge_inputs( struct brw_context *brw,
>  /*
>   * \brief Resolve buffers before drawing.
>   *
> - * Resolve the depth buffer's HiZ buffer and resolve the depth buffer of each
> - * enabled depth texture.
> + * Resolve the depth buffer's HiZ buffer, resolve the depth buffer of each
> + * enabled depth texture, and flush the render cache for any dirty textures.
>   *
>   * (In the future, this will also perform MSAA resolves).
>   */
> @@ -314,9 +314,7 @@ brw_predraw_resolve_buffers(struct brw_context *brw)
> if (depth_irb)
>intel_renderbuffer_resolve_hiz(brw, depth_irb);
>  
> -   /* Resolve depth buffer of each enabled depth texture, and color buffer of
> -* each fast-clear-enabled color texture.
> -*/
> +   /* Resolve depth buffer and render cache of each enabled texture. */
> for (int i = 0; i < ctx->Const.MaxCombinedTextureImageUnits; i++) {
>if (!ctx->Texture.Unit[i]._Really

Re: [Mesa-dev] [PATCH] glsl: fix compiler warnings in link_uniforms.cpp

2014-03-05 Thread Matt Turner
On Wed, Mar 5, 2014 at 3:42 PM, Brian Paul  wrote:
> With a non-debug build, gcc has two complaints:
> 1. 'found' var not used.  Silence with '(void) found;'
> 2. 'id' not initialized.  It's assigned by the UniformHash->get()
>call, actually.  But init it to zero to silence gcc.
> ---
>  src/glsl/link_uniforms.cpp |3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
> index 1cf376d..1c451e7 100644
> --- a/src/glsl/link_uniforms.cpp
> +++ b/src/glsl/link_uniforms.cpp
> @@ -775,9 +775,10 @@ link_set_image_access_qualifiers(struct 
> gl_shader_program *prog)
>
>   if (var && var->data.mode == ir_var_uniform &&
>   var->type->contains_image()) {
> -unsigned id;
> +unsigned id = 0;
>  bool found = prog->UniformHash->get(id, var->name);
>  assert(found);
> +(void) found;
>  const gl_uniform_storage *storage = &prog->UniformStorage[id];
>  const unsigned index = storage->image[i].index;
>  const GLenum access = (var->data.image.read_only ? GL_READ_ONLY :
> --
> 1.7.10.4

Wow, we're passing id as a non-constant reference to ->get(), and then
indirectly asserting that it was set. It might be nice to modify ::get
to just return the new id as an int, where -1 means failure. That
shouldn't block this patch though.

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


[Mesa-dev] [PATCH 1/3] radeon: Rename struct radeon_llvm_binary to radeon_shader_binary

2014-03-05 Thread Tom Stellard
And move its definition into r600_pipe_common.h;  This struct is a just
a container for shader code and has nothing to do with LLVM.
---
 src/gallium/drivers/r600/r600_llvm.c  |  4 ++--
 src/gallium/drivers/radeon/Makefile.am|  1 +
 src/gallium/drivers/radeon/r600_pipe_common.h | 16 
 src/gallium/drivers/radeon/radeon_llvm_emit.c |  3 ++-
 src/gallium/drivers/radeon/radeon_llvm_emit.h | 10 ++
 src/gallium/drivers/radeonsi/si_shader.c  |  2 +-
 6 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_llvm.c 
b/src/gallium/drivers/r600/r600_llvm.c
index e395bf6..4fcca69 100644
--- a/src/gallium/drivers/r600/r600_llvm.c
+++ b/src/gallium/drivers/r600/r600_llvm.c
@@ -827,11 +827,11 @@ unsigned r600_llvm_compile(
unsigned dump)
 {
unsigned r;
-   struct radeon_llvm_binary binary;
+   struct radeon_shader_binary binary;
const char * gpu_family = r600_get_llvm_processor_name(family);
unsigned i;
 
-   memset(&binary, 0, sizeof(struct radeon_llvm_binary));
+   memset(&binary, 0, sizeof(struct radeon_shader_binary));
r = radeon_llvm_compile(mod, &binary, gpu_family, dump);
 
assert(binary.code_size % 4 == 0);
diff --git a/src/gallium/drivers/radeon/Makefile.am 
b/src/gallium/drivers/radeon/Makefile.am
index 7971191..b521658 100644
--- a/src/gallium/drivers/radeon/Makefile.am
+++ b/src/gallium/drivers/radeon/Makefile.am
@@ -17,6 +17,7 @@ noinst_LTLIBRARIES += libllvmradeon.la
 
 libllvmradeon_la_CFLAGS = \
$(GALLIUM_DRIVER_CFLAGS) \
+   $(RADEON_CFLAGS) \
$(LLVM_CFLAGS)
 
 libllvmradeon_la_SOURCES = \
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h 
b/src/gallium/drivers/radeon/r600_pipe_common.h
index 692de5e..1367ae4 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.h
+++ b/src/gallium/drivers/radeon/r600_pipe_common.h
@@ -91,6 +91,22 @@
 
 struct r600_common_context;
 
+struct radeon_shader_binary {
+   /** Shader code */
+   unsigned char *code;
+   unsigned code_size;
+
+   /** Config/Context register state that accompanies this shader.
+* This is a stream of dword pairs.  First dword contains the
+* register address, the second dword contains the value.*/
+   unsigned char *config;
+   unsigned config_size;
+
+   /** Set to 1 if the disassembly for this binary has been dumped to
+*  stderr. */
+   int disassembled;
+};
+
 struct r600_resource {
struct u_resource   b;
 
diff --git a/src/gallium/drivers/radeon/radeon_llvm_emit.c 
b/src/gallium/drivers/radeon/radeon_llvm_emit.c
index 92e7dbc..4e0aaea 100644
--- a/src/gallium/drivers/radeon/radeon_llvm_emit.c
+++ b/src/gallium/drivers/radeon/radeon_llvm_emit.c
@@ -24,6 +24,7 @@
  *
  */
 #include "radeon_llvm_emit.h"
+#include "r600_pipe_common.h"
 #include "util/u_memory.h"
 
 #include 
@@ -85,7 +86,7 @@ static LLVMTargetRef get_r600_target() {
  *
  * @returns 0 for success, 1 for failure
  */
-unsigned radeon_llvm_compile(LLVMModuleRef M, struct radeon_llvm_binary 
*binary,
+unsigned radeon_llvm_compile(LLVMModuleRef M, struct radeon_shader_binary 
*binary,
  const char * gpu_family, unsigned 
dump) {
 
LLVMTargetRef target;
diff --git a/src/gallium/drivers/radeon/radeon_llvm_emit.h 
b/src/gallium/drivers/radeon/radeon_llvm_emit.h
index 532b7b8..780ff5f 100644
--- a/src/gallium/drivers/radeon/radeon_llvm_emit.h
+++ b/src/gallium/drivers/radeon/radeon_llvm_emit.h
@@ -29,19 +29,13 @@
 
 #include 
 
-struct radeon_llvm_binary {
-   unsigned char *code;
-   unsigned code_size;
-   unsigned char *config;
-   unsigned config_size;
-   int disassembled;
-};
+struct radeon_shader_binary;
 
 void radeon_llvm_shader_type(LLVMValueRef F, unsigned type);
 
 unsigned  radeon_llvm_compile(
LLVMModuleRef M,
-   struct radeon_llvm_binary *binary,
+   struct radeon_shader_binary *binary,
const char * gpu_family,
unsigned dump);
 
diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index 3a441f9..e4390ee 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -2295,7 +2295,7 @@ int si_compile_llvm(struct si_context *sctx, struct 
si_pipe_shader *shader,
 {
unsigned i;
uint32_t *ptr;
-   struct radeon_llvm_binary binary;
+   struct radeon_shader_binary binary;
bool dump = r600_can_dump_shader(&sctx->screen->b,
shader->selector ? shader->selector->tokens : NULL);
memset(&binary, 0, sizeof(binary));
-- 
1.8.1.5


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


[Mesa-dev] [PATCH 3/3] clover: Inline all functions for drivers that don't support subroutines

2014-03-05 Thread Tom Stellard
---
 src/gallium/drivers/radeon/radeon_llvm_util.c  | 35 --
 .../state_trackers/clover/core/compiler.hpp|  3 +-
 src/gallium/state_trackers/clover/core/device.cpp  |  6 +++
 src/gallium/state_trackers/clover/core/device.hpp  |  1 +
 src/gallium/state_trackers/clover/core/program.cpp |  3 +-
 .../state_trackers/clover/llvm/invocation.cpp  | 55 +-
 6 files changed, 55 insertions(+), 48 deletions(-)

diff --git a/src/gallium/drivers/radeon/radeon_llvm_util.c 
b/src/gallium/drivers/radeon/radeon_llvm_util.c
index 2ace91f..fe7f9a6 100644
--- a/src/gallium/drivers/radeon/radeon_llvm_util.c
+++ b/src/gallium/drivers/radeon/radeon_llvm_util.c
@@ -53,40 +53,6 @@ unsigned radeon_llvm_get_num_kernels(LLVMContextRef ctx,
return LLVMGetNamedMetadataNumOperands(mod, "opencl.kernels");
 }
 
-static void radeon_llvm_optimize(LLVMModuleRef mod)
-{
-   const char *data_layout = LLVMGetDataLayout(mod);
-   LLVMTargetDataRef TD = LLVMCreateTargetData(data_layout);
-   LLVMPassManagerBuilderRef builder = LLVMPassManagerBuilderCreate();
-   LLVMPassManagerRef pass_manager = LLVMCreatePassManager();
-
-   /* Functions calls are not supported yet, so we need to inline
-* everything.  The most efficient way to do this is to add
-* the always_inline attribute to all non-kernel functions
-* and then run the Always Inline pass.  The Always Inline
-* pass will automaically inline functions with this attribute
-* and does not perform the expensive cost analysis that the normal
-* inliner does.
-*/
-
-   LLVMValueRef fn;
-   for (fn = LLVMGetFirstFunction(mod); fn; fn = LLVMGetNextFunction(fn)) {
-   /* All the non-kernel functions have internal linkage */
-   if (LLVMGetLinkage(fn) == LLVMInternalLinkage) {
-   LLVMAddFunctionAttr(fn, LLVMAlwaysInlineAttribute);
-   }
-   }
-
-   LLVMAddTargetData(TD, pass_manager);
-   LLVMAddAlwaysInlinerPass(pass_manager);
-   LLVMPassManagerBuilderPopulateModulePassManager(builder, pass_manager);
-
-   LLVMRunPassManager(pass_manager, mod);
-   LLVMPassManagerBuilderDispose(builder);
-   LLVMDisposePassManager(pass_manager);
-   LLVMDisposeTargetData(TD);
-}
-
 LLVMModuleRef radeon_llvm_get_kernel_module(LLVMContextRef ctx, unsigned index,
const unsigned char *bitcode, unsigned bitcode_len)
 {
@@ -109,6 +75,5 @@ LLVMModuleRef radeon_llvm_get_kernel_module(LLVMContextRef 
ctx, unsigned index,
LLVMDeleteFunction(kernel_function);
}
FREE(kernel_metadata);
-   radeon_llvm_optimize(mod);
return mod;
 }
diff --git a/src/gallium/state_trackers/clover/core/compiler.hpp 
b/src/gallium/state_trackers/clover/core/compiler.hpp
index 49cd022..5035a6b 100644
--- a/src/gallium/state_trackers/clover/core/compiler.hpp
+++ b/src/gallium/state_trackers/clover/core/compiler.hpp
@@ -32,7 +32,8 @@ namespace clover {
module compile_program_llvm(const compat::string &source,
pipe_shader_ir ir,
const compat::string &target,
-   const compat::string &opts);
+   const compat::string &opts,
+   bool subroutines_supported);
 
module compile_program_tgsi(const compat::string &source);
 }
diff --git a/src/gallium/state_trackers/clover/core/device.cpp 
b/src/gallium/state_trackers/clover/core/device.cpp
index 2c5f9b7..6820f56 100644
--- a/src/gallium/state_trackers/clover/core/device.cpp
+++ b/src/gallium/state_trackers/clover/core/device.cpp
@@ -187,3 +187,9 @@ enum pipe_endian
 device::endianness() const {
return (enum pipe_endian)pipe->get_param(pipe, PIPE_CAP_ENDIANNESS);
 }
+
+bool
+device::subroutines_supported() const {
+   return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE,
+ PIPE_SHADER_CAP_SUBROUTINES);
+}
diff --git a/src/gallium/state_trackers/clover/core/device.hpp 
b/src/gallium/state_trackers/clover/core/device.hpp
index 433ac81..b187a93 100644
--- a/src/gallium/state_trackers/clover/core/device.hpp
+++ b/src/gallium/state_trackers/clover/core/device.hpp
@@ -68,6 +68,7 @@ namespace clover {
   enum pipe_shader_ir ir_format() const;
   std::string ir_target() const;
   enum pipe_endian endianness() const;
+  bool subroutines_supported() const;
 
   friend class command_queue;
   friend class root_resource;
diff --git a/src/gallium/state_trackers/clover/core/program.cpp 
b/src/gallium/state_trackers/clover/core/program.cpp
index 3aaa652..b547023 100644
--- a/src/gallium/state_trackers/clover/core/program.cpp
+++ b/src/gallium/state_trackers/clover/core/program.cpp
@@ -56,7 +56,8 @@ program::build(const ref_vector &devs, const char 
*opts) {
 auto module = (dev.ir_format() == PIPE_SHADER_IR_TGSI ?
 

[Mesa-dev] [PATCH 2/3] radeon/llvm: Factor elf parsing code out into its own function

2014-03-05 Thread Tom Stellard
---
 src/gallium/drivers/radeon/Makefile.sources   |  1 +
 src/gallium/drivers/radeon/radeon_elf_util.c  | 90 +++
 src/gallium/drivers/radeon/radeon_elf_util.h  | 39 
 src/gallium/drivers/radeon/radeon_llvm_emit.c | 53 +---
 4 files changed, 132 insertions(+), 51 deletions(-)
 create mode 100644 src/gallium/drivers/radeon/radeon_elf_util.c
 create mode 100644 src/gallium/drivers/radeon/radeon_elf_util.h

diff --git a/src/gallium/drivers/radeon/Makefile.sources 
b/src/gallium/drivers/radeon/Makefile.sources
index bbfb8ad..6ebed2c 100644
--- a/src/gallium/drivers/radeon/Makefile.sources
+++ b/src/gallium/drivers/radeon/Makefile.sources
@@ -1,5 +1,6 @@
 C_SOURCES := \
r600_buffer_common.c \
+   radeon_elf_util.c \
r600_pipe_common.c \
 r600_query.c \
r600_streamout.c \
diff --git a/src/gallium/drivers/radeon/radeon_elf_util.c 
b/src/gallium/drivers/radeon/radeon_elf_util.c
new file mode 100644
index 000..7d92962
--- /dev/null
+++ b/src/gallium/drivers/radeon/radeon_elf_util.c
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2014 Advanced Micro Devices, Inc.
+ *
+ * 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: Tom Stellard 
+ *
+ */
+
+#include "radeon_elf_util.h"
+#include "r600_pipe_common.h"
+
+#include "util/u_memory.h"
+
+#include 
+#include 
+#include 
+
+void radeon_elf_read(const char *elf_data, unsigned elf_size,
+   struct radeon_shader_binary *binary,
+   unsigned debug)
+{
+   char *elf_buffer;
+   Elf *elf;
+   Elf_Scn *section = NULL;
+   size_t section_str_index;
+
+   /* One of the libelf implementations
+* (http://www.mr511.de/software/english.htm) requires calling
+* elf_version() before elf_memory().
+*/
+   elf_version(EV_CURRENT);
+   elf_buffer = MALLOC(elf_size);
+   memcpy(elf_buffer, elf_data, elf_size);
+
+   elf = elf_memory(elf_buffer, elf_size);
+
+   elf_getshdrstrndx(elf, §ion_str_index);
+   binary->disassembled = 0;
+
+   while ((section = elf_nextscn(elf, section))) {
+   const char *name;
+   Elf_Data *section_data = NULL;
+   GElf_Shdr section_header;
+   if (gelf_getshdr(section, §ion_header) != §ion_header) {
+   fprintf(stderr, "Failed to read ELF section header\n");
+   return;
+   }
+   name = elf_strptr(elf, section_str_index, 
section_header.sh_name);
+   if (!strcmp(name, ".text")) {
+   section_data = elf_getdata(section, section_data);
+   binary->code_size = section_data->d_size;
+   binary->code = MALLOC(binary->code_size * 
sizeof(unsigned char));
+   memcpy(binary->code, section_data->d_buf, 
binary->code_size);
+   } else if (!strcmp(name, ".AMDGPU.config")) {
+   section_data = elf_getdata(section, section_data);
+   binary->config_size = section_data->d_size;
+   binary->config = MALLOC(binary->config_size * 
sizeof(unsigned char));
+   memcpy(binary->config, section_data->d_buf, 
binary->config_size);
+   } else if (debug && !strcmp(name, ".AMDGPU.disasm")) {
+   binary->disassembled = 1;
+   section_data = elf_getdata(section, section_data);
+   fprintf(stderr, "\nShader Disassembly:\n\n");
+   fprintf(stderr, "%.*s\n", (int)section_data->d_size,
+ (char *)section_data->d_buf);
+   }
+   }
+
+   if (elf){
+   elf_end(elf);
+   }
+   FREE(elf_buffer);
+}
diff --git a/src/gallium/drivers/radeon/radeon_el

[Mesa-dev] [PATCH] R600/SI: Custom lower i1 stores

2014-03-05 Thread Tom Stellard
These are sometimes created by the shrink to boolean optimization in the
globalopt pass.
---
 lib/Target/R600/SIISelLowering.cpp |  6 ++
 test/CodeGen/R600/store.ll | 23 ---
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/lib/Target/R600/SIISelLowering.cpp 
b/lib/Target/R600/SIISelLowering.cpp
index b64e2de..8a1cc82 100644
--- a/lib/Target/R600/SIISelLowering.cpp
+++ b/lib/Target/R600/SIISelLowering.cpp
@@ -98,6 +98,7 @@ SITargetLowering::SITargetLowering(TargetMachine &TM) :
   setOperationAction(ISD::LOAD, MVT::v4i32, Custom);
   setOperationAction(ISD::LOAD, MVT::v8i32, Custom);
 
+  setOperationAction(ISD::STORE, MVT::i1, Custom);
   setOperationAction(ISD::STORE, MVT::i32, Custom);
   setOperationAction(ISD::STORE, MVT::i64, Custom);
   setOperationAction(ISD::STORE, MVT::i128, Custom);
@@ -841,6 +842,11 @@ SDValue SITargetLowering::LowerSTORE(SDValue Op, 
SelectionDAG &DAG) const {
   if (VT.isVector() && VT.getVectorNumElements() >= 8)
   return SplitVectorStore(Op, DAG);
 
+  if (VT == MVT::i1)
+return DAG.getTruncStore(Store->getChain(), DL,
+DAG.getSExtOrTrunc(Store->getValue(), DL, MVT::i32),
+Store->getBasePtr(), MVT::i1, Store->getMemOperand());
+
   if (Store->getAddressSpace() != AMDGPUAS::PRIVATE_ADDRESS)
 return SDValue();
 
diff --git a/test/CodeGen/R600/store.ll b/test/CodeGen/R600/store.ll
index 5e51d56..a3c5331 100644
--- a/test/CodeGen/R600/store.ll
+++ b/test/CodeGen/R600/store.ll
@@ -1,10 +1,18 @@
-; RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck --check-prefix=EG-CHECK 
%s
-; RUN: llc < %s -march=r600 -mcpu=cayman | FileCheck --check-prefix=CM-CHECK %s
-; RUN: llc < %s -march=r600 -mcpu=verde -verify-machineinstrs | FileCheck 
--check-prefix=SI-CHECK %s
+; RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck --check-prefix=EG-CHECK 
--check-prefix=FUNC %s
+; RUN: llc < %s -march=r600 -mcpu=cayman | FileCheck --check-prefix=CM-CHECK 
--check-prefix=FUNC %s
+; RUN: llc < %s -march=r600 -mcpu=verde -verify-machineinstrs | FileCheck 
--check-prefix=SI-CHECK --check-prefix=FUNC %s
 
 
;======;
 ; Global Address Space
 
;======;
+; FUNC-LABEL: @store_i1
+; EG-CHECK: MEM_RAT MSKOR
+; SI-CHECK: BUFFER_STORE_BYTE
+define void @store_i1(i1 addrspace(1)* %out) {
+entry:
+  store i1 true, i1 addrspace(1)* %out
+  ret void
+}
 
 ; i8 store
 ; EG-CHECK-LABEL: @store_i8
@@ -173,6 +181,15 @@ entry:
 ; Local Address Space
 
;======;
 
+; FUNC-LABEL: @store_local_i1
+; EG-CHECK: LDS_BYTE_WRITE
+; SI-CHECK: DS_WRITE_B8
+define void @store_local_i1(i1 addrspace(3)* %out) {
+entry:
+  store i1 true, i1 addrspace(3)* %out
+  ret void
+}
+
 ; EG-CHECK-LABEL: @store_local_i8
 ; EG-CHECK: LDS_BYTE_WRITE
 ; SI-CHECK-LABEL: @store_local_i8
-- 
1.8.1.5


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


Re: [Mesa-dev] [PATCH 1/3] radeon: Rename struct radeon_llvm_binary to radeon_shader_binary

2014-03-05 Thread Michel Dänzer
On Mit, 2014-03-05 at 21:25 -0500, Tom Stellard wrote:
> And move its definition into r600_pipe_common.h;  This struct is a just
> a container for shader code and has nothing to do with LLVM.

Well, it has something to do with LLVM in that the drivers only use it
with LLVM. :)


> diff --git a/src/gallium/drivers/radeon/Makefile.am 
> b/src/gallium/drivers/radeon/Makefile.am
> index 7971191..b521658 100644
> --- a/src/gallium/drivers/radeon/Makefile.am
> +++ b/src/gallium/drivers/radeon/Makefile.am
> @@ -17,6 +17,7 @@ noinst_LTLIBRARIES += libllvmradeon.la
>  
>  libllvmradeon_la_CFLAGS = \
>   $(GALLIUM_DRIVER_CFLAGS) \
> + $(RADEON_CFLAGS) \
>   $(LLVM_CFLAGS)
>  
>  libllvmradeon_la_SOURCES = \

Should this be a separate change?


Other than that, patches 1 and 2 are

Reviewed-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: Custom lower i1 stores

2014-03-05 Thread Michel Dänzer
On Mit, 2014-03-05 at 21:35 -0500, Tom Stellard wrote:
> These are sometimes created by the shrink to boolean optimization in the
> globalopt pass.

Reviewed-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


[Mesa-dev] [Bug 75226] Dark rendering of War for the Overworld

2014-03-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=75226

Chia-I Wu  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #17 from Chia-I Wu  ---
I've pushed the fix to master (commit 4c68c6dcf).  It is verified with the
trace on radeonsi, ilo, and llvmpipe.  I am closing the bug now.  In case it
does not fix the real game, feel free to reopen it.

-- 
You are receiving this mail because:
You are the assignee for the bug.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/2] glapi: replace 'user' with 'context' in u_current.[ch] code

2014-03-05 Thread Chia-I Wu
On Wed, Mar 5, 2014 at 10:48 PM, Brian Paul  wrote:
> To make the functions more understandable.
Both patches are

Reviewed-by: Chia-I Wu 

> ---
>  src/mapi/glapi/glapi.c |2 +-
>  src/mapi/mapi_glapi.c  |2 +-
>  src/mapi/u_current.c   |   32 
>  src/mapi/u_current.h   |   20 ++--
>  4 files changed, 28 insertions(+), 28 deletions(-)
>
> diff --git a/src/mapi/glapi/glapi.c b/src/mapi/glapi/glapi.c
> index 3a0b638..231bdad 100644
> --- a/src/mapi/glapi/glapi.c
> +++ b/src/mapi/glapi/glapi.c
> @@ -54,7 +54,7 @@ _glapi_check_multithread(void)
>  void
>  _glapi_set_context(void *context)
>  {
> -   u_current_set_user((const void *) context);
> +   u_current_set_context((const void *) context);
>  }
>
>  void
> diff --git a/src/mapi/mapi_glapi.c b/src/mapi/mapi_glapi.c
> index 925caf3..d345f2a 100644
> --- a/src/mapi/mapi_glapi.c
> +++ b/src/mapi/mapi_glapi.c
> @@ -58,7 +58,7 @@ _glapi_check_multithread(void)
>  void
>  _glapi_set_context(void *context)
>  {
> -   u_current_set_user((const void *) context);
> +   u_current_set_context((const void *) context);
>  }
>
>  void
> diff --git a/src/mapi/u_current.c b/src/mapi/u_current.c
> index 0721338..72190fe 100644
> --- a/src/mapi/u_current.c
> +++ b/src/mapi/u_current.c
> @@ -103,18 +103,18 @@ __thread struct mapi_table *u_current_table
>  __attribute__((tls_model("initial-exec")))
>  = (struct mapi_table *) table_noop_array;
>
> -__thread void *u_current_user
> +__thread void *u_current_context
>  __attribute__((tls_model("initial-exec")));
>
>  #else
>
>  struct mapi_table *u_current_table =
> (struct mapi_table *) table_noop_array;
> -void *u_current_user;
> +void *u_current_context;
>
>  #ifdef THREADS
>  struct u_tsd u_current_table_tsd;
> -static struct u_tsd u_current_user_tsd;
> +static struct u_tsd u_current_context_tsd;
>  static int ThreadSafe;
>  #endif /* THREADS */
>
> @@ -127,7 +127,7 @@ u_current_destroy(void)
>  {
>  #if defined(THREADS) && defined(_WIN32)
> u_tsd_destroy(&u_current_table_tsd);
> -   u_tsd_destroy(&u_current_user_tsd);
> +   u_tsd_destroy(&u_current_context_tsd);
>  #endif
>  }
>
> @@ -138,7 +138,7 @@ static void
>  u_current_init_tsd(void)
>  {
> u_tsd_init(&u_current_table_tsd);
> -   u_tsd_init(&u_current_user_tsd);
> +   u_tsd_init(&u_current_context_tsd);
>  }
>
>  /**
> @@ -169,7 +169,7 @@ u_current_init(void)
> else if (knownID != u_thread_self()) {
>ThreadSafe = 1;
>u_current_set(NULL);
> -  u_current_set_user(NULL);
> +  u_current_set_context(NULL);
> }
> u_mutex_unlock(ThreadCheckMutex);
>  }
> @@ -191,17 +191,17 @@ u_current_init(void)
>   * void from the real context pointer type.
>   */
>  void
> -u_current_set_user(const void *ptr)
> +u_current_set_context(const void *ptr)
>  {
> u_current_init();
>
>  #if defined(GLX_USE_TLS)
> -   u_current_user = (void *) ptr;
> +   u_current_context = (void *) ptr;
>  #elif defined(THREADS)
> -   u_tsd_set(&u_current_user_tsd, (void *) ptr);
> -   u_current_user = (ThreadSafe) ? NULL : (void *) ptr;
> +   u_tsd_set(&u_current_context_tsd, (void *) ptr);
> +   u_current_context = (ThreadSafe) ? NULL : (void *) ptr;
>  #else
> -   u_current_user = (void *) ptr;
> +   u_current_context = (void *) ptr;
>  #endif
>  }
>
> @@ -211,16 +211,16 @@ u_current_set_user(const void *ptr)
>   * void to the real context pointer type.
>   */
>  void *
> -u_current_get_user_internal(void)
> +u_current_get_context_internal(void)
>  {
>  #if defined(GLX_USE_TLS)
> -   return u_current_user;
> +   return u_current_context;
>  #elif defined(THREADS)
> return (ThreadSafe)
> -  ? u_tsd_get(&u_current_user_tsd)
> -  : u_current_user;
> +  ? u_tsd_get(&u_current_context_tsd)
> +  : u_current_context;
>  #else
> -   return u_current_user;
> +   return u_current_context;
>  #endif
>  }
>
> diff --git a/src/mapi/u_current.h b/src/mapi/u_current.h
> index f9cffd8..6709af2 100644
> --- a/src/mapi/u_current.h
> +++ b/src/mapi/u_current.h
> @@ -11,14 +11,14 @@
>
>  #ifdef GLX_USE_TLS
>  #define u_current_table _glapi_tls_Dispatch
> -#define u_current_user _glapi_tls_Context
> +#define u_current_context _glapi_tls_Context
>  #else
>  #define u_current_table _glapi_Dispatch
> -#define u_current_user _glapi_Context
> +#define u_current_context _glapi_Context
>  #endif
>
>  #define u_current_get_internal _glapi_get_dispatch
> -#define u_current_get_user_internal _glapi_get_context
> +#define u_current_get_context_internal _glapi_get_context
>
>  #define u_current_table_tsd _gl_DispatchTSD
>
> @@ -33,13 +33,13 @@ struct mapi_table;
>  extern __thread struct mapi_table *u_current_table
>  __attribute__((tls_model("initial-exec")));
>
> -extern __thread void *u_current_user
> +extern __thread void *u_current_context
>  __attribute__((tls_model("initial-exec")));
>
>  #else /* GLX_USE_TLS */
>
>  extern struct mapi_table *u_current_table;
> -extern void *u_current_user;
>

Re: [Mesa-dev] [PATCH 1/2] glapi: use 'Mesa' in error messages

2014-03-05 Thread Chia-I Wu
On Thu, Mar 6, 2014 at 7:06 AM, Brian Paul  wrote:
> A user would have no idea what "_glthread_" is.  This removes the
> last remaining instance of the _glthread_ string in Mesa.
Reviewed-by: Chia-I Wu 
> ---
>  src/mapi/u_thread.h |6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/mapi/u_thread.h b/src/mapi/u_thread.h
> index 0fc9392..78f2269 100644
> --- a/src/mapi/u_thread.h
> +++ b/src/mapi/u_thread.h
> @@ -57,9 +57,9 @@
>  /*
>   * Error messages
>   */
> -#define INIT_TSD_ERROR "_glthread_: failed to allocate key for thread 
> specific data"
> -#define GET_TSD_ERROR "_glthread_: failed to get thread specific data"
> -#define SET_TSD_ERROR "_glthread_: thread failed to set thread specific data"
> +#define INIT_TSD_ERROR "Mesa: failed to allocate key for thread specific 
> data"
> +#define GET_TSD_ERROR "Mesa: failed to get thread specific data"
> +#define SET_TSD_ERROR "Mesa: thread failed to set thread specific data"
>
>
>  /*
> --
> 1.7.10.4
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev



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


Re: [Mesa-dev] [PATCH 2/2] glapi: remove u_mutex wrapper code, use c99 thread mutexes directly

2014-03-05 Thread Chia-I Wu
On Thu, Mar 6, 2014 at 7:06 AM, Brian Paul  wrote:
> ---
>  src/mapi/mapi.c  |   10 +-
>  src/mapi/stub.c  |6 +++---
>  src/mapi/u_current.c |6 +++---
>  src/mapi/u_execmem.c |6 +++---
>  src/mapi/u_thread.h  |   10 --
>  5 files changed, 14 insertions(+), 24 deletions(-)
>
> diff --git a/src/mapi/mapi.c b/src/mapi/mapi.c
> index 56f209b..8d0baca 100644
> --- a/src/mapi/mapi.c
> +++ b/src/mapi/mapi.c
> @@ -72,15 +72,15 @@ get_stub(const char *name, const struct mapi_stub *alias)
>  void
>  mapi_init(const char *spec)
>  {
> -   u_mutex_declare_static(mutex);
> +   static mtx_t mutex = _MTX_INITIALIZER_NP;
> const char *p;
> int ver, count;
>
> -   u_mutex_lock(mutex);
> +   mtx_lock(&mutex);
>
> /* already initialized */
> if (mapi_num_stubs) {
> -  u_mutex_unlock(mutex);
> +  mtx_unlock(&mutex);
>return;
> }
>
> @@ -90,7 +90,7 @@ mapi_init(const char *spec)
> /* parse version string */
> ver = atoi(p);
> if (ver != 1) {
> -  u_mutex_unlock(mutex);
> +  mtx_unlock(&mutex);
>return;
> }
> p += strlen(p) + 1;
> @@ -115,7 +115,7 @@ mapi_init(const char *spec)
>
> mapi_num_stubs = count;
>
> -   u_mutex_unlock(mutex);
> +   mtx_unlock(&mutex);
>  }
>
>  /**
> diff --git a/src/mapi/stub.c b/src/mapi/stub.c
> index acd2c0a..b5db597 100644
> --- a/src/mapi/stub.c
> +++ b/src/mapi/stub.c
> @@ -126,11 +126,11 @@ stub_add_dynamic(const char *name)
>  struct mapi_stub *
>  stub_find_dynamic(const char *name, int generate)
>  {
> -   u_mutex_declare_static(dynamic_mutex);
> +   static mtx_t dynamic_mutex = _MTX_INITIALIZER_NP 
> PTHREAD_MUTEX_INITIALIZER;
PTHREAD_MUTEX_INITIALIZER should be dropped.  With that fixed,

Reviewed-by: Chia-I Wu 

> struct mapi_stub *stub = NULL;
> int count, i;
>
> -   u_mutex_lock(dynamic_mutex);
> +   mtx_lock(&dynamic_mutex);
>
> if (generate)
>assert(!stub_find_public(name));
> @@ -147,7 +147,7 @@ stub_find_dynamic(const char *name, int generate)
> if (generate && !stub)
>   stub = stub_add_dynamic(name);
>
> -   u_mutex_unlock(dynamic_mutex);
> +   mtx_unlock(&dynamic_mutex);
>
> return stub;
>  }
> diff --git a/src/mapi/u_current.c b/src/mapi/u_current.c
> index 0721338..9c3537a 100644
> --- a/src/mapi/u_current.c
> +++ b/src/mapi/u_current.c
> @@ -144,7 +144,7 @@ u_current_init_tsd(void)
>  /**
>   * Mutex for multithread check.
>   */
> -u_mutex_declare_static(ThreadCheckMutex);
> +static mtx_t ThreadCheckMutex = _MTX_INITIALIZER_NP;
>
>  /**
>   * We should call this periodically from a function such as glXMakeCurrent
> @@ -159,7 +159,7 @@ u_current_init(void)
> if (ThreadSafe)
>return;
>
> -   u_mutex_lock(ThreadCheckMutex);
> +   mtx_lock(&ThreadCheckMutex);
> if (firstCall) {
>u_current_init_tsd();
>
> @@ -171,7 +171,7 @@ u_current_init(void)
>u_current_set(NULL);
>u_current_set_user(NULL);
> }
> -   u_mutex_unlock(ThreadCheckMutex);
> +   mtx_unlock(&ThreadCheckMutex);
>  }
>
>  #else
> diff --git a/src/mapi/u_execmem.c b/src/mapi/u_execmem.c
> index 3573652..ac1cae0 100644
> --- a/src/mapi/u_execmem.c
> +++ b/src/mapi/u_execmem.c
> @@ -39,7 +39,7 @@
>
>  #define EXEC_MAP_SIZE (4*1024)
>
> -u_mutex_declare_static(exec_mutex);
> +static mtx_t exec_mutex = _MTX_INITIALIZER_NP;
>
>  static unsigned int head = 0;
>
> @@ -123,7 +123,7 @@ u_execmem_alloc(unsigned int size)
>  {
> void *addr = NULL;
>
> -   u_mutex_lock(exec_mutex);
> +   mtx_lock(&exec_mutex);
>
> if (!init_map())
>goto bail;
> @@ -137,7 +137,7 @@ u_execmem_alloc(unsigned int size)
> head += size;
>
>  bail:
> -   u_mutex_unlock(exec_mutex);
> +   mtx_unlock(&exec_mutex);
>
> return addr;
>  }
> diff --git a/src/mapi/u_thread.h b/src/mapi/u_thread.h
> index 78f2269..57c3b07 100644
> --- a/src/mapi/u_thread.h
> +++ b/src/mapi/u_thread.h
> @@ -79,16 +79,6 @@ struct u_tsd {
> unsigned initMagic;
>  };
>
> -typedef mtx_t u_mutex;
> -
> -#define u_mutex_declare_static(name) \
> -   static u_mutex name = _MTX_INITIALIZER_NP
> -
> -#define u_mutex_init(name)mtx_init(&(name), mtx_plain)
> -#define u_mutex_destroy(name) mtx_destroy(&(name))
> -#define u_mutex_lock(name)(void) mtx_lock(&(name))
> -#define u_mutex_unlock(name)  (void) mtx_unlock(&(name))
> -
>
>  static INLINE unsigned long
>  u_thread_self(void)
> --
> 1.7.10.4
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev



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


[Mesa-dev] [PATCH] mesa/st: only compare the current scissor

2014-03-05 Thread Ilia Mirkin
sizeof(scissor) returns the size of the full array rather than a single
element. Fix it to consider just the one element.

Fixes: 0705fa35cdaf15ec969c28dc85e88b8be1149a3b
Signed-off-by: Ilia Mirkin 
---

Noticed this when playing with valgrind for unrelated reasons. Seems fairly
obvious.

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

diff --git a/src/mesa/state_tracker/st_atom_scissor.c 
b/src/mesa/state_tracker/st_atom_scissor.c
index a19ade1..b720309 100644
--- a/src/mesa/state_tracker/st_atom_scissor.c
+++ b/src/mesa/state_tracker/st_atom_scissor.c
@@ -85,7 +85,7 @@ update_scissor( struct st_context *st )
  scissor[i].maxy = maxy;
   }
 
-  if (memcmp(&scissor[i], &st->state.scissor[i], sizeof(scissor)) != 0) {
+  if (memcmp(&scissor[i], &st->state.scissor[i], sizeof(scissor[0])) != 0) 
{
  /* state has changed */
  st->state.scissor[i] = scissor[i];  /* struct copy */
  changed = true;
-- 
1.8.3.2

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


[Mesa-dev] [PATCH] nouveau: fix fence waiting logic in screen destroy

2014-03-05 Thread Ilia Mirkin
nouveau_fence_wait has the expectation that an external entity is
holding onto the fence being waited on, not that it is merely held onto
by the current pointer. Fixes a use-after-free in nouveau_fence_wait
when used on the screen's current fence.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=75279
Signed-off-by: Ilia Mirkin 
---

Should the waiting be predicated on the current fence having been emitted? I
removed that from nv30 (which would just go ahead and _leak_ that fence it it
hadn't been emitted...). I figure it doesn't really matter enough to worry
about that. The bigger reason to do it, I guess, is to make sure that all the
fences on the list get processed. But perhaps it'd be OK to just nuke them
without regard for such details?

 src/gallium/drivers/nouveau/nv30/nv30_screen.c | 14 ++
 src/gallium/drivers/nouveau/nv50/nv50_screen.c | 11 +--
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c |  9 -
 3 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c 
b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
index 82f2c06..5378913 100644
--- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
+++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
@@ -308,10 +308,16 @@ nv30_screen_destroy(struct pipe_screen *pscreen)
if (!nouveau_drm_screen_unref(&screen->base))
   return;
 
-   if (screen->base.fence.current &&
-   screen->base.fence.current->state >= NOUVEAU_FENCE_STATE_EMITTED) {
-  nouveau_fence_wait(screen->base.fence.current);
-  nouveau_fence_ref (NULL, &screen->base.fence.current);
+   if (screen->base.fence.current) {
+  struct nouveau_fence *current = NULL;
+
+  /* nouveau_fence_wait will create a new current fence, so wait on the
+   * _current_ one, and remove both.
+   */
+  nouveau_fence_ref(screen->base.fence.current, ¤t);
+  nouveau_fence_wait(current);
+  nouveau_fence_ref(NULL, ¤t);
+  nouveau_fence_ref(NULL, &screen->base.fence.current);
}
 
nouveau_object_del(&screen->query);
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c 
b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
index ab0d63e..e8c7fe3 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
@@ -294,8 +294,15 @@ nv50_screen_destroy(struct pipe_screen *pscreen)
   return;
 
if (screen->base.fence.current) {
-  nouveau_fence_wait(screen->base.fence.current);
-  nouveau_fence_ref (NULL, &screen->base.fence.current);
+  struct nouveau_fence *current = NULL;
+
+  /* nouveau_fence_wait will create a new current fence, so wait on the
+   * _current_ one, and remove both.
+   */
+  nouveau_fence_ref(screen->base.fence.current, ¤t);
+  nouveau_fence_wait(current);
+  nouveau_fence_ref(NULL, ¤t);
+  nouveau_fence_ref(NULL, &screen->base.fence.current);
}
if (screen->base.pushbuf)
   screen->base.pushbuf->user_priv = NULL;
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c 
b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
index 044847d..04f3088 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
@@ -340,7 +340,14 @@ nvc0_screen_destroy(struct pipe_screen *pscreen)
   return;
 
if (screen->base.fence.current) {
-  nouveau_fence_wait(screen->base.fence.current);
+  struct nouveau_fence *current = NULL;
+
+  /* nouveau_fence_wait will create a new current fence, so wait on the
+   * _current_ one, and remove both.
+   */
+  nouveau_fence_ref(screen->base.fence.current, ¤t);
+  nouveau_fence_wait(current);
+  nouveau_fence_ref(NULL, ¤t);
   nouveau_fence_ref(NULL, &screen->base.fence.current);
}
if (screen->base.pushbuf)
-- 
1.8.3.2

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


[Mesa-dev] [PATCH v2] nouveau: add valid range tracking to nouveau_buffer

2014-03-05 Thread Ilia Mirkin
This logic is borrowed from the radeon code. The transfer logic will
only get called for PIPE_BUFFER resources, so it shouldn't be necessary
to worry about them becoming render targets.

Signed-off-by: Ilia Mirkin 
---

This was re-tested by someone on both nv50 and nvc0. The performance gain
remains on nv50 (25-30%), while no change in performance is observed on nvc0,
for source games.

v1 -> v2:
 - make copy_buffer also populate the valid range

 src/gallium/drivers/nouveau/nouveau_buffer.c | 31 
 src/gallium/drivers/nouveau/nouveau_buffer.h |  4 +++
 src/gallium/drivers/nouveau/nv50/nv50_resource.c |  2 ++
 src/gallium/drivers/nouveau/nv50/nv50_state.c|  4 +++
 src/gallium/drivers/nouveau/nvc0/nvc0_resource.c |  2 ++
 src/gallium/drivers/nouveau/nvc0/nvc0_state.c|  4 +++
 6 files changed, 47 insertions(+)

diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.c 
b/src/gallium/drivers/nouveau/nouveau_buffer.c
index 5b0b93b..e308ff4 100644
--- a/src/gallium/drivers/nouveau/nouveau_buffer.c
+++ b/src/gallium/drivers/nouveau/nouveau_buffer.c
@@ -69,6 +69,8 @@ nouveau_buffer_allocate(struct nouveau_screen *screen,
if (buf->bo)
   buf->address = buf->bo->offset + buf->offset;
 
+   util_range_set_empty(&buf->valid_buffer_range);
+
return TRUE;
 }
 
@@ -124,6 +126,8 @@ nouveau_buffer_destroy(struct pipe_screen *pscreen,
nouveau_fence_ref(NULL, &res->fence);
nouveau_fence_ref(NULL, &res->fence_wr);
 
+   util_range_destroy(&res->valid_buffer_range);
+
FREE(res);
 
NOUVEAU_DRV_STAT(nouveau_screen(pscreen), buf_obj_current_count, -1);
@@ -387,6 +391,17 @@ nouveau_buffer_transfer_map(struct pipe_context *pipe,
if (usage & PIPE_TRANSFER_WRITE)
   NOUVEAU_DRV_STAT(nv->screen, buf_transfers_wr, 1);
 
+   /* If we are trying to write to an uninitialized range, the user shouldn't
+* care what was there before. So we can treat the write as if the target
+* range were being discarded. Furthermore, since we know that even if this
+* buffer is busy due to GPU activity, because the contents were
+* uninitialized, the GPU can't care what was there, and so we can treat
+* the write as being unsynchronized.
+*/
+   if ((usage & PIPE_TRANSFER_WRITE) &&
+   !util_ranges_intersect(&buf->valid_buffer_range, box->x, box->x + 
box->width))
+  usage |= PIPE_TRANSFER_DISCARD_RANGE | PIPE_TRANSFER_UNSYNCHRONIZED;
+
if (buf->domain == NOUVEAU_BO_VRAM) {
   if (usage & NOUVEAU_TRANSFER_DISCARD) {
  /* Set up a staging area for the user to write to. It will be copied
@@ -492,8 +507,14 @@ nouveau_buffer_transfer_flush_region(struct pipe_context 
*pipe,
  const struct pipe_box *box)
 {
struct nouveau_transfer *tx = nouveau_transfer(transfer);
+   struct nv04_resource *buf = nv04_resource(transfer->resource);
+
if (tx->map)
   nouveau_transfer_write(nouveau_context(pipe), tx, box->x, box->width);
+
+   util_range_add(&buf->valid_buffer_range,
+  tx->base.box.x + box->x,
+  tx->base.box.x + box->x + box->width);
 }
 
 /* Unmap stage of the transfer. If it was a WRITE transfer and the map that
@@ -522,6 +543,9 @@ nouveau_buffer_transfer_unmap(struct pipe_context *pipe,
  if (bind & (PIPE_BIND_CONSTANT_BUFFER))
 nv->cb_dirty = TRUE;
   }
+
+  util_range_add(&buf->valid_buffer_range,
+ tx->base.box.x, tx->base.box.x + tx->base.box.width);
}
 
if (!tx->bo && (tx->base.usage & PIPE_TRANSFER_WRITE))
@@ -562,6 +586,8 @@ nouveau_copy_buffer(struct nouveau_context *nv,
 &dst->base, 0, dstx, 0, 0,
 &src->base, 0, &src_box);
}
+
+   util_range_add(&dst->valid_buffer_range, dstx, dstx + size);
 }
 
 
@@ -659,6 +685,8 @@ nouveau_buffer_create(struct pipe_screen *pscreen,
 
NOUVEAU_DRV_STAT(screen, buf_obj_current_count, 1);
 
+   util_range_init(&buffer->valid_buffer_range);
+
return &buffer->base;
 
 fail:
@@ -690,6 +718,9 @@ nouveau_user_buffer_create(struct pipe_screen *pscreen, 
void *ptr,
buffer->data = ptr;
buffer->status = NOUVEAU_BUFFER_STATUS_USER_MEMORY;
 
+   util_range_init(&buffer->valid_buffer_range);
+   util_range_add(&buffer->valid_buffer_range, 0, bytes);
+
return &buffer->base;
 }
 
diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.h 
b/src/gallium/drivers/nouveau/nouveau_buffer.h
index aeb9b17..f881adc 100644
--- a/src/gallium/drivers/nouveau/nouveau_buffer.h
+++ b/src/gallium/drivers/nouveau/nouveau_buffer.h
@@ -1,6 +1,7 @@
 #ifndef __NOUVEAU_BUFFER_H__
 #define __NOUVEAU_BUFFER_H__
 
+#include "util/u_range.h"
 #include "util/u_transfer.h"
 #include "util/u_double_list.h"
 
@@ -44,6 +45,9 @@ struct nv04_resource {
struct nouveau_fence *fence_wr;
 
struct nouveau_mm_allocation *mm;
+
+   /* buffer range that has been initialized */
+   struct util_range valid_buffer_range;
 };

[Mesa-dev] [PATCH 2/2] glsl: Improve debug output and variable names for opt_dead_code_local.

2014-03-05 Thread Eric Anholt
I know this code has confused others, and it confused me 3 years later,
too.
---
 src/glsl/opt_dead_code_local.cpp | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/glsl/opt_dead_code_local.cpp b/src/glsl/opt_dead_code_local.cpp
index e7d46ed..703613b 100644
--- a/src/glsl/opt_dead_code_local.cpp
+++ b/src/glsl/opt_dead_code_local.cpp
@@ -38,7 +38,7 @@
 #include "ir_optimization.h"
 #include "glsl_types.h"
 
-static bool debug = false;
+static bool debug = true;
 
 namespace {
 
@@ -51,14 +51,14 @@ public:
   assert(ir);
   this->lhs = lhs;
   this->ir = ir;
-  this->available = ir->write_mask;
+  this->unused = ir->write_mask;
}
 
ir_variable *lhs;
ir_assignment *ir;
 
/* bitmask of xyzw channels written that haven't been used so far. */
-   int available;
+   int unused;
 };
 
 class kill_for_derefs_visitor : public ir_hierarchical_visitor {
@@ -68,7 +68,7 @@ public:
   this->assignments = assignments;
}
 
-   void kill_channels(ir_variable *const var, int used)
+   void use_channels(ir_variable *const var, int used)
{
   foreach_list_safe(n, this->assignments) {
 assignment_entry *entry = (assignment_entry *) n;
@@ -76,14 +76,14 @@ public:
 if (entry->lhs == var) {
if (var->type->is_scalar() || var->type->is_vector()) {
   if (debug)
- printf("kill %s (0x%01x - 0x%01x)\n", entry->lhs->name,
-entry->available, used);
-  entry->available &= ~used;
-  if (!entry->available)
+ printf("used %s (0x%01x - 0x%01x)\n", entry->lhs->name,
+entry->unused, used & 0xf);
+  entry->unused &= ~used;
+  if (!entry->unused)
  entry->remove();
} else {
   if (debug)
- printf("kill %s\n", entry->lhs->name);
+ printf("used %s\n", entry->lhs->name);
   entry->remove();
}
 }
@@ -92,7 +92,7 @@ public:
 
virtual ir_visitor_status visit(ir_dereference_variable *ir)
{
-  kill_channels(ir->var, ~0);
+  use_channels(ir->var, ~0);
 
   return visit_continue;
}
@@ -109,7 +109,7 @@ public:
   used |= 1 << ir->mask.z;
   used |= 1 << ir->mask.w;
 
-  kill_channels(deref->var, used);
+  use_channels(deref->var, used);
 
   return visit_continue_with_parent;
}
@@ -202,7 +202,7 @@ process_assignment(void *ctx, ir_assignment *ir, exec_list 
*assignments)
if (entry->lhs != var)
   continue;
 
-   int remove = entry->available & ir->write_mask;
+   int remove = entry->unused & ir->write_mask;
if (debug) {
   printf("%s 0x%01x - 0x%01x = 0x%01x\n",
  var->name,
@@ -219,7 +219,7 @@ process_assignment(void *ctx, ir_assignment *ir, exec_list 
*assignments)
   }
 
   entry->ir->write_mask &= ~remove;
-  entry->available &= ~remove;
+  entry->unused &= ~remove;
   if (entry->ir->write_mask == 0) {
  /* Delete the dead assignment. */
  entry->ir->remove();
@@ -283,7 +283,7 @@ process_assignment(void *ctx, ir_assignment *ir, exec_list 
*assignments)
   foreach_list(n, assignments) {
 assignment_entry *entry = (assignment_entry *) n;
 
-printf("%s (0x%01x)\n", entry->lhs->name, entry->available);
+printf("%s (0x%01x)\n", entry->lhs->name, entry->unused);
   }
}
 
-- 
1.9.0

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


[Mesa-dev] [PATCH 1/2] glsl: Skip making a temporary for assignments when we don't need one.

2014-03-05 Thread Eric Anholt
While we wish our optimization passes could identify all the cases where
we can coalesce our variables, we miss out on a lot of opportunities.

total instructions in shared programs: 1673849 -> 1673166 (-0.04%)
instructions in affected programs: 299521 -> 298838 (-0.23%)
GAINED:7
LOST:  0

Note that many programs are "hurt".  The notable ones are where we produce
unrolling in cases we didn't before (presumably just because of the lower
instruction count).  But there are also some cases where pushing things
right into the variables prevents copy propagation and tree grafting,
since we don't split our variable usage webs apart.
---
 src/glsl/ast.h  |  13 
 src/glsl/ast_to_hir.cpp | 171 +++-
 2 files changed, 123 insertions(+), 61 deletions(-)

diff --git a/src/glsl/ast.h b/src/glsl/ast.h
index 1efb306..d506627 100644
--- a/src/glsl/ast.h
+++ b/src/glsl/ast.h
@@ -199,6 +199,13 @@ public:
virtual ir_rvalue *hir(exec_list *instructions,
  struct _mesa_glsl_parse_state *state);
 
+   virtual void hir_no_rvalue(exec_list *instructions,
+  struct _mesa_glsl_parse_state *state);
+
+   ir_rvalue *do_hir(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state,
+ bool needs_rvalue);
+
virtual void print(void) const;
 
enum ast_operators oper;
@@ -269,6 +276,9 @@ public:
virtual ir_rvalue *hir(exec_list *instructions,
  struct _mesa_glsl_parse_state *state);
 
+   virtual void hir_no_rvalue(exec_list *instructions,
+  struct _mesa_glsl_parse_state *state);
+
 private:
/**
 * Is this function call actually a constructor?
@@ -341,6 +351,9 @@ public:
 
virtual ir_rvalue *hir(exec_list *instructions,
   struct _mesa_glsl_parse_state *state);
+
+   virtual void hir_no_rvalue(exec_list *instructions,
+  struct _mesa_glsl_parse_state *state);
 };
 
 /**
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 8f6e901..8d55ee3 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -56,6 +56,9 @@
 #include "glsl_types.h"
 #include "program/hash_table.h"
 #include "ir.h"
+#include "ir_builder.h"
+
+using namespace ir_builder;
 
 static void
 detect_conflicting_assignments(struct _mesa_glsl_parse_state *state,
@@ -733,10 +736,12 @@ mark_whole_array_access(ir_rvalue *access)
}
 }
 
-ir_rvalue *
+static bool
 do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state,
  const char *non_lvalue_description,
- ir_rvalue *lhs, ir_rvalue *rhs, bool is_initializer,
+ ir_rvalue *lhs, ir_rvalue *rhs,
+  ir_rvalue **out_rvalue, bool needs_rvalue,
+  bool is_initializer,
  YYLTYPE lhs_loc)
 {
void *ctx = state;
@@ -855,27 +860,33 @@ do_assignment(exec_list *instructions, struct 
_mesa_glsl_parse_state *state,
 * to handle things like:
 *
 * i = j += 1;
-*
-* So we always just store the computed value being assigned to a
-* temporary and return a deref of that temporary.  If the rvalue
-* ends up not being used, the temp will get copy-propagated out.
 */
-   ir_variable *var = new(ctx) ir_variable(rhs->type, "assignment_tmp",
-  ir_var_temporary);
-   ir_dereference_variable *deref_var = new(ctx) ir_dereference_variable(var);
-   instructions->push_tail(var);
-   instructions->push_tail(new(ctx) ir_assignment(deref_var, rhs));
-   deref_var = new(ctx) ir_dereference_variable(var);
+   if (needs_rvalue) {
+  ir_variable *var = new(ctx) ir_variable(rhs->type, "assignment_tmp",
+  ir_var_temporary);
+  instructions->push_tail(var);
+  instructions->push_tail(assign(var, rhs));
+
+  if (!error_emitted) {
+ ir_dereference_variable *deref_var = new(ctx) 
ir_dereference_variable(var);
+ instructions->push_tail(new(ctx) ir_assignment(lhs, deref_var));
+  }
+  ir_rvalue *rvalue = new(ctx) ir_dereference_variable(var);
 
-   if (!error_emitted)
-  instructions->push_tail(new(ctx) ir_assignment(lhs, deref_var));
+  if (extract_channel) {
+ rvalue = new(ctx) ir_expression(ir_binop_vector_extract,
+ rvalue,
+ extract_channel->clone(ctx, NULL));
+  }
 
-   if (extract_channel) {
-  return new(ctx) ir_expression(ir_binop_vector_extract,
-new(ctx) ir_dereference_variable(var),
-extract_channel->clone(ctx, NULL));
+  *out_rvalue = rvalue;
+   } else {
+  if (!error_emitted)
+ instructions->push_tail(new(ctx) ir_assignment(lhs, rhs));
+  *out_r