Re: [Mesa-dev] [PATCH] i965: Use new/delete instead of realloc() in brw_ir_allocator.h

2015-02-11 Thread Francisco Jerez
Matt Turner matts...@gmail.com writes:

 On Wed, Feb 11, 2015 at 6:37 AM, Juha-Pekka Heikkila
 juhapekka.heikk...@gmail.com wrote:
 There is no error path available thus instead of giving
 realloc possibility to fail use new which will never
 return null pointer and throws bad_alloc on failure.

 The problem was that we weren't checking if realloc failed.

 Why is the solution to change from malloc/free to new/delete?

The new operator is guaranteed not to return NULL by the C++ standard.
Aside from that Juha-Pekka's code seems more idiomatic to me than
calling realloc() from a C++ source file, but that might just be a
matter of taste.

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


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


[Mesa-dev] [Bug 89068] glTexImage2D regression by texstore_rgba switch to _mesa_format_convert

2015-02-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=89068

--- Comment #6 from Brad King brad.k...@kitware.com ---
Thanks for taking a look!

I've just run a debug session with commit 1e02f2ba checked out.

 what GPU are you running on?

I'm building software-only:

 ./autogen.sh --prefix=... \
   --disable-dri --disable-egl --disable-shared-glapi \
   --enable-xlib-glx --enable-gallium-osmesa --with-gallium-drivers=swrast \
   --enable-gallium-llvm=yes LLVM_CONFIG=/usr/bin/llvm-config-3.3 \
   --enable-llvm-shared-libs --enable-debug

 a) the values of the parameters passed to compute_src2dst_component_mapping
 _after_ it has been called (they all are 4-element arrays, the last one is
 an out parameter so that is why I need the values after the call has been
 done)

(gdb) p src2rgba
$1 = \000\001\002\003
(gdb) p rgba2dst
$2 = \000\001\002\003
(gdb) p rebase_swizzle
$3 = (uint8_t *) 0x0
(gdb) p src2dst
$4 = \000\001\002\003

 b) The following input parameters for the call to _mesa_swizzle_and_convert
 right after: src_type, dst_type, dst_num_channels, src_num_channels,
 normalized, width.

$5 = MESA_ARRAY_FORMAT_TYPE_USHORT
(gdb) p src_num_channels
$6 = 4
(gdb) p dst_type
$7 = MESA_ARRAY_FORMAT_TYPE_UBYTE
(gdb) p dst_num_channels
$8 = 4
(gdb) p normalized
$9 = true
(gdb) p width
$10 = 256

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


Re: [Mesa-dev] [PATCH] gallium: add PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS

2015-02-11 Thread Brian Paul

On 02/11/2015 07:23 AM, Marek Olšák wrote:

From: Marek Olšák marek.ol...@amd.com

This is the same as the Mesa core setting.

This avoids a serious r600g bug.
Bugzilla:_https://bugs.freedesktop.org/show_bug.cgi?id=86720

Cc: 10.5 10.4 10.3 mesa-sta...@lists.freedesktop.org
---
  src/gallium/auxiliary/gallivm/lp_bld_limits.h| 2 ++
  src/gallium/auxiliary/tgsi/tgsi_exec.h   | 2 ++
  src/gallium/docs/source/screen.rst   | 4 
  src/gallium/drivers/freedreno/freedreno_screen.c | 2 ++
  src/gallium/drivers/i915/i915_screen.c   | 2 ++
  src/gallium/drivers/ilo/ilo_screen.c | 2 ++
  src/gallium/drivers/nouveau/nv30/nv30_screen.c   | 4 
  src/gallium/drivers/nouveau/nv50/nv50_screen.c   | 2 ++
  src/gallium/drivers/nouveau/nvc0/nvc0_screen.c   | 2 ++
  src/gallium/drivers/r300/r300_screen.c   | 4 
  src/gallium/drivers/r600/r600_pipe.c | 6 ++
  src/gallium/drivers/radeonsi/si_pipe.c   | 2 ++
  src/gallium/drivers/svga/svga_screen.c   | 4 
  src/gallium/drivers/vc4/vc4_screen.c | 2 ++
  src/gallium/include/pipe/p_defines.h | 3 ++-
  src/mesa/state_tracker/st_extensions.c   | 3 +++
  16 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_limits.h 
b/src/gallium/auxiliary/gallivm/lp_bld_limits.h
index 8c66f9d..7856006 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_limits.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_limits.h
@@ -128,6 +128,8 @@ gallivm_get_shader_param(enum pipe_shader_cap param)
return 1;
 case PIPE_SHADER_CAP_DOUBLES:
return 0;
+   case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS:
+  return 32;
 }
 /* if we get here, we missed a shader cap above (and should have seen
  * a compiler warning.)
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h 
b/src/gallium/auxiliary/tgsi/tgsi_exec.h
index cc5a916..56c8930 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h
@@ -457,6 +457,8 @@ tgsi_exec_get_shader_param(enum pipe_shader_cap param)
return 1;
 case PIPE_SHADER_CAP_DOUBLES:
return 0;
+   case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS:
+  return 32;
 }
 /* if we get here, we missed a shader cap above (and should have seen
  * a compiler warning.)
diff --git a/src/gallium/docs/source/screen.rst 
b/src/gallium/docs/source/screen.rst
index 5d80908..aa519d2 100644
--- a/src/gallium/docs/source/screen.rst
+++ b/src/gallium/docs/source/screen.rst
@@ -326,6 +326,10 @@ to be 0.
sampler views. Must not be lower than PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS.
  * ``PIPE_SHADER_CAP_DOUBLES``: Whether double precision floating-point
operations are supported.
+* ``PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS``: This is the maximum number of
+  iterations that loops are allowed to have to be unrolled. It is only
+  a hint to state trackers. Whether any loops will be unrolled is not
+  guaranteed.


  .. _pipe_compute_cap:
diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c 
b/src/gallium/drivers/freedreno/freedreno_screen.c
index 1ce96d3..90fd6f8 100644
--- a/src/gallium/drivers/freedreno/freedreno_screen.c
+++ b/src/gallium/drivers/freedreno/freedreno_screen.c
@@ -398,6 +398,8 @@ fd_screen_get_shader_param(struct pipe_screen *pscreen, 
unsigned shader,
return 16;
case PIPE_SHADER_CAP_PREFERRED_IR:
return PIPE_SHADER_IR_TGSI;
+   case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS:
+   return 32;
}
debug_printf(unknown shader param %d\n, param);
return 0;
diff --git a/src/gallium/drivers/i915/i915_screen.c 
b/src/gallium/drivers/i915/i915_screen.c
index 2dcb507..d2199a2 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -155,6 +155,8 @@ i915_get_shader_param(struct pipe_screen *screen, unsigned 
shader, enum pipe_sha
case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS:
   return I915_TEX_UNITS;
+  case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS:
+ return 32;
default:
   debug_printf(%s: Unknown cap %u.\n, __FUNCTION__, cap);
   return 0;
diff --git a/src/gallium/drivers/ilo/ilo_screen.c 
b/src/gallium/drivers/ilo/ilo_screen.c
index 04c1283..6e9e723 100644
--- a/src/gallium/drivers/ilo/ilo_screen.c
+++ b/src/gallium/drivers/ilo/ilo_screen.c
@@ -154,6 +154,8 @@ ilo_get_shader_param(struct pipe_screen *screen, unsigned 
shader,
return PIPE_SHADER_IR_TGSI;
 case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED:
return 1;
+   case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS:
+  return 32;

 default:
return 0;
diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c 
b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
index 83cae7a..9c183f2 100644
--- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
+++ 

[Mesa-dev] [PATCH 2/2] st/nine: Mark end of non-void function unreachable

2015-02-11 Thread Tobias Klausmann
Signed-off-by: Tobias Klausmann tobias.johannes.klausm...@mni.thm.de
---
 src/gallium/state_trackers/nine/nine_pipe.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/nine/nine_pipe.h 
b/src/gallium/state_trackers/nine/nine_pipe.h
index 17844d5..b8e728e 100644
--- a/src/gallium/state_trackers/nine/nine_pipe.h
+++ b/src/gallium/state_trackers/nine/nine_pipe.h
@@ -222,7 +222,7 @@ d3d9_get_pipe_depth_format_bindings(D3DFORMAT format)
 case D3DFMT_DF24:
 case D3DFMT_INTZ:
 return PIPE_BIND_DEPTH_STENCIL | PIPE_BIND_SAMPLER_VIEW;
-default: assert(0);
+default: unreachable(Unexpected format);
 }
 }
 
-- 
2.2.2

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


Re: [Mesa-dev] [PATCH] i965: Use new/delete instead of realloc() in brw_ir_allocator.h

2015-02-11 Thread Francisco Jerez
Juha-Pekka Heikkila juhapekka.heikk...@gmail.com writes:

 There is no error path available thus instead of giving
 realloc possibility to fail use new which will never
 return null pointer and throws bad_alloc on failure.

 Signed-off-by: Juha-Pekka Heikkila juhapekka.heikk...@gmail.com
 ---
  src/mesa/drivers/dri/i965/brw_ir_allocator.h | 16 
  1 file changed, 12 insertions(+), 4 deletions(-)

 diff --git a/src/mesa/drivers/dri/i965/brw_ir_allocator.h 
 b/src/mesa/drivers/dri/i965/brw_ir_allocator.h
 index b1237ed..5330bff 100644
 --- a/src/mesa/drivers/dri/i965/brw_ir_allocator.h
 +++ b/src/mesa/drivers/dri/i965/brw_ir_allocator.h
 @@ -40,8 +40,8 @@ namespace brw {
  
~simple_allocator()
{
 - free(offsets);
 - free(sizes);
 + delete[] offsets;
 + delete[] sizes;
}
  
unsigned
 @@ -49,8 +49,16 @@ namespace brw {
{
   if (capacity = count) {
  capacity = MAX2(16, capacity * 2);
 -sizes = (unsigned *)realloc(sizes, capacity * sizeof(unsigned));
 -offsets = (unsigned *)realloc(offsets, capacity * 
 sizeof(unsigned));
 +
 +unsigned *tmp_sizes = new unsigned[capacity];
 +memcpy(tmp_sizes, sizes, count * sizeof(unsigned));
 +delete[] sizes;
 +sizes = tmp_sizes;
 +
 +unsigned *tmp_offsets = new unsigned[capacity];
 +memcpy(tmp_offsets, offsets, count * sizeof(unsigned));
 +delete[] offsets;
 +offsets = tmp_offsets;
   }
  
   sizes[count] = size;
 -- 
 1.8.5.1

Looks OK to me,
Reviewed-by: Francisco Jerez curroje...@riseup.net


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


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


Re: [Mesa-dev] [PATCH] i965: Use new/delete instead of realloc() in brw_ir_allocator.h

2015-02-11 Thread Matt Turner
On Wed, Feb 11, 2015 at 6:37 AM, Juha-Pekka Heikkila
juhapekka.heikk...@gmail.com wrote:
 There is no error path available thus instead of giving
 realloc possibility to fail use new which will never
 return null pointer and throws bad_alloc on failure.

The problem was that we weren't checking if realloc failed.

Why is the solution to change from malloc/free to new/delete?
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] gallium: add PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS

2015-02-11 Thread Marek Olšák
I completely agree with you. Turning off the R600 optimizing Shader
Backend would also work, but the performance drop would be unpleasant.

Marek

On Wed, Feb 11, 2015 at 4:11 PM, Roland Scheidegger srol...@vmware.com wrote:
 I don't think this is a good idea. This pollutes the gallium interface
 (albeit in some rather minor way, but still) to just cover up a driver
 bug. It does not do anything to actually fix the root cause of the bug
 (presumably it would still just lock up if the loop would actually have
 256 iterations and hence still not get unrolled, and it's a hint only so
 even with less iterations you could still get such loops with other
 state trackers).
 Unless such a hint would be useful in general for drivers to set some
 limit for loop unrolling.

 Roland


 Am 11.02.2015 um 15:23 schrieb Marek Olšák:
 From: Marek Olšák marek.ol...@amd.com

 This is the same as the Mesa core setting.

 This avoids a serious r600g bug.
 Bugzilla:_https://bugs.freedesktop.org/show_bug.cgi?id=86720

 Cc: 10.5 10.4 10.3 mesa-sta...@lists.freedesktop.org
 ---
  src/gallium/auxiliary/gallivm/lp_bld_limits.h| 2 ++
  src/gallium/auxiliary/tgsi/tgsi_exec.h   | 2 ++
  src/gallium/docs/source/screen.rst   | 4 
  src/gallium/drivers/freedreno/freedreno_screen.c | 2 ++
  src/gallium/drivers/i915/i915_screen.c   | 2 ++
  src/gallium/drivers/ilo/ilo_screen.c | 2 ++
  src/gallium/drivers/nouveau/nv30/nv30_screen.c   | 4 
  src/gallium/drivers/nouveau/nv50/nv50_screen.c   | 2 ++
  src/gallium/drivers/nouveau/nvc0/nvc0_screen.c   | 2 ++
  src/gallium/drivers/r300/r300_screen.c   | 4 
  src/gallium/drivers/r600/r600_pipe.c | 6 ++
  src/gallium/drivers/radeonsi/si_pipe.c   | 2 ++
  src/gallium/drivers/svga/svga_screen.c   | 4 
  src/gallium/drivers/vc4/vc4_screen.c | 2 ++
  src/gallium/include/pipe/p_defines.h | 3 ++-
  src/mesa/state_tracker/st_extensions.c   | 3 +++
  16 files changed, 45 insertions(+), 1 deletion(-)

 diff --git a/src/gallium/auxiliary/gallivm/lp_bld_limits.h 
 b/src/gallium/auxiliary/gallivm/lp_bld_limits.h
 index 8c66f9d..7856006 100644
 --- a/src/gallium/auxiliary/gallivm/lp_bld_limits.h
 +++ b/src/gallium/auxiliary/gallivm/lp_bld_limits.h
 @@ -128,6 +128,8 @@ gallivm_get_shader_param(enum pipe_shader_cap param)
return 1;
 case PIPE_SHADER_CAP_DOUBLES:
return 0;
 +   case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS:
 +  return 32;
 }
 /* if we get here, we missed a shader cap above (and should have seen
  * a compiler warning.)
 diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h 
 b/src/gallium/auxiliary/tgsi/tgsi_exec.h
 index cc5a916..56c8930 100644
 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.h
 +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h
 @@ -457,6 +457,8 @@ tgsi_exec_get_shader_param(enum pipe_shader_cap param)
return 1;
 case PIPE_SHADER_CAP_DOUBLES:
return 0;
 +   case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS:
 +  return 32;
 }
 /* if we get here, we missed a shader cap above (and should have seen
  * a compiler warning.)
 diff --git a/src/gallium/docs/source/screen.rst 
 b/src/gallium/docs/source/screen.rst
 index 5d80908..aa519d2 100644
 --- a/src/gallium/docs/source/screen.rst
 +++ b/src/gallium/docs/source/screen.rst
 @@ -326,6 +326,10 @@ to be 0.
sampler views. Must not be lower than 
 PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS.
  * ``PIPE_SHADER_CAP_DOUBLES``: Whether double precision floating-point
operations are supported.
 +* ``PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS``: This is the maximum number of
 +  iterations that loops are allowed to have to be unrolled. It is only
 +  a hint to state trackers. Whether any loops will be unrolled is not
 +  guaranteed.


  .. _pipe_compute_cap:
 diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c 
 b/src/gallium/drivers/freedreno/freedreno_screen.c
 index 1ce96d3..90fd6f8 100644
 --- a/src/gallium/drivers/freedreno/freedreno_screen.c
 +++ b/src/gallium/drivers/freedreno/freedreno_screen.c
 @@ -398,6 +398,8 @@ fd_screen_get_shader_param(struct pipe_screen *pscreen, 
 unsigned shader,
   return 16;
   case PIPE_SHADER_CAP_PREFERRED_IR:
   return PIPE_SHADER_IR_TGSI;
 + case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS:
 + return 32;
   }
   debug_printf(unknown shader param %d\n, param);
   return 0;
 diff --git a/src/gallium/drivers/i915/i915_screen.c 
 b/src/gallium/drivers/i915/i915_screen.c
 index 2dcb507..d2199a2 100644
 --- a/src/gallium/drivers/i915/i915_screen.c
 +++ b/src/gallium/drivers/i915/i915_screen.c
 @@ -155,6 +155,8 @@ i915_get_shader_param(struct pipe_screen *screen, 
 unsigned shader, enum pipe_sha
case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS:
   return I915_TEX_UNITS;
 +  case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS:
 + 

Re: [Mesa-dev] [PATCH 02/11] i965/blorp: round to nearest when converting float to integer

2015-02-11 Thread Matt Turner
On Tue, Feb 10, 2015 at 11:00 PM, Samuel Iglesias Gonsálvez
sigles...@igalia.com wrote:
 On Tuesday 10 February 2015 11:32:32 Matt Turner wrote:
 On Tue, Feb 10, 2015 at 10:52 AM, Matt Turner matts...@gmail.com wrote:
  +   /* Round floating point values to nearest integer to avoid off by
  one texel +* kind of errors when blitting.
  +*/
  +   x0 = wm_push_consts.dst_x0 = dst_x0 + 0.5;
  +   y0 = wm_push_consts.dst_y0 = dst_y0 + 0.5;
  +   x1 = wm_push_consts.dst_x1 = dst_x1 + 0.5;
  +   y1 = wm_push_consts.dst_y1 = dst_y1 + 0.5;
 
  Can we use round(dst_??) here instead?
 
  x + 0.5 has the surprising property that nextafter(0.5, 0.0) (i.e.,
  the largest value less than 0.5) + 0.5 is exactly half way between the
  largest value less than 1.0 and 1.0, so it gets rounded to 1.0 instead
  of down to 0.0. It's an uncommon case, but round() should better
  describe what we want to do anyway.

 And just to short circuit the process, assuming round() works have a

 Reviewed-by: Matt Turner matts...@gmail.com

 and feel free to commit. Shouldn't be necessary to resend.

 Thanks for your review, Matt. I'll do the change and check that it works as
 expected.

Sorry for the late comment -- I should have said round*f* :)
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] i965: Use new/delete instead of realloc() in brw_ir_allocator.h

2015-02-11 Thread Juha-Pekka Heikkila
On 11.02.2015 19:02, Matt Turner wrote:
 On Wed, Feb 11, 2015 at 6:37 AM, Juha-Pekka Heikkila
 juhapekka.heikk...@gmail.com wrote:
 There is no error path available thus instead of giving
 realloc possibility to fail use new which will never
 return null pointer and throws bad_alloc on failure.
 
 The problem was that we weren't checking if realloc failed.
 
 Why is the solution to change from malloc/free to new/delete?
 

Checking after realloc return value wouldn't help much here because
there is no way to return anything which would indicate 'failed'. The
way this 'allocate' method is used doesn't also help in this case thus
new would throw catchable error instead of just segfaulting or causing
randomness.

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


Re: [Mesa-dev] [PATCH] i965: Use new/delete instead of realloc() in brw_ir_allocator.h

2015-02-11 Thread Jason Ekstrand
On Wed, Feb 11, 2015 at 12:30 PM, Francisco Jerez curroje...@riseup.net
wrote:

 Matt Turner matts...@gmail.com writes:

  On Wed, Feb 11, 2015 at 9:16 AM, Francisco Jerez curroje...@riseup.net
 wrote:
  Matt Turner matts...@gmail.com writes:
 
  On Wed, Feb 11, 2015 at 6:37 AM, Juha-Pekka Heikkila
  juhapekka.heikk...@gmail.com wrote:
  There is no error path available thus instead of giving
  realloc possibility to fail use new which will never
  return null pointer and throws bad_alloc on failure.
 
  The problem was that we weren't checking if realloc failed.
 
  Why is the solution to change from malloc/free to new/delete?
 
  The new operator is guaranteed not to return NULL by the C++ standard.
  Aside from that Juha-Pekka's code seems more idiomatic to me than
  calling realloc() from a C++ source file, but that might just be a
  matter of taste.
 
  But new will throw an exception if it fails, right? Presumably under
  the same conditions as malloc/realloc returning NULL (i.e., being out
  of address space).

 Yeah, so this patch doesn't really handle the out of memory condition.
 According to Juha-Pekka it silences a Klocwork warning and IMHO it
 improves code-style slightly.  But, sure, if it actually happens it's
 just trading one kind of failure for another.


The fact of the matter is that we don't handle exceptions either so we get
a crash either way.  It's just the difference between a segfault or an
unhandled exception.  Also, for whatever it's worth, in the case where
realloc can expand in-place, the realloc call will be faster because we
won't have to do a memcpy.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCHv4 32/32] i965: Don't compact instructions with unmapped bits.

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


Re: [Mesa-dev] [PATCH] i965: Use new/delete instead of realloc() in brw_ir_allocator.h

2015-02-11 Thread Matt Turner
On Wed, Feb 11, 2015 at 9:16 AM, Francisco Jerez curroje...@riseup.net wrote:
 Matt Turner matts...@gmail.com writes:

 On Wed, Feb 11, 2015 at 6:37 AM, Juha-Pekka Heikkila
 juhapekka.heikk...@gmail.com wrote:
 There is no error path available thus instead of giving
 realloc possibility to fail use new which will never
 return null pointer and throws bad_alloc on failure.

 The problem was that we weren't checking if realloc failed.

 Why is the solution to change from malloc/free to new/delete?

 The new operator is guaranteed not to return NULL by the C++ standard.
 Aside from that Juha-Pekka's code seems more idiomatic to me than
 calling realloc() from a C++ source file, but that might just be a
 matter of taste.

But new will throw an exception if it fails, right? Presumably under
the same conditions as malloc/realloc returning NULL (i.e., being out
of address space).
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] i965: Use new/delete instead of realloc() in brw_ir_allocator.h

2015-02-11 Thread Francisco Jerez
Matt Turner matts...@gmail.com writes:

 On Wed, Feb 11, 2015 at 9:16 AM, Francisco Jerez curroje...@riseup.net 
 wrote:
 Matt Turner matts...@gmail.com writes:

 On Wed, Feb 11, 2015 at 6:37 AM, Juha-Pekka Heikkila
 juhapekka.heikk...@gmail.com wrote:
 There is no error path available thus instead of giving
 realloc possibility to fail use new which will never
 return null pointer and throws bad_alloc on failure.

 The problem was that we weren't checking if realloc failed.

 Why is the solution to change from malloc/free to new/delete?

 The new operator is guaranteed not to return NULL by the C++ standard.
 Aside from that Juha-Pekka's code seems more idiomatic to me than
 calling realloc() from a C++ source file, but that might just be a
 matter of taste.

 But new will throw an exception if it fails, right? Presumably under
 the same conditions as malloc/realloc returning NULL (i.e., being out
 of address space).

Yeah, so this patch doesn't really handle the out of memory condition.
According to Juha-Pekka it silences a Klocwork warning and IMHO it
improves code-style slightly.  But, sure, if it actually happens it's
just trading one kind of failure for another.


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


Re: [Mesa-dev] [PATCH 1/3] nir: Add support for CSE on textures.

