Re: [Mesa-dev] [PATCH] i965: Do Sandybridge workaround flushes before each primitive.

2015-01-21 Thread Chad Versace
On 01/09/2015 11:07 PM, Kenneth Graunke wrote:
 Sandybridge requires the post-sync non-zero workaround in a ton of
 places, and if you ever miss one, the GPU usually hangs.
 
 Currently, we try to track exactly when a workaround flush is
 necessary (via the brw-batch.need_workaround_flush flag).  This is
 tricky to get right, and we've botched it several times in the past.
 
 This patch unconditionally performs the post-sync non-zero flush at the
 start of each primitive's state upload (including BLORP).  We drop the
 needs_workaround_flush flag, and drop all the other callers, as the
 flush has already been performed.
 
 We have no data to indicate that simply flushing all the time will
 hurt performance, and it has the potential to help stability.
 
 Signed-off-by: Kenneth Graunke kenn...@whitecape.org

Ken, what prompted you to write this patch? Did a SNB hang bite you
recently?

I know how painful it is to solve i-forgot-fush-hangs on SNB, so
I'm in favor of this patch if it doesn't hurt performance?

Before I give it a rb, I'd like to know how you confirmed that it
didn't hurt perf.

 @@ -883,10 +863,6 @@ brw_upload_invariant_state(struct brw_context *brw)
  {
 const bool is_965 = brw-gen == 4  !brw-is_g4x;
  
 -   /* 3DSTATE_SIP, 3DSTATE_MULTISAMPLE, etc. are nonpipelined. */
 -   if (brw-gen == 6)
 -  intel_emit_post_sync_nonzero_flush(brw);
 -

With this hunk, no workaround flush happens before uploading the invariant
state if hw ctx is enabled (which it isn't on Chrome OS btw).
Pre-patch, the flush did happen because intel_batchbuffer_init()
set need_workaround_flush = true. This worries me. Should I be worried?

Since this patch's goal is to be overly cautious, I would like to be
overlay cautious here too and continue to do the flush.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/2] nir: Add src and dest constructors

2015-01-21 Thread Jason Ekstrand
---
 src/glsl/nir/nir.h | 37 +
 1 file changed, 37 insertions(+)

diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index 5ebfc5a..7b5794d 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -482,6 +482,43 @@ typedef struct {
bool is_ssa;
 } nir_dest;
 
+static inline nir_src
+nir_src_for_ssa(nir_ssa_def *def)
+{
+   nir_src src;
+
+   src.is_ssa = true;
+   src.ssa = def;
+
+   return src;
+}
+
+static inline nir_src
+nir_src_for_reg(nir_register *reg)
+{
+   nir_src src;
+
+   src.is_ssa = false;
+   src.reg.reg = reg;
+   src.reg.indirect = NULL;
+   src.reg.base_offset = 0;
+
+   return src;
+}
+
+static inline nir_dest
+nir_dest_for_reg(nir_register *reg)
+{
+   nir_dest dest;
+
+   dest.is_ssa = false;
+   dest.reg.reg = reg;
+   dest.reg.indirect = NULL;
+   dest.reg.base_offset = 0;
+
+   return dest;
+}
+
 nir_src nir_src_copy(nir_src src, void *mem_ctx);
 nir_dest nir_dest_copy(nir_dest dest, void *mem_ctx);
 
-- 
2.2.1

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


[Mesa-dev] [PATCH 2/2] nir: Stop using designated initializers

2015-01-21 Thread Jason Ekstrand
Designated initializers with anonymous unions don't work in MSVC or
GCC  4.6.  With a couple of constructor methods, we don't need them any
more and the code is actually cleaner.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88467
---
 src/glsl/nir/nir_from_ssa.c | 30 --
 src/glsl/nir/nir_lower_atomics.c|  8 +++-
 src/glsl/nir/nir_lower_io.c |  9 ++---
 src/glsl/nir/nir_lower_locals_to_regs.c |  9 ++---
 src/glsl/nir/nir_lower_system_values.c  |  8 +++-
 src/glsl/nir/nir_lower_vars_to_ssa.c| 16 
 src/glsl/nir/nir_opt_constant_folding.c | 16 
 src/glsl/nir/nir_opt_cse.c  | 16 ++--
 src/glsl/nir/nir_opt_peephole_select.c  |  8 +++-
 src/glsl/nir/nir_search.c   |  8 ++--
 10 files changed, 37 insertions(+), 91 deletions(-)

diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c
index 9728b99..8b8f0f5 100644
--- a/src/glsl/nir/nir_from_ssa.c
+++ b/src/glsl/nir/nir_from_ssa.c
@@ -382,12 +382,9 @@ isolate_phi_nodes_block(nir_block *block, void *void_state)
   entry-dest.is_ssa = true;
   nir_ssa_def_init(block_pcopy-instr, entry-dest.ssa,
phi-dest.ssa.num_components, phi-dest.ssa.name);
-
-  nir_src entry_dest_src = {
- .ssa = entry-dest.ssa,
- .is_ssa = true,
-  };
-  nir_ssa_def_rewrite_uses(phi-dest.ssa, entry_dest_src, state-mem_ctx);
+  nir_ssa_def_rewrite_uses(phi-dest.ssa,
+   nir_src_for_ssa(entry-dest.ssa),
+   state-mem_ctx);
 
   entry-src.is_ssa = true;
   entry-src.ssa = phi-dest.ssa;
@@ -620,22 +617,16 @@ emit_copy(nir_parallel_copy_instr *pcopy, nir_src src, 
nir_src dest_src,
assert(!dest_src.is_ssa 
   dest_src.reg.indirect == NULL 
   dest_src.reg.base_offset == 0);
-   nir_dest dest = {
-  .reg.reg = dest_src.reg.reg,
-  .reg.indirect = NULL,
-  .reg.base_offset = 0,
-  .is_ssa = false,
-   };
 
if (src.is_ssa)
-  assert(src.ssa-num_components = dest.reg.reg-num_components);
+  assert(src.ssa-num_components = dest_src.reg.reg-num_components);
else
-  assert(src.reg.reg-num_components = dest.reg.reg-num_components);
+  assert(src.reg.reg-num_components = dest_src.reg.reg-num_components);
 
nir_alu_instr *mov = nir_alu_instr_create(mem_ctx, nir_op_imov);
mov-src[0].src = nir_src_copy(src, mem_ctx);
-   mov-dest.dest = nir_dest_copy(dest, mem_ctx);
-   mov-dest.write_mask = (1  dest.reg.reg-num_components) - 1;
+   mov-dest.dest = nir_dest_for_reg(dest_src.reg.reg);
+   mov-dest.write_mask = (1  dest_src.reg.reg-num_components) - 1;
 
nir_instr_insert_before(pcopy-instr, mov-instr);
 }
@@ -720,12 +711,7 @@ resolve_parallel_copy(nir_parallel_copy_instr *pcopy,
  values[src_idx] = entry-src;
   }
 
-  nir_src dest_src = {
- .reg.reg = entry-dest.reg.reg,
- .reg.indirect = NULL,
- .reg.base_offset = 0,
- .is_ssa = false,
-  };
+  nir_src dest_src = nir_src_for_reg(entry-dest.reg.reg);
 
   int dest_idx = -1;
   for (int i = 0; i  num_vals; ++i) {
diff --git a/src/glsl/nir/nir_lower_atomics.c b/src/glsl/nir/nir_lower_atomics.c
index 874c534..c45b397 100644
--- a/src/glsl/nir/nir_lower_atomics.c
+++ b/src/glsl/nir/nir_lower_atomics.c
@@ -115,11 +115,9 @@ lower_instr(nir_intrinsic_instr *instr, nir_function_impl 
*impl)
   new_instr-dest.is_ssa = true;
   nir_ssa_def_init(new_instr-instr, new_instr-dest.ssa,
instr-dest.ssa.num_components, NULL);
-  nir_src new_dest_src = {
- .is_ssa = true,
- .ssa = new_instr-dest.ssa,
-  };
-  nir_ssa_def_rewrite_uses(instr-dest.ssa, new_dest_src, mem_ctx);
+  nir_ssa_def_rewrite_uses(instr-dest.ssa,
+   nir_src_for_ssa(new_instr-dest.ssa),
+   mem_ctx);
} else {
   new_instr-dest = nir_dest_copy(instr-dest, mem_ctx);
}
diff --git a/src/glsl/nir/nir_lower_io.c b/src/glsl/nir/nir_lower_io.c
index af87c13..c35058c 100644
--- a/src/glsl/nir/nir_lower_io.c
+++ b/src/glsl/nir/nir_lower_io.c
@@ -238,13 +238,8 @@ nir_lower_io_block(nir_block *block, void *void_state)
 load-dest.is_ssa = true;
 nir_ssa_def_init(load-instr, load-dest.ssa,
  intrin-num_components, NULL);
-
-nir_src new_src = {
-   .is_ssa = true,
-   .ssa = load-dest.ssa,
-};
-
-nir_ssa_def_rewrite_uses(intrin-dest.ssa, new_src,
+nir_ssa_def_rewrite_uses(intrin-dest.ssa,
+ nir_src_for_ssa(load-dest.ssa),
  state-mem_ctx);
  } else {
 load-dest = nir_dest_copy(intrin-dest, state-mem_ctx);
diff --git 

[Mesa-dev] [Bug 88467] nir.c:140: error: ‘nir_src’ has no member named ‘ssa’

2015-01-21 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=88467

--- Comment #11 from Jason Ekstrand ja...@jlekstrand.net ---
(In reply to Jason Ekstrand from comment #10)
 (In reply to Dave Airlie from comment #6)
  This is actually more annoying
  
  with gcc 4.4
  
  gcc -std=gnu99 supports anonymous structs, but doesn't support designated
  initialisers for anonymous structs.
  
  I'm not really sure what we can do now, I've built with -std=gnu99 and now
  get less warnings but all the designated initalisers are fail.
 
 I've been meaning to get rid of those.  They don't work properly on msvc
 either.  I'll kick out a patch later today and note it on the bug.

I just dropped the patches on the list.  If a branch is better, it can be found
here:

http://cgit.freedesktop.org/~jekstrand/mesa/log/?h=review/src-constructors

-- 
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] [PATCH 1/3] i965: Fix max_wm_threads for gen8

2015-01-21 Thread ville . syrjala
From: Ville Syrjälä ville.syrj...@linux.intel.com

max_wm_threads depends on the GT SKU on gen8. Update the values to
match the spec.

The max number of threads in 3DSTATE_PS is always programmed to 64
and the hardware internally scales that depending on the GT SKU. So
this doesn't change the max number of threads actually used, but it
does affect the scratch space calculation.

This is most important on CHV where the old value was too small, so
the amount of scratch space allocated wasn't sufficient to satisfy the
actual max number of threads used. On BDW GT1 and GT2 we reduce the
value to avoid overallocating the scratch space needlessly. BDW GT3
is unaffected.

Signed-off-by: Ville Syrjälä ville.syrj...@linux.intel.com
---
 src/mesa/drivers/dri/i965/brw_device_info.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_device_info.c 
b/src/mesa/drivers/dri/i965/brw_device_info.c
index 65942c2..2c3af66 100644
--- a/src/mesa/drivers/dri/i965/brw_device_info.c
+++ b/src/mesa/drivers/dri/i965/brw_device_info.c
@@ -198,11 +198,11 @@ static const struct brw_device_info 
brw_device_info_hsw_gt3 = {
.has_llc = true, \
.has_pln = true, \
.max_vs_threads = 504,   \
-   .max_gs_threads = 504,   \
-   .max_wm_threads = 384\
+   .max_gs_threads = 504\
 
 static const struct brw_device_info brw_device_info_bdw_gt1 = {
GEN8_FEATURES, .gt = 1,
+   .max_wm_threads = 128,
.urb = {
   .size = 192,
   .min_vs_entries = 64,
@@ -213,6 +213,7 @@ static const struct brw_device_info brw_device_info_bdw_gt1 
= {
 
 static const struct brw_device_info brw_device_info_bdw_gt2 = {
GEN8_FEATURES, .gt = 2,
+   .max_wm_threads = 192,
.urb = {
   .size = 384,
   .min_vs_entries = 64,
@@ -223,6 +224,7 @@ static const struct brw_device_info brw_device_info_bdw_gt2 
= {
 
 static const struct brw_device_info brw_device_info_bdw_gt3 = {
GEN8_FEATURES, .gt = 3,
+   .max_wm_threads = 384,
.urb = {
   .size = 384,
   .min_vs_entries = 64,
@@ -239,7 +241,7 @@ static const struct brw_device_info brw_device_info_chv = {
.has_llc = false,
.max_vs_threads = 80,
.max_gs_threads = 80,
-   .max_wm_threads = 102,
+   .max_wm_threads = 128,
.urb = {
   .size = 128,
   .min_vs_entries = 64,
-- 
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: Fix min_vs_entries for CHV

2015-01-21 Thread ville . syrjala
From: Ville Syrjälä ville.syrj...@linux.intel.com

According to BSpec the correct number for min_vs_entries is 34 for CHV.

Signed-off-by: Ville Syrjälä ville.syrj...@linux.intel.com
---
 src/mesa/drivers/dri/i965/brw_device_info.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_device_info.c 
b/src/mesa/drivers/dri/i965/brw_device_info.c
index 2c3af66..bdef42b 100644
--- a/src/mesa/drivers/dri/i965/brw_device_info.c
+++ b/src/mesa/drivers/dri/i965/brw_device_info.c
@@ -244,7 +244,7 @@ static const struct brw_device_info brw_device_info_chv = {
.max_wm_threads = 128,
.urb = {
   .size = 128,
-  .min_vs_entries = 64,
+  .min_vs_entries = 34,
   .max_vs_entries = 640,
   .max_gs_entries = 256,
}
-- 
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] mesa: Add initializer macros to fix missing initializer warnings

2015-01-21 Thread Jan Vesely
NFC.

Signed-off-by: Jan Vesely jan.ves...@rutgers.edu
---
 src/mesa/main/texcompress_bptc.c | 40 ++--
 1 file changed, 22 insertions(+), 18 deletions(-)

diff --git a/src/mesa/main/texcompress_bptc.c b/src/mesa/main/texcompress_bptc.c
index c944ac2..56ca320 100644
--- a/src/mesa/main/texcompress_bptc.c
+++ b/src/mesa/main/texcompress_bptc.c
@@ -59,6 +59,8 @@ struct bptc_float_bitfield {
bool reverse;
 };
 
+#define BPTC_FLOAT_BITFIELD_END { -1, 0, 0, 0, false }
+
 struct bptc_float_mode {
bool reserved;
bool transformed_endpoints;
@@ -69,6 +71,8 @@ struct bptc_float_mode {
struct bptc_float_bitfield bitfields[24];
 };
 
+#define BPTC_FLOAT_MODE_RESERVED { true, false, 0, 0, 0, {}, {}}
+
 struct bit_writer {
uint8_t buf;
int pos;
@@ -98,7 +102,7 @@ bptc_float_modes[] = {
{ 1, 2, 0, 5, false }, { 3, 2, 1, 1, false }, { 2, 2, 0, 4, false },
{ 2, 0, 0, 5, false }, { 3, 2, 2, 1, false }, { 3, 0, 0, 5, false },
{ 3, 2, 3, 1, false },
-   { -1 } }
+   BPTC_FLOAT_BITFIELD_END }
},
/* 01 */
{ false, true, 5, 7, 3, { 6, 6, 6 },
@@ -111,7 +115,7 @@ bptc_float_modes[] = {
{ 3, 1, 0, 4, false }, { 1, 2, 0, 6, false }, { 2, 2, 0, 4, false },
{ 2, 0, 0, 6, false },
{ 3, 0, 0, 6, false },
-   { -1 } }
+   BPTC_FLOAT_BITFIELD_END }
},
/* 00010 */
{ false, true, 5, 11, 3, { 5, 4, 4 },
@@ -121,13 +125,13 @@ bptc_float_modes[] = {
{ 3, 1, 0, 4, false }, { 1, 2, 0, 4, false }, { 0, 2, 10, 1, false },
{ 3, 2, 1, 1, false }, { 2, 2, 0, 4, false }, { 2, 0, 0, 5, false },
{ 3, 2, 2, 1, false }, { 3, 0, 0, 5, false }, { 3, 2, 3, 1, false },
-   { -1 } }
+   BPTC_FLOAT_BITFIELD_END }
},
/* 00011 */
{ false, false, 0, 10, 4, { 10, 10, 10 },
  { { 0, 0, 0, 10, false }, { 0, 1, 0, 10, false }, { 0, 2, 0, 10, false },
{ 1, 0, 0, 10, false }, { 1, 1, 0, 10, false }, { 1, 2, 0, 10, false },
-   { -1 } }
+   BPTC_FLOAT_BITFIELD_END }
},
/* 00110 */
{ false, true, 5, 11, 3, { 4, 5, 4 },
@@ -138,14 +142,14 @@ bptc_float_modes[] = {
{ 3, 2, 1, 1, false }, { 2, 2, 0, 4, false }, { 2, 0, 0, 4, false },
{ 3, 2, 0, 1, false }, { 3, 2, 2, 1, false }, { 3, 0, 0, 4, false },
{ 2, 1, 4, 1, false }, { 3, 2, 3, 1, false },
-   { -1 } }
+   BPTC_FLOAT_BITFIELD_END }
},
/* 00111 */
{ false, true, 0, 11, 4, { 9, 9, 9 },
  { { 0, 0, 0, 10, false }, { 0, 1, 0, 10, false }, { 0, 2, 0, 10, false },
{ 1, 0, 0, 9, false }, { 0, 0, 10, 1, false }, { 1, 1, 0, 9, false },
{ 0, 1, 10, 1, false }, { 1, 2, 0, 9, false }, { 0, 2, 10, 1, false },
-   { -1 } }
+   BPTC_FLOAT_BITFIELD_END }
},
/* 01010 */
{ false, true, 5, 11, 3, { 4, 4, 5 },
@@ -156,14 +160,14 @@ bptc_float_modes[] = {
{ 0, 2, 10, 1, false }, { 2, 2, 0, 4, false }, { 2, 0, 0, 4, false },
{ 3, 2, 1, 1, false }, { 3, 2, 2, 1, false }, { 3, 0, 0, 4, false },
{ 3, 2, 4, 1, false }, { 3, 2, 3, 1, false },
-   { -1 } }
+   BPTC_FLOAT_BITFIELD_END }
},
/* 01011 */
{ false, true, 0, 12, 4, { 8, 8, 8 },
  { { 0, 0, 0, 10, false }, { 0, 1, 0, 10, false }, { 0, 2, 0, 10, false },
{ 1, 0, 0, 8, false }, { 0, 0, 10, 2, true }, { 1, 1, 0, 8, false },
{ 0, 1, 10, 2, true }, { 1, 2, 0, 8, false }, { 0, 2, 10, 2, true },
-   { -1 } }
+   BPTC_FLOAT_BITFIELD_END }
},
/* 01110 */
{ false, true, 5, 9, 3, { 5, 5, 5 },
@@ -174,14 +178,14 @@ bptc_float_modes[] = {
{ 1, 2, 0, 5, false }, { 3, 2, 1, 1, false }, { 2, 2, 0, 4, false },
{ 2, 0, 0, 5, false }, { 3, 2, 2, 1, false }, { 3, 0, 0, 5, false },
{ 3, 2, 3, 1, false },
-   { -1 } }
+   BPTC_FLOAT_BITFIELD_END }
},
/* 0 */
{ false, true, 0, 16, 4, { 4, 4, 4 },
  { { 0, 0, 0, 10, false }, { 0, 1, 0, 10, false }, { 0, 2, 0, 10, false },
{ 1, 0, 0, 4, false }, { 0, 0, 10, 6, true }, { 1, 1, 0, 4, false },
{ 0, 1, 10, 6, true }, { 1, 2, 0, 4, false }, { 0, 2, 10, 6, true },
-   { -1 } }
+   BPTC_FLOAT_BITFIELD_END }
},
/* 10010 */
{ false, true, 5, 8, 3, { 6, 5, 5 },
@@ -192,10 +196,10 @@ bptc_float_modes[] = {
{ 3, 2, 0, 1, false }, { 3, 1, 0, 4, false }, { 1, 2, 0, 5, false },
{ 3, 2, 1, 1, false }, { 2, 2, 0, 4, false }, { 2, 0, 0, 6, false },
{ 3, 0, 0, 6, false },
-   { -1 } }
+   BPTC_FLOAT_BITFIELD_END }
},
/* 10011 */
-   { true /* reserved */ },
+   BPTC_FLOAT_MODE_RESERVED,
/* 10110 */
{ false, true, 5, 8, 3, { 5, 6, 5 },
  { { 0, 0, 0, 8, false }, { 3, 2, 0, 1, false }, { 2, 2, 4, 1, false },
@@ -205,10 +209,10 @@ bptc_float_modes[] = {
{ 1, 1, 0, 6, false }, { 3, 1, 0, 4, false }, { 1, 2, 0, 5, false },
{ 3, 2, 1, 1, false }, { 2, 2, 0, 4, false }, { 2, 0, 0, 5, false },
{ 3, 2, 2, 1, false }, { 3, 0, 0, 5, false }, { 

[Mesa-dev] [PATCH 3/3] mesa: more missing initializers

2015-01-21 Thread Jan Vesely
NFC.

Signed-off-by: Jan Vesely jan.ves...@rutgers.edu
---
 src/mesa/state_tracker/st_extensions.c | 47 ++
 1 file changed, 31 insertions(+), 16 deletions(-)

diff --git a/src/mesa/state_tracker/st_extensions.c 
b/src/mesa/state_tracker/st_extensions.c
index 48ed9d2..f2bcf64 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -470,7 +470,8 @@ void st_init_extensions(struct pipe_screen *screen,
static const struct st_extension_format_mapping rendertarget_mapping[] = {
   { { o(ARB_texture_float) },
 { PIPE_FORMAT_R32G32B32A32_FLOAT,
-  PIPE_FORMAT_R16G16B16A16_FLOAT } },
+  PIPE_FORMAT_R16G16B16A16_FLOAT },
+ GL_FALSE },
 
   { { o(ARB_texture_rgb10_a2ui) },
 { PIPE_FORMAT_R10G10B10A2_UINT,
@@ -483,22 +484,26 @@ void st_init_extensions(struct pipe_screen *screen,
  GL_TRUE }, /* at least one format must be supported */
 
   { { o(EXT_packed_float) },
-{ PIPE_FORMAT_R11G11B10_FLOAT } },
+{ PIPE_FORMAT_R11G11B10_FLOAT },
+ GL_FALSE },
 
   { { o(EXT_texture_integer) },
 { PIPE_FORMAT_R32G32B32A32_UINT,
-  PIPE_FORMAT_R32G32B32A32_SINT } },
+  PIPE_FORMAT_R32G32B32A32_SINT },
+ GL_FALSE },
 
   { { o(ARB_texture_rg) },
 { PIPE_FORMAT_R8_UNORM,
-  PIPE_FORMAT_R8G8_UNORM } },
+  PIPE_FORMAT_R8G8_UNORM },
+ GL_FALSE },
};
 
/* Required: depth stencil and sampler support */
static const struct st_extension_format_mapping depthstencil_mapping[] = {
   { { o(ARB_depth_buffer_float) },
 { PIPE_FORMAT_Z32_FLOAT,
-  PIPE_FORMAT_Z32_FLOAT_S8X24_UINT } },
+  PIPE_FORMAT_Z32_FLOAT_S8X24_UINT },
+ GL_FALSE },
};
 
/* Required: sampler support */
@@ -507,32 +512,38 @@ void st_init_extensions(struct pipe_screen *screen,
 { PIPE_FORMAT_RGTC1_UNORM,
   PIPE_FORMAT_RGTC1_SNORM,
   PIPE_FORMAT_RGTC2_UNORM,
-  PIPE_FORMAT_RGTC2_SNORM } },
+  PIPE_FORMAT_RGTC2_SNORM },
+ GL_FALSE },
 
   { { o(EXT_texture_compression_latc) },
 { PIPE_FORMAT_LATC1_UNORM,
   PIPE_FORMAT_LATC1_SNORM,
   PIPE_FORMAT_LATC2_UNORM,
-  PIPE_FORMAT_LATC2_SNORM } },
+  PIPE_FORMAT_LATC2_SNORM },
+ GL_FALSE },
 
   { { o(EXT_texture_compression_s3tc),
   o(ANGLE_texture_compression_dxt) },
 { PIPE_FORMAT_DXT1_RGB,
   PIPE_FORMAT_DXT1_RGBA,
   PIPE_FORMAT_DXT3_RGBA,
-  PIPE_FORMAT_DXT5_RGBA } },
+  PIPE_FORMAT_DXT5_RGBA },
+ GL_FALSE },
 
   { { o(ARB_texture_compression_bptc) },
 { PIPE_FORMAT_BPTC_RGBA_UNORM,
   PIPE_FORMAT_BPTC_SRGBA,
   PIPE_FORMAT_BPTC_RGB_FLOAT,
-  PIPE_FORMAT_BPTC_RGB_UFLOAT } },
+  PIPE_FORMAT_BPTC_RGB_UFLOAT },
+ GL_FALSE },
 
   { { o(EXT_texture_shared_exponent) },
-{ PIPE_FORMAT_R9G9B9E5_FLOAT } },
+{ PIPE_FORMAT_R9G9B9E5_FLOAT },
+ GL_FALSE },
 
   { { o(EXT_texture_snorm) },
-{ PIPE_FORMAT_R8G8B8A8_SNORM } },
+{ PIPE_FORMAT_R8G8B8A8_SNORM },
+ GL_FALSE },
 
   { { o(EXT_texture_sRGB),
   o(EXT_texture_sRGB_decode) },
@@ -541,7 +552,8 @@ void st_init_extensions(struct pipe_screen *screen,
 GL_TRUE }, /* at least one format must be supported */
 
   { { o(ATI_texture_compression_3dc) },
-{ PIPE_FORMAT_LATC2_UNORM } },
+{ PIPE_FORMAT_LATC2_UNORM },
+ GL_FALSE },
 
   { { o(MESA_ycbcr_texture) },
 { PIPE_FORMAT_UYVY,
@@ -569,17 +581,20 @@ void st_init_extensions(struct pipe_screen *screen,
   PIPE_FORMAT_R10G10B10A2_USCALED,
   PIPE_FORMAT_B10G10R10A2_USCALED,
   PIPE_FORMAT_R10G10B10A2_SSCALED,
-  PIPE_FORMAT_B10G10R10A2_SSCALED } },
+  PIPE_FORMAT_B10G10R10A2_SSCALED },
+ GL_FALSE },
+
   { { o(ARB_vertex_type_10f_11f_11f_rev) },
-{ PIPE_FORMAT_R11G11B10_FLOAT } },
+{ PIPE_FORMAT_R11G11B10_FLOAT },
+ GL_FALSE },
};
 
static const struct st_extension_format_mapping tbo_rgb32[] = {
   { {o(ARB_texture_buffer_object_rgb32) },
 { PIPE_FORMAT_R32G32B32_FLOAT,
   PIPE_FORMAT_R32G32B32_UINT,
-  PIPE_FORMAT_R32G32B32_SINT,
-} },
+  PIPE_FORMAT_R32G32B32_SINT },
+ GL_FALSE },
};
 
/*
-- 
2.1.0

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


[Mesa-dev] [PATCH 1/3] mesa: get_hash: Add missing field initializers

2015-01-21 Thread Jan Vesely
NFC.

Signed-off-by: Jan Vesely jan.ves...@rutgers.edu
---

This series fixes 38 -Wmissing-field-initializers warnings reported by gcc

 src/mesa/main/get_hash_params.py | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
index c487e98..b8a1182 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -234,10 +234,10 @@ descriptor=[
 
 { apis: [GLES], params: [
 # OES_point_size_array
-  [ POINT_SIZE_ARRAY_OES, 
ARRAY_FIELD(VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled, TYPE_BOOLEAN) ],
-  [ POINT_SIZE_ARRAY_TYPE_OES, 
ARRAY_FIELD(VertexAttrib[VERT_ATTRIB_POINT_SIZE].Type, TYPE_ENUM) ],
-  [ POINT_SIZE_ARRAY_STRIDE_OES, 
ARRAY_FIELD(VertexAttrib[VERT_ATTRIB_POINT_SIZE].Stride, TYPE_INT) ],
-  [ POINT_SIZE_ARRAY_BUFFER_BINDING_OES, LOC_CUSTOM, TYPE_INT, 0 ],
+  [ POINT_SIZE_ARRAY_OES, 
ARRAY_FIELD(VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled, TYPE_BOOLEAN), 
NO_EXTRA ],
+  [ POINT_SIZE_ARRAY_TYPE_OES, 
ARRAY_FIELD(VertexAttrib[VERT_ATTRIB_POINT_SIZE].Type, TYPE_ENUM), NO_EXTRA ],
+  [ POINT_SIZE_ARRAY_STRIDE_OES, 
ARRAY_FIELD(VertexAttrib[VERT_ATTRIB_POINT_SIZE].Stride, TYPE_INT), NO_EXTRA 
],
+  [ POINT_SIZE_ARRAY_BUFFER_BINDING_OES, LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA 
],
 ]},
 
 { apis: [GL, GL_CORE, GLES2], params: [
-- 
2.1.0

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


[Mesa-dev] [Bug 87886] constant fps drops with Intel and Radeon

2015-01-21 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=87886

Stéphane Travostino stephane.travost...@gmail.com changed:

   What|Removed |Added

 Status|NEEDINFO|RESOLVED
 Resolution|--- |NOTABUG

--- Comment #30 from Stéphane Travostino stephane.travost...@gmail.com ---
Solved!

Yes, forcing the min/max i915 freq didn't stop the GPU from going to the low
frequency by itself, so as you say it's something outside the control of the
kernel.

This machine is a Sony Vaio VPCSA series, and has a sony_laptop module to
control keyboard backlight, and.. thermal control.

By default /sys/devices/platform/sony-laptop/thermal_control is set to
balanced, changing it to performance I get:

- Stable FPS on both Intel  Radeon
- Intel CAGF frequency stable on max when running intensive OpenGL operations
- No more FPS drops

Thanks everybody for the help troubleshooting this, marking this as NOTABUG.

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


[Mesa-dev] [PATCH 3/3] i965: Fix URB size for gen8

2015-01-21 Thread ville . syrjala
From: Ville Syrjälä ville.syrj...@linux.intel.com

Increase the device info .urb.size for BDW GT3 and CHV to match the
default URB size for each.

Also add all missing platforms (BYT,BDW,CHV) to the comment describing
the default URB size in gen7_urb.c.

Signed-off-by: Ville Syrjälä ville.syrj...@linux.intel.com
---
 src/mesa/drivers/dri/i965/brw_device_info.c | 4 ++--
 src/mesa/drivers/dri/i965/gen7_urb.c| 5 -
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_device_info.c 
b/src/mesa/drivers/dri/i965/brw_device_info.c
index bdef42b..d0b9e05 100644
--- a/src/mesa/drivers/dri/i965/brw_device_info.c
+++ b/src/mesa/drivers/dri/i965/brw_device_info.c
@@ -226,7 +226,7 @@ static const struct brw_device_info brw_device_info_bdw_gt3 
= {
GEN8_FEATURES, .gt = 3,
.max_wm_threads = 384,
.urb = {
-  .size = 384,
+  .size = 768,
   .min_vs_entries = 64,
   .max_vs_entries = 2560,
   .max_gs_entries = 960,
@@ -243,7 +243,7 @@ static const struct brw_device_info brw_device_info_chv = {
.max_gs_threads = 80,
.max_wm_threads = 128,
.urb = {
-  .size = 128,
+  .size = 192,
   .min_vs_entries = 34,
   .max_vs_entries = 640,
   .max_gs_entries = 256,
diff --git a/src/mesa/drivers/dri/i965/gen7_urb.c 
b/src/mesa/drivers/dri/i965/gen7_urb.c
index 201f42e..f90d6e3 100644
--- a/src/mesa/drivers/dri/i965/gen7_urb.c
+++ b/src/mesa/drivers/dri/i965/gen7_urb.c
@@ -50,9 +50,12 @@
  * Currently we split the constant buffer space evenly among whatever stages
  * are active.  This is probably not ideal, but simple.
  *
- * Ivybridge GT1 and Haswell GT1 have 128kB of URB space.
+ * Ivybridge GT1, Baytrail and Haswell GT1 have 128kB of URB space.
  * Ivybridge GT2 and Haswell GT2 have 256kB of URB space.
  * Haswell GT3 has 512kB of URB space.
+ * Broadwell GT1 and Cherryview have 192kB of URB space.
+ * Broadwell GT2 has 384kB of URB space.
+ * Broadwell GT3 has 768kB of URB space.
  *
  * See Volume 2a: 3D Pipeline, section 1.8, Volume 1b: Configurations,
  * and the documentation for 3DSTATE_PUSH_CONSTANT_ALLOC_xS.
-- 
2.0.5

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


Re: [Mesa-dev] [PATCH 2/2] nir: Stop using designated initializers

2015-01-21 Thread Connor Abbott
Assuming this actually compiles with GCC 4.4...

Reviewed-by: Connor Abbott cwabbo...@gmail.com

On Wed, Jan 21, 2015 at 2:14 PM, Jason Ekstrand ja...@jlekstrand.net wrote:
 Designated initializers with anonymous unions don't work in MSVC or
 GCC  4.6.  With a couple of constructor methods, we don't need them any
 more and the code is actually cleaner.

 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88467
 ---
  src/glsl/nir/nir_from_ssa.c | 30 --
  src/glsl/nir/nir_lower_atomics.c|  8 +++-
  src/glsl/nir/nir_lower_io.c |  9 ++---
  src/glsl/nir/nir_lower_locals_to_regs.c |  9 ++---
  src/glsl/nir/nir_lower_system_values.c  |  8 +++-
  src/glsl/nir/nir_lower_vars_to_ssa.c| 16 
  src/glsl/nir/nir_opt_constant_folding.c | 16 
  src/glsl/nir/nir_opt_cse.c  | 16 ++--
  src/glsl/nir/nir_opt_peephole_select.c  |  8 +++-
  src/glsl/nir/nir_search.c   |  8 ++--
  10 files changed, 37 insertions(+), 91 deletions(-)

 diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c
 index 9728b99..8b8f0f5 100644
 --- a/src/glsl/nir/nir_from_ssa.c
 +++ b/src/glsl/nir/nir_from_ssa.c
 @@ -382,12 +382,9 @@ isolate_phi_nodes_block(nir_block *block, void 
 *void_state)
entry-dest.is_ssa = true;
nir_ssa_def_init(block_pcopy-instr, entry-dest.ssa,
 phi-dest.ssa.num_components, phi-dest.ssa.name);
 -
 -  nir_src entry_dest_src = {
 - .ssa = entry-dest.ssa,
 - .is_ssa = true,
 -  };
 -  nir_ssa_def_rewrite_uses(phi-dest.ssa, entry_dest_src, 
 state-mem_ctx);
 +  nir_ssa_def_rewrite_uses(phi-dest.ssa,
 +   nir_src_for_ssa(entry-dest.ssa),
 +   state-mem_ctx);

entry-src.is_ssa = true;
entry-src.ssa = phi-dest.ssa;
 @@ -620,22 +617,16 @@ emit_copy(nir_parallel_copy_instr *pcopy, nir_src src, 
 nir_src dest_src,
 assert(!dest_src.is_ssa 
dest_src.reg.indirect == NULL 
dest_src.reg.base_offset == 0);
 -   nir_dest dest = {
 -  .reg.reg = dest_src.reg.reg,
 -  .reg.indirect = NULL,
 -  .reg.base_offset = 0,
 -  .is_ssa = false,
 -   };

 if (src.is_ssa)
 -  assert(src.ssa-num_components = dest.reg.reg-num_components);
 +  assert(src.ssa-num_components = dest_src.reg.reg-num_components);
 else
 -  assert(src.reg.reg-num_components = dest.reg.reg-num_components);
 +  assert(src.reg.reg-num_components = 
 dest_src.reg.reg-num_components);

 nir_alu_instr *mov = nir_alu_instr_create(mem_ctx, nir_op_imov);
 mov-src[0].src = nir_src_copy(src, mem_ctx);
 -   mov-dest.dest = nir_dest_copy(dest, mem_ctx);
 -   mov-dest.write_mask = (1  dest.reg.reg-num_components) - 1;
 +   mov-dest.dest = nir_dest_for_reg(dest_src.reg.reg);
 +   mov-dest.write_mask = (1  dest_src.reg.reg-num_components) - 1;

 nir_instr_insert_before(pcopy-instr, mov-instr);
  }
 @@ -720,12 +711,7 @@ resolve_parallel_copy(nir_parallel_copy_instr *pcopy,
   values[src_idx] = entry-src;
}

 -  nir_src dest_src = {
 - .reg.reg = entry-dest.reg.reg,
 - .reg.indirect = NULL,
 - .reg.base_offset = 0,
 - .is_ssa = false,
 -  };
 +  nir_src dest_src = nir_src_for_reg(entry-dest.reg.reg);

int dest_idx = -1;
for (int i = 0; i  num_vals; ++i) {
 diff --git a/src/glsl/nir/nir_lower_atomics.c 
 b/src/glsl/nir/nir_lower_atomics.c
 index 874c534..c45b397 100644
 --- a/src/glsl/nir/nir_lower_atomics.c
 +++ b/src/glsl/nir/nir_lower_atomics.c
 @@ -115,11 +115,9 @@ lower_instr(nir_intrinsic_instr *instr, 
 nir_function_impl *impl)
new_instr-dest.is_ssa = true;
nir_ssa_def_init(new_instr-instr, new_instr-dest.ssa,
 instr-dest.ssa.num_components, NULL);
 -  nir_src new_dest_src = {
 - .is_ssa = true,
 - .ssa = new_instr-dest.ssa,
 -  };
 -  nir_ssa_def_rewrite_uses(instr-dest.ssa, new_dest_src, mem_ctx);
 +  nir_ssa_def_rewrite_uses(instr-dest.ssa,
 +   nir_src_for_ssa(new_instr-dest.ssa),
 +   mem_ctx);
 } else {
new_instr-dest = nir_dest_copy(instr-dest, mem_ctx);
 }
 diff --git a/src/glsl/nir/nir_lower_io.c b/src/glsl/nir/nir_lower_io.c
 index af87c13..c35058c 100644
 --- a/src/glsl/nir/nir_lower_io.c
 +++ b/src/glsl/nir/nir_lower_io.c
 @@ -238,13 +238,8 @@ nir_lower_io_block(nir_block *block, void *void_state)
  load-dest.is_ssa = true;
  nir_ssa_def_init(load-instr, load-dest.ssa,
   intrin-num_components, NULL);
 -
 -nir_src new_src = {
 -   .is_ssa = true,
 -   .ssa = load-dest.ssa,
 -};
 -
 -nir_ssa_def_rewrite_uses(intrin-dest.ssa, new_src,
 +

Re: [Mesa-dev] [PATCH 2/3] mesa: Add initializer macros to fix missing initializer warnings

2015-01-21 Thread Ian Romanick
On 01/21/2015 10:33 AM, Jan Vesely wrote:
 NFC.

NFC?  I'm assuming this doesn't mean Near Field Communications or no
'fine' clue.

 Signed-off-by: Jan Vesely jan.ves...@rutgers.edu
 ---
  src/mesa/main/texcompress_bptc.c | 40 
 ++--
  1 file changed, 22 insertions(+), 18 deletions(-)
 
 diff --git a/src/mesa/main/texcompress_bptc.c 
 b/src/mesa/main/texcompress_bptc.c
 index c944ac2..56ca320 100644
 --- a/src/mesa/main/texcompress_bptc.c
 +++ b/src/mesa/main/texcompress_bptc.c
 @@ -59,6 +59,8 @@ struct bptc_float_bitfield {
 bool reverse;
  };
  
 +#define BPTC_FLOAT_BITFIELD_END { -1, 0, 0, 0, false }
 +
  struct bptc_float_mode {
 bool reserved;
 bool transformed_endpoints;
 @@ -69,6 +71,8 @@ struct bptc_float_mode {
 struct bptc_float_bitfield bitfields[24];
  };
  
 +#define BPTC_FLOAT_MODE_RESERVED { true, false, 0, 0, 0, {}, {}}
 +
  struct bit_writer {
 uint8_t buf;
 int pos;
 @@ -98,7 +102,7 @@ bptc_float_modes[] = {
 { 1, 2, 0, 5, false }, { 3, 2, 1, 1, false }, { 2, 2, 0, 4, false },
 { 2, 0, 0, 5, false }, { 3, 2, 2, 1, false }, { 3, 0, 0, 5, false },
 { 3, 2, 3, 1, false },
 -   { -1 } }

I think just adding a , after the -1 will have the same effect.  C
explicitly states that missing members are initialized to 0.

 +   BPTC_FLOAT_BITFIELD_END }
 },
 /* 01 */
 { false, true, 5, 7, 3, { 6, 6, 6 },
 @@ -111,7 +115,7 @@ bptc_float_modes[] = {
 { 3, 1, 0, 4, false }, { 1, 2, 0, 6, false }, { 2, 2, 0, 4, false },
 { 2, 0, 0, 6, false },
 { 3, 0, 0, 6, false },
 -   { -1 } }
 +   BPTC_FLOAT_BITFIELD_END }
 },
 /* 00010 */
 { false, true, 5, 11, 3, { 5, 4, 4 },
 @@ -121,13 +125,13 @@ bptc_float_modes[] = {
 { 3, 1, 0, 4, false }, { 1, 2, 0, 4, false }, { 0, 2, 10, 1, false },
 { 3, 2, 1, 1, false }, { 2, 2, 0, 4, false }, { 2, 0, 0, 5, false },
 { 3, 2, 2, 1, false }, { 3, 0, 0, 5, false }, { 3, 2, 3, 1, false },
 -   { -1 } }
 +   BPTC_FLOAT_BITFIELD_END }
 },
 /* 00011 */
 { false, false, 0, 10, 4, { 10, 10, 10 },
   { { 0, 0, 0, 10, false }, { 0, 1, 0, 10, false }, { 0, 2, 0, 10, false 
 },
 { 1, 0, 0, 10, false }, { 1, 1, 0, 10, false }, { 1, 2, 0, 10, false 
 },
 -   { -1 } }
 +   BPTC_FLOAT_BITFIELD_END }
 },
 /* 00110 */
 { false, true, 5, 11, 3, { 4, 5, 4 },
 @@ -138,14 +142,14 @@ bptc_float_modes[] = {
 { 3, 2, 1, 1, false }, { 2, 2, 0, 4, false }, { 2, 0, 0, 4, false },
 { 3, 2, 0, 1, false }, { 3, 2, 2, 1, false }, { 3, 0, 0, 4, false },
 { 2, 1, 4, 1, false }, { 3, 2, 3, 1, false },
 -   { -1 } }
 +   BPTC_FLOAT_BITFIELD_END }
 },
 /* 00111 */
 { false, true, 0, 11, 4, { 9, 9, 9 },
   { { 0, 0, 0, 10, false }, { 0, 1, 0, 10, false }, { 0, 2, 0, 10, false 
 },
 { 1, 0, 0, 9, false }, { 0, 0, 10, 1, false }, { 1, 1, 0, 9, false },
 { 0, 1, 10, 1, false }, { 1, 2, 0, 9, false }, { 0, 2, 10, 1, false },
 -   { -1 } }
 +   BPTC_FLOAT_BITFIELD_END }
 },
 /* 01010 */
 { false, true, 5, 11, 3, { 4, 4, 5 },
 @@ -156,14 +160,14 @@ bptc_float_modes[] = {
 { 0, 2, 10, 1, false }, { 2, 2, 0, 4, false }, { 2, 0, 0, 4, false },
 { 3, 2, 1, 1, false }, { 3, 2, 2, 1, false }, { 3, 0, 0, 4, false },
 { 3, 2, 4, 1, false }, { 3, 2, 3, 1, false },
 -   { -1 } }
 +   BPTC_FLOAT_BITFIELD_END }
 },
 /* 01011 */
 { false, true, 0, 12, 4, { 8, 8, 8 },
   { { 0, 0, 0, 10, false }, { 0, 1, 0, 10, false }, { 0, 2, 0, 10, false 
 },
 { 1, 0, 0, 8, false }, { 0, 0, 10, 2, true }, { 1, 1, 0, 8, false },
 { 0, 1, 10, 2, true }, { 1, 2, 0, 8, false }, { 0, 2, 10, 2, true },
 -   { -1 } }
 +   BPTC_FLOAT_BITFIELD_END }
 },
 /* 01110 */
 { false, true, 5, 9, 3, { 5, 5, 5 },
 @@ -174,14 +178,14 @@ bptc_float_modes[] = {
 { 1, 2, 0, 5, false }, { 3, 2, 1, 1, false }, { 2, 2, 0, 4, false },
 { 2, 0, 0, 5, false }, { 3, 2, 2, 1, false }, { 3, 0, 0, 5, false },
 { 3, 2, 3, 1, false },
 -   { -1 } }
 +   BPTC_FLOAT_BITFIELD_END }
 },
 /* 0 */
 { false, true, 0, 16, 4, { 4, 4, 4 },
   { { 0, 0, 0, 10, false }, { 0, 1, 0, 10, false }, { 0, 2, 0, 10, false 
 },
 { 1, 0, 0, 4, false }, { 0, 0, 10, 6, true }, { 1, 1, 0, 4, false },
 { 0, 1, 10, 6, true }, { 1, 2, 0, 4, false }, { 0, 2, 10, 6, true },
 -   { -1 } }
 +   BPTC_FLOAT_BITFIELD_END }
 },
 /* 10010 */
 { false, true, 5, 8, 3, { 6, 5, 5 },
 @@ -192,10 +196,10 @@ bptc_float_modes[] = {
 { 3, 2, 0, 1, false }, { 3, 1, 0, 4, false }, { 1, 2, 0, 5, false },
 { 3, 2, 1, 1, false }, { 2, 2, 0, 4, false }, { 2, 0, 0, 6, false },
 { 3, 0, 0, 6, false },
 -   { -1 } }
 +   BPTC_FLOAT_BITFIELD_END }
 },
 /* 10011 */
 -   { true /* reserved */ },
 +   

