Re: [Mesa-dev] [PATCH 2/4] gallium: add PIPE_BIND_COMMAND_BUFFER

2013-04-05 Thread Christoph Bumiller
On 04.04.2013 21:53, Christoph Bumiller wrote:
 On 04.04.2013 21:44, Jose Fonseca wrote:
 I think that PIPE_BIND_INDIRECT_BUFFER would be more self-descriptive.

Marek suggested PIPE_BIND_DRAW_INDIRECT_BUFFER, but I think that's too
specific because there's also a DISPATCH_INDIRECT buffer for compute
shaders.

And just INDIRECT_BUFFER without the _DRAW_ doesn't seem so
self-descriptive if you're not thinking in the right context.

I'd like to stick with BIND_COMMAND_BUFFER, or maybe
BIND_COMMAND_ARGS_BUFFER ...

 Or do you envision other uses of such buffer?
 It's possible that at some point we add a mechanism to let the driver
 store arbitrary commands into a buffer created by the st, or have
 resources used as arguments conditional rendering ...
 Lost of possiblities, but nothing concrete, and for the command lists
 like with D3D's deferred contexts we'd probably return opaque objects
 that can contain more auxiliary data.
 I like it to be more generic, but then it could turn out that there be
 different requirements on these command source buffers in the future
 ... I'm undecided now.


 Jose

 - Original Message -
 Intended for use with GL_ARB_draw_indirect's DRAW_INDIRECT_BUFFER
 target or for D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS.
 ---
  src/gallium/docs/source/screen.rst   |2 ++
  src/gallium/include/pipe/p_defines.h |1 +
  2 files changed, 3 insertions(+), 0 deletions(-)

 diff --git a/src/gallium/docs/source/screen.rst
 b/src/gallium/docs/source/screen.rst
 index c1a3c0b..f8cdded 100644
 --- a/src/gallium/docs/source/screen.rst
 +++ b/src/gallium/docs/source/screen.rst
 @@ -306,6 +306,8 @@ resources might be created and handled quite 
 differently.
bound to the graphics pipeline as a shader resource.
  * ``PIPE_BIND_COMPUTE_RESOURCE``: A buffer or texture that can be
bound to the compute program as a shader resource.
 +* ``PIPE_BIND_COMMAND_BUFFER``: A buffer or that may be sourced by the
 +  GPU command processor, like with indirect drawing.
  
  .. _pipe_usage:
  
 diff --git a/src/gallium/include/pipe/p_defines.h
 b/src/gallium/include/pipe/p_defines.h
 index 5b00acc..2b79f2a 100644
 --- a/src/gallium/include/pipe/p_defines.h
 +++ b/src/gallium/include/pipe/p_defines.h
 @@ -315,6 +315,7 @@ enum pipe_flush_flags {
  #define PIPE_BIND_GLOBAL   (1  18) /* set_global_binding */
  #define PIPE_BIND_SHADER_RESOURCE  (1  19) /* set_shader_resources */
  #define PIPE_BIND_COMPUTE_RESOURCE (1  20) /* set_compute_resources 
 */
 +#define PIPE_BIND_COMMAND_BUFFER   (1  21) /* pipe_draw_info.indirect
 */
  
  /* The first two flags above were previously part of the amorphous
   * TEXTURE_USAGE, most of which are now descriptions of the ways a
 --
 1.7.3.4

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

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

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


Re: [Mesa-dev] [PATCH] gallivm: fix breakc

2013-04-05 Thread Jose Fonseca
- Original Message -
 we break when the mask values are 0 not, 1, plus it's bit comparison
 not a floating point comparison. This fixes both.
 
 Signed-off-by: Zack Rusin za...@vmware.com
 ---
  src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c |   26
  ---
  1 file changed, 14 insertions(+), 12 deletions(-)
 
 diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
 b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
 index d8c419b..1e062e9 100644
 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
 +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
 @@ -217,15 +217,14 @@ static void lp_exec_break_condition(struct lp_exec_mask
 *mask,
  LLVMValueRef cond)
  {
 LLVMBuilderRef builder = mask-bld-gallivm-builder;
 -   LLVMValueRef exec_mask = LLVMBuildNot(builder,
 +   LLVMValueRef cond_mask = LLVMBuildAnd(builder,
   mask-exec_mask,
 - break);
 -
 -   exec_mask = LLVMBuildAnd(builder, exec_mask, cond, );
 + cond, cond_mask);
 +   cond_mask = LLVMBuildNot(builder, cond, break_cond);
  
 mask-break_mask = LLVMBuildAnd(builder,
 mask-break_mask,
 -   exec_mask, break_full);
 +   cond_mask, breakc_full);
  
 lp_exec_mask_update(mask);
  }
 @@ -287,14 +286,14 @@ static void lp_exec_endloop(struct gallivm_state
 *gallivm,
builder,
LLVMIntNE,
LLVMBuildBitCast(builder, mask-exec_mask, reg_type, ),
 -  LLVMConstNull(reg_type), );
 +  LLVMConstNull(reg_type), i1cond);
  
 /* i2cond = (looplimiter  0) */
 i2cond = LLVMBuildICmp(
builder,
LLVMIntSGT,
limiter,
 -  LLVMConstNull(int_type), );
 +  LLVMConstNull(int_type), i2cond);
  
 /* if( i1cond  i2cond ) */
 icond = LLVMBuildAnd(builder, i1cond, i2cond, );
 @@ -2298,13 +2297,16 @@ breakc_emit(
 struct lp_build_tgsi_context * bld_base,
 struct lp_build_emit_data * emit_data)
  {
 -   LLVMValueRef tmp;
 struct lp_build_tgsi_soa_context * bld = lp_soa_context(bld_base);
 +   LLVMBuilderRef builder = bld_base-base.gallivm-builder;
 +   struct lp_build_context *uint_bld = bld_base-uint_bld;
 +   LLVMValueRef unsigned_cond =
 +  LLVMBuildBitCast(builder, emit_data-args[0], uint_bld-vec_type, );
 +   LLVMValueRef cond = lp_build_cmp(uint_bld, PIPE_FUNC_NOTEQUAL,
 +unsigned_cond,
 +uint_bld-zero);
  
 -   tmp = lp_build_cmp(bld_base-base, PIPE_FUNC_NOTEQUAL,
 -  emit_data-args[0], bld-bld_base.base.zero);
 -
 -   lp_exec_break_condition(bld-exec_mask, tmp);
 +   lp_exec_break_condition(bld-exec_mask, cond);
  }
  
  static void
 --
 1.7.10.4
 
 


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


Re: [Mesa-dev] [PATCH 1/4] mesa: implement GL_ARB_draw_indirect

2013-04-05 Thread Christoph Bumiller
On 04.04.2013 21:17, Brian Paul wrote:
 I just did a quick skim and found a few minor things.

 First, the subject might be mesa: implement GL_ARB_draw_indirect and
 GL_ARB_multi_draw_indirect

 This is a big patch and I think it could have been broken down into
 smaller pieces, but I know it's a PITA to redo.  Next time.

 +static void GLAPIENTRY
 +save_DrawArraysIndirect(GLenum mode, const GLvoid *indirect)
 +{
 +   GET_CURRENT_CONTEXT(ctx);
 +   _mesa_error(ctx, GL_INVALID_OPERATION,
 +   glDrawArraysIndirect() during display list compile);
 +}

 Is this specified in the spec?  IIRC, if a command isn't supposed to
 get compiled into a dlist it's just immediately executed.



Not that I can see.
But I figured since DrawElementsInstancedBaseVertex return
GL_INVALID_OPERATION, the indirect version, which is essentially the
same except for the place it takes its arguments from (especially in
compatibility mode, where the indirect argument is a user pointer (this
is not implemented, only exposing the extension in core profile for now,
which means it won't ever be used with display lists anyway until
compatibility for it is implemented), would behave the same.

I also don't get why DrawElements non-instanced non-baseVertex is
specified to execute immediately instead of returning INVALID_OPERATION.
Surely if I can draw one instance I can draw 2 instances if it's
executed immediately anyway.

The NV binary driver seems to simply execute it immediately fwiw.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/4] mesa: implement GL_ARB_draw_indirect