2015-02-11 Thread Connor Abbott
On Wed, Feb 11, 2015 at 2:36 PM, Eric Anholt e...@anholt.net wrote:
 Connor Abbott cwabbo...@gmail.com writes:

 On Tue, Feb 10, 2015 at 1:32 PM, Eric Anholt e...@anholt.net wrote:
 Connor Abbott cwabbo...@gmail.com writes:

 On Sat, Feb 7, 2015 at 12:16 AM, Eric Anholt e...@anholt.net wrote:
 NIR instruction count results on i965:
 total instructions in shared programs: 1261954 - 1261937 (-0.00%)
 instructions in affected programs: 455 - 438 (-3.74%)

 One in yofrankie, two in tropics.  Apparently i965 had also optimized all
 of these out anyway.
 ---
  src/glsl/nir/nir_opt_cse.c | 43 
 +++
  1 file changed, 39 insertions(+), 4 deletions(-)

 diff --git a/src/glsl/nir/nir_opt_cse.c b/src/glsl/nir/nir_opt_cse.c
 index b3e9c0d..55dc083 100644
 --- a/src/glsl/nir/nir_opt_cse.c
 +++ b/src/glsl/nir/nir_opt_cse.c
 @@ -80,8 +80,41 @@ nir_instrs_equal(nir_instr *instr1, nir_instr *instr2)
}
return true;
 }
 -   case nir_instr_type_tex:
 -  return false;
 +   case nir_instr_type_tex: {
 +  nir_tex_instr *tex1 = nir_instr_as_tex(instr1);
 +  nir_tex_instr *tex2 = nir_instr_as_tex(instr2);
 +
 +  if (tex1-op != tex2-op)
 + return false;
 +
 +  if (tex1-num_srcs != tex2-num_srcs)
 + return false;
 +  for (unsigned i = 0; i  tex1-num_srcs; i++) {
 + if (tex1-src[i].src_type != tex2-src[i].src_type ||
 + !nir_srcs_equal(tex1-src[i].src, tex2-src[i].src)) {
 +return false;
 + }
 +  }
 +
 +  if (tex1-coord_components != tex2-coord_components ||
 +  tex1-sampler_dim != tex2-sampler_dim ||
 +  tex1-is_array != tex2-is_array ||
 +  tex1-is_shadow != tex2-is_shadow ||
 +  tex1-is_new_style_shadow != tex2-is_new_style_shadow ||
 +  memcmp(tex1-const_offset, tex2-const_offset,
 + sizeof(tex1-const_offset)) != 0 ||
 +  tex1-component != tex2-component ||
 + tex1-sampler_index != tex2-sampler_index ||
 + tex1-sampler_array_size != tex2-sampler_array_size) {

 I think some of these fields are sometimes unused, so you need to
 split them out and not check them if they're unused. For example,
 is_new_style_shadow is only used when is_shadow is true, and component
 isn't used if we're not doing a textureGather (?) op -- I don't
 remember all the details. That, or we have to have a defined value for
 these fields when they're unused and document that somewhere.

 Oh god, we don't zero-allocate structures.  This is going to be awful.

 No, with valgrind it's actually better... you get an error if you
 don't know what you're doing rather than silently having it ignored.
 These days, zero-allocating structures by default doesn't make much
 sense any more.

 So, why should nir.c not be zero-filling those fields, when we zero fill
 the nir_dests and nir_srcs and and tex-sampler and tex-sampler_index
 and deref-base_offset?

because in 99% of cases, that's what we want. To be clear, I'm not
against initializing stuff to some default value when it makes sense,
and in this case I'm fine with initializing all the sometimes-used
things to 0 and ensuring that they stay 0 to make comparing
tex_instr's less of a PITA. But I don't think we should be blindly
calling calloc()/rzalloc() on everything; if there's some field the
caller has to set, and there's no default value that 99% of callers
will want, don't set it and then let valgrind find any errors (or,
even better, pass it as a parameter to the constructor). And yes,
there are probably a few places where we initialize stuff when it's
not necessary -- that's a mistake on my part.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] nir: Recognize open-coded fmin/fmax.

2015-02-11 Thread Kenneth Graunke
On Wednesday, February 11, 2015 09:58:28 AM Matt Turner wrote:
 And unfortunately other shaders do the same thing but with =/= which
 we can't apply this optimization to because of NaNs.
 
 instructions in affected programs: 23309 - 22938 (-1.59%)
 ---
  src/glsl/nir/nir_opt_algebraic.py | 2 ++
  1 file changed, 2 insertions(+)
 
 diff --git a/src/glsl/nir/nir_opt_algebraic.py 
 b/src/glsl/nir/nir_opt_algebraic.py
 index a5fe19a..db105d4 100644
 --- a/src/glsl/nir/nir_opt_algebraic.py
 +++ b/src/glsl/nir/nir_opt_algebraic.py
 @@ -82,6 +82,8 @@ optimizations = [
 (('feq', ('fadd', a, b), 0.0), ('feq', a, ('fneg', b))),
 (('fne', ('fadd', a, b), 0.0), ('fne', a, ('fneg', b))),
 (('fge', ('fneg', ('fabs', a)), 0.0), ('feq', a, 0.0)),
 +   (('bcsel', ('flt', a, b), a, b), ('fmin', a, b)),
 +   (('bcsel', ('flt', a, b), b, a), ('fmax', a, b)),
 (('fmin', ('fmax', a, 0.0), 1.0), ('fsat', a)),
 # Logical and bit operations
 (('fand', a, 0.0), 0.0),
 

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


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] i965: Use new/delete instead of realloc() in brw_ir_allocator.h

2015-02-11 Thread Kenneth Graunke
On Wednesday, February 11, 2015 04:56:56 PM Juha-Pekka Heikkila wrote:
 There is no error path available thus instead of giving
 realloc possibility to fail use new which will never
 return null pointer and throws bad_alloc on failure.
 
 Signed-off-by: Juha-Pekka Heikkila juhapekka.heikk...@gmail.com
 ---
  src/mesa/drivers/dri/i965/brw_ir_allocator.h | 16 
  1 file changed, 12 insertions(+), 4 deletions(-)
 
 diff --git a/src/mesa/drivers/dri/i965/brw_ir_allocator.h 
 b/src/mesa/drivers/dri/i965/brw_ir_allocator.h
 index b1237ed..5330bff 100644
 --- a/src/mesa/drivers/dri/i965/brw_ir_allocator.h
 +++ b/src/mesa/drivers/dri/i965/brw_ir_allocator.h
 @@ -40,8 +40,8 @@ namespace brw {
  
~simple_allocator()
{
 - free(offsets);
 - free(sizes);
 + delete[] offsets;
 + delete[] sizes;
}
  
unsigned
 @@ -49,8 +49,16 @@ namespace brw {
{
   if (capacity = count) {
  capacity = MAX2(16, capacity * 2);
 -sizes = (unsigned *)realloc(sizes, capacity * sizeof(unsigned));
 -offsets = (unsigned *)realloc(offsets, capacity * 
 sizeof(unsigned));
 +
 +unsigned *tmp_sizes = new unsigned[capacity];
 +memcpy(tmp_sizes, sizes, count * sizeof(unsigned));
 +delete[] sizes;
 +sizes = tmp_sizes;
 +
 +unsigned *tmp_offsets = new unsigned[capacity];
 +memcpy(tmp_offsets, offsets, count * sizeof(unsigned));
 +delete[] offsets;
 +offsets = tmp_offsets;
   }
  
   sizes[count] = size;
 

Okay, I'll go ahead and say what Matt and Jason were probably thinking:

NAK.

I'm not against using new/delete in general, but using realloc to double
the size of arrays is a pattern we use all over the codebase.  I don't
see any reason not to use that same pattern here.  Plus, the old code
was 2 lines of code...and now it's 8 lines of code, for no real benefit.

Most idiomatic C++ code I've seen would just some kind of flexible array
class, like std::vector, rather than open coding this.  So, we're
already divergent from C++ best practices, and instead are following the
typical C idiom.  This is neither.

In fact, your new code is more likely to fail than the old one: instead
of growing the array from size N to size 2*N---which realloc may be able
to do in-place---you're briefly keeping both around, using N+2*N=3*N
space.  If realloc failed, this would absolutely fail too.

If we compiled without exceptions, this would crash in an identical
manner - no actual error handling is done here.  With exceptions, it's
not much better - we throw an exception all the way outside of libGL and
back to the application (since we sure don't handle those), leaving our
work in some unknown state.

Plus, as has been repeatedly mentioned - malloc doesn't fail if you're
out of memory - it only fails if you're out of virtual address space.

--Ken


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


[Mesa-dev] [Bug 88880] glxextensions.c: buffer overflow and incorrect zeroing

2015-02-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=0

--- Comment #2 from Ian Romanick i...@freedesktop.org ---
It's invalid because the code referenced in the bug report was removed by
commit 7ef4a07 in July 2006.  I think it's time for any upgrade. :)

See also bug #7353.

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


Re: [Mesa-dev] [PATCH] i965: Use new/delete instead of realloc() in brw_ir_allocator.h

2015-02-11 Thread Matt Turner
On Wed, Feb 11, 2015 at 9:35 AM, Jason Ekstrand ja...@jlekstrand.net wrote:
 On Wed, Feb 11, 2015 at 12:30 PM, Francisco Jerez curroje...@riseup.net
 wrote:

 Matt Turner matts...@gmail.com writes:

  On Wed, Feb 11, 2015 at 9:16 AM, Francisco Jerez curroje...@riseup.net
  wrote:
  Matt Turner matts...@gmail.com writes:
 
  On Wed, Feb 11, 2015 at 6:37 AM, Juha-Pekka Heikkila
  juhapekka.heikk...@gmail.com wrote:
  There is no error path available thus instead of giving
  realloc possibility to fail use new which will never
  return null pointer and throws bad_alloc on failure.
 
  The problem was that we weren't checking if realloc failed.
 
  Why is the solution to change from malloc/free to new/delete?
 
  The new operator is guaranteed not to return NULL by the C++ standard.
  Aside from that Juha-Pekka's code seems more idiomatic to me than
  calling realloc() from a C++ source file, but that might just be a
  matter of taste.
 
  But new will throw an exception if it fails, right? Presumably under
  the same conditions as malloc/realloc returning NULL (i.e., being out
  of address space).

 Yeah, so this patch doesn't really handle the out of memory condition.
 According to Juha-Pekka it silences a Klocwork warning and IMHO it
 improves code-style slightly.  But, sure, if it actually happens it's
 just trading one kind of failure for another.


 The fact of the matter is that we don't handle exceptions either so we get a
 crash either way.  It's just the difference between a segfault or an
 unhandled exception.  Also, for whatever it's worth, in the case where
 realloc can expand in-place, the realloc call will be faster because we
 won't have to do a memcpy.

Indeed. And another thing to consider is that we've discussed
compiling with -fno-exceptions.

I think it's okay to add out-of-memory checks where we can reasonably
do something about them, but code churn *just* to silence a tool (one
that I'm not aware of catching any meaningful bugs) doesn't seem good.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] i965/vs/skl: Use vec4 datatypes for message header

2015-02-11 Thread Kenneth Graunke
On Wednesday, February 11, 2015 10:35:04 AM Ben Widawsky wrote:
 On Wed, Feb 11, 2015 at 05:08:33AM -0800, Kenneth Graunke wrote:
  On Tuesday, February 10, 2015 05:22:45 PM Ben Widawsky wrote:
   Since we can be in this code with SIMD4x2, the execsize will be 4, and so 
   the
   register width must be = 4. If you use a vec8, the width is 8, and we'll 
   assert
   fail.
  
  NAK with this rationale.
  
  brw_fs*.cpp is _only_ for SIMD8 (or SIMD16) mode.
  
  brw_vec4*cpp is for SIMD4x1/SIMD4x2 code.
  
  Code in brw_fs_generator.cpp absolutely cannot run in SIMD4x2 mode.
  
 
 I don't quite understand how the code works, but according to the comments in
 the code (which you reviewed) we take this path on SKL. See
 fs_visitor::lower_uniform_pull_constant_loads and
 fs_generator::generate_uniform_pull_constant_load_gen7
 
 In either event, the patch fixes the aforementioned assertion - if you have a
 better explanation and/or fix, I would be happy to adjust.

I apologize - I misunderstood.

This shader runs in SIMD8 mode.  But, we're using a SIMD4x2 mode sampler
message (even in SIMD8 mode), because we want to load a vector stored as
xyzw from the buffer into a register, but stored how we store uniforms
(also xyzw).  This has execsize 4, and you hit width/execsize assertions.

4,4,1 is effectively the same as 8,8,1 anyway, so it's the same data.

I would perhaps say:

We're using a SIMD4x2 sampler message, which has execsize 4, and so the
register width must be = 4.  Use 4,4,1 regioning instead of 8,8,1
regioning to access the same data but avoid tripping the assert.

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

Thanks, Ben.


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] i965: Add a function to disassemble an instruction from the 4 dwords.

2015-02-11 Thread Ian Romanick
Reviewed-by: Ian Romanick ian.d.roman...@intel.com

On 02/06/2015 12:36 AM, Kenneth Graunke wrote:
 I used this a while back when debugging GPU hangs, and it seems like it
 could be useful, so I figured I'd add it so people can use it in the
 debugger.
 
 Signed-off-by: Kenneth Graunke kenn...@whitecape.org
 ---
  src/mesa/drivers/dri/i965/brw_disasm.c | 12 
  1 file changed, 12 insertions(+)
 
 From the clearing out my 162 branches file...
 
 diff --git a/src/mesa/drivers/dri/i965/brw_disasm.c 
 b/src/mesa/drivers/dri/i965/brw_disasm.c
 index 7405d9b..863a6b3 100644
 --- a/src/mesa/drivers/dri/i965/brw_disasm.c
 +++ b/src/mesa/drivers/dri/i965/brw_disasm.c
 @@ -1197,6 +1197,18 @@ qtr_ctrl(FILE *file, struct brw_context *brw, brw_inst 
 *inst)
 return 0;
  }
  
 +#ifdef DEBUG
 +static __attribute__((__unused__)) int
 +brw_disassemble_imm(struct brw_context *brw,
 +uint32_t dw3, uint32_t dw2, uint32_t dw1, uint32_t dw0)
 +{
 +   brw_inst inst;
 +   inst.data[0] = (((uint64_t) dw1)  32) | ((uint64_t) dw0);
 +   inst.data[1] = (((uint64_t) dw3)  32) | ((uint64_t) dw2);
 +   return brw_disassemble_inst(stderr, brw, inst, false);
 +}
 +#endif
 +
  int
  brw_disassemble_inst(FILE *file, struct brw_context *brw, brw_inst *inst,
   bool is_compacted)
 

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


Re: [Mesa-dev] [PATCH] i965/vs/skl: Use vec4 datatypes for message header

2015-02-11 Thread Ben Widawsky
On Wed, Feb 11, 2015 at 05:08:33AM -0800, Kenneth Graunke wrote:
 On Tuesday, February 10, 2015 05:22:45 PM Ben Widawsky wrote:
  Since we can be in this code with SIMD4x2, the execsize will be 4, and so 
  the
  register width must be = 4. If you use a vec8, the width is 8, and we'll 
  assert
  fail.
 
 NAK with this rationale.
 
 brw_fs*.cpp is _only_ for SIMD8 (or SIMD16) mode.
 
 brw_vec4*cpp is for SIMD4x1/SIMD4x2 code.
 
 Code in brw_fs_generator.cpp absolutely cannot run in SIMD4x2 mode.
 

I don't quite understand how the code works, but according to the comments in
the code (which you reviewed) we take this path on SKL. See
fs_visitor::lower_uniform_pull_constant_loads and
fs_generator::generate_uniform_pull_constant_load_gen7

In either event, the patch fixes the aforementioned assertion - if you have a
better explanation and/or fix, I would be happy to adjust.

  
  Fixes the following piglit tests:
  spec/glsl-1.20/compiler/structure-and-array-operations/array-selection.vert
  spec/glsl-es-3.00/compiler/uniform_block/interface-name-basic.vert
  spec/glsl-es-3.00/compiler/uniform_block/interface-name-field-clashes-with-struct.vert
  spec/glsl-es-3.00/compiler/uniform_block/interface-name-field-clashes-with-function.vert
  spec/glsl-es-3.00/compiler/uniform_block/interface-name-array.vert
  glslparsertest/glsl2/condition-07.vert
  spec/glsl-es-3.00/compiler/uniform_block/interface-name-field-clashes-with-variable.vert
  
  Cc: Neil Roberts n...@linux.intel.com
  Signed-off-by: Ben Widawsky b...@bwidawsk.net
  ---
   src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)
  
  diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp 
  b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
  index 8cd36f8..f7b8771 100644
  --- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
  +++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
  @@ -1024,13 +1024,13 @@ 
  fs_generator::generate_uniform_pull_constant_load_gen7(fs_inst *inst,
   
  if (brw-gen = 9) {
 /* Skylake requires a message header in order to use SIMD4x2 mode. */
  -  src = retype(brw_vec8_grf(offset.nr - 1, 0), BRW_REGISTER_TYPE_UD);
  +  src = retype(brw_vec4_grf(offset.nr - 1, 0), BRW_REGISTER_TYPE_UD);
 mlen = 2;
 header_present = true;
   
 brw_push_insn_state(p);
 brw_set_default_mask_control(p, BRW_MASK_DISABLE);
  -  brw_MOV(p, src, retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UD));
  +  brw_MOV(p, src, retype(brw_vec4_grf(0, 0), BRW_REGISTER_TYPE_UD));
 brw_set_default_access_mode(p, BRW_ALIGN_1);
   
 brw_MOV(p, get_element_ud(src, 2),
  


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


[Mesa-dev] [Bug 89088] Mesa fails to build if indent does not support requested arguments (eg: -nut)

2015-02-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=89088

Bug ID: 89088
   Summary: Mesa fails to build if indent does not support
requested arguments (eg: -nut)
   Product: Mesa
   Version: 10.4
  Hardware: Other
OS: All
Status: NEW
  Severity: normal
  Priority: medium
 Component: Mesa core
  Assignee: mesa-dev@lists.freedesktop.org
  Reporter: jerem...@freedesktop.org
QA Contact: mesa-dev@lists.freedesktop.org

make[4]: Entering directory
`/opt/local/var/macports/build/_Users_jeremy_src_macports_trunk_dports_x11_mesa/mesa/work/Mesa-10.4.4/src/mapi/glapi/gen'
/opt/local/bin/python2.7  ../../../../src/mapi/mapi_abi.py \
--printer glapi --mode lib ./gl_and_es_API.xml 
../../../../src/mapi/glapi/glapi_mapi_tmp.h
/opt/local/bin/python2.7  gl_procs.py -c -f ./gl_and_es_API.xml 
../../../../src/mapi/glapi/glprocs.h
/opt/local/bin/python2.7  gl_apitemp.py -f ./gl_and_es_API.xml 
../../../../src/mapi/glapi/glapitemp.h
/opt/local/bin/python2.7  gl_table.py -f ./gl_and_es_API.xml 
../../../../src/mapi/glapi/glapitable.h
/opt/local/bin/python2.7  gl_gentable.py -f ./gl_and_es_API.xml 
../../../../src/mapi/glapi/glapi_gentable.c
/opt/local/bin/python2.7  gl_enums.py -f ./gl_and_es_API.xml 
../../../../src/mesa/main/enums.c
/opt/local/bin/python2.7  gl_genexec.py -f ./gl_and_es_API.xml 
../../../../src/mesa/main/api_exec.c
/opt/local/bin/python2.7  gl_table.py -f ./gl_and_es_API.xml -m remap_table 
../../../../src/mesa/main/dispatch.h
/opt/local/bin/python2.7  remap_helper.py -f ./gl_and_es_API.xml 
../../../../src/mesa/main/remap_helper.h
/opt/local/bin/python2.7  glX_proto_send.py -f ./gl_API.xml -m proto \
  | indent -i4 -nut -br -brs -npcs -ce -TGLubyte -TGLbyte -TBool 
../../../../src/glx/indirect.c
indent: Command line: unknown parameter -nut
Traceback (most recent call last):
  File glX_proto_send.py, line 1126, in module
printer.Print( api )
  File
/opt/local/var/macports/build/_Users_jeremy_src_macports_trunk_dports_x11_mesa/mesa/work/Mesa-10.4.4/src/mapi/glapi/gen/gl_XML.py,
line 120, in Print
self.printBody(api)
  File glX_proto_send.py, line 346, in printBody
self.printFunction(func, func.name)
  File glX_proto_send.py, line 443, in printFunction
self.printRenderFunction(func)
  File glX_proto_send.py, line 901, in printRenderFunction
self.common_emit_args(f, gc-pc, 4, 0)
  File glX_proto_send.py, line 492, in common_emit_args
self.common_emit_one_arg(p, pc, adjust, extra_offset)
  File glX_proto_send.py, line 482, in common_emit_one_arg
% (pc, p.offset + adjust, src_ptr, p.size_string() )
IOError: [Errno 32] Broken pipe
/opt/local/bin/python2.7  glX_proto_send.py -f ./gl_API.xml -m init_h 
../../../../src/glx/indirect.h

Note that what makes this even worse is that subsequent 'make' invocations will
eventually continue because the generated header files still get created
(incorrectly) despite the error.

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


Re: [Mesa-dev] [PATCH v5 03/29] glsl: Add double builtin type

2015-02-11 Thread Ian Romanick
This patch is

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

On 02/10/2015 03:58 AM, Ilia Mirkin wrote:
 This causes a lot of warnings about unchecked type in
 switch statements - fix them later.
 
 Signed-off-by: Dave Airlie airl...@redhat.com
 Reviewed-by: Matt Turner matts...@gmail.com
 ---
  src/glsl/glsl_types.h | 9 +
  1 file changed, 9 insertions(+)
 
 diff --git a/src/glsl/glsl_types.h b/src/glsl/glsl_types.h
 index 441015c..f472db0 100644
 --- a/src/glsl/glsl_types.h
 +++ b/src/glsl/glsl_types.h
 @@ -51,6 +51,7 @@ enum glsl_base_type {
 GLSL_TYPE_UINT = 0,
 GLSL_TYPE_INT,
 GLSL_TYPE_FLOAT,
 +   GLSL_TYPE_DOUBLE,
 GLSL_TYPE_BOOL,
 GLSL_TYPE_SAMPLER,
 GLSL_TYPE_IMAGE,
 @@ -421,6 +422,14 @@ struct glsl_type {
 }
  
 /**
 +* Query whether or not a type is a double type
 +*/
 +   bool is_double() const
 +   {
 +  return base_type == GLSL_TYPE_DOUBLE;
 +   }
 +
 +   /**
  * Query whether or not a type is a non-array boolean type
  */
 bool is_boolean() const
 

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


Re: [Mesa-dev] [PATCH] nir/lower_phis_to_scalar: Fix some logic in is_phi_scalarizable

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


Re: [Mesa-dev] [PATCH] nir/lower_phis_to_scalar: Fix some logic in is_phi_scalarizable

2015-02-11 Thread Kenneth Graunke
On Monday, February 09, 2015 02:23:25 PM Jason Ekstrand wrote:
 ---
  src/glsl/nir/nir_lower_phis_to_scalar.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
 
 diff --git a/src/glsl/nir/nir_lower_phis_to_scalar.c 
 b/src/glsl/nir/nir_lower_phis_to_scalar.c
 index 3bb5cc7..7cd93ea 100644
 --- a/src/glsl/nir/nir_lower_phis_to_scalar.c
 +++ b/src/glsl/nir/nir_lower_phis_to_scalar.c
 @@ -65,9 +65,9 @@ is_phi_src_scalarizable(nir_phi_src *src,
 * are ok too.
 */
return nir_op_infos[src_alu-op].output_size == 0 ||
 - src_alu-op != nir_op_vec2 ||
 - src_alu-op != nir_op_vec3 ||
 - src_alu-op != nir_op_vec4;
 + src_alu-op == nir_op_vec2 ||
 + src_alu-op == nir_op_vec3 ||
 + src_alu-op == nir_op_vec4;
 }
  
 case nir_instr_type_phi:
 

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


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] program: Remove _mesa_nop_vertex_program/_mesa_nop_fragment_program.

2015-02-11 Thread Eric Anholt
Kenneth Graunke kenn...@whitecape.org writes:

 On Tuesday, February 10, 2015 08:08:38 PM Matt Turner wrote:
 Dead since
 
commit 284ce20901b0c2cfab1d952cc129b8f3cd068f12
Author: Eric Anholt e...@anholt.net
Date:   Fri Aug 20 10:52:14 2010 -0700
 
Remove remnants of the old glsl compiler.
 ---
  src/mesa/program/programopt.c | 91 
 ---
  src/mesa/program/programopt.h |  6 ---
  2 files changed, 97 deletions(-)

 LGTM.  I wonder if there's a GCC or Clang option to report dead code
 like this.  4 years is a long time for this to slip under the radar...

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

Looks like my last adventure in this produced this script:

find -iname '*.o' -exec nm -C \{\} \; | grep  [TD]  | awk '{print $3;}' | 
sort | uniq  symbols.defined

find -iname '*.o' -exec nm -C \{\} \; | grep  U  | awk '{print $2;}' | sort | 
uniq  symbols.used

diff -u symbols.defined symbols.used


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 1/3] nir: Add support for CSE on textures.

2015-02-11 Thread Eric Anholt
Connor Abbott cwabbo...@gmail.com writes:

 On Tue, Feb 10, 2015 at 1:32 PM, Eric Anholt e...@anholt.net wrote:
 Connor Abbott cwabbo...@gmail.com writes:

 On Sat, Feb 7, 2015 at 12:16 AM, Eric Anholt e...@anholt.net wrote:
 NIR instruction count results on i965:
 total instructions in shared programs: 1261954 - 1261937 (-0.00%)
 instructions in affected programs: 455 - 438 (-3.74%)

 One in yofrankie, two in tropics.  Apparently i965 had also optimized all
 of these out anyway.
 ---
  src/glsl/nir/nir_opt_cse.c | 43 
 +++
  1 file changed, 39 insertions(+), 4 deletions(-)

 diff --git a/src/glsl/nir/nir_opt_cse.c b/src/glsl/nir/nir_opt_cse.c
 index b3e9c0d..55dc083 100644
 --- a/src/glsl/nir/nir_opt_cse.c
 +++ b/src/glsl/nir/nir_opt_cse.c
 @@ -80,8 +80,41 @@ nir_instrs_equal(nir_instr *instr1, nir_instr *instr2)
}
return true;
 }
 -   case nir_instr_type_tex:
 -  return false;
 +   case nir_instr_type_tex: {
 +  nir_tex_instr *tex1 = nir_instr_as_tex(instr1);
 +  nir_tex_instr *tex2 = nir_instr_as_tex(instr2);
 +
 +  if (tex1-op != tex2-op)
 + return false;
 +
 +  if (tex1-num_srcs != tex2-num_srcs)
 + return false;
 +  for (unsigned i = 0; i  tex1-num_srcs; i++) {
 + if (tex1-src[i].src_type != tex2-src[i].src_type ||
 + !nir_srcs_equal(tex1-src[i].src, tex2-src[i].src)) {
 +return false;
 + }
 +  }
 +
 +  if (tex1-coord_components != tex2-coord_components ||
 +  tex1-sampler_dim != tex2-sampler_dim ||
 +  tex1-is_array != tex2-is_array ||
 +  tex1-is_shadow != tex2-is_shadow ||
 +  tex1-is_new_style_shadow != tex2-is_new_style_shadow ||
 +  memcmp(tex1-const_offset, tex2-const_offset,
 + sizeof(tex1-const_offset)) != 0 ||
 +  tex1-component != tex2-component ||
 + tex1-sampler_index != tex2-sampler_index ||
 + tex1-sampler_array_size != tex2-sampler_array_size) {

 I think some of these fields are sometimes unused, so you need to
 split them out and not check them if they're unused. For example,
 is_new_style_shadow is only used when is_shadow is true, and component
 isn't used if we're not doing a textureGather (?) op -- I don't
 remember all the details. That, or we have to have a defined value for
 these fields when they're unused and document that somewhere.

 Oh god, we don't zero-allocate structures.  This is going to be awful.

 No, with valgrind it's actually better... you get an error if you
 don't know what you're doing rather than silently having it ignored.
 These days, zero-allocating structures by default doesn't make much
 sense any more.

So, why should nir.c not be zero-filling those fields, when we zero fill
the nir_dests and nir_srcs and and tex-sampler and tex-sampler_index
and deref-base_offset?


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


[Mesa-dev] [PATCH] nir: Recognize open-coded fmin/fmax.

2015-02-11 Thread Matt Turner
And unfortunately other shaders do the same thing but with =/= which
we can't apply this optimization to because of NaNs.

instructions in affected programs: 23309 - 22938 (-1.59%)
---
 src/glsl/nir/nir_opt_algebraic.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/glsl/nir/nir_opt_algebraic.py 
b/src/glsl/nir/nir_opt_algebraic.py
index a5fe19a..db105d4 100644
--- a/src/glsl/nir/nir_opt_algebraic.py
+++ b/src/glsl/nir/nir_opt_algebraic.py
@@ -82,6 +82,8 @@ optimizations = [
(('feq', ('fadd', a, b), 0.0), ('feq', a, ('fneg', b))),
(('fne', ('fadd', a, b), 0.0), ('fne', a, ('fneg', b))),
(('fge', ('fneg', ('fabs', a)), 0.0), ('feq', a, 0.0)),
+   (('bcsel', ('flt', a, b), a, b), ('fmin', a, b)),
+   (('bcsel', ('flt', a, b), b, a), ('fmax', a, b)),
(('fmin', ('fmax', a, 0.0), 1.0), ('fsat', a)),
# Logical and bit operations
(('fand', a, 0.0), 0.0),
-- 
2.0.5

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


Re: [Mesa-dev] [PATCH] darwin: Fix install name of libOSMesa

2015-02-11 Thread Jeremy Huddleston Sequoia

 On Feb 11, 2015, at 05:02, Emil Velikov emil.l.veli...@gmail.com wrote:
 
 On 11 February 2015 at 10:32, Jeremy Huddleston Sequoia
 jerem...@apple.com wrote:
 libOSMesa is a library, not a module
 
 Fwiw I'm not 100% sure that's the case. But considering it's been like
 that* for a long time we should be safe.
 Just a couple small requests - can you clarify what you mean with Fix
 install name

Passing -module to glibtool causes the resulting library to be called 
libSomething.so rather than libSomething.dylib on darwin.

 and update the gallium one (src/gallium/targets/osmesa).

I can do that, but I can't test it since gallium doesn't build on darwin, so 
I'd prefer to leave that alone for now.

--Jeremy

 
 Thanks
 Emil
 
 * lib prefix, soname, living in lib, pkgconfig providing -lOSMesa) I
 see no problems wit



smime.p7s
Description: S/MIME cryptographic signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] mesa: fix AtomicBuffer typo in _mesa_DeleteBuffers

2015-02-11 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

Cc: 10.5 10.4 10.3 mesa-sta...@lists.freedesktop.org
---
 src/mesa/main/bufferobj.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 0c1ce98..0c23b42 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1226,7 +1226,7 @@ _mesa_DeleteBuffers(GLsizei n, const GLuint *ids)
 }
  }
 
- if (ctx-UniformBuffer == bufObj) {
+ if (ctx-AtomicBuffer == bufObj) {
 _mesa_BindBuffer( GL_ATOMIC_COUNTER_BUFFER, 0 );
  }
 
-- 
2.1.0

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


[Mesa-dev] [PATCH] i965: Use new/delete instead of realloc() in brw_ir_allocator.h

2015-02-11 Thread Juha-Pekka Heikkila
There is no error path available thus instead of giving
realloc possibility to fail use new which will never
return null pointer and throws bad_alloc on failure.

Signed-off-by: Juha-Pekka Heikkila juhapekka.heikk...@gmail.com
---
 src/mesa/drivers/dri/i965/brw_ir_allocator.h | 19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_ir_allocator.h 
b/src/mesa/drivers/dri/i965/brw_ir_allocator.h
index b1237ed..b3fba29 100644
--- a/src/mesa/drivers/dri/i965/brw_ir_allocator.h
+++ b/src/mesa/drivers/dri/i965/brw_ir_allocator.h
@@ -40,17 +40,28 @@ namespace brw {
 
   ~simple_allocator()
   {
- free(offsets);
- free(sizes);
+ delete[] offsets;
+ delete[] sizes;
   }
 
   unsigned
   allocate(unsigned size)
   {
  if (capacity = count) {
+unsigned *tmp_sizes;
+unsigned *tmp_offsets;
+
 capacity = MAX2(16, capacity * 2);
-sizes = (unsigned *)realloc(sizes, capacity * sizeof(unsigned));
-offsets = (unsigned *)realloc(offsets, capacity * 
sizeof(unsigned));
+
+tmp_sizes = new unsigned[capacity * sizeof(unsigned)];
+memcpy(tmp_sizes, sizes, count*sizeof(unsigned));
+delete[] sizes;
+sizes = tmp_sizes;
+
+tmp_offsets = new unsigned[capacity * sizeof(unsigned)];
+memcpy(tmp_offsets, offsets, count*sizeof(unsigned));
+delete[] offsets;
+offsets = tmp_offsets;
  }
 
  sizes[count] = size;
-- 
1.8.5.1

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


[Mesa-dev] [PATCH 1/2] gallium: define unreachable macro

2015-02-11 Thread Tobias Klausmann
This is done the same way for glsl et al. already

Signed-off-by: Tobias Klausmann tobias.johannes.klausm...@mni.thm.de
---
 src/gallium/include/pipe/p_compiler.h | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/src/gallium/include/pipe/p_compiler.h 
b/src/gallium/include/pipe/p_compiler.h
index fb018bf..62ba9d3 100644
--- a/src/gallium/include/pipe/p_compiler.h
+++ b/src/gallium/include/pipe/p_compiler.h
@@ -249,6 +249,29 @@ void _ReadWriteBarrier(void);
 
 
 /**
+ * Unreachable macro. Useful for suppressing control reaches end of non-void
+ * function warnings.
+ */
+#ifdef HAVE___BUILTIN_UNREACHABLE
+#define unreachable(str)\
+do {\
+   assert(!str);\
+   __builtin_unreachable(); \
+} while (0)
+#elif _MSC_VER = 1200
+#define unreachable(str)\
+do {\
+   assert(!str);\
+   __assume(0); \
+} while (0)
+#endif
+
+#ifndef unreachable
+#define unreachable(str) assert(!str)
+#endif
+
+
+/**
  * Static (compile-time) assertion.
  * Basically, use COND to dimension an array.  If COND is false/zero the
  * array size will be -1 and we'll get a compilation error.
-- 
2.2.2

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


[Mesa-dev] [PATCH] i965: Use new/delete instead of realloc() in brw_ir_allocator.h

2015-02-11 Thread Juha-Pekka Heikkila
There is no error path available thus instead of giving
realloc possibility to fail use new which will never
return null pointer and throws bad_alloc on failure.

Signed-off-by: Juha-Pekka Heikkila juhapekka.heikk...@gmail.com
---
 src/mesa/drivers/dri/i965/brw_ir_allocator.h | 16 
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_ir_allocator.h 
b/src/mesa/drivers/dri/i965/brw_ir_allocator.h
index b1237ed..5330bff 100644
--- a/src/mesa/drivers/dri/i965/brw_ir_allocator.h
+++ b/src/mesa/drivers/dri/i965/brw_ir_allocator.h
@@ -40,8 +40,8 @@ namespace brw {
 
   ~simple_allocator()
   {
- free(offsets);
- free(sizes);
+ delete[] offsets;
+ delete[] sizes;
   }
 
   unsigned
@@ -49,8 +49,16 @@ namespace brw {
   {
  if (capacity = count) {
 capacity = MAX2(16, capacity * 2);
-sizes = (unsigned *)realloc(sizes, capacity * sizeof(unsigned));
-offsets = (unsigned *)realloc(offsets, capacity * 
sizeof(unsigned));
+
+unsigned *tmp_sizes = new unsigned[capacity];
+memcpy(tmp_sizes, sizes, count * sizeof(unsigned));
+delete[] sizes;
+sizes = tmp_sizes;
+
+unsigned *tmp_offsets = new unsigned[capacity];
+memcpy(tmp_offsets, offsets, count * sizeof(unsigned));
+delete[] offsets;
+offsets = tmp_offsets;
  }
 
  sizes[count] = size;
-- 
1.8.5.1

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


Re: [Mesa-dev] [PATCH] gallium: add PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS

2015-02-11 Thread Roland Scheidegger
I don't think this is a good idea. This pollutes the gallium interface
(albeit in some rather minor way, but still) to just cover up a driver
bug. It does not do anything to actually fix the root cause of the bug
(presumably it would still just lock up if the loop would actually have
256 iterations and hence still not get unrolled, and it's a hint only so
even with less iterations you could still get such loops with other
state trackers).
Unless such a hint would be useful in general for drivers to set some
limit for loop unrolling.

Roland


Am 11.02.2015 um 15:23 schrieb Marek Olšák:
 From: Marek Olšák marek.ol...@amd.com
 
 This is the same as the Mesa core setting.
 
 This avoids a serious r600g bug.
 Bugzilla:_https://bugs.freedesktop.org/show_bug.cgi?id=86720
 
 Cc: 10.5 10.4 10.3 mesa-sta...@lists.freedesktop.org
 ---
  src/gallium/auxiliary/gallivm/lp_bld_limits.h| 2 ++
  src/gallium/auxiliary/tgsi/tgsi_exec.h   | 2 ++
  src/gallium/docs/source/screen.rst   | 4 
  src/gallium/drivers/freedreno/freedreno_screen.c | 2 ++
  src/gallium/drivers/i915/i915_screen.c   | 2 ++
  src/gallium/drivers/ilo/ilo_screen.c | 2 ++
  src/gallium/drivers/nouveau/nv30/nv30_screen.c   | 4 
  src/gallium/drivers/nouveau/nv50/nv50_screen.c   | 2 ++
  src/gallium/drivers/nouveau/nvc0/nvc0_screen.c   | 2 ++
  src/gallium/drivers/r300/r300_screen.c   | 4 
  src/gallium/drivers/r600/r600_pipe.c | 6 ++
  src/gallium/drivers/radeonsi/si_pipe.c   | 2 ++
  src/gallium/drivers/svga/svga_screen.c   | 4 
  src/gallium/drivers/vc4/vc4_screen.c | 2 ++
  src/gallium/include/pipe/p_defines.h | 3 ++-
  src/mesa/state_tracker/st_extensions.c   | 3 +++
  16 files changed, 45 insertions(+), 1 deletion(-)
 
 diff --git a/src/gallium/auxiliary/gallivm/lp_bld_limits.h 
 b/src/gallium/auxiliary/gallivm/lp_bld_limits.h
 index 8c66f9d..7856006 100644
 --- a/src/gallium/auxiliary/gallivm/lp_bld_limits.h
 +++ b/src/gallium/auxiliary/gallivm/lp_bld_limits.h
 @@ -128,6 +128,8 @@ gallivm_get_shader_param(enum pipe_shader_cap param)
return 1;
 case PIPE_SHADER_CAP_DOUBLES:
return 0;
 +   case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS:
 +  return 32;
 }
 /* if we get here, we missed a shader cap above (and should have seen
  * a compiler warning.)
 diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h 
 b/src/gallium/auxiliary/tgsi/tgsi_exec.h
 index cc5a916..56c8930 100644
 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.h
 +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h
 @@ -457,6 +457,8 @@ tgsi_exec_get_shader_param(enum pipe_shader_cap param)
return 1;
 case PIPE_SHADER_CAP_DOUBLES:
return 0;
 +   case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS:
 +  return 32;
 }
 /* if we get here, we missed a shader cap above (and should have seen
  * a compiler warning.)
 diff --git a/src/gallium/docs/source/screen.rst 
 b/src/gallium/docs/source/screen.rst
 index 5d80908..aa519d2 100644
 --- a/src/gallium/docs/source/screen.rst
 +++ b/src/gallium/docs/source/screen.rst
 @@ -326,6 +326,10 @@ to be 0.
sampler views. Must not be lower than PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS.
  * ``PIPE_SHADER_CAP_DOUBLES``: Whether double precision floating-point
operations are supported.
 +* ``PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS``: This is the maximum number of
 +  iterations that loops are allowed to have to be unrolled. It is only
 +  a hint to state trackers. Whether any loops will be unrolled is not
 +  guaranteed.
  
  
  .. _pipe_compute_cap:
 diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c 
 b/src/gallium/drivers/freedreno/freedreno_screen.c
 index 1ce96d3..90fd6f8 100644
 --- a/src/gallium/drivers/freedreno/freedreno_screen.c
 +++ b/src/gallium/drivers/freedreno/freedreno_screen.c
 @@ -398,6 +398,8 @@ fd_screen_get_shader_param(struct pipe_screen *pscreen, 
 unsigned shader,
   return 16;
   case PIPE_SHADER_CAP_PREFERRED_IR:
   return PIPE_SHADER_IR_TGSI;
 + case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS:
 + return 32;
   }
   debug_printf(unknown shader param %d\n, param);
   return 0;
 diff --git a/src/gallium/drivers/i915/i915_screen.c 
 b/src/gallium/drivers/i915/i915_screen.c
 index 2dcb507..d2199a2 100644
 --- a/src/gallium/drivers/i915/i915_screen.c
 +++ b/src/gallium/drivers/i915/i915_screen.c
 @@ -155,6 +155,8 @@ i915_get_shader_param(struct pipe_screen *screen, 
 unsigned shader, enum pipe_sha
case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS:
   return I915_TEX_UNITS;
 +  case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS:
 + return 32;
default:
   debug_printf(%s: Unknown cap %u.\n, __FUNCTION__, cap);
   return 0;
 diff --git a/src/gallium/drivers/ilo/ilo_screen.c 
 b/src/gallium/drivers/ilo/ilo_screen.c
 index 

Re: [Mesa-dev] [PATCH 1/2] gallium: define unreachable macro

2015-02-11 Thread Ilia Mirkin
It's already defined in src/util/macros.h which you can include via
#include util/macros.h -- I suspect some key gallium file should
include that...

On Wed, Feb 11, 2015 at 10:47 AM, Tobias Klausmann
tobias.johannes.klausm...@mni.thm.de wrote:
 This is done the same way for glsl et al. already

 Signed-off-by: Tobias Klausmann tobias.johannes.klausm...@mni.thm.de
 ---
  src/gallium/include/pipe/p_compiler.h | 23 +++
  1 file changed, 23 insertions(+)

 diff --git a/src/gallium/include/pipe/p_compiler.h 
 b/src/gallium/include/pipe/p_compiler.h
 index fb018bf..62ba9d3 100644
 --- a/src/gallium/include/pipe/p_compiler.h
 +++ b/src/gallium/include/pipe/p_compiler.h
 @@ -249,6 +249,29 @@ void _ReadWriteBarrier(void);


  /**
 + * Unreachable macro. Useful for suppressing control reaches end of non-void
 + * function warnings.
 + */
 +#ifdef HAVE___BUILTIN_UNREACHABLE
 +#define unreachable(str)\
 +do {\
 +   assert(!str);\
 +   __builtin_unreachable(); \
 +} while (0)
 +#elif _MSC_VER = 1200
 +#define unreachable(str)\
 +do {\
 +   assert(!str);\
 +   __assume(0); \
 +} while (0)
 +#endif
 +
 +#ifndef unreachable
 +#define unreachable(str) assert(!str)
 +#endif
 +
 +
 +/**
   * Static (compile-time) assertion.
   * Basically, use COND to dimension an array.  If COND is false/zero the
   * array size will be -1 and we'll get a compilation error.
 --
 2.2.2

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


[Mesa-dev] [PATCH 3/4] radeonsi: small fix in SPI state

2015-02-11 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

Cc: 10.4 mesa-sta...@lists.freedesktop.org
---
 src/gallium/drivers/radeonsi/si_state_shaders.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c 
b/src/gallium/drivers/radeonsi/si_state_shaders.c
index 27ccc8e..dea99ea 100644
--- a/src/gallium/drivers/radeonsi/si_state_shaders.c
+++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
@@ -662,8 +662,10 @@ bcolor:
}
 
if (j == vsinfo-num_outputs) {
-   /* No corresponding output found, load defaults into 
input */
-   tmp |= S_028644_OFFSET(0x20);
+   /* No corresponding output found, load defaults into 
input.
+* Don't set any other bits.
+* (FLAT_SHADE=1 completely changes behavior) */
+   tmp = S_028644_OFFSET(0x20);
}
 
si_pm4_set_reg(pm4,
-- 
2.1.0

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


[Mesa-dev] [PATCH] gallium: add PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS

2015-02-11 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

This is the same as the Mesa core setting.

This avoids a serious r600g bug.
Bugzilla:_https://bugs.freedesktop.org/show_bug.cgi?id=86720

Cc: 10.5 10.4 10.3 mesa-sta...@lists.freedesktop.org
---
 src/gallium/auxiliary/gallivm/lp_bld_limits.h| 2 ++
 src/gallium/auxiliary/tgsi/tgsi_exec.h   | 2 ++
 src/gallium/docs/source/screen.rst   | 4 
 src/gallium/drivers/freedreno/freedreno_screen.c | 2 ++
 src/gallium/drivers/i915/i915_screen.c   | 2 ++
 src/gallium/drivers/ilo/ilo_screen.c | 2 ++
 src/gallium/drivers/nouveau/nv30/nv30_screen.c   | 4 
 src/gallium/drivers/nouveau/nv50/nv50_screen.c   | 2 ++
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c   | 2 ++
 src/gallium/drivers/r300/r300_screen.c   | 4 
 src/gallium/drivers/r600/r600_pipe.c | 6 ++
 src/gallium/drivers/radeonsi/si_pipe.c   | 2 ++
 src/gallium/drivers/svga/svga_screen.c   | 4 
 src/gallium/drivers/vc4/vc4_screen.c | 2 ++
 src/gallium/include/pipe/p_defines.h | 3 ++-
 src/mesa/state_tracker/st_extensions.c   | 3 +++
 16 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_limits.h 
b/src/gallium/auxiliary/gallivm/lp_bld_limits.h
index 8c66f9d..7856006 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_limits.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_limits.h
@@ -128,6 +128,8 @@ gallivm_get_shader_param(enum pipe_shader_cap param)
   return 1;
case PIPE_SHADER_CAP_DOUBLES:
   return 0;
+   case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS:
+  return 32;
}
/* if we get here, we missed a shader cap above (and should have seen
 * a compiler warning.)
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h 
b/src/gallium/auxiliary/tgsi/tgsi_exec.h
index cc5a916..56c8930 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h
@@ -457,6 +457,8 @@ tgsi_exec_get_shader_param(enum pipe_shader_cap param)
   return 1;
case PIPE_SHADER_CAP_DOUBLES:
   return 0;
+   case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS:
+  return 32;
}
/* if we get here, we missed a shader cap above (and should have seen
 * a compiler warning.)
diff --git a/src/gallium/docs/source/screen.rst 
b/src/gallium/docs/source/screen.rst
index 5d80908..aa519d2 100644
--- a/src/gallium/docs/source/screen.rst
+++ b/src/gallium/docs/source/screen.rst
@@ -326,6 +326,10 @@ to be 0.
   sampler views. Must not be lower than PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS.
 * ``PIPE_SHADER_CAP_DOUBLES``: Whether double precision floating-point
   operations are supported.
+* ``PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS``: This is the maximum number of
+  iterations that loops are allowed to have to be unrolled. It is only
+  a hint to state trackers. Whether any loops will be unrolled is not
+  guaranteed.
 
 
 .. _pipe_compute_cap:
diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c 
b/src/gallium/drivers/freedreno/freedreno_screen.c
index 1ce96d3..90fd6f8 100644
--- a/src/gallium/drivers/freedreno/freedreno_screen.c
+++ b/src/gallium/drivers/freedreno/freedreno_screen.c
@@ -398,6 +398,8 @@ fd_screen_get_shader_param(struct pipe_screen *pscreen, 
unsigned shader,
return 16;
case PIPE_SHADER_CAP_PREFERRED_IR:
return PIPE_SHADER_IR_TGSI;
+   case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS:
+   return 32;
}
debug_printf(unknown shader param %d\n, param);
return 0;
diff --git a/src/gallium/drivers/i915/i915_screen.c 
b/src/gallium/drivers/i915/i915_screen.c
index 2dcb507..d2199a2 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -155,6 +155,8 @@ i915_get_shader_param(struct pipe_screen *screen, unsigned 
shader, enum pipe_sha
   case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
   case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS:
  return I915_TEX_UNITS;
+  case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS:
+ return 32;
   default:
  debug_printf(%s: Unknown cap %u.\n, __FUNCTION__, cap);
  return 0;
diff --git a/src/gallium/drivers/ilo/ilo_screen.c 
b/src/gallium/drivers/ilo/ilo_screen.c
index 04c1283..6e9e723 100644
--- a/src/gallium/drivers/ilo/ilo_screen.c
+++ b/src/gallium/drivers/ilo/ilo_screen.c
@@ -154,6 +154,8 @@ ilo_get_shader_param(struct pipe_screen *screen, unsigned 
shader,
   return PIPE_SHADER_IR_TGSI;
case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED:
   return 1;
+   case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS:
+  return 32;
 
default:
   return 0;
diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c 
b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
index 83cae7a..9c183f2 100644
--- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
+++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
@@ -247,6 +247,8 @@ 

[Mesa-dev] [PATCH 2/4] r600g, radeonsi: use fences to implement PIPE_QUERY_GPU_FINISHED

2015-02-11 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

---
 src/gallium/drivers/radeon/r600_query.c | 22 +-
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/radeon/r600_query.c 
b/src/gallium/drivers/radeon/r600_query.c
index 4571b3c..8d80612 100644
--- a/src/gallium/drivers/radeon/r600_query.c
+++ b/src/gallium/drivers/radeon/r600_query.c
@@ -52,6 +52,8 @@ struct r600_query {
/* for custom non-GPU queries */
uint64_t begin_result;
uint64_t end_result;
+   /* Fence for GPU_FINISHED. */
+   struct pipe_fence_handle *fence;
 };
 
 
@@ -75,6 +77,7 @@ static struct r600_resource *r600_new_query_buffer(struct 
r600_common_context *c
/* Non-GPU queries. */
switch (type) {
case PIPE_QUERY_TIMESTAMP_DISJOINT:
+   case PIPE_QUERY_GPU_FINISHED:
case R600_QUERY_DRAW_CALLS:
case R600_QUERY_REQUESTED_VRAM:
case R600_QUERY_REQUESTED_GTT:
@@ -113,7 +116,6 @@ static struct r600_resource *r600_new_query_buffer(struct 
r600_common_context *c
}
ctx-ws-buffer_unmap(buf-cs_buf);
break;
-   case PIPE_QUERY_GPU_FINISHED:
case PIPE_QUERY_TIME_ELAPSED:
case PIPE_QUERY_TIMESTAMP:
break;
@@ -275,8 +277,6 @@ static void r600_emit_query_end(struct r600_common_context 
*ctx, struct r600_que
radeon_emit(cs, va);
radeon_emit(cs, (va  32UL)  0xFF);
break;
-case PIPE_QUERY_GPU_FINISHED:
-   break;
default:
assert(0);
}
@@ -360,8 +360,6 @@ static struct pipe_query *r600_create_query(struct 
pipe_context *ctx, unsigned q
query-result_size = 16 * rctx-max_db;
query-num_cs_dw = 6;
break;
-   case PIPE_QUERY_GPU_FINISHED:
-   query-num_cs_dw = 2;
break;
case PIPE_QUERY_TIME_ELAPSED:
query-result_size = 16;
@@ -384,8 +382,9 @@ static struct pipe_query *r600_create_query(struct 
pipe_context *ctx, unsigned q
query-result_size = (rctx-chip_class = EVERGREEN ? 11 : 8) * 
16;
query-num_cs_dw = 8;
break;
-   /* Non-GPU queries. */
+   /* Non-GPU queries and queries not requiring a buffer. */
case PIPE_QUERY_TIMESTAMP_DISJOINT:
+   case PIPE_QUERY_GPU_FINISHED:
case R600_QUERY_DRAW_CALLS:
case R600_QUERY_REQUESTED_VRAM:
case R600_QUERY_REQUESTED_GTT:
@@ -498,6 +497,9 @@ static void r600_end_query(struct pipe_context *ctx, struct 
pipe_query *query)
switch (rquery-type) {
case PIPE_QUERY_TIMESTAMP_DISJOINT:
return;
+   case PIPE_QUERY_GPU_FINISHED:
+   rctx-rings.gfx.flush(rctx, RADEON_FLUSH_ASYNC, rquery-fence);
+   return;
case R600_QUERY_DRAW_CALLS:
rquery-end_result = rctx-num_draw_calls;
return;
@@ -555,6 +557,7 @@ static boolean r600_get_query_buffer_result(struct 
r600_common_context *ctx,
boolean wait,
union pipe_query_result *result)
 {
+   struct pipe_screen *screen = ctx-b.screen;
unsigned results_base = 0;
char *map;
 
@@ -566,6 +569,10 @@ static boolean r600_get_query_buffer_result(struct 
r600_common_context *ctx,
(uint64_t)ctx-screen-info.r600_clock_crystal_freq * 
1000;
result-timestamp_disjoint.disjoint = FALSE;
return TRUE;
+   case PIPE_QUERY_GPU_FINISHED:
+   result-b = screen-fence_finish(screen, query-fence,
+   wait ? PIPE_TIMEOUT_INFINITE : 0);
+   return result-b;
case R600_QUERY_DRAW_CALLS:
case R600_QUERY_REQUESTED_VRAM:
case R600_QUERY_REQUESTED_GTT:
@@ -600,9 +607,6 @@ static boolean r600_get_query_buffer_result(struct 
r600_common_context *ctx,
results_base += 16;
}
break;
-   case PIPE_QUERY_GPU_FINISHED:
-   result-b = TRUE;
-   break;
case PIPE_QUERY_TIME_ELAPSED:
while (results_base != qbuf-results_end) {
result-u64 +=
-- 
2.1.0

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


[Mesa-dev] [PATCH 1/4] r600g, radeonsi: demote TIMESTAMP_DISJOINT query to be a software query

2015-02-11 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

The query result is always constant.
---
 src/gallium/drivers/radeon/r600_query.c | 27 +--
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/src/gallium/drivers/radeon/r600_query.c 
b/src/gallium/drivers/radeon/r600_query.c
index 590db13..4571b3c 100644
--- a/src/gallium/drivers/radeon/r600_query.c
+++ b/src/gallium/drivers/radeon/r600_query.c
@@ -58,8 +58,7 @@ struct r600_query {
 static bool r600_is_timer_query(unsigned type)
 {
return type == PIPE_QUERY_TIME_ELAPSED ||
-  type == PIPE_QUERY_TIMESTAMP ||
-  type == PIPE_QUERY_TIMESTAMP_DISJOINT;
+  type == PIPE_QUERY_TIMESTAMP;
 }
 
 static bool r600_query_needs_begin(unsigned type)
@@ -75,6 +74,7 @@ static struct r600_resource *r600_new_query_buffer(struct 
r600_common_context *c
 
/* Non-GPU queries. */
switch (type) {
+   case PIPE_QUERY_TIMESTAMP_DISJOINT:
case R600_QUERY_DRAW_CALLS:
case R600_QUERY_REQUESTED_VRAM:
case R600_QUERY_REQUESTED_GTT:
@@ -116,7 +116,6 @@ static struct r600_resource *r600_new_query_buffer(struct 
r600_common_context *c
case PIPE_QUERY_GPU_FINISHED:
case PIPE_QUERY_TIME_ELAPSED:
case PIPE_QUERY_TIMESTAMP:
-   case PIPE_QUERY_TIMESTAMP_DISJOINT:
break;
case PIPE_QUERY_PRIMITIVES_EMITTED:
case PIPE_QUERY_PRIMITIVES_GENERATED:
@@ -209,8 +208,6 @@ static void r600_emit_query_begin(struct 
r600_common_context *ctx, struct r600_q
radeon_emit(cs, va);
radeon_emit(cs, (va  32UL)  0xFF);
break;
-   case PIPE_QUERY_TIMESTAMP_DISJOINT:
-   break;
default:
assert(0);
}
@@ -279,7 +276,6 @@ static void r600_emit_query_end(struct r600_common_context 
*ctx, struct r600_que
radeon_emit(cs, (va  32UL)  0xFF);
break;
 case PIPE_QUERY_GPU_FINISHED:
-case PIPE_QUERY_TIMESTAMP_DISJOINT:
break;
default:
assert(0);
@@ -375,8 +371,6 @@ static struct pipe_query *r600_create_query(struct 
pipe_context *ctx, unsigned q
query-result_size = 8;
query-num_cs_dw = 8;
break;
-   case PIPE_QUERY_TIMESTAMP_DISJOINT:
-   break;
case PIPE_QUERY_PRIMITIVES_EMITTED:
case PIPE_QUERY_PRIMITIVES_GENERATED:
case PIPE_QUERY_SO_STATISTICS:
@@ -391,6 +385,7 @@ static struct pipe_query *r600_create_query(struct 
pipe_context *ctx, unsigned q
query-num_cs_dw = 8;
break;
/* Non-GPU queries. */
+   case PIPE_QUERY_TIMESTAMP_DISJOINT:
case R600_QUERY_DRAW_CALLS:
case R600_QUERY_REQUESTED_VRAM:
case R600_QUERY_REQUESTED_GTT:
@@ -447,6 +442,8 @@ static void r600_begin_query(struct pipe_context *ctx, 
struct pipe_query *query)
 
/* Non-GPU queries. */
switch (rquery-type) {
+   case PIPE_QUERY_TIMESTAMP_DISJOINT:
+   return;
case R600_QUERY_DRAW_CALLS:
rquery-begin_result = rctx-num_draw_calls;
return;
@@ -499,6 +496,8 @@ static void r600_end_query(struct pipe_context *ctx, struct 
pipe_query *query)
 
/* Non-GPU queries. */
switch (rquery-type) {
+   case PIPE_QUERY_TIMESTAMP_DISJOINT:
+   return;
case R600_QUERY_DRAW_CALLS:
rquery-end_result = rctx-num_draw_calls;
return;
@@ -561,6 +560,12 @@ static boolean r600_get_query_buffer_result(struct 
r600_common_context *ctx,
 
/* Non-GPU queries. */
switch (query-type) {
+   case PIPE_QUERY_TIMESTAMP_DISJOINT:
+   /* Convert from cycles per millisecond to cycles per second 
(Hz). */
+   result-timestamp_disjoint.frequency =
+   (uint64_t)ctx-screen-info.r600_clock_crystal_freq * 
1000;
+   result-timestamp_disjoint.disjoint = FALSE;
+   return TRUE;
case R600_QUERY_DRAW_CALLS:
case R600_QUERY_REQUESTED_VRAM:
case R600_QUERY_REQUESTED_GTT:
@@ -612,12 +617,6 @@ static boolean r600_get_query_buffer_result(struct 
r600_common_context *ctx,
  (uint64_t)current_result[1]  32;
break;
}
-   case PIPE_QUERY_TIMESTAMP_DISJOINT:
-   /* Convert from cycles per millisecond to cycles per second 
(Hz). */
-   result-timestamp_disjoint.frequency =
-   (uint64_t)ctx-screen-info.r600_clock_crystal_freq * 
1000;
-   result-timestamp_disjoint.disjoint = FALSE;
-   break;
case PIPE_QUERY_PRIMITIVES_EMITTED:
/* SAMPLE_STREAMOUTSTATS stores this structure:
 * {
-- 
2.1.0

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org

[Mesa-dev] [PATCH 4/4] radeonsi: initialize TC_L2_dirty to false after buffer allocation

2015-02-11 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

I forgot to do this, though true should have no effect on correctness.
---
 src/gallium/drivers/radeon/r600_buffer_common.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/drivers/radeon/r600_buffer_common.c 
b/src/gallium/drivers/radeon/r600_buffer_common.c
index b7306d7..ebe8067 100644
--- a/src/gallium/drivers/radeon/r600_buffer_common.c
+++ b/src/gallium/drivers/radeon/r600_buffer_common.c
@@ -185,6 +185,7 @@ bool r600_init_resource(struct r600_common_screen *rscreen,
pb_reference(old_buf, NULL);
 
util_range_set_empty(res-valid_buffer_range);
+   res-TC_L2_dirty = false;
 
if (rscreen-debug_flags  DBG_VM  res-b.b.target == PIPE_BUFFER) {
fprintf(stderr, VM start=0x%PRIX64  end=0x%PRIX64 | Buffer 
%u bytes\n,
-- 
2.1.0

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


Re: [Mesa-dev] [PATCH] mesa: fix AtomicBuffer typo in _mesa_DeleteBuffers

2015-02-11 Thread Brian Paul

On 02/11/2015 07:24 AM, Marek Olšák wrote:

From: Marek Olšák marek.ol...@amd.com

Cc: 10.5 10.4 10.3 mesa-sta...@lists.freedesktop.org
---
  src/mesa/main/bufferobj.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 0c1ce98..0c23b42 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1226,7 +1226,7 @@ _mesa_DeleteBuffers(GLsizei n, const GLuint *ids)
  }
   }

- if (ctx-UniformBuffer == bufObj) {
+ if (ctx-AtomicBuffer == bufObj) {
  _mesa_BindBuffer( GL_ATOMIC_COUNTER_BUFFER, 0 );
   }




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

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


Re: [Mesa-dev] [PATCH] i965: Use new/delete instead of realloc() in brw_ir_allocator.h

2015-02-11 Thread Francisco Jerez
Matt Turner matts...@gmail.com writes:
[...]
 Indeed. And another thing to consider is that we've discussed
 compiling with -fno-exceptions.


Heh, the benefit you get from doing that is virtually zero.  And in
cases like this where failure would have to be handled many levels up in
the stack and require redesigning an interface used in hundreds of
places making it more awkward to use, not using exceptions is a really
strong incentive not to handle failure at all.  I cannot see any better
solution here other than throwing an exception or letting the program
segfault.

 I think it's okay to add out-of-memory checks where we can reasonably
 do something about them, but code churn *just* to silence a tool (one
 that I'm not aware of catching any meaningful bugs) doesn't seem good.


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


[Mesa-dev] [Bug 89088] Mesa fails to build if indent does not support requested arguments (eg: -nut)

2015-02-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=89088

--- Comment #1 from Matt Turner matts...@gmail.com ---
A commit was made recently to require GNU indent:

commit efef6c828092702b1f928f98d15fb90b4544a85c
Author: Samuel Iglesias Gonsalvez sigles...@igalia.com
Date:   Tue Jan 13 11:02:27 2015 +0100

configure: add check for GNU indent

Do you have this in your tree?

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


[Mesa-dev] [PATCH] glext.h: Add missing include of stddef.h for ptrdiff_t

2015-02-11 Thread Jeremy Huddleston Sequoia

Signed-off-by: Jeremy Huddleston Sequoia jerem...@apple.com
---
 include/GL/glext.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/GL/glext.h b/include/GL/glext.h
index 256ad35..0328cf6 100644
--- a/include/GL/glext.h
+++ b/include/GL/glext.h
@@ -4470,6 +4470,7 @@ GLAPI void APIENTRY glVertexBlendARB (GLint count);
 
 #ifndef GL_ARB_vertex_buffer_object
 #define GL_ARB_vertex_buffer_object 1
+#include stddef.h
 typedef ptrdiff_t GLsizeiptrARB;
 typedef ptrdiff_t GLintptrARB;
 #define GL_BUFFER_SIZE_ARB0x8764
-- 
2.3.0




smime.p7s
Description: S/MIME cryptographic signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/3] nir: Add support for CSE on textures.

2015-02-11 Thread Connor Abbott
On Wed, Feb 11, 2015 at 3:17 PM, Eric Anholt e...@anholt.net wrote:
 Connor Abbott cwabbo...@gmail.com writes:

 On Wed, Feb 11, 2015 at 2:36 PM, Eric Anholt e...@anholt.net wrote:
 Connor Abbott cwabbo...@gmail.com writes:

 On Tue, Feb 10, 2015 at 1:32 PM, Eric Anholt e...@anholt.net wrote:
 Connor Abbott cwabbo...@gmail.com writes:

 On Sat, Feb 7, 2015 at 12:16 AM, Eric Anholt e...@anholt.net wrote:
 NIR instruction count results on i965:
 total instructions in shared programs: 1261954 - 1261937 (-0.00%)
 instructions in affected programs: 455 - 438 (-3.74%)

 One in yofrankie, two in tropics.  Apparently i965 had also optimized 
 all
 of these out anyway.
 ---
  src/glsl/nir/nir_opt_cse.c | 43 
 +++
  1 file changed, 39 insertions(+), 4 deletions(-)

 diff --git a/src/glsl/nir/nir_opt_cse.c b/src/glsl/nir/nir_opt_cse.c
 index b3e9c0d..55dc083 100644
 --- a/src/glsl/nir/nir_opt_cse.c
 +++ b/src/glsl/nir/nir_opt_cse.c
 @@ -80,8 +80,41 @@ nir_instrs_equal(nir_instr *instr1, nir_instr 
 *instr2)
}
return true;
 }
 -   case nir_instr_type_tex:
 -  return false;
 +   case nir_instr_type_tex: {
 +  nir_tex_instr *tex1 = nir_instr_as_tex(instr1);
 +  nir_tex_instr *tex2 = nir_instr_as_tex(instr2);
 +
 +  if (tex1-op != tex2-op)
 + return false;
 +
 +  if (tex1-num_srcs != tex2-num_srcs)
 + return false;
 +  for (unsigned i = 0; i  tex1-num_srcs; i++) {
 + if (tex1-src[i].src_type != tex2-src[i].src_type ||
 + !nir_srcs_equal(tex1-src[i].src, tex2-src[i].src)) {
 +return false;
 + }
 +  }
 +
 +  if (tex1-coord_components != tex2-coord_components ||
 +  tex1-sampler_dim != tex2-sampler_dim ||
 +  tex1-is_array != tex2-is_array ||
 +  tex1-is_shadow != tex2-is_shadow ||
 +  tex1-is_new_style_shadow != tex2-is_new_style_shadow ||
 +  memcmp(tex1-const_offset, tex2-const_offset,
 + sizeof(tex1-const_offset)) != 0 ||
 +  tex1-component != tex2-component ||
 + tex1-sampler_index != tex2-sampler_index ||
 + tex1-sampler_array_size != tex2-sampler_array_size) {

 I think some of these fields are sometimes unused, so you need to
 split them out and not check them if they're unused. For example,
 is_new_style_shadow is only used when is_shadow is true, and component
 isn't used if we're not doing a textureGather (?) op -- I don't
 remember all the details. That, or we have to have a defined value for
 these fields when they're unused and document that somewhere.

 Oh god, we don't zero-allocate structures.  This is going to be awful.

 No, with valgrind it's actually better... you get an error if you
 don't know what you're doing rather than silently having it ignored.
 These days, zero-allocating structures by default doesn't make much
 sense any more.

 So, why should nir.c not be zero-filling those fields, when we zero fill
 the nir_dests and nir_srcs and and tex-sampler and tex-sampler_index
 and deref-base_offset?

 because in 99% of cases, that's what we want. To be clear, I'm not
 against initializing stuff to some default value when it makes sense,
 and in this case I'm fine with initializing all the sometimes-used
 things to 0 and ensuring that they stay 0 to make comparing
 tex_instr's less of a PITA. But I don't think we should be blindly
 calling calloc()/rzalloc() on everything; if there's some field the
 caller has to set, and there's no default value that 99% of callers
 will want, don't set it and then let valgrind find any errors (or,
 even better, pass it as a parameter to the constructor). And yes,
 there are probably a few places where we initialize stuff when it's
 not necessary -- that's a mistake on my part.

 What I most object to about not calling calloc/rzalloc is that it means
 you don't get to find the errors you've created until you happen to run
 under valgrind, since you almost always get zero-filled contents anyway.

That's true, although maybe it's just a sign that you aren't using
valgrind enough. But the alternative of basically making valgrind
useless and masking cases where you actually forgot to initialize
stuff seems a lot worse to me.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/3] nir: Add support for CSE on textures.

2015-02-11 Thread Eric Anholt
Connor Abbott cwabbo...@gmail.com writes:

 On Wed, Feb 11, 2015 at 2:36 PM, Eric Anholt e...@anholt.net wrote:
 Connor Abbott cwabbo...@gmail.com writes:

 On Tue, Feb 10, 2015 at 1:32 PM, Eric Anholt e...@anholt.net wrote:
 Connor Abbott cwabbo...@gmail.com writes:

 On Sat, Feb 7, 2015 at 12:16 AM, Eric Anholt e...@anholt.net wrote:
 NIR instruction count results on i965:
 total instructions in shared programs: 1261954 - 1261937 (-0.00%)
 instructions in affected programs: 455 - 438 (-3.74%)

 One in yofrankie, two in tropics.  Apparently i965 had also optimized all
 of these out anyway.
 ---
  src/glsl/nir/nir_opt_cse.c | 43 
 +++
  1 file changed, 39 insertions(+), 4 deletions(-)

 diff --git a/src/glsl/nir/nir_opt_cse.c b/src/glsl/nir/nir_opt_cse.c
 index b3e9c0d..55dc083 100644
 --- a/src/glsl/nir/nir_opt_cse.c
 +++ b/src/glsl/nir/nir_opt_cse.c
 @@ -80,8 +80,41 @@ nir_instrs_equal(nir_instr *instr1, nir_instr *instr2)
}
return true;
 }
 -   case nir_instr_type_tex:
 -  return false;
 +   case nir_instr_type_tex: {
 +  nir_tex_instr *tex1 = nir_instr_as_tex(instr1);
 +  nir_tex_instr *tex2 = nir_instr_as_tex(instr2);
 +
 +  if (tex1-op != tex2-op)
 + return false;
 +
 +  if (tex1-num_srcs != tex2-num_srcs)
 + return false;
 +  for (unsigned i = 0; i  tex1-num_srcs; i++) {
 + if (tex1-src[i].src_type != tex2-src[i].src_type ||
 + !nir_srcs_equal(tex1-src[i].src, tex2-src[i].src)) {
 +return false;
 + }
 +  }
 +
 +  if (tex1-coord_components != tex2-coord_components ||
 +  tex1-sampler_dim != tex2-sampler_dim ||
 +  tex1-is_array != tex2-is_array ||
 +  tex1-is_shadow != tex2-is_shadow ||
 +  tex1-is_new_style_shadow != tex2-is_new_style_shadow ||
 +  memcmp(tex1-const_offset, tex2-const_offset,
 + sizeof(tex1-const_offset)) != 0 ||
 +  tex1-component != tex2-component ||
 + tex1-sampler_index != tex2-sampler_index ||
 + tex1-sampler_array_size != tex2-sampler_array_size) {

 I think some of these fields are sometimes unused, so you need to
 split them out and not check them if they're unused. For example,
 is_new_style_shadow is only used when is_shadow is true, and component
 isn't used if we're not doing a textureGather (?) op -- I don't
 remember all the details. That, or we have to have a defined value for
 these fields when they're unused and document that somewhere.

 Oh god, we don't zero-allocate structures.  This is going to be awful.

 No, with valgrind it's actually better... you get an error if you
 don't know what you're doing rather than silently having it ignored.
 These days, zero-allocating structures by default doesn't make much
 sense any more.

 So, why should nir.c not be zero-filling those fields, when we zero fill
 the nir_dests and nir_srcs and and tex-sampler and tex-sampler_index
 and deref-base_offset?

 because in 99% of cases, that's what we want. To be clear, I'm not
 against initializing stuff to some default value when it makes sense,
 and in this case I'm fine with initializing all the sometimes-used
 things to 0 and ensuring that they stay 0 to make comparing
 tex_instr's less of a PITA. But I don't think we should be blindly
 calling calloc()/rzalloc() on everything; if there's some field the
 caller has to set, and there's no default value that 99% of callers
 will want, don't set it and then let valgrind find any errors (or,
 even better, pass it as a parameter to the constructor). And yes,
 there are probably a few places where we initialize stuff when it's
 not necessary -- that's a mistake on my part.

What I most object to about not calling calloc/rzalloc is that it means
you don't get to find the errors you've created until you happen to run
under valgrind, since you almost always get zero-filled contents anyway.


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] glext.h: Add missing include of stddef.h for ptrdiff_t

2015-02-11 Thread Matt Turner
On Wed, Feb 11, 2015 at 12:36 PM, Jeremy Huddleston Sequoia
jerem...@freedesktop.org wrote:

 Signed-off-by: Jeremy Huddleston Sequoia jerem...@apple.com

The file comes from Khronos. We can't update it.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2.1/3?] squash! nir_algebraic.py: don't store a dictionary of indexes

2015-02-11 Thread Kenneth Graunke
Since condition_list is an ordered list, we can just use enumerate()
when walking through it to get (index, value) pairs, rather than storing
a second dictionary mapping items to their indices.  When looking for an
existing entry, use list.index() to get the index of that item.
---
 src/glsl/nir/nir_algebraic.py | 15 +--
 1 file changed, 5 insertions(+), 10 deletions(-)

Here's my review feedback for this patch.  I haven't tested it, but it does
compile at least.  With this squashed in, patches 1-2 of the miniseries are

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

diff --git a/src/glsl/nir/nir_algebraic.py b/src/glsl/nir/nir_algebraic.py
index 9c5a906..1acf1ce 100644
--- a/src/glsl/nir/nir_algebraic.py
+++ b/src/glsl/nir/nir_algebraic.py
@@ -128,7 +128,6 @@ class Expression(Value):
 
 _optimization_ids = itertools.count()
 
-condition_index_map = {'true' : 0}
 condition_list = ['true']
 
 class SearchAndReplace(object):
@@ -142,12 +141,9 @@ class SearchAndReplace(object):
   else:
  self.condition = 'true'
 
-  if self.condition in condition_index_map:
- self.condition_index = condition_index_map[self.condition]
-  else:
- self.condition_index = len(condition_list)
+  if self.condition not in condition_list:
  condition_list.append(self.condition)
- condition_index_map[self.condition] = self.condition_index
+  self.condition_index = condition_list.index(self.condition)
 
   varset = VarSet()
   if isinstance(search, Expression):
@@ -250,8 +246,8 @@ ${pass_name}(nir_shader *shader)
bool condition_flags[${len(condition_list)}];
const nir_shader_compiler_options *options = shader-options;
 
-   % for condition in condition_list:
-   condition_flags[${condition_index_map[condition]}] = ${condition};
+   % for index, condition in enumerate(condition_list):
+   condition_flags[${index}] = ${condition};
% endfor
 
nir_foreach_overload(shader, overload) {
@@ -280,5 +276,4 @@ class AlgebraicPass(object):
def render(self):
   return _algebraic_pass_template.render(pass_name=self.pass_name,
  xform_dict=self.xform_dict,
- condition_list=condition_list,
- 
condition_index_map=condition_index_map)
+ condition_list=condition_list)
-- 
2.2.2

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


[Mesa-dev] [PATCH 1/6] mesa: implement GL_AMD_pinned_memory

2015-02-11 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

It's not possible to query the current buffer binding, because the extension
doesn't define GL_..._BUFFER__BINDING_AMD.

Drivers should check the target parameter of Drivers.BufferData. If it's
equal to GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, the memory should be pinned.
That's all there is to it.

A piglit test is on the piglit mailing list.
---
 src/mapi/glapi/gen/gl_API.xml |  4 
 src/mesa/main/bufferobj.c | 33 +++--
 src/mesa/main/extensions.c|  1 +
 src/mesa/main/mtypes.h|  7 +++
 4 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index 17bf62a..cc8aaf3 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -12856,6 +12856,10 @@
 enum name=SKIP_DECODE_EXT  value=0x8A4A/
 /category
 
+category name=GL_AMD_pinned_memory number=411
+enum name=EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD   value=0x9160/
+/category
+
 xi:include href=INTEL_performance_query.xml 
xmlns:xi=http://www.w3.org/2001/XInclude/
 
 category name=GL_EXT_polygon_offset_clamp number=460
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 0c23b42..b372c68 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -117,6 +117,11 @@ get_buffer_target(struct gl_context *ctx, GLenum target)
  return ctx-AtomicBuffer;
   }
   break;
+   case GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD:
+  if (ctx-Extensions.AMD_pinned_memory) {
+ return ctx-ExternalVirtualMemoryBuffer;
+  }
+  break;
default:
   return NULL;
}
@@ -1242,6 +1247,10 @@ _mesa_DeleteBuffers(GLsizei n, const GLuint *ids)
 _mesa_BindBuffer( GL_TEXTURE_BUFFER, 0 );
  }
 
+ if (ctx-ExternalVirtualMemoryBuffer == bufObj) {
+_mesa_BindBuffer(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, 0);
+ }
+
  /* The ID is immediately freed for re-use */
  _mesa_HashRemove(ctx-Shared-BufferObjects, ids[i]);
  /* Make sure we do not run into the classic ABA problem on bind.
@@ -1381,7 +1390,16 @@ _mesa_BufferStorage(GLenum target, GLsizeiptr size, 
const GLvoid *data,
ASSERT(ctx-Driver.BufferData);
if (!ctx-Driver.BufferData(ctx, target, size, data, GL_DYNAMIC_DRAW,
flags, bufObj)) {
-  _mesa_error(ctx, GL_OUT_OF_MEMORY, glBufferStorage());
+  if (target == GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD) {
+ /* Even though the interaction between AMD_pinned_memory and
+  * glBufferStorage is not described in the spec, Graham Sellers
+  * said that it should behave the same as glBufferData.
+  */
+ _mesa_error(ctx, GL_INVALID_OPERATION, glBufferStorage());
+  }
+  else {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, glBufferStorage());
+  }
}
 }
 
@@ -1465,7 +1483,18 @@ _mesa_BufferData(GLenum target, GLsizeiptrARB size,
GL_MAP_WRITE_BIT |
GL_DYNAMIC_STORAGE_BIT,
bufObj)) {
-  _mesa_error(ctx, GL_OUT_OF_MEMORY, glBufferDataARB());
+  if (target == GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD) {
+ /* From GL_AMD_pinned_memory:
+  *
+  *   INVALID_OPERATION is generated by BufferData if target is
+  *   EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, and the store cannot be
+  *   mapped to the GPU address space.
+  */
+ _mesa_error(ctx, GL_INVALID_OPERATION, glBufferData());
+  }
+  else {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, glBufferData());
+  }
}
 }
 
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 220b220..685236a 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -335,6 +335,7 @@ static const struct extension extension_table[] = {
{ GL_AMD_conservative_depth,  o(ARB_conservative_depth),  
GL, 2009 },
{ GL_AMD_draw_buffers_blend,  o(ARB_draw_buffers_blend),  
GL, 2009 },
{ GL_AMD_performance_monitor, o(AMD_performance_monitor), 
GL, 2007 },
+   { GL_AMD_pinned_memory,   o(AMD_pinned_memory),   
GL, 2013 },
{ GL_AMD_seamless_cubemap_per_texture,
o(AMD_seamless_cubemap_per_texture),GL, 2009 },
{ GL_AMD_shader_stencil_export,   
o(ARB_shader_stencil_export),   GL, 2009 },
{ GL_AMD_shader_trinary_minmax,   o(dummy_true),  
GL, 2012 },
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 1c33ef4..08133f1 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3837,6 +3837,7 @@ struct gl_extensions

[Mesa-dev] [PATCH 3/6] winsys/radeon: allow mapping a user buffer by returning the same pointer

2015-02-11 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

OpenGL requires this.
---
 src/gallium/winsys/radeon/drm/radeon_drm_bo.c | 5 +
 src/gallium/winsys/radeon/drm/radeon_drm_bo.h | 1 +
 src/gallium/winsys/radeon/drm/radeon_winsys.h | 4 ++--
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index 2605ca6..8f4b135 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -345,6 +345,10 @@ void *radeon_bo_do_map(struct radeon_bo *bo)
 struct drm_radeon_gem_mmap args = {0};
 void *ptr;
 
+/* If the buffer is created from user memory, return the user pointer. */
+if (bo-user_ptr)
+return bo-user_ptr;
+
 /* Return the pointer if it's already mapped. */
 if (bo-ptr)
 return bo-ptr;
@@ -900,6 +904,7 @@ static struct pb_buffer *radeon_winsys_bo_from_ptr(struct 
radeon_winsys *rws,
 bo-base.vtbl = radeon_bo_vtbl;
 bo-mgr = mgr;
 bo-rws = mgr-rws;
+bo-user_ptr = pointer;
 bo-va = 0;
 bo-initial_domain = RADEON_DOMAIN_GTT;
 pipe_mutex_init(bo-map_mutex);
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.h 
b/src/gallium/winsys/radeon/drm/radeon_drm_bo.h
index 1c00a13..b83ce16 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.h
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.h
@@ -50,6 +50,7 @@ struct radeon_bo {
 
 struct radeon_bomgr *mgr;
 struct radeon_drm_winsys *rws;
+void *user_ptr; /* from buffer_from_ptr */
 
 void *ptr;
 pipe_mutex map_mutex;
diff --git a/src/gallium/winsys/radeon/drm/radeon_winsys.h 
b/src/gallium/winsys/radeon/drm/radeon_winsys.h
index d9fa1ab..3a6037c 100644
--- a/src/gallium/winsys/radeon/drm/radeon_winsys.h
+++ b/src/gallium/winsys/radeon/drm/radeon_winsys.h
@@ -394,8 +394,8 @@ struct radeon_winsys {
 unsigned *stride);
 
 /**
- * Get a winsys buffer from a user pointer. The resulting buffer can't be
- * mapped or exported. Both pointer and size must be page aligned.
+ * Get a winsys buffer from a user pointer. The resulting buffer can't
+ * be exported. Both pointer and size must be page aligned.
  *
  * \param wsThe winsys this function is called from.
  * \param pointer   User pointer to turn into a buffer object.
-- 
2.1.0

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


[Mesa-dev] [PATCH 2/6] gallium: add interface and state tracker support for GL_AMD_pinned_memory

2015-02-11 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

---
 src/gallium/docs/source/screen.rst |  5 +
 src/gallium/drivers/i915/i915_screen.c |  1 +
 src/gallium/drivers/ilo/ilo_screen.c   |  1 +
 src/gallium/drivers/llvmpipe/lp_screen.c   |  1 +
 src/gallium/drivers/nouveau/nv30/nv30_screen.c |  1 +
 src/gallium/drivers/nouveau/nv50/nv50_screen.c |  1 +
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c |  1 +
 src/gallium/drivers/r300/r300_screen.c |  1 +
 src/gallium/drivers/softpipe/sp_screen.c   |  1 +
 src/gallium/drivers/svga/svga_screen.c |  1 +
 src/gallium/drivers/vc4/vc4_screen.c   |  1 +
 src/gallium/include/pipe/p_defines.h   |  1 +
 src/gallium/include/pipe/p_screen.h|  8 
 src/mesa/state_tracker/st_cb_bufferobjects.c   | 18 +-
 src/mesa/state_tracker/st_extensions.c |  1 +
 15 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/src/gallium/docs/source/screen.rst 
b/src/gallium/docs/source/screen.rst
index aa519d2..313980a 100644
--- a/src/gallium/docs/source/screen.rst
+++ b/src/gallium/docs/source/screen.rst
@@ -246,6 +246,11 @@ The integer capabilities:
 * ``PIPE_CAP_MULTISAMPLE_Z_RESOLVE``: Whether the driver supports blitting
   a multisampled depth buffer into a single-sampled texture (or depth buffer).
   Only the first sampled should be copied.
+* ``PIPE_CAP_RESOURCE_FROM_USER_MEMORY``: Whether the driver can create
+  a pipe_resource where an already-existing piece of (malloc'd) user memory
+  is used as its backing storage. In other words, whether the driver can map
+  existing user memory into the device address space for direct device access.
+  The create function is pipe_screen::resource_from_user_memory.
 
 
 .. _pipe_capf:
diff --git a/src/gallium/drivers/i915/i915_screen.c 
b/src/gallium/drivers/i915/i915_screen.c
index d2199a2..6c35fc8 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -231,6 +231,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap 
cap)
case PIPE_CAP_VERTEXID_NOBASE:
case PIPE_CAP_POLYGON_OFFSET_CLAMP:
case PIPE_CAP_MULTISAMPLE_Z_RESOLVE:
+   case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
   return 0;
 
case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS:
diff --git a/src/gallium/drivers/ilo/ilo_screen.c 
b/src/gallium/drivers/ilo/ilo_screen.c
index 6e9e723..0182b7f 100644
--- a/src/gallium/drivers/ilo/ilo_screen.c
+++ b/src/gallium/drivers/ilo/ilo_screen.c
@@ -473,6 +473,7 @@ ilo_get_param(struct pipe_screen *screen, enum pipe_cap 
param)
case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
case PIPE_CAP_SAMPLER_VIEW_TARGET:
case PIPE_CAP_MULTISAMPLE_Z_RESOLVE:
+   case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
   return 0;
 
case PIPE_CAP_VENDOR_ID:
diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c 
b/src/gallium/drivers/llvmpipe/lp_screen.c
index 31c65df..8b6e66e 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -288,6 +288,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum 
pipe_cap param)
case PIPE_CAP_POLYGON_OFFSET_CLAMP:
   return 1;
case PIPE_CAP_MULTISAMPLE_Z_RESOLVE:
+   case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
   return 0;
}
/* should only get here on unhandled cases */
diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c 
b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
index 9c183f2..247ecbb 100644
--- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
+++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
@@ -160,6 +160,7 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
case PIPE_CAP_VERTEXID_NOBASE:
case PIPE_CAP_POLYGON_OFFSET_CLAMP:
case PIPE_CAP_MULTISAMPLE_Z_RESOLVE:
+   case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
   return 0;
 
case PIPE_CAP_VENDOR_ID:
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c 
b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
index b79c237..729fc04 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
@@ -208,6 +208,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
case PIPE_CAP_DRAW_INDIRECT:
case PIPE_CAP_VERTEXID_NOBASE:
case PIPE_CAP_MULTISAMPLE_Z_RESOLVE: /* potentially supported on some hw */
+   case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
   return 0;
 
case PIPE_CAP_VENDOR_ID:
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c 
b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
index 4e53ca4..956905c 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
@@ -192,6 +192,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
case PIPE_CAP_FAKE_SW_MSAA:
case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
case PIPE_CAP_VERTEXID_NOBASE:
+   case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
   return 0;
 

[Mesa-dev] [PATCH 4/6] winsys/radeon: allow unaligned size for user-memory buffers

2015-02-11 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

This is not required, but being user-friendly doesn't hurt.
---
 src/gallium/winsys/radeon/drm/radeon_drm_bo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index 8f4b135..e3b2c22 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -883,7 +883,7 @@ static struct pb_buffer *radeon_winsys_bo_from_ptr(struct 
radeon_winsys *rws,
 
 memset(args, 0, sizeof(args));
 args.addr = (uintptr_t)pointer;
-args.size = size;
+args.size = align(size, sysconf(_SC_PAGE_SIZE));
 args.flags = RADEON_GEM_USERPTR_ANONONLY |
 RADEON_GEM_USERPTR_VALIDATE |
 RADEON_GEM_USERPTR_REGISTER;
-- 
2.1.0

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


[Mesa-dev] [PATCH 5/6] winsys/radeon: test the userptr ioctl to see if it's present

2015-02-11 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

There seems to be no other way to check for support.
The DRM version wasn't bumped.
---
 src/gallium/winsys/radeon/drm/radeon_drm_bo.c | 18 --
 src/gallium/winsys/radeon/drm/radeon_drm_cs.h |  1 -
 src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 15 +++
 src/gallium/winsys/radeon/drm/radeon_drm_winsys.h | 19 +++
 src/gallium/winsys/radeon/drm/radeon_winsys.h |  1 +
 5 files changed, 35 insertions(+), 19 deletions(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index e3b2c22..e609d68 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -42,24 +42,6 @@
 #include fcntl.h
 #include stdio.h
 
-#ifndef DRM_RADEON_GEM_USERPTR
-
-#define DRM_RADEON_GEM_USERPTR 0x2d
-
-#define RADEON_GEM_USERPTR_READONLY(1  0)
-#define RADEON_GEM_USERPTR_ANONONLY(1  1)
-#define RADEON_GEM_USERPTR_VALIDATE(1  2)
-#define RADEON_GEM_USERPTR_REGISTER(1  3)
-
-struct drm_radeon_gem_userptr {
-   uint64_taddr;
-   uint64_tsize;
-   uint32_tflags;
-   uint32_thandle;
-};
-
-#endif
-
 extern const struct pb_vtbl radeon_bo_vtbl;
 
 static INLINE struct radeon_bo *radeon_bo(struct pb_buffer *bo)
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_cs.h 
b/src/gallium/winsys/radeon/drm/radeon_drm_cs.h
index 089494e..fcc29fe 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_cs.h
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_cs.h
@@ -28,7 +28,6 @@
 #define RADEON_DRM_CS_H
 
 #include radeon_drm_bo.h
-#include radeon_drm.h
 
 struct radeon_cs_context {
 uint32_tbuf[RADEON_MAX_CMDBUF_DWORDS];
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
index 72b7931..2b12f4d 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
@@ -309,6 +309,21 @@ static boolean do_winsys_init(struct radeon_drm_winsys *ws)
}
 }
 
+/* Check for userptr support. */
+{
+struct drm_radeon_gem_userptr args = {0};
+
+/* If the ioctl doesn't exist, -EINVAL is returned.
+ *
+ * If the ioctl exists, it should return -EACCES
+ * if RADEON_GEM_USERPTR_READONLY or RADEON_GEM_USERPTR_REGISTER
+ * aren't set.
+ */
+ws-info.has_userptr =
+drmCommandWriteRead(ws-fd, DRM_RADEON_GEM_USERPTR,
+args, sizeof(args)) == -EACCES;
+}
+
 /* Get GEM info. */
 retval = drmCommandWriteRead(ws-fd, DRM_RADEON_GEM_INFO,
 gem_info, sizeof(gem_info));
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h 
b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
index 1e0c632..5711ffa 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h
@@ -32,6 +32,25 @@
 
 #include radeon_winsys.h
 #include os/os_thread.h
+#include radeon_drm.h
+
+#ifndef DRM_RADEON_GEM_USERPTR
+
+#define DRM_RADEON_GEM_USERPTR 0x2d
+
+#define RADEON_GEM_USERPTR_READONLY(1  0)
+#define RADEON_GEM_USERPTR_ANONONLY(1  1)
+#define RADEON_GEM_USERPTR_VALIDATE(1  2)
+#define RADEON_GEM_USERPTR_REGISTER(1  3)
+
+struct drm_radeon_gem_userptr {
+   uint64_taddr;
+   uint64_tsize;
+   uint32_tflags;
+   uint32_thandle;
+};
+
+#endif
 
 struct radeon_drm_cs;
 
diff --git a/src/gallium/winsys/radeon/drm/radeon_winsys.h 
b/src/gallium/winsys/radeon/drm/radeon_winsys.h
index 3a6037c..a8cc60a 100644
--- a/src/gallium/winsys/radeon/drm/radeon_winsys.h
+++ b/src/gallium/winsys/radeon/drm/radeon_winsys.h
@@ -214,6 +214,7 @@ struct radeon_info {
 
 boolean has_uvd;
 uint32_tvce_fw_version;
+boolean has_userptr;
 
 uint32_tr300_num_gb_pipes;
 uint32_tr300_num_z_pipes;
-- 
2.1.0

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


[Mesa-dev] [PATCH 6/6] r600g, radeonsi: implement GL_AMD_pinned_memory

2015-02-11 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

---
 src/gallium/drivers/r600/r600_pipe.c|  3 ++
 src/gallium/drivers/radeon/r600_buffer_common.c | 47 ++---
 src/gallium/drivers/radeon/r600_pipe_common.c   |  1 +
 src/gallium/drivers/radeon/r600_pipe_common.h   |  4 +++
 src/gallium/drivers/radeonsi/si_pipe.c  |  3 ++
 5 files changed, 54 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_pipe.c 
b/src/gallium/drivers/r600/r600_pipe.c
index e10b224..f226b8d 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -270,6 +270,9 @@ static int r600_get_param(struct pipe_screen* pscreen, enum 
pipe_cap param)
case PIPE_CAP_POLYGON_OFFSET_CLAMP:
return 1;
 
+   case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
+   return !R600_BIG_ENDIAN  rscreen-b.info.has_userptr;
+
case PIPE_CAP_COMPUTE:
return rscreen-b.chip_class  R700;
 
diff --git a/src/gallium/drivers/radeon/r600_buffer_common.c 
b/src/gallium/drivers/radeon/r600_buffer_common.c
index ebe8067..fc5f6c2 100644
--- a/src/gallium/drivers/radeon/r600_buffer_common.c
+++ b/src/gallium/drivers/radeon/r600_buffer_common.c
@@ -385,11 +385,10 @@ static const struct u_resource_vtbl r600_buffer_vtbl =
NULL/* transfer_inline_write */
 };
 
-struct pipe_resource *r600_buffer_create(struct pipe_screen *screen,
-const struct pipe_resource *templ,
-unsigned alignment)
+static struct r600_resource *
+r600_alloc_buffer_struct(struct pipe_screen *screen,
+const struct pipe_resource *templ)
 {
-   struct r600_common_screen *rscreen = (struct r600_common_screen*)screen;
struct r600_resource *rbuffer;
 
rbuffer = MALLOC_STRUCT(r600_resource);
@@ -399,7 +398,17 @@ struct pipe_resource *r600_buffer_create(struct 
pipe_screen *screen,
rbuffer-b.b.screen = screen;
rbuffer-b.vtbl = r600_buffer_vtbl;
rbuffer-buf = NULL;
+   rbuffer-TC_L2_dirty = false;
util_range_init(rbuffer-valid_buffer_range);
+   return rbuffer;
+}
+
+struct pipe_resource *r600_buffer_create(struct pipe_screen *screen,
+const struct pipe_resource *templ,
+unsigned alignment)
+{
+   struct r600_common_screen *rscreen = (struct r600_common_screen*)screen;
+   struct r600_resource *rbuffer = r600_alloc_buffer_struct(screen, templ);
 
if (!r600_init_resource(rscreen, rbuffer, templ-width0, alignment, 
TRUE)) {
FREE(rbuffer);
@@ -407,3 +416,33 @@ struct pipe_resource *r600_buffer_create(struct 
pipe_screen *screen,
}
return rbuffer-b.b;
 }
+
+struct pipe_resource *
+r600_buffer_from_user_memory(struct pipe_screen *screen,
+const struct pipe_resource *templ,
+void *user_memory)
+{
+   struct r600_common_screen *rscreen = (struct r600_common_screen*)screen;
+   struct radeon_winsys *ws = rscreen-ws;
+   struct r600_resource *rbuffer = r600_alloc_buffer_struct(screen, templ);
+
+   rbuffer-domains = RADEON_DOMAIN_GTT;
+   util_range_add(rbuffer-valid_buffer_range, 0, templ-width0);
+
+   /* Convert a user pointer to a buffer. */
+   rbuffer-buf = ws-buffer_from_ptr(ws, user_memory, templ-width0);
+   if (!rbuffer-buf) {
+   FREE(rbuffer);
+   return NULL;
+   }
+
+   rbuffer-cs_buf = ws-buffer_get_cs_handle(rbuffer-buf);
+
+   if (rscreen-info.r600_virtual_address)
+   rbuffer-gpu_address =
+   ws-buffer_get_virtual_address(rbuffer-cs_buf);
+   else
+   rbuffer-gpu_address = 0;
+
+   return rbuffer-b.b;
+}
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c 
b/src/gallium/drivers/radeon/r600_pipe_common.c
index ee4cda7..dabe53c 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.c
+++ b/src/gallium/drivers/radeon/r600_pipe_common.c
@@ -833,6 +833,7 @@ bool r600_common_screen_init(struct r600_common_screen 
*rscreen,
rscreen-b.fence_reference = r600_fence_reference;
rscreen-b.fence_signalled = r600_fence_signalled;
rscreen-b.resource_destroy = u_resource_destroy_vtbl;
+   rscreen-b.resource_from_user_memory = r600_buffer_from_user_memory;
 
if (rscreen-info.has_uvd) {
rscreen-b.get_video_param = rvid_get_video_param;
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h 
b/src/gallium/drivers/radeon/r600_pipe_common.h
index 46a6bf3..a5c7bd3 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.h
+++ b/src/gallium/drivers/radeon/r600_pipe_common.h
@@ -445,6 +445,10 @@ bool r600_init_resource(struct r600_common_screen *rscreen,
 struct pipe_resource *r600_buffer_create(struct pipe_screen *screen,
   

[Mesa-dev] [PATCH] nir: Zero-init our structures.

2015-02-11 Thread Eric Anholt
We were filling out almost all fields of almost all instructions, but
leaving out a couple of them.  This simplifies the source code, cuts 700
bytes from the compiled binary, and prevents developer surprise when one
field of your otherwise-containing-defaults struct is actually
uninitialized.
---
 src/glsl/nir/nir.c | 138 +++--
 1 file changed, 29 insertions(+), 109 deletions(-)

diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
index b46fd30..1a95060 100644
--- a/src/glsl/nir/nir.c
+++ b/src/glsl/nir/nir.c
@@ -31,7 +31,7 @@
 nir_shader *
 nir_shader_create(void *mem_ctx)
 {
-   nir_shader *shader = ralloc(mem_ctx, nir_shader);
+   nir_shader *shader = rzalloc(mem_ctx, nir_shader);
 
shader-uniforms = _mesa_hash_table_create(shader, _mesa_key_hash_string,
   _mesa_key_string_equal);
@@ -40,18 +40,10 @@ nir_shader_create(void *mem_ctx)
shader-outputs = _mesa_hash_table_create(shader, _mesa_key_hash_string,
  _mesa_key_string_equal);
 
-   shader-num_user_structures = 0;
-   shader-user_structures = NULL;
-
exec_list_make_empty(shader-functions);
exec_list_make_empty(shader-registers);
exec_list_make_empty(shader-globals);
exec_list_make_empty(shader-system_values);
-   shader-reg_alloc = 0;
-
-   shader-num_inputs = 0;
-   shader-num_outputs = 0;
-   shader-num_uniforms = 0;
 
return shader;
 }
@@ -59,7 +51,7 @@ nir_shader_create(void *mem_ctx)
 static nir_register *
 reg_create(void *mem_ctx, struct exec_list *list)
 {
-   nir_register *reg = ralloc(mem_ctx, nir_register);
+   nir_register *reg = rzalloc(mem_ctx, nir_register);
 
reg-uses = _mesa_set_create(mem_ctx, _mesa_hash_pointer,
 _mesa_key_pointer_equal);
@@ -68,11 +60,6 @@ reg_create(void *mem_ctx, struct exec_list *list)
reg-if_uses = _mesa_set_create(mem_ctx, _mesa_hash_pointer,
_mesa_key_pointer_equal);
 
-   reg-num_components = 0;
-   reg-num_array_elems = 0;
-   reg-is_packed = false;
-   reg-name = NULL;
-
exec_list_push_tail(list, reg-node);
 
return reg;
@@ -107,7 +94,7 @@ nir_reg_remove(nir_register *reg)
 nir_function *
 nir_function_create(nir_shader *shader, const char *name)
 {
-   nir_function *func = ralloc(shader, nir_function);
+   nir_function *func = rzalloc(shader, nir_function);
 
exec_list_push_tail(shader-functions, func-node);
exec_list_make_empty(func-overload_list);
@@ -122,12 +109,9 @@ nir_function_overload_create(nir_function *func)
 {
void *mem_ctx = ralloc_parent(func);
 
-   nir_function_overload *overload = ralloc(mem_ctx, nir_function_overload);
+   nir_function_overload *overload = rzalloc(mem_ctx, nir_function_overload);
 
-   overload-num_params = 0;
-   overload-params = NULL;
overload-return_type = glsl_void_type();
-   overload-impl = NULL;
 
exec_list_push_tail(func-overload_list, overload-node);
overload-function = func;
@@ -247,7 +231,7 @@ nir_function_impl_create(nir_function_overload *overload)
 
void *mem_ctx = ralloc_parent(overload);
 
-   nir_function_impl *impl = ralloc(mem_ctx, nir_function_impl);
+   nir_function_impl *impl = rzalloc(mem_ctx, nir_function_impl);
 
overload-impl = impl;
impl-overload = overload;
@@ -257,11 +241,6 @@ nir_function_impl_create(nir_function_overload *overload)
exec_list_make_empty(impl-body);
exec_list_make_empty(impl-registers);
exec_list_make_empty(impl-locals);
-   impl-num_params = 0;
-   impl-params = NULL;
-   impl-return_var = NULL;
-   impl-reg_alloc = 0;
-   impl-ssa_alloc = 0;
impl-valid_metadata = nir_metadata_none;
 
/* create start  end blocks */
@@ -283,14 +262,12 @@ nir_function_impl_create(nir_function_overload *overload)
 nir_block *
 nir_block_create(void *mem_ctx)
 {
-   nir_block *block = ralloc(mem_ctx, nir_block);
+   nir_block *block = rzalloc(mem_ctx, nir_block);
 
cf_init(block-cf_node, nir_cf_node_block);
 
-   block-successors[0] = block-successors[1] = NULL;
block-predecessors = _mesa_set_create(mem_ctx, _mesa_hash_pointer,
   _mesa_key_pointer_equal);
-   block-imm_dom = NULL;
block-dom_frontier = _mesa_set_create(mem_ctx, _mesa_hash_pointer,
   _mesa_key_pointer_equal);
 
@@ -299,22 +276,12 @@ nir_block_create(void *mem_ctx)
return block;
 }
 
-static inline void
-src_init(nir_src *src)
-{
-   src-is_ssa = false;
-   src-reg.reg = NULL;
-   src-reg.indirect = NULL;
-   src-reg.base_offset = 0;
-}
-
 nir_if *
 nir_if_create(void *mem_ctx)
 {
-   nir_if *if_stmt = ralloc(mem_ctx, nir_if);
+   nir_if *if_stmt = rzalloc(mem_ctx, nir_if);
 
cf_init(if_stmt-cf_node, nir_cf_node_if);
-   src_init(if_stmt-condition);
 
nir_block *then = nir_block_create(mem_ctx);
exec_list_make_empty(if_stmt-then_list);
@@ -332,7 +299,7 @@ 

[Mesa-dev] [PATCH 1/3] glsl: Propagate negates through multiplication chains.

2015-02-11 Thread Matt Turner
We propagate negations to the right-most leaves of the multiplication
expression trees:

 - mul(neg(x), neg(y)) - mul(x, y)
 - mul(neg(x), y) - neg(mul(x, y))
 - mul(x, neg(y)) - neg(mul(x, y))

total instructions in shared programs: 5943123 - 5937229 (-0.10%)
instructions in affected programs: 868221 - 862327 (-0.68%)
helped:4518
HURT:  356
GAINED:1
---
 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 7bc65da..aecd6e1 100644
--- a/src/glsl/opt_algebraic.cpp
+++ b/src/glsl/opt_algebraic.cpp
@@ -514,6 +514,20 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
   if (is_vec_negative_one(op_const[1]))
  return neg(ir-operands[0]);
 
+  if (op_expr[0]  op_expr[0]-operation == ir_unop_neg) {
+ if (op_expr[1]  op_expr[1]-operation == ir_unop_neg) {
+/* mul(neg(x), neg(y)) - mul(x, y) */
+return mul(op_expr[0]-operands[0], op_expr[1]-operands[0]);
+ }
+
+ /* mul(neg(x), y) - neg(mul(x, y)) */
+ return neg(mul(op_expr[0]-operands[0], ir-operands[1]));
+  }
+
+  /* mul(x, neg(y)) - neg(mul(x, y)) */
+  if (op_expr[1]  op_expr[1]-operation == ir_unop_neg) {
+ return neg(mul(ir-operands[0], op_expr[1]-operands[0]));
+  }
 
   /* Reassociate multiplication of constants so that we can do
* constant folding.
-- 
2.0.5

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


[Mesa-dev] [PATCH 1/3] i965/fs: Add unit tests for saturate propagation pass.

2015-02-11 Thread Matt Turner
Cc: mesa-sta...@lists.freedesktop.org
---
 src/mesa/drivers/dri/i965/Makefile.am  |   7 +
 .../dri/i965/test_fs_saturate_propagation.cpp  | 355 +
 2 files changed, 362 insertions(+)
 create mode 100644 src/mesa/drivers/dri/i965/test_fs_saturate_propagation.cpp

diff --git a/src/mesa/drivers/dri/i965/Makefile.am 
b/src/mesa/drivers/dri/i965/Makefile.am
index 07eefce..53e91fe 100644
--- a/src/mesa/drivers/dri/i965/Makefile.am
+++ b/src/mesa/drivers/dri/i965/Makefile.am
@@ -54,6 +54,7 @@ TEST_LIBS = \
 
 TESTS = \
test_fs_cmod_propagation \
+   test_fs_saturate_propagation \
 test_eu_compact \
test_vf_float_conversions \
 test_vec4_copy_propagation \
@@ -67,6 +68,12 @@ test_fs_cmod_propagation_LDADD = \
$(TEST_LIBS) \
$(top_builddir)/src/gtest/libgtest.la
 
+test_fs_saturate_propagation_SOURCES = \
+   test_fs_saturate_propagation.cpp
+test_fs_saturate_propagation_LDADD = \
+   $(TEST_LIBS) \
+   $(top_builddir)/src/gtest/libgtest.la
+
 test_vf_float_conversions_SOURCES = \
test_vf_float_conversions.cpp
 test_vf_float_conversions_LDADD = \
diff --git a/src/mesa/drivers/dri/i965/test_fs_saturate_propagation.cpp 
b/src/mesa/drivers/dri/i965/test_fs_saturate_propagation.cpp
new file mode 100644
index 000..2000830
--- /dev/null
+++ b/src/mesa/drivers/dri/i965/test_fs_saturate_propagation.cpp
@@ -0,0 +1,355 @@
+/*
+ * Copyright © 2015 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the Software),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include gtest/gtest.h
+#include brw_fs.h
+#include brw_cfg.h
+#include program/program.h
+
+class saturate_propagation_test : public ::testing::Test {
+   virtual void SetUp();
+
+public:
+   struct brw_context *brw;
+   struct gl_context *ctx;
+   struct brw_wm_prog_data *prog_data;
+   struct gl_shader_program *shader_prog;
+   struct brw_fragment_program *fp;
+   fs_visitor *v;
+};
+
+class saturate_propagation_fs_visitor : public fs_visitor
+{
+public:
+   saturate_propagation_fs_visitor(struct brw_context *brw,
+   struct brw_wm_prog_data *prog_data,
+   struct gl_shader_program *shader_prog)
+  : fs_visitor(brw, NULL, NULL, prog_data, shader_prog, NULL, 8) {}
+};
+
+
+void saturate_propagation_test::SetUp()
+{
+   brw = (struct brw_context *)calloc(1, sizeof(*brw));
+   ctx = brw-ctx;
+
+   fp = ralloc(NULL, struct brw_fragment_program);
+   prog_data = ralloc(NULL, struct brw_wm_prog_data);
+   shader_prog = ralloc(NULL, struct gl_shader_program);
+
+   v = new saturate_propagation_fs_visitor(brw, prog_data, shader_prog);
+
+   _mesa_init_fragment_program(ctx, fp-program, GL_FRAGMENT_SHADER, 0);
+
+   brw-gen = 4;
+}
+
+static fs_inst *
+instruction(bblock_t *block, int num)
+{
+   fs_inst *inst = (fs_inst *)block-start();
+   for (int i = 0; i  num; i++) {
+  inst = (fs_inst *)inst-next;
+   }
+   return inst;
+}
+
+static bool
+saturate_propagation(fs_visitor *v)
+{
+   const bool print = false;
+
+   if (print) {
+  fprintf(stderr, = Before =\n);
+  v-cfg-dump(v);
+   }
+
+   bool ret = v-opt_saturate_propagation();
+
+   if (print) {
+  fprintf(stderr, \n= After =\n);
+  v-cfg-dump(v);
+   }
+
+   return ret;
+}
+
+TEST_F(saturate_propagation_test, basic)
+{
+   fs_reg dst0 = v-vgrf(glsl_type::float_type);
+   fs_reg dst1 = v-vgrf(glsl_type::float_type);
+   fs_reg src0 = v-vgrf(glsl_type::float_type);
+   fs_reg src1 = v-vgrf(glsl_type::float_type);
+   v-emit(BRW_OPCODE_ADD, dst0, src0, src1);
+   v-emit(BRW_OPCODE_MOV, dst1, dst0)
+  -saturate = true;
+
+   /* = Before =
+*
+* 0: add(8)dst0  src0  src1
+* 1: mov.sat(8)dst1  dst0
+*
+* = After =
+* 0: add.sat(8)dst0  src0  src1
+* 1: mov(8)dst1  dst0
+*/
+
+   v-calculate_cfg();
+   bblock_t *block0 = v-cfg-blocks[0];
+
+   

[Mesa-dev] [PATCH 2/3] i965/fs: Use fs_inst::overwrites_reg() in saturate propagation.

2015-02-11 Thread Matt Turner
This is safer and matches the conditional_mod propagation pass.

Cc: mesa-sta...@lists.freedesktop.org
---
 .../dri/i965/brw_fs_saturate_propagation.cpp   |  8 ++---
 .../dri/i965/test_fs_saturate_propagation.cpp  | 40 ++
 2 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp
index a9966a4..bc51661 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp
@@ -64,10 +64,10 @@ opt_saturate_propagation_local(fs_visitor *v, bblock_t 
*block)
 
   bool interfered = false;
   foreach_inst_in_block_reverse_starting_from(fs_inst, scan_inst, inst, 
block) {
- if (scan_inst-dst.file == GRF 
- scan_inst-dst.reg == inst-src[0].reg 
- scan_inst-dst.reg_offset == inst-src[0].reg_offset 
- !scan_inst-is_partial_write()) {
+ if (scan_inst-overwrites_reg(inst-src[0])) {
+if (scan_inst-is_partial_write())
+   break;
+
 if (scan_inst-saturate) {
inst-saturate = false;
progress = true;
diff --git a/src/mesa/drivers/dri/i965/test_fs_saturate_propagation.cpp 
b/src/mesa/drivers/dri/i965/test_fs_saturate_propagation.cpp
index 2000830..f897bdd 100644
--- a/src/mesa/drivers/dri/i965/test_fs_saturate_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/test_fs_saturate_propagation.cpp
@@ -353,3 +353,43 @@ TEST_F(saturate_propagation_test, 
intervening_saturating_copy)
EXPECT_EQ(BRW_OPCODE_MOV, instruction(block0, 2)-opcode);
EXPECT_FALSE(instruction(block0, 2)-saturate);
 }
+
+TEST_F(saturate_propagation_test, intervening_dest_write)
+{
+   fs_reg dst0 = v-vgrf(glsl_type::vec4_type);
+   fs_reg dst1 = v-vgrf(glsl_type::float_type);
+   fs_reg src0 = v-vgrf(glsl_type::float_type);
+   fs_reg src1 = v-vgrf(glsl_type::float_type);
+   fs_reg src2 = v-vgrf(glsl_type::vec2_type);
+   v-emit(BRW_OPCODE_ADD, offset(dst0, 2), src0, src1);
+   v-emit(SHADER_OPCODE_TEX, dst0, src2)
+  -regs_written = 4;
+   v-emit(BRW_OPCODE_MOV, dst1, offset(dst0, 2))
+  -saturate = true;
+
+   /* = Before =
+*
+* 0: add(8)dst0+2  src0src1
+* 1: tex(8) rlen 4 dst0+0  src2
+* 2: mov.sat(8)dst1dst0+2
+*
+* = After =
+* (no changes)
+*/
+
+   v-calculate_cfg();
+   bblock_t *block0 = v-cfg-blocks[0];
+
+   EXPECT_EQ(0, block0-start_ip);
+   EXPECT_EQ(2, block0-end_ip);
+
+   EXPECT_FALSE(saturate_propagation(v));
+   EXPECT_EQ(0, block0-start_ip);
+   EXPECT_EQ(2, block0-end_ip);
+   EXPECT_EQ(BRW_OPCODE_ADD, instruction(block0, 0)-opcode);
+   EXPECT_FALSE(instruction(block0, 0)-saturate);
+   EXPECT_EQ(SHADER_OPCODE_TEX, instruction(block0, 1)-opcode);
+   EXPECT_FALSE(instruction(block0, 0)-saturate);
+   EXPECT_EQ(BRW_OPCODE_MOV, instruction(block0, 2)-opcode);
+   EXPECT_TRUE(instruction(block0, 2)-saturate);
+}
-- 
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] i965: Emit MUL with a negated src for neg(mul(...)).

2015-02-11 Thread Matt Turner
total instructions in shared programs: 5932832 - 5932736 (-0.00%)
instructions in affected programs: 8184 - 8088 (-1.17%)
helped:52
HURT:  14
GAINED:1
---
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp   | 14 ++
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 19 +++
 2 files changed, 33 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index b628bff..17849c7 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -630,6 +630,20 @@ fs_visitor::visit(ir_expression *ir)
 
/* Deal with the real oddball stuff first */
switch (ir-operation) {
+   case ir_unop_neg: {
+  if (!ir-type-is_float())
+ break;
+
+  ir_expression *mul = ir-operands[0]-as_expression();
+  if (mul  mul-operation == ir_binop_mul) {
+ mul-accept(this);
+ fs_inst *mul_inst = (fs_inst *) this-instructions.get_tail();
+ assert(mul_inst-opcode == BRW_OPCODE_MUL);
+
+ mul_inst-src[1].negate = true;
+  }
+  break;
+   }
case ir_binop_add:
   if (brw-gen = 5  try_emit_line(ir))
  return;
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index 5638105..2c21344 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -1309,6 +1309,25 @@ vec4_visitor::visit(ir_expression *ir)
src_reg op[Elements(ir-operands)];
vec4_instruction *inst;
 
+   switch (ir-operation) {
+   case ir_unop_neg: {
+  if (!ir-type-is_float())
+ break;
+
+  ir_expression *mul = ir-operands[0]-as_expression();
+  if (mul  mul-operation == ir_binop_mul) {
+ mul-accept(this);
+ vec4_instruction *mul_inst = (vec4_instruction *) 
this-instructions.get_tail();
+ assert(mul_inst-opcode == BRW_OPCODE_MUL);
+
+ mul_inst-src[1].negate = true;
+  }
+  break;
+   }
+   default:
+  break;
+   }
+
if (ir-operation == ir_binop_add) {
   if (try_emit_mad(ir))
 return;
-- 
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] i965/fs: Consider MOV.SAT to interfere if it has a source modifier.

2015-02-11 Thread Matt Turner
The saturate propagation pass recognizes that the second instruction
below does not interfere with an attempt to propagate the saturate
modifier from instruction 3 to 1.

 1:  add(8) dst0   src0  src1
 2:  mov.sat(8) dst1   dst0
 3:  mov.sat(8) dst2   dst0

Unfortunately, we did not consider the case of instruction 2 having a
source modifier on dst0. Take for instance:

 1:  add(8) dst0   src0  src1
 2:  mov.sat(8) dst1  -dst0
 3:  mov.sat(8) dst2   dst0

Consider such an instruction to interfere. Increase instruction counts
in Anomaly 2, which could be a bug fix depending on the values the first
instruction produces.

Cc: mesa-sta...@lists.freedesktop.org
---
 .../dri/i965/brw_fs_saturate_propagation.cpp   | 12 --
 .../dri/i965/test_fs_saturate_propagation.cpp  | 44 ++
 2 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp
index bc51661..e406c28 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_saturate_propagation.cpp
@@ -81,12 +81,16 @@ opt_saturate_propagation_local(fs_visitor *v, bblock_t 
*block)
 break;
  }
  for (int i = 0; i  scan_inst-sources; i++) {
-if ((scan_inst-opcode != BRW_OPCODE_MOV || !scan_inst-saturate) 

-scan_inst-src[i].file == GRF 
+if (scan_inst-src[i].file == GRF 
 scan_inst-src[i].reg == inst-src[0].reg 
 scan_inst-src[i].reg_offset == inst-src[0].reg_offset) {
-   interfered = true;
-   break;
+   if (scan_inst-opcode != BRW_OPCODE_MOV ||
+   !scan_inst-saturate ||
+   scan_inst-src[0].abs ||
+   scan_inst-src[0].negate) {
+  interfered = true;
+  break;
+   }
 }
  }
 
diff --git a/src/mesa/drivers/dri/i965/test_fs_saturate_propagation.cpp 
b/src/mesa/drivers/dri/i965/test_fs_saturate_propagation.cpp
index f897bdd..6f762bc 100644
--- a/src/mesa/drivers/dri/i965/test_fs_saturate_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/test_fs_saturate_propagation.cpp
@@ -393,3 +393,47 @@ TEST_F(saturate_propagation_test, intervening_dest_write)
EXPECT_EQ(BRW_OPCODE_MOV, instruction(block0, 2)-opcode);
EXPECT_TRUE(instruction(block0, 2)-saturate);
 }
+
+TEST_F(saturate_propagation_test, mul_neg_mov_sat_mov_sat)
+{
+   fs_reg dst0 = v-vgrf(glsl_type::float_type);
+   fs_reg dst1 = v-vgrf(glsl_type::float_type);
+   fs_reg dst2 = v-vgrf(glsl_type::float_type);
+   fs_reg src0 = v-vgrf(glsl_type::float_type);
+   fs_reg src1 = v-vgrf(glsl_type::float_type);
+   v-emit(BRW_OPCODE_MUL, dst0, src0, src1);
+   dst0.negate = true;
+   v-emit(BRW_OPCODE_MOV, dst1, dst0)
+  -saturate = true;
+   dst0.negate = false;
+   v-emit(BRW_OPCODE_MOV, dst2, dst0)
+  -saturate = true;
+
+   /* = Before =
+*
+* 0: mul(8)dst0  src0  src1
+* 1: mov.sat(8)dst1  -dst0
+* 2: mov.sat(8)dst2  dst0
+*
+* = After =
+* (no changes)
+*/
+
+   v-calculate_cfg();
+   bblock_t *block0 = v-cfg-blocks[0];
+
+   EXPECT_EQ(0, block0-start_ip);
+   EXPECT_EQ(2, block0-end_ip);
+
+   EXPECT_FALSE(saturate_propagation(v));
+   EXPECT_EQ(0, block0-start_ip);
+   EXPECT_EQ(2, block0-end_ip);
+   EXPECT_EQ(BRW_OPCODE_MUL, instruction(block0, 0)-opcode);
+   EXPECT_FALSE(instruction(block0, 0)-saturate);
+   EXPECT_FALSE(instruction(block0, 0)-src[1].negate);
+   EXPECT_EQ(BRW_OPCODE_MOV, instruction(block0, 1)-opcode);
+   EXPECT_TRUE(instruction(block0, 1)-saturate);
+   EXPECT_TRUE(instruction(block0, 1)-src[0].negate);
+   EXPECT_EQ(BRW_OPCODE_MOV, instruction(block0, 2)-opcode);
+   EXPECT_TRUE(instruction(block0, 2)-saturate);
+}
-- 
2.0.5

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


[Mesa-dev] [PATCH 2/3] i965/fs: Allow CSE to handle MULs with negated arguments.

2015-02-11 Thread Matt Turner
mul x, -y is equivalent to mul -x, y; and mul x, y is the negation of
mul x, -y.

total instructions in shared programs: 5937689 - 5929512 (-0.14%)
instructions in affected programs: 871152 - 862975 (-0.94%)
helped:4228
HURT:  17
GAINED:12
---
 src/mesa/drivers/dri/i965/brw_fs_cse.cpp | 43 +++-
 1 file changed, 37 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
index ae069bb..803c3be 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
@@ -116,7 +116,6 @@ is_expression_commutative(const fs_inst *inst)
case BRW_OPCODE_OR:
case BRW_OPCODE_XOR:
case BRW_OPCODE_ADD:
-   case BRW_OPCODE_MUL:
   return true;
case BRW_OPCODE_SEL:
   /* MIN and MAX are commutative. */
@@ -131,7 +130,7 @@ is_expression_commutative(const fs_inst *inst)
 }
 
 static bool
-operands_match(const fs_inst *a, const fs_inst *b)
+operands_match(const fs_inst *a, const fs_inst *b, bool *negate)
 {
fs_reg *xs = a-src;
fs_reg *ys = b-src;
@@ -140,6 +139,35 @@ operands_match(const fs_inst *a, const fs_inst *b)
   return xs[0].equals(ys[0]) 
  ((xs[1].equals(ys[1])  xs[2].equals(ys[2])) ||
   (xs[2].equals(ys[1])  xs[1].equals(ys[2])));
+   } else if (a-opcode == BRW_OPCODE_MUL  a-dst.type == 
BRW_REGISTER_TYPE_F) {
+  bool xs0_negate = xs[0].negate;
+  bool xs1_negate = xs[1].file == IMM ? xs[1].fixed_hw_reg.dw1.f  0.0f
+  : xs[1].negate;
+  bool ys0_negate = ys[0].negate;
+  bool ys1_negate = ys[1].file == IMM ? ys[1].fixed_hw_reg.dw1.f  0.0f
+  : ys[1].negate;
+  float xs1_imm = xs[1].fixed_hw_reg.dw1.f;
+  float ys1_imm = ys[1].fixed_hw_reg.dw1.f;
+
+  xs[0].negate = false;
+  xs[1].negate = false;
+  ys[0].negate = false;
+  ys[1].negate = false;
+  xs[1].fixed_hw_reg.dw1.f = fabsf(xs[1].fixed_hw_reg.dw1.f);
+  ys[1].fixed_hw_reg.dw1.f = fabsf(ys[1].fixed_hw_reg.dw1.f);
+
+  bool ret = (xs[0].equals(ys[0])  xs[1].equals(ys[1])) ||
+ (xs[1].equals(ys[0])  xs[0].equals(ys[1]));
+
+  xs[0].negate = xs0_negate;
+  xs[1].negate = xs[1].file == IMM ? false : xs1_negate;
+  ys[0].negate = ys0_negate;
+  ys[1].negate = ys[1].file == IMM ? false : ys1_negate;
+  xs[1].fixed_hw_reg.dw1.f = xs1_imm;
+  ys[1].fixed_hw_reg.dw1.f = ys1_imm;
+
+  *negate = (xs0_negate + xs1_negate) != (ys0_negate + ys1_negate);
+  return ret;
} else if (!is_expression_commutative(a)) {
   bool match = true;
   for (int i = 0; i  a-sources; i++) {
@@ -156,7 +184,7 @@ operands_match(const fs_inst *a, const fs_inst *b)
 }
 
 static bool
-instructions_match(fs_inst *a, fs_inst *b)
+instructions_match(fs_inst *a, fs_inst *b, bool *negate)
 {
return a-opcode == b-opcode 
   a-saturate == b-saturate 
@@ -173,7 +201,7 @@ instructions_match(fs_inst *a, fs_inst *b)
   a-header_present == b-header_present 
   a-shadow_compare == b-shadow_compare)
: true) 
-  operands_match(a, b);
+  operands_match(a, b, negate);
 }
 
 bool
@@ -191,11 +219,12 @@ fs_visitor::opt_cse_local(bblock_t *block)
   (inst-dst.file != HW_REG || inst-dst.is_null()))
   {
  bool found = false;
+ bool negate = false;
 
  foreach_in_list_use_after(aeb_entry, entry, aeb) {
 /* Match current instruction's expression against those in AEB. */
 if (!(entry-generator-dst.is_null()  !inst-dst.is_null()) 
-instructions_match(inst, entry-generator)) {
+instructions_match(inst, entry-generator, negate)) {
found = true;
progress = true;
break;
@@ -261,6 +290,7 @@ fs_visitor::opt_cse_local(bblock_t *block)
} else {
   copy = MOV(dst, tmp);
   copy-force_writemask_all = inst-force_writemask_all;
+  copy-src[0].negate = negate;
}
inst-insert_before(block, copy);
 }
@@ -281,9 +311,10 @@ fs_visitor::opt_cse_local(bblock_t *block)
   * the flag register if we just wrote it.
   */
  if (inst-writes_flag()) {
+bool negate; /* dummy */
 if (entry-generator-reads_flag() ||
 (entry-generator-writes_flag() 
- !instructions_match(inst, entry-generator))) {
+ !instructions_match(inst, entry-generator, negate))) {
entry-remove();
ralloc_free(entry);
continue;
-- 
2.0.5

___
mesa-dev mailing list

Re: [Mesa-dev] [PATCH 1/2] gallium: define unreachable macro

2015-02-11 Thread Tobias Klausmann


On 11.02.2015 16:50, Ilia Mirkin wrote:

It's already defined in src/util/macros.h which you can include via
#include util/macros.h -- I suspect some key gallium file should
include that...
Mh, i was under the expression these should be duped, as we already have 
STATIC_ASSERT and likely/unlikely in p_compiler.h

We could clean these up there and include macros.h there...


On Wed, Feb 11, 2015 at 10:47 AM, Tobias Klausmann
tobias.johannes.klausm...@mni.thm.de wrote:

This is done the same way for glsl et al. already

Signed-off-by: Tobias Klausmann tobias.johannes.klausm...@mni.thm.de
---
  src/gallium/include/pipe/p_compiler.h | 23 +++
  1 file changed, 23 insertions(+)

diff --git a/src/gallium/include/pipe/p_compiler.h 
b/src/gallium/include/pipe/p_compiler.h
index fb018bf..62ba9d3 100644
--- a/src/gallium/include/pipe/p_compiler.h
+++ b/src/gallium/include/pipe/p_compiler.h
@@ -249,6 +249,29 @@ void _ReadWriteBarrier(void);


  /**
+ * Unreachable macro. Useful for suppressing control reaches end of non-void
+ * function warnings.
+ */
+#ifdef HAVE___BUILTIN_UNREACHABLE
+#define unreachable(str)\
+do {\
+   assert(!str);\
+   __builtin_unreachable(); \
+} while (0)
+#elif _MSC_VER = 1200
+#define unreachable(str)\
+do {\
+   assert(!str);\
+   __assume(0); \
+} while (0)
+#endif
+
+#ifndef unreachable
+#define unreachable(str) assert(!str)
+#endif
+
+
+/**
   * Static (compile-time) assertion.
   * Basically, use COND to dimension an array.  If COND is false/zero the
   * array size will be -1 and we'll get a compilation error.
--
2.2.2



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


[Mesa-dev] [Bug 89050] [HSW DRI3] Piglit glx_GLX_ARB_create_context_current_with_no_framebuffer fails

2015-02-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=89050

Chris Wilson ch...@chris-wilson.co.uk changed:

   What|Removed |Added

 Status|NEEDINFO|RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #4 from Chris Wilson ch...@chris-wilson.co.uk ---
There's a patch on bug 79629.

*** This bug has been marked as a duplicate of bug 79629 ***

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


[Mesa-dev] [Bug 79629] [Dri3 bisected] piglit glx_GLX_ARB_create_context_current_with_no_framebuffer fail

2015-02-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=79629

--- Comment #18 from Chris Wilson ch...@chris-wilson.co.uk ---
*** Bug 89050 has been marked as a duplicate of this bug. ***

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


[Mesa-dev] [Bug 88852] macros.h(181) : error C2143: syntax error : missing '{' before 'enum [tag]'

2015-02-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=88852

Ian Romanick i...@freedesktop.org changed:

   What|Removed |Added

 Status|NEW |NEEDINFO

--- Comment #2 from Ian Romanick i...@freedesktop.org ---
ping?

I think Jason's patches landed, right?  Can we close this?

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


[Mesa-dev] [Bug 88535] Mesa 10.3.0 implementation error: gen7_update_renderbuffer_surface: renderbuffer format MESA_FORMAT_RGBX_UNORM16 unsupported

2015-02-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=88535

Ian Romanick i...@freedesktop.org changed:

   What|Removed |Added

 Status|NEW |NEEDINFO

--- Comment #3 from Ian Romanick i...@freedesktop.org ---
Are you able to test with 10.4.4 stable release or 10.5 branch?

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


[Mesa-dev] [Bug 89088] Mesa fails to build if indent does not support requested arguments (eg: -nut)

2015-02-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=89088

Matt Turner matts...@gmail.com changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|mesa-dev@lists.freedesktop. |jerem...@freedesktop.org
   |org |

--- Comment #3 from Matt Turner matts...@gmail.com ---
Okay. Please send a cherry-pick request to mesa-sta...@lists.freedesktop.org.

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


Re: [Mesa-dev] [PATCH 10/10] i965/fs: Add algebraic optimizations for MAD.

2015-02-11 Thread Matt Turner
On Mon, Feb 9, 2015 at 6:00 PM, Kenneth Graunke kenn...@whitecape.org wrote:
 With that fixed, and the shader-db numbers confirmed, patches 9-10 are:
 Reviewed-by: Kenneth Graunke kenn...@whitecape.org

To close the loop, the shader-db results are unchanged after the fix.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/3] glsl: Propagate negates through multiplication chains.

2015-02-11 Thread Ian Romanick
On 02/11/2015 02:54 PM, Matt Turner wrote:
 We propagate negations to the right-most leaves of the multiplication
 expression trees:
 
  - mul(neg(x), neg(y)) - mul(x, y)
  - mul(neg(x), y) - neg(mul(x, y))
  - mul(x, neg(y)) - neg(mul(x, y))
 
 total instructions in shared programs: 5943123 - 5937229 (-0.10%)
 instructions in affected programs: 868221 - 862327 (-0.68%)
 helped:4518
 HURT:  356
 GAINED:1

This seems very counter intuitive.  Why does this help?  It seems like
the negate modifier on the multiplication sources should be free... how
do we get cheaper than free? :)

 ---
  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 7bc65da..aecd6e1 100644
 --- a/src/glsl/opt_algebraic.cpp
 +++ b/src/glsl/opt_algebraic.cpp
 @@ -514,6 +514,20 @@ ir_algebraic_visitor::handle_expression(ir_expression 
 *ir)
if (is_vec_negative_one(op_const[1]))
   return neg(ir-operands[0]);
  
 +  if (op_expr[0]  op_expr[0]-operation == ir_unop_neg) {
 + if (op_expr[1]  op_expr[1]-operation == ir_unop_neg) {
 +/* mul(neg(x), neg(y)) - mul(x, y) */
 +return mul(op_expr[0]-operands[0], op_expr[1]-operands[0]);
 + }
 +
 + /* mul(neg(x), y) - neg(mul(x, y)) */
 + return neg(mul(op_expr[0]-operands[0], ir-operands[1]));
 +  }
 +
 +  /* mul(x, neg(y)) - neg(mul(x, y)) */
 +  if (op_expr[1]  op_expr[1]-operation == ir_unop_neg) {
 + return neg(mul(ir-operands[0], op_expr[1]-operands[0]));
 +  }
  
/* Reassociate multiplication of constants so that we can do
 * constant folding.
 

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


[Mesa-dev] [Bug 63717] Poor performance in games with Intel 965GM

2015-02-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=63717

Matt Turner matts...@gmail.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |WONTFIX

--- Comment #4 from Matt Turner matts...@gmail.com ---
I'm going to mark as RESOLVED/WONTFIX because no one is going to focus on 965GM
performance (sorry). Various optimizations will trickle down to 965GM though.

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


Re: [Mesa-dev] [PATCH 3/3] i965: Emit MUL with a negated src for neg(mul(...)).

2015-02-11 Thread Ian Romanick
On 02/11/2015 02:54 PM, Matt Turner wrote:
 total instructions in shared programs: 5932832 - 5932736 (-0.00%)
 instructions in affected programs: 8184 - 8088 (-1.17%)
 helped:52
 HURT:  14
 GAINED:1
 ---
  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp   | 14 ++
  src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 19 +++
  2 files changed, 33 insertions(+)
 
 diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp 
 b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
 index b628bff..17849c7 100644
 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
 +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
 @@ -630,6 +630,20 @@ fs_visitor::visit(ir_expression *ir)
  
 /* Deal with the real oddball stuff first */
 switch (ir-operation) {
 +   case ir_unop_neg: {
 +  if (!ir-type-is_float())
 + break;
 +
 +  ir_expression *mul = ir-operands[0]-as_expression();
 +  if (mul  mul-operation == ir_binop_mul) {
 + mul-accept(this);
 + fs_inst *mul_inst = (fs_inst *) this-instructions.get_tail();
 + assert(mul_inst-opcode == BRW_OPCODE_MUL);
 +
 + mul_inst-src[1].negate = true;

Are you sure that mul_inst-src[1].negate will be false?

Also, shouldn't this return here?  The other cases return when they are
able to generate code for the expression.

 +  }
 +  break;
 +   }
 case ir_binop_add:
if (brw-gen = 5  try_emit_line(ir))
   return;
 diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp 
 b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
 index 5638105..2c21344 100644
 --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
 +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
 @@ -1309,6 +1309,25 @@ vec4_visitor::visit(ir_expression *ir)
 src_reg op[Elements(ir-operands)];
 vec4_instruction *inst;
  
 +   switch (ir-operation) {
 +   case ir_unop_neg: {
 +  if (!ir-type-is_float())
 + break;
 +
 +  ir_expression *mul = ir-operands[0]-as_expression();
 +  if (mul  mul-operation == ir_binop_mul) {
 + mul-accept(this);
 + vec4_instruction *mul_inst = (vec4_instruction *) 
 this-instructions.get_tail();
 + assert(mul_inst-opcode == BRW_OPCODE_MUL);
 +
 + mul_inst-src[1].negate = true;
 +  }
 +  break;
 +   }
 +   default:
 +  break;
 +   }
 +
 if (ir-operation == ir_binop_add) {
if (try_emit_mad(ir))
return;
 

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


Re: [Mesa-dev] [PATCH 1/3] glsl: Propagate negates through multiplication chains.

2015-02-11 Thread Ian Romanick
On 02/11/2015 04:05 PM, Matt Turner wrote:
 On Wed, Feb 11, 2015 at 3:51 PM, Ian Romanick i...@freedesktop.org wrote:
 On 02/11/2015 02:54 PM, Matt Turner wrote:
 We propagate negations to the right-most leaves of the multiplication
 expression trees:

  - mul(neg(x), neg(y)) - mul(x, y)
  - mul(neg(x), y) - neg(mul(x, y))
  - mul(x, neg(y)) - neg(mul(x, y))

 total instructions in shared programs: 5943123 - 5937229 (-0.10%)
 instructions in affected programs: 868221 - 862327 (-0.68%)
 helped:4518
 HURT:  356
 GAINED:1

 This seems very counter intuitive.  Why does this help?  It seems like
 the negate modifier on the multiplication sources should be free... how
 do we get cheaper than free? :)
 
 Lots of shaders do things like var * 0.5 and var * -0.5. By making the
 second of those -(var * 0.5) we can do the multiplication once and use
 its result in both places, negated once.
 
 I also noticed we were generating a lot more LRPs after this. I guess
 the LRP peephole is able to recognize more stuff without some negates
 in the way.
 
 If you want, I can try to take a closer look at some affected shaders
 -- though it is kind of hard. Diff'ing GLSL IR is impossible, and even
 if you get past the compiler_temp@ variables being renumbered it's
 still really difficult to see what's going on.

Naw, that's fine.  Enabling additional CSE is a perfectly valid
explanation... though it makes me wonder if CSE should be smarter.  For
all the programs helped, about 8% are hurt.  *shrug*
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 88885] Transform feedback uses incorrect interleaving if a previous draw did not write gl_Position

2015-02-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=5

Carl Worth cwo...@cworth.org changed:

   What|Removed |Added

   Assignee|mesa-dev@lists.freedesktop. |cwo...@cworth.org
   |org |

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


Re: [Mesa-dev] [PATCH] nir: Zero-init our structures.

2015-02-11 Thread Jason Ekstrand
I didn't look through it close enough to call it a review, but I like it.
Especially getting rid of src/def_init.

Acked-by: Jason Ekstrand jason.ekstr...@intel.com

On Wed, Feb 11, 2015 at 4:32 PM, Eric Anholt e...@anholt.net wrote:

 We were filling out almost all fields of almost all instructions, but
 leaving out a couple of them.  This simplifies the source code, cuts 700
 bytes from the compiled binary, and prevents developer surprise when one
 field of your otherwise-containing-defaults struct is actually
 uninitialized.
 ---
  src/glsl/nir/nir.c | 138
 +++--
  1 file changed, 29 insertions(+), 109 deletions(-)

 diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
 index b46fd30..1a95060 100644
 --- a/src/glsl/nir/nir.c
 +++ b/src/glsl/nir/nir.c
 @@ -31,7 +31,7 @@
  nir_shader *
  nir_shader_create(void *mem_ctx)
  {
 -   nir_shader *shader = ralloc(mem_ctx, nir_shader);
 +   nir_shader *shader = rzalloc(mem_ctx, nir_shader);

 shader-uniforms = _mesa_hash_table_create(shader,
 _mesa_key_hash_string,
_mesa_key_string_equal);
 @@ -40,18 +40,10 @@ nir_shader_create(void *mem_ctx)
 shader-outputs = _mesa_hash_table_create(shader,
 _mesa_key_hash_string,
   _mesa_key_string_equal);

 -   shader-num_user_structures = 0;
 -   shader-user_structures = NULL;
 -
 exec_list_make_empty(shader-functions);
 exec_list_make_empty(shader-registers);
 exec_list_make_empty(shader-globals);
 exec_list_make_empty(shader-system_values);
 -   shader-reg_alloc = 0;
 -
 -   shader-num_inputs = 0;
 -   shader-num_outputs = 0;
 -   shader-num_uniforms = 0;

 return shader;
  }
 @@ -59,7 +51,7 @@ nir_shader_create(void *mem_ctx)
  static nir_register *
  reg_create(void *mem_ctx, struct exec_list *list)
  {
 -   nir_register *reg = ralloc(mem_ctx, nir_register);
 +   nir_register *reg = rzalloc(mem_ctx, nir_register);

 reg-uses = _mesa_set_create(mem_ctx, _mesa_hash_pointer,
  _mesa_key_pointer_equal);
 @@ -68,11 +60,6 @@ reg_create(void *mem_ctx, struct exec_list *list)
 reg-if_uses = _mesa_set_create(mem_ctx, _mesa_hash_pointer,
 _mesa_key_pointer_equal);

 -   reg-num_components = 0;
 -   reg-num_array_elems = 0;
 -   reg-is_packed = false;
 -   reg-name = NULL;
 -
 exec_list_push_tail(list, reg-node);

 return reg;
 @@ -107,7 +94,7 @@ nir_reg_remove(nir_register *reg)
  nir_function *
  nir_function_create(nir_shader *shader, const char *name)
  {
 -   nir_function *func = ralloc(shader, nir_function);
 +   nir_function *func = rzalloc(shader, nir_function);

 exec_list_push_tail(shader-functions, func-node);
 exec_list_make_empty(func-overload_list);
 @@ -122,12 +109,9 @@ nir_function_overload_create(nir_function *func)
  {
 void *mem_ctx = ralloc_parent(func);

 -   nir_function_overload *overload = ralloc(mem_ctx,
 nir_function_overload);
 +   nir_function_overload *overload = rzalloc(mem_ctx,
 nir_function_overload);

 -   overload-num_params = 0;
 -   overload-params = NULL;
 overload-return_type = glsl_void_type();
 -   overload-impl = NULL;

 exec_list_push_tail(func-overload_list, overload-node);
 overload-function = func;
 @@ -247,7 +231,7 @@ nir_function_impl_create(nir_function_overload
 *overload)

 void *mem_ctx = ralloc_parent(overload);

 -   nir_function_impl *impl = ralloc(mem_ctx, nir_function_impl);
 +   nir_function_impl *impl = rzalloc(mem_ctx, nir_function_impl);

 overload-impl = impl;
 impl-overload = overload;
 @@ -257,11 +241,6 @@ nir_function_impl_create(nir_function_overload
 *overload)
 exec_list_make_empty(impl-body);
 exec_list_make_empty(impl-registers);
 exec_list_make_empty(impl-locals);
 -   impl-num_params = 0;
 -   impl-params = NULL;
 -   impl-return_var = NULL;
 -   impl-reg_alloc = 0;
 -   impl-ssa_alloc = 0;
 impl-valid_metadata = nir_metadata_none;

 /* create start  end blocks */
 @@ -283,14 +262,12 @@ nir_function_impl_create(nir_function_overload
 *overload)
  nir_block *
  nir_block_create(void *mem_ctx)
  {
 -   nir_block *block = ralloc(mem_ctx, nir_block);
 +   nir_block *block = rzalloc(mem_ctx, nir_block);

 cf_init(block-cf_node, nir_cf_node_block);

 -   block-successors[0] = block-successors[1] = NULL;
 block-predecessors = _mesa_set_create(mem_ctx, _mesa_hash_pointer,
_mesa_key_pointer_equal);
 -   block-imm_dom = NULL;
 block-dom_frontier = _mesa_set_create(mem_ctx, _mesa_hash_pointer,
_mesa_key_pointer_equal);

 @@ -299,22 +276,12 @@ nir_block_create(void *mem_ctx)
 return block;
  }

 -static inline void
 -src_init(nir_src *src)
 -{
 -   src-is_ssa = false;
 -   src-reg.reg = NULL;
 -   src-reg.indirect = NULL;
 -   src-reg.base_offset = 0;
 -}
 -
  nir_if *

[Mesa-dev] [Bug 89088] Mesa fails to build if indent does not support requested arguments (eg: -nut)

2015-02-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=89088

--- Comment #2 from Jeremy Huddleston jerem...@freedesktop.org ---
No, I was encountering this on the MacPorts Snow Leopard buildbot after
updating mesa from 8.0.5 to 10.4.4.  We should probably cherry-pick that into
10.5 and 10.4.

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


Re: [Mesa-dev] [PATCH v3 01/12] nir/dominance: Expose the dominance intersection function

2015-02-11 Thread Connor Abbott
Reviewed-by: Connor Abbott cwabbo...@gmail.com

On Mon, Feb 9, 2015 at 11:24 PM, Jason Ekstrand ja...@jlekstrand.net wrote:
 Being able to find the least common anscestor in the dominance tree is a
 useful thing that we may want to do in other passes.  In particular, we
 need it for GCM.

 v2: Handle NULL inputs by returning the other block
 ---
  src/glsl/nir/nir.h   |  2 ++
  src/glsl/nir/nir_dominance.c | 22 ++
  2 files changed, 24 insertions(+)

 diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
 index 4cb2e92..886dcd2 100644
 --- a/src/glsl/nir/nir.h
 +++ b/src/glsl/nir/nir.h
 @@ -1500,6 +1500,8 @@ static inline void nir_validate_shader(nir_shader 
 *shader) { }
  void nir_calc_dominance_impl(nir_function_impl *impl);
  void nir_calc_dominance(nir_shader *shader);

 +nir_block *nir_dominance_lca(nir_block *b1, nir_block *b2);
 +
  void nir_dump_dom_tree_impl(nir_function_impl *impl, FILE *fp);
  void nir_dump_dom_tree(nir_shader *shader, FILE *fp);

 diff --git a/src/glsl/nir/nir_dominance.c b/src/glsl/nir/nir_dominance.c
 index 67fdcc6..831b9a3 100644
 --- a/src/glsl/nir/nir_dominance.c
 +++ b/src/glsl/nir/nir_dominance.c
 @@ -212,6 +212,28 @@ nir_calc_dominance(nir_shader *shader)
 }
  }

 +/**
 + * Computes the least common anscestor of two blocks.  If one of the blocks
 + * is null, the other block is returned.
 + */
 +nir_block *
 +nir_dominance_lca(nir_block *b1, nir_block *b2)
 +{
 +   if (b1 == NULL)
 +  return b2;
 +
 +   if (b2 == NULL)
 +  return b1;
 +
 +   assert(nir_cf_node_get_function(b1-cf_node) ==
 +  nir_cf_node_get_function(b2-cf_node));
 +
 +   assert(nir_cf_node_get_function(b1-cf_node)-valid_metadata 
 +  nir_metadata_dominance);
 +
 +   return intersect(b1, b2);
 +}
 +
  static bool
  dump_block_dom(nir_block *block, void *state)
  {
 --
 2.2.2

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


Re: [Mesa-dev] [PATCH 1/3] glsl: Propagate negates through multiplication chains.

2015-02-11 Thread Matt Turner
On Wed, Feb 11, 2015 at 3:51 PM, Ian Romanick i...@freedesktop.org wrote:
 On 02/11/2015 02:54 PM, Matt Turner wrote:
 We propagate negations to the right-most leaves of the multiplication
 expression trees:

  - mul(neg(x), neg(y)) - mul(x, y)
  - mul(neg(x), y) - neg(mul(x, y))
  - mul(x, neg(y)) - neg(mul(x, y))

 total instructions in shared programs: 5943123 - 5937229 (-0.10%)
 instructions in affected programs: 868221 - 862327 (-0.68%)
 helped:4518
 HURT:  356
 GAINED:1

 This seems very counter intuitive.  Why does this help?  It seems like
 the negate modifier on the multiplication sources should be free... how
 do we get cheaper than free? :)

Lots of shaders do things like var * 0.5 and var * -0.5. By making the
second of those -(var * 0.5) we can do the multiplication once and use
its result in both places, negated once.

I also noticed we were generating a lot more LRPs after this. I guess
the LRP peephole is able to recognize more stuff without some negates
in the way.

If you want, I can try to take a closer look at some affected shaders
-- though it is kind of hard. Diff'ing GLSL IR is impossible, and even
if you get past the compiler_temp@ variables being renumbered it's
still really difficult to see what's going on.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 89050] [HSW DRI3] Piglit glx_GLX_ARB_create_context_current_with_no_framebuffer fails

2015-02-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=89050

Ian Romanick i...@freedesktop.org changed:

   What|Removed |Added

 Status|NEW |NEEDINFO
   Assignee|mesa-dev@lists.freedesktop. |ch...@chris-wilson.co.uk
   |org |

--- Comment #3 from Ian Romanick i...@freedesktop.org ---
Chris, are you able to reproduce this?  Any ideas?

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


[Mesa-dev] [Bug 88852] macros.h(181) : error C2143: syntax error : missing '{' before 'enum [tag]'

2015-02-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=88852

Jason Ekstrand ja...@jlekstrand.net changed:

   What|Removed |Added

 Status|NEEDINFO|RESOLVED
 Resolution|--- |FIXED

--- Comment #3 from Jason Ekstrand ja...@jlekstrand.net ---
Yeah, this should be fixed no.  Closing.

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


[Mesa-dev] [Bug 86944] glsl_parser_extras.cpp, line 1455: Error: Badly formed expression.

2015-02-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=86944

Ian Romanick i...@freedesktop.org changed:

   What|Removed |Added

 Status|NEW |NEEDINFO

--- Comment #10 from Ian Romanick i...@freedesktop.org ---
Is this still an issue?

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


[Mesa-dev] [Bug 82477] [softpipe] piglit fp-long-alu regression

2015-02-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=82477

--- Comment #3 from Ian Romanick i...@freedesktop.org ---
*** Bug 82471 has been marked as a duplicate of this bug. ***

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


[Mesa-dev] [Bug 82471] [swrast] piglit fp-condition_codes-01 regression

2015-02-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=82471

Ian Romanick i...@freedesktop.org changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #1 from Ian Romanick i...@freedesktop.org ---


*** This bug has been marked as a duplicate of bug 82477 ***

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


[Mesa-dev] [Bug 79706] [TRACKER] Mesa regression tracker

2015-02-11 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=79706
Bug 79706 depends on bug 82471, which changed state.

Bug 82471 Summary: [swrast] piglit fp-condition_codes-01 regression
https://bugs.freedesktop.org/show_bug.cgi?id=82471

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |DUPLICATE

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


Re: [Mesa-dev] [PATCH 1/6] mesa: implement GL_AMD_pinned_memory

2015-02-11 Thread Ian Romanick
I was wondering when you'd get around to implementing this. :)

This patch is

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

On 02/11/2015 12:18 PM, Marek Olšák wrote:
 From: Marek Olšák marek.ol...@amd.com
 
 It's not possible to query the current buffer binding, because the extension
 doesn't define GL_..._BUFFER__BINDING_AMD.
 
 Drivers should check the target parameter of Drivers.BufferData. If it's
 equal to GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, the memory should be pinned.
 That's all there is to it.
 
 A piglit test is on the piglit mailing list.
 ---
  src/mapi/glapi/gen/gl_API.xml |  4 
  src/mesa/main/bufferobj.c | 33 +++--
  src/mesa/main/extensions.c|  1 +
  src/mesa/main/mtypes.h|  7 +++
  4 files changed, 43 insertions(+), 2 deletions(-)
 
 diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
 index 17bf62a..cc8aaf3 100644
 --- a/src/mapi/glapi/gen/gl_API.xml
 +++ b/src/mapi/glapi/gen/gl_API.xml
 @@ -12856,6 +12856,10 @@
  enum name=SKIP_DECODE_EXT  value=0x8A4A/
  /category
  
 +category name=GL_AMD_pinned_memory number=411
 +enum name=EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD   value=0x9160/
 +/category
 +
  xi:include href=INTEL_performance_query.xml 
 xmlns:xi=http://www.w3.org/2001/XInclude/
  
  category name=GL_EXT_polygon_offset_clamp number=460
 diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
 index 0c23b42..b372c68 100644
 --- a/src/mesa/main/bufferobj.c
 +++ b/src/mesa/main/bufferobj.c
 @@ -117,6 +117,11 @@ get_buffer_target(struct gl_context *ctx, GLenum target)
   return ctx-AtomicBuffer;
}
break;
 +   case GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD:
 +  if (ctx-Extensions.AMD_pinned_memory) {
 + return ctx-ExternalVirtualMemoryBuffer;
 +  }
 +  break;
 default:
return NULL;
 }
 @@ -1242,6 +1247,10 @@ _mesa_DeleteBuffers(GLsizei n, const GLuint *ids)
  _mesa_BindBuffer( GL_TEXTURE_BUFFER, 0 );
   }
  
 + if (ctx-ExternalVirtualMemoryBuffer == bufObj) {
 +_mesa_BindBuffer(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, 0);
 + }
 +
   /* The ID is immediately freed for re-use */
   _mesa_HashRemove(ctx-Shared-BufferObjects, ids[i]);
   /* Make sure we do not run into the classic ABA problem on bind.
 @@ -1381,7 +1390,16 @@ _mesa_BufferStorage(GLenum target, GLsizeiptr size, 
 const GLvoid *data,
 ASSERT(ctx-Driver.BufferData);
 if (!ctx-Driver.BufferData(ctx, target, size, data, GL_DYNAMIC_DRAW,
 flags, bufObj)) {
 -  _mesa_error(ctx, GL_OUT_OF_MEMORY, glBufferStorage());
 +  if (target == GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD) {
 + /* Even though the interaction between AMD_pinned_memory and
 +  * glBufferStorage is not described in the spec, Graham Sellers
 +  * said that it should behave the same as glBufferData.
 +  */
 + _mesa_error(ctx, GL_INVALID_OPERATION, glBufferStorage());
 +  }
 +  else {
 + _mesa_error(ctx, GL_OUT_OF_MEMORY, glBufferStorage());
 +  }
 }
  }
  
 @@ -1465,7 +1483,18 @@ _mesa_BufferData(GLenum target, GLsizeiptrARB size,
 GL_MAP_WRITE_BIT |
 GL_DYNAMIC_STORAGE_BIT,
 bufObj)) {
 -  _mesa_error(ctx, GL_OUT_OF_MEMORY, glBufferDataARB());
 +  if (target == GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD) {
 + /* From GL_AMD_pinned_memory:
 +  *
 +  *   INVALID_OPERATION is generated by BufferData if target is
 +  *   EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, and the store cannot be
 +  *   mapped to the GPU address space.
 +  */
 + _mesa_error(ctx, GL_INVALID_OPERATION, glBufferData());
 +  }
 +  else {
 + _mesa_error(ctx, GL_OUT_OF_MEMORY, glBufferData());
 +  }
 }
  }
  
 diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
 index 220b220..685236a 100644
 --- a/src/mesa/main/extensions.c
 +++ b/src/mesa/main/extensions.c
 @@ -335,6 +335,7 @@ static const struct extension extension_table[] = {
 { GL_AMD_conservative_depth,  
 o(ARB_conservative_depth),  GL, 2009 },
 { GL_AMD_draw_buffers_blend,  
 o(ARB_draw_buffers_blend),  GL, 2009 },
 { GL_AMD_performance_monitor, 
 o(AMD_performance_monitor), GL, 2007 },
 +   { GL_AMD_pinned_memory,   o(AMD_pinned_memory), 
   GL, 2013 },
 { GL_AMD_seamless_cubemap_per_texture,
 o(AMD_seamless_cubemap_per_texture),GL, 2009 },
 { GL_AMD_shader_stencil_export,   
 o(ARB_shader_stencil_export),   GL, 2009 },
 { 

Re: [Mesa-dev] [PATCH] i965: Use new/delete instead of realloc() in brw_ir_allocator.h

2015-02-11 Thread Ian Romanick
On 02/11/2015 12:15 PM, Francisco Jerez wrote:
 Matt Turner matts...@gmail.com writes:
 [...]
 Indeed. And another thing to consider is that we've discussed
 compiling with -fno-exceptions.

 
 Heh, the benefit you get from doing that is virtually zero.  And in
 cases like this where failure would have to be handled many levels up in
 the stack and require redesigning an interface used in hundreds of
 places making it more awkward to use, not using exceptions is a really
 strong incentive not to handle failure at all.  I cannot see any better
 solution here other than throwing an exception or letting the program
 segfault.

Except OpenGL is a C API.  I don't see how an exception could even get
delivered to a C program calling down into our driver through the GL API.

Since our driver can be called from the X server, just letting the
program segfault is, at best, not cool.

If some of our internals are designed so that we can't handle possibly
handle a resource allocation failure, that internal is designed wrong.
Looking at src/mesa/drivers/dri/i965/brw_ir_allocator.h, there are
several trivial ways that simple_allocator::allocate could be modified
to allow error reporting.

 I think it's okay to add out-of-memory checks where we can reasonably
 do something about them, but code churn *just* to silence a tool (one
 that I'm not aware of catching any meaningful bugs) doesn't seem good.

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




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 3/3] i965: Emit MUL with a negated src for neg(mul(...)).

2015-02-11 Thread Matt Turner
On Wed, Feb 11, 2015 at 3:57 PM, Ian Romanick i...@freedesktop.org wrote:
 On 02/11/2015 02:54 PM, Matt Turner wrote:
 total instructions in shared programs: 5932832 - 5932736 (-0.00%)
 instructions in affected programs: 8184 - 8088 (-1.17%)
 helped:52
 HURT:  14
 GAINED:1
 ---
  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp   | 14 ++
  src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 19 +++
  2 files changed, 33 insertions(+)

 diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp 
 b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
 index b628bff..17849c7 100644
 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
 +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
 @@ -630,6 +630,20 @@ fs_visitor::visit(ir_expression *ir)

 /* Deal with the real oddball stuff first */
 switch (ir-operation) {
 +   case ir_unop_neg: {
 +  if (!ir-type-is_float())
 + break;
 +
 +  ir_expression *mul = ir-operands[0]-as_expression();
 +  if (mul  mul-operation == ir_binop_mul) {
 + mul-accept(this);
 + fs_inst *mul_inst = (fs_inst *) this-instructions.get_tail();
 + assert(mul_inst-opcode == BRW_OPCODE_MUL);
 +
 + mul_inst-src[1].negate = true;

 Are you sure that mul_inst-src[1].negate will be false?

Yes. We used to modify existing operands' negate field in place when
we visited ir_unop_neg, but with commit 0ae9ca12 I changed it so that
we always emit a MOV.

 Also, shouldn't this return here?  The other cases return when they are
 able to generate code for the expression.

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


[Mesa-dev] [PATCH 5/5] r200: Drop unused variable.

2015-02-11 Thread Eric Anholt
Quiets compiler warning since e7f2f2dea5acdbd1a12ed88914e64a38a97432f0.
---
 src/mesa/drivers/dri/r200/r200_ioctl.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/mesa/drivers/dri/r200/r200_ioctl.c 
b/src/mesa/drivers/dri/r200/r200_ioctl.c
index 515be92..d665c8b 100644
--- a/src/mesa/drivers/dri/r200/r200_ioctl.c
+++ b/src/mesa/drivers/dri/r200/r200_ioctl.c
@@ -56,7 +56,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
SOFTWARE.
  */
 static void r200Clear( struct gl_context *ctx, GLbitfield mask )
 {
-   r200ContextPtr rmesa = R200_CONTEXT(ctx);
GLuint hwmask, swmask;
GLuint hwbits = BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT |
BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL |
-- 
2.1.4

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


[Mesa-dev] [PATCH 3/5] i965: Move some asserts to unreachable.

2015-02-11 Thread Eric Anholt
If execution was supposed to be supported in this case, we'd run into
trouble from completely uninitialized sat_imm values.  Shuts up compiler
warnings.
---
 src/mesa/drivers/dri/i965/brw_shader.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp 
b/src/mesa/drivers/dri/i965/brw_shader.cpp
index 3eea088..c758f77 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -607,10 +607,10 @@ brw_saturate_immediate(enum brw_reg_type type, struct 
brw_reg *reg)
case BRW_REGISTER_TYPE_V:
case BRW_REGISTER_TYPE_UV:
case BRW_REGISTER_TYPE_VF:
-  assert(!unimplemented: saturate vector immediate);
+  unreachable(!unimplemented: saturate vector immediate);
case BRW_REGISTER_TYPE_DF:
case BRW_REGISTER_TYPE_HF:
-  assert(!unimplemented: saturate DF/HF immediate);
+  unreachable(!unimplemented: saturate DF/HF immediate);
}
 
if (imm.ud != sat_imm.ud) {
-- 
2.1.4

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


[Mesa-dev] [PATCH 4/5] i965: Quiet another compiler warning about uninitialized values.

2015-02-11 Thread Eric Anholt
The compiler can't tell that we're always going to hit the first if block
on the first time through the loop.
---
 src/mesa/drivers/dri/i965/brw_vec4.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index ee74052..fda8552 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -378,9 +378,9 @@ vec4_visitor::opt_vector_float()
int last_reg = -1, last_reg_offset = -1;
enum register_file last_reg_file = BAD_FILE;
 
-   int remaining_channels;
+   int remaining_channels = 0;
uint8_t imm[4];
-   int inst_count;
+   int inst_count = 0;
vec4_instruction *imm_inst[4];
 
foreach_block_and_inst_safe(block, vec4_instruction, inst, cfg) {
-- 
2.1.4

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


[Mesa-dev] [PATCH 1/5] gallium/dri: Shut up a compiler warning.

2015-02-11 Thread Eric Anholt
The compiler doesn't see that buffers is set in the !image case and used
in the !image case.
---
 src/gallium/state_trackers/dri/dri2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/dri/dri2.c 
b/src/gallium/state_trackers/dri/dri2.c
index aecc8eb..7d65ba3 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -368,7 +368,7 @@ dri2_allocate_textures(struct dri_context *ctx,
/* Image specific variables */
struct __DRIimageList images;
/* Dri2 specific variables */
-   __DRIbuffer *buffers;
+   __DRIbuffer *buffers = NULL;
struct winsys_handle whandle;
unsigned num_buffers = statts_count;
 
-- 
2.1.4

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


[Mesa-dev] [PATCH 2/5] i965: Shut up a compiler warning about uninitialized var.

2015-02-11 Thread Eric Anholt
We always pass this argument, even if it won't be used by the particular
texture op.
---
 src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
index da81b61..3014e3e 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
@@ -1494,7 +1494,7 @@ fs_visitor::nir_emit_texture(nir_tex_instr *instr)
bool is_cube_array = instr-sampler_dim == GLSL_SAMPLER_DIM_CUBE 
 instr-is_array;
 
-   int lod_components, offset_components = 0;
+   int lod_components = 0, offset_components = 0;
 
fs_reg coordinate, shadow_comparitor, lod, lod2, sample_index, mcs, offset;
 
-- 
2.1.4

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


Re: [Mesa-dev] [PATCH 3/3] dri/common: Fix returned value of __DRI2_RENDERER_PREFERRED_PROFILE

2015-02-11 Thread Ian Romanick
On 02/09/2015 04:19 AM, Andreas Boll wrote:
 If the renderer supports the core profile the query returned incorrectly
 0x8 as value, because it was using (1U  __DRI_API_OPENGL_CORE) for the
 returned value.
 
 The same happened with the compatibility profile. It returned 0x1
 (1U  __DRI_API_OPENGL) instead of 0x2.
 
 Used defines for the incorrect behavior:
dri_interface.h: #define __DRI_API_OPENGL   0
dri_interface.h: #define __DRI_API_OPENGL_CORE  3
 
 Now we return GLX_CONTEXT_CORE_PROFILE_BIT_ARB (0x1) for a preferred
 core context profile and GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB (0x2)
 for a preferred compatibility context profile.
 
 Cc: 10.3 10.4 10.5 mesa-sta...@lists.freedesktop.org
 Signed-off-by: Andreas Boll andreas.boll@gmail.com
 ---
 
 I've noticed this wrong behavior while testing Adam's glxinfo changes [1]
 (glxinfo: Add support for GLX_MESA_query_renderer)
 
 For reproducing this bug and/or testing this and the previous patch just run
   glxinfo | grep Preferred profile
 
 Andreas.
 
 [1] 
 http://cgit.freedesktop.org/mesa/demos/commit/?id=999b6950c644266bb871e79438751bdba2fa2a08
 
  src/mesa/drivers/dri/common/utils.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
 
 diff --git a/src/mesa/drivers/dri/common/utils.c 
 b/src/mesa/drivers/dri/common/utils.c
 index ccdc971..08e0d79 100644
 --- a/src/mesa/drivers/dri/common/utils.c
 +++ b/src/mesa/drivers/dri/common/utils.c
 @@ -522,7 +522,8 @@ driQueryRendererIntegerCommon(__DRIscreen *psp, int 
 param, unsigned int *value)
 }
 case __DRI2_RENDERER_PREFERRED_PROFILE:
value[0] = (psp-max_gl_core_version != 0)
 - ? (1U  __DRI_API_OPENGL_CORE) : (1U  __DRI_API_OPENGL);
 + ? GLX_CONTEXT_CORE_PROFILE_BIT_ARB
 + : GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;

The code in src/mesa/drivers/dri/common is supposed to be API (GLX vs.
EGL) agnostic.  The place in the src/glx that calls into the driver is
supposed to translate the (1U  __DRI_API_OPENGL_CORE) into
GLX_CONTEXT_CORE_PROFILE_BIT_ARB.

return 0;
 case __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION:
value[0] = psp-max_gl_core_version / 10;
 

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


Re: [Mesa-dev] [PATCH 1/7] mesa: Add gallium include dirs to more parts of the tree.

2015-02-11 Thread Eric Anholt
Matt Turner matts...@gmail.com writes:

 On Wed, Feb 11, 2015 at 4:48 PM, Eric Anholt e...@anholt.net wrote:
 ---

 Maybe I just read what I wanted to read in the cover letter, but I was
 expecting you to move u_math.h to src/util instead of this patch.

 That doesn't work because of u_math's inclusion of pipe/p_compiler.h?

...which in turn relies on p_config.h.  So, yeah.  Basically I was
trying to get something out that hopefully wouldn't be sufficiently
objected to, that would get us making progress toward more sharing.  I
know I've started toward getting bitset.h moved a bunch of times, and
lost motivation before getting something perfect.  I think I'm not
alone.


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


[Mesa-dev] [PATCH 18/23] main: Add entry point for FlushMappedNamedBufferRange.

2015-02-11 Thread Laura Ekstrand
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  6 ++
 src/mesa/main/bufferobj.c  | 16 
 src/mesa/main/bufferobj.h  |  4 
 src/mesa/main/tests/dispatch_sanity.cpp|  1 +
 4 files changed, 27 insertions(+)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 281646d..27938c5 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -80,6 +80,12 @@
   param name=buffer type=GLuint /
/function
 
+   function name=FlushMappedNamedBufferRange offset=assign
+  param name=buffer type=GLuint /
+  param name=offset type=GLintptr /
+  param name=length type=GLsizeiptr /
+   /function
+
!-- Texture object functions --
 
function name=CreateTextures offset=assign
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 992e940..9b3d2ea 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -2493,6 +2493,22 @@ _mesa_FlushMappedBufferRange(GLenum target, GLintptr 
offset,
glFlushMappedBufferRange);
 }
 
+void GLAPIENTRY
+_mesa_FlushMappedNamedBufferRange(GLuint buffer, GLintptr offset,
+  GLsizeiptr length)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_buffer_object *bufObj;
+
+   bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
+   glFlushMappedNamedBufferRange);
+   if (!bufObj)
+  return;
+
+   _mesa_flush_mapped_buffer_range(ctx, bufObj, offset, length,
+   glFlushMappedNamedBufferRange);
+}
+
 
 static GLenum
 buffer_object_purgeable(struct gl_context *ctx, GLuint name, GLenum option)
diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
index f51bf36..0b77bff 100644
--- a/src/mesa/main/bufferobj.h
+++ b/src/mesa/main/bufferobj.h
@@ -299,6 +299,10 @@ void GLAPIENTRY
 _mesa_FlushMappedBufferRange(GLenum target,
  GLintptr offset, GLsizeiptr length);
 
+void GLAPIENTRY
+_mesa_FlushMappedNamedBufferRange(GLuint buffer, GLintptr offset,
+  GLsizeiptr length);
+
 GLenum GLAPIENTRY
 _mesa_ObjectPurgeableAPPLE(GLenum objectType, GLuint name, GLenum option);
 
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index de52e69..dc6c257 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -965,6 +965,7 @@ const struct function gl_core_functions_possible[] = {
{ glMapNamedBuffer, 45, -1 },
{ glMapNamedBufferRange, 45, -1 },
{ glUnmapNamedBuffer, 45, -1 },
+   { glFlushMappedNamedBufferRange, 45, -1 },
{ glCreateTextures, 45, -1 },
{ glTextureStorage1D, 45, -1 },
{ glTextureStorage2D, 45, -1 },
-- 
2.1.0

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


[Mesa-dev] [PATCH 19/23] main: Refactor GetBufferParameteri[64]v.

2015-02-11 Thread Laura Ekstrand
v2: Split into a refactor commit and an entry point commit.
---
 src/mesa/main/bufferobj.c | 119 ++
 1 file changed, 45 insertions(+), 74 deletions(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 9b3d2ea..dfeda21 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1883,128 +1883,99 @@ _mesa_UnmapNamedBuffer(GLuint buffer)
return _mesa_unmap_buffer(ctx, bufObj, glUnmapNamedBuffer);
 }
 
-void GLAPIENTRY
-_mesa_GetBufferParameteriv(GLenum target, GLenum pname, GLint *params)
-{
-   GET_CURRENT_CONTEXT(ctx);
-   struct gl_buffer_object *bufObj;
-
-   bufObj = get_buffer(ctx, glGetBufferParameterivARB, target,
-   GL_INVALID_OPERATION);
-   if (!bufObj)
-  return;
 
+static bool
+get_buffer_parameter(struct gl_context *ctx,
+ struct gl_buffer_object *bufObj, GLenum pname,
+ GLint64 *params, const char *func)
+{
switch (pname) {
case GL_BUFFER_SIZE_ARB:
-  *params = (GLint) bufObj-Size;
-  return;
+  *params = bufObj-Size;
+  break;
case GL_BUFFER_USAGE_ARB:
   *params = bufObj-Usage;
-  return;
+  break;
case GL_BUFFER_ACCESS_ARB:
   *params = simplified_access_mode(ctx,
 bufObj-Mappings[MAP_USER].AccessFlags);
-  return;
+  break;
case GL_BUFFER_MAPPED_ARB:
   *params = _mesa_bufferobj_mapped(bufObj, MAP_USER);
-  return;
+  break;
case GL_BUFFER_ACCESS_FLAGS:
   if (!ctx-Extensions.ARB_map_buffer_range)
  goto invalid_pname;
   *params = bufObj-Mappings[MAP_USER].AccessFlags;
-  return;
+  break;
case GL_BUFFER_MAP_OFFSET:
   if (!ctx-Extensions.ARB_map_buffer_range)
  goto invalid_pname;
-  *params = (GLint) bufObj-Mappings[MAP_USER].Offset;
-  return;
+  *params = bufObj-Mappings[MAP_USER].Offset;
+  break;
case GL_BUFFER_MAP_LENGTH:
   if (!ctx-Extensions.ARB_map_buffer_range)
  goto invalid_pname;
-  *params = (GLint) bufObj-Mappings[MAP_USER].Length;
-  return;
+  *params = bufObj-Mappings[MAP_USER].Length;
+  break;
case GL_BUFFER_IMMUTABLE_STORAGE:
   if (!ctx-Extensions.ARB_buffer_storage)
  goto invalid_pname;
   *params = bufObj-Immutable;
-  return;
+  break;
case GL_BUFFER_STORAGE_FLAGS:
   if (!ctx-Extensions.ARB_buffer_storage)
  goto invalid_pname;
   *params = bufObj-StorageFlags;
-  return;
+  break;
default:
-  ; /* fall-through */
+  goto invalid_pname;
}
 
+   return true;
+
 invalid_pname:
-   _mesa_error(ctx, GL_INVALID_ENUM, glGetBufferParameterivARB(pname=%s),
+   _mesa_error(ctx, GL_INVALID_ENUM, %s(invalid pname: %s), func,
_mesa_lookup_enum_by_nr(pname));
+   return false;
 }
 
+void GLAPIENTRY
+_mesa_GetBufferParameteriv(GLenum target, GLenum pname, GLint *params)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_buffer_object *bufObj;
+   GLint64 parameter;
+
+   bufObj = get_buffer(ctx, glGetBufferParameteriv, target,
+   GL_INVALID_OPERATION);
+   if (!bufObj)
+  return;
+
+   if (!get_buffer_parameter(ctx, bufObj, pname, parameter,
+ glGetBufferParameteriv))
+  return; /* Error already recorded. */
+
+   *params = (GLint) parameter;
+}
 
-/**
- * New in GL 3.2
- * This is pretty much a duplicate of GetBufferParameteriv() but the
- * GL_BUFFER_SIZE_ARB attribute will be 64-bits on a 64-bit system.
- */
 void GLAPIENTRY
 _mesa_GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params)
 {
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
+   GLint64 parameter;
 
bufObj = get_buffer(ctx, glGetBufferParameteri64v, target,
GL_INVALID_OPERATION);
if (!bufObj)
   return;
 
-   switch (pname) {
-   case GL_BUFFER_SIZE_ARB:
-  *params = bufObj-Size;
-  return;
-   case GL_BUFFER_USAGE_ARB:
-  *params = bufObj-Usage;
-  return;
-   case GL_BUFFER_ACCESS_ARB:
-  *params = simplified_access_mode(ctx,
- bufObj-Mappings[MAP_USER].AccessFlags);
-  return;
-   case GL_BUFFER_ACCESS_FLAGS:
-  if (!ctx-Extensions.ARB_map_buffer_range)
- goto invalid_pname;
-  *params = bufObj-Mappings[MAP_USER].AccessFlags;
-  return;
-   case GL_BUFFER_MAPPED_ARB:
-  *params = _mesa_bufferobj_mapped(bufObj, MAP_USER);
-  return;
-   case GL_BUFFER_MAP_OFFSET:
-  if (!ctx-Extensions.ARB_map_buffer_range)
- goto invalid_pname;
-  *params = bufObj-Mappings[MAP_USER].Offset;
-  return;
-   case GL_BUFFER_MAP_LENGTH:
-  if (!ctx-Extensions.ARB_map_buffer_range)
- goto invalid_pname;
-  *params = bufObj-Mappings[MAP_USER].Length;
-  return;
-   case GL_BUFFER_IMMUTABLE_STORAGE:
-  if (!ctx-Extensions.ARB_buffer_storage)
- goto 

[Mesa-dev] [PATCH 02/23] main: Add entry point for TextureBufferRange.

2015-02-11 Thread Laura Ekstrand
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  8 +++
 src/mesa/main/tests/dispatch_sanity.cpp|  1 +
 src/mesa/main/teximage.c   | 90 ++
 src/mesa/main/teximage.h   |  4 ++
 4 files changed, 103 insertions(+)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 2fe1638..86c00f9 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -21,6 +21,14 @@
   param name=buffer type=GLuint /
/function
 
+   function name=TextureBufferRange offset=assign
+  param name=texture type=GLuint /
+  param name=internalformat type=GLenum /
+  param name=buffer type=GLuint /
+  param name=offset type=GLintptr /
+  param name=size type=GLsizeiptr /
+   /function
+
function name=TextureStorage1D offset=assign
   param name=texture type=GLuint /
   param name=levels type=GLsizei /
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index 1f1a3a8..b78c1ce 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -987,6 +987,7 @@ const struct function gl_core_functions_possible[] = {
{ glTextureStorage2DMultisample, 45, -1 },
{ glTextureStorage3DMultisample, 45, -1 },
{ glTextureBuffer, 45, -1 },
+   { glTextureBufferRange, 45, -1 },
 
/* GL_EXT_polygon_offset_clamp */
{ glPolygonOffsetClampEXT, 11, -1 },
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 336feff..ce6f446 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -5197,6 +5197,96 @@ _mesa_TextureBuffer(GLuint texture, GLenum 
internalFormat, GLuint buffer)
   bufObj, 0, buffer ? -1 : 0, false, true);
 }
 
+void GLAPIENTRY
+_mesa_TextureBufferRange(GLuint texture, GLenum internalFormat, GLuint buffer,
+ GLintptr offset, GLsizeiptr size)
+{
+   struct gl_texture_object *texObj;
+   struct gl_buffer_object *bufObj;
+
+   GET_CURRENT_CONTEXT(ctx);
+
+   /* NOTE: ARB_texture_buffer_object has interactions with
+* the compatibility profile that are not implemented.
+*/
+   if (!(ctx-API == API_OPENGL_CORE 
+ ctx-Extensions.ARB_texture_buffer_object)) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  glTextureBufferRange(ARB_texture_buffer_object is not
+   implemented for the compatibility profile));
+  return;
+   }
+
+   bufObj = _mesa_lookup_bufferobj(ctx, buffer);
+   if (bufObj) {
+  /* OpenGL 4.5 core spec (30.10.2014) says in Section 8.9 Buffer
+   * Textures:
+   *An INVALID_VALUE error is generated if offset is negative, if
+   *size is less than or equal to zero, or if offset + size is greater
+   *than the value of BUFFER_SIZE for the buffer bound to target.
+   */
+  if (offset  0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ glTextureBufferRange(offset %d  0), (int) offset);
+ return;
+  }
+
+  if (size = 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ glTextureBufferRange(size %d = 0), (int) size);
+ return;
+  }
+
+  if (offset + size  bufObj-Size) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ glTextureBufferRange(
+ offset %d + size %d  buffer_size %d), (int) offset,
+ (int) size, (int) bufObj-Size);
+ return;
+  }
+
+  /* OpenGL 4.5 core spec (30.10.2014) says in Section 8.9 Buffer
+   * Textures:
+   *An INVALID_VALUE error is generated if offset is not an integer
+   *multiple of the value of TEXTURE_BUFFER_OFFSET_ALIGNMENT.
+   */
+  if (offset % ctx-Const.TextureBufferOffsetAlignment) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ glTextureBufferRange(invalid offset alignment));
+ return;
+  }
+   } else if (buffer) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  glTextureBufferRange(unrecognized buffer %u), buffer);
+  return;
+   } else {
+
+  /* OpenGL 4.5 core spec (30.10.2014) says in Section 8.9 Buffer
+   * Textures:
+   *If buffer is zero, then any buffer object attached to the buffer
+   *texture is detached, the values offset and size are ignored and
+   *the state for offset and size for the buffer texture are reset to
+   *zero.
+   */
+  offset = 0;
+  size = 0;
+   }
+
+   /* Get the texture object by Name. */
+   texObj = _mesa_lookup_texture_err(ctx, texture, glTextureBufferRange);
+   if (!texObj)
+  return;
+
+   if (texObj-Target != GL_TEXTURE_BUFFER_ARB) {
+  _mesa_error(ctx, GL_INVALID_ENUM, glTextureBufferRange(texture target
+ is not GL_TEXTURE_BUFFER));
+  return;

[Mesa-dev] [PATCH 23/23] main: Cosmetic changes to GetBufferSubData.

2015-02-11 Thread Laura Ekstrand
---
 src/mesa/main/bufferobj.c | 2 +-
 src/mesa/main/bufferobj.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 0272704..38d8b5a 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1668,7 +1668,7 @@ _mesa_GetBufferSubData(GLenum target, GLintptr offset,
}
 
ASSERT(ctx-Driver.GetBufferSubData);
-   ctx-Driver.GetBufferSubData( ctx, offset, size, data, bufObj );
+   ctx-Driver.GetBufferSubData(ctx, offset, size, data, bufObj);
 }
 
 void GLAPIENTRY
diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
index feeaa8b..b5d73ae 100644
--- a/src/mesa/main/bufferobj.h
+++ b/src/mesa/main/bufferobj.h
@@ -230,8 +230,8 @@ _mesa_NamedBufferSubData(GLuint buffer, GLintptr offset,
  GLsizeiptr size, const GLvoid *data);
 
 void GLAPIENTRY
-_mesa_GetBufferSubData(GLenum target, GLintptrARB offset,
-   GLsizeiptrARB size, void * data);
+_mesa_GetBufferSubData(GLenum target, GLintptr offset,
+   GLsizeiptr size, GLvoid *data);
 
 void GLAPIENTRY
 _mesa_GetNamedBufferSubData(GLuint buffer, GLintptr offset,
-- 
2.1.0

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


[Mesa-dev] [PATCH 14/23] main: Refactor MapBuffer[Range].

2015-02-11 Thread Laura Ekstrand
v2: review from Jason Ekstrand
   - Split refactor from addition of DSA entry points.
review from Ian Romanick
   - Remove _mesa from static software fallback map_buffer_range
   - Restore VBO_DEBUG and BOUNDS_CHECK
---
 src/mesa/main/bufferobj.c | 286 --
 src/mesa/main/bufferobj.h |   6 +
 2 files changed, 131 insertions(+), 161 deletions(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 88230d6..ccf1207 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -701,10 +701,10 @@ _mesa_ClearBufferSubData_sw(struct gl_context *ctx,
  * Called via glMapBufferRange().
  */
 static void *
-_mesa_buffer_map_range( struct gl_context *ctx, GLintptr offset,
-GLsizeiptr length, GLbitfield access,
-struct gl_buffer_object *bufObj,
-gl_map_buffer_index index)
+map_buffer_range_fallback(struct gl_context *ctx, GLintptr offset,
+  GLsizeiptr length, GLbitfield access,
+  struct gl_buffer_object *bufObj,
+  gl_map_buffer_index index)
 {
(void) ctx;
assert(!_mesa_bufferobj_mapped(bufObj, index));
@@ -1116,7 +1116,7 @@ _mesa_init_buffer_object_functions(struct 
dd_function_table *driver)
driver-ClearBufferSubData = _mesa_ClearBufferSubData_sw;
 
/* GL_ARB_map_buffer_range */
-   driver-MapBufferRange = _mesa_buffer_map_range;
+   driver-MapBufferRange = map_buffer_range_fallback;
driver-FlushMappedBufferRange = _mesa_buffer_flush_mapped_range;
 
/* GL_ARB_copy_buffer */
@@ -1799,116 +1799,6 @@ _mesa_ClearNamedBufferSubData(GLuint buffer, GLenum 
internalformat,
 }
 
 
-void * GLAPIENTRY
-_mesa_MapBuffer(GLenum target, GLenum access)
-{
-   GET_CURRENT_CONTEXT(ctx);
-   struct gl_buffer_object * bufObj;
-   GLbitfield accessFlags;
-   void *map;
-   bool valid_access;
-
-   ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL);
-
-   switch (access) {
-   case GL_READ_ONLY_ARB:
-  accessFlags = GL_MAP_READ_BIT;
-  valid_access = _mesa_is_desktop_gl(ctx);
-  break;
-   case GL_WRITE_ONLY_ARB:
-  accessFlags = GL_MAP_WRITE_BIT;
-  valid_access = true;
-  break;
-   case GL_READ_WRITE_ARB:
-  accessFlags = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT;
-  valid_access = _mesa_is_desktop_gl(ctx);
-  break;
-   default:
-  valid_access = false;
-  break;
-   }
-
-   if (!valid_access) {
-  _mesa_error(ctx, GL_INVALID_ENUM, glMapBufferARB(access));
-  return NULL;
-   }
-
-   bufObj = get_buffer(ctx, glMapBufferARB, target, GL_INVALID_OPERATION);
-   if (!bufObj)
-  return NULL;
-
-   if (accessFlags  GL_MAP_READ_BIT 
-   !(bufObj-StorageFlags  GL_MAP_READ_BIT)) {
-  _mesa_error(ctx, GL_INVALID_OPERATION,
-  glMapBuffer(invalid read flag));
-  return NULL;
-   }
-
-   if (accessFlags  GL_MAP_WRITE_BIT 
-   !(bufObj-StorageFlags  GL_MAP_WRITE_BIT)) {
-  _mesa_error(ctx, GL_INVALID_OPERATION,
-  glMapBuffer(invalid write flag));
-  return NULL;
-   }
-
-   if (_mesa_bufferobj_mapped(bufObj, MAP_USER)) {
-  _mesa_error(ctx, GL_INVALID_OPERATION, glMapBufferARB(already mapped));
-  return NULL;
-   }
-
-   if (!bufObj-Size) {
-  _mesa_error(ctx, GL_OUT_OF_MEMORY,
-  glMapBuffer(buffer size = 0));
-  return NULL;
-   }
-
-   ASSERT(ctx-Driver.MapBufferRange);
-   map = ctx-Driver.MapBufferRange(ctx, 0, bufObj-Size, accessFlags, bufObj,
-MAP_USER);
-   if (!map) {
-  _mesa_error(ctx, GL_OUT_OF_MEMORY, glMapBufferARB(map failed));
-  return NULL;
-   }
-   else {
-  /* The driver callback should have set these fields.
-   * This is important because other modules (like VBO) might call
-   * the driver function directly.
-   */
-  ASSERT(bufObj-Mappings[MAP_USER].Pointer == map);
-  ASSERT(bufObj-Mappings[MAP_USER].Length == bufObj-Size);
-  ASSERT(bufObj-Mappings[MAP_USER].Offset == 0);
-  bufObj-Mappings[MAP_USER].AccessFlags = accessFlags;
-   }
-
-   if (access == GL_WRITE_ONLY_ARB || access == GL_READ_WRITE_ARB)
-  bufObj-Written = GL_TRUE;
-
-#ifdef VBO_DEBUG
-   printf(glMapBufferARB(%u, sz %ld, access 0x%x)\n,
- bufObj-Name, bufObj-Size, access);
-   if (access == GL_WRITE_ONLY_ARB) {
-  GLuint i;
-  GLubyte *b = (GLubyte *) bufObj-Pointer;
-  for (i = 0; i  bufObj-Size; i++)
- b[i] = i  0xff;
-   }
-#endif
-
-#ifdef BOUNDS_CHECK
-   {
-  GLubyte *buf = (GLubyte *) bufObj-Pointer;
-  GLuint i;
-  /* buffer is 100 bytes larger than requested, fill with magic value */
-  for (i = 0; i  100; i++) {
- buf[bufObj-Size - i - 1] = 123;
-  }
-   }
-#endif
-
-   return bufObj-Mappings[MAP_USER].Pointer;
-}
-
-
 GLboolean GLAPIENTRY
 _mesa_UnmapBuffer(GLenum target)
 {
@@ -2231,35 +2121,26 @@ 

[Mesa-dev] [PATCH 03/23] main: Add utility function _mesa_lookup_bufferobj_err.

2015-02-11 Thread Laura Ekstrand
---
 src/mesa/main/bufferobj.c | 19 +++
 src/mesa/main/bufferobj.h |  4 
 2 files changed, 23 insertions(+)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 0c1ce98..b7dce0e 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1001,6 +1001,25 @@ _mesa_lookup_bufferobj_locked(struct gl_context *ctx, 
GLuint buffer)
   _mesa_HashLookupLocked(ctx-Shared-BufferObjects, buffer);
 }
 
+/**
+ * A convenience function for direct state access functions that throws
+ * GL_INVALID_OPERATION if buffer is not the name of a buffer object in the
+ * hash table.
+ */
+struct gl_buffer_object *
+_mesa_lookup_bufferobj_err(struct gl_context *ctx, GLuint buffer,
+   const char *caller)
+{
+   struct gl_buffer_object *bufObj;
+
+   bufObj = _mesa_lookup_bufferobj(ctx, buffer);
+   if (!bufObj)
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  %s(non-generated buffer name %u), caller, buffer);
+
+   return bufObj;
+}
+
 
 void
 _mesa_begin_bufferobj_lookups(struct gl_context *ctx)
diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
index fe294fc..8e53bfd 100644
--- a/src/mesa/main/bufferobj.h
+++ b/src/mesa/main/bufferobj.h
@@ -89,6 +89,10 @@ _mesa_lookup_bufferobj(struct gl_context *ctx, GLuint 
buffer);
 extern struct gl_buffer_object *
 _mesa_lookup_bufferobj_locked(struct gl_context *ctx, GLuint buffer);
 
+extern struct gl_buffer_object *
+_mesa_lookup_bufferobj_err(struct gl_context *ctx, GLuint buffer,
+   const char *caller);
+
 extern void
 _mesa_begin_bufferobj_lookups(struct gl_context *ctx);
 
-- 
2.1.0

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


[Mesa-dev] [PATCH 12/23] main: Add entry points for ClearNamedBuffer[Sub]Data.

2015-02-11 Thread Laura Ekstrand
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml | 18 +
 src/mesa/main/bufferobj.c  | 35 ++
 src/mesa/main/bufferobj.h  | 11 
 src/mesa/main/tests/dispatch_sanity.cpp|  2 ++
 4 files changed, 66 insertions(+)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 042b2a8..ce4017b 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -43,6 +43,24 @@
   param name=size type=GLsizeiptr /
/function
 
+   function name=ClearNamedBufferData offset=assign
+  param name=buffer type=GLuint /
+  param name=internalformat type=GLenum /
+  param name=format type=GLenum /
+  param name=type type=GLenum /
+  param name=data type=const GLvoid * /
+   /function
+
+   function name=ClearNamedBufferSubData offset=assign
+  param name=buffer type=GLuint /
+  param name=internalformat type=GLenum /
+  param name=offset type=GLintptr /
+  param name=size type=GLsizeiptr /
+  param name=format type=GLenum /
+  param name=type type=GLenum /
+  param name=data type=const GLvoid * /
+   /function
+
!-- Texture object functions --
 
function name=CreateTextures offset=assign
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index b8fa917..bd21c8a 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1744,6 +1744,22 @@ _mesa_ClearBufferData(GLenum target, GLenum 
internalformat, GLenum format,
glClearBufferData, false);
 }
 
+void GLAPIENTRY
+_mesa_ClearNamedBufferData(GLuint buffer, GLenum internalformat,
+   GLenum format, GLenum type, const GLvoid *data)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_buffer_object *bufObj;
+
+   bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, glClearNamedBufferData);
+   if (!bufObj)
+  return;
+
+   _mesa_clear_buffer_sub_data(ctx, bufObj, internalformat, 0, bufObj-Size,
+   format, type, data,
+   glClearNamedBufferData, false);
+}
+
 
 void GLAPIENTRY
 _mesa_ClearBufferSubData(GLenum target, GLenum internalformat,
@@ -1763,6 +1779,25 @@ _mesa_ClearBufferSubData(GLenum target, GLenum 
internalformat,
glClearBufferSubData, true);
 }
 
+void GLAPIENTRY
+_mesa_ClearNamedBufferSubData(GLuint buffer, GLenum internalformat,
+  GLintptr offset, GLsizeiptr size,
+  GLenum format, GLenum type,
+  const GLvoid *data)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_buffer_object *bufObj;
+
+   bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
+   glClearNamedBufferSubData);
+   if (!bufObj)
+  return;
+
+   _mesa_clear_buffer_sub_data(ctx, bufObj, internalformat, offset, size,
+   format, type, data,
+   glClearNamedBufferSubData, true);
+}
+
 
 void * GLAPIENTRY
 _mesa_MapBuffer(GLenum target, GLenum access)
diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
index 5911270..5254727 100644
--- a/src/mesa/main/bufferobj.h
+++ b/src/mesa/main/bufferobj.h
@@ -223,11 +223,22 @@ _mesa_ClearBufferData(GLenum target, GLenum 
internalformat,
   const GLvoid * data);
 
 void GLAPIENTRY
+_mesa_ClearNamedBufferData(GLuint buffer, GLenum internalformat,
+   GLenum format, GLenum type,
+   const GLvoid *data);
+
+void GLAPIENTRY
 _mesa_ClearBufferSubData(GLenum target, GLenum internalformat,
  GLintptr offset, GLsizeiptr size,
  GLenum format, GLenum type,
  const GLvoid * data);
 
+void GLAPIENTRY
+_mesa_ClearNamedBufferSubData(GLuint buffer, GLenum internalformat,
+  GLintptr offset, GLsizeiptr size,
+  GLenum format, GLenum type,
+  const GLvoid *data);
+
 void * GLAPIENTRY
 _mesa_MapBuffer(GLenum target, GLenum access);
 
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index aa8e352..4bd3e10 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -960,6 +960,8 @@ const struct function gl_core_functions_possible[] = {
{ glNamedBufferData, 45, -1 },
{ glNamedBufferSubData, 45, -1 },
{ glCopyNamedBufferSubData, 45, -1 },
+   { glClearNamedBufferData, 45, -1 },
+   { glClearNamedBufferSubData, 45, -1 },
{ glCreateTextures, 45, -1 },
{ glTextureStorage1D, 45, -1 },
{ glTextureStorage2D, 45, -1 },
-- 
2.1.0

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org

  1   2   >