Re: [Mesa-dev] [PATCH 1/3] i965: Fix max_wm_threads for gen8

2015-01-21 Thread Kenneth Graunke
On Wednesday, January 21, 2015 08:17:34 PM ville.syrj...@linux.intel.com wrote:
 From: Ville Syrjälä ville.syrj...@linux.intel.com
 
 max_wm_threads depends on the GT SKU on gen8. Update the values to
 match the spec.
 
 The max number of threads in 3DSTATE_PS is always programmed to 64
 and the hardware internally scales that depending on the GT SKU. So
 this doesn't change the max number of threads actually used, but it
 does affect the scratch space calculation.
 
 This is most important on CHV where the old value was too small, so
 the amount of scratch space allocated wasn't sufficient to satisfy the
 actual max number of threads used. On BDW GT1 and GT2 we reduce the
 value to avoid overallocating the scratch space needlessly. BDW GT3
 is unaffected.
 
 Signed-off-by: Ville Syrjälä ville.syrj...@linux.intel.com
 ---
  src/mesa/drivers/dri/i965/brw_device_info.c | 8 +---
  1 file changed, 5 insertions(+), 3 deletions(-)
 
 diff --git a/src/mesa/drivers/dri/i965/brw_device_info.c 
 b/src/mesa/drivers/dri/i965/brw_device_info.c
 index 65942c2..2c3af66 100644
 --- a/src/mesa/drivers/dri/i965/brw_device_info.c
 +++ b/src/mesa/drivers/dri/i965/brw_device_info.c
 @@ -198,11 +198,11 @@ static const struct brw_device_info 
 brw_device_info_hsw_gt3 = {
 .has_llc = true, \
 .has_pln = true, \
 .max_vs_threads = 504,   \
 -   .max_gs_threads = 504,   \
 -   .max_wm_threads = 384\
 +   .max_gs_threads = 504\
  
  static const struct brw_device_info brw_device_info_bdw_gt1 = {
 GEN8_FEATURES, .gt = 1,
 +   .max_wm_threads = 128,
 .urb = {
.size = 192,
.min_vs_entries = 64,
 @@ -213,6 +213,7 @@ static const struct brw_device_info 
 brw_device_info_bdw_gt1 = {
  
  static const struct brw_device_info brw_device_info_bdw_gt2 = {
 GEN8_FEATURES, .gt = 2,
 +   .max_wm_threads = 192,
 .urb = {
.size = 384,
.min_vs_entries = 64,
 @@ -223,6 +224,7 @@ static const struct brw_device_info 
 brw_device_info_bdw_gt2 = {
  
  static const struct brw_device_info brw_device_info_bdw_gt3 = {
 GEN8_FEATURES, .gt = 3,
 +   .max_wm_threads = 384,
 .urb = {
.size = 384,
.min_vs_entries = 64,
 @@ -239,7 +241,7 @@ static const struct brw_device_info brw_device_info_chv = 
 {
 .has_llc = false,
 .max_vs_threads = 80,
 .max_gs_threads = 80,
 -   .max_wm_threads = 102,
 +   .max_wm_threads = 128,
 .urb = {
.size = 128,
.min_vs_entries = 64,
 

Yikes!  Thanks for catching this!

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

One issue though...the Cherryview fix definitely should be marked for stable
(add Cc: mesa-sta...@lists.freedesktop.org to the commit message before
pushing).  But I'm not sure whether we want the BDW space reductions to hit
stable or not.  It's probably fine, but it's also unnecessary.

We could split the patch and mark only the CHV part go to stable, or just
mark the whole thing.  I'll leave it up to you.

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 1/2] nir: Add src and dest constructors

2015-01-21 Thread Connor Abbott
Reviewed-by: Connor Abbott cwabbo...@gmail.com

On Wed, Jan 21, 2015 at 2:14 PM, Jason Ekstrand ja...@jlekstrand.net wrote:
 ---
  src/glsl/nir/nir.h | 37 +
  1 file changed, 37 insertions(+)

 diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
 index 5ebfc5a..7b5794d 100644
 --- a/src/glsl/nir/nir.h
 +++ b/src/glsl/nir/nir.h
 @@ -482,6 +482,43 @@ typedef struct {
 bool is_ssa;
  } nir_dest;

 +static inline nir_src
 +nir_src_for_ssa(nir_ssa_def *def)
 +{
 +   nir_src src;
 +
 +   src.is_ssa = true;
 +   src.ssa = def;
 +
 +   return src;
 +}
 +
 +static inline nir_src
 +nir_src_for_reg(nir_register *reg)
 +{
 +   nir_src src;
 +
 +   src.is_ssa = false;
 +   src.reg.reg = reg;
 +   src.reg.indirect = NULL;
 +   src.reg.base_offset = 0;
 +
 +   return src;
 +}
 +
 +static inline nir_dest
 +nir_dest_for_reg(nir_register *reg)
 +{
 +   nir_dest dest;
 +
 +   dest.is_ssa = false;
 +   dest.reg.reg = reg;
 +   dest.reg.indirect = NULL;
 +   dest.reg.base_offset = 0;
 +
 +   return dest;
 +}
 +
  nir_src nir_src_copy(nir_src src, void *mem_ctx);
  nir_dest nir_dest_copy(nir_dest dest, void *mem_ctx);

 --
 2.2.1

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


Re: [Mesa-dev] [PATCH] glsl/parser: (trivial) fix indentation in one function

2015-01-21 Thread Matt Turner
On Wed, Jan 21, 2015 at 1:12 PM, Tobias Klausmann
tobias.johannes.klausm...@mni.thm.de wrote:
 Signed-off-by: Tobias Klausmann tobias.johannes.klausm...@mni.thm.de
 ---
  src/glsl/glcpp/glcpp-parse.y | 19 ++-
  1 file changed, 10 insertions(+), 9 deletions(-)

 diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
 index e5bebe5..8b545da 100644
 --- a/src/glsl/glcpp/glcpp-parse.y
 +++ b/src/glsl/glcpp/glcpp-parse.y
 @@ -2401,8 +2401,8 @@ _glcpp_parser_handle_version_declaration(glcpp_parser_t 
 *parser, intmax_t versio
  add_builtin_define(parser, 
 GL_ARB_fragment_coord_conventions,
 1);

 -  if (extensions-ARB_fragment_layer_viewport)
 - add_builtin_define(parser, 
 GL_ARB_fragment_layer_viewport, 1);
 + if (extensions-ARB_fragment_layer_viewport)
 +add_builtin_define(parser, GL_ARB_fragment_layer_viewport, 
 1);

   if (extensions-ARB_explicit_attrib_location)
  add_builtin_define(parser, 
 GL_ARB_explicit_attrib_location, 1);
 @@ -2449,7 +2449,8 @@ _glcpp_parser_handle_version_declaration(glcpp_parser_t 
 *parser, intmax_t versio
  add_builtin_define(parser, GL_AMD_vertex_shader_layer, 1);

   if (extensions-AMD_vertex_shader_viewport_index)
 -add_builtin_define(parser, 
 GL_AMD_vertex_shader_viewport_index, 1);
 +add_builtin_define(parser, 
 GL_AMD_vertex_shader_viewport_index,
 +   1);

   if (extensions-ARB_shading_language_420pack)
  add_builtin_define(parser, 
 GL_ARB_shading_language_420pack, 1);
 @@ -2466,17 +2467,17 @@ 
 _glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t 
 versio
   if (extensions-ARB_viewport_array)
  add_builtin_define(parser, GL_ARB_viewport_array, 1);

 -  if (extensions-ARB_compute_shader)
 - add_builtin_define(parser, GL_ARB_compute_shader, 1);
 + if (extensions-ARB_compute_shader)
 + add_builtin_define(parser, GL_ARB_compute_shader, 1);

We're messing up the indentation here.

But really we want to get rid of tabs, not add more. glcpp is
unfortunately full of tabs.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] glsl/parser: (trivial) fix indentation in one function

2015-01-21 Thread Tobias Klausmann

On 21.01.2015 22:22, Matt Turner wrote:
On Wed, Jan 21, 2015 at 1:12 PM, Tobias Klausmann 
tobias.johannes.klausm...@mni.thm.de wrote:

(snip)
We're messing up the indentation here. But really we want to get rid 
of tabs, not add more. glcpp is unfortunately full of tabs.

Alright ignore this one then.

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


[Mesa-dev] [PATCH] glsl/parser: (trivial) fix indentation in one function

2015-01-21 Thread Tobias Klausmann
Signed-off-by: Tobias Klausmann tobias.johannes.klausm...@mni.thm.de
---
 src/glsl/glcpp/glcpp-parse.y | 19 ++-
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index e5bebe5..8b545da 100644
--- a/src/glsl/glcpp/glcpp-parse.y
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -2401,8 +2401,8 @@ _glcpp_parser_handle_version_declaration(glcpp_parser_t 
*parser, intmax_t versio
 add_builtin_define(parser, GL_ARB_fragment_coord_conventions,
1);
 
-  if (extensions-ARB_fragment_layer_viewport)
- add_builtin_define(parser, GL_ARB_fragment_layer_viewport, 
1);
+ if (extensions-ARB_fragment_layer_viewport)
+add_builtin_define(parser, GL_ARB_fragment_layer_viewport, 
1);
 
  if (extensions-ARB_explicit_attrib_location)
 add_builtin_define(parser, GL_ARB_explicit_attrib_location, 
1);
@@ -2449,7 +2449,8 @@ _glcpp_parser_handle_version_declaration(glcpp_parser_t 
*parser, intmax_t versio
 add_builtin_define(parser, GL_AMD_vertex_shader_layer, 1);
 
  if (extensions-AMD_vertex_shader_viewport_index)
-add_builtin_define(parser, 
GL_AMD_vertex_shader_viewport_index, 1);
+add_builtin_define(parser, 
GL_AMD_vertex_shader_viewport_index,
+   1);
 
  if (extensions-ARB_shading_language_420pack)
 add_builtin_define(parser, GL_ARB_shading_language_420pack, 
1);
@@ -2466,17 +2467,17 @@ _glcpp_parser_handle_version_declaration(glcpp_parser_t 
*parser, intmax_t versio
  if (extensions-ARB_viewport_array)
 add_builtin_define(parser, GL_ARB_viewport_array, 1);
 
-  if (extensions-ARB_compute_shader)
- add_builtin_define(parser, GL_ARB_compute_shader, 1);
+ if (extensions-ARB_compute_shader)
+ add_builtin_define(parser, GL_ARB_compute_shader, 1);
 
  if (extensions-ARB_shader_image_load_store)
 add_builtin_define(parser, GL_ARB_shader_image_load_store, 
1);
 
-  if (extensions-ARB_derivative_control)
- add_builtin_define(parser, GL_ARB_derivative_control, 1);
+ if (extensions-ARB_derivative_control)
+add_builtin_define(parser, GL_ARB_derivative_control, 1);
 
-  if (extensions-ARB_shader_precision)
- add_builtin_define(parser, GL_ARB_shader_precision, 1);
+ if (extensions-ARB_shader_precision)
+add_builtin_define(parser, GL_ARB_shader_precision, 1);
   }
}
 
-- 
2.2.1

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


Re: [Mesa-dev] [PATCH 2/3] i965: Fix min_vs_entries for CHV

2015-01-21 Thread Kenneth Graunke
On Wednesday, January 21, 2015 08:17:35 PM ville.syrj...@linux.intel.com wrote:
 From: Ville Syrjälä ville.syrj...@linux.intel.com
 
 According to BSpec the correct number for min_vs_entries is 34 for CHV.
 
 Signed-off-by: Ville Syrjälä ville.syrj...@linux.intel.com
 ---
  src/mesa/drivers/dri/i965/brw_device_info.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/src/mesa/drivers/dri/i965/brw_device_info.c 
 b/src/mesa/drivers/dri/i965/brw_device_info.c
 index 2c3af66..bdef42b 100644
 --- a/src/mesa/drivers/dri/i965/brw_device_info.c
 +++ b/src/mesa/drivers/dri/i965/brw_device_info.c
 @@ -244,7 +244,7 @@ static const struct brw_device_info brw_device_info_chv = 
 {
 .max_wm_threads = 128,
 .urb = {
.size = 128,
 -  .min_vs_entries = 64,
 +  .min_vs_entries = 34,
.max_vs_entries = 640,
.max_gs_entries = 256,
 }
 

Yes, it is.  Thanks!  Given that we always try to allocate the VS as much
space as possible, I doubt this will have much practical impact - and we're
overallocating now - so I don't think it's a stable candidate.

Definitely worth fixing though.

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 v2] glsl: do not allow interface block to have name already taken

2015-01-21 Thread Ian Romanick
Reviewed-by: Ian Romanick ian.d.roman...@intel.com

On 01/20/2015 09:45 PM, Tapani Pälli wrote:
 Fixes currently failing Piglit case
interface-blocks-name-reused-globally.vert
 
 v2: combine var declaration with assignment (Ian)
 
 Signed-off-by: Tapani Pälli tapani.pa...@intel.com
 ---
  src/glsl/ast_to_hir.cpp | 16 +++-
  1 file changed, 15 insertions(+), 1 deletion(-)
 
 diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
 index 811a955..1ba29f7 100644
 --- a/src/glsl/ast_to_hir.cpp
 +++ b/src/glsl/ast_to_hir.cpp
 @@ -5443,9 +5443,23 @@ ast_interface_block::hir(exec_list *instructions,
  
 state-struct_specifier_depth--;
  
 -   if (!redeclaring_per_vertex)
 +   if (!redeclaring_per_vertex) {
validate_identifier(this-block_name, loc, state);
  
 +  /* From section 4.3.9 (Interface Blocks) of the GLSL 4.50 spec:
 +   *
 +   * Block names have no other use within a shader beyond interface
 +   * matching; it is a compile-time error to use a block name at 
 global
 +   * scope for anything other than as a block name.
 +   */
 +  ir_variable *var = state-symbols-get_variable(this-block_name);
 +  if (var  !var-type-is_interface()) {
 + _mesa_glsl_error(loc, state, Block name `%s' is 
 +  already used in the scope.,
 +  this-block_name);
 +  }
 +   }
 +
 const glsl_type *earlier_per_vertex = NULL;
 if (redeclaring_per_vertex) {
/* Find the previous declaration of gl_PerVertex.  If we're redeclaring
 

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


Re: [Mesa-dev] [PATCH 06/16] i965: Add a brw_invert_cmod() function.

2015-01-21 Thread Matt Turner
On Tue, Jan 20, 2015 at 12:11 AM, Kenneth Graunke kenn...@whitecape.org wrote:
 On Monday, January 19, 2015 03:31:05 PM Matt Turner wrote:
 ---
  src/mesa/drivers/dri/i965/brw_eu.c | 22 ++
  src/mesa/drivers/dri/i965/brw_eu.h |  1 +
  2 files changed, 23 insertions(+)

 diff --git a/src/mesa/drivers/dri/i965/brw_eu.c 
 b/src/mesa/drivers/dri/i965/brw_eu.c
 index 9905972..9977eed 100644
 --- a/src/mesa/drivers/dri/i965/brw_eu.c
 +++ b/src/mesa/drivers/dri/i965/brw_eu.c
 @@ -88,6 +88,28 @@ brw_swap_cmod(uint32_t cmod)
 }
  }

 +/* Returns the corresponding inverted conditional mod. */
 +enum brw_conditional_mod
 +brw_invert_cmod(enum brw_conditional_mod cmod)
 +{
 +   switch (cmod) {
 +   case BRW_CONDITIONAL_Z:
 +  return BRW_CONDITIONAL_NZ;
 +   case BRW_CONDITIONAL_NZ:
 +  return BRW_CONDITIONAL_Z;
 +   case BRW_CONDITIONAL_G:
 +  return BRW_CONDITIONAL_LE;
 +   case BRW_CONDITIONAL_GE:
 +  return BRW_CONDITIONAL_L;
 +   case BRW_CONDITIONAL_L:
 +  return BRW_CONDITIONAL_GE;
 +   case BRW_CONDITIONAL_LE:
 +  return BRW_CONDITIONAL_G;
 +   default:
 +  return BRW_CONDITIONAL_NONE;
 +   }
 +}

 Heh, I thought this looked familiar...apparently I wrote one too :)
 http://lists.freedesktop.org/archives/mesa-dev/2014-August/066127.html

 I wasn't sure whether invert meant flip direction or negate condition
 until I read the code.  How about calling it brw_negate_cmod instead?

 /* Returns a conditional modifier that negates the condition. */
 enum brw_conditional_mod
 brw_negate_cmod(uint32_t cmod)
 {
...
 }

 Either way is fine.
 Reviewed-by: Kenneth Graunke kenn...@whitecape.org

Okay, I changed the name, and in the process of thinking about that
and a comment Jason made I realized that part of this function was
wrong. When you negate, you don't want to swap Z - NZ. I've changed
the function accordingly:

+   switch (cmod) {
+   case BRW_CONDITIONAL_Z:
+   case BRW_CONDITIONAL_NZ:
+  return cmod;
[snip]
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 06/16] i965: Add a brw_invert_cmod() function.

2015-01-21 Thread Matt Turner
On Wed, Jan 21, 2015 at 2:52 PM, Kenneth Graunke kenn...@whitecape.org wrote:
 On Wednesday, January 21, 2015 01:02:46 PM Matt Turner wrote:
 On Tue, Jan 20, 2015 at 12:11 AM, Kenneth Graunke kenn...@whitecape.org 
 wrote:
  On Monday, January 19, 2015 03:31:05 PM Matt Turner wrote:
  ---
   src/mesa/drivers/dri/i965/brw_eu.c | 22 ++
   src/mesa/drivers/dri/i965/brw_eu.h |  1 +
   2 files changed, 23 insertions(+)
 
  diff --git a/src/mesa/drivers/dri/i965/brw_eu.c 
  b/src/mesa/drivers/dri/i965/brw_eu.c
  index 9905972..9977eed 100644
  --- a/src/mesa/drivers/dri/i965/brw_eu.c
  +++ b/src/mesa/drivers/dri/i965/brw_eu.c
  @@ -88,6 +88,28 @@ brw_swap_cmod(uint32_t cmod)
  }
   }
 
  +/* Returns the corresponding inverted conditional mod. */
  +enum brw_conditional_mod
  +brw_invert_cmod(enum brw_conditional_mod cmod)
  +{
  +   switch (cmod) {
  +   case BRW_CONDITIONAL_Z:
  +  return BRW_CONDITIONAL_NZ;
  +   case BRW_CONDITIONAL_NZ:
  +  return BRW_CONDITIONAL_Z;
  +   case BRW_CONDITIONAL_G:
  +  return BRW_CONDITIONAL_LE;
  +   case BRW_CONDITIONAL_GE:
  +  return BRW_CONDITIONAL_L;
  +   case BRW_CONDITIONAL_L:
  +  return BRW_CONDITIONAL_GE;
  +   case BRW_CONDITIONAL_LE:
  +  return BRW_CONDITIONAL_G;
  +   default:
  +  return BRW_CONDITIONAL_NONE;
  +   }
  +}
 
  Heh, I thought this looked familiar...apparently I wrote one too :)
  http://lists.freedesktop.org/archives/mesa-dev/2014-August/066127.html
 
  I wasn't sure whether invert meant flip direction or negate condition
  until I read the code.  How about calling it brw_negate_cmod instead?
 
  /* Returns a conditional modifier that negates the condition. */
  enum brw_conditional_mod
  brw_negate_cmod(uint32_t cmod)
  {
 ...
  }
 
  Either way is fine.
  Reviewed-by: Kenneth Graunke kenn...@whitecape.org

 Okay, I changed the name, and in the process of thinking about that
 and a comment Jason made I realized that part of this function was
 wrong. When you negate, you don't want to swap Z - NZ. I've changed
 the function accordingly:

 +   switch (cmod) {
 +   case BRW_CONDITIONAL_Z:
 +   case BRW_CONDITIONAL_NZ:
 +  return cmod;
 [snip]

 What?  This function takes a comparison that produces A and gives you
 a new one that produces !A.

No. It gives the conditional mod you get by negating both operands of
the comparison.

 You absolutely have to change == to != (and
 vice versa), or the function is just plain broken.  You had it right the
 first time.

 brw_swap_cmod doesn't do that, because it takes `X CMP Y` = A and
 returns a new comparison such that `Y CMP' X` = A.  In other words, if
 X  Y, then Y  X.  But if X == Y, then Y == X.

If you review the rest of the series (please do!), you'll see this
function used in patch 14/16. The commit message gives an example of
where we want to use this function, transforming:

   add(8)   temp   a  b
   cmp.l.f0(8)  null   -temp  0.0

into

   add.ge.f0(8) temp   a  b

Imagine that was instead of cmp.l.f0, cmp.z.f0:

   add(8)   temp   a  b
   cmp.z.f0(8)  null   -temp  0.0

This is doing f0 = (-(a + b) == 0.0). If I swap Z - NZ, I'd get

   add.nz.f0(8) temp a b

which would be f0 = ((a + b) != 0.0). In fact, we want the cmp's
original .z on the add:

   add.z.f0(8) temp a b

Perhaps there's a better name we can give the function?
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] i965: Do Sandybridge workaround flushes before each primitive.

2015-01-21 Thread Kenneth Graunke
On Wednesday, January 21, 2015 11:59:39 AM Chad Versace wrote:
 On 01/09/2015 11:07 PM, Kenneth Graunke wrote:
  Sandybridge requires the post-sync non-zero workaround in a ton of
  places, and if you ever miss one, the GPU usually hangs.
  
  Currently, we try to track exactly when a workaround flush is
  necessary (via the brw-batch.need_workaround_flush flag).  This is
  tricky to get right, and we've botched it several times in the past.
  
  This patch unconditionally performs the post-sync non-zero flush at the
  start of each primitive's state upload (including BLORP).  We drop the
  needs_workaround_flush flag, and drop all the other callers, as the
  flush has already been performed.
  
  We have no data to indicate that simply flushing all the time will
  hurt performance, and it has the potential to help stability.
  
  Signed-off-by: Kenneth Graunke kenn...@whitecape.org
 
 Ken, what prompted you to write this patch? Did a SNB hang bite you
 recently?

I actually wrote a similar patch back in January 2014, which dropped the flag,
but continued doing the flush all through the code.  During review, Eric
suggested doing it once at the top instead.

https://freedesktop.org/patch/19180/

I keep seeing reports of SNB GPU hangs go by occasionally, so I figured I'd
throw the patch out there and see if it helped anybody.  I'm not aware of it
helping anything, but there are some mystery hangs left.

 I know how painful it is to solve i-forgot-fush-hangs on SNB, so
 I'm in favor of this patch if it doesn't hurt performainvariant_statence?
 
 Before I give it a rb, I'd like to know how you confirmed that it
 didn't hurt perf.

I don't remember.  Is there anything you'd like me to check?

  @@ -883,10 +863,6 @@ brw_upload_invariant_state(struct brw_context *brw)
   {
  const bool is_965 = brw-gen == 4  !brw-is_g4x;
   
  -   /* 3DSTATE_SIP, 3DSTATE_MULTISAMPLE, etc. are nonpipelined. */
  -   if (brw-gen == 6)
  -  intel_emit_post_sync_nonzero_flush(brw);
  -
 
 With this hunk, no workaround flush happens before uploading the invariant
 state if hw ctx is enabled (which it isn't on Chrome OS btw).

Which reminds me - does ChromeOS add brw_invariant_state back to gen6_atoms?
(It definitely should.)

 Pre-patch, the flush did happen because intel_batchbuffer_init()
 set need_workaround_flush = true. This worries me. Should I be worried?

 Since this patch's goal is to be overly cautious, I would like to be
 overlay cautious here too and continue to do the flush.

I agree - we should keep that flush, if only to be cautious.
Apparently I was a bit overzealous with the delete key :)

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


Re: [Mesa-dev] [PATCH 06/16] i965: Add a brw_invert_cmod() function.

2015-01-21 Thread Matt Turner
On Wed, Jan 21, 2015 at 3:19 PM, Kenneth Graunke kenn...@whitecape.org wrote:
 Okay, I see what you're doing now.  It's definitely not what my
 brw_negate_cmod function did.  This is why you absolutely need
 doxygen comments, ideally with an example.  The functions for
 (a cmp1 b) - !(a cmp1 b) and (a cmp1 b) - (!a cmp2 !b) look
 way too similar at a glance...

Sure, that would have prevented confusion. I'll add

/* Returns the corresponding conditional mod for negating both operands to a
 * CMP.
 */
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 06/16] i965: Add a brw_invert_cmod() function.

2015-01-21 Thread Kenneth Graunke
On Wednesday, January 21, 2015 01:02:46 PM Matt Turner wrote:
 On Tue, Jan 20, 2015 at 12:11 AM, Kenneth Graunke kenn...@whitecape.org 
 wrote:
  On Monday, January 19, 2015 03:31:05 PM Matt Turner wrote:
  ---
   src/mesa/drivers/dri/i965/brw_eu.c | 22 ++
   src/mesa/drivers/dri/i965/brw_eu.h |  1 +
   2 files changed, 23 insertions(+)
 
  diff --git a/src/mesa/drivers/dri/i965/brw_eu.c 
  b/src/mesa/drivers/dri/i965/brw_eu.c
  index 9905972..9977eed 100644
  --- a/src/mesa/drivers/dri/i965/brw_eu.c
  +++ b/src/mesa/drivers/dri/i965/brw_eu.c
  @@ -88,6 +88,28 @@ brw_swap_cmod(uint32_t cmod)
  }
   }
 
  +/* Returns the corresponding inverted conditional mod. */
  +enum brw_conditional_mod
  +brw_invert_cmod(enum brw_conditional_mod cmod)
  +{
  +   switch (cmod) {
  +   case BRW_CONDITIONAL_Z:
  +  return BRW_CONDITIONAL_NZ;
  +   case BRW_CONDITIONAL_NZ:
  +  return BRW_CONDITIONAL_Z;
  +   case BRW_CONDITIONAL_G:
  +  return BRW_CONDITIONAL_LE;
  +   case BRW_CONDITIONAL_GE:
  +  return BRW_CONDITIONAL_L;
  +   case BRW_CONDITIONAL_L:
  +  return BRW_CONDITIONAL_GE;
  +   case BRW_CONDITIONAL_LE:
  +  return BRW_CONDITIONAL_G;
  +   default:
  +  return BRW_CONDITIONAL_NONE;
  +   }
  +}
 
  Heh, I thought this looked familiar...apparently I wrote one too :)
  http://lists.freedesktop.org/archives/mesa-dev/2014-August/066127.html
 
  I wasn't sure whether invert meant flip direction or negate condition
  until I read the code.  How about calling it brw_negate_cmod instead?
 
  /* Returns a conditional modifier that negates the condition. */
  enum brw_conditional_mod
  brw_negate_cmod(uint32_t cmod)
  {
 ...
  }
 
  Either way is fine.
  Reviewed-by: Kenneth Graunke kenn...@whitecape.org
 
 Okay, I changed the name, and in the process of thinking about that
 and a comment Jason made I realized that part of this function was
 wrong. When you negate, you don't want to swap Z - NZ. I've changed
 the function accordingly:
 
 +   switch (cmod) {
 +   case BRW_CONDITIONAL_Z:
 +   case BRW_CONDITIONAL_NZ:
 +  return cmod;
 [snip]

What?  This function takes a comparison that produces A and gives you
a new one that produces !A.  You absolutely have to change == to != (and
vice versa), or the function is just plain broken.  You had it right the
first time.

brw_swap_cmod doesn't do that, because it takes `X CMP Y` = A and
returns a new comparison such that `Y CMP' X` = A.  In other words, if
X  Y, then Y  X.  But if X == Y, then Y == X.

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 06/16] i965: Add a brw_invert_cmod() function.

2015-01-21 Thread Kenneth Graunke
On Wednesday, January 21, 2015 03:05:03 PM Matt Turner wrote:
 On Wed, Jan 21, 2015 at 2:52 PM, Kenneth Graunke kenn...@whitecape.org 
 wrote:
  On Wednesday, January 21, 2015 01:02:46 PM Matt Turner wrote:
  On Tue, Jan 20, 2015 at 12:11 AM, Kenneth Graunke kenn...@whitecape.org 
  wrote:
   On Monday, January 19, 2015 03:31:05 PM Matt Turner wrote:
   ---
src/mesa/drivers/dri/i965/brw_eu.c | 22 ++
src/mesa/drivers/dri/i965/brw_eu.h |  1 +
2 files changed, 23 insertions(+)
  
   diff --git a/src/mesa/drivers/dri/i965/brw_eu.c 
   b/src/mesa/drivers/dri/i965/brw_eu.c
   index 9905972..9977eed 100644
   --- a/src/mesa/drivers/dri/i965/brw_eu.c
   +++ b/src/mesa/drivers/dri/i965/brw_eu.c
   @@ -88,6 +88,28 @@ brw_swap_cmod(uint32_t cmod)
   }
}
  
   +/* Returns the corresponding inverted conditional mod. */
   +enum brw_conditional_mod
   +brw_invert_cmod(enum brw_conditional_mod cmod)
   +{
   +   switch (cmod) {
   +   case BRW_CONDITIONAL_Z:
   +  return BRW_CONDITIONAL_NZ;
   +   case BRW_CONDITIONAL_NZ:
   +  return BRW_CONDITIONAL_Z;
   +   case BRW_CONDITIONAL_G:
   +  return BRW_CONDITIONAL_LE;
   +   case BRW_CONDITIONAL_GE:
   +  return BRW_CONDITIONAL_L;
   +   case BRW_CONDITIONAL_L:
   +  return BRW_CONDITIONAL_GE;
   +   case BRW_CONDITIONAL_LE:
   +  return BRW_CONDITIONAL_G;
   +   default:
   +  return BRW_CONDITIONAL_NONE;
   +   }
   +}
  
   Heh, I thought this looked familiar...apparently I wrote one too :)
   http://lists.freedesktop.org/archives/mesa-dev/2014-August/066127.html
  
   I wasn't sure whether invert meant flip direction or negate 
   condition
   until I read the code.  How about calling it brw_negate_cmod instead?
  
   /* Returns a conditional modifier that negates the condition. */
   enum brw_conditional_mod
   brw_negate_cmod(uint32_t cmod)
   {
  ...
   }
  
   Either way is fine.
   Reviewed-by: Kenneth Graunke kenn...@whitecape.org
 
  Okay, I changed the name, and in the process of thinking about that
  and a comment Jason made I realized that part of this function was
  wrong. When you negate, you don't want to swap Z - NZ. I've changed
  the function accordingly:
 
  +   switch (cmod) {
  +   case BRW_CONDITIONAL_Z:
  +   case BRW_CONDITIONAL_NZ:
  +  return cmod;
  [snip]
 
  What?  This function takes a comparison that produces A and gives you
  a new one that produces !A.
 
 No. It gives the conditional mod you get by negating both operands of
 the comparison.
 
  You absolutely have to change == to != (and
  vice versa), or the function is just plain broken.  You had it right the
  first time.
 
  brw_swap_cmod doesn't do that, because it takes `X CMP Y` = A and
  returns a new comparison such that `Y CMP' X` = A.  In other words, if
  X  Y, then Y  X.  But if X == Y, then Y == X.
 
 If you review the rest of the series (please do!), you'll see this

It's on my list...

 function used in patch 14/16. The commit message gives an example of
 where we want to use this function, transforming:
 
add(8)   temp   a  b
cmp.l.f0(8)  null   -temp  0.0
 
 into
 
add.ge.f0(8) temp   a  b
 
 Imagine that was instead of cmp.l.f0, cmp.z.f0:
 
add(8)   temp   a  b
cmp.z.f0(8)  null   -temp  0.0
 
 This is doing f0 = (-(a + b) == 0.0). If I swap Z - NZ, I'd get
 
add.nz.f0(8) temp a b
 
 which would be f0 = ((a + b) != 0.0). In fact, we want the cmp's
 original .z on the add:
 
add.z.f0(8) temp a b
 
 Perhaps there's a better name we can give the function?

Okay, I see what you're doing now.  It's definitely not what my
brw_negate_cmod function did.  This is why you absolutely need
doxygen comments, ideally with an example.  The functions for
(a cmp1 b) - !(a cmp1 b) and (a cmp1 b) - (!a cmp2 !b) look
way too similar at a glance...

brw_invert_cmod is probably fine, with a comment.

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 2/3] mesa: Add initializer macros to fix missing initializer warnings

2015-01-21 Thread Jan Vesely
On Wed, 2015-01-21 at 12:34 -0800, Ian Romanick wrote:
 On 01/21/2015 10:33 AM, Jan Vesely wrote:
  NFC.
 
 NFC?  I'm assuming this doesn't mean Near Field Communications or no
 'fine' clue.

No functional change. seen that in other commits somwhere, thoght it was
universal

 
  Signed-off-by: Jan Vesely jan.ves...@rutgers.edu
  ---
   src/mesa/main/texcompress_bptc.c | 40 
  ++--
   1 file changed, 22 insertions(+), 18 deletions(-)
  
  diff --git a/src/mesa/main/texcompress_bptc.c 
  b/src/mesa/main/texcompress_bptc.c
  index c944ac2..56ca320 100644
  --- a/src/mesa/main/texcompress_bptc.c
  +++ b/src/mesa/main/texcompress_bptc.c
  @@ -59,6 +59,8 @@ struct bptc_float_bitfield {
  bool reverse;
   };
   
  +#define BPTC_FLOAT_BITFIELD_END { -1, 0, 0, 0, false }
  +
   struct bptc_float_mode {
  bool reserved;
  bool transformed_endpoints;
  @@ -69,6 +71,8 @@ struct bptc_float_mode {
  struct bptc_float_bitfield bitfields[24];
   };
   
  +#define BPTC_FLOAT_MODE_RESERVED { true, false, 0, 0, 0, {}, {}}
  +
   struct bit_writer {
  uint8_t buf;
  int pos;
  @@ -98,7 +102,7 @@ bptc_float_modes[] = {
  { 1, 2, 0, 5, false }, { 3, 2, 1, 1, false }, { 2, 2, 0, 4, false },
  { 2, 0, 0, 5, false }, { 3, 2, 2, 1, false }, { 3, 0, 0, 5, false },
  { 3, 2, 3, 1, false },
  -   { -1 } }
 
 I think just adding a , after the -1 will have the same effect.  C
 explicitly states that missing members are initialized to 0.

It does not get rid of the warnings, at least not on my setup (gcc (GCC)
4.9.2 20141101 (Red Hat 4.9.2-1)). I know c90 allows it but I have seen
few gcc bugs that requested relaxing this warning (like [0], although
that one seems to target zero initialization).

Other than that, macro looked nicer than { true /*reserved*/ }

jan

[0] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36750

 
  +   BPTC_FLOAT_BITFIELD_END }
  },
  /* 01 */
  { false, true, 5, 7, 3, { 6, 6, 6 },
  @@ -111,7 +115,7 @@ bptc_float_modes[] = {
  { 3, 1, 0, 4, false }, { 1, 2, 0, 6, false }, { 2, 2, 0, 4, false },
  { 2, 0, 0, 6, false },
  { 3, 0, 0, 6, false },
  -   { -1 } }
  +   BPTC_FLOAT_BITFIELD_END }
  },
  /* 00010 */
  { false, true, 5, 11, 3, { 5, 4, 4 },
  @@ -121,13 +125,13 @@ bptc_float_modes[] = {
  { 3, 1, 0, 4, false }, { 1, 2, 0, 4, false }, { 0, 2, 10, 1, false 
  },
  { 3, 2, 1, 1, false }, { 2, 2, 0, 4, false }, { 2, 0, 0, 5, false },
  { 3, 2, 2, 1, false }, { 3, 0, 0, 5, false }, { 3, 2, 3, 1, false },
  -   { -1 } }
  +   BPTC_FLOAT_BITFIELD_END }
  },
  /* 00011 */
  { false, false, 0, 10, 4, { 10, 10, 10 },
{ { 0, 0, 0, 10, false }, { 0, 1, 0, 10, false }, { 0, 2, 0, 10, 
  false },
  { 1, 0, 0, 10, false }, { 1, 1, 0, 10, false }, { 1, 2, 0, 10, 
  false },
  -   { -1 } }
  +   BPTC_FLOAT_BITFIELD_END }
  },
  /* 00110 */
  { false, true, 5, 11, 3, { 4, 5, 4 },
  @@ -138,14 +142,14 @@ bptc_float_modes[] = {
  { 3, 2, 1, 1, false }, { 2, 2, 0, 4, false }, { 2, 0, 0, 4, false },
  { 3, 2, 0, 1, false }, { 3, 2, 2, 1, false }, { 3, 0, 0, 4, false },
  { 2, 1, 4, 1, false }, { 3, 2, 3, 1, false },
  -   { -1 } }
  +   BPTC_FLOAT_BITFIELD_END }
  },
  /* 00111 */
  { false, true, 0, 11, 4, { 9, 9, 9 },
{ { 0, 0, 0, 10, false }, { 0, 1, 0, 10, false }, { 0, 2, 0, 10, 
  false },
  { 1, 0, 0, 9, false }, { 0, 0, 10, 1, false }, { 1, 1, 0, 9, false 
  },
  { 0, 1, 10, 1, false }, { 1, 2, 0, 9, false }, { 0, 2, 10, 1, false 
  },
  -   { -1 } }
  +   BPTC_FLOAT_BITFIELD_END }
  },
  /* 01010 */
  { false, true, 5, 11, 3, { 4, 4, 5 },
  @@ -156,14 +160,14 @@ bptc_float_modes[] = {
  { 0, 2, 10, 1, false }, { 2, 2, 0, 4, false }, { 2, 0, 0, 4, false 
  },
  { 3, 2, 1, 1, false }, { 3, 2, 2, 1, false }, { 3, 0, 0, 4, false },
  { 3, 2, 4, 1, false }, { 3, 2, 3, 1, false },
  -   { -1 } }
  +   BPTC_FLOAT_BITFIELD_END }
  },
  /* 01011 */
  { false, true, 0, 12, 4, { 8, 8, 8 },
{ { 0, 0, 0, 10, false }, { 0, 1, 0, 10, false }, { 0, 2, 0, 10, 
  false },
  { 1, 0, 0, 8, false }, { 0, 0, 10, 2, true }, { 1, 1, 0, 8, false },
  { 0, 1, 10, 2, true }, { 1, 2, 0, 8, false }, { 0, 2, 10, 2, true },
  -   { -1 } }
  +   BPTC_FLOAT_BITFIELD_END }
  },
  /* 01110 */
  { false, true, 5, 9, 3, { 5, 5, 5 },
  @@ -174,14 +178,14 @@ bptc_float_modes[] = {
  { 1, 2, 0, 5, false }, { 3, 2, 1, 1, false }, { 2, 2, 0, 4, false },
  { 2, 0, 0, 5, false }, { 3, 2, 2, 1, false }, { 3, 0, 0, 5, false },
  { 3, 2, 3, 1, false },
  -   { -1 } }
  +   BPTC_FLOAT_BITFIELD_END }
  },
  /* 0 */
  { false, true, 0, 16, 4, { 4, 4, 4 },
{ { 0, 0, 0, 10, false }, { 0, 1, 0, 10, false }, { 0, 2, 0, 

Re: [Mesa-dev] [PATCH 2/3] mesa: Add initializer macros to fix missing initializer warnings

2015-01-21 Thread Matt Turner
On Wed, Jan 21, 2015 at 3:49 PM, Jan Vesely jan.ves...@rutgers.edu wrote:
 On Wed, 2015-01-21 at 12:34 -0800, Ian Romanick wrote:
 On 01/21/2015 10:33 AM, Jan Vesely wrote:
  NFC.

 NFC?  I'm assuming this doesn't mean Near Field Communications or no
 'fine' clue.

 No functional change. seen that in other commits somwhere, thoght it was
 universal

NFC literally doesn't ever appear in the Mesa git log. I don't think
saying no functional change is necessary for warning fixes.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 84566] Unify the format conversion code

2015-01-21 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=84566

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

   What|Removed |Added

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

--- Comment #56 from Jason Ekstrand ja...@jlekstrand.net ---
This was merged as of a few weeks ago.  Good work guys!

-- 
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] [PATCH] mesa/autoconf: attempt to use gnu99 on older gcc compilers

2015-01-21 Thread Dave Airlie
From: Dave Airlie airl...@redhat.com

anonymous structs/union don't work with c99 but do work with gnu99
on gcc 4.4.

This on top of Jason's designated initialisers changes, make
Mesa build on RHEL6 again.

Signed-off-by: Dave Airlie airl...@redhat.com
---
 configure.ac |   12 +++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index a4c5c74..9420a90 100644
--- a/configure.ac
+++ b/configure.ac
@@ -145,6 +145,7 @@ AC_MSG_RESULT([$acv_mesa_CLANG])
 dnl If we're using GCC, make sure that it is at least version 4.2.0.  Older
 dnl versions are explictly not supported.
 GEN_ASM_OFFSETS=no
+USE_GNU99=no
 if test x$GCC = xyes -a x$acv_mesa_CLANG = xno; then
 AC_MSG_CHECKING([whether gcc version is sufficient])
 major=0
@@ -163,6 +164,9 @@ if test x$GCC = xyes -a x$acv_mesa_CLANG = xno; then
 AC_MSG_RESULT([yes])
 fi
 
+if test $GCC_VERSION_MAJOR -lt 4 -o $GCC_VERSION_MAJOR -eq 4 -a 
$GCC_VERSION_MINOR -lt 6 ; then
+USE_GNU99=yes
+fi
 if test x$cross_compiling = xyes; then
 GEN_ASM_OFFSETS=yes
 fi
@@ -221,7 +225,13 @@ esac
 
 dnl Add flags for gcc and g++
 if test x$GCC = xyes; then
-CFLAGS=$CFLAGS -Wall -std=c99
+CFLAGS=$CFLAGS -Wall
+
+if test x$USE_GNU99 = xyes; then
+   CFLAGS=$CFLAGS -std=gnu99
+else
+   CFLAGS=$CFLAGS -std=c99
+fi
 
 # Enable -Werror=implicit-function-declaration and
 # -Werror=missing-prototypes, if available, or otherwise, just
-- 
1.7.1

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


Re: [Mesa-dev] [PATCH] mesa/autoconf: attempt to use gnu99 on older gcc compilers

2015-01-21 Thread Ian Romanick
On 01/21/2015 05:35 PM, Matt Turner wrote:
 On Wed, Jan 21, 2015 at 5:28 PM, Dave Airlie airl...@gmail.com wrote:
 From: Dave Airlie airl...@redhat.com

 anonymous structs/union don't work with c99 but do work with gnu99
 on gcc 4.4.

 This on top of Jason's designated initialisers changes, make
 Mesa build on RHEL6 again.

 Signed-off-by: Dave Airlie airl...@redhat.com
 ---
  configure.ac |   12 +++-
  1 files changed, 11 insertions(+), 1 deletions(-)

 diff --git a/configure.ac b/configure.ac
 index a4c5c74..9420a90 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -145,6 +145,7 @@ AC_MSG_RESULT([$acv_mesa_CLANG])
  dnl If we're using GCC, make sure that it is at least version 4.2.0.  Older
  dnl versions are explictly not supported.
  GEN_ASM_OFFSETS=no
 +USE_GNU99=no
  if test x$GCC = xyes -a x$acv_mesa_CLANG = xno; then
  AC_MSG_CHECKING([whether gcc version is sufficient])
  major=0
 @@ -163,6 +164,9 @@ if test x$GCC = xyes -a x$acv_mesa_CLANG = xno; then
  AC_MSG_RESULT([yes])
  fi

 +if test $GCC_VERSION_MAJOR -lt 4 -o $GCC_VERSION_MAJOR -eq 4 -a 
 $GCC_VERSION_MINOR -lt 6 ; then
 
 Can't we just do this test...
 
 +USE_GNU99=yes
 +fi
  if test x$cross_compiling = xyes; then
  GEN_ASM_OFFSETS=yes
  fi
 @@ -221,7 +225,13 @@ esac

  dnl Add flags for gcc and g++
  if test x$GCC = xyes; then
 -CFLAGS=$CFLAGS -Wall -std=c99
 +CFLAGS=$CFLAGS -Wall
 +
 +if test x$USE_GNU99 = xyes; then
 
 ... right here?

It would happen on clang if we did.  Above, it's inside a block of am I
GCC and definitely not clang.  That said, I don't know how important
that is...

 +   CFLAGS=$CFLAGS -std=gnu99
 +else
 +   CFLAGS=$CFLAGS -std=c99
 +fi

  # Enable -Werror=implicit-function-declaration and
  # -Werror=missing-prototypes, if available, or otherwise, just
 --
 1.7.1

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

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


Re: [Mesa-dev] [PATCH] mesa/autoconf: attempt to use gnu99 on older gcc compilers

2015-01-21 Thread Matt Turner
On Wed, Jan 21, 2015 at 5:28 PM, Dave Airlie airl...@gmail.com wrote:
 From: Dave Airlie airl...@redhat.com

 anonymous structs/union don't work with c99 but do work with gnu99
 on gcc 4.4.

 This on top of Jason's designated initialisers changes, make
 Mesa build on RHEL6 again.

 Signed-off-by: Dave Airlie airl...@redhat.com
 ---
  configure.ac |   12 +++-
  1 files changed, 11 insertions(+), 1 deletions(-)

 diff --git a/configure.ac b/configure.ac
 index a4c5c74..9420a90 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -145,6 +145,7 @@ AC_MSG_RESULT([$acv_mesa_CLANG])
  dnl If we're using GCC, make sure that it is at least version 4.2.0.  Older
  dnl versions are explictly not supported.
  GEN_ASM_OFFSETS=no
 +USE_GNU99=no
  if test x$GCC = xyes -a x$acv_mesa_CLANG = xno; then
  AC_MSG_CHECKING([whether gcc version is sufficient])
  major=0
 @@ -163,6 +164,9 @@ if test x$GCC = xyes -a x$acv_mesa_CLANG = xno; then
  AC_MSG_RESULT([yes])
  fi

 +if test $GCC_VERSION_MAJOR -lt 4 -o $GCC_VERSION_MAJOR -eq 4 -a 
 $GCC_VERSION_MINOR -lt 6 ; then

Can't we just do this test...

 +USE_GNU99=yes
 +fi
  if test x$cross_compiling = xyes; then
  GEN_ASM_OFFSETS=yes
  fi
 @@ -221,7 +225,13 @@ esac

  dnl Add flags for gcc and g++
  if test x$GCC = xyes; then
 -CFLAGS=$CFLAGS -Wall -std=c99
 +CFLAGS=$CFLAGS -Wall
 +
 +if test x$USE_GNU99 = xyes; then

... right here?

 +   CFLAGS=$CFLAGS -std=gnu99
 +else
 +   CFLAGS=$CFLAGS -std=c99
 +fi

  # Enable -Werror=implicit-function-declaration and
  # -Werror=missing-prototypes, if available, or otherwise, just
 --
 1.7.1

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


Re: [Mesa-dev] [PATCH 06/16] i965: Add a brw_invert_cmod() function.

2015-01-21 Thread Ian Romanick
On 01/21/2015 03:05 PM, Matt Turner wrote:
 On Wed, Jan 21, 2015 at 2:52 PM, Kenneth Graunke kenn...@whitecape.org 
 wrote:
 On Wednesday, January 21, 2015 01:02:46 PM Matt Turner wrote:
 On Tue, Jan 20, 2015 at 12:11 AM, Kenneth Graunke kenn...@whitecape.org 
 wrote:
 On Monday, January 19, 2015 03:31:05 PM Matt Turner wrote:
 ---
  src/mesa/drivers/dri/i965/brw_eu.c | 22 ++
  src/mesa/drivers/dri/i965/brw_eu.h |  1 +
  2 files changed, 23 insertions(+)

 diff --git a/src/mesa/drivers/dri/i965/brw_eu.c 
 b/src/mesa/drivers/dri/i965/brw_eu.c
 index 9905972..9977eed 100644
 --- a/src/mesa/drivers/dri/i965/brw_eu.c
 +++ b/src/mesa/drivers/dri/i965/brw_eu.c
 @@ -88,6 +88,28 @@ brw_swap_cmod(uint32_t cmod)
 }
  }

 +/* Returns the corresponding inverted conditional mod. */
 +enum brw_conditional_mod
 +brw_invert_cmod(enum brw_conditional_mod cmod)
 +{
 +   switch (cmod) {
 +   case BRW_CONDITIONAL_Z:
 +  return BRW_CONDITIONAL_NZ;
 +   case BRW_CONDITIONAL_NZ:
 +  return BRW_CONDITIONAL_Z;
 +   case BRW_CONDITIONAL_G:
 +  return BRW_CONDITIONAL_LE;
 +   case BRW_CONDITIONAL_GE:
 +  return BRW_CONDITIONAL_L;
 +   case BRW_CONDITIONAL_L:
 +  return BRW_CONDITIONAL_GE;
 +   case BRW_CONDITIONAL_LE:
 +  return BRW_CONDITIONAL_G;
 +   default:
 +  return BRW_CONDITIONAL_NONE;
 +   }
 +}

 Heh, I thought this looked familiar...apparently I wrote one too :)
 http://lists.freedesktop.org/archives/mesa-dev/2014-August/066127.html

 I wasn't sure whether invert meant flip direction or negate condition
 until I read the code.  How about calling it brw_negate_cmod instead?

 /* Returns a conditional modifier that negates the condition. */
 enum brw_conditional_mod
 brw_negate_cmod(uint32_t cmod)
 {
...
 }

 Either way is fine.
 Reviewed-by: Kenneth Graunke kenn...@whitecape.org

 Okay, I changed the name, and in the process of thinking about that
 and a comment Jason made I realized that part of this function was
 wrong. When you negate, you don't want to swap Z - NZ. I've changed
 the function accordingly:

 +   switch (cmod) {
 +   case BRW_CONDITIONAL_Z:
 +   case BRW_CONDITIONAL_NZ:
 +  return cmod;
 [snip]

 What?  This function takes a comparison that produces A and gives you
 a new one that produces !A.
 
 No. It gives the conditional mod you get by negating both operands of
 the comparison.

Which is the same as if you commute the arguments, right?  Maybe
brw_cmod_for_commuted_args or brw_cmod_for_negated_args is a better
name.  Based on this discussion, I think the function pre-comment is
also a little misleading.  It sounds like it returns the !A cmod.

 You absolutely have to change == to != (and
 vice versa), or the function is just plain broken.  You had it right the
 first time.

 brw_swap_cmod doesn't do that, because it takes `X CMP Y` = A and
 returns a new comparison such that `Y CMP' X` = A.  In other words, if
 X  Y, then Y  X.  But if X == Y, then Y == X.
 
 If you review the rest of the series (please do!), you'll see this
 function used in patch 14/16. The commit message gives an example of
 where we want to use this function, transforming:
 
add(8)   temp   a  b
cmp.l.f0(8)  null   -temp  0.0
 
 into
 
add.ge.f0(8) temp   a  b
 
 Imagine that was instead of cmp.l.f0, cmp.z.f0:
 
add(8)   temp   a  b
cmp.z.f0(8)  null   -temp  0.0
 
 This is doing f0 = (-(a + b) == 0.0). If I swap Z - NZ, I'd get
 
add.nz.f0(8) temp a b
 
 which would be f0 = ((a + b) != 0.0). In fact, we want the cmp's
 original .z on the add:
 
add.z.f0(8) temp a b
 
 Perhaps there's a better name we can give the function?
 ___
 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 06/16] i965: Add a brw_invert_cmod() function.