2013-04-05 Thread Christoph Bumiller
On 05.04.2013 13:32, Christoph Bumiller wrote:
 On 04.04.2013 21:17, Brian Paul wrote:
 I just did a quick skim and found a few minor things.

 First, the subject might be mesa: implement GL_ARB_draw_indirect and
 GL_ARB_multi_draw_indirect

 This is a big patch and I think it could have been broken down into
 smaller pieces, but I know it's a PITA to redo.  Next time.
 +static void GLAPIENTRY
 +save_DrawArraysIndirect(GLenum mode, const GLvoid *indirect)
 +{
 +   GET_CURRENT_CONTEXT(ctx);
 +   _mesa_error(ctx, GL_INVALID_OPERATION,
 +   glDrawArraysIndirect() during display list compile);
 +}
 Is this specified in the spec?  IIRC, if a command isn't supposed to
 get compiled into a dlist it's just immediately executed.


 Not that I can see.
 But I figured since DrawElementsInstancedBaseVertex return
 GL_INVALID_OPERATION, the indirect version, which is essentially the
 same except for the place it takes its arguments from (especially in
 compatibility mode, where the indirect argument is a user pointer (this
 is not implemented, only exposing the extension in core profile for now,
 which means it won't ever be used with display lists anyway until
 compatibility for it is implemented), would behave the same.


 I also don't get why DrawElements non-instanced non-baseVertex is
 specified to execute immediately instead of returning INVALID_OPERATION.
 Surely if I can draw one instance I can draw 2 instances if it's
 executed immediately anyway.
Nevermind this paragraph.

 The NV binary driver seems to simply execute it immediately fwiw.
 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev

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


Re: [Mesa-dev] [PATCH 2/4] gallium: add PIPE_BIND_COMMAND_BUFFER

2013-04-05 Thread Jose Fonseca
I don't feel strongly about it anyway. Can always change it later.

Jose

- Original Message -
 On 04.04.2013 21:53, Christoph Bumiller wrote:
  On 04.04.2013 21:44, Jose Fonseca wrote:
  I think that PIPE_BIND_INDIRECT_BUFFER would be more self-descriptive.
 
 Marek suggested PIPE_BIND_DRAW_INDIRECT_BUFFER, but I think that's too
 specific because there's also a DISPATCH_INDIRECT buffer for compute
 shaders.
 
 And just INDIRECT_BUFFER without the _DRAW_ doesn't seem so
 self-descriptive if you're not thinking in the right context.
 
 I'd like to stick with BIND_COMMAND_BUFFER, or maybe
 BIND_COMMAND_ARGS_BUFFER ...
 
  Or do you envision other uses of such buffer?
  It's possible that at some point we add a mechanism to let the driver
  store arbitrary commands into a buffer created by the st, or have
  resources used as arguments conditional rendering ...
  Lost of possiblities, but nothing concrete, and for the command lists
  like with D3D's deferred contexts we'd probably return opaque objects
  that can contain more auxiliary data.
  I like it to be more generic, but then it could turn out that there be
  different requirements on these command source buffers in the future
  ... I'm undecided now.
 
 
  Jose
 
  - Original Message -
  Intended for use with GL_ARB_draw_indirect's DRAW_INDIRECT_BUFFER
  target or for D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS.
  ---
   src/gallium/docs/source/screen.rst   |2 ++
   src/gallium/include/pipe/p_defines.h |1 +
   2 files changed, 3 insertions(+), 0 deletions(-)
 
  diff --git a/src/gallium/docs/source/screen.rst
  b/src/gallium/docs/source/screen.rst
  index c1a3c0b..f8cdded 100644
  --- a/src/gallium/docs/source/screen.rst
  +++ b/src/gallium/docs/source/screen.rst
  @@ -306,6 +306,8 @@ resources might be created and handled quite
  differently.
 bound to the graphics pipeline as a shader resource.
   * ``PIPE_BIND_COMPUTE_RESOURCE``: A buffer or texture that can be
 bound to the compute program as a shader resource.
  +* ``PIPE_BIND_COMMAND_BUFFER``: A buffer or that may be sourced by the
  +  GPU command processor, like with indirect drawing.
   
   .. _pipe_usage:
   
  diff --git a/src/gallium/include/pipe/p_defines.h
  b/src/gallium/include/pipe/p_defines.h
  index 5b00acc..2b79f2a 100644
  --- a/src/gallium/include/pipe/p_defines.h
  +++ b/src/gallium/include/pipe/p_defines.h
  @@ -315,6 +315,7 @@ enum pipe_flush_flags {
   #define PIPE_BIND_GLOBAL   (1  18) /* set_global_binding
   */
   #define PIPE_BIND_SHADER_RESOURCE  (1  19) /* set_shader_resources
   */
   #define PIPE_BIND_COMPUTE_RESOURCE (1  20) /*
   set_compute_resources */
  +#define PIPE_BIND_COMMAND_BUFFER   (1  21) /*
  pipe_draw_info.indirect
  */
   
   /* The first two flags above were previously part of the amorphous
* TEXTURE_USAGE, most of which are now descriptions of the ways a
  --
  1.7.3.4
 
  ___
  mesa-dev mailing list
  mesa-dev@lists.freedesktop.org
  http://lists.freedesktop.org/mailman/listinfo/mesa-dev
 
  ___
  mesa-dev mailing list
  mesa-dev@lists.freedesktop.org
  http://lists.freedesktop.org/mailman/listinfo/mesa-dev
 
 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 3/5] gallium: add PIPE_BIND_COMMAND_ARGS_BUFFER

2013-04-05 Thread Christoph Bumiller
Intended for use with GL_ARB_draw_indirect's DRAW_INDIRECT_BUFFER
target or for D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS.
---
 src/gallium/docs/source/screen.rst   |3 +++
 src/gallium/include/pipe/p_defines.h |1 +
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/gallium/docs/source/screen.rst 
b/src/gallium/docs/source/screen.rst
index c1a3c0b..d8cfb97 100644
--- a/src/gallium/docs/source/screen.rst
+++ b/src/gallium/docs/source/screen.rst
@@ -306,6 +306,9 @@ resources might be created and handled quite differently.
   bound to the graphics pipeline as a shader resource.
 * ``PIPE_BIND_COMPUTE_RESOURCE``: A buffer or texture that can be
   bound to the compute program as a shader resource.
+* ``PIPE_BIND_COMMAND_ARGS_BUFFER``: A buffer that may be sourced by the
+  GPU command processor. It can contain, for example, the arguments to
+  indirect draw calls.
 
 .. _pipe_usage:
 
diff --git a/src/gallium/include/pipe/p_defines.h 
b/src/gallium/include/pipe/p_defines.h
index 5b00acc..4c6b1f1 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -315,6 +315,7 @@ enum pipe_flush_flags {
 #define PIPE_BIND_GLOBAL   (1  18) /* set_global_binding */
 #define PIPE_BIND_SHADER_RESOURCE  (1  19) /* set_shader_resources */
 #define PIPE_BIND_COMPUTE_RESOURCE (1  20) /* set_compute_resources */
+#define PIPE_BIND_COMMAND_ARGS_BUFFER  (1  21) /* pipe_draw_info.indirect */
 
 /* The first two flags above were previously part of the amorphous
  * TEXTURE_USAGE, most of which are now descriptions of the ways a
-- 
1.7.3.4

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


[Mesa-dev] [PATCH 1/5] mesa: add indirect drawing buffer parameter to draw functions

2013-04-05 Thread Christoph Bumiller
Split from patch implementing ARB_draw_indirect.

v2:
Const-qualify the struct gl_buffer_object *indirect argument.
---
 src/mesa/drivers/dri/i965/brw_draw.c |3 ++-
 src/mesa/drivers/dri/i965/brw_draw.h |3 ++-
 src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c |9 ++---
 src/mesa/state_tracker/st_cb_rasterpos.c |2 +-
 src/mesa/state_tracker/st_draw.c |3 ++-
 src/mesa/state_tracker/st_draw.h |6 --
 src/mesa/state_tracker/st_draw_feedback.c|3 ++-
 src/mesa/tnl/tnl.h   |3 ++-
 src/mesa/vbo/vbo.h   |5 -
 src/mesa/vbo/vbo_exec_array.c|8 
 src/mesa/vbo/vbo_exec_draw.c |2 +-
 src/mesa/vbo/vbo_primitive_restart.c |4 ++--
 src/mesa/vbo/vbo_rebase.c|2 +-
 src/mesa/vbo/vbo_save_draw.c |2 +-
 src/mesa/vbo/vbo_split_copy.c|2 +-
 src/mesa/vbo/vbo_split_inplace.c |2 +-
 16 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_draw.c 
b/src/mesa/drivers/dri/i965/brw_draw.c
index 809bcc5..9212eb1 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -548,7 +548,8 @@ void brw_draw_prims( struct gl_context *ctx,
 GLboolean index_bounds_valid,
 GLuint min_index,
 GLuint max_index,
-struct gl_transform_feedback_object *tfb_vertcount )
+struct gl_transform_feedback_object *tfb_vertcount,
+const struct gl_buffer_object *indirect )
 {
struct intel_context *intel = intel_context(ctx);
const struct gl_client_array **arrays = ctx-Array._DrawArrays;
diff --git a/src/mesa/drivers/dri/i965/brw_draw.h 
b/src/mesa/drivers/dri/i965/brw_draw.h
index d86a9e7..8f0c768 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.h
+++ b/src/mesa/drivers/dri/i965/brw_draw.h
@@ -41,7 +41,8 @@ void brw_draw_prims( struct gl_context *ctx,
 GLboolean index_bounds_valid,
 GLuint min_index,
 GLuint max_index,
-struct gl_transform_feedback_object *tfb_vertcount );
+struct gl_transform_feedback_object *tfb_vertcount,
+const struct gl_buffer_object *indirect );
 
 void brw_draw_init( struct brw_context *brw );
 void brw_draw_destroy( struct brw_context *brw );
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c 
b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
index 436db32..69f30e2 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
@@ -222,7 +222,8 @@ TAG(vbo_render_prims)(struct gl_context *ctx,
  const struct _mesa_index_buffer *ib,
  GLboolean index_bounds_valid,
  GLuint min_index, GLuint max_index,
- struct gl_transform_feedback_object *tfb_vertcount);
+ struct gl_transform_feedback_object *tfb_vertcount,
+ const struct gl_buffer_object *indirect);
 
 static GLboolean
 vbo_maybe_split(struct gl_context *ctx, const struct gl_client_array **arrays,
@@ -453,7 +454,8 @@ TAG(vbo_render_prims)(struct gl_context *ctx,
  const struct _mesa_index_buffer *ib,
  GLboolean index_bounds_valid,
  GLuint min_index, GLuint max_index,
- struct gl_transform_feedback_object *tfb_vertcount)
+ struct gl_transform_feedback_object *tfb_vertcount,
+ const struct gl_buffer_object *indirect)
 {
struct nouveau_render_state *render = to_render_state(ctx);
const struct gl_client_array **arrays = ctx-Array._DrawArrays;
@@ -489,7 +491,8 @@ TAG(vbo_check_render_prims)(struct gl_context *ctx,
const struct _mesa_index_buffer *ib,
GLboolean index_bounds_valid,
GLuint min_index, GLuint max_index,
-   struct gl_transform_feedback_object *tfb_vertcount)
+   struct gl_transform_feedback_object *tfb_vertcount,
+   const struct gl_buffer_object *indirect)
 {
struct nouveau_context *nctx = to_nouveau_context(ctx);
 
diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c 
b/src/mesa/state_tracker/st_cb_rasterpos.c
index 4731f26..778218a1 100644
--- a/src/mesa/state_tracker/st_cb_rasterpos.c
+++ b/src/mesa/state_tracker/st_cb_rasterpos.c
@@ -255,7 +255,7 @@ st_RasterPos(struct gl_context *ctx, const GLfloat v[4])
 * st_feedback_draw_vbo doesn't check for that flag. */
ctx-Array._DrawArrays = rs-arrays;
st_feedback_draw_vbo(ctx, rs-prim, 1, NULL, GL_TRUE, 0, 1,
-NULL);
+NULL, 

[Mesa-dev] [PATCH 5/5] st/mesa: add support for indirect drawing

2013-04-05 Thread Christoph Bumiller
---
 src/mesa/state_tracker/st_cb_bufferobjects.c |3 +++
 src/mesa/state_tracker/st_draw.c |   11 ++-
 src/mesa/state_tracker/st_extensions.c   |3 ++-
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c 
b/src/mesa/state_tracker/st_cb_bufferobjects.c
index 8ff32c8..2e719cc 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -205,6 +205,9 @@ st_bufferobj_data(struct gl_context *ctx,
case GL_UNIFORM_BUFFER:
   bind = PIPE_BIND_CONSTANT_BUFFER;
   break;
+   case GL_DRAW_INDIRECT_BUFFER:
+  bind = PIPE_BIND_COMMAND_ARGS_BUFFER;
+  break;
default:
   bind = 0;
}
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 82a4bcd..3c74c50 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -256,6 +256,14 @@ st_draw_vbo(struct gl_context *ctx,
   }
}
 
+   if (indirect) {
+  info.indirect = st_buffer_object(indirect)-buffer;
+
+  /* Primitive restart is not handled by the VBO module in this case. */
+  info.primitive_restart = ctx-Array._PrimitiveRestart;
+  info.restart_index = ctx-Array._RestartIndex;
+   }
+
/* do actual drawing */
for (i = 0; i  nr_prims; i++) {
   info.mode = translate_prim( ctx, prims[i].mode );
@@ -268,6 +276,7 @@ st_draw_vbo(struct gl_context *ctx,
  info.min_index = info.start;
  info.max_index = info.start + info.count - 1;
   }
+  info.indirect_offset = prims[i].indirect_offset;
 
   if (ST_DEBUG  DEBUG_DRAW) {
  debug_printf(st/draw: mode %s  start %u  count %u  indexed %d\n,
@@ -277,7 +286,7 @@ st_draw_vbo(struct gl_context *ctx,
   info.indexed);
   }
 
-  if (info.count_from_stream_output) {
+  if (info.count_from_stream_output || info.indirect) {
  cso_draw_vbo(st-cso_context, info);
   }
   else if (info.primitive_restart) {
diff --git a/src/mesa/state_tracker/st_extensions.c 
b/src/mesa/state_tracker/st_extensions.c
index 11db9d3..0488755 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -398,7 +398,8 @@ void st_init_extensions(struct st_context *st)
   { o(MESA_texture_array),   PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS 
},
 
   { o(OES_standard_derivatives), PIPE_CAP_SM3  
},
-  { o(ARB_texture_cube_map_array),   PIPE_CAP_CUBE_MAP_ARRAY   
}
+  { o(ARB_texture_cube_map_array),   PIPE_CAP_CUBE_MAP_ARRAY   
},
+  { o(ARB_draw_indirect),PIPE_CAP_DRAW_INDIRECT
},
};
 
/* Required: render target and sampler support */
-- 
1.7.3.4

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


[Mesa-dev] [PATCH 2/5] mesa: implement GL_ARB_draw_indirect and GL_ARB_multi_draw_indirect

2013-04-05 Thread Christoph Bumiller
v2:
Removed some stray extern qualifiers.

Documented use of Draw*IndirectCommand sizes.

Removed separate extension enable flag for ARB_multi_draw_indirect
since this can always be supported by looping.

Kept generation of GL_INVALID_OPERATION in display list compile.
The spec doesn't say anything about them, but all the direct drawing
commands that support instancing do the same.
---
 src/mapi/glapi/gen/Makefile.am  |1 +
 src/mapi/glapi/gen/gl_API.xml   |4 +-
 src/mesa/main/api_validate.c|  153 +++
 src/mesa/main/api_validate.h|   26 
 src/mesa/main/bufferobj.c   |9 +
 src/mesa/main/dd.h  |   12 ++
 src/mesa/main/dlist.c   |   41 +
 src/mesa/main/extensions.c  |2 +
 src/mesa/main/get.c |5 +
 src/mesa/main/get_hash_params.py|2 +
 src/mesa/main/mtypes.h  |3 +
 src/mesa/main/tests/dispatch_sanity.cpp |8 +-
 src/mesa/main/vtxfmt.c  |7 +
 src/mesa/vbo/vbo_exec_array.c   |  249 +++
 src/mesa/vbo/vbo_save_api.c |   53 +++
 15 files changed, 570 insertions(+), 5 deletions(-)

diff --git a/src/mapi/glapi/gen/Makefile.am b/src/mapi/glapi/gen/Makefile.am
index 36e47e2..243c148 100644
--- a/src/mapi/glapi/gen/Makefile.am
+++ b/src/mapi/glapi/gen/Makefile.am
@@ -96,6 +96,7 @@ API_XML = \
ARB_depth_clamp.xml \
ARB_draw_buffers_blend.xml \
ARB_draw_elements_base_vertex.xml \
+   ARB_draw_indirect.xml \
ARB_draw_instanced.xml \
ARB_ES2_compatibility.xml \
ARB_ES3_compatibility.xml \
diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index df95924..f22fdac 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -8240,6 +8240,8 @@
 
 !-- ARB extensions #86...#93 --
 
+xi:include href=ARB_draw_indirect.xml 
xmlns:xi=http://www.w3.org/2001/XInclude/
+
 category name=GL_ARB_transform_feedback3 number=94
   enum name=MAX_TRANSFORM_FEEDBACK_BUFFERS value=0x8E70/
   enum name=MAX_VERTEX_STREAMS value=0x8E71/
@@ -8317,7 +8319,7 @@
 
 xi:include href=ARB_invalidate_subdata.xml 
xmlns:xi=http://www.w3.org/2001/XInclude/
 
-!-- ARB extensions #133...#138 --
+!-- ARB extensions #134...#138 --
 
 xi:include href=ARB_texture_buffer_range.xml 
xmlns:xi=http://www.w3.org/2001/XInclude/
 
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 53b0021..e875c5d 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -737,3 +737,156 @@ _mesa_validate_DrawTransformFeedback(struct gl_context 
*ctx,
 
return GL_TRUE;
 }
+
+static GLboolean
+valid_draw_indirect(struct gl_context *ctx,
+GLenum mode, const GLvoid *indirect,
+GLsizei size, const char *name)
+{
+   const GLsizeiptr end = (GLsizeiptr)indirect + size;
+
+   if (!_mesa_valid_prim_mode(ctx, mode, name))
+  return GL_FALSE;
+
+   if ((GLsizeiptr)indirect  (sizeof(GLuint) - 1)) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  %s(indirect is not aligned), name);
+  return GL_FALSE;
+   }
+
+   if (_mesa_is_bufferobj(ctx-DrawIndirectBuffer)) {
+  if (_mesa_bufferobj_mapped(ctx-DrawIndirectBuffer)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ %s(DRAW_INDIRECT_BUFFER is mapped), name);
+ return GL_FALSE;
+  }
+  if (ctx-DrawIndirectBuffer-Size  end) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ %s(DRAW_INDIRECT_BUFFER too small), name);
+ return GL_FALSE;
+  }
+   } else {
+  if (ctx-API != API_OPENGL_COMPAT) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ %s: no buffer bound to DRAW_INDIRECT_BUFFER, name);
+ return GL_FALSE;
+  }
+   }
+
+   if (!check_valid_to_render(ctx, name))
+  return GL_FALSE;
+
+   return GL_TRUE;
+}
+
+static inline GLboolean
+valid_draw_indirect_elements(struct gl_context *ctx,
+ GLenum mode, GLenum type, const GLvoid *indirect,
+ GLsizeiptr size, const char *name)
+{
+   if (!valid_elements_type(ctx, type, name))
+  return GL_FALSE;
+
+   /*
+* Unlike regular DrawElementsInstancedBaseVertex commands, the indices
+* may not come from a client array and must come from an index buffer.
+* If no element array buffer is bound, an INVALID_OPERATION error is
+* generated.
+*/
+   if (!_mesa_is_bufferobj(ctx-Array.ArrayObj-ElementArrayBufferObj)) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  %s(no buffer bound to GL_ELEMENT_ARRAY_BUFFER), name);
+  return GL_FALSE;
+   }
+
+   return valid_draw_indirect(ctx, mode, indirect, size, name);
+}
+
+static inline GLboolean
+valid_draw_indirect_multi(struct gl_context *ctx,
+  

[Mesa-dev] [PATCH 4/5] gallium: add facilities for indirect drawing

2013-04-05 Thread Christoph Bumiller
v2:
Added comments to util_draw_indirect, clarified and fixed map size.
Removed unlikely().
---
 src/gallium/auxiliary/util/u_draw.c  |   43 ++
 src/gallium/auxiliary/util/u_draw.h  |8 
 src/gallium/auxiliary/util/u_dump_state.c|3 ++
 src/gallium/docs/source/screen.rst   |3 ++
 src/gallium/drivers/freedreno/freedreno_screen.c |1 +
 src/gallium/drivers/i915/i915_screen.c   |1 +
 src/gallium/drivers/llvmpipe/lp_draw_arrays.c|5 +++
 src/gallium/drivers/llvmpipe/lp_screen.c |2 +
 src/gallium/drivers/nv30/nv30_screen.c   |1 +
 src/gallium/drivers/nv50/nv50_screen.c   |2 +
 src/gallium/drivers/r300/r300_screen.c   |1 +
 src/gallium/drivers/r600/r600_pipe.c |1 +
 src/gallium/drivers/radeonsi/radeonsi_pipe.c |1 +
 src/gallium/drivers/softpipe/sp_draw_arrays.c|6 +++
 src/gallium/drivers/softpipe/sp_screen.c |2 +
 src/gallium/drivers/svga/svga_screen.c   |1 +
 src/gallium/drivers/trace/tr_dump_state.c|3 ++
 src/gallium/include/pipe/p_defines.h |3 +-
 src/gallium/include/pipe/p_state.h   |   22 +++
 19 files changed, 108 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_draw.c 
b/src/gallium/auxiliary/util/u_draw.c
index 83d9284..b9f8fcd 100644
--- a/src/gallium/auxiliary/util/u_draw.c
+++ b/src/gallium/auxiliary/util/u_draw.c
@@ -27,6 +27,7 @@
 
 
 #include util/u_debug.h
+#include util/u_inlines.h
 #include util/u_math.h
 #include util/u_format.h
 #include util/u_draw.h
@@ -123,3 +124,45 @@ util_draw_max_index(
 
return max_index + 1;
 }
+
+
+/* This extracts the draw arguments from the info_in-indirect resource,
+ * puts them into a new instance of pipe_draw_info, and calls draw_vbo on it.
+ */
+void
+util_draw_indirect(struct pipe_context *pipe,
+   const struct pipe_draw_info *info_in)
+{
+   struct pipe_draw_info info;
+   struct pipe_transfer *transfer;
+   uint32_t *params;
+   const unsigned num_params = info_in-indexed ? 5 : 4;
+
+   assert(info_in-indirect);
+   assert(!info_in-count_from_stream_output);
+
+   memcpy(info, info_in, sizeof(info));
+
+   params = (uint32_t *)
+  pipe_buffer_map_range(pipe,
+info_in-indirect,
+info_in-indirect_offset,
+num_params * sizeof(uint32_t),
+PIPE_TRANSFER_READ,
+transfer);
+   if (!transfer) {
+  debug_printf(%s: failed to map indirect buffer\n, __FUNCTION__);
+  return;
+   }
+
+   info.count = params[0];
+   info.instance_count = params[1];
+   info.start = params[2];
+   info.index_bias = info_in-indexed ? params[3] : 0;
+   info.start_instance = info_in-indexed ? params[4] : params[3];
+   info.indirect = NULL;
+
+   pipe_buffer_unmap(pipe, transfer);
+
+   pipe-draw_vbo(pipe, info);
+}
diff --git a/src/gallium/auxiliary/util/u_draw.h 
b/src/gallium/auxiliary/util/u_draw.h
index 3dc6918..1dd6b51 100644
--- a/src/gallium/auxiliary/util/u_draw.h
+++ b/src/gallium/auxiliary/util/u_draw.h
@@ -142,6 +142,14 @@ util_draw_range_elements(struct pipe_context *pipe,
 }
 
 
+/* This converts an indirect draw into a direct draw by mapping the indirect
+ * buffer, extracting its arguments, and calling pipe-draw_vbo.
+ */
+void
+util_draw_indirect(struct pipe_context *pipe,
+   const struct pipe_draw_info *info);
+
+
 unsigned
 util_draw_max_index(
   const struct pipe_vertex_buffer *vertex_buffers,
diff --git a/src/gallium/auxiliary/util/u_dump_state.c 
b/src/gallium/auxiliary/util/u_dump_state.c
index 2f28f3c..21b6044 100644
--- a/src/gallium/auxiliary/util/u_dump_state.c
+++ b/src/gallium/auxiliary/util/u_dump_state.c
@@ -758,6 +758,9 @@ util_dump_draw_info(FILE *stream, const struct 
pipe_draw_info *state)
 
util_dump_member(stream, ptr, state, count_from_stream_output);
 
+   util_dump_member(stream, ptr, state, indirect);
+   util_dump_member(stream, uint, state, indirect_offset);
+
util_dump_struct_end(stream);
 }
 
diff --git a/src/gallium/docs/source/screen.rst 
b/src/gallium/docs/source/screen.rst
index d8cfb97..96f316a 100644
--- a/src/gallium/docs/source/screen.rst
+++ b/src/gallium/docs/source/screen.rst
@@ -151,6 +151,9 @@ The integer capabilities:
   dedicated memory should return 1 and all software rasterizers should return 
0.
 * ``PIPE_CAP_QUERY_PIPELINE_STATISTICS``: Whether 
PIPE_QUERY_PIPELINE_STATISTICS
   is supported.
+* ``PIPE_CAP_DRAW_INDIRECT``: Whether the driver supports taking draw arguments
+  { count, instance_count, start, index_bias } from a PIPE_BUFFER resource.
+  See pipe_draw_info.
 
 
 .. _pipe_capf:
diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c 
b/src/gallium/drivers/freedreno/freedreno_screen.c
index 283d07f..2b13e29 100644
--- 

[Mesa-dev] [PATCH] st/mesa: add support for indirect drawing v2

2013-04-05 Thread Christoph Bumiller
v2:
Fix for constness of indirect buffer argument.
Remove separate extension enable for multi_draw_indirect.
---
 src/mesa/state_tracker/st_cb_bufferobjects.c |3 +++
 src/mesa/state_tracker/st_cb_bufferobjects.h |6 ++
 src/mesa/state_tracker/st_draw.c |   11 ++-
 src/mesa/state_tracker/st_extensions.c   |3 ++-
 4 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c 
b/src/mesa/state_tracker/st_cb_bufferobjects.c
index 8ff32c8..2e719cc 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -205,6 +205,9 @@ st_bufferobj_data(struct gl_context *ctx,
case GL_UNIFORM_BUFFER:
   bind = PIPE_BIND_CONSTANT_BUFFER;
   break;
+   case GL_DRAW_INDIRECT_BUFFER:
+  bind = PIPE_BIND_COMMAND_ARGS_BUFFER;
+  break;
default:
   bind = 0;
}
diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.h 
b/src/mesa/state_tracker/st_cb_bufferobjects.h
index 1c991d2..05cc0fa 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.h
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.h
@@ -54,6 +54,12 @@ st_buffer_object(struct gl_buffer_object *obj)
return (struct st_buffer_object *) obj;
 }
 
+static INLINE const struct st_buffer_object *
+st_const_buffer_object(const struct gl_buffer_object *obj)
+{
+   return (const struct st_buffer_object *) obj;
+}
+
 
 extern void
 st_bufferobj_validate_usage(struct st_context *st,
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 82a4bcd..a07f8be 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -256,6 +256,14 @@ st_draw_vbo(struct gl_context *ctx,
   }
}
 
