Re: [Mesa-dev] glsl: optimize list handling in opt_dead_code

2016-10-18 Thread Maciej Cencora
On wtorek, 18 października 2016 00:07:18 CEST Jan Ziak wrote:
> This patch replaces the ir_variable_refcount_entry's linked-list
> with an array-list.
>
> The array-list has local storage which does not require ANY additional
> allocations if the list has small number of elements. The size of this
> storage is configurable for each variable.
>
> Benchmark results for "./run -1 shaders" from shader-db[1]:
>
> - The total number of executed instructions goes down from 64.184 to
63.797
>   giga-instructions when Mesa is compiled with "gcc -O0 ..."

Hi,

A total number of instructions in -O0 is not a good indicator of whether
this change is beneficial from performance POV.
You should check it with -O2 or whatever is the default in mesa release
builds.

> - In the call tree starting at function do_dead_code():
>   - the number of calls to malloc() is reduced by about 10%
>   - the number of calls to free() is reduced by about 30%

These are certainly a win.

>
> [1] git://anongit.freedesktop.org/mesa/shader-db
>
> Signed-off-by: Jan Ziak (http://atom-symbol.net) <0xe2.0x9a.0...@gmail.com
>
> ---
>  src/compiler/glsl/ir_variable_refcount.cpp |  14 +--
>  src/compiler/glsl/ir_variable_refcount.h   |   8 +-
>  src/compiler/glsl/opt_dead_code.cpp|  19 ++--
>  src/util/fast_list.h   | 167
+
>  4 files changed, 176 insertions(+), 32 deletions(-)
>
> diff --git a/src/compiler/glsl/ir_variable_refcount.cpp
b/src/compiler/glsl/ir_variable_refcount.cpp
> index 8306be1..94d6edc 100644
> --- a/src/compiler/glsl/ir_variable_refcount.cpp
> +++ b/src/compiler/glsl/ir_variable_refcount.cpp
> @@ -46,15 +46,6 @@ static void
>  free_entry(struct hash_entry *entry)
>  {
> ir_variable_refcount_entry *ivre = (ir_variable_refcount_entry *)
entry->data;
> -
> -   /* Free assignment list */
> -   exec_node *n;
> -   while ((n = ivre->assign_list.pop_head()) != NULL) {
> -  struct assignment_entry *assignment_entry =
> - exec_node_data(struct assignment_entry, n, link);
> -  free(assignment_entry);
> -   }
> -
> delete ivre;
>  }
>
> @@ -142,10 +133,7 @@
ir_variable_refcount_visitor::visit_leave(ir_assignment *ir)
> */
>assert(entry->referenced_count >= entry->assigned_count);
>if (entry->referenced_count == entry->assigned_count) {
> - struct assignment_entry *assignment_entry =
> -(struct assignment_entry *)calloc(1,
sizeof(*assignment_entry));
> - assignment_entry->assign = ir;
> - entry->assign_list.push_head(_entry->link);
> + entry->assign_list.add(ir);
>}
> }
>
> diff --git a/src/compiler/glsl/ir_variable_refcount.h
b/src/compiler/glsl/ir_variable_refcount.h
> index 08a11c0..c3ec5fe 100644
> --- a/src/compiler/glsl/ir_variable_refcount.h
> +++ b/src/compiler/glsl/ir_variable_refcount.h
> @@ -32,11 +32,7 @@
>  #include "ir.h"
>  #include "ir_visitor.h"
>  #include "compiler/glsl_types.h"
> -
> -struct assignment_entry {
> -   exec_node link;
> -   ir_assignment *assign;
> -};
> +#include "util/fast_list.h"
>
>  class ir_variable_refcount_entry
>  {
> @@ -50,7 +46,7 @@ public:
>  * This is intended to be used for dead code optimisation and may
>  * not be a complete list.
>  */
> -   exec_list assign_list;
> +   arraylist assign_list;
>
> /** Number of times the variable is referenced, including
assignments. */
> unsigned referenced_count;
> diff --git a/src/compiler/glsl/opt_dead_code.cpp
b/src/compiler/glsl/opt_dead_code.cpp
> index 75e668a..06e8c3d 100644
> --- a/src/compiler/glsl/opt_dead_code.cpp
> +++ b/src/compiler/glsl/opt_dead_code.cpp
> @@ -52,7 +52,7 @@ do_dead_code(exec_list *instructions, bool
uniform_locations_assigned)
>
> struct hash_entry *e;
> hash_table_foreach(v.ht, e) {
> -  ir_variable_refcount_entry *entry = (ir_variable_refcount_entry
*)e->data;
> +  ir_variable_refcount_entry *const entry =
(ir_variable_refcount_entry *)e->data;
>
>/* Since each assignment is a reference, the refereneced count
must be
> * greater than or equal to the assignment count.  If they are
equal,
> @@ -89,7 +89,7 @@ do_dead_code(exec_list *instructions, bool
uniform_locations_assigned)
>if (entry->var->data.always_active_io)
>   continue;
>
> -  if (!entry->assign_list.is_empty()) {
> +  if (!entry->assign_list.empty()) {
>   /* Remove all the dead assignments to the variable we found.
>* Don't do so if it's a shader or function output, though.
>*/
> @@ -98,26 +98,19 @@ do_dead_code(exec_list *instructions, bool
uniform_locations_assigned)
>   entry->var->data.mode != ir_var_shader_out &&
>   entry->var->data.mode != ir_var_shader_storage) {
>
> -while (!entry->assign_list.is_empty()) {
> -   struct assignment_entry *assignment_entry =
> -  exec_node_data(struct assignment_entry,
> -  

Re: [Mesa-dev] 7.8 patches from master

2010-08-03 Thread Maciej Cencora
Dnia wtorek 03 sierpnia 2010 o 18:23:37 Alex Deucher napisał(a):
 On Tue, Aug 3, 2010 at 12:21 PM, Alex Deucher alexdeuc...@gmail.com wrote:
  On Tue, Aug 3, 2010 at 10:41 AM, Henri Verbeet hverb...@gmail.com wrote:
  On 3 August 2010 15:52, Brian Paul bri...@vmware.com wrote:
  Axes, Henri and Macij should double-check their patches but I'm OK with
  the
  
  If that's a64b14fdcfdc045e027c4d81e0add1a85e381619 and
  b132401075bd9c358c30211a0b364699ab6f7463, I think those should be safe
  enough. Note that passing -x to git cherry-pick will mention the
  commit something was cherry picked from in the commit log.
  
  As for other commits, 2fdff50999825f5698f1f7f88565162f39227b2f,
  7ba75d11cff09642f8c3133ec39382b25adb8711 and
  85af7dcd0e4d33ac85b15cb522d6949686674e27 should be safe as well, but I
  guess it depends on how Alex feels about those.
  
  Most of these commit ids are invalid.  Maybe local commits?
  
  Here's my rough list for 7.8:
  fef9b532cd1631cc53056b9eba4369d1310b88df
  eb4dc547885994cc7961f7996c33ff484f664964
  04a148629f565f556d0b6e7465f8a19921eed7af
  12172071b5f5cb7f475a20ead8a65eb12fa94737
  1f7bc87391bc42eb9003020b7654e985494c6e61
  1ec492a366e236569dc68f4de32e641c88cbcd63
  1bf75a921bcd11dfdc389f490081d83ab536fc58
  8744c36ea4f32124e91d26cab2bb76529f6eecf1
  5552dffa39d1401d20df4696540f5de2e8c852ea
  71646528da5355468be8b52be662d0afd49a38f1
  51c438feb765cf03d1a6448295e6c62be61a5e56
  2bd69080a229fb81685234a08922dffbcecdfe95
  2fdff50999825f5698f1f7f88565162f39227b2f
  ad24ea37bb0cef7b383bb38e31466b6bb1f7fce6
  72e6a1e72f21653295165320fbca6961eddc9eb3
  ba03a0b5ba73bc8e79d0ffa6d1da623544716f74
  0a7803cbaca13033d9ed31ef33f59efa913fbfce
  646d2e9fbc41bf49075013009e9583bec4a51168
  9b3bf392e1af72d29afa0804260cac4d8ffe24e1
 
 Plus, the following which are already in your tree:
 a88dd2d39a0603e222aca5f5f6eb92db9c1ac77d
 61122b526c06a814537cdf58bd0136c7b5085f25
 cca4468100eb6a942aa128c5f27f6637b3828d61
 
  This one needs to go in as well, but it touches some files that are
  not available in the 7.8 branch; however, those parts of the patch can
  be ignored for 7.8.
  d6a5f94ea4d03b05c434fcad125d1f9c50c638e8
  
  Alex

Hi,

Ack for all my patches on the list plus these:
452a7d5a9d339db3326f33d464dce1a879ccc533
ba196a8318af6217fece3777ea038539fea4b415
addedd091e81907837b3aa0680b242b8fdbde7ef

and these two but they have to go together:
a68e8a4eaadfe2a1e4999d5e378c7d9fa99dc656 
1a8a230a61289392e8300901dfabd7911799cbc3

Regards,
Maciej Cencora


 
 ___

 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 1/2] Skip fbo readdrawpix and copypix tests if EXT_framebuffer_blit isn't available

2010-07-16 Thread Maciej Cencora

Signed-off-by: Maciej Cencora m.cenc...@gmail.com
---
 tests/fbo/fbo-copypix.c |1 +
 tests/fbo/fbo-readdrawpix.c |1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/tests/fbo/fbo-copypix.c b/tests/fbo/fbo-copypix.c
index ac6547d..362459b 100644
--- a/tests/fbo/fbo-copypix.c
+++ b/tests/fbo/fbo-copypix.c
@@ -228,4 +228,5 @@ piglit_init(int argc, char **argv)
piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
 
piglit_require_extension(GL_EXT_framebuffer_object);
+   piglit_require_extension(GL_EXT_framebuffer_blit);
 }
diff --git a/tests/fbo/fbo-readdrawpix.c b/tests/fbo/fbo-readdrawpix.c
index af2be79..15d8521 100644
--- a/tests/fbo/fbo-readdrawpix.c
+++ b/tests/fbo/fbo-readdrawpix.c
@@ -231,4 +231,5 @@ piglit_init(int argc, char **argv)
piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
 
piglit_require_extension(GL_EXT_framebuffer_object);
+   piglit_require_extension(GL_EXT_framebuffer_blit);
 }
-- 
1.7.0.4


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


[Mesa-dev] [PATCH 2/2] Add one ignore string

2010-07-16 Thread Maciej Cencora
Signed-off-by: Maciej Cencora m.cenc...@gmail.com
---
 tests/all.tests |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/tests/all.tests b/tests/all.tests
index 4a7bff0..a3bc15f 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -923,4 +923,5 @@ Test.ignoreErrors.append(re.compile(Mesa: User 
error:.*))
 Test.ignoreErrors.append(re.compile(Mesa: Initializing .* optimizations))
 Test.ignoreErrors.append(re.compile(debug_get_.*))
 Test.ignoreErrors.append(re.compile(util_cpu_caps.*))
+Test.ignoreErrors.append(re.compile(Mesa: 3Dnow! detected))
 
-- 
1.7.0.4

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


[Mesa-dev] Bug in _mesa_meta_GenerateMipmap

2010-07-11 Thread Maciej Cencora
Hi,

while working on failing piglit tests I've stumbled on a problem with 
_mesa_meta_GenerateMipmap. The function creates new texture images for lower 
mipmap levels, but during call to glTexImage the format and type are hardcoded 
to GL_RGBA and GL_UNSIGNED_BYTE respectivily. And that's where the problem 
arise because base image (the one that other levels are generated from) could 
have other format and type specified (in failing test texturing/gen-teximage 
these are GL_RGBA, GL_FLOAT).
The result is that for base image MESA_FORMAT_ARGB is chosen and for next 
levels it's MESA_FORMAT_RGBA_REV. Of course such texture with images of 
different formats is invalid and will be missampled by GPU.

As the fix is not straightforward for me (not sure where to get format and type 
from, since the gl_texture_image doesn't hold them) could someone more 
familiar with core mesa take a look at this?

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


Re: [Mesa-dev] Enable HW GenerateMipmap for radeon v2

2010-05-25 Thread Maciej Cencora
Dnia wtorek 25 maja 2010 o 07:10:18 Will Dyson napisał(a):
 Wire up _mesa_meta_GenerateMipmap() for radeon. This greatly improves the
 playability of some games, such as FlightGear and the recently GPL'd game
 Lugaru.
 
 FlightGear still generates many fallbacks due to Alpha-only textures, but
 only at startup time.
 
 V2:
 Address comments from Maciej Cencora m.cenc...@gmail.com.
 Fixed meta.h inclusion.
 Added comment where MaxLevel test is changed. Reword other comments.
 Provide an upper bound check for the image level.
 Don't gratuitiously move code around.
 
 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev

For the series:

Signed-off-by: Maciej Cencora m.cenc...@gmail.com
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 3/3] Enable hardware mipmap generation for radeon.

2010-05-22 Thread Maciej Cencora
Dnia wtorek 18 maja 2010 o 21:09:59 Will Dyson napisał(a):
 Use _mesa_meta_GenerateMipmap. It is Fast Enough(tm).
 ---
  src/mesa/drivers/dri/radeon/radeon_texture.c |   15 ++-
  1 files changed, 10 insertions(+), 5 deletions(-)
 
 diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c
 b/src/mesa/drivers/dri/radeon/radeon_texture.c index 6ceff88..3224731
 100644
 --- a/src/mesa/drivers/dri/radeon/radeon_texture.c
 +++ b/src/mesa/drivers/dri/radeon/radeon_texture.c
 @@ -244,15 +244,18 @@ void radeonUnmapTexture(GLcontext *ctx, struct
 gl_texture_object *texObj) static void radeon_generate_mipmap(GLcontext
 *ctx, GLenum target, struct gl_texture_object *texObj)
  {
 + int i;
 + GLuint face = _mesa_tex_target_to_face(target);
 + radeon_texture_image *baseimage =
 get_radeon_texture_image(texObj-Image[face][texObj-BaseLevel]);
 radeonTexObj* t = radeon_tex_obj(texObj);
   GLuint nr_faces = (t-base.Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
 - int i, face;
 
   radeon_print(RADEON_TEXTURE, RADEON_VERBOSE,
   %s(%p, tex %p) Target type %s.\n,
   __func__, ctx, texObj,
   _mesa_lookup_enum_by_nr(target));
 
 + radeon_teximage_map(baseimage, GL_FALSE);
   _mesa_generate_mipmap(ctx, target, texObj);
 
   for (face = 0; face  nr_faces; face++) {
 @@ -270,7 +273,7 @@ static void radeon_generate_mipmap(GLcontext *ctx,
 GLenum target, radeon_miptree_unreference(image-mt);
   }
   }
 -
 + radeon_teximage_unmap(baseimage);
  }
 
  void radeonGenerateMipmap(GLcontext* ctx, GLenum target, struct
 gl_texture_object *texObj) @@ -294,9 +297,11 @@ void
 radeonGenerateMipmap(GLcontext* ctx, GLenum target, struct
 gl_texture_objec radeon_firevertices(rmesa);
   }
 
 - radeon_teximage_map(baseimage, GL_FALSE);
 - radeon_generate_mipmap(ctx, target, texObj);
 - radeon_teximage_unmap(baseimage);
 + if (_mesa_meta_check_generate_mipmap_fallback(ctx, target, texObj)) {
 + radeon_generate_mipmap(ctx, target, texObj);
 + } else {
 + _mesa_meta_GenerateMipmap(ctx, target, texObj);
 + }
  }

You've forgot to include meta.h header.

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