2015-01-21 Thread Matt Turner
On Wed, Jan 21, 2015 at 6:57 PM, Ian Romanick i...@freedesktop.org wrote:
 On 01/21/2015 03:05 PM, Matt Turner wrote:
 On Wed, Jan 21, 2015 at 2:52 PM, Kenneth Graunke kenn...@whitecape.org 
 wrote:
 On Wednesday, January 21, 2015 01:02:46 PM Matt Turner wrote:
 Okay, I changed the name, and in the process of thinking about that
 and a comment Jason made I realized that part of this function was
 wrong. When you negate, you don't want to swap Z - NZ. I've changed
 the function accordingly:

 +   switch (cmod) {
 +   case BRW_CONDITIONAL_Z:
 +   case BRW_CONDITIONAL_NZ:
 +  return cmod;
 [snip]

 What?  This function takes a comparison that produces A and gives you
 a new one that produces !A.

 No. It gives the conditional mod you get by negating both operands of
 the comparison.

 Which is the same as if you commute the arguments, right?

Yes, actually. Thanks for mentioning that. That's made me realize the
rest of the patch is wrong (in addition to Z/NZ) and that I should
just be using the existing brw_swap_cmod() function.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] nir: Replace assert(0) with unreachable().

2015-01-21 Thread Connor Abbott
Reviewed-by: Connor Abbott cwabbo...@gmail.com

On Wed, Jan 21, 2015 at 11:23 PM, Matt Turner matts...@gmail.com wrote:
 Fixes a couple of warnings in the process.
 ---
  src/glsl/nir/glsl_to_nir.cpp   | 57 
 --
  src/glsl/nir/nir.h |  3 +-
  src/glsl/nir/nir_lower_system_values.c |  3 +-
  src/glsl/nir/nir_to_ssa.c  |  2 +-
  4 files changed, 22 insertions(+), 43 deletions(-)

 diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp
 index 6ac830e..1457c1c 100644
 --- a/src/glsl/nir/glsl_to_nir.cpp
 +++ b/src/glsl/nir/glsl_to_nir.cpp
 @@ -216,8 +216,7 @@ constant_copy(ir_constant *ir, void *mem_ctx)
break;

 default:
 -  assert(0);
 -  break;
 +  unreachable(not reached);
 }

 return ret;
 @@ -278,8 +277,7 @@ nir_visitor::visit(ir_variable *ir)
break;

 default:
 -  assert(0);
 -  break;
 +  unreachable(not reached);
 }

 var-data.interpolation = ir-data.interpolation;
 @@ -311,8 +309,7 @@ nir_visitor::visit(ir_variable *ir)
var-data.depth_layout = nir_depth_layout_unchanged;
break;
 default:
 -  assert(0);
 -  break;
 +  unreachable(not reached);
 }

 var-data.location = ir-data.location;
 @@ -374,8 +371,7 @@ nir_visitor::visit(ir_variable *ir)
break;

 default:
 -  assert(0);
 -  break;
 +  unreachable(not reached);
 }

 _mesa_hash_table_insert(var_table, ir, var);
 @@ -429,8 +425,7 @@ nir_visitor::create_overload(ir_function_signature *ir, 
 nir_function *function)
   break;

default:
 - assert(0);
 - break;
 + unreachable(not reached);
}

overload-params[i].type = param-type;
 @@ -573,8 +568,7 @@ nir_visitor::visit(ir_loop_jump *ir)
type = nir_jump_continue;
break;
 default:
 -  assert(0);
 -  break;
 +  unreachable(not reached);
 }

 nir_jump_instr *instr = nir_jump_instr_create(this-shader, type);
 @@ -793,8 +787,7 @@ get_instr_dest(nir_instr *instr)
   return tex_instr-dest;

default:
 - assert(0);
 - break;
 + unreachable(not reached);
 }

 return NULL;
 @@ -1087,8 +1080,7 @@ nir_visitor::visit(ir_expression *ir)
dest_size, srcs);
   break;
default:
 - assert(0);
 - break;
 + unreachable(not reached);
}
break;
 case ir_unop_trunc: emit(nir_op_ftrunc, dest_size, srcs); break;
 @@ -1207,8 +1199,7 @@ nir_visitor::visit(ir_expression *ir)
   }
   break;
default:
 - assert(0);
 - break;
 + unreachable(not reached);
}
break;
 case ir_binop_add:
 @@ -1296,8 +1287,7 @@ nir_visitor::visit(ir_expression *ir)
   break;

default:
 - assert(0);
 - break;
 + unreachable(not reached);
}

instr = emit(op, dest_size, srcs);
 @@ -1402,8 +1392,7 @@ nir_visitor::visit(ir_expression *ir)
 case 3: emit(nir_op_ball_fequal3, dest_size, srcs); break;
 case 4: emit(nir_op_ball_fequal4, dest_size, srcs); break;
 default:
 -  assert(0);
 -  break;
 +  unreachable(not reached);
  }
   } else {
  switch (ir-operands[0]-type-vector_elements) {
 @@ -1412,8 +1401,7 @@ nir_visitor::visit(ir_expression *ir)
 case 3: emit(nir_op_ball_iequal3, dest_size, srcs); break;
 case 4: emit(nir_op_ball_iequal4, dest_size, srcs); break;
 default:
 -  assert(0);
 -  break;
 +  unreachable(not reached);
  }
   }
} else {
 @@ -1423,8 +1411,7 @@ nir_visitor::visit(ir_expression *ir)
  case 3: emit(nir_op_fall_equal3, dest_size, srcs); break;
  case 4: emit(nir_op_fall_equal4, dest_size, srcs); break;
  default:
 -   assert(0);
 -   break;
 +   unreachable(not reached);
   }
}
break;
 @@ -1437,8 +1424,7 @@ nir_visitor::visit(ir_expression *ir)
 case 3: emit(nir_op_bany_fnequal3, dest_size, srcs); break;
 case 4: emit(nir_op_bany_fnequal4, dest_size, srcs); break;
 default:
 -  assert(0);
 -  break;
 +  unreachable(not reached);
  }
   } else {
  switch (ir-operands[0]-type-vector_elements) {
 @@ -1447,8 +1433,7 @@ nir_visitor::visit(ir_expression *ir)
 case 3: emit(nir_op_bany_inequal3, dest_size, srcs); break;
 case 4: emit(nir_op_bany_inequal4, dest_size, srcs); break;
 default:
 -  assert(0);
 -  break;
 +  unreachable(not 

[Mesa-dev] [PATCH] nir: Replace assert(0) with unreachable().

2015-01-21 Thread Matt Turner
Fixes a couple of warnings in the process.
---
 src/glsl/nir/glsl_to_nir.cpp   | 57 --
 src/glsl/nir/nir.h |  3 +-
 src/glsl/nir/nir_lower_system_values.c |  3 +-
 src/glsl/nir/nir_to_ssa.c  |  2 +-
 4 files changed, 22 insertions(+), 43 deletions(-)

diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp
index 6ac830e..1457c1c 100644
--- a/src/glsl/nir/glsl_to_nir.cpp
+++ b/src/glsl/nir/glsl_to_nir.cpp
@@ -216,8 +216,7 @@ constant_copy(ir_constant *ir, void *mem_ctx)
   break;
 
default:
-  assert(0);
-  break;
+  unreachable(not reached);
}
 
return ret;
@@ -278,8 +277,7 @@ nir_visitor::visit(ir_variable *ir)
   break;
 
default:
-  assert(0);
-  break;
+  unreachable(not reached);
}
 
var-data.interpolation = ir-data.interpolation;
@@ -311,8 +309,7 @@ nir_visitor::visit(ir_variable *ir)
   var-data.depth_layout = nir_depth_layout_unchanged;
   break;
default:
-  assert(0);
-  break;
+  unreachable(not reached);
}
 
var-data.location = ir-data.location;
@@ -374,8 +371,7 @@ nir_visitor::visit(ir_variable *ir)
   break;
 
default:
-  assert(0);
-  break;
+  unreachable(not reached);
}
 
_mesa_hash_table_insert(var_table, ir, var);
@@ -429,8 +425,7 @@ nir_visitor::create_overload(ir_function_signature *ir, 
nir_function *function)
  break;
 
   default:
- assert(0);
- break;
+ unreachable(not reached);
   }
 
   overload-params[i].type = param-type;
@@ -573,8 +568,7 @@ nir_visitor::visit(ir_loop_jump *ir)
   type = nir_jump_continue;
   break;
default:
-  assert(0);
-  break;
+  unreachable(not reached);
}
 
nir_jump_instr *instr = nir_jump_instr_create(this-shader, type);
@@ -793,8 +787,7 @@ get_instr_dest(nir_instr *instr)
  return tex_instr-dest;
 
   default:
- assert(0);
- break;
+ unreachable(not reached);
}
 
return NULL;
@@ -1087,8 +1080,7 @@ nir_visitor::visit(ir_expression *ir)
   dest_size, srcs);
  break;
   default:
- assert(0);
- break;
+ unreachable(not reached);
   }
   break;
case ir_unop_trunc: emit(nir_op_ftrunc, dest_size, srcs); break;
@@ -1207,8 +1199,7 @@ nir_visitor::visit(ir_expression *ir)
  }
  break;
   default:
- assert(0);
- break;
+ unreachable(not reached);
   }
   break;
case ir_binop_add:
@@ -1296,8 +1287,7 @@ nir_visitor::visit(ir_expression *ir)
  break;
 
   default:
- assert(0);
- break;
+ unreachable(not reached);
   }
 
   instr = emit(op, dest_size, srcs);
@@ -1402,8 +1392,7 @@ nir_visitor::visit(ir_expression *ir)
case 3: emit(nir_op_ball_fequal3, dest_size, srcs); break;
case 4: emit(nir_op_ball_fequal4, dest_size, srcs); break;
default:
-  assert(0);
-  break;
+  unreachable(not reached);
 }
  } else {
 switch (ir-operands[0]-type-vector_elements) {
@@ -1412,8 +1401,7 @@ nir_visitor::visit(ir_expression *ir)
case 3: emit(nir_op_ball_iequal3, dest_size, srcs); break;
case 4: emit(nir_op_ball_iequal4, dest_size, srcs); break;
default:
-  assert(0);
-  break;
+  unreachable(not reached);
 }
  }
   } else {
@@ -1423,8 +1411,7 @@ nir_visitor::visit(ir_expression *ir)
 case 3: emit(nir_op_fall_equal3, dest_size, srcs); break;
 case 4: emit(nir_op_fall_equal4, dest_size, srcs); break;
 default:
-   assert(0);
-   break;
+   unreachable(not reached);
  }
   }
   break;
@@ -1437,8 +1424,7 @@ nir_visitor::visit(ir_expression *ir)
case 3: emit(nir_op_bany_fnequal3, dest_size, srcs); break;
case 4: emit(nir_op_bany_fnequal4, dest_size, srcs); break;
default:
-  assert(0);
-  break;
+  unreachable(not reached);
 }
  } else {
 switch (ir-operands[0]-type-vector_elements) {
@@ -1447,8 +1433,7 @@ nir_visitor::visit(ir_expression *ir)
case 3: emit(nir_op_bany_inequal3, dest_size, srcs); break;
case 4: emit(nir_op_bany_inequal4, dest_size, srcs); break;
default:
-  assert(0);
-  break;
+  unreachable(not reached);
 }
  }
   } else {
@@ -1458,8 +1443,7 @@ nir_visitor::visit(ir_expression *ir)
 case 3: emit(nir_op_fany_nequal3, dest_size, srcs); break;
 case 4: emit(nir_op_fany_nequal4, dest_size, srcs); 

Re: [Mesa-dev] [PATCH 5/5] nir: Add nir_lower_alu_scalar.

2015-01-21 Thread Jason Ekstrand
Overall this looks correct.  I've got a few nits below and I'd like to take
a look at it with fresh eyes before giving an R-B as it's complicated
especially with all of the stuff to handle non-ssa.  Not sure if it's
really worth doing non-ssa now that I see how much more complicated it
makes things.
--Jason

On Wed, Jan 21, 2015 at 5:26 PM, Eric Anholt e...@anholt.net wrote:

 This is the equivalent of brw_fs_channel_expressions.cpp, which I wanted
 for vc4.
 ---

 This series, plus a commit to make i965 use it instead of
 channel_expressions,
 is on the nir-scalarize branch of my mesa tree.  With the whole series,
 there
 are 6 regressions, 3 of which are due to lower-vec-to-movs being broken
 when
 faced with r0 = vec4 r0.yxxx, r0., r0.zxxx, r0.wxxx (fs-swap-problem
 test, for example).  The other 3 are sampler-nonconst-2d-array and friends,
 which I haven't figured out yet.

 Full disclosure: I did a cleanup to use nir_alu_ssa_dest_init() more and
 haven't repiglited since then.

 The full i965 conversion has the following shader-db results for me,
 presumably because of losing GLSL-IR-level optimizations due to not
 splitting
 expressions in GLSL IR:

 total instructions in shared programs: 137974 - 139306 (0.97%)
 instructions in affected programs: 55959 - 57291 (2.38%)

 src/glsl/Makefile.sources   |   1 +
  src/glsl/nir/nir.h  |   1 +
  src/glsl/nir/nir_lower_alu_scalar.c | 287
 
  3 files changed, 289 insertions(+)
  create mode 100644 src/glsl/nir/nir_lower_alu_scalar.c

 diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
 index 6237627..9cd1a6a 100644
 --- a/src/glsl/Makefile.sources
 +++ b/src/glsl/Makefile.sources
 @@ -24,6 +24,7 @@ NIR_FILES = \
 $(GLSL_SRCDIR)/nir/nir_intrinsics.c \
 $(GLSL_SRCDIR)/nir/nir_intrinsics.h \
 $(GLSL_SRCDIR)/nir/nir_live_variables.c \
 +   $(GLSL_SRCDIR)/nir/nir_lower_alu_scalar.c \
 $(GLSL_SRCDIR)/nir/nir_lower_atomics.c \
 $(GLSL_SRCDIR)/nir/nir_lower_global_vars_to_local.c \
 $(GLSL_SRCDIR)/nir/nir_lower_locals_to_regs.c \
 diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
 index 7f0aa36..fb42d91 100644
 --- a/src/glsl/nir/nir.h
 +++ b/src/glsl/nir/nir.h
 @@ -1521,6 +1521,7 @@ void nir_lower_vars_to_ssa(nir_shader *shader);
  void nir_remove_dead_variables(nir_shader *shader);

  void nir_lower_vec_to_movs(nir_shader *shader);
 +void nir_lower_ops_scalar(nir_shader *shader);

  void nir_lower_samplers(nir_shader *shader,
  struct gl_shader_program *shader_program,
 diff --git a/src/glsl/nir/nir_lower_alu_scalar.c
 b/src/glsl/nir/nir_lower_alu_scalar.c
 new file mode 100644
 index 000..e13ad1e
 --- /dev/null
 +++ b/src/glsl/nir/nir_lower_alu_scalar.c
 @@ -0,0 +1,287 @@
 +/*
 + * Copyright © 2014-2015 Broadcom
 + *
 + * 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 nir.h
 +
 +/** @file nir_lower_alu_scalar.c
 + *
 + * Replaces nir_alu_instr operations with more than one channel used in
 the
 + * arguments with individual per-channel operations.
 + */
 +
 +static void
 +unsupported(nir_instr *instr)
 +{
 +   fprintf(stderr, Unsupported instruction in scalar lowering: );
 +   nir_print_instr(instr, stderr);
 +   fprintf(stderr, \n);
 +   abort();
 +}
 +
 +static void
 +nir_alu_ssa_dest_init(nir_alu_instr *instr, unsigned num_components)
 +{
 +   nir_ssa_dest_init(instr-instr, instr-dest.dest, num_components,
 NULL);
 +   instr-dest.write_mask = (1  num_components) - 1;
 +}
 +
 +static void
 +reduce_op_replace(nir_alu_instr *instr, nir_ssa_def *def, void *mem_ctx)
 +{
 +   assert(instr-dest.write_mask == 1);
 +
 +   if (instr-dest.dest.is_ssa) {
 +  nir_src new_src;
 +  new_src.is_ssa = true;
 +  new_src.ssa = def;
 +  nir_ssa_def_rewrite_uses(instr-dest.dest.ssa, new_src, mem_ctx);
 +   } 

[Mesa-dev] [Bug 87137] Unable to build when configured with openmp and CFLAGS/LDFLAGS contain -fopenmp

2015-01-21 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=87137

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

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |NOTABUG

-- 
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 v1] Remove UINT_AS_FLT, INT_AS_FLT, FLOAT_AS_FLT macros.No functional changes, only bug fixed.

2015-01-21 Thread Kenneth Graunke
On Thursday, January 22, 2015 12:12:18 AM marius.pre...@intel.com wrote:
 From: Marius Predut marius.pre...@intel.com
 
 On 32-bit, for floating point operations is used x86 FPU registers instead 
 SSE,
 reason for  when reinterprets an integer as a float result is unexpected
 (modify floats when they are written to memory).

 
 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82668
 
 Signed-off-by: Marius Predut marius.pre...@intel.com
 ---
  src/mesa/main/context.c   |3 ++-
  src/mesa/main/macros.h|   32 
  src/mesa/vbo/vbo_attrib_tmp.h |   20 
  src/mesa/vbo/vbo_exec.h   |3 ++-
  src/mesa/vbo/vbo_exec_api.c   |   25 -
  src/mesa/vbo/vbo_exec_eval.c  |   22 +-
  src/mesa/vbo/vbo_save_api.c   |   10 +-
  7 files changed, 70 insertions(+), 45 deletions(-)

Your commit title says No functional changes, only bug fixed.  This is
contradictory - a bug fix is a change in behavior, or a functional change.

No functional changes is a phrase used for patches which alter whitespace,
comments, change style, or move code around while not actually changing the
result of the code.

Removing the macros is also not really the point of the patch - it's fixing
an x86 FPU bug.  I would make the commit title something to that effect.

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 2/2] nir: Stop using designated initializers

2015-01-21 Thread Dave Airlie
On 22 January 2015 at 06:19, Jason Ekstrand ja...@jlekstrand.net wrote:


 On Wed, Jan 21, 2015 at 12:19 PM, Connor Abbott cwabbo...@gmail.com wrote:

 Assuming this actually compiles with GCC 4.4...


 I don't know for sure, but it certainly gets us closer
 --Jason

Much closer,

 CC nir_search.lo
../../src/glsl/nir/nir_search.c: In function ‘construct_value’:
../../src/glsl/nir/nir_search.c:226: error: unknown field ‘ssa’
specified in initializer
../../src/glsl/nir/nir_search.c:226: warning: missing braces around initializer
../../src/glsl/nir/nir_search.c:226: warning: (near initialization for
‘val.src.anonymous’)
../../src/glsl/nir/nir_search.c:226: warning: initialization from
incompatible pointer type
../../src/glsl/nir/nir_search.c:270: error: unknown field ‘ssa’
specified in initializer
../../src/glsl/nir/nir_search.c:270: warning: missing braces around initializer
../../src/glsl/nir/nir_search.c:270: warning: (near initialization for
‘val.src.anonymous’)
../../src/glsl/nir/nir_search.c:270: warning: initialization from
incompatible pointer type
make[3]: *** [nir_search.lo] Error 1

Seems to be the remaining case.

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


[Mesa-dev] [PATCH v1] Remove UINT_AS_FLT, INT_AS_FLT, FLOAT_AS_FLT macros.No functional changes, only bug fixed.

2015-01-21 Thread marius . predut
From: Marius Predut marius.pre...@intel.com

On 32-bit, for floating point operations is used x86 FPU registers instead SSE,
reason for  when reinterprets an integer as a float result is unexpected
(modify floats when they are written to memory).

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82668

Signed-off-by: Marius Predut marius.pre...@intel.com
---
 src/mesa/main/context.c   |3 ++-
 src/mesa/main/macros.h|   32 
 src/mesa/vbo/vbo_attrib_tmp.h |   20 
 src/mesa/vbo/vbo_exec.h   |3 ++-
 src/mesa/vbo/vbo_exec_api.c   |   25 -
 src/mesa/vbo/vbo_exec_eval.c  |   22 +-
 src/mesa/vbo/vbo_save_api.c   |   10 +-
 7 files changed, 70 insertions(+), 45 deletions(-)

diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 400c158..11ab8a9 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -134,6 +134,7 @@
 #include math/m_matrix.h
 #include main/dispatch.h /* for _gloffset_COUNT */
 #include uniforms.h
+#include macros.h
 
 #ifdef USE_SPARC_ASM
 #include sparc/sparc.h
@@ -656,7 +657,7 @@ _mesa_init_constants(struct gl_constants *consts, gl_api 
api)
consts-MaxSamples = 0;
 
/* GLSL default if NativeIntegers == FALSE */
-   consts-UniformBooleanTrue = FLT_AS_UINT(1.0f);
+   consts-UniformBooleanTrue = FLOAT_AS_UNION(1.0f).u;
 
/* GL_ARB_sync */
consts-MaxServerWaitTimeout = 0x1fff7fffULL;
diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
index cd5f2d6..12c9997 100644
--- a/src/mesa/main/macros.h
+++ b/src/mesa/main/macros.h
@@ -32,6 +32,7 @@
 #define MACROS_H
 
 #include imports.h
+#include program/prog_parameter.h
 
 
 /**
@@ -170,27 +171,26 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256];
ub = ((GLubyte) F_TO_I((f) * 255.0F))
 #endif
 
-static inline GLfloat INT_AS_FLT(GLint i)
+static union gl_constant_value UINT_AS_UNION(GLuint u)
 {
-   fi_type tmp;
-   tmp.i = i;
-   return tmp.f;
+   union gl_constant_value tmp;
+   tmp.u = u;
+   return tmp;
 }
 
-static inline GLfloat UINT_AS_FLT(GLuint u)
+static inline union gl_constant_value INT_AS_UNION(GLint i)
 {
-   fi_type tmp;
-   tmp.u = u;
-   return tmp.f;
+   union gl_constant_value tmp;
+   tmp.i = i;
+   return tmp;
 }
 
-static inline unsigned FLT_AS_UINT(float f)
+static inline union gl_constant_value FLOAT_AS_UNION(GLfloat f)
 {
-   fi_type tmp;
+   union gl_constant_value tmp;
tmp.f = f;
-   return tmp.u;
+   return tmp;
 }
-
 /**
  * Convert a floating point value to an unsigned fixed point value.
  *
@@ -628,12 +628,12 @@ COPY_CLEAN_4V_TYPE_AS_FLOAT(GLfloat dst[4], int sz, const 
GLfloat src[4],
   ASSIGN_4V(dst, 0, 0, 0, 1);
   break;
case GL_INT:
-  ASSIGN_4V(dst, INT_AS_FLT(0), INT_AS_FLT(0),
- INT_AS_FLT(0), INT_AS_FLT(1));
+  ASSIGN_4V(dst, INT_AS_UNION(0).f, INT_AS_UNION(0).f,
+INT_AS_UNION(0).f, INT_AS_UNION(1).f);
   break;
case GL_UNSIGNED_INT:
-  ASSIGN_4V(dst, UINT_AS_FLT(0), UINT_AS_FLT(0),
- UINT_AS_FLT(0), UINT_AS_FLT(1));
+  ASSIGN_4V(dst, UINT_AS_UNION(0).f, UINT_AS_UNION(0).f,
+UINT_AS_UNION(0).f, UINT_AS_UNION(1).f);
   break;
default:
   ASSIGN_4V(dst, 0.0f, 0.0f, 0.0f, 1.0f); /* silence warnings */
diff --git a/src/mesa/vbo/vbo_attrib_tmp.h b/src/mesa/vbo/vbo_attrib_tmp.h
index ec66934..17a0a10 100644
--- a/src/mesa/vbo/vbo_attrib_tmp.h
+++ b/src/mesa/vbo/vbo_attrib_tmp.h
@@ -28,6 +28,18 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include util/u_format_r11g11b10f.h
 #include main/varray.h
 
+
+/* ATTR */
+#define ATTR( A, N, T, V0, V1, V2, V3 )  ATTR_##T((A), (N), (T), (V0), 
(V1), (V2), (V3))
+
+#define ATTR_GL_UNSIGNED_INT( A, N, T, V0, V1, V2, V3 ) \
+ATTR_UNION(A, N, T, UINT_AS_UNION(V0), UINT_AS_UNION(V1), 
UINT_AS_UNION(V2), UINT_AS_UNION(V3))
+#define ATTR_GL_INT( A, N, T, V0, V1, V2, V3 ) \
+ATTR_UNION(A, N, T, INT_AS_UNION(V0), INT_AS_UNION(V1), INT_AS_UNION(V2), 
INT_AS_UNION(V3))
+#define ATTR_GL_FLOAT( A, N, T, V0, V1, V2, V3 )   \
+ATTR_UNION(A, N, T, FLOAT_AS_UNION(V0), FLOAT_AS_UNION(V1), 
FLOAT_AS_UNION(V2), FLOAT_AS_UNION(V3))
+
+
 /* float */
 #define ATTR1FV( A, V ) ATTR( A, 1, GL_FLOAT, (V)[0], 0, 0, 1 )
 #define ATTR2FV( A, V ) ATTR( A, 2, GL_FLOAT, (V)[0], (V)[1], 0, 1 )