+   if (indirect) {
+  info.indirect = st_const_buffer_object(indirect)-buffer;
+
+  /* Primitive restart is not handled by the VBO module in this case. */
+  info.primitive_restart = ctx-Array._PrimitiveRestart;
+  info.restart_index = ctx-Array._RestartIndex;
+   }
+
/* do actual drawing */
for (i = 0; i  nr_prims; i++) {
   info.mode = translate_prim( ctx, prims[i].mode );
@@ -268,6 +276,7 @@ st_draw_vbo(struct gl_context *ctx,
  info.min_index = info.start;
  info.max_index = info.start + info.count - 1;
   }
+  info.indirect_offset = prims[i].indirect_offset;
 
   if (ST_DEBUG  DEBUG_DRAW) {
  debug_printf(st/draw: mode %s  start %u  count %u  indexed %d\n,
@@ -277,7 +286,7 @@ st_draw_vbo(struct gl_context *ctx,
   info.indexed);
   }
 
-  if (info.count_from_stream_output) {
+  if (info.count_from_stream_output || info.indirect) {
  cso_draw_vbo(st-cso_context, info);
   }
   else if (info.primitive_restart) {
diff --git a/src/mesa/state_tracker/st_extensions.c 
b/src/mesa/state_tracker/st_extensions.c
index 11db9d3..0488755 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -398,7 +398,8 @@ void st_init_extensions(struct st_context *st)
   { o(MESA_texture_array),   PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS 
},
 
   { o(OES_standard_derivatives), PIPE_CAP_SM3  
},
-  { o(ARB_texture_cube_map_array),   PIPE_CAP_CUBE_MAP_ARRAY   
}
+  { o(ARB_texture_cube_map_array),   PIPE_CAP_CUBE_MAP_ARRAY   
},
+  { o(ARB_draw_indirect),PIPE_CAP_DRAW_INDIRECT
},
};
 
/* Required: render target and sampler support */
-- 
1.7.3.4

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


[Mesa-dev] [PATCH] mesa/draw_indirect: fix index bounds

2013-04-05 Thread Christoph Bumiller
(Will be merged into the original patches.)

Calculating the actual limits is impossible, and softpipe drops
vertices that lie outside the specified range.
---
 src/gallium/auxiliary/util/u_draw.c |4 
 src/mesa/state_tracker/st_draw.c|3 +++
 src/mesa/vbo/vbo_exec_array.c   |8 
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_draw.c 
b/src/gallium/auxiliary/util/u_draw.c
index b9f8fcd..d13ccd4 100644
--- a/src/gallium/auxiliary/util/u_draw.c
+++ b/src/gallium/auxiliary/util/u_draw.c
@@ -161,6 +161,10 @@ util_draw_indirect(struct pipe_context *pipe,
info.index_bias = info_in-indexed ? params[3] : 0;
info.start_instance = info_in-indexed ? params[4] : params[3];
info.indirect = NULL;
+   if (!info_in-indexed) {
+  info.min_index = info.start;
+  info.max_index = info.start + info.count - 1;
+   }
 
pipe_buffer_unmap(pipe, transfer);
 
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index a07f8be..64470f7 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -273,6 +273,9 @@ st_draw_vbo(struct gl_context *ctx,
   info.instance_count = prims[i].num_instances;
   info.index_bias = prims[i].basevertex;
   if (!ib) {
+ /* NOTE: For indirect drawing, max_index correctly evaluates to ~0,
+  * since start and count will be 0.
+  */
  info.min_index = info.start;
  info.max_index = info.start + info.count - 1;
   }
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 75fda00..ba70b5b 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -1382,7 +1382,7 @@ vbo_validated_drawarraysindirect(struct gl_context *ctx,
 
check_buffers_are_unmapped(exec-array.inputs);
vbo-draw_prims(ctx, prim, 1,
-   NULL, GL_TRUE, 0, 0,
+   NULL, GL_TRUE, 0, ~0,
NULL,
ctx-DrawIndirectBuffer);
 
@@ -1422,7 +1422,7 @@ vbo_validated_multidrawarraysindirect(struct gl_context 
*ctx,
 
check_buffers_are_unmapped(exec-array.inputs);
vbo-draw_prims(ctx, prim, primcount,
-   NULL, GL_TRUE, 0, 0,
+   NULL, GL_TRUE, 0, ~0,
NULL,
ctx-DrawIndirectBuffer);
 
@@ -1458,7 +1458,7 @@ vbo_validated_drawelementsindirect(struct gl_context *ctx,
 
check_buffers_are_unmapped(exec-array.inputs);
vbo-draw_prims(ctx, prim, 1,
-   ib, GL_TRUE, 0, 0,
+   ib, GL_TRUE, 0, ~0,
NULL,
ctx-DrawIndirectBuffer);
 
@@ -1507,7 +1507,7 @@ vbo_validated_multidrawelementsindirect(struct gl_context 
*ctx,
 
check_buffers_are_unmapped(exec-array.inputs);
vbo-draw_prims(ctx, prim, primcount,
-   ib, GL_TRUE, 0, 0,
+   ib, GL_TRUE, 0, ~0,
NULL,
ctx-DrawIndirectBuffer);
 
-- 
1.7.3.4

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


Re: [Mesa-dev] [PATCH] gallium/u_blitter: fix is_blit_generic_supported() stencil checking

2013-04-05 Thread Jose Fonseca


- Original Message -
 Don't check if there's sampler support for stencil if we're not
 going to actually blit/copy stencil values.  Fixes the case where
 we mistakenly said we can't support a blit of depth values from
 S8Z24 to X8Z24.
 
 Also, rename the is_stencil variable to dst_has_stencil to improve
 readability.
 
 NOTE: This is a candidate for the stable branches.
 ---
  src/gallium/auxiliary/util/u_blitter.c |   28 +++-
  1 files changed, 15 insertions(+), 13 deletions(-)
 
 diff --git a/src/gallium/auxiliary/util/u_blitter.c
 b/src/gallium/auxiliary/util/u_blitter.c
 index 70fec91..2a4a13e 100644
 --- a/src/gallium/auxiliary/util/u_blitter.c
 +++ b/src/gallium/auxiliary/util/u_blitter.c
 @@ -1135,18 +1135,17 @@ static boolean is_blit_generic_supported(struct
 blitter_context *blitter,
  
 if (dst) {
unsigned bind;
 -  boolean is_stencil;
const struct util_format_description *desc =
  util_format_description(dst_format);
 -
 -  is_stencil = util_format_has_stencil(desc);
 +  boolean dst_has_stencil = util_format_has_stencil(desc);
  
/* Stencil export must be supported for stencil copy. */
 -  if ((mask  PIPE_MASK_S)  is_stencil  !ctx-has_stencil_export) {
 +  if ((mask  PIPE_MASK_S)  dst_has_stencil 
 +  !ctx-has_stencil_export) {
   return FALSE;
}
  
 -  if (is_stencil || util_format_has_depth(desc))
 +  if (dst_has_stencil || util_format_has_depth(desc))
   bind = PIPE_BIND_DEPTH_STENCIL;
else
   bind = PIPE_BIND_RENDER_TARGET;
 @@ -1168,15 +1167,18 @@ static boolean is_blit_generic_supported(struct
 blitter_context *blitter,
}
  
/* Check stencil sampler support for stencil copy. */
 -  if (util_format_has_stencil(util_format_description(src_format))) {
 - enum pipe_format stencil_format =
 +  if (mask  PIPE_MASK_S) {
 + if (util_format_has_stencil(util_format_description(src_format))) {
 +enum pipe_format stencil_format =
 util_format_stencil_only(src_format);
 - assert(stencil_format != PIPE_FORMAT_NONE);
 +assert(stencil_format != PIPE_FORMAT_NONE);
  
 - if (stencil_format != src_format 
 - !screen-is_format_supported(screen, stencil_format,
 src-target,
 - src-nr_samples, PIPE_BIND_SAMPLER_VIEW)) {
 -return FALSE;
 +if (stencil_format != src_format 
 +!screen-is_format_supported(screen, stencil_format,
 + src-target, src-nr_samples,
 + PIPE_BIND_SAMPLER_VIEW)) {
 +   return FALSE;
 +}
   }
}
 }
 --
 1.7.3.4
 
 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev
 

Looks good to me.

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


Re: [Mesa-dev] [PATCH] gallium/u_blitter: fix is_blit_generic_supported() stencil checking

2013-04-05 Thread Brian Paul

On 04/05/2013 11:32 AM, Jose Fonseca wrote:



- Original Message -

Don't check if there's sampler support for stencil if we're not
going to actually blit/copy stencil values.  Fixes the case where
we mistakenly said we can't support a blit of depth values from
S8Z24 to X8Z24.

Also, rename the is_stencil variable to dst_has_stencil to improve
readability.

NOTE: This is a candidate for the stable branches.
---
  src/gallium/auxiliary/util/u_blitter.c |   28 +++-
  1 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_blitter.c
b/src/gallium/auxiliary/util/u_blitter.c
index 70fec91..2a4a13e 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -1135,18 +1135,17 @@ static boolean is_blit_generic_supported(struct
blitter_context *blitter,

 if (dst) {
unsigned bind;
-  boolean is_stencil;
const struct util_format_description *desc =
  util_format_description(dst_format);
-
-  is_stencil = util_format_has_stencil(desc);
+  boolean dst_has_stencil = util_format_has_stencil(desc);

/* Stencil export must be supported for stencil copy. */
-  if ((mask  PIPE_MASK_S)  is_stencil  !ctx-has_stencil_export) {
+  if ((mask  PIPE_MASK_S)  dst_has_stencil
+  !ctx-has_stencil_export) {
   return FALSE;
}

-  if (is_stencil || util_format_has_depth(desc))
+  if (dst_has_stencil || util_format_has_depth(desc))
   bind = PIPE_BIND_DEPTH_STENCIL;
else
   bind = PIPE_BIND_RENDER_TARGET;
@@ -1168,15 +1167,18 @@ static boolean is_blit_generic_supported(struct
blitter_context *blitter,
}

/* Check stencil sampler support for stencil copy. */
-  if (util_format_has_stencil(util_format_description(src_format))) {
- enum pipe_format stencil_format =
+  if (mask  PIPE_MASK_S) {
+ if (util_format_has_stencil(util_format_description(src_format))) {
+enum pipe_format stencil_format =
 util_format_stencil_only(src_format);
- assert(stencil_format != PIPE_FORMAT_NONE);
+assert(stencil_format != PIPE_FORMAT_NONE);

- if (stencil_format != src_format
- !screen-is_format_supported(screen, stencil_format,
src-target,
- src-nr_samples, PIPE_BIND_SAMPLER_VIEW)) {
-return FALSE;
+if (stencil_format != src_format
+!screen-is_format_supported(screen, stencil_format,
+ src-target, src-nr_samples,
+ PIPE_BIND_SAMPLER_VIEW)) {
+   return FALSE;
+}
   }
}
 }
--
1.7.3.4

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



Looks good to me.

Reviewed-by: Jose Fonsecajfons...@vmware.com


Thanks.  I'm hoping that Marek can also review since he's the original 
author...


-Brian

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


[Mesa-dev] [PATCH] gallium/auxiliary: Add ETC as compressed format

2013-04-05 Thread Wladimir
From 1b3d69d7749e3b82f529d2a41b80f5cd64447d92 Mon Sep 17 00:00:00 2001
From: Wladimir J. van der Laan laa...@gmail.com
Date: Fri, 5 Apr 2013 18:58:32 +0200
Subject: [PATCH] gallium/auxiliary: Add ETC as compressed format

Add UTIL_FORMAT_LAYOUT_ETC to util_format_is_compressed. It was missing.

Signed-off-by: Wladimir J. van der Laan laa...@gmail.com
---
 src/gallium/auxiliary/util/u_format.h |1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/auxiliary/util/u_format.h
b/src/gallium/auxiliary/util/u_format.h
index 0030126..ed942fb 100644
--- a/src/gallium/auxiliary/util/u_format.h
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -447,6 +447,7 @@ util_format_is_compressed(enum pipe_format format)
switch (desc-layout) {
case UTIL_FORMAT_LAYOUT_S3TC:
case UTIL_FORMAT_LAYOUT_RGTC:
+   case UTIL_FORMAT_LAYOUT_ETC:
   /* XXX add other formats in the future */
   return TRUE;
default:
-- 
1.7.9.5
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 47607] [advocacy] Make Anomaly Warzone Earth work with Mesa

2013-04-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=47607

--- Comment #11 from Jordan Justen jljus...@gmail.com ---
I wanted to add one note. The game now works for me with
Mesa 9.0.3 via Steam, but it is crashing for me with Mesa 9.1.1
after the intro movie. I'll work with the game developer on
this...

-- 
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] gallium/auxiliary: Add ETC as compressed format

2013-04-05 Thread Brian Paul

On 04/05/2013 11:49 AM, Wladimir wrote:

 From 1b3d69d7749e3b82f529d2a41b80f5cd64447d92 Mon Sep 17 00:00:00 2001
From: Wladimir J. van der Laan laa...@gmail.com
mailto:laa...@gmail.com
Date: Fri, 5 Apr 2013 18:58:32 +0200
Subject: [PATCH] gallium/auxiliary: Add ETC as compressed format

Add UTIL_FORMAT_LAYOUT_ETC to util_format_is_compressed. It was missing.

Signed-off-by: Wladimir J. van der Laan laa...@gmail.com
mailto:laa...@gmail.com
---
  src/gallium/auxiliary/util/u_format.h |1 +
  1 file changed, 1 insertion(+)

diff --git a/src/gallium/auxiliary/util/u_format.h
b/src/gallium/auxiliary/util/u_format.h
index 0030126..ed942fb 100644
--- a/src/gallium/auxiliary/util/u_format.h
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -447,6 +447,7 @@ util_format_is_compressed(enum pipe_format format)
 switch (desc-layout) {
 case UTIL_FORMAT_LAYOUT_S3TC:
 case UTIL_FORMAT_LAYOUT_RGTC:
+   case UTIL_FORMAT_LAYOUT_ETC:
/* XXX add other formats in the future */
return TRUE;
 default:


Reviewed-by: Brian Paul bri...@vmware.com

Do you need someone to commit this for you?

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


[Mesa-dev] [PATCH 2/2] i965/vs: Use GRFs for pull constant offsets on gen7.

2013-04-05 Thread Eric Anholt
This allows the computation of the offset to get written directly into the
message source.

shader-db results:
total instructions in shared programs: 3308390 - 3283025 (-0.77%)
instructions in affected programs: 442998 - 417633 (-5.73%)

No difference in GLB2.7 low res (n=9).
---
 src/mesa/drivers/dri/i965/brw_defines.h|1 +
 src/mesa/drivers/dri/i965/brw_shader.cpp   |2 ++
 src/mesa/drivers/dri/i965/brw_vec4.cpp |8 -
 src/mesa/drivers/dri/i965/brw_vec4.h   |4 +++
 src/mesa/drivers/dri/i965/brw_vec4_emit.cpp|   45 +++-
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp |   18 +++---
 6 files changed, 56 insertions(+), 22 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_defines.h 
b/src/mesa/drivers/dri/i965/brw_defines.h
index 3d07c36..a13f9dc 100644
--- a/src/mesa/drivers/dri/i965/brw_defines.h
+++ b/src/mesa/drivers/dri/i965/brw_defines.h
@@ -739,6 +739,7 @@ enum opcode {
VS_OPCODE_SCRATCH_READ,
VS_OPCODE_SCRATCH_WRITE,
VS_OPCODE_PULL_CONSTANT_LOAD,
+   VS_OPCODE_PULL_CONSTANT_LOAD_GEN7,
 };
 
 #define BRW_PREDICATE_NONE 0
diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp 
b/src/mesa/drivers/dri/i965/brw_shader.cpp
index 1a52039..b3bd1b9 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -498,6 +498,8 @@ brw_instruction_name(enum opcode op)
   return scratch_write;
case VS_OPCODE_PULL_CONSTANT_LOAD:
   return pull_constant_load;
+   case VS_OPCODE_PULL_CONSTANT_LOAD_GEN7:
+  return pull_constant_load_gen7;
 
default:
   /* Yes, this leaks.  It's in debug code, it should never occur, and if
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index e470ac8..67dd17a 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -230,7 +230,13 @@ vec4_instruction::is_math()
 bool
 vec4_instruction::is_send_from_grf()
 {
-   return opcode == SHADER_OPCODE_SHADER_TIME_ADD;
+   switch (opcode) {
+   case SHADER_OPCODE_SHADER_TIME_ADD:
+   case VS_OPCODE_PULL_CONSTANT_LOAD_GEN7:
+  return true;
+   default:
+  return false;
+   }
 }
 
 bool
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h 
b/src/mesa/drivers/dri/i965/brw_vec4.h
index 8f130e1..e286925 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -544,6 +544,10 @@ private:
struct brw_reg dst,
struct brw_reg index,
struct brw_reg offset);
+   void generate_pull_constant_load_gen7(vec4_instruction *inst,
+ struct brw_reg dst,
+ struct brw_reg surf_index,
+ struct brw_reg offset);
 
struct brw_context *brw;
struct intel_context *intel;
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
index e378f7f..963901c 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp
@@ -558,27 +558,11 @@ 
vec4_generator::generate_pull_constant_load(vec4_instruction *inst,
 struct brw_reg index,
 struct brw_reg offset)
 {
+   assert(intel-gen = 7);
assert(index.file == BRW_IMMEDIATE_VALUE 
  index.type == BRW_REGISTER_TYPE_UD);
uint32_t surf_index = index.dw1.ud;
 
-   if (intel-gen == 7) {
-  gen6_resolve_implied_move(p, offset, inst-base_mrf);
-  brw_instruction *insn = brw_next_insn(p, BRW_OPCODE_SEND);
-  brw_set_dest(p, insn, dst);
-  brw_set_src0(p, insn, offset);
-  brw_set_sampler_message(p, insn,
-  surf_index,
-  0, /* LD message ignores sampler unit */
-  GEN5_SAMPLER_MESSAGE_SAMPLE_LD,
-  1, /* rlen */
-  1, /* mlen */
-  false, /* no header */
-  BRW_SAMPLER_SIMD_MODE_SIMD4X2,
-  0);
-  return;
-   }
-
struct brw_reg header = brw_vec8_grf(0, 0);
 
gen6_resolve_implied_move(p, header, inst-base_mrf);
@@ -614,6 +598,29 @@ 
vec4_generator::generate_pull_constant_load(vec4_instruction *inst,
 }
 
 void
+vec4_generator::generate_pull_constant_load_gen7(vec4_instruction *inst,
+ struct brw_reg dst,
+ struct brw_reg surf_index,
+ struct brw_reg offset)
+{
+   assert(surf_index.file == BRW_IMMEDIATE_VALUE 
+ surf_index.type == BRW_REGISTER_TYPE_UD);
+
+   brw_instruction *insn = brw_next_insn(p, BRW_OPCODE_SEND);
+   

[Mesa-dev] [Bug 63078] EGL X11 Regression: Maximum swap interval is 0 (worked with 9.0)

2013-04-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=63078

Chad Versace chad.vers...@linux.intel.com changed:

   What|Removed |Added

 CC||chad.vers...@linux.intel.co
   ||m

-- 
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] [Bug 56542] [bisected] Piglit gl_select tests crash on exit

2013-04-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=56542

Jerome Glisse gli...@freedesktop.org changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |NOTOURBUG

--- Comment #1 from Jerome Glisse gli...@freedesktop.org ---
It's a freeglut bug, they should not close X connection in an atexit handler.
This is really bad.

-- 
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 2/3] intel: Do temporary CPU maps of textures that are too big to GTT map.

2013-04-05 Thread Eric Anholt
Daniel Vetter dan...@ffwll.ch writes:

 On Tue, Apr 02, 2013 at 06:46:32PM -0700, Eric Anholt wrote:
 This still fails, since 8192*4bpp == 32768, which is too big to use the
 blitter on.
 
 Reviewed-by: Kenneth Graunke kenn...@whitecape.org
 ---
  src/mesa/drivers/dri/intel/intel_mipmap_tree.c |   21 +
  1 file changed, 21 insertions(+)
 
 diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c 
 b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
 index ffdaec5..5e0cd61 100644
 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
 +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
 @@ -1703,6 +1703,23 @@ intel_miptree_map_singlesample(struct intel_context 
 *intel,
  {
 struct intel_miptree_map *map;
  
 +   /* Estimate the size of the mappable aperture into the GTT.  There's an
 +* ioctl to get the whole GTT size, but not one to get the mappable 
 subset.
 +* It turns out it's basically always 256MB, though some ancient hardware
 +* was smaller.
 +*/

 Gen6+ have an adjustable GTT with sizes 128M, 256M and 512M. At least
 128M I've seen in the wild. Do we need a new getparam? Iirc the ddx
 cobbles this out of libpciaccess by looking at the size of the relevant
 bar. Also note that on old crap (this seems to be part of the shared intel
 library functions) it can be as little as 64M ;-)

Yeah, I'd forgotten that we actually did see 128 post-gen4, and that it
was either 64 or 128 on gen2.

For the purpose of this code, I'm pretty comfortable with being really
conservative to get the bugs fixed, and I'd love to see the getter from
the kernel to get the real number later.  The 2D driver having to do
pciaccess for this is something we need to fix for non-root X some day
anyway, right?


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


[Mesa-dev] [PATCH 4/4] radeonsi: Handle new format for configuration values emitted by the LLVM backend

2013-04-05 Thread Tom Stellard
From: Tom Stellard thomas.stell...@amd.com

Instead of emitting configuration values (e.g. number of gprs used) in a
predefined order, the LLVM backend now emits these values in
register/value pairs.  The first dword contains the register address and
the second dword contians the value to write.
---
 src/gallium/drivers/radeonsi/radeonsi_shader.c | 26 +++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.c 
b/src/gallium/drivers/radeonsi/radeonsi_shader.c
index 0aeecc2..78c1cf4 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_shader.c
+++ b/src/gallium/drivers/radeonsi/radeonsi_shader.c
@@ -1175,9 +1175,29 @@ int si_pipe_shader_create(
}
}
 
-   shader-num_sgprs = util_le32_to_cpu(*(uint32_t*)binary.config);
-   shader-num_vgprs = util_le32_to_cpu(*(uint32_t*)(binary.config + 4));
-   shader-spi_ps_input_ena = util_le32_to_cpu(*(uint32_t*)(binary.config 
+ 8));
+   /* XXX: We may be able to emit some of these values directly rather than
+* extracting fields to be emitted later.
+*/
+   for (i = 0; i  binary.config_size; i+= 8) {
+   unsigned reg = util_le32_to_cpu(*(uint32_t*)(binary.config + 
i));
+   unsigned value = util_le32_to_cpu(*(uint32_t*)(binary.config + 
i + 4));
+   switch (reg) {
+   case R_00B028_SPI_SHADER_PGM_RSRC1_PS:
+   case R_00B128_SPI_SHADER_PGM_RSRC1_VS:
+   case R_00B228_SPI_SHADER_PGM_RSRC1_GS:
+   case R_00B848_COMPUTE_PGM_RSRC1:
+   shader-num_sgprs = (G_00B028_SGPRS(value) * 8) + 1;
+   shader-num_vgprs = (G_00B028_VGPRS(value) * 4) + 1;
+   break;
+   case R_0286CC_SPI_PS_INPUT_ENA:
+   shader-spi_ps_input_ena = value;
+   break;
+   default:
+   fprintf(stderr, Warning: Compiler emitted unknown 
+   config register: 0x%x\n, reg);
+   break;
+   }
+   }
 
radeon_llvm_dispose(si_shader_ctx.radeon_bld);
tgsi_parse_free(si_shader_ctx.parse);
-- 
1.8.1.5

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


[Mesa-dev] [PATCH 2/4] radeon/llvm: Handle ELF formatted binary output from the LLVM backend

2013-04-05 Thread Tom Stellard
From: Tom Stellard thomas.stell...@amd.com

---
 configure.ac|  2 ++
 src/gallium/drivers/radeon/Makefile.am  |  3 +-
 src/gallium/drivers/radeon/radeon_llvm_emit.cpp | 38 ++---
 3 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index 81d4a3f..9e550e3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1776,6 +1776,8 @@ radeon_llvm_check() {
 fi
 AC_MSG_WARN([Please ensure you use the latest llvm tree from 
git://people.freedesktop.org/~tstellar/llvm master before submitting a bug])
 LLVM_COMPONENTS=${LLVM_COMPONENTS} r600 bitreader
+AC_CHECK_LIB([elf], [elf_memory] [ELF_LIB=-lelf],
+ [AC_MSG_ERROR([radeonsi and r600g require 
libelf when using LLVM])])
 }
 
 dnl Gallium drivers
diff --git a/src/gallium/drivers/radeon/Makefile.am 
b/src/gallium/drivers/radeon/Makefile.am
index 140f6c6..f08561a 100644
--- a/src/gallium/drivers/radeon/Makefile.am
+++ b/src/gallium/drivers/radeon/Makefile.am
@@ -32,4 +32,5 @@ libllvmradeon@VERSION@_la_SOURCES = \
 libllvmradeon@VERSION@_la_LIBADD = \
$(LIBGALLIUM_LIBS) \
$(CLOCK_LIB) \
-   $(LLVM_LIBS)
+   $(LLVM_LIBS) \
+   $(ELF_LIB)
diff --git a/src/gallium/drivers/radeon/radeon_llvm_emit.cpp 
b/src/gallium/drivers/radeon/radeon_llvm_emit.cpp
index 9c5fd78..d2dc035 100644
--- a/src/gallium/drivers/radeon/radeon_llvm_emit.cpp
+++ b/src/gallium/drivers/radeon/radeon_llvm_emit.cpp
@@ -52,6 +52,8 @@
 #include iostream
 #include stdlib.h
 #include stdio.h
+#include libelf.h
+#include gelf.h
 
 using namespace llvm;
 
@@ -154,10 +156,38 @@ radeon_llvm_compile(LLVMModuleRef M, struct 
radeon_llvm_binary *binary,
out.flush();
std::string data = oStream.str();
 
-
-   binary-code = (unsigned char*)malloc(data.length() * sizeof(unsigned 
char));
-   memcpy(binary-code, data.c_str(), data.length() * sizeof(unsigned char));
-   binary-code_size = data.length();
+   char *elf_buffer;
+
+   elf_buffer = (char*)malloc(data.length());
+   memcpy(elf_buffer, data.c_str(), data.length());
+
+   Elf *elf = elf_memory(elf_buffer, data.length());
+   Elf_Scn *section = NULL;
+   size_t section_str_index;
+
+   elf_getshdrstrndx(elf, section_str_index);
+
+   while ((section = elf_nextscn(elf, section))) {
+  const char *name;
+  Elf_Data *section_data = NULL;
+  GElf_Shdr section_header;
+  if (gelf_getshdr(section, section_header) != section_header) {
+ fprintf(stderr, Failed to read ELF section header\n);
+ return 1;
+  }
+  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 = (unsigned char*)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 = (unsigned char*)malloc(binary-config_size * 
sizeof(unsigned char));
+ memcpy(binary-config, section_data-d_buf, binary-config_size);
+  }
+   }
 
return 0;
 }
-- 
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/4] radeonsi: Read config values from the .AMDGPU.config ELF section

2013-04-05 Thread Tom Stellard
From: Tom Stellard thomas.stell...@amd.com

---
 src/gallium/drivers/radeonsi/radeonsi_shader.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.c 
b/src/gallium/drivers/radeonsi/radeonsi_shader.c
index 218997f..0aeecc2 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_shader.c
+++ b/src/gallium/drivers/radeonsi/radeonsi_shader.c
@@ -1175,9 +1175,9 @@ int si_pipe_shader_create(
}
}
 
-   shader-num_sgprs = util_le32_to_cpu(*(uint32_t*)binary.code);
-   shader-num_vgprs = util_le32_to_cpu(*(uint32_t*)(binary.code + 4));
-   shader-spi_ps_input_ena = util_le32_to_cpu(*(uint32_t*)(binary.code + 
8));
+   shader-num_sgprs = util_le32_to_cpu(*(uint32_t*)binary.config);
+   shader-num_vgprs = util_le32_to_cpu(*(uint32_t*)(binary.config + 4));
+   shader-spi_ps_input_ena = util_le32_to_cpu(*(uint32_t*)(binary.config 
+ 8));
 
radeon_llvm_dispose(si_shader_ctx.radeon_bld);
tgsi_parse_free(si_shader_ctx.parse);
@@ -1185,7 +1185,7 @@ int si_pipe_shader_create(
/* copy new shader */
si_resource_reference(shader-bo, NULL);
shader-bo = si_resource_create_custom(ctx-screen, 
PIPE_USAGE_IMMUTABLE,
-  binary.code_size - 12);
+  binary.code_size);
if (shader-bo == NULL) {
FREE(si_shader_ctx.constants);
FREE(si_shader_ctx.resources);
@@ -1195,11 +1195,11 @@ int si_pipe_shader_create(
 
ptr = (uint32_t*)rctx-ws-buffer_map(shader-bo-cs_buf, rctx-cs, 
PIPE_TRANSFER_WRITE);
if (0 /*R600_BIG_ENDIAN*/) {
-   for (i = 0; i  (binary.code_size-12)/4; ++i) {
-   ptr[i] = util_bswap32(*(uint32_t*)(binary.code+12 + 
i*4));
+   for (i = 0; i  binary.code_size / 4; ++i) {
+   ptr[i] = util_bswap32(*(uint32_t*)(binary.code + i*4));
}
} else {
-   memcpy(ptr, binary.code + 12, binary.code_size - 12);
+   memcpy(ptr, binary.code, binary.code_size);
}
rctx-ws-buffer_unmap(shader-bo-cs_buf);
 
-- 
1.8.1.5

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


[Mesa-dev] [PATCH 2/3] R600/SI: Emit configuration value in the .AMDGPU.config ELF section

2013-04-05 Thread Tom Stellard
From: Tom Stellard thomas.stell...@amd.com

---
 lib/Target/R600/AMDGPUAsmPrinter.cpp | 10 +-
 test/CodeGen/R600/elf.ll |  1 +
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/Target/R600/AMDGPUAsmPrinter.cpp 
b/lib/Target/R600/AMDGPUAsmPrinter.cpp
index f600144..011c602 100644
--- a/lib/Target/R600/AMDGPUAsmPrinter.cpp
+++ b/lib/Target/R600/AMDGPUAsmPrinter.cpp
@@ -21,7 +21,10 @@
 #include AMDGPU.h
 #include SIMachineFunctionInfo.h
 #include SIRegisterInfo.h
+#include llvm/MC/MCContext.h
+#include llvm/MC/MCSectionELF.h
 #include llvm/MC/MCStreamer.h
+#include llvm/Support/ELF.h
 #include llvm/Support/TargetRegistry.h
 #include llvm/Target/TargetLoweringObjectFile.h
 
@@ -50,10 +53,15 @@ bool AMDGPUAsmPrinter::runOnMachineFunction(MachineFunction 
MF) {
   if (OutStreamer.hasRawTextSupport()) {
 OutStreamer.EmitRawText(@ + MF.getName() + :);
   }
-  OutStreamer.SwitchSection(getObjFileLowering().getTextSection());
   if (STM.device()-getGeneration()  AMDGPUDeviceInfo::HD6XXX) {
+const MCSectionELF *ConfigSection = getObjFileLowering().getContext()
+
.getELFSection(.AMDGPU.config,
+ELF::SHT_NULL, 0,
+SectionKind::getReadOnly());
+OutStreamer.SwitchSection(ConfigSection);
 EmitProgramInfo(MF);
   }
+  OutStreamer.SwitchSection(getObjFileLowering().getTextSection());
   EmitFunctionBody();
   return false;
 }
diff --git a/test/CodeGen/R600/elf.ll b/test/CodeGen/R600/elf.ll
index 470e4ca..2383148 100644
--- a/test/CodeGen/R600/elf.ll
+++ b/test/CodeGen/R600/elf.ll
@@ -1,6 +1,7 @@
 ; RUN: llc  %s -march=r600 -mcpu=SI -filetype=obj | llvm-readobj -s - | 
FileCheck %s
 
 ; CHECK: Format: ELF32
+; CHECK: Name: .AMDGPU.config
 define void @test(i32 %p) {
%i = add i32 %p, 2
%r = bitcast i32 %i to float
-- 
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] R600/SI: Emit config values in register value pairs.

2013-04-05 Thread Tom Stellard
From: Tom Stellard thomas.stell...@amd.com

Instead of emitting config values in a predefined order, the code
emitter will now emit a 32-bit register index followed by the 32-bit
config value.
---
 lib/Target/R600/AMDGPUAsmPrinter.cpp | 19 ---
 lib/Target/R600/SIDefines.h  | 22 ++
 test/CodeGen/R600/elf.ll | 11 ---
 3 files changed, 46 insertions(+), 6 deletions(-)
 create mode 100644 lib/Target/R600/SIDefines.h

diff --git a/lib/Target/R600/AMDGPUAsmPrinter.cpp 
b/lib/Target/R600/AMDGPUAsmPrinter.cpp
index 011c602..3c09496 100644
--- a/lib/Target/R600/AMDGPUAsmPrinter.cpp
+++ b/lib/Target/R600/AMDGPUAsmPrinter.cpp
@@ -19,6 +19,7 @@
 
 #include AMDGPUAsmPrinter.h
 #include AMDGPU.h
+#include SIDefines.h
 #include SIMachineFunctionInfo.h
 #include SIRegisterInfo.h
 #include llvm/MC/MCContext.h
@@ -147,7 +148,19 @@ void AMDGPUAsmPrinter::EmitProgramInfo(MachineFunction 
MF) {
 MaxSGPR += 2;
   }
   SIMachineFunctionInfo * MFI = MF.getInfoSIMachineFunctionInfo();
-  OutStreamer.EmitIntValue(MaxSGPR + 1, 4);
-  OutStreamer.EmitIntValue(MaxVGPR + 1, 4);
-  OutStreamer.EmitIntValue(MFI-PSInputAddr, 4);
+  unsigned RsrcReg;
+  switch (MFI-ShaderType) {
+  default: // Fall through
+  case ShaderType::COMPUTE:  RsrcReg = R_00B848_COMPUTE_PGM_RSRC1; break;
+  case ShaderType::GEOMETRY: RsrcReg = R_00B228_SPI_SHADER_PGM_RSRC1_GS; break;
+  case ShaderType::PIXEL:RsrcReg = R_00B028_SPI_SHADER_PGM_RSRC1_PS; break;
+  case ShaderType::VERTEX:   RsrcReg = R_00B128_SPI_SHADER_PGM_RSRC1_VS; break;
+  }
+
+  OutStreamer.EmitIntValue(RsrcReg, 4);
+  OutStreamer.EmitIntValue(S_00B028_VGPRS(MaxVGPR / 4) | 
S_00B028_SGPRS(MaxSGPR / 8), 4);
+  if (MFI-ShaderType == ShaderType::PIXEL) {
+OutStreamer.EmitIntValue(R_0286CC_SPI_PS_INPUT_ENA, 4);
+OutStreamer.EmitIntValue(MFI-PSInputAddr, 4);
+  }
 }
diff --git a/lib/Target/R600/SIDefines.h b/lib/Target/R600/SIDefines.h
new file mode 100644
index 000..716b093
--- /dev/null
+++ b/lib/Target/R600/SIDefines.h
@@ -0,0 +1,22 @@
+//===-- SIDefines.h - SI Helper Macros --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+/// \file
+//===--===//
+
+#ifndef SIDEFINES_H_
+#define SIDEFINES_H_
+
+#define R_00B028_SPI_SHADER_PGM_RSRC1_PS
0x00B028
+#define R_00B128_SPI_SHADER_PGM_RSRC1_VS
0x00B128
+#define R_00B228_SPI_SHADER_PGM_RSRC1_GS
0x00B228
+#define R_00B848_COMPUTE_PGM_RSRC1  
0x00B848
+#define   S_00B028_VGPRS(x)   (((x)  
0x3F)  0)
+#define   S_00B028_SGPRS(x)   (((x)  
0x0F)  6)
+#define R_0286CC_SPI_PS_INPUT_ENA   
0x0286CC
+
+#endif // SIDEFINES_H_
diff --git a/test/CodeGen/R600/elf.ll b/test/CodeGen/R600/elf.ll
index 2383148..555ee3d 100644
--- a/test/CodeGen/R600/elf.ll
+++ b/test/CodeGen/R600/elf.ll
@@ -1,7 +1,12 @@
-; RUN: llc  %s -march=r600 -mcpu=SI -filetype=obj | llvm-readobj -s - | 
FileCheck %s
+; RUN: llc  %s -march=r600 -mcpu=SI -filetype=obj | llvm-readobj -s - | 
FileCheck --check-prefix=ELF-CHECK %s
+; RUN: llc  %s -march=r600 -mcpu=SI -o - | FileCheck 
--check-prefix=CONFIG-CHECK %s
 
-; CHECK: Format: ELF32
-; CHECK: Name: .AMDGPU.config
+; ELF-CHECK: Format: ELF32
+; ELF-CHECK: Name: .AMDGPU.config
+
+; CONFIG-CHECK: .section .AMDGPU.config
+; CONFIG-CHECK-NEXT: .long   45096
+; CONFIG-CHECK-NEXT: .long   0
 define void @test(i32 %p) {
%i = add i32 %p, 2
%r = bitcast i32 %i to float
-- 
1.8.1.5

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


[Mesa-dev] [PATCH 1/3] R600: Emit ELF formatted code rather than raw ISA.

2013-04-05 Thread Tom Stellard
From: Tom Stellard thomas.stell...@amd.com

---
 lib/Target/R600/MCTargetDesc/AMDGPUAsmBackend.cpp  | 29 ++--
 .../R600/MCTargetDesc/AMDGPUELFObjectWriter.cpp| 39 ++
 .../R600/MCTargetDesc/AMDGPUMCTargetDesc.cpp   |  2 +-
 lib/Target/R600/MCTargetDesc/AMDGPUMCTargetDesc.h  |  4 +++
 lib/Target/R600/MCTargetDesc/CMakeLists.txt|  1 +
 test/CodeGen/R600/elf.ll   | 11 ++
 6 files changed, 74 insertions(+), 12 deletions(-)
 create mode 100644 lib/Target/R600/MCTargetDesc/AMDGPUELFObjectWriter.cpp
 create mode 100644 test/CodeGen/R600/elf.ll

diff --git a/lib/Target/R600/MCTargetDesc/AMDGPUAsmBackend.cpp 
b/lib/Target/R600/MCTargetDesc/AMDGPUAsmBackend.cpp
index 98fca43..a3397f3 100644
--- a/lib/Target/R600/MCTargetDesc/AMDGPUAsmBackend.cpp
+++ b/lib/Target/R600/MCTargetDesc/AMDGPUAsmBackend.cpp
@@ -44,7 +44,6 @@ public:
   AMDGPUAsmBackend(const Target T)
 : MCAsmBackend() {}
 
-  virtual AMDGPUMCObjectWriter *createObjectWriter(raw_ostream OS) const;
   virtual unsigned getNumFixupKinds() const { return 0; };
   virtual void applyFixup(const MCFixup Fixup, char *Data, unsigned DataSize,
   uint64_t Value) const;
@@ -71,16 +70,6 @@ void AMDGPUMCObjectWriter::WriteObject(MCAssembler Asm,
   }
 }
 
-MCAsmBackend *llvm::createAMDGPUAsmBackend(const Target T, StringRef TT,
-   StringRef CPU) {
-  return new AMDGPUAsmBackend(T);
-}
-
-AMDGPUMCObjectWriter * AMDGPUAsmBackend::createObjectWriter(
-raw_ostream OS) const 
{
-  return new AMDGPUMCObjectWriter(OS);
-}
-
 void AMDGPUAsmBackend::applyFixup(const MCFixup Fixup, char *Data,
   unsigned DataSize, uint64_t Value) const {
 
@@ -88,3 +77,21 @@ void AMDGPUAsmBackend::applyFixup(const MCFixup Fixup, char 
*Data,
   assert(Fixup.getKind() == FK_PCRel_4);
   *Dst = (Value - 4) / 4;
 }
+
+//===--===//
+// ELFAMDGPUAsmBackend class
+//===--===//
+
+class ELFAMDGPUAsmBackend : public AMDGPUAsmBackend {
+public:
+  ELFAMDGPUAsmBackend(const Target T) : AMDGPUAsmBackend(T) { }
+
+  MCObjectWriter *createObjectWriter(raw_ostream OS) const {
+return createAMDGPUELFObjectWriter(OS);
+  }
+};
+
+MCAsmBackend *llvm::createAMDGPUAsmBackend(const Target T, StringRef TT,
+   StringRef CPU) {
+  return new ELFAMDGPUAsmBackend(T);
+}
diff --git a/lib/Target/R600/MCTargetDesc/AMDGPUELFObjectWriter.cpp 
b/lib/Target/R600/MCTargetDesc/AMDGPUELFObjectWriter.cpp
new file mode 100644
index 000..48fac9f
--- /dev/null
+++ b/lib/Target/R600/MCTargetDesc/AMDGPUELFObjectWriter.cpp
@@ -0,0 +1,39 @@
+//===-- AMDGPUELFObjectWriter.cpp - AMDGPU ELF Writer 
--==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+/// \file
+//===--===//
+
+#include AMDGPUMCTargetDesc.h
+#include llvm/MC/MCELFObjectWriter.h
+
+using namespace llvm;
+
+namespace {
+
+class AMDGPUELFObjectWriter : public MCELFObjectTargetWriter {
+public:
+  AMDGPUELFObjectWriter();
+protected:
+  virtual unsigned GetRelocType(const MCValue Target, const MCFixup Fixup,
+bool IsPCRel, bool IsRelocWithSymbol,
+int64_t Addend) const {
+llvm_unreachable(Not implemented);
+  }
+
+};
+
+
+} // End anonymous namespace
+
+AMDGPUELFObjectWriter::AMDGPUELFObjectWriter()
+  : MCELFObjectTargetWriter(false, 0, 0, false) { }
+
+MCObjectWriter *llvm::createAMDGPUELFObjectWriter(raw_ostream OS) {
+  MCELFObjectTargetWriter *MOTW = new AMDGPUELFObjectWriter();
+  return createELFObjectWriter(MOTW, OS, true);
+}
diff --git a/lib/Target/R600/MCTargetDesc/AMDGPUMCTargetDesc.cpp 
b/lib/Target/R600/MCTargetDesc/AMDGPUMCTargetDesc.cpp
index 072ee49..45d009c 100644
--- a/lib/Target/R600/MCTargetDesc/AMDGPUMCTargetDesc.cpp
+++ b/lib/Target/R600/MCTargetDesc/AMDGPUMCTargetDesc.cpp
@@ -88,7 +88,7 @@ static MCStreamer *createMCStreamer(const Target T, 
StringRef TT,
 MCCodeEmitter *_Emitter,
 bool RelaxAll,
 bool NoExecStack) {
-  return createPureStreamer(Ctx, MAB, _OS, _Emitter);
+  return createELFStreamer(Ctx, MAB, _OS, _Emitter, false, false);
 }
 
 extern C void LLVMInitializeR600TargetMC() {
diff --git a/lib/Target/R600/MCTargetDesc/AMDGPUMCTargetDesc.h 
b/lib/Target/R600/MCTargetDesc/AMDGPUMCTargetDesc.h
index 363a4af..09d0d5b 100644
--- a/lib/Target/R600/MCTargetDesc/AMDGPUMCTargetDesc.h
+++ b/lib/Target/R600/MCTargetDesc/AMDGPUMCTargetDesc.h
@@ 

Re: [Mesa-dev] [PATCH 2/2] i965/vs: Use GRFs for pull constant offsets on gen7.

2013-04-05 Thread Matt Turner
Reviewed-by: Matt Turner matts...@gmail.com
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] intel: Do temporary CPU maps of textures that are too big to GTT map.

2013-04-05 Thread Eric Anholt
This still fails, since 8192*4bpp == 32768, which is too big to use the
blitter on.

v2: Be more conservative about the size of the GTT -- I'd forgotten some
of the horror of older hardware.
---
 src/mesa/drivers/dri/intel/intel_mipmap_tree.c |   23 +++
 1 file changed, 23 insertions(+)

diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c 
b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index ffdaec5..152d4631 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -1703,6 +1703,25 @@ intel_miptree_map_singlesample(struct intel_context 
*intel,
 {
struct intel_miptree_map *map;
 
+   /* Estimate the size of the mappable aperture into the GTT.  There's an
+* ioctl to get the whole GTT size, but not one to get the mappable subset.
+* Generally it's 256MB, but some gen4+ (particularly things like G41)
+* occasionally has only 128, and 830-class hardware could be either 64 or
+* 128.  Since the kernel doesn't expose information to let us actually
+* determine the size, just be pessimistic.
+*/
+   uint32_t gtt_size = 128 * 1024 * 1024;
+   if (intel-gen == 2)
+  gtt_size = 64 * 1024 * 1024;
+
+   /* We don't want to map two objects such that a memcpy between them would
+* just fault one mapping in and then the other over and over forever.  So
+* we would need to divide the GTT size by 2.  Additionally, some GTT is
+* taken up by things like the framebuffer and the ringbuffer and such, so
+* be more conservative.
+*/
+   uint32_t max_gtt_map_object_size = gtt_size / 4;
+
assert(mt-num_samples = 1);
 
map = intel_miptree_attach_map(mt, level, slice, x, y, w, h, mode);
@@ -1749,6 +1768,10 @@ intel_miptree_map_singlesample(struct intel_context 
*intel,
 mt-region-tiling == I915_TILING_X 
 mt-region-pitch  32768) {
   intel_miptree_map_blit(intel, mt, map, level, slice);
+   } else if (mt-region-bo-size = max_gtt_map_object_size) {
+  assert(mt-region-pitch  32768 ||
+ mt-region-tiling == I915_TILING_NONE);
+  intel_miptree_map_blit(intel, mt, map, level, slice);
} else {
   intel_miptree_map_gtt(intel, mt, map, level, slice);
}
-- 
1.7.10.4

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


[Mesa-dev] [PATCH] clover: Use a non-NULL value to represent the platform_id

2013-04-05 Thread Tom Stellard
From: Tom Stellard thomas.stell...@amd.com

Using a NULL value for the platform_id is legal according to the spec,
however, passing a NULL value as the platform parameter to
clGetPlatformInfo() results in implementation defined behavior.

In order to avoid implementation defined behavior some apps require that
the platfrom_id is non-NULL.  To statisfy this requirement, we just need
to hard-code clover's platform_id to something other than NULL.
---
 src/gallium/state_trackers/clover/api/platform.cpp | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/clover/api/platform.cpp 
b/src/gallium/state_trackers/clover/api/platform.cpp
index f99b694..6457a4d 100644
--- a/src/gallium/state_trackers/clover/api/platform.cpp
+++ b/src/gallium/state_trackers/clover/api/platform.cpp
@@ -24,6 +24,8 @@
 
 using namespace clover;
 
+static cl_platform_id mesa_platform = (cl_platform_id)0xc1c1c1c1;
+
 PUBLIC cl_int
 clGetPlatformIDs(cl_uint num_entries, cl_platform_id *platforms,
  cl_uint *num_platforms) {
@@ -34,7 +36,7 @@ clGetPlatformIDs(cl_uint num_entries, cl_platform_id 
*platforms,
if (num_platforms)
   *num_platforms = 1;
if (platforms)
-  *platforms = NULL;
+  *platforms = mesa_platform;
 
return CL_SUCCESS;
 }
@@ -42,7 +44,7 @@ clGetPlatformIDs(cl_uint num_entries, cl_platform_id 
*platforms,
 PUBLIC cl_int
 clGetPlatformInfo(cl_platform_id platform, cl_platform_info param_name,
   size_t size, void *buf, size_t *size_ret) {
-   if (platform != NULL)
+   if (platform != mesa_platform)
   return CL_INVALID_PLATFORM;
 
switch (param_name) {
-- 
1.7.11.4

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


Re: [Mesa-dev] [PATCH] Fix glXChooseFBConfig with GLX_DRAWABLE_TYPE GLX_DONT_CARE

2013-04-05 Thread Alexander Monakov
On Thu, Apr 4, 2013 at 1:02 AM, Ian Romanick i...@freedesktop.org wrote:
 Reveiwed-by: Ian Romanick ian.d.roman...@intel.com

 Please add the following lines to the commit message:

 NOTE: This is a candidate for stable branches.

 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=47478
 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=62999
 Bugzilla: http://bugs.winehq.org/show_bug.cgi?id=26763

Done. I don't have git write access, can you push it for me?
From e19c1fcfdd72fc3f87908db77808f65be5000843 Mon Sep 17 00:00:00 2001
From: Alexander Monakov amona...@ispras.ru
Date: Tue, 2 Apr 2013 01:38:27 +0400
Subject: [PATCH] Honor GLX_DONT_CARE in MATCH_MASK

NOTE: This is a candidate for stable branches.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=47478
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=62999
Bugzilla: http://bugs.winehq.org/show_bug.cgi?id=26763
---
 src/glx/glxcmds.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c
index 7b62be3..5c79073 100644
--- a/src/glx/glxcmds.c
+++ b/src/glx/glxcmds.c
@@ -912,8 +912,10 @@ init_fbconfig_for_chooser(struct glx_config * config,
 /* Test that all bits from a are contained in b */
 #define MATCH_MASK(param)  \
   do { \
-if ((a-param  ~b-param) != 0)   \
+if ( ((int) a- param != (int) GLX_DONT_CARE)  \
+  ((a-param  ~b-param) != 0) ) {   \
   return False;\
+}   \
   } while (0);
 
 /**
-- 
1.7.11.5

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


[Mesa-dev] [PATCH] clover: Use a non-NULL value to represent the platform_id v2

2013-04-05 Thread Tom Stellard
From: Tom Stellard thomas.stell...@amd.com

Using a NULL value for the platform_id is legal according to the spec,
however, passing a NULL value as the platform parameter to
clGetPlatformInfo() results in implementation defined behavior.

In order to avoid implementation defined behavior some apps require that
the platfrom_id is non-NULL.  To statisfy this requirement, we just need
to hard-code clover's platform_id to something other than NULL.

v2:
  - Handle platform check in clGetDeviceIDs()
  - Use a macro for MESA_PLATFORM_ID
---
 src/gallium/state_trackers/clover/api/device.cpp   | 2 +-
 src/gallium/state_trackers/clover/api/platform.cpp | 4 ++--
 src/gallium/state_trackers/clover/api/util.hpp | 2 ++
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/gallium/state_trackers/clover/api/device.cpp 
b/src/gallium/state_trackers/clover/api/device.cpp
index cf68d0f..d9b0223 100644
--- a/src/gallium/state_trackers/clover/api/device.cpp
+++ b/src/gallium/state_trackers/clover/api/device.cpp
@@ -33,7 +33,7 @@ clGetDeviceIDs(cl_platform_id platform, cl_device_type 
device_type,
cl_uint *num_devices) {
std::vectorcl_device_id devs;
 
-   if (platform != NULL)
+   if (platform != MESA_PLATFORM_ID)
   return CL_INVALID_PLATFORM;
 
if ((!num_entries  devices) ||
diff --git a/src/gallium/state_trackers/clover/api/platform.cpp 
b/src/gallium/state_trackers/clover/api/platform.cpp
index f99b694..3a988a6 100644
--- a/src/gallium/state_trackers/clover/api/platform.cpp
+++ b/src/gallium/state_trackers/clover/api/platform.cpp
@@ -34,7 +34,7 @@ clGetPlatformIDs(cl_uint num_entries, cl_platform_id 
*platforms,
if (num_platforms)
   *num_platforms = 1;
if (platforms)
-  *platforms = NULL;
+  *platforms = MESA_PLATFORM_ID;
 
return CL_SUCCESS;
 }
@@ -42,7 +42,7 @@ clGetPlatformIDs(cl_uint num_entries, cl_platform_id 
*platforms,
 PUBLIC cl_int
 clGetPlatformInfo(cl_platform_id platform, cl_platform_info param_name,
   size_t size, void *buf, size_t *size_ret) {
-   if (platform != NULL)
+   if (platform != MESA_PLATFORM_ID)
   return CL_INVALID_PLATFORM;
 
switch (param_name) {
diff --git a/src/gallium/state_trackers/clover/api/util.hpp 
b/src/gallium/state_trackers/clover/api/util.hpp
index 2f9ec1f..0e80cda 100644
--- a/src/gallium/state_trackers/clover/api/util.hpp
+++ b/src/gallium/state_trackers/clover/api/util.hpp
@@ -31,6 +31,8 @@
 #include core/base.hpp
 #include pipe/p_compiler.h
 
+#define MESA_PLATFORM_ID ((cl_platform_id)0xc1c1c1c1)
+
 namespace clover {
///
/// Return a matrix (a container of containers) in \a buf with
-- 
1.7.11.4

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


Re: [Mesa-dev] [PATCH 2/5] mesa: implement GL_ARB_draw_indirect and GL_ARB_multi_draw_indirect

2013-04-05 Thread Ian Romanick

On 04/05/2013 05:29 AM, Christoph Bumiller wrote:

v2:
Removed some stray extern qualifiers.

Documented use of Draw*IndirectCommand sizes.

Removed separate extension enable flag for ARB_multi_draw_indirect
since this can always be supported by looping.

Kept generation of GL_INVALID_OPERATION in display list compile.
The spec doesn't say anything about them, but all the direct drawing
commands that support instancing do the same.


I think we can dodge the issue entirely.  The extension spec says OpenGL 
3.1 is required (though it's not immediately obvious to me why), and we 
only expose OpenGL 3.1 without compatibility... without display lists.


It looks like (below) this extension is only exposed in core profile any 
way.  Just gut all the API_OPENGL_COMPAT checks and all the display list 
stuff.  That should simplify things a bit...



---
  src/mapi/glapi/gen/Makefile.am  |1 +
  src/mapi/glapi/gen/gl_API.xml   |4 +-
  src/mesa/main/api_validate.c|  153 +++
  src/mesa/main/api_validate.h|   26 
  src/mesa/main/bufferobj.c   |9 +
  src/mesa/main/dd.h  |   12 ++
  src/mesa/main/dlist.c   |   41 +
  src/mesa/main/extensions.c  |2 +
  src/mesa/main/get.c |5 +
  src/mesa/main/get_hash_params.py|2 +
  src/mesa/main/mtypes.h  |3 +
  src/mesa/main/tests/dispatch_sanity.cpp |8 +-
  src/mesa/main/vtxfmt.c  |7 +
  src/mesa/vbo/vbo_exec_array.c   |  249 +++
  src/mesa/vbo/vbo_save_api.c |   53 +++
  15 files changed, 570 insertions(+), 5 deletions(-)

diff --git a/src/mapi/glapi/gen/Makefile.am b/src/mapi/glapi/gen/Makefile.am
index 36e47e2..243c148 100644
--- a/src/mapi/glapi/gen/Makefile.am
+++ b/src/mapi/glapi/gen/Makefile.am
@@ -96,6 +96,7 @@ API_XML = \
ARB_depth_clamp.xml \
ARB_draw_buffers_blend.xml \
ARB_draw_elements_base_vertex.xml \
+   ARB_draw_indirect.xml \
ARB_draw_instanced.xml \
ARB_ES2_compatibility.xml \
ARB_ES3_compatibility.xml \
diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index df95924..f22fdac 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -8240,6 +8240,8 @@

  !-- ARB extensions #86...#93 --

+xi:include href=ARB_draw_indirect.xml 
xmlns:xi=http://www.w3.org/2001/XInclude/
+
  category name=GL_ARB_transform_feedback3 number=94
enum name=MAX_TRANSFORM_FEEDBACK_BUFFERS value=0x8E70/
enum name=MAX_VERTEX_STREAMS value=0x8E71/
@@ -8317,7 +8319,7 @@

  xi:include href=ARB_invalidate_subdata.xml 
xmlns:xi=http://www.w3.org/2001/XInclude/

-!-- ARB extensions #133...#138 --
+!-- ARB extensions #134...#138 --

  xi:include href=ARB_texture_buffer_range.xml 
xmlns:xi=http://www.w3.org/2001/XInclude/

diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 53b0021..e875c5d 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -737,3 +737,156 @@ _mesa_validate_DrawTransformFeedback(struct gl_context 
*ctx,

 return GL_TRUE;
  }
+
+static GLboolean
+valid_draw_indirect(struct gl_context *ctx,
+GLenum mode, const GLvoid *indirect,
+GLsizei size, const char *name)
+{
+   const GLsizeiptr end = (GLsizeiptr)indirect + size;
+
+   if (!_mesa_valid_prim_mode(ctx, mode, name))
+  return GL_FALSE;
+
+   if ((GLsizeiptr)indirect  (sizeof(GLuint) - 1)) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  %s(indirect is not aligned), name);
+  return GL_FALSE;
+   }
+
+   if (_mesa_is_bufferobj(ctx-DrawIndirectBuffer)) {
+  if (_mesa_bufferobj_mapped(ctx-DrawIndirectBuffer)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ %s(DRAW_INDIRECT_BUFFER is mapped), name);
+ return GL_FALSE;
+  }
+  if (ctx-DrawIndirectBuffer-Size  end) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ %s(DRAW_INDIRECT_BUFFER too small), name);
+ return GL_FALSE;
+  }
+   } else {
+  if (ctx-API != API_OPENGL_COMPAT) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ %s: no buffer bound to DRAW_INDIRECT_BUFFER, name);
+ return GL_FALSE;
+  }
+   }
+
+   if (!check_valid_to_render(ctx, name))
+  return GL_FALSE;
+
+   return GL_TRUE;
+}
+
+static inline GLboolean
+valid_draw_indirect_elements(struct gl_context *ctx,
+ GLenum mode, GLenum type, const GLvoid *indirect,
+ GLsizeiptr size, const char *name)
+{
+   if (!valid_elements_type(ctx, type, name))
+  return GL_FALSE;
+
+   /*
+* Unlike regular DrawElementsInstancedBaseVertex commands, the indices
+* may not come from a client array and must come from an index buffer.
+* If no 

[Mesa-dev] [PATCH] clover: Use a non-NULL value to represent the platform_id v3

2013-04-05 Thread Tom Stellard
From: Tom Stellard thomas.stell...@amd.com

Using a NULL value for the platform_id is legal according to the spec,
however, passing a NULL value as the platform parameter to
clGetPlatformInfo() results in implementation defined behavior.

In order to avoid implementation defined behavior some apps require that
the platfrom_id is non-NULL.  To statisfy this requirement, we just need
to hard-code clover's platform_id to something other than NULL.

v2:
  - Handle platform check in clGetDeviceIDs()
  - Use a macro for MESA_PLATFORM_ID

v3:
  - Use MESA_PLATFORM_ID when calling clGetDeviceIDs() from
clCreateContextFromType()
---
 src/gallium/state_trackers/clover/api/context.cpp  | 2 +-
 src/gallium/state_trackers/clover/api/device.cpp   | 2 +-
 src/gallium/state_trackers/clover/api/platform.cpp | 4 ++--
 src/gallium/state_trackers/clover/api/util.hpp | 2 ++
 4 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/gallium/state_trackers/clover/api/context.cpp 
b/src/gallium/state_trackers/clover/api/context.cpp
index 80afb6b..d509619 100644
--- a/src/gallium/state_trackers/clover/api/context.cpp
+++ b/src/gallium/state_trackers/clover/api/context.cpp
@@ -65,7 +65,7 @@ clCreateContextFromType(const cl_context_properties *props,
cl_device_id dev;
cl_int ret;
 
-   ret = clGetDeviceIDs(0, type, 1, dev, 0);
+   ret = clGetDeviceIDs(MESA_PLATFORM_ID, type, 1, dev, 0);
if (ret) {
   ret_error(errcode_ret, ret);
   return NULL;
diff --git a/src/gallium/state_trackers/clover/api/device.cpp 
b/src/gallium/state_trackers/clover/api/device.cpp
index cf68d0f..d9b0223 100644
--- a/src/gallium/state_trackers/clover/api/device.cpp
+++ b/src/gallium/state_trackers/clover/api/device.cpp
@@ -33,7 +33,7 @@ clGetDeviceIDs(cl_platform_id platform, cl_device_type 
device_type,
cl_uint *num_devices) {
std::vectorcl_device_id devs;
 
-   if (platform != NULL)
+   if (platform != MESA_PLATFORM_ID)
   return CL_INVALID_PLATFORM;
 
if ((!num_entries  devices) ||
diff --git a/src/gallium/state_trackers/clover/api/platform.cpp 
b/src/gallium/state_trackers/clover/api/platform.cpp
index f99b694..3a988a6 100644
--- a/src/gallium/state_trackers/clover/api/platform.cpp
+++ b/src/gallium/state_trackers/clover/api/platform.cpp
@@ -34,7 +34,7 @@ clGetPlatformIDs(cl_uint num_entries, cl_platform_id 
*platforms,
if (num_platforms)
   *num_platforms = 1;
if (platforms)
-  *platforms = NULL;
+  *platforms = MESA_PLATFORM_ID;
 
return CL_SUCCESS;
 }
@@ -42,7 +42,7 @@ clGetPlatformIDs(cl_uint num_entries, cl_platform_id 
*platforms,
 PUBLIC cl_int
 clGetPlatformInfo(cl_platform_id platform, cl_platform_info param_name,
   size_t size, void *buf, size_t *size_ret) {
-   if (platform != NULL)
+   if (platform != MESA_PLATFORM_ID)
   return CL_INVALID_PLATFORM;
 
switch (param_name) {
diff --git a/src/gallium/state_trackers/clover/api/util.hpp 
b/src/gallium/state_trackers/clover/api/util.hpp
index 2f9ec1f..0e80cda 100644
--- a/src/gallium/state_trackers/clover/api/util.hpp
+++ b/src/gallium/state_trackers/clover/api/util.hpp
@@ -31,6 +31,8 @@
 #include core/base.hpp
 #include pipe/p_compiler.h
 
+#define MESA_PLATFORM_ID ((cl_platform_id)0xc1c1c1c1)
+
 namespace clover {
///
/// Return a matrix (a container of containers) in \a buf with
-- 
1.7.11.4

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


[Mesa-dev] [PATCH 00/12] RFC: add support of ARB_separate_shader_object extensions

2013-04-05 Thread gregory
Hello,

Please find an implementation of the ARB_separate_shader_objects extensions. I 
concentrate mostly on the state part of 
the extensions aka the pipeline object. I think GLSL already compiled program 
separately anyway.

I test my implementation on the test that I send yesterday ago on piglit. All 
tests are ok but I miss a test for new uniform function.
Besides there are still some parts unimplemented:
1/ GLX Protocol: not sure it will be useful, as understand GLX is kinda 
drepecated
2/ Display list: need to be done or maybe enable the extensions on CORE profile

Stuff that bug me:
1/ I don't get how to use ralloc_strdup. So I set the ralloc's context to NULL, 
not sure it is fully correct
2/ I implement the feature as a pure mesa state. I don't know if they're any 
rule to create driver functions. Maybe it 
   would be better to add 
CreatePipelineObject/DeletePipelineObject/BindPipeline/UseProgramStages. 
Opinion is welcome

Note: I didn't yet rebase my work on latest mesa. Not sure if it is critical 
for a preliminary review.
Note2: I create the xml manually, don't know if there is any automatic flow.

Thanks

gregory (12):
  sso: Create extensions entry points
  sso: Add pipeline container/state
  sso: add support of GL_PROGRAM_SEPARABLE and CreateShaderProgramv
  sso: implement ActiveShaderProgram  GetProgramPipelineiv
  sso: replace Shader binding point with _Shader
  sso: rename Shader to the pointer _Shader
  sso: update meta state
  sso:Implement _mesa_UseProgramStages
  sso: implement BindProgramPipeline
  sso: update glGet: GL_PROGRAM_PIPELINE_BINDING
  sso: implement ValidateProgramPipeline and GetProgramPipelineInfoLog
  sso: Finally enable the extension on Gallium

 src/mapi/glapi/gen/ARB_separate_shader_objects.xml |  392 ++
 src/mapi/glapi/gen/Makefile.am |1 +
 src/mapi/glapi/gen/gl_API.xml  |6 +-
 src/mapi/glapi/gen/gl_genexec.py   |1 +
 src/mesa/drivers/common/meta.c |   35 +-
 src/mesa/drivers/dri/i965/brw_gs.c |2 +-
 src/mesa/drivers/dri/i965/brw_shader.cpp   |2 +-
 src/mesa/drivers/dri/i965/brw_vs.c |4 +-
 src/mesa/drivers/dri/i965/brw_vs_surface_state.c   |2 +-
 src/mesa/drivers/dri/i965/brw_wm.c |4 +-
 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_sol_state.c |4 +-
 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   |2 +-
 src/mesa/main/context.c|   44 +-
 src/mesa/main/extensions.c |1 +
 src/mesa/main/ff_fragment_shader.cpp   |8 +-
 src/mesa/main/get.c|   17 +
 src/mesa/main/get_hash_params.py   |3 +
 src/mesa/main/mtypes.h |   38 +
 src/mesa/main/pipelineobj.c|  800 
 src/mesa/main/pipelineobj.h|  101 +++
 src/mesa/main/shaderapi.c  |  250 --
 src/mesa/main/shaderapi.h  |8 +-
 src/mesa/main/state.c  |   14 +-
 src/mesa/main/texstate.c   |   12 +-
 src/mesa/main/transformfeedback.c  |4 +-
 src/mesa/main/uniform_query.cpp|   75 +-
 src/mesa/main/uniforms.c   |  392 +-
 src/mesa/main/uniforms.h   |   77 ++
 src/mesa/program/ir_to_mesa.cpp|   12 +-
 src/mesa/sources.mak   |1 +
 src/mesa/state_tracker/st_atom_clip.c  |2 +-
 src/mesa/state_tracker/st_atom_constbuf.c  |4 +-
 src/mesa/state_tracker/st_cb_drawpixels.c  |2 +-
 src/mesa/state_tracker/st_draw.c   |6 +-
 src/mesa/state_tracker/st_extensions.c |1 +
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |2 +-
 src/mesa/state_tracker/st_program.c|6 +-
 src/mesa/swrast/s_fragprog.c   |2 +-
 44 files changed, 2182 insertions(+), 171 deletions(-)
 create mode 100644 src/mapi/glapi/gen/ARB_separate_shader_objects.xml
 create mode 100644 src/mesa/main/pipelineobj.c
 create mode 100644 src/mesa/main/pipelineobj.h

-- 
1.7.10.4

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


[Mesa-dev] [PATCH 01/12] sso: Create extensions entry points

2013-04-05 Thread gregory
Nothings implemented yet but glProgramUniform* which are mostly
a copy/paste of the older function glUniform*

I create dedicated pipelineobj.[ch] file that will contains function
related to the new pipeline container object.
---
 src/mapi/glapi/gen/ARB_separate_shader_objects.xml |  392 
 src/mapi/glapi/gen/Makefile.am |1 +
 src/mapi/glapi/gen/gl_API.xml  |6 +-
 src/mapi/glapi/gen/gl_genexec.py   |1 +
 src/mesa/main/extensions.c |1 +
 src/mesa/main/mtypes.h |1 +
 src/mesa/main/pipelineobj.c|  135 +++
 src/mesa/main/pipelineobj.h|   73 
 src/mesa/main/shaderapi.c  |9 +
 src/mesa/main/shaderapi.h  |3 +
 src/mesa/main/uniforms.c   |  326 
 src/mesa/main/uniforms.h   |   74 
 src/mesa/sources.mak   |1 +
 13 files changed, 1022 insertions(+), 1 deletion(-)
 create mode 100644 src/mapi/glapi/gen/ARB_separate_shader_objects.xml
 create mode 100644 src/mesa/main/pipelineobj.c
 create mode 100644 src/mesa/main/pipelineobj.h

diff --git a/src/mapi/glapi/gen/ARB_separate_shader_objects.xml 
b/src/mapi/glapi/gen/ARB_separate_shader_objects.xml
new file mode 100644
index 000..29a37f5
--- /dev/null
+++ b/src/mapi/glapi/gen/ARB_separate_shader_objects.xml
@@ -0,0 +1,392 @@
+?xml version=1.0?
+!DOCTYPE OpenGLAPI SYSTEM gl_API.dtd
+
+!-- Note: no GLX protocol info yet. --
+
+OpenGLAPI
+   category name=ARB_separate_shader_objects number=97
+  enum   name=ACTIVE_PROGRAM   
value=0x8259/
+  enum   name=PROGRAM_PIPELINE_BINDING 
value=0x825A/
+  enum   name=VERTEX_SHADER_BIT
value=0x0001/
+  enum   name=FRAGMENT_SHADER_BIT  
value=0x0002/
+  enum   name=GEOMETRY_SHADER_BIT  
value=0x0004/
+  enum   name=TESS_CONTROL_SHADER_BIT  
value=0x0008/
+  enum   name=TESS_EVALUATION_SHADER_BIT   
value=0x0010/
+  enum   name=ALL_SHADER_BITS  
value=0x/
+  enum   name=PROGRAM_SEPARABLE
value=0x8258/
+
+  function name=UseProgramStages offset=assign
+ param name=pipeline type=GLuint /
+ param name=stages type=GLbitfield /
+ param name=program type=GLuint /
+  /function
+  function name=ActiveShaderProgram offset=assign
+ param name=pipeline type=GLuint /
+ param name=program type=GLuint /
+  /function
+  function name=CreateShaderProgramv offset=assign
+ param name=type type=GLenum /
+ param name=count type=GLsizei /
+ param name=strings type=const GLchar * const * /
+ return type=uint/
+  /function
+  function name=BindProgramPipeline offset=assign
+ param name=pipeline type=GLuint /
+  /function
+  function name=DeleteProgramPipelines offset=assign
+ param name=n type=GLsizei /
+ param name=pipelines type=const GLuint * /
+  /function
+  function name=GenProgramPipelines offset=assign
+ param name=n type=GLsizei /
+ param name=pipelines type=GLuint * /
+  /function
+  function name=IsProgramPipeline offset=assign
+ param name=pipeline type=GLuint /
+ return type=GLboolean/
+  /function
+  function name=GetProgramPipelineiv offset=assign
+ param name=pipeline type=GLuint /
+ param name=pname type=GLenum /
+ param name=params type=GLint * /
+  /function
+  function name=ProgramUniform1i offset=assign
+ param name=program type=GLuint /
+ param name=location type=GLint /
+ param name=x type=GLint /
+  /function
+  function name=ProgramUniform2i offset=assign
+ param name=program type=GLuint /
+ param name=location type=GLint /
+ param name=x type=GLint /
+ param name=y type=GLint /
+  /function
+  function name=ProgramUniform3i offset=assign
+ param name=program type=GLuint /
+ param name=location type=GLint /
+ param name=x type=GLint /
+ param name=y type=GLint /
+ param name=z type=GLint /
+  /function
+  function name=ProgramUniform4i offset=assign
+ param name=program type=GLuint /
+ param name=location type=GLint /
+ param name=x type=GLint /
+ param name=y type=GLint /
+ param name=z type=GLint /
+ param name=w type=GLint /
+  /function
+  function name=ProgramUniform1ui offset=assign
+ param name=program type=GLuint /
+ param name=location type=GLint /
+ param name=x type=GLuint /
+ 

[Mesa-dev] [PATCH 02/12] sso: Add pipeline container/state

2013-04-05 Thread gregory
* Extend gl_shader_state as pipeline object state
* Add a new container gl_pipeline_shader_state that contains
  binding point of the previous object
* Update mesa init/free shader state due to the extension of
  the attibute
* Add an init/free pipeline function for the context
* Implement GenProgramPipeline/DeleteProgramPipeline/IsProgramPipeline.
 I based my work on the VAO code.
---
 src/mesa/main/context.c |3 +
 src/mesa/main/mtypes.h  |   26 +
 src/mesa/main/pipelineobj.c |  233 ++-
 src/mesa/main/pipelineobj.h |   25 +
 src/mesa/main/shaderapi.c   |   10 +-
 src/mesa/main/shaderapi.h   |3 +
 6 files changed, 298 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 0539934..d089827 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -106,6 +106,7 @@
 #include macros.h
 #include matrix.h
 #include multisample.h
+#include pipelineobj.h
 #include pixel.h
 #include pixelstore.h
 #include points.h
@@ -762,6 +763,7 @@ init_attrib_groups(struct gl_context *ctx)
_mesa_init_lighting( ctx );
_mesa_init_matrix( ctx );
_mesa_init_multisample( ctx );
+   _mesa_init_pipeline( ctx );
_mesa_init_pixel( ctx );
_mesa_init_pixelstore( ctx );
_mesa_init_point( ctx );
@@ -1167,6 +1169,7 @@ _mesa_free_context_data( struct gl_context *ctx )
_mesa_free_texture_data( ctx );
_mesa_free_matrix_data( ctx );
_mesa_free_viewport_data( ctx );
+   _mesa_free_pipeline_data(ctx);
_mesa_free_program_data(ctx);
_mesa_free_shader_state(ctx);
_mesa_free_queryobj_data(ctx);
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index bacfc85..7c147d2 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2380,9 +2380,19 @@ struct gl_shader_program
 
 /**
  * Context state for GLSL vertex/fragment shaders.
+ * Extended to support pipeline object
  */
 struct gl_shader_state
 {
+   /** Name of the pipeline object as received from glGenProgramPipelines.
+* It would be 0 for shaders without separate shader objects.
+*/
+   GLuint Name;
+
+   GLint RefCount;
+
+   _glthread_Mutex Mutex;
+
/**
 * Programs used for rendering
 *
@@ -2404,8 +2414,23 @@ struct gl_shader_state
struct gl_shader_program *ActiveProgram;
 
GLbitfield Flags;/** Mask of GLSL_x flags */
+
+   GLboolean ValidationStatus;  /** Pipeline Validation status */
+
+   GLboolean EverBound; /** Has the pipeline object been 
created */
 };
 
+/**
+ * Context state for GLSL pipeline shaders.
+ */
+struct gl_pipeline_shader_state
+{
+   /** Currently bound pipeline object. See _mesa_BindProgramPipeline() */
+   struct gl_shader_state *PipelineObj;
+
+   /** Pipeline objects */
+   struct _mesa_HashTable *Objects;
+};
 
 /**
  * Compiler options for a single GLSL shaders type
@@ -3509,6 +3534,7 @@ struct gl_context
struct gl_geometry_program_state GeometryProgram;
struct gl_ati_fragment_shader_state ATIFragmentShader;
 
+   struct gl_pipeline_shader_state Pipeline; /** GLSL pipeline shader object 
state */
struct gl_shader_state Shader; /** GLSL shader object state */
struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_TYPES];
 
diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
index ae5e2fb..e50416c 100644
--- a/src/mesa/main/pipelineobj.c
+++ b/src/mesa/main/pipelineobj.c
@@ -54,6 +54,170 @@
 #include ../glsl/glsl_parser_extras.h
 #include ../glsl/ir_uniform.h
 
+/**
+ * Delete a pipeline object.
+ */
+void
+_mesa_delete_pipeline_object( struct gl_context *ctx, struct gl_shader_state 
*obj )
+{
+   (void) ctx;
+   _mesa_reference_shader_program(ctx, obj-_CurrentFragmentProgram, NULL);
+   _mesa_reference_shader_program(ctx, obj-CurrentFragmentProgram, NULL);
+   _mesa_reference_shader_program(ctx, obj-CurrentVertexProgram, NULL);
+   _mesa_reference_shader_program(ctx, obj-CurrentGeometryProgram, NULL);
+   _mesa_reference_shader_program(ctx, obj-ActiveProgram, NULL);
+   _glthread_DESTROY_MUTEX(obj-Mutex);
+   free(obj);
+}
+
+/**
+ * Allocate and initialize a new pipeline object.
+ *
+ */
+static struct gl_shader_state *
+_mesa_new_pipeline_object( struct gl_context *ctx, GLuint name )
+{
+   struct gl_shader_state *obj = CALLOC_STRUCT(gl_shader_state);
+   if (obj) {
+  obj-Name = name;
+  _glthread_INIT_MUTEX(obj-Mutex);
+  obj-RefCount = 1;
+  obj-Flags = get_shader_flags();
+   }
+
+   return obj;
+}
+
+/**
+ * Initialize pipeline object state for given context.
+ */
+void
+_mesa_init_pipeline(struct gl_context *ctx)
+{
+   ctx-Pipeline.Objects = _mesa_NewHashTable();
+
+   ctx-Pipeline.PipelineObj = NULL;
+}
+
+
+/**
+ * Callback for deleting a pipeline object.  Called by _mesa_HashDeleteAll().
+ */
+static void
+delete_pipelineobj_cb(GLuint id, void *data, void *userData)
+{
+   struct gl_shader_state *PipelineObj = (struct gl_shader_state *) 

[Mesa-dev] [PATCH 03/12] sso: add support of GL_PROGRAM_SEPARABLE and CreateShaderProgramv

2013-04-05 Thread gregory
CreateShaderProgramv is similar as CreateShaderProgramEXT. The 2 differences are
1/ it an array of strings
2/ it support the GL_PROGRAM_SEPARABLE (aka SeparateShader) flag
---
 src/mesa/main/mtypes.h|5 +++
 src/mesa/main/shaderapi.c |   90 +++--
 2 files changed, 67 insertions(+), 28 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 7c147d2..2445574 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2254,6 +2254,11 @@ struct gl_shader_program
 * glClear()).
 */
GLboolean InternalSeparateShader;
+   /* ARB_separate_shader_objects
+* indicates whether program can be bound for individual pipeline stages 
using
+* UseProgramStages after it is next linked.
+*/
+   GLboolean SeparateShader;
 
GLuint NumShaders;  /** number of attached shaders */
struct gl_shader **Shaders; /** List of attached the shaders */
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 95ad5ea..a86a429 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -620,6 +620,11 @@ get_programiv(struct gl_context *ctx, GLuint program, 
GLenum pname, GLint *param
case GL_PROGRAM_BINARY_LENGTH:
   *params = 0;
   return;
+   case GL_PROGRAM_SEPARABLE:
+  if(!ctx-Extensions.ARB_separate_shader_objects)
+ break;
+  *params = shProg-SeparateShader;
+  return;
default:
   break;
}
@@ -1693,6 +1698,25 @@ _mesa_ProgramParameteri(GLuint program, GLenum pname, 
GLint value)
*/
   shProg-BinaryRetreivableHint = value;
   return;
+
+   case GL_PROGRAM_SEPARABLE:
+  if(!ctx-Extensions.ARB_separate_shader_objects)
+ break;
+
+  /* Spec imply that the behavior is the same as ARB_get_program_binary
+   * Chapter 7.3 Program Objects
+   */
+  if (value != GL_TRUE  value != GL_FALSE) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ glProgramParameteri(pname=%s, value=%d): 
+ value must be 0 or 1.,
+ _mesa_lookup_enum_by_nr(pname),
+ value);
+ return;
+  }
+  shProg-SeparateShader = value;
+  return;
+
default:
   break;
}
@@ -1764,59 +1788,69 @@ _mesa_ActiveProgramEXT(GLuint program)
return;
 }
 
-
-/**
- * For GL_EXT_separate_shader_objects
- */
-GLuint GLAPIENTRY
-_mesa_CreateShaderProgramEXT(GLenum type, const GLchar *string)
+static GLuint
+_mesa_create_shader_program(struct gl_context* ctx, GLboolean separate, GLenum 
type, GLsizei count, const GLchar* const *strings)
 {
-   GET_CURRENT_CONTEXT(ctx);
const GLuint shader = create_shader(ctx, type);
GLuint program = 0;
 
if (shader) {
-  shader_source(ctx, shader, _mesa_strdup(string));
+  _mesa_ShaderSource(shader, count, strings, NULL);
+
   compile_shader(ctx, shader);
 
   program = create_shader_program(ctx);
   if (program) {
-struct gl_shader_program *shProg;
-struct gl_shader *sh;
-GLint compiled = GL_FALSE;
+ struct gl_shader_program *shProg;
+ struct gl_shader *sh;
+ GLint compiled = GL_FALSE;
 
-shProg = _mesa_lookup_shader_program(ctx, program);
-sh = _mesa_lookup_shader(ctx, shader);
+ shProg = _mesa_lookup_shader_program(ctx, program);
+ sh = _mesa_lookup_shader(ctx, shader);
 
-get_shaderiv(ctx, shader, GL_COMPILE_STATUS, compiled);
-if (compiled) {
-   attach_shader(ctx, program, shader);
-   link_program(ctx, program);
-   detach_shader(ctx, program, shader);
+ shProg-SeparateShader = separate;
 
+ get_shaderiv(ctx, shader, GL_COMPILE_STATUS, compiled);
+ if (compiled) {
+attach_shader(ctx, program, shader);
+link_program(ctx, program);
+detach_shader(ctx, program, shader);
 #if 0
-   /* Possibly... */
-   if (active-user-defined-varyings-in-linked-program) {
-  append-error-to-info-log;
-  shProg-LinkStatus = GL_FALSE;
-   }
+/* Possibly... */
+if (active-user-defined-varyings-in-linked-program) {
+   append-error-to-info-log;
+   shProg-LinkStatus = GL_FALSE;
+}
 #endif
-}
+ }
 
-ralloc_strcat(shProg-InfoLog, sh-InfoLog);
+ ralloc_strcat(shProg-InfoLog, sh-InfoLog);
   }
-
   delete_shader(ctx, shader);
}
-
return program;
 }
 
 /**
+ * For GL_EXT_separate_shader_objects
+ */
+GLuint GLAPIENTRY
+_mesa_CreateShaderProgramEXT(GLenum type, const GLchar *string)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   return _mesa_create_shader_program(ctx, GL_FALSE, type, 1, string);
+}
+
+/**
  * ARB_separate_shader_objects: Compile  Link Program
+ * Basically the same as _mesa_CreateShaderProgramEXT but
+ * with support of multiple strings and SeparateShader flag.
  */
 

[Mesa-dev] [PATCH 04/12] sso: implement ActiveShaderProgram GetProgramPipelineiv

2013-04-05 Thread gregory
---
 src/mesa/main/pipelineobj.c |   73 +++
 1 file changed, 73 insertions(+)

diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
index e50416c..7a56c67 100644
--- a/src/mesa/main/pipelineobj.c
+++ b/src/mesa/main/pipelineobj.c
@@ -233,6 +233,28 @@ _mesa_UseProgramStages (GLuint pipeline, GLbitfield 
stages, GLuint program)
 void GLAPIENTRY
 _mesa_ActiveShaderProgram (GLuint pipeline, GLuint program)
 {
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_shader_program *shProg = (program != 0)
+  ? _mesa_lookup_shader_program_err(ctx, program, 
glActiveShaderProgram(program))
+  : NULL;
+
+   struct gl_shader_state *pipe = lookup_pipeline_object(ctx, pipeline);
+
+   if (!pipe) {
+  _mesa_error(ctx, GL_INVALID_OPERATION, 
glActiveShaderProgram(pipeline));
+  return;
+   }
+
+   /* Object is created by any Pipeline call but glGenProgramPipelines, 
glIsProgramPipeline and GetProgramPipelineInfoLog */
+   pipe-EverBound = GL_TRUE;
+
+   if ((shProg != NULL)  !shProg-LinkStatus) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+glActiveShaderProgram(program %u not linked), shProg-Name);
+  return;
+   }
+
+   _mesa_reference_shader_program(ctx, pipe-ActiveProgram, shProg);
 }
 
 /**
@@ -350,6 +372,57 @@ _mesa_IsProgramPipeline (GLuint pipeline)
 void GLAPIENTRY
 _mesa_GetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params)
 {
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_shader_state *pipe = lookup_pipeline_object(ctx, pipeline);
+
+   /* Are geometry shaders available in this context?
+*/
+   const bool has_gs = _mesa_is_desktop_gl(ctx)  
ctx-Extensions.ARB_geometry_shader4;
+
+   if (!pipe) {
+  _mesa_error(ctx, GL_INVALID_OPERATION, 
glGetProgramPipelineiv(pipeline));
+  return;
+   }
+
+   /* Object is created by any Pipeline call but glGenProgramPipelines, 
glIsProgramPipeline and GetProgramPipelineInfoLog */
+   pipe-EverBound = GL_TRUE;
+
+   switch (pname) {
+  case GL_ACTIVE_PROGRAM:
+ *params = (pipe-ActiveProgram) ? pipe-ActiveProgram-Name : 0;
+ return;
+  case GL_INFO_LOG_LENGTH:
+ // TODO
+ *params = 0;
+ return;
+  case GL_VALIDATE_STATUS:
+ *params = pipe-ValidationStatus;
+ return;
+  case GL_VERTEX_SHADER:
+ *params = (pipe-CurrentVertexProgram) ? 
pipe-CurrentVertexProgram-Name : 0;
+ return;
+  case GL_TESS_EVALUATION_SHADER:
+ /* NOT YET SUPPORTED */
+ break;
+  case GL_TESS_CONTROL_SHADER:
+ /* NOT YET SUPPORTED */
+ break;
+  case GL_GEOMETRY_SHADER:
+ if (!has_gs) break;
+ *params = (pipe-CurrentGeometryProgram) ? 
pipe-CurrentGeometryProgram-Name : 0;;
+ return;
+  case GL_FRAGMENT_SHADER:
+ *params = (pipe-CurrentFragmentProgram) ? 
pipe-CurrentFragmentProgram-Name : 0;;
+ return;
+  case GL_COMPUTE_SHADER:
+ /* NOT YET SUPPORTED */
+ break;
+  default:
+ break;
+   }
+
+   _mesa_error(ctx, GL_INVALID_ENUM, glGetProgramPipelineiv(pname=%s),
+ _mesa_lookup_enum_by_nr(pname));
 }
 
 /**
-- 
1.7.10.4

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


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

2013-04-05 Thread gregory
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...
---
 src/mesa/main/mtypes.h  |4 ++
 src/mesa/main/pipelineobj.c |8 
 src/mesa/main/shaderapi.c   |   91 +--
 3 files changed, 100 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 2445574..dc54f3d 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2433,6 +2433,9 @@ struct gl_pipeline_shader_state
/** Currently bound pipeline object. See _mesa_BindProgramPipeline() */
struct gl_shader_state *PipelineObj;
 
+   /* Default Object to ensure that _Shader is never NULL */
+   struct gl_shader_state *Default;
+
/** Pipeline objects */
struct _mesa_HashTable *Objects;
 };
@@ -3541,6 +3544,7 @@ struct gl_context
 
struct gl_pipeline_shader_state Pipeline; /** GLSL pipeline shader object 
state */
struct gl_shader_state Shader; /** GLSL shader object state */
+   struct gl_shader_state *_Shader; /** Points to ::Shader or 
::Pipeline.PipelineObj or ::Pipeline.Default */
struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_TYPES];
 
struct gl_query_state Query;  /** occlusion, timer queries */
diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
index 7a56c67..c805cdf 100644
--- a/src/mesa/main/pipelineobj.c
+++ b/src/mesa/main/pipelineobj.c
@@ -97,6 +97,10 @@ _mesa_init_pipeline(struct gl_context *ctx)
ctx-Pipeline.Objects = _mesa_NewHashTable();
 
ctx-Pipeline.PipelineObj = NULL;
+
+   /* Install a default Pipeline */
+   ctx-Pipeline.Default = _mesa_new_pipeline_object(ctx, 0);
+   _mesa_reference_pipeline_object(ctx, ctx-_Shader, ctx-Pipeline.Default);
 }
 
 
@@ -120,6 +124,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 a86a429..1092287 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -43,6 +43,7 @@
 #include main/hash.h
 #include main/mfeatures.h
 #include main/mtypes.h
+#include main/pipelineobj.h
 #include main/shaderapi.h
 #include main/shaderobj.h
 #include main/transformfeedback.h
@@ -138,6 +139,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);
_glthread_DESTROY_MUTEX(ctx-Shader.Mutex);
 }
@@ -1453,7 +1456,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.PipelineObj) {
+ _mesa_BindProgramPipeline (ctx-Pipeline.PipelineObj-Name);
+  }
+   }
 }
 
 
@@ -1769,7 +1794,37 @@ _mesa_UseShaderProgramEXT(GLenum type, GLuint program)
   }
}
 
