Re: [Mesa-dev] [PATCH 10/10] glsl: fail when a shader's input var has not an equivalent out var in previous

2015-03-27 Thread Ben Widawsky
On Mon, Dec 01, 2014 at 02:04:50PM +0100, Eduardo Lima Mitev wrote:
 From: Samuel Iglesias Gonsalvez sigles...@igalia.com
 
 GLSL ES 3.00 spec, 4.3.10 (Linking of Vertex Outputs and Fragment Inputs),
 page 45 says the following:
 
 The type of vertex outputs and fragment input with the same name must match,
 otherwise the link command will fail. The precision does not need to match.
 Only those fragment inputs statically used (i.e. read) in the fragment shader
 must be declared as outputs in the vertex shader; declaring superfluous vertex
 shader outputs is permissible.
 [...]
 The term static use means that after preprocessing the shader includes at
 least one statement that accesses the input or output, even if that statement
 is never actually executed.
 
 And it includes a table with all the possibilities.
 
 Similar table or content is present in other GLSL specs: GLSL 4.40, GLSL 1.50,
 etc but for more stages (vertex and geometry shaders, etc).
 
 This patch detects that case and returns a link error. It fixes the following
 dEQP test:
 
   dEQP-GLES3.functional.shaders.linkage.varying.rules.illegal_usage_1
 
 However, it adds a new regression in piglit because the test hasn't a
 vertex shader and it checks the link status.
 
 bin/glslparsertest \
 tests/spec/glsl-1.50/compiler/gs-also-uses-smooth-flat-noperspective.geom 
 pass \
 1.50 --check-link
 
 This piglit test is wrong according to the spec wording above, so if this 
 patch
 is merged it should be updated.
 
 Signed-off-by: Samuel Iglesias Gonsalvez sigles...@igalia.com
 ---
  src/glsl/link_varyings.cpp | 16 
  1 file changed, 16 insertions(+)
 
 diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
 index 1fe198a..036996f 100644
 --- a/src/glsl/link_varyings.cpp
 +++ b/src/glsl/link_varyings.cpp
 @@ -263,6 +263,22 @@ cross_validate_outputs_to_inputs(struct 
 gl_shader_program *prog,
   if (output != NULL) {
  cross_validate_types_and_qualifiers(prog, input, output,
  consumer-Stage, 
 producer-Stage);
 + } else {
 +/* Check for input vars with unmatched output vars in prev stage
 + * taking into account that interface blocks could have a match
 + * output but with different name, so we ignore them.
 + */
 +if (input-data.used  !input-data.assigned 
 +!(input-is_interface_instance() ||
 +  input-get_interface_type() ||
 +  input-is_in_uniform_block()) 
 +input-data.how_declared == ir_var_declared_normally 
 +input-data.location == -1)
 +   linker_error(prog,
 +%s shader input `%s' 
 +has no matching output in the previous stage\n,
 +_mesa_shader_stage_to_string(consumer-Stage),
 +input-name);

The current code isn't wrong, but it made things somewhat confusing for me when
reviewing. I don't think there is ever a case where input-data.assigned is
valid. Inputs are supposed to be read only, and so they would never be assigned.
How about instead: assert(!input-data.assigned);

I am also not certain if how_declared is correct. It seems like we shouldn't get
this far if that wasn't true, but I am not an expert (and I can't see it being
wrong).

With the data.assigned change, it's
Reviewed-by: Ben Widawsky b...@bwidawsk.net

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

-- 
Ben Widawsky, Intel Open Source Technology Center
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] State of Geometry shader instancing on radeonsi

2015-03-27 Thread Alexandre Demers
Good to have your input. I'll work on it.

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

I think I didn't tell you how I'd like the viewport and scissor states
to be implemented. Here it is:

1 r600_atom for all 16 viewports
1 r600_atom for all 16 scissors

Each atom should have a bitmask saying which slots are dirty. (same
principle as resource slots)

The emit functions should only set dirty viewports/scissors registers.

Marek



On Thu, Mar 26, 2015 at 10:18 PM, Alexandre Demers
alexandre.f.dem...@gmail.com wrote:
 Update on radeonsi's GL_ARB_viewport_array: even though I don't have much
 time right now, the easy part is done. I should push my changes to my git
 tree soon. I'll let you know where it is.

 However, I may need some help for the last part, mostly because r600g
 doesn't help a lot on that matter. Then again, I'll let you know if needed.

 Alexandre Demers


 On 2015-03-04 21:45, Alexandre Demers wrote:

 Then you can count me as working on ARB_viewport_array.

 Alexandre Demers

 On 2015-02-25 14:25, Marek Olšák wrote:

 Nobody is working on ARB_gpu_shader5 for radeonsi.

 Marek



 On Wed, Feb 25, 2015 at 6:41 PM, Ilia Mirkin imir...@alum.mit.edu
 wrote:

 On Wed, Feb 25, 2015 at 11:24 AM, Alexandre Demers
 alexandre.f.dem...@gmail.com wrote:

 Hi everyone,

 I'd like to know if someone is working on Geometry shader instancing
 for radeonsi or if there is already a work in progress somewhere I
 would have missed. I might be interested in giving it a try and then
 on GL_ARB_viewport_array.

 While there's no harm in working on GS instancing on its own, note
 that it's only a small part of the ARB_gpu_shader5 extension, so won't
 be immediately useful until the other pieces are completed (which will
 mostly involve adding LLVM support for the ops in question if they're
 not there yet, and then wiring them up).

 ARB_viewport_array is a much more self-contained extension. Note that
 ARB_fragment_layer_viewport will automatically get enabled once you
 claim multiple viewports, so make sure to make gl_ViewportIndex work
 in fp as well if you decide to do it. You may have to pass it as a
 varying by hand, not sure... IIRC I had to do that in r600. There
 are piglits that cover the various cases.

 [Hopefully Marek and/or some of the other AMD guys will pipe up if
 they've worked on any of these things and just haven't published yet.]

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




 ---
 This email has been checked for viruses by Avast antivirus software.
 http://www.avast.com

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


Re: [Mesa-dev] [PATCH 10/10] glsl: fail when a shader's input var has not an equivalent out var in previous

2015-03-27 Thread Timothy Arceri
On Thu, 2015-03-26 at 23:10 -0700, Ben Widawsky wrote:
 On Mon, Dec 01, 2014 at 02:04:50PM +0100, Eduardo Lima Mitev wrote:
  From: Samuel Iglesias Gonsalvez sigles...@igalia.com
  
  GLSL ES 3.00 spec, 4.3.10 (Linking of Vertex Outputs and Fragment Inputs),
  page 45 says the following:
  
  The type of vertex outputs and fragment input with the same name must 
  match,
  otherwise the link command will fail. The precision does not need to match.
  Only those fragment inputs statically used (i.e. read) in the fragment 
  shader
  must be declared as outputs in the vertex shader; declaring superfluous 
  vertex
  shader outputs is permissible.
  [...]
  The term static use means that after preprocessing the shader includes at
  least one statement that accesses the input or output, even if that 
  statement
  is never actually executed.
  
  And it includes a table with all the possibilities.
  
  Similar table or content is present in other GLSL specs: GLSL 4.40, GLSL 
  1.50,
  etc but for more stages (vertex and geometry shaders, etc).
  
  This patch detects that case and returns a link error. It fixes the 
  following
  dEQP test:
  
dEQP-GLES3.functional.shaders.linkage.varying.rules.illegal_usage_1
  
  However, it adds a new regression in piglit because the test hasn't a
  vertex shader and it checks the link status.
  
  bin/glslparsertest \
  tests/spec/glsl-1.50/compiler/gs-also-uses-smooth-flat-noperspective.geom 
  pass \
  1.50 --check-link
  
  This piglit test is wrong according to the spec wording above, so if this 
  patch
  is merged it should be updated.
  
  Signed-off-by: Samuel Iglesias Gonsalvez sigles...@igalia.com
  ---
   src/glsl/link_varyings.cpp | 16 
   1 file changed, 16 insertions(+)
  
  diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
  index 1fe198a..036996f 100644
  --- a/src/glsl/link_varyings.cpp
  +++ b/src/glsl/link_varyings.cpp
  @@ -263,6 +263,22 @@ cross_validate_outputs_to_inputs(struct 
  gl_shader_program *prog,
if (output != NULL) {
   cross_validate_types_and_qualifiers(prog, input, output,
   consumer-Stage, 
  producer-Stage);
  + } else {
  +/* Check for input vars with unmatched output vars in prev 
  stage
  + * taking into account that interface blocks could have a match
  + * output but with different name, so we ignore them.
  + */
  +if (input-data.used  !input-data.assigned 
  +!(input-is_interface_instance() ||
  +  input-get_interface_type() ||
  +  input-is_in_uniform_block()) 
  +input-data.how_declared == ir_var_declared_normally 
  +input-data.location == -1)
  +   linker_error(prog,
  +%s shader input `%s' 
  +has no matching output in the previous 
  stage\n,
  +_mesa_shader_stage_to_string(consumer-Stage),
  +input-name);
 
 The current code isn't wrong, but it made things somewhat confusing for me 
 when
 reviewing. I don't think there is ever a case where input-data.assigned is
 valid. Inputs are supposed to be read only, and so they would never be 
 assigned.
 How about instead: assert(!input-data.assigned);

Currently the compile check for read only inputs is missing. I wrote a
patch for it in December [1], it needs to be rebased. I will do that and
also track down and create a second patch for interface support if your
interested in reviewing them.

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



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


Re: [Mesa-dev] [PATCH 10/10] glsl: fail when a shader's input var has not an equivalent out var in previous

2015-03-27 Thread Samuel Iglesias Gonsálvez
On Thursday 26 March 2015 23:10:53 Ben Widawsky wrote:
 On Mon, Dec 01, 2014 at 02:04:50PM +0100, Eduardo Lima Mitev wrote:
  From: Samuel Iglesias Gonsalvez sigles...@igalia.com
  
  GLSL ES 3.00 spec, 4.3.10 (Linking of Vertex Outputs and Fragment Inputs),
  page 45 says the following:
  
  The type of vertex outputs and fragment input with the same name must
  match, otherwise the link command will fail. The precision does not need
  to match. Only those fragment inputs statically used (i.e. read) in the
  fragment shader must be declared as outputs in the vertex shader;
  declaring superfluous vertex shader outputs is permissible.
  [...]
  The term static use means that after preprocessing the shader includes at
  least one statement that accesses the input or output, even if that
  statement is never actually executed.
  
  And it includes a table with all the possibilities.
  
  Similar table or content is present in other GLSL specs: GLSL 4.40, GLSL
  1.50, etc but for more stages (vertex and geometry shaders, etc).
  
  This patch detects that case and returns a link error. It fixes the
  following 
  dEQP test:
dEQP-GLES3.functional.shaders.linkage.varying.rules.illegal_usage_1
  
  However, it adds a new regression in piglit because the test hasn't a
  vertex shader and it checks the link status.
  
  bin/glslparsertest \
  tests/spec/glsl-1.50/compiler/gs-also-uses-smooth-flat-noperspective.geom
  pass \ 1.50 --check-link
  
  This piglit test is wrong according to the spec wording above, so if this
  patch is merged it should be updated.
  
  Signed-off-by: Samuel Iglesias Gonsalvez sigles...@igalia.com
  ---
  
   src/glsl/link_varyings.cpp | 16 
   1 file changed, 16 insertions(+)
  
  diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
  index 1fe198a..036996f 100644
  --- a/src/glsl/link_varyings.cpp
  +++ b/src/glsl/link_varyings.cpp
  @@ -263,6 +263,22 @@ cross_validate_outputs_to_inputs(struct
  gl_shader_program *prog, 
if (output != NULL) {

   cross_validate_types_and_qualifiers(prog, input, output,
   
   consumer-Stage,
   producer-Stage);
  
  + } else {
  +/* Check for input vars with unmatched output vars in prev
  stage + * taking into account that interface blocks could
  have a match + * output but with different name, so we ignore
  them. + */
  +if (input-data.used  !input-data.assigned 
  +!(input-is_interface_instance() ||
  +  input-get_interface_type() ||
  +  input-is_in_uniform_block()) 
  +input-data.how_declared == ir_var_declared_normally 
  +input-data.location == -1)
  +   linker_error(prog,
  +%s shader input `%s' 
  +has no matching output in the previous
  stage\n, +   
  _mesa_shader_stage_to_string(consumer-Stage), + 
input-name);
 
 The current code isn't wrong, but it made things somewhat confusing for me
 when reviewing. I don't think there is ever a case where
 input-data.assigned is valid. Inputs are supposed to be read only, and so
 they would never be assigned. How about instead:
 assert(!input-data.assigned);
 

OK, I will do it.

 I am also not certain if how_declared is correct. It seems like we shouldn't
 get this far if that wasn't true, but I am not an expert (and I can't see
 it being wrong).
 

I am going to check that part again, just in case how_declared is not needed 
at this point.

 With the data.assigned change, it's
 Reviewed-by: Ben Widawsky b...@bwidawsk.net
 

Thanks for your review!

Sam

}
 
 }
  
  }


signature.asc
Description: This is a digitally signed message part.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] docs: note that classic osmesa/libEGL no longer builds with scons

2015-03-27 Thread Jose Fonseca

On 25/03/15 20:12, Emil Velikov wrote:

Plus nuke final note of osmesa from README.WIN32

Signed-off-by: Emil Velikov emil.l.veli...@gmail.com
---
  docs/README.WIN32 | 4 
  docs/relnotes/10.6.0.html | 2 ++
  2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/docs/README.WIN32 b/docs/README.WIN32
index e0e5b9b..94e1d6f 100644
--- a/docs/README.WIN32
+++ b/docs/README.WIN32
@@ -11,10 +11,6 @@ no longer shipped or supported.

  Run

-  scons osmesa
-
-to build classic osmesa driver; or
-
scons libgl-gdi

  to build gallium based GDI driver.
diff --git a/docs/relnotes/10.6.0.html b/docs/relnotes/10.6.0.html
index 005..3233637 100644
--- a/docs/relnotes/10.6.0.html
+++ b/docs/relnotes/10.6.0.html
@@ -65,6 +65,8 @@ TBD.
  liRemoved OpenVG support./li
  liRemoved the galahad gallium driver./li
  liRemoved the identity gallium driver./li
+liRemoved the EGL loader from the Windows SCons build./li
+liRemoved the classic osmesa from the Windows SCons build./li
  /ul

  /div



Thanks.

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 14/16] main: Added entry point for glCreateRenderbuffers

2015-03-27 Thread Martin Peres

On 27/03/15 07:13, Ilia Mirkin wrote:

On Fri, Mar 27, 2015 at 1:06 AM, Vinson Lee v...@freedesktop.org wrote:

On Mon, Feb 16, 2015 at 6:14 AM, Martin Peres
martin.pe...@linux.intel.com wrote:

@@ -1404,14 +1405,36 @@ _mesa_GenRenderbuffers(GLsizei n, GLuint *renderbuffers)
 for (i = 0; i  n; i++) {
GLuint name = first + i;
renderbuffers[i] = name;
-  /* insert dummy placeholder into hash table */
+
+  if (dsa) {
+ obj = _mesa_new_renderbuffer(ctx, name);
+  } else {
+ obj = DummyRenderbuffer;
+  }
+  /* insert the object into the hash table */
mtx_lock(ctx-Shared-Mutex);
-  _mesa_HashInsert(ctx-Shared-RenderBuffers, name, DummyRenderbuffer);
+  _mesa_HashInsert(ctx-Shared-RenderBuffers, name, obj);
mtx_unlock(ctx-Shared-Mutex);
 }
  }


This patch introduced a new Coverity unused value defect.

returned_pointer: Assigning value from allocate_renderbuffer(ctx,
name, func) to obj here, but that stored value is overwritten before
it can be used.

Yeah, I mentioned this to Martin privately. Actually the patch above
is fine. However I'm guessing that on rebasing, it became this:

   if (dsa) {
  obj = allocate_renderbuffer(ctx, name, func);
   } else {
  obj = DummyRenderbuffer;

  /* insert the object into the hash table */
  mtx_lock(ctx-Shared-Mutex);
  _mesa_HashInsert(ctx-Shared-RenderBuffers, name, obj);
  mtx_unlock(ctx-Shared-Mutex);
   }

Which seems quite wrong -- we should move the closing } above the hash
insertion, I would imagine.


Sorry for the noise. This is not a bug as allocate_renderbuffer inserts 
the hash in the table.
Illia is right, the code used to look like what he said but I changed it 
and forgot to remove the (now-useless) assignation.


I have a patch ready that would silence this warning, should I post it?



   -ilia


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


Re: [Mesa-dev] [PATCH] glsl/cse: Maintain a list of free ae_entry objects

2015-03-27 Thread Jordan Justen
On 2015-03-26 20:52:33, Ian Romanick wrote:
 From: Ian Romanick ian.d.roman...@intel.com
 
 The CSE algorithm will continuously allocate new ae_entry objects.  As
 each new basic block is exited, all of the previously allocated objects
 are dumped.  Instead, put them in a free list and re-use them in the
 next basic block.  Reduce, reuse, recycle!
 
 Signed-off-by: Ian Romanick ian.d.roman...@intel.com
 Cc: Jordan Justen jordan.l.jus...@intel.com
 
 ---
  src/glsl/opt_cse.cpp | 63 
 +---
  1 file changed, 55 insertions(+), 8 deletions(-)
 
 diff --git a/src/glsl/opt_cse.cpp b/src/glsl/opt_cse.cpp
 index 623268e..425eebc 100644
 --- a/src/glsl/opt_cse.cpp
 +++ b/src/glsl/opt_cse.cpp
 @@ -63,6 +63,17 @@ public:
var = NULL;
 }
  
 +   void init(ir_instruction *base_ir, ir_rvalue **val)
 +   {
 +  this-val = val;
 +  this-base_ir = base_ir;
 +  this-var = NULL;
 +
 +  assert(val);
 +  assert(*val);
 +  assert(base_ir);
 +   }
 +
 /**
  * The pointer to the expression that we might be able to reuse
  *
 @@ -116,6 +127,18 @@ private:
 ir_rvalue *try_cse(ir_rvalue *rvalue);
 void add_to_ae(ir_rvalue **rvalue);
  
 +   /**
 +* Move all nodes from the ae list to the free list
 +*/
 +   void empty_ae_list();
 +
 +   /**
 +* Get and initialize a new ae_entry
 +*
 +* This will either come from the free list or be freshly allocated.
 +*/
 +   ae_entry *get_ae_entry(ir_rvalue **rvalue);
 +
 /** List of ae_entry: The available expressions to reuse */
 exec_list *ae;
  
 @@ -126,6 +149,11 @@ private:
  * right.
  */
 exec_list *validate_instructions;
 +
 +   /**
 +* List of available-for-use ae_entry objects.
 +*/
 +   exec_list free_ae_entries;
  };
  
  /**
 @@ -322,6 +350,25 @@ cse_visitor::try_cse(ir_rvalue *rvalue)
 return NULL;
  }
  
 +void
 +cse_visitor::empty_ae_list()
 +{
 +   free_ae_entries.append_list(ae);

The routine name 'append_list' doesn't immediately say to me that the
source ae list is going to be emptied in the process.

Looking at exec_list_append, it indeed does make sure that the source
list is properly marked as empty. (Albeit with a comment that says
this is done 'for good measure')

It seems like given the exec_list_append implementation, the only sane
thing it can do with the source list ('ae' in this case) is to mark it
empty.

Reviewed-by: Jordan Justen jordan.l.jus...@intel.com

 +}
 +
 +ae_entry *
 +cse_visitor::get_ae_entry(ir_rvalue **rvalue)
 +{
 +   ae_entry *entry = (ae_entry *) free_ae_entries.pop_head();
 +   if (entry) {
 +  entry-init(base_ir, rvalue);
 +   } else {
 +  entry = new(mem_ctx) ae_entry(base_ir, rvalue);
 +   }
 +
 +   return entry;
 +}
 +
  /** Add the rvalue to the list of available expressions for CSE. */
  void
  cse_visitor::add_to_ae(ir_rvalue **rvalue)
 @@ -332,7 +379,7 @@ cse_visitor::add_to_ae(ir_rvalue **rvalue)
printf(\n);
 }
  
 -   ae-push_tail(new(mem_ctx) ae_entry(base_ir, rvalue));
 +   ae-push_tail(get_ae_entry(rvalue));
  
 if (debug)
dump_ae(ae);
 @@ -370,33 +417,33 @@ cse_visitor::visit_enter(ir_if *ir)
  {
 handle_rvalue(ir-condition);
  
 -   ae-make_empty();
 +   empty_ae_list();
 visit_list_elements(this, ir-then_instructions);
  
 -   ae-make_empty();
 +   empty_ae_list();
 visit_list_elements(this, ir-else_instructions);
  
 -   ae-make_empty();
 +   empty_ae_list();
 return visit_continue_with_parent;
  }
  
  ir_visitor_status
  cse_visitor::visit_enter(ir_function_signature *ir)
  {
 -   ae-make_empty();
 +   empty_ae_list();
 visit_list_elements(this, ir-body);
  
 -   ae-make_empty();
 +   empty_ae_list();
 return visit_continue_with_parent;
  }
  
  ir_visitor_status
  cse_visitor::visit_enter(ir_loop *ir)
  {
 -   ae-make_empty();
 +   empty_ae_list();
 visit_list_elements(this, ir-body_instructions);
  
 -   ae-make_empty();
 +   empty_ae_list();
 return visit_continue_with_parent;
  }
  
 -- 
 2.1.0
 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] gbm: Add GBM_BO_USE_LINEAR flag

2015-03-27 Thread Michel Dänzer
From: Flora Cui flora@amd.com

Signed-off-by: Flora Cui flora@amd.com
Reviewed-by: Jammy Zhou jammy.z...@amd.com
Reviewed-by: Michel Dänzer michel.daen...@amd.com
Signed-off-by: Michel Dänzer michel.daen...@amd.com
---
 src/gbm/backends/dri/gbm_dri.c | 2 ++
 src/gbm/main/gbm.h | 4 
 2 files changed, 6 insertions(+)

diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index c513672..62bdf89 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -858,6 +858,8 @@ gbm_dri_bo_create(struct gbm_device *gbm,
   dri_use |= __DRI_IMAGE_USE_SCANOUT;
if (usage  GBM_BO_USE_CURSOR)
   dri_use |= __DRI_IMAGE_USE_CURSOR;
+   if (usage  GBM_BO_USE_LINEAR)
+  dri_use |= __DRI_IMAGE_USE_LINEAR;
 
/* Gallium drivers requires shared in order to get the handle/stride */
dri_use |= __DRI_IMAGE_USE_SHARE;
diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h
index 7b23c26..2708e50 100644
--- a/src/gbm/main/gbm.h
+++ b/src/gbm/main/gbm.h
@@ -209,6 +209,10 @@ enum gbm_bo_flags {
 * with GBM_BO_USE_CURSOR. but may not work for other combinations.
 */
GBM_BO_USE_WRITE= (1  3),
+   /**
+* Buffer is linear, i.e. not tiled.
+*/
+   GBM_BO_USE_LINEAR = (1  4),
 };
 
 int
-- 
2.1.4

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


Re: [Mesa-dev] [PATCH 8/8] i965/fs: Relax type check in cmod propagation.

2015-03-27 Thread Jason Ekstrand
On Mar 26, 2015 6:58 PM, Matt Turner matts...@gmail.com wrote:

 On Thu, Mar 26, 2015 at 1:35 PM, Jason Ekstrand ja...@jlekstrand.net
wrote:
  What about other datatypes such as D or UW?  Perhaps we should have
  some sort of is_integer function and just do is_integer(a) !=
  is_integer(b)?

 I can't come up with any case where we'd be doing a partial write
 (with B/UB/W/UW types) and then comparing that. I don't think that's
 possible.

 Your question about D though -- that's fine. The check is if the
 types aren't the same, and one is a float.

We could still have a problem with doubles or half-float.  Probably worth
at least a fixme comment.  Other than that.

Reviewed-by: Jason Ekstrand jason.ekstr...@intel.com
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 10/10] glsl: fail when a shader's input var has not an equivalent out var in previous

2015-03-27 Thread Timothy Arceri
On Fri, 2015-03-27 at 18:07 +1100, Timothy Arceri wrote:
 On Thu, 2015-03-26 at 23:10 -0700, Ben Widawsky wrote:
  On Mon, Dec 01, 2014 at 02:04:50PM +0100, Eduardo Lima Mitev wrote:
   From: Samuel Iglesias Gonsalvez sigles...@igalia.com
   
   GLSL ES 3.00 spec, 4.3.10 (Linking of Vertex Outputs and Fragment Inputs),
   page 45 says the following:
   
   The type of vertex outputs and fragment input with the same name must 
   match,
   otherwise the link command will fail. The precision does not need to 
   match.
   Only those fragment inputs statically used (i.e. read) in the fragment 
   shader
   must be declared as outputs in the vertex shader; declaring superfluous 
   vertex
   shader outputs is permissible.
   [...]
   The term static use means that after preprocessing the shader includes at
   least one statement that accesses the input or output, even if that 
   statement
   is never actually executed.
   
   And it includes a table with all the possibilities.
   
   Similar table or content is present in other GLSL specs: GLSL 4.40, GLSL 
   1.50,
   etc but for more stages (vertex and geometry shaders, etc).
   
   This patch detects that case and returns a link error. It fixes the 
   following
   dEQP test:
   
 dEQP-GLES3.functional.shaders.linkage.varying.rules.illegal_usage_1
   
   However, it adds a new regression in piglit because the test hasn't a
   vertex shader and it checks the link status.
   
   bin/glslparsertest \
   tests/spec/glsl-1.50/compiler/gs-also-uses-smooth-flat-noperspective.geom 
   pass \
   1.50 --check-link
   
   This piglit test is wrong according to the spec wording above, so if this 
   patch
   is merged it should be updated.
   
   Signed-off-by: Samuel Iglesias Gonsalvez sigles...@igalia.com
   ---
src/glsl/link_varyings.cpp | 16 
1 file changed, 16 insertions(+)
   
   diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
   index 1fe198a..036996f 100644
   --- a/src/glsl/link_varyings.cpp
   +++ b/src/glsl/link_varyings.cpp
   @@ -263,6 +263,22 @@ cross_validate_outputs_to_inputs(struct 
   gl_shader_program *prog,
 if (output != NULL) {
cross_validate_types_and_qualifiers(prog, input, output,
consumer-Stage, 
   producer-Stage);
   + } else {
   +/* Check for input vars with unmatched output vars in prev 
   stage
   + * taking into account that interface blocks could have a 
   match
   + * output but with different name, so we ignore them.
   + */
   +if (input-data.used  !input-data.assigned 
   +!(input-is_interface_instance() ||
   +  input-get_interface_type() ||
   +  input-is_in_uniform_block()) 
   +input-data.how_declared == ir_var_declared_normally 
   +input-data.location == -1)
   +   linker_error(prog,
   +%s shader input `%s' 
   +has no matching output in the previous 
   stage\n,
   +
   _mesa_shader_stage_to_string(consumer-Stage),
   +input-name);
  
  The current code isn't wrong, but it made things somewhat confusing for me 
  when
  reviewing. I don't think there is ever a case where input-data.assigned is
  valid. Inputs are supposed to be read only, and so they would never be 
  assigned.
  How about instead: assert(!input-data.assigned);
 
 Currently the compile check for read only inputs is missing. I wrote a
 patch for it in December [1], it needs to be rebased. I will do that and
 also track down and create a second patch for interface support if your
 interested in reviewing them.

Ignore this patch it doesn't seem to be needed any more, but I have a
patch for the interface check on the way.

 
 [1]
 http://lists.freedesktop.org/archives/mesa-dev/2014-December/073358.html
 
 
 
 ___
 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] glsl: mark uniform and input interface blocks as read only

2015-03-27 Thread Timothy Arceri
---

 Piglit tests:

 http://lists.freedesktop.org/archives/piglit/2015-March/015369.html

 src/glsl/ast_to_hir.cpp | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index d9ce6c9..49bddc4 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -5775,6 +5775,9 @@ ast_interface_block::hir(exec_list *instructions,
   var-data.matrix_layout = matrix_layout == GLSL_MATRIX_LAYOUT_INHERITED
  ? GLSL_MATRIX_LAYOUT_COLUMN_MAJOR : matrix_layout;
 
+  if (var_mode == ir_var_shader_in || var_mode == ir_var_uniform)
+ var-data.read_only = true;
+
   if (state-stage == MESA_SHADER_GEOMETRY  var_mode == ir_var_shader_in)
  handle_geometry_shader_input_decl(state, loc, var);
 
@@ -5815,6 +5818,9 @@ ast_interface_block::hir(exec_list *instructions,
  var-data.sample = fields[i].sample;
  var-init_interface_type(block_type);
 
+ if (var_mode == ir_var_shader_in || var_mode == ir_var_uniform)
+var-data.read_only = true;
+
  if (fields[i].matrix_layout == GLSL_MATRIX_LAYOUT_INHERITED) {
 var-data.matrix_layout = matrix_layout == 
GLSL_MATRIX_LAYOUT_INHERITED
? GLSL_MATRIX_LAYOUT_COLUMN_MAJOR : matrix_layout;
-- 
2.1.0

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


Re: [Mesa-dev] New stable-branch 10.5 candidate pushed

2015-03-27 Thread Emil Velikov
Hi Bernd,

On 26 March 2015 at 22:44, Bernd Kuhls bernd.ku...@t-online.de wrote:
 Emil Velikov emil.l.veli...@gmail.com wrote in news:55136BE1.6090001
 @gmail.com:
 and no longer requires python/mako in order to build.

 Hi,

 I am a bit confused, quoting the commit
 http://cgit.freedesktop.org/mesa/mesa/commit/?h=10.5
 id=e98909b0567b8a83a6a953cfa4ee4e7beef436b9

 It is still returning error when Python is not installed.

 So python2 still needs to be installed, although it is not necessarily being
 used, right?

Hmm should have nitpicked on the commit message, but that's all gone
now. The essence of things is:

 - If you have python2 available you need mako otherwise configure
will error out.
I have some patches that resolve this but they're not reviewed yet.

 - Otherwise python2+mako should not be used (even if available).
If you spot that's not the case please file a bug.

Hope that clears things up a bit.

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


Re: [Mesa-dev] [PATCH] radeonsi: Cache LLVMTargetMachineRef in context instead of in screen

2015-03-27 Thread Tom Stellard
On Fri, Mar 27, 2015 at 10:05:06AM +0900, Michel Dänzer wrote:
 From: Michel Dänzer michel.daen...@amd.com
 
 Fixes a crash in genymotion with several threads compiling shaders
 concurrently.
 
 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89746
 
 Cc: 10.5 mesa-sta...@lists.freedesktop.org
 Signed-off-by: Michel Dänzer michel.daen...@amd.com

Reviewed-by: Tom Stellard thomas.stell...@amd.com

Thanks for looking into this.
 ---
  src/gallium/drivers/radeonsi/si_compute.c   |  3 +-
  src/gallium/drivers/radeonsi/si_pipe.c  | 43 
 +
  src/gallium/drivers/radeonsi/si_pipe.h  |  3 +-
  src/gallium/drivers/radeonsi/si_shader.c| 13 +---
  src/gallium/drivers/radeonsi/si_shader.h|  5 +--
  src/gallium/drivers/radeonsi/si_state_shaders.c |  4 ++-
  6 files changed, 41 insertions(+), 30 deletions(-)
 
 diff --git a/src/gallium/drivers/radeonsi/si_compute.c 
 b/src/gallium/drivers/radeonsi/si_compute.c
 index 8609b89..89bef2e 100644
 --- a/src/gallium/drivers/radeonsi/si_compute.c
 +++ b/src/gallium/drivers/radeonsi/si_compute.c
 @@ -130,7 +130,8 @@ static void *si_create_compute_state(
   for (i = 0; i  program-num_kernels; i++) {
   LLVMModuleRef mod = 
 radeon_llvm_get_kernel_module(program-llvm_ctx, i,
  code, 
 header-num_bytes);
 - si_compile_llvm(sctx-screen, program-kernels[i], 
 mod);
 + si_compile_llvm(sctx-screen, program-kernels[i], 
 sctx-tm,
 + mod);
   LLVMDisposeModule(mod);
   }
   }
 diff --git a/src/gallium/drivers/radeonsi/si_pipe.c 
 b/src/gallium/drivers/radeonsi/si_pipe.c
 index d335bda..0eada72 100644
 --- a/src/gallium/drivers/radeonsi/si_pipe.c
 +++ b/src/gallium/drivers/radeonsi/si_pipe.c
 @@ -69,6 +69,11 @@ static void si_destroy_context(struct pipe_context 
 *context)
   si_pm4_cleanup(sctx);
  
   r600_common_context_cleanup(sctx-b);
 +
 +#if HAVE_LLVM = 0x0306
 + LLVMDisposeTargetMachine(sctx-tm);
 +#endif
 +
   FREE(sctx);
  }
  
 @@ -77,6 +82,12 @@ static struct pipe_context *si_create_context(struct 
 pipe_screen *screen, void *
   struct si_context *sctx = CALLOC_STRUCT(si_context);
   struct si_screen* sscreen = (struct si_screen *)screen;
   struct radeon_winsys *ws = sscreen-b.ws;
 + LLVMTargetRef r600_target;
 +#if HAVE_LLVM = 0x0306
 + const char *triple = amdgcn--;
 +#else
 + const char *triple = r600--;
 +#endif
   int shader, i;
  
   if (sctx == NULL)
 @@ -170,6 +181,17 @@ static struct pipe_context *si_create_context(struct 
 pipe_screen *screen, void *
*/
   sctx-scratch_waves = 32 * sscreen-b.info.max_compute_units;
  
 +#if HAVE_LLVM = 0x0306
 + /* Initialize LLVM TargetMachine */
 + r600_target = radeon_llvm_get_r600_target(triple);
 + sctx-tm = LLVMCreateTargetMachine(r600_target, triple,
 +
 r600_get_llvm_processor_name(sscreen-b.family),
 ++DumpCode,+vgpr-spilling,
 +LLVMCodeGenLevelDefault,
 +LLVMRelocDefault,
 +LLVMCodeModelDefault);
 +#endif
 +
   return sctx-b.b;
  fail:
   si_destroy_context(sctx-b.b);
 @@ -445,12 +467,6 @@ static void si_destroy_screen(struct pipe_screen* 
 pscreen)
   if (!sscreen-b.ws-unref(sscreen-b.ws))
   return;
  
 -#if HAVE_LLVM = 0x0306
 - // r600_destroy_common_screen() frees sscreen, so we need to make
 - // sure to dispose the TargetMachine before we call it.
 - LLVMDisposeTargetMachine(sscreen-tm);
 -#endif
 -
   r600_destroy_common_screen(sscreen-b);
  }
  
 @@ -508,12 +524,7 @@ static bool si_initialize_pipe_config(struct si_screen 
 *sscreen)
  struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws)
  {
   struct si_screen *sscreen = CALLOC_STRUCT(si_screen);
 - LLVMTargetRef r600_target;
 -#if HAVE_LLVM = 0x0306
 - const char *triple = amdgcn--;
 -#else
 - const char *triple = r600--;
 -#endif
 +
   if (sscreen == NULL) {
   return NULL;
   }
 @@ -541,13 +552,5 @@ struct pipe_screen *radeonsi_screen_create(struct 
 radeon_winsys *ws)
   /* Create the auxiliary context. This must be done last. */
   sscreen-b.aux_context = sscreen-b.b.context_create(sscreen-b.b, 
 NULL);
  
 -#if HAVE_LLVM = 0x0306
 - /* Initialize LLVM TargetMachine */
 - r600_target = radeon_llvm_get_r600_target(triple);
 - sscreen-tm = LLVMCreateTargetMachine(r600_target, triple,
 - r600_get_llvm_processor_name(sscreen-b.family),
 - +DumpCode,+vgpr-spilling, 
 LLVMCodeGenLevelDefault, LLVMRelocDefault,
 - LLVMCodeModelDefault);
 

Re: [Mesa-dev] [PATCH] gbm: Add GBM_BO_USE_LINEAR flag

2015-03-27 Thread Alex Deucher
On Fri, Mar 27, 2015 at 4:58 AM, Michel Dänzer mic...@daenzer.net wrote:
 From: Flora Cui flora@amd.com

 Signed-off-by: Flora Cui flora@amd.com
 Reviewed-by: Jammy Zhou jammy.z...@amd.com
 Reviewed-by: Michel Dänzer michel.daen...@amd.com
 Signed-off-by: Michel Dänzer michel.daen...@amd.com

Reviewed-by: Alex Deucher alexander.deuc...@amd.com

 ---
  src/gbm/backends/dri/gbm_dri.c | 2 ++
  src/gbm/main/gbm.h | 4 
  2 files changed, 6 insertions(+)

 diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
 index c513672..62bdf89 100644
 --- a/src/gbm/backends/dri/gbm_dri.c
 +++ b/src/gbm/backends/dri/gbm_dri.c
 @@ -858,6 +858,8 @@ gbm_dri_bo_create(struct gbm_device *gbm,
dri_use |= __DRI_IMAGE_USE_SCANOUT;
 if (usage  GBM_BO_USE_CURSOR)
dri_use |= __DRI_IMAGE_USE_CURSOR;
 +   if (usage  GBM_BO_USE_LINEAR)
 +  dri_use |= __DRI_IMAGE_USE_LINEAR;

 /* Gallium drivers requires shared in order to get the handle/stride */
 dri_use |= __DRI_IMAGE_USE_SHARE;
 diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h
 index 7b23c26..2708e50 100644
 --- a/src/gbm/main/gbm.h
 +++ b/src/gbm/main/gbm.h
 @@ -209,6 +209,10 @@ enum gbm_bo_flags {
  * with GBM_BO_USE_CURSOR. but may not work for other combinations.
  */
 GBM_BO_USE_WRITE= (1  3),
 +   /**
 +* Buffer is linear, i.e. not tiled.
 +*/
 +   GBM_BO_USE_LINEAR = (1  4),
  };

  int
 --
 2.1.4

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


Re: [Mesa-dev] [PATCH 14/16] main: Added entry point for glCreateRenderbuffers

2015-03-27 Thread Ilia Mirkin
On Fri, Mar 27, 2015 at 4:19 AM, Martin Peres
martin.pe...@linux.intel.com wrote:
 On 27/03/15 07:13, Ilia Mirkin wrote:

 On Fri, Mar 27, 2015 at 1:06 AM, Vinson Lee v...@freedesktop.org wrote:

 On Mon, Feb 16, 2015 at 6:14 AM, Martin Peres
 martin.pe...@linux.intel.com wrote:

 @@ -1404,14 +1405,36 @@ _mesa_GenRenderbuffers(GLsizei n, GLuint
 *renderbuffers)
  for (i = 0; i  n; i++) {
 GLuint name = first + i;
 renderbuffers[i] = name;
 -  /* insert dummy placeholder into hash table */
 +
 +  if (dsa) {
 + obj = _mesa_new_renderbuffer(ctx, name);
 +  } else {
 + obj = DummyRenderbuffer;
 +  }
 +  /* insert the object into the hash table */
 mtx_lock(ctx-Shared-Mutex);
 -  _mesa_HashInsert(ctx-Shared-RenderBuffers, name,
 DummyRenderbuffer);
 +  _mesa_HashInsert(ctx-Shared-RenderBuffers, name, obj);
 mtx_unlock(ctx-Shared-Mutex);
  }
   }

 This patch introduced a new Coverity unused value defect.

 returned_pointer: Assigning value from allocate_renderbuffer(ctx,
 name, func) to obj here, but that stored value is overwritten before
 it can be used.

 Yeah, I mentioned this to Martin privately. Actually the patch above
 is fine. However I'm guessing that on rebasing, it became this:

if (dsa) {
   obj = allocate_renderbuffer(ctx, name, func);
} else {
   obj = DummyRenderbuffer;

   /* insert the object into the hash table */
   mtx_lock(ctx-Shared-Mutex);
   _mesa_HashInsert(ctx-Shared-RenderBuffers, name, obj);
   mtx_unlock(ctx-Shared-Mutex);
}

 Which seems quite wrong -- we should move the closing } above the hash
 insertion, I would imagine.


 Sorry for the noise. This is not a bug as allocate_renderbuffer inserts the
 hash in the table.
 Illia is right, the code used to look like what he said but I changed it and
 forgot to remove the (now-useless) assignation.

 I have a patch ready that would silence this warning, should I post it?

Yes. If a patch improves code (e.g. by removing an unnecessary and/or
confusing assignment), why not? Pointless assignments are...
pointless. (BTW, 'assignation' is something else... English is fun.)

Also, it doesn't seem like allocate_renderbuffer locks the hash before
inserting into it... that seems like a potential bug too, right?
Alternatively if the locking is unnecessary, remove it in the other
place?

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


[Mesa-dev] [PATCH] llvmpipe: simplify address calculation for 4x4 blocks

2015-03-27 Thread sroland
From: Roland Scheidegger srol...@vmware.com

These functions looked quite complicated, even though what they actually did
was trivial (ever since we dropped swizzled rendering). Also drop lookup of
format block per bytes done for each block, and do it once per scene instead.
This improves everybody's favorite benchmark by 3% or so, though
lp_rast_shade_quads_all() which calls this shows up still quite high for a
function which does little more than call the jit function.
(This would most likely be much better handled by the jit function itself,
the strides are passed through anyway already, though for being able to
handle layers it would definitely add some complexity.)
---
 src/gallium/drivers/llvmpipe/lp_rast.c  | 20 +--
 src/gallium/drivers/llvmpipe/lp_rast_priv.h | 87 +
 src/gallium/drivers/llvmpipe/lp_scene.c |  3 +
 src/gallium/drivers/llvmpipe/lp_scene.h |  1 +
 4 files changed, 35 insertions(+), 76 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c 
b/src/gallium/drivers/llvmpipe/lp_rast.c
index 903e7c5..7019acb 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast.c
@@ -91,6 +91,9 @@ lp_rast_tile_begin(struct lp_rasterizer_task *task,
const struct cmd_bin *bin,
int x, int y)
 {
+   unsigned i;
+   struct lp_scene *scene = task-scene;
+
LP_DBG(DEBUG_RAST, %s %d,%d\n, __FUNCTION__, x, y);
 
task-bin = bin;
@@ -104,9 +107,18 @@ lp_rast_tile_begin(struct lp_rasterizer_task *task,
task-thread_data.vis_counter = 0;
task-ps_invocations = 0;
 
-   /* reset pointers to color and depth tile(s) */
-   memset(task-color_tiles, 0, sizeof(task-color_tiles));
-   task-depth_tile = NULL;
+   for (i = 0; i  task-scene-fb.nr_cbufs; i++) {
+  if (task-scene-fb.cbufs[i]) {
+ task-color_tiles[i] = scene-cbufs[i].map +
+scene-cbufs[i].stride * task-y +
+scene-cbufs[i].format_bytes * task-x;
+  }
+   }
+   if (task-scene-fb.zsbuf) {
+  task-depth_tile = scene-zsbuf.map +
+ scene-zsbuf.stride * task-y +
+ scene-zsbuf.format_bytes * task-x;
+   }
 }
 
 
@@ -186,7 +198,7 @@ lp_rast_clear_zstencil(struct lp_rasterizer_task *task,
 
if (scene-fb.zsbuf) {
   unsigned layer;
-  uint8_t *dst_layer = lp_rast_get_depth_tile_pointer(task, 
LP_TEX_USAGE_READ_WRITE);
+  uint8_t *dst_layer = task-depth_tile;
   block_size = util_format_get_blocksize(scene-fb.zsbuf-format);
 
   clear_value = clear_mask;
diff --git a/src/gallium/drivers/llvmpipe/lp_rast_priv.h 
b/src/gallium/drivers/llvmpipe/lp_rast_priv.h
index d92230d..e6ebbcd 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_priv.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast_priv.h
@@ -141,64 +141,6 @@ lp_rast_shade_quads_mask(struct lp_rasterizer_task *task,
  unsigned mask);
 
 
-
-/**
- * Get pointer to the color tile
- */
-static INLINE uint8_t *
-lp_rast_get_color_tile_pointer(struct lp_rasterizer_task *task,
-   unsigned buf, enum lp_texture_usage usage)
-{
-   const struct lp_scene *scene = task-scene;
-   unsigned format_bytes;
-
-   assert(task-x  scene-tiles_x * TILE_SIZE);
-   assert(task-y  scene-tiles_y * TILE_SIZE);
-   assert(task-x % TILE_SIZE == 0);
-   assert(task-y % TILE_SIZE == 0);
-   assert(buf  scene-fb.nr_cbufs);
-
-   if (!task-color_tiles[buf]) {
-  struct pipe_surface *cbuf = scene-fb.cbufs[buf];
-  assert(cbuf);
-
-  format_bytes = util_format_get_blocksize(cbuf-format);
-  task-color_tiles[buf] = scene-cbufs[buf].map + 
scene-cbufs[buf].stride * task-y +
-   format_bytes * task-x;
-   }
-
-   return task-color_tiles[buf];
-}
-
-
-/**
- * Get pointer to the depth tile
- */
-static INLINE uint8_t *
-lp_rast_get_depth_tile_pointer(struct lp_rasterizer_task *task,
-   enum lp_texture_usage usage)
-{
-   const struct lp_scene *scene = task-scene;
-   unsigned format_bytes;
-
-   assert(task-x  scene-tiles_x * TILE_SIZE);
-   assert(task-y  scene-tiles_y * TILE_SIZE);
-   assert(task-x % TILE_SIZE == 0);
-   assert(task-y % TILE_SIZE == 0);
-
-   if (!task-depth_tile) {
-  struct pipe_surface *dbuf = scene-fb.zsbuf;
-  assert(dbuf);
-
-  format_bytes = util_format_get_blocksize(dbuf-format);
-  task-depth_tile = scene-zsbuf.map + scene-zsbuf.stride * task-y +
- format_bytes * task-x;
-   }
-
-   return task-depth_tile;
-}
-
-
 /**
  * Get the pointer to a 4x4 color block (within a 64x64 tile).
  * \param x, y location of 4x4 block in window coords
@@ -208,7 +150,7 @@ lp_rast_get_color_block_pointer(struct lp_rasterizer_task 
*task,
 unsigned buf, unsigned x, unsigned y,
 unsigned layer)
 {
-   unsigned px, py, pixel_offset, 

Re: [Mesa-dev] [PATCH] glsl/cse: Maintain a list of free ae_entry objects

2015-03-27 Thread Eric Anholt
Kenneth Graunke kenn...@whitecape.org writes:

 On Thursday, March 26, 2015 08:52:33 PM Ian Romanick wrote:
 From: Ian Romanick ian.d.roman...@intel.com
 
 The CSE algorithm will continuously allocate new ae_entry objects.  As
 each new basic block is exited, all of the previously allocated objects
 are dumped.  Instead, put them in a free list and re-use them in the
 next basic block.  Reduce, reuse, recycle!
 
 Signed-off-by: Ian Romanick ian.d.roman...@intel.com
 Cc: Jordan Justen jordan.l.jus...@intel.com
 
 ---
  src/glsl/opt_cse.cpp | 63 
 +---
  1 file changed, 55 insertions(+), 8 deletions(-)
 
 diff --git a/src/glsl/opt_cse.cpp b/src/glsl/opt_cse.cpp
 index 623268e..425eebc 100644
 --- a/src/glsl/opt_cse.cpp
 +++ b/src/glsl/opt_cse.cpp
 @@ -63,6 +63,17 @@ public:
var = NULL;
 }
  
 +   void init(ir_instruction *base_ir, ir_rvalue **val)
 +   {
 +  this-val = val;
 +  this-base_ir = base_ir;
 +  this-var = NULL;
 +
 +  assert(val);
 +  assert(*val);
 +  assert(base_ir);
 +   }
 +
 /**
  * The pointer to the expression that we might be able to reuse
  *
 @@ -116,6 +127,18 @@ private:
 ir_rvalue *try_cse(ir_rvalue *rvalue);
 void add_to_ae(ir_rvalue **rvalue);
  
 +   /**
 +* Move all nodes from the ae list to the free list
 +*/
 +   void empty_ae_list();
 +
 +   /**
 +* Get and initialize a new ae_entry
 +*
 +* This will either come from the free list or be freshly allocated.
 +*/
 +   ae_entry *get_ae_entry(ir_rvalue **rvalue);
 +
 /** List of ae_entry: The available expressions to reuse */
 exec_list *ae;
  
 @@ -126,6 +149,11 @@ private:
  * right.
  */
 exec_list *validate_instructions;
 +
 +   /**
 +* List of available-for-use ae_entry objects.
 +*/
 +   exec_list free_ae_entries;
  };
  
  /**
 @@ -322,6 +350,25 @@ cse_visitor::try_cse(ir_rvalue *rvalue)
 return NULL;
  }
  
 +void
 +cse_visitor::empty_ae_list()
 +{
 +   free_ae_entries.append_list(ae);

 If you're just trying to save memory...it sure looks like you can just
 ralloc_free(mem_ctx); mem_ctx = ralloc_context(NULL) here.  Which would
 be much simpler.

 But I suppose this does reduce the number of malloc calls considerably,
 so it's probably more efficient.

Yeah, I'd rather see us just ralloc_free the things if the goal is
reducing memory overhead.


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


Re: [Mesa-dev] [PATCH] glsl: allow ForceGLSLVersion to override #version directives

2015-03-27 Thread Ilia Mirkin
What's the use-case for applying a different version to a shader with
an explicit #version?

On Fri, Mar 27, 2015 at 2:13 PM, Brian Paul bri...@vmware.com wrote:
 Previously, the ctx-Const.ForceGLSLVersion setting only worked if
 the shader lacked a #version directive.  Now, the ForceGLSLVersion
 setting will override the #version directive too.

 This change should be safe since it should be rare to have an app
 that has a mix of shader versions and we only wanted to override
 the #version for shaders which lacked the #version directive.
 ---
  src/glsl/glsl_parser_extras.cpp | 11 +++
  src/glsl/glsl_parser_extras.h   |  1 +
  src/mesa/main/mtypes.h  |  4 ++--
  3 files changed, 10 insertions(+), 6 deletions(-)

 diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
 index 79624bc..0aa3c54 100644
 --- a/src/glsl/glsl_parser_extras.cpp
 +++ b/src/glsl/glsl_parser_extras.cpp
 @@ -73,8 +73,8 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct 
 gl_context *_ctx,
 this-uses_builtin_functions = false;

 /* Set default language version and extensions */
 -   this-language_version = ctx-Const.ForceGLSLVersion ?
 -ctx-Const.ForceGLSLVersion : 110;
 +   this-language_version = 110;
 +   this-forced_language_version = ctx-Const.ForceGLSLVersion;
 this-es_shader = false;
 this-ARB_texture_rectangle_enable = true;

 @@ -320,11 +320,14 @@ 
 _mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int version,
this-ARB_texture_rectangle_enable = false;
 }

 -   this-language_version = version;
 +   if (this-forced_language_version)
 +  this-language_version = this-forced_language_version;
 +   else
 +  this-language_version = version;

 bool supported = false;
 for (unsigned i = 0; i  this-num_supported_versions; i++) {
 -  if (this-supported_versions[i].ver == (unsigned) version
 +  if (this-supported_versions[i].ver == this-language_version
 this-supported_versions[i].es == this-es_shader) {
   supported = true;
   break;
 diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
 index 0975c86..1f5478b 100644
 --- a/src/glsl/glsl_parser_extras.h
 +++ b/src/glsl/glsl_parser_extras.h
 @@ -226,6 +226,7 @@ struct _mesa_glsl_parse_state {

 bool es_shader;
 unsigned language_version;
 +   unsigned forced_language_version;
 gl_shader_stage stage;

 /**
 diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
 index 8e1dba6..f718768 100644
 --- a/src/mesa/main/mtypes.h
 +++ b/src/mesa/main/mtypes.h
 @@ -3527,8 +3527,8 @@ struct gl_constants
 GLboolean ForceGLSLExtensionsWarn;

 /**
 -* If non-zero, forces GLSL shaders without the #version directive to 
 behave
 -* as if they began with #version ForceGLSLVersion.
 +* If non-zero, forces GLSL shaders to behave as if they began
 +* with #version ForceGLSLVersion.
  */
 GLuint ForceGLSLVersion;

 --
 1.9.1

 ___
 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] glsl: allow ForceGLSLVersion to override #version directives

2015-03-27 Thread Brian Paul


The Geeks3d GpuTest GiMark test for Windows has several shaders with 
#version 330 that don't actually use any 3.30 features.  Other shaders 
in the test use #version 130.  Furthermore, when a context is created, 
only a 3.0 context is requested.  We don't support GL 3.0 w/ 3.30 
shaders but if I override the #version 330 with 130 then everything 
works fine.


-Brian

On 03/27/2015 12:13 PM, Ilia Mirkin wrote:

What's the use-case for applying a different version to a shader with
an explicit #version?

On Fri, Mar 27, 2015 at 2:13 PM, Brian Paul bri...@vmware.com wrote:

Previously, the ctx-Const.ForceGLSLVersion setting only worked if
the shader lacked a #version directive.  Now, the ForceGLSLVersion
setting will override the #version directive too.

This change should be safe since it should be rare to have an app
that has a mix of shader versions and we only wanted to override
the #version for shaders which lacked the #version directive.
---
  src/glsl/glsl_parser_extras.cpp | 11 +++
  src/glsl/glsl_parser_extras.h   |  1 +
  src/mesa/main/mtypes.h  |  4 ++--
  3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 79624bc..0aa3c54 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -73,8 +73,8 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct 
gl_context *_ctx,
 this-uses_builtin_functions = false;

 /* Set default language version and extensions */
-   this-language_version = ctx-Const.ForceGLSLVersion ?
-ctx-Const.ForceGLSLVersion : 110;
+   this-language_version = 110;
+   this-forced_language_version = ctx-Const.ForceGLSLVersion;
 this-es_shader = false;
 this-ARB_texture_rectangle_enable = true;

@@ -320,11 +320,14 @@ _mesa_glsl_parse_state::process_version_directive(YYLTYPE 
*locp, int version,
this-ARB_texture_rectangle_enable = false;
 }

-   this-language_version = version;
+   if (this-forced_language_version)
+  this-language_version = this-forced_language_version;
+   else
+  this-language_version = version;

 bool supported = false;
 for (unsigned i = 0; i  this-num_supported_versions; i++) {
-  if (this-supported_versions[i].ver == (unsigned) version
+  if (this-supported_versions[i].ver == this-language_version
 this-supported_versions[i].es == this-es_shader) {
   supported = true;
   break;
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index 0975c86..1f5478b 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -226,6 +226,7 @@ struct _mesa_glsl_parse_state {

 bool es_shader;
 unsigned language_version;
+   unsigned forced_language_version;
 gl_shader_stage stage;

 /**
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 8e1dba6..f718768 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3527,8 +3527,8 @@ struct gl_constants
 GLboolean ForceGLSLExtensionsWarn;

 /**
-* If non-zero, forces GLSL shaders without the #version directive to behave
-* as if they began with #version ForceGLSLVersion.
+* If non-zero, forces GLSL shaders to behave as if they began
+* with #version ForceGLSLVersion.
  */
 GLuint ForceGLSLVersion;

--
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.freedesktop.org_mailman_listinfo_mesa-2Ddevd=AwIBaQc=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEsr=T0t4QG7chq2ZwJo6wilkFznRSFy-8uDKartPGbomVj8m=ldpjgViUPOu17CxrbA3nCCexS68kJbTju51AqpuolTAs=95-rcxtOJ28IZZjXd3g1FPtmCrob8AIQ5HG_21mXNZce=


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


Re: [Mesa-dev] [PATCH v2 15/15] nvc0: all queries use an unsigned 64-bits integer by default

2015-03-27 Thread Ilia Mirkin
Patches 11-15 are all

Reviewed-by: Ilia Mirkin imir...@alum.mit.edu

but please fix up patch #13 with that small bit I mentioned.

On Sun, Mar 22, 2015 at 11:35 AM, Samuel Pitoiset
samuel.pitoi...@gmail.com wrote:
 Signed-off-by: Samuel Pitoiset samuel.pitoi...@gmail.com
 ---
  src/gallium/drivers/nouveau/nvc0/nvc0_query.c | 12 +++-
  1 file changed, 7 insertions(+), 5 deletions(-)

 diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c 
 b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
 index c3a1899..fcdb0a3 100644
 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
 +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
 @@ -1418,6 +1418,13 @@ nvc0_screen_get_driver_query_info(struct pipe_screen 
 *pscreen,
 if (!info)
return count;

 +   /* Init default values. */
 +   info-name = this_is_not_the_query_you_are_looking_for;
 +   info-query_type = 0xdeadd01d;
 +   info-group_id = 0;
 +   info-max_value.u64 = 0;
 +   info-type = PIPE_DRIVER_QUERY_TYPE_UINT64;
 +
  #ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS
 if (id  NVC0_QUERY_DRV_STAT_COUNT) {
info-name = nvc0_drv_stat_names[id];
 @@ -1441,16 +1448,11 @@ nvc0_screen_get_driver_query_info(struct pipe_screen 
 *pscreen,
if (screen-compute) {
   info-name = nvc0_pm_query_names[id - NVC0_QUERY_DRV_STAT_COUNT];
   info-query_type = NVC0_PM_QUERY(id - NVC0_QUERY_DRV_STAT_COUNT);
 - info-max_value.u64 = 0;
   info-group_id = NVC0_QUERY_MP_COUNTER_GROUP;
   return 1;
}
 }
 /* user asked for info about non-existing query */
 -   info-name = this_is_not_the_query_you_are_looking_for;
 -   info-query_type = 0xdeadd01d;
 -   info-group_id = 0;
 -   info-max_value.u64 = 0;
 return 0;
  }

 --
 2.3.3

 ___
 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] glsl: allow ForceGLSLVersion to override #version directives

2015-03-27 Thread Ilia Mirkin
On Fri, Mar 27, 2015 at 2:44 PM, Brian Paul bri...@vmware.com wrote:

 The Geeks3d GpuTest GiMark test for Windows has several shaders with
 #version 330 that don't actually use any 3.30 features.  Other shaders in
 the test use #version 130.  Furthermore, when a context is created, only a
 3.0 context is requested.  We don't support GL 3.0 w/ 3.30 shaders but if I
 override the #version 330 with 130 then everything works fine.

That's incredibly annoying. Well your patch looks like it'll work as
advertised, so

Reviewed-by: Ilia Mirkin imir...@alum.mit.edu

But perhaps leave it on the list for a bit in case there are
dissenting opinions on the actual functionality?

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


Re: [Mesa-dev] [PATCH] glsl: allow ForceGLSLVersion to override #version directives

2015-03-27 Thread Brian Paul

On 03/27/2015 12:49 PM, Ilia Mirkin wrote:

On Fri, Mar 27, 2015 at 2:44 PM, Brian Paul bri...@vmware.com wrote:


The Geeks3d GpuTest GiMark test for Windows has several shaders with
#version 330 that don't actually use any 3.30 features.  Other shaders in
the test use #version 130.  Furthermore, when a context is created, only a
3.0 context is requested.  We don't support GL 3.0 w/ 3.30 shaders but if I
override the #version 330 with 130 then everything works fine.


That's incredibly annoying. Well your patch looks like it'll work as
advertised, so

Reviewed-by: Ilia Mirkin imir...@alum.mit.edu

But perhaps leave it on the list for a bit in case there are
dissenting opinions on the actual functionality?


Sure, no problem.

The sad reality is that Windows OpenGL apps are pretty sloppy/buggy when 
it comes to choosing the right OpenGL context version/profile and shader 
versions.  We have quite a few work-arounds in our in-house code to 
allow these apps to run.  If we don't do that, we get bug reports and 
negative comments from product reviewers.


The problem is the Windows nvidia/amd/intel drivers are often more lax 
than Mesa about version/extension checking.  Also, the nvidia/amd/intel 
drivers support compat profile with OpenGL 3.2+ so a lot of those apps 
don't have any consideration of core vs. compat profile issues.  It's an 
ongoing headache.


-Brian

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


Re: [Mesa-dev] [PATCH] glsl/cse: Maintain a list of free ae_entry objects

2015-03-27 Thread Kenneth Graunke
On Thursday, March 26, 2015 08:52:33 PM Ian Romanick wrote:
 From: Ian Romanick ian.d.roman...@intel.com
 
 The CSE algorithm will continuously allocate new ae_entry objects.  As
 each new basic block is exited, all of the previously allocated objects
 are dumped.  Instead, put them in a free list and re-use them in the
 next basic block.  Reduce, reuse, recycle!
 
 Signed-off-by: Ian Romanick ian.d.roman...@intel.com
 Cc: Jordan Justen jordan.l.jus...@intel.com
 
 ---
  src/glsl/opt_cse.cpp | 63 
+---
  1 file changed, 55 insertions(+), 8 deletions(-)
 
 diff --git a/src/glsl/opt_cse.cpp b/src/glsl/opt_cse.cpp
 index 623268e..425eebc 100644
 --- a/src/glsl/opt_cse.cpp
 +++ b/src/glsl/opt_cse.cpp
 @@ -63,6 +63,17 @@ public:
var = NULL;
 }
  
 +   void init(ir_instruction *base_ir, ir_rvalue **val)
 +   {
 +  this-val = val;
 +  this-base_ir = base_ir;
 +  this-var = NULL;
 +
 +  assert(val);
 +  assert(*val);
 +  assert(base_ir);
 +   }
 +
 /**
  * The pointer to the expression that we might be able to reuse
  *
 @@ -116,6 +127,18 @@ private:
 ir_rvalue *try_cse(ir_rvalue *rvalue);
 void add_to_ae(ir_rvalue **rvalue);
  
 +   /**
 +* Move all nodes from the ae list to the free list
 +*/
 +   void empty_ae_list();
 +
 +   /**
 +* Get and initialize a new ae_entry
 +*
 +* This will either come from the free list or be freshly allocated.
 +*/
 +   ae_entry *get_ae_entry(ir_rvalue **rvalue);
 +
 /** List of ae_entry: The available expressions to reuse */
 exec_list *ae;
  
 @@ -126,6 +149,11 @@ private:
  * right.
  */
 exec_list *validate_instructions;
 +
 +   /**
 +* List of available-for-use ae_entry objects.
 +*/
 +   exec_list free_ae_entries;
  };
  
  /**
 @@ -322,6 +350,25 @@ cse_visitor::try_cse(ir_rvalue *rvalue)
 return NULL;
  }
  
 +void
 +cse_visitor::empty_ae_list()
 +{
 +   free_ae_entries.append_list(ae);

If you're just trying to save memory...it sure looks like you can just
ralloc_free(mem_ctx); mem_ctx = ralloc_context(NULL) here.  Which would
be much simpler.

But I suppose this does reduce the number of malloc calls considerably,
so it's probably more efficient.

 +}
 +
 +ae_entry *
 +cse_visitor::get_ae_entry(ir_rvalue **rvalue)
 +{
 +   ae_entry *entry = (ae_entry *) free_ae_entries.pop_head();
 +   if (entry) {
 +  entry-init(base_ir, rvalue);
 +   } else {
 +  entry = new(mem_ctx) ae_entry(base_ir, rvalue);
 +   }
 +
 +   return entry;
 +}
 +


signature.asc
Description: This is a digitally signed message part.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 13/15] nvc0: expose more driver-specific query groups

2015-03-27 Thread Ilia Mirkin
It's really confusing to have MP_COUNTER_GROUP being 0 or 1 depending
on the setting of DEBUG. Please make them the same.

On Sun, Mar 22, 2015 at 11:35 AM, Samuel Pitoiset
samuel.pitoi...@gmail.com wrote:
 This patch exposes Driver statistics and MP counters groups.

 Signed-off-by: Samuel Pitoiset samuel.pitoi...@gmail.com
 ---
  src/gallium/drivers/nouveau/nvc0/nvc0_query.c  | 61 
 --
  src/gallium/drivers/nouveau/nvc0/nvc0_screen.h | 11 +
  2 files changed, 69 insertions(+), 3 deletions(-)

 diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c 
 b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
 index 52f6d6c..a63a740 100644
 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
 +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
 @@ -24,8 +24,6 @@

  #define NVC0_PUSH_EXPLICIT_SPACE_CHECKING

 -#include util/u_query.h
 -
  #include nvc0/nvc0_context.h
  #include nv_object.xml.h
  #include nvc0/nve4_compute.xml.h
 @@ -1424,6 +1422,7 @@ nvc0_screen_get_driver_query_info(struct pipe_screen 
 *pscreen,
info-max_value.u64 = 0;
if (strstr(info-name, bytes))
   info-type = PIPE_DRIVER_QUERY_TYPE_BYTES;
 +  info-group_id = NVC0_QUERY_DRV_STAT_GROUP;
return 1;
 } else
  #endif
 @@ -1433,18 +1432,21 @@ nvc0_screen_get_driver_query_info(struct pipe_screen 
 *pscreen,
   info-query_type = NVE4_PM_QUERY(id - NVC0_QUERY_DRV_STAT_COUNT);
   info-max_value.u64 =
  (id  NVE4_PM_QUERY_METRIC_MP_OCCUPANCY) ? 0 : 100;
 + info-group_id = NVC0_QUERY_MP_COUNTER_GROUP;
   return 1;
} else
if (screen-compute) {
   info-name = nvc0_pm_query_names[id - NVC0_QUERY_DRV_STAT_COUNT];
   info-query_type = NVC0_PM_QUERY(id - NVC0_QUERY_DRV_STAT_COUNT);
   info-max_value.u64 = 0;
 + info-group_id = NVC0_QUERY_MP_COUNTER_GROUP;
   return 1;
}
 }
 /* user asked for info about non-existing query */
 info-name = this_is_not_the_query_you_are_looking_for;
 info-query_type = 0xdeadd01d;
 +   info-group_id = 0;
 info-max_value.u64 = 0;
 return 0;
  }
 @@ -1454,7 +1456,60 @@ nvc0_screen_get_driver_query_group_info(struct 
 pipe_screen *pscreen,
  unsigned id,
  struct pipe_driver_query_group_info 
 *info)
  {
 -   return util_get_driver_query_group_info(id, NVC0_QUERY_DRV_STAT_COUNT, 
 info);
 +   struct nvc0_screen *screen = nvc0_screen(pscreen);
 +   int count = 0;
 +
 +#ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS
 +   count++;
 +#endif
 +   if (screen-base.device-drm_version = 0x01000101) {
 +  if (screen-base.class_3d = NVE4_3D_CLASS) {
 + count++;
 +  } else
 +  if (screen-compute) {
 + count++; /* NVC0_COMPUTE is not always enabled */
 +  }
 +   }
 +
 +   if (!info)
 +  return count;
 +
 +#ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS
 +   if (id == NVC0_QUERY_DRV_STAT_GROUP) {
 +  info-name = Driver statistics;
 +  info-max_active_queries = NVC0_QUERY_DRV_STAT_COUNT;
 +  info-num_queries = NVC0_QUERY_DRV_STAT_COUNT;
 +  return 1;
 +   } else
 +#endif
 +   if (id == NVC0_QUERY_MP_COUNTER_GROUP) {
 +  info-name = MP counters;
 +
 +  if (screen-base.class_3d = NVE4_3D_CLASS) {
 + info-num_queries = NVE4_PM_QUERY_COUNT;
 +
 + /* On NVE4+, each multiprocessor have 8 hardware counters separated
 +  * in two distinct domains, but we allow only one active query
 +  * simultaneously because some of them use more than one hardware
 +  * counter and this will result in an undefined behaviour. */
 + info-max_active_queries = 1; /* TODO: handle multiple hw counters 
 */
 + return 1;
 +  } else
 +  if (screen-compute) {
 + info-num_queries = NVC0_PM_QUERY_COUNT;
 +
 + /* On NVC0:NVE4, each multiprocessor have 8 hardware counters
 +  * in a single domain. */
 + info-max_active_queries = 8;
 + return 1;
 +  }
 +   }
 +
 +   /* user asked for info about non-existing query group */
 +   info-name = this_is_not_the_query_group_you_are_looking_for;
 +   info-max_active_queries = 0;
 +   info-num_queries = 0;
 +   return 0;
  }

  void
 diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h 
 b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h
 index 6bf43d9..b7c53c6 100644
 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h
 +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h
 @@ -234,10 +234,21 @@ nvc0_screen(struct pipe_screen *screen)
  #define NVC0_QUERY_DRV_STAT_PUSHBUF_COUNT   27
  #define NVC0_QUERY_DRV_STAT_RESOURCE_VALIDATE_COUNT 28

 +/*
 + * Query groups:
 + */
 +#define NVC0_QUERY_DRV_STAT_GROUP   0
 +#define NVC0_QUERY_MP_COUNTER_GROUP 1
 +
  #else

  #define NVC0_QUERY_DRV_STAT_COUNT 0

 +/*
 + * Query groups:
 + */
 +#define NVC0_QUERY_MP_COUNTER_GROUP 0
 +
  #endif

  int 

Re: [Mesa-dev] [PATCH 5/8] nir: Add addition/multiplication identities of exp/log.

2015-03-27 Thread Eric Anholt
Matt Turner matts...@gmail.com writes:

 instructions in affected programs: 2858 - 2808 (-1.75%)
 helped:12
 ---
  src/glsl/nir/nir_opt_algebraic.py | 8 
  1 file changed, 8 insertions(+)

 diff --git a/src/glsl/nir/nir_opt_algebraic.py 
 b/src/glsl/nir/nir_opt_algebraic.py
 index 6730408..34a401a 100644
 --- a/src/glsl/nir/nir_opt_algebraic.py
 +++ b/src/glsl/nir/nir_opt_algebraic.py
 @@ -149,6 +149,14 @@ optimizations = [
 (('flog', ('frsq', a)), ('fmul', -0.5, ('flog', a))),
 (('flog2', ('fpow', a, b)), ('fmul', b, ('flog2', a))),
 (('flog', ('fpow', a, b)), ('fmul', b, ('flog', a))),
 +   (('fadd', ('flog2', a), ('flog2', b)), ('flog2', ('fmul', a, b))),
 +   (('fadd', ('flog', a), ('flog', b)), ('flog', ('fmul', a, b))),
 +   (('fadd', ('flog2', a), ('fneg', ('flog2', b))), ('flog2', ('fdiv', a, 
 b))),
 +   (('fadd', ('flog', a), ('fneg', ('flog', b))), ('flog', ('fdiv', a, b))),

 +   (('fmul', ('fexp2', a), ('fexp2', a)), ('fmul', 2.0, ('fexp2', a))),
 +   (('fmul', ('fexp', a), ('fexp', a)), ('fmul', 2.0, ('fexp', a))),


e^a * e^a - 2 * e^a?  This doesn't seem right.  And something specific
to this doesn't seem particularly better than the general case below.

 +   (('fmul', ('fexp2', a), ('fexp2', b)), ('fexp2', ('fadd', a, b))),
 +   (('fmul', ('fexp', a), ('fexp', b)), ('fexp', ('fadd', a, b))),


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


Re: [Mesa-dev] [PATCH] glsl/cse: Maintain a list of free ae_entry objects

2015-03-27 Thread Thomas Helland
This looks good to me, and matches a solution I found
online the other day for reducing memory allocation overhead.

Reviewed-by: Thomas Helland thomashellan...@gmail.com

Did you happen to profile this? Did you identify other places that
could need a similar treatment?
I'm about to do a last round of micro-adjustments and profiling
of my hash table series before sending it out, but the memory
allocations take up such a portion of the run-time that
profiling the table starts to get lost in the noise.

Thomas

2015-03-27 4:52 GMT+01:00 Ian Romanick i...@freedesktop.org:
 From: Ian Romanick ian.d.roman...@intel.com

 The CSE algorithm will continuously allocate new ae_entry objects.  As
 each new basic block is exited, all of the previously allocated objects
 are dumped.  Instead, put them in a free list and re-use them in the
 next basic block.  Reduce, reuse, recycle!

 Signed-off-by: Ian Romanick ian.d.roman...@intel.com
 Cc: Jordan Justen jordan.l.jus...@intel.com

 ---
  src/glsl/opt_cse.cpp | 63 
 +---
  1 file changed, 55 insertions(+), 8 deletions(-)

 diff --git a/src/glsl/opt_cse.cpp b/src/glsl/opt_cse.cpp
 index 623268e..425eebc 100644
 --- a/src/glsl/opt_cse.cpp
 +++ b/src/glsl/opt_cse.cpp
 @@ -63,6 +63,17 @@ public:
var = NULL;
 }

 +   void init(ir_instruction *base_ir, ir_rvalue **val)
 +   {
 +  this-val = val;
 +  this-base_ir = base_ir;
 +  this-var = NULL;
 +
 +  assert(val);
 +  assert(*val);
 +  assert(base_ir);
 +   }
 +
 /**
  * The pointer to the expression that we might be able to reuse
  *
 @@ -116,6 +127,18 @@ private:
 ir_rvalue *try_cse(ir_rvalue *rvalue);
 void add_to_ae(ir_rvalue **rvalue);

 +   /**
 +* Move all nodes from the ae list to the free list
 +*/
 +   void empty_ae_list();
 +
 +   /**
 +* Get and initialize a new ae_entry
 +*
 +* This will either come from the free list or be freshly allocated.
 +*/
 +   ae_entry *get_ae_entry(ir_rvalue **rvalue);
 +
 /** List of ae_entry: The available expressions to reuse */
 exec_list *ae;

 @@ -126,6 +149,11 @@ private:
  * right.
  */
 exec_list *validate_instructions;
 +
 +   /**
 +* List of available-for-use ae_entry objects.
 +*/
 +   exec_list free_ae_entries;
  };

  /**
 @@ -322,6 +350,25 @@ cse_visitor::try_cse(ir_rvalue *rvalue)
 return NULL;
  }

 +void
 +cse_visitor::empty_ae_list()
 +{
 +   free_ae_entries.append_list(ae);
 +}
 +
 +ae_entry *
 +cse_visitor::get_ae_entry(ir_rvalue **rvalue)
 +{
 +   ae_entry *entry = (ae_entry *) free_ae_entries.pop_head();
 +   if (entry) {
 +  entry-init(base_ir, rvalue);
 +   } else {
 +  entry = new(mem_ctx) ae_entry(base_ir, rvalue);
 +   }
 +
 +   return entry;
 +}
 +
  /** Add the rvalue to the list of available expressions for CSE. */
  void
  cse_visitor::add_to_ae(ir_rvalue **rvalue)
 @@ -332,7 +379,7 @@ cse_visitor::add_to_ae(ir_rvalue **rvalue)
printf(\n);
 }

 -   ae-push_tail(new(mem_ctx) ae_entry(base_ir, rvalue));
 +   ae-push_tail(get_ae_entry(rvalue));

 if (debug)
dump_ae(ae);
 @@ -370,33 +417,33 @@ cse_visitor::visit_enter(ir_if *ir)
  {
 handle_rvalue(ir-condition);

 -   ae-make_empty();
 +   empty_ae_list();
 visit_list_elements(this, ir-then_instructions);

 -   ae-make_empty();
 +   empty_ae_list();
 visit_list_elements(this, ir-else_instructions);

 -   ae-make_empty();
 +   empty_ae_list();
 return visit_continue_with_parent;
  }

  ir_visitor_status
  cse_visitor::visit_enter(ir_function_signature *ir)
  {
 -   ae-make_empty();
 +   empty_ae_list();
 visit_list_elements(this, ir-body);

 -   ae-make_empty();
 +   empty_ae_list();
 return visit_continue_with_parent;
  }

  ir_visitor_status
  cse_visitor::visit_enter(ir_loop *ir)
  {
 -   ae-make_empty();
 +   empty_ae_list();
 visit_list_elements(this, ir-body_instructions);

 -   ae-make_empty();
 +   empty_ae_list();
 return visit_continue_with_parent;
  }

 --
 2.1.0

 ___
 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] glsl: allow ForceGLSLVersion to override #version directives

2015-03-27 Thread Brian Paul
Previously, the ctx-Const.ForceGLSLVersion setting only worked if
the shader lacked a #version directive.  Now, the ForceGLSLVersion
setting will override the #version directive too.

This change should be safe since it should be rare to have an app
that has a mix of shader versions and we only wanted to override
the #version for shaders which lacked the #version directive.
---
 src/glsl/glsl_parser_extras.cpp | 11 +++
 src/glsl/glsl_parser_extras.h   |  1 +
 src/mesa/main/mtypes.h  |  4 ++--
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 79624bc..0aa3c54 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -73,8 +73,8 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct 
gl_context *_ctx,
this-uses_builtin_functions = false;
 
/* Set default language version and extensions */
-   this-language_version = ctx-Const.ForceGLSLVersion ?
-ctx-Const.ForceGLSLVersion : 110;
+   this-language_version = 110;
+   this-forced_language_version = ctx-Const.ForceGLSLVersion;
this-es_shader = false;
this-ARB_texture_rectangle_enable = true;
 
@@ -320,11 +320,14 @@ _mesa_glsl_parse_state::process_version_directive(YYLTYPE 
*locp, int version,
   this-ARB_texture_rectangle_enable = false;
}
 
-   this-language_version = version;
+   if (this-forced_language_version)
+  this-language_version = this-forced_language_version;
+   else
+  this-language_version = version;
 
bool supported = false;
for (unsigned i = 0; i  this-num_supported_versions; i++) {
-  if (this-supported_versions[i].ver == (unsigned) version
+  if (this-supported_versions[i].ver == this-language_version
this-supported_versions[i].es == this-es_shader) {
  supported = true;
  break;
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index 0975c86..1f5478b 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -226,6 +226,7 @@ struct _mesa_glsl_parse_state {
 
bool es_shader;
unsigned language_version;
+   unsigned forced_language_version;
gl_shader_stage stage;
 
/**
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 8e1dba6..f718768 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3527,8 +3527,8 @@ struct gl_constants
GLboolean ForceGLSLExtensionsWarn;
 
/**
-* If non-zero, forces GLSL shaders without the #version directive to behave
-* as if they began with #version ForceGLSLVersion.
+* If non-zero, forces GLSL shaders to behave as if they began
+* with #version ForceGLSLVersion.
 */
GLuint ForceGLSLVersion;
 
-- 
1.9.1

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


Re: [Mesa-dev] [PATCH] glsl: mark uniform and input interface blocks as read only

2015-03-27 Thread Mark Janes
Reviewed-by: Mark Janes mark.a.ja...@intel.com

Timothy Arceri t_arc...@yahoo.com.au writes:

 ---

  Piglit tests:

  http://lists.freedesktop.org/archives/piglit/2015-March/015369.html

  src/glsl/ast_to_hir.cpp | 6 ++
  1 file changed, 6 insertions(+)

 diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
 index d9ce6c9..49bddc4 100644
 --- a/src/glsl/ast_to_hir.cpp
 +++ b/src/glsl/ast_to_hir.cpp
 @@ -5775,6 +5775,9 @@ ast_interface_block::hir(exec_list *instructions,
var-data.matrix_layout = matrix_layout == GLSL_MATRIX_LAYOUT_INHERITED
   ? GLSL_MATRIX_LAYOUT_COLUMN_MAJOR : matrix_layout;
  
 +  if (var_mode == ir_var_shader_in || var_mode == ir_var_uniform)
 + var-data.read_only = true;
 +
if (state-stage == MESA_SHADER_GEOMETRY  var_mode == 
 ir_var_shader_in)
   handle_geometry_shader_input_decl(state, loc, var);
  
 @@ -5815,6 +5818,9 @@ ast_interface_block::hir(exec_list *instructions,
   var-data.sample = fields[i].sample;
   var-init_interface_type(block_type);
  
 + if (var_mode == ir_var_shader_in || var_mode == ir_var_uniform)
 +var-data.read_only = true;
 +
   if (fields[i].matrix_layout == GLSL_MATRIX_LAYOUT_INHERITED) {
  var-data.matrix_layout = matrix_layout == 
 GLSL_MATRIX_LAYOUT_INHERITED
 ? GLSL_MATRIX_LAYOUT_COLUMN_MAJOR : matrix_layout;
 -- 
 2.1.0

 ___
 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 2/3] nir: Convert to using pipeline.h.

2015-03-27 Thread Eric Anholt
One file that actually grubs through gl_shader_programs is left.
---
 src/glsl/nir/nir_lower_system_values.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/glsl/nir/nir_lower_system_values.c 
b/src/glsl/nir/nir_lower_system_values.c
index a6eec65..75db08d 100644
--- a/src/glsl/nir/nir_lower_system_values.c
+++ b/src/glsl/nir/nir_lower_system_values.c
@@ -26,7 +26,7 @@
  */
 
 #include nir.h
-#include main/mtypes.h
+#include util/pipeline.h
 
 static void
 convert_instr(nir_intrinsic_instr *instr)
-- 
2.1.4

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


[Mesa-dev] [PATCH 3/3] gallium: Add tgsi_to_nir to get a nir_shader for a TGSI shader.

2015-03-27 Thread Eric Anholt
This will be used by the VC4 driver for doing device-independent
optimization, and hopefully eventually replacing its whole IR.  It also
may be useful to other drivers for the same reason.

v2: Add all of the instructions I was relying on tgsi_lowering to remove,
and more.
v3: Rebase on SSA rework of the builder.
v4: Use the NIR ineg operation instead of doing a src modifier.
v5: Don't use ineg for fnegs.  (infer_src_type on MOV doesn't do what I
expect, again).
v6: Fix handling of multi-channel KILL_IF sources.
v7: Make ttn_get_f() return a swizzle of a scalar load_const, rather than
a vector load_const.  CSE doesn't recognize that srcs out of those
channels are actually all the same.
v8: Rebase on nir_builder auto-sizing, make the scalar arguments to
non-ALU instructions actually be scalars.
v9: Add support for if/loop instructions, additional texture targets, and
untested support for indirect addressing on temps.
v10: Rebase on master, drop bad comment about control flow and just choose
 the X channel, use int comparison opcodes in LIT for now, drop unused
 pipe_context argument..
v11: Fix translation of LRP (previously missed because I mis-translated
 back out), use nir_builder init helpers.
v12: Rebase on master, adding explicit include of mtypes.h to get
 INTERP_QUALIFIER_*
v13: Rebase on variables being in lists instead of hash tables, drop use
 of mtypes.h in favor of util/pipeline.h.  Use Ken's nir_builder
 swizzle and fmov/imov_alu helpers, drop struct in front of
 nir_builder, use nir_builder directly as the function arg in a lot of
 cases, drop redundant members of ttn_compile that are also in
 nir_builder, drop some half-baked malloc failure handling.
---

This series is present as part of my vc4-nir-rebase-qir-2 branch.  The
shader-db results across the branch are:

total uniforms in shared programs: 13433 - 13434 (0.01%)
uniforms in affected programs: 62 - 63 (1.61%)
total instructions in shared programs: 40003 - 39794 (-0.52%)
instructions in affected programs: 15494 - 15285 (-1.35%)

I don't get to delete my driver's optimization code in that branch
yet, notably because of optimization available in the programmable
blending I have to generate.

 src/gallium/auxiliary/Makefile.sources  |1 +
 src/gallium/auxiliary/nir/tgsi_to_nir.c | 1425 +++
 src/gallium/auxiliary/nir/tgsi_to_nir.h |   30 +
 3 files changed, 1456 insertions(+)
 create mode 100644 src/gallium/auxiliary/nir/tgsi_to_nir.c
 create mode 100644 src/gallium/auxiliary/nir/tgsi_to_nir.h

diff --git a/src/gallium/auxiliary/Makefile.sources 
b/src/gallium/auxiliary/Makefile.sources
index 09496fa..08e4e4c 100644
--- a/src/gallium/auxiliary/Makefile.sources
+++ b/src/gallium/auxiliary/Makefile.sources
@@ -69,6 +69,7 @@ C_SOURCES := \
indices/u_indices_priv.h \
indices/u_primconvert.c \
indices/u_primconvert.h \
+   nir/tgsi_to_nir.c \
os/os_memory_aligned.h \
os/os_memory_debug.h \
os/os_memory_stdc.h \
diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c 
b/src/gallium/auxiliary/nir/tgsi_to_nir.c
new file mode 100644
index 000..e8cf9f4
--- /dev/null
+++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c
@@ -0,0 +1,1425 @@
+/*
+ * Copyright © 2014-2015 Broadcom
+ * Copyright (C) 2014 Rob Clark robcl...@freedesktop.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the Software),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include util/ralloc.h
+#include glsl/nir/nir.h
+#include glsl/nir/nir_builder.h
+#include glsl/list.h
+#include util/pipeline.h
+
+#include nir/tgsi_to_nir.h
+#include tgsi/tgsi_parse.h
+#include tgsi/tgsi_dump.h
+#include tgsi/tgsi_info.h
+#include tgsi/tgsi_scan.h
+
+#define SWIZ(X, Y, Z, W) (unsigned[4]){  \
+  TGSI_SWIZZLE_##X,  \
+  TGSI_SWIZZLE_##Y,  \
+  TGSI_SWIZZLE_##Z,  \
+  

[Mesa-dev] [PATCH 1/3] mesa: Make a shared header for 3D pipeline enum / #defines.

2015-03-27 Thread Eric Anholt
NIR uses these enums/#defines in nir_variables and associated intrinsics,
but I want to be able to use them from TGSI-NIR and NIR-TGSI.
Otherwise, we had to pull in all of mtypes.h.

This doesn't cover all of the enums we might want from a shared compiler
core (like varying slots or vert attribs), but it at least covers what I
need at the moment (system values and interp qualifiers).
---
 src/mesa/main/mtypes.h | 135 +--
 src/util/pipeline.h| 170 +
 2 files changed, 171 insertions(+), 134 deletions(-)
 create mode 100644 src/util/pipeline.h

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 8e1dba6..e4f8803 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -42,6 +42,7 @@
 #include main/config.h
 #include glapi/glapi.h
 #include math/m_matrix.h /* GLmatrix */
+#include util/pipeline.h
 #include util/simple_list.h  /* struct simple_node */
 #include main/formats.h   /* MESA_FORMAT_COUNT */
 
@@ -2082,140 +2083,6 @@ typedef enum
 
 
 /**
- * If the register file is PROGRAM_SYSTEM_VALUE, the register index will be
- * one of these values.
- */
-typedef enum
-{
-   /**
-* \name Vertex shader system values
-*/
-   /*@{*/
-   /**
-* OpenGL-style vertex ID.
-*
-* Section 2.11.7 (Shader Execution), subsection Shader Inputs, of the
-* OpenGL 3.3 core profile spec says:
-*
-* gl_VertexID holds the integer index i implicitly passed by
-* DrawArrays or one of the other drawing commands defined in section
-* 2.8.3.
-*
-* Section 2.8.3 (Drawing Commands) of the same spec says:
-*
-* The commandsare equivalent to the commands with the same base
-* name (without the BaseVertex suffix), except that the ith element
-* transferred by the corresponding draw call will be taken from
-* element indices[i] + basevertex of each enabled array.
-*
-* Additionally, the overview in the GL_ARB_shader_draw_parameters spec
-* says:
-*
-* In unextended GL, vertex shaders have inputs named gl_VertexID and
-* gl_InstanceID, which contain, respectively the index of the vertex
-* and instance. The value of gl_VertexID is the implicitly passed
-* index of the vertex being processed, which includes the value of
-* baseVertex, for those commands that accept it.
-*
-* gl_VertexID gets basevertex added in.  This differs from DirectX where
-* SV_VertexID does \b not get basevertex added in.
-*
-* \note
-* If all system values are available, \c SYSTEM_VALUE_VERTEX_ID will be
-* equal to \c SYSTEM_VALUE_VERTEX_ID_ZERO_BASE plus
-* \c SYSTEM_VALUE_BASE_VERTEX.
-*
-* \sa SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, SYSTEM_VALUE_BASE_VERTEX
-*/
-   SYSTEM_VALUE_VERTEX_ID,
-
-   /**
-* Instanced ID as supplied to gl_InstanceID
-*
-* Values assigned to gl_InstanceID always begin with zero, regardless of
-* the value of baseinstance.
-*
-* Section 11.1.3.9 (Shader Inputs) of the OpenGL 4.4 core profile spec
-* says:
-*
-* gl_InstanceID holds the integer instance number of the current
-* primitive in an instanced draw call (see section 10.5).
-*
-* Through a big chain of pseudocode, section 10.5 describes that
-* baseinstance is not counted by gl_InstanceID.  In that section, notice
-*
-* If an enabled vertex attribute array is instanced (it has a
-* non-zero divisor as specified by VertexAttribDivisor), the element
-* index that is transferred to the GL, for all vertices, is given by
-*
-* floor(instance/divisor) + baseinstance
-*
-* If an array corresponding to an attribute required by a vertex
-* shader is not enabled, then the corresponding element is taken from
-* the current attribute state (see section 10.2).
-*
-* Note that baseinstance is \b not included in the value of instance.
-*/
-   SYSTEM_VALUE_INSTANCE_ID,
-
-   /**
-* DirectX-style vertex ID.
-*
-* Unlike \c SYSTEM_VALUE_VERTEX_ID, this system value does \b not include
-* the value of basevertex.
-*
-* \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_BASE_VERTEX
-*/
-   SYSTEM_VALUE_VERTEX_ID_ZERO_BASE,
-
-   /**
-* Value of \c basevertex passed to \c glDrawElementsBaseVertex and similar
-* functions.
-*
-* \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_VERTEX_ID_ZERO_BASE
-*/
-   SYSTEM_VALUE_BASE_VERTEX,
-   /*@}*/
-
-   /**
-* \name Geometry shader system values
-*/
-   /*@{*/
-   SYSTEM_VALUE_INVOCATION_ID,
-   /*@}*/
-
-   /**
-* \name Fragment shader system values
-*/
-   /*@{*/
-   SYSTEM_VALUE_FRONT_FACE, /** (not done yet) */
-   SYSTEM_VALUE_SAMPLE_ID,
-   SYSTEM_VALUE_SAMPLE_POS,
-   SYSTEM_VALUE_SAMPLE_MASK_IN,
-   /*@}*/
-
-   SYSTEM_VALUE_MAX /** Number of 

Re: [Mesa-dev] [PATCH 1/3] mesa: Make a shared header for 3D pipeline enum / #defines.

2015-03-27 Thread Ilia Mirkin
On Fri, Mar 27, 2015 at 4:54 PM, Eric Anholt e...@anholt.net wrote:
 NIR uses these enums/#defines in nir_variables and associated intrinsics,
 but I want to be able to use them from TGSI-NIR and NIR-TGSI.
 Otherwise, we had to pull in all of mtypes.h.

 This doesn't cover all of the enums we might want from a shared compiler
 core (like varying slots or vert attribs), but it at least covers what I
 need at the moment (system values and interp qualifiers).
 ---
  src/mesa/main/mtypes.h | 135 +--
  src/util/pipeline.h| 170 
 +
  2 files changed, 171 insertions(+), 134 deletions(-)
  create mode 100644 src/util/pipeline.h

 diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
 index 8e1dba6..e4f8803 100644
 --- a/src/mesa/main/mtypes.h
 +++ b/src/mesa/main/mtypes.h
 @@ -42,6 +42,7 @@
  #include main/config.h
  #include glapi/glapi.h
  #include math/m_matrix.h /* GLmatrix */
 +#include util/pipeline.h
  #include util/simple_list.h  /* struct simple_node */
  #include main/formats.h   /* MESA_FORMAT_COUNT */

 @@ -2082,140 +2083,6 @@ typedef enum


  /**
 - * If the register file is PROGRAM_SYSTEM_VALUE, the register index will be
 - * one of these values.
 - */
 -typedef enum
 -{
 -   /**
 -* \name Vertex shader system values
 -*/
 -   /*@{*/
 -   /**
 -* OpenGL-style vertex ID.
 -*
 -* Section 2.11.7 (Shader Execution), subsection Shader Inputs, of the
 -* OpenGL 3.3 core profile spec says:
 -*
 -* gl_VertexID holds the integer index i implicitly passed by
 -* DrawArrays or one of the other drawing commands defined in section
 -* 2.8.3.
 -*
 -* Section 2.8.3 (Drawing Commands) of the same spec says:
 -*
 -* The commandsare equivalent to the commands with the same base
 -* name (without the BaseVertex suffix), except that the ith element
 -* transferred by the corresponding draw call will be taken from
 -* element indices[i] + basevertex of each enabled array.
 -*
 -* Additionally, the overview in the GL_ARB_shader_draw_parameters spec
 -* says:
 -*
 -* In unextended GL, vertex shaders have inputs named gl_VertexID and
 -* gl_InstanceID, which contain, respectively the index of the vertex
 -* and instance. The value of gl_VertexID is the implicitly passed
 -* index of the vertex being processed, which includes the value of
 -* baseVertex, for those commands that accept it.
 -*
 -* gl_VertexID gets basevertex added in.  This differs from DirectX where
 -* SV_VertexID does \b not get basevertex added in.
 -*
 -* \note
 -* If all system values are available, \c SYSTEM_VALUE_VERTEX_ID will be
 -* equal to \c SYSTEM_VALUE_VERTEX_ID_ZERO_BASE plus
 -* \c SYSTEM_VALUE_BASE_VERTEX.
 -*
 -* \sa SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, SYSTEM_VALUE_BASE_VERTEX
 -*/
 -   SYSTEM_VALUE_VERTEX_ID,
 -
 -   /**
 -* Instanced ID as supplied to gl_InstanceID
 -*
 -* Values assigned to gl_InstanceID always begin with zero, regardless of
 -* the value of baseinstance.
 -*
 -* Section 11.1.3.9 (Shader Inputs) of the OpenGL 4.4 core profile spec
 -* says:
 -*
 -* gl_InstanceID holds the integer instance number of the current
 -* primitive in an instanced draw call (see section 10.5).
 -*
 -* Through a big chain of pseudocode, section 10.5 describes that
 -* baseinstance is not counted by gl_InstanceID.  In that section, notice
 -*
 -* If an enabled vertex attribute array is instanced (it has a
 -* non-zero divisor as specified by VertexAttribDivisor), the element
 -* index that is transferred to the GL, for all vertices, is given by
 -*
 -* floor(instance/divisor) + baseinstance
 -*
 -* If an array corresponding to an attribute required by a vertex
 -* shader is not enabled, then the corresponding element is taken from
 -* the current attribute state (see section 10.2).
 -*
 -* Note that baseinstance is \b not included in the value of instance.
 -*/
 -   SYSTEM_VALUE_INSTANCE_ID,
 -
 -   /**
 -* DirectX-style vertex ID.
 -*
 -* Unlike \c SYSTEM_VALUE_VERTEX_ID, this system value does \b not include
 -* the value of basevertex.
 -*
 -* \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_BASE_VERTEX
 -*/
 -   SYSTEM_VALUE_VERTEX_ID_ZERO_BASE,
 -
 -   /**
 -* Value of \c basevertex passed to \c glDrawElementsBaseVertex and 
 similar
 -* functions.
 -*
 -* \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_VERTEX_ID_ZERO_BASE
 -*/
 -   SYSTEM_VALUE_BASE_VERTEX,
 -   /*@}*/
 -
 -   /**
 -* \name Geometry shader system values
 -*/
 -   /*@{*/
 -   SYSTEM_VALUE_INVOCATION_ID,
 -   /*@}*/
 -
 -   /**
 -* \name Fragment shader system values
 -*/
 -   /*@{*/
 -   

Re: [Mesa-dev] [PATCH] glsl: allow ForceGLSLVersion to override #version directives

2015-03-27 Thread Ilia Mirkin
On Fri, Mar 27, 2015 at 3:00 PM, Brian Paul bri...@vmware.com wrote:
 On 03/27/2015 12:49 PM, Ilia Mirkin wrote:

 On Fri, Mar 27, 2015 at 2:44 PM, Brian Paul bri...@vmware.com wrote:


 The Geeks3d GpuTest GiMark test for Windows has several shaders with
 #version 330 that don't actually use any 3.30 features.  Other shaders in
 the test use #version 130.  Furthermore, when a context is created, only
 a
 3.0 context is requested.  We don't support GL 3.0 w/ 3.30 shaders but if
 I
 override the #version 330 with 130 then everything works fine.


 That's incredibly annoying. Well your patch looks like it'll work as
 advertised, so

 Reviewed-by: Ilia Mirkin imir...@alum.mit.edu

 But perhaps leave it on the list for a bit in case there are
 dissenting opinions on the actual functionality?


 Sure, no problem.

 The sad reality is that Windows OpenGL apps are pretty sloppy/buggy when it
 comes to choosing the right OpenGL context version/profile and shader
 versions.  We have quite a few work-arounds in our in-house code to allow
 these apps to run.  If we don't do that, we get bug reports and negative
 comments from product reviewers.

Yeah, you can't really hold end users hostage over buggy applications,
esp when they work with other (less discerning) drivers.

 The problem is the Windows nvidia/amd/intel drivers are often more lax than
 Mesa about version/extension checking.  Also, the nvidia/amd/intel drivers
 support compat profile with OpenGL 3.2+ so a lot of those apps don't have
 any consideration of core vs. compat profile issues.  It's an ongoing
 headache.

Right. I think that will keep on being a headache until Mesa starts
supporting higher GL compat versions, especially for Windows-targeted
software (I guess OSX also doesn't do compat beyond GL2.1 or 3.0). But
I'm not well enough versed in the details to be able to suggest a path
forward, nor am I going to personally be able to do the work...

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


Re: [Mesa-dev] [PATCH 3/3] gallium: Add tgsi_to_nir to get a nir_shader for a TGSI shader.

2015-03-27 Thread Ilia Mirkin
On Fri, Mar 27, 2015 at 4:54 PM, Eric Anholt e...@anholt.net wrote:
 diff --git a/src/gallium/auxiliary/Makefile.sources 
 b/src/gallium/auxiliary/Makefile.sources
 index 09496fa..08e4e4c 100644
 --- a/src/gallium/auxiliary/Makefile.sources
 +++ b/src/gallium/auxiliary/Makefile.sources
 @@ -69,6 +69,7 @@ C_SOURCES := \
 indices/u_indices_priv.h \
 indices/u_primconvert.c \
 indices/u_primconvert.h \
 +   nir/tgsi_to_nir.c \
 os/os_memory_aligned.h \
 os/os_memory_debug.h \
 os/os_memory_stdc.h \

I believe you're supposed to include .h files in these lists as well
nowadays, since Emil uses them to generate the list of all files to
include in the distribution tarball.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/3] mesa: Make a shared header for 3D pipeline enum / #defines.

2015-03-27 Thread Kenneth Graunke
On Friday, March 27, 2015 01:54:30 PM Eric Anholt wrote:
 NIR uses these enums/#defines in nir_variables and associated intrinsics,
 but I want to be able to use them from TGSI-NIR and NIR-TGSI.
 Otherwise, we had to pull in all of mtypes.h.
 
 This doesn't cover all of the enums we might want from a shared compiler
 core (like varying slots or vert attribs), but it at least covers what I
 need at the moment (system values and interp qualifiers).
 ---
  src/mesa/main/mtypes.h | 135 +--
  src/util/pipeline.h| 170 
+
  2 files changed, 171 insertions(+), 134 deletions(-)
  create mode 100644 src/util/pipeline.h

Pulling these out of mtypes.h seems like a fine plan.  However, I don't
think the new header really belongs in src/util.

src/util is meant for memory allocation libraries, data structures,
atomic code, and other generic sort of helper stuff.

This is clearly compiler stuff - maybe put it in src/glsl or
src/mesa/program?


signature.asc
Description: This is a digitally signed message part.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] llvmpipe: simplify address calculation for 4x4 blocks

2015-03-27 Thread Jose Fonseca

Reviewed-by: Jose Fonseca jfons...@vmware.com

On 27/03/15 15:53, srol...@vmware.com wrote:

From: Roland Scheidegger srol...@vmware.com

These functions looked quite complicated, even though what they actually did
was trivial (ever since we dropped swizzled rendering). Also drop lookup of
format block per bytes done for each block, and do it once per scene instead.
This improves everybody's favorite benchmark by 3% or so, though
lp_rast_shade_quads_all() which calls this shows up still quite high for a
function which does little more than call the jit function.
(This would most likely be much better handled by the jit function itself,
the strides are passed through anyway already, though for being able to
handle layers it would definitely add some complexity.)
---
  src/gallium/drivers/llvmpipe/lp_rast.c  | 20 +--
  src/gallium/drivers/llvmpipe/lp_rast_priv.h | 87 +
  src/gallium/drivers/llvmpipe/lp_scene.c |  3 +
  src/gallium/drivers/llvmpipe/lp_scene.h |  1 +
  4 files changed, 35 insertions(+), 76 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c 
b/src/gallium/drivers/llvmpipe/lp_rast.c
index 903e7c5..7019acb 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast.c
@@ -91,6 +91,9 @@ lp_rast_tile_begin(struct lp_rasterizer_task *task,
 const struct cmd_bin *bin,
 int x, int y)
  {
+   unsigned i;
+   struct lp_scene *scene = task-scene;
+
 LP_DBG(DEBUG_RAST, %s %d,%d\n, __FUNCTION__, x, y);

 task-bin = bin;
@@ -104,9 +107,18 @@ lp_rast_tile_begin(struct lp_rasterizer_task *task,
 task-thread_data.vis_counter = 0;
 task-ps_invocations = 0;

-   /* reset pointers to color and depth tile(s) */
-   memset(task-color_tiles, 0, sizeof(task-color_tiles));
-   task-depth_tile = NULL;
+   for (i = 0; i  task-scene-fb.nr_cbufs; i++) {
+  if (task-scene-fb.cbufs[i]) {
+ task-color_tiles[i] = scene-cbufs[i].map +
+scene-cbufs[i].stride * task-y +
+scene-cbufs[i].format_bytes * task-x;
+  }
+   }
+   if (task-scene-fb.zsbuf) {
+  task-depth_tile = scene-zsbuf.map +
+ scene-zsbuf.stride * task-y +
+ scene-zsbuf.format_bytes * task-x;
+   }
  }


@@ -186,7 +198,7 @@ lp_rast_clear_zstencil(struct lp_rasterizer_task *task,

 if (scene-fb.zsbuf) {
unsigned layer;
-  uint8_t *dst_layer = lp_rast_get_depth_tile_pointer(task, 
LP_TEX_USAGE_READ_WRITE);
+  uint8_t *dst_layer = task-depth_tile;
block_size = util_format_get_blocksize(scene-fb.zsbuf-format);

clear_value = clear_mask;
diff --git a/src/gallium/drivers/llvmpipe/lp_rast_priv.h 
b/src/gallium/drivers/llvmpipe/lp_rast_priv.h
index d92230d..e6ebbcd 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_priv.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast_priv.h
@@ -141,64 +141,6 @@ lp_rast_shade_quads_mask(struct lp_rasterizer_task *task,
   unsigned mask);


-
-/**
- * Get pointer to the color tile
- */
-static INLINE uint8_t *
-lp_rast_get_color_tile_pointer(struct lp_rasterizer_task *task,
-   unsigned buf, enum lp_texture_usage usage)
-{
-   const struct lp_scene *scene = task-scene;
-   unsigned format_bytes;
-
-   assert(task-x  scene-tiles_x * TILE_SIZE);
-   assert(task-y  scene-tiles_y * TILE_SIZE);
-   assert(task-x % TILE_SIZE == 0);
-   assert(task-y % TILE_SIZE == 0);
-   assert(buf  scene-fb.nr_cbufs);
-
-   if (!task-color_tiles[buf]) {
-  struct pipe_surface *cbuf = scene-fb.cbufs[buf];
-  assert(cbuf);
-
-  format_bytes = util_format_get_blocksize(cbuf-format);
-  task-color_tiles[buf] = scene-cbufs[buf].map + scene-cbufs[buf].stride * 
task-y +
-   format_bytes * task-x;
-   }
-
-   return task-color_tiles[buf];
-}
-
-
-/**
- * Get pointer to the depth tile
- */
-static INLINE uint8_t *
-lp_rast_get_depth_tile_pointer(struct lp_rasterizer_task *task,
-   enum lp_texture_usage usage)
-{
-   const struct lp_scene *scene = task-scene;
-   unsigned format_bytes;
-
-   assert(task-x  scene-tiles_x * TILE_SIZE);
-   assert(task-y  scene-tiles_y * TILE_SIZE);
-   assert(task-x % TILE_SIZE == 0);
-   assert(task-y % TILE_SIZE == 0);
-
-   if (!task-depth_tile) {
-  struct pipe_surface *dbuf = scene-fb.zsbuf;
-  assert(dbuf);
-
-  format_bytes = util_format_get_blocksize(dbuf-format);
-  task-depth_tile = scene-zsbuf.map + scene-zsbuf.stride * task-y +
- format_bytes * task-x;
-   }
-
-   return task-depth_tile;
-}
-
-
  /**
   * Get the pointer to a 4x4 color block (within a 64x64 tile).
   * \param x, y location of 4x4 block in window coords
@@ -208,7 +150,7 @@ lp_rast_get_color_block_pointer(struct lp_rasterizer_task 
*task,
  unsigned buf, 

Re: [Mesa-dev] [PATCH 1/3] mesa: Make a shared header for 3D pipeline enum / #defines.

2015-03-27 Thread Kenneth Graunke
On Friday, March 27, 2015 04:57:45 PM Ilia Mirkin wrote:
 On Fri, Mar 27, 2015 at 4:54 PM, Eric Anholt e...@anholt.net wrote:
[snip]
  +#ifndef PIPELINE_H
  +#define PIPELINE_H
  +
  +/**
  + * Bitflags for system values.
  + */
  +#define SYSTEM_BIT_SAMPLE_ID BITFIELD64_BIT(SYSTEM_VALUE_SAMPLE_ID)
  +#define SYSTEM_BIT_SAMPLE_POS BITFIELD64_BIT(SYSTEM_VALUE_SAMPLE_POS)
  +#define SYSTEM_BIT_SAMPLE_MASK_IN 
BITFIELD64_BIT(SYSTEM_VALUE_SAMPLE_MASK_IN)
 
 Please include whatever defines BITFIELD64_BIT, otherwise including
 just this file will cause compilation errors.

Which raises an interesting point.  That header is mtypes.h, so how does
splitting this out actually help anything at all?

FWIW, I think moving those declarations to src/util/bitset.h might not
be a crazy plan.  Or, you could always just open code it - it's just
((GLbitfield64)1  (b)) aka (1ull  b) anyway.


signature.asc
Description: This is a digitally signed message part.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] glsl/cse: Maintain a list of free ae_entry objects

2015-03-27 Thread Ian Romanick
On 03/27/2015 11:33 AM, Kenneth Graunke wrote:
 On Thursday, March 26, 2015 08:52:33 PM Ian Romanick wrote:
 From: Ian Romanick ian.d.roman...@intel.com

 The CSE algorithm will continuously allocate new ae_entry objects.  As
 each new basic block is exited, all of the previously allocated objects
 are dumped.  Instead, put them in a free list and re-use them in the
 next basic block.  Reduce, reuse, recycle!

 Signed-off-by: Ian Romanick ian.d.roman...@intel.com
 Cc: Jordan Justen jordan.l.jus...@intel.com

 ---
  src/glsl/opt_cse.cpp | 63 
 +---
  1 file changed, 55 insertions(+), 8 deletions(-)

 diff --git a/src/glsl/opt_cse.cpp b/src/glsl/opt_cse.cpp
 index 623268e..425eebc 100644
 --- a/src/glsl/opt_cse.cpp
 +++ b/src/glsl/opt_cse.cpp
 @@ -63,6 +63,17 @@ public:
var = NULL;
 }
  
 +   void init(ir_instruction *base_ir, ir_rvalue **val)
 +   {
 +  this-val = val;
 +  this-base_ir = base_ir;
 +  this-var = NULL;
 +
 +  assert(val);
 +  assert(*val);
 +  assert(base_ir);
 +   }
 +
 /**
  * The pointer to the expression that we might be able to reuse
  *
 @@ -116,6 +127,18 @@ private:
 ir_rvalue *try_cse(ir_rvalue *rvalue);
 void add_to_ae(ir_rvalue **rvalue);
  
 +   /**
 +* Move all nodes from the ae list to the free list
 +*/
 +   void empty_ae_list();
 +
 +   /**
 +* Get and initialize a new ae_entry
 +*
 +* This will either come from the free list or be freshly allocated.
 +*/
 +   ae_entry *get_ae_entry(ir_rvalue **rvalue);
 +
 /** List of ae_entry: The available expressions to reuse */
 exec_list *ae;
  
 @@ -126,6 +149,11 @@ private:
  * right.
  */
 exec_list *validate_instructions;
 +
 +   /**
 +* List of available-for-use ae_entry objects.
 +*/
 +   exec_list free_ae_entries;
  };
  
  /**
 @@ -322,6 +350,25 @@ cse_visitor::try_cse(ir_rvalue *rvalue)
 return NULL;
  }
  
 +void
 +cse_visitor::empty_ae_list()
 +{
 +   free_ae_entries.append_list(ae);
 
 If you're just trying to save memory...it sure looks like you can just
 ralloc_free(mem_ctx); mem_ctx = ralloc_context(NULL) here.  Which would
 be much simpler.
 
 But I suppose this does reduce the number of malloc calls considerably,
 so it's probably more efficient.

It was a bit of both.  The original code was clearly doing it wrong,
and using an object pool seemed like the obvious solution.  Doing an
extra ralloc_free and ralloc_context here will increase the time spent
in ralloc, and that doesn't seem desirable.

Now, if I really thought CSE was a significant performance bottleneck,
I'd change get_ae_entry to use pop_tail to get the most recently added
(and likely cache-hot) ae_entry.  I'd probably also keep the ae_entry
list across calls and free them all at the end of the optimization loop.
 It doesn't seem worth the effort.

There are a bunch of places throughout Mesa that could benefit from an
object pool.  What may be worth the effort is making a general mechanism
that could be used in all the places.  That couldn't be more than a half
day of effort.

 +}
 +
 +ae_entry *
 +cse_visitor::get_ae_entry(ir_rvalue **rvalue)
 +{
 +   ae_entry *entry = (ae_entry *) free_ae_entries.pop_head();
 +   if (entry) {
 +  entry-init(base_ir, rvalue);
 +   } else {
 +  entry = new(mem_ctx) ae_entry(base_ir, rvalue);
 +   }
 +
 +   return entry;
 +}
 +




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


Re: [Mesa-dev] [PATCH] glsl/cse: Maintain a list of free ae_entry objects

2015-03-27 Thread Ian Romanick
On 03/27/2015 11:56 AM, Thomas Helland wrote:
 This looks good to me, and matches a solution I found
 online the other day for reducing memory allocation overhead.
 
 Reviewed-by: Thomas Helland thomashellan...@gmail.com
 
 Did you happen to profile this? Did you identify other places that
 could need a similar treatment?

I did neither.  I was in this file doing something else, and I just
happened to notice this... and I couldn't not fix it. :)

There are probably a ton of places throughout Mesa (especially in the
compiler stack) that could use an object pool.  Like I mentioned in my
reply to Ken, we'd probably want to make a general object pool
implementation to use everywhere.

 I'm about to do a last round of micro-adjustments and profiling
 of my hash table series before sending it out, but the memory
 allocations take up such a portion of the run-time that
 profiling the table starts to get lost in the noise.
 
 Thomas
 
 2015-03-27 4:52 GMT+01:00 Ian Romanick i...@freedesktop.org:
 From: Ian Romanick ian.d.roman...@intel.com

 The CSE algorithm will continuously allocate new ae_entry objects.  As
 each new basic block is exited, all of the previously allocated objects
 are dumped.  Instead, put them in a free list and re-use them in the
 next basic block.  Reduce, reuse, recycle!

 Signed-off-by: Ian Romanick ian.d.roman...@intel.com
 Cc: Jordan Justen jordan.l.jus...@intel.com

 ---
  src/glsl/opt_cse.cpp | 63 
 +---
  1 file changed, 55 insertions(+), 8 deletions(-)

 diff --git a/src/glsl/opt_cse.cpp b/src/glsl/opt_cse.cpp
 index 623268e..425eebc 100644
 --- a/src/glsl/opt_cse.cpp
 +++ b/src/glsl/opt_cse.cpp
 @@ -63,6 +63,17 @@ public:
var = NULL;
 }

 +   void init(ir_instruction *base_ir, ir_rvalue **val)
 +   {
 +  this-val = val;
 +  this-base_ir = base_ir;
 +  this-var = NULL;
 +
 +  assert(val);
 +  assert(*val);
 +  assert(base_ir);
 +   }
 +
 /**
  * The pointer to the expression that we might be able to reuse
  *
 @@ -116,6 +127,18 @@ private:
 ir_rvalue *try_cse(ir_rvalue *rvalue);
 void add_to_ae(ir_rvalue **rvalue);

 +   /**
 +* Move all nodes from the ae list to the free list
 +*/
 +   void empty_ae_list();
 +
 +   /**
 +* Get and initialize a new ae_entry
 +*
 +* This will either come from the free list or be freshly allocated.
 +*/
 +   ae_entry *get_ae_entry(ir_rvalue **rvalue);
 +
 /** List of ae_entry: The available expressions to reuse */
 exec_list *ae;

 @@ -126,6 +149,11 @@ private:
  * right.
  */
 exec_list *validate_instructions;
 +
 +   /**
 +* List of available-for-use ae_entry objects.
 +*/
 +   exec_list free_ae_entries;
  };

  /**
 @@ -322,6 +350,25 @@ cse_visitor::try_cse(ir_rvalue *rvalue)
 return NULL;
  }

 +void
 +cse_visitor::empty_ae_list()
 +{
 +   free_ae_entries.append_list(ae);
 +}
 +
 +ae_entry *
 +cse_visitor::get_ae_entry(ir_rvalue **rvalue)
 +{
 +   ae_entry *entry = (ae_entry *) free_ae_entries.pop_head();
 +   if (entry) {
 +  entry-init(base_ir, rvalue);
 +   } else {
 +  entry = new(mem_ctx) ae_entry(base_ir, rvalue);
 +   }
 +
 +   return entry;
 +}
 +
  /** Add the rvalue to the list of available expressions for CSE. */
  void
  cse_visitor::add_to_ae(ir_rvalue **rvalue)
 @@ -332,7 +379,7 @@ cse_visitor::add_to_ae(ir_rvalue **rvalue)
printf(\n);
 }

 -   ae-push_tail(new(mem_ctx) ae_entry(base_ir, rvalue));
 +   ae-push_tail(get_ae_entry(rvalue));

 if (debug)
dump_ae(ae);
 @@ -370,33 +417,33 @@ cse_visitor::visit_enter(ir_if *ir)
  {
 handle_rvalue(ir-condition);

 -   ae-make_empty();
 +   empty_ae_list();
 visit_list_elements(this, ir-then_instructions);

 -   ae-make_empty();
 +   empty_ae_list();
 visit_list_elements(this, ir-else_instructions);

 -   ae-make_empty();
 +   empty_ae_list();
 return visit_continue_with_parent;
  }

  ir_visitor_status
  cse_visitor::visit_enter(ir_function_signature *ir)
  {
 -   ae-make_empty();
 +   empty_ae_list();
 visit_list_elements(this, ir-body);

 -   ae-make_empty();
 +   empty_ae_list();
 return visit_continue_with_parent;
  }

  ir_visitor_status
  cse_visitor::visit_enter(ir_loop *ir)
  {
 -   ae-make_empty();
 +   empty_ae_list();
 visit_list_elements(this, ir-body_instructions);

 -   ae-make_empty();
 +   empty_ae_list();
 return visit_continue_with_parent;
  }

 --
 2.1.0

 ___
 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 1/1] gallivm: Fix build since llvm r233411

2015-03-27 Thread Tom Stellard
On Fri, Mar 27, 2015 at 06:46:43PM -0400, Jan Vesely wrote:
 Signed-off-by: Jan Vesely jan.ves...@rutgers.edu
Reviewed-by: Tom Stellard thomas.stell...@amd.com
 ---
  src/gallium/auxiliary/gallivm/lp_bld_debug.cpp | 4 
  1 file changed, 4 insertions(+)
 
 diff --git a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp 
 b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
 index bf6268b..d4d453d 100644
 --- a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
 +++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
 @@ -322,7 +322,11 @@ disassemble(const void* func, llvm::raw_ostream  Out)
/*
 * Print the instruction.
 */
 +#if HAVE_LLVM = 0x0307
 +  Printer-printInst(Inst, Out, , *STI);
 +#else
Printer-printInst(Inst, Out, );
 +#endif
  
/*
 * Advance.
 -- 
 2.1.0
 
 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 3/3] gallium: Add tgsi_to_nir to get a nir_shader for a TGSI shader.

2015-03-27 Thread Kenneth Graunke
On Friday, March 27, 2015 01:54:32 PM Eric Anholt wrote:
 This will be used by the VC4 driver for doing device-independent
 optimization, and hopefully eventually replacing its whole IR.  It also
 may be useful to other drivers for the same reason.
 
 v2: Add all of the instructions I was relying on tgsi_lowering to remove,
 and more.
 v3: Rebase on SSA rework of the builder.
 v4: Use the NIR ineg operation instead of doing a src modifier.
 v5: Don't use ineg for fnegs.  (infer_src_type on MOV doesn't do what I
 expect, again).
 v6: Fix handling of multi-channel KILL_IF sources.
 v7: Make ttn_get_f() return a swizzle of a scalar load_const, rather than
 a vector load_const.  CSE doesn't recognize that srcs out of those
 channels are actually all the same.
 v8: Rebase on nir_builder auto-sizing, make the scalar arguments to
 non-ALU instructions actually be scalars.
 v9: Add support for if/loop instructions, additional texture targets, and
 untested support for indirect addressing on temps.
 v10: Rebase on master, drop bad comment about control flow and just choose
  the X channel, use int comparison opcodes in LIT for now, drop unused
  pipe_context argument..
 v11: Fix translation of LRP (previously missed because I mis-translated
  back out), use nir_builder init helpers.
 v12: Rebase on master, adding explicit include of mtypes.h to get
  INTERP_QUALIFIER_*
 v13: Rebase on variables being in lists instead of hash tables, drop use
  of mtypes.h in favor of util/pipeline.h.  Use Ken's nir_builder
  swizzle and fmov/imov_alu helpers, drop struct in front of
  nir_builder, use nir_builder directly as the function arg in a lot of
  cases, drop redundant members of ttn_compile that are also in
  nir_builder, drop some half-baked malloc failure handling.
 ---
 
 This series is present as part of my vc4-nir-rebase-qir-2 branch.  The
 shader-db results across the branch are:
 
 total uniforms in shared programs: 13433 - 13434 (0.01%)
 uniforms in affected programs: 62 - 63 (1.61%)
 total instructions in shared programs: 40003 - 39794 (-0.52%)
 instructions in affected programs: 15494 - 15285 (-1.35%)
 
 I don't get to delete my driver's optimization code in that branch
 yet, notably because of optimization available in the programmable
 blending I have to generate.

Hi Eric!

I have a bunch of comments below, but overall this looks great.

You should probably have someone who knows TGSI better than I do review
it, but for what it's worth, this is:

Reviewed-by: Kenneth Graunke kenn...@whitecape.org

 
  src/gallium/auxiliary/Makefile.sources  |1 +
  src/gallium/auxiliary/nir/tgsi_to_nir.c | 1425 
+++
  src/gallium/auxiliary/nir/tgsi_to_nir.h |   30 +
  3 files changed, 1456 insertions(+)
  create mode 100644 src/gallium/auxiliary/nir/tgsi_to_nir.c
  create mode 100644 src/gallium/auxiliary/nir/tgsi_to_nir.h
 
 diff --git a/src/gallium/auxiliary/Makefile.sources 
b/src/gallium/auxiliary/Makefile.sources
 index 09496fa..08e4e4c 100644
 --- a/src/gallium/auxiliary/Makefile.sources
 +++ b/src/gallium/auxiliary/Makefile.sources
 @@ -69,6 +69,7 @@ C_SOURCES := \
   indices/u_indices_priv.h \
   indices/u_primconvert.c \
   indices/u_primconvert.h \
 + nir/tgsi_to_nir.c \
   os/os_memory_aligned.h \
   os/os_memory_debug.h \
   os/os_memory_stdc.h \
 diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c 
b/src/gallium/auxiliary/nir/tgsi_to_nir.c
 new file mode 100644
 index 000..e8cf9f4
 --- /dev/null
 +++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c
 @@ -0,0 +1,1425 @@
 +/*
 + * Copyright © 2014-2015 Broadcom
 + * Copyright (C) 2014 Rob Clark robcl...@freedesktop.org
 + *
 + * Permission is hereby granted, free of charge, to any person obtaining a
 + * copy of this software and associated documentation files (the 
Software),
 + * to deal in the Software without restriction, including without 
limitation
 + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 + * and/or sell copies of the Software, and to permit persons to whom the
 + * Software is furnished to do so, subject to the following conditions:
 + *
 + * The above copyright notice and this permission notice (including the 
next
 + * paragraph) shall be included in all copies or substantial portions of 
the
 + * Software.
 + *
 + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS 
OR
 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 
OTHER
 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
DEALINGS
 + * IN THE SOFTWARE.
 + */
 +
 +#include util/ralloc.h
 +#include glsl/nir/nir.h
 +#include glsl/nir/nir_builder.h
 

[Mesa-dev] [PATCH 1/1] gallivm: Fix build since llvm r233411

2015-03-27 Thread Jan Vesely
Signed-off-by: Jan Vesely jan.ves...@rutgers.edu
---
 src/gallium/auxiliary/gallivm/lp_bld_debug.cpp | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp 
b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
index bf6268b..d4d453d 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
+++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
@@ -322,7 +322,11 @@ disassemble(const void* func, llvm::raw_ostream  Out)
   /*
* Print the instruction.
*/
+#if HAVE_LLVM = 0x0307
+  Printer-printInst(Inst, Out, , *STI);
+#else
   Printer-printInst(Inst, Out, );
+#endif
 
   /*
* Advance.
-- 
2.1.0

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


Re: [Mesa-dev] [PATCH 5/8] nir: Add addition/multiplication identities of exp/log.

2015-03-27 Thread Matt Turner
On Fri, Mar 27, 2015 at 11:56 AM, Eric Anholt e...@anholt.net wrote:
 Matt Turner matts...@gmail.com writes:

 instructions in affected programs: 2858 - 2808 (-1.75%)
 helped:12
 ---
  src/glsl/nir/nir_opt_algebraic.py | 8 
  1 file changed, 8 insertions(+)

 diff --git a/src/glsl/nir/nir_opt_algebraic.py 
 b/src/glsl/nir/nir_opt_algebraic.py
 index 6730408..34a401a 100644
 --- a/src/glsl/nir/nir_opt_algebraic.py
 +++ b/src/glsl/nir/nir_opt_algebraic.py
 @@ -149,6 +149,14 @@ optimizations = [
 (('flog', ('frsq', a)), ('fmul', -0.5, ('flog', a))),
 (('flog2', ('fpow', a, b)), ('fmul', b, ('flog2', a))),
 (('flog', ('fpow', a, b)), ('fmul', b, ('flog', a))),
 +   (('fadd', ('flog2', a), ('flog2', b)), ('flog2', ('fmul', a, b))),
 +   (('fadd', ('flog', a), ('flog', b)), ('flog', ('fmul', a, b))),
 +   (('fadd', ('flog2', a), ('fneg', ('flog2', b))), ('flog2', ('fdiv', a, 
 b))),
 +   (('fadd', ('flog', a), ('fneg', ('flog', b))), ('flog', ('fdiv', a, b))),

 +   (('fmul', ('fexp2', a), ('fexp2', a)), ('fmul', 2.0, ('fexp2', a))),
 +   (('fmul', ('fexp', a), ('fexp', a)), ('fmul', 2.0, ('fexp', a))),


 e^a * e^a - 2 * e^a?  This doesn't seem right.  And something specific
 to this doesn't seem particularly better than the general case below.

Whoops. That was supposed to be e^a * e^a = e^2a.

When I added the two patterns below, I hit a case where they were
increasing instruction counts because 'a' was the same expression as
'b' but upon removing the two patterns above I can't find it.

I'll just remove them.

Thanks!

 +   (('fmul', ('fexp2', a), ('fexp2', b)), ('fexp2', ('fadd', a, b))),
 +   (('fmul', ('fexp', a), ('fexp', b)), ('fexp', ('fadd', a, b))),
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 06/16] glsl: fix assignment of multiple scalar and vecs to matrices.

2015-03-27 Thread Ben Widawsky
On Thu, Dec 11, 2014 at 11:34:12PM +0100, Eduardo Lima Mitev wrote:
 From: Samuel Iglesias Gonsalvez sigles...@igalia.com
 
 When a vec has more elements than row components in a matrix, the
 code could end up failing an assert inside assign_to_matrix_column().
 
 This patch makes sure that when there is still room in the matrix for
 more elements (but in other columns of the matrix), the data is actually
 assigned.

I wonder where the issue is addressed that you may have more elements than there
is space. The algorithm below doesn't write to invalid locations, but the
problem exists.

 
 This patch fixes the following dEQP test:
 
   
 dEQP-GLES3.functional.shaders.conversions.matrix_combine.float_bvec4_ivec2_bool_to_mat4x2_vertex
 
 No piglit regressions observed
 
 Signed-off-by: Samuel Iglesias Gonsalvez sigles...@igalia.com
 ---
  src/glsl/ast_function.cpp | 121 
 ++
  1 file changed, 68 insertions(+), 53 deletions(-)
 
 diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp
 index cbff9d8..451e3be 100644
 --- a/src/glsl/ast_function.cpp
 +++ b/src/glsl/ast_function.cpp
 @@ -1334,67 +1334,82 @@ emit_inline_matrix_constructor(const glsl_type *type,
unsigned row_idx = 0;
  
foreach_in_list(ir_rvalue, rhs, parameters) {
 -  const unsigned components_remaining_this_column = rows - row_idx;
 +  unsigned components_remaining_this_column;
unsigned rhs_components = rhs-type-components();
unsigned rhs_base = 0;

You may as well fix the whitespace here too.

  
 -  /* Since the parameter might be used in the RHS of two assignments,
 -   * generate a temporary and copy the paramter there.
 -   */
 -  ir_variable *rhs_var =
 - new(ctx) ir_variable(rhs-type, mat_ctor_vec, ir_var_temporary);
 -  instructions-push_tail(rhs_var);
 -
 -  ir_dereference *rhs_var_ref =
 - new(ctx) ir_dereference_variable(rhs_var);
 -  ir_instruction *inst = new(ctx) ir_assignment(rhs_var_ref, rhs, NULL);
 -  instructions-push_tail(inst);
 -
 -  /* Assign the current parameter to as many components of the matrix
 -   * as it will fill.
 -   *
 -   * NOTE: A single vector parameter can span two matrix columns.  A
 -   * single vec4, for example, can completely fill a mat2.
 -   */
 -  if (rhs_components = components_remaining_this_column) {
 - const unsigned count = MIN2(rhs_components,
 - components_remaining_this_column);
 -

In the old code... if a = b, then the MIN is just b, right? 

 - rhs_var_ref = new(ctx) ir_dereference_variable(rhs_var);
 -
 - ir_instruction *inst = assign_to_matrix_column(var, col_idx,
 -row_idx,
 -rhs_var_ref, 0,
 -count, ctx);
 - instructions-push_tail(inst);
 -
 - rhs_base = count;
 + /* Since the parameter might be used in the RHS of two assignments,
 +  * generate a temporary and copy the paramter there.
 +  */
 + ir_variable *rhs_var =
 +new(ctx) ir_variable(rhs-type, mat_ctor_vec, 
 ir_var_temporary);
 + instructions-push_tail(rhs_var);
 +
 + ir_dereference *rhs_var_ref =
 +new(ctx) ir_dereference_variable(rhs_var);
 + ir_instruction *inst = new(ctx) ir_assignment(rhs_var_ref, rhs, 
 NULL);
 + instructions-push_tail(inst);
 +
 + do {
 +components_remaining_this_column = rows - row_idx;
 +/* Assign the current parameter to as many components of the 
 matrix
 + * as it will fill.
 + *
 + * NOTE: A single vector parameter can span two matrix columns.  
 A
 + * single vec4, for example, can completely fill a mat2.
 + */
 +if (components_remaining_this_column  0 
 +(rhs_components - rhs_base) = 
 components_remaining_this_column) {
 +   const unsigned count = MIN2(rhs_components - rhs_base,
 +   components_remaining_this_column);

With the realization from the original, this too, isn't it just
components_remaining_this_column? That allows you to kill the count variable and
make the code a bit simpler (IMO). But instead...

I may be misunderstanding how the code is supported to work, but it looks to me
like the loop you added for assigning extra elements (rhs_components) belongs
here. As I understand it, the code is filling up space a row at a time, and then
moving over to the next column. It seems like if you add the do while loop, you
could get rid of the next if entirely - even the fist 'if' becomes just your
do_while loop.

Overgeneralized version in my head...
foreach_in_list {
i = 0;
do {
mat[col % 

[Mesa-dev] [PATCH] nir: Fix copy and pasted error message in nir_validate.

2015-03-27 Thread Kenneth Graunke
These are nir_cf_nodes, not ALU instructions.
Also, use unreachable() to preempt said review feedback.

Signed-off-by: Kenneth Graunke kenn...@whitecape.org
---
 src/glsl/nir/nir_validate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/glsl/nir/nir_validate.c b/src/glsl/nir/nir_validate.c
index f247ae0..79c23db 100644
--- a/src/glsl/nir/nir_validate.c
+++ b/src/glsl/nir/nir_validate.c
@@ -680,7 +680,7 @@ validate_cf_node(nir_cf_node *node, validate_state *state)
   break;
 
default:
-  assert(!Invalid ALU instruction type);
+  unreachable(!Invalid CF node type);
   break;
}
 }
-- 
2.3.4

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


Re: [Mesa-dev] [PATCH] glsl: support unsigned increment in ir_loop controls

2015-03-27 Thread Ilia Mirkin
On Wed, Aug 6, 2014 at 10:46 AM, Ian Romanick i...@freedesktop.org wrote:
 On 07/30/2014 04:11 AM, Tapani Pälli wrote:
 Current version can create ir_expression where operands have
 different base type, patch adds support for unsigned type.

 Signed-off-by: Tapani Pälli tapani.pa...@intel.com
 https://bugs.freedesktop.org/show_bug.cgi?id=80880
 ---
  src/glsl/loop_controls.cpp | 18 +++---
  1 file changed, 15 insertions(+), 3 deletions(-)

 diff --git a/src/glsl/loop_controls.cpp b/src/glsl/loop_controls.cpp
 index 36b49eb..419f9c1 100644
 --- a/src/glsl/loop_controls.cpp
 +++ b/src/glsl/loop_controls.cpp
 @@ -123,9 +123,21 @@ calculate_iterations(ir_rvalue *from, ir_rvalue *to, 
 ir_rvalue *increment,
 bool valid_loop = false;

 for (unsigned i = 0; i  Elements(bias); i++) {
 -  iter = (increment-type-is_integer())
 -  ? new(mem_ctx) ir_constant(iter_value + bias[i])
 -  : new(mem_ctx) ir_constant(float(iter_value + bias[i]));
 +
 +  /* Increment may be of type int, uint or float. */
 +  switch (increment-type-base_type) {
 +  case GLSL_TYPE_INT:
 + iter = new(mem_ctx) ir_constant(iter_value + bias[i]);
 + break;
 +  case GLSL_TYPE_UINT:
 + iter = new(mem_ctx) ir_constant(unsigned(iter_value + bias[i]));
 + break;
 +  case GLSL_TYPE_FLOAT:
 + iter = new(mem_ctx) ir_constant(float(iter_value + bias[i]));
 + break;
 +  default:
 +  assert(!Unsupported type for loop iterator.);

 Right... because this code was written when we only had int and
 float types.

 Two things:

   - Use spaces instead of tabs.  It looks like the surrounding code
 uses tabs, and that's my fault.  We're trying to fix that in new
 code.

   - Change the assert to unreachable(Unsupported type for loop iterator.)

Tapani, looks like you made this unreachable(!...), which is wrong.
See the unreachable macro. You don't want the ! in there.

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


Re: [Mesa-dev] [PATCH 31/41] i965/fs: Use instruction execution sizes to set compression state

2015-03-27 Thread Ilia Mirkin
On Tue, Sep 23, 2014 at 2:14 PM, Matt Turner matts...@gmail.com wrote:
 On Sat, Sep 20, 2014 at 10:23 AM, Jason Ekstrand ja...@jlekstrand.net wrote:
 Signed-off-by: Jason Ekstrand jason.ekstr...@intel.com
 ---
  src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 23 ++-
  1 file changed, 18 insertions(+), 5 deletions(-)

 diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp 
 b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
 index f20a4a7..00cf3ec 100644
 --- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
 +++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
 @@ -1536,12 +1536,25 @@ fs_generator::generate_code(const cfg_t *cfg)
brw_set_default_mask_control(p, inst-force_writemask_all);
brw_set_default_acc_write_control(p, inst-writes_accumulator);

 -  if (inst-force_uncompressed || dispatch_width == 8) {
 +  switch (inst-exec_size) {
 +  case 1:
 +  case 2:
 +  case 4:
 + assert(inst-force_writemask_all);
  brw_set_default_compression_control(p, BRW_COMPRESSION_NONE);
 -  } else if (inst-force_sechalf) {
 -brw_set_default_compression_control(p, BRW_COMPRESSION_2NDHALF);
 -  } else {
 -brw_set_default_compression_control(p, BRW_COMPRESSION_COMPRESSED);
 + break;
 +  case 8:
 + if (inst-force_sechalf) {
 +brw_set_default_compression_control(p, BRW_COMPRESSION_2NDHALF);
 + } else {
 +   brw_set_default_compression_control(p, BRW_COMPRESSION_NONE);

 Indentation is off here, or in the block above.

 + }
 + break;
 +  case 16:
 + brw_set_default_compression_control(p, BRW_COMPRESSION_COMPRESSED);
 + break;
 +  default:
 + assert(!Invalid instruction width);

 unreachable.

Jason,

I see that you took this suggestion, however you forgot to flip the
condition. unreachable() just takes a string, not a condition. You
need to remove the ! in there.

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


[Mesa-dev] [PATCH 1/3] glsl: Factor out a get_mul_type() function.

2015-03-27 Thread Matt Turner
---
 src/glsl/ast_to_hir.cpp | 62 -
 src/glsl/glsl_types.cpp | 67 +
 src/glsl/glsl_types.h   |  6 +
 3 files changed, 78 insertions(+), 57 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 036ec17..7836936 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -375,66 +375,14 @@ arithmetic_result_type(ir_rvalue * value_a, ir_rvalue * 
value_b,
   if (type_a == type_b)
  return type_a;
} else {
-  if (type_a-is_matrix()  type_b-is_matrix()) {
- /* Matrix multiply.  The columns of A must match the rows of B.  Given
-  * the other previously tested constraints, this means the vector type
-  * of a row from A must be the same as the vector type of a column 
from
-  * B.
-  */
- if (type_a-row_type() == type_b-column_type()) {
-/* The resulting matrix has the number of columns of matrix B and
- * the number of rows of matrix A.  We get the row count of A by
- * looking at the size of a vector that makes up a column.  The
- * transpose (size of a row) is done for B.
- */
-const glsl_type *const type =
-   glsl_type::get_instance(type_a-base_type,
-   type_a-column_type()-vector_elements,
-   type_b-row_type()-vector_elements);
-assert(type != glsl_type::error_type);
+  const glsl_type *type = glsl_type::get_mul_type(type_a, type_b);
 
-return type;
- }
-  } else if (type_a-is_matrix()) {
- /* A is a matrix and B is a column vector.  Columns of A must match
-  * rows of B.  Given the other previously tested constraints, this
-  * means the vector type of a row from A must be the same as the
-  * vector the type of B.
-  */
- if (type_a-row_type() == type_b) {
-/* The resulting vector has a number of elements equal to
- * the number of rows of matrix A. */
-const glsl_type *const type =
-   glsl_type::get_instance(type_a-base_type,
-   type_a-column_type()-vector_elements,
-   1);
-assert(type != glsl_type::error_type);
-
-return type;
- }
-  } else {
- assert(type_b-is_matrix());
-
- /* A is a row vector and B is a matrix.  Columns of A must match rows
-  * of B.  Given the other previously tested constraints, this means
-  * the type of A must be the same as the vector type of a column from
-  * B.
-  */
- if (type_a == type_b-column_type()) {
-/* The resulting vector has a number of elements equal to
- * the number of columns of matrix B. */
-const glsl_type *const type =
-   glsl_type::get_instance(type_a-base_type,
-   type_b-row_type()-vector_elements,
-   1);
-assert(type != glsl_type::error_type);
-
-return type;
- }
+  if (type == glsl_type::error_type) {
+ _mesa_glsl_error(loc, state,
+  size mismatch for matrix multiplication);
   }
 
-  _mesa_glsl_error(loc, state, size mismatch for matrix multiplication);
-  return glsl_type::error_type;
+  return type;
}
 
 
diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
index be87b0a..4aa36a7 100644
--- a/src/glsl/glsl_types.cpp
+++ b/src/glsl/glsl_types.cpp
@@ -825,6 +825,73 @@ glsl_type::get_interface_instance(const glsl_struct_field 
*fields,
 
 
 const glsl_type *
+glsl_type::get_mul_type(const glsl_type *type_a, const glsl_type *type_b)
+{
+   if (type_a == type_b) {
+  return type_a;
+   } else if (type_a-is_matrix()  type_b-is_matrix()) {
+  /* Matrix multiply.  The columns of A must match the rows of B.  Given
+   * the other previously tested constraints, this means the vector type
+   * of a row from A must be the same as the vector type of a column from
+   * B.
+   */
+  if (type_a-row_type() == type_b-column_type()) {
+ /* The resulting matrix has the number of columns of matrix B and
+  * the number of rows of matrix A.  We get the row count of A by
+  * looking at the size of a vector that makes up a column.  The
+  * transpose (size of a row) is done for B.
+  */
+ const glsl_type *const type =
+get_instance(type_a-base_type,
+ type_a-column_type()-vector_elements,
+ type_b-row_type()-vector_elements);
+ assert(type != error_type);
+
+ return type;
+  }
+   } else if (type_a-is_matrix()) {
+  /* A is a matrix and B is 

[Mesa-dev] [PATCH 2/3] glsl: Implement type inferencing of matrix types.

2015-03-27 Thread Matt Turner
---
 src/glsl/ir.cpp | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index 54656f8..4b8ca9b 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -380,10 +380,12 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, 
ir_rvalue *op1)
   } else if (op1-type-is_scalar()) {
 this-type = op0-type;
   } else {
-/* FINISHME: matrix types */
-assert(!op0-type-is_matrix()  !op1-type-is_matrix());
-assert(op0-type == op1-type);
-this-type = op0-type;
+ if (this-operation == ir_binop_mul) {
+this-type = glsl_type::get_mul_type(op0-type, op1-type);
+ } else {
+assert(op0-type == op1-type);
+this-type = op0-type;
+ }
   }
   break;
 
-- 
2.0.5

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


[Mesa-dev] [PATCH 3/3] glsl: Reassociate multiplication of mat*mat*vec.

2015-03-27 Thread Matt Turner
The typical case of mat4*mat4*vec4 is 80 scalar multiplications, but
mat4*(mat4*vec4) is only 32.

On HSW (with vec4 vertex shaders):
instructions in affected programs: 4420 - 3194 (-27.74%)

On BDW (with scalar vertex shaders):
instructions in affected programs: 12756 - 6726 (-47.27%)

Implementing a general matrix chain ordering is harder (or at least
tedious) because of having to walk the GLSL IR to create a list of
multiplicands. I'm guessing that this patch handles 90+% of cases, but
of course to tell definitively you'd have to implement the general
thing.
---
 src/glsl/opt_algebraic.cpp | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
index 98c852a..a940d2f 100644
--- a/src/glsl/opt_algebraic.cpp
+++ b/src/glsl/opt_algebraic.cpp
@@ -290,6 +290,20 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
ir_expression *op_expr[4] = {NULL, NULL, NULL, NULL};
unsigned int i;
 
+   if (ir-operation == ir_binop_mul 
+   ir-operands[0]-type-is_matrix() 
+   ir-operands[1]-type-is_vector()) {
+  ir_expression *matrix_mul = ir-operands[0]-as_expression();
+
+  if (matrix_mul  matrix_mul-operation == ir_binop_mul 
+ matrix_mul-operands[0]-type-is_matrix() 
+ matrix_mul-operands[1]-type-is_matrix()) {
+
+ return mul(matrix_mul-operands[0],
+mul(matrix_mul-operands[1], ir-operands[1]));
+  }
+   }
+
assert(ir-get_num_operands() = 4);
for (i = 0; i  ir-get_num_operands(); i++) {
   if (ir-operands[i]-type-is_matrix())
-- 
2.0.5

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


Re: [Mesa-dev] [PATCH] nir: Fix copy and pasted error message in nir_validate.

2015-03-27 Thread Ilia Mirkin
On Sat, Mar 28, 2015 at 12:23 AM, Kenneth Graunke kenn...@whitecape.org wrote:
 These are nir_cf_nodes, not ALU instructions.
 Also, use unreachable() to preempt said review feedback.

 Signed-off-by: Kenneth Graunke kenn...@whitecape.org
 ---
  src/glsl/nir/nir_validate.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/src/glsl/nir/nir_validate.c b/src/glsl/nir/nir_validate.c
 index f247ae0..79c23db 100644
 --- a/src/glsl/nir/nir_validate.c
 +++ b/src/glsl/nir/nir_validate.c
 @@ -680,7 +680,7 @@ validate_cf_node(nir_cf_node *node, validate_state *state)
break;

 default:
 -  assert(!Invalid ALU instruction type);
 +  unreachable(!Invalid CF node type);

unreachable just takes a str, not a condition passed through to an assert.

break;

should probably remove the break while you're at it.

 }
  }
 --
 2.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