@@ -41,8 +53,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 /* int */
 #define ATTRI( A, N, X, Y, Z, W) ATTR( A, N, GL_INT, \
-   INT_AS_FLT(X), INT_AS_FLT(Y), \
-   INT_AS_FLT(Z), INT_AS_FLT(W) )
+   X, Y, \
+   Z, W )
 
 #define ATTR2IV( A, V ) ATTRI( A, 2, (V)[0], (V)[1], 0, 1 )
 #define ATTR3IV( A, V ) ATTRI( A, 3, (V)[0], (V)[1], (V)[2], 1 )
@@ -56,8 +68,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 /* uint */
 #define ATTRUI( A, N, X, Y, 

Re: [Mesa-dev] [PATCH 2.1/2] SQUASH nir: Get rid of more designated initializers

2015-01-21 Thread Connor Abbott
Reviewed-by: Connor Abbbott cwabbo...@gmail.com

On Wed, Jan 21, 2015 at 8:25 PM, Jason Ekstrand ja...@jlekstrand.net wrote:
 ---
  src/glsl/nir/nir_search.c | 24 ++--
  1 file changed, 10 insertions(+), 14 deletions(-)

 diff --git a/src/glsl/nir/nir_search.c b/src/glsl/nir/nir_search.c
 index a7bd051..e69fdfd 100644
 --- a/src/glsl/nir/nir_search.c
 +++ b/src/glsl/nir/nir_search.c
 @@ -221,13 +221,11 @@ construct_value(const nir_search_value *value, 
 nir_alu_type type,

nir_instr_insert_before(instr, alu-instr);

 -  nir_alu_src val = {
 - .src.is_ssa = true,
 - .src.ssa = alu-dest.dest.ssa,
 - .negate = false,
 - .abs = false,
 - .swizzle = { 0, 1, 2, 3 }
 -  };
 +  nir_alu_src val;
 +  val.src = nir_src_for_ssa(alu-dest.dest.ssa);
 +  val.negate = false;
 +  val.abs = false,
 +  memcpy(val.swizzle, identity_swizzle, sizeof val.swizzle);

return val;
 }
 @@ -265,13 +263,11 @@ construct_value(const nir_search_value *value, 
 nir_alu_type type,

nir_instr_insert_before(instr, load-instr);

 -  nir_alu_src val = {
 - .src.is_ssa = true,
 - .src.ssa = load-def,
 - .negate = false,
 - .abs = false,
 - .swizzle = { 0, 0, 0, 0 } /* Splatted scalar */
 -  };
 +  nir_alu_src val;
 +  val.src = nir_src_for_ssa(load-def);
 +  val.negate = false;
 +  val.abs = false,
 +  memset(val.swizzle, 0, sizeof val.swizzle);

return val;
 }
 --
 2.2.1

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


[Mesa-dev] [PATCH 2/2] st/clover: Use std::string for target IR string parameter

2015-01-21 Thread Michel Dänzer
From: Michel Dänzer michel.daen...@amd.com

That's what device::ir_target() returns. Fixes reading beyond allocated
memory:

==1936== Invalid read of size 1
==1936==at 0x4C2C1B4: strlen (vg_replace_strmem.c:412)
==1936==by 0x9E00C30: std::basic_stringchar, std::char_traitschar, 
std::allocatorchar ::basic_string(char const*, std::allocatorchar const) 
(in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.20)
==1936==by 0x5B44FAE: clover::compile_program_llvm(clover::compat::string 
const, clover::compat::vectorclover::compat::pairclover::compat::string, 
clover::compat::string  const, pipe_shader_ir, clover::compat::string 
const, clover::compat::string const, clover::compat::string) 
(invocation.cpp:698)
==1936==by 0x5B39A20: 
clover::program::build(clover::ref_vectorclover::device const, char const*, 
clover::compat::vectorclover::compat::pairclover::compat::string, 
clover::compat::string  const) (program.cpp:63)
==1936==by 0x5B20152: clBuildProgram (program.cpp:182)
==1936==by 0x400F41: main (hello_world.c:109)
==1936==  Address 0x56fee1f is 0 bytes after a block of size 15 alloc'd
==1936==at 0x4C28C20: malloc (vg_replace_malloc.c:296)
==1936==by 0x5B398F0: alloc (compat.hpp:59)
==1936==by 0x5B398F0: vectorstd::basic_stringchar  (compat.hpp:98)
==1936==by 0x5B398F0: stringstd::basic_stringchar  (compat.hpp:327)
==1936==by 0x5B398F0: 
clover::program::build(clover::ref_vectorclover::device const, char const*, 
clover::compat::vectorclover::compat::pairclover::compat::string, 
clover::compat::string  const) (program.cpp:63)
==1936==by 0x5B20152: clBuildProgram (program.cpp:182)
==1936==by 0x400F41: main (hello_world.c:109)

Signed-off-by: Michel Dänzer michel.daen...@amd.com
---
 src/gallium/state_trackers/clover/core/compiler.hpp   | 2 +-
 src/gallium/state_trackers/clover/llvm/invocation.cpp | 8 
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/gallium/state_trackers/clover/core/compiler.hpp 
b/src/gallium/state_trackers/clover/core/compiler.hpp
index 7210d1e..21ef1e9 100644
--- a/src/gallium/state_trackers/clover/core/compiler.hpp
+++ b/src/gallium/state_trackers/clover/core/compiler.hpp
@@ -35,7 +35,7 @@ namespace clover {
module compile_program_llvm(const compat::string source,
const header_map headers,
pipe_shader_ir ir,
-   const compat::string target,
+   const std::string target,
const compat::string opts,
compat::string r_log);
 
diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index 6cc07b2..5050345 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -686,7 +686,7 @@ module
 clover::compile_program_llvm(const compat::string source,
  const header_map headers,
  enum pipe_shader_ir ir,
- const compat::string target,
+ const std::string target,
  const compat::string opts,
  compat::string r_log) {
 
@@ -695,9 +695,9 @@ clover::compile_program_llvm(const compat::string source,
  debug_options, 0);
 
std::vectorllvm::Function * kernels;
-   size_t processor_str_len = std::string(target.begin()).find_first_of(-);
-   std::string processor(target.begin(), 0, processor_str_len);
-   std::string triple(target.begin(), processor_str_len + 1,
+   size_t processor_str_len = target.find_first_of(-);
+   std::string processor(target.data(), 0, processor_str_len);
+   std::string triple(target.data(), processor_str_len + 1,
   target.size() - processor_str_len - 1);
clang::LangAS::Map address_spaces;
llvm::LLVMContext llvm_ctx;
-- 
2.1.4

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


[Mesa-dev] [PATCH 1/2] r600g, radeonsi: Fix calculation of IR target cap string buffer size

2015-01-21 Thread Michel Dänzer
From: Michel Dänzer michel.daen...@amd.com

Fixes writing beyond the allocated buffer:

==31855== Invalid write of size 1
==31855==at 0x50AB2A9: vsprintf (iovsprintf.c:43)
==31855==by 0x508F6F6: sprintf (sprintf.c:32)
==31855==by 0xB59C7EC: r600_get_compute_param (r600_pipe_common.c:526)
==31855==by 0x5B2B7DE: get_compute_paramchar (device.cpp:37)
==31855==by 0x5B2B7DE: clover::device::ir_target() const (device.cpp:201)
==31855==by 0x5B398E0: 
clover::program::build(clover::ref_vectorclover::device const, char const*, 
clover::compat::vectorclover::compat::pairclover::compat::string, 
clover::compat::string  const) (program.cpp:63)
==31855==by 0x5B20152: clBuildProgram (program.cpp:182)
==31855==by 0x400F41: main (hello_world.c:109)
==31855==  Address 0x56fed5f is 0 bytes after a block of size 15 alloc'd
==31855==at 0x4C29180: operator new(unsigned long) (vg_replace_malloc.c:324)
==31855==by 0x5B2B7C2: allocate (new_allocator.h:104)
==31855==by 0x5B2B7C2: allocate (alloc_traits.h:357)
==31855==by 0x5B2B7C2: _M_allocate (stl_vector.h:170)
==31855==by 0x5B2B7C2: _M_create_storage (stl_vector.h:185)
==31855==by 0x5B2B7C2: _Vector_base (stl_vector.h:136)
==31855==by 0x5B2B7C2: vector (stl_vector.h:278)
==31855==by 0x5B2B7C2: get_compute_paramchar (device.cpp:35)
==31855==by 0x5B2B7C2: clover::device::ir_target() const (device.cpp:201)
==31855==by 0x5B398E0: 
clover::program::build(clover::ref_vectorclover::device const, char const*, 
clover::compat::vectorclover::compat::pairclover::compat::string, 
clover::compat::string  const) (program.cpp:63)
==31855==by 0x5B20152: clBuildProgram (program.cpp:182)
==31855==by 0x400F41: main (hello_world.c:109)

Signed-off-by: Michel Dänzer michel.daen...@amd.com
---
 src/gallium/drivers/radeon/r600_pipe_common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c 
b/src/gallium/drivers/radeon/r600_pipe_common.c
index f91772e..ddb4142 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.c
+++ b/src/gallium/drivers/radeon/r600_pipe_common.c
@@ -524,9 +524,9 @@ static int r600_get_compute_param(struct pipe_screen 
*screen,
}
if (ret) {
sprintf(ret, %s-%s, gpu, triple);
-
}
-   return (strlen(triple) + strlen(gpu)) * sizeof(char);
+   /* +2 for dash and terminating NIL byte */
+   return (strlen(triple) + strlen(gpu) + 2) * sizeof(char);
}
case PIPE_COMPUTE_CAP_GRID_DIMENSION:
if (ret) {
-- 
2.1.4

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


Re: [Mesa-dev] [PATCH 1/5] nir: Expose nir_print_instr() for debug prints

2015-01-21 Thread Jason Ekstrand
On Wed, Jan 21, 2015 at 5:25 PM, Eric Anholt e...@anholt.net wrote:

 It's nice to have this present in your default cases so you can see what
 instruction is triggering an abort.
 ---
  src/glsl/nir/nir.h   |  1 +
  src/glsl/nir/nir_print.c | 14 --
  2 files changed, 13 insertions(+), 2 deletions(-)

 diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
 index 7b5794d..761f20a 100644
 --- a/src/glsl/nir/nir.h
 +++ b/src/glsl/nir/nir.h
 @@ -1480,6 +1480,7 @@ void nir_index_ssa_defs(nir_function_impl *impl);
  void nir_index_blocks(nir_function_impl *impl);

  void nir_print_shader(nir_shader *shader, FILE *fp);
 +void nir_print_instr(nir_instr *instr, FILE *fp);

  #ifdef DEBUG
  void nir_validate_shader(nir_shader *shader);
 diff --git a/src/glsl/nir/nir_print.c b/src/glsl/nir/nir_print.c
 index 1a50ae9..924989a 100644
 --- a/src/glsl/nir/nir_print.c
 +++ b/src/glsl/nir/nir_print.c
 @@ -611,8 +611,6 @@ print_instr(nir_instr *instr, print_var_state *state,
 unsigned tabs, FILE *fp)
unreachable(Invalid instruction type);
break;
 }
 -
 -   fprintf(fp, \n);
  }

  static int
 @@ -658,6 +656,7 @@ print_block(nir_block *block, print_var_state *state,
 unsigned tabs, FILE *fp)

 nir_foreach_instr(block, instr) {
print_instr(instr, state, tabs, fp);
 +  fprintf(fp, \n);
 }

 print_tabs(tabs, fp);
 @@ -871,3 +870,14 @@ nir_print_shader(nir_shader *shader, FILE *fp)

 destroy_print_state(state);
  }
 +
 +void
 +nir_print_instr(nir_instr *instr, FILE *fp)
 +{
 +   print_var_state state;
 +   init_print_state(state);
 +
 +   print_instr(instr, state, 0, fp);


This won't work with intrinsics because, while we've created the table of
variable names, we haven't filled it out by printing the variables.  Maybe
the thing to do would be to make print_var use the variable's nominal name
if the print state is NULL and then just call print_instr(instr, NULL, 0,
fp) here.

Otherwise, I really want this.
--Jason


 +
 +   destroy_print_state(state);
 +}
 --
 2.1.3

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

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


[Mesa-dev] [PATCH 2/7] nir: Add a pass to lower vector phi nodes to scalar phi nodes

2015-01-21 Thread Jason Ekstrand
---
 src/glsl/Makefile.sources   |   1 +
 src/glsl/nir/nir.h  |   2 +
 src/glsl/nir/nir_lower_phis_to_scalar.c | 238 
 3 files changed, 241 insertions(+)
 create mode 100644 src/glsl/nir/nir_lower_phis_to_scalar.c

diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
index 7c9f63b..b3facb1 100644
--- a/src/glsl/Makefile.sources
+++ b/src/glsl/Makefile.sources
@@ -29,6 +29,7 @@ NIR_FILES = \
$(GLSL_SRCDIR)/nir/nir_lower_global_vars_to_local.c \
$(GLSL_SRCDIR)/nir/nir_lower_locals_to_regs.c \
$(GLSL_SRCDIR)/nir/nir_lower_io.c \
+   $(GLSL_SRCDIR)/nir/nir_lower_phis_to_scalar.c \
$(GLSL_SRCDIR)/nir/nir_lower_samplers.cpp \
$(GLSL_SRCDIR)/nir/nir_lower_system_values.c \
$(GLSL_SRCDIR)/nir/nir_lower_to_source_mods.c \
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index 5b1188b..a7e6146 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -1518,6 +1518,8 @@ void nir_remove_dead_variables(nir_shader *shader);
 
 void nir_lower_vec_to_movs(nir_shader *shader);
 
+void nir_lower_phis_to_scalar(nir_shader *shader);
+
 void nir_lower_samplers(nir_shader *shader,
 struct gl_shader_program *shader_program,
 struct gl_program *prog);