-   _mesa_use_shader_program(ctx, type, 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 

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

2013-04-05 Thread gregory
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
---
 src/mesa/drivers/common/meta.c   |   10 ++--
 src/mesa/drivers/dri/i965/brw_gs.c   |2 +-
 src/mesa/drivers/dri/i965/brw_shader.cpp |2 +-
 src/mesa/drivers/dri/i965/brw_vs.c   |4 +-
 src/mesa/drivers/dri/i965/brw_vs_surface_state.c |2 +-
 src/mesa/drivers/dri/i965/brw_wm.c   |4 +-
 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_sol_state.c   |4 +-
 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 |2 +-
 src/mesa/main/context.c  |   32 +--
 src/mesa/main/ff_fragment_shader.cpp |8 +--
 src/mesa/main/get.c  |8 +++
 src/mesa/main/shaderapi.c|   26 -
 src/mesa/main/state.c|   14 ++---
 src/mesa/main/texstate.c |   12 ++--
 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  |   12 ++--
 src/mesa/state_tracker/st_atom_clip.c|2 +-
 src/mesa/state_tracker/st_atom_constbuf.c|4 +-
 src/mesa/state_tracker/st_cb_drawpixels.c|2 +-
 src/mesa/state_tracker/st_draw.c |6 +-
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp   |2 +-
 src/mesa/state_tracker/st_program.c  |6 +-
 src/mesa/swrast/s_fragprog.c |2 +-
 31 files changed, 132 insertions(+), 124 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 8114550..139e240 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -617,13 +617,13 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
 
   if (ctx-Extensions.ARB_shader_objects) {
 _mesa_reference_shader_program(ctx, save-VertexShader,
-   ctx-Shader.CurrentVertexProgram);
+   ctx-_Shader-CurrentVertexProgram);
 _mesa_reference_shader_program(ctx, save-GeometryShader,
-   ctx-Shader.CurrentGeometryProgram);
+   ctx-_Shader-CurrentGeometryProgram);
 _mesa_reference_shader_program(ctx, save-FragmentShader,
-   ctx-Shader.CurrentFragmentProgram);
+   ctx-_Shader-CurrentFragmentProgram);
 _mesa_reference_shader_program(ctx, save-ActiveShader,
-   ctx-Shader.ActiveProgram);
+   ctx-_Shader-ActiveProgram);
 
  _mesa_UseProgram(0);
   }
