[Mesa-dev] [Bug 84186] X 1.16.1 RC 1 segfaults and reports "XXX fail to create fbo" with Radeon HD 7970.

2014-12-17 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=84186

Wim Lewis  changed:

   What|Removed |Added

 CC||w...@.org

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


[Mesa-dev] [Bug 84186] X 1.16.1 RC 1 segfaults and reports "XXX fail to create fbo" with Radeon HD 7970.

2014-12-17 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=84186

--- Comment #11 from Wim Lewis  ---
Created attachment 110973
  --> https://bugs.freedesktop.org/attachment.cgi?id=110973&action=edit
Backtraces from att_incomplete()

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


[Mesa-dev] [Bug 84186] X 1.16.1 RC 1 segfaults and reports "XXX fail to create fbo" with Radeon HD 7970.

2014-12-17 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=84186

--- Comment #10 from Wim Lewis  ---
(Continuing this bug report from
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=767356)

I rebuilt with --enable-debug and got this output. I'm not sure what info is
useful, so I'm also attaching a file with stack traces from the places where
att_incomplete() was called.

(gdb) set env MESA_DEBUG=incomplete_fbo
(gdb) set env GLAMOR_DEBUG=1
(gdb) set env EGL_LOG_LEVEL=debug
(gdb) run -keeptty
X.Org X Server 1.16.2.901 (1.16.3 RC 1)
Release Date: 2014-12-09
[...snip...]
(==) Log file: "/var/log/Xorg.0.log", Time: Wed Dec 17 23:25:32 2014
(==) Using system config directory "/usr/share/X11/xorg.conf.d"
(II) [KMS] Kernel modesetting enabled.
[New Thread 0x7fffed0f6700 (LWP 5888)]
libEGL debug: Native platform type: drm (autodetected)
libEGL debug: EGL search path is /usr/lib/x86_64-linux-gnu/egl
libEGL debug: added egl_dri2 to module array
libEGL debug: the best driver is DRI2
Mesa: attachment incomplete: teximage width/height=0
Mesa: FBO Incomplete: color attachment incomplete [0]
 glamor_pixmap_ensure_fb:glamor: Failed to create fbo, incomplete
attachment
Mesa: attachment incomplete: teximage width/height=0
Mesa: FBO Incomplete: color attachment incomplete [0]
 glamor_pixmap_ensure_fb:glamor: Failed to create fbo, incomplete
attachment
XXX fail to create fbo.

Program received signal SIGSEGV, Segmentation fault.
0x713733a0 in glamor_set_screen_pixmap
(screen_pixmap=screen_pixmap@entry=0x5623db10, back_pixmap=0x0) at
../../glamor/glamor.c:122
122../../glamor/glamor.c: No such file or directory.

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


[Mesa-dev] [Bug 86701] [regression] weston-simple-egl not running anymore inside qemu

2014-12-17 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=86701

--- Comment #3 from Pekka Paalanen  ---
Actually we seem to have an even older report of a similar thing: bug #64045

-- 
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 007/133] nir: add a validation pass

2014-12-17 Thread Eric Anholt
Jason Ekstrand  writes:

> From: Connor Abbott 
>
> This is similar to ir_validate.cpp.
>
> v2: Jason Ekstrand :
>whitespace fixes

I have again not reviewed the control flow bits.  Couple of questions I
had, though:

> +static void
> +validate_var_use(nir_variable *var, validate_state *state)
> +{
> +   if (var->data.mode == nir_var_local) {
> +  struct hash_entry *entry =
> + _mesa_hash_table_search(state->var_defs, _mesa_hash_pointer(var),
> + var);
> +
> +  assert(entry);
> +  assert((nir_function_impl *) entry->data == state->impl);
> +   }
> +}

Is there guaranteed to be a def of a local variable before a use?  It
would be undefined execution behavior, but not assertion failure
quality, right?

> +static void
> +postvalidate_reg_decl(nir_register *reg, validate_state *state)
> +{
> +   struct hash_entry *entry = _mesa_hash_table_search(state->regs,
> +  
> _mesa_hash_pointer(reg),
> +  reg);
> +
> +   reg_validate_state *reg_state = (reg_validate_state *) entry->data;
> +
> +   if (reg_state->uses->entries != reg->uses->entries) {
> +  printf("extra entries in register uses:\n");
> +  struct set_entry *entry;
> +  set_foreach(reg->uses, entry) {
> + struct set_entry *entry2 =
> +_mesa_set_search(reg_state->uses, _mesa_hash_pointer(entry->key),
> + entry->key);
> +
> + if (entry2 == NULL) {
> +printf("%p\n", entry->key);
> + }
> +  }
> +
> +  abort();
> +   }
> +
> +   if (reg_state->defs->entries != reg->defs->entries) {
> +  printf("extra entries in register defs:\n");
> +  struct set_entry *entry;
> +  set_foreach(reg->defs, entry) {
> + struct set_entry *entry2 =
> +_mesa_set_search(reg_state->defs, _mesa_hash_pointer(entry->key),
> + entry->key);
> +
> + if (entry2 == NULL) {
> +printf("%p\n", entry->key);
> + }
> +  }

Couldn't these failures go the other way and there be, for example,
defs that weren't tracked in the reg?

(Not necessarily important to fix, since you'll at least get the
abort())


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


Re: [Mesa-dev] [PATCH 006/133] nir: add a printer

2014-12-17 Thread Eric Anholt
Jason Ekstrand  writes:

> From: Connor Abbott 
>
> This is similar to ir_print_visitor.cpp.


> +static void
> +print_alu_src(nir_alu_src *src, FILE *fp)
> +{
> +   if (src->negate)
> +  fprintf(fp, "-");
> +   if (src->abs)
> +  fprintf(fp, "abs(");
> +
> +   print_src(&src->src, fp);
> +
> +   if (src->swizzle[0] != 0 ||
> +   src->swizzle[1] != 1 ||
> +   src->swizzle[2] != 2 ||
> +   src->swizzle[3] != 3) {
> +  fprintf(fp, ".");
> +  for (unsigned i = 0; i < 4; i++)
> + fprintf(fp, "%c", "xyzw"[src->swizzle[i]]);

Not necessary in the review process, but I've been thinking it would be
nice to use nir_alu_instr_channel_used() to skip printing unused swizzle
characters (replacing it with '_' maybe).  It would usually help me when
I'm reading shader dumps.

> +static void
> +print_alu_instr(nir_alu_instr *instr, FILE *fp)
> +{
> +   if (instr->has_predicate) {
> +  fprintf(fp, "(");
> +  print_src(&instr->predicate, fp);
> +  fprintf(fp, ") ");
> +   }
> +
> +   print_alu_dest(&instr->dest, fp);
> +
> +   fprintf(fp, " = %s", nir_op_infos[instr->op].name);
> +   if (instr->dest.saturate)
> +  fprintf(fp, ".sat");
> +   fprintf(fp, " ");
> +
> +   bool first = true;
> +   for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++) {
> +  if (!first)
> + fprintf(fp, ", ");

replace !first with i != 0?

(optional style change throughout the file)

> +  print_alu_src(&instr->src[i], fp);
> +
> +  first = false;
> +   }
> +}


> +
> +   bool offset_nonzero = false;
> +   for (unsigned i = 0; i < 4; i++)
> +  if (instr->const_offset[i] != 0) {
> + offset_nonzero = true;
> + break;
> +  }
> +
> +   if (offset_nonzero) {
> +  fprintf(fp, "[%i %i %i %i] (offset), ",
> +  instr->const_offset[0], instr->const_offset[1],
> +  instr->const_offset[2], instr->const_offset[3]);
> +   }

cleanup: just replace the "offset_nonzero = true;" statement with this
fprintf?  (also, {} around long multi-line blocks, please, even if
they're a single statement).

Other then these little cleanups,

Reviewed-by: Eric Anholt 

I've got a patch in my series to make a single-instruction printer,
which is really nice to have for debugging in various "unreachable"
default blocks of switch statements and nir_validate and things.


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


Re: [Mesa-dev] [PATCH 004/133] nir: add the core datastructures

2014-12-17 Thread Eric Anholt
Connor Abbott  writes:

> On Tue, Dec 16, 2014 at 5:48 PM, Eric Anholt  wrote:
>> Jason Ekstrand  writes:
>>> +typedef struct {
>>> +   nir_register *reg;
>>> +   struct nir_src *indirect; /** < NULL for no indirect offset */
>>> +   unsigned base_offset;
>>> +
>>> +   /* TODO def-use chain goes here */
>>> +} nir_reg_dest;
>>
>> Aren't these TODOs resolved by the du/ud chains being in the
>> nir_register?
>
> No, those only list all the definitions and all the uses, whereas a
> hash set here would tell use which definitions each use can pick up
> and which use each definition can reach (AKA the UD and DU chains).
> That being said, the plan is to do all the optimizations in SSA, so
> unless someone has a burning need to do optimizations in non-SSA NIR
> it's pretty useless.

Oh, I see.  That would certainly be useful if you were doing non-SSA
optimization.


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


Re: [Mesa-dev] [PATCH 091/133] nir: Add a pass to lower local variable accesses to SSA values

2014-12-17 Thread Connor Abbott
On Wed, Dec 17, 2014 at 10:50 PM, Jason Ekstrand  wrote:
>
>
> On Wed, Dec 17, 2014 at 7:13 PM, Connor Abbott  wrote:
>>
>> On Tue, Dec 16, 2014 at 1:11 AM, Jason Ekstrand 
>> wrote:
>> > This pass analizes all of the load/store operations and, when a variable
>> > is
>> > never aliased (potentially used by an indirect operation), it is lowered
>> > directly to an SSA value.  This pass translates to SSA directly and does
>> > not require any fixup by the original to-SSA pass.
>> > ---
>> >  src/glsl/Makefile.sources  |1 +
>> >  src/glsl/nir/nir.h |2 +
>> >  src/glsl/nir/nir_lower_variables.c | 1071
>> > 
>> >  3 files changed, 1074 insertions(+)
>> >  create mode 100644 src/glsl/nir/nir_lower_variables.c
>> >
>> > diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
>> > index 84245bc..1d3b049 100644
>> > --- a/src/glsl/Makefile.sources
>> > +++ b/src/glsl/Makefile.sources
>> > @@ -24,6 +24,7 @@ NIR_FILES = \
>> > $(GLSL_SRCDIR)/nir/nir_lower_atomics.c \
>> > $(GLSL_SRCDIR)/nir/nir_lower_samplers.cpp \
>> > $(GLSL_SRCDIR)/nir/nir_lower_system_values.c \
>> > +   $(GLSL_SRCDIR)/nir/nir_lower_variables.c \
>> > $(GLSL_SRCDIR)/nir/nir_lower_variables_scalar.c \
>> > $(GLSL_SRCDIR)/nir/nir_lower_vec_to_movs.c \
>> > $(GLSL_SRCDIR)/nir/nir_metadata.c \
>> > diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
>> > index 86cda07..b3abfb9 100644
>> > --- a/src/glsl/nir/nir.h
>> > +++ b/src/glsl/nir/nir.h
>> > @@ -1358,6 +1358,8 @@ void nir_dump_cfg(nir_shader *shader, FILE *fp);
>> >
>> >  void nir_split_var_copies(nir_shader *shader);
>> >
>> > +void nir_lower_variables(nir_shader *shader);
>> > +
>> >  void nir_lower_variables_scalar(nir_shader *shader, bool lower_globals,
>> >  bool lower_io, bool add_names,
>> >  bool native_integers);
>> > diff --git a/src/glsl/nir/nir_lower_variables.c
>> > b/src/glsl/nir/nir_lower_variables.c
>> > new file mode 100644
>> > index 000..052b021
>> > --- /dev/null
>> > +++ b/src/glsl/nir/nir_lower_variables.c
>> > @@ -0,0 +1,1071 @@
>> > +/*
>> > + * 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"
>> > +
>> > +struct deref_node {
>> > +   struct deref_node *parent;
>> > +   const struct glsl_type *type;
>> > +
>> > +   bool lower_to_ssa;
>> > +
>> > +   struct set *loads;
>> > +   struct set *stores;
>> > +   struct set *copies;
>> > +
>> > +   nir_ssa_def **def_stack;
>> > +   nir_ssa_def **def_stack_tail;
>> > +
>> > +   struct deref_node *wildcard;
>> > +   struct deref_node *indirect;
>> > +   struct deref_node *children[0];
>> > +};
>>
>> I think this should be a typedef'd struct, that's the way everything
>> else is in NIR, including all the other pass-specific structures (all
>> bikesheds aside).
>
>
> Sure, and I think I certainly will if it gets moved to a header file.  In
> general, I haven't been typdef'ing pass-specific stuff.  Maybe you were, but
> I haven't.
>
>>
>>
>> > +
>> > +struct lower_variables_state {
>> > +   void *mem_ctx;
>> > +   void *dead_ctx;
>> > +   nir_function_impl *impl;
>> > +
>> > +   /* A hash table mapping variables to deref_node data */
>> > +   struct hash_table *deref_var_nodes;
>> > +   /* A hash table mapping dereference leaves to deref_node data */
>> > +   struct hash_table *deref_leaves;
>> > +
>> > +   /* A hash table mapping phi nodes to deref_state data */
>> > +   struct hash_table *phi_table;
>> > +};
>> > +
>> > +/* The following two functions implement

Re: [Mesa-dev] [PATCH 091/133] nir: Add a pass to lower local variable accesses to SSA values

2014-12-17 Thread Jason Ekstrand
On Wed, Dec 17, 2014 at 7:13 PM, Connor Abbott  wrote:
>
> On Tue, Dec 16, 2014 at 1:11 AM, Jason Ekstrand 
> wrote:
> > This pass analizes all of the load/store operations and, when a variable
> is
> > never aliased (potentially used by an indirect operation), it is lowered
> > directly to an SSA value.  This pass translates to SSA directly and does
> > not require any fixup by the original to-SSA pass.
> > ---
> >  src/glsl/Makefile.sources  |1 +
> >  src/glsl/nir/nir.h |2 +
> >  src/glsl/nir/nir_lower_variables.c | 1071
> 
> >  3 files changed, 1074 insertions(+)
> >  create mode 100644 src/glsl/nir/nir_lower_variables.c
> >
> > diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
> > index 84245bc..1d3b049 100644
> > --- a/src/glsl/Makefile.sources
> > +++ b/src/glsl/Makefile.sources
> > @@ -24,6 +24,7 @@ NIR_FILES = \
> > $(GLSL_SRCDIR)/nir/nir_lower_atomics.c \
> > $(GLSL_SRCDIR)/nir/nir_lower_samplers.cpp \
> > $(GLSL_SRCDIR)/nir/nir_lower_system_values.c \
> > +   $(GLSL_SRCDIR)/nir/nir_lower_variables.c \
> > $(GLSL_SRCDIR)/nir/nir_lower_variables_scalar.c \
> > $(GLSL_SRCDIR)/nir/nir_lower_vec_to_movs.c \
> > $(GLSL_SRCDIR)/nir/nir_metadata.c \
> > diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> > index 86cda07..b3abfb9 100644
> > --- a/src/glsl/nir/nir.h
> > +++ b/src/glsl/nir/nir.h
> > @@ -1358,6 +1358,8 @@ void nir_dump_cfg(nir_shader *shader, FILE *fp);
> >
> >  void nir_split_var_copies(nir_shader *shader);
> >
> > +void nir_lower_variables(nir_shader *shader);
> > +
> >  void nir_lower_variables_scalar(nir_shader *shader, bool lower_globals,
> >  bool lower_io, bool add_names,
> >  bool native_integers);
> > diff --git a/src/glsl/nir/nir_lower_variables.c
> b/src/glsl/nir/nir_lower_variables.c
> > new file mode 100644
> > index 000..052b021
> > --- /dev/null
> > +++ b/src/glsl/nir/nir_lower_variables.c
> > @@ -0,0 +1,1071 @@
> > +/*
> > + * 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"
> > +
> > +struct deref_node {
> > +   struct deref_node *parent;
> > +   const struct glsl_type *type;
> > +
> > +   bool lower_to_ssa;
> > +
> > +   struct set *loads;
> > +   struct set *stores;
> > +   struct set *copies;
> > +
> > +   nir_ssa_def **def_stack;
> > +   nir_ssa_def **def_stack_tail;
> > +
> > +   struct deref_node *wildcard;
> > +   struct deref_node *indirect;
> > +   struct deref_node *children[0];
> > +};
>
> I think this should be a typedef'd struct, that's the way everything
> else is in NIR, including all the other pass-specific structures (all
> bikesheds aside).
>

Sure, and I think I certainly will if it gets moved to a header file.  In
general, I haven't been typdef'ing pass-specific stuff.  Maybe you were,
but I haven't.


>
> > +
> > +struct lower_variables_state {
> > +   void *mem_ctx;
> > +   void *dead_ctx;
> > +   nir_function_impl *impl;
> > +
> > +   /* A hash table mapping variables to deref_node data */
> > +   struct hash_table *deref_var_nodes;
> > +   /* A hash table mapping dereference leaves to deref_node data */
> > +   struct hash_table *deref_leaves;
> > +
> > +   /* A hash table mapping phi nodes to deref_state data */
> > +   struct hash_table *phi_table;
> > +};
> > +
> > +/* The following two functions implement a hash and equality check for
> > + * variable dreferences.  When the hash or equality function encounters
> an
> > + * array, all indirects are treated as equal and are never equal to a
> > + * direct dereference or a wildcard.
> > +

Re: [Mesa-dev] [PATCH 000/123] Reintroducing NIR, a new IR for mesa

2014-12-17 Thread Connor Abbott
On Wed, Dec 17, 2014 at 1:59 AM, Connor Abbott  wrote:
> Patches 23-26, 28, 30-35, 37-38, 40, (41 gets killed later so I didn't
> review it), 42-44 are
>
> Reviewed-by: Connor Abbott 
>
> I'm going to bed now, but I'll try to do some more later.

Patches 47-48, 52-54, 56-58, 60-64, 66-70, 72-73, 76-87, and 89 are also

Reviewed-by: Connor Abbott 

>
> On Tue, Dec 16, 2014 at 1:04 AM, Jason Ekstrand  wrote:
>> NIR (pronounced "ner") is a new IR (internal representation) for the Mesa
>> shader compiler that will sit between the old IR (GLSL IR) and back-end
>> compilers.  The primary purpose of NIR is to be more efficient for doing
>> optimizations and generate better code for the back-ends.  We have a lot of
>> optimizations implemented in GLSL IR right now.  However, they still
>> generate fairly bad code primarily because its tree-based structure makes
>> writing good optimizations difficult.  For this reason, we have implemented
>> a lot of optimizations in the i965 back-end compilers just to fix up the
>> code we get from GLSL IR.  The "proper fix" to this is to implement a
>> better high-level IR; enter NIR.
>>
>> Most of the initial work on NIR including setting up common data
>> structures, helper methods, and a few basic passes was by Connor Abbot who
>> interned with us over the summer.  Connor did a fantastic job, but there is
>> still a lot left to be done.  I've spent the last two months trying to fill
>> in the pieces that we need in order to get NIR off the ground.  At this
>> point, we now have compitent in and out of SSA passes, are at zero piglit
>> regressions for i965 SIMD8 fragment shaders, and the shader-db numbers
>> aren't terrible.
>>
>> This is still a bit experimental.  I have been testing only on HSW but it
>> should work ok on SNB and later.  Eventually, once we get booleans fixed
>> up, it should work fine on older chips as well.  It also doesn't yet
>> support SIMD16, so performance won't be that great.  That said, I think we
>> are at the point now where we should try and land this and I can stop
>> developing in my masive private branch.  Since this isn't quite ready for
>> prime-time yet, using it requires setting the INTEL_USE_NIR environment
>> variable.
>>
>> A few key points about NIR:
>>
>>  1. It is primarily an SSA-based IR.
>>  2. It supports source/destination-modifiers and swizzles/*write-masks.
>>  3. Standard GPU operations such as sin() and fmad() are first-class ALU
>> operations, not intrinsics.
>>  4. GLSL concepts like inputs, outputs, uniforms, etc. are built into the
>> IR so we can do proper analysis on them.
>>  5. Even though it's SSA, it still has a concept of registers and
>> write-masks in the core IR data structures.  This means we can generate
>> code that is much closer to what backends want.
>>  6. Control flow is structured explicitly in the IR.
>>
>> (*write-masks are not available for SSA values)
>>
>> While source/destination modifiers and writemasks/swizzles are not
>> particularly useful for optimizations, having them represented in the IR
>> gives us the ability to generate more useful code for backends.
>>
>> A few notes about review:
>>
>>  1. For those of you who aren't interested in the general compiler, I'm
>> sorry for the patch-bomb.  However, several people have requsted that
>> we maintain the history of the NIR development since connor's original
>> drop at the end of the summer.  Therefore, while I've squashed several
>> things, I've tried to leave the diff of what I've done more-or-less
>> preserved.
>>
>>  2. No, this is not LLVM.  There was a long-winded discussion about that
>> when Connor dropped his patches that went a whole lot of nowhere as
>> usual.  I would really prefer if we left that debate alone.  If there
>> must be bikeshedding on the topic, please do so on the cover-letter
>> e-mail.
>>
>>  3. Please keep all bikeshedding about C++, typedefs, etc.  on the core
>> datastructures e-mail.  If we need, we can split that off in its own
>> thread.
>>
>>  4. While I welcome review, I don't plan to make non-trivial changes to
>> specific patches or squash anything beyond what has already been
>> squashed.  I've tried thus far to more-or-less keep the history and I'd
>> like to continue this if we can.
>>
>>  5. Eric Anholt has also written NIR -> TGSI -> NIR passes which will
>> hopefully get landed soon after NIR initially lands.  Exactly how that
>> all gets hooked up for other gallium drivers beyond vc4 is outside the
>> scope of this series.
>>
>> I have pushed a branch to my personal freedesktop.org account.  For certain
>> types of review, it may be easier to look at the end result rather than the
>> patches.  The branch can be found via freedesktop cgit here:
>>
>> http://cgit.freedesktop.org/~jekstrand/mesa/log/?h=review/nir-v1
>>
>> Last week, I did a presentation for some of the other Intel people to try
>> and help bring them 

Re: [Mesa-dev] [PATCH 091/133] nir: Add a pass to lower local variable accesses to SSA values

2014-12-17 Thread Connor Abbott
On Wed, Dec 17, 2014 at 10:13 PM, Connor Abbott  wrote:
> On Tue, Dec 16, 2014 at 1:11 AM, Jason Ekstrand  wrote:
>> This pass analizes all of the load/store operations and, when a variable is
>> never aliased (potentially used by an indirect operation), it is lowered
>> directly to an SSA value.  This pass translates to SSA directly and does
>> not require any fixup by the original to-SSA pass.
>> ---
>>  src/glsl/Makefile.sources  |1 +
>>  src/glsl/nir/nir.h |2 +
>>  src/glsl/nir/nir_lower_variables.c | 1071 
>> 
>>  3 files changed, 1074 insertions(+)
>>  create mode 100644 src/glsl/nir/nir_lower_variables.c
>>
>> diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
>> index 84245bc..1d3b049 100644
>> --- a/src/glsl/Makefile.sources
>> +++ b/src/glsl/Makefile.sources
>> @@ -24,6 +24,7 @@ NIR_FILES = \
>> $(GLSL_SRCDIR)/nir/nir_lower_atomics.c \
>> $(GLSL_SRCDIR)/nir/nir_lower_samplers.cpp \
>> $(GLSL_SRCDIR)/nir/nir_lower_system_values.c \
>> +   $(GLSL_SRCDIR)/nir/nir_lower_variables.c \
>> $(GLSL_SRCDIR)/nir/nir_lower_variables_scalar.c \
>> $(GLSL_SRCDIR)/nir/nir_lower_vec_to_movs.c \
>> $(GLSL_SRCDIR)/nir/nir_metadata.c \
>> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
>> index 86cda07..b3abfb9 100644
>> --- a/src/glsl/nir/nir.h
>> +++ b/src/glsl/nir/nir.h
>> @@ -1358,6 +1358,8 @@ void nir_dump_cfg(nir_shader *shader, FILE *fp);
>>
>>  void nir_split_var_copies(nir_shader *shader);
>>
>> +void nir_lower_variables(nir_shader *shader);
>> +
>>  void nir_lower_variables_scalar(nir_shader *shader, bool lower_globals,
>>  bool lower_io, bool add_names,
>>  bool native_integers);
>> diff --git a/src/glsl/nir/nir_lower_variables.c 
>> b/src/glsl/nir/nir_lower_variables.c
>> new file mode 100644
>> index 000..052b021
>> --- /dev/null
>> +++ b/src/glsl/nir/nir_lower_variables.c
>> @@ -0,0 +1,1071 @@
>> +/*
>> + * 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"
>> +
>> +struct deref_node {
>> +   struct deref_node *parent;
>> +   const struct glsl_type *type;
>> +
>> +   bool lower_to_ssa;
>> +
>> +   struct set *loads;
>> +   struct set *stores;
>> +   struct set *copies;
>> +
>> +   nir_ssa_def **def_stack;
>> +   nir_ssa_def **def_stack_tail;
>> +
>> +   struct deref_node *wildcard;
>> +   struct deref_node *indirect;
>> +   struct deref_node *children[0];
>> +};
>
> I think this should be a typedef'd struct, that's the way everything
> else is in NIR, including all the other pass-specific structures (all
> bikesheds aside).
>
>> +
>> +struct lower_variables_state {
>> +   void *mem_ctx;
>> +   void *dead_ctx;
>> +   nir_function_impl *impl;
>> +
>> +   /* A hash table mapping variables to deref_node data */
>> +   struct hash_table *deref_var_nodes;
>> +   /* A hash table mapping dereference leaves to deref_node data */
>> +   struct hash_table *deref_leaves;
>> +
>> +   /* A hash table mapping phi nodes to deref_state data */
>> +   struct hash_table *phi_table;
>> +};
>> +
>> +/* The following two functions implement a hash and equality check for
>> + * variable dreferences.  When the hash or equality function encounters an
>> + * array, all indirects are treated as equal and are never equal to a
>> + * direct dereference or a wildcard.
>> + */
>> +static uint32_t
>> +hash_deref(const void *void_deref)
>> +{
>> +   const nir_deref *deref = void_deref;
>> +
>> +   uint32_t hash;
>> +   if (deref->child) {
>> +  hash = hash_deref(deref->child);
>> +   } else {
>> +  hash = 2166136261ul;
>> +   }
>> +
>> +   switch (

Re: [Mesa-dev] [PATCH 090/133] nir: Add a copy splitting pass

2014-12-17 Thread Connor Abbott
On Wed, Dec 17, 2014 at 9:38 PM, Jason Ekstrand  wrote:
>
>
> On Wed, Dec 17, 2014 at 6:01 PM, Connor Abbott  wrote:
>>
>> > +
>> > +static nir_deref *
>> > +get_deref_tail(nir_deref *deref)
>> > +{
>> > +   while (deref->child != NULL)
>> > +  deref = deref->child;
>> > +   return deref;
>> > +}
>>
>> I think long-term, we should probably make dereferences exec lists so
>> we don't have to do things like this. In the meantime, though, I
>> could've sworn I had to write this exact same function somewhere else
>> (glsl to nir?)... might be a good idea to move this to nir.c and reuse
>> it, unless nobody else needs this.
>
>
> I also thought about making them a single block of data and dropping the
> linked list thing entirely.  It always has to start with a variable and the
> only difference between an array deref and a structure deref is that an
> array deref can have an indirect/wildcard.  This would make it a little more
> awkward to build the deref chains, but they would take less memory and
> copying/iterating would be easier.  That said, I haven't written the patch
> yet, so I don't know how hard it would be.

Yeah, a lot of things would be better than what we have now. I'm still
leaning a bit towards linked lists rather than arrays, but if you can
come up with something that makes functions like
nir_split_var_copy_instr() easier to write I'd be happy too.

>
> And yes, I copied that function from lower_variables_scalar.
>
>>
>>
>> > +
>> > +static void
>> > +nir_split_var_copy_instr(nir_intrinsic_instr *old_copy,
>> > + nir_deref *dest_head, nir_deref *src_head,
>> > + nir_deref *dest_tail, nir_deref *src_tail,
>> > + struct split_var_copies_state *state)
>>
>> It took me a while to see exactly what this is doing, why we need
>> separate dest_tail and src_tail variables even though they're almost
>> always the same, and how it creates this temporary deref chain that's
>> shared between source and destination (a no-no in NIR) but that's ok
>> because they both get copied at the very end of the recursion when we
>> actually emit the instructions. I'd like to see a comment explaining
>> how this function works that explains those things.
>
>
> Sure.  A comment would be a good plan.  Also, I do modify deref chains in
> several of my patches.  Sometimes I even set them back.  Yes, this is
> probably bad form.  However, the kind of iteration we're doing almost
> requires it.  I'd like to come up with a better plan for that at some point,
> but I haven't found one yet.
> --Jason

Yeah, although at least to me, doing "modify the variable; recurse;
un-modify it" is a lot more obvious than what's going on here. I know
dealing with this stuff is painful... it's sort of a relic of GLSL IR,
but I haven't thought of a better way to do it either. At least it's
fairly contained, in that only a limited number of optimization and
lowering passes will have to deal with it.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 091/133] nir: Add a pass to lower local variable accesses to SSA values

2014-12-17 Thread Connor Abbott
On Tue, Dec 16, 2014 at 1:11 AM, Jason Ekstrand  wrote:
> This pass analizes all of the load/store operations and, when a variable is
> never aliased (potentially used by an indirect operation), it is lowered
> directly to an SSA value.  This pass translates to SSA directly and does
> not require any fixup by the original to-SSA pass.
> ---
>  src/glsl/Makefile.sources  |1 +
>  src/glsl/nir/nir.h |2 +
>  src/glsl/nir/nir_lower_variables.c | 1071 
> 
>  3 files changed, 1074 insertions(+)
>  create mode 100644 src/glsl/nir/nir_lower_variables.c
>
> diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
> index 84245bc..1d3b049 100644
> --- a/src/glsl/Makefile.sources
> +++ b/src/glsl/Makefile.sources
> @@ -24,6 +24,7 @@ NIR_FILES = \
> $(GLSL_SRCDIR)/nir/nir_lower_atomics.c \
> $(GLSL_SRCDIR)/nir/nir_lower_samplers.cpp \
> $(GLSL_SRCDIR)/nir/nir_lower_system_values.c \
> +   $(GLSL_SRCDIR)/nir/nir_lower_variables.c \
> $(GLSL_SRCDIR)/nir/nir_lower_variables_scalar.c \
> $(GLSL_SRCDIR)/nir/nir_lower_vec_to_movs.c \
> $(GLSL_SRCDIR)/nir/nir_metadata.c \
> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> index 86cda07..b3abfb9 100644
> --- a/src/glsl/nir/nir.h
> +++ b/src/glsl/nir/nir.h
> @@ -1358,6 +1358,8 @@ void nir_dump_cfg(nir_shader *shader, FILE *fp);
>
>  void nir_split_var_copies(nir_shader *shader);
>
> +void nir_lower_variables(nir_shader *shader);
> +
>  void nir_lower_variables_scalar(nir_shader *shader, bool lower_globals,
>  bool lower_io, bool add_names,
>  bool native_integers);
> diff --git a/src/glsl/nir/nir_lower_variables.c 
> b/src/glsl/nir/nir_lower_variables.c
> new file mode 100644
> index 000..052b021
> --- /dev/null
> +++ b/src/glsl/nir/nir_lower_variables.c
> @@ -0,0 +1,1071 @@
> +/*
> + * 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"
> +
> +struct deref_node {
> +   struct deref_node *parent;
> +   const struct glsl_type *type;
> +
> +   bool lower_to_ssa;
> +
> +   struct set *loads;
> +   struct set *stores;
> +   struct set *copies;
> +
> +   nir_ssa_def **def_stack;
> +   nir_ssa_def **def_stack_tail;
> +
> +   struct deref_node *wildcard;
> +   struct deref_node *indirect;
> +   struct deref_node *children[0];
> +};

I think this should be a typedef'd struct, that's the way everything
else is in NIR, including all the other pass-specific structures (all
bikesheds aside).

> +
> +struct lower_variables_state {
> +   void *mem_ctx;
> +   void *dead_ctx;
> +   nir_function_impl *impl;
> +
> +   /* A hash table mapping variables to deref_node data */
> +   struct hash_table *deref_var_nodes;
> +   /* A hash table mapping dereference leaves to deref_node data */
> +   struct hash_table *deref_leaves;
> +
> +   /* A hash table mapping phi nodes to deref_state data */
> +   struct hash_table *phi_table;
> +};
> +
> +/* The following two functions implement a hash and equality check for
> + * variable dreferences.  When the hash or equality function encounters an
> + * array, all indirects are treated as equal and are never equal to a
> + * direct dereference or a wildcard.
> + */
> +static uint32_t
> +hash_deref(const void *void_deref)
> +{
> +   const nir_deref *deref = void_deref;
> +
> +   uint32_t hash;
> +   if (deref->child) {
> +  hash = hash_deref(deref->child);
> +   } else {
> +  hash = 2166136261ul;
> +   }
> +
> +   switch (deref->deref_type) {
> +   case nir_deref_type_var:
> +  hash ^= _mesa_hash_pointer(nir_deref_as_var(deref)->var);
> +  break;
> +   case nir_deref_type_array: {
> +  nir_deref_array *array 

Re: [Mesa-dev] [PATCH 090/133] nir: Add a copy splitting pass

2014-12-17 Thread Jason Ekstrand
On Wed, Dec 17, 2014 at 6:01 PM, Connor Abbott  wrote:

> > +
> > +static nir_deref *
> > +get_deref_tail(nir_deref *deref)
> > +{
> > +   while (deref->child != NULL)
> > +  deref = deref->child;
> > +   return deref;
> > +}
>
> I think long-term, we should probably make dereferences exec lists so
> we don't have to do things like this. In the meantime, though, I
> could've sworn I had to write this exact same function somewhere else
> (glsl to nir?)... might be a good idea to move this to nir.c and reuse
> it, unless nobody else needs this.
>

I also thought about making them a single block of data and dropping the
linked list thing entirely.  It always has to start with a variable and the
only difference between an array deref and a structure deref is that an
array deref can have an indirect/wildcard.  This would make it a little
more awkward to build the deref chains, but they would take less memory and
copying/iterating would be easier.  That said, I haven't written the patch
yet, so I don't know how hard it would be.

And yes, I copied that function from lower_variables_scalar.


>
> > +
> > +static void
> > +nir_split_var_copy_instr(nir_intrinsic_instr *old_copy,
> > + nir_deref *dest_head, nir_deref *src_head,
> > + nir_deref *dest_tail, nir_deref *src_tail,
> > + struct split_var_copies_state *state)
>
> It took me a while to see exactly what this is doing, why we need
> separate dest_tail and src_tail variables even though they're almost
> always the same, and how it creates this temporary deref chain that's
> shared between source and destination (a no-no in NIR) but that's ok
> because they both get copied at the very end of the recursion when we
> actually emit the instructions. I'd like to see a comment explaining
> how this function works that explains those things.
>

Sure.  A comment would be a good plan.  Also, I do modify deref chains in
several of my patches.  Sometimes I even set them back.  Yes, this is
probably bad form.  However, the kind of iteration we're doing almost
requires it.  I'd like to come up with a better plan for that at some
point, but I haven't found one yet.
--Jason
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] Finishing make distcheck

2014-12-17 Thread Matt Turner
On Fri, Dec 12, 2014 at 12:34 PM, Matt Turner  wrote:
> On Thu, Dec 11, 2014 at 2:25 AM, Emil Velikov  
> wrote:
>>  * Let's drop "mesa: Remove tarballs/checksum rules." for now. Apart
>> from the mapi issue, vdpau and xvmc will need the uninstall-hook,
>> clean-local rules.
>
> Okay, I've committed everything except that patch. I'll take a look at
> vdpau/xvmc.

I've fixed VDPAU and XvMC and pushed a small set of patches to finish distcheck!

The only remaining question is whether we want to continue shipping
zip files. Feel free to do this, anyone, if you think we should by
adding dist-zip to the line containing dist-xz in configure.ac.

Emil, when it comes time to make the 10.5 release you or I can add
support to the modular/release.sh script.

I'll go see if I can finish the subdir-objects stuff now...
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 075/133] i965/fs_nir: Handle SSA constants

2014-12-17 Thread Connor Abbott
On Wed, Dec 17, 2014 at 8:41 PM, Jason Ekstrand  wrote:
>
>
> On Wed, Dec 17, 2014 at 5:30 PM, Connor Abbott  wrote:
>>
>> On Tue, Dec 16, 2014 at 1:05 AM, Jason Ekstrand 
>> wrote:
>> > ---
>> >  src/glsl/nir/nir_from_ssa.c  | 40 -
>> >  src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 50
>> > +---
>> >  2 files changed, 65 insertions(+), 25 deletions(-)
>> >
>> > diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c
>> > index 62a54fe..9311bda 100644
>>
>> It would be nice if you could squash all the following nir_from_ssa.c
>> changes into "nir: Add a better out-of-ssa pass", since nir_from_ssa.c
>> already has some stuff about special-casing SSA constants so this is
>> rather confusing.
>
>
> Certainly, this could be split into two patches:  The first one makes i965
> ssa-const safe, and the second doesn't lower load_const SSA values.
> However, for the sake of the history, I'd like to keep it seperate from
> from_ssa.  Also, load_const is never mentioned in nir_from_ssa before this
> patch, so I'm not sure what you mean by "already have special-casing".
> --Jason

Nvm, I was reviewing this from your freedesktop branch, which had this
patch already applied. Yeah, splitting it up would be nice though.

>
>>
>>
>> > --- a/src/glsl/nir/nir_from_ssa.c
>> > +++ b/src/glsl/nir/nir_from_ssa.c
>> > @@ -469,6 +469,12 @@ get_register_for_ssa_def(nir_ssa_def *def, struct
>> > from_ssa_state *state)
>> > if (entry) {
>> >return (nir_register *)entry->data;
>> > } else {
>> > +  /* We leave load_const SSA values alone.  They act as immediates
>> > to
>> > +   * the backend.  If it got coalesced into a phi, that's ok.
>> > +   */
>> > +  if (def->parent_instr->type == nir_instr_type_load_const)
>> > + return NULL;
>> > +
>> >nir_register *reg = nir_local_reg_create(state->impl);
>> >reg->name = def->name;
>> >reg->num_components = def->num_components;
>> > @@ -486,12 +492,18 @@ rewrite_ssa_src(nir_src *src, void *void_state)
>> > struct from_ssa_state *state = void_state;
>> >
>> > if (src->is_ssa) {
>> > -  /* We don't need to remove it from the uses set because that is
>> > going
>> > -   * away.  We just need to add it to the one for the register. */
>> >nir_register *reg = get_register_for_ssa_def(src->ssa, state);
>> > +
>> > +  if (reg == NULL) {
>> > + assert(src->ssa->parent_instr->type ==
>> > nir_instr_type_load_const);
>> > + return true;
>> > +  }
>> > +
>> >memset(src, 0, sizeof *src);
>> >src->reg.reg = reg;
>> >
>> > +  /* We don't need to remove it from the uses set because that is
>> > going
>> > +   * away.  We just need to add it to the one for the register. */
>> >_mesa_set_add(reg->uses, _mesa_hash_pointer(state->instr),
>> > state->instr);
>> > }
>> >
>> > @@ -504,10 +516,16 @@ rewrite_ssa_dest(nir_dest *dest, void *void_state)
>> > struct from_ssa_state *state = void_state;
>> >
>> > if (dest->is_ssa) {
>> > +  nir_register *reg = get_register_for_ssa_def(&dest->ssa, state);
>> > +
>> > +  if (reg == NULL) {
>> > + assert(dest->ssa.parent_instr->type ==
>> > nir_instr_type_load_const);
>> > + return true;
>> > +  }
>> > +
>> >_mesa_set_destroy(dest->ssa.uses, NULL);
>> >_mesa_set_destroy(dest->ssa.if_uses, NULL);
>> >
>> > -  nir_register *reg = get_register_for_ssa_def(&dest->ssa, state);
>> >memset(dest, 0, sizeof *dest);
>> >dest->reg.reg = reg;
>> >
>> > @@ -534,7 +552,6 @@ resolve_registers_block(nir_block *block, void
>> > *void_state)
>> >instr->type == nir_instr_type_phi) {
>> >   nir_instr_remove(instr);
>> >   ralloc_steal(state->dead_ctx, instr);
>> > - continue;
>> >}
>> > }
>> > state->instr = NULL;
>> > @@ -543,11 +560,18 @@ resolve_registers_block(nir_block *block, void
>> > *void_state)
>> > if (following_if && following_if->condition.is_ssa) {
>> >nir_register *reg =
>> > get_register_for_ssa_def(following_if->condition.ssa,
>> > state);
>> > -  memset(&following_if->condition, 0, sizeof
>> > following_if->condition);
>> > -  following_if->condition.reg.reg = reg;
>> > +  if (reg) {
>> > + memset(&following_if->condition, 0, sizeof
>> > following_if->condition);
>> > + following_if->condition.reg.reg = reg;
>> >
>> > -  _mesa_set_add(reg->if_uses, _mesa_hash_pointer(following_if),
>> > -following_if);
>> > + _mesa_set_add(reg->if_uses, _mesa_hash_pointer(following_if),
>> > +   following_if);
>> > +  } else {
>> > + /* FIXME: We really shouldn't hit this.  We should be doing
>> > +  * constant control flow propagation.
>> > +  */
>> > + assert(following_if->co

Re: [Mesa-dev] [PATCH 04/41] main: Moved _mesa_lock_texture and _mesa_unlock_texture to texobj.h from teximage.h.

2014-12-17 Thread Laura Ekstrand
Nits fixed.

On Tue, Dec 16, 2014 at 7:45 AM, Brian Paul  wrote:
>
> On 12/15/2014 06:22 PM, Laura Ekstrand wrote:
>
>> ---
>>   src/mesa/drivers/dri/i965/intel_tex_copy.c |  1 +
>>   src/mesa/drivers/dri/swrast/swrast.c   |  1 +
>>   src/mesa/main/texgetimage.c|  2 +-
>>   src/mesa/main/teximage.h   | 18 --
>>   src/mesa/main/texobj.h | 18 ++
>>   5 files changed, 21 insertions(+), 19 deletions(-)
>>
>> diff --git a/src/mesa/drivers/dri/i965/intel_tex_copy.c
>> b/src/mesa/drivers/dri/i965/intel_tex_copy.c
>> index d55539a..5d249ed 100644
>> --- a/src/mesa/drivers/dri/i965/intel_tex_copy.c
>> +++ b/src/mesa/drivers/dri/i965/intel_tex_copy.c
>> @@ -28,6 +28,7 @@
>>   #include "main/mtypes.h"
>>   #include "main/enums.h"
>>   #include "main/image.h"
>> +#include "main/texobj.h"
>>   #include "main/teximage.h"
>>   #include "main/texstate.h"
>>   #include "main/fbobject.h"
>>
>
> Minor nit: we generally try to #include files in alphabetical order (same
> thing below).
>
>
>
>  diff --git a/src/mesa/drivers/dri/swrast/swrast.c
>> b/src/mesa/drivers/dri/swrast/swrast.c
>> index e8a2c12..63ebcd9 100644
>> --- a/src/mesa/drivers/dri/swrast/swrast.c
>> +++ b/src/mesa/drivers/dri/swrast/swrast.c
>> @@ -52,6 +52,7 @@
>>   #include "drivers/common/meta.h"
>>   #include "utils.h"
>>
>> +#include "main/texobj.h"
>>   #include "main/teximage.h"
>>   #include "main/texformat.h"
>>   #include "main/texstate.h"
>> diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
>> index cb5f793..1c09337 100644
>> --- a/src/mesa/main/texgetimage.c
>> +++ b/src/mesa/main/texgetimage.c
>> @@ -45,7 +45,7 @@
>>   #include "texgetimage.h"
>>   #include "teximage.h"
>>   #include "texstore.h"
>> -
>> +#include "texobj.h"
>>
>>
>>   /**
>> diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h
>> index 4b27381..f652b6c 100644
>> --- a/src/mesa/main/teximage.h
>> +++ b/src/mesa/main/teximage.h
>> @@ -160,24 +160,6 @@ _mesa_legal_texture_base_format_for_target(struct
>> gl_context *ctx,
>>  unsigned dimensions,
>>  const char *caller);
>>
>> -/**
>> - * Lock a texture for updating.  See also _mesa_lock_context_textures().
>> - */
>> -static inline void
>> -_mesa_lock_texture(struct gl_context *ctx, struct gl_texture_object
>> *texObj)
>> -{
>> -   mtx_lock(&ctx->Shared->TexMutex);
>> -   ctx->Shared->TextureStateStamp++;
>> -   (void) texObj;
>> -}
>> -
>> -static inline void
>> -_mesa_unlock_texture(struct gl_context *ctx, struct gl_texture_object
>> *texObj)
>> -{
>> -   (void) texObj;
>> -   mtx_unlock(&ctx->Shared->TexMutex);
>> -}
>> -
>>   /*@}*/
>>
>>
>> diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h
>> index abf03a1..b1534a1 100644
>> --- a/src/mesa/main/texobj.h
>> +++ b/src/mesa/main/texobj.h
>> @@ -93,6 +93,24 @@ _mesa_reference_texobj(struct gl_texture_object **ptr,
>> _mesa_reference_texobj_(ptr, tex);
>>   }
>>
>> +/**
>> + * Lock a texture for updating.  See also _mesa_lock_context_textures().
>> + */
>> +static inline void
>> +_mesa_lock_texture(struct gl_context *ctx, struct gl_texture_object
>> *texObj)
>> +{
>> +   mtx_lock(&ctx->Shared->TexMutex);
>> +   ctx->Shared->TextureStateStamp++;
>> +   (void) texObj;
>> +}
>> +
>> +static inline void
>> +_mesa_unlock_texture(struct gl_context *ctx, struct gl_texture_object
>> *texObj)
>> +{
>> +   (void) texObj;
>> +   mtx_unlock(&ctx->Shared->TexMutex);
>> +}
>> +
>>
>>   /**
>>* Return number of faces for a texture target.  This will be 6 for
>>
>>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 051/133] nir: Add an SSA-based liveness analysis pass.

2014-12-17 Thread Connor Abbott
On Wed, Dec 17, 2014 at 8:48 PM, Jason Ekstrand  wrote:
>
>
> On Wed, Dec 17, 2014 at 2:23 PM, Connor Abbott  wrote:
>>
>> On Wed, Dec 17, 2014 at 5:11 PM, Jason Ekstrand 
>> wrote:
>> > On Wed, Dec 17, 2014 at 1:52 PM, Connor Abbott 
>> > wrote:
>> >>
>> >> I'm sure you're already aware, but there are two things we could do to
>> >> speed this up:
>> >>
>> >> 1. Pre-compute def/kill sets for each block similar to what i965 does.
>> >
>> >
>> > Sure, but we walk the instructions at most deepest block depth + 1 and
>> > the
>> > depest we've ever seen in the wild is 2.
>>
>> Well, there's always orbital explorer ;)
>>
>> >
>> >> 2. Use a worklist + an array of flags for "this block is in the
>> >> worklist" rather than walking all the basic blocks in reverse to find
>> >> the few we need to update.
>> >
>> >
>> > Sure, we could, but I don't see how pushing the blocks onto a stack and
>> > then
>> > popping them back off really gains us anything over just walking them.
>> > If
>> > there's something I'm missing, please let me know because it's not
>> > jumping
>> > out at me.  I'll freely admit that I'm not terribly familiar with
>> > worklists.
>>
>> I didn't mean a stack, I meant a FIFO queue. The idea is that rather
>> than walking through every instruction, even when there are only
>> changes to be made, we pop a pointer to a block off the worklist, see
>> if it's live-in set changed, and if it did, we push every predecessor
>> not already in the worklist onto the worklist and then mark the block
>> as not being in the worklist. We start by pushing all the blocks in
>> the worklist in reverse order, since that's the most efficient
>> ordering. Then, we're only processing blocks that we know might change
>> rather than every possible one, and for control flow without loops we
>> only walk the instructions once instead of twice. I think this is
>> going to be a pretty common thing for optimization passes to do, so it
>> would be nice to have a common implementation of the worklist.
>
>
> Reading through that a second time and it makes more sense now.  Sure, we
> could do it that way and it is more efficient.  However, that's also a
> pretty solid rewrite so I think it'll have to wait until more pressing
> things get done.
> --Jason

Ok.

>
>>
>>
>> >
>> >>
>> >>
>> >> Wrt #2, we already use a worklist in the DCE pass, but it's kinda lame
>> >> because it's using a linked list when we could just allocate an array
>> >> of pointers up-front based on the maximum size (the number of blocks
>> >> in this case, the number of SSA definitions in that case) and use it
>> >> as a ringbuffer. It would be a nice cleanup to implement such a
>> >> bounded worklist and share it between these two passes, since we'll
>> >> probably want to use it for lots of other passes too.
>> >>
>> >> I don't either thing should block merging this, though.
>> >>
>> >> A few other comments below.
>> >>
>> >> On Tue, Dec 16, 2014 at 1:05 AM, Jason Ekstrand 
>> >> wrote:
>> >> > ---
>> >> >  src/glsl/Makefile.sources |   1 +
>> >> >  src/glsl/nir/nir.h|  13 ++
>> >> >  src/glsl/nir/nir_live_variables.c | 282
>> >> > ++
>> >> >  src/glsl/nir/nir_metadata.c   |   2 +
>> >> >  src/mesa/main/bitset.h|   1 +
>> >> >  5 files changed, 299 insertions(+)
>> >> >  create mode 100644 src/glsl/nir/nir_live_variables.c
>> >> >
>> >> > diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
>> >> > index 4eb6320..433224e 100644
>> >> > --- a/src/glsl/Makefile.sources
>> >> > +++ b/src/glsl/Makefile.sources
>> >> > @@ -20,6 +20,7 @@ NIR_FILES = \
>> >> > $(GLSL_SRCDIR)/nir/nir_from_ssa.c \
>> >> > $(GLSL_SRCDIR)/nir/nir_intrinsics.c \
>> >> > $(GLSL_SRCDIR)/nir/nir_intrinsics.h \
>> >> > +   $(GLSL_SRCDIR)/nir/nir_live_variables.c \
>> >> > $(GLSL_SRCDIR)/nir/nir_lower_atomics.c \
>> >> > $(GLSL_SRCDIR)/nir/nir_lower_samplers.cpp \
>> >> > $(GLSL_SRCDIR)/nir/nir_lower_system_values.c \
>> >> > diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
>> >> > index f744736..2f2edb6 100644
>> >> > --- a/src/glsl/nir/nir.h
>> >> > +++ b/src/glsl/nir/nir.h
>> >> > @@ -420,6 +420,9 @@ typedef struct {
>> >> > /** generic SSA definition index. */
>> >> > unsigned index;
>> >> >
>> >> > +   /** Index into the live_in and live_out bitfields */
>> >> > +   unsigned live_index;
>> >> > +
>> >> > nir_instr *parent_instr;
>> >> >
>> >> > struct set *uses;
>> >> > @@ -999,6 +1002,10 @@ typedef struct nir_block {
>> >> > struct nir_block **dom_children;
>> >> >
>> >> > struct set *dom_frontier;
>> >> > +
>> >> > +   /* live in and out for this block; used for liveness analysis */
>> >> > +   BITSET_WORD *live_in;
>> >> > +   BITSET_WORD *live_out;
>> >> >  } nir_block;
>> >> >
>> >> >  #define nir_block_first_instr(block) \
>> >> > @@ -1047,6 +1054,7 @@ typedef enum {
>> >> > nir_metadata_none = 0x0,
>> >> >

Re: [Mesa-dev] [PATCH 090/133] nir: Add a copy splitting pass

2014-12-17 Thread Connor Abbott
On Tue, Dec 16, 2014 at 1:11 AM, Jason Ekstrand  wrote:
> ---
>  src/glsl/Makefile.sources   |   1 +
>  src/glsl/nir/nir.h  |   2 +
>  src/glsl/nir/nir_split_var_copies.c | 225 
> 
>  3 files changed, 228 insertions(+)
>  create mode 100644 src/glsl/nir/nir_split_var_copies.c
>
> diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
> index 20496ff..84245bc 100644
> --- a/src/glsl/Makefile.sources
> +++ b/src/glsl/Makefile.sources
> @@ -37,6 +37,7 @@ NIR_FILES = \
> $(GLSL_SRCDIR)/nir/nir_opt_peephole_select.c \
> $(GLSL_SRCDIR)/nir/nir_print.c \
> $(GLSL_SRCDIR)/nir/nir_remove_dead_variables.c \
> +   $(GLSL_SRCDIR)/nir/nir_split_var_copies.c \
> $(GLSL_SRCDIR)/nir/nir_to_ssa.c \
> $(GLSL_SRCDIR)/nir/nir_validate.c \
> $(GLSL_SRCDIR)/nir/nir_types.cpp \
> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> index fc16cb5..86cda07 100644
> --- a/src/glsl/nir/nir.h
> +++ b/src/glsl/nir/nir.h
> @@ -1356,6 +1356,8 @@ void nir_dump_dom_frontier(nir_shader *shader, FILE 
> *fp);
>  void nir_dump_cfg_impl(nir_function_impl *impl, FILE *fp);
>  void nir_dump_cfg(nir_shader *shader, FILE *fp);
>
> +void nir_split_var_copies(nir_shader *shader);
> +
>  void nir_lower_variables_scalar(nir_shader *shader, bool lower_globals,
>  bool lower_io, bool add_names,
>  bool native_integers);
> diff --git a/src/glsl/nir/nir_split_var_copies.c 
> b/src/glsl/nir/nir_split_var_copies.c
> new file mode 100644
> index 000..19724b6
> --- /dev/null
> +++ b/src/glsl/nir/nir_split_var_copies.c
> @@ -0,0 +1,225 @@
> +/*
> + * 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 "copy splitting" which is similar to structure splitting only
> + * it works on copy operations rather than the datatypes themselves.  The
> + * GLSL language allows you to copy one variable to another an entire
> + * structure (which may contain arrays or other structures) at a time.
> + * Normally, in a language such as C this would be handled by a "structure
> + * splitting" pass that breaks up the structures.  Unfortunately for us,
> + * structures used in inputs or outputs can't be split.  Therefore,
> + * regardlesss of what we do, we have to be able to copy to/from
> + * structures.
> + *
> + * The primary purpose of structure splitting is to allow you to better
> + * optimize variable access and lower things to registers where you can.
> + * The primary issue here is that, if you lower the copy to a bunch of
> + * loads and stores, you loose a lot of information about the copy
> + * operation that you would like to keep around.  To solve this problem, we
> + * have a "copy splitting" pass that, instead of splitting the structures
> + * or lowering the copy into loads and storres, splits the copy operation
> + * into a bunch of copy operations one for each leaf of the structure tree.
> + * If an intermediate array is encountered, it is referenced with a
> + * wildcard reference to indicate that the entire array is to be copied.
> + *
> + * As things become direct, array copies may be able to be losslessly
> + * lowered to having fewer and fewer wildcards.  However, until that
> + * happens we want to keep the information about the arrays intact.
> + *
> + * Prior to the copy splitting pass, there are no wildcard references but
> + * there may be incomplete references where the tail of the deref chain is
> + * an array or a structure and not a specific element.  After the copy
> + * splitting pass has completed, every variable deref will be a full-length
> + * dereference pointing to a single leaf in the s

Re: [Mesa-dev] [PATCH 02/41] main: Created a standard function that looks up a texture object by its ID and throws INVALID_OPERATION if the ID isn't in the hash table.

2014-12-17 Thread Laura Ekstrand
That makes sense. It's now

main: Added utility function _mesa_lookup_texture_err().

On Wed, Dec 17, 2014 at 3:47 AM, Anuj Phogat  wrote:
>
> Keep the subject of commit message short (under 50 chars) and use present
> tense.
> Here you can use "mesa: Add utility function _mesa_lookup_texture_error()".
>
> On Tue, Dec 16, 2014 at 6:52 AM, Laura Ekstrand 
> wrote:
> > Most ARB_DIRECT_STATE_ACCESS functions take an object's ID and use it to
> look
> > up the object in its hash table.  If the user passes a fake object ID
> (ie. a
> > non-generated name), the implementation should throw INVALID_OPERATION.
> > This is a convenience function for texture objects.
> > ---
> >  src/mesa/main/texobj.c | 17 -
> >  src/mesa/main/texobj.h |  3 +++
> >  2 files changed, 19 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
> > index 923cf60..49ab2c4 100644
> > --- a/src/mesa/main/texobj.c
> > +++ b/src/mesa/main/texobj.c
> > @@ -60,6 +60,22 @@ _mesa_lookup_texture(struct gl_context *ctx, GLuint
> id)
> >_mesa_HashLookup(ctx->Shared->TexObjects, id);
> >  }
> >
> > +/**
> > + * Wrapper around _mesa_lookup_texture that throws GL_INVALID_OPERATION
> if id
> > + * is not in the hash table. After calling _mesa_error, it returns NULL.
> > + */
> > +struct gl_texture_object *
> > +_mesa_lookup_texture_err(struct gl_context *ctx, GLuint id, const char*
> func)
> I would use the name _mesa_lookup_texture_error() here.
> > +{
> > +   struct gl_texture_object *texObj;
> > +
> > +   texObj = _mesa_lookup_texture(ctx, id); /* Returns NULL if not
> found. */
> > +
> > +   if (!texObj)
> > +  _mesa_error(ctx, GL_INVALID_OPERATION, "%s(texture)", func);
> > +
> > +   return texObj;
> > +}
> >
> >  void
> >  _mesa_begin_texture_lookups(struct gl_context *ctx)
> > @@ -1419,7 +1435,6 @@ _mesa_BindTexture( GLenum target, GLuint texName )
> >ctx->Driver.BindTexture(ctx, ctx->Texture.CurrentUnit, target,
> newTexObj);
> >  }
> >
> > -
> unwanted change.
> >  void GLAPIENTRY
> >  _mesa_BindTextures(GLuint first, GLsizei count, const GLuint *textures)
> >  {
> > diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h
> > index b1b7a30..abf03a1 100644
> > --- a/src/mesa/main/texobj.h
> > +++ b/src/mesa/main/texobj.h
> > @@ -46,6 +46,9 @@
> >  extern struct gl_texture_object *
> >  _mesa_lookup_texture(struct gl_context *ctx, GLuint id);
> >
> > +extern struct gl_texture_object *
> > +_mesa_lookup_texture_err(struct gl_context *ctx, GLuint id, const char*
> func);
> > +
> >  extern void
> >  _mesa_begin_texture_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 mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 03/41] i965: intel_tex_image.c now accepts TEXTURE_CUBE_MAP as a valid target.

2014-12-17 Thread Laura Ekstrand
Sure.  It's now
i965: blit_texture_to_pbo() now accepts TEXTURE_CUBE_MAP.

On Wed, Dec 17, 2014 at 4:20 AM, Anuj Phogat  wrote:
>
> How about using below subject?
> i965: intel_get_tex_image() now accepts TEXTURE_CUBE_MAP as a valid target
>
> It's more specific than using a file name. I'll leave it up to you if
> you want to make this change.
>
> On Tue, Dec 16, 2014 at 6:52 AM, Laura Ekstrand 
> wrote:
> > ARB_DIRECT_STATE_ACCESS permits the user to use TEXTURE_CUBE_MAP as a
> target.
> > ---
> >  src/mesa/drivers/dri/i965/intel_tex_image.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c
> b/src/mesa/drivers/dri/i965/intel_tex_image.c
> > index 3317779..855a6b4 100644
> > --- a/src/mesa/drivers/dri/i965/intel_tex_image.c
> > +++ b/src/mesa/drivers/dri/i965/intel_tex_image.c
> > @@ -459,6 +459,7 @@ blit_texture_to_pbo(struct gl_context *ctx,
> >
> > if (target == GL_TEXTURE_1D_ARRAY ||
> > target == GL_TEXTURE_2D_ARRAY ||
> > +   target == GL_TEXTURE_CUBE_MAP ||
> > target == GL_TEXTURE_CUBE_MAP_ARRAY ||
> > target == GL_TEXTURE_3D) {
> >perf_debug("%s: no support for multiple slices, fallback to CPU
> mapping "
> > --
> > 2.1.0
> >
> > ___
> > mesa-dev mailing list
> > mesa-dev@lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 051/133] nir: Add an SSA-based liveness analysis pass.

2014-12-17 Thread Jason Ekstrand
On Wed, Dec 17, 2014 at 2:23 PM, Connor Abbott  wrote:
>
> On Wed, Dec 17, 2014 at 5:11 PM, Jason Ekstrand 
> wrote:
> > On Wed, Dec 17, 2014 at 1:52 PM, Connor Abbott 
> wrote:
> >>
> >> I'm sure you're already aware, but there are two things we could do to
> >> speed this up:
> >>
> >> 1. Pre-compute def/kill sets for each block similar to what i965 does.
> >
> >
> > Sure, but we walk the instructions at most deepest block depth + 1 and
> the
> > depest we've ever seen in the wild is 2.
>
> Well, there's always orbital explorer ;)
>
> >
> >> 2. Use a worklist + an array of flags for "this block is in the
> >> worklist" rather than walking all the basic blocks in reverse to find
> >> the few we need to update.
> >
> >
> > Sure, we could, but I don't see how pushing the blocks onto a stack and
> then
> > popping them back off really gains us anything over just walking them.
> If
> > there's something I'm missing, please let me know because it's not
> jumping
> > out at me.  I'll freely admit that I'm not terribly familiar with
> worklists.
>
> I didn't mean a stack, I meant a FIFO queue. The idea is that rather
> than walking through every instruction, even when there are only
> changes to be made, we pop a pointer to a block off the worklist, see
> if it's live-in set changed, and if it did, we push every predecessor
> not already in the worklist onto the worklist and then mark the block
> as not being in the worklist. We start by pushing all the blocks in
> the worklist in reverse order, since that's the most efficient
> ordering. Then, we're only processing blocks that we know might change
> rather than every possible one, and for control flow without loops we
> only walk the instructions once instead of twice. I think this is
> going to be a pretty common thing for optimization passes to do, so it
> would be nice to have a common implementation of the worklist.
>

Reading through that a second time and it makes more sense now.  Sure, we
could do it that way and it is more efficient.  However, that's also a
pretty solid rewrite so I think it'll have to wait until more pressing
things get done.
--Jason


>
> >
> >>
> >>
> >> Wrt #2, we already use a worklist in the DCE pass, but it's kinda lame
> >> because it's using a linked list when we could just allocate an array
> >> of pointers up-front based on the maximum size (the number of blocks
> >> in this case, the number of SSA definitions in that case) and use it
> >> as a ringbuffer. It would be a nice cleanup to implement such a
> >> bounded worklist and share it between these two passes, since we'll
> >> probably want to use it for lots of other passes too.
> >>
> >> I don't either thing should block merging this, though.
> >>
> >> A few other comments below.
> >>
> >> On Tue, Dec 16, 2014 at 1:05 AM, Jason Ekstrand 
> >> wrote:
> >> > ---
> >> >  src/glsl/Makefile.sources |   1 +
> >> >  src/glsl/nir/nir.h|  13 ++
> >> >  src/glsl/nir/nir_live_variables.c | 282
> >> > ++
> >> >  src/glsl/nir/nir_metadata.c   |   2 +
> >> >  src/mesa/main/bitset.h|   1 +
> >> >  5 files changed, 299 insertions(+)
> >> >  create mode 100644 src/glsl/nir/nir_live_variables.c
> >> >
> >> > diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
> >> > index 4eb6320..433224e 100644
> >> > --- a/src/glsl/Makefile.sources
> >> > +++ b/src/glsl/Makefile.sources
> >> > @@ -20,6 +20,7 @@ NIR_FILES = \
> >> > $(GLSL_SRCDIR)/nir/nir_from_ssa.c \
> >> > $(GLSL_SRCDIR)/nir/nir_intrinsics.c \
> >> > $(GLSL_SRCDIR)/nir/nir_intrinsics.h \
> >> > +   $(GLSL_SRCDIR)/nir/nir_live_variables.c \
> >> > $(GLSL_SRCDIR)/nir/nir_lower_atomics.c \
> >> > $(GLSL_SRCDIR)/nir/nir_lower_samplers.cpp \
> >> > $(GLSL_SRCDIR)/nir/nir_lower_system_values.c \
> >> > diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> >> > index f744736..2f2edb6 100644
> >> > --- a/src/glsl/nir/nir.h
> >> > +++ b/src/glsl/nir/nir.h
> >> > @@ -420,6 +420,9 @@ typedef struct {
> >> > /** generic SSA definition index. */
> >> > unsigned index;
> >> >
> >> > +   /** Index into the live_in and live_out bitfields */
> >> > +   unsigned live_index;
> >> > +
> >> > nir_instr *parent_instr;
> >> >
> >> > struct set *uses;
> >> > @@ -999,6 +1002,10 @@ typedef struct nir_block {
> >> > struct nir_block **dom_children;
> >> >
> >> > struct set *dom_frontier;
> >> > +
> >> > +   /* live in and out for this block; used for liveness analysis */
> >> > +   BITSET_WORD *live_in;
> >> > +   BITSET_WORD *live_out;
> >> >  } nir_block;
> >> >
> >> >  #define nir_block_first_instr(block) \
> >> > @@ -1047,6 +1054,7 @@ typedef enum {
> >> > nir_metadata_none = 0x0,
> >> > nir_metadata_block_index = 0x1,
> >> > nir_metadata_dominance = 0x2,
> >> > +   nir_metadata_live_variables = 0x4,
> >> >  } nir_metadata;
> >> >
> >> >  typedef struct {
> >> > @@ -1274,6 +1282,8 @

Re: [Mesa-dev] [PATCH 089/133] nir: Automatically update SSA if uses

2014-12-17 Thread Connor Abbott
Can we move this right after patch 53 (nir: Automatically handle SSA
uses when an instruction is inserted), since they're doing similar
things?

On Tue, Dec 16, 2014 at 1:11 AM, Jason Ekstrand  wrote:
> ---
>  src/glsl/nir/nir.c | 9 -
>  1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
> index 07d7b94..a4edc79 100644
> --- a/src/glsl/nir/nir.c
> +++ b/src/glsl/nir/nir.c
> @@ -1004,13 +1004,12 @@ update_if_uses(nir_cf_node *node)
>return;
>
> nir_if *if_stmt = nir_cf_node_as_if(node);
> -   if (if_stmt->condition.is_ssa)
> -  return;
>
> -   nir_register *reg = if_stmt->condition.reg.reg;
> -   assert(reg != NULL);
> +   struct set *if_uses_set = if_stmt->condition.is_ssa ?
> + if_stmt->condition.ssa->if_uses :
> + if_stmt->condition.reg.reg->uses;
>
> -   _mesa_set_add(reg->if_uses, _mesa_hash_pointer(if_stmt), if_stmt);
> +   _mesa_set_add(if_uses_set, _mesa_hash_pointer(if_stmt), if_stmt);
>  }
>
>  void
> --
> 2.2.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 088/133] nir: Use the enum for the variable mode

2014-12-17 Thread Jason Ekstrand
On Wed, Dec 17, 2014 at 5:39 PM, Connor Abbott  wrote:

> Again, this looks pretty self-contained and pretty easy to squash.
>

Sure.


>
> On Tue, Dec 16, 2014 at 1:11 AM, Jason Ekstrand 
> wrote:
> > ---
> >  src/glsl/nir/nir.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> > index b04a137..fc16cb5 100644
> > --- a/src/glsl/nir/nir.h
> > +++ b/src/glsl/nir/nir.h
> > @@ -155,7 +155,7 @@ typedef struct {
> > *
> > * \sa nir_variable_mode
> > */
> > -  unsigned mode:4;
> > +  nir_variable_mode mode:4;
> >
> >/**
> > * Interpolation mode for shader inputs / outputs
> > --
> > 2.2.0
> >
> > ___
> > mesa-dev mailing list
> > mesa-dev@lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 075/133] i965/fs_nir: Handle SSA constants

2014-12-17 Thread Jason Ekstrand
On Wed, Dec 17, 2014 at 5:30 PM, Connor Abbott  wrote:
>
> On Tue, Dec 16, 2014 at 1:05 AM, Jason Ekstrand 
> wrote:
> > ---
> >  src/glsl/nir/nir_from_ssa.c  | 40 -
> >  src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 50
> +---
> >  2 files changed, 65 insertions(+), 25 deletions(-)
> >
> > diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c
> > index 62a54fe..9311bda 100644
>
> It would be nice if you could squash all the following nir_from_ssa.c
> changes into "nir: Add a better out-of-ssa pass", since nir_from_ssa.c
> already has some stuff about special-casing SSA constants so this is
> rather confusing.
>

Certainly, this could be split into two patches:  The first one makes i965
ssa-const safe, and the second doesn't lower load_const SSA values.
However, for the sake of the history, I'd like to keep it seperate from
from_ssa.  Also, load_const is never mentioned in nir_from_ssa before this
patch, so I'm not sure what you mean by "already have special-casing".
--Jason


>
> > --- a/src/glsl/nir/nir_from_ssa.c
> > +++ b/src/glsl/nir/nir_from_ssa.c
> > @@ -469,6 +469,12 @@ get_register_for_ssa_def(nir_ssa_def *def, struct
> from_ssa_state *state)
> > if (entry) {
> >return (nir_register *)entry->data;
> > } else {
> > +  /* We leave load_const SSA values alone.  They act as immediates
> to
> > +   * the backend.  If it got coalesced into a phi, that's ok.
> > +   */
> > +  if (def->parent_instr->type == nir_instr_type_load_const)
> > + return NULL;
> > +
> >nir_register *reg = nir_local_reg_create(state->impl);
> >reg->name = def->name;
> >reg->num_components = def->num_components;
> > @@ -486,12 +492,18 @@ rewrite_ssa_src(nir_src *src, void *void_state)
> > struct from_ssa_state *state = void_state;
> >
> > if (src->is_ssa) {
> > -  /* We don't need to remove it from the uses set because that is
> going
> > -   * away.  We just need to add it to the one for the register. */
> >nir_register *reg = get_register_for_ssa_def(src->ssa, state);
> > +
> > +  if (reg == NULL) {
> > + assert(src->ssa->parent_instr->type ==
> nir_instr_type_load_const);
> > + return true;
> > +  }
> > +
> >memset(src, 0, sizeof *src);
> >src->reg.reg = reg;
> >
> > +  /* We don't need to remove it from the uses set because that is
> going
> > +   * away.  We just need to add it to the one for the register. */
> >_mesa_set_add(reg->uses, _mesa_hash_pointer(state->instr),
> state->instr);
> > }
> >
> > @@ -504,10 +516,16 @@ rewrite_ssa_dest(nir_dest *dest, void *void_state)
> > struct from_ssa_state *state = void_state;
> >
> > if (dest->is_ssa) {
> > +  nir_register *reg = get_register_for_ssa_def(&dest->ssa, state);
> > +
> > +  if (reg == NULL) {
> > + assert(dest->ssa.parent_instr->type ==
> nir_instr_type_load_const);
> > + return true;
> > +  }
> > +
> >_mesa_set_destroy(dest->ssa.uses, NULL);
> >_mesa_set_destroy(dest->ssa.if_uses, NULL);
> >
> > -  nir_register *reg = get_register_for_ssa_def(&dest->ssa, state);
> >memset(dest, 0, sizeof *dest);
> >dest->reg.reg = reg;
> >
> > @@ -534,7 +552,6 @@ resolve_registers_block(nir_block *block, void
> *void_state)
> >instr->type == nir_instr_type_phi) {
> >   nir_instr_remove(instr);
> >   ralloc_steal(state->dead_ctx, instr);
> > - continue;
> >}
> > }
> > state->instr = NULL;
> > @@ -543,11 +560,18 @@ resolve_registers_block(nir_block *block, void
> *void_state)
> > if (following_if && following_if->condition.is_ssa) {
> >nir_register *reg =
> get_register_for_ssa_def(following_if->condition.ssa,
> > state);
> > -  memset(&following_if->condition, 0, sizeof
> following_if->condition);
> > -  following_if->condition.reg.reg = reg;
> > +  if (reg) {
> > + memset(&following_if->condition, 0, sizeof
> following_if->condition);
> > + following_if->condition.reg.reg = reg;
> >
> > -  _mesa_set_add(reg->if_uses, _mesa_hash_pointer(following_if),
> > -following_if);
> > + _mesa_set_add(reg->if_uses, _mesa_hash_pointer(following_if),
> > +   following_if);
> > +  } else {
> > + /* FIXME: We really shouldn't hit this.  We should be doing
> > +  * constant control flow propagation.
> > +  */
> > + assert(following_if->condition.ssa->parent_instr->type ==
> nir_instr_type_load_const);
> > +  }
> > }
> >
> > return true;
> > diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> > index 3ec2fa6..019d649 100644
> > --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> > +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> 

Re: [Mesa-dev] [PATCH 088/133] nir: Use the enum for the variable mode

2014-12-17 Thread Connor Abbott
Again, this looks pretty self-contained and pretty easy to squash.

On Tue, Dec 16, 2014 at 1:11 AM, Jason Ekstrand  wrote:
> ---
>  src/glsl/nir/nir.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> index b04a137..fc16cb5 100644
> --- a/src/glsl/nir/nir.h
> +++ b/src/glsl/nir/nir.h
> @@ -155,7 +155,7 @@ typedef struct {
> *
> * \sa nir_variable_mode
> */
> -  unsigned mode:4;
> +  nir_variable_mode mode:4;
>
>/**
> * Interpolation mode for shader inputs / outputs
> --
> 2.2.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 071/133] nir: Add a fused multiply-add peephole

2014-12-17 Thread Jason Ekstrand
On Wed, Dec 17, 2014 at 5:13 PM, Connor Abbott  wrote:
>
> Would it be possible to drop this patch since this all gets deleted later?
>

We could, but I'd rather leave it in the history.
--Jason


>
> On Tue, Dec 16, 2014 at 1:05 AM, Jason Ekstrand 
> wrote:
> > ---
> >  src/glsl/Makefile.sources|   1 +
> >  src/glsl/nir/nir.h   |   1 +
> >  src/glsl/nir/nir_opcodes.h   |   1 +
> >  src/glsl/nir/nir_opt_peephole_ffma.c | 191
> +++
> >  src/mesa/drivers/dri/i965/brw_fs_nir.cpp |   2 +
> >  5 files changed, 196 insertions(+)
> >  create mode 100644 src/glsl/nir/nir_opt_peephole_ffma.c
> >
> > diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
> > index 38ffb85..31608dc 100644
> > --- a/src/glsl/Makefile.sources
> > +++ b/src/glsl/Makefile.sources
> > @@ -32,6 +32,7 @@ NIR_FILES = \
> > $(GLSL_SRCDIR)/nir/nir_opt_copy_propagate.c \
> > $(GLSL_SRCDIR)/nir/nir_opt_dce.c \
> > $(GLSL_SRCDIR)/nir/nir_opt_global_to_local.c \
> > +   $(GLSL_SRCDIR)/nir/nir_opt_peephole_ffma.c \
> > $(GLSL_SRCDIR)/nir/nir_opt_peephole_select.c \
> > $(GLSL_SRCDIR)/nir/nir_print.c \
> > $(GLSL_SRCDIR)/nir/nir_remove_dead_variables.c \
> > diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> > index bc2280b..e20eb7c 100644
> > --- a/src/glsl/nir/nir.h
> > +++ b/src/glsl/nir/nir.h
> > @@ -1374,6 +1374,7 @@ bool nir_opt_dce_impl(nir_function_impl *impl);
> >  bool nir_opt_dce(nir_shader *shader);
> >
> >  bool nir_opt_peephole_select(nir_shader *shader);
> > +bool nir_opt_peephole_ffma(nir_shader *shader);
> >
> >  #ifdef __cplusplus
> >  } /* extern "C" */
> > diff --git a/src/glsl/nir/nir_opcodes.h b/src/glsl/nir/nir_opcodes.h
> > index 988f691..35d4634 100644
> > --- a/src/glsl/nir/nir_opcodes.h
> > +++ b/src/glsl/nir/nir_opcodes.h
> > @@ -307,6 +307,7 @@ BINOP_HORIZ(vec2, 2, nir_type_unsigned, 1,
> nir_type_unsigned, 1, nir_type_unsign
> > ARR(src1_size, src2_size, src3_size), \
> > ARR(nir_type_unsigned, nir_type_unsigned, nir_type_unsigned))
> >
> > +/* fma(a, b, c) = (a * b) + c */
> >  TRIOP(ffma, nir_type_float)
> >
> >  TRIOP(flrp, nir_type_float)
> > diff --git a/src/glsl/nir/nir_opt_peephole_ffma.c
> b/src/glsl/nir/nir_opt_peephole_ffma.c
> > new file mode 100644
> > index 000..2c9b8e5
> > --- /dev/null
> > +++ b/src/glsl/nir/nir_opt_peephole_ffma.c
> > @@ -0,0 +1,191 @@
> > +/*
> > + * 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 a small peephole optimization that looks for a multiply
> that
> > + * is only ever used in an add and replaces both with an fma.
> > + */
> > +
> > +struct peephole_ffma_state {
> > +   void *mem_ctx;
> > +   nir_function_impl *impl;
> > +   bool progress;
> > +};
> > +
> > +static inline nir_alu_instr *
> > +get_mul_for_src(nir_alu_instr *add, unsigned idx)
> > +{
> > +   if (!add->src[idx].src.is_ssa)
> > +  return NULL;
> > +
> > +   /* We can't handle these in between the operations */
> > +   if (add->src[idx].negate || add->src[idx].abs)
> > +  return NULL;
> > +
> > +   nir_instr *instr = add->src[idx].src.ssa->parent_instr;
> > +   if (instr->type != nir_instr_type_alu)
> > +  return NULL;
> > +
> > +   nir_alu_instr *mul = nir_instr_as_alu(instr);
> > +   if (mul->op != nir_op_fmul)
> > +  return NULL;
> > +
> > +   /* Can't handle a saturate in between */
> > +   if (mul->dest.saturate)
> > +  return NULL;
> > +
> > +   /* We already know that the same source is not used twice in the add
> and
> > +* we will assume valid use-def information, so this check is
> 

Re: [Mesa-dev] [PATCH 07/11] mesa: implement glGetCompressedTextureSubImage()

2014-12-17 Thread Laura Ekstrand
On Sat, Dec 13, 2014 at 6:42 AM, Brian Paul  wrote:
>
> ---
>  src/mesa/main/texgetimage.c | 440
> +---
>  src/mesa/main/texgetimage.h |   7 +
>  2 files changed, 297 insertions(+), 150 deletions(-)
>
> diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
> index ced6a34..ac0be35 100644
> --- a/src/mesa/main/texgetimage.c
> +++ b/src/mesa/main/texgetimage.c
> @@ -25,7 +25,8 @@
>
>
>  /**
> - * Code for glGetTexImage() and glGetCompressedTexImage().
> + * Code for glGetTexImage(), glGetCompressedTexImage(),
> + * glGetTextureSubImage() and glGetCompressedTextureSubImage(),
>   */
>
>
> @@ -717,10 +718,8 @@ _mesa_get_compressed_texsubimage(struct gl_context
> *ctx,
> GLubyte *dest;
>
> _mesa_compute_compressed_pixelstore(dimensions, texImage->TexFormat,
> -   texImage->Width, texImage->Height,
> -   texImage->Depth,
> -   &ctx->Pack,
> -   &store);
> +   width, height, depth,
> +   &ctx->Pack, &store);
>
> if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
>/* pack texture image into a PBO */
> @@ -731,7 +730,7 @@ _mesa_get_compressed_texsubimage(struct gl_context
> *ctx,
>if (!dest) {
>   /* out of memory or other unexpected error */
>   _mesa_error(ctx, GL_OUT_OF_MEMORY,
> - "glGetCompresssedTexImage(map PBO failed)");
> +"glGetCompresssedTexImage/TextureSubImage(map PBO
> failed)");
>   return;
>}
>dest = ADD_POINTERS(dest, img);
> @@ -746,25 +745,27 @@ _mesa_get_compressed_texsubimage(struct gl_context
> *ctx,
>GLubyte *src;
>
>/* map src texture buffer */
> -  ctx->Driver.MapTextureImage(ctx, texImage, 0,
> -  0, 0, texImage->Width, texImage->Height,
> +  ctx->Driver.MapTextureImage(ctx, texImage, zoffset + slice,
> +  xoffset, yoffset, width, height,
>GL_MAP_READ_BIT, &src, &srcRowStride);
>
>if (src) {
> -
> + /* Copy a row of blocks */
>   for (i = 0; i < store.CopyRowsPerSlice; i++) {
>  memcpy(dest, src, store.CopyBytesPerRow);
>  dest += store.TotalBytesPerRow;
>  src += srcRowStride;
>   }
>
> - ctx->Driver.UnmapTextureImage(ctx, texImage, 0);
> + ctx->Driver.UnmapTextureImage(ctx, texImage, zoffset + slice);
>
>   /* Advance to next slice */
>   dest += store.TotalBytesPerRow * (store.TotalRowsPerSlice -
> store.CopyRowsPerSlice);
>
>} else {
> - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetCompresssedTexImage");
> + _mesa_error(ctx, GL_OUT_OF_MEMORY,
> + "glGetCompresssedTexImage/TextureSubImage");
> + break; /* don't try the remaining slices */
>}
> }
>
> @@ -821,6 +822,12 @@ getteximage_error_check(struct gl_context *ctx,
> const GLint maxLevels = _mesa_max_texture_levels(ctx, target);
> GLenum baseFormat, err;
>
> +   if (maxLevels == 0) {
> +  /* invalid texture (gen'd but never defined) */
> +  _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid texture)",
> caller);
> +  return GL_TRUE;
> +   }
> +
> assert(maxLevels != 0);
> if (level < 0 || level >= maxLevels) {
>_mesa_error(ctx, GL_INVALID_VALUE, "%s(level)", caller);
> @@ -888,7 +895,9 @@ getteximage_error_check(struct gl_context *ctx,
>
>
>  /**
> - * Do error checking related to the PBO and image size.
> + * Do error checking related to the PBO and image size (for returning
> + * uncompressed images only).
> + * \return true if error is found, false otherwise.
>   */
>  static bool
>  pbo_error_check(struct gl_context *ctx, GLenum target,
> @@ -1006,145 +1015,36 @@ _mesa_GetTexImage( GLenum target, GLint level,
> GLenum format,
>
>
>  /**
> - * Do error checking for a glGetCompressedTexImage() call.
> - * \return GL_TRUE if any error, GL_FALSE if no errors.
> + * Compute the number of bytes that will be read/written from/to a buffer
> + * when packing/unpacking a compressed image.  This observes the given GL
> + * pixel store state which may specify non-default GL_SKIP_PIXEL,
> + * GL_ROW_LENGTH, etc. values for compressed images.
> + * Basically, if the value we compute here is larger than the dest/src
> buffer
> + * size, we'll have to raise an GL_INVALID_OPERATION (out of bounds)
> error.
> + *
> + * \return number of bytes which will be read/written.
>   */
> -static GLboolean
> -getcompressedteximage_error_check(struct gl_context *ctx, GLenum target,
> -  GLint level, GLsizei clientMemSize,
> GLvoid *img)
> +static GLsizei
> +packed_compressed_size(GLuint dimensions, mesa_format format,
> +   GLsi

Re: [Mesa-dev] [PATCH 075/133] i965/fs_nir: Handle SSA constants

2014-12-17 Thread Connor Abbott
On Tue, Dec 16, 2014 at 1:05 AM, Jason Ekstrand  wrote:
> ---
>  src/glsl/nir/nir_from_ssa.c  | 40 -
>  src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 50 
> +---
>  2 files changed, 65 insertions(+), 25 deletions(-)
>
> diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c
> index 62a54fe..9311bda 100644

It would be nice if you could squash all the following nir_from_ssa.c
changes into "nir: Add a better out-of-ssa pass", since nir_from_ssa.c
already has some stuff about special-casing SSA constants so this is
rather confusing.

> --- a/src/glsl/nir/nir_from_ssa.c
> +++ b/src/glsl/nir/nir_from_ssa.c
> @@ -469,6 +469,12 @@ get_register_for_ssa_def(nir_ssa_def *def, struct 
> from_ssa_state *state)
> if (entry) {
>return (nir_register *)entry->data;
> } else {
> +  /* We leave load_const SSA values alone.  They act as immediates to
> +   * the backend.  If it got coalesced into a phi, that's ok.
> +   */
> +  if (def->parent_instr->type == nir_instr_type_load_const)
> + return NULL;
> +
>nir_register *reg = nir_local_reg_create(state->impl);
>reg->name = def->name;
>reg->num_components = def->num_components;
> @@ -486,12 +492,18 @@ rewrite_ssa_src(nir_src *src, void *void_state)
> struct from_ssa_state *state = void_state;
>
> if (src->is_ssa) {
> -  /* We don't need to remove it from the uses set because that is going
> -   * away.  We just need to add it to the one for the register. */
>nir_register *reg = get_register_for_ssa_def(src->ssa, state);
> +
> +  if (reg == NULL) {
> + assert(src->ssa->parent_instr->type == nir_instr_type_load_const);
> + return true;
> +  }
> +
>memset(src, 0, sizeof *src);
>src->reg.reg = reg;
>
> +  /* We don't need to remove it from the uses set because that is going
> +   * away.  We just need to add it to the one for the register. */
>_mesa_set_add(reg->uses, _mesa_hash_pointer(state->instr), 
> state->instr);
> }
>
> @@ -504,10 +516,16 @@ rewrite_ssa_dest(nir_dest *dest, void *void_state)
> struct from_ssa_state *state = void_state;
>
> if (dest->is_ssa) {
> +  nir_register *reg = get_register_for_ssa_def(&dest->ssa, state);
> +
> +  if (reg == NULL) {
> + assert(dest->ssa.parent_instr->type == nir_instr_type_load_const);
> + return true;
> +  }
> +
>_mesa_set_destroy(dest->ssa.uses, NULL);
>_mesa_set_destroy(dest->ssa.if_uses, NULL);
>
> -  nir_register *reg = get_register_for_ssa_def(&dest->ssa, state);
>memset(dest, 0, sizeof *dest);
>dest->reg.reg = reg;
>
> @@ -534,7 +552,6 @@ resolve_registers_block(nir_block *block, void 
> *void_state)
>instr->type == nir_instr_type_phi) {
>   nir_instr_remove(instr);
>   ralloc_steal(state->dead_ctx, instr);
> - continue;
>}
> }
> state->instr = NULL;
> @@ -543,11 +560,18 @@ resolve_registers_block(nir_block *block, void 
> *void_state)
> if (following_if && following_if->condition.is_ssa) {
>nir_register *reg = 
> get_register_for_ssa_def(following_if->condition.ssa,
> state);
> -  memset(&following_if->condition, 0, sizeof following_if->condition);
> -  following_if->condition.reg.reg = reg;
> +  if (reg) {
> + memset(&following_if->condition, 0, sizeof following_if->condition);
> + following_if->condition.reg.reg = reg;
>
> -  _mesa_set_add(reg->if_uses, _mesa_hash_pointer(following_if),
> -following_if);
> + _mesa_set_add(reg->if_uses, _mesa_hash_pointer(following_if),
> +   following_if);
> +  } else {
> + /* FIXME: We really shouldn't hit this.  We should be doing
> +  * constant control flow propagation.
> +  */
> + assert(following_if->condition.ssa->parent_instr->type == 
> nir_instr_type_load_const);
> +  }
> }
>
> return true;
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp 
> b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> index 3ec2fa6..019d649 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> @@ -981,25 +981,37 @@ fs_visitor::nir_emit_alu(nir_alu_instr *instr)
>  fs_reg
>  fs_visitor::get_nir_src(nir_src src)
>  {
> -   fs_reg reg;
> -   if (src.reg.reg->is_global)
> -  reg = nir_globals[src.reg.reg->index];
> -   else
> -  reg = nir_locals[src.reg.reg->index];
> +   if (src.is_ssa) {
> +  assert(src.ssa->parent_instr->type == nir_instr_type_load_const);
> +  nir_load_const_instr *load = 
> nir_instr_as_load_const(src.ssa->parent_instr);
> +  fs_reg reg(GRF, virtual_grf_alloc(src.ssa->num_components),
> + BRW_REGISTER_TYPE_D);
>
> -   /* to avoid floating-point denorm flushing problems, s

Re: [Mesa-dev] [PATCH 074/133] i965/fs_nir: Use an array rather than a hash table for register lookup

2014-12-17 Thread Connor Abbott
We shouldn't ever have global registers until we start dealing with
subroutines, so you don't need to handle them here.

On Tue, Dec 16, 2014 at 1:05 AM, Jason Ekstrand  wrote:
> ---
>  src/mesa/drivers/dri/i965/brw_fs.h   |  4 +--
>  src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 46 
> +++-
>  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp |  5 +--
>  3 files changed, 30 insertions(+), 25 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.h 
> b/src/mesa/drivers/dri/i965/brw_fs.h
> index c244781..6b50c7d 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs.h
> +++ b/src/mesa/drivers/dri/i965/brw_fs.h
> @@ -572,7 +572,6 @@ public:
> void nir_setup_inputs(nir_shader *shader);
> void nir_setup_outputs(nir_shader *shader);
> void nir_setup_uniforms(nir_shader *shader);
> -   void nir_setup_registers(exec_list *regs);
> void nir_setup_uniform(nir_variable *var);
> void nir_setup_builtin_uniform(nir_variable *var);
> void nir_emit_impl(nir_function_impl *impl);
> @@ -698,7 +697,8 @@ public:
> fs_reg *fp_temp_regs;
> fs_reg *fp_input_regs;
>
> -   struct hash_table *nir_reg_ht;
> +   fs_reg *nir_locals;
> +   fs_reg *nir_globals;
> fs_reg nir_inputs;
> fs_reg nir_outputs;
> fs_reg nir_uniforms;
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp 
> b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> index 5703225..3ec2fa6 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
> @@ -98,7 +98,13 @@ fs_visitor::emit_nir_code()
>nir_setup_uniforms(nir);
> }
>
> -   nir_setup_registers(&nir->registers);
> +   nir_globals = ralloc_array(mem_ctx, fs_reg, nir->reg_alloc);
> +   foreach_list_typed(nir_register, reg, node, &nir->registers) {
> +  unsigned array_elems =
> + reg->num_array_elems == 0 ? 1 : reg->num_array_elems;
> +  unsigned size = array_elems * reg->num_components;
> +  nir_globals[reg->index] = fs_reg(GRF, virtual_grf_alloc(size));
> +   }
>
> /* get the main function and emit it */
> nir_foreach_overload(nir, overload) {
> @@ -276,22 +282,16 @@ fs_visitor::nir_setup_builtin_uniform(nir_variable *var)
>  }
>
>  void
> -fs_visitor::nir_setup_registers(exec_list *list)
> +fs_visitor::nir_emit_impl(nir_function_impl *impl)
>  {
> -   foreach_list_typed(nir_register, nir_reg, node, list) {
> +   nir_locals = reralloc(mem_ctx, nir_locals, fs_reg, impl->reg_alloc);
> +   foreach_list_typed(nir_register, reg, node, &impl->registers) {
>unsigned array_elems =
> - nir_reg->num_array_elems == 0 ? 1 : nir_reg->num_array_elems;
> -  unsigned size = array_elems * nir_reg->num_components;
> -  fs_reg *reg = new(mem_ctx) fs_reg(GRF, virtual_grf_alloc(size));
> -  _mesa_hash_table_insert(this->nir_reg_ht, _mesa_hash_pointer(nir_reg),
> -  nir_reg, reg);
> + reg->num_array_elems == 0 ? 1 : reg->num_array_elems;
> +  unsigned size = array_elems * reg->num_components;
> +  nir_locals[reg->index] = fs_reg(GRF, virtual_grf_alloc(size));
> }
> -}
>
> -void
> -fs_visitor::nir_emit_impl(nir_function_impl *impl)
> -{
> -   nir_setup_registers(&impl->registers);
> nir_emit_cf_list(&impl->body);
>  }
>
> @@ -981,10 +981,12 @@ fs_visitor::nir_emit_alu(nir_alu_instr *instr)
>  fs_reg
>  fs_visitor::get_nir_src(nir_src src)
>  {
> -   struct hash_entry *entry =
> -  _mesa_hash_table_search(this->nir_reg_ht, 
> _mesa_hash_pointer(src.reg.reg),
> -  src.reg.reg);
> -   fs_reg reg = *((fs_reg *) entry->data);
> +   fs_reg reg;
> +   if (src.reg.reg->is_global)
> +  reg = nir_globals[src.reg.reg->index];
> +   else
> +  reg = nir_locals[src.reg.reg->index];
> +
> /* to avoid floating-point denorm flushing problems, set the type by
>  * default to D - instructions that need floating point semantics will set
>  * this to F if they need to
> @@ -1042,10 +1044,12 @@ fs_visitor::get_nir_alu_src(nir_alu_instr *instr, 
> unsigned src)
>  fs_reg
>  fs_visitor::get_nir_dest(nir_dest dest)
>  {
> -   struct hash_entry *entry =
> -  _mesa_hash_table_search(this->nir_reg_ht,
> -  _mesa_hash_pointer(dest.reg.reg), 
> dest.reg.reg);
> -   fs_reg reg = *((fs_reg *) entry->data);
> +   fs_reg reg;
> +   if (dest.reg.reg->is_global)
> +  reg = nir_globals[dest.reg.reg->index];
> +   else
> +  reg = nir_locals[dest.reg.reg->index];
> +
> reg.reg_offset = dest.reg.base_offset;
> if (dest.reg.indirect) {
>reg.reladdr = new(mem_ctx) fs_reg();
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp 
> b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> index fd7dd43..9b73595 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> @@ -3820,7 +3820,9 @@ fs_visitor::init()
> this->variable_ht = hash_table_ctor(0,
> 

Re: [Mesa-dev] [PATCH 071/133] nir: Add a fused multiply-add peephole

2014-12-17 Thread Connor Abbott
Would it be possible to drop this patch since this all gets deleted later?

On Tue, Dec 16, 2014 at 1:05 AM, Jason Ekstrand  wrote:
> ---
>  src/glsl/Makefile.sources|   1 +
>  src/glsl/nir/nir.h   |   1 +
>  src/glsl/nir/nir_opcodes.h   |   1 +
>  src/glsl/nir/nir_opt_peephole_ffma.c | 191 
> +++
>  src/mesa/drivers/dri/i965/brw_fs_nir.cpp |   2 +
>  5 files changed, 196 insertions(+)
>  create mode 100644 src/glsl/nir/nir_opt_peephole_ffma.c
>
> diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
> index 38ffb85..31608dc 100644
> --- a/src/glsl/Makefile.sources
> +++ b/src/glsl/Makefile.sources
> @@ -32,6 +32,7 @@ NIR_FILES = \
> $(GLSL_SRCDIR)/nir/nir_opt_copy_propagate.c \
> $(GLSL_SRCDIR)/nir/nir_opt_dce.c \
> $(GLSL_SRCDIR)/nir/nir_opt_global_to_local.c \
> +   $(GLSL_SRCDIR)/nir/nir_opt_peephole_ffma.c \
> $(GLSL_SRCDIR)/nir/nir_opt_peephole_select.c \
> $(GLSL_SRCDIR)/nir/nir_print.c \
> $(GLSL_SRCDIR)/nir/nir_remove_dead_variables.c \
> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> index bc2280b..e20eb7c 100644
> --- a/src/glsl/nir/nir.h
> +++ b/src/glsl/nir/nir.h
> @@ -1374,6 +1374,7 @@ bool nir_opt_dce_impl(nir_function_impl *impl);
>  bool nir_opt_dce(nir_shader *shader);
>
>  bool nir_opt_peephole_select(nir_shader *shader);
> +bool nir_opt_peephole_ffma(nir_shader *shader);
>
>  #ifdef __cplusplus
>  } /* extern "C" */
> diff --git a/src/glsl/nir/nir_opcodes.h b/src/glsl/nir/nir_opcodes.h
> index 988f691..35d4634 100644
> --- a/src/glsl/nir/nir_opcodes.h
> +++ b/src/glsl/nir/nir_opcodes.h
> @@ -307,6 +307,7 @@ BINOP_HORIZ(vec2, 2, nir_type_unsigned, 1, 
> nir_type_unsigned, 1, nir_type_unsign
> ARR(src1_size, src2_size, src3_size), \
> ARR(nir_type_unsigned, nir_type_unsigned, nir_type_unsigned))
>
> +/* fma(a, b, c) = (a * b) + c */
>  TRIOP(ffma, nir_type_float)
>
>  TRIOP(flrp, nir_type_float)
> diff --git a/src/glsl/nir/nir_opt_peephole_ffma.c 
> b/src/glsl/nir/nir_opt_peephole_ffma.c
> new file mode 100644
> index 000..2c9b8e5
> --- /dev/null
> +++ b/src/glsl/nir/nir_opt_peephole_ffma.c
> @@ -0,0 +1,191 @@
> +/*
> + * 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 a small peephole optimization that looks for a multiply that
> + * is only ever used in an add and replaces both with an fma.
> + */
> +
> +struct peephole_ffma_state {
> +   void *mem_ctx;
> +   nir_function_impl *impl;
> +   bool progress;
> +};
> +
> +static inline nir_alu_instr *
> +get_mul_for_src(nir_alu_instr *add, unsigned idx)
> +{
> +   if (!add->src[idx].src.is_ssa)
> +  return NULL;
> +
> +   /* We can't handle these in between the operations */
> +   if (add->src[idx].negate || add->src[idx].abs)
> +  return NULL;
> +
> +   nir_instr *instr = add->src[idx].src.ssa->parent_instr;
> +   if (instr->type != nir_instr_type_alu)
> +  return NULL;
> +
> +   nir_alu_instr *mul = nir_instr_as_alu(instr);
> +   if (mul->op != nir_op_fmul)
> +  return NULL;
> +
> +   /* Can't handle a saturate in between */
> +   if (mul->dest.saturate)
> +  return NULL;
> +
> +   /* We already know that the same source is not used twice in the add and
> +* we will assume valid use-def information, so this check is sufficient
> +*/
> +   if (mul->dest.dest.ssa.uses->entries > 1)
> +  return NULL; /* Not the only use */
> +
> +   return mul;
> +}
> +
> +/* Copies (and maybe swizzles) the given ALU source */
> +static inline void
> +copy_alu_src(void *mem_ctx, nir_alu_src *new_src, nir_alu_src old_src,
> + uint8_t *swizzle)
> +{
> +   new_src->src = nir_src_copy(old_src.s

Re: [Mesa-dev] [PATCH 060/133] nir: Validate all lists in the validator

2014-12-17 Thread Connor Abbott
On Wed, Dec 17, 2014 at 8:00 PM, Jason Ekstrand  wrote:
>
>
> On Wed, Dec 17, 2014 at 4:52 PM, Connor Abbott  wrote:
>>
>> I think we're missing a few things:
>>
>> * Phi node sources
>
>
> Added
>
>>
>> * Parallel copy entries
>
>
> I don't think we're validating anything for parallel copies right now.  It
> would be nice to, but there's no real good way to do so since they always
> get created and destroyed inside of the out-of-SSA pass.  We do support
> printing them, but that's really only for debugging out-of-SSA and getting
> it to happen requires hacking up the out-of-SSA pass.

Sure, although if you sprinkle nir_validate() calls as a debugging
tactic in that particular then it might get hit (ok that's a bit
theoretical)... but it doesn't really matter to me if you include them
or not.

>
>>
>>
>> Whether you care enough to validate those is up to you. Otherwise
>>
>> Reviewed-by: Connor Abbott 
>>
>>
>> On Tue, Dec 16, 2014 at 1:05 AM, Jason Ekstrand 
>> wrote:
>> > ---
>> >  src/glsl/nir/nir_validate.c | 13 +
>> >  1 file changed, 13 insertions(+)
>> >
>> > diff --git a/src/glsl/nir/nir_validate.c b/src/glsl/nir/nir_validate.c
>> > index 200c85a..ae8deb8 100644
>> > --- a/src/glsl/nir/nir_validate.c
>> > +++ b/src/glsl/nir/nir_validate.c
>> > @@ -452,6 +452,7 @@ validate_phi_src(nir_phi_instr *instr, nir_block
>> > *pred, validate_state *state)
>> >  {
>> > state->instr = &instr->instr;
>> >
>> > +   exec_list_validate(&instr->srcs);
>> > foreach_list_typed(nir_phi_src, src, node, &instr->srcs) {
>> >if (src->pred == pred) {
>> >   validate_src(&src->src, state);
>> > @@ -482,6 +483,7 @@ validate_block(nir_block *block, validate_state
>> > *state)
>> >
>> > state->block = block;
>> >
>> > +   exec_list_validate(&block->instr_list);
>> > nir_foreach_instr(block, instr) {
>> >if (instr->type == nir_instr_type_phi) {
>> >   assert(instr == nir_block_first_instr(block) ||
>> > @@ -548,10 +550,12 @@ validate_if(nir_if *if_stmt, validate_state
>> > *state)
>> > nir_cf_node *old_parent = state->parent_node;
>> > state->parent_node = &if_stmt->cf_node;
>> >
>> > +   exec_list_validate(&if_stmt->then_list);
>> > foreach_list_typed(nir_cf_node, cf_node, node, &if_stmt->then_list)
>> > {
>> >validate_cf_node(cf_node, state);
>> > }
>> >
>> > +   exec_list_validate(&if_stmt->else_list);
>> > foreach_list_typed(nir_cf_node, cf_node, node, &if_stmt->else_list)
>> > {
>> >validate_cf_node(cf_node, state);
>> > }
>> > @@ -579,6 +583,7 @@ validate_loop(nir_loop *loop, validate_state *state)
>> > nir_cf_node *old_parent = state->parent_node;
>> > state->parent_node = &loop->cf_node;
>> >
>> > +   exec_list_validate(&loop->body);
>> > foreach_list_typed(nir_cf_node, cf_node, node, &loop->body) {
>> >validate_cf_node(cf_node, state);
>> > }
>> > @@ -705,14 +710,17 @@ validate_function_impl(nir_function_impl *impl,
>> > validate_state *state)
>> > state->impl = impl;
>> > state->parent_node = &impl->cf_node;
>> >
>> > +   exec_list_validate(&impl->locals);
>> > foreach_list_typed(nir_variable, var, node, &impl->locals) {
>> >validate_var_decl(var, false, state);
>> > }
>> >
>> > +   exec_list_validate(&impl->registers);
>> > foreach_list_typed(nir_register, reg, node, &impl->registers) {
>> >prevalidate_reg_decl(reg, false, state);
>> > }
>> >
>> > +   exec_list_validate(&impl->body);
>> > foreach_list_typed(nir_cf_node, node, node, &impl->body) {
>> >validate_cf_node(node, state);
>> > }
>> > @@ -733,6 +741,7 @@ validate_function_overload(nir_function_overload
>> > *overload,
>> >  static void
>> >  validate_function(nir_function *func, validate_state *state)
>> >  {
>> > +   exec_list_validate(&func->overload_list);
>> > foreach_list_typed(nir_function_overload, overload, node,
>> > &func->overload_list) {
>> >assert(overload->function == func);
>> >validate_function_overload(overload, state);
>> > @@ -774,18 +783,22 @@ nir_validate_shader(nir_shader *shader)
>> >validate_var_decl((nir_variable *) entry->data, true, &state);
>> > }
>> >
>> > +   exec_list_validate(&shader->globals);
>> > foreach_list_typed(nir_variable, var, node, &shader->globals) {
>> >   validate_var_decl(var, true, &state);
>> > }
>> >
>> > +   exec_list_validate(&shader->system_values);
>> > foreach_list_typed(nir_variable, var, node, &shader->system_values)
>> > {
>> >   validate_var_decl(var, true, &state);
>> > }
>> >
>> > +   exec_list_validate(&shader->registers);
>> > foreach_list_typed(nir_register, reg, node, &shader->registers) {
>> >prevalidate_reg_decl(reg, true, &state);
>> > }
>> >
>> > +   exec_list_validate(&shader->functions);
>> > foreach_list_typed(nir_function, func, node, &shader->functions) {
>> >validate_function(func, &state);
>> > }
>> > --
>> > 2.2.0
>> >
>

Re: [Mesa-dev] [PATCH 000/123] Reintroducing NIR, a new IR for mesa

2014-12-17 Thread Jason Ekstrand
For my own sake as well of those reviewing things, I'm keeping both the
review/nir-v1 branch and
http://patchwork.freedesktop.org/bundle/jekstrand/nir-v1/ up-to-date as new
patches get sent out and reviewed-by's get added.

On Tue, Dec 16, 2014 at 10:59 PM, Connor Abbott  wrote:
>
> Patches 23-26, 28, 30-35, 37-38, 40, (41 gets killed later so I didn't
> review it), 42-44 are
>
> Reviewed-by: Connor Abbott 
>
> I'm going to bed now, but I'll try to do some more later.
>
> On Tue, Dec 16, 2014 at 1:04 AM, Jason Ekstrand 
> wrote:
> > NIR (pronounced "ner") is a new IR (internal representation) for the Mesa
> > shader compiler that will sit between the old IR (GLSL IR) and back-end
> > compilers.  The primary purpose of NIR is to be more efficient for doing
> > optimizations and generate better code for the back-ends.  We have a lot
> of
> > optimizations implemented in GLSL IR right now.  However, they still
> > generate fairly bad code primarily because its tree-based structure makes
> > writing good optimizations difficult.  For this reason, we have
> implemented
> > a lot of optimizations in the i965 back-end compilers just to fix up the
> > code we get from GLSL IR.  The "proper fix" to this is to implement a
> > better high-level IR; enter NIR.
> >
> > Most of the initial work on NIR including setting up common data
> > structures, helper methods, and a few basic passes was by Connor Abbot
> who
> > interned with us over the summer.  Connor did a fantastic job, but there
> is
> > still a lot left to be done.  I've spent the last two months trying to
> fill
> > in the pieces that we need in order to get NIR off the ground.  At this
> > point, we now have compitent in and out of SSA passes, are at zero piglit
> > regressions for i965 SIMD8 fragment shaders, and the shader-db numbers
> > aren't terrible.
> >
> > This is still a bit experimental.  I have been testing only on HSW but it
> > should work ok on SNB and later.  Eventually, once we get booleans fixed
> > up, it should work fine on older chips as well.  It also doesn't yet
> > support SIMD16, so performance won't be that great.  That said, I think
> we
> > are at the point now where we should try and land this and I can stop
> > developing in my masive private branch.  Since this isn't quite ready for
> > prime-time yet, using it requires setting the INTEL_USE_NIR environment
> > variable.
> >
> > A few key points about NIR:
> >
> >  1. It is primarily an SSA-based IR.
> >  2. It supports source/destination-modifiers and swizzles/*write-masks.
> >  3. Standard GPU operations such as sin() and fmad() are first-class ALU
> > operations, not intrinsics.
> >  4. GLSL concepts like inputs, outputs, uniforms, etc. are built into the
> > IR so we can do proper analysis on them.
> >  5. Even though it's SSA, it still has a concept of registers and
> > write-masks in the core IR data structures.  This means we can
> generate
> > code that is much closer to what backends want.
> >  6. Control flow is structured explicitly in the IR.
> >
> > (*write-masks are not available for SSA values)
> >
> > While source/destination modifiers and writemasks/swizzles are not
> > particularly useful for optimizations, having them represented in the IR
> > gives us the ability to generate more useful code for backends.
> >
> > A few notes about review:
> >
> >  1. For those of you who aren't interested in the general compiler, I'm
> > sorry for the patch-bomb.  However, several people have requsted that
> > we maintain the history of the NIR development since connor's
> original
> > drop at the end of the summer.  Therefore, while I've squashed
> several
> > things, I've tried to leave the diff of what I've done more-or-less
> > preserved.
> >
> >  2. No, this is not LLVM.  There was a long-winded discussion about that
> > when Connor dropped his patches that went a whole lot of nowhere as
> > usual.  I would really prefer if we left that debate alone.  If there
> > must be bikeshedding on the topic, please do so on the cover-letter
> > e-mail.
> >
> >  3. Please keep all bikeshedding about C++, typedefs, etc.  on the core
> > datastructures e-mail.  If we need, we can split that off in its own
> > thread.
> >
> >  4. While I welcome review, I don't plan to make non-trivial changes to
> > specific patches or squash anything beyond what has already been
> > squashed.  I've tried thus far to more-or-less keep the history and
> I'd
> > like to continue this if we can.
> >
> >  5. Eric Anholt has also written NIR -> TGSI -> NIR passes which will
> > hopefully get landed soon after NIR initially lands.  Exactly how
> that
> > all gets hooked up for other gallium drivers beyond vc4 is outside
> the
> > scope of this series.
> >
> > I have pushed a branch to my personal freedesktop.org account.  For
> certain
> > types of review, it may be easier to look at the end result rather than
> the
> > pa

Re: [Mesa-dev] [PATCH 055/133] nir: Add a parallel copy instruction type

2014-12-17 Thread Jason Ekstrand
On Wed, Dec 17, 2014 at 2:35 PM, Connor Abbott  wrote:
>
> On Tue, Dec 16, 2014 at 1:05 AM, Jason Ekstrand 
> wrote:
> > ---
> >  src/glsl/nir/nir.c   | 45
> -
> >  src/glsl/nir/nir.h   | 23 +++
> >  src/glsl/nir/nir_print.c | 21 +
> >  3 files changed, 88 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
> > index 27e903e..d3fd084 100644
> > --- a/src/glsl/nir/nir.c
> > +++ b/src/glsl/nir/nir.c
> > @@ -475,6 +475,18 @@ nir_phi_instr_create(void *mem_ctx)
> > return instr;
> >  }
> >
> > +nir_parallel_copy_instr *
> > +nir_parallel_copy_instr_create(void *mem_ctx)
> > +{
> > +   nir_parallel_copy_instr *instr = ralloc(mem_ctx,
> nir_parallel_copy_instr);
> > +   instr_init(&instr->instr, nir_instr_type_parallel_copy);
> > +
> > +   instr->at_end = false;
> > +   exec_list_make_empty(&instr->copies);
> > +
> > +   return instr;
> > +}
> > +
> >  nir_ssa_undef_instr *
> >  nir_ssa_undef_instr_create(void *mem_ctx)
> >  {
> > @@ -1377,6 +1389,18 @@ visit_phi_dest(nir_phi_instr *instr,
> nir_foreach_dest_cb cb, void *state)
> > return cb(&instr->dest, state);
> >  }
> >
> > +static bool
> > +visit_parallel_copy_dest(nir_parallel_copy_instr *instr,
> > + nir_foreach_dest_cb cb, void *state)
> > +{
> > +   foreach_list_typed(nir_parallel_copy_copy, copy, node,
> &instr->copies) {
> > +  if (!cb(©->dest, state))
> > + return false;
> > +   }
> > +
> > +   return true;
> > +}
> > +
> >  bool
> >  nir_foreach_dest(nir_instr *instr, nir_foreach_dest_cb cb, void *state)
> >  {
> > @@ -1391,7 +1415,9 @@ nir_foreach_dest(nir_instr *instr,
> nir_foreach_dest_cb cb, void *state)
> >return visit_load_const_dest(nir_instr_as_load_const(instr), cb,
> state);
> > case nir_instr_type_phi:
> >return visit_phi_dest(nir_instr_as_phi(instr), cb, state);
> > -  break;
> > +   case nir_instr_type_parallel_copy:
> > +  return visit_parallel_copy_dest(nir_instr_as_parallel_copy(instr),
> > +  cb, state);
> >
> > case nir_instr_type_ssa_undef:
> > case nir_instr_type_call:
> > @@ -1526,6 +1552,18 @@ visit_phi_src(nir_phi_instr *instr,
> nir_foreach_src_cb cb, void *state)
> > return true;
> >  }
> >
> > +static bool
> > +visit_parallel_copy_src(nir_parallel_copy_instr *instr,
> > +nir_foreach_src_cb cb, void *state)
> > +{
> > +   foreach_list_typed(nir_parallel_copy_copy, copy, node,
> &instr->copies) {
> > +  if (!visit_src(©->src, cb, state))
> > + return false;
> > +   }
> > +
> > +   return true;
> > +}
> > +
> >  typedef struct {
> > void *state;
> > nir_foreach_src_cb cb;
> > @@ -1570,6 +1608,11 @@ nir_foreach_src(nir_instr *instr,
> nir_foreach_src_cb cb, void *state)
> >if (!visit_phi_src(nir_instr_as_phi(instr), cb, state))
> >   return false;
> >break;
> > +   case nir_instr_type_parallel_copy:
> > +  if (!visit_parallel_copy_src(nir_instr_as_parallel_copy(instr),
> > +   cb, state))
> > + return false;
> > +  break;
> > case nir_instr_type_jump:
> > case nir_instr_type_ssa_undef:
> >return true;
> > diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> > index 988a135..2ebf826 100644
> > --- a/src/glsl/nir/nir.h
> > +++ b/src/glsl/nir/nir.h
> > @@ -396,6 +396,7 @@ typedef enum {
> > nir_instr_type_jump,
> > nir_instr_type_ssa_undef,
> > nir_instr_type_phi,
> > +   nir_instr_type_parallel_copy,
> >  } nir_instr_type;
> >
> >  typedef struct {
> > @@ -933,6 +934,24 @@ typedef struct {
> > nir_dest dest;
> >  } nir_phi_instr;
> >
> > +typedef struct {
> > +   struct exec_node node;
> > +   nir_src src;
> > +   nir_dest dest;
> > +} nir_parallel_copy_copy;
>
> I don't really care too much what this is called, but maybe something
> less silly like "nir_parallel_copy_entry"?
>
> > +
> > +typedef struct {
> > +   nir_instr instr;
> > +
> > +   /* Indicates that this is the parallel copy at the end of the block.
> > +* When isolating phi nodes, we create 2 parallel copies in most
> blocks;
> > +* this flag helps tell them apart.
> > +*/
> > +   bool at_end;
>
> Do we really need this? I haven't read the pass yet, but I thought we
> could figure this out by checking to see if we're the last instruction
> of the basic block.
>

Patches 139 and 140 clean up both of these issues
--Jason


>
> > +
> > +   struct exec_list copies;
> > +} nir_parallel_copy_instr;
> > +
> >  #define nir_instr_as_alu(_instr) exec_node_data(nir_alu_instr, _instr,
> instr)
> >  #define nir_instr_as_call(_instr) exec_node_data(nir_call_instr,
> _instr, instr)
> >  #define nir_instr_as_jump(_instr) exec_node_data(nir_jump_instr,
> _instr, instr)
> > @@ -946,6 +965,8 @@ typedef struct {
> > exec_node_data(nir_ssa_undef_instr, _instr, instr)
> >  #defin

[Mesa-dev] [PATCH 140/133] nir: Rename parallel_copy_copy to parallel_copy_entry and add a foreach macro

2014-12-17 Thread Jason Ekstrand
parallel_copy_copy was a silly name.  Also, things were getting long and
annoying, so I added a foreach macro.  For historical reasons, several of
the original iterations over parallel copy entries in from_ssa used the
_safe variants of the loop.  However, all of these no longer ever remove an
entry so it's ok to make them all use the normal iterator.
---
 src/glsl/nir/nir.c  | 10 +++
 src/glsl/nir/nir.h  | 13 ++--
 src/glsl/nir/nir_from_ssa.c | 72 ++---
 src/glsl/nir/nir_print.c|  6 ++--
 4 files changed, 55 insertions(+), 46 deletions(-)

diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
index 17c1efe..fd18903 100644
--- a/src/glsl/nir/nir.c
+++ b/src/glsl/nir/nir.c
@@ -471,7 +471,7 @@ nir_parallel_copy_instr_create(void *mem_ctx)
nir_parallel_copy_instr *instr = ralloc(mem_ctx, nir_parallel_copy_instr);
instr_init(&instr->instr, nir_instr_type_parallel_copy);
 
-   exec_list_make_empty(&instr->copies);
+   exec_list_make_empty(&instr->entries);
 
return instr;
 }
@@ -1410,8 +1410,8 @@ static bool
 visit_parallel_copy_dest(nir_parallel_copy_instr *instr,
  nir_foreach_dest_cb cb, void *state)
 {
-   foreach_list_typed(nir_parallel_copy_copy, copy, node, &instr->copies) {
-  if (!cb(©->dest, state))
+   nir_foreach_parallel_copy_entry(instr, entry) {
+  if (!cb(&entry->dest, state))
  return false;
}
 
@@ -1598,8 +1598,8 @@ static bool
 visit_parallel_copy_src(nir_parallel_copy_instr *instr,
 nir_foreach_src_cb cb, void *state)
 {
-   foreach_list_typed(nir_parallel_copy_copy, copy, node, &instr->copies) {
-  if (!visit_src(©->src, cb, state))
+   nir_foreach_parallel_copy_entry(instr, entry) {
+  if (!visit_src(&entry->src, cb, state))
  return false;
}
 
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index a23bc5f..a30f619 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -963,11 +963,20 @@ typedef struct {
struct exec_node node;
nir_src src;
nir_dest dest;
-} nir_parallel_copy_copy;
+} nir_parallel_copy_entry;
+
+#define nir_foreach_parallel_copy_entry(pcopy, entry) \
+   foreach_list_typed(nir_parallel_copy_entry, entry, node, &(pcopy)->entries)
 
 typedef struct {
nir_instr instr;
-   struct exec_list copies;
+
+   /* A list of nir_parallel_copy_entry's.  The sources of all of the
+* entries are copied to the corresponding destinations "in parallel".
+* In other words, if we have two entries: a -> b and b -> a, the values
+* get swapped.
+*/
+   struct exec_list entries;
 } nir_parallel_copy_instr;
 
 NIR_DEFINE_CAST(nir_instr_as_alu, nir_instr, nir_alu_instr, instr)
diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c
index 29fcc64..11f3ecd 100644
--- a/src/glsl/nir/nir_from_ssa.c
+++ b/src/glsl/nir/nir_from_ssa.c
@@ -350,22 +350,22 @@ isolate_phi_nodes_block(nir_block *block, void 
*void_state)
 get_parallel_copy_at_end_of_block(src->pred);
  assert(pcopy);
 
- nir_parallel_copy_copy *copy = ralloc(state->dead_ctx,
-   nir_parallel_copy_copy);
- exec_list_push_tail(&pcopy->copies, ©->node);
+ nir_parallel_copy_entry *entry = ralloc(state->dead_ctx,
+ nir_parallel_copy_entry);
+ exec_list_push_tail(&pcopy->entries, &entry->node);
 
- copy->src = nir_src_copy(src->src, state->dead_ctx);
+ entry->src = nir_src_copy(src->src, state->dead_ctx);
  _mesa_set_add(src->src.ssa->uses,
_mesa_hash_pointer(&pcopy->instr), &pcopy->instr);
 
- copy->dest.is_ssa = true;
- nir_ssa_def_init(&pcopy->instr, ©->dest.ssa,
+ entry->dest.is_ssa = true;
+ nir_ssa_def_init(&pcopy->instr, &entry->dest.ssa,
   phi->dest.ssa.num_components, src->src.ssa->name);
 
- struct set_entry *entry = _mesa_set_search(src->src.ssa->uses,
-_mesa_hash_pointer(instr),
-instr);
- if (entry)
+ struct set_entry *use_entry =
+_mesa_set_search(src->src.ssa->uses,
+ _mesa_hash_pointer(instr), instr);
+ if (use_entry)
 /* It is possible that a phi node can use the same source twice
  * but for different basic blocks.  If that happens, entry will
  * be NULL because we already deleted it.  This is safe
@@ -373,28 +373,28 @@ isolate_phi_nodes_block(nir_block *block, void 
*void_state)
  * all of the sources of the phi from their respective use sets
  * and moved them to the parallel copy definitions.
  */
-_mesa_set_remove(src->src.ssa->uses, entry);
+_mesa_set_remove(src->src.ssa->uses, use_entry);
 
-

[Mesa-dev] [PATCH 139/133] nir/from_ssa: Clean up parallel copy handling and document it better

2014-12-17 Thread Jason Ekstrand
Previously, we were doing a lazy creation of the parallel copy
instructions.  This is confusing, hard to get right, and involves some
extra state tracking of the copies.  This commit adds an extra walk over
the basic blocks to add the block-end parallel copies up front.  This
should be much less confusing and, consequently, easier to get right.  This
commit also adds more comments about parallel copies to help explain what
all is going on.

As a consequence of these changes, we can now remove the at_end parameter
from nir_parallel_copy_instr.
---
 src/glsl/nir/nir.c  |   1 -
 src/glsl/nir/nir.h  |   7 ---
 src/glsl/nir/nir_from_ssa.c | 150 +++-
 3 files changed, 92 insertions(+), 66 deletions(-)

diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
index d0cab5a..17c1efe 100644
--- a/src/glsl/nir/nir.c
+++ b/src/glsl/nir/nir.c
@@ -471,7 +471,6 @@ nir_parallel_copy_instr_create(void *mem_ctx)
nir_parallel_copy_instr *instr = ralloc(mem_ctx, nir_parallel_copy_instr);
instr_init(&instr->instr, nir_instr_type_parallel_copy);
 
-   instr->at_end = false;
exec_list_make_empty(&instr->copies);
 
return instr;
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index dbfa461..a23bc5f 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -967,13 +967,6 @@ typedef struct {
 
 typedef struct {
nir_instr instr;
-
-   /* Indicates that this is the parallel copy at the end of the block.
-* When isolating phi nodes, we create 2 parallel copies in most blocks;
-* this flag helps tell them apart.
-*/
-   bool at_end;
-
struct exec_list copies;
 } nir_parallel_copy_instr;
 
diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c
index 1d17ac4..29fcc64 100644
--- a/src/glsl/nir/nir_from_ssa.c
+++ b/src/glsl/nir/nir_from_ssa.c
@@ -229,48 +229,90 @@ merge_sets_interfere(merge_set *a, merge_set *b)
return false;
 }
 
-static nir_parallel_copy_instr *
-block_get_parallel_copy_at_end(nir_block *block, void *mem_ctx)
+static bool
+add_parallel_copy_to_end_of_block(nir_block *block, void *void_state)
 {
-   nir_instr *last_instr = nir_block_last_instr(block);
+   struct from_ssa_state *state = void_state;
 
-   /* First we try and find a parallel copy if it already exists.  If the
-* last instruction is a jump, it will be right before the jump;
-* otherwise, it will be the last instruction.
-*/
-   nir_instr *pcopy_instr;
-   if (last_instr != NULL && last_instr->type == nir_instr_type_jump)
-  pcopy_instr = nir_instr_prev(last_instr);
-   else
-  pcopy_instr = last_instr;
+   bool need_end_copy = false;
+   if (block->successors[0]) {
+  nir_instr *instr = nir_block_first_instr(block->successors[0]);
+  if (instr && instr->type == nir_instr_type_phi)
+ need_end_copy = true;
+   }
 
-   if (pcopy_instr != NULL &&
-   pcopy_instr->type == nir_instr_type_parallel_copy) {
-  /* A parallel copy already exists. */
-  nir_parallel_copy_instr *pcopy = nir_instr_as_parallel_copy(pcopy_instr);
+   if (block->successors[1]) {
+  nir_instr *instr = nir_block_first_instr(block->successors[1]);
+  if (instr && instr->type == nir_instr_type_phi)
+ need_end_copy = true;
+   }
 
-  /* This parallel copy may be the copy for the beginning of some
-   * block, so we need to check for that before we return it.
+   if (need_end_copy) {
+  /* If one of our successors has at least one phi node, we need to
+   * create a parallel copy at the end of the block but before the jump
+   * (if there is one).
*/
-  if (pcopy->at_end)
- return pcopy;
+  nir_parallel_copy_instr *pcopy =
+ nir_parallel_copy_instr_create(state->dead_ctx);
+
+  nir_instr *last_instr = nir_block_last_instr(block);
+  if (last_instr && last_instr->type == nir_instr_type_jump) {
+ nir_instr_insert_before(last_instr, &pcopy->instr);
+  } else {
+ nir_instr_insert_after_block(block, &pcopy->instr);
+  }
}
 
-   /* At this point, we haven't found a suitable parallel copy, so we
-* have to create one.
-*/
-   nir_parallel_copy_instr *pcopy = nir_parallel_copy_instr_create(mem_ctx);
-   pcopy->at_end = true;
+   return true;
+}
 
-   if (last_instr && last_instr->type == nir_instr_type_jump) {
-  nir_instr_insert_before(last_instr, &pcopy->instr);
-   } else {
-  nir_instr_insert_after_block(block, &pcopy->instr);
-   }
+static nir_parallel_copy_instr *
+get_parallel_copy_at_end_of_block(nir_block *block)
+{
+   nir_instr *last_instr = nir_block_last_instr(block);
+   if (last_instr == NULL)
+  return NULL;
 
-   return pcopy;
+   /* The last instruction may be a jump in which case the parallel copy is
+* right before it.
+*/
+   if (last_instr->type == nir_instr_type_jump)
+  last_instr = nir_instr_prev(last_instr);
+
+   if (last_instr->type == nir_instr_type_parallel_copy)
+  return nir_i

Re: [Mesa-dev] [PATCH 060/133] nir: Validate all lists in the validator

2014-12-17 Thread Jason Ekstrand
On Wed, Dec 17, 2014 at 4:52 PM, Connor Abbott  wrote:
>
> I think we're missing a few things:
>
> * Phi node sources
>

Added


> * Parallel copy entries
>

I don't think we're validating anything for parallel copies right now.  It
would be nice to, but there's no real good way to do so since they always
get created and destroyed inside of the out-of-SSA pass.  We do support
printing them, but that's really only for debugging out-of-SSA and getting
it to happen requires hacking up the out-of-SSA pass.


>
> Whether you care enough to validate those is up to you. Otherwise
>
> Reviewed-by: Connor Abbott 
>
>
> On Tue, Dec 16, 2014 at 1:05 AM, Jason Ekstrand 
> wrote:
> > ---
> >  src/glsl/nir/nir_validate.c | 13 +
> >  1 file changed, 13 insertions(+)
> >
> > diff --git a/src/glsl/nir/nir_validate.c b/src/glsl/nir/nir_validate.c
> > index 200c85a..ae8deb8 100644
> > --- a/src/glsl/nir/nir_validate.c
> > +++ b/src/glsl/nir/nir_validate.c
> > @@ -452,6 +452,7 @@ validate_phi_src(nir_phi_instr *instr, nir_block
> *pred, validate_state *state)
> >  {
> > state->instr = &instr->instr;
> >
> > +   exec_list_validate(&instr->srcs);
> > foreach_list_typed(nir_phi_src, src, node, &instr->srcs) {
> >if (src->pred == pred) {
> >   validate_src(&src->src, state);
> > @@ -482,6 +483,7 @@ validate_block(nir_block *block, validate_state
> *state)
> >
> > state->block = block;
> >
> > +   exec_list_validate(&block->instr_list);
> > nir_foreach_instr(block, instr) {
> >if (instr->type == nir_instr_type_phi) {
> >   assert(instr == nir_block_first_instr(block) ||
> > @@ -548,10 +550,12 @@ validate_if(nir_if *if_stmt, validate_state *state)
> > nir_cf_node *old_parent = state->parent_node;
> > state->parent_node = &if_stmt->cf_node;
> >
> > +   exec_list_validate(&if_stmt->then_list);
> > foreach_list_typed(nir_cf_node, cf_node, node, &if_stmt->then_list) {
> >validate_cf_node(cf_node, state);
> > }
> >
> > +   exec_list_validate(&if_stmt->else_list);
> > foreach_list_typed(nir_cf_node, cf_node, node, &if_stmt->else_list) {
> >validate_cf_node(cf_node, state);
> > }
> > @@ -579,6 +583,7 @@ validate_loop(nir_loop *loop, validate_state *state)
> > nir_cf_node *old_parent = state->parent_node;
> > state->parent_node = &loop->cf_node;
> >
> > +   exec_list_validate(&loop->body);
> > foreach_list_typed(nir_cf_node, cf_node, node, &loop->body) {
> >validate_cf_node(cf_node, state);
> > }
> > @@ -705,14 +710,17 @@ validate_function_impl(nir_function_impl *impl,
> validate_state *state)
> > state->impl = impl;
> > state->parent_node = &impl->cf_node;
> >
> > +   exec_list_validate(&impl->locals);
> > foreach_list_typed(nir_variable, var, node, &impl->locals) {
> >validate_var_decl(var, false, state);
> > }
> >
> > +   exec_list_validate(&impl->registers);
> > foreach_list_typed(nir_register, reg, node, &impl->registers) {
> >prevalidate_reg_decl(reg, false, state);
> > }
> >
> > +   exec_list_validate(&impl->body);
> > foreach_list_typed(nir_cf_node, node, node, &impl->body) {
> >validate_cf_node(node, state);
> > }
> > @@ -733,6 +741,7 @@ validate_function_overload(nir_function_overload
> *overload,
> >  static void
> >  validate_function(nir_function *func, validate_state *state)
> >  {
> > +   exec_list_validate(&func->overload_list);
> > foreach_list_typed(nir_function_overload, overload, node,
> &func->overload_list) {
> >assert(overload->function == func);
> >validate_function_overload(overload, state);
> > @@ -774,18 +783,22 @@ nir_validate_shader(nir_shader *shader)
> >validate_var_decl((nir_variable *) entry->data, true, &state);
> > }
> >
> > +   exec_list_validate(&shader->globals);
> > foreach_list_typed(nir_variable, var, node, &shader->globals) {
> >   validate_var_decl(var, true, &state);
> > }
> >
> > +   exec_list_validate(&shader->system_values);
> > foreach_list_typed(nir_variable, var, node, &shader->system_values) {
> >   validate_var_decl(var, true, &state);
> > }
> >
> > +   exec_list_validate(&shader->registers);
> > foreach_list_typed(nir_register, reg, node, &shader->registers) {
> >prevalidate_reg_decl(reg, true, &state);
> > }
> >
> > +   exec_list_validate(&shader->functions);
> > foreach_list_typed(nir_function, func, node, &shader->functions) {
> >validate_function(func, &state);
> > }
> > --
> > 2.2.0
> >
> > ___
> > mesa-dev mailing list
> > mesa-dev@lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 060/133] nir: Validate all lists in the validator

2014-12-17 Thread Connor Abbott
I think we're missing a few things:

* Phi node sources
* Parallel copy entries

Whether you care enough to validate those is up to you. Otherwise

Reviewed-by: Connor Abbott 


On Tue, Dec 16, 2014 at 1:05 AM, Jason Ekstrand  wrote:
> ---
>  src/glsl/nir/nir_validate.c | 13 +
>  1 file changed, 13 insertions(+)
>
> diff --git a/src/glsl/nir/nir_validate.c b/src/glsl/nir/nir_validate.c
> index 200c85a..ae8deb8 100644
> --- a/src/glsl/nir/nir_validate.c
> +++ b/src/glsl/nir/nir_validate.c
> @@ -452,6 +452,7 @@ validate_phi_src(nir_phi_instr *instr, nir_block *pred, 
> validate_state *state)
>  {
> state->instr = &instr->instr;
>
> +   exec_list_validate(&instr->srcs);
> foreach_list_typed(nir_phi_src, src, node, &instr->srcs) {
>if (src->pred == pred) {
>   validate_src(&src->src, state);
> @@ -482,6 +483,7 @@ validate_block(nir_block *block, validate_state *state)
>
> state->block = block;
>
> +   exec_list_validate(&block->instr_list);
> nir_foreach_instr(block, instr) {
>if (instr->type == nir_instr_type_phi) {
>   assert(instr == nir_block_first_instr(block) ||
> @@ -548,10 +550,12 @@ validate_if(nir_if *if_stmt, validate_state *state)
> nir_cf_node *old_parent = state->parent_node;
> state->parent_node = &if_stmt->cf_node;
>
> +   exec_list_validate(&if_stmt->then_list);
> foreach_list_typed(nir_cf_node, cf_node, node, &if_stmt->then_list) {
>validate_cf_node(cf_node, state);
> }
>
> +   exec_list_validate(&if_stmt->else_list);
> foreach_list_typed(nir_cf_node, cf_node, node, &if_stmt->else_list) {
>validate_cf_node(cf_node, state);
> }
> @@ -579,6 +583,7 @@ validate_loop(nir_loop *loop, validate_state *state)
> nir_cf_node *old_parent = state->parent_node;
> state->parent_node = &loop->cf_node;
>
> +   exec_list_validate(&loop->body);
> foreach_list_typed(nir_cf_node, cf_node, node, &loop->body) {
>validate_cf_node(cf_node, state);
> }
> @@ -705,14 +710,17 @@ validate_function_impl(nir_function_impl *impl, 
> validate_state *state)
> state->impl = impl;
> state->parent_node = &impl->cf_node;
>
> +   exec_list_validate(&impl->locals);
> foreach_list_typed(nir_variable, var, node, &impl->locals) {
>validate_var_decl(var, false, state);
> }
>
> +   exec_list_validate(&impl->registers);
> foreach_list_typed(nir_register, reg, node, &impl->registers) {
>prevalidate_reg_decl(reg, false, state);
> }
>
> +   exec_list_validate(&impl->body);
> foreach_list_typed(nir_cf_node, node, node, &impl->body) {
>validate_cf_node(node, state);
> }
> @@ -733,6 +741,7 @@ validate_function_overload(nir_function_overload 
> *overload,
>  static void
>  validate_function(nir_function *func, validate_state *state)
>  {
> +   exec_list_validate(&func->overload_list);
> foreach_list_typed(nir_function_overload, overload, node, 
> &func->overload_list) {
>assert(overload->function == func);
>validate_function_overload(overload, state);
> @@ -774,18 +783,22 @@ nir_validate_shader(nir_shader *shader)
>validate_var_decl((nir_variable *) entry->data, true, &state);
> }
>
> +   exec_list_validate(&shader->globals);
> foreach_list_typed(nir_variable, var, node, &shader->globals) {
>   validate_var_decl(var, true, &state);
> }
>
> +   exec_list_validate(&shader->system_values);
> foreach_list_typed(nir_variable, var, node, &shader->system_values) {
>   validate_var_decl(var, true, &state);
> }
>
> +   exec_list_validate(&shader->registers);
> foreach_list_typed(nir_register, reg, node, &shader->registers) {
>prevalidate_reg_decl(reg, true, &state);
> }
>
> +   exec_list_validate(&shader->functions);
> foreach_list_typed(nir_function, func, node, &shader->functions) {
>validate_function(func, &state);
> }
> --
> 2.2.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 057/133] nir: Add a better out-of-SSA pass

2014-12-17 Thread Jason Ekstrand
On Wed, Dec 17, 2014 at 3:30 PM, Connor Abbott  wrote:
>
> Whew! Other than a few minor things below,
>
> Reviewed-by: Connor Abbott 
>
> I tried to understand it all as much as I could, but it is rather
> tricky... but I can't suggest anything to make it easier to
> understand, after all the paper itself is rather tricky and your
> comments help a lot. If anyone has any ideas, please say something...
>
> On Tue, Dec 16, 2014 at 1:05 AM, Jason Ekstrand 
> wrote:
> > This commit rewrites the out-of-SSA pass to not be nearly as naieve.
> It's
> > based on "Revisiting Out-of-SSA Translation for Correctness, Code
> Quality,
> > and Efficiency" by Boissinot et. al.  It should be fairly close to
> > state-of-the art.
> > ---
> >  src/glsl/nir/nir_from_ssa.c | 793
> +++-
> >  1 file changed, 715 insertions(+), 78 deletions(-)
> >
> > diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c
> > index a26f0c4..62a54fe 100644
> > --- a/src/glsl/nir/nir_from_ssa.c
> > +++ b/src/glsl/nir/nir_from_ssa.c
> > @@ -28,54 +28,474 @@
> >  #include "nir.h"
> >
> >  /*
> > - * Implements a quick-and-dirty out-of-ssa pass.
> > + * This file implements an out-of-SSA pass as described in "Revisiting
> > + * Out-of-SSA Translation for Correctness, Code Quality, and
> Efficiency" by
> > + * Boissinot et. al.
> >   */
> >
> >  struct from_ssa_state {
> > void *mem_ctx;
> > void *dead_ctx;
> > struct hash_table *ssa_table;
> > -   nir_function_impl *current_impl;
> > +   struct hash_table *merge_node_table;
> > +   nir_instr *instr;
> > +   nir_function_impl *impl;
> >  };
> >
> > +/* Returns true if a dominates b */
> >  static bool
> > -rewrite_ssa_src(nir_src *src, void *void_state)
> > +ssa_def_dominates(nir_ssa_def *a, nir_ssa_def *b)
> > +{
> > +   if (a->live_index == 0) {
> > +  /* SSA undefs always dominate */
> > +  return true;
> > +   } else if (b->live_index < a->live_index) {
> > +  return false;
> > +   } else if (a->parent_instr->block == b->parent_instr->block) {
> > +  return a->live_index <= b->live_index;
> > +   } else {
> > +  nir_block *block = b->parent_instr->block;
> > +  while (block->imm_dom != NULL) {
> > + if (block->imm_dom == a->parent_instr->block)
> > +return true;
> > + block = block->imm_dom;
> > +  }
> > +  return false;
> > +   }
> > +}
> > +
> > +
> > +/* The following data structure, which I have named merge_set is a way
> of
> > + * representing a set registers of non-interfering registers.  This is
> > + * based on the concept of a "dominence forest" presented in "Fast Copy
> > + * Coalescing and Live-Range Identification" by Budimlic et. al. but the
> > + * implementation concept is taken from  "Revisiting Out-of-SSA
> Translation
> > + * for Correctness, Code Quality, and Efficiency" by Boissinot et. al..
> > + *
> > + * Each SSA definition is associated with a merge_node and the
> association
> > + * is represented by a combination of a hash table and the "def"
> parameter
> > + * in the merge_node structure.  The merge_set stores a linked list of
> > + * merge_node's in dominence order of the ssa definitions.  (Since the
> > + * liveness analysis pass indexes the SSA values in dominence order for
> us,
> > + * this is an easy thing to keep up.)  It is assumed that no pair of the
> > + * nodes in a given set interfere.  Merging two sets or checking for
> > + * interference can be done in a single linear-time merge-sort walk of
> the
> > + * two lists of nodes.
> > + */
> > +struct merge_set;
> > +
> > +typedef struct {
> > +   struct exec_node node;
> > +   struct merge_set *set;
> > +   nir_ssa_def *def;
> > +} merge_node;
> > +
> > +typedef struct merge_set {
> > +   struct exec_list nodes;
> > +   unsigned size;
> > +   nir_register *reg;
> > +} merge_set;
> > +
> > +#if 0
> > +static void
> > +merge_set_dump(merge_set *set, FILE *fp)
> > +{
> > +   nir_ssa_def *dom[set->size];
> > +   int dom_idx = -1;
> > +
> > +   foreach_list_typed(merge_node, node, node, &set->nodes) {
> > +  while (dom_idx >= 0 && !ssa_def_dominates(dom[dom_idx],
> node->def))
> > + dom_idx--;
> > +
> > +  for (int i = 0; i <= dom_idx; i++)
> > + fprintf(fp, "  ");
> > +
> > +  if (node->def->name)
> > + fprintf(fp, "ssa_%d /* %s */\n", node->def->index,
> node->def->name);
> > +  else
> > + fprintf(fp, "ssa_%d\n", node->def->index);
> > +
> > +  dom[++dom_idx] = node->def;
> > +   }
> > +}
> > +#endif
> > +
> > +static merge_node *
> > +get_merge_node(nir_ssa_def *def, struct from_ssa_state *state)
> > +{
> > +   struct hash_entry *entry =
> > +  _mesa_hash_table_search(state->merge_node_table,
> > +  _mesa_hash_pointer(def), def);
> > +   if (entry)
> > +  return entry->data;
> > +
> > +   merge_set *set = ralloc(state->dead_ctx, merge_set);
> > +   exec_list_make_empty(&set->nodes);
> > +   set->size 

Re: [Mesa-dev] [PATCH 1/3] mesa: bump required GCC version to 4.2.0

2014-12-17 Thread Ian Romanick
On 12/17/2014 12:51 PM, Timothy Arceri wrote:
> It turns out Mesa hasn't compiled on less
> then 4.2 for a while so update conf to
> reflect this.

This and patch 3 could probably be squashed, but meh.

Series is

Reviewed-by: Ian Romanick 

> Signed-off-by: Timothy Arceri 
> ---
>  configure.ac | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index fdb7676..c8723ef 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -102,7 +102,7 @@ AC_COMPILE_IFELSE(
>  
>  AC_MSG_RESULT([$acv_mesa_CLANG])
>  
> -dnl If we're using GCC, make sure that it is at least version 4.1.0.  Older
> +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
>  if test "x$GCC" = xyes -a "x$acv_mesa_CLANG" = xno; then
> @@ -116,9 +116,9 @@ if test "x$GCC" = xyes -a "x$acv_mesa_CLANG" = xno; then
>  GCC_VERSION_MINOR=`echo $GCC_VERSION | cut -d. -f2`
>  fi
>  
> -if test $GCC_VERSION_MAJOR -lt 4 -o $GCC_VERSION_MAJOR -eq 4 -a 
> $GCC_VERSION_MINOR -lt 1 ; then
> +if test $GCC_VERSION_MAJOR -lt 4 -o $GCC_VERSION_MAJOR -eq 4 -a 
> $GCC_VERSION_MINOR -lt 2 ; then
>  AC_MSG_RESULT([no])
> -AC_MSG_ERROR([If using GCC, version 4.1.0 or later is required.])
> +AC_MSG_ERROR([If using GCC, version 4.2.0 or later is required.])
>  else
>  AC_MSG_RESULT([yes])
>  fi
> 

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


Re: [Mesa-dev] [PATCH 05/11] mesa: implement _mesa_GetTextureSubImage()

2014-12-17 Thread Laura Ekstrand
On Sat, Dec 13, 2014 at 6:42 AM, Brian Paul  wrote:
>
> One of the two new functions in GL_ARB_get_texture_sub_image.
> ---
>  src/mesa/main/texgetimage.c | 305
> ++--
>  src/mesa/main/texgetimage.h |   8 ++
>  2 files changed, 277 insertions(+), 36 deletions(-)
>
> diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
> index 71c25bb..e1f238b 100644
> --- a/src/mesa/main/texgetimage.c
> +++ b/src/mesa/main/texgetimage.c
> @@ -44,6 +44,7 @@
>  #include "texcompress.h"
>  #include "texgetimage.h"
>  #include "teximage.h"
> +#include "texobj.h"
>  #include "texstore.h"
>
>
> @@ -803,41 +804,36 @@ legal_getteximage_target(struct gl_context *ctx,
> GLenum target)
>
> In my work with DSA textures, I have discovered that it's more robust to
pass in both the texture object and target.  I originally just passed in
the texObj instead of the target in error checks and used texObj->Target,
but I failed a number of Piglit tests afterwards.  This is because, for
non-DSA texture objects, the target passed into the function and the
texObj->Target don't always match (especially for proxy targets).


>  /**
> - * Do error checking for a glGetTexImage() call.
> + * Do error checking for a glGetTexImage() or glGetTextureSubImage() call.
>   * \return GL_TRUE if any error, GL_FALSE if no errors.
>   */
>  static GLboolean
> -getteximage_error_check(struct gl_context *ctx, GLenum target, GLint
> level,
> +getteximage_error_check(struct gl_context *ctx,
> +struct gl_texture_object *texObj, GLint level,
>  GLenum format, GLenum type, GLsizei clientMemSize,
> -GLvoid *pixels )
> +GLvoid *pixels, const char *caller)
>  {
> -   struct gl_texture_object *texObj;
> +   GLenum target = texObj->Target;
> struct gl_texture_image *texImage;
> const GLint maxLevels = _mesa_max_texture_levels(ctx, target);
> -   const GLuint dimensions = (target == GL_TEXTURE_3D) ? 3 : 2;
> GLenum baseFormat, err;
>
> -   if (!legal_getteximage_target(ctx, target)) {
> -  _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(target=0x%x)",
> target);
> -  return GL_TRUE;
> -   }
> -
> assert(maxLevels != 0);
> if (level < 0 || level >= maxLevels) {
> -  _mesa_error( ctx, GL_INVALID_VALUE, "glGetTexImage(level)" );
> +  _mesa_error(ctx, GL_INVALID_VALUE, "%s(level)", caller);
>return GL_TRUE;
> }
>
> err = _mesa_error_check_format_and_type(ctx, format, type);
> if (err != GL_NO_ERROR) {
> -  _mesa_error(ctx, err, "glGetTexImage(format/type)");
> +  _mesa_error(ctx, err, "%s(format/type)", caller);
>return GL_TRUE;
> }
>
> texObj = _mesa_get_current_tex_object(ctx, target);
>
> if (!texObj) {
> -  _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(target)");
> +  _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", caller);
>return GL_TRUE;
> }
>
> @@ -854,64 +850,79 @@ getteximage_error_check(struct gl_context *ctx,
> GLenum target, GLint level,
>  */
> if (_mesa_is_color_format(format)
> && !_mesa_is_color_format(baseFormat)) {
> -  _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format
> mismatch)");
> +  _mesa_error(ctx, GL_INVALID_OPERATION, "%s(format mismatch)",
> caller);
>return GL_TRUE;
> }
> else if (_mesa_is_depth_format(format)
>  && !_mesa_is_depth_format(baseFormat)
>  && !_mesa_is_depthstencil_format(baseFormat)) {
> -  _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format
> mismatch)");
> +  _mesa_error(ctx, GL_INVALID_OPERATION, "%s(format mismatch)",
> caller);
>return GL_TRUE;
> }
> else if (_mesa_is_stencil_format(format)
>  && !ctx->Extensions.ARB_texture_stencil8) {
> -  _mesa_error(ctx, GL_INVALID_ENUM,
> "glGetTexImage(format=GL_STENCIL_INDEX)");
> +  _mesa_error(ctx, GL_INVALID_ENUM, "%s(format=GL_STENCIL_INDEX)",
> caller);
>return GL_TRUE;
> }
> else if (_mesa_is_ycbcr_format(format)
>  && !_mesa_is_ycbcr_format(baseFormat)) {
> -  _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format
> mismatch)");
> +  _mesa_error(ctx, GL_INVALID_OPERATION, "%s(format mismatch)",
> caller);
>return GL_TRUE;
> }
> else if (_mesa_is_depthstencil_format(format)
>  && !_mesa_is_depthstencil_format(baseFormat)) {
> -  _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format
> mismatch)");
> +  _mesa_error(ctx, GL_INVALID_OPERATION, "%s(format mismatch)",
> caller);
>return GL_TRUE;
> }
> else if (_mesa_is_enum_format_integer(format) !=
>  _mesa_is_format_integer(texImage->TexFormat)) {
> -  _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format
> mismatch)");
> +  _mesa_error(ctx, GL_INVALID_OPERATION, "%s(format mismatch)",
> caller);
>return GL_TRUE;
> }

Re: [Mesa-dev] [PATCH 018/133] nir: add an SSA-based copy propagation pass

2014-12-17 Thread Connor Abbott
On Wed, Dec 17, 2014 at 6:02 PM, Jason Ekstrand  wrote:
>
>
> On Wed, Dec 17, 2014 at 2:26 PM, Connor Abbott  wrote:
>>
>> On Wed, Dec 17, 2014 at 5:20 PM, Jason Ekstrand 
>> wrote:
>> >
>> >
>> > On Wed, Dec 17, 2014 at 1:10 PM, Jason Ekstrand 
>> > wrote:
>> >>
>> >>
>> >>
>> >> On Wed, Dec 17, 2014 at 12:07 PM, Connor Abbott 
>> >> wrote:
>> >>>
>> >>> On Tue, Dec 16, 2014 at 1:04 AM, Jason Ekstrand 
>> >>> wrote:
>> >>> > From: Connor Abbott 
>> >>> >
>> >>> > ---
>> >>> >  src/glsl/Makefile.sources |   1 +
>> >>> >  src/glsl/nir/nir.h|   3 +
>> >>> >  src/glsl/nir/nir_opt_copy_propagate.c | 313
>> >>> > ++
>> >>> >  3 files changed, 317 insertions(+)
>> >>> >  create mode 100644 src/glsl/nir/nir_opt_copy_propagate.c
>> >>> >
>> >>> > diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
>> >>> > index 0aaea58..556648b 100644
>> >>> > --- a/src/glsl/Makefile.sources
>> >>> > +++ b/src/glsl/Makefile.sources
>> >>> > @@ -25,6 +25,7 @@ NIR_FILES = \
>> >>> > $(GLSL_SRCDIR)/nir/nir_lower_variables_scalar.c \
>> >>> > $(GLSL_SRCDIR)/nir/nir_opcodes.c \
>> >>> > $(GLSL_SRCDIR)/nir/nir_opcodes.h \
>> >>> > +   $(GLSL_SRCDIR)/nir/nir_opt_copy_propagate.c \
>> >>> > $(GLSL_SRCDIR)/nir/nir_opt_global_to_local.c \
>> >>> > $(GLSL_SRCDIR)/nir/nir_print.c \
>> >>> > $(GLSL_SRCDIR)/nir/nir_remove_dead_variables.c \
>> >>> > diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
>> >>> > index c2b4724..a5cb5ed 100644
>> >>> > --- a/src/glsl/nir/nir.h
>> >>> > +++ b/src/glsl/nir/nir.h
>> >>> > @@ -1293,6 +1293,9 @@ void nir_convert_to_ssa(nir_shader *shader);
>> >>> >
>> >>> >  bool nir_opt_global_to_local(nir_shader *shader);
>> >>> >
>> >>> > +bool nir_copy_prop_impl(nir_function_impl *impl);
>> >>> > +bool nir_copy_prop(nir_shader *shader);
>> >>> > +
>> >>> >  #ifdef __cplusplus
>> >>> >  } /* extern "C" */
>> >>> >  #endif
>> >>> > diff --git a/src/glsl/nir/nir_opt_copy_propagate.c
>> >>> > b/src/glsl/nir/nir_opt_copy_propagate.c
>> >>> > new file mode 100644
>> >>> > index 000..a2be047
>> >>> > --- /dev/null
>> >>> > +++ b/src/glsl/nir/nir_opt_copy_propagate.c
>> >>> > @@ -0,0 +1,313 @@
>> >>> > +/*
>> >>> > + * 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:
>> >>> > + *Connor Abbott (cwabbo...@gmail.com)
>> >>> > + *
>> >>> > + */
>> >>> > +
>> >>> > +#include "nir.h"
>> >>> > +#include 
>> >>> > +
>> >>> > +/**
>> >>> > + * SSA-based copy propagation
>> >>> > + */
>> >>> > +
>> >>> > +static bool is_move(nir_alu_instr *instr)
>> >>> > +{
>> >>> > +   if (instr->op != nir_op_fmov &&
>> >>> > +   instr->op != nir_op_imov)
>> >>> > +  return false;
>> >>> > +
>> >>> > +   if (instr->dest.saturate)
>> >>> > +  return false;
>> >>> > +
>> >>> > +   /* we handle modifiers in a separate pass */
>> >>>
>> >>> This comment is stale now, since this pass should never see
>> >>> modifiers... maybe we should replace those if's with asserts to make
>> >>> that clear.
>> >>
>> >>
>> >> Easy enough to do.
>> >
>> >
>> > Wait, I just remembered that I left them in intentionally.  We may want
>> > to
>> > run copy prop after lowering to source mods.  In fact, when I wrote
>> > lower_to_source_mods, I was lazy and just changed sat instructions to
>> > mov
>> > and trusted in copy prop to clan up the swizzles for me.  If anything,
>> > we
>> > may want to make copy prop simply handle them correctly.
>> > --Jason
>>
>> Ok

Re: [Mesa-dev] [PATCH 045/133] nir: Add a basic metadata management system

2014-12-17 Thread Connor Abbott
On Wed, Dec 17, 2014 at 5:59 PM, Jason Ekstrand  wrote:
>
>
> On Wed, Dec 17, 2014 at 11:51 AM, Connor Abbott  wrote:
>>
>> One thing I'm a little worried about is that passes might forget to
>> require the right metadata, and they'll just happen to work since the
>> pass before also requires the same metadata and preserves it. I think
>> a good thing to do to combat this is to have a debug mode that dirties
>> *all* the metadata in nir_metadata_preserve(), even the stuff the
>> caller asks us to preserve, and actually goes and destroys it/somehow
>> makes it garbage so that passes that forget to require the right
>> metadata will fail spectacularly. The other, more insidious, issue is
>> passes accidentally preserving metadata that the author didn't realize
>> they invalidated. We could solve this by somehow re-calculating the
>> metadata in nir_metadata_preserve() and comparing it to the old
>> metadata before trashing it, but I'm not as clear on how that would
>> work and it seems like a lot more work so I'm fine with leaving it out
>> for now. I'd like this to happen whenever we enable nir_validate
>> (#ifdef DEBUG?), but I'll leave figuring out how to enable it up to
>> you.
>
>
> Oh, I am well aware...
>
> As far as preserving goes, I really don't care.  If you don't ask for
> metadata but try and use it, that's your fault and there's not much we can
> do about it.  Eventually, we may end up trashing everything at the beginning
> of each optimization loop and that may help a little bit.  More worrying is
> what happens if you don't call nir_metadata_preserve...

Fine, although I think I'm still a little more worried about it than
you are :) At least it's relatively easy to solve (just trash
everything on nir_metadata_preserve()).

>
> I've thought about a couple of possible solutions to this.  One would be to
> have some sort of data structure to represent a pass that contains the
> metadata it requires and the metadata it preserves and never call the
> functions directly.  The problem here is that requiring/preserving may be
> more interesting than that.  For instance, the nir_lower_variables pass
> requires dominance but only if there's actually stuff to lower.  Most
> optimization passes only dirty metadata if they actually do work, etc.

I don't think this will be too bad, though. If we did go down this
approach, then we would still have nir_metadata_require() and
nir_metadata_preserve() as a separate function, so passes like
lower_variables could still call them directly when they realize they
can bail early / need to modify stuff and then get re-analyze it. The
runner would only dirty the metadata if the pass reports making
progress, so that isn't a hard problem to solve. This is the approach
that LLVM takes, so it's been proven before.

>
> Another thought that I've had is, when I make an OPT macro or whatever, we
> can have a flag that gets set before each pass and then unset when you call
> nir_metadata_preserve.  If you never call nir_metadata_preserve, we
> assert-fail in debug mode and just dirty the universe in release mode.  If
> we did this, we would also need a nir_metadata_preserve_all function for
> optimizations to call if they do no work that just unsets the flag.
>
> So yes, it's on my radar.
> --Jason
>
>>
>>
>> On Tue, Dec 16, 2014 at 1:04 AM, Jason Ekstrand 
>> wrote:
>> > ---
>> >  src/glsl/Makefile.sources|  1 +
>> >  src/glsl/nir/nir.c   | 19 +++-
>> >  src/glsl/nir/nir.h   | 21 --
>> >  src/glsl/nir/nir_dominance.c |  6 ++---
>> >  src/glsl/nir/nir_metadata.c  | 52
>> > 
>> >  5 files changed, 82 insertions(+), 17 deletions(-)
>> >  create mode 100644 src/glsl/nir/nir_metadata.c
>> >
>> > diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
>> > index d3b17bd..4eb6320 100644
>> > --- a/src/glsl/Makefile.sources
>> > +++ b/src/glsl/Makefile.sources
>> > @@ -25,6 +25,7 @@ NIR_FILES = \
>> > $(GLSL_SRCDIR)/nir/nir_lower_system_values.c \
>> > $(GLSL_SRCDIR)/nir/nir_lower_variables_scalar.c \
>> > $(GLSL_SRCDIR)/nir/nir_lower_vec_to_movs.c \
>> > +   $(GLSL_SRCDIR)/nir/nir_metadata.c \
>> > $(GLSL_SRCDIR)/nir/nir_opcodes.c \
>> > $(GLSL_SRCDIR)/nir/nir_opcodes.h \
>> > $(GLSL_SRCDIR)/nir/nir_opt_copy_propagate.c \
>> > diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
>> > index 3dd9e5a..0124799 100644
>> > --- a/src/glsl/nir/nir.c
>> > +++ b/src/glsl/nir/nir.c
>> > @@ -106,6 +106,7 @@ nir_function_create(nir_shader *shader, const char
>> > *name)
>> > exec_list_push_tail(&shader->functions, &func->node);
>> > exec_list_make_empty(&func->overload_list);
>> > func->name = name;
>> > +   func->shader = shader;
>> >
>> > return func;
>> >  }
>> > @@ -243,8 +244,7 @@ nir_function_impl_create(nir_function_overload
>> > *overload)
>> > impl->return_var = NULL;
>> > impl->reg_alloc = 0;
>> > impl->

Re: [Mesa-dev] [PATCH 057/133] nir: Add a better out-of-SSA pass

2014-12-17 Thread Connor Abbott
Whew! Other than a few minor things below,

Reviewed-by: Connor Abbott 

I tried to understand it all as much as I could, but it is rather
tricky... but I can't suggest anything to make it easier to
understand, after all the paper itself is rather tricky and your
comments help a lot. If anyone has any ideas, please say something...

On Tue, Dec 16, 2014 at 1:05 AM, Jason Ekstrand  wrote:
> This commit rewrites the out-of-SSA pass to not be nearly as naieve.  It's
> based on "Revisiting Out-of-SSA Translation for Correctness, Code Quality,
> and Efficiency" by Boissinot et. al.  It should be fairly close to
> state-of-the art.
> ---
>  src/glsl/nir/nir_from_ssa.c | 793 
> +++-
>  1 file changed, 715 insertions(+), 78 deletions(-)
>
> diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c
> index a26f0c4..62a54fe 100644
> --- a/src/glsl/nir/nir_from_ssa.c
> +++ b/src/glsl/nir/nir_from_ssa.c
> @@ -28,54 +28,474 @@
>  #include "nir.h"
>
>  /*
> - * Implements a quick-and-dirty out-of-ssa pass.
> + * This file implements an out-of-SSA pass as described in "Revisiting
> + * Out-of-SSA Translation for Correctness, Code Quality, and Efficiency" by
> + * Boissinot et. al.
>   */
>
>  struct from_ssa_state {
> void *mem_ctx;
> void *dead_ctx;
> struct hash_table *ssa_table;
> -   nir_function_impl *current_impl;
> +   struct hash_table *merge_node_table;
> +   nir_instr *instr;
> +   nir_function_impl *impl;
>  };
>
> +/* Returns true if a dominates b */
>  static bool
> -rewrite_ssa_src(nir_src *src, void *void_state)
> +ssa_def_dominates(nir_ssa_def *a, nir_ssa_def *b)
> +{
> +   if (a->live_index == 0) {
> +  /* SSA undefs always dominate */
> +  return true;
> +   } else if (b->live_index < a->live_index) {
> +  return false;
> +   } else if (a->parent_instr->block == b->parent_instr->block) {
> +  return a->live_index <= b->live_index;
> +   } else {
> +  nir_block *block = b->parent_instr->block;
> +  while (block->imm_dom != NULL) {
> + if (block->imm_dom == a->parent_instr->block)
> +return true;
> + block = block->imm_dom;
> +  }
> +  return false;
> +   }
> +}
> +
> +
> +/* The following data structure, which I have named merge_set is a way of
> + * representing a set registers of non-interfering registers.  This is
> + * based on the concept of a "dominence forest" presented in "Fast Copy
> + * Coalescing and Live-Range Identification" by Budimlic et. al. but the
> + * implementation concept is taken from  "Revisiting Out-of-SSA Translation
> + * for Correctness, Code Quality, and Efficiency" by Boissinot et. al..
> + *
> + * Each SSA definition is associated with a merge_node and the association
> + * is represented by a combination of a hash table and the "def" parameter
> + * in the merge_node structure.  The merge_set stores a linked list of
> + * merge_node's in dominence order of the ssa definitions.  (Since the
> + * liveness analysis pass indexes the SSA values in dominence order for us,
> + * this is an easy thing to keep up.)  It is assumed that no pair of the
> + * nodes in a given set interfere.  Merging two sets or checking for
> + * interference can be done in a single linear-time merge-sort walk of the
> + * two lists of nodes.
> + */
> +struct merge_set;
> +
> +typedef struct {
> +   struct exec_node node;
> +   struct merge_set *set;
> +   nir_ssa_def *def;
> +} merge_node;
> +
> +typedef struct merge_set {
> +   struct exec_list nodes;
> +   unsigned size;
> +   nir_register *reg;
> +} merge_set;
> +
> +#if 0
> +static void
> +merge_set_dump(merge_set *set, FILE *fp)
> +{
> +   nir_ssa_def *dom[set->size];
> +   int dom_idx = -1;
> +
> +   foreach_list_typed(merge_node, node, node, &set->nodes) {
> +  while (dom_idx >= 0 && !ssa_def_dominates(dom[dom_idx], node->def))
> + dom_idx--;
> +
> +  for (int i = 0; i <= dom_idx; i++)
> + fprintf(fp, "  ");
> +
> +  if (node->def->name)
> + fprintf(fp, "ssa_%d /* %s */\n", node->def->index, node->def->name);
> +  else
> + fprintf(fp, "ssa_%d\n", node->def->index);
> +
> +  dom[++dom_idx] = node->def;
> +   }
> +}
> +#endif
> +
> +static merge_node *
> +get_merge_node(nir_ssa_def *def, struct from_ssa_state *state)
> +{
> +   struct hash_entry *entry =
> +  _mesa_hash_table_search(state->merge_node_table,
> +  _mesa_hash_pointer(def), def);
> +   if (entry)
> +  return entry->data;
> +
> +   merge_set *set = ralloc(state->dead_ctx, merge_set);
> +   exec_list_make_empty(&set->nodes);
> +   set->size = 1;
> +   set->reg = NULL;
> +
> +   merge_node *node = ralloc(state->dead_ctx, merge_node);
> +   node->set = set;
> +   node->def = def;
> +   exec_list_push_head(&set->nodes, &node->node);
> +
> +   _mesa_hash_table_insert(state->merge_node_table,
> +   _mesa_hash_pointer(def), def, node);
> +
> +   return node;

Re: [Mesa-dev] [PATCH 045/133] nir: Add a basic metadata management system

2014-12-17 Thread Matt Turner
On Wed, Dec 17, 2014 at 11:51 AM, Connor Abbott  wrote:
> One thing I'm a little worried about is that passes might forget to
> require the right metadata, and they'll just happen to work since the
> pass before also requires the same metadata and preserves it. I think
> a good thing to do to combat this is to have a debug mode that dirties
> *all* the metadata in nir_metadata_preserve(), even the stuff the
> caller asks us to preserve, and actually goes and destroys it/somehow
> makes it garbage so that passes that forget to require the right
> metadata will fail spectacularly. The other, more insidious, issue is
> passes accidentally preserving metadata that the author didn't realize
> they invalidated. We could solve this by somehow re-calculating the
> metadata in nir_metadata_preserve() and comparing it to the old
> metadata before trashing it, but I'm not as clear on how that would
> work and it seems like a lot more work so I'm fine with leaving it out
> for now. I'd like this to happen whenever we enable nir_validate
> (#ifdef DEBUG?), but I'll leave figuring out how to enable it up to
> you.

I don't really think this is a big concern. We called
calculate_cfg()/calculate_live_intervals() in the i965 driver in a
bunch of optimization passes.

In most cases forgetting to call them lead to instant segfaults. It
was only rarely that it wasn't entirely obvious what was going on, but
even then noticing that we're reading some live variable information
without generating it makes it pretty easy to spot.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 018/133] nir: add an SSA-based copy propagation pass

2014-12-17 Thread Jason Ekstrand
On Wed, Dec 17, 2014 at 2:26 PM, Connor Abbott  wrote:
>
> On Wed, Dec 17, 2014 at 5:20 PM, Jason Ekstrand 
> wrote:
> >
> >
> > On Wed, Dec 17, 2014 at 1:10 PM, Jason Ekstrand 
> > wrote:
> >>
> >>
> >>
> >> On Wed, Dec 17, 2014 at 12:07 PM, Connor Abbott 
> >> wrote:
> >>>
> >>> On Tue, Dec 16, 2014 at 1:04 AM, Jason Ekstrand 
> >>> wrote:
> >>> > From: Connor Abbott 
> >>> >
> >>> > ---
> >>> >  src/glsl/Makefile.sources |   1 +
> >>> >  src/glsl/nir/nir.h|   3 +
> >>> >  src/glsl/nir/nir_opt_copy_propagate.c | 313
> >>> > ++
> >>> >  3 files changed, 317 insertions(+)
> >>> >  create mode 100644 src/glsl/nir/nir_opt_copy_propagate.c
> >>> >
> >>> > diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
> >>> > index 0aaea58..556648b 100644
> >>> > --- a/src/glsl/Makefile.sources
> >>> > +++ b/src/glsl/Makefile.sources
> >>> > @@ -25,6 +25,7 @@ NIR_FILES = \
> >>> > $(GLSL_SRCDIR)/nir/nir_lower_variables_scalar.c \
> >>> > $(GLSL_SRCDIR)/nir/nir_opcodes.c \
> >>> > $(GLSL_SRCDIR)/nir/nir_opcodes.h \
> >>> > +   $(GLSL_SRCDIR)/nir/nir_opt_copy_propagate.c \
> >>> > $(GLSL_SRCDIR)/nir/nir_opt_global_to_local.c \
> >>> > $(GLSL_SRCDIR)/nir/nir_print.c \
> >>> > $(GLSL_SRCDIR)/nir/nir_remove_dead_variables.c \
> >>> > diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> >>> > index c2b4724..a5cb5ed 100644
> >>> > --- a/src/glsl/nir/nir.h
> >>> > +++ b/src/glsl/nir/nir.h
> >>> > @@ -1293,6 +1293,9 @@ void nir_convert_to_ssa(nir_shader *shader);
> >>> >
> >>> >  bool nir_opt_global_to_local(nir_shader *shader);
> >>> >
> >>> > +bool nir_copy_prop_impl(nir_function_impl *impl);
> >>> > +bool nir_copy_prop(nir_shader *shader);
> >>> > +
> >>> >  #ifdef __cplusplus
> >>> >  } /* extern "C" */
> >>> >  #endif
> >>> > diff --git a/src/glsl/nir/nir_opt_copy_propagate.c
> >>> > b/src/glsl/nir/nir_opt_copy_propagate.c
> >>> > new file mode 100644
> >>> > index 000..a2be047
> >>> > --- /dev/null
> >>> > +++ b/src/glsl/nir/nir_opt_copy_propagate.c
> >>> > @@ -0,0 +1,313 @@
> >>> > +/*
> >>> > + * 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:
> >>> > + *Connor Abbott (cwabbo...@gmail.com)
> >>> > + *
> >>> > + */
> >>> > +
> >>> > +#include "nir.h"
> >>> > +#include 
> >>> > +
> >>> > +/**
> >>> > + * SSA-based copy propagation
> >>> > + */
> >>> > +
> >>> > +static bool is_move(nir_alu_instr *instr)
> >>> > +{
> >>> > +   if (instr->op != nir_op_fmov &&
> >>> > +   instr->op != nir_op_imov)
> >>> > +  return false;
> >>> > +
> >>> > +   if (instr->dest.saturate)
> >>> > +  return false;
> >>> > +
> >>> > +   /* we handle modifiers in a separate pass */
> >>>
> >>> This comment is stale now, since this pass should never see
> >>> modifiers... maybe we should replace those if's with asserts to make
> >>> that clear.
> >>
> >>
> >> Easy enough to do.
> >
> >
> > Wait, I just remembered that I left them in intentionally.  We may want
> to
> > run copy prop after lowering to source mods.  In fact, when I wrote
> > lower_to_source_mods, I was lazy and just changed sat instructions to mov
> > and trusted in copy prop to clan up the swizzles for me.  If anything, we
> > may want to make copy prop simply handle them correctly.
> > --Jason
>
> Ok, that's fine. In that case, we should probably have a separate pass
> to move sat/abs/neg out of moves like the comment mentions, similar to
> what we do in i965 fs. Or did you already write one?
>

I don't think that we actually have that proble

Re: [Mesa-dev] [PATCH 045/133] nir: Add a basic metadata management system

2014-12-17 Thread Jason Ekstrand
On Wed, Dec 17, 2014 at 11:51 AM, Connor Abbott  wrote:
>
> One thing I'm a little worried about is that passes might forget to
> require the right metadata, and they'll just happen to work since the
> pass before also requires the same metadata and preserves it. I think
> a good thing to do to combat this is to have a debug mode that dirties
> *all* the metadata in nir_metadata_preserve(), even the stuff the
> caller asks us to preserve, and actually goes and destroys it/somehow
> makes it garbage so that passes that forget to require the right
> metadata will fail spectacularly. The other, more insidious, issue is
> passes accidentally preserving metadata that the author didn't realize
> they invalidated. We could solve this by somehow re-calculating the
> metadata in nir_metadata_preserve() and comparing it to the old
> metadata before trashing it, but I'm not as clear on how that would
> work and it seems like a lot more work so I'm fine with leaving it out
> for now. I'd like this to happen whenever we enable nir_validate
> (#ifdef DEBUG?), but I'll leave figuring out how to enable it up to
> you.
>

Oh, I am well aware...

As far as preserving goes, I really don't care.  If you don't ask for
metadata but try and use it, that's your fault and there's not much we can
do about it.  Eventually, we may end up trashing everything at the
beginning of each optimization loop and that may help a little bit.  More
worrying is what happens if you don't call nir_metadata_preserve...

I've thought about a couple of possible solutions to this.  One would be to
have some sort of data structure to represent a pass that contains the
metadata it requires and the metadata it preserves and never call the
functions directly.  The problem here is that requiring/preserving may be
more interesting than that.  For instance, the nir_lower_variables pass
requires dominance but only if there's actually stuff to lower.  Most
optimization passes only dirty metadata if they actually do work, etc.

Another thought that I've had is, when I make an OPT macro or whatever, we
can have a flag that gets set before each pass and then unset when you call
nir_metadata_preserve.  If you never call nir_metadata_preserve, we
assert-fail in debug mode and just dirty the universe in release mode.  If
we did this, we would also need a nir_metadata_preserve_all function for
optimizations to call if they do no work that just unsets the flag.

So yes, it's on my radar.
--Jason


>
> On Tue, Dec 16, 2014 at 1:04 AM, Jason Ekstrand 
> wrote:
> > ---
> >  src/glsl/Makefile.sources|  1 +
> >  src/glsl/nir/nir.c   | 19 +++-
> >  src/glsl/nir/nir.h   | 21 --
> >  src/glsl/nir/nir_dominance.c |  6 ++---
> >  src/glsl/nir/nir_metadata.c  | 52
> 
> >  5 files changed, 82 insertions(+), 17 deletions(-)
> >  create mode 100644 src/glsl/nir/nir_metadata.c
> >
> > diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
> > index d3b17bd..4eb6320 100644
> > --- a/src/glsl/Makefile.sources
> > +++ b/src/glsl/Makefile.sources
> > @@ -25,6 +25,7 @@ NIR_FILES = \
> > $(GLSL_SRCDIR)/nir/nir_lower_system_values.c \
> > $(GLSL_SRCDIR)/nir/nir_lower_variables_scalar.c \
> > $(GLSL_SRCDIR)/nir/nir_lower_vec_to_movs.c \
> > +   $(GLSL_SRCDIR)/nir/nir_metadata.c \
> > $(GLSL_SRCDIR)/nir/nir_opcodes.c \
> > $(GLSL_SRCDIR)/nir/nir_opcodes.h \
> > $(GLSL_SRCDIR)/nir/nir_opt_copy_propagate.c \
> > diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
> > index 3dd9e5a..0124799 100644
> > --- a/src/glsl/nir/nir.c
> > +++ b/src/glsl/nir/nir.c
> > @@ -106,6 +106,7 @@ nir_function_create(nir_shader *shader, const char
> *name)
> > exec_list_push_tail(&shader->functions, &func->node);
> > exec_list_make_empty(&func->overload_list);
> > func->name = name;
> > +   func->shader = shader;
> >
> > return func;
> >  }
> > @@ -243,8 +244,7 @@ nir_function_impl_create(nir_function_overload
> *overload)
> > impl->return_var = NULL;
> > impl->reg_alloc = 0;
> > impl->ssa_alloc = 0;
> > -   impl->block_index_dirty = true;
> > -   impl->dominance_dirty = true;
> > +   impl->valid_metadata = nir_metadata_none;
> >
> > /* create start & end blocks */
> > nir_block *start_block = nir_block_create(mem_ctx);
> > @@ -815,7 +815,7 @@ handle_jump(nir_block *block)
> > unlink_block_successors(block);
> >
> > nir_function_impl *impl = nir_cf_node_get_function(&block->cf_node);
> > -   impl->dominance_dirty = true;
> > +   nir_metadata_dirty(impl, nir_metadata_none);
> >
> > if (jump_instr->type == nir_jump_break ||
> > jump_instr->type == nir_jump_continue) {
> > @@ -912,7 +912,7 @@ handle_remove_jump(nir_block *block, nir_jump_type
> type)
> > }
> >
> > nir_function_impl *impl = nir_cf_node_get_function(&block->cf_node);
> > -   impl->dominance_dirty = true;
> > +   nir_metadata_dirty(impl,

[Mesa-dev] [PATCH 138/133] nir: Rename nir_block_following_if to nir_block_get_following_if

2014-12-17 Thread Jason Ekstrand
The new name is a little longer but less confusing.
---
 src/glsl/nir/nir.c| 2 +-
 src/glsl/nir/nir.h| 2 +-
 src/glsl/nir/nir_from_ssa.c   | 2 +-
 src/glsl/nir/nir_live_variables.c | 2 +-
 src/glsl/nir/nir_opt_dce.c| 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
index 0e5a5e1..d0cab5a 100644
--- a/src/glsl/nir/nir.c
+++ b/src/glsl/nir/nir.c
@@ -1949,7 +1949,7 @@ nir_foreach_block_reverse(nir_function_impl *impl, 
nir_foreach_block_cb cb,
 }
 
 nir_if *
-nir_block_following_if(nir_block *block)
+nir_block_get_following_if(nir_block *block)
 {
if (exec_node_is_tail_sentinel(&block->cf_node.node))
   return NULL;
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index ba04c29..dbfa461 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -1336,7 +1336,7 @@ bool nir_foreach_block_reverse(nir_function_impl *impl, 
nir_foreach_block_cb cb,
 /* If the following CF node is an if, this function returns that if.
  * Otherwise, it returns NULL.
  */
-nir_if *nir_block_following_if(nir_block *block);
+nir_if *nir_block_get_following_if(nir_block *block);
 
 void nir_index_local_regs(nir_function_impl *impl);
 void nir_index_global_regs(nir_shader *shader);
diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c
index ae3666b..b903cd2 100644
--- a/src/glsl/nir/nir_from_ssa.c
+++ b/src/glsl/nir/nir_from_ssa.c
@@ -562,7 +562,7 @@ resolve_registers_block(nir_block *block, void *void_state)
}
state->instr = NULL;
 
-   nir_if *following_if = nir_block_following_if(block);
+   nir_if *following_if = nir_block_get_following_if(block);
if (following_if && following_if->condition.is_ssa) {
   nir_register *reg = get_register_for_ssa_def(following_if->condition.ssa,
state);
diff --git a/src/glsl/nir/nir_live_variables.c 
b/src/glsl/nir/nir_live_variables.c
index 13306b3..129e5ef 100644
--- a/src/glsl/nir/nir_live_variables.c
+++ b/src/glsl/nir/nir_live_variables.c
@@ -165,7 +165,7 @@ walk_instructions_block(nir_block *block, void *void_state)
memcpy(block->live_in, block->live_out,
   state->bitset_words * sizeof(BITSET_WORD));
 
-   nir_if *following_if = nir_block_following_if(block);
+   nir_if *following_if = nir_block_get_following_if(block);
if (following_if)
   set_src_live(&following_if->condition, block->live_in);
 
diff --git a/src/glsl/nir/nir_opt_dce.c b/src/glsl/nir/nir_opt_dce.c
index 9778e9e..3f7d94d 100644
--- a/src/glsl/nir/nir_opt_dce.c
+++ b/src/glsl/nir/nir_opt_dce.c
@@ -116,7 +116,7 @@ init_block_cb(nir_block *block, void *_state)
nir_foreach_instr(block, instr)
   init_instr(instr, worklist);
 
-   nir_if *following_if = nir_block_following_if(block);
+   nir_if *following_if = nir_block_get_following_if(block);
if (following_if) {
   if (following_if->condition.is_ssa &&
   !following_if->condition.ssa->parent_instr->live)
-- 
2.2.0

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


Re: [Mesa-dev] [PATCH 055/133] nir: Add a parallel copy instruction type

2014-12-17 Thread Connor Abbott
On Tue, Dec 16, 2014 at 1:05 AM, Jason Ekstrand  wrote:
> ---
>  src/glsl/nir/nir.c   | 45 -
>  src/glsl/nir/nir.h   | 23 +++
>  src/glsl/nir/nir_print.c | 21 +
>  3 files changed, 88 insertions(+), 1 deletion(-)
>
> diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
> index 27e903e..d3fd084 100644
> --- a/src/glsl/nir/nir.c
> +++ b/src/glsl/nir/nir.c
> @@ -475,6 +475,18 @@ nir_phi_instr_create(void *mem_ctx)
> return instr;
>  }
>
> +nir_parallel_copy_instr *
> +nir_parallel_copy_instr_create(void *mem_ctx)
> +{
> +   nir_parallel_copy_instr *instr = ralloc(mem_ctx, nir_parallel_copy_instr);
> +   instr_init(&instr->instr, nir_instr_type_parallel_copy);
> +
> +   instr->at_end = false;
> +   exec_list_make_empty(&instr->copies);
> +
> +   return instr;
> +}
> +
>  nir_ssa_undef_instr *
>  nir_ssa_undef_instr_create(void *mem_ctx)
>  {
> @@ -1377,6 +1389,18 @@ visit_phi_dest(nir_phi_instr *instr, 
> nir_foreach_dest_cb cb, void *state)
> return cb(&instr->dest, state);
>  }
>
> +static bool
> +visit_parallel_copy_dest(nir_parallel_copy_instr *instr,
> + nir_foreach_dest_cb cb, void *state)
> +{
> +   foreach_list_typed(nir_parallel_copy_copy, copy, node, &instr->copies) {
> +  if (!cb(©->dest, state))
> + return false;
> +   }
> +
> +   return true;
> +}
> +
>  bool
>  nir_foreach_dest(nir_instr *instr, nir_foreach_dest_cb cb, void *state)
>  {
> @@ -1391,7 +1415,9 @@ nir_foreach_dest(nir_instr *instr, nir_foreach_dest_cb 
> cb, void *state)
>return visit_load_const_dest(nir_instr_as_load_const(instr), cb, 
> state);
> case nir_instr_type_phi:
>return visit_phi_dest(nir_instr_as_phi(instr), cb, state);
> -  break;
> +   case nir_instr_type_parallel_copy:
> +  return visit_parallel_copy_dest(nir_instr_as_parallel_copy(instr),
> +  cb, state);
>
> case nir_instr_type_ssa_undef:
> case nir_instr_type_call:
> @@ -1526,6 +1552,18 @@ visit_phi_src(nir_phi_instr *instr, nir_foreach_src_cb 
> cb, void *state)
> return true;
>  }
>
> +static bool
> +visit_parallel_copy_src(nir_parallel_copy_instr *instr,
> +nir_foreach_src_cb cb, void *state)
> +{
> +   foreach_list_typed(nir_parallel_copy_copy, copy, node, &instr->copies) {
> +  if (!visit_src(©->src, cb, state))
> + return false;
> +   }
> +
> +   return true;
> +}
> +
>  typedef struct {
> void *state;
> nir_foreach_src_cb cb;
> @@ -1570,6 +1608,11 @@ nir_foreach_src(nir_instr *instr, nir_foreach_src_cb 
> cb, void *state)
>if (!visit_phi_src(nir_instr_as_phi(instr), cb, state))
>   return false;
>break;
> +   case nir_instr_type_parallel_copy:
> +  if (!visit_parallel_copy_src(nir_instr_as_parallel_copy(instr),
> +   cb, state))
> + return false;
> +  break;
> case nir_instr_type_jump:
> case nir_instr_type_ssa_undef:
>return true;
> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> index 988a135..2ebf826 100644
> --- a/src/glsl/nir/nir.h
> +++ b/src/glsl/nir/nir.h
> @@ -396,6 +396,7 @@ typedef enum {
> nir_instr_type_jump,
> nir_instr_type_ssa_undef,
> nir_instr_type_phi,
> +   nir_instr_type_parallel_copy,
>  } nir_instr_type;
>
>  typedef struct {
> @@ -933,6 +934,24 @@ typedef struct {
> nir_dest dest;
>  } nir_phi_instr;
>
> +typedef struct {
> +   struct exec_node node;
> +   nir_src src;
> +   nir_dest dest;
> +} nir_parallel_copy_copy;

I don't really care too much what this is called, but maybe something
less silly like "nir_parallel_copy_entry"?

> +
> +typedef struct {
> +   nir_instr instr;
> +
> +   /* Indicates that this is the parallel copy at the end of the block.
> +* When isolating phi nodes, we create 2 parallel copies in most blocks;
> +* this flag helps tell them apart.
> +*/
> +   bool at_end;

Do we really need this? I haven't read the pass yet, but I thought we
could figure this out by checking to see if we're the last instruction
of the basic block.

> +
> +   struct exec_list copies;
> +} nir_parallel_copy_instr;
> +
>  #define nir_instr_as_alu(_instr) exec_node_data(nir_alu_instr, _instr, instr)
>  #define nir_instr_as_call(_instr) exec_node_data(nir_call_instr, _instr, 
> instr)
>  #define nir_instr_as_jump(_instr) exec_node_data(nir_jump_instr, _instr, 
> instr)
> @@ -946,6 +965,8 @@ typedef struct {
> exec_node_data(nir_ssa_undef_instr, _instr, instr)
>  #define nir_instr_as_phi(_instr) \
> exec_node_data(nir_phi_instr, _instr, instr)
> +#define nir_instr_as_parallel_copy(_instr) \
> +   exec_node_data(nir_parallel_copy_instr, _instr, instr)
>
>
>  /*
> @@ -1251,6 +1272,8 @@ nir_tex_instr *nir_tex_instr_create(void *mem_ctx, 
> unsigned num_srcs);
>
>  nir_phi_instr *nir_phi_instr_create(void *mem_ctx);
>
> +nir_parallel_copy_instr *nir_parallel_copy_i

Re: [Mesa-dev] [PATCH 018/133] nir: add an SSA-based copy propagation pass

2014-12-17 Thread Connor Abbott
On Wed, Dec 17, 2014 at 5:20 PM, Jason Ekstrand  wrote:
>
>
> On Wed, Dec 17, 2014 at 1:10 PM, Jason Ekstrand 
> wrote:
>>
>>
>>
>> On Wed, Dec 17, 2014 at 12:07 PM, Connor Abbott 
>> wrote:
>>>
>>> On Tue, Dec 16, 2014 at 1:04 AM, Jason Ekstrand 
>>> wrote:
>>> > From: Connor Abbott 
>>> >
>>> > ---
>>> >  src/glsl/Makefile.sources |   1 +
>>> >  src/glsl/nir/nir.h|   3 +
>>> >  src/glsl/nir/nir_opt_copy_propagate.c | 313
>>> > ++
>>> >  3 files changed, 317 insertions(+)
>>> >  create mode 100644 src/glsl/nir/nir_opt_copy_propagate.c
>>> >
>>> > diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
>>> > index 0aaea58..556648b 100644
>>> > --- a/src/glsl/Makefile.sources
>>> > +++ b/src/glsl/Makefile.sources
>>> > @@ -25,6 +25,7 @@ NIR_FILES = \
>>> > $(GLSL_SRCDIR)/nir/nir_lower_variables_scalar.c \
>>> > $(GLSL_SRCDIR)/nir/nir_opcodes.c \
>>> > $(GLSL_SRCDIR)/nir/nir_opcodes.h \
>>> > +   $(GLSL_SRCDIR)/nir/nir_opt_copy_propagate.c \
>>> > $(GLSL_SRCDIR)/nir/nir_opt_global_to_local.c \
>>> > $(GLSL_SRCDIR)/nir/nir_print.c \
>>> > $(GLSL_SRCDIR)/nir/nir_remove_dead_variables.c \
>>> > diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
>>> > index c2b4724..a5cb5ed 100644
>>> > --- a/src/glsl/nir/nir.h
>>> > +++ b/src/glsl/nir/nir.h
>>> > @@ -1293,6 +1293,9 @@ void nir_convert_to_ssa(nir_shader *shader);
>>> >
>>> >  bool nir_opt_global_to_local(nir_shader *shader);
>>> >
>>> > +bool nir_copy_prop_impl(nir_function_impl *impl);
>>> > +bool nir_copy_prop(nir_shader *shader);
>>> > +
>>> >  #ifdef __cplusplus
>>> >  } /* extern "C" */
>>> >  #endif
>>> > diff --git a/src/glsl/nir/nir_opt_copy_propagate.c
>>> > b/src/glsl/nir/nir_opt_copy_propagate.c
>>> > new file mode 100644
>>> > index 000..a2be047
>>> > --- /dev/null
>>> > +++ b/src/glsl/nir/nir_opt_copy_propagate.c
>>> > @@ -0,0 +1,313 @@
>>> > +/*
>>> > + * 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:
>>> > + *Connor Abbott (cwabbo...@gmail.com)
>>> > + *
>>> > + */
>>> > +
>>> > +#include "nir.h"
>>> > +#include 
>>> > +
>>> > +/**
>>> > + * SSA-based copy propagation
>>> > + */
>>> > +
>>> > +static bool is_move(nir_alu_instr *instr)
>>> > +{
>>> > +   if (instr->op != nir_op_fmov &&
>>> > +   instr->op != nir_op_imov)
>>> > +  return false;
>>> > +
>>> > +   if (instr->dest.saturate)
>>> > +  return false;
>>> > +
>>> > +   /* we handle modifiers in a separate pass */
>>>
>>> This comment is stale now, since this pass should never see
>>> modifiers... maybe we should replace those if's with asserts to make
>>> that clear.
>>
>>
>> Easy enough to do.
>
>
> Wait, I just remembered that I left them in intentionally.  We may want to
> run copy prop after lowering to source mods.  In fact, when I wrote
> lower_to_source_mods, I was lazy and just changed sat instructions to mov
> and trusted in copy prop to clan up the swizzles for me.  If anything, we
> may want to make copy prop simply handle them correctly.
> --Jason

Ok, that's fine. In that case, we should probably have a separate pass
to move sat/abs/neg out of moves like the comment mentions, similar to
what we do in i965 fs. Or did you already write one?

>
>>
>>
>>>
>>>
>>> > +
>>> > +   if (instr->src[0].abs || instr->src[0].negate)
>>> > +  return false;
>>> > +
>>> > +   if (!instr->src[0].src.is_ssa)
>>> > +  return false;
>>> > +
>>> > +   return true;
>>> > +
>>> > +}
>>> > +
>>> > +static bool
>>> > +is_swizzleless_move(nir_alu_instr *instr)
>>> > +{
>>> > +   if (!is_move(instr))
>>> > +  return false;
>>> > 

Re: [Mesa-dev] [PATCH 051/133] nir: Add an SSA-based liveness analysis pass.

2014-12-17 Thread Connor Abbott
On Wed, Dec 17, 2014 at 5:11 PM, Jason Ekstrand  wrote:
> On Wed, Dec 17, 2014 at 1:52 PM, Connor Abbott  wrote:
>>
>> I'm sure you're already aware, but there are two things we could do to
>> speed this up:
>>
>> 1. Pre-compute def/kill sets for each block similar to what i965 does.
>
>
> Sure, but we walk the instructions at most deepest block depth + 1 and the
> depest we've ever seen in the wild is 2.

Well, there's always orbital explorer ;)

>
>> 2. Use a worklist + an array of flags for "this block is in the
>> worklist" rather than walking all the basic blocks in reverse to find
>> the few we need to update.
>
>
> Sure, we could, but I don't see how pushing the blocks onto a stack and then
> popping them back off really gains us anything over just walking them.  If
> there's something I'm missing, please let me know because it's not jumping
> out at me.  I'll freely admit that I'm not terribly familiar with worklists.

I didn't mean a stack, I meant a FIFO queue. The idea is that rather
than walking through every instruction, even when there are only
changes to be made, we pop a pointer to a block off the worklist, see
if it's live-in set changed, and if it did, we push every predecessor
not already in the worklist onto the worklist and then mark the block
as not being in the worklist. We start by pushing all the blocks in
the worklist in reverse order, since that's the most efficient
ordering. Then, we're only processing blocks that we know might change
rather than every possible one, and for control flow without loops we
only walk the instructions once instead of twice. I think this is
going to be a pretty common thing for optimization passes to do, so it
would be nice to have a common implementation of the worklist.

>
>>
>>
>> Wrt #2, we already use a worklist in the DCE pass, but it's kinda lame
>> because it's using a linked list when we could just allocate an array
>> of pointers up-front based on the maximum size (the number of blocks
>> in this case, the number of SSA definitions in that case) and use it
>> as a ringbuffer. It would be a nice cleanup to implement such a
>> bounded worklist and share it between these two passes, since we'll
>> probably want to use it for lots of other passes too.
>>
>> I don't either thing should block merging this, though.
>>
>> A few other comments below.
>>
>> On Tue, Dec 16, 2014 at 1:05 AM, Jason Ekstrand 
>> wrote:
>> > ---
>> >  src/glsl/Makefile.sources |   1 +
>> >  src/glsl/nir/nir.h|  13 ++
>> >  src/glsl/nir/nir_live_variables.c | 282
>> > ++
>> >  src/glsl/nir/nir_metadata.c   |   2 +
>> >  src/mesa/main/bitset.h|   1 +
>> >  5 files changed, 299 insertions(+)
>> >  create mode 100644 src/glsl/nir/nir_live_variables.c
>> >
>> > diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
>> > index 4eb6320..433224e 100644
>> > --- a/src/glsl/Makefile.sources
>> > +++ b/src/glsl/Makefile.sources
>> > @@ -20,6 +20,7 @@ NIR_FILES = \
>> > $(GLSL_SRCDIR)/nir/nir_from_ssa.c \
>> > $(GLSL_SRCDIR)/nir/nir_intrinsics.c \
>> > $(GLSL_SRCDIR)/nir/nir_intrinsics.h \
>> > +   $(GLSL_SRCDIR)/nir/nir_live_variables.c \
>> > $(GLSL_SRCDIR)/nir/nir_lower_atomics.c \
>> > $(GLSL_SRCDIR)/nir/nir_lower_samplers.cpp \
>> > $(GLSL_SRCDIR)/nir/nir_lower_system_values.c \
>> > diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
>> > index f744736..2f2edb6 100644
>> > --- a/src/glsl/nir/nir.h
>> > +++ b/src/glsl/nir/nir.h
>> > @@ -420,6 +420,9 @@ typedef struct {
>> > /** generic SSA definition index. */
>> > unsigned index;
>> >
>> > +   /** Index into the live_in and live_out bitfields */
>> > +   unsigned live_index;
>> > +
>> > nir_instr *parent_instr;
>> >
>> > struct set *uses;
>> > @@ -999,6 +1002,10 @@ typedef struct nir_block {
>> > struct nir_block **dom_children;
>> >
>> > struct set *dom_frontier;
>> > +
>> > +   /* live in and out for this block; used for liveness analysis */
>> > +   BITSET_WORD *live_in;
>> > +   BITSET_WORD *live_out;
>> >  } nir_block;
>> >
>> >  #define nir_block_first_instr(block) \
>> > @@ -1047,6 +1054,7 @@ typedef enum {
>> > nir_metadata_none = 0x0,
>> > nir_metadata_block_index = 0x1,
>> > nir_metadata_dominance = 0x2,
>> > +   nir_metadata_live_variables = 0x4,
>> >  } nir_metadata;
>> >
>> >  typedef struct {
>> > @@ -1274,6 +1282,8 @@ bool nir_foreach_src(nir_instr *instr,
>> > nir_foreach_src_cb cb, void *state);
>> >  typedef bool (*nir_foreach_block_cb)(nir_block *block, void *state);
>> >  bool nir_foreach_block(nir_function_impl *impl, nir_foreach_block_cb
>> > cb,
>> > void *state);
>> > +bool nir_foreach_block_reverse(nir_function_impl *impl,
>> > nir_foreach_block_cb cb,
>> > +   void *state);
>>
>> This hunk should go in the previous patch that defined this function.
>>
>> >
>> >  /* If the follow

Re: [Mesa-dev] [PATCH 018/133] nir: add an SSA-based copy propagation pass

2014-12-17 Thread Jason Ekstrand
On Wed, Dec 17, 2014 at 1:10 PM, Jason Ekstrand 
wrote:
>
>
>
> On Wed, Dec 17, 2014 at 12:07 PM, Connor Abbott 
> wrote:
>>
>> On Tue, Dec 16, 2014 at 1:04 AM, Jason Ekstrand 
>> wrote:
>> > From: Connor Abbott 
>> >
>> > ---
>> >  src/glsl/Makefile.sources |   1 +
>> >  src/glsl/nir/nir.h|   3 +
>> >  src/glsl/nir/nir_opt_copy_propagate.c | 313
>> ++
>> >  3 files changed, 317 insertions(+)
>> >  create mode 100644 src/glsl/nir/nir_opt_copy_propagate.c
>> >
>> > diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
>> > index 0aaea58..556648b 100644
>> > --- a/src/glsl/Makefile.sources
>> > +++ b/src/glsl/Makefile.sources
>> > @@ -25,6 +25,7 @@ NIR_FILES = \
>> > $(GLSL_SRCDIR)/nir/nir_lower_variables_scalar.c \
>> > $(GLSL_SRCDIR)/nir/nir_opcodes.c \
>> > $(GLSL_SRCDIR)/nir/nir_opcodes.h \
>> > +   $(GLSL_SRCDIR)/nir/nir_opt_copy_propagate.c \
>> > $(GLSL_SRCDIR)/nir/nir_opt_global_to_local.c \
>> > $(GLSL_SRCDIR)/nir/nir_print.c \
>> > $(GLSL_SRCDIR)/nir/nir_remove_dead_variables.c \
>> > diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
>> > index c2b4724..a5cb5ed 100644
>> > --- a/src/glsl/nir/nir.h
>> > +++ b/src/glsl/nir/nir.h
>> > @@ -1293,6 +1293,9 @@ void nir_convert_to_ssa(nir_shader *shader);
>> >
>> >  bool nir_opt_global_to_local(nir_shader *shader);
>> >
>> > +bool nir_copy_prop_impl(nir_function_impl *impl);
>> > +bool nir_copy_prop(nir_shader *shader);
>> > +
>> >  #ifdef __cplusplus
>> >  } /* extern "C" */
>> >  #endif
>> > diff --git a/src/glsl/nir/nir_opt_copy_propagate.c
>> b/src/glsl/nir/nir_opt_copy_propagate.c
>> > new file mode 100644
>> > index 000..a2be047
>> > --- /dev/null
>> > +++ b/src/glsl/nir/nir_opt_copy_propagate.c
>> > @@ -0,0 +1,313 @@
>> > +/*
>> > + * 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:
>> > + *Connor Abbott (cwabbo...@gmail.com)
>> > + *
>> > + */
>> > +
>> > +#include "nir.h"
>> > +#include 
>> > +
>> > +/**
>> > + * SSA-based copy propagation
>> > + */
>> > +
>> > +static bool is_move(nir_alu_instr *instr)
>> > +{
>> > +   if (instr->op != nir_op_fmov &&
>> > +   instr->op != nir_op_imov)
>> > +  return false;
>> > +
>> > +   if (instr->dest.saturate)
>> > +  return false;
>> > +
>> > +   /* we handle modifiers in a separate pass */
>>
>> This comment is stale now, since this pass should never see
>> modifiers... maybe we should replace those if's with asserts to make
>> that clear.
>>
>
> Easy enough to do.
>

Wait, I just remembered that I left them in intentionally.  We may want to
run copy prop after lowering to source mods.  In fact, when I wrote
lower_to_source_mods, I was lazy and just changed sat instructions to mov
and trusted in copy prop to clan up the swizzles for me.  If anything, we
may want to make copy prop simply handle them correctly.
--Jason


>
>
>>
>> > +
>> > +   if (instr->src[0].abs || instr->src[0].negate)
>> > +  return false;
>> > +
>> > +   if (!instr->src[0].src.is_ssa)
>> > +  return false;
>> > +
>> > +   return true;
>> > +
>> > +}
>> > +
>> > +static bool
>> > +is_swizzleless_move(nir_alu_instr *instr)
>> > +{
>> > +   if (!is_move(instr))
>> > +  return false;
>> > +
>> > +   for (unsigned i = 0; i < 4; i++) {
>> > +  if (!((instr->dest.write_mask >> i) & 1))
>> > + break;
>> > +  if (instr->src[0].swizzle[i] != i)
>> > + return false;
>> > +   }
>> > +
>> > +   return true;
>> > +}
>> > +
>> > +static bool is_vec(nir_alu_instr *instr)
>> > +{
>> > +   for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++)
>> > +  if (!instr->src[i].src.is_ssa)
>> > + return 

Re: [Mesa-dev] [PATCH 051/133] nir: Add an SSA-based liveness analysis pass.

2014-12-17 Thread Jason Ekstrand
On Wed, Dec 17, 2014 at 1:52 PM, Connor Abbott  wrote:
>
> I'm sure you're already aware, but there are two things we could do to
> speed this up:
>
> 1. Pre-compute def/kill sets for each block similar to what i965 does.
>

Sure, but we walk the instructions at most deepest block depth + 1 and the
depest we've ever seen in the wild is 2.

2. Use a worklist + an array of flags for "this block is in the
> worklist" rather than walking all the basic blocks in reverse to find
> the few we need to update.
>

Sure, we could, but I don't see how pushing the blocks onto a stack and
then popping them back off really gains us anything over just walking
them.  If there's something I'm missing, please let me know because it's
not jumping out at me.  I'll freely admit that I'm not terribly familiar
with worklists.


>
> Wrt #2, we already use a worklist in the DCE pass, but it's kinda lame
> because it's using a linked list when we could just allocate an array
> of pointers up-front based on the maximum size (the number of blocks
> in this case, the number of SSA definitions in that case) and use it
> as a ringbuffer. It would be a nice cleanup to implement such a
> bounded worklist and share it between these two passes, since we'll
> probably want to use it for lots of other passes too.
>
> I don't either thing should block merging this, though.
>
> A few other comments below.
>
> On Tue, Dec 16, 2014 at 1:05 AM, Jason Ekstrand 
> wrote:
> > ---
> >  src/glsl/Makefile.sources |   1 +
> >  src/glsl/nir/nir.h|  13 ++
> >  src/glsl/nir/nir_live_variables.c | 282
> ++
> >  src/glsl/nir/nir_metadata.c   |   2 +
> >  src/mesa/main/bitset.h|   1 +
> >  5 files changed, 299 insertions(+)
> >  create mode 100644 src/glsl/nir/nir_live_variables.c
> >
> > diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
> > index 4eb6320..433224e 100644
> > --- a/src/glsl/Makefile.sources
> > +++ b/src/glsl/Makefile.sources
> > @@ -20,6 +20,7 @@ NIR_FILES = \
> > $(GLSL_SRCDIR)/nir/nir_from_ssa.c \
> > $(GLSL_SRCDIR)/nir/nir_intrinsics.c \
> > $(GLSL_SRCDIR)/nir/nir_intrinsics.h \
> > +   $(GLSL_SRCDIR)/nir/nir_live_variables.c \
> > $(GLSL_SRCDIR)/nir/nir_lower_atomics.c \
> > $(GLSL_SRCDIR)/nir/nir_lower_samplers.cpp \
> > $(GLSL_SRCDIR)/nir/nir_lower_system_values.c \
> > diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> > index f744736..2f2edb6 100644
> > --- a/src/glsl/nir/nir.h
> > +++ b/src/glsl/nir/nir.h
> > @@ -420,6 +420,9 @@ typedef struct {
> > /** generic SSA definition index. */
> > unsigned index;
> >
> > +   /** Index into the live_in and live_out bitfields */
> > +   unsigned live_index;
> > +
> > nir_instr *parent_instr;
> >
> > struct set *uses;
> > @@ -999,6 +1002,10 @@ typedef struct nir_block {
> > struct nir_block **dom_children;
> >
> > struct set *dom_frontier;
> > +
> > +   /* live in and out for this block; used for liveness analysis */
> > +   BITSET_WORD *live_in;
> > +   BITSET_WORD *live_out;
> >  } nir_block;
> >
> >  #define nir_block_first_instr(block) \
> > @@ -1047,6 +1054,7 @@ typedef enum {
> > nir_metadata_none = 0x0,
> > nir_metadata_block_index = 0x1,
> > nir_metadata_dominance = 0x2,
> > +   nir_metadata_live_variables = 0x4,
> >  } nir_metadata;
> >
> >  typedef struct {
> > @@ -1274,6 +1282,8 @@ bool nir_foreach_src(nir_instr *instr,
> nir_foreach_src_cb cb, void *state);
> >  typedef bool (*nir_foreach_block_cb)(nir_block *block, void *state);
> >  bool nir_foreach_block(nir_function_impl *impl, nir_foreach_block_cb cb,
> > void *state);
> > +bool nir_foreach_block_reverse(nir_function_impl *impl,
> nir_foreach_block_cb cb,
> > +   void *state);
>
> This hunk should go in the previous patch that defined this function.
>
> >
> >  /* If the following CF node is an if, this function returns that if.
> >   * Otherwise, it returns NULL.
> > @@ -1318,6 +1328,9 @@ void nir_lower_system_values(nir_shader *shader);
> >
> >  void nir_lower_atomics(nir_shader *shader);
> >
> > +void nir_live_variables_impl(nir_function_impl *impl);
> > +bool nir_ssa_defs_interfere(nir_ssa_def *a, nir_ssa_def *b);
> > +
> >  void nir_convert_to_ssa_impl(nir_function_impl *impl);
> >  void nir_convert_to_ssa(nir_shader *shader);
> >  void nir_convert_from_ssa(nir_shader *shader);
> > diff --git a/src/glsl/nir/nir_live_variables.c
> b/src/glsl/nir/nir_live_variables.c
> > new file mode 100644
> > index 000..7d99a06
> > --- /dev/null
> > +++ b/src/glsl/nir/nir_live_variables.c
> > @@ -0,0 +1,282 @@
> > +/*
> > + * 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
> l

Re: [Mesa-dev] [PATCH 051/133] nir: Add an SSA-based liveness analysis pass.

2014-12-17 Thread Jason Ekstrand
On Wed, Dec 17, 2014 at 1:52 PM, Connor Abbott  wrote:
>
> I'm sure you're already aware, but there are two things we could do to
> speed this up:
>
> 1. Pre-compute def/kill sets for each block similar to what i965 does.
> 2. Use a worklist + an array of flags for "this block is in the
> worklist" rather than walking all the basic blocks in reverse to find
> the few we need to update.
>
> Wrt #2, we already use a worklist in the DCE pass, but it's kinda lame
> because it's using a linked list when we could just allocate an array
> of pointers up-front based on the maximum size (the number of blocks
> in this case, the number of SSA definitions in that case) and use it
> as a ringbuffer. It would be a nice cleanup to implement such a
> bounded worklist and share it between these two passes, since we'll
> probably want to use it for lots of other passes too.
>
> I don't either thing should block merging this, though.
>
> A few other comments below.
>
> On Tue, Dec 16, 2014 at 1:05 AM, Jason Ekstrand 
> wrote:
> > ---
> >  src/glsl/Makefile.sources |   1 +
> >  src/glsl/nir/nir.h|  13 ++
> >  src/glsl/nir/nir_live_variables.c | 282
> ++
> >  src/glsl/nir/nir_metadata.c   |   2 +
> >  src/mesa/main/bitset.h|   1 +
> >  5 files changed, 299 insertions(+)
> >  create mode 100644 src/glsl/nir/nir_live_variables.c
> >
> > diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
> > index 4eb6320..433224e 100644
> > --- a/src/glsl/Makefile.sources
> > +++ b/src/glsl/Makefile.sources
> > @@ -20,6 +20,7 @@ NIR_FILES = \
> > $(GLSL_SRCDIR)/nir/nir_from_ssa.c \
> > $(GLSL_SRCDIR)/nir/nir_intrinsics.c \
> > $(GLSL_SRCDIR)/nir/nir_intrinsics.h \
> > +   $(GLSL_SRCDIR)/nir/nir_live_variables.c \
> > $(GLSL_SRCDIR)/nir/nir_lower_atomics.c \
> > $(GLSL_SRCDIR)/nir/nir_lower_samplers.cpp \
> > $(GLSL_SRCDIR)/nir/nir_lower_system_values.c \
> > diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> > index f744736..2f2edb6 100644
> > --- a/src/glsl/nir/nir.h
> > +++ b/src/glsl/nir/nir.h
> > @@ -420,6 +420,9 @@ typedef struct {
> > /** generic SSA definition index. */
> > unsigned index;
> >
> > +   /** Index into the live_in and live_out bitfields */
> > +   unsigned live_index;
> > +
> > nir_instr *parent_instr;
> >
> > struct set *uses;
> > @@ -999,6 +1002,10 @@ typedef struct nir_block {
> > struct nir_block **dom_children;
> >
> > struct set *dom_frontier;
> > +
> > +   /* live in and out for this block; used for liveness analysis */
> > +   BITSET_WORD *live_in;
> > +   BITSET_WORD *live_out;
> >  } nir_block;
> >
> >  #define nir_block_first_instr(block) \
> > @@ -1047,6 +1054,7 @@ typedef enum {
> > nir_metadata_none = 0x0,
> > nir_metadata_block_index = 0x1,
> > nir_metadata_dominance = 0x2,
> > +   nir_metadata_live_variables = 0x4,
> >  } nir_metadata;
> >
> >  typedef struct {
> > @@ -1274,6 +1282,8 @@ bool nir_foreach_src(nir_instr *instr,
> nir_foreach_src_cb cb, void *state);
> >  typedef bool (*nir_foreach_block_cb)(nir_block *block, void *state);
> >  bool nir_foreach_block(nir_function_impl *impl, nir_foreach_block_cb cb,
> > void *state);
> > +bool nir_foreach_block_reverse(nir_function_impl *impl,
> nir_foreach_block_cb cb,
> > +   void *state);
>
> This hunk should go in the previous patch that defined this function.
>
> >
> >  /* If the following CF node is an if, this function returns that if.
> >   * Otherwise, it returns NULL.
> > @@ -1318,6 +1328,9 @@ void nir_lower_system_values(nir_shader *shader);
> >
> >  void nir_lower_atomics(nir_shader *shader);
> >
> > +void nir_live_variables_impl(nir_function_impl *impl);
> > +bool nir_ssa_defs_interfere(nir_ssa_def *a, nir_ssa_def *b);
> > +
> >  void nir_convert_to_ssa_impl(nir_function_impl *impl);
> >  void nir_convert_to_ssa(nir_shader *shader);
> >  void nir_convert_from_ssa(nir_shader *shader);
> > diff --git a/src/glsl/nir/nir_live_variables.c
> b/src/glsl/nir/nir_live_variables.c
> > new file mode 100644
> > index 000..7d99a06
> > --- /dev/null
> > +++ b/src/glsl/nir/nir_live_variables.c
> > @@ -0,0 +1,282 @@
> > +/*
> > + * 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
> >

Re: [Mesa-dev] [PATCH 1/3] mesa: bump required GCC version to 4.2.0

2014-12-17 Thread Timothy Arceri
On Thu, 2014-12-18 at 08:46 +1100, Timothy Arceri wrote:
> On Wed, 2014-12-17 at 13:15 -0800, Matt Turner wrote:
> > On Wed, Dec 17, 2014 at 12:51 PM, Timothy Arceri  
> > wrote:
> > > It turns out Mesa hasn't compiled on less
> > > then 4.2 for a while so update conf to
> > > reflect this.
> > 
> > The first two are:
> > 
> > Reviewed-by: Matt Turner 
> > 
> > and the last is
> > 
> > Acked-by: Matt Turner 
> > 
> > By the way, you seem to be manually line wrapping your commit
> > messages. vim is apparently run with appropriate options here when I
> > git commit such that it automatically handles this. I haven't done
> > anything to configure this.
> 
> Yeah I started doing it after sending in a couple of patches with long
> commit messages that were on a single line (although admittedly now that
> I think about it I think I edited the message directly in a patch file
> in those cases).
> 
> I thought it was automatically wrapped too but last week I tried to edit
> a commit message during a rebase on one of the patches with the long
> commit message and it wouldn't automatically wrap it so I started
> doubting if it was wrapped when doing a commit also.
> Maybe a bug? But more likely just me not using git correctly.
> 
> Anyway I'll try remove the manual wrapping before committing.

I just tested a commit no automatic line wrapping on my system. I don't
believe I changed anything. Anyway I'll make the commit message a little
longer as brian suggested.

> 
> 
> 
> ___
> 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 051/133] nir: Add an SSA-based liveness analysis pass.

2014-12-17 Thread Connor Abbott
I'm sure you're already aware, but there are two things we could do to
speed this up:

1. Pre-compute def/kill sets for each block similar to what i965 does.
2. Use a worklist + an array of flags for "this block is in the
worklist" rather than walking all the basic blocks in reverse to find
the few we need to update.

Wrt #2, we already use a worklist in the DCE pass, but it's kinda lame
because it's using a linked list when we could just allocate an array
of pointers up-front based on the maximum size (the number of blocks
in this case, the number of SSA definitions in that case) and use it
as a ringbuffer. It would be a nice cleanup to implement such a
bounded worklist and share it between these two passes, since we'll
probably want to use it for lots of other passes too.

I don't either thing should block merging this, though.

A few other comments below.

On Tue, Dec 16, 2014 at 1:05 AM, Jason Ekstrand  wrote:
> ---
>  src/glsl/Makefile.sources |   1 +
>  src/glsl/nir/nir.h|  13 ++
>  src/glsl/nir/nir_live_variables.c | 282 
> ++
>  src/glsl/nir/nir_metadata.c   |   2 +
>  src/mesa/main/bitset.h|   1 +
>  5 files changed, 299 insertions(+)
>  create mode 100644 src/glsl/nir/nir_live_variables.c
>
> diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
> index 4eb6320..433224e 100644
> --- a/src/glsl/Makefile.sources
> +++ b/src/glsl/Makefile.sources
> @@ -20,6 +20,7 @@ NIR_FILES = \
> $(GLSL_SRCDIR)/nir/nir_from_ssa.c \
> $(GLSL_SRCDIR)/nir/nir_intrinsics.c \
> $(GLSL_SRCDIR)/nir/nir_intrinsics.h \
> +   $(GLSL_SRCDIR)/nir/nir_live_variables.c \
> $(GLSL_SRCDIR)/nir/nir_lower_atomics.c \
> $(GLSL_SRCDIR)/nir/nir_lower_samplers.cpp \
> $(GLSL_SRCDIR)/nir/nir_lower_system_values.c \
> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> index f744736..2f2edb6 100644
> --- a/src/glsl/nir/nir.h
> +++ b/src/glsl/nir/nir.h
> @@ -420,6 +420,9 @@ typedef struct {
> /** generic SSA definition index. */
> unsigned index;
>
> +   /** Index into the live_in and live_out bitfields */
> +   unsigned live_index;
> +
> nir_instr *parent_instr;
>
> struct set *uses;
> @@ -999,6 +1002,10 @@ typedef struct nir_block {
> struct nir_block **dom_children;
>
> struct set *dom_frontier;
> +
> +   /* live in and out for this block; used for liveness analysis */
> +   BITSET_WORD *live_in;
> +   BITSET_WORD *live_out;
>  } nir_block;
>
>  #define nir_block_first_instr(block) \
> @@ -1047,6 +1054,7 @@ typedef enum {
> nir_metadata_none = 0x0,
> nir_metadata_block_index = 0x1,
> nir_metadata_dominance = 0x2,
> +   nir_metadata_live_variables = 0x4,
>  } nir_metadata;
>
>  typedef struct {
> @@ -1274,6 +1282,8 @@ bool nir_foreach_src(nir_instr *instr, 
> nir_foreach_src_cb cb, void *state);
>  typedef bool (*nir_foreach_block_cb)(nir_block *block, void *state);
>  bool nir_foreach_block(nir_function_impl *impl, nir_foreach_block_cb cb,
> void *state);
> +bool nir_foreach_block_reverse(nir_function_impl *impl, nir_foreach_block_cb 
> cb,
> +   void *state);

This hunk should go in the previous patch that defined this function.

>
>  /* If the following CF node is an if, this function returns that if.
>   * Otherwise, it returns NULL.
> @@ -1318,6 +1328,9 @@ void nir_lower_system_values(nir_shader *shader);
>
>  void nir_lower_atomics(nir_shader *shader);
>
> +void nir_live_variables_impl(nir_function_impl *impl);
> +bool nir_ssa_defs_interfere(nir_ssa_def *a, nir_ssa_def *b);
> +
>  void nir_convert_to_ssa_impl(nir_function_impl *impl);
>  void nir_convert_to_ssa(nir_shader *shader);
>  void nir_convert_from_ssa(nir_shader *shader);
> diff --git a/src/glsl/nir/nir_live_variables.c 
> b/src/glsl/nir/nir_live_variables.c
> new file mode 100644
> index 000..7d99a06
> --- /dev/null
> +++ b/src/glsl/nir/nir_live_variables.c
> @@ -0,0 +1,282 @@
> +/*
> + * 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 H

Re: [Mesa-dev] [PATCH 1/3] mesa: bump required GCC version to 4.2.0

2014-12-17 Thread Timothy Arceri
On Wed, 2014-12-17 at 13:15 -0800, Matt Turner wrote:
> On Wed, Dec 17, 2014 at 12:51 PM, Timothy Arceri  
> wrote:
> > It turns out Mesa hasn't compiled on less
> > then 4.2 for a while so update conf to
> > reflect this.
> 
> The first two are:
> 
> Reviewed-by: Matt Turner 
> 
> and the last is
> 
> Acked-by: Matt Turner 
> 
> By the way, you seem to be manually line wrapping your commit
> messages. vim is apparently run with appropriate options here when I
> git commit such that it automatically handles this. I haven't done
> anything to configure this.

Yeah I started doing it after sending in a couple of patches with long
commit messages that were on a single line (although admittedly now that
I think about it I think I edited the message directly in a patch file
in those cases).

I thought it was automatically wrapped too but last week I tried to edit
a commit message during a rebase on one of the patches with the long
commit message and it wouldn't automatically wrap it so I started
doubting if it was wrapped when doing a commit also.
Maybe a bug? But more likely just me not using git correctly.

Anyway I'll try remove the manual wrapping before committing.



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


Re: [Mesa-dev] [PATCH 050/133] nir: Make the nir_index_* functions return the nuber of items

2014-12-17 Thread Connor Abbott
This patch needs to get renamed, probably something like "nir: set
reg_alloc and ssa_alloc when indexing registers and SSA values"

On Tue, Dec 16, 2014 at 1:05 AM, Jason Ekstrand  wrote:
> ---
>  src/glsl/nir/nir.c | 3 +++
>  src/glsl/nir/nir.h | 4 ++--
>  2 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
> index e90eeda..2c06d7e 100644
> --- a/src/glsl/nir/nir.c
> +++ b/src/glsl/nir/nir.c
> @@ -1334,6 +1334,7 @@ nir_index_local_regs(nir_function_impl *impl)
> foreach_list_typed(nir_register, reg, node, &impl->registers) {
>reg->index = index++;
> }
> +   impl->reg_alloc = index;
>  }
>
>  void
> @@ -1343,6 +1344,7 @@ nir_index_global_regs(nir_shader *shader)
> foreach_list_typed(nir_register, reg, node, &shader->registers) {
>reg->index = index++;
> }
> +   shader->reg_alloc = index;
>  }
>
>  static bool
> @@ -1765,4 +1767,5 @@ nir_index_ssa_defs(nir_function_impl *impl)
>  {
> unsigned index = 0;
> nir_foreach_block(impl, index_ssa_block, &index);
> +   impl->ssa_alloc = index;
>  }
> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> index f405694..f744736 100644
> --- a/src/glsl/nir/nir.h
> +++ b/src/glsl/nir/nir.h
> @@ -357,7 +357,7 @@ typedef struct {
> unsigned num_components; /** < number of vector components */
> unsigned num_array_elems; /** < size of array (0 for no array) */
>
> -   /** for liveness analysis, the index in the bit-array of live variables */
> +   /** generic register index. */
> unsigned index;
>
> /** only for debug purposes, can be NULL */
> @@ -417,7 +417,7 @@ typedef struct {
> /** for debugging only, can be NULL */
> const char* name;
>
> -   /** index into the bit-array for liveness analysis */
> +   /** generic SSA definition index. */
> unsigned index;
>
> nir_instr *parent_instr;
> --
> 2.2.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 049/133] nir: Add a function to detect if a block is immediately followed by an if

2014-12-17 Thread Connor Abbott
On Tue, Dec 16, 2014 at 1:04 AM, Jason Ekstrand  wrote:
> Since we don't actually have an "if" instruction, this is a very common
> pattern when iterating over instructions.  This adds a helper function for
> it to make things a little less painful.
> ---
>  src/glsl/nir/nir.c  | 17 +
>  src/glsl/nir/nir.h  |  5 +
>  src/glsl/nir/nir_from_ssa.c |  9 +++--
>  src/glsl/nir/nir_opt_dce.c  | 12 +---
>  4 files changed, 30 insertions(+), 13 deletions(-)
>
> diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
> index 5dbcc77..e90eeda 100644
> --- a/src/glsl/nir/nir.c
> +++ b/src/glsl/nir/nir.c
> @@ -1686,6 +1686,23 @@ nir_foreach_block_reverse(nir_function_impl *impl, 
> nir_foreach_block_cb cb,
> return true;
>  }
>
> +nir_if *
> +nir_block_following_if(nir_block *block)

Could you rename this to "nir_block_get_following_if"? I read this as
"block following if" (i.e. finding the block after an if statement)
and was confused at first. Also, it's generally a good idea to name
functions with verbs.

> +{
> +   if (exec_node_is_tail_sentinel(&block->cf_node.node))
> +  return NULL;
> +
> +   if (nir_cf_node_is_last(&block->cf_node))
> +  return NULL;
> +
> +   nir_cf_node *next_node = nir_cf_node_next(&block->cf_node);
> +
> +   if (next_node->type != nir_cf_node_if)
> +  return NULL;
> +
> +   return nir_cf_node_as_if(next_node);
> +}
> +
>  static bool
>  index_block(nir_block *block, void *state)
>  {
> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> index 8d5f6b8..f405694 100644
> --- a/src/glsl/nir/nir.h
> +++ b/src/glsl/nir/nir.h
> @@ -1275,6 +1275,11 @@ typedef bool (*nir_foreach_block_cb)(nir_block *block, 
> void *state);
>  bool nir_foreach_block(nir_function_impl *impl, nir_foreach_block_cb cb,
> void *state);
>
> +/* If the following CF node is an if, this function returns that if.
> + * Otherwise, it returns NULL.
> + */
> +nir_if *nir_block_following_if(nir_block *block);
> +
>  void nir_index_local_regs(nir_function_impl *impl);
>  void nir_index_global_regs(nir_shader *shader);
>  void nir_index_ssa_defs(nir_function_impl *impl);
> diff --git a/src/glsl/nir/nir_from_ssa.c b/src/glsl/nir/nir_from_ssa.c
> index 04c8103..a26f0c4 100644
> --- a/src/glsl/nir/nir_from_ssa.c
> +++ b/src/glsl/nir/nir_from_ssa.c
> @@ -109,12 +109,9 @@ convert_from_ssa_block(nir_block *block, void 
> *void_state)
>}
> }
>
> -   if (block->cf_node.node.next != NULL && /* check that we aren't the end 
> node */
> -   !nir_cf_node_is_last(&block->cf_node) &&
> -   nir_cf_node_next(&block->cf_node)->type == nir_cf_node_if) {
> -  nir_if *if_stmt = nir_cf_node_as_if(nir_cf_node_next(&block->cf_node));
> -  rewrite_ssa_src(&if_stmt->condition, state);
> -   }
> +   nir_if *following_if = nir_block_following_if(block);
> +   if (following_if)
> +  rewrite_ssa_src(&following_if->condition, state);
>
> return true;
>  }
> diff --git a/src/glsl/nir/nir_opt_dce.c b/src/glsl/nir/nir_opt_dce.c
> index c18ba32..c3bbcb4 100644
> --- a/src/glsl/nir/nir_opt_dce.c
> +++ b/src/glsl/nir/nir_opt_dce.c
> @@ -123,13 +123,11 @@ init_block_cb(nir_block *block, void *_state)
> nir_foreach_instr(block, instr)
>init_instr(instr, worklist);
>
> -   if (block->cf_node.node.next != NULL && /* check that we aren't the end 
> node */
> -   !nir_cf_node_is_last(&block->cf_node) &&
> -   nir_cf_node_next(&block->cf_node)->type == nir_cf_node_if) {
> -  nir_if *if_stmt = nir_cf_node_as_if(nir_cf_node_next(&block->cf_node));
> -  if (if_stmt->condition.is_ssa &&
> -  !if_stmt->condition.ssa->parent_instr->live)
> - worklist_push(worklist, if_stmt->condition.ssa->parent_instr);
> +   nir_if *following_if = nir_block_following_if(block);
> +   if (following_if) {
> +  if (following_if->condition.is_ssa &&
> +  !following_if->condition.ssa->parent_instr->live)
> + worklist_push(worklist, following_if->condition.ssa->parent_instr);
> }
>
> return true;
> --
> 2.2.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/3] mesa: bump required GCC version to 4.2.0

2014-12-17 Thread Matt Turner
On Wed, Dec 17, 2014 at 12:51 PM, Timothy Arceri  wrote:
> It turns out Mesa hasn't compiled on less
> then 4.2 for a while so update conf to
> reflect this.

The first two are:

Reviewed-by: Matt Turner 

and the last is

Acked-by: Matt Turner 

By the way, you seem to be manually line wrapping your commit
messages. vim is apparently run with appropriate options here when I
git commit such that it automatically handles this. I haven't done
anything to configure this.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 018/133] nir: add an SSA-based copy propagation pass

2014-12-17 Thread Jason Ekstrand
On Wed, Dec 17, 2014 at 12:07 PM, Connor Abbott  wrote:
>
> On Tue, Dec 16, 2014 at 1:04 AM, Jason Ekstrand 
> wrote:
> > From: Connor Abbott 
> >
> > ---
> >  src/glsl/Makefile.sources |   1 +
> >  src/glsl/nir/nir.h|   3 +
> >  src/glsl/nir/nir_opt_copy_propagate.c | 313
> ++
> >  3 files changed, 317 insertions(+)
> >  create mode 100644 src/glsl/nir/nir_opt_copy_propagate.c
> >
> > diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
> > index 0aaea58..556648b 100644
> > --- a/src/glsl/Makefile.sources
> > +++ b/src/glsl/Makefile.sources
> > @@ -25,6 +25,7 @@ NIR_FILES = \
> > $(GLSL_SRCDIR)/nir/nir_lower_variables_scalar.c \
> > $(GLSL_SRCDIR)/nir/nir_opcodes.c \
> > $(GLSL_SRCDIR)/nir/nir_opcodes.h \
> > +   $(GLSL_SRCDIR)/nir/nir_opt_copy_propagate.c \
> > $(GLSL_SRCDIR)/nir/nir_opt_global_to_local.c \
> > $(GLSL_SRCDIR)/nir/nir_print.c \
> > $(GLSL_SRCDIR)/nir/nir_remove_dead_variables.c \
> > diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> > index c2b4724..a5cb5ed 100644
> > --- a/src/glsl/nir/nir.h
> > +++ b/src/glsl/nir/nir.h
> > @@ -1293,6 +1293,9 @@ void nir_convert_to_ssa(nir_shader *shader);
> >
> >  bool nir_opt_global_to_local(nir_shader *shader);
> >
> > +bool nir_copy_prop_impl(nir_function_impl *impl);
> > +bool nir_copy_prop(nir_shader *shader);
> > +
> >  #ifdef __cplusplus
> >  } /* extern "C" */
> >  #endif
> > diff --git a/src/glsl/nir/nir_opt_copy_propagate.c
> b/src/glsl/nir/nir_opt_copy_propagate.c
> > new file mode 100644
> > index 000..a2be047
> > --- /dev/null
> > +++ b/src/glsl/nir/nir_opt_copy_propagate.c
> > @@ -0,0 +1,313 @@
> > +/*
> > + * 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:
> > + *Connor Abbott (cwabbo...@gmail.com)
> > + *
> > + */
> > +
> > +#include "nir.h"
> > +#include 
> > +
> > +/**
> > + * SSA-based copy propagation
> > + */
> > +
> > +static bool is_move(nir_alu_instr *instr)
> > +{
> > +   if (instr->op != nir_op_fmov &&
> > +   instr->op != nir_op_imov)
> > +  return false;
> > +
> > +   if (instr->dest.saturate)
> > +  return false;
> > +
> > +   /* we handle modifiers in a separate pass */
>
> This comment is stale now, since this pass should never see
> modifiers... maybe we should replace those if's with asserts to make
> that clear.
>

Easy enough to do.


>
> > +
> > +   if (instr->src[0].abs || instr->src[0].negate)
> > +  return false;
> > +
> > +   if (!instr->src[0].src.is_ssa)
> > +  return false;
> > +
> > +   return true;
> > +
> > +}
> > +
> > +static bool
> > +is_swizzleless_move(nir_alu_instr *instr)
> > +{
> > +   if (!is_move(instr))
> > +  return false;
> > +
> > +   for (unsigned i = 0; i < 4; i++) {
> > +  if (!((instr->dest.write_mask >> i) & 1))
> > + break;
> > +  if (instr->src[0].swizzle[i] != i)
> > + return false;
> > +   }
> > +
> > +   return true;
> > +}
> > +
> > +static bool is_vec(nir_alu_instr *instr)
> > +{
> > +   for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++)
> > +  if (!instr->src[i].src.is_ssa)
> > + return false;
> > +
> > +   return instr->op == nir_op_vec2 ||
> > +  instr->op == nir_op_vec3 ||
> > +  instr->op == nir_op_vec4;
> > +}
> > +
> > +typedef struct {
> > +   nir_ssa_def *def;
> > +   bool found;
> > +} search_def_state;
> > +
> > +static bool
> > +search_def(nir_src *src, void *_state)
> > +{
> > +   search_def_state *state = (search_def_state *) _state;
> > +
> > +   if (src->is_ssa && src->ssa == state->def)
> > +  state->found = true;
> > +
> > +   return true;
> > +}
> > +
> > +static void
> > +rewrite_src_instr(nir_src *src, nir_ssa_d

Re: [Mesa-dev] [PATCH 046/133] nir: Add an assert

2014-12-17 Thread Jason Ekstrand
Sure, I can try and remember to do that.

On Wed, Dec 17, 2014 at 11:33 AM, Connor Abbott  wrote:
>
> Sorry to ask, but... this one is so trivial and touches code that no
> earlier patch touches, why don't we just squash it into the commit
> that adds nir.c?
>
> On Tue, Dec 16, 2014 at 1:04 AM, Jason Ekstrand 
> wrote:
> > ---
> >  src/glsl/nir/nir.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
> > index 0124799..3c897b2 100644
> > --- a/src/glsl/nir/nir.c
> > +++ b/src/glsl/nir/nir.c
> > @@ -840,6 +840,7 @@ handle_jump(nir_block *block)
> >  unlink_blocks(last_block, after_block);
> >}
> > } else {
> > +  assert(jump_instr->type == nir_jump_return);
> >link_blocks(block, impl->end_block, NULL);
> > }
> >  }
> > --
> > 2.2.0
> >
> > ___
> > mesa-dev mailing list
> > mesa-dev@lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 137/133] i965/fs_nir: Handle sample ID, position, and mask better

2014-12-17 Thread Jason Ekstrand
Before, we were emitting the full pile of setup instructions for sample_id
and sample_pos every time they were used.  With this commit, we emit them
in their own pass once at the beginning of the shader and simply emit uses
later on.  When it comes time for setting up VS, we can put setup for its
special values in the same pass.
---
 src/mesa/drivers/dri/i965/brw_fs.h   |  2 +
 src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 81 +++-
 2 files changed, 71 insertions(+), 12 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.h 
b/src/mesa/drivers/dri/i965/brw_fs.h
index 8f6b3b0..0cd3966 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -574,6 +574,7 @@ public:
void nir_setup_uniforms(nir_shader *shader);
void nir_setup_uniform(nir_variable *var);
void nir_setup_builtin_uniform(nir_variable *var);
+   void nir_emit_system_values(nir_shader *shader);
void nir_emit_impl(nir_function_impl *impl);
void nir_emit_cf_list(exec_list *list);
void nir_emit_if(nir_if *if_stmt);
@@ -701,6 +702,7 @@ public:
fs_reg nir_inputs;
fs_reg nir_outputs;
fs_reg nir_uniforms;
+   fs_reg *nir_system_values;
 
/** @{ debug annotation info */
const char *current_annotation;
diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
index 9046e26..32f9538 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
@@ -106,6 +106,8 @@ fs_visitor::emit_nir_code()
   nir_setup_uniforms(nir);
}
 
+   nir_emit_system_values(nir);
+
nir_globals = ralloc_array(mem_ctx, fs_reg, nir->reg_alloc);
foreach_list_typed(nir_register, reg, node, &nir->registers) {
   unsigned array_elems =
@@ -289,6 +291,60 @@ fs_visitor::nir_setup_builtin_uniform(nir_variable *var)
}
 }
 
+static bool
+emit_system_values_block(nir_block *block, void *void_visitor)
+{
+   fs_visitor *v = (fs_visitor *)void_visitor;
+   fs_reg *reg;
+
+   nir_foreach_instr(block, instr) {
+  if (instr->type != nir_instr_type_intrinsic)
+ continue;
+
+  nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
+  switch (intrin->intrinsic) {
+  case nir_intrinsic_load_sample_pos:
+ assert(v->stage == MESA_SHADER_FRAGMENT);
+ reg = &v->nir_system_values[SYSTEM_VALUE_SAMPLE_POS];
+ if (reg->file == BAD_FILE)
+*reg = *v->emit_samplepos_setup();
+ break;
+
+  case nir_intrinsic_load_sample_id:
+ assert(v->stage == MESA_SHADER_FRAGMENT);
+ reg = &v->nir_system_values[SYSTEM_VALUE_SAMPLE_ID];
+ if (reg->file == BAD_FILE)
+*reg = *v->emit_sampleid_setup();
+ break;
+
+  case nir_intrinsic_load_sample_mask_in:
+ assert(v->stage == MESA_SHADER_FRAGMENT);
+ assert(v->brw->gen >= 7);
+ reg = &v->nir_system_values[SYSTEM_VALUE_SAMPLE_MASK_IN];
+ if (reg->file == BAD_FILE)
+*reg = fs_reg(retype(brw_vec8_grf(v->payload.sample_mask_in_reg, 
0),
+ BRW_REGISTER_TYPE_D));
+ break;
+
+  default:
+ break;
+  }
+   }
+
+   return true;
+}
+
+void
+fs_visitor::nir_emit_system_values(nir_shader *shader)
+{
+   nir_system_values = ralloc_array(mem_ctx, fs_reg, SYSTEM_VALUE_MAX);
+   nir_foreach_overload(shader, overload) {
+  assert(strcmp(overload->function->name, "main") == 0);
+  assert(overload->impl);
+  nir_foreach_block(overload->impl, emit_system_values_block, this);
+   }
+}
+
 void
 fs_visitor::nir_emit_impl(nir_function_impl *impl)
 {
@@ -1276,26 +1332,27 @@ fs_visitor::nir_emit_intrinsic(nir_intrinsic_instr 
*instr)
   assert(!"TODO");
 
case nir_intrinsic_load_sample_mask_in: {
-  assert(brw->gen >= 7);
-  fs_reg reg = fs_reg(retype(brw_vec8_grf(payload.sample_mask_in_reg, 0),
-  BRW_REGISTER_TYPE_D));
-  dest.type = reg.type;
-  emit(MOV(dest, reg));
+  fs_reg sample_mask_in = nir_system_values[SYSTEM_VALUE_SAMPLE_MASK_IN];
+  assert(sample_mask_in.file != BAD_FILE);
+  dest.type = sample_mask_in.type;
+  emit(MOV(dest, sample_mask_in));
   break;
}
 
case nir_intrinsic_load_sample_pos: {
-  fs_reg *reg = emit_samplepos_setup();
-  dest.type = reg->type;
-  emit(MOV(dest, *reg));
-  emit(MOV(offset(dest, 1), offset(*reg, 1)));
+  fs_reg sample_pos = nir_system_values[SYSTEM_VALUE_SAMPLE_POS];
+  assert(sample_pos.file != BAD_FILE);
+  dest.type = sample_pos.type;
+  emit(MOV(dest, sample_pos));
+  emit(MOV(offset(dest, 1), offset(sample_pos, 1)));
   break;
}
 
case nir_intrinsic_load_sample_id: {
-  fs_reg *reg = emit_sampleid_setup();
-  dest.type = reg->type;
-  emit(MOV(dest, *reg));
+  fs_reg sample_id = nir_system_values[SYSTEM_VALUE_SAMPLE_ID];
+  assert(sample_id.file != BAD_FILE);
+  dest.typ

[Mesa-dev] [PATCH 3/3] docs: note change in minimum GCC version to 4.2.0

2014-12-17 Thread Timothy Arceri
Signed-off-by: Timothy Arceri 
---
 docs/relnotes/10.5.0.html | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/relnotes/10.5.0.html b/docs/relnotes/10.5.0.html
index ed62248..381e02a 100644
--- a/docs/relnotes/10.5.0.html
+++ b/docs/relnotes/10.5.0.html
@@ -59,7 +59,7 @@ TBD.
 Changes
 
 
-Removed support for GCC versions earlier than 4.1.0.
+Removed support for GCC versions earlier than 4.2.0.
 
 
 
-- 
2.1.0

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


[Mesa-dev] [PATCH 2/3] gallium: remove support for GCC older than 4.2.0

2014-12-17 Thread Timothy Arceri
Signed-off-by: Timothy Arceri 
---
 src/gallium/include/pipe/p_compiler.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/include/pipe/p_compiler.h 
b/src/gallium/include/pipe/p_compiler.h
index 939fb06..fb018bf 100644
--- a/src/gallium/include/pipe/p_compiler.h
+++ b/src/gallium/include/pipe/p_compiler.h
@@ -155,7 +155,7 @@ typedef unsigned char boolean;
 /* See http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Variable-Attributes.html */
 #define PIPE_ALIGN_VAR(_alignment) __attribute__((aligned(_alignment)))
 
-#if (__GNUC__ > 4 || (__GNUC__ == 4 &&__GNUC_MINOR__>1)) && 
!defined(PIPE_ARCH_X86_64)
+#if defined(__GNUC__) && !defined(PIPE_ARCH_X86_64)
 #define PIPE_ALIGN_STACK __attribute__((force_align_arg_pointer))
 #else
 #define PIPE_ALIGN_STACK
-- 
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: bump required GCC version to 4.2.0

2014-12-17 Thread Timothy Arceri
It turns out Mesa hasn't compiled on less
then 4.2 for a while so update conf to
reflect this.

Signed-off-by: Timothy Arceri 
---
 configure.ac | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index fdb7676..c8723ef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -102,7 +102,7 @@ AC_COMPILE_IFELSE(
 
 AC_MSG_RESULT([$acv_mesa_CLANG])
 
-dnl If we're using GCC, make sure that it is at least version 4.1.0.  Older
+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
 if test "x$GCC" = xyes -a "x$acv_mesa_CLANG" = xno; then
@@ -116,9 +116,9 @@ if test "x$GCC" = xyes -a "x$acv_mesa_CLANG" = xno; then
 GCC_VERSION_MINOR=`echo $GCC_VERSION | cut -d. -f2`
 fi
 
-if test $GCC_VERSION_MAJOR -lt 4 -o $GCC_VERSION_MAJOR -eq 4 -a 
$GCC_VERSION_MINOR -lt 1 ; then
+if test $GCC_VERSION_MAJOR -lt 4 -o $GCC_VERSION_MAJOR -eq 4 -a 
$GCC_VERSION_MINOR -lt 2 ; then
 AC_MSG_RESULT([no])
-AC_MSG_ERROR([If using GCC, version 4.1.0 or later is required.])
+AC_MSG_ERROR([If using GCC, version 4.2.0 or later is required.])
 else
 AC_MSG_RESULT([yes])
 fi
-- 
2.1.0

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


[Mesa-dev] [Bug 86594] Segfault in glGetActiveUniformName

2014-12-17 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=86594

Ian Romanick  changed:

   What|Removed |Added

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

-- 
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 018/133] nir: add an SSA-based copy propagation pass

2014-12-17 Thread Connor Abbott
On Tue, Dec 16, 2014 at 1:04 AM, Jason Ekstrand  wrote:
> From: Connor Abbott 
>
> ---
>  src/glsl/Makefile.sources |   1 +
>  src/glsl/nir/nir.h|   3 +
>  src/glsl/nir/nir_opt_copy_propagate.c | 313 
> ++
>  3 files changed, 317 insertions(+)
>  create mode 100644 src/glsl/nir/nir_opt_copy_propagate.c
>
> diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
> index 0aaea58..556648b 100644
> --- a/src/glsl/Makefile.sources
> +++ b/src/glsl/Makefile.sources
> @@ -25,6 +25,7 @@ NIR_FILES = \
> $(GLSL_SRCDIR)/nir/nir_lower_variables_scalar.c \
> $(GLSL_SRCDIR)/nir/nir_opcodes.c \
> $(GLSL_SRCDIR)/nir/nir_opcodes.h \
> +   $(GLSL_SRCDIR)/nir/nir_opt_copy_propagate.c \
> $(GLSL_SRCDIR)/nir/nir_opt_global_to_local.c \
> $(GLSL_SRCDIR)/nir/nir_print.c \
> $(GLSL_SRCDIR)/nir/nir_remove_dead_variables.c \
> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> index c2b4724..a5cb5ed 100644
> --- a/src/glsl/nir/nir.h
> +++ b/src/glsl/nir/nir.h
> @@ -1293,6 +1293,9 @@ void nir_convert_to_ssa(nir_shader *shader);
>
>  bool nir_opt_global_to_local(nir_shader *shader);
>
> +bool nir_copy_prop_impl(nir_function_impl *impl);
> +bool nir_copy_prop(nir_shader *shader);
> +
>  #ifdef __cplusplus
>  } /* extern "C" */
>  #endif
> diff --git a/src/glsl/nir/nir_opt_copy_propagate.c 
> b/src/glsl/nir/nir_opt_copy_propagate.c
> new file mode 100644
> index 000..a2be047
> --- /dev/null
> +++ b/src/glsl/nir/nir_opt_copy_propagate.c
> @@ -0,0 +1,313 @@
> +/*
> + * 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:
> + *Connor Abbott (cwabbo...@gmail.com)
> + *
> + */
> +
> +#include "nir.h"
> +#include 
> +
> +/**
> + * SSA-based copy propagation
> + */
> +
> +static bool is_move(nir_alu_instr *instr)
> +{
> +   if (instr->op != nir_op_fmov &&
> +   instr->op != nir_op_imov)
> +  return false;
> +
> +   if (instr->dest.saturate)
> +  return false;
> +
> +   /* we handle modifiers in a separate pass */

This comment is stale now, since this pass should never see
modifiers... maybe we should replace those if's with asserts to make
that clear.

> +
> +   if (instr->src[0].abs || instr->src[0].negate)
> +  return false;
> +
> +   if (!instr->src[0].src.is_ssa)
> +  return false;
> +
> +   return true;
> +
> +}
> +
> +static bool
> +is_swizzleless_move(nir_alu_instr *instr)
> +{
> +   if (!is_move(instr))
> +  return false;
> +
> +   for (unsigned i = 0; i < 4; i++) {
> +  if (!((instr->dest.write_mask >> i) & 1))
> + break;
> +  if (instr->src[0].swizzle[i] != i)
> + return false;
> +   }
> +
> +   return true;
> +}
> +
> +static bool is_vec(nir_alu_instr *instr)
> +{
> +   for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++)
> +  if (!instr->src[i].src.is_ssa)
> + return false;
> +
> +   return instr->op == nir_op_vec2 ||
> +  instr->op == nir_op_vec3 ||
> +  instr->op == nir_op_vec4;
> +}
> +
> +typedef struct {
> +   nir_ssa_def *def;
> +   bool found;
> +} search_def_state;
> +
> +static bool
> +search_def(nir_src *src, void *_state)
> +{
> +   search_def_state *state = (search_def_state *) _state;
> +
> +   if (src->is_ssa && src->ssa == state->def)
> +  state->found = true;
> +
> +   return true;
> +}
> +
> +static void
> +rewrite_src_instr(nir_src *src, nir_ssa_def *new_def, nir_instr 
> *parent_instr)
> +{
> +   nir_ssa_def *old_def = src->ssa;
> +
> +   src->ssa = new_def;
> +
> +   /*
> +* The instruction could still use the old definition in one of its other
> +* sources, so only remove the instruction from the uses if there are no
> +* more uses left.
> +*/
> +
> +   search_def_state search_state;
> +   search_state.def = old_def

[Mesa-dev] [Bug 86701] [regression] weston-simple-egl not running anymore inside qemu

2014-12-17 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=86701

Link Mauve  changed:

   What|Removed |Added

   Hardware|Other   |All
Version|git |10.4

--- Comment #2 from Link Mauve  ---
This removal prevents any application from using llvmpipe on wayland, even with
LIBGL_ALWAYS_SOFTWARE.

It still works fine on Xwayland and egl_dri2, but this isn’t a suitable
fallback.

Imo the best fix would be to wire llvmpipe to egl_dri2 on wayland too.

-- 
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 045/133] nir: Add a basic metadata management system

2014-12-17 Thread Connor Abbott
One thing I'm a little worried about is that passes might forget to
require the right metadata, and they'll just happen to work since the
pass before also requires the same metadata and preserves it. I think
a good thing to do to combat this is to have a debug mode that dirties
*all* the metadata in nir_metadata_preserve(), even the stuff the
caller asks us to preserve, and actually goes and destroys it/somehow
makes it garbage so that passes that forget to require the right
metadata will fail spectacularly. The other, more insidious, issue is
passes accidentally preserving metadata that the author didn't realize
they invalidated. We could solve this by somehow re-calculating the
metadata in nir_metadata_preserve() and comparing it to the old
metadata before trashing it, but I'm not as clear on how that would
work and it seems like a lot more work so I'm fine with leaving it out
for now. I'd like this to happen whenever we enable nir_validate
(#ifdef DEBUG?), but I'll leave figuring out how to enable it up to
you.


On Tue, Dec 16, 2014 at 1:04 AM, Jason Ekstrand  wrote:
> ---
>  src/glsl/Makefile.sources|  1 +
>  src/glsl/nir/nir.c   | 19 +++-
>  src/glsl/nir/nir.h   | 21 --
>  src/glsl/nir/nir_dominance.c |  6 ++---
>  src/glsl/nir/nir_metadata.c  | 52 
> 
>  5 files changed, 82 insertions(+), 17 deletions(-)
>  create mode 100644 src/glsl/nir/nir_metadata.c
>
> diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
> index d3b17bd..4eb6320 100644
> --- a/src/glsl/Makefile.sources
> +++ b/src/glsl/Makefile.sources
> @@ -25,6 +25,7 @@ NIR_FILES = \
> $(GLSL_SRCDIR)/nir/nir_lower_system_values.c \
> $(GLSL_SRCDIR)/nir/nir_lower_variables_scalar.c \
> $(GLSL_SRCDIR)/nir/nir_lower_vec_to_movs.c \
> +   $(GLSL_SRCDIR)/nir/nir_metadata.c \
> $(GLSL_SRCDIR)/nir/nir_opcodes.c \
> $(GLSL_SRCDIR)/nir/nir_opcodes.h \
> $(GLSL_SRCDIR)/nir/nir_opt_copy_propagate.c \
> diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
> index 3dd9e5a..0124799 100644
> --- a/src/glsl/nir/nir.c
> +++ b/src/glsl/nir/nir.c
> @@ -106,6 +106,7 @@ nir_function_create(nir_shader *shader, const char *name)
> exec_list_push_tail(&shader->functions, &func->node);
> exec_list_make_empty(&func->overload_list);
> func->name = name;
> +   func->shader = shader;
>
> return func;
>  }
> @@ -243,8 +244,7 @@ nir_function_impl_create(nir_function_overload *overload)
> impl->return_var = NULL;
> impl->reg_alloc = 0;
> impl->ssa_alloc = 0;
> -   impl->block_index_dirty = true;
> -   impl->dominance_dirty = true;
> +   impl->valid_metadata = nir_metadata_none;
>
> /* create start & end blocks */
> nir_block *start_block = nir_block_create(mem_ctx);
> @@ -815,7 +815,7 @@ handle_jump(nir_block *block)
> unlink_block_successors(block);
>
> nir_function_impl *impl = nir_cf_node_get_function(&block->cf_node);
> -   impl->dominance_dirty = true;
> +   nir_metadata_dirty(impl, nir_metadata_none);
>
> if (jump_instr->type == nir_jump_break ||
> jump_instr->type == nir_jump_continue) {
> @@ -912,7 +912,7 @@ handle_remove_jump(nir_block *block, nir_jump_type type)
> }
>
> nir_function_impl *impl = nir_cf_node_get_function(&block->cf_node);
> -   impl->dominance_dirty = true;
> +   nir_metadata_dirty(impl, nir_metadata_none);
>  }
>
>  /**
> @@ -1019,8 +1019,7 @@ nir_cf_node_insert_after(nir_cf_node *node, nir_cf_node 
> *after)
> }
>
> nir_function_impl *impl = nir_cf_node_get_function(node);
> -   impl->block_index_dirty = true;
> -   impl->dominance_dirty = true;
> +   nir_metadata_dirty(impl, nir_metadata_none);
>  }
>
>  void
> @@ -1062,8 +1061,7 @@ nir_cf_node_insert_before(nir_cf_node *node, 
> nir_cf_node *before)
> }
>
> nir_function_impl *impl = nir_cf_node_get_function(node);
> -   impl->block_index_dirty = true;
> -   impl->dominance_dirty = true;
> +   nir_metadata_dirty(impl, nir_metadata_none);
>  }
>
>  void
> @@ -1109,7 +1107,7 @@ void
>  nir_cf_node_remove(nir_cf_node *node)
>  {
> nir_function_impl *impl = nir_cf_node_get_function(node);
> -   impl->block_index_dirty = true;
> +   nir_metadata_dirty(impl, nir_metadata_none);
>
> if (node->type == nir_cf_node_block) {
>/*
> @@ -1673,13 +1671,12 @@ nir_index_blocks(nir_function_impl *impl)
>  {
> unsigned index = 0;
>
> -   if (!impl->block_index_dirty)
> +   if (impl->valid_metadata & nir_metadata_block_index)
>return;
>
> nir_foreach_block(impl, index_block, &index);
>
> impl->num_blocks = index;
> -   impl->block_index_dirty = false;
>  }
>
>  static void
> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> index c9146c0..8d5f6b8 100644
> --- a/src/glsl/nir/nir.h
> +++ b/src/glsl/nir/nir.h
> @@ -33,6 +33,7 @@
>  #include "GL/gl.h" /* GLenum */
>  #include "util/ralloc.h"
>  #include "main/mtypes.h"
> +#include "main/bitset.h

[Mesa-dev] [PATCH] mesa: plumb offset/size parameters through GetTexImage code

2014-12-17 Thread Brian Paul
Needed for GL_ARB_get_texture_sub_image.  But at this point, the
offsets are always zero and the sizes match the whole texture image.

v2: Fixes, suggestions from Laura Ekstrand:
* Fix calls to ctx->Driver.UnmapTextureImage() to pass the correct
  slice value.
* Added comments and assertions to check zoffset+depth<=tex->Depth before
  the 'img' loops.
* Added a new zoffset==0 assert in get_tex_memcpy().
---
 src/mesa/main/texgetimage.c | 128 +++-
 1 file changed, 78 insertions(+), 50 deletions(-)

diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index 03ad5f4..bf52638 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -74,12 +74,11 @@ type_needs_clamping(GLenum type)
  */
 static void
 get_tex_depth(struct gl_context *ctx, GLuint dimensions,
+  GLint xoffset, GLint yoffset, GLint zoffset,
+  GLsizei width, GLsizei height, GLint depth,
   GLenum format, GLenum type, GLvoid *pixels,
   struct gl_texture_image *texImage)
 {
-   const GLint width = texImage->Width;
-   GLint height = texImage->Height;
-   GLint depth = texImage->Depth;
GLint img, row;
GLfloat *depthRow = malloc(width * sizeof(GLfloat));
 
@@ -93,14 +92,18 @@ get_tex_depth(struct gl_context *ctx, GLuint dimensions,
   height = 1;
}
 
+   /* Note that we also checked for zoffset + img < texImage->Depth
+* in dimensions_error_check().
+*/
+   assert(zoffset + depth <= texImage->Depth);
for (img = 0; img < depth; img++) {
   GLubyte *srcMap;
   GLint srcRowStride;
 
   /* map src texture buffer */
-  ctx->Driver.MapTextureImage(ctx, texImage, img,
-  0, 0, width, height, GL_MAP_READ_BIT,
-  &srcMap, &srcRowStride);
+  ctx->Driver.MapTextureImage(ctx, texImage, zoffset + img,
+  xoffset, yoffset, width, height,
+  GL_MAP_READ_BIT, &srcMap, &srcRowStride);
 
   if (srcMap) {
  for (row = 0; row < height; row++) {
@@ -112,7 +115,7 @@ get_tex_depth(struct gl_context *ctx, GLuint dimensions,
 _mesa_pack_depth_span(ctx, width, dest, type, depthRow, 
&ctx->Pack);
  }
 
- ctx->Driver.UnmapTextureImage(ctx, texImage, img);
+ ctx->Driver.UnmapTextureImage(ctx, texImage, zoffset + img);
   }
   else {
  _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage");
@@ -129,26 +132,29 @@ get_tex_depth(struct gl_context *ctx, GLuint dimensions,
  */
 static void
 get_tex_depth_stencil(struct gl_context *ctx, GLuint dimensions,
+  GLint xoffset, GLint yoffset, GLint zoffset,
+  GLsizei width, GLsizei height, GLint depth,
   GLenum format, GLenum type, GLvoid *pixels,
   struct gl_texture_image *texImage)
 {
-   const GLint width = texImage->Width;
-   const GLint height = texImage->Height;
-   const GLint depth = texImage->Depth;
GLint img, row;
 
assert(format == GL_DEPTH_STENCIL);
assert(type == GL_UNSIGNED_INT_24_8 ||
   type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
 
+   /* Note that we also checked for zoffset + img < texImage->Depth
+* in dimensions_error_check().
+*/
+   assert(zoffset + depth <= texImage->Depth);
for (img = 0; img < depth; img++) {
   GLubyte *srcMap;
   GLint rowstride;
 
   /* map src texture buffer */
-  ctx->Driver.MapTextureImage(ctx, texImage, img,
-  0, 0, width, height, GL_MAP_READ_BIT,
-  &srcMap, &rowstride);
+  ctx->Driver.MapTextureImage(ctx, texImage, zoffset + img,
+  xoffset, yoffset, width, height,
+  GL_MAP_READ_BIT, &srcMap, &rowstride);
 
   if (srcMap) {
  for (row = 0; row < height; row++) {
@@ -165,7 +171,7 @@ get_tex_depth_stencil(struct gl_context *ctx, GLuint 
dimensions,
 }
  }
 
- ctx->Driver.UnmapTextureImage(ctx, texImage, img);
+ ctx->Driver.UnmapTextureImage(ctx, texImage, zoffset + img);
   }
   else {
  _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage");
@@ -180,22 +186,25 @@ get_tex_depth_stencil(struct gl_context *ctx, GLuint 
dimensions,
  */
 static void
 get_tex_ycbcr(struct gl_context *ctx, GLuint dimensions,
+  GLint xoffset, GLint yoffset, GLint zoffset,
+  GLsizei width, GLsizei height, GLint depth,
   GLenum format, GLenum type, GLvoid *pixels,
   struct gl_texture_image *texImage)
 {
-   const GLint width = texImage->Width;
-   const GLint height = texImage->Height;
-   const GLint depth = texImage->Depth;
GLint img, row;
 
+   /* Note that we also checked for zoffset + img < texImage->Depth
+* in dimensions_error_check().
+*/
+   assert(zoffset + depth <= t

Re: [Mesa-dev] [PATCH 04/11] mesa: plumb offset/size parameters through GetTexImage code

2014-12-17 Thread Brian Paul

On 12/16/2014 03:22 PM, Laura Ekstrand wrote:



On Sat, Dec 13, 2014 at 6:42 AM, Brian Paul mailto:bri...@vmware.com>> wrote:

Needed for GL_ARB_get_texture_sub_image.  But at this point, the
offsets are always zero and the sizes match the whole texture image.
---
  src/mesa/main/texgetimage.c | 105

  1 file changed, 58 insertions(+), 47 deletions(-)

diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index 03ad5f4..71c25bb 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -74,12 +74,11 @@ type_needs_clamping(GLenum type)
   */
  static void
  get_tex_depth(struct gl_context *ctx, GLuint dimensions,
+  GLint xoffset, GLint yoffset, GLint zoffset,
+  GLsizei width, GLsizei height, GLint depth,
GLenum format, GLenum type, GLvoid *pixels,
struct gl_texture_image *texImage)
  {
-   const GLint width = texImage->Width;
-   GLint height = texImage->Height;
-   GLint depth = texImage->Depth;
 GLint img, row;
 GLfloat *depthRow = malloc(width * sizeof(GLfloat));

@@ -98,9 +97,9 @@ get_tex_depth(struct gl_context *ctx, GLuint
dimensions,
GLint srcRowStride;

You are not checking here to make sure that zoffset + img < depth.  I
looked in the next patch (implement _mesa_GetTextureSubImage) and found
that the dimensions_error_check does this.  It might be good to make a
note of that here.


I've added a comment and assertion there and before similar loops.




/* map src texture buffer */
-  ctx->Driver.MapTextureImage(ctx, texImage, img,
-  0, 0, width, height, GL_MAP_READ_BIT,
-&srcMap, &srcRowStride);
+  ctx->Driver.MapTextureImage(ctx, texImage, zoffset + img,
+  xoffset, yoffset, width, height,
+  GL_MAP_READ_BIT, &srcMap,
&srcRowStride);

if (srcMap) {
   for (row = 0; row < height; row++) {

Why didn't you update ctx->Driver.UnmapTextureImage(ctx, texImage, img)
to take zoffset + img here?  You did that for
get_tex_rgba_uncompressed.  Is there some reason that it has to be
UnmapTextureImage(.. img only) for all of the other functions?


Those were oversights.  Fixed now.  I'll post a v2 patch.

Thanks.

-Brian


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


Re: [Mesa-dev] [PATCH 01/11] meta: handle subimages in _mesa_meta_setup_texture_coords()

2014-12-17 Thread Brian Paul

On 12/16/2014 12:56 PM, Laura Ekstrand wrote:



On Sat, Dec 13, 2014 at 6:42 AM, Brian Paul mailto:bri...@vmware.com>> wrote:

In preparation for getting texture sub images.
---
  src/mesa/drivers/common/meta.c | 88
+-
  src/mesa/drivers/common/meta.h |  4 ++
  src/mesa/drivers/common/meta_generate_mipmap.c |  4 +-
  3 files changed, 64 insertions(+), 32 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c
b/src/mesa/drivers/common/meta.c
index 87532c1..a84e512 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -2450,30 +2450,53 @@ _mesa_meta_Bitmap(struct gl_context *ctx,

  /**
   * Compute the texture coordinates for the four vertices of a quad for
- * drawing a 2D texture image or slice of a cube/3D texture.
+ * drawing a 2D texture image or slice of a cube/3D texture.  The
offset
+ * and width, height specify a sub-region of the 2D image.
+ *
   * \param faceTarget  GL_TEXTURE_1D/2D/3D or cube face name
   * \param slice  slice of a 1D/2D array texture or 3D texture
- * \param width  width of the texture image
- * \param height  height of the texture image
+ * \param xoffset  X position of sub texture
+ * \param yoffset  Y position of sub texture
+ * \param width  width of the sub texture image
+ * \param height  height of the sub texture image
+ * \param total_width  total width of the texture image
+ * \param total_height  total height of the texture image
+ * \param total_depth  total depth of the texture image
   * \param coords0/1/2/3  returns the computed texcoords
   */


I'm confused.  Here you take the args width, height, then total_width,
total_height, and total_depth.  But in the definition of
_mesa_meta_setup_texture_coords in meta.h, you have width, height,
depth, total_width, and total_height.


Typo.  I've fixed the meta.h declaration.

-Brian


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


Re: [Mesa-dev] [PATCH 046/133] nir: Add an assert

2014-12-17 Thread Connor Abbott
Sorry to ask, but... this one is so trivial and touches code that no
earlier patch touches, why don't we just squash it into the commit
that adds nir.c?

On Tue, Dec 16, 2014 at 1:04 AM, Jason Ekstrand  wrote:
> ---
>  src/glsl/nir/nir.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
> index 0124799..3c897b2 100644
> --- a/src/glsl/nir/nir.c
> +++ b/src/glsl/nir/nir.c
> @@ -840,6 +840,7 @@ handle_jump(nir_block *block)
>  unlink_blocks(last_block, after_block);
>}
> } else {
> +  assert(jump_instr->type == nir_jump_return);
>link_blocks(block, impl->end_block, NULL);
> }
>  }
> --
> 2.2.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


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

2014-12-17 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=86944

Jason Ekstrand  changed:

   What|Removed |Added

 CC|ja...@jlekstrand.net|

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


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

2014-12-17 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=86944

José Fonseca  changed:

   What|Removed |Added

   Assignee|jfons...@vmware.com |mesa-dev@lists.freedesktop.
   ||org

--- Comment #9 from José Fonseca  ---
> Build error with Oracle Studio.

Just realized this is not with MSVC.

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


Re: [Mesa-dev] [PATCH 3/3] glx/dri3: Request non-vsynced Present for swapinterval zero.

2014-12-17 Thread Mario Kleiner

On 12/17/2014 12:45 PM, Eero Tamminen wrote:

Hi,

On 12/16/2014 08:30 PM, Mario Kleiner wrote:

On 12/16/2014 09:23 AM, Keith Packard wrote:

Mario Kleiner  writes:


The 0 case is good for benchmarking.
Sure, but the current code does benchmarking just fine. In fact, 
because

it doesn't copy queued frames that aren't the most recent before the
vblank, benchmarks tend to run *faster* as a result, and people
generally like that aspect of it...



Hmm. For benchmarking i think i'd consider that a mild form of cheating.
You get higher fps because you skip processing like the whole gpu blit
overhead and host processing overhead for queuing / validating /
processing the copy command in the command stream, so the benchmark
numbers don't translate very well anymore in how the system would behave
in a non-benchmark situation?mesa-dev


From performance numbers on Windows it's clear that Windows doesn't
copy frames that happen faster than monitor update frequency.



Under desktop composition, yes. As far as i observed (and i think also 
read somewhere), their compositor wakes up once at the beginning of a 
refresh cycle and composites everything that needs composition and was 
submitted in the previous frame, then pageflips at the next vsync, so 
you'll always have at least 1 frame lag, while at the same time skipping 
frames if the client renders too fast. It's somewhat different for 
unredirected windows, but the rules of when a window gets unredirected 
are somewhat weird and also inconsistently (buggy) implemented on many 
drivers in my experience. OSX ditto. One reason why many of my timing 
sensitive users are fleeing to Linux...



This isn't cheating.  It makes numbers more relevant as it minimizes
Windowing system impact/distortion on application rendering performance.

The problem with Windowing system doing extra copies is that it doesn't
affect all applications equally.  If application is memory bandwidth
limited, the windowing system impact is directly proportional to FPS.
If application isn't memory bandwidth limited, it has no impact. And
whether application is memory bandwidth limited, is HW dependent, which
distorts also HW comparisons.


I can agree that benchmarking is hard and it depends on what you want to 
measure ;-) - so many benchmarks to pick from...


But my main concern is not the benchmarking, but the other use cases i 
mentioned for non-vsynced operation, and some consistency between 
implementations. It's difficult to explain to "normal" users why they 
should follow totally different procedures depending on 
XOrg-Version/Mesa-Version/Type and version of ddx/Which kernel they 
use/What distro and distro version they use/If its DRI2 or DRI3/what 
acceleration api is in use/whatever. Especially when i myself as someone 
who can read source code and does a lot of testing have huge trouble 
remembering all the special cases.


I just like api's to behave somewhat predictable over time and rather 
have more extra api for fine grained control and introducing new 
functionality than less api, so that i can make decisions about what 
tradeoffs to choose automatically in my app, instead of exposing tons of 
configuration howtos to my users.


-mario





- Eero


... but read on below ...


In my specific case i always want vsync'ed swap for actual visual
stimulation in neuroscience/medical settings, with no frame skipped
ever. The bonus use for me, except for benchmarking how fast the 
system

can go, is if one has a multi-display setup, e.g., dual-display for
stereoscopic stimulation - one display per eye, or some CAVE like 
setup

for VR with more than 2 displays. You want display updates and scanout
on all of them synchronized, so the scene stays coherent. One 
simple way
for visually testing multi-display sync is to intentionally swap 
all of
them without vsync, e.g., timed to swap in the middle of the 
scanout. If
the tear-lines on all displays are roughly at the same vertical 
position
and stay there then that's a good visual test if stuff works. There 
are

other ways to do it, but this is the one method that seems to work
cross-platform, without lots of mental context switching depending on
what os/gpu/server/driver combo with what settings one uses, and much
more easy to grasp for scientists with no graphics background. You can
see at a glance if stuff is roughly correct or not.

It seems like you want something that the GL API doesn't express
precisely; my reading of the  GL spec definitely lets Present work the
way it does today, and as you avoid tearing *and* improve 
performance in

the vblank_mode=0 case, I'm very reluctant to change it.


 From GLX_EXT_swap_control and MESA_swap_control:

"If  is set to a value of 0, buffer swaps are not
 synchronized to a video frame."


It depends on how you interpret the "not synchronized to a video frame"?
Can you explain your interpretation?

I don't think the spec says anywhere that dropping old "not most recent
at vblank time

Re: [Mesa-dev] [PATCH v3 09/28] mesa: Add RGBA to Luminance conversion helpers

2014-12-17 Thread Jason Ekstrand
On Dec 17, 2014 4:52 AM, "Iago Toral"  wrote:
>
> On Wed, 2014-12-17 at 03:51 -0800, Jason Ekstrand wrote:
> >
> >
> >
> >
> >
> > On Tue, Dec 16, 2014 at 11:37 PM, Iago Toral 
> > wrote:
> > On Tue, 2014-12-16 at 10:54 -0800, Jason Ekstrand wrote:
> > >
> > >
> > > On Tue, Dec 16, 2014 at 4:01 AM, Iago Toral
> >  wrote:
> > > On Tue, 2014-12-16 at 08:29 +0100, Iago Toral wrote:
> > > > On Mon, 2014-12-15 at 10:19 -0800, Jason Ekstrand
> > wrote:
> > > > >
> > > > >
> > > > > On Mon, Dec 15, 2014 at 3:12 AM, Iago Toral
> > >  wrote:
> > > > > On Fri, 2014-12-12 at 11:36 -0800, Jason
> > Ekstrand
> > > wrote:
> > > > > >
> > > > > >
> > > > > > On Tue, Dec 9, 2014 at 4:0 Iago
> > Toral
> > > Quiroga
> > > > > 
> > > > > > wrote:
> > > > > > For glReadPixels with a
> > Luminance
> > > destination format
> > > > > we
> > > > > > compute luminance
> > > > > > values from RGBA as L=R+G+B.
> > This,
> > > however, requires
> > > > > ad-hoc
> > > > > > implementation,
> > > > > > since pack/unpack functions or
> > > > > _mesa_swizzle_and_convert won't
> > > > > > do this
> > > > > > (and thus, neither will
> > > _mesa_format_convert). This
> > > > > patch adds
> > > > > > helpers
> > > > > > to do this computation so they
> > can be
> > > used to
> > > > > support
> > > > > > conversion to luminance
> > > > > > formats.
> > > > > >
> > > > > > The current implementation of
> > > glReadPixels does this
> > > > > > computation as part
> > > > > > of the span functions in
> > pack.c (see
> > > > > > _mesa_pack_rgba_span_float),
> > that do
> > > > > > this together with other
> > things like
> > > type
> > > > > conversion, etc. We
> > > > > > do not want
> > > > > > to use these functions but use
> > > _mesa_format_convert
> > > > > instead
> > > > > > (later patches
> > > > > > will remove the color span
> > functions),
> > > so we need to
> > > > > extract
> > > > > > this functionality
> > > > > > as helpers.
> > > > > > ---
> > > > > >  src/mesa/main/pack.c | 63
> > > > > >
> > >
> > 
> > > > > >  src/mesa/main/pack.h |  9
> > 
> > > > > >  2 files changed, 72
> > insertions(+)
> > > > > >
> > > > > > diff --git
> > a/src/mesa/main/pack.c
> > > > > b/src/mesa/main/pack.c
> > > > > > index de6ab27..fa4046c 100644
> > > > > > --- a/src/mesa/main/pack.c
> > > > > > +++ b/src/mesa/main/pack.c
> > > > > > @@ -4334,4 +4334,67 @@
> > > _mesa_rebase_rgba_uint(GLuint
> > > > > n, GLuint
> > > > > > rgba[][4], GLenum baseFormat)
> > > > > > }
> > > > > >  }
> > > > > >
> > > > > > +void
> > > > > >
> > >  +_mesa_pack_luminance_from_rgba_float(GLuint n,
> > > > > GLfloat
> > > > > > rgba[][4],
> > > > > > +
> > >  GLvoid
> > > > > *dstAddr, GLenum
> > > > > > dst_format,

Re: [Mesa-dev] [PATCH 031/133] nir: Add fine and coarse derivative opcodes

2014-12-17 Thread Jason Ekstrand
On Dec 17, 2014 7:43 AM, "Connor Abbott"  wrote:
>
> On Wed, Dec 17, 2014 at 6:52 AM, Jason Ekstrand 
wrote:
> >
> >
> > On Tue, Dec 16, 2014 at 10:31 PM, Connor Abbott 
wrote:
> >>
> >> As a future cleanup, would it be worth getting rid of fddx and fddy
> >> entirely and just generating the correct variant based on the
> >> glHint/drirc configuration?
> >
> >
> > Nope.  https://www.opengl.org/registry/specs/ARB/derivative_control.txt
>
> I just meant doing the
>
> if (fs_key->high_quality_derivatives) { emit ddx_fine } else { emit
> ddx_coarse } part in NIR so other drivers don't have to handle it, I
> still don't understand why that's not possible.

Sure, we could do that but i don't think we want to.  On i965, switching
the derivative glHint forces a recompile but this may not always be the
case.  If we do have a driver that can switch on-the-fly or if as figure
out how to do it in i965 for cheap, we'll want all 6.

>
> >
> >>
> >>
> >> On Tue, Dec 16, 2014 at 1:04 AM, Jason Ekstrand 
> >> wrote:
> >> > ---
> >> >  src/glsl/nir/nir_opcodes.h | 4 
> >> >  1 file changed, 4 insertions(+)
> >> >
> >> > diff --git a/src/glsl/nir/nir_opcodes.h b/src/glsl/nir/nir_opcodes.h
> >> > index bee4bd1..9a7a2ab 100644
> >> > --- a/src/glsl/nir/nir_opcodes.h
> >> > +++ b/src/glsl/nir/nir_opcodes.h
> >> > @@ -111,6 +111,10 @@ UNOP(fcos_reduced, nir_type_float)
> >> >  /*@{*/
> >> >  UNOP(fddx, nir_type_float)
> >> >  UNOP(fddy, nir_type_float)
> >> > +UNOP(fddx_fine, nir_type_float)
> >> > +UNOP(fddy_fine, nir_type_float)
> >> > +UNOP(fddx_coarse, nir_type_float)
> >> > +UNOP(fddy_coarse, nir_type_float)
> >> >  /*@}*/
> >> >
> >> >  /**
> >> > --
> >> > 2.2.0
> >> >
> >> > ___
> >> > mesa-dev mailing list
> >> > mesa-dev@lists.freedesktop.org
> >> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v3] i965: Fix bitcast operations with negate (ceil)

2014-12-17 Thread Jason Ekstrand
Reviewed-by: Jason Ekstrand 
On Dec 17, 2014 5:26 AM, "Matt Turner"  wrote:

> Reviewed-by: Matt Turner 
>
> Thanks Iago!
> ___
> 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] [RFC 6/8] mesa: remove support for GCC older than 4.1.0

2014-12-17 Thread Jonathan Gray
On Wed, Dec 17, 2014 at 07:39:21AM -0800, Matt Turner wrote:
> On Wed, Dec 17, 2014 at 7:28 AM, Jonathan Gray  wrote:
> > On Thu, Dec 18, 2014 at 12:26:10AM +1100, Timothy Arceri wrote:
> >> On Tue, 2014-12-16 at 22:58 -0800, Vinson Lee wrote:
> >> > On Mon, Dec 15, 2014 at 6:23 PM, Jonathan Gray  wrote:
> >> > > On Sat, Dec 13, 2014 at 09:09:27PM +1100, Timothy Arceri wrote:
> >> > >> On Fri, 2014-12-12 at 07:01 -0600, kallisti5 wrote:
> >> > >> > On 2014-12-12 05:46, Timothy Arceri wrote:
> >> > >> > > Signed-off-by: Timothy Arceri 
> >> > >> > > ---
> >> > >> > >  src/mesa/main/compiler.h | 2 +-
> >> > >> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> >> > >> > >
> >> > >> > > diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h
> >> > >> > > index 34671dc..cdc843d 100644
> >> > >> > > --- a/src/mesa/main/compiler.h
> >> > >> > > +++ b/src/mesa/main/compiler.h
> >> > >> > > @@ -122,7 +122,7 @@ extern "C" {
> >> > >> > >   * inline a static function that we later use in an alias. - ajax
> >> > >> > >   */
> >> > >> > >  #ifndef PUBLIC
> >> > >> > > -#  if (defined(__GNUC__) && __GNUC__ >= 4) || 
> >> > >> > > (defined(__SUNPRO_C) &&
> >> > >> > > (__SUNPRO_C >= 0x590))
> >> > >> > > +#  if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >=
> >> > >> > > 0x590))
> >> > >> > >  #define PUBLIC __attribute__((visibility("default")))
> >> > >> > >  #define USED __attribute__((used))
> >> > >> > >  #  else
> >> > >> >
> >> > >> > Why not also drop the SUNPRO_C version check?
> >> > >> >
> >> > >> > #  if defined(__GNUC__) || defined(__SUNPRO_C)
> >> > >> >
> >> > >> > I downloaded SunStudio 12 (circa 2007) and __SUNPRO_C is set to 
> >> > >> > 0x590.
> >> > >> > If we drop support for GCC 4.1 (2007), might as well drop older sun
> >> > >> > compilers.
> >> > >>
> >> > >>
> >> > >> The series is dropping support for GCC 4.0. 4.1 is shipped with Redhat
> >> > >> Enterprise Linux 5 which is still in support so I've set that as the
> >> > >> minimum version.
> >> > >
> >> > > It is worth pointing out OpenBSD ships a patched GCC 4.2.1 as the base
> >> > > compiler as that was the last GPLv2 licensed version.  Not relevant 
> >> > > this
> >> > > time, perhaps it will be next time.
> >> > > ___
> >> > > mesa-dev mailing list
> >> > > mesa-dev@lists.freedesktop.org
> >> > > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> >> >
> >> >
> >> > Latest master doesn't build with GCC 4.1.
> >> >
> >> > glsl/ir_uniform.h:45: error: use of enum ???gl_uniform_driver_format???
> >> > without previous declaration
> >>
> >> My reasoning for using 4.1 seems to be flawed as RHEL 5 comes with
> >> autoconf 2.59 by default and current Mesa requires 2.60. Maybe bumping
> >> GCC to 4.2 would be better. I assume the above issue doesn't happen on
> >> 4.2 since OpenBSD uses it?
> >
> > I don't see that error with master here.
> >
> > The problem seems to be the use of an attribute on the enum which going
> > by https://gcc.gnu.org/gcc-4.2/changes.html is only supported after 4.2.0?
> 
> Indeed, and that code has been in place since June and no one has
> complained as far as I can tell.
> 
> I'm okay with bumping the minimum to 4.2. We're already using
> __attribute__((packed)) on enums in a number of places in the i965
> driver.

i965 also requires the GCC extension of binary integer constants which
was introduced in GCC 4.3.  I backported the GPLv2 patch in GCC PR 23479
for that to OpenBSD's 4.2.1.  I know at least FreeBSD did that as well.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 045/133] nir: Add a basic metadata management system

2014-12-17 Thread Connor Abbott
On Wed, Dec 17, 2014 at 7:04 AM, Jason Ekstrand  wrote:
>
>
> On Tue, Dec 16, 2014 at 10:58 PM, Connor Abbott  wrote:
>>
>> On Tue, Dec 16, 2014 at 1:04 AM, Jason Ekstrand 
>> wrote:
>> > ---
>> >  src/glsl/Makefile.sources|  1 +
>> >  src/glsl/nir/nir.c   | 19 +++-
>> >  src/glsl/nir/nir.h   | 21 --
>> >  src/glsl/nir/nir_dominance.c |  6 ++---
>> >  src/glsl/nir/nir_metadata.c  | 52
>> > 
>> >  5 files changed, 82 insertions(+), 17 deletions(-)
>> >  create mode 100644 src/glsl/nir/nir_metadata.c
>> >
>> > diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
>> > index d3b17bd..4eb6320 100644
>> > --- a/src/glsl/Makefile.sources
>> > +++ b/src/glsl/Makefile.sources
>> > @@ -25,6 +25,7 @@ NIR_FILES = \
>> > $(GLSL_SRCDIR)/nir/nir_lower_system_values.c \
>> > $(GLSL_SRCDIR)/nir/nir_lower_variables_scalar.c \
>> > $(GLSL_SRCDIR)/nir/nir_lower_vec_to_movs.c \
>> > +   $(GLSL_SRCDIR)/nir/nir_metadata.c \
>> > $(GLSL_SRCDIR)/nir/nir_opcodes.c \
>> > $(GLSL_SRCDIR)/nir/nir_opcodes.h \
>> > $(GLSL_SRCDIR)/nir/nir_opt_copy_propagate.c \
>> > diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
>> > index 3dd9e5a..0124799 100644
>> > --- a/src/glsl/nir/nir.c
>> > +++ b/src/glsl/nir/nir.c
>> > @@ -106,6 +106,7 @@ nir_function_create(nir_shader *shader, const char
>> > *name)
>> > exec_list_push_tail(&shader->functions, &func->node);
>> > exec_list_make_empty(&func->overload_list);
>> > func->name = name;
>> > +   func->shader = shader;
>> >
>> > return func;
>> >  }
>> > @@ -243,8 +244,7 @@ nir_function_impl_create(nir_function_overload
>> > *overload)
>> > impl->return_var = NULL;
>> > impl->reg_alloc = 0;
>> > impl->ssa_alloc = 0;
>> > -   impl->block_index_dirty = true;
>> > -   impl->dominance_dirty = true;
>> > +   impl->valid_metadata = nir_metadata_none;
>> >
>> > /* create start & end blocks */
>> > nir_block *start_block = nir_block_create(mem_ctx);
>> > @@ -815,7 +815,7 @@ handle_jump(nir_block *block)
>> > unlink_block_successors(block);
>> >
>> > nir_function_impl *impl = nir_cf_node_get_function(&block->cf_node);
>> > -   impl->dominance_dirty = true;
>> > +   nir_metadata_dirty(impl, nir_metadata_none);
>> >
>> > if (jump_instr->type == nir_jump_break ||
>> > jump_instr->type == nir_jump_continue) {
>> > @@ -912,7 +912,7 @@ handle_remove_jump(nir_block *block, nir_jump_type
>> > type)
>> > }
>> >
>> > nir_function_impl *impl = nir_cf_node_get_function(&block->cf_node);
>> > -   impl->dominance_dirty = true;
>> > +   nir_metadata_dirty(impl, nir_metadata_none);
>> >  }
>> >
>> >  /**
>> > @@ -1019,8 +1019,7 @@ nir_cf_node_insert_after(nir_cf_node *node,
>> > nir_cf_node *after)
>> > }
>> >
>> > nir_function_impl *impl = nir_cf_node_get_function(node);
>> > -   impl->block_index_dirty = true;
>> > -   impl->dominance_dirty = true;
>> > +   nir_metadata_dirty(impl, nir_metadata_none);
>> >  }
>> >
>> >  void
>> > @@ -1062,8 +1061,7 @@ nir_cf_node_insert_before(nir_cf_node *node,
>> > nir_cf_node *before)
>> > }
>> >
>> > nir_function_impl *impl = nir_cf_node_get_function(node);
>> > -   impl->block_index_dirty = true;
>> > -   impl->dominance_dirty = true;
>> > +   nir_metadata_dirty(impl, nir_metadata_none);
>> >  }
>> >
>> >  void
>> > @@ -1109,7 +1107,7 @@ void
>> >  nir_cf_node_remove(nir_cf_node *node)
>> >  {
>> > nir_function_impl *impl = nir_cf_node_get_function(node);
>> > -   impl->block_index_dirty = true;
>> > +   nir_metadata_dirty(impl, nir_metadata_none);
>> >
>> > if (node->type == nir_cf_node_block) {
>> >/*
>> > @@ -1673,13 +1671,12 @@ nir_index_blocks(nir_function_impl *impl)
>> >  {
>> > unsigned index = 0;
>> >
>> > -   if (!impl->block_index_dirty)
>> > +   if (impl->valid_metadata & nir_metadata_block_index)
>> >return;
>> >
>> > nir_foreach_block(impl, index_block, &index);
>> >
>> > impl->num_blocks = index;
>> > -   impl->block_index_dirty = false;
>> >  }
>> >
>> >  static void
>> > diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
>> > index c9146c0..8d5f6b8 100644
>> > --- a/src/glsl/nir/nir.h
>> > +++ b/src/glsl/nir/nir.h
>> > @@ -33,6 +33,7 @@
>> >  #include "GL/gl.h" /* GLenum */
>> >  #include "util/ralloc.h"
>> >  #include "main/mtypes.h"
>> > +#include "main/bitset.h"
>> >  #include "nir_types.h"
>> >  #include 
>> >
>> > @@ -45,6 +46,7 @@ extern "C" {
>> >
>> >  struct nir_function_overload;
>> >  struct nir_function;
>> > +struct nir_shader;
>> >
>> >
>> >  /**
>> > @@ -1037,6 +1039,16 @@ typedef struct {
>> >  #define nir_loop_last_cf_node(loop) \
>> > exec_node_data(nir_cf_node, exec_list_get_tail(&(loop)->body), node)
>> >
>> > +/**
>> > + * Various bits of metadata that can may be created or required by
>> > + * optimization and analysis passes
>> > + */
>> > +typedef enum {
>> > +   nir_

Re: [Mesa-dev] [PATCH 031/133] nir: Add fine and coarse derivative opcodes

2014-12-17 Thread Connor Abbott
On Wed, Dec 17, 2014 at 6:52 AM, Jason Ekstrand  wrote:
>
>
> On Tue, Dec 16, 2014 at 10:31 PM, Connor Abbott  wrote:
>>
>> As a future cleanup, would it be worth getting rid of fddx and fddy
>> entirely and just generating the correct variant based on the
>> glHint/drirc configuration?
>
>
> Nope.  https://www.opengl.org/registry/specs/ARB/derivative_control.txt

I just meant doing the

if (fs_key->high_quality_derivatives) { emit ddx_fine } else { emit
ddx_coarse } part in NIR so other drivers don't have to handle it, I
still don't understand why that's not possible.

>
>>
>>
>> On Tue, Dec 16, 2014 at 1:04 AM, Jason Ekstrand 
>> wrote:
>> > ---
>> >  src/glsl/nir/nir_opcodes.h | 4 
>> >  1 file changed, 4 insertions(+)
>> >
>> > diff --git a/src/glsl/nir/nir_opcodes.h b/src/glsl/nir/nir_opcodes.h
>> > index bee4bd1..9a7a2ab 100644
>> > --- a/src/glsl/nir/nir_opcodes.h
>> > +++ b/src/glsl/nir/nir_opcodes.h
>> > @@ -111,6 +111,10 @@ UNOP(fcos_reduced, nir_type_float)
>> >  /*@{*/
>> >  UNOP(fddx, nir_type_float)
>> >  UNOP(fddy, nir_type_float)
>> > +UNOP(fddx_fine, nir_type_float)
>> > +UNOP(fddy_fine, nir_type_float)
>> > +UNOP(fddx_coarse, nir_type_float)
>> > +UNOP(fddy_coarse, nir_type_float)
>> >  /*@}*/
>> >
>> >  /**
>> > --
>> > 2.2.0
>> >
>> > ___
>> > mesa-dev mailing list
>> > mesa-dev@lists.freedesktop.org
>> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [RFC 6/8] mesa: remove support for GCC older than 4.1.0

2014-12-17 Thread Matt Turner
On Wed, Dec 17, 2014 at 7:28 AM, Jonathan Gray  wrote:
> On Thu, Dec 18, 2014 at 12:26:10AM +1100, Timothy Arceri wrote:
>> On Tue, 2014-12-16 at 22:58 -0800, Vinson Lee wrote:
>> > On Mon, Dec 15, 2014 at 6:23 PM, Jonathan Gray  wrote:
>> > > On Sat, Dec 13, 2014 at 09:09:27PM +1100, Timothy Arceri wrote:
>> > >> On Fri, 2014-12-12 at 07:01 -0600, kallisti5 wrote:
>> > >> > On 2014-12-12 05:46, Timothy Arceri wrote:
>> > >> > > Signed-off-by: Timothy Arceri 
>> > >> > > ---
>> > >> > >  src/mesa/main/compiler.h | 2 +-
>> > >> > >  1 file changed, 1 insertion(+), 1 deletion(-)
>> > >> > >
>> > >> > > diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h
>> > >> > > index 34671dc..cdc843d 100644
>> > >> > > --- a/src/mesa/main/compiler.h
>> > >> > > +++ b/src/mesa/main/compiler.h
>> > >> > > @@ -122,7 +122,7 @@ extern "C" {
>> > >> > >   * inline a static function that we later use in an alias. - ajax
>> > >> > >   */
>> > >> > >  #ifndef PUBLIC
>> > >> > > -#  if (defined(__GNUC__) && __GNUC__ >= 4) || (defined(__SUNPRO_C) 
>> > >> > > &&
>> > >> > > (__SUNPRO_C >= 0x590))
>> > >> > > +#  if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >=
>> > >> > > 0x590))
>> > >> > >  #define PUBLIC __attribute__((visibility("default")))
>> > >> > >  #define USED __attribute__((used))
>> > >> > >  #  else
>> > >> >
>> > >> > Why not also drop the SUNPRO_C version check?
>> > >> >
>> > >> > #  if defined(__GNUC__) || defined(__SUNPRO_C)
>> > >> >
>> > >> > I downloaded SunStudio 12 (circa 2007) and __SUNPRO_C is set to 0x590.
>> > >> > If we drop support for GCC 4.1 (2007), might as well drop older sun
>> > >> > compilers.
>> > >>
>> > >>
>> > >> The series is dropping support for GCC 4.0. 4.1 is shipped with Redhat
>> > >> Enterprise Linux 5 which is still in support so I've set that as the
>> > >> minimum version.
>> > >
>> > > It is worth pointing out OpenBSD ships a patched GCC 4.2.1 as the base
>> > > compiler as that was the last GPLv2 licensed version.  Not relevant this
>> > > time, perhaps it will be next time.
>> > > ___
>> > > mesa-dev mailing list
>> > > mesa-dev@lists.freedesktop.org
>> > > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>> >
>> >
>> > Latest master doesn't build with GCC 4.1.
>> >
>> > glsl/ir_uniform.h:45: error: use of enum ???gl_uniform_driver_format???
>> > without previous declaration
>>
>> My reasoning for using 4.1 seems to be flawed as RHEL 5 comes with
>> autoconf 2.59 by default and current Mesa requires 2.60. Maybe bumping
>> GCC to 4.2 would be better. I assume the above issue doesn't happen on
>> 4.2 since OpenBSD uses it?
>
> I don't see that error with master here.
>
> The problem seems to be the use of an attribute on the enum which going
> by https://gcc.gnu.org/gcc-4.2/changes.html is only supported after 4.2.0?

Indeed, and that code has been in place since June and no one has
complained as far as I can tell.

I'm okay with bumping the minimum to 4.2. We're already using
__attribute__((packed)) on enums in a number of places in the i965
driver.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [RFC 6/8] mesa: remove support for GCC older than 4.1.0

2014-12-17 Thread Jonathan Gray
On Thu, Dec 18, 2014 at 12:26:10AM +1100, Timothy Arceri wrote:
> On Tue, 2014-12-16 at 22:58 -0800, Vinson Lee wrote:
> > On Mon, Dec 15, 2014 at 6:23 PM, Jonathan Gray  wrote:
> > > On Sat, Dec 13, 2014 at 09:09:27PM +1100, Timothy Arceri wrote:
> > >> On Fri, 2014-12-12 at 07:01 -0600, kallisti5 wrote:
> > >> > On 2014-12-12 05:46, Timothy Arceri wrote:
> > >> > > Signed-off-by: Timothy Arceri 
> > >> > > ---
> > >> > >  src/mesa/main/compiler.h | 2 +-
> > >> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >> > >
> > >> > > diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h
> > >> > > index 34671dc..cdc843d 100644
> > >> > > --- a/src/mesa/main/compiler.h
> > >> > > +++ b/src/mesa/main/compiler.h
> > >> > > @@ -122,7 +122,7 @@ extern "C" {
> > >> > >   * inline a static function that we later use in an alias. - ajax
> > >> > >   */
> > >> > >  #ifndef PUBLIC
> > >> > > -#  if (defined(__GNUC__) && __GNUC__ >= 4) || (defined(__SUNPRO_C) 
> > >> > > &&
> > >> > > (__SUNPRO_C >= 0x590))
> > >> > > +#  if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >=
> > >> > > 0x590))
> > >> > >  #define PUBLIC __attribute__((visibility("default")))
> > >> > >  #define USED __attribute__((used))
> > >> > >  #  else
> > >> >
> > >> > Why not also drop the SUNPRO_C version check?
> > >> >
> > >> > #  if defined(__GNUC__) || defined(__SUNPRO_C)
> > >> >
> > >> > I downloaded SunStudio 12 (circa 2007) and __SUNPRO_C is set to 0x590.
> > >> > If we drop support for GCC 4.1 (2007), might as well drop older sun
> > >> > compilers.
> > >>
> > >>
> > >> The series is dropping support for GCC 4.0. 4.1 is shipped with Redhat
> > >> Enterprise Linux 5 which is still in support so I've set that as the
> > >> minimum version.
> > >
> > > It is worth pointing out OpenBSD ships a patched GCC 4.2.1 as the base
> > > compiler as that was the last GPLv2 licensed version.  Not relevant this
> > > time, perhaps it will be next time.
> > > ___
> > > mesa-dev mailing list
> > > mesa-dev@lists.freedesktop.org
> > > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> > 
> > 
> > Latest master doesn't build with GCC 4.1.
> > 
> > glsl/ir_uniform.h:45: error: use of enum ???gl_uniform_driver_format???
> > without previous declaration
> 
> My reasoning for using 4.1 seems to be flawed as RHEL 5 comes with
> autoconf 2.59 by default and current Mesa requires 2.60. Maybe bumping
> GCC to 4.2 would be better. I assume the above issue doesn't happen on
> 4.2 since OpenBSD uses it?

I don't see that error with master here.

The problem seems to be the use of an attribute on the enum which going
by https://gcc.gnu.org/gcc-4.2/changes.html is only supported after 4.2.0?
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 045/133] nir: Add a basic metadata management system

2014-12-17 Thread Matt Turner
On Wed, Dec 17, 2014 at 4:04 AM, Jason Ekstrand  wrote:
> On Tue, Dec 16, 2014 at 10:58 PM, Connor Abbott  wrote:
>> On Tue, Dec 16, 2014 at 1:04 AM, Jason Ekstrand 
>> wrote:
>> > +/**
>> > + * Various bits of metadata that can may be created or required by
>> > + * optimization and analysis passes
>> > + */
>> > +typedef enum {
>> > +   nir_metadata_none = 0x0,
>> > +   nir_metadata_block_index = 0x1,
>> > +   nir_metadata_dominance = 0x2,
>> > +} nir_metadata;
>>
>> Bikeshed: I'm a little concerned here about using an enum to represent
>> a bit flag. An enum is supposed to represent a value that can equal
>> one of several things, but this isn't what's going on here. I think
>> that more pedantic compilers like Clang (and perhaps GCC with
>> -Wpedantic) might even generate warnings, since things like:
>>
>> nir_metadata_block_index | nir_metadata_dominance
>>
>> are technically undefined as per the C spec because the resulting
>> value isn't an element of the enum IIRC (I'm too lazy to verify this,
>> though). So overall it seems pretty sketchy, and you don't get most of
>> the good things that come with enums like better type safety anyways
>> since you're masking together values like they're integers.
>
>
> In ANSI C, enums are just integers with the guarantee that it has enough
> bits to hold the biggest value.  You can OR them, add them, or even multiply
> if you wish.  I don't know that this is allowed in C++ and *maybe* it's
> changed in C99 or C11, but it is allowed in ANSI C.  Having them be enums
> also has the nice little benefit that they generate debug symbols and GDB is
> smart enough to look for bitfield combinations and show you
> "nir_metadata_block_index | nir_metadata_dominance" which is pretty nifty...

Just to confirm -- you are right.

C++ requires you to overload operators in order to use enums this
way... in the name of type-safety or something.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 10/41] main: Added entry point for glCreateTextures.

2014-12-17 Thread Fredrik Höglund
On Tuesday 16 December 2014, Laura Ekstrand wrote:
> ---
>  src/mapi/glapi/gen/ARB_direct_state_access.xml |   8 ++
>  src/mesa/main/texobj.c | 109 
> +++--
>  src/mesa/main/texobj.h |   2 +
>  3 files changed, 92 insertions(+), 27 deletions(-)
> 
> diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
> b/src/mapi/glapi/gen/ARB_direct_state_access.xml
> index fcec608..9f2eacb 100644
> --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
> +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
> @@ -7,5 +7,13 @@
> 
> 
>  
> +   
> +
> +   
> +  
> +  
> +  
> +   
> +
>  
>  
> diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
> index 6215fe3..26d07ee 100644
> --- a/src/mesa/main/texobj.c
> +++ b/src/mesa/main/texobj.c
> @@ -1100,38 +1100,23 @@ invalidate_tex_image_error_check(struct gl_context 
> *ctx, GLuint texture,
> return t;
>  }
>  
> -/*@}*/
> -
> -
> -/***/
> -/** \name API functions */
> -/*@{*/
> -
> -
> -/**
> - * Generate texture names.
> - *
> - * \param n number of texture names to be generated.
> - * \param textures an array in which will hold the generated texture names.
> - *
> - * \sa glGenTextures().
> - *
> - * Calls _mesa_HashFindFreeKeyBlock() to find a block of free texture
> - * IDs which are stored in \p textures.  Corresponding empty texture
> - * objects are also generated.
> - */ 
> -void GLAPIENTRY
> -_mesa_GenTextures( GLsizei n, GLuint *textures )
> +/* Helper function for glCreateTextures and glGenTextures. Need this because
> + * glCreateTextures should throw errors if target = 0. This is not exposed to
> + * the rest of Mesa to encourage Mesa internals to use nameless textures,
> + * which do not require expensive hash lookups. */
> +static void
> +create_textures( struct gl_context *ctx, GLenum target,
> +   GLsizei n, GLuint *textures, bool dsa )
>  {
> -   GET_CURRENT_CONTEXT(ctx);
> GLuint first;
> GLint i;
> +   const char *func = dsa ? "Create" : "Gen";
>  
> if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
> -  _mesa_debug(ctx, "glGenTextures %d\n", n);
> +  _mesa_debug(ctx, "gl%sTextures %d\n", func, n);
>  
> if (n < 0) {
> -  _mesa_error( ctx, GL_INVALID_VALUE, "glGenTextures" );
> +  _mesa_error( ctx, GL_INVALID_VALUE, "gl%sTextures", func );
>return;
> }
>  
> @@ -1148,15 +1133,28 @@ _mesa_GenTextures( GLsizei n, GLuint *textures )
> /* Allocate new, empty texture objects */
> for (i = 0; i < n; i++) {
>struct gl_texture_object *texObj;
> +  GLint targetIndex;
>GLuint name = first + i;
> -  GLenum target = 0;
>texObj = ctx->Driver.NewTextureObject(ctx, name, target);
>if (!texObj) {
>   mtx_unlock(&ctx->Shared->Mutex);
> - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTextures");
> + _mesa_error(ctx, GL_OUT_OF_MEMORY, "gl%sTextures", func);
>   return;
>}
>  
> +  /* Initialize the target index if target is non-zero. */
> +  if (target != 0)
> +  {
> + targetIndex = _mesa_tex_target_to_index(ctx, texObj->Target);
> + if (targetIndex < 0) { /* Bad Target */
> +mtx_unlock(&ctx->Shared->Mutex);
> +_mesa_error(ctx, GL_INVALID_ENUM, "gl%sTextures(target)", func);

I suggest including the value passed in the target parameter in the error
message.  The same goes for other error messages introduced this series.

> +return;
> + }
> + assert(targetIndex < NUM_TEXTURE_TARGETS);
> + texObj->TargetIndex = targetIndex;
> +  }
> +
>/* insert into hash table */
>_mesa_HashInsert(ctx->Shared->TexObjects, texObj->Name, texObj);
>  
> @@ -1166,6 +1164,63 @@ _mesa_GenTextures( GLsizei n, GLuint *textures )
> mtx_unlock(&ctx->Shared->Mutex);
>  }
>  
> +/*@}*/
> +
> +
> +/***/
> +/** \name API functions */
> +/*@{*/
> +
> +
> +/**
> + * Generate texture names.
> + *
> + * \param n number of texture names to be generated.
> + * \param textures an array in which will hold the generated texture names.
> + *
> + * \sa glGenTextures(), glCreateTextures().
> + *
> + * Calls _mesa_HashFindFreeKeyBlock() to find a block of free texture
> + * IDs which are stored in \p textures.  Corresponding empty texture
> + * objects are also generated.
> + */ 
> +void GLAPIENTRY
> +_mesa_GenTextures( GLsizei n, GLuint *textures )
> +{
> +   GET_CURRENT_CONTEXT(ctx);
> +   create_textures(ctx, 0, n, textures, false);
> +}
> +
> +/**
> + * Create texture objects.
> + *
> + * \param target the texture target for each name to be generated.
> + * \param n number of texture names to be generated.
> + * \param textures an array in which will hold the generated texture names.
> + *
> + * \sa glCreateTextures(), glGenTextures().
> + *

Re: [Mesa-dev] [PATCH v3] i965: Fix bitcast operations with negate (ceil)

2014-12-17 Thread Matt Turner
Reviewed-by: Matt Turner 

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


Re: [Mesa-dev] [RFC 6/8] mesa: remove support for GCC older than 4.1.0

2014-12-17 Thread Timothy Arceri
On Tue, 2014-12-16 at 22:58 -0800, Vinson Lee wrote:
> On Mon, Dec 15, 2014 at 6:23 PM, Jonathan Gray  wrote:
> > On Sat, Dec 13, 2014 at 09:09:27PM +1100, Timothy Arceri wrote:
> >> On Fri, 2014-12-12 at 07:01 -0600, kallisti5 wrote:
> >> > On 2014-12-12 05:46, Timothy Arceri wrote:
> >> > > Signed-off-by: Timothy Arceri 
> >> > > ---
> >> > >  src/mesa/main/compiler.h | 2 +-
> >> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> >> > >
> >> > > diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h
> >> > > index 34671dc..cdc843d 100644
> >> > > --- a/src/mesa/main/compiler.h
> >> > > +++ b/src/mesa/main/compiler.h
> >> > > @@ -122,7 +122,7 @@ extern "C" {
> >> > >   * inline a static function that we later use in an alias. - ajax
> >> > >   */
> >> > >  #ifndef PUBLIC
> >> > > -#  if (defined(__GNUC__) && __GNUC__ >= 4) || (defined(__SUNPRO_C) &&
> >> > > (__SUNPRO_C >= 0x590))
> >> > > +#  if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >=
> >> > > 0x590))
> >> > >  #define PUBLIC __attribute__((visibility("default")))
> >> > >  #define USED __attribute__((used))
> >> > >  #  else
> >> >
> >> > Why not also drop the SUNPRO_C version check?
> >> >
> >> > #  if defined(__GNUC__) || defined(__SUNPRO_C)
> >> >
> >> > I downloaded SunStudio 12 (circa 2007) and __SUNPRO_C is set to 0x590.
> >> > If we drop support for GCC 4.1 (2007), might as well drop older sun
> >> > compilers.
> >>
> >>
> >> The series is dropping support for GCC 4.0. 4.1 is shipped with Redhat
> >> Enterprise Linux 5 which is still in support so I've set that as the
> >> minimum version.
> >
> > It is worth pointing out OpenBSD ships a patched GCC 4.2.1 as the base
> > compiler as that was the last GPLv2 licensed version.  Not relevant this
> > time, perhaps it will be next time.
> > ___
> > mesa-dev mailing list
> > mesa-dev@lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 
> 
> Latest master doesn't build with GCC 4.1.
> 
> glsl/ir_uniform.h:45: error: use of enum ‘gl_uniform_driver_format’
> without previous declaration

My reasoning for using 4.1 seems to be flawed as RHEL 5 comes with
autoconf 2.59 by default and current Mesa requires 2.60. Maybe bumping
GCC to 4.2 would be better. I assume the above issue doesn't happen on
4.2 since OpenBSD uses it?


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


[Mesa-dev] [PATCH v3] i965: Fix bitcast operations with negate (ceil)

2014-12-17 Thread Iago Toral Quiroga
Commit 0ae9ca12a8 put source modifiers out of the bitcast operations
by adding a MOV operation that would handle them separately. It missed
the case of ceil though: the implementation negates both its source and
destination operands. The source operand will be used for RNDD, which
we can handle normally, but we need to fix the modifier for the
negated result.

v2:
  - RNDD can handle the source modifier so no need to put that one
in a separate MOV.

Fixes the following 42 dEQP tests:
dEQP-GLES3.functional.shaders.builtin_functions.common.ceil.*_vertex
dEQP-GLES3.functional.shaders.builtin_functions.common.ceil.*_fragment
dEQP-GLES3.functional.shaders.builtin_functions.precision.ceil._*vertex.*
dEQP-GLES3.functional.shaders.builtin_functions.precision.ceil._*fragment.*
---
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp   | 11 +++
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 11 +++
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index b4f8f37..aeea2bf 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -889,10 +889,13 @@ fs_visitor::visit(ir_expression *ir)
case ir_unop_trunc:
   emit(RNDZ(this->result, op[0]));
   break;
-   case ir_unop_ceil:
-  op[0].negate = !op[0].negate;
-  emit(RNDD(this->result, op[0]));
-  this->result.negate = true;
+   case ir_unop_ceil: {
+ fs_reg tmp = fs_reg(this, ir->type);
+ op[0].negate = !op[0].negate;
+ emit(RNDD(tmp, op[0]));
+ tmp.negate = true;
+ emit(MOV(this->result, tmp));
+  }
   break;
case ir_unop_floor:
   emit(RNDD(this->result, op[0]));
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index 73fff75..d938523 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -1649,10 +1649,13 @@ vec4_visitor::visit(ir_expression *ir)
case ir_unop_trunc:
   emit(RNDZ(result_dst, op[0]));
   break;
-   case ir_unop_ceil:
-  op[0].negate = !op[0].negate;
-  inst = emit(RNDD(result_dst, op[0]));
-  this->result.negate = true;
+   case ir_unop_ceil: {
+ src_reg tmp = src_reg(this, ir->type);
+ op[0].negate = !op[0].negate;
+ emit(RNDD(dst_reg(tmp), op[0]));
+ tmp.negate = true;
+ emit(MOV(result_dst, tmp));
+  }
   break;
case ir_unop_floor:
   inst = emit(RNDD(result_dst, op[0]));
-- 
1.9.1

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


Re: [Mesa-dev] [PATCH] i965: Fix bitcast operations with negate (ceil)

2014-12-17 Thread Iago Toral
On Wed, 2014-12-17 at 04:19 -0800, Jason Ekstrand wrote:
> On Wed, Dec 17, 2014 at 1:24 AM, Iago Toral Quiroga
>  wrote:
> Commit 0ae9ca12a8 put source modifiers out of the bitcast
> operations
> by adding a MOV operation that would handle them separately.
> It missed
> the case of ceil though, which negates both its source and
> destination
> operands.
> 
> Fixes the following 42 dEQP tests:
> dEQP-GLES3.functional.shaders.builtin_functions.common.ceil.*_vertex
> dEQP-GLES3.functional.shaders.builtin_functions.common.ceil.*_fragment
> 
> dEQP-GLES3.functional.shaders.builtin_functions.precision.ceil._*vertex.*
> 
> dEQP-GLES3.functional.shaders.builtin_functions.precision.ceil._*fragment.*
> ---
>  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp   | 12
> 
>  src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 12
> 
>  2 files changed, 16 insertions(+), 8 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> index b4f8f37..4526b75 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> @@ -889,10 +889,14 @@ fs_visitor::visit(ir_expression *ir)
> case ir_unop_trunc:
>emit(RNDZ(this->result, op[0]));
>break;
> -   case ir_unop_ceil:
> -  op[0].negate = !op[0].negate;
> -  emit(RNDD(this->result, op[0]));
> -  this->result.negate = true;
> +   case ir_unop_ceil: {
> + fs_reg tmp = fs_reg(this, ir->type);
> + op[0].negate = !op[0].negate;
> + emit(MOV(tmp, op[0]));
> 
> 
> Do we really need this first mov?  I don't think we do as we can just
> use a source modifier on RNDD.  It won't affect the quality of the
> final code because copy propagation should clean it up, but more
> direct codegen is nicer.

Yes, you are right. I'll remove it and send a new patch.
Thanks!

>  
> + emit(RNDD(tmp, tmp));
> + tmp.negate = true;
> + emit(MOV(this->result, tmp));
> +  }
>break;
> case ir_unop_floor:
>emit(RNDD(this->result, op[0]));
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
> b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
> index 73fff75..7c4a3e1 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
> @@ -1649,10 +1649,14 @@ vec4_visitor::visit(ir_expression *ir)
> case ir_unop_trunc:
>emit(RNDZ(result_dst, op[0]));
>break;
> -   case ir_unop_ceil:
> -  op[0].negate = !op[0].negate;
> -  inst = emit(RNDD(result_dst, op[0]));
> -  this->result.negate = true;
> +   case ir_unop_ceil: {
> + src_reg tmp = src_reg(this, ir->type);
> + op[0].negate = !op[0].negate;
> + emit(MOV(dst_reg(tmp), op[0]));
> + emit(RNDD(dst_reg(tmp), tmp));
> + tmp.negate = true;
> + emit(MOV(result_dst, tmp));
> +  }
>break;
> case ir_unop_floor:
>inst = emit(RNDD(result_dst, op[0]));
> --
> 1.9.1
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


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


Re: [Mesa-dev] [PATCH v3 09/28] mesa: Add RGBA to Luminance conversion helpers

2014-12-17 Thread Iago Toral
On Wed, 2014-12-17 at 03:51 -0800, Jason Ekstrand wrote:
> 
> 
> 
> 
> 
> On Tue, Dec 16, 2014 at 11:37 PM, Iago Toral 
> wrote:
> On Tue, 2014-12-16 at 10:54 -0800, Jason Ekstrand wrote:
> >
> >
> > On Tue, Dec 16, 2014 at 4:01 AM, Iago Toral
>  wrote:
> > On Tue, 2014-12-16 at 08:29 +0100, Iago Toral wrote:
> > > On Mon, 2014-12-15 at 10:19 -0800, Jason Ekstrand
> wrote:
> > > >
> > > >
> > > > On Mon, Dec 15, 2014 at 3:12 AM, Iago Toral
> >  wrote:
> > > > On Fri, 2014-12-12 at 11:36 -0800, Jason
> Ekstrand
> > wrote:
> > > > >
> > > > >
> > > > > On Tue, Dec 9, 2014 at 4:07 AM, Iago
> Toral
> > Quiroga
> > > > 
> > > > > wrote:
> > > > > For glReadPixels with a
> Luminance
> > destination format
> > > > we
> > > > > compute luminance
> > > > > values from RGBA as L=R+G+B.
> This,
> > however, requires
> > > > ad-hoc
> > > > > implementation,
> > > > > since pack/unpack functions or
> > > > _mesa_swizzle_and_convert won't
> > > > > do this
> > > > > (and thus, neither will
> > _mesa_format_convert). This
> > > > patch adds
> > > > > helpers
> > > > > to do this computation so they
> can be
> > used to
> > > > support
> > > > > conversion to luminance
> > > > > formats.
> > > > >
> > > > > The current implementation of
> > glReadPixels does this
> > > > > computation as part
> > > > > of the span functions in
> pack.c (see
> > > > > _mesa_pack_rgba_span_float),
> that do
> > > > > this together with other
> things like
> > type
> > > > conversion, etc. We
> > > > > do not want
> > > > > to use these functions but use
> > _mesa_format_convert
> > > > instead
> > > > > (later patches
> > > > > will remove the color span
> functions),
> > so we need to
> > > > extract
> > > > > this functionality
> > > > > as helpers.
> > > > > ---
> > > > >  src/mesa/main/pack.c | 63
> > > > >
> >
> 
> > > > >  src/mesa/main/pack.h |  9
> 
> > > > >  2 files changed, 72
> insertions(+)
> > > > >
> > > > > diff --git
> a/src/mesa/main/pack.c
> > > > b/src/mesa/main/pack.c
> > > > > index de6ab27..fa4046c 100644
> > > > > --- a/src/mesa/main/pack.c
> > > > > +++ b/src/mesa/main/pack.c
> > > > > @@ -4334,4 +4334,67 @@
> > _mesa_rebase_rgba_uint(GLuint
> > > > n, GLuint
> > > > > rgba[][4], GLenum baseFormat)
> > > > > }
> > > > >  }
> > > > >
> > > > > +void
> > > > >
> >  +_mesa_pack_luminance_from_rgba_float(GLuint n,
> > > > GLfloat
> > > > > rgba[][4],
> > > > > +
> >  GLvoid
> > > > *dstAddr, GLenum
> > > > > dst_format,
> > > > > +
> >  GLbitfield
> > > > transferOps)
> > > > > +{
> > > > > +   int i;
> > > > > 

Re: [Mesa-dev] [PATCH 03/41] i965: intel_tex_image.c now accepts TEXTURE_CUBE_MAP as a valid target.

2014-12-17 Thread Anuj Phogat
How about using below subject?
i965: intel_get_tex_image() now accepts TEXTURE_CUBE_MAP as a valid target

It's more specific than using a file name. I'll leave it up to you if
you want to make this change.

On Tue, Dec 16, 2014 at 6:52 AM, Laura Ekstrand  wrote:
> ARB_DIRECT_STATE_ACCESS permits the user to use TEXTURE_CUBE_MAP as a target.
> ---
>  src/mesa/drivers/dri/i965/intel_tex_image.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c 
> b/src/mesa/drivers/dri/i965/intel_tex_image.c
> index 3317779..855a6b4 100644
> --- a/src/mesa/drivers/dri/i965/intel_tex_image.c
> +++ b/src/mesa/drivers/dri/i965/intel_tex_image.c
> @@ -459,6 +459,7 @@ blit_texture_to_pbo(struct gl_context *ctx,
>
> if (target == GL_TEXTURE_1D_ARRAY ||
> target == GL_TEXTURE_2D_ARRAY ||
> +   target == GL_TEXTURE_CUBE_MAP ||
> target == GL_TEXTURE_CUBE_MAP_ARRAY ||
> target == GL_TEXTURE_3D) {
>perf_debug("%s: no support for multiple slices, fallback to CPU 
> mapping "
> --
> 2.1.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] i965: Fix bitcast operations with negate (ceil)

2014-12-17 Thread Jason Ekstrand
On Wed, Dec 17, 2014 at 1:24 AM, Iago Toral Quiroga 
wrote:
>
> Commit 0ae9ca12a8 put source modifiers out of the bitcast operations
> by adding a MOV operation that would handle them separately. It missed
> the case of ceil though, which negates both its source and destination
> operands.
>
> Fixes the following 42 dEQP tests:
> dEQP-GLES3.functional.shaders.builtin_functions.common.ceil.*_vertex
> dEQP-GLES3.functional.shaders.builtin_functions.common.ceil.*_fragment
> dEQP-GLES3.functional.shaders.builtin_functions.precision.ceil._*vertex.*
> dEQP-GLES3.functional.shaders.builtin_functions.precision.ceil._*fragment.*
> ---
>  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp   | 12 
>  src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 12 
>  2 files changed, 16 insertions(+), 8 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> index b4f8f37..4526b75 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
> @@ -889,10 +889,14 @@ fs_visitor::visit(ir_expression *ir)
> case ir_unop_trunc:
>emit(RNDZ(this->result, op[0]));
>break;
> -   case ir_unop_ceil:
> -  op[0].negate = !op[0].negate;
> -  emit(RNDD(this->result, op[0]));
> -  this->result.negate = true;
> +   case ir_unop_ceil: {
> + fs_reg tmp = fs_reg(this, ir->type);
> + op[0].negate = !op[0].negate;
> + emit(MOV(tmp, op[0]));
>

Do we really need this first mov?  I don't think we do as we can just use a
source modifier on RNDD.  It won't affect the quality of the final code
because copy propagation should clean it up, but more direct codegen is
nicer.


> + emit(RNDD(tmp, tmp));
> + tmp.negate = true;
> + emit(MOV(this->result, tmp));
> +  }
>break;
> case ir_unop_floor:
>emit(RNDD(this->result, op[0]));
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
> b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
> index 73fff75..7c4a3e1 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
> @@ -1649,10 +1649,14 @@ vec4_visitor::visit(ir_expression *ir)
> case ir_unop_trunc:
>emit(RNDZ(result_dst, op[0]));
>break;
> -   case ir_unop_ceil:
> -  op[0].negate = !op[0].negate;
> -  inst = emit(RNDD(result_dst, op[0]));
> -  this->result.negate = true;
> +   case ir_unop_ceil: {
> + src_reg tmp = src_reg(this, ir->type);
> + op[0].negate = !op[0].negate;
> + emit(MOV(dst_reg(tmp), op[0]));
> + emit(RNDD(dst_reg(tmp), tmp));
> + tmp.negate = true;
> + emit(MOV(result_dst, tmp));
> +  }
>break;
> case ir_unop_floor:
>inst = emit(RNDD(result_dst, op[0]));
> --
> 1.9.1
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 045/133] nir: Add a basic metadata management system

2014-12-17 Thread Jason Ekstrand
On Tue, Dec 16, 2014 at 10:58 PM, Connor Abbott  wrote:
>
> On Tue, Dec 16, 2014 at 1:04 AM, Jason Ekstrand 
> wrote:
> > ---
> >  src/glsl/Makefile.sources|  1 +
> >  src/glsl/nir/nir.c   | 19 +++-
> >  src/glsl/nir/nir.h   | 21 --
> >  src/glsl/nir/nir_dominance.c |  6 ++---
> >  src/glsl/nir/nir_metadata.c  | 52
> 
> >  5 files changed, 82 insertions(+), 17 deletions(-)
> >  create mode 100644 src/glsl/nir/nir_metadata.c
> >
> > diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
> > index d3b17bd..4eb6320 100644
> > --- a/src/glsl/Makefile.sources
> > +++ b/src/glsl/Makefile.sources
> > @@ -25,6 +25,7 @@ NIR_FILES = \
> > $(GLSL_SRCDIR)/nir/nir_lower_system_values.c \
> > $(GLSL_SRCDIR)/nir/nir_lower_variables_scalar.c \
> > $(GLSL_SRCDIR)/nir/nir_lower_vec_to_movs.c \
> > +   $(GLSL_SRCDIR)/nir/nir_metadata.c \
> > $(GLSL_SRCDIR)/nir/nir_opcodes.c \
> > $(GLSL_SRCDIR)/nir/nir_opcodes.h \
> > $(GLSL_SRCDIR)/nir/nir_opt_copy_propagate.c \
> > diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
> > index 3dd9e5a..0124799 100644
> > --- a/src/glsl/nir/nir.c
> > +++ b/src/glsl/nir/nir.c
> > @@ -106,6 +106,7 @@ nir_function_create(nir_shader *shader, const char
> *name)
> > exec_list_push_tail(&shader->functions, &func->node);
> > exec_list_make_empty(&func->overload_list);
> > func->name = name;
> > +   func->shader = shader;
> >
> > return func;
> >  }
> > @@ -243,8 +244,7 @@ nir_function_impl_create(nir_function_overload
> *overload)
> > impl->return_var = NULL;
> > impl->reg_alloc = 0;
> > impl->ssa_alloc = 0;
> > -   impl->block_index_dirty = true;
> > -   impl->dominance_dirty = true;
> > +   impl->valid_metadata = nir_metadata_none;
> >
> > /* create start & end blocks */
> > nir_block *start_block = nir_block_create(mem_ctx);
> > @@ -815,7 +815,7 @@ handle_jump(nir_block *block)
> > unlink_block_successors(block);
> >
> > nir_function_impl *impl = nir_cf_node_get_function(&block->cf_node);
> > -   impl->dominance_dirty = true;
> > +   nir_metadata_dirty(impl, nir_metadata_none);
> >
> > if (jump_instr->type == nir_jump_break ||
> > jump_instr->type == nir_jump_continue) {
> > @@ -912,7 +912,7 @@ handle_remove_jump(nir_block *block, nir_jump_type
> type)
> > }
> >
> > nir_function_impl *impl = nir_cf_node_get_function(&block->cf_node);
> > -   impl->dominance_dirty = true;
> > +   nir_metadata_dirty(impl, nir_metadata_none);
> >  }
> >
> >  /**
> > @@ -1019,8 +1019,7 @@ nir_cf_node_insert_after(nir_cf_node *node,
> nir_cf_node *after)
> > }
> >
> > nir_function_impl *impl = nir_cf_node_get_function(node);
> > -   impl->block_index_dirty = true;
> > -   impl->dominance_dirty = true;
> > +   nir_metadata_dirty(impl, nir_metadata_none);
> >  }
> >
> >  void
> > @@ -1062,8 +1061,7 @@ nir_cf_node_insert_before(nir_cf_node *node,
> nir_cf_node *before)
> > }
> >
> > nir_function_impl *impl = nir_cf_node_get_function(node);
> > -   impl->block_index_dirty = true;
> > -   impl->dominance_dirty = true;
> > +   nir_metadata_dirty(impl, nir_metadata_none);
> >  }
> >
> >  void
> > @@ -1109,7 +1107,7 @@ void
> >  nir_cf_node_remove(nir_cf_node *node)
> >  {
> > nir_function_impl *impl = nir_cf_node_get_function(node);
> > -   impl->block_index_dirty = true;
> > +   nir_metadata_dirty(impl, nir_metadata_none);
> >
> > if (node->type == nir_cf_node_block) {
> >/*
> > @@ -1673,13 +1671,12 @@ nir_index_blocks(nir_function_impl *impl)
> >  {
> > unsigned index = 0;
> >
> > -   if (!impl->block_index_dirty)
> > +   if (impl->valid_metadata & nir_metadata_block_index)
> >return;
> >
> > nir_foreach_block(impl, index_block, &index);
> >
> > impl->num_blocks = index;
> > -   impl->block_index_dirty = false;
> >  }
> >
> >  static void
> > diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> > index c9146c0..8d5f6b8 100644
> > --- a/src/glsl/nir/nir.h
> > +++ b/src/glsl/nir/nir.h
> > @@ -33,6 +33,7 @@
> >  #include "GL/gl.h" /* GLenum */
> >  #include "util/ralloc.h"
> >  #include "main/mtypes.h"
> > +#include "main/bitset.h"
> >  #include "nir_types.h"
> >  #include 
> >
> > @@ -45,6 +46,7 @@ extern "C" {
> >
> >  struct nir_function_overload;
> >  struct nir_function;
> > +struct nir_shader;
> >
> >
> >  /**
> > @@ -1037,6 +1039,16 @@ typedef struct {
> >  #define nir_loop_last_cf_node(loop) \
> > exec_node_data(nir_cf_node, exec_list_get_tail(&(loop)->body), node)
> >
> > +/**
> > + * Various bits of metadata that can may be created or required by
> > + * optimization and analysis passes
> > + */
> > +typedef enum {
> > +   nir_metadata_none = 0x0,
> > +   nir_metadata_block_index = 0x1,
> > +   nir_metadata_dominance = 0x2,
> > +} nir_metadata;
>
> Bikeshed: I'm a little concerned here about using an enum to represent
> a bit flag. An enum i

Re: [Mesa-dev] [PATCH 031/133] nir: Add fine and coarse derivative opcodes

2014-12-17 Thread Jason Ekstrand
On Tue, Dec 16, 2014 at 10:31 PM, Connor Abbott  wrote:
>
> As a future cleanup, would it be worth getting rid of fddx and fddy
> entirely and just generating the correct variant based on the
> glHint/drirc configuration?
>

Nope.  https://www.opengl.org/registry/specs/ARB/derivative_control.txt


>
> On Tue, Dec 16, 2014 at 1:04 AM, Jason Ekstrand 
> wrote:
> > ---
> >  src/glsl/nir/nir_opcodes.h | 4 
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/src/glsl/nir/nir_opcodes.h b/src/glsl/nir/nir_opcodes.h
> > index bee4bd1..9a7a2ab 100644
> > --- a/src/glsl/nir/nir_opcodes.h
> > +++ b/src/glsl/nir/nir_opcodes.h
> > @@ -111,6 +111,10 @@ UNOP(fcos_reduced, nir_type_float)
> >  /*@{*/
> >  UNOP(fddx, nir_type_float)
> >  UNOP(fddy, nir_type_float)
> > +UNOP(fddx_fine, nir_type_float)
> > +UNOP(fddy_fine, nir_type_float)
> > +UNOP(fddx_coarse, nir_type_float)
> > +UNOP(fddy_coarse, nir_type_float)
> >  /*@}*/
> >
> >  /**
> > --
> > 2.2.0
> >
> > ___
> > mesa-dev mailing list
> > mesa-dev@lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v3 09/28] mesa: Add RGBA to Luminance conversion helpers

2014-12-17 Thread Jason Ekstrand
On Tue, Dec 16, 2014 at 11:37 PM, Iago Toral  wrote:
>
> On Tue, 2014-12-16 at 10:54 -0800, Jason Ekstrand wrote:
> >
> >
> > On Tue, Dec 16, 2014 at 4:01 AM, Iago Toral  wrote:
> > On Tue, 2014-12-16 at 08:29 +0100, Iago Toral wrote:
> > > On Mon, 2014-12-15 at 10:19 -0800, Jason Ekstrand wrote:
> > > >
> > > >
> > > > On Mon, Dec 15, 2014 at 3:12 AM, Iago Toral
> >  wrote:
> > > > On Fri, 2014-12-12 at 11:36 -0800, Jason Ekstrand
> > wrote:
> > > > >
> > > > >
> > > > > On Tue, Dec 9, 2014 at 4:07 AM, Iago Toral
> > Quiroga
> > > > 
> > > > > wrote:
> > > > > For glReadPixels with a Luminance
> > destination format
> > > > we
> > > > > compute luminance
> > > > > values from RGBA as L=R+G+B. This,
> > however, requires
> > > > ad-hoc
> > > > > implementation,
> > > > > since pack/unpack functions or
> > > > _mesa_swizzle_and_convert won't
> > > > > do this
> > > > > (and thus, neither will
> > _mesa_format_convert). This
> > > > patch adds
> > > > > helpers
> > > > > to do this computation so they can be
> > used to
> > > > support
> > > > > conversion to luminance
> > > > > formats.
> > > > >
> > > > > The current implementation of
> > glReadPixels does this
> > > > > computation as part
> > > > > of the span functions in pack.c (see
> > > > > _mesa_pack_rgba_span_float), that do
> > > > > this together with other things like
> > type
> > > > conversion, etc. We
> > > > > do not want
> > > > > to use these functions but use
> > _mesa_format_convert
> > > > instead
> > > > > (later patches
> > > > > will remove the color span functions),
> > so we need to
> > > > extract
> > > > > this functionality
> > > > > as helpers.
> > > > > ---
> > > > >  src/mesa/main/pack.c | 63
> > > > >
> >  
> > > > >  src/mesa/main/pack.h |  9 
> > > > >  2 files changed, 72 insertions(+)
> > > > >
> > > > > diff --git a/src/mesa/main/pack.c
> > > > b/src/mesa/main/pack.c
> > > > > index de6ab27..fa4046c 100644
> > > > > --- a/src/mesa/main/pack.c
> > > > > +++ b/src/mesa/main/pack.c
> > > > > @@ -4334,4 +4334,67 @@
> > _mesa_rebase_rgba_uint(GLuint
> > > > n, GLuint
> > > > > rgba[][4], GLenum baseFormat)
> > > > > }
> > > > >  }
> > > > >
> > > > > +void
> > > > >
> >  +_mesa_pack_luminance_from_rgba_float(GLuint n,
> > > > GLfloat
> > > > > rgba[][4],
> > > > > +
> >  GLvoid
> > > > *dstAddr, GLenum
> > > > > dst_format,
> > > > > +
> >  GLbitfield
> > > > transferOps)
> > > > > +{
> > > > > +   int i;
> > > > > +   GLfloat *dst = (GLfloat *) dstAddr;
> > > > > +
> > > > > +   switch (dst_format) {
> > > > > +   case GL_LUMINANCE:
> > > > > +  if (transferOps &
> > IMAGE_CLAMP_BIT) {
> > > > > + for (i = 0; i < n; i++) {
> > > > > +GLfloat sum =
> > rgba[i][RCOMP] +
> > > > rgba[i][GCOMP] +
> > > > > rgba[i][BCOMP];
> > > > > +dst[i] = CLAMP(sum, 0.0F,
> > 1.0F);
> > > > > + }
> > > > > +  } else {
> > > > > + for (i = 0; i < n; i++) {
> > > > > +dst[i] = rgba[i][RCOMP] +
> > > > rgba[i][GCOMP] +
> > > > >

Re: [Mesa-dev] [PATCH 02/41] main: Created a standard function that looks up a texture object by its ID and throws INVALID_OPERATION if the ID isn't in the hash table.

2014-12-17 Thread Anuj Phogat
Keep the subject of commit message short (under 50 chars) and use present tense.
Here you can use "mesa: Add utility function _mesa_lookup_texture_error()".

On Tue, Dec 16, 2014 at 6:52 AM, Laura Ekstrand  wrote:
> Most ARB_DIRECT_STATE_ACCESS functions take an object's ID and use it to look
> up the object in its hash table.  If the user passes a fake object ID (ie. a
> non-generated name), the implementation should throw INVALID_OPERATION.
> This is a convenience function for texture objects.
> ---
>  src/mesa/main/texobj.c | 17 -
>  src/mesa/main/texobj.h |  3 +++
>  2 files changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
> index 923cf60..49ab2c4 100644
> --- a/src/mesa/main/texobj.c
> +++ b/src/mesa/main/texobj.c
> @@ -60,6 +60,22 @@ _mesa_lookup_texture(struct gl_context *ctx, GLuint id)
>_mesa_HashLookup(ctx->Shared->TexObjects, id);
>  }
>
> +/**
> + * Wrapper around _mesa_lookup_texture that throws GL_INVALID_OPERATION if id
> + * is not in the hash table. After calling _mesa_error, it returns NULL.
> + */
> +struct gl_texture_object *
> +_mesa_lookup_texture_err(struct gl_context *ctx, GLuint id, const char* func)
I would use the name _mesa_lookup_texture_error() here.
> +{
> +   struct gl_texture_object *texObj;
> +
> +   texObj = _mesa_lookup_texture(ctx, id); /* Returns NULL if not found. */
> +
> +   if (!texObj)
> +  _mesa_error(ctx, GL_INVALID_OPERATION, "%s(texture)", func);
> +
> +   return texObj;
> +}
>
>  void
>  _mesa_begin_texture_lookups(struct gl_context *ctx)
> @@ -1419,7 +1435,6 @@ _mesa_BindTexture( GLenum target, GLuint texName )
>ctx->Driver.BindTexture(ctx, ctx->Texture.CurrentUnit, target, 
> newTexObj);
>  }
>
> -
unwanted change.
>  void GLAPIENTRY
>  _mesa_BindTextures(GLuint first, GLsizei count, const GLuint *textures)
>  {
> diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h
> index b1b7a30..abf03a1 100644
> --- a/src/mesa/main/texobj.h
> +++ b/src/mesa/main/texobj.h
> @@ -46,6 +46,9 @@
>  extern struct gl_texture_object *
>  _mesa_lookup_texture(struct gl_context *ctx, GLuint id);
>
> +extern struct gl_texture_object *
> +_mesa_lookup_texture_err(struct gl_context *ctx, GLuint id, const char* 
> func);
> +
>  extern void
>  _mesa_begin_texture_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 mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 3/3] glx/dri3: Request non-vsynced Present for swapinterval zero.

2014-12-17 Thread Eero Tamminen

Hi,

On 12/16/2014 08:30 PM, Mario Kleiner wrote:

On 12/16/2014 09:23 AM, Keith Packard wrote:

Mario Kleiner  writes:


The 0 case is good for benchmarking.

Sure, but the current code does benchmarking just fine. In fact, because
it doesn't copy queued frames that aren't the most recent before the
vblank, benchmarks tend to run *faster* as a result, and people
generally like that aspect of it...



Hmm. For benchmarking i think i'd consider that a mild form of cheating.
You get higher fps because you skip processing like the whole gpu blit
overhead and host processing overhead for queuing / validating /
processing the copy command in the command stream, so the benchmark
numbers don't translate very well anymore in how the system would behave
in a non-benchmark situation?mesa-dev


From performance numbers on Windows it's clear that Windows doesn't
copy frames that happen faster than monitor update frequency.

This isn't cheating.  It makes numbers more relevant as it minimizes
Windowing system impact/distortion on application rendering performance.

The problem with Windowing system doing extra copies is that it doesn't
affect all applications equally.  If application is memory bandwidth
limited, the windowing system impact is directly proportional to FPS.
If application isn't memory bandwidth limited, it has no impact.  And
whether application is memory bandwidth limited, is HW dependent, which
distorts also HW comparisons.


- Eero


... but read on below ...


In my specific case i always want vsync'ed swap for actual visual
stimulation in neuroscience/medical settings, with no frame skipped
ever. The bonus use for me, except for benchmarking how fast the system
can go, is if one has a multi-display setup, e.g., dual-display for
stereoscopic stimulation - one display per eye, or some CAVE like setup
for VR with more than 2 displays. You want display updates and scanout
on all of them synchronized, so the scene stays coherent. One simple way
for visually testing multi-display sync is to intentionally swap all of
them without vsync, e.g., timed to swap in the middle of the scanout. If
the tear-lines on all displays are roughly at the same vertical position
and stay there then that's a good visual test if stuff works. There are
other ways to do it, but this is the one method that seems to work
cross-platform, without lots of mental context switching depending on
what os/gpu/server/driver combo with what settings one uses, and much
more easy to grasp for scientists with no graphics background. You can
see at a glance if stuff is roughly correct or not.

It seems like you want something that the GL API doesn't express
precisely; my reading of the  GL spec definitely lets Present work the
way it does today, and as you avoid tearing *and* improve performance in
the vblank_mode=0 case, I'm very reluctant to change it.


 From GLX_EXT_swap_control and MESA_swap_control:

"If  is set to a value of 0, buffer swaps are not
 synchronized to a video frame."


It depends on how you interpret the "not synchronized to a video frame"?
Can you explain your interpretation?

I don't think the spec says anywhere that dropping old "not most recent
at vblank time" frames is allowed, like Present does atm.? And the
current Present implementation does synchronize the "buffer swap" of its
most recent received Pixmap to the [onset of] a video frame, so while
preventing tearing it goes a bit slower than it could go without vsync.

Every past/other implementation than DRI3/Present that i have experience
with interpreted the spec the way that patch tries to restore, at least
everything i know of from OSX/Windows/Linux proprietary/DRI2, so my
interpretation is certainly a valid interpretation, and it is the one
that provides consistency and therefore the least surprise to
implementers of GL clients and end users.


Present could trivially offer a new bit to force tearing; I'm not sure
how you'd get at that from GL though.



It does already with PresentOptionAsync? It just needs to be used in
accordance with the mainstream interpretation of the _swap_control spec,
like this patch suggests.

I'm not trying to claim here that the current behaviour of Mesa+Present
isn't useful for some types of applications like games. I'm just saying
it shouldn't be the default behaviour for swapinterval 0 or > 0. As far
as i understand the meaning, intention and origin of the
EXT_swap_control_tear extension, the current Present implementation
would implement a useful approximation of EXT_swap_control_tear for a
swapinterval of < 0. Not an exact implementation, but at least following
the spirit of that extension.

So i'm arguing for restoring the default behaviour any other
implementation has with that patch, but providing the current behaviour
via sync_control_tear? Or maybe even some new sync_control_tear2 to
cover the difference between the current method and sync_control_tear.

When we are at the topic, i can also send you my christm

[Mesa-dev] [Bug 87407] glReadPixels not working when the RGBA component is of the type dFdy(abs())

2014-12-17 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=87407

Andrés Gómez García  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 CC||ago...@igalia.com,
   ||i...@freedesktop.org,
   ||matts...@gmail.com
   Assignee|mesa-dev@lists.freedesktop. |ago...@igalia.com
   |org |

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


  1   2   >