diff --git a/src/glsl/nir/nir_lower_phis_to_scalar.c 
b/src/glsl/nir/nir_lower_phis_to_scalar.c
new file mode 100644
index 000..9f901d6
--- /dev/null
+++ b/src/glsl/nir/nir_lower_phis_to_scalar.c
@@ -0,0 +1,238 @@
+/*
+ * Copyright © 2014 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.
+ *
+ * Authors:
+ *Jason Ekstrand (ja...@jlekstrand.net)
+ *
+ */
+
+#include nir.h
+
+/*
+ * Implements common subexpression elimination
+ */
+
+struct lower_phis_to_scalar_state {
+   void *mem_ctx;
+   void *dead_ctx;
+
+   /* Hash table marking which phi nodes are scalarizable.  The key is
+* pointers to phi instructions and the entry is either NULL for not
+* scalarizable or non-null for scalarizable.
+*/
+   struct hash_table *phi_table;
+};
+
+/* Determines if the given phi node should be lowered.  The only phi nodes
+ * we will scalarize at the moment are those where all of the sources are
+ * scalarizable.
+ */
+static bool
+should_lower_phi(nir_phi_instr *phi, struct lower_phis_to_scalar_state *state)
+{
+   /* Already scalar */
+   if (phi-dest.ssa.num_components == 1)
+  return false;
+
+   struct hash_entry *entry = _mesa_hash_table_search(state-phi_table, phi);
+   if (entry)
+  return entry-data != NULL;
+
+   nir_foreach_phi_src(phi, src) {
+  /* Don't know what to do with non-ssa sources */
+  if (!src-src.is_ssa)
+ return false;
+
+  nir_instr *src_instr = src-src.ssa-parent_instr;
+  switch (src_instr-type) {
+  case nir_instr_type_alu: {
+ nir_alu_instr *src_alu = nir_instr_as_alu(src_instr);
+
+ /* ALU operations with output_size == 0 should be scalarized.  We
+  * will also see a bunch of vecN operations from scalarizing ALU
+  * operations and, since they can easily be copy-propagated, they
+  * 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;
+  }
+
+  case nir_instr_type_phi: {
+ nir_phi_instr *src_phi = nir_instr_as_phi(src_instr);
+
+ /* Insert an entry and mark it as scalarizable for now. That way
+  * we don't recurse forever and a cycle in the depencence graph
+  * won't automatically make us fail to scalarize.
+  */
+ entry = _mesa_hash_table_insert(state-phi_table, src_phi, (void *)1);
+ bool scalarizable = should_lower_phi(src_phi, state);
+ entry-data = (void *)scalarizable;

[Mesa-dev] [PATCH 6/7] i965/fs: Use NIR's scalarizing abilities and stop handling vectors

2015-01-21 Thread Jason Ekstrand
Now that we can scalarize with NIR, there's no need for all this code
anymore.  Let's get rid of it and just do scalar operations.
---
 src/mesa/drivers/dri/i965/brw_fs.h   |  15 -
 src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 489 ++-
 2 files changed, 158 insertions(+), 346 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.h 
b/src/mesa/drivers/dri/i965/brw_fs.h
index 1de10bb..914a575 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -590,21 +590,6 @@ public:
fs_reg get_nir_alu_src(nir_alu_instr *instr, unsigned src);
fs_reg get_nir_dest(nir_dest dest);
void emit_percomp(fs_inst *inst, unsigned wr_mask);
-   void emit_percomp(enum opcode op, fs_reg dest, fs_reg src0,
- unsigned wr_mask, bool saturate = false,
- enum brw_predicate predicate = BRW_PREDICATE_NONE,
- enum brw_conditional_mod mod = BRW_CONDITIONAL_NONE);
-   void emit_percomp(enum opcode op, fs_reg dest, fs_reg src0, fs_reg src1,
- unsigned wr_mask, bool saturate = false,
- enum brw_predicate predicate = BRW_PREDICATE_NONE,
- enum brw_conditional_mod mod = BRW_CONDITIONAL_NONE);
-   void emit_math_percomp(enum opcode op, fs_reg dest, fs_reg src0,
-  unsigned wr_mask, bool saturate = false);
-   void emit_math_percomp(enum opcode op, fs_reg dest, fs_reg src0,
-  fs_reg src1, unsigned wr_mask,
-  bool saturate = false);
-   void emit_reduction(enum opcode op, fs_reg dest, fs_reg src,
-   unsigned num_components);
 
int setup_color_payload(fs_reg *dst, fs_reg color, unsigned components);
void emit_alpha_test();
diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
index 510092e..b88cb8b 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
@@ -40,11 +40,18 @@ fs_visitor::emit_nir_code()
nir_split_var_copies(nir);
nir_validate_shader(nir);
 
+   nir_lower_alu_to_scalar(nir);
+   nir_validate_shader(nir);
+   nir_lower_alu_reductions(nir);
+   nir_validate_shader(nir);
+
bool progress;
do {
   progress = false;
   nir_lower_vars_to_ssa(nir);
   nir_validate_shader(nir);
+  nir_lower_phis_to_scalar(nir);
+  nir_validate_shader(nir);
   progress |= nir_copy_prop(nir);
   nir_validate_shader(nir);
   progress |= nir_opt_dce(nir);
@@ -491,20 +498,30 @@ fs_visitor::nir_emit_alu(nir_alu_instr *instr)
for (unsigned i = 0; i  nir_op_infos[instr-op].num_inputs; i++)
   op[i] = get_nir_alu_src(instr, i);
 
+   if (nir_op_infos[instr-op].output_size == 0) {
+  /* We've already scalarized, so we know that we only have one
+   * channel.  The only question is which channel.
+   */
+  assert(_mesa_bitcount(instr-dest.write_mask) == 1);
+  unsigned off = ffs(instr-dest.write_mask) - 1;
+  result = offset(result, off);
+
+  for (unsigned i = 0; i  nir_op_infos[instr-op].num_inputs; i++)
+ op[i] = offset(op[i], off);
+   }
+
switch (instr-op) {
case nir_op_fmov:
case nir_op_i2f:
-   case nir_op_u2f: {
-  fs_inst *inst = MOV(result, op[0]);
-  inst-saturate = instr-dest.saturate;
-  emit_percomp(inst, instr-dest.write_mask);
-   }
+   case nir_op_u2f:
+  emit(MOV(result, op[0]))
+  -saturate = instr-dest.saturate;
   break;
 
case nir_op_imov:
case nir_op_f2i:
case nir_op_f2u:
-  emit_percomp(MOV(result, op[0]), instr-dest.write_mask);
+  emit(MOV(result, op[0]));
   break;
 
case nir_op_fsign: {
@@ -513,55 +530,46 @@ fs_visitor::nir_emit_alu(nir_alu_instr *instr)
  * Predicated OR ORs 1.0 (0x3f80) with the sign bit if val is not
  * zero.
  */
-  emit_percomp(CMP(reg_null_f, op[0], fs_reg(0.0f), BRW_CONDITIONAL_NZ),
-   instr-dest.write_mask);
+  emit(CMP(reg_null_f, op[0], fs_reg(0.0f), BRW_CONDITIONAL_NZ));
 
   fs_reg result_int = retype(result, BRW_REGISTER_TYPE_UD);
   op[0].type = BRW_REGISTER_TYPE_UD;
   result.type = BRW_REGISTER_TYPE_UD;
-  emit_percomp(AND(result_int, op[0], fs_reg(0x8000u)),
-   instr-dest.write_mask);
+  emit(AND(result_int, op[0], fs_reg(0x8000u)));
 
-  fs_inst *inst = OR(result_int, result_int, fs_reg(0x3f80u));
-  inst-predicate = BRW_PREDICATE_NORMAL;
-  emit_percomp(inst, instr-dest.write_mask);
+  emit(OR(result_int, result_int, fs_reg(0x3f80u)))
+  -predicate = BRW_PREDICATE_NORMAL;
   if (instr-dest.saturate) {
- fs_inst *inst = MOV(result, result);
- inst-saturate = true;
- emit_percomp(inst, instr-dest.write_mask);
+ emit(MOV(result, result))
+ -saturate = true;
   }
   break;
}
 
-   

[Mesa-dev] [PATCH 15/21] main: Add entry point for UnmapNamedBuffer.

2015-01-21 Thread Laura Ekstrand
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  5 ++
 src/mesa/main/bufferobj.c  | 87 ++
 src/mesa/main/bufferobj.h  |  7 +++
 src/mesa/main/tests/dispatch_sanity.cpp|  1 +
 4 files changed, 47 insertions(+), 53 deletions(-)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 7727f0d..f2b17c8 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -75,6 +75,11 @@
   param name=access type=GLbitfield /
/function
 
+   function name=UnmapNamedBuffer offset=assign
+  return type=GLboolean /
+  param name=buffer type=GLuint /
+   /function
+
   !-- Texture object functions --
 
function name=CreateTextures offset=assign
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 16c0faa..087d31e 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -49,10 +49,6 @@
 #include dispatch.h
 
 
-/* Debug flags */
-/*#define VBO_DEBUG*/
-/*#define BOUNDS_CHECK*/
-
 
 /**
  * Used as a placeholder for buffer objects between glGenBuffers() and
@@ -736,15 +732,15 @@ _mesa_buffer_flush_mapped_range( struct gl_context *ctx,
 
 
 /**
- * Default callback for \c dd_function_table::MapBuffer().
+ * Default callback for \c dd_function_table::UnmapBuffer().
  *
  * The input parameters will have been already tested for errors.
  *
  * \sa glUnmapBufferARB, dd_function_table::UnmapBuffer
  */
 static GLboolean
-_mesa_buffer_unmap(struct gl_context *ctx, struct gl_buffer_object *bufObj,
-   gl_map_buffer_index index)
+_mesa_UnmapBuffer_sw(struct gl_context *ctx, struct gl_buffer_object *bufObj,
+ gl_map_buffer_index index)
 {
(void) ctx;
/* XXX we might assert here that bufObj-Pointer is non-null */
@@ -1110,7 +1106,7 @@ _mesa_init_buffer_object_functions(struct 
dd_function_table *driver)
driver-BufferData = _mesa_BufferData_sw;
driver-BufferSubData = _mesa_BufferSubData_sw;
driver-GetBufferSubData = _mesa_buffer_get_subdata;
-   driver-UnmapBuffer = _mesa_buffer_unmap;
+   driver-UnmapBuffer = _mesa_UnmapBuffer_sw;
 
/* GL_ARB_clear_buffer_object */
driver-ClearBufferSubData = _mesa_ClearBufferSubData_sw;
@@ -1794,59 +1790,19 @@ _mesa_ClearNamedBufferSubData(GLuint buffer, GLenum 
internalformat,
 }
 
 
-GLboolean GLAPIENTRY
-_mesa_UnmapBuffer(GLenum target)
+GLboolean
+_mesa_unmap_buffer(struct gl_context *ctx, struct gl_buffer_object *bufObj,
+   const char *func)
 {
-   GET_CURRENT_CONTEXT(ctx);
-   struct gl_buffer_object *bufObj;
GLboolean status = GL_TRUE;
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
 
-   bufObj = get_buffer(ctx, glUnmapBufferARB, target, GL_INVALID_OPERATION);
-   if (!bufObj)
-  return GL_FALSE;
-
if (!_mesa_bufferobj_mapped(bufObj, MAP_USER)) {
-  _mesa_error(ctx, GL_INVALID_OPERATION, glUnmapBufferARB);
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  %s(buffer is already unmapped), func);
   return GL_FALSE;
}
 
-#ifdef BOUNDS_CHECK
-   if (bufObj-Access != GL_READ_ONLY_ARB) {
-  GLubyte *buf = (GLubyte *) bufObj-Pointer;
-  GLuint i;
-  /* check that last 100 bytes are still = magic value */
-  for (i = 0; i  100; i++) {
- GLuint pos = bufObj-Size - i - 1;
- if (buf[pos] != 123) {
-_mesa_warning(ctx, Out of bounds buffer object write detected
-   at position %d (value = %u)\n,
-  pos, buf[pos]);
- }
-  }
-   }
-#endif
-
-#ifdef VBO_DEBUG
-   if (bufObj-AccessFlags  GL_MAP_WRITE_BIT) {
-  GLuint i, unchanged = 0;
-  GLubyte *b = (GLubyte *) bufObj-Pointer;
-  GLint pos = -1;
-  /* check which bytes changed */
-  for (i = 0; i  bufObj-Size - 1; i++) {
- if (b[i] == (i  0xff)  b[i+1] == ((i+1)  0xff)) {
-unchanged++;
-if (pos == -1)
-   pos = i;
- }
-  }
-  if (unchanged) {
- printf(glUnmapBufferARB(%u): %u of %ld unchanged, starting at %d\n,
-  bufObj-Name, unchanged, bufObj-Size, pos);
-  }
-   }
-#endif
-
status = ctx-Driver.UnmapBuffer(ctx, bufObj, MAP_USER);
bufObj-Mappings[MAP_USER].AccessFlags = 0;
ASSERT(bufObj-Mappings[MAP_USER].Pointer == NULL);
@@ -1856,6 +1812,31 @@ _mesa_UnmapBuffer(GLenum target)
return status;
 }
 
+GLboolean GLAPIENTRY
+_mesa_UnmapBuffer(GLenum target)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_buffer_object *bufObj;
+
+   bufObj = get_buffer(ctx, glUnmapBuffer, target, GL_INVALID_OPERATION);
+   if (!bufObj)
+  return GL_FALSE;
+
+   return _mesa_unmap_buffer(ctx, bufObj, glUnmapBuffer);
+}
+
+GLboolean GLAPIENTRY
+_mesa_UnmapNamedBuffer(GLuint buffer)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_buffer_object *bufObj;
+
+   bufObj = 

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

2015-01-21 Thread Laura Ekstrand
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  18 +++
 src/mesa/main/bufferobj.c  | 156 ++---
 src/mesa/main/bufferobj.h  |  34 --
 src/mesa/main/tests/dispatch_sanity.cpp|   2 +
 src/mesa/state_tracker/st_cb_bufferobjects.c   |   4 +-
 5 files changed, 135 insertions(+), 79 deletions(-)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 8c80dfb..4b29e00 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 31ae006..1ec1681 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -660,11 +660,11 @@ _mesa_buffer_get_subdata( struct gl_context *ctx, 
GLintptrARB offset,
  * dd_function_table::ClearBufferSubData.
  */
 void
-_mesa_buffer_clear_subdata(struct gl_context *ctx,
-   GLintptr offset, GLsizeiptr size,
-   const GLvoid *clearValue,
-   GLsizeiptr clearValueSize,
-   struct gl_buffer_object *bufObj)
+_mesa_ClearBufferSubData_sw(struct gl_context *ctx,
+GLintptr offset, GLsizeiptr size,
+const GLvoid *clearValue,
+GLsizeiptr clearValueSize,
+struct gl_buffer_object *bufObj)
 {
GLsizeiptr i;
GLubyte *dest;
@@ -1113,7 +1113,7 @@ _mesa_init_buffer_object_functions(struct 
dd_function_table *driver)
driver-UnmapBuffer = _mesa_buffer_unmap;
 
/* GL_ARB_clear_buffer_object */
-   driver-ClearBufferSubData = _mesa_buffer_clear_subdata;
+   driver-ClearBufferSubData = _mesa_ClearBufferSubData_sw;
 
/* GL_ARB_map_buffer_range */
driver-MapBufferRange = _mesa_buffer_map_range;
@@ -1666,57 +1666,93 @@ _mesa_GetBufferSubData(GLenum target, GLintptr offset,
ctx-Driver.GetBufferSubData( ctx, offset, size, data, bufObj );
 }
 
-
-void GLAPIENTRY
-_mesa_ClearBufferData(GLenum target, GLenum internalformat, GLenum format,
-  GLenum type, const GLvoid* data)
+/**
+ * \param subdata   true if caller is *SubData, false if *Data
+ */
+void
+_mesa_clear_buffer_sub_data(struct gl_context *ctx,
+struct gl_buffer_object *bufObj,
+GLenum internalformat,
+GLintptr offset, GLsizeiptr size,
+GLenum format, GLenum type,
+const GLvoid *data,
+const char *func, bool subdata)
 {
-   GET_CURRENT_CONTEXT(ctx);
-   struct gl_buffer_object* bufObj;
mesa_format mesaFormat;
GLubyte clearValue[MAX_PIXEL_BYTES];
GLsizeiptr clearValueSize;
 
-   bufObj = get_buffer(ctx, glClearBufferData, target, GL_INVALID_VALUE);
-   if (!bufObj) {
-  return;
-   }
-
-   if (_mesa_check_disallowed_mapping(bufObj)) {
-  _mesa_error(ctx, GL_INVALID_OPERATION,
-  glClearBufferData(buffer currently mapped));
+   /* This checks for disallowed mappings. */
+   if (!buffer_object_subdata_range_good(ctx, bufObj, offset, size,
+ subdata, func)) {
   return;
}
 
mesaFormat = validate_clear_buffer_format(ctx, internalformat,
- format, type,
- glClearBufferData);
+ format, type, func);
+
if (mesaFormat == MESA_FORMAT_NONE) {
   return;
}
 
clearValueSize = _mesa_get_format_bytes(mesaFormat);
-   if (bufObj-Size % clearValueSize != 0) {
+   if (offset % clearValueSize != 0 || size % clearValueSize != 0) {
   _mesa_error(ctx, GL_INVALID_VALUE,
-  glClearBufferData(size is not a multiple of 
-  internalformat size));
+  %s(offset or size is not a multiple of 
+  internalformat size), func);
   return;
}
 
if (data == NULL) {
   /* clear to zeros, per the spec */
-  

[Mesa-dev] [PATCH 17/21] main: Add entry point for FlushMappedNamedBufferRange.

2015-01-21 Thread Laura Ekstrand
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  6 ++
 src/mesa/main/bufferobj.c  | 76 +-
 src/mesa/main/bufferobj.h  | 10 
 src/mesa/main/tests/dispatch_sanity.cpp|  1 +
 4 files changed, 67 insertions(+), 26 deletions(-)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index f2b17c8..1e6b9c4 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 087d31e..e446f39 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -718,10 +718,10 @@ _mesa_MapBufferRange_sw(struct gl_context *ctx, GLintptr 
offset,
  * Called via glFlushMappedBufferRange().
  */
 static void
-_mesa_buffer_flush_mapped_range( struct gl_context *ctx,
- GLintptr offset, GLsizeiptr length,
- struct gl_buffer_object *obj,
- gl_map_buffer_index index)
+_mesa_FlushMappedBufferRange_sw(struct gl_context *ctx,
+GLintptr offset, GLsizeiptr length,
+struct gl_buffer_object *obj,
+gl_map_buffer_index index)
 {
(void) ctx;
(void) offset;
@@ -1113,7 +1113,7 @@ _mesa_init_buffer_object_functions(struct 
dd_function_table *driver)
 
/* GL_ARB_map_buffer_range */
driver-MapBufferRange = _mesa_MapBufferRange_sw;
-   driver-FlushMappedBufferRange = _mesa_buffer_flush_mapped_range;
+   driver-FlushMappedBufferRange = _mesa_FlushMappedBufferRange_sw;
 
/* GL_ARB_copy_buffer */
driver-CopyBufferSubData = _mesa_CopyBufferSubData_sw;
@@ -2359,57 +2359,49 @@ _mesa_MapNamedBuffer(GLuint buffer, GLenum access)
 }
 
 
-/**
- * See GL_ARB_map_buffer_range spec
- */
-void GLAPIENTRY
-_mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
+void
+_mesa_flush_mapped_buffer_range(struct gl_context *ctx,
+struct gl_buffer_object *bufObj,
+GLintptr offset, GLsizeiptr length,
+const char *func)
 {
-   GET_CURRENT_CONTEXT(ctx);
-   struct gl_buffer_object *bufObj;
-
if (!ctx-Extensions.ARB_map_buffer_range) {
   _mesa_error(ctx, GL_INVALID_OPERATION,
-  glFlushMappedBufferRange(extension not supported));
+  %s(ARB_map_buffer_range not supported), func);
   return;
}
 
if (offset  0) {
   _mesa_error(ctx, GL_INVALID_VALUE,
-  glFlushMappedBufferRange(offset = %ld), (long)offset);
+  %s(offset %ld  0), func, (long) offset);
   return;
}
 
if (length  0) {
   _mesa_error(ctx, GL_INVALID_VALUE,
-  glFlushMappedBufferRange(length = %ld), (long)length);
+  %s(length %ld  0), func, (long) length);
   return;
}
 
-   bufObj = get_buffer(ctx, glFlushMappedBufferRange, target,
-   GL_INVALID_OPERATION);
-   if (!bufObj)
-  return;
-
if (!_mesa_bufferobj_mapped(bufObj, MAP_USER)) {
   /* buffer is not mapped */
   _mesa_error(ctx, GL_INVALID_OPERATION,
-  glFlushMappedBufferRange(buffer is not mapped));
+  %s(buffer is not mapped), func);
   return;
}
 
if ((bufObj-Mappings[MAP_USER].AccessFlags 
 GL_MAP_FLUSH_EXPLICIT_BIT) == 0) {
   _mesa_error(ctx, GL_INVALID_OPERATION,
-  glFlushMappedBufferRange(GL_MAP_FLUSH_EXPLICIT_BIT not 
set));
+  %s(GL_MAP_FLUSH_EXPLICIT_BIT not set), func);
   return;
}
 
if (offset + length  bufObj-Mappings[MAP_USER].Length) {
   _mesa_error(ctx, GL_INVALID_VALUE,
- glFlushMappedBufferRange(offset %ld + length %ld  mapped 
length %ld),
- (long)offset, (long)length,
-  (long)bufObj-Mappings[MAP_USER].Length);
+  %s(offset %ld + length %ld  mapped length %ld), func,
+  (long) offset, (long) length,
+  (long) bufObj-Mappings[MAP_USER].Length);
   return;
}
 
@@ -2420,6 +2412,38 @@ _mesa_FlushMappedBufferRange(GLenum target, GLintptr 
offset, GLsizeiptr length)
  MAP_USER);
 }
 
+void GLAPIENTRY
+_mesa_FlushMappedBufferRange(GLenum target, GLintptr offset,
+ GLsizeiptr length)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_buffer_object 

[Mesa-dev] [PATCH 09/21] GL: Correct function arguments for glCopyNamedBufferSubData.

2015-01-21 Thread Laura Ekstrand
---
 include/GL/glext.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/GL/glext.h b/include/GL/glext.h
index 3f141a2..925df18 100644
--- a/include/GL/glext.h
+++ b/include/GL/glext.h
@@ -2738,7 +2738,7 @@ GLAPI void APIENTRY glCreateBuffers (GLsizei n, GLuint 
*buffers);
 GLAPI void APIENTRY glNamedBufferStorage (GLuint buffer, GLsizeiptr size, 
const void *data, GLbitfield flags);
 GLAPI void APIENTRY glNamedBufferData (GLuint buffer, GLsizeiptr size, const 
void *data, GLenum usage);
 GLAPI void APIENTRY glNamedBufferSubData (GLuint buffer, GLintptr offset, 
GLsizeiptr size, const void *data);
-GLAPI void APIENTRY glCopyNamedBufferSubData (GLuint readBuffer, GLuint 
writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizei size);
+GLAPI void APIENTRY glCopyNamedBufferSubData (GLuint readBuffer, GLuint 
writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
 GLAPI void APIENTRY glClearNamedBufferData (GLuint buffer, GLenum 
internalformat, GLenum format, GLenum type, const void *data);
 GLAPI void APIENTRY glClearNamedBufferSubData (GLuint buffer, GLenum 
internalformat, GLintptr offset, GLsizei size, GLenum format, GLenum type, 
const void *data);
 GLAPI void *APIENTRY glMapNamedBuffer (GLuint buffer, GLenum access);
-- 
2.1.0

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


[Mesa-dev] [PATCH 16/21] GL: Correct function arguments for FlushMappedNamedBufferRange.

2015-01-21 Thread Laura Ekstrand
---
 include/GL/glext.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/GL/glext.h b/include/GL/glext.h
index bca1b6e..cf0ea3f 100644
--- a/include/GL/glext.h
+++ b/include/GL/glext.h
@@ -2744,7 +2744,7 @@ GLAPI void APIENTRY glClearNamedBufferSubData (GLuint 
buffer, GLenum internalfor
 GLAPI void *APIENTRY glMapNamedBuffer (GLuint buffer, GLenum access);
 GLAPI void *APIENTRY glMapNamedBufferRange (GLuint buffer, GLintptr offset, 
GLsizeiptr length, GLbitfield access);
 GLAPI GLboolean APIENTRY glUnmapNamedBuffer (GLuint buffer);
-GLAPI void APIENTRY glFlushMappedNamedBufferRange (GLuint buffer, GLintptr 
offset, GLsizei length);
+GLAPI void APIENTRY glFlushMappedNamedBufferRange (GLuint buffer, GLintptr 
offset, GLsizeiptr length);
 GLAPI void APIENTRY glGetNamedBufferParameteriv (GLuint buffer, GLenum pname, 
GLint *params);
 GLAPI void APIENTRY glGetNamedBufferParameteri64v (GLuint buffer, GLenum 
pname, GLint64 *params);
 GLAPI void APIENTRY glGetNamedBufferPointerv (GLuint buffer, GLenum pname, 
void **params);
-- 
2.1.0

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


[Mesa-dev] [PATCH 20/21] GL: Correct function arguments for GetNamedBufferSubData.

2015-01-21 Thread Laura Ekstrand
---
 include/GL/glext.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/GL/glext.h b/include/GL/glext.h
index cf0ea3f..ceb8b2f 100644
--- a/include/GL/glext.h
+++ b/include/GL/glext.h
@@ -2748,7 +2748,7 @@ GLAPI void APIENTRY glFlushMappedNamedBufferRange (GLuint 
buffer, GLintptr offse
 GLAPI void APIENTRY glGetNamedBufferParameteriv (GLuint buffer, GLenum pname, 
GLint *params);
 GLAPI void APIENTRY glGetNamedBufferParameteri64v (GLuint buffer, GLenum 
pname, GLint64 *params);
 GLAPI void APIENTRY glGetNamedBufferPointerv (GLuint buffer, GLenum pname, 
void **params);
-GLAPI void APIENTRY glGetNamedBufferSubData (GLuint buffer, GLintptr offset, 
GLsizei size, void *data);
+GLAPI void APIENTRY glGetNamedBufferSubData (GLuint buffer, GLintptr offset, 
GLsizeiptr size, void *data);
 GLAPI void APIENTRY glCreateFramebuffers (GLsizei n, GLuint *framebuffers);
 GLAPI void APIENTRY glNamedFramebufferRenderbuffer (GLuint framebuffer, GLenum 
attachment, GLenum renderbuffertarget, GLuint renderbuffer);
 GLAPI void APIENTRY glNamedFramebufferParameteri (GLuint framebuffer, GLenum 
pname, GLint param);
-- 
2.1.0

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


[Mesa-dev] [PATCH 19/21] main: Add entry point for GetNamedBufferPointerv.

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

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 46f4e9a..9cfc8e5 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -98,6 +98,12 @@
   param name=params type=GLint64 * /
/function
 
+   function name=GetNamedBufferPointerv offset=assign
+  param name=buffer type=GLuint /
+  param name=pname type=GLenum /
+  param name=params type=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 51b5d59..5495057 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1977,14 +1977,15 @@ void GLAPIENTRY
 _mesa_GetBufferPointerv(GLenum target, GLenum pname, GLvoid **params)
 {
GET_CURRENT_CONTEXT(ctx);
-   struct gl_buffer_object * bufObj;
+   struct gl_buffer_object *bufObj;
 
if (pname != GL_BUFFER_MAP_POINTER_ARB) {
-  _mesa_error(ctx, GL_INVALID_ENUM, glGetBufferPointervARB(pname));
+  _mesa_error(ctx, GL_INVALID_ENUM, glGetBufferPointerv(pname != 
+  GL_BUFFER_MAP_POINTER));
   return;
}
 
-   bufObj = get_buffer(ctx, glGetBufferPointervARB, target,
+   bufObj = get_buffer(ctx, glGetBufferPointerv, target,
GL_INVALID_OPERATION);
if (!bufObj)
   return;
@@ -1992,6 +1993,26 @@ _mesa_GetBufferPointerv(GLenum target, GLenum pname, 
GLvoid **params)
*params = bufObj-Mappings[MAP_USER].Pointer;
 }
 
+void GLAPIENTRY
+_mesa_GetNamedBufferPointerv(GLuint buffer, GLenum pname, GLvoid **params)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_buffer_object *bufObj;
+
+   if (pname != GL_BUFFER_MAP_POINTER_ARB) {
+  _mesa_error(ctx, GL_INVALID_ENUM, glGetNamedBufferPointerv(pname != 
+  GL_BUFFER_MAP_POINTER));
+  return;
+   }
+
+   bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
+   glGetNamedBufferPointerv);
+   if (!bufObj)
+  return;
+
+   *params = bufObj-Mappings[MAP_USER].Pointer;
+}
+
 
 void
 _mesa_copy_buffer_sub_data(struct gl_context *ctx,
diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
index e55de54..60f5607 100644
--- a/src/mesa/main/bufferobj.h
+++ b/src/mesa/main/bufferobj.h
@@ -278,6 +278,10 @@ void GLAPIENTRY
 _mesa_GetBufferPointerv(GLenum target, GLenum pname, GLvoid **params);
 
 void GLAPIENTRY
+_mesa_GetNamedBufferPointerv(GLuint buffer, GLenum pname, GLvoid **params);
+
+
+void GLAPIENTRY
 _mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
 GLintptr readOffset, GLintptr writeOffset,
 GLsizeiptr size);
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index 7d53ba4..4d5cb6a 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -968,6 +968,7 @@ const struct function gl_core_functions_possible[] = {
{ glFlushMappedNamedBufferRange, 45, -1 },
{ glGetNamedBufferParameteriv, 45, -1 },
{ glGetNamedBufferParameteri64v, 45, -1 },
+   { glGetNamedBufferPointerv, 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 18/21] main: Add entry points for GetNamedBufferParameteri[64]v.

2015-01-21 Thread Laura Ekstrand
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  12 ++
 src/mesa/main/bufferobj.c  | 170 +
 src/mesa/main/bufferobj.h  |   7 +
 src/mesa/main/tests/dispatch_sanity.cpp|   2 +
 4 files changed, 111 insertions(+), 80 deletions(-)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 1e6b9c4..46f4e9a 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -86,6 +86,18 @@
   param name=length type=GLsizeiptr /
/function
 
+   function name=GetNamedBufferParameteriv offset=assign
+  param name=buffer type=GLuint /
+  param name=pname type=GLenum /
+  param name=params type=GLint * /
+   /function
+
+   function name=GetNamedBufferParameteri64v offset=assign
+  param name=buffer type=GLuint /
+  param name=pname type=GLenum /
+  param name=params type=GLint64 * /
+   /function
+
   !-- Texture object functions --
 
function name=CreateTextures offset=assign
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index e446f39..51b5d59 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1838,128 +1838,138 @@ _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 *param, const char *func)
+{
switch (pname) {
case GL_BUFFER_SIZE_ARB:
-  *params = (GLint) bufObj-Size;
-  return;
+  *param = bufObj-Size;
+  break;
case GL_BUFFER_USAGE_ARB:
-  *params = bufObj-Usage;
-  return;
+  *param = bufObj-Usage;
+  break;
case GL_BUFFER_ACCESS_ARB:
-  *params = simplified_access_mode(ctx,
-bufObj-Mappings[MAP_USER].AccessFlags);
-  return;
-   case GL_BUFFER_MAPPED_ARB:
-  *params = _mesa_bufferobj_mapped(bufObj, MAP_USER);
-  return;
+  *param = simplified_access_mode(ctx,
+ bufObj-Mappings[MAP_USER].AccessFlags);
+  break;
case GL_BUFFER_ACCESS_FLAGS:
   if (!ctx-Extensions.ARB_map_buffer_range)
  goto invalid_pname;
-  *params = bufObj-Mappings[MAP_USER].AccessFlags;
-  return;
+  *param = bufObj-Mappings[MAP_USER].AccessFlags;
+  break;
+   case GL_BUFFER_MAPPED_ARB:
+  *param = _mesa_bufferobj_mapped(bufObj, MAP_USER);
+  break;
case GL_BUFFER_MAP_OFFSET:
   if (!ctx-Extensions.ARB_map_buffer_range)
  goto invalid_pname;
-  *params = (GLint) bufObj-Mappings[MAP_USER].Offset;
-  return;
+  *param = 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;
+  *param = bufObj-Mappings[MAP_USER].Length;
+  break;
case GL_BUFFER_IMMUTABLE_STORAGE:
   if (!ctx-Extensions.ARB_buffer_storage)
  goto invalid_pname;
-  *params = bufObj-Immutable;
-  return;
+  *param = bufObj-Immutable;
+  break;
case GL_BUFFER_STORAGE_FLAGS:
   if (!ctx-Extensions.ARB_buffer_storage)
  goto invalid_pname;
-  *params = bufObj-StorageFlags;
-  return;
+  *param = bufObj-StorageFlags;
+  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 

[Mesa-dev] [PATCH 21/21] main: Add entry point for glGetNamedBufferSubData.

2015-01-21 Thread Laura Ekstrand
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  7 +++
 src/mesa/main/bufferobj.c  | 24 +++-
 src/mesa/main/bufferobj.h  |  8 ++--
 src/mesa/main/tests/dispatch_sanity.cpp|  1 +
 4 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 9cfc8e5..51eefd9 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -104,6 +104,13 @@
   param name=params type=GLvoid ** /
/function
 
+   function name=GetNamedBufferSubData offset=assign
+  param name=buffer type=GLuint /
+  param name=offset type=GLintptr /
+  param name=size type=GLsizeiptr /
+  param name=data type=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 5495057..30942a4 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1659,9 +1659,31 @@ _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
+_mesa_GetNamedBufferSubData(GLuint buffer, GLintptr offset,
+GLsizeiptr size, GLvoid *data)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_buffer_object *bufObj;
+
+   bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
+   glGetNamedBufferSubData);
+   if (!bufObj)
+  return;
+
+   if (!buffer_object_subdata_range_good(ctx, bufObj, offset, size, false,
+ glGetNamedBufferSubData)) {
+  return;
+   }
+
+   ASSERT(ctx-Driver.GetBufferSubData);
+   ctx-Driver.GetBufferSubData(ctx, offset, size, data, bufObj);
+}
+
+
 /**
  * \param subdata   true if caller is *SubData, false if *Data
  */
diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
index 60f5607..6f8aade 100644
--- a/src/mesa/main/bufferobj.h
+++ b/src/mesa/main/bufferobj.h
@@ -230,8 +230,12 @@ _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,
+GLsizeiptr size, GLvoid *data);
 
 void GLAPIENTRY
 _mesa_ClearBufferData(GLenum target, GLenum internalformat,
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index 4d5cb6a..b6438c8 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -969,6 +969,7 @@ const struct function gl_core_functions_possible[] = {
{ glGetNamedBufferParameteriv, 45, -1 },
{ glGetNamedBufferParameteri64v, 45, -1 },
{ glGetNamedBufferPointerv, 45, -1 },
+   { glGetNamedBufferSubData, 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 14/21] main: Add entry points for MapNamedBuffer[Range].

2015-01-21 Thread Laura Ekstrand
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  14 ++
 src/mesa/main/bufferobj.c  | 327 -
 src/mesa/main/bufferobj.h  |  20 +-
 src/mesa/main/tests/dispatch_sanity.cpp|   2 +
 4 files changed, 189 insertions(+), 174 deletions(-)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 4b29e00..7727f0d 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -61,6 +61,20 @@
   param name=data type=const GLvoid * /
/function
 
+   function name=MapNamedBuffer offset=assign
+  return type=GLvoid * /
+  param name=buffer type=GLuint /
+  param name=access type=GLenum /
+   /function
+
+   function name=MapNamedBufferRange offset=assign
+  return type=GLvoid * /
+  param name=buffer type=GLuint /
+  param name=offset type=GLintptr /
+  param name=length type=GLsizeiptr /
+  param name=access type=GLbitfield /
+   /function
+
   !-- Texture object functions --
 
function name=CreateTextures offset=assign
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 1ec1681..16c0faa 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -701,7 +701,7 @@ _mesa_ClearBufferSubData_sw(struct gl_context *ctx,
  * Called via glMapBufferRange().
  */
 static void *
-_mesa_buffer_map_range( struct gl_context *ctx, GLintptr offset,
+_mesa_MapBufferRange_sw(struct gl_context *ctx, GLintptr offset,
 GLsizeiptr length, GLbitfield access,
 struct gl_buffer_object *bufObj,
 gl_map_buffer_index 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 = _mesa_MapBufferRange_sw;
driver-FlushMappedBufferRange = _mesa_buffer_flush_mapped_range;
 
/* GL_ARB_copy_buffer */
@@ -1794,116 +1794,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; 

[Mesa-dev] [PATCH 11/21] GL: Correct function arguments for ClearNamedBufferSubData.

2015-01-21 Thread Laura Ekstrand
---
 include/GL/glext.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/GL/glext.h b/include/GL/glext.h
index 925df18..2543d1b 100644
--- a/include/GL/glext.h
+++ b/include/GL/glext.h
@@ -2740,7 +2740,7 @@ GLAPI void APIENTRY glNamedBufferData (GLuint buffer, 
GLsizeiptr size, const voi
 GLAPI void APIENTRY glNamedBufferSubData (GLuint buffer, GLintptr offset, 
GLsizeiptr size, const void *data);
 GLAPI void APIENTRY glCopyNamedBufferSubData (GLuint readBuffer, GLuint 
writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
 GLAPI void APIENTRY glClearNamedBufferData (GLuint buffer, GLenum 
internalformat, GLenum format, GLenum type, const void *data);
-GLAPI void APIENTRY glClearNamedBufferSubData (GLuint buffer, GLenum 
internalformat, GLintptr offset, GLsizei size, GLenum format, GLenum type, 
const void *data);
+GLAPI void APIENTRY glClearNamedBufferSubData (GLuint buffer, GLenum 
internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, 
const void *data);
 GLAPI void *APIENTRY glMapNamedBuffer (GLuint buffer, GLenum access);
 GLAPI void *APIENTRY glMapNamedBufferRange (GLuint buffer, GLintptr offset, 
GLsizei length, GLbitfield access);
 GLAPI GLboolean APIENTRY glUnmapNamedBuffer (GLuint buffer);
-- 
2.1.0

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


[Mesa-dev] [PATCH 10/21] main: Add entry point for CopyNamedBufferSubData.

2015-01-21 Thread Laura Ekstrand
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |   8 ++
 src/mesa/main/bufferobj.c  | 102 -
 src/mesa/main/bufferobj.h  |  12 +++
 src/mesa/main/tests/dispatch_sanity.cpp|   1 +
 4 files changed, 89 insertions(+), 34 deletions(-)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 8a5cebb..8c80dfb 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -35,6 +35,14 @@
   param name=data type=const GLvoid * /
/function
 
+   function name=CopyNamedBufferSubData offset=assign
+  param name=readBuffer type=GLuint /
+  param name=writeBuffer type=GLuint /
+  param name=readOffset type=GLintptr /
+  param name=writeOffset type=GLintptr /
+  param name=size 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 20c2cdc..31ae006 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -761,11 +761,11 @@ _mesa_buffer_unmap(struct gl_context *ctx, struct 
gl_buffer_object *bufObj,
  * Called via glCopyBufferSubData().
  */
 static void
-_mesa_copy_buffer_subdata(struct gl_context *ctx,
-  struct gl_buffer_object *src,
-  struct gl_buffer_object *dst,
-  GLintptr readOffset, GLintptr writeOffset,
-  GLsizeiptr size)
+_mesa_CopyBufferSubData_sw(struct gl_context *ctx,
+   struct gl_buffer_object *src,
+   struct gl_buffer_object *dst,
+   GLintptr readOffset, GLintptr writeOffset,
+   GLsizeiptr size)
 {
GLubyte *srcPtr, *dstPtr;
 
@@ -1120,7 +1120,7 @@ _mesa_init_buffer_object_functions(struct 
dd_function_table *driver)
driver-FlushMappedBufferRange = _mesa_buffer_flush_mapped_range;
 
/* GL_ARB_copy_buffer */
-   driver-CopyBufferSubData = _mesa_copy_buffer_subdata;
+   driver-CopyBufferSubData = _mesa_CopyBufferSubData_sw;
 }
 
 
@@ -2096,65 +2096,54 @@ _mesa_GetBufferPointerv(GLenum target, GLenum pname, 
GLvoid **params)
 }
 
 
-void GLAPIENTRY
-_mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
-GLintptr readOffset, GLintptr writeOffset,
-GLsizeiptr size)
+void
+_mesa_copy_buffer_sub_data(struct gl_context *ctx,
+   struct gl_buffer_object *src,
+   struct gl_buffer_object *dst,
+   GLintptr readOffset, GLintptr writeOffset,
+   GLsizeiptr size, const char *func)
 {
-   GET_CURRENT_CONTEXT(ctx);
-   struct gl_buffer_object *src, *dst;
-
-   src = get_buffer(ctx, glCopyBufferSubData, readTarget,
-GL_INVALID_OPERATION);
-   if (!src)
-  return;
-
-   dst = get_buffer(ctx, glCopyBufferSubData, writeTarget,
-GL_INVALID_OPERATION);
-   if (!dst)
-  return;
-
if (_mesa_check_disallowed_mapping(src)) {
   _mesa_error(ctx, GL_INVALID_OPERATION,
-  glCopyBufferSubData(readBuffer is mapped));
+  %s(readBuffer is mapped), func);
   return;
}
 
if (_mesa_check_disallowed_mapping(dst)) {
   _mesa_error(ctx, GL_INVALID_OPERATION,
-  glCopyBufferSubData(writeBuffer is mapped));
+  %s(writeBuffer is mapped), func);
   return;
}
 
if (readOffset  0) {
   _mesa_error(ctx, GL_INVALID_VALUE,
-  glCopyBufferSubData(readOffset = %d), (int) readOffset);
+  %s(readOffset %d  0), func, (int) readOffset);
   return;
}
 
if (writeOffset  0) {
   _mesa_error(ctx, GL_INVALID_VALUE,
-  glCopyBufferSubData(writeOffset = %d), (int) writeOffset);
+  %s(writeOffset %d  0), func, (int) writeOffset);
   return;
}
 
if (size  0) {
   _mesa_error(ctx, GL_INVALID_VALUE,
-  glCopyBufferSubData(writeOffset = %d), (int) size);
+  %s(size %d  0), func, (int) size);
   return;
}
 
if (readOffset + size  src-Size) {
   _mesa_error(ctx, GL_INVALID_VALUE,
-  glCopyBufferSubData(readOffset + size = %d),
-  (int) (readOffset + size));
+  %s(readOffset %d + size %d  src_buffer_size %d), func,
+  (int) readOffset, (int) size, (int) src-Size);
   return;
}
 
if (writeOffset + size  dst-Size) {
   _mesa_error(ctx, GL_INVALID_VALUE,
-  glCopyBufferSubData(writeOffset + size = %d),
-  (int) (writeOffset + size));
+  %s(writeOffset %d + size %d  dst_buffer_size %d), func,
+  (int) writeOffset, (int) 

[Mesa-dev] [PATCH 3/7] nir/search: Don't use a nir_alu_src for storing variables

2015-01-21 Thread Jason Ekstrand
Originally, I used a nir_alu_src because I was lazy.  However, we only need
part of that datastructure and carying the whole thing around implies
things we don't want such as the possibility of using non-SSA sources.
---
 src/glsl/nir/nir_search.c | 21 +
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/src/glsl/nir/nir_search.c b/src/glsl/nir/nir_search.c
index 35323f9..4f46cf6 100644
--- a/src/glsl/nir/nir_search.c
+++ b/src/glsl/nir/nir_search.c
@@ -27,9 +27,14 @@
 
 #include nir_search.h
 
+struct match_var {
+   nir_ssa_def *ssa;
+   uint8_t swizzle[4];
+};
+
 struct match_state {
unsigned variables_seen;
-   nir_alu_src variables[NIR_SEARCH_MAX_VARIABLES];
+   struct match_var variables[NIR_SEARCH_MAX_VARIABLES];
 };
 
 static bool
@@ -65,8 +70,7 @@ match_value(const nir_search_value *value, nir_alu_instr 
*instr, unsigned src,
   nir_search_variable *var = nir_search_value_as_variable(value);
 
   if (state-variables_seen  (1  var-variable)) {
- if (!nir_srcs_equal(state-variables[var-variable].src,
- instr-src[src].src))
+ if (state-variables[var-variable].ssa != instr-src[src].src.ssa)
 return false;
 
  assert(!instr-src[src].abs  !instr-src[src].negate);
@@ -79,9 +83,7 @@ match_value(const nir_search_value *value, nir_alu_instr 
*instr, unsigned src,
  return true;
   } else {
  state-variables_seen |= (1  var-variable);
- state-variables[var-variable].src = instr-src[src].src;
- state-variables[var-variable].abs = false;
- state-variables[var-variable].negate = false;
+ state-variables[var-variable].ssa = instr-src[src].src.ssa;
 
  for (int i = 0; i  4; ++i) {
 if (i  num_components)
@@ -236,8 +238,11 @@ construct_value(const nir_search_value *value, 
nir_alu_type type,
   const nir_search_variable *var = nir_search_value_as_variable(value);
   assert(state-variables_seen  (1  var-variable));
 
-  nir_alu_src val = state-variables[var-variable];
-  val.src = nir_src_copy(val.src, mem_ctx);
+  nir_alu_src val;
+  val.src = nir_src_for_ssa(state-variables[var-variable].ssa);
+  val.abs = false;
+  val.negate = false;
+  memcpy(val.swizzle, state-variables[var-variable].swizzle, 4);
 
   return val;
}
-- 
2.2.1

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


[Mesa-dev] [PATCH 4/7] nir/search: Add a swizzle to nir_search_variable and use it for replacements

2015-01-21 Thread Jason Ekstrand
---
 src/glsl/nir/nir_algebraic.py | 14 ++
 src/glsl/nir/nir_search.c |  6 +-
 src/glsl/nir/nir_search.h |  7 +++
 3 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/src/glsl/nir/nir_algebraic.py b/src/glsl/nir/nir_algebraic.py
index f9b246d..37eb523 100644
--- a/src/glsl/nir/nir_algebraic.py
+++ b/src/glsl/nir/nir_algebraic.py
@@ -28,6 +28,7 @@ import itertools
 import struct
 import sys
 import mako.template
+import re
 
 # Represents a set of variables, each with a unique id
 class VarSet(object):
@@ -60,6 +61,7 @@ static const ${val.c_type} ${val.name} = {
{ ${hex(val)} /* ${val.value} */ },
 % elif isinstance(val, Variable):
${val.index}, /* ${val.var_name} */
+   { ${', '.join(str(s) for s in val.swizzle)} },
 % elif isinstance(val, Expression):
nir_op_${val.opcode},
{ ${', '.join(src.c_ptr for src in val.sources)} },
@@ -106,13 +108,25 @@ class Constant(Value):
   else:
  assert False
 
+_swizzle_re = re.compile(r'(.*)\.([xyzw]{1,4})')
+
 class Variable(Value):
def __init__(self, val, name, varset):
+  match = _swizzle_re.match(name)
+  if match:
+ name = match.group(1)
+
   Value.__init__(self, name, variable)
+
   self.var_name = val
   self.index = varset[val]
   self.name = name
 
+  if match:
+ self.swizzle = ['xyzw'.find(s) for s in match.group(2)]
+  else:
+ self.swizzle = range(4)
+
 class Expression(Value):
def __init__(self, expr, name_base, varset):
   Value.__init__(self, name_base, expression)
diff --git a/src/glsl/nir/nir_search.c b/src/glsl/nir/nir_search.c
index 4f46cf6..4af34bf 100644
--- a/src/glsl/nir/nir_search.c
+++ b/src/glsl/nir/nir_search.c
@@ -69,6 +69,8 @@ match_value(const nir_search_value *value, nir_alu_instr 
*instr, unsigned src,
case nir_search_value_variable: {
   nir_search_variable *var = nir_search_value_as_variable(value);
 
+  assert(memcmp(var-swizzle, identity_swizzle, 4) == 0);
+
   if (state-variables_seen  (1  var-variable)) {
  if (state-variables[var-variable].ssa != instr-src[src].src.ssa)
 return false;
@@ -242,7 +244,9 @@ construct_value(const nir_search_value *value, nir_alu_type 
type,
   val.src = nir_src_for_ssa(state-variables[var-variable].ssa);
   val.abs = false;
   val.negate = false;
-  memcpy(val.swizzle, state-variables[var-variable].swizzle, 4);
+
+  for (unsigned i = 0; i  4; ++i)
+ val.swizzle[i] = 
state-variables[var-variable].swizzle[var-swizzle[i]];
 
   return val;
}
diff --git a/src/glsl/nir/nir_search.h b/src/glsl/nir/nir_search.h
index 8ec58b0..8b89dd0 100644
--- a/src/glsl/nir/nir_search.h
+++ b/src/glsl/nir/nir_search.h
@@ -47,6 +47,13 @@ typedef struct {
 
/** The variable index;  Must be less than NIR_SEARCH_MAX_VARIABLES */
unsigned variable;
+
+   /** A swizzle value corresponding to nir_alu_src.swizzle
+*
+* This is currently only allowed in replacement expressions, not
+* searches.
+*/
+   uint8_t swizzle[4];
 } nir_search_variable;
 
 typedef struct {
-- 
2.2.1

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


Re: [Mesa-dev] [PATCH] radeonsi: Enable VGPR spilling for all shader types v3

2015-01-21 Thread Michel Dänzer
On 21.01.2015 21:12, Marek Olšák wrote:
 We also had a case when the CPU accidentally corrupted shaders,
 because the shaders were mapped after textures and a CPU texture
 upload overflowed and overwrote shaders. I suppose we should have
 unmapped the shaders.

Sounds like a good idea.


Tom, for now I suggest this solution, summarized from Marek's previous
descriptions:

(At least) for shaders which have relocations, keep a copy of the
machine code in malloced memory. When the relocated values change,
update them in the malloced memory, allocate a new BO, map it, copy the
machine code from the malloced memory to the BO, replace any existing
shader BO with the new one and invalidate the shader state.


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast | Mesa and X developer
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] mesa/autoconf: attempt to use gnu99 on older gcc compilers

2015-01-21 Thread Jason Ekstrand
FYI: I just pushed the NIR patches with Connor's R-B so as soon as we're
done with configure.ac, we should be building on RHEL6 again.
--Jason

On Wed, Jan 21, 2015 at 5:37 PM, Ian Romanick i...@freedesktop.org wrote:

 On 01/21/2015 05:35 PM, Matt Turner wrote:
  On Wed, Jan 21, 2015 at 5:28 PM, Dave Airlie airl...@gmail.com wrote:
  From: Dave Airlie airl...@redhat.com
 
  anonymous structs/union don't work with c99 but do work with gnu99
  on gcc 4.4.
 
  This on top of Jason's designated initialisers changes, make
  Mesa build on RHEL6 again.
 
  Signed-off-by: Dave Airlie airl...@redhat.com
  ---
   configure.ac |   12 +++-
   1 files changed, 11 insertions(+), 1 deletions(-)
 
  diff --git a/configure.ac b/configure.ac
  index a4c5c74..9420a90 100644
  --- a/configure.ac
  +++ b/configure.ac
  @@ -145,6 +145,7 @@ AC_MSG_RESULT([$acv_mesa_CLANG])
   dnl If we're using GCC, make sure that it is at least version 4.2.0.
 Older
   dnl versions are explictly not supported.
   GEN_ASM_OFFSETS=no
  +USE_GNU99=no
   if test x$GCC = xyes -a x$acv_mesa_CLANG = xno; then
   AC_MSG_CHECKING([whether gcc version is sufficient])
   major=0
  @@ -163,6 +164,9 @@ if test x$GCC = xyes -a x$acv_mesa_CLANG = xno;
 then
   AC_MSG_RESULT([yes])
   fi
 
  +if test $GCC_VERSION_MAJOR -lt 4 -o $GCC_VERSION_MAJOR -eq 4 -a
 $GCC_VERSION_MINOR -lt 6 ; then
 
  Can't we just do this test...
 
  +USE_GNU99=yes
  +fi
   if test x$cross_compiling = xyes; then
   GEN_ASM_OFFSETS=yes
   fi
  @@ -221,7 +225,13 @@ esac
 
   dnl Add flags for gcc and g++
   if test x$GCC = xyes; then
  -CFLAGS=$CFLAGS -Wall -std=c99
  +CFLAGS=$CFLAGS -Wall
  +
  +if test x$USE_GNU99 = xyes; then
 
  ... right here?

 It would happen on clang if we did.  Above, it's inside a block of am I
 GCC and definitely not clang.  That said, I don't know how important
 that is...

  +   CFLAGS=$CFLAGS -std=gnu99
  +else
  +   CFLAGS=$CFLAGS -std=c99
  +fi
 
   # Enable -Werror=implicit-function-declaration and
   # -Werror=missing-prototypes, if available, or otherwise, just
  --
  1.7.1
 
  ___
  mesa-dev mailing list
  mesa-dev@lists.freedesktop.org
  http://lists.freedesktop.org/mailman/listinfo/mesa-dev
  ___
  mesa-dev mailing list
  mesa-dev@lists.freedesktop.org
  http://lists.freedesktop.org/mailman/listinfo/mesa-dev
 

 ___
 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 4/5] nir: Make some helpers for copying ALU src/dests.

2015-01-21 Thread Jason Ekstrand
On Wed, Jan 21, 2015 at 5:26 PM, Eric Anholt e...@anholt.net wrote:

 There aren't many users yet, but I wanted to do this from my scalarizing
 pass.
 ---
  src/glsl/nir/nir.c | 18 ++
  src/glsl/nir/nir.h |  5 -
  src/glsl/nir/nir_lower_vec_to_movs.c   |  7 ++-
  src/glsl/nir/nir_opt_peephole_select.c |  5 +
  4 files changed, 25 insertions(+), 10 deletions(-)

 diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
 index 16ad2da..e414df9 100644
 --- a/src/glsl/nir/nir.c
 +++ b/src/glsl/nir/nir.c
 @@ -175,6 +175,24 @@ nir_dest nir_dest_copy(nir_dest dest, void *mem_ctx)
 return ret;
  }

 +void
 +nir_alu_src_copy(nir_alu_src *dest, nir_alu_src *src, void *mem_ctx)
 +{


We already have nir_src_copy which returns a nir_src instead of taking a
pointer.  TBH, I'm not sure which I prefer, but it would be good to be
consistent.  Thoughts?


 +   dest-src = nir_src_copy(src-src, mem_ctx);
 +   dest-abs = src-abs;
 +   dest-negate = src-negate;
 +   for (unsigned i = 0; i  4; i++)
 +  dest-swizzle[i] = src-swizzle[i];
 +}
 +
 +void
 +nir_alu_dest_copy(nir_alu_dest *dest, nir_alu_dest *src, void *mem_ctx)
 +{
 +   dest-dest = nir_dest_copy(src-dest, mem_ctx);
 +   dest-write_mask = src-write_mask;
 +   dest-saturate = src-saturate;
 +}
 +
  static inline void
  block_add_pred(nir_block *block, nir_block *pred)
  {
 diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
 index 8dc5222..7f0aa36 100644
 --- a/src/glsl/nir/nir.h
 +++ b/src/glsl/nir/nir.h
 @@ -569,7 +569,10 @@ typedef struct {
 unsigned write_mask : 4; /* ignored if dest.is_ssa is true */
  } nir_alu_dest;

 -#define OPCODE(name, num_inputs, output_size, output_type, \
 +void nir_alu_src_copy(nir_alu_src *dest, nir_alu_src *src, void *mem_ctx);
 +void nir_alu_dest_copy(nir_alu_dest *dest, nir_alu_dest *src, void
 *mem_ctx);
 +
 +#define OPCODE(name, num_inputs, output_size, output_type,  \


Accidental whitespace change?


 input_sizes, input_types, algebraic_props) \
 nir_op_##name,

 diff --git a/src/glsl/nir/nir_lower_vec_to_movs.c
 b/src/glsl/nir/nir_lower_vec_to_movs.c
 index a3120b6..022889e 100644
 --- a/src/glsl/nir/nir_lower_vec_to_movs.c
 +++ b/src/glsl/nir/nir_lower_vec_to_movs.c
 @@ -57,15 +57,12 @@ lower_vec_to_movs_block(nir_block *block, void
 *mem_ctx)
   assert(src_idx  nir_op_infos[vec-op].num_inputs);

   nir_alu_instr *mov = nir_alu_instr_create(mem_ctx, nir_op_imov);
 - mov-src[0].src = nir_src_copy(vec-src[src_idx].src, mem_ctx);
 - mov-src[0].negate = vec-src[src_idx].negate;
 - mov-src[0].abs = vec-src[src_idx].abs;
 + nir_alu_src_copy(mov-src[0], vec-src[src_idx], mem_ctx);

   /* We only care about the one swizzle */
   mov-src[0].swizzle[i] = vec-src[src_idx].swizzle[0];

 - mov-dest.dest = nir_dest_copy(vec-dest.dest, mem_ctx);
 - mov-dest.saturate = vec-dest.saturate;
 + nir_alu_dest_copy(mov-dest, vec-dest, mem_ctx);
   mov-dest.write_mask = (1u  i);

   nir_instr_insert_before(vec-instr, mov-instr);
 diff --git a/src/glsl/nir/nir_opt_peephole_select.c
 b/src/glsl/nir/nir_opt_peephole_select.c
 index 023fae5..a5ac11f 100644
 --- a/src/glsl/nir/nir_opt_peephole_select.c
 +++ b/src/glsl/nir/nir_opt_peephole_select.c
 @@ -154,10 +154,7 @@ nir_opt_peephole_select_block(nir_block *block, void
 *void_state)
  assert(mov-instr.type == nir_instr_type_alu);
  assert(mov-op == nir_op_fmov || mov-op == nir_op_imov);

 -sel-src[idx].src = nir_src_copy(mov-src[0].src,
 state-mem_ctx);
 -sel-src[idx].negate = mov-src[0].negate;
 -sel-src[idx].abs = mov-src[0].abs;
 -memcpy(sel-src[idx].swizzle, mov-src[0].swizzle, 4);
 +nir_alu_src_copy(sel-src[idx], mov-src[0],
 state-mem_ctx);
   } else {
  sel-src[idx].src = nir_src_copy(src-src, state-mem_ctx);
   }
 --
 2.1.3

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

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


Re: [Mesa-dev] [PATCH 2/5] nir: Make an easier helper for setting up SSA defs.

2015-01-21 Thread Jason Ekstrand
Yes, please.  I've made that mistake enough myself.

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

On Wed, Jan 21, 2015 at 5:25 PM, Eric Anholt e...@anholt.net wrote:

 Almost all instructions we nir_ssa_def_init() for are nir_dests, and you
 have to keep from forgetting to set is_ssa when you do.  Just provide the
 simpler helper, instead.
 ---
  src/glsl/nir/glsl_to_nir.cpp| 14 --
  src/glsl/nir/nir.c  |  8 
  src/glsl/nir/nir.h  |  2 ++
  src/glsl/nir/nir_from_ssa.c | 10 --
  src/glsl/nir/nir_lower_atomics.c| 11 ---
  src/glsl/nir/nir_lower_io.c | 11 ---
  src/glsl/nir/nir_lower_locals_to_regs.c | 11 ---
  src/glsl/nir/nir_lower_system_values.c  |  5 ++---
  src/glsl/nir/nir_lower_var_copies.c |  3 +--
  src/glsl/nir/nir_lower_vars_to_ssa.c| 15 ++-
  src/glsl/nir/nir_opt_peephole_select.c  |  5 ++---
  src/glsl/nir/nir_search.c   |  8 +++-
  src/glsl/nir/nir_to_ssa.c   |  9 ++---
  13 files changed, 46 insertions(+), 66 deletions(-)

 diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp
 index 6ac830e..80bc4ba 100644
 --- a/src/glsl/nir/glsl_to_nir.cpp
 +++ b/src/glsl/nir/glsl_to_nir.cpp
 @@ -618,8 +618,7 @@ nir_visitor::visit(ir_call *ir)
   (ir_dereference *) ir-actual_parameters.get_head();
param-accept(this);
instr-variables[0] = this-deref_head;
 -  instr-dest.is_ssa = true;
 -  nir_ssa_def_init(instr-instr, instr-dest.ssa, 1, NULL);
 +  nir_ssa_dest_init(instr-instr, instr-dest, 1, NULL);

nir_instr_insert_after_cf_list(this-cf_node_list, instr-instr);

 @@ -702,9 +701,7 @@ nir_visitor::visit(ir_assignment *ir)
nir_intrinsic_instr *load =
   nir_intrinsic_instr_create(this-shader, nir_intrinsic_load_var);
load-num_components = ir-lhs-type-vector_elements;
 -  load-dest.is_ssa = true;
 -  nir_ssa_def_init(load-instr, load-dest.ssa,
 -   num_components, NULL);
 +  nir_ssa_dest_init(load-instr, load-dest, num_components, NULL);
load-variables[0] = lhs_deref;
nir_instr_insert_after_cf_list(this-cf_node_list, load-instr);

 @@ -717,9 +714,7 @@ nir_visitor::visit(ir_assignment *ir)
   default: unreachable(Invalid number of components); break;
}
nir_alu_instr *vec = nir_alu_instr_create(this-shader, vec_op);
 -  vec-dest.dest.is_ssa = true;
 -  nir_ssa_def_init(vec-instr, vec-dest.dest.ssa,
 -   num_components, NULL);
 +  nir_ssa_dest_init(vec-instr, vec-dest.dest, num_components,
 NULL);
vec-dest.write_mask = (1  num_components) - 1;

unsigned component = 0;
 @@ -805,8 +800,7 @@ nir_visitor::add_instr(nir_instr *instr, unsigned
 num_components)
  {
 nir_dest *dest = get_instr_dest(instr);

 -   dest-is_ssa = true;
 -   nir_ssa_def_init(instr, dest-ssa, num_components, NULL);
 +   nir_ssa_dest_init(instr, dest, num_components, NULL);

 nir_instr_insert_after_cf_list(this-cf_node_list, instr);
 this-result = instr;
 diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
 index 89e21fd..16ad2da 100644
 --- a/src/glsl/nir/nir.c
 +++ b/src/glsl/nir/nir.c
 @@ -1791,6 +1791,14 @@ nir_ssa_def_init(nir_instr *instr, nir_ssa_def *def,
 }
  }

 +void
 +nir_ssa_dest_init(nir_instr *instr, nir_dest *dest,
 + unsigned num_components, const char *name)
 +{
 +   dest-is_ssa = true;
 +   nir_ssa_def_init(instr, dest-ssa, num_components, name);
 +}
 +
  struct ssa_def_rewrite_state {
 void *mem_ctx;
 nir_ssa_def *old;
 diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
 index 761f20a..8dc5222 100644
 --- a/src/glsl/nir/nir.h
 +++ b/src/glsl/nir/nir.h
 @@ -1457,6 +1457,8 @@ nir_const_value *nir_src_as_const_value(nir_src src);
  bool nir_srcs_equal(nir_src src1, nir_src src2);
  void nir_instr_rewrite_src(nir_instr *instr, nir_src *src, nir_src
 new_src);

 +void nir_ssa_dest_init(nir_instr *instr, nir_dest *dest,
 +   unsigned num_components, const char *name);
  void nir_ssa_def_init(nir_instr *instr, nir_ssa_def *def,
unsigned num_components, const char *name);
  void nir_ssa_def_rewrite_uses(nir_ssa_def *def, nir_src new_src, void
 *mem_ctx);
 diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c
 index 9728b99..88212a2 100644
 --- a/src/glsl/nir/nir_from_ssa.c
 +++ b/src/glsl/nir/nir_from_ssa.c
 @@ -355,9 +355,8 @@ isolate_phi_nodes_block(nir_block *block, void
 *void_state)
   entry-src = nir_src_copy(src-src, state-dead_ctx);
   _mesa_set_add(src-src.ssa-uses, pcopy-instr);

 - entry-dest.is_ssa = true;
 - nir_ssa_def_init(pcopy-instr, entry-dest.ssa,
 -  phi-dest.ssa.num_components,
 src-src.ssa-name);
 + nir_ssa_dest_init(pcopy-instr, entry-dest,
 +  

[Mesa-dev] [PATCH 08/21] main: Add entry point for NamedBufferSubData.

2015-01-21 Thread Laura Ekstrand
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |   7 ++
 src/mesa/main/bufferobj.c  | 150 -
 src/mesa/main/bufferobj.h  |  13 ++-
 src/mesa/main/tests/dispatch_sanity.cpp|   1 +
 4 files changed, 113 insertions(+), 58 deletions(-)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 4b1ef6f..8a5cebb 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -28,6 +28,13 @@
   param name=usage type=GLenum /
/function
 
+   function name=NamedBufferSubData offset=assign
+  param name=buffer type=GLuint /
+  param name=offset type=GLintptr /
+  param name=size type=GLsizeiptr /
+  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 c77029f..20c2cdc 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -227,67 +227,62 @@ bufferobj_range_mapped(const struct gl_buffer_object *obj,
  * \c glClearBufferSubData.
  *
  * \param ctx GL context.
- * \param target  Buffer object target on which to operate.
+ * \param bufObj  The buffer object.
  * \param offset  Offset of the first byte of the subdata range.
  * \param sizeSize, in bytes, of the subdata range.
  * \param mappedRange  If true, checks if an overlapping range is mapped.
  * If false, checks if buffer is mapped.
- * \param errorNoBuffer  Error code if no buffer is bound to target.
- * \param caller  Name of calling function for recording errors.
- * \return   A pointer to the buffer object bound to \c target in the
- *   specified context or \c NULL if any of the parameter or state
- *   conditions are invalid.
+ * \param func  Name of calling function for recording errors.
+ * \return   false if error, true otherwise
  *
  * \sa glBufferSubDataARB, glGetBufferSubDataARB, glClearBufferSubData
  */
-static struct gl_buffer_object *
-buffer_object_subdata_range_good(struct gl_context * ctx, GLenum target,
- GLintptrARB offset, GLsizeiptrARB size,
- bool mappedRange, GLenum errorNoBuffer,
- const char *caller)
+static bool
+buffer_object_subdata_range_good(struct gl_context *ctx,
+ struct gl_buffer_object *bufObj,
+ GLintptr offset, GLsizeiptr size,
+ bool mappedRange, const char *func)
 {
-   struct gl_buffer_object *bufObj;
-
if (size  0) {
-  _mesa_error(ctx, GL_INVALID_VALUE, %s(size  0), caller);
-  return NULL;
+  _mesa_error(ctx, GL_INVALID_VALUE, %s(size  0), func);
+  return false;
}
 
if (offset  0) {
-  _mesa_error(ctx, GL_INVALID_VALUE, %s(offset  0), caller);
-  return NULL;
+  _mesa_error(ctx, GL_INVALID_VALUE, %s(offset  0), func);
+  return false;
}
 
-   bufObj = get_buffer(ctx, caller, target, errorNoBuffer);
-   if (!bufObj)
-  return NULL;
-
if (offset + size  bufObj-Size) {
   _mesa_error(ctx, GL_INVALID_VALUE,
-  %s(offset %lu + size %lu  buffer size %lu), caller,
+  %s(offset %lu + size %lu  buffer size %lu), func,
   (unsigned long) offset,
   (unsigned long) size,
   (unsigned long) bufObj-Size);
-  return NULL;
+  return false;
}
 
if (bufObj-Mappings[MAP_USER].AccessFlags  GL_MAP_PERSISTENT_BIT)
-  return bufObj;
+  return true;
 
if (mappedRange) {
   if (bufferobj_range_mapped(bufObj, offset, size)) {
- _mesa_error(ctx, GL_INVALID_OPERATION, %s, caller);
- return NULL;
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ %s(range is mapped without GL_MAP_PERSISTENT_BIT),
+ func);
+ return false;
   }
}
else {
   if (_mesa_bufferobj_mapped(bufObj, MAP_USER)) {
- _mesa_error(ctx, GL_INVALID_OPERATION, %s, caller);
- return NULL;
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ %s(buffer is mapped without GL_MAP_PERSISTENT_BIT),
+ func);
+ return false;
   }
}
 
-   return bufObj;
+   return true;
 }
 
 
@@ -602,9 +597,9 @@ _mesa_BufferData_sw(struct gl_context *ctx, GLenum target, 
GLsizeiptr size,
  * \sa glBufferSubDataARB, dd_function_table::BufferSubData.
  */
 static void
-_mesa_buffer_subdata( struct gl_context *ctx, GLintptrARB offset,
- GLsizeiptrARB size, const GLvoid * data,
- struct gl_buffer_object * bufObj )
+_mesa_BufferSubData_sw(struct gl_context *ctx, GLintptr offset,
+   GLsizeiptr size, const GLvoid *data,
+ 

[Mesa-dev] [PATCH 05/21] GL: Correct function arguments for NamedBufferData.

2015-01-21 Thread Laura Ekstrand
---
 include/GL/glext.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/GL/glext.h b/include/GL/glext.h
index 1ffe576..0bc9e98 100644
--- a/include/GL/glext.h
+++ b/include/GL/glext.h
@@ -2736,7 +2736,7 @@ GLAPI void APIENTRY glGetTransformFeedbacki_v (GLuint 
xfb, GLenum pname, GLuint
 GLAPI void APIENTRY glGetTransformFeedbacki64_v (GLuint xfb, GLenum pname, 
GLuint index, GLint64 *param);
 GLAPI void APIENTRY glCreateBuffers (GLsizei n, GLuint *buffers);
 GLAPI void APIENTRY glNamedBufferStorage (GLuint buffer, GLsizeiptr size, 
const void *data, GLbitfield flags);
-GLAPI void APIENTRY glNamedBufferData (GLuint buffer, GLsizei size, const void 
*data, GLenum usage);
+GLAPI void APIENTRY glNamedBufferData (GLuint buffer, GLsizeiptr size, const 
void *data, GLenum usage);
 GLAPI void APIENTRY glNamedBufferSubData (GLuint buffer, GLintptr offset, 
GLsizei size, const void *data);
 GLAPI void APIENTRY glCopyNamedBufferSubData (GLuint readBuffer, GLuint 
writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizei size);
 GLAPI void APIENTRY glClearNamedBufferData (GLuint buffer, GLenum 
internalformat, GLenum format, GLenum type, const void *data);
-- 
2.1.0

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


[Mesa-dev] [PATCH 04/21] main: Add entry point for NamedBufferStorage.

2015-01-21 Thread Laura Ekstrand
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  7 +++
 src/mesa/main/bufferobj.c  | 63 +++---
 src/mesa/main/bufferobj.h  |  9 
 src/mesa/main/tests/dispatch_sanity.cpp|  1 +
 4 files changed, 64 insertions(+), 16 deletions(-)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 6c9d0e8..ff81c21 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -14,6 +14,13 @@
   param name=buffers type=GLuint * /
/function
 
+   function name=NamedBufferStorage offset=assign
+  param name=buffer type=GLuint /
+  param name=size type=GLsizeiptr /
+  param name=data type=const GLvoid * /
+  param name=flags type=GLbitfield /
+   /function
+
!-- Texture object functions --
 
function name=CreateTextures offset=assign
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 8653500..0977459 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1386,15 +1386,13 @@ _mesa_IsBuffer(GLuint id)
 }
 
 
-void GLAPIENTRY
-_mesa_BufferStorage(GLenum target, GLsizeiptr size, const GLvoid *data,
-GLbitfield flags)
+void
+_mesa_buffer_storage(struct gl_context *ctx, struct gl_buffer_object *bufObj,
+ GLenum target, GLsizeiptr size, const GLvoid *data,
+ GLbitfield flags, const char *func)
 {
-   GET_CURRENT_CONTEXT(ctx);
-   struct gl_buffer_object *bufObj;
-
if (size = 0) {
-  _mesa_error(ctx, GL_INVALID_VALUE, glBufferStorage(size = 0));
+  _mesa_error(ctx, GL_INVALID_VALUE, %s(size = 0), func);
   return;
}
 
@@ -1404,27 +1402,25 @@ _mesa_BufferStorage(GLenum target, GLsizeiptr size, 
const GLvoid *data,
  GL_MAP_COHERENT_BIT |
  GL_DYNAMIC_STORAGE_BIT |
  GL_CLIENT_STORAGE_BIT)) {
-  _mesa_error(ctx, GL_INVALID_VALUE, glBufferStorage(flags));
+  _mesa_error(ctx, GL_INVALID_VALUE, %s(invalid flag bits set), func);
   return;
}
 
if (flags  GL_MAP_PERSISTENT_BIT 
!(flags  (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT))) {
-  _mesa_error(ctx, GL_INVALID_VALUE, glBufferStorage(flags!=READ/WRITE));
+  _mesa_error(ctx, GL_INVALID_VALUE,
+  %s(PERSISTENT and flags!=READ/WRITE), func);
   return;
}
 
if (flags  GL_MAP_COHERENT_BIT  !(flags  GL_MAP_PERSISTENT_BIT)) {
-  _mesa_error(ctx, GL_INVALID_VALUE, glBufferStorage(flags!=PERSISTENT));
+  _mesa_error(ctx, GL_INVALID_VALUE,
+  %s(COHERENT and flags!=PERSISTENT), func);
   return;
}
 
-   bufObj = get_buffer(ctx, glBufferStorage, target, GL_INVALID_OPERATION);
-   if (!bufObj)
-  return;
-
if (bufObj-Immutable) {
-  _mesa_error(ctx, GL_INVALID_OPERATION, glBufferStorage(immutable));
+  _mesa_error(ctx, GL_INVALID_OPERATION, %s(immutable), func);
   return;
}
 
@@ -1439,10 +1435,45 @@ _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());
+  _mesa_error(ctx, GL_OUT_OF_MEMORY, %s(), func);
}
 }
 
+void GLAPIENTRY
+_mesa_BufferStorage(GLenum target, GLsizeiptr size, const GLvoid *data,
+GLbitfield flags)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_buffer_object *bufObj;
+
+   bufObj = get_buffer(ctx, glBufferStorage, target, GL_INVALID_OPERATION);
+   if (!bufObj)
+  return;
+
+   _mesa_buffer_storage(ctx, bufObj, target, size, data, flags,
+glBufferStorage);
+}
+
+void GLAPIENTRY
+_mesa_NamedBufferStorage(GLuint buffer, GLsizeiptr size, const GLvoid *data,
+ GLbitfield flags)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_buffer_object *bufObj;
+
+   bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, glNamedBufferStorage);
+   if (!bufObj)
+  return;
+
+   /*
+* In direct state access, buffer objects have an unspecified target since
+* they are not required to be bound.
+*/
+   _mesa_buffer_storage(ctx, bufObj, GL_NONE, size, data, flags,
+glNamedBufferStorage);
+}
+
+
 
 void GLAPIENTRY
 _mesa_BufferData(GLenum target, GLsizeiptrARB size,
diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
index 665d843..0537bd4 100644
--- a/src/mesa/main/bufferobj.h
+++ b/src/mesa/main/bufferobj.h
@@ -130,6 +130,11 @@ extern void
 _mesa_init_buffer_object_functions(struct dd_function_table *driver);
 
 extern void
+_mesa_buffer_storage(struct gl_context *ctx, struct gl_buffer_object *bufObj,
+ GLenum target, GLsizeiptr size, const GLvoid *data,
+ GLbitfield flags, const char *func);
+
+extern 

[Mesa-dev] [PATCH 07/21] GL: Correct function arguments for glNamedBufferSubData.

2015-01-21 Thread Laura Ekstrand
---
 include/GL/glext.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/GL/glext.h b/include/GL/glext.h
index 0bc9e98..3f141a2 100644
--- a/include/GL/glext.h
+++ b/include/GL/glext.h
@@ -2737,7 +2737,7 @@ GLAPI void APIENTRY glGetTransformFeedbacki64_v (GLuint 
xfb, GLenum pname, GLuin
 GLAPI void APIENTRY glCreateBuffers (GLsizei n, GLuint *buffers);
 GLAPI void APIENTRY glNamedBufferStorage (GLuint buffer, GLsizeiptr size, 
const void *data, GLbitfield flags);
 GLAPI void APIENTRY glNamedBufferData (GLuint buffer, GLsizeiptr size, const 
void *data, GLenum usage);
-GLAPI void APIENTRY glNamedBufferSubData (GLuint buffer, GLintptr offset, 
GLsizei size, const void *data);
+GLAPI void APIENTRY glNamedBufferSubData (GLuint buffer, GLintptr offset, 
GLsizeiptr size, const void *data);
 GLAPI void APIENTRY glCopyNamedBufferSubData (GLuint readBuffer, GLuint 
writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizei size);
 GLAPI void APIENTRY glClearNamedBufferData (GLuint buffer, GLenum 
internalformat, GLenum format, GLenum type, const void *data);
 GLAPI void APIENTRY glClearNamedBufferSubData (GLuint buffer, GLenum 
internalformat, GLintptr offset, GLsizei size, GLenum format, GLenum type, 
const void *data);
-- 
2.1.0

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


[Mesa-dev] [PATCH 13/21] GL: Correct function arguments for MapNamedBufferRange.

2015-01-21 Thread Laura Ekstrand
---
 include/GL/glext.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/GL/glext.h b/include/GL/glext.h
index 2543d1b..bca1b6e 100644
--- a/include/GL/glext.h
+++ b/include/GL/glext.h
@@ -2742,7 +2742,7 @@ GLAPI void APIENTRY glCopyNamedBufferSubData (GLuint 
readBuffer, GLuint writeBuf
 GLAPI void APIENTRY glClearNamedBufferData (GLuint buffer, GLenum 
internalformat, GLenum format, GLenum type, const void *data);
 GLAPI void APIENTRY glClearNamedBufferSubData (GLuint buffer, GLenum 
internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, 
const void *data);
 GLAPI void *APIENTRY glMapNamedBuffer (GLuint buffer, GLenum access);
-GLAPI void *APIENTRY glMapNamedBufferRange (GLuint buffer, GLintptr offset, 
GLsizei length, GLbitfield access);
+GLAPI void *APIENTRY glMapNamedBufferRange (GLuint buffer, GLintptr offset, 
GLsizeiptr length, GLbitfield access);
 GLAPI GLboolean APIENTRY glUnmapNamedBuffer (GLuint buffer);
 GLAPI void APIENTRY glFlushMappedNamedBufferRange (GLuint buffer, GLintptr 
offset, GLsizei length);
 GLAPI void APIENTRY glGetNamedBufferParameteriv (GLuint buffer, GLenum pname, 
GLint *params);
-- 
2.1.0

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


[Mesa-dev] [PATCH 06/21] main: Add entry point for NamedBufferData.

2015-01-21 Thread Laura Ekstrand
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  9 ++-
 src/mesa/main/bufferobj.c  | 77 --
 src/mesa/main/bufferobj.h  | 13 -
 src/mesa/main/tests/dispatch_sanity.cpp|  1 +
 4 files changed, 69 insertions(+), 31 deletions(-)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index ff81c21..4b1ef6f 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -21,7 +21,14 @@
   param name=flags type=GLbitfield /
/function
 
-   !-- Texture object functions --
+   function name=NamedBufferData offset=assign
+  param name=buffer type=GLuint /
+  param name=size type=GLsizeiptr /
+  param name=data type=const GLvoid * /
+  param name=usage type=GLenum /
+   /function
+
+  !-- Texture object functions --
 
function name=CreateTextures offset=assign
   param name=target type=GLenum /
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 0977459..c77029f 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -556,9 +556,9 @@ _mesa_total_buffer_object_memory(struct gl_context *ctx)
  * \sa glBufferDataARB, dd_function_table::BufferData.
  */
 static GLboolean
-_mesa_buffer_data( struct gl_context *ctx, GLenum target, GLsizeiptrARB size,
-  const GLvoid * data, GLenum usage, GLenum storageFlags,
-  struct gl_buffer_object * bufObj )
+_mesa_BufferData_sw(struct gl_context *ctx, GLenum target, GLsizeiptr size,
+const GLvoid *data, GLenum usage, GLenum storageFlags,
+struct gl_buffer_object *bufObj)
 {
void * new_data;
 
@@ -1112,7 +1112,7 @@ _mesa_init_buffer_object_functions(struct 
dd_function_table *driver)
/* GL_ARB_vertex/pixel_buffer_object */
driver-NewBufferObject = _mesa_new_buffer_object;
driver-DeleteBuffer = _mesa_delete_buffer_object;
-   driver-BufferData = _mesa_buffer_data;
+   driver-BufferData = _mesa_BufferData_sw;
driver-BufferSubData = _mesa_buffer_subdata;
driver-GetBufferSubData = _mesa_buffer_get_subdata;
driver-UnmapBuffer = _mesa_buffer_unmap;
@@ -1474,23 +1474,22 @@ _mesa_NamedBufferStorage(GLuint buffer, GLsizeiptr 
size, const GLvoid *data,
 }
 
 
-
-void GLAPIENTRY
-_mesa_BufferData(GLenum target, GLsizeiptrARB size,
-const GLvoid * data, GLenum usage)
+void
+_mesa_buffer_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,
+  GLenum target, GLsizeiptr size, const GLvoid *data,
+  GLenum usage, const char *func)
 {
-   GET_CURRENT_CONTEXT(ctx);
-   struct gl_buffer_object *bufObj;
bool valid_usage;
 
if (MESA_VERBOSE  VERBOSE_API)
-  _mesa_debug(ctx, glBufferData(%s, %ld, %p, %s)\n,
+  _mesa_debug(ctx, %s(%s, %ld, %p, %s)\n,
+  func,
   _mesa_lookup_enum_by_nr(target),
   (long int) size, data,
   _mesa_lookup_enum_by_nr(usage));
 
if (size  0) {
-  _mesa_error(ctx, GL_INVALID_VALUE, glBufferDataARB(size  0));
+  _mesa_error(ctx, GL_INVALID_VALUE, %s(size  0), func);
   return;
}
 
@@ -1519,16 +1518,13 @@ _mesa_BufferData(GLenum target, GLsizeiptrARB size,
}
 
if (!valid_usage) {
-  _mesa_error(ctx, GL_INVALID_ENUM, glBufferData(usage));
+  _mesa_error(ctx, GL_INVALID_ENUM, %s(invalid usage: %s), func,
+  _mesa_lookup_enum_by_nr(usage));
   return;
}
 
-   bufObj = get_buffer(ctx, glBufferDataARB, target, GL_INVALID_OPERATION);
-   if (!bufObj)
-  return;
-
if (bufObj-Immutable) {
-  _mesa_error(ctx, GL_INVALID_OPERATION, glBufferData(immutable));
+  _mesa_error(ctx, GL_INVALID_OPERATION, %s(immutable), func);
   return;
}
 
@@ -1539,25 +1535,50 @@ _mesa_BufferData(GLenum target, GLsizeiptrARB size,
 
bufObj-Written = GL_TRUE;
 
-#ifdef VBO_DEBUG
-   printf(glBufferDataARB(%u, sz %ld, from %p, usage 0x%x)\n,
-bufObj-Name, size, data, usage);
-#endif
-
-#ifdef BOUNDS_CHECK
-   size += 100;
-#endif
-
ASSERT(ctx-Driver.BufferData);
if (!ctx-Driver.BufferData(ctx, target, size, data, usage,
GL_MAP_READ_BIT |
GL_MAP_WRITE_BIT |
GL_DYNAMIC_STORAGE_BIT,
bufObj)) {
-  _mesa_error(ctx, GL_OUT_OF_MEMORY, glBufferDataARB());
+  _mesa_error(ctx, GL_OUT_OF_MEMORY, %s, func);
}
 }
 
+void GLAPIENTRY
+_mesa_BufferData(GLenum target, GLsizeiptr size,
+ const GLvoid *data, GLenum usage)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_buffer_object *bufObj;
+
+   bufObj = get_buffer(ctx, glBufferData, target, GL_INVALID_OPERATION);
+   if (!bufObj)
+  return;
+
+   _mesa_buffer_data(ctx, bufObj, target, size, data, usage,
+   

[Mesa-dev] [PATCH 02/21] main: Add entry point for CreateBuffers.

2015-01-21 Thread Laura Ekstrand
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  7 +++
 src/mesa/main/bufferobj.c  | 65 --
 src/mesa/main/bufferobj.h  |  5 +-
 src/mesa/main/tests/dispatch_sanity.cpp|  1 +
 4 files changed, 64 insertions(+), 14 deletions(-)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 86c00f9..6c9d0e8 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -7,6 +7,13 @@
enum name=QUERY_TARGETvalue=0x82EA/
enum name=TEXTURE_BINDING value=0x82EB/
 
+   !-- Buffer object functions --
+
+   function name=CreateBuffers offset=assign
+  param name=n type=GLsizei /
+  param name=buffers type=GLuint * /
+   /function
+
!-- Texture object functions --
 
function name=CreateTextures offset=assign
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index aea7f1d..8653500 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1283,27 +1283,29 @@ _mesa_DeleteBuffers(GLsizei n, const GLuint *ids)
 
 
 /**
- * Generate a set of unique buffer object IDs and store them in \c buffer.
- * 
- * \param n   Number of IDs to generate.
- * \param buffer  Array of \c n locations to store the IDs.
+ * This is the implementation for glGenBuffers and glCreateBuffers. It is not
+ * exposed to the rest of Mesa to encourage the use of nameless buffers in
+ * driver internals.
  */
-void GLAPIENTRY
-_mesa_GenBuffers(GLsizei n, GLuint *buffer)
+static void
+create_buffers(GLsizei n, GLuint *buffers, bool dsa)
 {
GET_CURRENT_CONTEXT(ctx);
GLuint first;
GLint i;
+   struct gl_buffer_object *buf;
+
+   const char *func = dsa ? glCreateBuffers : glGenBuffers;
 
if (MESA_VERBOSE  VERBOSE_API)
-  _mesa_debug(ctx, glGenBuffers(%d)\n, n);
+  _mesa_debug(ctx, %s(%d)\n, func, n);
 
if (n  0) {
-  _mesa_error(ctx, GL_INVALID_VALUE, glGenBuffersARB);
+  _mesa_error(ctx, GL_INVALID_VALUE, %s(n %d  0), func, n);
   return;
}
 
-   if (!buffer) {
+   if (!buffers) {
   return;
}
 
@@ -1314,16 +1316,53 @@ _mesa_GenBuffers(GLsizei n, GLuint *buffer)
 
first = _mesa_HashFindFreeKeyBlock(ctx-Shared-BufferObjects, n);
 
-   /* Insert the ID and pointer to dummy buffer object into hash table */
+   /* Insert the ID and pointer into the hash table. If non-DSA, insert a
+* DummyBufferObject.  Otherwise, create a new buffer object and insert
+* it.
+*/
for (i = 0; i  n; i++) {
-  _mesa_HashInsert(ctx-Shared-BufferObjects, first + i,
-   DummyBufferObject);
-  buffer[i] = first + i;
+  buffers[i] = first + i;
+  if (dsa) {
+ ASSERT(ctx-Driver.NewBufferObject);
+ buf = ctx-Driver.NewBufferObject(ctx, buffers[i]);
+ if (!buf) {
+_mesa_error(ctx, GL_OUT_OF_MEMORY, %s, func);
+return;
+ }
+  }
+  else
+ buf = DummyBufferObject;
+
+  _mesa_HashInsert(ctx-Shared-BufferObjects, buffers[i], buf);
}
 
mtx_unlock(ctx-Shared-Mutex);
 }
 
+/**
+ * Generate a set of unique buffer object IDs and store them in \c buffers.
+ *
+ * \param nNumber of IDs to generate.
+ * \param buffers  Array of \c n locations to store the IDs.
+ */
+void GLAPIENTRY
+_mesa_GenBuffers(GLsizei n, GLuint *buffers)
+{
+   create_buffers(n, buffers, false);
+}
+
+/**
+ * Create a set of buffer objects and store their unique IDs in \c buffers.
+ *
+ * \param nNumber of IDs to generate.
+ * \param buffers  Array of \c n locations to store the IDs.
+ */
+void GLAPIENTRY
+_mesa_CreateBuffers(GLsizei n, GLuint *buffers)
+{
+   create_buffers(n, buffers, true);
+}
+
 
 /**
  * Determine if ID is the name of a buffer object.
diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h
index b4e1c10..665d843 100644
--- a/src/mesa/main/bufferobj.h
+++ b/src/mesa/main/bufferobj.h
@@ -150,7 +150,10 @@ void GLAPIENTRY
 _mesa_DeleteBuffers(GLsizei n, const GLuint * buffer);
 
 void GLAPIENTRY
-_mesa_GenBuffers(GLsizei n, GLuint * buffer);
+_mesa_GenBuffers(GLsizei n, GLuint *buffers);
+
+void GLAPIENTRY
+_mesa_CreateBuffers(GLsizei n, GLuint *buffers);
 
 GLboolean GLAPIENTRY
 _mesa_IsBuffer(GLuint buffer);
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index 39d255d..af9054a 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -955,6 +955,7 @@ const struct function gl_core_functions_possible[] = {
{ glClipControl, 45, -1 },
 
/* GL_ARB_direct_state_access */
+   { glCreateBuffers, 45, -1 },
{ glCreateTextures, 45, -1 },
{ glTextureStorage1D, 45, -1 },
{ glTextureStorage2D, 45, -1 },
-- 
2.1.0

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

[Mesa-dev] [PATCH 01/21] main: Add utility function _mesa_lookup_bufferobj_err().

2015-01-21 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..aea7f1d 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 *func)
+{
+   struct gl_buffer_object *bufObj;
+
+   bufObj = _mesa_lookup_bufferobj(ctx, buffer);
+   if (!bufObj)
+  _mesa_error(ctx, GL_INVALID_OPERATION, %s(non-generated buffer name),
+  func);
+
+   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..b4e1c10 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 *func);
+
 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 03/21] GL: Correct function arguments for NamedBufferStorage.

2015-01-21 Thread Laura Ekstrand
---
 include/GL/glext.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/GL/glext.h b/include/GL/glext.h
index 88505b0..1ffe576 100644
--- a/include/GL/glext.h
+++ b/include/GL/glext.h
@@ -2735,7 +2735,7 @@ GLAPI void APIENTRY glGetTransformFeedbackiv (GLuint xfb, 
GLenum pname, GLint *p
 GLAPI void APIENTRY glGetTransformFeedbacki_v (GLuint xfb, GLenum pname, 
GLuint index, GLint *param);
 GLAPI void APIENTRY glGetTransformFeedbacki64_v (GLuint xfb, GLenum pname, 
GLuint index, GLint64 *param);
 GLAPI void APIENTRY glCreateBuffers (GLsizei n, GLuint *buffers);
-GLAPI void APIENTRY glNamedBufferStorage (GLuint buffer, GLsizei size, const 
void *data, GLbitfield flags);
+GLAPI void APIENTRY glNamedBufferStorage (GLuint buffer, GLsizeiptr size, 
const void *data, GLbitfield flags);
 GLAPI void APIENTRY glNamedBufferData (GLuint buffer, GLsizei size, const void 
*data, GLenum usage);
 GLAPI void APIENTRY glNamedBufferSubData (GLuint buffer, GLintptr offset, 
GLsizei size, const void *data);
 GLAPI void APIENTRY glCopyNamedBufferSubData (GLuint readBuffer, GLuint 
writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizei size);
-- 
2.1.0

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


Re: [Mesa-dev] [PATCH 06/21] main: Add entry point for NamedBufferData.

2015-01-21 Thread Ian Romanick
On 01/21/2015 05:40 PM, Laura Ekstrand wrote:
 ---
  src/mapi/glapi/gen/ARB_direct_state_access.xml |  9 ++-
  src/mesa/main/bufferobj.c  | 77 
 --
  src/mesa/main/bufferobj.h  | 13 -
  src/mesa/main/tests/dispatch_sanity.cpp|  1 +
  4 files changed, 69 insertions(+), 31 deletions(-)
 
 diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
 b/src/mapi/glapi/gen/ARB_direct_state_access.xml
 index ff81c21..4b1ef6f 100644
 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
 +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
 @@ -21,7 +21,14 @@
param name=flags type=GLbitfield /
 /function
  
 -   !-- Texture object functions --
 +   function name=NamedBufferData offset=assign
 +  param name=buffer type=GLuint /
 +  param name=size type=GLsizeiptr /
 +  param name=data type=const GLvoid * /
 +  param name=usage type=GLenum /
 +   /function
 +
 +  !-- Texture object functions --

I think you accidentally deleted a space before this comment.

  
 function name=CreateTextures offset=assign
param name=target type=GLenum /
 diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
 index 0977459..c77029f 100644
 --- a/src/mesa/main/bufferobj.c
 +++ b/src/mesa/main/bufferobj.c
 @@ -556,9 +556,9 @@ _mesa_total_buffer_object_memory(struct gl_context *ctx)
   * \sa glBufferDataARB, dd_function_table::BufferData.
   */
  static GLboolean
 -_mesa_buffer_data( struct gl_context *ctx, GLenum target, GLsizeiptrARB size,
 -const GLvoid * data, GLenum usage, GLenum storageFlags,
 -struct gl_buffer_object * bufObj )
 +_mesa_BufferData_sw(struct gl_context *ctx, GLenum target, GLsizeiptr size,
 +const GLvoid *data, GLenum usage, GLenum storageFlags,
 +struct gl_buffer_object *bufObj)

We should pick a different name for this.  Names with this pattern are
(almost exclusively) direct API entry points.  Maybe _swrast_buffer_data?

Alternately, if the new _mesa_buffer_data will only ever be called
from the same file, we could just call that buffer_data and make it static.

  {
 void * new_data;
  
 @@ -1112,7 +1112,7 @@ _mesa_init_buffer_object_functions(struct 
 dd_function_table *driver)
 /* GL_ARB_vertex/pixel_buffer_object */
 driver-NewBufferObject = _mesa_new_buffer_object;
 driver-DeleteBuffer = _mesa_delete_buffer_object;
 -   driver-BufferData = _mesa_buffer_data;
 +   driver-BufferData = _mesa_BufferData_sw;
 driver-BufferSubData = _mesa_buffer_subdata;
 driver-GetBufferSubData = _mesa_buffer_get_subdata;
 driver-UnmapBuffer = _mesa_buffer_unmap;
 @@ -1474,23 +1474,22 @@ _mesa_NamedBufferStorage(GLuint buffer, GLsizeiptr 
 size, const GLvoid *data,
  }
  
  
 -
 -void GLAPIENTRY
 -_mesa_BufferData(GLenum target, GLsizeiptrARB size,
 -const GLvoid * data, GLenum usage)
 +void
 +_mesa_buffer_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,
 +  GLenum target, GLsizeiptr size, const GLvoid *data,
 +  GLenum usage, const char *func)
  {
 -   GET_CURRENT_CONTEXT(ctx);
 -   struct gl_buffer_object *bufObj;
 bool valid_usage;
  
 if (MESA_VERBOSE  VERBOSE_API)
 -  _mesa_debug(ctx, glBufferData(%s, %ld, %p, %s)\n,
 +  _mesa_debug(ctx, %s(%s, %ld, %p, %s)\n,
 +  func,
_mesa_lookup_enum_by_nr(target),
(long int) size, data,
_mesa_lookup_enum_by_nr(usage));
  
 if (size  0) {
 -  _mesa_error(ctx, GL_INVALID_VALUE, glBufferDataARB(size  0));
 +  _mesa_error(ctx, GL_INVALID_VALUE, %s(size  0), func);
return;
 }
  
 @@ -1519,16 +1518,13 @@ _mesa_BufferData(GLenum target, GLsizeiptrARB size,
 }
  
 if (!valid_usage) {
 -  _mesa_error(ctx, GL_INVALID_ENUM, glBufferData(usage));
 +  _mesa_error(ctx, GL_INVALID_ENUM, %s(invalid usage: %s), func,
 +  _mesa_lookup_enum_by_nr(usage));
return;
 }
  
 -   bufObj = get_buffer(ctx, glBufferDataARB, target, GL_INVALID_OPERATION);
 -   if (!bufObj)
 -  return;
 -
 if (bufObj-Immutable) {
 -  _mesa_error(ctx, GL_INVALID_OPERATION, glBufferData(immutable));
 +  _mesa_error(ctx, GL_INVALID_OPERATION, %s(immutable), func);
return;
 }
  
 @@ -1539,25 +1535,50 @@ _mesa_BufferData(GLenum target, GLsizeiptrARB size,
  
 bufObj-Written = GL_TRUE;
  
 -#ifdef VBO_DEBUG
 -   printf(glBufferDataARB(%u, sz %ld, from %p, usage 0x%x)\n,
 -bufObj-Name, size, data, usage);
 -#endif
 -
 -#ifdef BOUNDS_CHECK
 -   size += 100;
 -#endif
 -

This change by itself is not okay.  If someone builds with BOUNDS_CHECK
defined, the code in _mesa_MapBuffer and _mesa_UnmapBuffer will explode.
 I don't know how much utility there is to BOUNDS_CHECK or VBO_DEBUG.
I'd be inclined to send separate patches that completely remove each 

Re: [Mesa-dev] [PATCH 08/21] main: Add entry point for NamedBufferSubData.

2015-01-21 Thread Ian Romanick
On 01/21/2015 05:40 PM, Laura Ekstrand wrote:
 ---
  src/mapi/glapi/gen/ARB_direct_state_access.xml |   7 ++
  src/mesa/main/bufferobj.c  | 150 
 -
  src/mesa/main/bufferobj.h  |  13 ++-
  src/mesa/main/tests/dispatch_sanity.cpp|   1 +
  4 files changed, 113 insertions(+), 58 deletions(-)
 
 diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
 b/src/mapi/glapi/gen/ARB_direct_state_access.xml
 index 4b1ef6f..8a5cebb 100644
 --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
 +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
 @@ -28,6 +28,13 @@
param name=usage type=GLenum /
 /function
  
 +   function name=NamedBufferSubData offset=assign
 +  param name=buffer type=GLuint /
 +  param name=offset type=GLintptr /
 +  param name=size type=GLsizeiptr /
 +  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 c77029f..20c2cdc 100644
 --- a/src/mesa/main/bufferobj.c
 +++ b/src/mesa/main/bufferobj.c
 @@ -227,67 +227,62 @@ bufferobj_range_mapped(const struct gl_buffer_object 
 *obj,
   * \c glClearBufferSubData.
   *
   * \param ctx GL context.
 - * \param target  Buffer object target on which to operate.
 + * \param bufObj  The buffer object.
   * \param offset  Offset of the first byte of the subdata range.
   * \param sizeSize, in bytes, of the subdata range.
   * \param mappedRange  If true, checks if an overlapping range is mapped.
   * If false, checks if buffer is mapped.
 - * \param errorNoBuffer  Error code if no buffer is bound to target.
 - * \param caller  Name of calling function for recording errors.
 - * \return   A pointer to the buffer object bound to \c target in the
 - *   specified context or \c NULL if any of the parameter or state
 - *   conditions are invalid.
 + * \param func  Name of calling function for recording errors.
 + * \return   false if error, true otherwise
   *
   * \sa glBufferSubDataARB, glGetBufferSubDataARB, glClearBufferSubData
   */
 -static struct gl_buffer_object *
 -buffer_object_subdata_range_good(struct gl_context * ctx, GLenum target,
 - GLintptrARB offset, GLsizeiptrARB size,
 - bool mappedRange, GLenum errorNoBuffer,
 - const char *caller)
 +static bool
 +buffer_object_subdata_range_good(struct gl_context *ctx,
 + struct gl_buffer_object *bufObj,
 + GLintptr offset, GLsizeiptr size,
 + bool mappedRange, const char *func)

Many places in Mesa use 'caller'.  This feels like a spurious change in
this patch.  If we want to unify on a single name, there should be a
patch that changes all the occurrences of 'func', 'caller', and
'function' to that single name.

  {
 -   struct gl_buffer_object *bufObj;
 -
 if (size  0) {
 -  _mesa_error(ctx, GL_INVALID_VALUE, %s(size  0), caller);
 -  return NULL;
 +  _mesa_error(ctx, GL_INVALID_VALUE, %s(size  0), func);
 +  return false;
 }
  
 if (offset  0) {
 -  _mesa_error(ctx, GL_INVALID_VALUE, %s(offset  0), caller);
 -  return NULL;
 +  _mesa_error(ctx, GL_INVALID_VALUE, %s(offset  0), func);
 +  return false;
 }
  
 -   bufObj = get_buffer(ctx, caller, target, errorNoBuffer);
 -   if (!bufObj)
 -  return NULL;
 -
 if (offset + size  bufObj-Size) {
_mesa_error(ctx, GL_INVALID_VALUE,
 -  %s(offset %lu + size %lu  buffer size %lu), caller,
 +  %s(offset %lu + size %lu  buffer size %lu), func,
(unsigned long) offset,
(unsigned long) size,
(unsigned long) bufObj-Size);
 -  return NULL;
 +  return false;
 }
  
 if (bufObj-Mappings[MAP_USER].AccessFlags  GL_MAP_PERSISTENT_BIT)
 -  return bufObj;
 +  return true;
  
 if (mappedRange) {
if (bufferobj_range_mapped(bufObj, offset, size)) {
 - _mesa_error(ctx, GL_INVALID_OPERATION, %s, caller);
 - return NULL;
 + _mesa_error(ctx, GL_INVALID_OPERATION,
 + %s(range is mapped without GL_MAP_PERSISTENT_BIT),

I don't understand why this error text was added here or below.  If it
is correct, it also seems like it should be a separate patch that
includes justification in the commit message.

 + func);
 + return false;
}
 }
 else {
if (_mesa_bufferobj_mapped(bufObj, MAP_USER)) {
 - _mesa_error(ctx, GL_INVALID_OPERATION, %s, caller);
 - return NULL;
 + _mesa_error(ctx, GL_INVALID_OPERATION,
 + %s(buffer is mapped without GL_MAP_PERSISTENT_BIT),
 + 

Re: [Mesa-dev] [PATCH 3/5] nir: Fix setup of constant bool initializers.

2015-01-21 Thread Jason Ekstrand
Connor wrote *exactly* the same patch:

http://lists.freedesktop.org/archives/mesa-dev/2015-January/074522.html

This version can have my R-B too.  And, fwiw, I like your commit message
better.

On Wed, Jan 21, 2015 at 5:25 PM, Eric Anholt e...@anholt.net wrote:

 brw_fs_nir has only seen scalar bools so far, thanks to vector splitting,
 and the ralloc of in glsl_to_nir.cpp will *usually* get you a 0-filled
 chunk of memory, so reading too large of a value will usually get you the
 right bool value.  But once we start doing vector bools in a few commits,
 we end up getting bad values.
 ---
  src/glsl/nir/nir_lower_vars_to_ssa.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/src/glsl/nir/nir_lower_vars_to_ssa.c
 b/src/glsl/nir/nir_lower_vars_to_ssa.c
 index 089f0d5..03967e3 100644
 --- a/src/glsl/nir/nir_lower_vars_to_ssa.c
 +++ b/src/glsl/nir/nir_lower_vars_to_ssa.c
 @@ -600,7 +600,7 @@ get_const_initializer_load(const nir_deref_var *deref,
   load-value.u[i] = constant-value.u[matrix_offset + i];
   break;
case GLSL_TYPE_BOOL:
 - load-value.u[i] = constant-value.u[matrix_offset + i] ?
 + load-value.u[i] = constant-value.b[matrix_offset + i] ?
   NIR_TRUE : NIR_FALSE;
   break;
default:
 --
 2.1.3

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

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


[Mesa-dev] [PATCH 3/5] nir: Fix setup of constant bool initializers.

2015-01-21 Thread Eric Anholt
brw_fs_nir has only seen scalar bools so far, thanks to vector splitting,
and the ralloc of in glsl_to_nir.cpp will *usually* get you a 0-filled
chunk of memory, so reading too large of a value will usually get you the
right bool value.  But once we start doing vector bools in a few commits,
we end up getting bad values.
---
 src/glsl/nir/nir_lower_vars_to_ssa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/glsl/nir/nir_lower_vars_to_ssa.c 
b/src/glsl/nir/nir_lower_vars_to_ssa.c
index 089f0d5..03967e3 100644
--- a/src/glsl/nir/nir_lower_vars_to_ssa.c
+++ b/src/glsl/nir/nir_lower_vars_to_ssa.c
@@ -600,7 +600,7 @@ get_const_initializer_load(const nir_deref_var *deref,
  load-value.u[i] = constant-value.u[matrix_offset + i];
  break;
   case GLSL_TYPE_BOOL:
- load-value.u[i] = constant-value.u[matrix_offset + i] ?
+ load-value.u[i] = constant-value.b[matrix_offset + i] ?
  NIR_TRUE : NIR_FALSE;
  break;
   default:
-- 
2.1.3

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


[Mesa-dev] [PATCH 5/5] nir: Add nir_lower_alu_scalar.

2015-01-21 Thread Eric Anholt
This is the equivalent of brw_fs_channel_expressions.cpp, which I wanted
for vc4.
---

This series, plus a commit to make i965 use it instead of channel_expressions,
is on the nir-scalarize branch of my mesa tree.  With the whole series, there
are 6 regressions, 3 of which are due to lower-vec-to-movs being broken when
faced with r0 = vec4 r0.yxxx, r0., r0.zxxx, r0.wxxx (fs-swap-problem
test, for example).  The other 3 are sampler-nonconst-2d-array and friends,
which I haven't figured out yet.

Full disclosure: I did a cleanup to use nir_alu_ssa_dest_init() more and
haven't repiglited since then.

The full i965 conversion has the following shader-db results for me,
presumably because of losing GLSL-IR-level optimizations due to not splitting
expressions in GLSL IR:

total instructions in shared programs: 137974 - 139306 (0.97%)
instructions in affected programs: 55959 - 57291 (2.38%)

src/glsl/Makefile.sources   |   1 +
 src/glsl/nir/nir.h  |   1 +
 src/glsl/nir/nir_lower_alu_scalar.c | 287 
 3 files changed, 289 insertions(+)
 create mode 100644 src/glsl/nir/nir_lower_alu_scalar.c

diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
index 6237627..9cd1a6a 100644
--- a/src/glsl/Makefile.sources
+++ b/src/glsl/Makefile.sources
@@ -24,6 +24,7 @@ NIR_FILES = \
$(GLSL_SRCDIR)/nir/nir_intrinsics.c \
$(GLSL_SRCDIR)/nir/nir_intrinsics.h \
$(GLSL_SRCDIR)/nir/nir_live_variables.c \
+   $(GLSL_SRCDIR)/nir/nir_lower_alu_scalar.c \
$(GLSL_SRCDIR)/nir/nir_lower_atomics.c \
$(GLSL_SRCDIR)/nir/nir_lower_global_vars_to_local.c \
$(GLSL_SRCDIR)/nir/nir_lower_locals_to_regs.c \
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index 7f0aa36..fb42d91 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -1521,6 +1521,7 @@ void nir_lower_vars_to_ssa(nir_shader *shader);
 void nir_remove_dead_variables(nir_shader *shader);
 
 void nir_lower_vec_to_movs(nir_shader *shader);
+void nir_lower_ops_scalar(nir_shader *shader);
 
 void nir_lower_samplers(nir_shader *shader,
 struct gl_shader_program *shader_program,
diff --git a/src/glsl/nir/nir_lower_alu_scalar.c 
b/src/glsl/nir/nir_lower_alu_scalar.c
new file mode 100644
index 000..e13ad1e
--- /dev/null
+++ b/src/glsl/nir/nir_lower_alu_scalar.c
@@ -0,0 +1,287 @@
+/*
+ * Copyright © 2014-2015 Broadcom
+ *
+ * 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 nir.h
+
+/** @file nir_lower_alu_scalar.c
+ *
+ * Replaces nir_alu_instr operations with more than one channel used in the
+ * arguments with individual per-channel operations.
+ */
+
+static void
+unsupported(nir_instr *instr)
+{
+   fprintf(stderr, Unsupported instruction in scalar lowering: );
+   nir_print_instr(instr, stderr);
+   fprintf(stderr, \n);
+   abort();
+}
+
+static void
+nir_alu_ssa_dest_init(nir_alu_instr *instr, unsigned num_components)
+{
+   nir_ssa_dest_init(instr-instr, instr-dest.dest, num_components, NULL);
+   instr-dest.write_mask = (1  num_components) - 1;
+}
+
+static void
+reduce_op_replace(nir_alu_instr *instr, nir_ssa_def *def, void *mem_ctx)
+{
+   assert(instr-dest.write_mask == 1);
+
+   if (instr-dest.dest.is_ssa) {
+  nir_src new_src;
+  new_src.is_ssa = true;
+  new_src.ssa = def;
+  nir_ssa_def_rewrite_uses(instr-dest.dest.ssa, new_src, mem_ctx);
+   } else {
+  nir_alu_instr *mov = nir_alu_instr_create(mem_ctx, nir_op_imov);
+  mov-src[0].src.is_ssa = true;
+  mov-src[0].src.ssa = def;
+
+  nir_alu_dest_copy(mov-dest, instr-dest, mem_ctx);
+  nir_instr_insert_after(instr-instr, mov-instr);
+   }
+
+   nir_instr_remove(instr-instr);
+}
+
+static void
+lower_reduction(nir_alu_instr *instr, nir_op chan_op, nir_op merge_op,
+void *mem_ctx)
+{
+   unsigned num_components = nir_op_infos[instr-op].input_sizes[0];
+
+  

[Mesa-dev] [PATCH 2/5] nir: Make an easier helper for setting up SSA defs.

2015-01-21 Thread Eric Anholt
Almost all instructions we nir_ssa_def_init() for are nir_dests, and you
have to keep from forgetting to set is_ssa when you do.  Just provide the
simpler helper, instead.
---
 src/glsl/nir/glsl_to_nir.cpp| 14 --
 src/glsl/nir/nir.c  |  8 
 src/glsl/nir/nir.h  |  2 ++
 src/glsl/nir/nir_from_ssa.c | 10 --
 src/glsl/nir/nir_lower_atomics.c| 11 ---
 src/glsl/nir/nir_lower_io.c | 11 ---
 src/glsl/nir/nir_lower_locals_to_regs.c | 11 ---
 src/glsl/nir/nir_lower_system_values.c  |  5 ++---
 src/glsl/nir/nir_lower_var_copies.c |  3 +--
 src/glsl/nir/nir_lower_vars_to_ssa.c| 15 ++-
 src/glsl/nir/nir_opt_peephole_select.c  |  5 ++---
 src/glsl/nir/nir_search.c   |  8 +++-
 src/glsl/nir/nir_to_ssa.c   |  9 ++---
 13 files changed, 46 insertions(+), 66 deletions(-)

diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp
index 6ac830e..80bc4ba 100644
--- a/src/glsl/nir/glsl_to_nir.cpp
+++ b/src/glsl/nir/glsl_to_nir.cpp
@@ -618,8 +618,7 @@ nir_visitor::visit(ir_call *ir)
  (ir_dereference *) ir-actual_parameters.get_head();
   param-accept(this);
   instr-variables[0] = this-deref_head;
-  instr-dest.is_ssa = true;
-  nir_ssa_def_init(instr-instr, instr-dest.ssa, 1, NULL);
+  nir_ssa_dest_init(instr-instr, instr-dest, 1, NULL);
 
   nir_instr_insert_after_cf_list(this-cf_node_list, instr-instr);
 
@@ -702,9 +701,7 @@ nir_visitor::visit(ir_assignment *ir)
   nir_intrinsic_instr *load =
  nir_intrinsic_instr_create(this-shader, nir_intrinsic_load_var);
   load-num_components = ir-lhs-type-vector_elements;
-  load-dest.is_ssa = true;
-  nir_ssa_def_init(load-instr, load-dest.ssa,
-   num_components, NULL);
+  nir_ssa_dest_init(load-instr, load-dest, num_components, NULL);
   load-variables[0] = lhs_deref;
   nir_instr_insert_after_cf_list(this-cf_node_list, load-instr);
 
@@ -717,9 +714,7 @@ nir_visitor::visit(ir_assignment *ir)
  default: unreachable(Invalid number of components); break;
   }
   nir_alu_instr *vec = nir_alu_instr_create(this-shader, vec_op);
-  vec-dest.dest.is_ssa = true;
-  nir_ssa_def_init(vec-instr, vec-dest.dest.ssa,
-   num_components, NULL);
+  nir_ssa_dest_init(vec-instr, vec-dest.dest, num_components, NULL);
   vec-dest.write_mask = (1  num_components) - 1;
 
   unsigned component = 0;
@@ -805,8 +800,7 @@ nir_visitor::add_instr(nir_instr *instr, unsigned 
num_components)
 {
nir_dest *dest = get_instr_dest(instr);
 
-   dest-is_ssa = true;
-   nir_ssa_def_init(instr, dest-ssa, num_components, NULL);
+   nir_ssa_dest_init(instr, dest, num_components, NULL);
 
nir_instr_insert_after_cf_list(this-cf_node_list, instr);
this-result = instr;
diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
index 89e21fd..16ad2da 100644
--- a/src/glsl/nir/nir.c
+++ b/src/glsl/nir/nir.c
@@ -1791,6 +1791,14 @@ nir_ssa_def_init(nir_instr *instr, nir_ssa_def *def,
}
 }
 
+void
+nir_ssa_dest_init(nir_instr *instr, nir_dest *dest,
+ unsigned num_components, const char *name)
+{
+   dest-is_ssa = true;
+   nir_ssa_def_init(instr, dest-ssa, num_components, name);
+}
+
 struct ssa_def_rewrite_state {
void *mem_ctx;
nir_ssa_def *old;
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index 761f20a..8dc5222 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -1457,6 +1457,8 @@ nir_const_value *nir_src_as_const_value(nir_src src);
 bool nir_srcs_equal(nir_src src1, nir_src src2);
 void nir_instr_rewrite_src(nir_instr *instr, nir_src *src, nir_src new_src);
 
+void nir_ssa_dest_init(nir_instr *instr, nir_dest *dest,
+   unsigned num_components, const char *name);
 void nir_ssa_def_init(nir_instr *instr, nir_ssa_def *def,
   unsigned num_components, const char *name);
 void nir_ssa_def_rewrite_uses(nir_ssa_def *def, nir_src new_src, void 
*mem_ctx);
diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c
index 9728b99..88212a2 100644
--- a/src/glsl/nir/nir_from_ssa.c
+++ b/src/glsl/nir/nir_from_ssa.c
@@ -355,9 +355,8 @@ isolate_phi_nodes_block(nir_block *block, void *void_state)
  entry-src = nir_src_copy(src-src, state-dead_ctx);
  _mesa_set_add(src-src.ssa-uses, pcopy-instr);
 
- entry-dest.is_ssa = true;
- nir_ssa_def_init(pcopy-instr, entry-dest.ssa,
-  phi-dest.ssa.num_components, src-src.ssa-name);
+ nir_ssa_dest_init(pcopy-instr, entry-dest,
+   phi-dest.ssa.num_components, src-src.ssa-name);
 
  struct set_entry *use_entry =
 _mesa_set_search(src-src.ssa-uses, instr);
@@ -379,9 +378,8 @@ isolate_phi_nodes_block(nir_block *block, void *void_state)

[Mesa-dev] [PATCH 2.1/2] SQUASH nir: Get rid of more designated initializers

2015-01-21 Thread Jason Ekstrand
---
 src/glsl/nir/nir_search.c | 24 ++--
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/src/glsl/nir/nir_search.c b/src/glsl/nir/nir_search.c
index a7bd051..e69fdfd 100644
--- a/src/glsl/nir/nir_search.c
+++ b/src/glsl/nir/nir_search.c
@@ -221,13 +221,11 @@ construct_value(const nir_search_value *value, 
nir_alu_type type,
 
   nir_instr_insert_before(instr, alu-instr);
 
-  nir_alu_src val = {
- .src.is_ssa = true,
- .src.ssa = alu-dest.dest.ssa,
- .negate = false,
- .abs = false,
- .swizzle = { 0, 1, 2, 3 }
-  };
+  nir_alu_src val;
+  val.src = nir_src_for_ssa(alu-dest.dest.ssa);
+  val.negate = false;
+  val.abs = false,
+  memcpy(val.swizzle, identity_swizzle, sizeof val.swizzle);
 
   return val;
}
@@ -265,13 +263,11 @@ construct_value(const nir_search_value *value, 
nir_alu_type type,
 
   nir_instr_insert_before(instr, load-instr);
 
-  nir_alu_src val = {
- .src.is_ssa = true,
- .src.ssa = load-def,
- .negate = false,
- .abs = false,
- .swizzle = { 0, 0, 0, 0 } /* Splatted scalar */
-  };
+  nir_alu_src val;
+  val.src = nir_src_for_ssa(load-def);
+  val.negate = false;
+  val.abs = false,
+  memset(val.swizzle, 0, sizeof val.swizzle);
 
   return val;
}
-- 
2.2.1

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


[Mesa-dev] [PATCH 4/5] nir: Make some helpers for copying ALU src/dests.

2015-01-21 Thread Eric Anholt
There aren't many users yet, but I wanted to do this from my scalarizing
pass.
---
 src/glsl/nir/nir.c | 18 ++
 src/glsl/nir/nir.h |  5 -
 src/glsl/nir/nir_lower_vec_to_movs.c   |  7 ++-
 src/glsl/nir/nir_opt_peephole_select.c |  5 +
 4 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
index 16ad2da..e414df9 100644
--- a/src/glsl/nir/nir.c
+++ b/src/glsl/nir/nir.c
@@ -175,6 +175,24 @@ nir_dest nir_dest_copy(nir_dest dest, void *mem_ctx)
return ret;
 }
 
+void
+nir_alu_src_copy(nir_alu_src *dest, nir_alu_src *src, void *mem_ctx)
+{
+   dest-src = nir_src_copy(src-src, mem_ctx);
+   dest-abs = src-abs;
+   dest-negate = src-negate;
+   for (unsigned i = 0; i  4; i++)
+  dest-swizzle[i] = src-swizzle[i];
+}
+
+void
+nir_alu_dest_copy(nir_alu_dest *dest, nir_alu_dest *src, void *mem_ctx)
+{
+   dest-dest = nir_dest_copy(src-dest, mem_ctx);
+   dest-write_mask = src-write_mask;
+   dest-saturate = src-saturate;
+}
+
 static inline void
 block_add_pred(nir_block *block, nir_block *pred)
 {
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index 8dc5222..7f0aa36 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -569,7 +569,10 @@ typedef struct {
unsigned write_mask : 4; /* ignored if dest.is_ssa is true */
 } nir_alu_dest;
 
-#define OPCODE(name, num_inputs, output_size, output_type, \
+void nir_alu_src_copy(nir_alu_src *dest, nir_alu_src *src, void *mem_ctx);
+void nir_alu_dest_copy(nir_alu_dest *dest, nir_alu_dest *src, void *mem_ctx);
+
+#define OPCODE(name, num_inputs, output_size, output_type,  \
input_sizes, input_types, algebraic_props) \
nir_op_##name,
 
diff --git a/src/glsl/nir/nir_lower_vec_to_movs.c 
b/src/glsl/nir/nir_lower_vec_to_movs.c
index a3120b6..022889e 100644
--- a/src/glsl/nir/nir_lower_vec_to_movs.c
+++ b/src/glsl/nir/nir_lower_vec_to_movs.c
@@ -57,15 +57,12 @@ lower_vec_to_movs_block(nir_block *block, void *mem_ctx)
  assert(src_idx  nir_op_infos[vec-op].num_inputs);
 
  nir_alu_instr *mov = nir_alu_instr_create(mem_ctx, nir_op_imov);
- mov-src[0].src = nir_src_copy(vec-src[src_idx].src, mem_ctx);
- mov-src[0].negate = vec-src[src_idx].negate;
- mov-src[0].abs = vec-src[src_idx].abs;
+ nir_alu_src_copy(mov-src[0], vec-src[src_idx], mem_ctx);
 
  /* We only care about the one swizzle */
  mov-src[0].swizzle[i] = vec-src[src_idx].swizzle[0];
 
- mov-dest.dest = nir_dest_copy(vec-dest.dest, mem_ctx);
- mov-dest.saturate = vec-dest.saturate;
+ nir_alu_dest_copy(mov-dest, vec-dest, mem_ctx);
  mov-dest.write_mask = (1u  i);
 
  nir_instr_insert_before(vec-instr, mov-instr);
diff --git a/src/glsl/nir/nir_opt_peephole_select.c 
b/src/glsl/nir/nir_opt_peephole_select.c
index 023fae5..a5ac11f 100644
--- a/src/glsl/nir/nir_opt_peephole_select.c
+++ b/src/glsl/nir/nir_opt_peephole_select.c
@@ -154,10 +154,7 @@ nir_opt_peephole_select_block(nir_block *block, void 
*void_state)
 assert(mov-instr.type == nir_instr_type_alu);
 assert(mov-op == nir_op_fmov || mov-op == nir_op_imov);
 
-sel-src[idx].src = nir_src_copy(mov-src[0].src, state-mem_ctx);
-sel-src[idx].negate = mov-src[0].negate;
-sel-src[idx].abs = mov-src[0].abs;
-memcpy(sel-src[idx].swizzle, mov-src[0].swizzle, 4);
+nir_alu_src_copy(sel-src[idx], mov-src[0], state-mem_ctx);
  } else {
 sel-src[idx].src = nir_src_copy(src-src, state-mem_ctx);
  }
-- 
2.1.3

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


[Mesa-dev] [PATCH 1/5] nir: Expose nir_print_instr() for debug prints

2015-01-21 Thread Eric Anholt
It's nice to have this present in your default cases so you can see what
instruction is triggering an abort.
---
 src/glsl/nir/nir.h   |  1 +
 src/glsl/nir/nir_print.c | 14 --
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index 7b5794d..761f20a 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -1480,6 +1480,7 @@ void nir_index_ssa_defs(nir_function_impl *impl);
 void nir_index_blocks(nir_function_impl *impl);
 
 void nir_print_shader(nir_shader *shader, FILE *fp);
+void nir_print_instr(nir_instr *instr, FILE *fp);
 
 #ifdef DEBUG
 void nir_validate_shader(nir_shader *shader);
diff --git a/src/glsl/nir/nir_print.c b/src/glsl/nir/nir_print.c
index 1a50ae9..924989a 100644
--- a/src/glsl/nir/nir_print.c
+++ b/src/glsl/nir/nir_print.c
@@ -611,8 +611,6 @@ print_instr(nir_instr *instr, print_var_state *state, 
unsigned tabs, FILE *fp)
   unreachable(Invalid instruction type);
   break;
}
-
-   fprintf(fp, \n);
 }
 
 static int
@@ -658,6 +656,7 @@ print_block(nir_block *block, print_var_state *state, 
unsigned tabs, FILE *fp)
 
nir_foreach_instr(block, instr) {
   print_instr(instr, state, tabs, fp);
+  fprintf(fp, \n);
}
 
print_tabs(tabs, fp);
@@ -871,3 +870,14 @@ nir_print_shader(nir_shader *shader, FILE *fp)
 
destroy_print_state(state);
 }
+
+void
+nir_print_instr(nir_instr *instr, FILE *fp)
+{
+   print_var_state state;
+   init_print_state(state);
+
+   print_instr(instr, state, 0, fp);
+
+   destroy_print_state(state);
+}
-- 
2.1.3

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


[Mesa-dev] [PATCH 7/7] i965/fs_nir: Get rid of get_alu_src

2015-01-21 Thread Jason Ekstrand
Originally, get_alu_src was supposed to handle resolving swizzles and
things like that.  However, now that every instruction we have only takes
scalar sources, we don't really need it anymore.  The only case where it's
still marginally useful is for the MOV's that are generated from the
out-of-ssa pass.  However, we can handle those as a special case easily
enough.
---
 src/mesa/drivers/dri/i965/brw_fs.h   |  1 -
 src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 92 +++-
 2 files changed, 42 insertions(+), 51 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.h 
b/src/mesa/drivers/dri/i965/brw_fs.h
index 914a575..a00c970 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -587,7 +587,6 @@ public:
void nir_emit_texture(nir_tex_instr *instr);
void nir_emit_jump(nir_jump_instr *instr);
fs_reg get_nir_src(nir_src src);
-   fs_reg get_nir_alu_src(nir_alu_instr *instr, unsigned src);
fs_reg get_nir_dest(nir_dest dest);
void emit_percomp(fs_inst *inst, unsigned wr_mask);
 
diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
index b88cb8b..565327f 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
@@ -491,27 +491,59 @@ fs_visitor::nir_emit_alu(nir_alu_instr *instr)
 {
struct brw_wm_prog_key *fs_key = (struct brw_wm_prog_key *) this-key;
 
-   fs_reg op[3];
fs_reg result = get_nir_dest(instr-dest.dest);
result.type = brw_type_for_nir_type(nir_op_infos[instr-op].output_type);
 
-   for (unsigned i = 0; i  nir_op_infos[instr-op].num_inputs; i++)
-  op[i] = get_nir_alu_src(instr, i);
+   fs_reg op[3];
+   for (unsigned i = 0; i  nir_op_infos[instr-op].num_inputs; i++) {
+  op[i] = get_nir_src(instr-src[i].src);
+  op[i].type = 
brw_type_for_nir_type(nir_op_infos[instr-op].input_types[i]);
+  op[i].abs = instr-src[i].abs;
+  op[i].negate = instr-src[i].negate;
+   }
+
+   /* We get a bunch of mov's out of the from_ssa pass and they may still
+* be vectorized.  We'll handle them as a special-case.
+*/
+   if (instr-op == nir_op_imov || instr-op == nir_op_fmov) {
+  /* The source and destination need to be different or the trivial way
+   * we're emitting them won't work.  That said, we came out of SSA, so
+   * this should always be true.
+   */
+  assert(instr-src[0].src.is_ssa ||
+ instr-dest.dest.reg.reg != instr-src[0].src.reg.reg);
+
+  for (unsigned i = 0; i  4; i++) {
+ if (!(instr-dest.write_mask  (1  i)))
+continue;
+
+ emit(MOV(offset(result, i), offset(op[0], instr-src[0].swizzle[i])))
+ -saturate = instr-dest.saturate;
+  }
+
+  return;
+   }
 
+   unsigned channel = 0;
if (nir_op_infos[instr-op].output_size == 0) {
-  /* We've already scalarized, so we know that we only have one
-   * channel.  The only question is which channel.
+  /* Since NIR is doing the scalarizing for us, we should only ever see
+   * vectorized operations with a single channel.
*/
   assert(_mesa_bitcount(instr-dest.write_mask) == 1);
-  unsigned off = ffs(instr-dest.write_mask) - 1;
-  result = offset(result, off);
+  channel = ffs(instr-dest.write_mask) - 1;
 
-  for (unsigned i = 0; i  nir_op_infos[instr-op].num_inputs; i++)
- op[i] = offset(op[i], off);
+  result = offset(result, channel);
+   }
+
+   /* At this point, all operations have at most one channel per input.  We
+* do, however, need to deal with the swizzle which we do here.
+*/
+   for (unsigned i = 0; i  nir_op_infos[instr-op].num_inputs; i++) {
+  assert(nir_op_infos[instr-op].input_sizes[i]  2);
+  op[i] = offset(op[i], instr-src[i].swizzle[channel]);
}
 
switch (instr-op) {
-   case nir_op_fmov:
case nir_op_i2f:
case nir_op_u2f:
   emit(MOV(result, op[0]))
@@ -996,46 +1028,6 @@ fs_visitor::get_nir_src(nir_src src)
 }
 
 fs_reg
-fs_visitor::get_nir_alu_src(nir_alu_instr *instr, unsigned src)
-{
-   fs_reg reg = get_nir_src(instr-src[src].src);
-
-   reg.type = brw_type_for_nir_type(nir_op_infos[instr-op].input_types[src]);
-   reg.abs = instr-src[src].abs;
-   reg.negate = instr-src[src].negate;
-
-   bool needs_swizzle = false;
-   unsigned num_components = 0;
-   for (unsigned i = 0; i  4; i++) {
-  if (!nir_alu_instr_channel_used(instr, src, i))
- continue;
-
-  if (instr-src[src].swizzle[i] != i)
- needs_swizzle = true;
-
-  num_components = i + 1;
-   }
-
-   if (needs_swizzle) {
-  /* resolve the swizzle through MOV's */
-  fs_reg new_reg = vgrf(num_components);
-  new_reg.type = reg.type;
-
-  for (unsigned i = 0; i  4; i++) {
- if (!nir_alu_instr_channel_used(instr, src, i))
-continue;
-
- emit(MOV(offset(new_reg, i),
-  offset(reg, instr-src[src].swizzle[i])));
- 

[Mesa-dev] [PATCH 1/7] nir: Add a pass for scalarizing ALU operations

2015-01-21 Thread Jason Ekstrand
---
 src/glsl/Makefile.sources  |   1 +
 src/glsl/nir/nir.h |   2 +
 src/glsl/nir/nir_lower_alu_to_scalar.c | 155 +
 3 files changed, 158 insertions(+)
 create mode 100644 src/glsl/nir/nir_lower_alu_to_scalar.c

diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
index 6237627..7c9f63b 100644
--- a/src/glsl/Makefile.sources
+++ b/src/glsl/Makefile.sources
@@ -24,6 +24,7 @@ NIR_FILES = \
$(GLSL_SRCDIR)/nir/nir_intrinsics.c \
$(GLSL_SRCDIR)/nir/nir_intrinsics.h \
$(GLSL_SRCDIR)/nir/nir_live_variables.c \
+   $(GLSL_SRCDIR)/nir/nir_lower_alu_to_scalar.c \
$(GLSL_SRCDIR)/nir/nir_lower_atomics.c \
$(GLSL_SRCDIR)/nir/nir_lower_global_vars_to_local.c \
$(GLSL_SRCDIR)/nir/nir_lower_locals_to_regs.c \
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index 7b5794d..5b1188b 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -1504,6 +1504,8 @@ void nir_split_var_copies(nir_shader *shader);
 void nir_lower_var_copy_instr(nir_intrinsic_instr *copy, void *mem_ctx);
 void nir_lower_var_copies(nir_shader *shader);
 
+void nir_lower_alu_to_scalar(nir_shader *shader);
+
 void nir_lower_global_vars_to_local(nir_shader *shader);
 
 void nir_lower_locals_to_regs(nir_shader *shader);
diff --git a/src/glsl/nir/nir_lower_alu_to_scalar.c 
b/src/glsl/nir/nir_lower_alu_to_scalar.c
new file mode 100644
index 000..38fe729
--- /dev/null
+++ b/src/glsl/nir/nir_lower_alu_to_scalar.c
@@ -0,0 +1,155 @@
+/*
+ * Copyright © 2014 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.
+ *
+ * Authors:
+ *Jason Ekstrand (ja...@jlekstrand.net)
+ *
+ */
+
+#include nir.h
+
+/*
+ * Implements common subexpression elimination
+ */
+
+struct lower_alu_to_scalar_state {
+   void *mem_ctx;
+   void *dead_ctx;
+};
+
+static bool
+lower_alu_to_scalar_block(nir_block *block, void *void_state)
+{
+   struct lower_alu_to_scalar_state *state = void_state;
+
+   nir_foreach_instr_safe(block, instr) {
+  if (instr-type != nir_instr_type_alu)
+ continue;
+
+  nir_alu_instr *alu = nir_instr_as_alu(instr);
+
+  if (nir_op_infos[alu-op].output_size != 0)
+ continue;
+
+  if (alu-dest.write_mask == 1)
+ continue; /* It's already scalar.  Nothing to do */
+
+  /* We only handle SSA for now. */
+  assert(alu-dest.dest.is_ssa);
+
+  /* Since it SSA, we should have already handled the 1 component case */
+  assert(alu-dest.dest.ssa.num_components  1);
+
+  /* Create a vecN operation to combine the results.  Most of these
+   * will be redundant, but copy propagation should clean them up for
+   * us.  No need to add the complexity here.
+   */
+  nir_op vec_op;
+  switch (alu-dest.dest.ssa.num_components) {
+  case 2: vec_op = nir_op_vec2; break;
+  case 3: vec_op = nir_op_vec3; break;
+  case 4: vec_op = nir_op_vec4; break;
+  default: unreachable(Invalid number of components);
+  }
+
+  nir_alu_instr *vec = nir_alu_instr_create(state-mem_ctx, vec_op);
+  vec-dest.dest.is_ssa = true;
+  nir_ssa_def_init(vec-instr, vec-dest.dest.ssa,
+   alu-dest.dest.ssa.num_components, NULL);
+  vec-dest.write_mask = (1  alu-dest.dest.ssa.num_components) - 1;
+
+  for (unsigned i = 0; i  4; i++) {
+ if (!(alu-dest.write_mask  (1  i)))
+continue;
+
+ nir_alu_instr *new_alu = nir_alu_instr_create(state-mem_ctx, 
alu-op);
+ new_alu-dest.dest.is_ssa = true;
+ nir_ssa_def_init(new_alu-instr, new_alu-dest.dest.ssa, 1, NULL);
+ new_alu-dest.write_mask = 1;
+ new_alu-dest.saturate = alu-dest.saturate;
+
+ vec-src[i].src.is_ssa = true;
+ vec-src[i].src.ssa = new_alu-dest.dest.ssa;
+
+ for (unsigned j = 0; j  nir_op_infos[alu-op].num_inputs; j++) {
+

[Mesa-dev] [PATCH 0/7] nir: Add scalarizing and use it in i965

2015-01-21 Thread Jason Ekstrand
Yes, I'm fully aware that some of this is a repeat of what eric just sent.
However, most of the repeated work is in the first patch (and the 5th)
which I'm not too worried about.  There's two solutions to scalarizing
things floating around and we can decide what we like best.

The important parts here are:

 1) The second patch which scalarizes phi nodes.  Having scalar ALU
operations is find and all, but if we really want to melt those DX
shaders, we need to split up the pyhi nodes as well.

 2) The additions to nir_search to handle swizzles on replacements.
Eventually, I'd like to support swizzles on search paterns as well, but
that's much harder to get right and I didn't want to bang my head on it
today.  One side-effect of this is that we can use it to do the
reduction replacements.  Whether it's better to do these with the
algebraic search-and-replace framework or direcly in C as Eric did, I
don't know.

 3) The last two patches which substantially simplifies the NIR - i965 FS
pass.  One of the benifits of this is that we're no longer emitting
piles of MOV operations just to resolve swizzles.  Instead, since
everything is vectorized, we can directly resolve them as we emit
instructions.

Also available here:

http://cgit.freedesktop.org/~jekstrand/mesa/log/?h=review/nir-scalarize

With all of this, we get the following from shader-db:

total instructions in shared programs: 6097323 - 6074645 (-0.37%)
instructions in affected programs: 814032 - 791354 (-2.79%)
GAINED:8
LOST:  11


Jason Ekstrand (7):
  nir: Add a pass for scalarizing ALU operations
  nir: Add a pass to lower vector phi nodes to scalar phi nodes
  nir/search: Don't use a nir_alu_src for storing variables
  nir/search: Add a swizzle to nir_search_variable and use it for
replacements
  nir: Add a pass to lower things like bany and ball to scalar
operations
  i965/fs: Use NIR's scalarizing abilities and stop handling vectors
  i965/fs_nir: Get rid of get_alu_src

 src/glsl/Makefile.am |   6 +
 src/glsl/Makefile.sources|   3 +
 src/glsl/nir/nir.h   |   6 +
 src/glsl/nir/nir_algebraic.py|  14 +
 src/glsl/nir/nir_lower_alu_reductions.py |  78 +
 src/glsl/nir/nir_lower_alu_to_scalar.c   | 155 +
 src/glsl/nir/nir_lower_phis_to_scalar.c  | 238 +
 src/glsl/nir/nir_search.c|  25 +-
 src/glsl/nir/nir_search.h|   7 +
 src/mesa/drivers/dri/i965/brw_fs.h   |  16 -
 src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 569 +++
 11 files changed, 718 insertions(+), 399 deletions(-)
 create mode 100644 src/glsl/nir/nir_lower_alu_reductions.py
 create mode 100644 src/glsl/nir/nir_lower_alu_to_scalar.c
 create mode 100644 src/glsl/nir/nir_lower_phis_to_scalar.c

-- 
2.2.1

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


[Mesa-dev] [PATCH 5/7] nir: Add a pass to lower things like bany and ball to scalar operations

2015-01-21 Thread Jason Ekstrand
---
 src/glsl/Makefile.am |  6 +++
 src/glsl/Makefile.sources|  1 +
 src/glsl/nir/nir.h   |  2 +
 src/glsl/nir/nir_lower_alu_reductions.py | 78 
 4 files changed, 87 insertions(+)
 create mode 100644 src/glsl/nir/nir_lower_alu_reductions.py

diff --git a/src/glsl/Makefile.am b/src/glsl/Makefile.am
index 01123bc..bc517c3 100644
--- a/src/glsl/Makefile.am
+++ b/src/glsl/Makefile.am
@@ -214,6 +214,7 @@ BUILT_SOURCES = 
\
glsl_lexer.cpp  \
glcpp/glcpp-parse.c \
glcpp/glcpp-lex.c   \
+   nir/nir_lower_alu_reductions.c  \
nir/nir_opt_algebraic.c
 CLEANFILES =   \
glcpp/glcpp-parse.h \
@@ -227,6 +228,11 @@ dist-hook:
$(RM) glcpp/tests/*.out
$(RM) glcpp/tests/subtest*/*.out
 
+nir/nir_lower_alu_reductions.c: nir/nir_lower_alu_reductions.py
\
+nir/nir_algebraic.py
+   $(MKDIR_P) nir; \
+   $(PYTHON2) $(PYTHON_FLAGS) $  $@
+
 nir/nir_opt_algebraic.c: nir/nir_opt_algebraic.py nir/nir_algebraic.py
$(MKDIR_P) nir; \
$(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/nir/nir_opt_algebraic.py  $@
diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
index b3facb1..4512da8 100644
--- a/src/glsl/Makefile.sources
+++ b/src/glsl/Makefile.sources
@@ -14,6 +14,7 @@ LIBGLCPP_GENERATED_FILES = \
$(GLSL_BUILDDIR)/glcpp/glcpp-parse.c
 
 NIR_GENERATED_FILES = \
+   $(GLSL_BUILDDIR)/nir/nir_lower_alu_reductions.c \
$(GLSL_BUILDDIR)/nir/nir_opt_algebraic.c
 
 NIR_FILES = \
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index a7e6146..56de444 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -1504,6 +1504,8 @@ void nir_split_var_copies(nir_shader *shader);
 void nir_lower_var_copy_instr(nir_intrinsic_instr *copy, void *mem_ctx);
 void nir_lower_var_copies(nir_shader *shader);
 
+bool nir_lower_alu_reductions(nir_shader *shader);
+
 void nir_lower_alu_to_scalar(nir_shader *shader);
 
 void nir_lower_global_vars_to_local(nir_shader *shader);
diff --git a/src/glsl/nir/nir_lower_alu_reductions.py 
b/src/glsl/nir/nir_lower_alu_reductions.py
new file mode 100644
index 000..30a2fcd
--- /dev/null
+++ b/src/glsl/nir/nir_lower_alu_reductions.py
@@ -0,0 +1,78 @@
+#! /usr/bin/env python
+#
+# Copyright (C) 2014 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.
+#
+# Authors:
+#Jason Ekstrand (ja...@jlekstrand.net)
+
+import nir_algebraic
+
+def reduction(name, num_srcs, reduce_op,
+  pre_reduce_op = None, pre_reduce_const = None):
+   def get_pre_reduce(chan):
+  swz = 'xyzw'[chan]
+  if pre_reduce_op is None:
+ return 'a.' + swz
+
+  if num_srcs == 1:
+ if pre_reduce_const is None:
+return (pre_reduce_op, 'a.' + swz)
+ else:
+return (pre_reduce_op, 'a.' + swz, pre_reduce_const)
+  elif num_srcs == 2:
+ return (pre_reduce_op, 'a.' + swz, 'b.' + swz)
+  else:
+ assert False
+
+   def get_search(chans):
+  if num_srcs == 1:
+ return (name + str(chans), 'a')
+  elif num_srcs == 2:
+ return (name + str(chans), 'a', 'b')
+  else:
+ assert False
+
+   return [
+  (get_search(2), (reduce_op, get_pre_reduce(0), get_pre_reduce(1))),
+  (get_search(3), (reduce_op,
+   (reduce_op, get_pre_reduce(0), get_pre_reduce(1)),
+   get_pre_reduce(2))),
+  (get_search(4), (reduce_op,
+   (reduce_op, get_pre_reduce(0), get_pre_reduce(1)),
+   

[Mesa-dev] [PATCH 2/2] main: Add entry point for glTextureBufferRange.

2015-01-21 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   | 92 +-
 src/mesa/main/teximage.h   |  4 ++
 4 files changed, 104 insertions(+), 1 deletion(-)

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 ee4db45..39d255d 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 },
 
{ NULL, 0, -1 }
 };
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 5ada94f..2baf5c4 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -4957,7 +4957,7 @@ _mesa_validate_texbuffer_format(const struct gl_context 
*ctx,
 
 void
 _mesa_texture_buffer_range(struct gl_context *ctx,
-   struct gl_texture_object *texObj, GLenum target, 
+   struct gl_texture_object *texObj, GLenum target,
GLenum internalFormat,
struct gl_buffer_object *bufObj,
GLintptr offset, GLsizeiptr size, bool range,
@@ -5123,6 +5123,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 

[Mesa-dev] [PATCH 1/2] GL: Corrected function arguments for TextureBufferRange.

2015-01-21 Thread Laura Ekstrand
---
 include/GL/glext.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/GL/glext.h b/include/GL/glext.h
index d3cfbb5..88505b0 100644
--- a/include/GL/glext.h
+++ b/include/GL/glext.h
@@ -2773,7 +2773,7 @@ GLAPI void APIENTRY glNamedRenderbufferStorageMultisample 
(GLuint renderbuffer,
 GLAPI void APIENTRY glGetNamedRenderbufferParameteriv (GLuint renderbuffer, 
GLenum pname, GLint *params);
 GLAPI void APIENTRY glCreateTextures (GLenum target, GLsizei n, GLuint 
*textures);
 GLAPI void APIENTRY glTextureBuffer (GLuint texture, GLenum internalformat, 
GLuint buffer);
-GLAPI void APIENTRY glTextureBufferRange (GLuint texture, GLenum 
internalformat, GLuint buffer, GLintptr offset, GLsizei size);
+GLAPI void APIENTRY glTextureBufferRange (GLuint texture, GLenum 
internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
 GLAPI void APIENTRY glTextureStorage1D (GLuint texture, GLsizei levels, GLenum 
internalformat, GLsizei width);
 GLAPI void APIENTRY glTextureStorage2D (GLuint texture, GLsizei levels, GLenum 
internalformat, GLsizei width, GLsizei height);
 GLAPI void APIENTRY glTextureStorage3D (GLuint texture, GLsizei levels, GLenum 
internalformat, GLsizei width, GLsizei height, GLsizei depth);
-- 
2.1.0

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


Re: [Mesa-dev] [PATCH 03/21] GL: Correct function arguments for NamedBufferStorage.

2015-01-21 Thread Ian Romanick
On 01/21/2015 05:40 PM, Laura Ekstrand wrote:
 ---
  include/GL/glext.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/include/GL/glext.h b/include/GL/glext.h
 index 88505b0..1ffe576 100644
 --- a/include/GL/glext.h
 +++ b/include/GL/glext.h
 @@ -2735,7 +2735,7 @@ GLAPI void APIENTRY glGetTransformFeedbackiv (GLuint 
 xfb, GLenum pname, GLint *p
  GLAPI void APIENTRY glGetTransformFeedbacki_v (GLuint xfb, GLenum pname, 
 GLuint index, GLint *param);
  GLAPI void APIENTRY glGetTransformFeedbacki64_v (GLuint xfb, GLenum pname, 
 GLuint index, GLint64 *param);
  GLAPI void APIENTRY glCreateBuffers (GLsizei n, GLuint *buffers);
 -GLAPI void APIENTRY glNamedBufferStorage (GLuint buffer, GLsizei size, const 
 void *data, GLbitfield flags);
 +GLAPI void APIENTRY glNamedBufferStorage (GLuint buffer, GLsizeiptr size, 
 const void *data, GLbitfield flags);

We can't land changes to the upstream header.  I submitted a bug to
Khronos, but there has been no progress.  If there are apps (or drivers)
shipping this extension, we may have to change the spec to GLsizei.

I'll poke again...

  GLAPI void APIENTRY glNamedBufferData (GLuint buffer, GLsizei size, const 
 void *data, GLenum usage);
  GLAPI void APIENTRY glNamedBufferSubData (GLuint buffer, GLintptr offset, 
 GLsizei size, const void *data);
  GLAPI void APIENTRY glCopyNamedBufferSubData (GLuint readBuffer, GLuint 
 writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizei size);
 

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


Re: [Mesa-dev] [PATCH 2/2] nir: Stop using designated initializers

2015-01-21 Thread Jason Ekstrand
On Wed, Jan 21, 2015 at 12:19 PM, Connor Abbott cwabbo...@gmail.com wrote:

 Assuming this actually compiles with GCC 4.4...


I don't know for sure, but it certainly gets us closer
--Jason



 Reviewed-by: Connor Abbott cwabbo...@gmail.com

 On Wed, Jan 21, 2015 at 2:14 PM, Jason Ekstrand ja...@jlekstrand.net
 wrote:
  Designated initializers with anonymous unions don't work in MSVC or
  GCC  4.6.  With a couple of constructor methods, we don't need them any
  more and the code is actually cleaner.
 
  Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88467
  ---
   src/glsl/nir/nir_from_ssa.c | 30
 --
   src/glsl/nir/nir_lower_atomics.c|  8 +++-
   src/glsl/nir/nir_lower_io.c |  9 ++---
   src/glsl/nir/nir_lower_locals_to_regs.c |  9 ++---
   src/glsl/nir/nir_lower_system_values.c  |  8 +++-
   src/glsl/nir/nir_lower_vars_to_ssa.c| 16 
   src/glsl/nir/nir_opt_constant_folding.c | 16 
   src/glsl/nir/nir_opt_cse.c  | 16 ++--
   src/glsl/nir/nir_opt_peephole_select.c  |  8 +++-
   src/glsl/nir/nir_search.c   |  8 ++--
   10 files changed, 37 insertions(+), 91 deletions(-)
 
  diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c
  index 9728b99..8b8f0f5 100644
  --- a/src/glsl/nir/nir_from_ssa.c
  +++ b/src/glsl/nir/nir_from_ssa.c
  @@ -382,12 +382,9 @@ isolate_phi_nodes_block(nir_block *block, void
 *void_state)
 entry-dest.is_ssa = true;
 nir_ssa_def_init(block_pcopy-instr, entry-dest.ssa,
  phi-dest.ssa.num_components, phi-dest.ssa.name
 );
  -
  -  nir_src entry_dest_src = {
  - .ssa = entry-dest.ssa,
  - .is_ssa = true,
  -  };
  -  nir_ssa_def_rewrite_uses(phi-dest.ssa, entry_dest_src,
 state-mem_ctx);
  +  nir_ssa_def_rewrite_uses(phi-dest.ssa,
  +   nir_src_for_ssa(entry-dest.ssa),
  +   state-mem_ctx);
 
 entry-src.is_ssa = true;
 entry-src.ssa = phi-dest.ssa;
  @@ -620,22 +617,16 @@ emit_copy(nir_parallel_copy_instr *pcopy, nir_src
 src, nir_src dest_src,
  assert(!dest_src.is_ssa 
 dest_src.reg.indirect == NULL 
 dest_src.reg.base_offset == 0);
  -   nir_dest dest = {
  -  .reg.reg = dest_src.reg.reg,
  -  .reg.indirect = NULL,
  -  .reg.base_offset = 0,
  -  .is_ssa = false,
  -   };
 
  if (src.is_ssa)
  -  assert(src.ssa-num_components = dest.reg.reg-num_components);
  +  assert(src.ssa-num_components =
 dest_src.reg.reg-num_components);
  else
  -  assert(src.reg.reg-num_components =
 dest.reg.reg-num_components);
  +  assert(src.reg.reg-num_components =
 dest_src.reg.reg-num_components);
 
  nir_alu_instr *mov = nir_alu_instr_create(mem_ctx, nir_op_imov);
  mov-src[0].src = nir_src_copy(src, mem_ctx);
  -   mov-dest.dest = nir_dest_copy(dest, mem_ctx);
  -   mov-dest.write_mask = (1  dest.reg.reg-num_components) - 1;
  +   mov-dest.dest = nir_dest_for_reg(dest_src.reg.reg);
  +   mov-dest.write_mask = (1  dest_src.reg.reg-num_components) - 1;
 
  nir_instr_insert_before(pcopy-instr, mov-instr);
   }
  @@ -720,12 +711,7 @@ resolve_parallel_copy(nir_parallel_copy_instr
 *pcopy,
values[src_idx] = entry-src;
 }
 
  -  nir_src dest_src = {
  - .reg.reg = entry-dest.reg.reg,
  - .reg.indirect = NULL,
  - .reg.base_offset = 0,
  - .is_ssa = false,
  -  };
  +  nir_src dest_src = nir_src_for_reg(entry-dest.reg.reg);
 
 int dest_idx = -1;
 for (int i = 0; i  num_vals; ++i) {
  diff --git a/src/glsl/nir/nir_lower_atomics.c
 b/src/glsl/nir/nir_lower_atomics.c
  index 874c534..c45b397 100644
  --- a/src/glsl/nir/nir_lower_atomics.c
  +++ b/src/glsl/nir/nir_lower_atomics.c
  @@ -115,11 +115,9 @@ lower_instr(nir_intrinsic_instr *instr,
 nir_function_impl *impl)
 new_instr-dest.is_ssa = true;
 nir_ssa_def_init(new_instr-instr, new_instr-dest.ssa,
  instr-dest.ssa.num_components, NULL);
  -  nir_src new_dest_src = {
  - .is_ssa = true,
  - .ssa = new_instr-dest.ssa,
  -  };
  -  nir_ssa_def_rewrite_uses(instr-dest.ssa, new_dest_src, mem_ctx);
  +  nir_ssa_def_rewrite_uses(instr-dest.ssa,
  +   nir_src_for_ssa(new_instr-dest.ssa),
  +   mem_ctx);
  } else {
 new_instr-dest = nir_dest_copy(instr-dest, mem_ctx);
  }
  diff --git a/src/glsl/nir/nir_lower_io.c b/src/glsl/nir/nir_lower_io.c
  index af87c13..c35058c 100644
  --- a/src/glsl/nir/nir_lower_io.c
  +++ b/src/glsl/nir/nir_lower_io.c
  @@ -238,13 +238,8 @@ nir_lower_io_block(nir_block *block, void
 *void_state)
   load-dest.is_ssa = true;
   nir_ssa_def_init(load-instr, load-dest.ssa,
   

Re: [Mesa-dev] [PATCH 3/3] i965: Fix URB size for gen8

2015-01-21 Thread Kenneth Graunke
On Wednesday, January 21, 2015 08:17:36 PM ville.syrj...@linux.intel.com wrote:
 From: Ville Syrjälä ville.syrj...@linux.intel.com
 
 Increase the device info .urb.size for BDW GT3 and CHV to match the
 default URB size for each.
 
 Also add all missing platforms (BYT,BDW,CHV) to the comment describing
 the default URB size in gen7_urb.c.
 
 Signed-off-by: Ville Syrjälä ville.syrj...@linux.intel.com
 ---
  src/mesa/drivers/dri/i965/brw_device_info.c | 4 ++--
  src/mesa/drivers/dri/i965/gen7_urb.c| 5 -
  2 files changed, 6 insertions(+), 3 deletions(-)
 
 diff --git a/src/mesa/drivers/dri/i965/brw_device_info.c 
 b/src/mesa/drivers/dri/i965/brw_device_info.c
 index bdef42b..d0b9e05 100644
 --- a/src/mesa/drivers/dri/i965/brw_device_info.c
 +++ b/src/mesa/drivers/dri/i965/brw_device_info.c
 @@ -226,7 +226,7 @@ static const struct brw_device_info 
 brw_device_info_bdw_gt3 = {
 GEN8_FEATURES, .gt = 3,
 .max_wm_threads = 384,
 .urb = {
 -  .size = 384,
 +  .size = 768,
.min_vs_entries = 64,
.max_vs_entries = 2560,
.max_gs_entries = 960,
 @@ -243,7 +243,7 @@ static const struct brw_device_info brw_device_info_chv = 
 {
 .max_gs_threads = 80,
 .max_wm_threads = 128,
 .urb = {
 -  .size = 128,
 +  .size = 192,
.min_vs_entries = 34,
.max_vs_entries = 640,
.max_gs_entries = 256,
 diff --git a/src/mesa/drivers/dri/i965/gen7_urb.c 
 b/src/mesa/drivers/dri/i965/gen7_urb.c
 index 201f42e..f90d6e3 100644
 --- a/src/mesa/drivers/dri/i965/gen7_urb.c
 +++ b/src/mesa/drivers/dri/i965/gen7_urb.c
 @@ -50,9 +50,12 @@
   * Currently we split the constant buffer space evenly among whatever stages
   * are active.  This is probably not ideal, but simple.
   *
 - * Ivybridge GT1 and Haswell GT1 have 128kB of URB space.
 + * Ivybridge GT1, Baytrail and Haswell GT1 have 128kB of URB space.
   * Ivybridge GT2 and Haswell GT2 have 256kB of URB space.
   * Haswell GT3 has 512kB of URB space.
 + * Broadwell GT1 and Cherryview have 192kB of URB space.
 + * Broadwell GT2 has 384kB of URB space.
 + * Broadwell GT3 has 768kB of URB space.
   *
   * See Volume 2a: 3D Pipeline, section 1.8, Volume 1b: Configurations,
   * and the documentation for 3DSTATE_PUSH_CONSTANT_ALLOC_xS.
 

Have you tested this?  I tried 768k on Broadwell GT3 a while back and got
no end of GPU hangs.  Which is odd, because it should be the correct value.

We really need to be programming the L3 to a known configuration and not
relying on default values...

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


Re: [Mesa-dev] [PATCH] radeonsi: Enable VGPR spilling for all shader types v3

2015-01-21 Thread Marek Olšák
On Wed, Jan 21, 2015 at 3:03 AM, Michel Dänzer mic...@daenzer.net wrote:
 On 20.01.2015 22:39, Marek Olšák wrote:
 The problem with CPDMA (DMA_DATA and WRITE_DATA) is that the ordering
 of flushes must be correct. First, partial flushes must be done, so
 that the shaders are idle.

 That's only necessary when reusing a single BO for the shader code, not
 when allocating a new BO when the relocations change, right?

Yes.



 Then you can use CP DMA to update the binary. After that, ICACHE should
 be invalidated.

 ICACHE has to be invalidated when writing with the CPU as well, right?

Yes, but the invalidation at the beginning of IBs is sufficient for
all CPU accesses, so nothing needs to be done.



 The problem with mapping VRAM can be avoided by keeping a CPU copy of
 the binary from the beginning. We would only need a CPU copy of those
 shaders that use the scratch buffer. Then, you wouldn't have to read
 VRAM at all, which would make it even simpler.

 Right, but CPU writes to the new BO in VRAM could cause stalls anyway.

If CPU writes are the problem, we can create a temporary BO in GTT,
upload and update the shader there, and copy it to the shader BO in
VRAM using CPDMA. In this case, the shader BO in VRAM doesn't have to
be reallocated, and shader state doesn't have to be re-emitted. Only
the ICACHE should be flushed after CPDMA.

One copy packet is better than a lot of small WRITE_DATA packets.

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


[Mesa-dev] [Bug 87886] constant fps drops with Intel and Radeon

2015-01-21 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=87886

--- Comment #26 from Eero Tamminen eero.t.tammi...@intel.com ---
as root, mount debugfs and monitor CAGF (actual GPU frequency) value from
/sys/kernel/debug/dri/0/i915_frequency_info, or if you have older kernel from
/sys/kernel/debug/dri/0/i915_cur_delayinfo  Does it keep up, or go down when
you get FPS drop?

(If it goes down, this seems like kernel power management 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] [PATCH] nir: Implement CSE on intrinsics that can be eliminated and reordered.

2015-01-21 Thread Kenneth Graunke
Matt and I noticed that one of the shaders hurt by INTEL_USE_NIR=1 had
load_input and load_uniform intrinsics repeated several times, with the
same parameters, but each one generating a distinct SSA value.  This
made ALU operations on those values appear distinct as well.

Generating distinct SSA values is silly - these are read only variables.
CSE'ing them makes everything use a single SSA value, which then allows
other operations to be CSE'd away as well.

Generalizing a bit, it seems like we should be able to safely CSE any
intrinsics that can be eliminated and reordered.  I didn't implement
support for variables for the time being.

--- NIR instruction statistics ---
total instructions in shared programs: 2435936 - 2023511 (-16.93%)
instructions in affected programs: 2413496 - 2001071 (-17.09%)
helped:16872

--- i965 instruction statistics ---
total instructions in shared programs: 6028987 - 6008427 (-0.34%)
instructions in affected programs: 640654 - 620094 (-3.21%)
helped:2071
HURT:  585
GAINED:14
LOST:  25

Signed-off-by: Kenneth Graunke kenn...@whitecape.org
---
 src/glsl/nir/nir_opt_cse.c | 38 --
 1 file changed, 36 insertions(+), 2 deletions(-)

diff --git a/src/glsl/nir/nir_opt_cse.c b/src/glsl/nir/nir_opt_cse.c
index e7dba1d..6ad78f6 100644
--- a/src/glsl/nir/nir_opt_cse.c
+++ b/src/glsl/nir/nir_opt_cse.c
@@ -112,7 +112,32 @@ nir_instrs_equal(nir_instr *instr1, nir_instr *instr2)
 
   return true;
}
-   case nir_instr_type_intrinsic:
+   case nir_instr_type_intrinsic: {
+  nir_intrinsic_instr *intrinsic1 = nir_instr_as_intrinsic(instr1);
+  nir_intrinsic_instr *intrinsic2 = nir_instr_as_intrinsic(instr2);
+  const nir_intrinsic_info *info =
+ nir_intrinsic_infos[intrinsic1-intrinsic];
+
+  if (intrinsic1-intrinsic != intrinsic2-intrinsic ||
+  intrinsic1-num_components != intrinsic2-num_components)
+ return false;
+
+  if (info-has_dest  intrinsic1-dest.ssa.num_components !=
+intrinsic2-dest.ssa.num_components)
+ return false;
+
+  for (unsigned i = 0; i  info-num_srcs; i++) {
+ if (!nir_srcs_equal(intrinsic1-src[i], intrinsic2-src[i]))
+return false;
+  }
+
+  for (unsigned i = 0; i  info-num_indices; i++) {
+ if (intrinsic1-const_index[i] != intrinsic2-const_index[i])
+return false;
+  }
+
+  return true;
+   }
case nir_instr_type_call:
case nir_instr_type_jump:
case nir_instr_type_ssa_undef:
@@ -147,7 +172,13 @@ nir_instr_can_cse(nir_instr *instr)
  nir_foreach_src(instr, src_is_ssa, NULL);
case nir_instr_type_tex:
   return false; /* TODO */
-   case nir_instr_type_intrinsic:
+   case nir_instr_type_intrinsic: {
+  const nir_intrinsic_info *info =
+ nir_intrinsic_infos[nir_instr_as_intrinsic(instr)-intrinsic];
+  return (info-flags  NIR_INTRINSIC_CAN_ELIMINATE) 
+ (info-flags  NIR_INTRINSIC_CAN_REORDER) 
+ info-num_variables == 0; /* not implemented yet */
+   }
case nir_instr_type_call:
case nir_instr_type_jump:
case nir_instr_type_ssa_undef:
@@ -172,6 +203,9 @@ nir_instr_get_dest_ssa_def(nir_instr *instr)
case nir_instr_type_phi:
   assert(nir_instr_as_phi(instr)-dest.is_ssa);
   return nir_instr_as_phi(instr)-dest.ssa;
+   case nir_instr_type_intrinsic:
+  assert(nir_instr_as_intrinsic(instr)-dest.is_ssa);
+  return nir_instr_as_intrinsic(instr)-dest.ssa;
default:
   unreachable(We never ask for any of these);
}
-- 
2.2.2

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


Re: [Mesa-dev] [PATCH] radeonsi: Enable VGPR spilling for all shader types v3

2015-01-21 Thread Christian König
In general I don't think that modifying shader code with the GPU is such 
a good idea. We already had quite a number of occasions where the GPU 
accidentally corrupted the shader data which usually leads to lockups.


Because of this I already wanted to suggest that everything that the GPU 
executes (e.g. Rings, IB, shader etc...) is only mapped readonly into 
the GPU address space.


Regards,
Christian.

Am 21.01.2015 um 12:20 schrieb Marek Olšák:

On Wed, Jan 21, 2015 at 3:03 AM, Michel Dänzer mic...@daenzer.net wrote:

On 20.01.2015 22:39, Marek Olšák wrote:

The problem with CPDMA (DMA_DATA and WRITE_DATA) is that the ordering
of flushes must be correct. First, partial flushes must be done, so
that the shaders are idle.

That's only necessary when reusing a single BO for the shader code, not
when allocating a new BO when the relocations change, right?

Yes.




Then you can use CP DMA to update the binary. After that, ICACHE should
be invalidated.

ICACHE has to be invalidated when writing with the CPU as well, right?

Yes, but the invalidation at the beginning of IBs is sufficient for
all CPU accesses, so nothing needs to be done.




The problem with mapping VRAM can be avoided by keeping a CPU copy of
the binary from the beginning. We would only need a CPU copy of those
shaders that use the scratch buffer. Then, you wouldn't have to read
VRAM at all, which would make it even simpler.

Right, but CPU writes to the new BO in VRAM could cause stalls anyway.

If CPU writes are the problem, we can create a temporary BO in GTT,
upload and update the shader there, and copy it to the shader BO in
VRAM using CPDMA. In this case, the shader BO in VRAM doesn't have to
be reallocated, and shader state doesn't have to be re-emitted. Only
the ICACHE should be flushed after CPDMA.

One copy packet is better than a lot of small WRITE_DATA packets.

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


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


[Mesa-dev] [Bug 88467] nir.c:140: error: ‘nir_src’ has no member named ‘ssa’

2015-01-21 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=88467

--- Comment #9 from Dave Airlie airl...@freedesktop.org ---
that doesn't help with our internal builds for inclusion in RHEL, they have to
build with the system compiler.

-- 
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 88662] unaligned access to gl_dlist_node

2015-01-21 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=88662

Bug ID: 88662
   Summary: unaligned access to gl_dlist_node
   Product: Mesa
   Version: 10.4
  Hardware: SPARC
OS: OpenBSD
Status: NEW
  Severity: normal
  Priority: medium
 Component: Mesa core
  Assignee: mesa-dev@lists.freedesktop.org
  Reporter: j...@openbsd.org
QA Contact: mesa-dev@lists.freedesktop.org

As part of testing for an update to Mesa 10.4 in OpenBSD Matthieu Herrb found
an alignment related crash with classic swrast on mips64el.  I've also
reproduced this on sparc64 which also has a requirement for strict 8 byte
pointer alignment.

As tracked down by Mark Kettenis since 483dc973c431cadec69b36e58a4559c734a7ef16
union gl_dlist_node no longer has a pointer in it so pointers returned from 
_mesa_dlist_alloc are only guaranteed to be 4 byte aligned.

_mesa_dlist_alloc(struct gl_context *ctx, GLuint opcode, GLuint bytes)
{
   Node *n = dlist_alloc(ctx, (OpCode) opcode, bytes);
   if (n)
  return n + 1;  /* return pointer to payload area, after opcode */
   else
  return NULL;
}

commit 483dc973c431cadec69b36e58a4559c734a7ef16
Author: Brian Paul bri...@vmware.com
Date:   Wed Dec 4 09:45:38 2013 -0700

mesa: remove gl_dlist_node::next pointer to reduce dlist memory use

Now, sizeof(gl_dlist_node)==4 even on 64-bit systems.  This can
halve the memory used by some display lists on 64-bit systems.

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

0x00c387368914 in _save_compile_vertex_list (ctx=0xc3532de000)
at
/usr/xenocara/lib/libGL/mesa/libmesa/../../../../dist/Mesa/src/mesa/vbo/vbo_save_api.c:393
393node-prim = save-prim;
(gdb) bt
#0  0x00c387368914 in _save_compile_vertex_list (ctx=0xc3532de000)
at
/usr/xenocara/lib/libGL/mesa/libmesa/../../../../dist/Mesa/src/mesa/vbo/vbo_save_api.c:393
#1  0x00c387396914 in vbo_save_SaveFlushVertices (ctx=0xc3532de000)
at
/usr/xenocara/lib/libGL/mesa/libmesa/../../../../dist/Mesa/src/mesa/vbo/vbo_save_api.c:1421
#2  0x00c387501fd0 in save_Attr3fNV (attr=2, x=0, y=0, z=-1)
at
/usr/xenocara/lib/libGL/mesa/libmesa/../../../../dist/Mesa/src/mesa/main/dlist.c:5062
#3  0x00c37fefe188 in glNormal3f (nx=0, ny=0, nz=-1) at
glapi_mapi_tmp.h:1920
#4  0x00c0abc02d7c in atexit () from /usr/X11R6/bin/glxgears

(gdb) p node
$1 = (struct vbo_save_vertex_list *) 0xc35bf3ac3c
(gdb) p (uint64_t)node % 8
$2 = 4
(gdb) p save
$3 = (struct vbo_save_context *) 0xc37b53d5a8
(gdb) p (uint64_t)save % 8
$4 = 0
(gdb) p node-prim
$6 = (struct _mesa_prim **) 0xc35bf3ad44
(gdb) p (uint64_t)node-prim % 8
$7 = 4
(gdb) p save-prim
$8 = (struct _mesa_prim **) 0xc37b53e968
(gdb) p (uint64_t)save-prim % 8
$9 = 0

Adding a void * pointer back to gl_dlist_node prevents the crash.

-- 
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: Implement CSE on intrinsics that can be eliminated and reordered.

2015-01-21 Thread Jason Ekstrand
On Jan 21, 2015 3:29 AM, Kenneth Graunke kenn...@whitecape.org wrote:

 Matt and I noticed that one of the shaders hurt by INTEL_USE_NIR=1 had
 load_input and load_uniform intrinsics repeated several times, with the
 same parameters, but each one generating a distinct SSA value.  This
 made ALU operations on those values appear distinct as well.

 Generating distinct SSA values is silly - these are read only variables.
 CSE'ing them makes everything use a single SSA value, which then allows
 other operations to be CSE'd away as well.

 Generalizing a bit, it seems like we should be able to safely CSE any
 intrinsics that can be eliminated and reordered.  I didn't implement
 support for variables for the time being.

I think this is fine for now.  If it ever becomes a problem, we can add a
can_cse flag.  Couple comments below; otherwise,
Reviewed-by: Jason Ekstrand jason.ekstr...@intel.com

 --- NIR instruction statistics ---
 total instructions in shared programs: 2435936 - 2023511 (-16.93%)
 instructions in affected programs: 2413496 - 2001071 (-17.09%)
 helped:16872

 --- i965 instruction statistics ---
 total instructions in shared programs: 6028987 - 6008427 (-0.34%)
 instructions in affected programs: 640654 - 620094 (-3.21%)
 helped:2071
 HURT:  585
 GAINED:14
 LOST:  25

 Signed-off-by: Kenneth Graunke kenn...@whitecape.org
 ---
  src/glsl/nir/nir_opt_cse.c | 38 --
  1 file changed, 36 insertions(+), 2 deletions(-)

 diff --git a/src/glsl/nir/nir_opt_cse.c b/src/glsl/nir/nir_opt_cse.c
 index e7dba1d..6ad78f6 100644
 --- a/src/glsl/nir/nir_opt_cse.c
 +++ b/src/glsl/nir/nir_opt_cse.c
 @@ -112,7 +112,32 @@ nir_instrs_equal(nir_instr *instr1, nir_instr
*instr2)

return true;
 }
 -   case nir_instr_type_intrinsic:
 +   case nir_instr_type_intrinsic: {
 +  nir_intrinsic_instr *intrinsic1 = nir_instr_as_intrinsic(instr1);
 +  nir_intrinsic_instr *intrinsic2 = nir_instr_as_intrinsic(instr2);
 +  const nir_intrinsic_info *info =
 + nir_intrinsic_infos[intrinsic1-intrinsic];
 +
 +  if (intrinsic1-intrinsic != intrinsic2-intrinsic ||
 +  intrinsic1-num_components != intrinsic2-num_components)
 + return false;
 +
 +  if (info-has_dest  intrinsic1-dest.ssa.num_components !=
 +intrinsic2-dest.ssa.num_components)
 + return false;
 +
 +  for (unsigned i = 0; i  info-num_srcs; i++) {
 + if (!nir_srcs_equal(intrinsic1-src[i], intrinsic2-src[i]))
 +return false;
 +  }
 +
 +  for (unsigned i = 0; i  info-num_indices; i++) {
 + if (intrinsic1-const_index[i] != intrinsic2-const_index[i])
 +return false;
 +  }

Can we assert num_vars == 0 somewhere in here.  It's a comment to the
reader that the assumption is there and a placeholder for when/if we add
variable support.

 +
 +  return true;
 +   }
 case nir_instr_type_call:
 case nir_instr_type_jump:
 case nir_instr_type_ssa_undef:
 @@ -147,7 +172,13 @@ nir_instr_can_cse(nir_instr *instr)
   nir_foreach_src(instr, src_is_ssa, NULL);
 case nir_instr_type_tex:
return false; /* TODO */
 -   case nir_instr_type_intrinsic:
 +   case nir_instr_type_intrinsic: {
 +  const nir_intrinsic_info *info =
 + nir_intrinsic_infos[nir_instr_as_intrinsic(instr)-intrinsic];
 +  return (info-flags  NIR_INTRINSIC_CAN_ELIMINATE) 
 + (info-flags  NIR_INTRINSIC_CAN_REORDER) 
 + info-num_variables == 0; /* not implemented yet */

We also need to ensure sources and destination are SSA here.  Maybe that
should be pulled out of the switch.

 +   }
 case nir_instr_type_call:
 case nir_instr_type_jump:
 case nir_instr_type_ssa_undef:
 @@ -172,6 +203,9 @@ nir_instr_get_dest_ssa_def(nir_instr *instr)
 case nir_instr_type_phi:
assert(nir_instr_as_phi(instr)-dest.is_ssa);
return nir_instr_as_phi(instr)-dest.ssa;
 +   case nir_instr_type_intrinsic:
 +  assert(nir_instr_as_intrinsic(instr)-dest.is_ssa);
 +  return nir_instr_as_intrinsic(instr)-dest.ssa;
 default:
unreachable(We never ask for any of these);
 }
 --
 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


[Mesa-dev] [Bug 88467] nir.c:140: error: ‘nir_src’ has no member named ‘ssa’

2015-01-21 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=88467

--- Comment #10 from Jason Ekstrand ja...@jlekstrand.net ---
(In reply to Dave Airlie from comment #6)
 This is actually more annoying
 
 with gcc 4.4
 
 gcc -std=gnu99 supports anonymous structs, but doesn't support designated
 initialisers for anonymous structs.
 
 I'm not really sure what we can do now, I've built with -std=gnu99 and now
 get less warnings but all the designated initalisers are fail.

I've been meaning to get rid of those.  They don't work properly on msvc
either.  I'll kick out a patch later today and note it on the bug.

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


  1   2   >