@@ -963,7 +963,7 @@ _mesa_meta_end(struct gl_context *ctx)
 _mesa_use_shader_program(ctx, GL_FRAGMENT_SHADER,
  save-FragmentShader);
 
-  _mesa_reference_shader_program(ctx, ctx-Shader.ActiveProgram,
+  _mesa_reference_shader_program(ctx, ctx-_Shader-ActiveProgram,
 save-ActiveShader);
 
   _mesa_reference_shader_program(ctx, save-VertexShader, NULL);
diff --git a/src/mesa/drivers/dri/i965/brw_gs.c 
b/src/mesa/drivers/dri/i965/brw_gs.c
index 00a2a5d..14bf4a4 100644
--- a/src/mesa/drivers/dri/i965/brw_gs.c
+++ b/src/mesa/drivers/dri/i965/brw_gs.c
@@ -189,7 +189,7 @@ static void populate_key( struct brw_context *brw,
   /* _NEW_TRANSFORM_FEEDBACK */
   if (_mesa_is_xfb_active_and_unpaused(ctx)) {
  const struct gl_shader_program *shaderprog =
-ctx-Shader.CurrentVertexProgram;
+ctx-_Shader-CurrentVertexProgram;
  const struct gl_transform_feedback_info *linked_xfb_info =
 shaderprog-LinkedTransformFeedback;
  int i;
diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp 
b/src/mesa/drivers/dri/i965/brw_shader.cpp
index 066cf4e..d8c5b56 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -255,7 +255,7 @@ brw_link_shader(struct gl_context *ctx, struct 
gl_shader_program *shProg)
 
   _mesa_reference_program(ctx, prog, NULL);
 
-  if (ctx-Shader.Flags  GLSL_DUMP) {
+  if (ctx-_Shader-Flags  GLSL_DUMP) {
  static const char *target_strings[]
 = { vertex, fragment, geometry };
  

[Mesa-dev] [PATCH 07/12] sso: update meta state

2013-04-05 Thread gregory
save and restore _Shader/Pipeline binding point. Rational we don't want any 
conflict
when the program will be unattached.
---
 src/mesa/drivers/common/meta.c |   25 ++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 139e240..62f6ffa 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -51,6 +51,7 @@
 #include main/macros.h
 #include main/matrix.h
 #include main/mipmap.h
+#include main/pipelineobj.h
 #include main/pixel.h
 #include main/pbo.h
 #include main/polygon.h
@@ -142,6 +143,8 @@ struct save_state
struct gl_shader_program *GeometryShader;
struct gl_shader_program *FragmentShader;
struct gl_shader_program *ActiveShader;
+   struct gl_shader_state   *_Shader;
+   struct gl_shader_state   *Pipeline;
 
/** MESA_META_STENCIL_TEST */
struct gl_stencil_attrib Stencil;
@@ -615,6 +618,13 @@ _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.PipelineObj);
+ _mesa_BindProgramPipeline(0);
+  }
+
   if (ctx-Extensions.ARB_shader_objects) {
 _mesa_reference_shader_program(ctx, save-VertexShader,
ctx-_Shader-CurrentVertexProgram);
@@ -952,16 +962,24 @@ _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.PipelineObj, 
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-VertexShader);
+_mesa_use_shader_program(ctx, GL_VERTEX_SHADER, save-VertexShader, 
ctx-_Shader);
 
   if (ctx-Extensions.ARB_geometry_shader4)
 _mesa_use_shader_program(ctx, GL_GEOMETRY_SHADER_ARB,
- save-GeometryShader);
+ save-GeometryShader, ctx-_Shader);
 
   if (ctx-Extensions.ARB_fragment_shader)
 _mesa_use_shader_program(ctx, GL_FRAGMENT_SHADER,
- save-FragmentShader);
+ save-FragmentShader, ctx-_Shader);
+
 
   _mesa_reference_shader_program(ctx, ctx-_Shader-ActiveProgram,
 save-ActiveShader);
@@ -970,6 +988,7 @@ _mesa_meta_end(struct gl_context *ctx)
   _mesa_reference_shader_program(ctx, save-GeometryShader, NULL);
   _mesa_reference_shader_program(ctx, save-FragmentShader, NULL);
   _mesa_reference_shader_program(ctx, save-ActiveShader, NULL);
+  _mesa_reference_pipeline_object(ctx, save-_Shader, NULL);
}
 
if (state  MESA_META_STENCIL_TEST) {
-- 
1.7.10.4

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


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

2013-04-05 Thread gregory
Implement _mesa_UseProgramStages = 
arb_separate_shader_object-GetProgramPipelineiv is now pass :)

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
---
 src/mesa/main/pipelineobj.c |  103 +++
 src/mesa/main/shaderapi.c   |   32 --
 src/mesa/main/shaderapi.h   |2 +-
 3 files changed, 122 insertions(+), 15 deletions(-)

diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
index c805cdf..79a5866 100644
--- a/src/mesa/main/pipelineobj.c
+++ b/src/mesa/main/pipelineobj.c
@@ -233,6 +233,109 @@ _mesa_reference_pipeline_object_(struct gl_context *ctx,
 void GLAPIENTRY
 _mesa_UseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program)
 {
+   GET_CURRENT_CONTEXT(ctx);
+
+   struct gl_shader_state *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;
+
+   /* NOT YET SUPPORTED:
+* GL_TESS_CONTROL_SHADER_BIT
+* GL_TESS_EVALUATION_SHADER_BIT
+* GL_COMPUTE_SHADER_BIT
+*/
+   GLbitfield any_valid_stages = GL_VERTEX_SHADER_BIT | GL_FRAGMENT_SHADER_BIT;
+   if (_mesa_is_desktop_gl(ctx)  ctx-Extensions.ARB_geometry_shader4)
+  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;
+   }
+
+   /*
+*  An INVALID_OPERATION error 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;
+*/
+   /*
+* 6a. Should the fragment shader program object be allowed to changed
+* within transform feedback mode?
+* RESOLVED:  No, this should generate an GL_INVALID_OPERATION error.
+*/
+   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) {
+  /* An INVALID_OPERATION error is generated if program is the name of a
+   * shader object
+   */
+  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;
+  }
+
+  /* An INVALID_VALUE error is generated if program is not the name of ei-
+   * ther a program or shader object
+   */
+  shProg = _mesa_lookup_shader_program(ctx, program);
+  if(shProg == NULL) {
+ _mesa_error(ctx, GL_INVALID_VALUE, glUseProgramStages(progam is not 
a program object));
+ return;
+  }
+
+  /* An INVALID_OPERATION error is generated if the program object named
+   * by program was linked without the PROGRAM_SEPARABLE parameter set, has
+   * not been linked, or was last linked unsuccessfully. The corresponding 
shader
+   * stages in pipeline 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;
+  }
+   }
+
+   /*
+*  7.  What happens if you have a program object current for a shader 
stage,
+*but the program object doesn't contain an executable for that stage?
+
+*RESOLVED:  This is not an error; instead it is as though there were no
+*program bound to that stage.  We have two different notions for
+*programs bound to shader stages.  A program is current for a stage
+*if it bound to that stage in the active program pipeline object.  A
+*program is active for a stage if it is current and it has an
+*executable for this stage.  In this case, the program would be current
+*but not active.
+
+*When no program is active for a stage, the stage will be replaced with
+*fixed functionality logic (compatibility profile vertex and fragment),
+*disabled (tessellation control and evaluation, geometry), or have
+*undefined results (core profile vertex and fragment).
+*/
+
+   if (stages  GL_VERTEX_SHADER_BIT)
+  _mesa_use_shader_program(ctx, GL_VERTEX_SHADER, shProg, pipe);
+   if (stages  GL_FRAGMENT_SHADER_BIT)
+  

[Mesa-dev] [PATCH 09/12] sso: implement BindProgramPipeline

2013-04-05 Thread gregory
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
---
 src/mesa/main/pipelineobj.c |   54 +++
 1 file changed, 54 insertions(+)

diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
index 79a5866..7351d45 100644
--- a/src/mesa/main/pipelineobj.c
+++ b/src/mesa/main/pipelineobj.c
@@ -374,6 +374,60 @@ _mesa_ActiveShaderProgram (GLuint pipeline, GLuint program)
 void GLAPIENTRY
 _mesa_BindProgramPipeline (GLuint pipeline)
 {
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_shader_state *newObj = NULL;
+
+   if ( ctx-_Shader-Name == pipeline )
+  return;   /* rebinding the same pipeline object- no change */
+
+   /*
+*  An INVALID_OPERATION error 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.PipelineObj, newObj);
+
+   /* Spec say:
+* if any program is bound to the context, the current pipeline object is
+* ignored.
+*/
+   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);
+  /* FIXME */
+  if (ctx-Driver.UseProgram)
+ ctx-Driver.UseProgram(ctx, NULL);
+   }
 }
 
 /**
-- 
1.7.10.4

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


[Mesa-dev] [PATCH 10/12] sso: update glGet: GL_PROGRAM_PIPELINE_BINDING

2013-04-05 Thread gregory
---
 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 7ce2df1..f6311a5 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -356,6 +356,7 @@ EXTRA_EXT(ARB_map_buffer_alignment);
 EXTRA_EXT(ARB_texture_cube_map_array);
 EXTRA_EXT(ARB_texture_buffer_range);
 EXTRA_EXT(ARB_texture_multisample);
+EXTRA_EXT(ARB_separate_shader_objects);
 
 static const int
 extra_NV_primitive_restart[] = {
@@ -861,6 +862,14 @@ find_custom_value(struct gl_context *ctx, const struct 
value_desc *d, union valu
  _mesa_problem(ctx, driver doesn't implement GetTimestamp);
   }
   break;
+   /* GL_ARB_separate_shader_objects */
+   case GL_PROGRAM_PIPELINE_BINDING:
+  if (ctx-Pipeline.PipelineObj) {
+ v-value_int = ctx-Pipeline.PipelineObj-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 7d4f7e2..e82c705 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -709,6 +709,9 @@ descriptor=[
 
 # GL_ARB_texture_cube_map_array
   [ TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB, LOC_CUSTOM, TYPE_INT, 
TEXTURE_CUBE_ARRAY_INDEX, extra_ARB_texture_cube_map_array ],
+
+# GL_ARB_separate_shader_objects
+  [ PROGRAM_PIPELINE_BINDING, LOC_CUSTOM, TYPE_INT, 
GL_PROGRAM_PIPELINE_BINDING, extra_ARB_separate_shader_objects ],
 ]},
 
 # Enums restricted to OpenGL Core profile
-- 
1.7.10.4

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


[Mesa-dev] [PATCH 11/12] sso: implement ValidateProgramPipeline and GetProgramPipelineInfoLog

2013-04-05 Thread gregory
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_pipeline 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.
---
 src/mesa/main/context.c |9 ++
 src/mesa/main/mtypes.h  |2 +
 src/mesa/main/pipelineobj.c |  202 ++-
 src/mesa/main/pipelineobj.h |3 +
 src/mesa/main/uniform_query.cpp |   71 ++
 src/mesa/main/uniforms.h|3 +
 6 files changed, 287 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 6a0619a..243f957 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1767,6 +1767,7 @@ _mesa_check_blend_func_error(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
  */
@@ -1876,6 +1877,14 @@ _mesa_valid_to_render(struct gl_context *ctx, const char 
*where)
   }
}
 
+   /* A pipeline object is bound */
+   if (ctx-_Shader-Name  !ctx-_Shader-ValidationStatus) {
+  /* 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 dc54f3d..c551273 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2423,6 +2423,8 @@ struct gl_shader_state
GLboolean ValidationStatus;  /** Pipeline Validation status */
 
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 7351d45..d90ef9b 100644
--- a/src/mesa/main/pipelineobj.c
+++ b/src/mesa/main/pipelineobj.c
@@ -66,6 +66,7 @@ _mesa_delete_pipeline_object( struct gl_context *ctx, struct 
gl_shader_state *ob
_mesa_reference_shader_program(ctx, obj-CurrentVertexProgram, NULL);
_mesa_reference_shader_program(ctx, obj-CurrentGeometryProgram, NULL);
_mesa_reference_shader_program(ctx, obj-ActiveProgram, NULL);
+   ralloc_free(obj-InfoLog);
_glthread_DESTROY_MUTEX(obj-Mutex);
free(obj);
 }
@@ -83,6 +84,7 @@ _mesa_new_pipeline_object( struct gl_context *ctx, GLuint 
name )
   _glthread_INIT_MUTEX(obj-Mutex);
   obj-RefCount = 1;
   obj-Flags = get_shader_flags();
+  obj-InfoLog = ralloc_strdup(NULL, );
}
 
return obj;
@@ -329,13 +331,15 @@ _mesa_UseProgramStages (GLuint pipeline, GLbitfield 
stages, GLuint program)
 *disabled (tessellation control and evaluation, geometry), or have
 *undefined results (core profile vertex and fragment).
 */
-
if (stages  GL_VERTEX_SHADER_BIT)
   _mesa_use_shader_program(ctx, GL_VERTEX_SHADER, shProg, pipe);
if (stages  GL_FRAGMENT_SHADER_BIT)
   _mesa_use_shader_program(ctx, GL_FRAGMENT_SHADER, shProg, pipe);
if (stages  GL_GEOMETRY_SHADER_BIT)
   _mesa_use_shader_program(ctx, GL_GEOMETRY_SHADER_ARB, shProg, pipe);
+
+   /* Validation would need to be redone */
+   pipe-ValidationStatus = GL_FALSE;
 }
 
 /**
@@ -557,8 +561,7 @@ _mesa_GetProgramPipelineiv (GLuint pipeline, GLenum pname, 
GLint *params)
  *params = (pipe-ActiveProgram) ? pipe-ActiveProgram-Name : 0;
  return;
   case GL_INFO_LOG_LENGTH:
- // TODO
- *params = 0;
+ *params = pipe-InfoLog ? strlen(pipe-InfoLog) + 1 : 0;
  return;
   case GL_VALIDATE_STATUS:
  *params = pipe-ValidationStatus;
@@ -590,15 +593,208 @@ _mesa_GetProgramPipelineiv (GLuint pipeline, GLenum 
pname, GLint *params)
  _mesa_lookup_enum_by_nr(pname));
 }
 
+static GLboolean
+ProgramEnabledEverywhere(struct gl_shader_state *pipe, struct 
gl_shader_program *prog,
+  char *errMsg, size_t errMsgLength)
+{
+   if (!prog) return GL_TRUE;
+
+   GLboolean status = GL_TRUE;
+
+   if (prog-_LinkedShaders[MESA_SHADER_VERTEX]) {
+  if (pipe-CurrentVertexProgram) {
+ if (prog-Name != pipe-CurrentVertexProgram-Name) {
+status = GL_FALSE;
+ }
+  } else {
+ status = GL_FALSE;
+  }
+   }
+
+   if (prog-_LinkedShaders[MESA_SHADER_FRAGMENT]) {
+ 

[Mesa-dev] [PATCH 12/12] sso: Finally enable the extension on Gallium

2013-04-05 Thread gregory
Note: it probably work on others drivers.
---
 src/mesa/state_tracker/st_extensions.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mesa/state_tracker/st_extensions.c 
b/src/mesa/state_tracker/st_extensions.c
index 11db9d3..4af46f3 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -519,6 +519,7 @@ void st_init_extensions(struct st_context *st)
ctx-Extensions.ARB_half_float_vertex = GL_TRUE;
ctx-Extensions.ARB_internalformat_query = GL_TRUE;
ctx-Extensions.ARB_map_buffer_range = GL_TRUE;
+   ctx-Extensions.ARB_separate_shader_objects = GL_TRUE;
ctx-Extensions.ARB_shader_objects = GL_TRUE;
ctx-Extensions.ARB_shading_language_100 = GL_TRUE;
ctx-Extensions.ARB_texture_border_clamp = GL_TRUE; /* XXX temp */
-- 
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] Fix glXChooseFBConfig with GLX_DRAWABLE_TYPE GLX_DONT_CARE

2013-04-05 Thread Ian Romanick

On 04/05/2013 01:51 PM, Alexander Monakov wrote:

On Thu, Apr 4, 2013 at 1:02 AM, Ian Romanick i...@freedesktop.org wrote:

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

Please add the following lines to the commit message:

NOTE: This is a candidate for stable branches.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=47478
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=62999
Bugzilla: http://bugs.winehq.org/show_bug.cgi?id=26763


Done. I don't have git write access, can you push it for me?


Done. :)  Thanks for the patch.

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


[Mesa-dev] radeonsi: tiling and compressed texture

2013-04-05 Thread j . glisse
Rebase on top of lastest libdrm patch. With small modification to ddx you can 
also
have tiled front buffer rendering. But again we need to wait next mesa release
before changing ddx to assume by default it is installed with a recent enough 
mesa.

No regression, just new test that pass.

Cheers,
Jerome

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


[Mesa-dev] [PATCH 1/2] radeonsi: add 2d tiling support for texture v2

2013-04-05 Thread j . glisse
From: Jerome Glisse jgli...@redhat.com

v2: Remove left over code

Signed-off-by: Jerome Glisse jgli...@redhat.com
---
 src/gallium/drivers/radeonsi/r600_texture.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/r600_texture.c 
b/src/gallium/drivers/radeonsi/r600_texture.c
index 1b8382f..8992f9a 100644
--- a/src/gallium/drivers/radeonsi/r600_texture.c
+++ b/src/gallium/drivers/radeonsi/r600_texture.c
@@ -47,7 +47,6 @@ static void r600_copy_to_staging_texture(struct pipe_context 
*ctx, struct r600_t
transfer-box);
 }
 
-
 /* Copy from a transfer's staging texture to a full GPU one. */
 static void r600_copy_from_staging_texture(struct pipe_context *ctx, struct 
r600_transfer *rtransfer)
 {
@@ -152,12 +151,12 @@ static int r600_init_surface(struct r600_screen *rscreen,
 
if (!is_flushed_depth  is_depth) {
surface-flags |= RADEON_SURF_ZBUFFER;
-
if (is_stencil) {
surface-flags |= RADEON_SURF_SBUFFER |
RADEON_SURF_HAS_SBUFFER_MIPTREE;
}
}
+   surface-flags |= RADEON_SURF_HAS_TILE_MODE_INDEX;
return 0;
 }
 
@@ -530,7 +529,11 @@ struct pipe_resource *si_texture_create(struct pipe_screen 
*screen,
 
if (!(templ-flags  R600_RESOURCE_FLAG_TRANSFER) 
!(templ-bind  PIPE_BIND_SCANOUT)) {
-   array_mode = V_009910_ARRAY_1D_TILED_THIN1;
+   if (util_format_is_compressed(templ-format)) {
+   array_mode = V_009910_ARRAY_1D_TILED_THIN1;
+   } else {
+   array_mode = V_009910_ARRAY_2D_TILED_THIN1;
+   }
}
 
r = r600_init_surface(rscreen, surface, templ, array_mode,
@@ -620,6 +623,8 @@ struct pipe_resource *si_texture_from_handle(struct 
pipe_screen *screen,
if (r) {
return NULL;
}
+   /* always set the scanout flags */
+   surface.flags |= RADEON_SURF_SCANOUT;
return (struct pipe_resource *)r600_texture_create_object(screen, 
templ, array_mode,
  stride, 0, 
buf, FALSE, surface);
 }
-- 
1.8.1.4

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


[Mesa-dev] [PATCH 2/2] radeonsi: add support for compressed texture

2013-04-05 Thread j . glisse
From: Jerome Glisse jgli...@redhat.com

Most test pass, issue are with border color and swizzle.

Based on ircnickmaelcum patch.

Signed-off-by: Jerome Glisse jgli...@redhat.com
---
 src/gallium/drivers/radeonsi/si_state.c | 165 +---
 src/gallium/drivers/radeonsi/sid.h  |   7 ++
 2 files changed, 96 insertions(+), 76 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_state.c 
b/src/gallium/drivers/radeonsi/si_state.c
index ca9e8b4..d968b95 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -30,6 +30,7 @@
 #include util/u_helpers.h
 #include util/u_math.h
 #include util/u_pack_color.h
+#include util/u_format_s3tc.h
 #include tgsi/tgsi_parse.h
 #include radeonsi_pipe.h
 #include radeonsi_shader.h
@@ -1164,6 +1165,8 @@ static uint32_t si_translate_texformat(struct pipe_screen 
*screen,
   const struct util_format_description 
*desc,
   int first_non_void)
 {
+   struct r600_screen *rscreen = (struct r600_screen*)screen;
+   bool enable_s3tc = rscreen-info.drm_minor = 31;
boolean uniform = TRUE;
int i;
 
@@ -1206,6 +1209,51 @@ static uint32_t si_translate_texformat(struct 
pipe_screen *screen,
}
 
/* TODO compressed formats */
+   if (desc-layout == UTIL_FORMAT_LAYOUT_RGTC) {
+   if (!enable_s3tc)
+   goto out_unknown;
+
+   switch (format) {
+   case PIPE_FORMAT_RGTC1_SNORM:
+   case PIPE_FORMAT_LATC1_SNORM:
+   case PIPE_FORMAT_RGTC1_UNORM:
+   case PIPE_FORMAT_LATC1_UNORM:
+   return V_008F14_IMG_DATA_FORMAT_BC4;
+   case PIPE_FORMAT_RGTC2_SNORM:
+   case PIPE_FORMAT_LATC2_SNORM:
+   case PIPE_FORMAT_RGTC2_UNORM:
+   case PIPE_FORMAT_LATC2_UNORM:
+   return V_008F14_IMG_DATA_FORMAT_BC5;
+   default:
+   goto out_unknown;
+   }
+   }
+
+   if (desc-layout == UTIL_FORMAT_LAYOUT_S3TC) {
+
+   if (!enable_s3tc)
+   goto out_unknown;
+
+   if (!util_format_s3tc_enabled) {
+   goto out_unknown;
+   }
+
+   switch (format) {
+   case PIPE_FORMAT_DXT1_RGB:
+   case PIPE_FORMAT_DXT1_RGBA:
+   case PIPE_FORMAT_DXT1_SRGB:
+   case PIPE_FORMAT_DXT1_SRGBA:
+   return V_008F14_IMG_DATA_FORMAT_BC1;
+   case PIPE_FORMAT_DXT3_RGBA:
+   case PIPE_FORMAT_DXT3_SRGBA:
+   return V_008F14_IMG_DATA_FORMAT_BC2;
+   case PIPE_FORMAT_DXT5_RGBA:
+   case PIPE_FORMAT_DXT5_SRGBA:
+   return V_008F14_IMG_DATA_FORMAT_BC3;
+   default:
+   goto out_unknown;
+   }
+   }
 
if (format == PIPE_FORMAT_R9G9B9E5_FLOAT) {
return V_008F14_IMG_DATA_FORMAT_5_9_9_9;
@@ -1541,67 +1589,16 @@ boolean si_is_format_supported(struct pipe_screen 
*screen,
return retval == usage;
 }
 
-static unsigned si_tile_mode_index(struct r600_resource_texture *rtex, 
unsigned level)
-{
-   if (util_format_is_depth_or_stencil(rtex-real_format)) {
-   if (rtex-surface.level[level].mode == RADEON_SURF_MODE_1D) {
-   return 4;
-   } else if (rtex-surface.level[level].mode == 
RADEON_SURF_MODE_2D) {
-   switch (rtex-real_format) {
-   case PIPE_FORMAT_Z16_UNORM:
-   return 5;
-   case PIPE_FORMAT_S8_UINT_Z24_UNORM:
-   case PIPE_FORMAT_X8Z24_UNORM:
-   case PIPE_FORMAT_Z24X8_UNORM:
-   case PIPE_FORMAT_Z24_UNORM_S8_UINT:
-   case PIPE_FORMAT_Z32_FLOAT:
-   case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
-   return 6;
-   default:
-   return 7;
-   }
-   }
-   }
+static unsigned si_tile_mode_index(struct r600_resource_texture *rtex, 
unsigned level, bool stencil)
+{
+   unsigned tile_mode_index = 0;
 
-   switch (rtex-surface.level[level].mode) {
-   default:
-   assert(!Invalid surface mode);
-   /* Fall through */
-   case RADEON_SURF_MODE_LINEAR_ALIGNED:
-   return 8;
-   case RADEON_SURF_MODE_1D:
-   if (rtex-surface.flags  RADEON_SURF_SCANOUT)
-   return 9;
-   else
-   return 13;
-   case RADEON_SURF_MODE_2D:
-   if (rtex-surface.flags  RADEON_SURF_SCANOUT) {
-   switch (util_format_get_blocksize(rtex-real_format)) {
- 

Re: [Mesa-dev] [PATCH 00/12] RFC: add support of ARB_separate_shader_object extensions

2013-04-05 Thread Ian Romanick

On 04/05/2013 02:25 PM, gregory wrote:

Hello,

Please find an implementation of the ARB_separate_shader_objects extensions. I 
concentrate mostly on the state part of
the extensions aka the pipeline object. I think GLSL already compiled program 
separately anyway.

I test my implementation on the test that I send yesterday ago on piglit. All 
tests are ok but I miss a test for new uniform function.
Besides there are still some parts unimplemented:
1/ GLX Protocol: not sure it will be useful, as understand GLX is kinda 
drepecated


We don't have any other GLX support for GLSL, so I wouldn't worry about it.


2/ Display list: need to be done or maybe enable the extensions on CORE profile


I haven't had any requests for the functionality with compatibility 
profiles.  As far as I can tell, all of the ISVs that want this feature 
are already shifting to core profiles.


Maybe Aras can give us one humble ISVs opinion. :)


Stuff that bug me:
1/ I don't get how to use ralloc_strdup. So I set the ralloc's context to NULL, 
not sure it is fully correct


The ralloc memory context is (usually) some other thing allocated by 
ralloc.  When the context is freed, all of the things allocated using 
that context will also be freed.  So,


a = ralloc_size(NULL, 32);
b = ralloc_size(a, 32);
...
ralloc_free(a);

Will free both a and b.

You can also use ralloc_steal to reparent an allocation.  So,

a = ralloc_size(NULL, 32);
b = ralloc_size(a, 32);
c = ralloc_size(NULL, 32);

ralloc_steal(c, b);

ralloc_free(a);

will only cause a to be freed.  b is now in the context of c.

We use this in the GLSL compiler to, basically, implement a 
mark-and-sweep garbage collector.  As various parts of the compiler 
allocate new objects and orphan others, we'll do a ralloc_steal pass to 
reparent all of the objects that are still connected.  A ralloc_free of 
the old context will destroy all the objects that are no longer connected.



2/ I implement the feature as a pure mesa state. I don't know if they're any 
rule to create driver functions. Maybe it
would be better to add 
CreatePipelineObject/DeletePipelineObject/BindPipeline/UseProgramStages. 
Opinion is welcome

Note: I didn't yet rebase my work on latest mesa. Not sure if it is critical 
for a preliminary review.
Note2: I create the xml manually, don't know if there is any automatic flow.

Thanks

gregory (12):
   sso: Create extensions entry points
   sso: Add pipeline container/state
   sso: add support of GL_PROGRAM_SEPARABLE and CreateShaderProgramv
   sso: implement ActiveShaderProgram  GetProgramPipelineiv
   sso: replace Shader binding point with _Shader
   sso: rename Shader to the pointer _Shader
   sso: update meta state
   sso:Implement _mesa_UseProgramStages
   sso: implement BindProgramPipeline
   sso: update glGet: GL_PROGRAM_PIPELINE_BINDING
   sso: implement ValidateProgramPipeline and GetProgramPipelineInfoLog
   sso: Finally enable the extension on Gallium

  src/mapi/glapi/gen/ARB_separate_shader_objects.xml |  392 ++
  src/mapi/glapi/gen/Makefile.am |1 +
  src/mapi/glapi/gen/gl_API.xml  |6 +-
  src/mapi/glapi/gen/gl_genexec.py   |1 +
  src/mesa/drivers/common/meta.c |   35 +-
  src/mesa/drivers/dri/i965/brw_gs.c |2 +-
  src/mesa/drivers/dri/i965/brw_shader.cpp   |2 +-
  src/mesa/drivers/dri/i965/brw_vs.c |4 +-
  src/mesa/drivers/dri/i965/brw_vs_surface_state.c   |2 +-
  src/mesa/drivers/dri/i965/brw_wm.c |4 +-
  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_sol_state.c |4 +-
  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   |2 +-
  src/mesa/main/context.c|   44 +-
  src/mesa/main/extensions.c |1 +
  src/mesa/main/ff_fragment_shader.cpp   |8 +-
  src/mesa/main/get.c|   17 +
  src/mesa/main/get_hash_params.py   |3 +
  src/mesa/main/mtypes.h |   38 +
  src/mesa/main/pipelineobj.c|  800 
  src/mesa/main/pipelineobj.h|  101 +++
  src/mesa/main/shaderapi.c  |  250 --
  src/mesa/main/shaderapi.h  |8 +-
  src/mesa/main/state.c  |   14 +-
  src/mesa/main/texstate.c   |   12 +-
  src/mesa/main/transformfeedback.c  |4 +-
  

Re: [Mesa-dev] [PATCH] intel: Do temporary CPU maps of textures that are too big to GTT map.

2013-04-05 Thread Daniel Vetter
On Fri, Apr 05, 2013 at 01:17:43PM -0700, Eric Anholt wrote:
 This still fails, since 8192*4bpp == 32768, which is too big to use the
 blitter on.
 
 v2: Be more conservative about the size of the GTT -- I'd forgotten some
 of the horror of older hardware.

Agreed on your other comments, we need to have a proper interface for
userspace to figure this out. And snoopable bos obviously need a separate
cache, otherwise we'll drown in clflush. On the patch:

Reviewed-by: Daniel Vetter daniel.vet...@ffwll.ch

 ---
  src/mesa/drivers/dri/intel/intel_mipmap_tree.c |   23 +++
  1 file changed, 23 insertions(+)
 
 diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c 
 b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
 index ffdaec5..152d4631 100644
 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
 +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
 @@ -1703,6 +1703,25 @@ intel_miptree_map_singlesample(struct intel_context 
 *intel,
  {
 struct intel_miptree_map *map;
  
 +   /* Estimate the size of the mappable aperture into the GTT.  There's an
 +* ioctl to get the whole GTT size, but not one to get the mappable 
 subset.
 +* Generally it's 256MB, but some gen4+ (particularly things like G41)
 +* occasionally has only 128, and 830-class hardware could be either 64 or
 +* 128.  Since the kernel doesn't expose information to let us actually
 +* determine the size, just be pessimistic.
 +*/
 +   uint32_t gtt_size = 128 * 1024 * 1024;
 +   if (intel-gen == 2)
 +  gtt_size = 64 * 1024 * 1024;
 +
 +   /* We don't want to map two objects such that a memcpy between them would
 +* just fault one mapping in and then the other over and over forever.  So
 +* we would need to divide the GTT size by 2.  Additionally, some GTT is
 +* taken up by things like the framebuffer and the ringbuffer and such, so
 +* be more conservative.
 +*/
 +   uint32_t max_gtt_map_object_size = gtt_size / 4;
 +
 assert(mt-num_samples = 1);
  
 map = intel_miptree_attach_map(mt, level, slice, x, y, w, h, mode);
 @@ -1749,6 +1768,10 @@ intel_miptree_map_singlesample(struct intel_context 
 *intel,
  mt-region-tiling == I915_TILING_X 
  mt-region-pitch  32768) {
intel_miptree_map_blit(intel, mt, map, level, slice);
 +   } else if (mt-region-bo-size = max_gtt_map_object_size) {
 +  assert(mt-region-pitch  32768 ||
 + mt-region-tiling == I915_TILING_NONE);
 +  intel_miptree_map_blit(intel, mt, map, level, slice);
 } else {
intel_miptree_map_gtt(intel, mt, map, level, slice);
 }
 -- 
 1.7.10.4
 
 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] intel: Allocate hiz in intel_renderbuffer_move_to_temp()

2013-04-05 Thread Eric Anholt
Chad Versace chad.vers...@linux.intel.com writes:

 When moving the renderbuffer to a new miptree, we neglected to allocate
 the hiz buffer for the new miptree. Oops.

 Fixes all Piglit depthstencil-render-miplevels tests from crash to pass on
 Sandybridge.

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


pgpq3PU8F4uF6.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] intel: Allocate hiz in intel_renderbuffer_move_to_temp()

2013-04-05 Thread Paul Berry
On 5 April 2013 15:28, Chad Versace chad.vers...@linux.intel.com wrote:

 When moving the renderbuffer to a new miptree, we neglected to allocate
 the hiz buffer for the new miptree. Oops.

 Fixes all Piglit depthstencil-render-miplevels tests from crash to pass on
 Sandybridge.

 CC: Paul Berry stereotype...@gmail.com
 CC: Eric Anholt e...@anholt.net
 Signed-off-by: Chad Versace chad.vers...@linux.intel.com


I haven't had a chance to review this yet, but:

Candidate for the 9.1 stable release branch?


 ---
  src/mesa/drivers/dri/intel/intel_fbo.c | 4 
  1 file changed, 4 insertions(+)

 diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c
 b/src/mesa/drivers/dri/intel/intel_fbo.c
 index b91d6e0..2977568 100644
 --- a/src/mesa/drivers/dri/intel/intel_fbo.c
 +++ b/src/mesa/drivers/dri/intel/intel_fbo.c
 @@ -1010,6 +1010,10 @@ intel_renderbuffer_move_to_temp(struct
 intel_context *intel,
   irb-mt-num_samples,
   false /* force_y_tiling */);

 +   if (intel-vtbl.is_hiz_depth_format(intel, new_mt-format)) {
 +  intel_miptree_alloc_hiz(intel, new_mt, irb-mt-num_samples);
 +   }
 +
 intel_miptree_copy_teximage(intel, intel_image, new_mt, invalidate);

 intel_miptree_reference(irb-mt, intel_image-mt);
 --
 1.8.1.4


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


[Mesa-dev] Mesa 9.1.2? (was Re: Mesa (9.1): 21 new commits)

2013-04-05 Thread Ian Romanick
I just cherry picked (almost) all of the marked patches from master that 
have been out for two weeks or more.  There are a couple that I did not 
pick.


c07c180 wayland: fix segfault when using software rendering
49c1fc7 r600g: don't emit SQ_DYN_GPR_RESOURCE_LIMIT_1 on cayman

I couldn't get these to apply cleanly, and it wasn't obvious what needed 
to happen to fix them.  Could someone either pick and fix them or add 
them to bin/.cherry-ignore?


Careful readers will also notice that I did a force-push shortly after 
the initial push.  It also appears that git threw me under a bus.  I 
thought I rebased out 446cb25a8 (mesa,gallium,egl,mapi: One definition 
of C99 inline/__func__ to rule them all.), but apparently not.  This, 
even with Vinson's fix, still causes some build issues.


  CC   galahad/glhd_objects.lo
In file included from ../../../src/gallium/include/pipe/p_context.h:31:0,
 from ../../../src/gallium/auxiliary/util/u_inlines.h:31,
 from galahad/glhd_objects.c:28:
../../../src/gallium/include/pipe/p_compiler.h:32:53: fatal error: 
c99_compat.h: No such file or directory

compilation terminated.
gmake[4]: *** [galahad/glhd_objects.lo] Error 1

I had to pick in 7bff1cc3 (autotools: Add missing top-level include 
dir.) to fix the problem.  Sorry. :(  I put that before the offending 
commit, so bisects on the 9.1 branch should still work.


With all that out of the way... how does a Mesa 9.1.2 release next 
Friday sound?  43 patches have been cherry picked since 9.1.1, so it 
seems like a good time.


On 04/05/2013 06:41 PM, Ian Romanick wrote:

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=324d73815dc4e75af136740f23da7cc6d7ac9b36
Author: Matt Turner matts...@gmail.com
Date:   Mon Mar 4 11:03:58 2013 -0800

 mesa: Implement TEXTURE_IMMUTABLE_LEVELS for ES 3.0.

 NOTE: This is a candidate for the 9.1 branch.
 Fixes piglit's texture-immutable-levels test.
 Reported-by: Marek Olšák mar...@gmail.com
 Reviewed-by: Brian Paul bri...@vmware.com
 (cherry picked from commit 12dc4be8a66c92ce04637abc54ed85ac7ff9aa13)

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9311044833c1787d6ebb943d015a894ecb9e627b
Author: Adam Jackson a...@redhat.com
Date:   Thu Mar 21 13:21:18 2013 -0400

 glx: Build with VISIBILITY_CFLAGS in automake

 Note: This is a candidate for the stable branches.

 Signed-off-by: Adam Jackson a...@redhat.com
 (cherry picked from commit 38aa8ec937a1c9972b65dc448cc50f3763fa2d3b)

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=67de05ee75fd91e71ca2e44ec08d125ea6c6388d
Author: Michel Dänzer michel.daen...@amd.com
Date:   Tue Mar 19 17:57:11 2013 +0100

 radeonsi: Emit pixel shader state even when only the vertex shader changed

 Fixes random failures with piglit glsl-max-varyings.

 NOTE: This is a candidate for the 9.1 branch.

 Reviewed-by: Christian König christian.koe...@amd.com
 (cherry picked from commit 032e5548b3d4b5efa52359218725cb8e31b622ad)

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0c5ada6fda57443f73d6fec250be57af0ab52d08
Author: Kenneth Graunke kenn...@whitecape.org
Date:   Fri Mar 15 14:48:24 2013 -0700

 i965: Don't use texture swizzling to force alpha to 1.0 if unnecessary.

 Commit 33599433c7 began setting the texture swizzle mode to XYZ1 for
 RED, RG, and RGB textures in order to force alpha to 1.0 in case we
 actually stored the texture as RGBA.

 This had a unforseen performance implication: the shader precompile
 assumes that the texture swizzle mode will be XYZW for non-shadow
 sampler types.  By setting it to XYZ1, this means every shader used with
 a RED, RG, or RGB texture has to be recompiled.  This is a very common
 case.

 Unfortunately, there's no way to improve the precompile, since RGBA
 textures still need XYZW, and there's no way to know by looking at
 the shader source what texture formats might be used.

 However, we only need to smash alpha to 1.0 if the texture's memory
 format actually has alpha bits.  If not, the sampler already returns 1.0
 for us without any special swizzling.  XRGB, for example, is a very
 common case where this occurs.

 This partially fixes a performance regression since commit 33599433c7.
 More work is required to fully fix it in all cases.  This at least helps
 Warsow.

 NOTE: This is a candidate for the 9.1 branch.

 Reviewed-by: Carl Worth cwo...@cworth.org
 Signed-off-by: Kenneth Graunke kenn...@whitecape.org
 (cherry picked from commit d86efc075ed84a8c45bfb71cee56dcd18858f727)

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f626e7529db9e1eeae6ba11eadd28e6cefea1545
Author: Maarten Lankhorst maarten.lankho...@canonical.com
Date:   Tue Mar 19 20:17:57 2013 +0100

 radeon/llvm: Do not link against libgallium when building statically.

 NOTE: This is a candidate for the 9.1 

Re: [Mesa-dev] Mesa 9.1.2? (was Re: Mesa (9.1): 21 new commits)

2013-04-05 Thread Jordan Justen
On Fri, Apr 5, 2013 at 7:03 PM, Ian Romanick i...@freedesktop.org wrote:
 I just cherry picked (almost) all of the marked patches from master that
 have been out for two weeks or more.  There are a couple that I did not
 pick.

 With all that out of the way... how does a Mesa 9.1.2 release next Friday
 sound?  43 patches have been cherry picked since 9.1.1, so it seems like a
 good time.

0967c362 brings  gen6 from not working at all on TF2, to somewhat
working with major issues.

So, if it is not considered too risky, then getting it onto 9.1 might be nice.

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