Re: [Mesa-dev] [PATCH 09/17] i965: Use a const nir_shader in backend_shader

2015-10-08 Thread Pohjolainen, Topi
On Thu, Oct 08, 2015 at 05:22:41PM -0700, Jason Ekstrand wrote:
> ---
>  src/mesa/drivers/dri/i965/brw_fs.h| 2 +-
>  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp  | 2 +-
>  src/mesa/drivers/dri/i965/brw_shader.cpp  | 2 +-
>  src/mesa/drivers/dri/i965/brw_shader.h| 4 ++--
>  src/mesa/drivers/dri/i965/brw_vec4.h  | 2 +-
>  src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp | 2 +-
>  src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h   | 2 +-
>  src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp| 2 +-
>  src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp | 2 +-
>  src/mesa/drivers/dri/i965/brw_vs.h| 2 +-
>  src/mesa/drivers/dri/i965/gen6_gs_visitor.h   | 2 +-
>  11 files changed, 12 insertions(+), 12 deletions(-)

Patches 7-9:

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


Re: [Mesa-dev] [PATCH 02/17] nir: Add a label to nir_shader_info

2015-10-08 Thread Pohjolainen, Topi
On Thu, Oct 08, 2015 at 05:22:34PM -0700, Jason Ekstrand wrote:
> ---
>  src/glsl/nir/glsl_to_nir.cpp | 2 ++
>  src/glsl/nir/nir.h   | 3 +++
>  src/glsl/nir/nir_sweep.c | 2 ++
>  3 files changed, 7 insertions(+)

This is needed in patch 8 and is:

Reviewed-by: Topi Pohjolainen 

> 
> diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp
> index efaa73e..cdae2d1 100644
> --- a/src/glsl/nir/glsl_to_nir.cpp
> +++ b/src/glsl/nir/glsl_to_nir.cpp
> @@ -151,6 +151,8 @@ glsl_to_nir(const struct gl_shader_program *shader_prog,
>   num_textures = i;
>  
> shader->info.name = ralloc_asprintf(shader, "GLSL%d", sh->Name);
> +   if (shader_prog->Label)
> +  shader->info.label = ralloc_strdup(shader, shader_prog->Label);
> shader->info.num_textures = num_textures;
> shader->info.num_ubos = sh->NumUniformBlocks;
> shader->info.num_abos = shader_prog->NumAtomicBuffers;
> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
> index bde9f49..b9f549b 100644
> --- a/src/glsl/nir/nir.h
> +++ b/src/glsl/nir/nir.h
> @@ -1460,6 +1460,9 @@ typedef struct nir_shader_compiler_options {
>  typedef struct nir_shader_info {
> const char *name;
>  
> +   /* Descriptive name provided by the client; may be NULL */
> +   const char *label;
> +
> /* Number of textures used by this shader */
> unsigned num_textures;
> /* Number of uniform buffers used by this shader */
> diff --git a/src/glsl/nir/nir_sweep.c b/src/glsl/nir/nir_sweep.c
> index b6ce43b..5a22f50 100644
> --- a/src/glsl/nir/nir_sweep.c
> +++ b/src/glsl/nir/nir_sweep.c
> @@ -155,6 +155,8 @@ nir_sweep(nir_shader *nir)
> ralloc_adopt(rubbish, nir);
>  
> ralloc_steal(nir, (char *)nir->info.name);
> +   if (nir->info.label)
> +  ralloc_steal(nir, (char *)nir->info.label);
>  
> /* Variables and registers are not dead.  Steal them back. */
> steal_list(nir, nir_variable, &nir->uniforms);
> -- 
> 2.5.0.400.gff86faf
> 
> ___
> 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 04/17] nir/info: Move the GS info into a stage-specific info union

2015-10-08 Thread Pohjolainen, Topi
On Thu, Oct 08, 2015 at 05:22:36PM -0700, Jason Ekstrand wrote:
> This way we can have other stage-specific info without consuming too much
> extra space.  While we're at it, we make sure that the geometry info is
> only set if we're actually a goemetry shader.
> ---
>  src/glsl/nir/glsl_to_nir.cpp | 12 ++--
>  src/glsl/nir/nir.h   | 14 --
>  2 files changed, 18 insertions(+), 8 deletions(-)

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


Re: [Mesa-dev] [PATCH 01/17] i965/asm: Explicitly use a nir_instr for IR annotations

2015-10-08 Thread Pohjolainen, Topi
On Thu, Oct 08, 2015 at 05:22:33PM -0700, Jason Ekstrand wrote:
> Now that everything goes through NIR, we don't need this to be a void
> pointer anymore.
> ---
>  src/mesa/drivers/dri/i965/brw_fs_generator.cpp   |  2 +-
>  src/mesa/drivers/dri/i965/brw_vec4_generator.cpp |  2 +-
>  src/mesa/drivers/dri/i965/intel_asm_annotation.c | 17 ++---
>  src/mesa/drivers/dri/i965/intel_asm_annotation.h |  3 +--
>  4 files changed, 5 insertions(+), 19 deletions(-)

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


[Mesa-dev] [PATCH] i965: Do not dereference NULL brw_shader pointer when debugging

2015-10-08 Thread Iago Toral Quiroga
For the VS and FS stages that use ARB_vertex_program or
ARB_fragment_program we don't have a shader program, however,
when debuging is enabled, we call brw_dump_ir like this:

brw_dump_ir("vertex", prog, &vs->base, &vp->program.Base);

which unconditionally dereferences vs, producing a NULL pointer
dereference in the situation explained above, as observed in this
gdb session for glxgears right before we call brw_dump_ir:

prog=0x0, vp=0x960f50, key=0x7fffc940) at brw_vs.c:174

(gdb) p vs
$7 = (struct brw_shader *) 0x0
(gdb) p vp
$8 = (struct brw_vertex_program *) 0x960f50
---
 src/mesa/drivers/dri/i965/brw_vs.c | 2 +-
 src/mesa/drivers/dri/i965/brw_wm.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vs.c 
b/src/mesa/drivers/dri/i965/brw_vs.c
index 38de98f..60fb5fa 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -171,7 +171,7 @@ brw_codegen_vs_prog(struct brw_context *brw,
}
 
if (unlikely(INTEL_DEBUG & DEBUG_VS))
-  brw_dump_ir("vertex", prog, &vs->base, &vp->program.Base);
+  brw_dump_ir("vertex", prog, vs ? &vs->base : NULL, &vp->program.Base);
 
int st_index = -1;
if (INTEL_DEBUG & DEBUG_SHADER_TIME)
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c 
b/src/mesa/drivers/dri/i965/brw_wm.c
index 4d5e7f6..65de543 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -222,7 +222,7 @@ brw_codegen_wm_prog(struct brw_context *brw,
}
 
if (unlikely(INTEL_DEBUG & DEBUG_WM))
-  brw_dump_ir("fragment", prog, &fs->base, &fp->program.Base);
+  brw_dump_ir("fragment", prog, fs ? &fs->base : NULL, &fp->program.Base);
 
int st_index8 = -1, st_index16 = -1;
if (INTEL_DEBUG & DEBUG_SHADER_TIME) {
-- 
1.9.1

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


[Mesa-dev] [PATCH] changes to get rid of ir_variable

2015-10-08 Thread Tapani Pälli
Hi;

Here's a proposal to start creating gl_shader_variable structs to
program resource list instead of maintaining a whole ir_variable. This
is done to strip dependency on GLSL IR from program resource queries.
It also may give possibility to free IR (or NIR) after linking, maybe
some more fields are required for backend (?)

Further changes are required in SSBO queries to not iterate IR, this
could be done as the next step. I posted this WIP to see if people think
there would be nicer alternatives to this.

Thanks;

Tapani Pälli (1):
  mesa: use gl_shader_variable in program resource list WIP

 src/glsl/linker.cpp| 42 ++-
 src/mesa/main/mtypes.h | 56 ++
 src/mesa/main/shader_query.cpp | 36 +--
 3 files changed, 110 insertions(+), 24 deletions(-)

-- 
2.4.3

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


[Mesa-dev] [PATCH] mesa: use gl_shader_variable in program resource list WIP

2015-10-08 Thread Tapani Pälli
Patch changes linker to allocate gl_shader_variable instead of using
ir_variable. This makes it possible to get rid of ir_variables and ir
as a whole.

Signed-off-by: Tapani Pälli 
---
 src/glsl/linker.cpp| 42 ++-
 src/mesa/main/mtypes.h | 56 ++
 src/mesa/main/shader_query.cpp | 36 +--
 3 files changed, 110 insertions(+), 24 deletions(-)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index a97b4ef..76f74dc 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -3305,6 +3305,27 @@ build_stageref(struct gl_shader_program *shProg, const 
char *name,
return stages;
 }
 
+/**
+ * Create gl_shader_variable from ir_variable class.
+ */
+static gl_shader_variable *
+create_shader_variable(struct gl_shader_program *shProg, const ir_variable *in)
+{
+   gl_shader_variable *out = ralloc(shProg, struct gl_shader_variable);
+   if (!out)
+  return NULL;
+
+   out->type = in->type;
+   out->name = ralloc_strdup(shProg, in->name);
+
+   out->location = in->data.location;
+   out->index = in->data.index;
+   out->patch = in->data.patch;
+   out->mode = in->data.mode;
+
+   return out;
+}
+
 static bool
 add_interface_variables(struct gl_shader_program *shProg,
 exec_list *ir, GLenum programInterface)
@@ -3350,9 +3371,13 @@ add_interface_variables(struct gl_shader_program *shProg,
   if (strncmp(var->name, "packed:", 7) == 0)
  continue;
 
-  if (!add_program_resource(shProg, programInterface, var,
-build_stageref(shProg, var->name,
-   var->data.mode) | mask))
+  gl_shader_variable *sha_v = create_shader_variable(shProg, var);
+  if (!sha_v)
+ return false;
+
+  if (!add_program_resource(shProg, programInterface, sha_v,
+build_stageref(shProg, sha_v->name,
+   sha_v->mode) | mask))
  return false;
}
return true;
@@ -3380,9 +3405,14 @@ add_packed_varyings(struct gl_shader_program *shProg, 
int stage)
  default:
 unreachable("unexpected type");
  }
- if (!add_program_resource(shProg, iface, var,
-   build_stageref(shProg, var->name,
-  var->data.mode)))
+
+ gl_shader_variable *sha_v = create_shader_variable(shProg, var);
+ if (!sha_v)
+return false;
+
+ if (!add_program_resource(shProg, iface, sha_v,
+   build_stageref(shProg, sha_v->name,
+  sha_v->mode)))
 return false;
   }
}
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 288d757..6a54fe2 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2518,6 +2518,62 @@ struct gl_active_atomic_buffer
 };
 
 /**
+ * Data container for shader queries. This holds only the minimal
+ * amount of required information for resource queries to work.
+ */
+struct gl_shader_variable
+{
+   /**
+* Declared type of the variable
+*/
+   const struct glsl_type *type;
+
+   /**
+* Declared name of the variable
+*/
+   char *name;
+
+   /**
+* Storage location of the base of this variable
+*
+* The precise meaning of this field depends on the nature of the variable.
+*
+*   - Vertex shader input: one of the values from \c gl_vert_attrib.
+*   - Vertex shader output: one of the values from \c gl_varying_slot.
+*   - Geometry shader input: one of the values from \c gl_varying_slot.
+*   - Geometry shader output: one of the values from \c gl_varying_slot.
+*   - Fragment shader input: one of the values from \c gl_varying_slot.
+*   - Fragment shader output: one of the values from \c gl_frag_result.
+*   - Uniforms: Per-stage uniform slot number for default uniform block.
+*   - Uniforms: Index within the uniform block definition for UBO members.
+*   - Non-UBO Uniforms: explicit location until linking then reused to
+* store uniform slot number.
+*   - Other: This field is not currently used.
+*
+* If the variable is a uniform, shader input, or shader output, and the
+* slot has not been assigned, the value will be -1.
+*/
+   int location;
+
+   /**
+* Output index for dual source blending.
+*
+* \note
+* The GLSL spec only allows the values 0 or 1 for the index in \b dual
+* source blending.
+*/
+   unsigned index:1;
+   unsigned patch:1;
+
+   /**
+* Storage class of the variable.
+*
+* \sa (n)ir_variable_mode
+*/
+   unsigned mode:4;
+};
+
+/**
  * Active resource in a gl_shader_program
  */
 struct gl_program_resource
diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index 6d73e3b..b42c5b0 100644

Re: [Mesa-dev] [PATCH] gallium/swrast: fix front buffer blitting. (v2)

2015-10-08 Thread Dave Airlie
On 9 October 2015 at 13:30, Boyan Ding  wrote:
> 2015-10-09 8:38 GMT+08:00 Dave Airlie :
>> From: Dave Airlie 
>>
>> So I've known this was broken before, cogl has a workaround
>> for it from what I know, but with the gallium based swrast
>> drivers BlitFramebuffer from back to front or vice-versa
>> was pretty broken.
>>
>> The legacy swrast driver tracks when a front buffer is used
>> and does the get/put images when it is mapped/unmapped,
>> so this patch attempts to add the same functionality to the
>> gallium drivers.
>>
>> It creates a new context interface to denote when a front
>> buffer is being created, and passes a private pointer to it,
>> this pointer is then used to decide on map/unmap if the
>> contents should be updated from the real frontbuffer using
>> get/put image.
>>
>> This is primarily to make gtk's gl code work, the only
>> thing I've tested so far is the glarea test from
>> https://github.com/ebassi/glarea-example.git
>>
>> v2: bump extension version,
>> check extension version before calling get image. (Ian)
>>
>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91930
>>
>> Signed-off-by: Dave Airlie 
>
> Hi Dave,
>
> I'm wondering if it is necessary to implement the new interface of
> swrastLoader in egl. If you think so, I may try to work on it in a
> few days. The X11 part of egl is somewhat funny since it uses pure
> xcb. Maybe the code there will need xcb-utils-image.
>
> I came up with the question above after I tested glarea on GNOME
> wayland with sw rendering, where it seems to work all right. It seems
> GLArea in gtk is using EGL on wayland while using glx on X.

EGL doesn't support front buffer rendering from what I know, so I don't
think the interface is required there.

So I don't think there is a requirement for this interface on egl.

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


Re: [Mesa-dev] [PATCH 01/12] i965: Move brw_dump_ir() out of brw_*_emit() functions

2015-10-08 Thread Iago Toral
On Thu, 2015-10-08 at 11:19 -0700, Kristian Høgsberg wrote:
> On Thu, Oct 8, 2015 at 4:42 AM, Iago Toral  wrote:
> > On Thu, 2015-10-08 at 12:32 +0100, Chris Wilson wrote:
> >> On Thu, Oct 08, 2015 at 01:23:27PM +0200, Iago Toral wrote:
> >> > Well, this is weird this patch makes this crash:
> >> >
> >> > INTEL_DEBUG=vs glxgears
> >> >
> >> > because that uses a vertex program, so &vs->base is a NULL pointer
> >> > dereference in this call:
> >> >
> >> > brw_dump_ir("vertex", prog, &vs->base, &vp->program.Base);
> >> >
> >>
> >> No, the crash is:
> >>
> >> > +   if (unlikely(INTEL_DEBUG & DEBUG_VS) && vs->base.ir)
> >>
> >> and friends.
> >> -Chris
> >
> > Correct. We still need to patch calls to brw_dump_ir to fix this though.
> 
> No, what happened was I rebased this across Jasons recent cleanup and
> didn't remove the vs->base.ir checks. I've removed them and verified
> that glxgears works with INTEL_DEBUG=vs.

No, the problem is still there, vs can be NULL and are always derefering
it in the call to brw_dump_ir. See this gdb session with current master:

#1  0x740454ea in brw_codegen_vs_prog (brw=0x77fd1040,
prog=0x0, vp=0x960f50, key=0x7fffc940) at brw_vs.c:174

Notice that prog is NULL, so vs is never set. Right when we call
brw_dump_ir we have:

(gdb) p vs
$7 = (struct brw_shader *) 0x0
(gdb) p vp
$8 = (struct brw_vertex_program *) 0x960f50

And we still do:
brw_dump_ir("vertex", prog, &vs->base, &vp->program.Base); 

it doesn't crash for some reason, but the problem is there. I'll send a
patch for this.

Iago

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


[Mesa-dev] [PATCH v3 4/7] nir: add an instruction set API

2015-10-08 Thread Connor Abbott
This will replace direct usage of nir_instrs_equal() in the CSE pass,
which reduces an O(n^2) algorithm with an effectively O(n) one. It'll
also be useful for implementing GVN on top of GCM.

v2:
- Add texture support.
- Add more comments.
- Rename instr_can_hash() to instr_can_rewrite() since it's really more
about whether its uses can be rewritten, and it's implicitly used by
nir_instrs_equal() as well.
- Rename nir_instr_set_add() to nir_instr_set_add_or_rewrite() (Jason).
- Make the HASH() macro less magical (Topi).
- Rewrite the commit message.

v3:
- For sorting phi sources, use a VLA, store pointers to the sources, and
compare the predecessor pointer directly (Jason).

Signed-off-by: Connor Abbott 
---
Jason, does this look good to you? Still no piglit regressions -- I'm
working on getting perf numbers.

 src/glsl/nir/nir_instr_set.c | 314 +++
 src/glsl/nir/nir_instr_set.h |  35 +
 2 files changed, 349 insertions(+)

diff --git a/src/glsl/nir/nir_instr_set.c b/src/glsl/nir/nir_instr_set.c
index 72ab048..7460fcc 100644
--- a/src/glsl/nir/nir_instr_set.c
+++ b/src/glsl/nir/nir_instr_set.c
@@ -22,6 +22,181 @@
  */
 
 #include "nir_instr_set.h"
+#include "nir_vla.h"
+
+#define HASH(hash, data) _mesa_fnv32_1a_accumulate((hash), (data))
+
+static uint32_t
+hash_src(uint32_t hash, const nir_src *src)
+{
+   assert(src->is_ssa);
+   hash = HASH(hash, src->ssa);
+   return hash;
+}
+
+static uint32_t
+hash_alu_src(uint32_t hash, const nir_alu_src *src, unsigned num_components)
+{
+   hash = HASH(hash, src->abs);
+   hash = HASH(hash, src->negate);
+
+   for (unsigned i = 0; i < num_components; i++)
+  hash = HASH(hash, src->swizzle[i]);
+
+   hash = hash_src(hash, &src->src);
+   return hash;
+}
+
+static uint32_t
+hash_alu(uint32_t hash, const nir_alu_instr *instr)
+{
+   hash = HASH(hash, instr->op);
+   hash = HASH(hash, instr->dest.dest.ssa.num_components);
+
+   if (nir_op_infos[instr->op].algebraic_properties & NIR_OP_IS_COMMUTATIVE) {
+  assert(nir_op_infos[instr->op].num_inputs == 2);
+  uint32_t hash0 = hash_alu_src(hash, &instr->src[0],
+nir_ssa_alu_instr_src_components(instr, 
0));
+  uint32_t hash1 = hash_alu_src(hash, &instr->src[1],
+nir_ssa_alu_instr_src_components(instr, 
1));
+  /* For commutative operations, we need some commutative way of
+   * combining the hashes.  One option would be to XOR them but that
+   * means that anything with two identical sources will hash to 0 and
+   * that's common enough we probably don't want the guaranteed
+   * collision.  Either addition or multiplication will also work.
+   */
+  hash = hash0 * hash1;
+   } else {
+  for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++) {
+ hash = hash_alu_src(hash, &instr->src[i],
+ nir_ssa_alu_instr_src_components(instr, i));
+  }
+   }
+
+   return hash;
+}
+
+static uint32_t
+hash_load_const(uint32_t hash, const nir_load_const_instr *instr)
+{
+   hash = HASH(hash, instr->def.num_components);
+
+   hash = _mesa_fnv32_1a_accumulate_block(hash, instr->value.f,
+  instr->def.num_components
+ * sizeof(instr->value.f[0]));
+
+   return hash;
+}
+
+static int
+cmp_phi_src(const void *data1, const void *data2)
+{
+   nir_phi_src *src1 = *(nir_phi_src **)data1;
+   nir_phi_src *src2 = *(nir_phi_src **)data2;
+   return src1->pred - src2->pred;
+}
+
+static uint32_t
+hash_phi(uint32_t hash, const nir_phi_instr *instr)
+{
+   hash = HASH(hash, instr->instr.block);
+
+   /* sort sources by predecessor, since the order shouldn't matter */
+   unsigned num_preds = instr->instr.block->predecessors->entries;
+   NIR_VLA(nir_phi_src *, srcs, num_preds);
+   unsigned i = 0;
+   nir_foreach_phi_src(instr, src) {
+  srcs[i++] = src;
+   }
+
+   qsort(srcs, num_preds, sizeof(nir_phi_src *), cmp_phi_src);
+
+   for (i = 0; i < num_preds; i++) {
+  hash = hash_src(hash, &srcs[i]->src);
+  hash = HASH(hash, srcs[i]->pred);
+   }
+
+   return hash;
+}
+
+static uint32_t
+hash_intrinsic(uint32_t hash, const nir_intrinsic_instr *instr)
+{
+   const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic];
+   hash = HASH(hash, instr->intrinsic);
+
+   if (info->has_dest)
+  hash = HASH(hash, instr->dest.ssa.num_components);
+
+   assert(info->num_variables == 0);
+
+   hash = _mesa_fnv32_1a_accumulate_block(hash, instr->const_index,
+  info->num_indices
+ * sizeof(instr->const_index[0]));
+   return hash;
+}
+
+static uint32_t
+hash_tex(uint32_t hash, const nir_tex_instr *instr)
+{
+   hash = HASH(hash, instr->op);
+   hash = HASH(hash, instr->num_srcs);
+
+   for (unsigned i = 0; i < instr->num_srcs; i++) {
+  hash = HASH(hash, instr

Re: [Mesa-dev] [PATCH] gallium/swrast: fix front buffer blitting. (v2)

2015-10-08 Thread Boyan Ding
2015-10-09 8:38 GMT+08:00 Dave Airlie :
> From: Dave Airlie 
>
> So I've known this was broken before, cogl has a workaround
> for it from what I know, but with the gallium based swrast
> drivers BlitFramebuffer from back to front or vice-versa
> was pretty broken.
>
> The legacy swrast driver tracks when a front buffer is used
> and does the get/put images when it is mapped/unmapped,
> so this patch attempts to add the same functionality to the
> gallium drivers.
>
> It creates a new context interface to denote when a front
> buffer is being created, and passes a private pointer to it,
> this pointer is then used to decide on map/unmap if the
> contents should be updated from the real frontbuffer using
> get/put image.
>
> This is primarily to make gtk's gl code work, the only
> thing I've tested so far is the glarea test from
> https://github.com/ebassi/glarea-example.git
>
> v2: bump extension version,
> check extension version before calling get image. (Ian)
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91930
>
> Signed-off-by: Dave Airlie 

Hi Dave,

I'm wondering if it is necessary to implement the new interface of
swrastLoader in egl. If you think so, I may try to work on it in a
few days. The X11 part of egl is somewhat funny since it uses pure
xcb. Maybe the code there will need xcb-utils-image.

I came up with the question above after I tested glarea on GNOME
wayland with sw rendering, where it seems to work all right. It seems
GLArea in gtk is using EGL on wayland while using glx on X.

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


Re: [Mesa-dev] [RFC] Vendor-neutral dispatch library for OpenGL

2015-10-08 Thread Michel Dänzer
On 07.10.2015 04:58, Kyle Brenneman wrote:
> On 10/06/2015 12:43 PM, Emil Velikov wrote:
>> On 6 October 2015 at 16:39, Kyle Brenneman  wrote:
>>> On 10/06/2015 07:34 AM, Emil Velikov wrote:

   * The existing x11glvnd extension seems to be a "xserver only" approach.
 Iirc at XDC last year, people were leaning towards using an FD to
 obtain all the information needed. Currently mesa/xserver uses that to
 detect if we should load i915, i965, r300, r600... driver. What's your
 take on this ?
>>> I'm open to alternatives, but I'm not familiar with the FD approach you're
>>> describing. Can you give me more details about it, or point me at where in
>>> the Mesa code it is?
>>>
>> The idea is that you can get the device(node) fd from the server
>> (x,weston,foo) and use that to communicate with the module and/apply
>> any form of heuristics. Currently mesa has a few:
>>  - get the kernel module name (via ioctls or sysfs) and map it to the
>> userspace driver.
>>  - get the vendor/device pciid (via libudev or sysfs), and map it to
>> the userspace driver.
>>
>> The code is in src/loader, it's a bit hard to look at, so be warned.
>>
>> I've been planning to nuke the ioctl vs sysfs vs libudev, by pushing
>> the chaos to libdrm. So that others can reuse it when needed. yet it's
>> not the most interesting thing to do bth.
> The only thing that libGLX can assume is that each X screen corresponds
> to at most one vendor library.

Actually, it can't: the amdgpu kernel driver is not only supported by
the Mesa radeonsi driver but will also be supported by future versions
of the Catalyst OpenGL driver. Either OpenGL driver will work with both
the xf86-video-amdgpu driver and the generic modesetting Xorg driver.


> The x11glvnd extension will (by default) hand back the name of whatever
> video driver is driving a screen. For cases where multiple vendor names
> should all use the same vendor library, all the different names would
> just be symlinks to the same library. So for example, you might have
> have libGLX_mesa.so as the library, and then you'd have symlinks to it
> named libGLX_intel.so, libGLX_vesa.so, and so on.

I hope we can handle the above scenario as well, allowing to select one
of the supported OpenGL drivers for each application without having to
resort to manipulating symlinks, e.g. via configuration files and/or
environment variables. I think something like Mesa's driconf
infrastructure would be nice for this from a user perspective, it allows
making persistent per-application configuration.


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


Re: [Mesa-dev] [PATCH] mesa: Correctly handle GL_BGRA_EXT in ES3 format_and_type checks

2015-10-08 Thread Michael Schellenberger Costa
Hi,
Am 08.10.2015 um 00:58 schrieb Jason Ekstrand:
> The EXT_texture_format_BGRA extension (which mesa supports 
> unconditionally) adds a new format and internal format called 
> GL_BGRA_EXT. Previously, this was not really handled at all in 
> _mesa_ex3_error_check_format_and_type.  When the checks were 
> tightened in commit f15a7f3c, we accidentally tightened things too 
> far and GL_BGRA_EXT would always cause an error to be thrown.
> 
> There were two primary issues here.  First, is that 
> _mesa_es3_effective_internal_format_for_format_and_type didn't 
> handle the GL_BGRA_EXT format.  Second is that it blindly uses 
> _mesa_base_tex_format which returns GL_RGBA for GL_BGRA_EXT.  This 
> commit fixes both of these issues as well as adds explicit checks 
> that GL_BGRA_EXT is only ever used with GL_BGRA_EXT and 
> GL_UNSIGNED_BYTE.
> 
> Signed-off-by: Jason Ekstrand  Bugzilla: 
> https://bugs.freedesktop.org/show_bug.cgi?id=92265 Cc: Eduardo
> Lima Mitev  --- src/mesa/main/glformats.c | 21 
> +++-- 1 file changed, 19 insertions(+), 2 
> deletions(-)
> 
> diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
>  index 7dab33c..843ec02 100644 --- a/src/mesa/main/glformats.c +++ 
> b/src/mesa/main/glformats.c @@ -2678,6 +2678,7 @@ 
> _mesa_es3_effective_internal_format_for_format_and_type(GLenum 
> format, * internal formats, they do not correspond to GL
> constants, so the base * format is returned instead. */ +
> case GL_BGRA_EXT: case GL_LUMINANCE_ALPHA: case GL_LUMINANCE: case 
> GL_ALPHA: @@ -2797,8 +2798,19 @@ 
> _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
> if (effectiveInternalFormat == GL_NONE) return 
> GL_INVALID_OPERATION;
> 
> -  GLenum baseInternalFormat = - _mesa_base_tex_format(ctx,
> effectiveInternalFormat); +  GLenum baseInternalFormat; +
> if (internalFormat == GL_BGRA_EXT) { + /* Unfortunately,
> _mesa_base_tex_format returns a base format of + * GL_RGBA for
> GL_BGRA_EXT.  This makes perfect sense if you're + * asking the
> question, "what channels doe this format have?" + * However, if
> we're trying to determine if two internal formats + * match in the
> ES3 sense, we actually want GL_BGRA.
Shouldnt this be GL_BGRA_EXT at the end of the comment?

Michael
> +  */ + baseInternalFormat = GL_BGRA_EXT; +  } 
> else { + baseInternalFormat = + _mesa_base_tex_format(ctx,
> effectiveInternalFormat); +  }
> 
> if (internalFormat != baseInternalFormat) return 
> GL_INVALID_OPERATION; @@ -2807,6 +2819,11 @@ 
> _mesa_es3_error_check_format_and_type(const struct gl_context *ctx,
> }
> 
> switch (format) { +   case GL_BGRA_EXT: +  if (type != 
> GL_UNSIGNED_BYTE || internalFormat != GL_BGRA) + return 
> GL_INVALID_OPERATION; +  break; + case GL_RGBA: switch (type) {
> case GL_UNSIGNED_BYTE:
> 

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


[Mesa-dev] [PATCH] gallium/swrast: fix front buffer blitting. (v2)

2015-10-08 Thread Dave Airlie
From: Dave Airlie 

So I've known this was broken before, cogl has a workaround
for it from what I know, but with the gallium based swrast
drivers BlitFramebuffer from back to front or vice-versa
was pretty broken.

The legacy swrast driver tracks when a front buffer is used
and does the get/put images when it is mapped/unmapped,
so this patch attempts to add the same functionality to the
gallium drivers.

It creates a new context interface to denote when a front
buffer is being created, and passes a private pointer to it,
this pointer is then used to decide on map/unmap if the
contents should be updated from the real frontbuffer using
get/put image.

This is primarily to make gtk's gl code work, the only
thing I've tested so far is the glarea test from
https://github.com/ebassi/glarea-example.git

v2: bump extension version,
check extension version before calling get image. (Ian)

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

Signed-off-by: Dave Airlie 
---
 include/GL/internal/dri_interface.h   | 11 +++-
 src/gallium/drivers/llvmpipe/lp_texture.c | 21 ++-
 src/gallium/drivers/softpipe/sp_texture.c | 18 ++---
 src/gallium/include/pipe/p_screen.h   |  4 +++
 src/gallium/include/state_tracker/drisw_api.h |  3 +++
 src/gallium/include/state_tracker/sw_winsys.h |  1 +
 src/gallium/state_trackers/dri/drisw.c| 39 +--
 src/gallium/winsys/sw/dri/dri_sw_winsys.c | 15 +++
 src/glx/drisw_glx.c   | 19 +
 9 files changed, 113 insertions(+), 18 deletions(-)

diff --git a/include/GL/internal/dri_interface.h 
b/include/GL/internal/dri_interface.h
index a0f155a..6bbd3fa 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -495,7 +495,7 @@ struct __DRIdamageExtensionRec {
  * SWRast Loader extension.
  */
 #define __DRI_SWRAST_LOADER "DRI_SWRastLoader"
-#define __DRI_SWRAST_LOADER_VERSION 2
+#define __DRI_SWRAST_LOADER_VERSION 3
 struct __DRIswrastLoaderExtensionRec {
 __DRIextension base;
 
@@ -528,6 +528,15 @@ struct __DRIswrastLoaderExtensionRec {
 void (*putImage2)(__DRIdrawable *drawable, int op,
   int x, int y, int width, int height, int stride,
   char *data, void *loaderPrivate);
+
+   /**
+ * Put image to drawable
+ *
+ * \since 3
+ */
+   void (*getImage2)(__DRIdrawable *readable,
+int x, int y, int width, int height, int stride,
+char *data, void *loaderPrivate);
 };
 
 /**
diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c 
b/src/gallium/drivers/llvmpipe/lp_texture.c
index af46342..7862ac8 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -200,7 +200,8 @@ llvmpipe_can_create_resource(struct pipe_screen *screen,
 
 static boolean
 llvmpipe_displaytarget_layout(struct llvmpipe_screen *screen,
-  struct llvmpipe_resource *lpr)
+  struct llvmpipe_resource *lpr,
+  const void *map_front_private)
 {
struct sw_winsys *winsys = screen->winsys;
 
@@ -215,12 +216,13 @@ llvmpipe_displaytarget_layout(struct llvmpipe_screen 
*screen,
   lpr->base.format,
   width, height,
   64,
+  map_front_private,
   &lpr->row_stride[0] );
 
if (lpr->dt == NULL)
   return FALSE;
 
-   {
+   if (!map_front_private) {
   void *map = winsys->displaytarget_map(winsys, lpr->dt,
 PIPE_TRANSFER_WRITE);
 
@@ -235,8 +237,9 @@ llvmpipe_displaytarget_layout(struct llvmpipe_screen 
*screen,
 
 
 static struct pipe_resource *
-llvmpipe_resource_create(struct pipe_screen *_screen,
- const struct pipe_resource *templat)
+llvmpipe_resource_create_front(struct pipe_screen *_screen,
+   const struct pipe_resource *templat,
+   const void *map_front_private)
 {
struct llvmpipe_screen *screen = llvmpipe_screen(_screen);
struct llvmpipe_resource *lpr = CALLOC_STRUCT(llvmpipe_resource);
@@ -254,7 +257,7 @@ llvmpipe_resource_create(struct pipe_screen *_screen,
 PIPE_BIND_SCANOUT |
 PIPE_BIND_SHARED)) {
  /* displayable surface */
- if (!llvmpipe_displaytarget_layout(screen, lpr))
+ if (!llvmpipe_displaytarget_layout(screen, lpr, map_front_private))
 goto fail;
   }
   else {
@@ -300,7 +303,12 @@ llvmpipe_resource_create(struct pipe_screen *_screen,
FREE(lpr);
return NULL;
 }
-
+static struct pipe_resource *
+llvmpipe_resource_create(struct pipe_screen *_screen,
+ 

Re: [Mesa-dev] [PATCH 00/17] i965: More compiler cleanups

2015-10-08 Thread Jason Ekstrand
On Thu, Oct 8, 2015 at 5:22 PM, Jason Ekstrand  wrote:
> This series contains even more compiler code-shuffling and cleanups.  In
> particular, it gets us down to the point where we can, for the most part,
> just go NIR -> binary.  It also rolls the entire compiler API into a single
> header file with a bunch of structs and 6 functions.  It also reworks the
> emit functions (now named compile) to set up some of prog_data for you.
>
> Sound too good to be true?  Well, that's because it is.  I haven't had the
> time or mental energy to re-work geometry shaders where most of the
> interesting prog_data setup is.  Also, we still do have to pass in some
> gl_program a few places to do workarounds on older hardware.  That said,
> the interface between compiler and driver is a whole lot nicer than it used
> to be.

This can all be found in this branch on fd.o:

http://cgit.freedesktop.org/~jekstrand/mesa/log/?h=review/i965-compiler-cleanups2

> Jason Ekstrand (17):
>   i965/asm: Explicitly use a nir_instr for IR annotations
>   nir: Add a label to nir_shader_info
>   mesa: Move gl_frag_depth_layout from mtypes.h to shader_enums.h
>   nir/info: Move the GS info into a stage-specific info union
>   nir/info: Add compute shader local size to nir_shader_info
>   nir/info: Add a few bits of info for fragment shaders
>   i965/fs: Remove the gl_program from the generator
>   i965/vec4: Remove gl_program and gl_shader_program from the generator
>   i965: Use a const nir_shader in backend_shader
>   i965/vs: Move use_legacy_snorm_formula into the shader key
>   i965/fs: Rework wm_fs_emit to take a nir_shader and a brw_compiler
>   i965/vs: Rework vs_emit to take a nir_shader and a brw_compiler
>   i965/gs: Rework gs_emit to take a nir_shader and a brw_compiler
>   i965/cs: Rework cs_emit to take a nir_shader and a brw_compiler
>   i965/fs: Move some of the prog_data setup into brw_wm_emit
>   i965: Rename brw_foo_emit to brw_compile_foo
>   i965: Move the entire compiler API into a single file
>
>  src/glsl/nir/glsl_to_nir.cpp  |  31 +-
>  src/glsl/nir/nir.h|  34 ++-
>  src/glsl/nir/nir_sweep.c  |   2 +
>  src/glsl/shader_enums.h   |  17 ++
>  src/mesa/drivers/dri/i965/Makefile.sources|   1 +
>  src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp   |   2 +-
>  src/mesa/drivers/dri/i965/brw_context.c   |   2 +-
>  src/mesa/drivers/dri/i965/brw_context.h   | 353 
> +-
>  src/mesa/drivers/dri/i965/brw_cs.c|  10 +-
>  src/mesa/drivers/dri/i965/brw_cs.h|  15 -
>  src/mesa/drivers/dri/i965/brw_fs.cpp  | 216 +
>  src/mesa/drivers/dri/i965/brw_fs.h|   5 +-
>  src/mesa/drivers/dri/i965/brw_fs_generator.cpp|   5 +-
>  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp  |   2 +-
>  src/mesa/drivers/dri/i965/brw_gs.c|   6 +-
>  src/mesa/drivers/dri/i965/brw_program.h   | 124 +---
>  src/mesa/drivers/dri/i965/brw_shader.cpp  |   2 +-
>  src/mesa/drivers/dri/i965/brw_shader.h|  62 +---
>  src/mesa/drivers/dri/i965/brw_vec4.cpp|  76 ++---
>  src/mesa/drivers/dri/i965/brw_vec4.h  |  12 +-
>  src/mesa/drivers/dri/i965/brw_vec4_generator.cpp  |  26 +-
>  src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp |  64 ++--
>  src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h   |  32 +-
>  src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp|   2 +-
>  src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp |  11 +-
>  src/mesa/drivers/dri/i965/brw_vs.c|  17 +-
>  src/mesa/drivers/dri/i965/brw_vs.h|  15 +-
>  src/mesa/drivers/dri/i965/brw_wm.c| 112 +--
>  src/mesa/drivers/dri/i965/brw_wm.h|  15 -
>  src/mesa/drivers/dri/i965/gen6_gs_visitor.h   |   2 +-
>  src/mesa/drivers/dri/i965/intel_asm_annotation.c  |  17 +-
>  src/mesa/drivers/dri/i965/intel_asm_annotation.h  |   3 +-
>  src/mesa/main/mtypes.h|  18 --
>  src/mesa/program/prog_to_nir.c|   6 +
>  34 files changed, 370 insertions(+), 947 deletions(-)
>
> --
> 2.5.0.400.gff86faf
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 07/17] i965/fs: Remove the gl_program from the generator

2015-10-08 Thread Jason Ekstrand
---
 src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp | 2 +-
 src/mesa/drivers/dri/i965/brw_fs.cpp| 4 ++--
 src/mesa/drivers/dri/i965/brw_fs.h  | 3 ---
 src/mesa/drivers/dri/i965/brw_fs_generator.cpp  | 3 +--
 src/mesa/drivers/dri/i965/brw_vec4.cpp  | 2 +-
 5 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp 
b/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp
index d458ad8..5308d17 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp
@@ -32,7 +32,7 @@ brw_blorp_eu_emitter::brw_blorp_eu_emitter(struct brw_context 
*brw,
  generator(brw->intelScreen->compiler, brw,
mem_ctx, (void *) rzalloc(mem_ctx, struct brw_wm_prog_key),
(struct brw_stage_prog_data *) rzalloc(mem_ctx, struct 
brw_wm_prog_data),
-   NULL, 0, false, "BLORP")
+   0, false, "BLORP")
 {
if (debug_flag)
   generator.enable_debug("blorp");
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
b/src/mesa/drivers/dri/i965/brw_fs.cpp
index ba62fdd..3c83f2a 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -5167,7 +5167,7 @@ brw_wm_fs_emit(struct brw_context *brw,
 
fs_generator g(brw->intelScreen->compiler, brw,
   mem_ctx, (void *) key, &prog_data->base,
-  &fp->Base, v.promoted_constants, v.runtime_check_aads_emit, 
"FS");
+  v.promoted_constants, v.runtime_check_aads_emit, "FS");
 
if (unlikely(INTEL_DEBUG & DEBUG_WM)) {
   char *name;
@@ -5323,7 +5323,7 @@ brw_cs_emit(struct brw_context *brw,
}
 
fs_generator g(brw->intelScreen->compiler, brw,
-  mem_ctx, (void*) key, &prog_data->base, &cp->Base,
+  mem_ctx, (void*) key, &prog_data->base,
   v8.promoted_constants, v8.runtime_check_aads_emit, "CS");
if (INTEL_DEBUG & DEBUG_CS) {
   char *name = ralloc_asprintf(mem_ctx, "%s compute shader %d",
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h 
b/src/mesa/drivers/dri/i965/brw_fs.h
index e8b511f..61b6ee6 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -400,7 +400,6 @@ public:
 void *mem_ctx,
 const void *key,
 struct brw_stage_prog_data *prog_data,
-struct gl_program *fp,
 unsigned promoted_constants,
 bool runtime_check_aads_emit,
 const char *stage_abbrev);
@@ -499,8 +498,6 @@ private:
const void * const key;
struct brw_stage_prog_data * const prog_data;
 
-   const struct gl_program *prog;
-
unsigned dispatch_width; /**< 8 or 16 */
 
exec_list discard_halt_patches;
diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
index 93ff5b1..8bdf582 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
@@ -131,7 +131,6 @@ fs_generator::fs_generator(const struct brw_compiler 
*compiler, void *log_data,
void *mem_ctx,
const void *key,
struct brw_stage_prog_data *prog_data,
-   struct gl_program *prog,
unsigned promoted_constants,
bool runtime_check_aads_emit,
const char *stage_abbrev)
@@ -139,7 +138,7 @@ fs_generator::fs_generator(const struct brw_compiler 
*compiler, void *log_data,
: compiler(compiler), log_data(log_data),
  devinfo(compiler->devinfo), key(key),
  prog_data(prog_data),
- prog(prog), promoted_constants(promoted_constants),
+ promoted_constants(promoted_constants),
  runtime_check_aads_emit(runtime_check_aads_emit), debug_flag(false),
  stage_abbrev(stage_abbrev), mem_ctx(mem_ctx)
 {
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index e966b96..602b943 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -1969,7 +1969,7 @@ brw_vs_emit(struct brw_context *brw,
 
   fs_generator g(brw->intelScreen->compiler, brw,
  mem_ctx, (void *) key, &prog_data->base.base,
- &vp->Base, v.promoted_constants,
+ v.promoted_constants,
  v.runtime_check_aads_emit, "VS");
   if (INTEL_DEBUG & DEBUG_VS) {
  char *name;
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 14/17] i965/cs: Rework cs_emit to take a nir_shader and a brw_compiler

2015-10-08 Thread Jason Ekstrand
This commit removes all dependence on GL state by getting rid of the
brw_context parameter and the GL data structures.
---
 src/mesa/drivers/dri/i965/brw_cs.c   | 10 +--
 src/mesa/drivers/dri/i965/brw_cs.h   | 10 ---
 src/mesa/drivers/dri/i965/brw_fs.cpp | 51 
 3 files changed, 42 insertions(+), 29 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_cs.c 
b/src/mesa/drivers/dri/i965/brw_cs.c
index 45fb816..12e7509 100644
--- a/src/mesa/drivers/dri/i965/brw_cs.c
+++ b/src/mesa/drivers/dri/i965/brw_cs.c
@@ -105,9 +105,15 @@ brw_codegen_cs_prog(struct brw_context *brw,
if (INTEL_DEBUG & DEBUG_SHADER_TIME)
   st_index = brw_get_shader_time_index(brw, prog, &cp->program.Base, 
ST_CS);
 
-   program = brw_cs_emit(brw, mem_ctx, key, &prog_data,
- &cp->program, prog, st_index, &program_size);
+   char *error_str;
+   program = brw_cs_emit(brw->intelScreen->compiler, brw, mem_ctx,
+ key, &prog_data, cp->program.Base.nir,
+ st_index, &program_size, &error_str);
if (program == NULL) {
+  prog->LinkStatus = false;
+  ralloc_strcat(&prog->InfoLog, error_str);
+  _mesa_problem(NULL, "Failed to compile compute shader: %s\n", error_str);
+
   ralloc_free(mem_ctx);
   return false;
}
diff --git a/src/mesa/drivers/dri/i965/brw_cs.h 
b/src/mesa/drivers/dri/i965/brw_cs.h
index 17c2ff9..1a9613e 100644
--- a/src/mesa/drivers/dri/i965/brw_cs.h
+++ b/src/mesa/drivers/dri/i965/brw_cs.h
@@ -39,15 +39,17 @@ extern "C" {
 void
 brw_upload_cs_prog(struct brw_context *brw);
 
+struct nir_shader;
+
 const unsigned *
-brw_cs_emit(struct brw_context *brw,
+brw_cs_emit(const struct brw_compiler *compiler, void *log_data,
 void *mem_ctx,
 const struct brw_cs_prog_key *key,
 struct brw_cs_prog_data *prog_data,
-struct gl_compute_program *cp,
-struct gl_shader_program *prog,
+const struct nir_shader *shader,
 int shader_time_index,
-unsigned *final_assembly_size);
+unsigned *final_assembly_size,
+char **error_str);
 
 void
 brw_cs_fill_local_id_payload(const struct brw_cs_prog_data *cs_prog_data,
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 8bdc676..146f4b4 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -5256,29 +5256,32 @@ fs_visitor::emit_cs_work_group_id_setup()
 }
 
 const unsigned *
-brw_cs_emit(struct brw_context *brw,
+brw_cs_emit(const struct brw_compiler *compiler, void *log_data,
 void *mem_ctx,
 const struct brw_cs_prog_key *key,
 struct brw_cs_prog_data *prog_data,
-struct gl_compute_program *cp,
-struct gl_shader_program *prog,
+const nir_shader *shader,
 int shader_time_index,
-unsigned *final_assembly_size)
+unsigned *final_assembly_size,
+char **error_str)
 {
-   prog_data->local_size[0] = cp->LocalSize[0];
-   prog_data->local_size[1] = cp->LocalSize[1];
-   prog_data->local_size[2] = cp->LocalSize[2];
+   prog_data->local_size[0] = shader->info.cs.local_size[0];
+   prog_data->local_size[1] = shader->info.cs.local_size[1];
+   prog_data->local_size[2] = shader->info.cs.local_size[2];
unsigned local_workgroup_size =
-  cp->LocalSize[0] * cp->LocalSize[1] * cp->LocalSize[2];
-   unsigned max_cs_threads = 
brw->intelScreen->compiler->devinfo->max_cs_threads;
+  shader->info.cs.local_size[0] * shader->info.cs.local_size[1] *
+  shader->info.cs.local_size[2];
+
+   unsigned max_cs_threads = compiler->devinfo->max_cs_threads;
 
cfg_t *cfg = NULL;
const char *fail_msg = NULL;
 
/* Now the main event: Visit the shader IR and generate our CS IR for it.
 */
-   fs_visitor v8(brw->intelScreen->compiler, brw, mem_ctx, key,
- &prog_data->base, &cp->Base, cp->Base.nir, 8, 
shader_time_index);
+   fs_visitor v8(compiler, log_data, mem_ctx, key, &prog_data->base,
+ NULL, /* Never used in core profile */
+ shader, 8, shader_time_index);
if (!v8.run_cs()) {
   fail_msg = v8.fail_msg;
} else if (local_workgroup_size <= 8 * max_cs_threads) {
@@ -5286,15 +5289,18 @@ brw_cs_emit(struct brw_context *brw,
   prog_data->simd_size = 8;
}
 
-   fs_visitor v16(brw->intelScreen->compiler, brw, mem_ctx, key,
-  &prog_data->base, &cp->Base, cp->Base.nir, 16, 
shader_time_index);
+   fs_visitor v16(compiler, log_data, mem_ctx, key, &prog_data->base,
+ NULL, /* Never used in core profile */
+ shader, 16, shader_time_index);
if (likely(!(INTEL_DEBUG & DEBUG_NO16)) &&
!fail_msg && !v8.simd16_unsupported &&
local_workgroup_size <= 16 * max_cs_threads) {
   /* Try a SIMD16 compile */
   v16.import_uni

[Mesa-dev] [PATCH 13/17] i965/gs: Rework gs_emit to take a nir_shader and a brw_compiler

2015-10-08 Thread Jason Ekstrand
This commit removes all dependence on GL state by getting rid of the
brw_context parameter and the GL data structures.  Unfortunately, we still
have to pass in the gl_shader_program for gen6 because it's needed for
transform feedback.
---
 src/mesa/drivers/dri/i965/brw_gs.c|  6 ++-
 src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp | 55 ---
 src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h   |  8 ++--
 3 files changed, 29 insertions(+), 40 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_gs.c 
b/src/mesa/drivers/dri/i965/brw_gs.c
index e0165fb..469a6fb 100644
--- a/src/mesa/drivers/dri/i965/brw_gs.c
+++ b/src/mesa/drivers/dri/i965/brw_gs.c
@@ -57,6 +57,7 @@ brw_codegen_gs_prog(struct brw_context *brw,
 struct brw_geometry_program *gp,
 struct brw_gs_prog_key *key)
 {
+   struct gl_shader *shader = prog->_LinkedShaders[MESA_SHADER_GEOMETRY];
struct brw_stage_state *stage_state = &brw->gs.base;
struct brw_gs_compile c;
memset(&c, 0, sizeof(c));
@@ -300,8 +301,11 @@ brw_codegen_gs_prog(struct brw_context *brw,
 
void *mem_ctx = ralloc_context(NULL);
unsigned program_size;
+   char *error_str;
const unsigned *program =
-  brw_gs_emit(brw, prog, &c, mem_ctx, st_index, &program_size);
+  brw_gs_emit(brw->intelScreen->compiler, brw, &c,
+  shader->Program->nir, prog,
+  mem_ctx, st_index, &program_size, &error_str);
if (program == NULL) {
   ralloc_free(mem_ctx);
   return false;
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
index c127280..173a8c4 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
@@ -598,31 +598,17 @@ vec4_gs_visitor::gs_end_primitive()
emit(OR(dst_reg(this->control_data_bits), this->control_data_bits, mask));
 }
 
-static const unsigned *
-generate_assembly(struct brw_context *brw,
-  const nir_shader *nir,
-  struct brw_vue_prog_data *prog_data,
-  void *mem_ctx,
-  const cfg_t *cfg,
-  unsigned *final_assembly_size)
-{
-   vec4_generator g(brw->intelScreen->compiler, brw,
-prog_data, mem_ctx,
-INTEL_DEBUG & DEBUG_GS, "geometry", "GS");
-   return g.generate_assembly(cfg, final_assembly_size, nir);
-}
-
 extern "C" const unsigned *
-brw_gs_emit(struct brw_context *brw,
-struct gl_shader_program *prog,
+brw_gs_emit(const struct brw_compiler *compiler, void *log_data,
 struct brw_gs_compile *c,
+const nir_shader *shader,
+struct gl_shader_program *shader_prog,
 void *mem_ctx,
 int shader_time_index,
-unsigned *final_assembly_size)
+unsigned *final_assembly_size,
+char **error_str)
 {
-   struct gl_shader *shader = prog->_LinkedShaders[MESA_SHADER_GEOMETRY];
-
-   if (brw->gen >= 7) {
+   if (compiler->devinfo->gen >= 7) {
   /* Compile the geometry shader in DUAL_OBJECT dispatch mode, if we can do
* so without spilling. If the GS invocations count > 1, then we can't 
use
* dual object mode.
@@ -631,13 +617,12 @@ brw_gs_emit(struct brw_context *brw,
   likely(!(INTEL_DEBUG & DEBUG_NO_DUAL_OBJECT_GS))) {
  c->prog_data.base.dispatch_mode = DISPATCH_MODE_4X2_DUAL_OBJECT;
 
- vec4_gs_visitor v(brw->intelScreen->compiler, brw,
-   c, shader->Program->nir,
+ vec4_gs_visitor v(compiler, log_data, c, shader,
mem_ctx, true /* no_spills */, shader_time_index);
  if (v.run()) {
-return generate_assembly(brw, shader->Program->nir,
- &c->prog_data.base, mem_ctx, v.cfg,
- final_assembly_size);
+vec4_generator g(compiler, log_data, &c->prog_data.base, mem_ctx,
+ INTEL_DEBUG & DEBUG_GS, "geometry", "GS");
+return g.generate_assembly(v.cfg, final_assembly_size, shader);
  }
   }
}
@@ -665,7 +650,7 @@ brw_gs_emit(struct brw_context *brw,
 * mode is more performant when invocations > 1. Gen6 only supports
 * SINGLE mode.
 */
-   if (c->prog_data.invocations <= 1 || brw->gen < 7)
+   if (c->prog_data.invocations <= 1 || compiler->devinfo->gen < 7)
   c->prog_data.base.dispatch_mode = DISPATCH_MODE_4X1_SINGLE;
else
   c->prog_data.base.dispatch_mode = DISPATCH_MODE_4X2_DUAL_INSTANCE;
@@ -673,24 +658,22 @@ brw_gs_emit(struct brw_context *brw,
vec4_gs_visitor *gs = NULL;
const unsigned *ret = NULL;
 
-   if (brw->gen >= 7)
-  gs = new vec4_gs_visitor(brw->intelScreen->compiler, brw,
-   c, shader->Program->nir,
+   if (compiler->devinfo->gen >= 7)
+  gs = new vec4_gs_visito

[Mesa-dev] [PATCH 04/17] nir/info: Move the GS info into a stage-specific info union

2015-10-08 Thread Jason Ekstrand
This way we can have other stage-specific info without consuming too much
extra space.  While we're at it, we make sure that the geometry info is
only set if we're actually a goemetry shader.
---
 src/glsl/nir/glsl_to_nir.cpp | 12 ++--
 src/glsl/nir/nir.h   | 14 --
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp
index cdae2d1..da15927 100644
--- a/src/glsl/nir/glsl_to_nir.cpp
+++ b/src/glsl/nir/glsl_to_nir.cpp
@@ -164,11 +164,19 @@ glsl_to_nir(const struct gl_shader_program *shader_prog,
shader->info.uses_texture_gather = sh->Program->UsesGather;
shader->info.uses_clip_distance_out = sh->Program->UsesClipDistanceOut;
shader->info.separate_shader = shader_prog->SeparateShader;
-   shader->info.gs.vertices_out = sh->Geom.VerticesOut;
-   shader->info.gs.invocations = sh->Geom.Invocations;
shader->info.has_transform_feedback_varyings =
   shader_prog->TransformFeedback.NumVarying > 0;
 
+   switch (stage) {
+   case MESA_SHADER_GEOMETRY:
+  shader->info.gs.vertices_out = sh->Geom.VerticesOut;
+  shader->info.gs.invocations = sh->Geom.Invocations;
+  break;
+
+   default:
+  break; /* No stage-specific info */
+   }
+
return shader;
 }
 
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index b9f549b..e511298 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -1493,13 +1493,15 @@ typedef struct nir_shader_info {
/** Was this shader linked with any transform feedback varyings? */
bool has_transform_feedback_varyings;
 
-   struct {
-  /** The maximum number of vertices the geometry shader might write. */
-  unsigned vertices_out;
+   union {
+  struct {
+ /** The maximum number of vertices the geometry shader might write. */
+ unsigned vertices_out;
 
-  /** 1 .. MAX_GEOMETRY_SHADER_INVOCATIONS */
-  unsigned invocations;
-   } gs;
+ /** 1 .. MAX_GEOMETRY_SHADER_INVOCATIONS */
+ unsigned invocations;
+  } gs;
+   };
 } nir_shader_info;
 
 typedef struct nir_shader {
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 12/17] i965/vs: Rework vs_emit to take a nir_shader and a brw_compiler

2015-10-08 Thread Jason Ekstrand
This commit removes all dependence on GL state by getting rid of the
brw_context parameter and the GL data structures.
---
 src/mesa/drivers/dri/i965/brw_vec4.cpp | 67 +-
 src/mesa/drivers/dri/i965/brw_vs.c | 14 ++-
 src/mesa/drivers/dri/i965/brw_vs.h | 11 --
 3 files changed, 44 insertions(+), 48 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index 4b03967..d6549de 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -1937,51 +1937,41 @@ extern "C" {
  * Returns the final assembly and the program's size.
  */
 const unsigned *
-brw_vs_emit(struct brw_context *brw,
+brw_vs_emit(const struct brw_compiler *compiler, void *log_data,
 void *mem_ctx,
 const struct brw_vs_prog_key *key,
 struct brw_vs_prog_data *prog_data,
-struct gl_vertex_program *vp,
-struct gl_shader_program *prog,
+const nir_shader *shader,
+gl_clip_plane *clip_planes,
 int shader_time_index,
-unsigned *final_assembly_size)
+unsigned *final_assembly_size,
+char **error_str)
 {
const unsigned *assembly = NULL;
 
-   if (brw->intelScreen->compiler->scalar_vs) {
+   if (compiler->scalar_vs) {
   prog_data->base.dispatch_mode = DISPATCH_MODE_SIMD8;
 
-  fs_visitor v(brw->intelScreen->compiler, brw,
-   mem_ctx, key, &prog_data->base.base,
+  fs_visitor v(compiler, log_data, mem_ctx, key, &prog_data->base.base,
NULL, /* prog; Only used for TEXTURE_RECTANGLE on gen < 8 */
-   vp->Base.nir, 8, shader_time_index);
-  if (!v.run_vs(brw_select_clip_planes(&brw->ctx))) {
- if (prog) {
-prog->LinkStatus = false;
-ralloc_strcat(&prog->InfoLog, v.fail_msg);
- }
-
- _mesa_problem(NULL, "Failed to compile vertex shader: %s\n",
-   v.fail_msg);
+   shader, 8, shader_time_index);
+  if (!v.run_vs(clip_planes)) {
+ if (error_str)
+*error_str = ralloc_strdup(mem_ctx, v.fail_msg);
 
  return NULL;
   }
 
-  fs_generator g(brw->intelScreen->compiler, brw,
- mem_ctx, (void *) key, &prog_data->base.base,
- v.promoted_constants,
+  fs_generator g(compiler, log_data, mem_ctx, (void *) key,
+ &prog_data->base.base, v.promoted_constants,
  v.runtime_check_aads_emit, "VS");
   if (INTEL_DEBUG & DEBUG_VS) {
- char *name;
- if (prog) {
-name = ralloc_asprintf(mem_ctx, "%s vertex shader %d",
-   prog->Label ? prog->Label : "unnamed",
-   prog->Name);
- } else {
-name = ralloc_asprintf(mem_ctx, "vertex program %d",
-   vp->Base.Id);
- }
- g.enable_debug(name);
+ const char *debug_name =
+ralloc_asprintf(mem_ctx, "%s vertex shader %s",
+shader->info.label ? shader->info.label : 
"unnamed",
+shader->info.name);
+
+ g.enable_debug(debug_name);
   }
   g.generate_code(v.cfg, 8);
   assembly = g.get_assembly(final_assembly_size);
@@ -1990,25 +1980,18 @@ brw_vs_emit(struct brw_context *brw,
if (!assembly) {
   prog_data->base.dispatch_mode = DISPATCH_MODE_4X2_DUAL_OBJECT;
 
-  vec4_vs_visitor v(brw->intelScreen->compiler, brw, key, prog_data,
-vp->Base.nir, brw_select_clip_planes(&brw->ctx),
-mem_ctx, shader_time_index);
+  vec4_vs_visitor v(compiler, log_data, key, prog_data,
+shader, clip_planes, mem_ctx, shader_time_index);
   if (!v.run()) {
- if (prog) {
-prog->LinkStatus = false;
-ralloc_strcat(&prog->InfoLog, v.fail_msg);
- }
-
- _mesa_problem(NULL, "Failed to compile vertex shader: %s\n",
-   v.fail_msg);
+ if (error_str)
+*error_str = ralloc_strdup(mem_ctx, v.fail_msg);
 
  return NULL;
   }
 
-  vec4_generator g(brw->intelScreen->compiler, brw,
-   &prog_data->base,
+  vec4_generator g(compiler, log_data, &prog_data->base,
mem_ctx, INTEL_DEBUG & DEBUG_VS, "vertex", "VS");
-  assembly = g.generate_assembly(v.cfg, final_assembly_size, vp->Base.nir);
+  assembly = g.generate_assembly(v.cfg, final_assembly_size, shader);
}
 
return assembly;
diff --git a/src/mesa/drivers/dri/i965/brw_vs.c 
b/src/mesa/drivers/dri/i965/brw_vs.c
index ecaeefa..f54c9a3 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -180,9 +180,19 @@ brw_codegen_vs_prog(struct brw_context *brw,
 
   

[Mesa-dev] [PATCH 03/17] mesa: Move gl_frag_depth_layout from mtypes.h to shader_enums.h

2015-10-08 Thread Jason Ekstrand
---
 src/glsl/shader_enums.h | 17 +
 src/mesa/main/mtypes.h  | 18 --
 2 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/src/glsl/shader_enums.h b/src/glsl/shader_enums.h
index 2a5d2c5..1c2f5dc 100644
--- a/src/glsl/shader_enums.h
+++ b/src/glsl/shader_enums.h
@@ -473,4 +473,21 @@ typedef enum
 
 const char * gl_frag_result_name(gl_frag_result result);
 
+/**
+ * \brief Layout qualifiers for gl_FragDepth.
+ *
+ * Extension AMD_conservative_depth allows gl_FragDepth to be redeclared with
+ * a layout qualifier.
+ *
+ * \see enum ir_depth_layout
+ */
+enum gl_frag_depth_layout
+{
+   FRAG_DEPTH_LAYOUT_NONE, /**< No layout is specified. */
+   FRAG_DEPTH_LAYOUT_ANY,
+   FRAG_DEPTH_LAYOUT_GREATER,
+   FRAG_DEPTH_LAYOUT_LESS,
+   FRAG_DEPTH_LAYOUT_UNCHANGED
+};
+
 #endif /* SHADER_ENUMS_H */
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 288d757..6a2f323 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1866,24 +1866,6 @@ typedef enum
 
 
 /**
- * \brief Layout qualifiers for gl_FragDepth.
- *
- * Extension AMD_conservative_depth allows gl_FragDepth to be redeclared with
- * a layout qualifier.
- *
- * \see enum ir_depth_layout
- */
-enum gl_frag_depth_layout
-{
-   FRAG_DEPTH_LAYOUT_NONE, /**< No layout is specified. */
-   FRAG_DEPTH_LAYOUT_ANY,
-   FRAG_DEPTH_LAYOUT_GREATER,
-   FRAG_DEPTH_LAYOUT_LESS,
-   FRAG_DEPTH_LAYOUT_UNCHANGED
-};
-
-
-/**
  * Base class for any kind of program object
  */
 struct gl_program
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 05/17] nir/info: Add compute shader local size to nir_shader_info

2015-10-08 Thread Jason Ekstrand
---
 src/glsl/nir/glsl_to_nir.cpp | 8 
 src/glsl/nir/nir.h   | 4 
 2 files changed, 12 insertions(+)

diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp
index da15927..e4aa709 100644
--- a/src/glsl/nir/glsl_to_nir.cpp
+++ b/src/glsl/nir/glsl_to_nir.cpp
@@ -173,6 +173,14 @@ glsl_to_nir(const struct gl_shader_program *shader_prog,
   shader->info.gs.invocations = sh->Geom.Invocations;
   break;
 
+   case MESA_SHADER_COMPUTE: {
+  struct gl_compute_program *cp = (struct gl_compute_program *)sh->Program;
+  shader->info.cs.local_size[0] = cp->LocalSize[0];
+  shader->info.cs.local_size[1] = cp->LocalSize[1];
+  shader->info.cs.local_size[2] = cp->LocalSize[2];
+  break;
+   }
+
default:
   break; /* No stage-specific info */
}
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index e511298..2ce958a 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -1501,6 +1501,10 @@ typedef struct nir_shader_info {
  /** 1 .. MAX_GEOMETRY_SHADER_INVOCATIONS */
  unsigned invocations;
   } gs;
+
+  struct {
+ unsigned local_size[3];
+  } cs;
};
 } nir_shader_info;
 
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 08/17] i965/vec4: Remove gl_program and gl_shader_program from the generator

2015-10-08 Thread Jason Ekstrand
---
 src/mesa/drivers/dri/i965/brw_vec4.cpp|  4 ++--
 src/mesa/drivers/dri/i965/brw_vec4.h  | 10 +++---
 src/mesa/drivers/dri/i965/brw_vec4_generator.cpp  | 24 ++-
 src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp | 11 +--
 4 files changed, 20 insertions(+), 29 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index 602b943..4b8390f 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -2007,9 +2007,9 @@ brw_vs_emit(struct brw_context *brw,
   }
 
   vec4_generator g(brw->intelScreen->compiler, brw,
-   prog, &vp->Base, &prog_data->base,
+   &prog_data->base,
mem_ctx, INTEL_DEBUG & DEBUG_VS, "vertex", "VS");
-  assembly = g.generate_assembly(v.cfg, final_assembly_size);
+  assembly = g.generate_assembly(v.cfg, final_assembly_size, vp->Base.nir);
}
 
return assembly;
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h 
b/src/mesa/drivers/dri/i965/brw_vec4.h
index 5e3500c..cf9ec0a 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -391,8 +391,6 @@ class vec4_generator
 {
 public:
vec4_generator(const struct brw_compiler *compiler, void *log_data,
-  struct gl_shader_program *shader_prog,
-  struct gl_program *prog,
   struct brw_vue_prog_data *prog_data,
   void *mem_ctx,
   bool debug_flag,
@@ -400,10 +398,11 @@ public:
   const char *stage_abbrev);
~vec4_generator();
 
-   const unsigned *generate_assembly(const cfg_t *cfg, unsigned *asm_size);
+   const unsigned *generate_assembly(const cfg_t *cfg, unsigned *asm_size,
+ const nir_shader *nir);
 
 private:
-   void generate_code(const cfg_t *cfg);
+   void generate_code(const cfg_t *cfg, const nir_shader *nir);
 
void generate_math1_gen4(vec4_instruction *inst,
struct brw_reg dst,
@@ -485,9 +484,6 @@ private:
 
struct brw_codegen *p;
 
-   struct gl_shader_program *shader_prog;
-   const struct gl_program *prog;
-
struct brw_vue_prog_data *prog_data;
 
void *mem_ctx;
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
index 2a1e415..a84f6c4 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
@@ -21,6 +21,7 @@
  */
 
 #include 
+#include "glsl/glsl_parser_extras.h"
 #include "brw_vec4.h"
 #include "brw_cfg.h"
 
@@ -137,15 +138,13 @@ vec4_instruction::get_src(const struct brw_vue_prog_data 
*prog_data, int i)
 
 vec4_generator::vec4_generator(const struct brw_compiler *compiler,
void *log_data,
-   struct gl_shader_program *shader_prog,
-   struct gl_program *prog,
struct brw_vue_prog_data *prog_data,
void *mem_ctx,
bool debug_flag,
const char *stage_name,
const char *stage_abbrev)
: compiler(compiler), log_data(log_data), devinfo(compiler->devinfo),
- shader_prog(shader_prog), prog(prog), prog_data(prog_data),
+ prog_data(prog_data),
  mem_ctx(mem_ctx), stage_name(stage_name), stage_abbrev(stage_abbrev),
  debug_flag(debug_flag)
 {
@@ -1142,7 +1141,7 @@ 
vec4_generator::generate_set_simd4x2_header_gen9(vec4_instruction *inst,
 }
 
 void
-vec4_generator::generate_code(const cfg_t *cfg)
+vec4_generator::generate_code(const cfg_t *cfg, const nir_shader *nir)
 {
struct annotation_info annotation;
memset(&annotation, 0, sizeof(annotation));
@@ -1648,14 +1647,10 @@ vec4_generator::generate_code(const cfg_t *cfg)
int after_size = p->next_insn_offset;
 
if (unlikely(debug_flag)) {
-  if (shader_prog) {
- fprintf(stderr, "Native code for %s %s shader %d:\n",
- shader_prog->Label ? shader_prog->Label : "unnamed",
- stage_name, shader_prog->Name);
-  } else {
- fprintf(stderr, "Native code for %s program %d:\n", stage_name,
- prog->Id);
-  }
+  fprintf(stderr, "Native code for %s %s shader %s:\n",
+  nir->info.label ? nir->info.label : "unnamed",
+  _mesa_shader_stage_to_string(nir->stage), nir->info.name);
+
   fprintf(stderr, "%s vec4 shader: %d instructions. %d loops. Compacted %d 
to %d"
   " bytes (%.0f%%)\n",
   stage_abbrev,
@@ -1676,10 +1671,11 @@ vec4_generator::generate_code(const cfg_t *cfg)
 
 const unsigned *
 vec4_generator::generate_assembly(const cfg_t *cfg,
-  unsigned *assembly_size)
+   

[Mesa-dev] [PATCH 11/17] i965/fs: Rework wm_fs_emit to take a nir_shader and a brw_compiler

2015-10-08 Thread Jason Ekstrand
This commit removes all dependence on GL state by getting rid of the
brw_context parameter and the GL data structures.
---
 src/mesa/drivers/dri/i965/brw_fs.cpp | 59 
 src/mesa/drivers/dri/i965/brw_wm.c   | 14 +++--
 src/mesa/drivers/dri/i965/brw_wm.h   | 13 +---
 3 files changed, 47 insertions(+), 39 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 3c83f2a..8bdc676 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -5115,40 +5115,39 @@ fs_visitor::run_cs()
 }
 
 const unsigned *
-brw_wm_fs_emit(struct brw_context *brw,
+brw_wm_fs_emit(const struct brw_compiler *compiler, void *log_data,
void *mem_ctx,
const struct brw_wm_prog_key *key,
struct brw_wm_prog_data *prog_data,
-   struct gl_fragment_program *fp,
-   struct gl_shader_program *prog,
+   const nir_shader *shader,
+   struct gl_program *prog,
int shader_time_index8, int shader_time_index16,
-   unsigned *final_assembly_size)
+   bool use_rep_send,
+   unsigned *final_assembly_size,
+   char **error_str)
 {
-   /* Now the main event: Visit the shader IR and generate our FS IR for it.
-*/
-   fs_visitor v(brw->intelScreen->compiler, brw, mem_ctx, key,
-&prog_data->base, &fp->Base, fp->Base.nir, 8, 
shader_time_index8);
+   fs_visitor v(compiler, log_data, mem_ctx, key,
+&prog_data->base, prog, shader, 8,
+shader_time_index8);
if (!v.run_fs(false /* do_rep_send */)) {
-  if (prog) {
- prog->LinkStatus = false;
- ralloc_strcat(&prog->InfoLog, v.fail_msg);
-  }
-
-  _mesa_problem(NULL, "Failed to compile fragment shader: %s\n",
-v.fail_msg);
+  if (error_str)
+ *error_str = ralloc_strdup(mem_ctx, v.fail_msg);
 
   return NULL;
}
 
cfg_t *simd16_cfg = NULL;
-   fs_visitor v2(brw->intelScreen->compiler, brw, mem_ctx, key,
- &prog_data->base, &fp->Base, fp->Base.nir, 16, 
shader_time_index16);
-   if (likely(!(INTEL_DEBUG & DEBUG_NO16) || brw->use_rep_send)) {
+   fs_visitor v2(compiler, log_data, mem_ctx, key,
+ &prog_data->base, prog, shader, 16,
+ shader_time_index16);
+   if (likely(!(INTEL_DEBUG & DEBUG_NO16) || use_rep_send)) {
   if (!v.simd16_unsupported) {
  /* Try a SIMD16 compile */
  v2.import_uniforms(&v);
- if (!v2.run_fs(brw->use_rep_send)) {
-perf_debug("SIMD16 shader failed to compile: %s", v2.fail_msg);
+ if (!v2.run_fs(use_rep_send)) {
+compiler->shader_perf_log(log_data,
+  "SIMD16 shader failed to compile: %s",
+  v2.fail_msg);
  } else {
 simd16_cfg = v2.cfg;
  }
@@ -5156,8 +5155,8 @@ brw_wm_fs_emit(struct brw_context *brw,
}
 
cfg_t *simd8_cfg;
-   int no_simd8 = (INTEL_DEBUG & DEBUG_NO8) || brw->no_simd8;
-   if ((no_simd8 || brw->gen < 5) && simd16_cfg) {
+   int no_simd8 = (INTEL_DEBUG & DEBUG_NO8) || use_rep_send;
+   if ((no_simd8 || compiler->devinfo->gen < 5) && simd16_cfg) {
   simd8_cfg = NULL;
   prog_data->no_8 = true;
} else {
@@ -5165,20 +5164,14 @@ brw_wm_fs_emit(struct brw_context *brw,
   prog_data->no_8 = false;
}
 
-   fs_generator g(brw->intelScreen->compiler, brw,
-  mem_ctx, (void *) key, &prog_data->base,
+   fs_generator g(compiler, log_data, mem_ctx, (void *) key, &prog_data->base,
   v.promoted_constants, v.runtime_check_aads_emit, "FS");
 
if (unlikely(INTEL_DEBUG & DEBUG_WM)) {
-  char *name;
-  if (prog)
- name = ralloc_asprintf(mem_ctx, "%s fragment shader %d",
-prog->Label ? prog->Label : "unnamed",
-prog->Name);
-  else
- name = ralloc_asprintf(mem_ctx, "fragment program %d", fp->Base.Id);
-
-  g.enable_debug(name);
+  g.enable_debug(ralloc_asprintf(mem_ctx, "%s fragment shader %s",
+ shader->info.label ? shader->info.label :
+  "unnamed",
+ shader->info.name));
}
 
if (simd8_cfg)
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c 
b/src/mesa/drivers/dri/i965/brw_wm.c
index 4d5e7f6..ab9461a 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -230,9 +230,19 @@ brw_codegen_wm_prog(struct brw_context *brw,
   st_index16 = brw_get_shader_time_index(brw, prog, &fp->program.Base, 
ST_FS16);
}
 
-   program = brw_wm_fs_emit(brw, mem_ctx, key, &prog_data,
-&fp->program, prog, st_index8, st_index16, 
&program_siz

[Mesa-dev] [PATCH 10/17] i965/vs: Move use_legacy_snorm_formula into the shader key

2015-10-08 Thread Jason Ekstrand
This is really an input into the shader compiler so it kind of makes sense
in the key.  Also, given where it's placed into the key, it doesn't
actually make it any bigger.
---
 src/mesa/drivers/dri/i965/brw_program.h   | 2 ++
 src/mesa/drivers/dri/i965/brw_vec4.cpp| 3 +--
 src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp | 9 -
 src/mesa/drivers/dri/i965/brw_vs.c| 3 +++
 src/mesa/drivers/dri/i965/brw_vs.h| 5 +
 5 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_program.h 
b/src/mesa/drivers/dri/i965/brw_program.h
index cf0522a..2a9d1e9 100644
--- a/src/mesa/drivers/dri/i965/brw_program.h
+++ b/src/mesa/drivers/dri/i965/brw_program.h
@@ -91,6 +91,8 @@ struct brw_vs_prog_key {
 
bool clamp_vertex_color:1;
 
+   bool use_legacy_snorm_formula:1;
+
/**
 * How many user clipping planes are being uploaded to the vertex shader as
 * push constants.
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index 4b8390f..4b03967 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -1992,8 +1992,7 @@ brw_vs_emit(struct brw_context *brw,
 
   vec4_vs_visitor v(brw->intelScreen->compiler, brw, key, prog_data,
 vp->Base.nir, brw_select_clip_planes(&brw->ctx),
-mem_ctx, shader_time_index,
-!_mesa_is_gles3(&brw->ctx));
+mem_ctx, shader_time_index);
   if (!v.run()) {
  if (prog) {
 prog->LinkStatus = false;
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp
index 485a80e..9cf04cd 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp
@@ -77,7 +77,8 @@ vec4_vs_visitor::emit_prolog()
 /* ES 3.0 has different rules for converting signed normalized
  * fixed-point numbers than desktop GL.
  */
-if ((wa_flags & BRW_ATTRIB_WA_SIGN) && !use_legacy_snorm_formula) {
+if ((wa_flags & BRW_ATTRIB_WA_SIGN) &&
+!key->use_legacy_snorm_formula) {
/* According to equation 2.2 of the ES 3.0 specification,
 * signed normalization conversion is done by:
 *
@@ -304,14 +305,12 @@ vec4_vs_visitor::vec4_vs_visitor(const struct 
brw_compiler *compiler,
  const nir_shader *shader,
  gl_clip_plane *clip_planes,
  void *mem_ctx,
- int shader_time_index,
- bool use_legacy_snorm_formula)
+ int shader_time_index)
: vec4_visitor(compiler, log_data, &key->tex, &vs_prog_data->base, shader,
   mem_ctx, false /* no_spills */, shader_time_index),
  key(key),
  vs_prog_data(vs_prog_data),
- clip_planes(clip_planes),
- use_legacy_snorm_formula(use_legacy_snorm_formula)
+ clip_planes(clip_planes)
 {
 }
 
diff --git a/src/mesa/drivers/dri/i965/brw_vs.c 
b/src/mesa/drivers/dri/i965/brw_vs.c
index 38de98f..ecaeefa 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -31,6 +31,7 @@
 
 
 #include "main/compiler.h"
+#include "main/context.h"
 #include "brw_context.h"
 #include "brw_vs.h"
 #include "brw_util.h"
@@ -329,6 +330,8 @@ brw_vs_populate_key(struct brw_context *brw,
   key->clamp_vertex_color = ctx->Light._ClampVertexColor;
}
 
+   key->use_legacy_snorm_formula = !_mesa_is_gles3(&brw->ctx);
+
/* _NEW_POINT */
if (brw->gen < 6 && ctx->Point.PointSprite) {
   for (i = 0; i < 8; i++) {
diff --git a/src/mesa/drivers/dri/i965/brw_vs.h 
b/src/mesa/drivers/dri/i965/brw_vs.h
index c927cac..8cf9fa1 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.h
+++ b/src/mesa/drivers/dri/i965/brw_vs.h
@@ -91,8 +91,7 @@ public:
const nir_shader *shader,
gl_clip_plane *clip_planes,
void *mem_ctx,
-   int shader_time_index,
-   bool use_legacy_snorm_formula);
+   int shader_time_index);
 
 protected:
virtual dst_reg *make_reg_for_system_value(int location,
@@ -113,8 +112,6 @@ private:
struct brw_vs_prog_data * const vs_prog_data;
 
gl_clip_plane *clip_planes;
-
-   bool use_legacy_snorm_formula;
 };
 
 } /* namespace brw */
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 01/17] i965/asm: Explicitly use a nir_instr for IR annotations

2015-10-08 Thread Jason Ekstrand
Now that everything goes through NIR, we don't need this to be a void
pointer anymore.
---
 src/mesa/drivers/dri/i965/brw_fs_generator.cpp   |  2 +-
 src/mesa/drivers/dri/i965/brw_vec4_generator.cpp |  2 +-
 src/mesa/drivers/dri/i965/intel_asm_annotation.c | 17 ++---
 src/mesa/drivers/dri/i965/intel_asm_annotation.h |  3 +--
 4 files changed, 5 insertions(+), 19 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
index 6f8b75e..93ff5b1 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
@@ -2188,7 +2188,7 @@ fs_generator::generate_code(const cfg_t *cfg, int 
dispatch_width)
   100.0f * (before_size - after_size) / before_size);
 
   dump_assembly(p->store, annotation.ann_count, annotation.ann,
-p->devinfo, prog);
+p->devinfo);
   ralloc_free(annotation.ann);
}
 
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
index dcacc90..2a1e415 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp
@@ -1663,7 +1663,7 @@ vec4_generator::generate_code(const cfg_t *cfg)
   100.0f * (before_size - after_size) / before_size);
 
   dump_assembly(p->store, annotation.ann_count, annotation.ann,
-p->devinfo, prog);
+p->devinfo);
   ralloc_free(annotation.ann);
}
 
diff --git a/src/mesa/drivers/dri/i965/intel_asm_annotation.c 
b/src/mesa/drivers/dri/i965/intel_asm_annotation.c
index bb8bb8d..b3d6324 100644
--- a/src/mesa/drivers/dri/i965/intel_asm_annotation.c
+++ b/src/mesa/drivers/dri/i965/intel_asm_annotation.c
@@ -33,8 +33,7 @@
 
 void
 dump_assembly(void *assembly, int num_annotations, struct annotation 
*annotation,
-  const struct brw_device_info *devinfo,
-  const struct gl_program *prog)
+  const struct brw_device_info *devinfo)
 {
const char *last_annotation_string = NULL;
const void *last_annotation_ir = NULL;
@@ -57,19 +56,7 @@ dump_assembly(void *assembly, int num_annotations, struct 
annotation *annotation
  last_annotation_ir = annotation[i].ir;
  if (last_annotation_ir) {
 fprintf(stderr, "   ");
-if (prog->nir)
-   nir_print_instr(annotation[i].ir, stderr);
-else if (!prog->Instructions)
-   fprint_ir(stderr, annotation[i].ir);
-else {
-   const struct prog_instruction *pi =
-  (const struct prog_instruction *)annotation[i].ir;
-   fprintf(stderr, "%d: ",
-   (int)(pi - prog->Instructions));
-   _mesa_fprint_instruction_opt(stderr,
-pi,
-0, PROG_PRINT_DEBUG, NULL);
-}
+nir_print_instr(annotation[i].ir, stderr);
 fprintf(stderr, "\n");
  }
   }
diff --git a/src/mesa/drivers/dri/i965/intel_asm_annotation.h 
b/src/mesa/drivers/dri/i965/intel_asm_annotation.h
index d9c69bc..6c72326 100644
--- a/src/mesa/drivers/dri/i965/intel_asm_annotation.h
+++ b/src/mesa/drivers/dri/i965/intel_asm_annotation.h
@@ -60,8 +60,7 @@ struct annotation_info {
 
 void
 dump_assembly(void *assembly, int num_annotations, struct annotation 
*annotation,
-  const struct brw_device_info *devinfo,
-  const struct gl_program *prog);
+  const struct brw_device_info *devinfo);
 
 void
 annotate(const struct brw_device_info *devinfo,
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 15/17] i965/fs: Move some of the prog_data setup into brw_wm_emit

2015-10-08 Thread Jason Ekstrand
This commit moves the common/modern stuff.  Some legacy stuff such as
setting use_alt_mode was left because it needs to know whether or not we're
an ARB program.
---
 src/mesa/drivers/dri/i965/brw_fs.cpp | 98 
 src/mesa/drivers/dri/i965/brw_wm.c   | 98 
 2 files changed, 98 insertions(+), 98 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 146f4b4..0e39b50 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -5114,6 +5114,90 @@ fs_visitor::run_cs()
return !failed;
 }
 
+/**
+ * Return a bitfield where bit n is set if barycentric interpolation mode n
+ * (see enum brw_wm_barycentric_interp_mode) is needed by the fragment shader.
+ */
+static unsigned
+brw_compute_barycentric_interp_modes(const struct brw_device_info *devinfo,
+ bool shade_model_flat,
+ bool persample_shading,
+ const nir_shader *shader)
+{
+   unsigned barycentric_interp_modes = 0;
+
+   nir_foreach_variable(var, &shader->inputs) {
+  enum glsl_interp_qualifier interp_qualifier =
+ (enum glsl_interp_qualifier)var->data.interpolation;
+  bool is_centroid = var->data.centroid && !persample_shading;
+  bool is_sample = var->data.sample || persample_shading;
+  bool is_gl_Color = (var->data.location == VARYING_SLOT_COL0) ||
+ (var->data.location == VARYING_SLOT_COL1);
+
+  /* Ignore WPOS and FACE, because they don't require interpolation. */
+  if (var->data.location == VARYING_SLOT_POS ||
+  var->data.location == VARYING_SLOT_FACE)
+ continue;
+
+  /* Determine the set (or sets) of barycentric coordinates needed to
+   * interpolate this variable.  Note that when
+   * brw->needs_unlit_centroid_workaround is set, centroid interpolation
+   * uses PIXEL interpolation for unlit pixels and CENTROID interpolation
+   * for lit pixels, so we need both sets of barycentric coordinates.
+   */
+  if (interp_qualifier == INTERP_QUALIFIER_NOPERSPECTIVE) {
+ if (is_centroid) {
+barycentric_interp_modes |=
+   1 << BRW_WM_NONPERSPECTIVE_CENTROID_BARYCENTRIC;
+ } else if (is_sample) {
+barycentric_interp_modes |=
+   1 << BRW_WM_NONPERSPECTIVE_SAMPLE_BARYCENTRIC;
+ }
+ if ((!is_centroid && !is_sample) ||
+ devinfo->needs_unlit_centroid_workaround) {
+barycentric_interp_modes |=
+   1 << BRW_WM_NONPERSPECTIVE_PIXEL_BARYCENTRIC;
+ }
+  } else if (interp_qualifier == INTERP_QUALIFIER_SMOOTH ||
+ (!(shade_model_flat && is_gl_Color) &&
+  interp_qualifier == INTERP_QUALIFIER_NONE)) {
+ if (is_centroid) {
+barycentric_interp_modes |=
+   1 << BRW_WM_PERSPECTIVE_CENTROID_BARYCENTRIC;
+ } else if (is_sample) {
+barycentric_interp_modes |=
+   1 << BRW_WM_PERSPECTIVE_SAMPLE_BARYCENTRIC;
+ }
+ if ((!is_centroid && !is_sample) ||
+ devinfo->needs_unlit_centroid_workaround) {
+barycentric_interp_modes |=
+   1 << BRW_WM_PERSPECTIVE_PIXEL_BARYCENTRIC;
+ }
+  }
+   }
+
+   return barycentric_interp_modes;
+}
+
+static uint8_t
+computed_depth_mode(const nir_shader *shader)
+{
+   if (shader->info.outputs_written & BITFIELD64_BIT(FRAG_RESULT_DEPTH)) {
+  switch (shader->info.fs.depth_layout) {
+  case FRAG_DEPTH_LAYOUT_NONE:
+  case FRAG_DEPTH_LAYOUT_ANY:
+ return BRW_PSCDEPTH_ON;
+  case FRAG_DEPTH_LAYOUT_GREATER:
+ return BRW_PSCDEPTH_ON_GE;
+  case FRAG_DEPTH_LAYOUT_LESS:
+ return BRW_PSCDEPTH_ON_LE;
+  case FRAG_DEPTH_LAYOUT_UNCHANGED:
+ return BRW_PSCDEPTH_OFF;
+  }
+   }
+   return BRW_PSCDEPTH_OFF;
+}
+
 const unsigned *
 brw_wm_fs_emit(const struct brw_compiler *compiler, void *log_data,
void *mem_ctx,
@@ -5126,6 +5210,20 @@ brw_wm_fs_emit(const struct brw_compiler *compiler, void 
*log_data,
unsigned *final_assembly_size,
char **error_str)
 {
+   /* key->alpha_test_func means simulating alpha testing via discards,
+* so the shader definitely kills pixels.
+*/
+   prog_data->uses_kill = shader->info.fs.uses_discard || key->alpha_test_func;
+   prog_data->uses_omask =
+  shader->info.outputs_written & BITFIELD64_BIT(FRAG_RESULT_SAMPLE_MASK);
+   prog_data->computed_depth_mode = computed_depth_mode(shader);
+
+   prog_data->barycentric_interp_modes =
+  brw_compute_barycentric_interp_modes(compiler->devinfo,
+   key->flat_shade,
+   key->persample_shading,
+   sha

[Mesa-dev] [PATCH 06/17] nir/info: Add a few bits of info for fragment shaders

2015-10-08 Thread Jason Ekstrand
---
 src/glsl/nir/glsl_to_nir.cpp   |  9 +
 src/glsl/nir/nir.h | 13 +
 src/mesa/program/prog_to_nir.c |  6 ++
 3 files changed, 28 insertions(+)

diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp
index e4aa709..ddacb4e 100644
--- a/src/glsl/nir/glsl_to_nir.cpp
+++ b/src/glsl/nir/glsl_to_nir.cpp
@@ -173,6 +173,15 @@ glsl_to_nir(const struct gl_shader_program *shader_prog,
   shader->info.gs.invocations = sh->Geom.Invocations;
   break;
 
+   case MESA_SHADER_FRAGMENT: {
+  struct gl_fragment_program *fp =
+ (struct gl_fragment_program *)sh->Program;
+
+  shader->info.fs.uses_discard = fp->UsesKill;
+  shader->info.fs.early_fragment_tests = sh->EarlyFragmentTests;
+  shader->info.fs.depth_layout = fp->FragDepthLayout;
+   }
+
case MESA_SHADER_COMPUTE: {
   struct gl_compute_program *cp = (struct gl_compute_program *)sh->Program;
   shader->info.cs.local_size[0] = cp->LocalSize[0];
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index 2ce958a..14f5535 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -1503,6 +1503,19 @@ typedef struct nir_shader_info {
   } gs;
 
   struct {
+ bool uses_discard;
+
+ /**
+  * Whether early fragment tests are enabled as defined by
+  * ARB_shader_image_load_store.
+  */
+ bool early_fragment_tests;
+
+ /** gl_FragDepth layout for ARB_conservative_depth. */
+ enum gl_frag_depth_layout depth_layout;
+  } fs;
+
+  struct {
  unsigned local_size[3];
   } cs;
};
diff --git a/src/mesa/program/prog_to_nir.c b/src/mesa/program/prog_to_nir.c
index fc00534..3d91b3b 100644
--- a/src/mesa/program/prog_to_nir.c
+++ b/src/mesa/program/prog_to_nir.c
@@ -1135,6 +1135,12 @@ prog_to_nir(const struct gl_program *prog,
s->info.uses_clip_distance_out = false;
s->info.separate_shader = false;
 
+   if (stage == MESA_SHADER_FRAGMENT) {
+  struct gl_fragment_program *fp = (struct gl_fragment_program *)prog;
+
+  s->info.fs.uses_discard = fp->UsesKill;
+   }
+
 fail:
if (c->error) {
   ralloc_free(s);
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 00/17] i965: More compiler cleanups

2015-10-08 Thread Jason Ekstrand
This series contains even more compiler code-shuffling and cleanups.  In
particular, it gets us down to the point where we can, for the most part,
just go NIR -> binary.  It also rolls the entire compiler API into a single
header file with a bunch of structs and 6 functions.  It also reworks the
emit functions (now named compile) to set up some of prog_data for you.

Sound too good to be true?  Well, that's because it is.  I haven't had the
time or mental energy to re-work geometry shaders where most of the
interesting prog_data setup is.  Also, we still do have to pass in some
gl_program a few places to do workarounds on older hardware.  That said,
the interface between compiler and driver is a whole lot nicer than it used
to be.

Jason Ekstrand (17):
  i965/asm: Explicitly use a nir_instr for IR annotations
  nir: Add a label to nir_shader_info
  mesa: Move gl_frag_depth_layout from mtypes.h to shader_enums.h
  nir/info: Move the GS info into a stage-specific info union
  nir/info: Add compute shader local size to nir_shader_info
  nir/info: Add a few bits of info for fragment shaders
  i965/fs: Remove the gl_program from the generator
  i965/vec4: Remove gl_program and gl_shader_program from the generator
  i965: Use a const nir_shader in backend_shader
  i965/vs: Move use_legacy_snorm_formula into the shader key
  i965/fs: Rework wm_fs_emit to take a nir_shader and a brw_compiler
  i965/vs: Rework vs_emit to take a nir_shader and a brw_compiler
  i965/gs: Rework gs_emit to take a nir_shader and a brw_compiler
  i965/cs: Rework cs_emit to take a nir_shader and a brw_compiler
  i965/fs: Move some of the prog_data setup into brw_wm_emit
  i965: Rename brw_foo_emit to brw_compile_foo
  i965: Move the entire compiler API into a single file

 src/glsl/nir/glsl_to_nir.cpp  |  31 +-
 src/glsl/nir/nir.h|  34 ++-
 src/glsl/nir/nir_sweep.c  |   2 +
 src/glsl/shader_enums.h   |  17 ++
 src/mesa/drivers/dri/i965/Makefile.sources|   1 +
 src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp   |   2 +-
 src/mesa/drivers/dri/i965/brw_context.c   |   2 +-
 src/mesa/drivers/dri/i965/brw_context.h   | 353 +-
 src/mesa/drivers/dri/i965/brw_cs.c|  10 +-
 src/mesa/drivers/dri/i965/brw_cs.h|  15 -
 src/mesa/drivers/dri/i965/brw_fs.cpp  | 216 +
 src/mesa/drivers/dri/i965/brw_fs.h|   5 +-
 src/mesa/drivers/dri/i965/brw_fs_generator.cpp|   5 +-
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp  |   2 +-
 src/mesa/drivers/dri/i965/brw_gs.c|   6 +-
 src/mesa/drivers/dri/i965/brw_program.h   | 124 +---
 src/mesa/drivers/dri/i965/brw_shader.cpp  |   2 +-
 src/mesa/drivers/dri/i965/brw_shader.h|  62 +---
 src/mesa/drivers/dri/i965/brw_vec4.cpp|  76 ++---
 src/mesa/drivers/dri/i965/brw_vec4.h  |  12 +-
 src/mesa/drivers/dri/i965/brw_vec4_generator.cpp  |  26 +-
 src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp |  64 ++--
 src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h   |  32 +-
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp|   2 +-
 src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp |  11 +-
 src/mesa/drivers/dri/i965/brw_vs.c|  17 +-
 src/mesa/drivers/dri/i965/brw_vs.h|  15 +-
 src/mesa/drivers/dri/i965/brw_wm.c| 112 +--
 src/mesa/drivers/dri/i965/brw_wm.h|  15 -
 src/mesa/drivers/dri/i965/gen6_gs_visitor.h   |   2 +-
 src/mesa/drivers/dri/i965/intel_asm_annotation.c  |  17 +-
 src/mesa/drivers/dri/i965/intel_asm_annotation.h  |   3 +-
 src/mesa/main/mtypes.h|  18 --
 src/mesa/program/prog_to_nir.c|   6 +
 34 files changed, 370 insertions(+), 947 deletions(-)

-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 02/17] nir: Add a label to nir_shader_info

2015-10-08 Thread Jason Ekstrand
---
 src/glsl/nir/glsl_to_nir.cpp | 2 ++
 src/glsl/nir/nir.h   | 3 +++
 src/glsl/nir/nir_sweep.c | 2 ++
 3 files changed, 7 insertions(+)

diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp
index efaa73e..cdae2d1 100644
--- a/src/glsl/nir/glsl_to_nir.cpp
+++ b/src/glsl/nir/glsl_to_nir.cpp
@@ -151,6 +151,8 @@ glsl_to_nir(const struct gl_shader_program *shader_prog,
  num_textures = i;
 
shader->info.name = ralloc_asprintf(shader, "GLSL%d", sh->Name);
+   if (shader_prog->Label)
+  shader->info.label = ralloc_strdup(shader, shader_prog->Label);
shader->info.num_textures = num_textures;
shader->info.num_ubos = sh->NumUniformBlocks;
shader->info.num_abos = shader_prog->NumAtomicBuffers;
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index bde9f49..b9f549b 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -1460,6 +1460,9 @@ typedef struct nir_shader_compiler_options {
 typedef struct nir_shader_info {
const char *name;
 
+   /* Descriptive name provided by the client; may be NULL */
+   const char *label;
+
/* Number of textures used by this shader */
unsigned num_textures;
/* Number of uniform buffers used by this shader */
diff --git a/src/glsl/nir/nir_sweep.c b/src/glsl/nir/nir_sweep.c
index b6ce43b..5a22f50 100644
--- a/src/glsl/nir/nir_sweep.c
+++ b/src/glsl/nir/nir_sweep.c
@@ -155,6 +155,8 @@ nir_sweep(nir_shader *nir)
ralloc_adopt(rubbish, nir);
 
ralloc_steal(nir, (char *)nir->info.name);
+   if (nir->info.label)
+  ralloc_steal(nir, (char *)nir->info.label);
 
/* Variables and registers are not dead.  Steal them back. */
steal_list(nir, nir_variable, &nir->uniforms);
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH 09/17] i965: Use a const nir_shader in backend_shader

2015-10-08 Thread Jason Ekstrand
---
 src/mesa/drivers/dri/i965/brw_fs.h| 2 +-
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp  | 2 +-
 src/mesa/drivers/dri/i965/brw_shader.cpp  | 2 +-
 src/mesa/drivers/dri/i965/brw_shader.h| 4 ++--
 src/mesa/drivers/dri/i965/brw_vec4.h  | 2 +-
 src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp | 2 +-
 src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h   | 2 +-
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp| 2 +-
 src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp | 2 +-
 src/mesa/drivers/dri/i965/brw_vs.h| 2 +-
 src/mesa/drivers/dri/i965/gen6_gs_visitor.h   | 2 +-
 11 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.h 
b/src/mesa/drivers/dri/i965/brw_fs.h
index 61b6ee6..96b94c6 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -96,7 +96,7 @@ public:
   const void *key,
   struct brw_stage_prog_data *prog_data,
   struct gl_program *prog,
-  nir_shader *shader,
+  const nir_shader *shader,
   unsigned dispatch_width,
   int shader_time_index);
 
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index df1a7ed..ed78382 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -1069,7 +1069,7 @@ fs_visitor::fs_visitor(const struct brw_compiler 
*compiler, void *log_data,
const void *key,
struct brw_stage_prog_data *prog_data,
struct gl_program *prog,
-   nir_shader *shader,
+   const nir_shader *shader,
unsigned dispatch_width,
int shader_time_index)
: backend_shader(compiler, log_data, mem_ctx, shader, prog_data),
diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp 
b/src/mesa/drivers/dri/i965/brw_shader.cpp
index 0f743fb..1d571b5 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -657,7 +657,7 @@ brw_abs_immediate(enum brw_reg_type type, struct brw_reg 
*reg)
 backend_shader::backend_shader(const struct brw_compiler *compiler,
void *log_data,
void *mem_ctx,
-   nir_shader *shader,
+   const nir_shader *shader,
struct brw_stage_prog_data *stage_prog_data)
: compiler(compiler),
  log_data(log_data),
diff --git a/src/mesa/drivers/dri/i965/brw_shader.h 
b/src/mesa/drivers/dri/i965/brw_shader.h
index ad2de5e..6d4cf04 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.h
+++ b/src/mesa/drivers/dri/i965/brw_shader.h
@@ -225,7 +225,7 @@ protected:
backend_shader(const struct brw_compiler *compiler,
   void *log_data,
   void *mem_ctx,
-  nir_shader *shader,
+  const nir_shader *shader,
   struct brw_stage_prog_data *stage_prog_data);
 
 public:
@@ -234,7 +234,7 @@ public:
void *log_data; /* Passed to compiler->*_log functions */
 
const struct brw_device_info * const devinfo;
-   nir_shader *nir;
+   const nir_shader *nir;
struct brw_stage_prog_data * const stage_prog_data;
 
/** ralloc context for temporary data used during compile */
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h 
b/src/mesa/drivers/dri/i965/brw_vec4.h
index cf9ec0a..d861b2e 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -72,7 +72,7 @@ public:
 void *log_data,
 const struct brw_sampler_prog_key_data *key,
 struct brw_vue_prog_data *prog_data,
-nir_shader *shader,
+const nir_shader *shader,
void *mem_ctx,
 bool no_spills,
 int shader_time_index);
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
index 2136b51..c127280 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp
@@ -37,7 +37,7 @@ namespace brw {
 vec4_gs_visitor::vec4_gs_visitor(const struct brw_compiler *compiler,
  void *log_data,
  struct brw_gs_compile *c,
- nir_shader *shader,
+ const nir_shader *shader,
  void *mem_ctx,
  bool no_spills,
  int shader_time_index)
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h 
b/src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h
index 3ff195c..d75e480 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_

[Mesa-dev] [PATCH 16/17] i965: Rename brw_foo_emit to brw_compile_foo

2015-10-08 Thread Jason Ekstrand
---
 src/mesa/drivers/dri/i965/brw_cs.c|  6 +++---
 src/mesa/drivers/dri/i965/brw_cs.h| 16 
 src/mesa/drivers/dri/i965/brw_fs.cpp  | 18 +-
 src/mesa/drivers/dri/i965/brw_gs.c|  6 +++---
 src/mesa/drivers/dri/i965/brw_vec4.cpp| 18 +-
 src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp | 16 
 src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h   | 17 +
 src/mesa/drivers/dri/i965/brw_vs.c|  8 
 src/mesa/drivers/dri/i965/brw_vs.h| 18 +-
 src/mesa/drivers/dri/i965/brw_wm.c|  2 +-
 src/mesa/drivers/dri/i965/brw_wm.h|  2 +-
 11 files changed, 64 insertions(+), 63 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_cs.c 
b/src/mesa/drivers/dri/i965/brw_cs.c
index 12e7509..263d224 100644
--- a/src/mesa/drivers/dri/i965/brw_cs.c
+++ b/src/mesa/drivers/dri/i965/brw_cs.c
@@ -106,9 +106,9 @@ brw_codegen_cs_prog(struct brw_context *brw,
   st_index = brw_get_shader_time_index(brw, prog, &cp->program.Base, 
ST_CS);
 
char *error_str;
-   program = brw_cs_emit(brw->intelScreen->compiler, brw, mem_ctx,
- key, &prog_data, cp->program.Base.nir,
- st_index, &program_size, &error_str);
+   program = brw_compile_cs(brw->intelScreen->compiler, brw, mem_ctx,
+key, &prog_data, cp->program.Base.nir,
+st_index, &program_size, &error_str);
if (program == NULL) {
   prog->LinkStatus = false;
   ralloc_strcat(&prog->InfoLog, error_str);
diff --git a/src/mesa/drivers/dri/i965/brw_cs.h 
b/src/mesa/drivers/dri/i965/brw_cs.h
index 1a9613e..aac519f 100644
--- a/src/mesa/drivers/dri/i965/brw_cs.h
+++ b/src/mesa/drivers/dri/i965/brw_cs.h
@@ -42,14 +42,14 @@ brw_upload_cs_prog(struct brw_context *brw);
 struct nir_shader;
 
 const unsigned *
-brw_cs_emit(const struct brw_compiler *compiler, void *log_data,
-void *mem_ctx,
-const struct brw_cs_prog_key *key,
-struct brw_cs_prog_data *prog_data,
-const struct nir_shader *shader,
-int shader_time_index,
-unsigned *final_assembly_size,
-char **error_str);
+brw_compile_cs(const struct brw_compiler *compiler, void *log_data,
+   void *mem_ctx,
+   const struct brw_cs_prog_key *key,
+   struct brw_cs_prog_data *prog_data,
+   const struct nir_shader *shader,
+   int shader_time_index,
+   unsigned *final_assembly_size,
+   char **error_str);
 
 void
 brw_cs_fill_local_id_payload(const struct brw_cs_prog_data *cs_prog_data,
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 0e39b50..23d6a3a 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -5199,7 +5199,7 @@ computed_depth_mode(const nir_shader *shader)
 }
 
 const unsigned *
-brw_wm_fs_emit(const struct brw_compiler *compiler, void *log_data,
+brw_compile_fs(const struct brw_compiler *compiler, void *log_data,
void *mem_ctx,
const struct brw_wm_prog_key *key,
struct brw_wm_prog_data *prog_data,
@@ -5354,14 +5354,14 @@ fs_visitor::emit_cs_work_group_id_setup()
 }
 
 const unsigned *
-brw_cs_emit(const struct brw_compiler *compiler, void *log_data,
-void *mem_ctx,
-const struct brw_cs_prog_key *key,
-struct brw_cs_prog_data *prog_data,
-const nir_shader *shader,
-int shader_time_index,
-unsigned *final_assembly_size,
-char **error_str)
+brw_compile_cs(const struct brw_compiler *compiler, void *log_data,
+   void *mem_ctx,
+   const struct brw_cs_prog_key *key,
+   struct brw_cs_prog_data *prog_data,
+   const nir_shader *shader,
+   int shader_time_index,
+   unsigned *final_assembly_size,
+   char **error_str)
 {
prog_data->local_size[0] = shader->info.cs.local_size[0];
prog_data->local_size[1] = shader->info.cs.local_size[1];
diff --git a/src/mesa/drivers/dri/i965/brw_gs.c 
b/src/mesa/drivers/dri/i965/brw_gs.c
index 469a6fb..10a7f28 100644
--- a/src/mesa/drivers/dri/i965/brw_gs.c
+++ b/src/mesa/drivers/dri/i965/brw_gs.c
@@ -303,9 +303,9 @@ brw_codegen_gs_prog(struct brw_context *brw,
unsigned program_size;
char *error_str;
const unsigned *program =
-  brw_gs_emit(brw->intelScreen->compiler, brw, &c,
-  shader->Program->nir, prog,
-  mem_ctx, st_index, &program_size, &error_str);
+  brw_compile_gs(brw->intelScreen->compiler, brw, &c,
+ shader->Program->nir, prog,
+ mem_ctx, st_index, &program_size, &error_str);
if (program == 

Re: [Mesa-dev] [PATCH 1/7] glsl: move gl_shader_stage_name() definition to shader_enums.h

2015-10-08 Thread Rob Clark
On Thu, Oct 8, 2015 at 1:52 PM, Emil Velikov  wrote:
> On 8 October 2015 at 18:08, Ilia Mirkin  wrote:
>> On Thu, Oct 8, 2015 at 1:09 PM, Emil Velikov  
>> wrote:
>>> This is a trivial enough function that can live in the header. While
>>> we're here, add a STATIC_ASSERT for good measure.
>>>
>>> Signed-off-by: Emil Velikov 
>>> ---
>>>  src/glsl/shader_enums.c | 13 -
>>>  src/glsl/shader_enums.h | 23 +--
>>>  2 files changed, 21 insertions(+), 15 deletions(-)
>>>
>>> diff --git a/src/glsl/shader_enums.c b/src/glsl/shader_enums.c
>>> index c196b79..b3da3e9 100644
>>> --- a/src/glsl/shader_enums.c
>>> +++ b/src/glsl/shader_enums.c
>>> @@ -32,19 +32,6 @@
>>>  #define ENUM(x) [x] = #x
>>>  #define NAME(val) val) < ARRAY_SIZE(names)) && names[(val)]) ? 
>>> names[(val)] : "UNKNOWN")
>>>
>>> -const char * gl_shader_stage_name(gl_shader_stage stage)
>>> -{
>>> -   static const char *names[] = {
>>> -  ENUM(MESA_SHADER_VERTEX),
>>> -  ENUM(MESA_SHADER_TESS_CTRL),
>>> -  ENUM(MESA_SHADER_TESS_EVAL),
>>> -  ENUM(MESA_SHADER_GEOMETRY),
>>> -  ENUM(MESA_SHADER_FRAGMENT),
>>> -  ENUM(MESA_SHADER_COMPUTE),
>>> -   };
>>> -   return NAME(stage);
>>> -}
>>> -
>>>  const char * gl_vert_attrib_name(gl_vert_attrib attrib)
>>>  {
>>> static const char *names[] = {
>>> diff --git a/src/glsl/shader_enums.h b/src/glsl/shader_enums.h
>>> index 2a5d2c5..fbd2744 100644
>>> --- a/src/glsl/shader_enums.h
>>> +++ b/src/glsl/shader_enums.h
>>> @@ -43,10 +43,27 @@ typedef enum
>>> MESA_SHADER_COMPUTE = 5,
>>>  } gl_shader_stage;
>>>
>>> -const char * gl_shader_stage_name(gl_shader_stage stage);
>>> -
>>>  #define MESA_SHADER_STAGES (MESA_SHADER_COMPUTE + 1)
>>>
>>> +#define ENUM(x) [x] = #x
>>> +
>>> +static const char *gl_shader_stage_names[] = {
>>> +   ENUM(MESA_SHADER_VERTEX),
>>> +   ENUM(MESA_SHADER_TESS_CTRL),
>>> +   ENUM(MESA_SHADER_TESS_EVAL),
>>> +   ENUM(MESA_SHADER_GEOMETRY),
>>> +   ENUM(MESA_SHADER_FRAGMENT),
>>> +   ENUM(MESA_SHADER_COMPUTE),
>>> +};
>>
>> Won't this bloat the binary by including this in every object file? I
>> don't know that the array will get merged. (The strings will though.)
>> Normally these things live in c files so that they're stored in only
>> one object.
>>
> The linker (with its garbage collector) will sort it out for us. Seems
> like we do get a small increase from the series
>
>textdata bss dec hex filename
> 5103374  204048   27648 5335070  51681e i965_dri.so.after
> 5104590  204208   27648 5336446  516d7e i965_dri.so.before
>
> Namely - we gain ~1.2k of text. Which imho doesn't sound that bad ?

fwiw, I wanted to mention that it going to be worse than that if you
build freedreno, since many of the shader_enum to string fxns will be
called in both nir_print and in freedreno.. and probably at some point
Eric might start wanting to use them for better error msgs in vc4, so
an arm megadriver build would end up w/ 3 copies of most of the fxns
and the string tables they reference.  Likewise, I guess i965 would
get worse if it started using some of these fxns too.  That is why I
mentioned earlier that this should be at most a temporary solution.

(But moving shader_enums into NIR turned out to be relatively easy so
I guess we can avoid the static-inline temporary soln now..)

BR,
-R

> Emil
> ___
> 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/7] glsl: move gl_shader_stage_name() definition to shader_enums.h

2015-10-08 Thread Rob Clark
On Thu, Oct 8, 2015 at 6:29 PM, Ilia Mirkin  wrote:
> On Thu, Oct 8, 2015 at 3:57 PM, Emil Velikov  wrote:
>> On 8 October 2015 at 19:38, Ilia Mirkin  wrote:
>>> On Thu, Oct 8, 2015 at 2:34 PM, Emil Velikov  
>>> wrote:
 On 8 October 2015 at 19:32, Ilia Mirkin  wrote:
> On Thu, Oct 8, 2015 at 2:23 PM, Emil Velikov  
> wrote:
>> On 8 October 2015 at 18:57, Ilia Mirkin  wrote:
>>> On Thu, Oct 8, 2015 at 1:52 PM, Emil Velikov  
>>> wrote:
 On 8 October 2015 at 18:08, Ilia Mirkin  wrote:
> On Thu, Oct 8, 2015 at 1:09 PM, Emil Velikov 
>  wrote:
>> This is a trivial enough function that can live in the header. While
>> we're here, add a STATIC_ASSERT for good measure.
>>
>> Signed-off-by: Emil Velikov 
>> ---
>>  src/glsl/shader_enums.c | 13 -
>>  src/glsl/shader_enums.h | 23 +--
>>  2 files changed, 21 insertions(+), 15 deletions(-)
>>
>> diff --git a/src/glsl/shader_enums.c b/src/glsl/shader_enums.c
>> index c196b79..b3da3e9 100644
>> --- a/src/glsl/shader_enums.c
>> +++ b/src/glsl/shader_enums.c
>> @@ -32,19 +32,6 @@
>>  #define ENUM(x) [x] = #x
>>  #define NAME(val) val) < ARRAY_SIZE(names)) && names[(val)]) ? 
>> names[(val)] : "UNKNOWN")
>>
>> -const char * gl_shader_stage_name(gl_shader_stage stage)
>> -{
>> -   static const char *names[] = {
>> -  ENUM(MESA_SHADER_VERTEX),
>> -  ENUM(MESA_SHADER_TESS_CTRL),
>> -  ENUM(MESA_SHADER_TESS_EVAL),
>> -  ENUM(MESA_SHADER_GEOMETRY),
>> -  ENUM(MESA_SHADER_FRAGMENT),
>> -  ENUM(MESA_SHADER_COMPUTE),
>> -   };
>> -   return NAME(stage);
>> -}
>> -
>>  const char * gl_vert_attrib_name(gl_vert_attrib attrib)
>>  {
>> static const char *names[] = {
>> diff --git a/src/glsl/shader_enums.h b/src/glsl/shader_enums.h
>> index 2a5d2c5..fbd2744 100644
>> --- a/src/glsl/shader_enums.h
>> +++ b/src/glsl/shader_enums.h
>> @@ -43,10 +43,27 @@ typedef enum
>> MESA_SHADER_COMPUTE = 5,
>>  } gl_shader_stage;
>>
>> -const char * gl_shader_stage_name(gl_shader_stage stage);
>> -
>>  #define MESA_SHADER_STAGES (MESA_SHADER_COMPUTE + 1)
>>
>> +#define ENUM(x) [x] = #x
>> +
>> +static const char *gl_shader_stage_names[] = {
>> +   ENUM(MESA_SHADER_VERTEX),
>> +   ENUM(MESA_SHADER_TESS_CTRL),
>> +   ENUM(MESA_SHADER_TESS_EVAL),
>> +   ENUM(MESA_SHADER_GEOMETRY),
>> +   ENUM(MESA_SHADER_FRAGMENT),
>> +   ENUM(MESA_SHADER_COMPUTE),
>> +};
>
> Won't this bloat the binary by including this in every object file? I
> don't know that the array will get merged. (The strings will though.)
> Normally these things live in c files so that they're stored in only
> one object.
>
 The linker (with its garbage collector) will sort it out for us. Seems
 like we do get a small increase from the series

textdata bss dec hex filename
 5103374  204048   27648 5335070  51681e i965_dri.so.after
 5104590  204208   27648 5336446  516d7e i965_dri.so.before

 Namely - we gain ~1.2k of text. Which imho doesn't sound that bad ?
>>>
>>> In exchange for what? From what I can tell... nothing. The array
>>> definition needs to live in a c file. You can move the function to
>>> look up from it into a header, that's fine.
>>
>> Nasty bug in(?) autohell [1]. If you're happy to dive in the auto*
>> boat and fix it, I would gladly purge this series :-)
>
> Well that's just asking for trouble:
>
> src/Makefile.am:glsl/shader_enums.c \
> src/mesa/Makefile.sources:  ../glsl/shader_enums.c \
>
 Yes it is nasty.

> It should just be removed from shader_enums.c and make sure that
> libglsl_util is a dep of libmesa_la and libmesagallium_la. Am I
> missing something?
 Give it a go and admire the duplicated symbols :)
>>>
>>> Errr, that was a typo. I meant it should be removed from
>>> PROGRAM_FILES. Any additional duplicated items should be removed as
>>> well.
>> Patches welcome :-) And please give the scons a test as well, just in case.
>
> Looks like Rob just sent one. Good thing I was lazy about looking into it.


yeah.. I'd like to unwind the dependency on glsl_types too, but I
figure that could wait so I sent the 'low hanging' part of just moving
shader_enums into nir..

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


Re: [Mesa-dev] [PATCH 1/7] glsl: move gl_shader_stage_name() definition to shader_enums.h

2015-10-08 Thread Ilia Mirkin
On Thu, Oct 8, 2015 at 3:57 PM, Emil Velikov  wrote:
> On 8 October 2015 at 19:38, Ilia Mirkin  wrote:
>> On Thu, Oct 8, 2015 at 2:34 PM, Emil Velikov  
>> wrote:
>>> On 8 October 2015 at 19:32, Ilia Mirkin  wrote:
 On Thu, Oct 8, 2015 at 2:23 PM, Emil Velikov  
 wrote:
> On 8 October 2015 at 18:57, Ilia Mirkin  wrote:
>> On Thu, Oct 8, 2015 at 1:52 PM, Emil Velikov  
>> wrote:
>>> On 8 October 2015 at 18:08, Ilia Mirkin  wrote:
 On Thu, Oct 8, 2015 at 1:09 PM, Emil Velikov 
  wrote:
> This is a trivial enough function that can live in the header. While
> we're here, add a STATIC_ASSERT for good measure.
>
> Signed-off-by: Emil Velikov 
> ---
>  src/glsl/shader_enums.c | 13 -
>  src/glsl/shader_enums.h | 23 +--
>  2 files changed, 21 insertions(+), 15 deletions(-)
>
> diff --git a/src/glsl/shader_enums.c b/src/glsl/shader_enums.c
> index c196b79..b3da3e9 100644
> --- a/src/glsl/shader_enums.c
> +++ b/src/glsl/shader_enums.c
> @@ -32,19 +32,6 @@
>  #define ENUM(x) [x] = #x
>  #define NAME(val) val) < ARRAY_SIZE(names)) && names[(val)]) ? 
> names[(val)] : "UNKNOWN")
>
> -const char * gl_shader_stage_name(gl_shader_stage stage)
> -{
> -   static const char *names[] = {
> -  ENUM(MESA_SHADER_VERTEX),
> -  ENUM(MESA_SHADER_TESS_CTRL),
> -  ENUM(MESA_SHADER_TESS_EVAL),
> -  ENUM(MESA_SHADER_GEOMETRY),
> -  ENUM(MESA_SHADER_FRAGMENT),
> -  ENUM(MESA_SHADER_COMPUTE),
> -   };
> -   return NAME(stage);
> -}
> -
>  const char * gl_vert_attrib_name(gl_vert_attrib attrib)
>  {
> static const char *names[] = {
> diff --git a/src/glsl/shader_enums.h b/src/glsl/shader_enums.h
> index 2a5d2c5..fbd2744 100644
> --- a/src/glsl/shader_enums.h
> +++ b/src/glsl/shader_enums.h
> @@ -43,10 +43,27 @@ typedef enum
> MESA_SHADER_COMPUTE = 5,
>  } gl_shader_stage;
>
> -const char * gl_shader_stage_name(gl_shader_stage stage);
> -
>  #define MESA_SHADER_STAGES (MESA_SHADER_COMPUTE + 1)
>
> +#define ENUM(x) [x] = #x
> +
> +static const char *gl_shader_stage_names[] = {
> +   ENUM(MESA_SHADER_VERTEX),
> +   ENUM(MESA_SHADER_TESS_CTRL),
> +   ENUM(MESA_SHADER_TESS_EVAL),
> +   ENUM(MESA_SHADER_GEOMETRY),
> +   ENUM(MESA_SHADER_FRAGMENT),
> +   ENUM(MESA_SHADER_COMPUTE),
> +};

 Won't this bloat the binary by including this in every object file? I
 don't know that the array will get merged. (The strings will though.)
 Normally these things live in c files so that they're stored in only
 one object.

>>> The linker (with its garbage collector) will sort it out for us. Seems
>>> like we do get a small increase from the series
>>>
>>>textdata bss dec hex filename
>>> 5103374  204048   27648 5335070  51681e i965_dri.so.after
>>> 5104590  204208   27648 5336446  516d7e i965_dri.so.before
>>>
>>> Namely - we gain ~1.2k of text. Which imho doesn't sound that bad ?
>>
>> In exchange for what? From what I can tell... nothing. The array
>> definition needs to live in a c file. You can move the function to
>> look up from it into a header, that's fine.
>
> Nasty bug in(?) autohell [1]. If you're happy to dive in the auto*
> boat and fix it, I would gladly purge this series :-)

 Well that's just asking for trouble:

 src/Makefile.am:glsl/shader_enums.c \
 src/mesa/Makefile.sources:  ../glsl/shader_enums.c \

>>> Yes it is nasty.
>>>
 It should just be removed from shader_enums.c and make sure that
 libglsl_util is a dep of libmesa_la and libmesagallium_la. Am I
 missing something?
>>> Give it a go and admire the duplicated symbols :)
>>
>> Errr, that was a typo. I meant it should be removed from
>> PROGRAM_FILES. Any additional duplicated items should be removed as
>> well.
> Patches welcome :-) And please give the scons a test as well, just in case.

Looks like Rob just sent one. Good thing I was lazy about looking into it.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] glsl: move shader_enums into nir

2015-10-08 Thread Rob Clark
From: Rob Clark 

First step towards inverting the dependency between glsl and nir (so nir
can be used without glsl).  Also solves this issue with 'make distclean'

  Making distclean in mesa
  make[2]: Entering directory '/mnt/sdb1/Src64/Mesa-git/mesa/src/mesa'
  Makefile:2486: ../glsl/.deps/shader_enums.Plo: No such file or directory
  make[2]: *** No rule to make target '../glsl/.deps/shader_enums.Plo'. Stop.
  make[2]: Leaving directory '/mnt/sdb1/Src64/Mesa-git/mesa/src/mesa'
  Makefile:684: recipe for target 'distclean-recursive' failed
  make[1]: *** [distclean-recursive] Error 1
  make[1]: Leaving directory '/mnt/sdb1/Src64/Mesa-git/mesa/src'
  Makefile:615: recipe for target 'distclean-recursive' failed
  make: *** [distclean-recursive] Error 1

Reported-by: Andy Furniss 
Signed-off-by: Rob Clark 
---
 src/Makefile.am|   1 -
 src/gallium/auxiliary/nir/tgsi_to_nir.c|   2 +-
 .../drivers/freedreno/ir3/ir3_compiler_nir.c   |   1 -
 src/gallium/drivers/freedreno/ir3/ir3_nir.h|   1 +
 src/gallium/drivers/freedreno/ir3/ir3_shader.h |   2 +-
 src/glsl/Makefile.sources  |   7 +-
 src/glsl/nir/nir.h |   2 +-
 src/glsl/nir/shader_enums.c| 205 +
 src/glsl/nir/shader_enums.h| 476 +
 src/glsl/shader_enums.c| 205 -
 src/glsl/shader_enums.h| 476 -
 src/mesa/Makefile.sources  |   4 +-
 src/mesa/main/mtypes.h |   2 +-
 13 files changed, 691 insertions(+), 693 deletions(-)
 create mode 100644 src/glsl/nir/shader_enums.c
 create mode 100644 src/glsl/nir/shader_enums.h
 delete mode 100644 src/glsl/shader_enums.c
 delete mode 100644 src/glsl/shader_enums.h

diff --git a/src/Makefile.am b/src/Makefile.am
index 9e15cca..0d49bcd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -62,7 +62,6 @@ AM_CPPFLAGS = \
 noinst_LTLIBRARIES = libglsl_util.la
 
 libglsl_util_la_SOURCES = \
-   glsl/shader_enums.c \
mesa/main/imports.c \
mesa/program/prog_hash_table.c \
mesa/program/symbol_table.c \
diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c 
b/src/gallium/auxiliary/nir/tgsi_to_nir.c
index cf43ef2..0539cfc 100644
--- a/src/gallium/auxiliary/nir/tgsi_to_nir.c
+++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c
@@ -27,7 +27,7 @@
 #include "glsl/nir/nir_control_flow.h"
 #include "glsl/nir/nir_builder.h"
 #include "glsl/list.h"
-#include "glsl/shader_enums.h"
+#include "glsl/nir/shader_enums.h"
 
 #include "nir/tgsi_to_nir.h"
 #include "tgsi/tgsi_parse.h"
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c 
b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
index 7eddbdd..8c9234b 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
@@ -36,7 +36,6 @@
 #include "tgsi/tgsi_strings.h"
 
 #include "nir/tgsi_to_nir.h"
-#include "glsl/shader_enums.h"
 
 #include "freedreno_util.h"
 
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_nir.h 
b/src/gallium/drivers/freedreno/ir3/ir3_nir.h
index f3d3075..9950782 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_nir.h
+++ b/src/gallium/drivers/freedreno/ir3/ir3_nir.h
@@ -30,6 +30,7 @@
 #define IR3_NIR_H_
 
 #include "glsl/nir/nir.h"
+#include "glsl/nir/shader_enums.h"
 
 bool ir3_nir_lower_if_else(nir_shader *shader);
 
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.h 
b/src/gallium/drivers/freedreno/ir3/ir3_shader.h
index 6dc0ce1..7e2c27d 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_shader.h
+++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.h
@@ -30,7 +30,7 @@
 #define IR3_SHADER_H_
 
 #include "pipe/p_state.h"
-#include "glsl/shader_enums.h"
+#include "glsl/nir/shader_enums.h"
 
 #include "ir3.h"
 #include "disasm.h"
diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
index 7083246..33ed48f 100644
--- a/src/glsl/Makefile.sources
+++ b/src/glsl/Makefile.sources
@@ -79,7 +79,9 @@ NIR_FILES = \
nir/nir_vla.h \
nir/nir_worklist.c \
nir/nir_worklist.h \
-   nir/nir_types.cpp
+   nir/nir_types.cpp \
+   nir/shader_enums.h \
+   nir/shader_enums.c
 
 # libglsl
 
@@ -203,8 +205,7 @@ LIBGLSL_FILES = \
opt_vectorize.cpp \
program.h \
s_expression.cpp \
-   s_expression.h \
-   shader_enums.h
+   s_expression.h
 
 # glsl_compiler
 
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index bde9f49..9d5bcf6 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -35,7 +35,7 @@
 #include "util/set.h"
 #include "util/bitset.h"
 #include "nir_types.h"
-#include "glsl/shader_enums.h"
+#include "shader_enums.h"
 #include 
 
 #include "nir_opcodes.h"
diff --git a/src/glsl/nir/shader_enums.c b/src/glsl/nir/shader_enums.c
new file mode 100644
index 000..3

[Mesa-dev] [PATCH 1/2] i965/gen9: Disable MCS for 1x color surfaces

2015-10-08 Thread Chad Versace
Fast color clears are disabled for gen9 (see the checks in
brw_meta_fast_clear), so there is no reason to allocate the MCS and
track its clear/resolve state.
---
 src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c 
b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index a169c41..b6e3520 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -201,6 +201,14 @@ intel_miptree_supports_non_msrt_fast_clear(struct 
brw_context *brw,
if (brw->gen < 7)
   return false;
 
+   if (brw->gen >= 9) {
+  /* FINISHME: Enable singlesample fast MCS clears on SKL after all GPU
+   * FINISHME: hangs are resolved.
+   */
+  perf_debug("singlesample fast MCS clears disabled on gen9");
+  return false;
+   }
+
if (mt->disable_aux_buffers)
   return false;
 
-- 
2.5.0.342.g44e0223

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


[Mesa-dev] [PATCH 2/2] i965/gen9: Enable rep clears on gen9

2015-10-08 Thread Chad Versace
The (gen < 9) check in brw_clear() was too broad. It disabled all types
of fast color clears:
a. singlesample rep clears
b. singlesample MCS fast clears
c. multisample MCS fast clears

The MCS clears are still buggy, but the rep clear works well. So let's
enable it.
---
 src/mesa/drivers/dri/i965/brw_clear.c   | 2 +-
 src/mesa/drivers/dri/i965/brw_meta_fast_clear.c | 5 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_clear.c 
b/src/mesa/drivers/dri/i965/brw_clear.c
index 17a745d..b011955 100644
--- a/src/mesa/drivers/dri/i965/brw_clear.c
+++ b/src/mesa/drivers/dri/i965/brw_clear.c
@@ -241,7 +241,7 @@ brw_clear(struct gl_context *ctx, GLbitfield mask)
}
 
/* Clear color buffers with fast clear or at least rep16 writes. */
-   if (brw->gen >= 6 && brw->gen < 9 && (mask & BUFFER_BITS_COLOR)) {
+   if (brw->gen >= 6 && (mask & BUFFER_BITS_COLOR)) {
   if (brw_meta_fast_clear(brw, fb, mask, partial_clear)) {
  debug_mask("blorp color", mask & BUFFER_BITS_COLOR);
  mask &= ~BUFFER_BITS_COLOR;
diff --git a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c 
b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
index eb20173..fbde3f0 100644
--- a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
+++ b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
@@ -451,6 +451,11 @@ brw_meta_fast_clear(struct brw_context *brw, struct 
gl_framebuffer *fb,
   if (irb->mt->fast_clear_state == INTEL_FAST_CLEAR_STATE_NO_MCS)
  clear_type = REP_CLEAR;
 
+  if (brw->gen >= 9 && clear_type == FAST_CLEAR) {
+ perf_debug("fast MCS clears are disabled on gen9");
+ clear_type = REP_CLEAR;
+  }
+
   /* We can't do scissored fast clears because of the restrictions on the
* fast clear rectangle size.
*/
-- 
2.5.0.342.g44e0223

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


[Mesa-dev] [PATCH 0/2] i965/gen9: Enable rep clears

2015-10-08 Thread Chad Versace
This series lives at
  git://github.com/chadversary/mesa refs/tags/skl-fast-clear-v08.01

No Piglit regressions on:
  - Skylake 0x1912 (rev 06)
  - linux 4.3-rc4
  - piglit master@2b23e7b

Chad Versace (2):
  i965/gen9: Disable MCS for 1x color surfaces
  i965/gen9: Enable rep clears on gen9

 src/mesa/drivers/dri/i965/brw_clear.c   | 2 +-
 src/mesa/drivers/dri/i965/brw_meta_fast_clear.c | 6 ++
 src/mesa/drivers/dri/i965/intel_mipmap_tree.c   | 8 
 3 files changed, 15 insertions(+), 1 deletion(-)

-- 
2.5.0.342.g44e0223

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


Re: [Mesa-dev] [PATCH 3/8] radeonsi: Enable DCC.

2015-10-08 Thread Marek Olšák
Hi Bas,

How's it going?

I've gotten a response from Catalyst devs and they're saying CMASK is
unnecessary here. If it's always cleared to 0xff, it's better to
disable it to save some bandwidth.

Also, it looks like we don't need DCC decompression at all, right? It
might be better to get rid of it and only use the 3D engine to access
DCC-encoded surfaces.

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


Re: [Mesa-dev] [PATCH 1/7] glsl: move gl_shader_stage_name() definition to shader_enums.h

2015-10-08 Thread Emil Velikov
On 8 October 2015 at 19:38, Ilia Mirkin  wrote:
> On Thu, Oct 8, 2015 at 2:34 PM, Emil Velikov  wrote:
>> On 8 October 2015 at 19:32, Ilia Mirkin  wrote:
>>> On Thu, Oct 8, 2015 at 2:23 PM, Emil Velikov  
>>> wrote:
 On 8 October 2015 at 18:57, Ilia Mirkin  wrote:
> On Thu, Oct 8, 2015 at 1:52 PM, Emil Velikov  
> wrote:
>> On 8 October 2015 at 18:08, Ilia Mirkin  wrote:
>>> On Thu, Oct 8, 2015 at 1:09 PM, Emil Velikov  
>>> wrote:
 This is a trivial enough function that can live in the header. While
 we're here, add a STATIC_ASSERT for good measure.

 Signed-off-by: Emil Velikov 
 ---
  src/glsl/shader_enums.c | 13 -
  src/glsl/shader_enums.h | 23 +--
  2 files changed, 21 insertions(+), 15 deletions(-)

 diff --git a/src/glsl/shader_enums.c b/src/glsl/shader_enums.c
 index c196b79..b3da3e9 100644
 --- a/src/glsl/shader_enums.c
 +++ b/src/glsl/shader_enums.c
 @@ -32,19 +32,6 @@
  #define ENUM(x) [x] = #x
  #define NAME(val) val) < ARRAY_SIZE(names)) && names[(val)]) ? 
 names[(val)] : "UNKNOWN")

 -const char * gl_shader_stage_name(gl_shader_stage stage)
 -{
 -   static const char *names[] = {
 -  ENUM(MESA_SHADER_VERTEX),
 -  ENUM(MESA_SHADER_TESS_CTRL),
 -  ENUM(MESA_SHADER_TESS_EVAL),
 -  ENUM(MESA_SHADER_GEOMETRY),
 -  ENUM(MESA_SHADER_FRAGMENT),
 -  ENUM(MESA_SHADER_COMPUTE),
 -   };
 -   return NAME(stage);
 -}
 -
  const char * gl_vert_attrib_name(gl_vert_attrib attrib)
  {
 static const char *names[] = {
 diff --git a/src/glsl/shader_enums.h b/src/glsl/shader_enums.h
 index 2a5d2c5..fbd2744 100644
 --- a/src/glsl/shader_enums.h
 +++ b/src/glsl/shader_enums.h
 @@ -43,10 +43,27 @@ typedef enum
 MESA_SHADER_COMPUTE = 5,
  } gl_shader_stage;

 -const char * gl_shader_stage_name(gl_shader_stage stage);
 -
  #define MESA_SHADER_STAGES (MESA_SHADER_COMPUTE + 1)

 +#define ENUM(x) [x] = #x
 +
 +static const char *gl_shader_stage_names[] = {
 +   ENUM(MESA_SHADER_VERTEX),
 +   ENUM(MESA_SHADER_TESS_CTRL),
 +   ENUM(MESA_SHADER_TESS_EVAL),
 +   ENUM(MESA_SHADER_GEOMETRY),
 +   ENUM(MESA_SHADER_FRAGMENT),
 +   ENUM(MESA_SHADER_COMPUTE),
 +};
>>>
>>> Won't this bloat the binary by including this in every object file? I
>>> don't know that the array will get merged. (The strings will though.)
>>> Normally these things live in c files so that they're stored in only
>>> one object.
>>>
>> The linker (with its garbage collector) will sort it out for us. Seems
>> like we do get a small increase from the series
>>
>>textdata bss dec hex filename
>> 5103374  204048   27648 5335070  51681e i965_dri.so.after
>> 5104590  204208   27648 5336446  516d7e i965_dri.so.before
>>
>> Namely - we gain ~1.2k of text. Which imho doesn't sound that bad ?
>
> In exchange for what? From what I can tell... nothing. The array
> definition needs to live in a c file. You can move the function to
> look up from it into a header, that's fine.

 Nasty bug in(?) autohell [1]. If you're happy to dive in the auto*
 boat and fix it, I would gladly purge this series :-)
>>>
>>> Well that's just asking for trouble:
>>>
>>> src/Makefile.am:glsl/shader_enums.c \
>>> src/mesa/Makefile.sources:  ../glsl/shader_enums.c \
>>>
>> Yes it is nasty.
>>
>>> It should just be removed from shader_enums.c and make sure that
>>> libglsl_util is a dep of libmesa_la and libmesagallium_la. Am I
>>> missing something?
>> Give it a go and admire the duplicated symbols :)
>
> Errr, that was a typo. I meant it should be removed from
> PROGRAM_FILES. Any additional duplicated items should be removed as
> well.
Patches welcome :-) And please give the scons a test as well, just in case.

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


Re: [Mesa-dev] [PATCH 12/12] i965: Link compiler unit tests to libi965_compiler.la

2015-10-08 Thread Emil Velikov
On 7 October 2015 at 15:11, Kristian Høgsberg Kristensen
 wrote:
> We can now link the unit tests against just libi965_compiler.la. This
> lets us drop a lot of DRI driver dependencies, but we still pull in all
> of libmesa and more.
>
> This also provides a few standalone users of libi965_compiler.la, which
> will help us accidentally using i965_dri.so functions from the compiler.
>
> Signed-off-by: Kristian Høgsberg Kristensen 
> ---
>  src/mesa/drivers/dri/i965/Makefile.am | 8 ++--
>  1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/Makefile.am 
> b/src/mesa/drivers/dri/i965/Makefile.am
> index 82e58a6..2e24151 100644
> --- a/src/mesa/drivers/dri/i965/Makefile.am
> +++ b/src/mesa/drivers/dri/i965/Makefile.am
> @@ -48,13 +48,9 @@ libi965_dri_la_LIBADD = libi965_compiler.la $(INTEL_LIBS)
>  libi965_compiler_la_SOURCES = $(i965_compiler_FILES)
>
>  TEST_LIBS = \
> -   libi965_dri.la \
> -   ../common/libdricommon.la \
> -   ../common/libxmlconfig.la \
> -   ../common/libmegadriver_stub.la \
> +   libi965_compiler.la \
>  ../../../libmesa.la \
> -   $(DRI_LIB_DEPS) \
> -$(CLOCK_LIB) \
> +   -lpthread -ldl \
You might want to replace these two with $(PTHREAD_LIBS) and $(DLOPEN_LIBS).

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


Re: [Mesa-dev] [RFC] Vendor-neutral dispatch library for OpenGL

2015-10-08 Thread Kyle Brenneman

On 10/08/2015 12:29 PM, Emil Velikov wrote:

On 06/10/15 20:58, Kyle Brenneman wrote:

On 10/06/2015 12:43 PM, Emil Velikov wrote:

On 6 October 2015 at 16:39, Kyle Brenneman  wrote:

On 10/06/2015 07:34 AM, Emil Velikov wrote:

Hello Kyle,

A few questions/points of discussion:

   * What is your take on having a libglvnd 'package', which provides
the headers (and maybe other materials), apart from the libraries ?
I'm basically thinking about OpenGL.h, GLX.h, etc for programs that
wish to use new ABI, and glvnd{Foo,Bar}.h which mesa and other GL
implementations.

I haven't looked much into packaging yet. I'm open to any suggestions that
might make that easier, though.

One thing that I'm planning to do but haven't gotten to yet is to move the
public headers into a separate directory. There's a couple of header files
(libglxabi.h and GLdispatchABI.h) that are intended to be used by vendor
library implementations, and the other headers are all internal.

The headers that you'd use for compiling an application (gl.h, glx.h, etc.)
could easily go into a separate package, too.


By 'packaging' I meant that the relevant files are available after
`make install'. Currently for GLdispatchABI.h and others that's not
the case. We can leave it up-to the distributions to manage the actual
packages (if in doubt a document to guide them), but we can make sure
that the files (including pkg-config and cmake ones, separate set for
user/developer) are there.

The 'make install' command currently doesn't do anything with the
regular GL headers. I would expect that if someone's building an OpenGL
application, then they've probably already installed some version of the
GL headers separately. Still, I could probably add a configure option or
something to include them.


Pretty much what I was wondering. Mostly as I've noticed that the
official Nvidia driver has started shipping some headers which clash
with mesa ones :'( Perhaps the AMD proprietary driver ships some as well ?


Including the public ABI headers in a "make install" does sound like a
good idea. Maybe put them next to the normal GL headers, or under a
GLVND subdirectory?

A separate location sounds better imho. Then again this information will
be made available via the .pc .cmake files. People that don't use them
can hardcode thing as needed :)

[snip]

   * There was an idea to expose separate libOpenGL libraries, one for
each (major?) GL version.
What happened on that front ?

Nothing as far as I know.

However, each of those libraries is basically just a thin wrapper around
libGLdispatch.so, so in theory you could define any number of libraries that
just export a different set of functions. It's more a question of how many
libraries we'd want to deal with.

 From an application standpoint, having a fixed set of libraries with a known
set of exported functions seems like the easiest option, since you could
then link your application against it and not have to modify it later.

That said, the set of functions to export from libGL.so and libOpenGL.so is
still an open question. The set right now is just what libglvnd inherited
from Mesa, but it would be good to have a more clearly-defined set. Maybe
something simple like all core OpenGL functions through version 4.5 or so?


I'm rather inclined towards "(ideally) no GL symbols should be
statically available" - just use *gl*GetProcAddress. Otherwise thing
are bound to get quite hairy.
  - Forward/backward compatibility
  - Incorrectly linked - program uses GL N, yet linked against GL N+1.
  - Developer confusion - which library do I need, how do I check for X
and not Y.
  - The easy way out - using GL N core function glFoo, link against GL
N, rather than LG N-1 + doing the extension check.

Note that libGL.so from older mesa was exposing a few too many symbols
statically, so we might want to make sure these/similar changes landed
in libglvnd.

libGLX.so itself only exports GLX 1.4 functions -- no extensions and no
OpenGL functions. If an app developer wants to, they could link against
only libGLX.so, and then use glXGetProcAddress to look up every OpenGL
function.

libOpenGL.so is there to avoid the hassle of having looking up every
OpenGL function, especially in simpler apps that don't need to use many
extension functions.

Developer confusion is why I think it would be best to define a set of
functions to export and just stick with it.

Greater confusion will come with the various different lists, imho. Esp.
since there will be some overlap but they (the lists) won't be quite the
same between the old and new ABI.

It would be easier to have a macro/helper that fetches any entry point
required via gl*GetProcAddress, rather having divergent flow based on
heuristics X.

See for example how GLEW does not always get it right, thus libepoxy was
born. I suspect a similar thing will happen for the new ABI.


As long as the set of
exported functions stays consistent between versions, then a developer
can rely on it without

[Mesa-dev] [PATCH] i965/gen8: Remove gen<8 checks in gen8 code

2015-10-08 Thread Chad Versace
Some assertions in gen8_surface_state.c checked for gen < 8.
---
 src/mesa/drivers/dri/i965/gen8_surface_state.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/gen8_surface_state.c 
b/src/mesa/drivers/dri/i965/gen8_surface_state.c
index e1e7704..18b8665 100644
--- a/src/mesa/drivers/dri/i965/gen8_surface_state.c
+++ b/src/mesa/drivers/dri/i965/gen8_surface_state.c
@@ -221,8 +221,8 @@ gen8_emit_texture_surface_state(struct brw_context *brw,
* "When Auxiliary Surface Mode is set to AUX_CCS_D or AUX_CCS_E, HALIGN
*  16 must be used."
*/
-  assert(brw->gen < 9 || mt->halign == 16);
-  assert(brw->gen < 8 || mt->num_samples > 1 || mt->halign == 16);
+  if (brw->gen >= 9 || mt->num_samples == 1)
+ assert(mt->halign == 16);
}
 
const uint32_t surf_type = translate_tex_target(target);
@@ -470,8 +470,8 @@ gen8_update_renderbuffer_surface(struct brw_context *brw,
* "When Auxiliary Surface Mode is set to AUX_CCS_D or AUX_CCS_E, HALIGN
*  16 must be used."
*/
-  assert(brw->gen < 9 || mt->halign == 16);
-  assert(brw->gen < 8 || mt->num_samples > 1 || mt->halign == 16);
+  if (brw->gen >= 9 || mt->num_samples == 1)
+ assert(mt->halign == 16);
}
 
uint32_t *surf = allocate_surface_state(brw, &offset, surf_index);
-- 
2.5.0.342.g44e0223

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


Re: [Mesa-dev] [PATCH 1/3] mesa: remove unneeded error check in create_textures()

2015-10-08 Thread Anuj Phogat
On Thu, Oct 8, 2015 at 11:01 AM, Brian Paul  wrote:
> You tested with all 3 patches and everything's OK now?
>
> I guess I'd still like an R-b on the 3rd patch ("mesa,meta: move
> gl_texture_object::TargetIndex initializations") from someone before
> pushing.
done.
>
> -Brian
>
>
> On 10/08/2015 11:57 AM, Mark Janes wrote:
>>
>> Tested-by: Mark Janes 
>>
>> Brian Paul  writes:
>>
>>> Callers of create_texture() will either pass target=0 or a validated
>>> GL texture target enum so no need to do another error check inside
>>> the loop.
>>> ---
>>>   src/mesa/main/texobj.c | 11 ++-
>>>   1 file changed, 2 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
>>> index 173e43c..aa4b38c 100644
>>> --- a/src/mesa/main/texobj.c
>>> +++ b/src/mesa/main/texobj.c
>>> @@ -1211,6 +1211,7 @@ _mesa_create_nameless_texture(struct gl_context
>>> *ctx, GLenum target)
>>>* 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.
>>> + * \param target  either 0 or a a valid / error-checked texture target
>>> enum
>>>*/
>>>   static void
>>>   create_textures(struct gl_context *ctx, GLenum target,
>>> @@ -1219,6 +1220,7 @@ create_textures(struct gl_context *ctx, GLenum
>>> target,
>>>  GLuint first;
>>>  GLint i;
>>>  const char *func = dsa ? "Create" : "Gen";
>>> +   const GLint targetIndex = _mesa_tex_target_to_index(ctx, target);
>>>
>>>  if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
>>> _mesa_debug(ctx, "gl%sTextures %d\n", func, n);
>>> @@ -1241,7 +1243,6 @@ create_textures(struct gl_context *ctx, GLenum
>>> target,
>>>  /* Allocate new, empty texture objects */
>>>  for (i = 0; i < n; i++) {
>>> struct gl_texture_object *texObj;
>>> -  GLint targetIndex;
>>> GLuint name = first + i;
>>> texObj = ctx->Driver.NewTextureObject(ctx, name, target);
>>> if (!texObj) {
>>> @@ -1252,14 +1253,6 @@ create_textures(struct gl_context *ctx, GLenum
>>> target,
>>>
>>> /* 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 =
>>> %s)",
>>> -func, _mesa_enum_to_string(texObj->Target));
>>> -return;
>>> - }
>>> - assert(targetIndex < NUM_TEXTURE_TARGETS);
>>>texObj->TargetIndex = targetIndex;
>>> }
>>>
>>> --
>>> 1.9.1
>>>
>>> ___
>>> mesa-dev mailing list
>>> mesa-dev@lists.freedesktop.org
>>>
>>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.freedesktop.org_mailman_listinfo_mesa-2Ddev&d=BQIBAg&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=T0t4QG7chq2ZwJo6wilkFznRSFy-8uDKartPGbomVj8&m=wH7wzPfX3yNt9F68zI5o07hlcSlDR3G_FNCKDirtQ2Y&s=cqrFZKT8ppra0ur69BB8607q0TMHVG6Z44hRctrib9k&e=
>
>
> ___
> 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] mesa, meta: move gl_texture_object::TargetIndex initializations

2015-10-08 Thread Anuj Phogat
On Thu, Oct 8, 2015 at 7:20 AM, Brian Paul  wrote:
> Before, we were unconditionally assigning the TargetIndex field in
> _mesa_BindTexture(), even if it was already set properly.  Now we
> initialize TargetIndex wherever we initialize the Target field, in
> _mesa_initialize_texture_object(), finish_texture_init(), etc.
>
> v2: also update the meta_copy_image code.  In make_view() the
> view_tex_obj->Target field was set, but not the TargetIndex field.
> Also, remove a second, redundant assignment to view_tex_obj->Target.
> Add sanity check assertions too.
> ---
>  src/mesa/drivers/common/meta_copy_image.c |  5 -
>  src/mesa/main/shared.c|  5 +
>  src/mesa/main/texobj.c| 27 ++-
>  src/mesa/main/textureview.c   |  2 ++
>  4 files changed, 29 insertions(+), 10 deletions(-)
>
> diff --git a/src/mesa/drivers/common/meta_copy_image.c 
> b/src/mesa/drivers/common/meta_copy_image.c
> index 33490ee..04b9caf 100644
> --- a/src/mesa/drivers/common/meta_copy_image.c
> +++ b/src/mesa/drivers/common/meta_copy_image.c
> @@ -108,7 +108,11 @@ make_view(struct gl_context *ctx, struct 
> gl_texture_image *tex_image,
>return false;
> }
>
> +   assert(tex_obj->Target != 0);
> +   assert(tex_obj->TargetIndex < NUM_TEXTURE_TARGETS);
> +
> view_tex_obj->Target = tex_obj->Target;
> +   view_tex_obj->TargetIndex = tex_obj->TargetIndex;
>
> *view_tex_image = _mesa_get_tex_image(ctx, view_tex_obj, tex_obj->Target, 
> 0);
>
> @@ -129,7 +133,6 @@ make_view(struct gl_context *ctx, struct gl_texture_image 
> *tex_image,
> view_tex_obj->NumLayers = tex_obj->NumLayers;
> view_tex_obj->Immutable = tex_obj->Immutable;
> view_tex_obj->ImmutableLevels = tex_obj->ImmutableLevels;
> -   view_tex_obj->Target = tex_obj->Target;
>
> if (ctx->Driver.TextureView != NULL &&
> !ctx->Driver.TextureView(ctx, view_tex_obj, tex_obj)) {
> diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c
> index 1acaf59..c37b31d 100644
> --- a/src/mesa/main/shared.c
> +++ b/src/mesa/main/shared.c
> @@ -107,6 +107,11 @@ _mesa_alloc_shared_state(struct gl_context *ctx)
>};
>STATIC_ASSERT(ARRAY_SIZE(targets) == NUM_TEXTURE_TARGETS);
>shared->DefaultTex[i] = ctx->Driver.NewTextureObject(ctx, 0, 
> targets[i]);
> +  /* Need to explicitly set/overwrite the TargetIndex field here since
> +   * the call to _mesa_tex_target_to_index() in NewTextureObject() may
> +   * fail if the texture target is not supported.
> +   */
> +  shared->DefaultTex[i]->TargetIndex = i;
> }
>
> /* sanity check */
> diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
> index 66eacf8..60c55ae 100644
> --- a/src/mesa/main/texobj.c
> +++ b/src/mesa/main/texobj.c
> @@ -286,6 +286,12 @@ _mesa_initialize_texture_object( struct gl_context *ctx,
> obj->RefCount = 1;
> obj->Name = name;
> obj->Target = target;
> +   if (target != 0) {
> +  obj->TargetIndex = _mesa_tex_target_to_index(ctx, target);
> +   }
> +   else {
> +  obj->TargetIndex = NUM_TEXTURE_TARGETS; /* invalid/error value */
> +   }
> obj->Priority = 1.0F;
> obj->BaseLevel = 0;
> obj->MaxLevel = 1000;
> @@ -340,6 +346,10 @@ finish_texture_init(struct gl_context *ctx, GLenum 
> target,
> GLenum filter = GL_LINEAR;
> assert(obj->Target == 0);
>
> +   obj->Target = target;
> +   obj->TargetIndex = _mesa_tex_target_to_index(ctx, target);
> +   assert(obj->TargetIndex < NUM_TEXTURE_TARGETS);
> +
> switch (target) {
>case GL_TEXTURE_2D_MULTISAMPLE:
>case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
> @@ -1200,7 +1210,6 @@ create_textures(struct gl_context *ctx, GLenum target,
> GLuint first;
> GLint i;
> const char *func = dsa ? "Create" : "Gen";
> -   const GLint targetIndex = _mesa_tex_target_to_index(ctx, target);
>
> if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
>_mesa_debug(ctx, "gl%sTextures %d\n", func, n);
> @@ -1231,11 +1240,6 @@ create_textures(struct gl_context *ctx, GLenum target,
>   return;
>}
>
> -  /* Initialize the target index if target is non-zero. */
> -  if (target != 0) {
> - texObj->TargetIndex = targetIndex;
> -  }
> -
>/* insert into hash table */
>_mesa_HashInsert(ctx->Shared->TexObjects, texObj->Name, texObj);
>
> @@ -1356,8 +1360,12 @@ unbind_texobj_from_texunits(struct gl_context *ctx,
> const gl_texture_index index = texObj->TargetIndex;
> GLuint u;
>
> -   if (texObj->Target == 0)
> +   if (texObj->Target == 0) {
> +  /* texture was never bound */
>return;
> +   }
> +
> +   assert(index < NUM_TEXTURE_TARGETS);
>
> for (u = 0; u < ctx->Texture.NumCurrentTexUsed; u++) {
>struct gl_texture_unit *unit = &ctx->Texture.Unit[u];
> @@ -1725,10 +1733,11 @@ _mesa_BindTexture( GLenum target, GLuint texName )
>   _mesa_HashInsert(ctx->Shared->TexObjects, texName, newTexObj);
>

Re: [Mesa-dev] [PATCH] i965/gen8: Drop some assertions for gen < 8

2015-10-08 Thread Chad Versace
Nevermind this patch. It contains a stupid mistake.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] i965/gen8: Drop some assertions for gen < 8

2015-10-08 Thread Chad Versace
---
 src/mesa/drivers/dri/i965/gen8_surface_state.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/gen8_surface_state.c 
b/src/mesa/drivers/dri/i965/gen8_surface_state.c
index e1e7704..1e3ae3f 100644
--- a/src/mesa/drivers/dri/i965/gen8_surface_state.c
+++ b/src/mesa/drivers/dri/i965/gen8_surface_state.c
@@ -222,7 +222,6 @@ gen8_emit_texture_surface_state(struct brw_context *brw,
*  16 must be used."
*/
   assert(brw->gen < 9 || mt->halign == 16);
-  assert(brw->gen < 8 || mt->num_samples > 1 || mt->halign == 16);
}
 
const uint32_t surf_type = translate_tex_target(target);
@@ -471,7 +470,6 @@ gen8_update_renderbuffer_surface(struct brw_context *brw,
*  16 must be used."
*/
   assert(brw->gen < 9 || mt->halign == 16);
-  assert(brw->gen < 8 || mt->num_samples > 1 || mt->halign == 16);
}
 
uint32_t *surf = allocate_surface_state(brw, &offset, surf_index);
-- 
2.5.0.342.g44e0223

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


Re: [Mesa-dev] [PATCH 12/12] i965: Link compiler unit tests to libi965_compiler.la

2015-10-08 Thread Jason Ekstrand
Looks good to me.  This patch and 12 are

Reviewed-by: Jason Ekstrand 

On Wed, Oct 7, 2015 at 7:11 AM, Kristian Høgsberg Kristensen
 wrote:
> We can now link the unit tests against just libi965_compiler.la. This
> lets us drop a lot of DRI driver dependencies, but we still pull in all
> of libmesa and more.
>
> This also provides a few standalone users of libi965_compiler.la, which
> will help us accidentally using i965_dri.so functions from the compiler.
>
> Signed-off-by: Kristian Høgsberg Kristensen 
> ---
>  src/mesa/drivers/dri/i965/Makefile.am | 8 ++--
>  1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/Makefile.am 
> b/src/mesa/drivers/dri/i965/Makefile.am
> index 82e58a6..2e24151 100644
> --- a/src/mesa/drivers/dri/i965/Makefile.am
> +++ b/src/mesa/drivers/dri/i965/Makefile.am
> @@ -48,13 +48,9 @@ libi965_dri_la_LIBADD = libi965_compiler.la $(INTEL_LIBS)
>  libi965_compiler_la_SOURCES = $(i965_compiler_FILES)
>
>  TEST_LIBS = \
> -   libi965_dri.la \
> -   ../common/libdricommon.la \
> -   ../common/libxmlconfig.la \
> -   ../common/libmegadriver_stub.la \
> +   libi965_compiler.la \
>  ../../../libmesa.la \
> -   $(DRI_LIB_DEPS) \
> -$(CLOCK_LIB) \
> +   -lpthread -ldl \
> ../common/libdri_test_stubs.la
>
>  TESTS = \
> --
> 2.4.3
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 09/12] i965: Move brw_get_shader_time_index() call out of emit functions

2015-10-08 Thread Jason Ekstrand
On Wed, Oct 7, 2015 at 7:11 AM, Kristian Høgsberg Kristensen
 wrote:
> brw_get_shader_time_index() is all tangled up in brw_context state and
> we can't call it from the compiler. Thanks the Jasons recent
> refactoring, we can just get the index and pass to the emit functions
> instead.
>
> Signed-off-by: Kristian Høgsberg Kristensen 
> ---
>  src/mesa/drivers/dri/i965/brw_cs.c|  6 +-
>  src/mesa/drivers/dri/i965/brw_cs.h|  1 +
>  src/mesa/drivers/dri/i965/brw_fs.cpp  | 12 ++--
>  src/mesa/drivers/dri/i965/brw_gs.c|  6 +-
>  src/mesa/drivers/dri/i965/brw_vec4.cpp|  5 +
>  src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp |  5 +
>  src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.h   |  1 +
>  src/mesa/drivers/dri/i965/brw_vs.c|  6 +-
>  src/mesa/drivers/dri/i965/brw_vs.h|  1 +
>  src/mesa/drivers/dri/i965/brw_wm.c|  8 +++-
>  src/mesa/drivers/dri/i965/brw_wm.h|  1 +
>  11 files changed, 30 insertions(+), 22 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_cs.c 
> b/src/mesa/drivers/dri/i965/brw_cs.c
> index 34680ee..45fb816 100644
> --- a/src/mesa/drivers/dri/i965/brw_cs.c
> +++ b/src/mesa/drivers/dri/i965/brw_cs.c
> @@ -101,8 +101,12 @@ brw_codegen_cs_prog(struct brw_context *brw,
> if (unlikely(INTEL_DEBUG & DEBUG_CS))
>brw_dump_ir("compute", prog, &cs->base, &cp->program.Base);
>
> +   int st_index = -1;
> +   if (INTEL_DEBUG & DEBUG_SHADER_TIME)
> +  st_index = brw_get_shader_time_index(brw, prog, &cp->program.Base, 
> ST_CS);
> +
> program = brw_cs_emit(brw, mem_ctx, key, &prog_data,
> - &cp->program, prog, &program_size);
> + &cp->program, prog, st_index, &program_size);
> if (program == NULL) {
>ralloc_free(mem_ctx);
>return false;
> diff --git a/src/mesa/drivers/dri/i965/brw_cs.h 
> b/src/mesa/drivers/dri/i965/brw_cs.h
> index c07eb6c..80f6e4c 100644
> --- a/src/mesa/drivers/dri/i965/brw_cs.h
> +++ b/src/mesa/drivers/dri/i965/brw_cs.h
> @@ -46,6 +46,7 @@ brw_cs_emit(struct brw_context *brw,
>  struct brw_cs_prog_data *prog_data,
>  struct gl_compute_program *cp,
>  struct gl_shader_program *prog,
> +int st_index,

Can we give the function parameters a more descriptive name such as
shader_time_index?  I don't care about the local temporaries as those
are documented by the fact that you immediately assign the result of
get_shader_time_index() to them.  However, the function arguments are
less obvious.  (Also, FWIW, it'll help me in rebasing because that's
what I named them.)

With that, and matt's whitespace change,

Reviewed-by: Jason Ekstrand 

>  unsigned *final_assembly_size);
>
>  void
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
> b/src/mesa/drivers/dri/i965/brw_fs.cpp
> index b4125aa..65c3628 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
> @@ -5121,14 +5121,9 @@ brw_wm_fs_emit(struct brw_context *brw,
> struct brw_wm_prog_data *prog_data,
> struct gl_fragment_program *fp,
> struct gl_shader_program *prog,
> +   int st_index8, int st_index16,
> unsigned *final_assembly_size)
>  {
> -   int st_index8 = -1, st_index16 = -1;
> -   if (INTEL_DEBUG & DEBUG_SHADER_TIME) {
> -  st_index8 = brw_get_shader_time_index(brw, prog, &fp->Base, ST_FS8);
> -  st_index16 = brw_get_shader_time_index(brw, prog, &fp->Base, ST_FS16);
> -   }
> -
> /* Now the main event: Visit the shader IR and generate our FS IR for it.
>  */
> fs_visitor v(brw->intelScreen->compiler, brw, mem_ctx, key,
> @@ -5273,6 +5268,7 @@ brw_cs_emit(struct brw_context *brw,
>  struct brw_cs_prog_data *prog_data,
>  struct gl_compute_program *cp,
>  struct gl_shader_program *prog,
> +int st_index,
>  unsigned *final_assembly_size)
>  {
> prog_data->local_size[0] = cp->LocalSize[0];
> @@ -5284,10 +5280,6 @@ brw_cs_emit(struct brw_context *brw,
> cfg_t *cfg = NULL;
> const char *fail_msg = NULL;
>
> -   int st_index = -1;
> -   if (INTEL_DEBUG & DEBUG_SHADER_TIME)
> -  st_index = brw_get_shader_time_index(brw, prog, &cp->Base, ST_CS);
> -
> /* Now the main event: Visit the shader IR and generate our CS IR for it.
>  */
> fs_visitor v8(brw->intelScreen->compiler, brw, mem_ctx, key,
> diff --git a/src/mesa/drivers/dri/i965/brw_gs.c 
> b/src/mesa/drivers/dri/i965/brw_gs.c
> index 26c91e4..e0165fb 100644
> --- a/src/mesa/drivers/dri/i965/brw_gs.c
> +++ b/src/mesa/drivers/dri/i965/brw_gs.c
> @@ -294,10 +294,14 @@ brw_codegen_gs_prog(struct brw_context *brw,
> if (unlikely(INTEL_DEBUG & DEBUG_GS))
>brw_dump_ir("geometry", prog, gs, NULL);
>
> +   int st_index = -1;
> +   if (INTEL_DE

Re: [Mesa-dev] [PATCH 10/12] i965/cs: Get max_cs_threads from brw_compiler devinfo

2015-10-08 Thread Jason Ekstrand
On Thu, Oct 8, 2015 at 11:35 AM, Kristian Høgsberg  wrote:
> On Wed, Oct 7, 2015 at 10:09 PM, Jason Ekstrand  wrote:
>>
>> On Oct 7, 2015 3:36 PM, "Kristian Høgsberg"  wrote:
>>>
>>> On Wed, Oct 7, 2015 at 3:11 PM, Matt Turner  wrote:
>>> > On Wed, Oct 7, 2015 at 7:11 AM, Kristian Høgsberg Kristensen
>>> >  wrote:
>>> >> Signed-off-by: Kristian Høgsberg Kristensen 
>>> >> ---
>>> >>  src/mesa/drivers/dri/i965/brw_fs.cpp | 5 +++--
>>> >>  1 file changed, 3 insertions(+), 2 deletions(-)
>>> >>
>>> >> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp
>>> >> b/src/mesa/drivers/dri/i965/brw_fs.cpp
>>> >> index 65c3628..b79b4a4 100644
>>> >> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
>>> >> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
>>> >> @@ -5276,6 +5276,7 @@ brw_cs_emit(struct brw_context *brw,
>>> >> prog_data->local_size[2] = cp->LocalSize[2];
>>> >> unsigned local_workgroup_size =
>>> >>cp->LocalSize[0] * cp->LocalSize[1] * cp->LocalSize[2];
>>> >> +   unsigned max_cs_threads =
>>> >> brw->intelScreen->compiler->devinfo->max_cs_threads;
>>> >
>>> > I'm not following how this helps? Seems like you want to just pass in
>>> > devinfo or something?
>>>
>>> We want to pass in just brw_compiler eventually. At that point
>>> brw_context won't be available. Jason will do that next, and I guess
>>> you could argue that this patch belongs in that series.
>>
>> I would tend to agree with Matt. This patch doesn't really do anything on
>> its own and I plan on doing it "for real" soon enough that "other callers"
>> won't have to wait long.  Let's put this off until we can do it "the right
>> way".
>
> I don't feel too strongly about this one and it certainly isn't
> directly related to or required for what this patch series tries to
> do. However, whatever we do in future patch series, this would have to
> be a patch on its own so as to isolate potential side effects from
> moving from brw->max_cs_threads to the devinfo field. We can do it now
> or later.

That seems like a reasonable argument.  I can include it in mine later
or, if you'd prefer,

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


Re: [Mesa-dev] [PATCH 1/7] glsl: move gl_shader_stage_name() definition to shader_enums.h

2015-10-08 Thread Ilia Mirkin
On Thu, Oct 8, 2015 at 2:34 PM, Emil Velikov  wrote:
> On 8 October 2015 at 19:32, Ilia Mirkin  wrote:
>> On Thu, Oct 8, 2015 at 2:23 PM, Emil Velikov  
>> wrote:
>>> On 8 October 2015 at 18:57, Ilia Mirkin  wrote:
 On Thu, Oct 8, 2015 at 1:52 PM, Emil Velikov  
 wrote:
> On 8 October 2015 at 18:08, Ilia Mirkin  wrote:
>> On Thu, Oct 8, 2015 at 1:09 PM, Emil Velikov  
>> wrote:
>>> This is a trivial enough function that can live in the header. While
>>> we're here, add a STATIC_ASSERT for good measure.
>>>
>>> Signed-off-by: Emil Velikov 
>>> ---
>>>  src/glsl/shader_enums.c | 13 -
>>>  src/glsl/shader_enums.h | 23 +--
>>>  2 files changed, 21 insertions(+), 15 deletions(-)
>>>
>>> diff --git a/src/glsl/shader_enums.c b/src/glsl/shader_enums.c
>>> index c196b79..b3da3e9 100644
>>> --- a/src/glsl/shader_enums.c
>>> +++ b/src/glsl/shader_enums.c
>>> @@ -32,19 +32,6 @@
>>>  #define ENUM(x) [x] = #x
>>>  #define NAME(val) val) < ARRAY_SIZE(names)) && names[(val)]) ? 
>>> names[(val)] : "UNKNOWN")
>>>
>>> -const char * gl_shader_stage_name(gl_shader_stage stage)
>>> -{
>>> -   static const char *names[] = {
>>> -  ENUM(MESA_SHADER_VERTEX),
>>> -  ENUM(MESA_SHADER_TESS_CTRL),
>>> -  ENUM(MESA_SHADER_TESS_EVAL),
>>> -  ENUM(MESA_SHADER_GEOMETRY),
>>> -  ENUM(MESA_SHADER_FRAGMENT),
>>> -  ENUM(MESA_SHADER_COMPUTE),
>>> -   };
>>> -   return NAME(stage);
>>> -}
>>> -
>>>  const char * gl_vert_attrib_name(gl_vert_attrib attrib)
>>>  {
>>> static const char *names[] = {
>>> diff --git a/src/glsl/shader_enums.h b/src/glsl/shader_enums.h
>>> index 2a5d2c5..fbd2744 100644
>>> --- a/src/glsl/shader_enums.h
>>> +++ b/src/glsl/shader_enums.h
>>> @@ -43,10 +43,27 @@ typedef enum
>>> MESA_SHADER_COMPUTE = 5,
>>>  } gl_shader_stage;
>>>
>>> -const char * gl_shader_stage_name(gl_shader_stage stage);
>>> -
>>>  #define MESA_SHADER_STAGES (MESA_SHADER_COMPUTE + 1)
>>>
>>> +#define ENUM(x) [x] = #x
>>> +
>>> +static const char *gl_shader_stage_names[] = {
>>> +   ENUM(MESA_SHADER_VERTEX),
>>> +   ENUM(MESA_SHADER_TESS_CTRL),
>>> +   ENUM(MESA_SHADER_TESS_EVAL),
>>> +   ENUM(MESA_SHADER_GEOMETRY),
>>> +   ENUM(MESA_SHADER_FRAGMENT),
>>> +   ENUM(MESA_SHADER_COMPUTE),
>>> +};
>>
>> Won't this bloat the binary by including this in every object file? I
>> don't know that the array will get merged. (The strings will though.)
>> Normally these things live in c files so that they're stored in only
>> one object.
>>
> The linker (with its garbage collector) will sort it out for us. Seems
> like we do get a small increase from the series
>
>textdata bss dec hex filename
> 5103374  204048   27648 5335070  51681e i965_dri.so.after
> 5104590  204208   27648 5336446  516d7e i965_dri.so.before
>
> Namely - we gain ~1.2k of text. Which imho doesn't sound that bad ?

 In exchange for what? From what I can tell... nothing. The array
 definition needs to live in a c file. You can move the function to
 look up from it into a header, that's fine.
>>>
>>> Nasty bug in(?) autohell [1]. If you're happy to dive in the auto*
>>> boat and fix it, I would gladly purge this series :-)
>>
>> Well that's just asking for trouble:
>>
>> src/Makefile.am:glsl/shader_enums.c \
>> src/mesa/Makefile.sources:  ../glsl/shader_enums.c \
>>
> Yes it is nasty.
>
>> It should just be removed from shader_enums.c and make sure that
>> libglsl_util is a dep of libmesa_la and libmesagallium_la. Am I
>> missing something?
> Give it a go and admire the duplicated symbols :)

Errr, that was a typo. I meant it should be removed from
PROGRAM_FILES. Any additional duplicated items should be removed as
well.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 10/12] i965/cs: Get max_cs_threads from brw_compiler devinfo

2015-10-08 Thread Kristian Høgsberg
On Wed, Oct 7, 2015 at 10:09 PM, Jason Ekstrand  wrote:
>
> On Oct 7, 2015 3:36 PM, "Kristian Høgsberg"  wrote:
>>
>> On Wed, Oct 7, 2015 at 3:11 PM, Matt Turner  wrote:
>> > On Wed, Oct 7, 2015 at 7:11 AM, Kristian Høgsberg Kristensen
>> >  wrote:
>> >> Signed-off-by: Kristian Høgsberg Kristensen 
>> >> ---
>> >>  src/mesa/drivers/dri/i965/brw_fs.cpp | 5 +++--
>> >>  1 file changed, 3 insertions(+), 2 deletions(-)
>> >>
>> >> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp
>> >> b/src/mesa/drivers/dri/i965/brw_fs.cpp
>> >> index 65c3628..b79b4a4 100644
>> >> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
>> >> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
>> >> @@ -5276,6 +5276,7 @@ brw_cs_emit(struct brw_context *brw,
>> >> prog_data->local_size[2] = cp->LocalSize[2];
>> >> unsigned local_workgroup_size =
>> >>cp->LocalSize[0] * cp->LocalSize[1] * cp->LocalSize[2];
>> >> +   unsigned max_cs_threads =
>> >> brw->intelScreen->compiler->devinfo->max_cs_threads;
>> >
>> > I'm not following how this helps? Seems like you want to just pass in
>> > devinfo or something?
>>
>> We want to pass in just brw_compiler eventually. At that point
>> brw_context won't be available. Jason will do that next, and I guess
>> you could argue that this patch belongs in that series.
>
> I would tend to agree with Matt. This patch doesn't really do anything on
> its own and I plan on doing it "for real" soon enough that "other callers"
> won't have to wait long.  Let's put this off until we can do it "the right
> way".

I don't feel too strongly about this one and it certainly isn't
directly related to or required for what this patch series tries to
do. However, whatever we do in future patch series, this would have to
be a patch on its own so as to isolate potential side effects from
moving from brw->max_cs_threads to the devinfo field. We can do it now
or later.

Kristian

> --Jason
>
>> However, this one occurrence is the only place the compiler accesses
>> devinfo values through brw_context and getting rid of it means callers
>> without a real brw_context have to fake a little less.
>>
>> Kristian
>> ___
>> 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/7] glsl: move gl_shader_stage_name() definition to shader_enums.h

2015-10-08 Thread Emil Velikov
On 8 October 2015 at 19:32, Ilia Mirkin  wrote:
> On Thu, Oct 8, 2015 at 2:23 PM, Emil Velikov  wrote:
>> On 8 October 2015 at 18:57, Ilia Mirkin  wrote:
>>> On Thu, Oct 8, 2015 at 1:52 PM, Emil Velikov  
>>> wrote:
 On 8 October 2015 at 18:08, Ilia Mirkin  wrote:
> On Thu, Oct 8, 2015 at 1:09 PM, Emil Velikov  
> wrote:
>> This is a trivial enough function that can live in the header. While
>> we're here, add a STATIC_ASSERT for good measure.
>>
>> Signed-off-by: Emil Velikov 
>> ---
>>  src/glsl/shader_enums.c | 13 -
>>  src/glsl/shader_enums.h | 23 +--
>>  2 files changed, 21 insertions(+), 15 deletions(-)
>>
>> diff --git a/src/glsl/shader_enums.c b/src/glsl/shader_enums.c
>> index c196b79..b3da3e9 100644
>> --- a/src/glsl/shader_enums.c
>> +++ b/src/glsl/shader_enums.c
>> @@ -32,19 +32,6 @@
>>  #define ENUM(x) [x] = #x
>>  #define NAME(val) val) < ARRAY_SIZE(names)) && names[(val)]) ? 
>> names[(val)] : "UNKNOWN")
>>
>> -const char * gl_shader_stage_name(gl_shader_stage stage)
>> -{
>> -   static const char *names[] = {
>> -  ENUM(MESA_SHADER_VERTEX),
>> -  ENUM(MESA_SHADER_TESS_CTRL),
>> -  ENUM(MESA_SHADER_TESS_EVAL),
>> -  ENUM(MESA_SHADER_GEOMETRY),
>> -  ENUM(MESA_SHADER_FRAGMENT),
>> -  ENUM(MESA_SHADER_COMPUTE),
>> -   };
>> -   return NAME(stage);
>> -}
>> -
>>  const char * gl_vert_attrib_name(gl_vert_attrib attrib)
>>  {
>> static const char *names[] = {
>> diff --git a/src/glsl/shader_enums.h b/src/glsl/shader_enums.h
>> index 2a5d2c5..fbd2744 100644
>> --- a/src/glsl/shader_enums.h
>> +++ b/src/glsl/shader_enums.h
>> @@ -43,10 +43,27 @@ typedef enum
>> MESA_SHADER_COMPUTE = 5,
>>  } gl_shader_stage;
>>
>> -const char * gl_shader_stage_name(gl_shader_stage stage);
>> -
>>  #define MESA_SHADER_STAGES (MESA_SHADER_COMPUTE + 1)
>>
>> +#define ENUM(x) [x] = #x
>> +
>> +static const char *gl_shader_stage_names[] = {
>> +   ENUM(MESA_SHADER_VERTEX),
>> +   ENUM(MESA_SHADER_TESS_CTRL),
>> +   ENUM(MESA_SHADER_TESS_EVAL),
>> +   ENUM(MESA_SHADER_GEOMETRY),
>> +   ENUM(MESA_SHADER_FRAGMENT),
>> +   ENUM(MESA_SHADER_COMPUTE),
>> +};
>
> Won't this bloat the binary by including this in every object file? I
> don't know that the array will get merged. (The strings will though.)
> Normally these things live in c files so that they're stored in only
> one object.
>
 The linker (with its garbage collector) will sort it out for us. Seems
 like we do get a small increase from the series

textdata bss dec hex filename
 5103374  204048   27648 5335070  51681e i965_dri.so.after
 5104590  204208   27648 5336446  516d7e i965_dri.so.before

 Namely - we gain ~1.2k of text. Which imho doesn't sound that bad ?
>>>
>>> In exchange for what? From what I can tell... nothing. The array
>>> definition needs to live in a c file. You can move the function to
>>> look up from it into a header, that's fine.
>>
>> Nasty bug in(?) autohell [1]. If you're happy to dive in the auto*
>> boat and fix it, I would gladly purge this series :-)
>
> Well that's just asking for trouble:
>
> src/Makefile.am:glsl/shader_enums.c \
> src/mesa/Makefile.sources:  ../glsl/shader_enums.c \
>
Yes it is nasty.

> It should just be removed from shader_enums.c and make sure that
> libglsl_util is a dep of libmesa_la and libmesagallium_la. Am I
> missing something?
Give it a go and admire the duplicated symbols :)

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


Re: [Mesa-dev] [PATCH 1/7] glsl: move gl_shader_stage_name() definition to shader_enums.h

2015-10-08 Thread Ilia Mirkin
On Thu, Oct 8, 2015 at 2:23 PM, Emil Velikov  wrote:
> On 8 October 2015 at 18:57, Ilia Mirkin  wrote:
>> On Thu, Oct 8, 2015 at 1:52 PM, Emil Velikov  
>> wrote:
>>> On 8 October 2015 at 18:08, Ilia Mirkin  wrote:
 On Thu, Oct 8, 2015 at 1:09 PM, Emil Velikov  
 wrote:
> This is a trivial enough function that can live in the header. While
> we're here, add a STATIC_ASSERT for good measure.
>
> Signed-off-by: Emil Velikov 
> ---
>  src/glsl/shader_enums.c | 13 -
>  src/glsl/shader_enums.h | 23 +--
>  2 files changed, 21 insertions(+), 15 deletions(-)
>
> diff --git a/src/glsl/shader_enums.c b/src/glsl/shader_enums.c
> index c196b79..b3da3e9 100644
> --- a/src/glsl/shader_enums.c
> +++ b/src/glsl/shader_enums.c
> @@ -32,19 +32,6 @@
>  #define ENUM(x) [x] = #x
>  #define NAME(val) val) < ARRAY_SIZE(names)) && names[(val)]) ? 
> names[(val)] : "UNKNOWN")
>
> -const char * gl_shader_stage_name(gl_shader_stage stage)
> -{
> -   static const char *names[] = {
> -  ENUM(MESA_SHADER_VERTEX),
> -  ENUM(MESA_SHADER_TESS_CTRL),
> -  ENUM(MESA_SHADER_TESS_EVAL),
> -  ENUM(MESA_SHADER_GEOMETRY),
> -  ENUM(MESA_SHADER_FRAGMENT),
> -  ENUM(MESA_SHADER_COMPUTE),
> -   };
> -   return NAME(stage);
> -}
> -
>  const char * gl_vert_attrib_name(gl_vert_attrib attrib)
>  {
> static const char *names[] = {
> diff --git a/src/glsl/shader_enums.h b/src/glsl/shader_enums.h
> index 2a5d2c5..fbd2744 100644
> --- a/src/glsl/shader_enums.h
> +++ b/src/glsl/shader_enums.h
> @@ -43,10 +43,27 @@ typedef enum
> MESA_SHADER_COMPUTE = 5,
>  } gl_shader_stage;
>
> -const char * gl_shader_stage_name(gl_shader_stage stage);
> -
>  #define MESA_SHADER_STAGES (MESA_SHADER_COMPUTE + 1)
>
> +#define ENUM(x) [x] = #x
> +
> +static const char *gl_shader_stage_names[] = {
> +   ENUM(MESA_SHADER_VERTEX),
> +   ENUM(MESA_SHADER_TESS_CTRL),
> +   ENUM(MESA_SHADER_TESS_EVAL),
> +   ENUM(MESA_SHADER_GEOMETRY),
> +   ENUM(MESA_SHADER_FRAGMENT),
> +   ENUM(MESA_SHADER_COMPUTE),
> +};

 Won't this bloat the binary by including this in every object file? I
 don't know that the array will get merged. (The strings will though.)
 Normally these things live in c files so that they're stored in only
 one object.

>>> The linker (with its garbage collector) will sort it out for us. Seems
>>> like we do get a small increase from the series
>>>
>>>textdata bss dec hex filename
>>> 5103374  204048   27648 5335070  51681e i965_dri.so.after
>>> 5104590  204208   27648 5336446  516d7e i965_dri.so.before
>>>
>>> Namely - we gain ~1.2k of text. Which imho doesn't sound that bad ?
>>
>> In exchange for what? From what I can tell... nothing. The array
>> definition needs to live in a c file. You can move the function to
>> look up from it into a header, that's fine.
>
> Nasty bug in(?) autohell [1]. If you're happy to dive in the auto*
> boat and fix it, I would gladly purge this series :-)

Well that's just asking for trouble:

src/Makefile.am:glsl/shader_enums.c \
src/mesa/Makefile.sources:  ../glsl/shader_enums.c \

It should just be removed from shader_enums.c and make sure that
libglsl_util is a dep of libmesa_la and libmesagallium_la. Am I
missing something?
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [RFC] Vendor-neutral dispatch library for OpenGL

2015-10-08 Thread Emil Velikov
On 06/10/15 20:58, Kyle Brenneman wrote:
> On 10/06/2015 12:43 PM, Emil Velikov wrote:
>> On 6 October 2015 at 16:39, Kyle Brenneman  wrote:
>>> On 10/06/2015 07:34 AM, Emil Velikov wrote:
 Hello Kyle,

 A few questions/points of discussion:

   * What is your take on having a libglvnd 'package', which provides
 the headers (and maybe other materials), apart from the libraries ?
 I'm basically thinking about OpenGL.h, GLX.h, etc for programs that
 wish to use new ABI, and glvnd{Foo,Bar}.h which mesa and other GL
 implementations.
>>> I haven't looked much into packaging yet. I'm open to any suggestions that
>>> might make that easier, though.
>>>
>>> One thing that I'm planning to do but haven't gotten to yet is to move the
>>> public headers into a separate directory. There's a couple of header files
>>> (libglxabi.h and GLdispatchABI.h) that are intended to be used by vendor
>>> library implementations, and the other headers are all internal.
>>>
>>> The headers that you'd use for compiling an application (gl.h, glx.h, etc.)
>>> could easily go into a separate package, too.
>>>
>> By 'packaging' I meant that the relevant files are available after
>> `make install'. Currently for GLdispatchABI.h and others that's not
>> the case. We can leave it up-to the distributions to manage the actual
>> packages (if in doubt a document to guide them), but we can make sure
>> that the files (including pkg-config and cmake ones, separate set for
>> user/developer) are there.
> The 'make install' command currently doesn't do anything with the
> regular GL headers. I would expect that if someone's building an OpenGL
> application, then they've probably already installed some version of the
> GL headers separately. Still, I could probably add a configure option or
> something to include them.
> 
Pretty much what I was wondering. Mostly as I've noticed that the
official Nvidia driver has started shipping some headers which clash
with mesa ones :'( Perhaps the AMD proprietary driver ships some as well ?

> Including the public ABI headers in a "make install" does sound like a
> good idea. Maybe put them next to the normal GL headers, or under a
> GLVND subdirectory?
A separate location sounds better imho. Then again this information will
be made available via the .pc .cmake files. People that don't use them
can hardcode thing as needed :)

[snip]
   * There was an idea to expose separate libOpenGL libraries, one for
 each (major?) GL version.
 What happened on that front ?
>>> Nothing as far as I know.
>>>
>>> However, each of those libraries is basically just a thin wrapper around
>>> libGLdispatch.so, so in theory you could define any number of libraries that
>>> just export a different set of functions. It's more a question of how many
>>> libraries we'd want to deal with.
>>>
>>> From an application standpoint, having a fixed set of libraries with a known
>>> set of exported functions seems like the easiest option, since you could
>>> then link your application against it and not have to modify it later.
>>>
>>> That said, the set of functions to export from libGL.so and libOpenGL.so is
>>> still an open question. The set right now is just what libglvnd inherited
>>> from Mesa, but it would be good to have a more clearly-defined set. Maybe
>>> something simple like all core OpenGL functions through version 4.5 or so?
>>>
>> I'm rather inclined towards "(ideally) no GL symbols should be
>> statically available" - just use *gl*GetProcAddress. Otherwise thing
>> are bound to get quite hairy.
>>  - Forward/backward compatibility
>>  - Incorrectly linked - program uses GL N, yet linked against GL N+1.
>>  - Developer confusion - which library do I need, how do I check for X
>> and not Y.
>>  - The easy way out - using GL N core function glFoo, link against GL
>> N, rather than LG N-1 + doing the extension check.
>>
>> Note that libGL.so from older mesa was exposing a few too many symbols
>> statically, so we might want to make sure these/similar changes landed
>> in libglvnd.
> libGLX.so itself only exports GLX 1.4 functions -- no extensions and no
> OpenGL functions. If an app developer wants to, they could link against
> only libGLX.so, and then use glXGetProcAddress to look up every OpenGL
> function.
> 
> libOpenGL.so is there to avoid the hassle of having looking up every
> OpenGL function, especially in simpler apps that don't need to use many
> extension functions.
> 
> Developer confusion is why I think it would be best to define a set of
> functions to export and just stick with it.
Greater confusion will come with the various different lists, imho. Esp.
since there will be some overlap but they (the lists) won't be quite the
same between the old and new ABI.

It would be easier to have a macro/helper that fetches any entry point
required via gl*GetProcAddress, rather having divergent flow based on
heuristics X.

See for example how GLEW does not always get it right, 

Re: [Mesa-dev] [PATCH 1/7] glsl: move gl_shader_stage_name() definition to shader_enums.h

2015-10-08 Thread Emil Velikov
On 8 October 2015 at 18:57, Ilia Mirkin  wrote:
> On Thu, Oct 8, 2015 at 1:52 PM, Emil Velikov  wrote:
>> On 8 October 2015 at 18:08, Ilia Mirkin  wrote:
>>> On Thu, Oct 8, 2015 at 1:09 PM, Emil Velikov  
>>> wrote:
 This is a trivial enough function that can live in the header. While
 we're here, add a STATIC_ASSERT for good measure.

 Signed-off-by: Emil Velikov 
 ---
  src/glsl/shader_enums.c | 13 -
  src/glsl/shader_enums.h | 23 +--
  2 files changed, 21 insertions(+), 15 deletions(-)

 diff --git a/src/glsl/shader_enums.c b/src/glsl/shader_enums.c
 index c196b79..b3da3e9 100644
 --- a/src/glsl/shader_enums.c
 +++ b/src/glsl/shader_enums.c
 @@ -32,19 +32,6 @@
  #define ENUM(x) [x] = #x
  #define NAME(val) val) < ARRAY_SIZE(names)) && names[(val)]) ? 
 names[(val)] : "UNKNOWN")

 -const char * gl_shader_stage_name(gl_shader_stage stage)
 -{
 -   static const char *names[] = {
 -  ENUM(MESA_SHADER_VERTEX),
 -  ENUM(MESA_SHADER_TESS_CTRL),
 -  ENUM(MESA_SHADER_TESS_EVAL),
 -  ENUM(MESA_SHADER_GEOMETRY),
 -  ENUM(MESA_SHADER_FRAGMENT),
 -  ENUM(MESA_SHADER_COMPUTE),
 -   };
 -   return NAME(stage);
 -}
 -
  const char * gl_vert_attrib_name(gl_vert_attrib attrib)
  {
 static const char *names[] = {
 diff --git a/src/glsl/shader_enums.h b/src/glsl/shader_enums.h
 index 2a5d2c5..fbd2744 100644
 --- a/src/glsl/shader_enums.h
 +++ b/src/glsl/shader_enums.h
 @@ -43,10 +43,27 @@ typedef enum
 MESA_SHADER_COMPUTE = 5,
  } gl_shader_stage;

 -const char * gl_shader_stage_name(gl_shader_stage stage);
 -
  #define MESA_SHADER_STAGES (MESA_SHADER_COMPUTE + 1)

 +#define ENUM(x) [x] = #x
 +
 +static const char *gl_shader_stage_names[] = {
 +   ENUM(MESA_SHADER_VERTEX),
 +   ENUM(MESA_SHADER_TESS_CTRL),
 +   ENUM(MESA_SHADER_TESS_EVAL),
 +   ENUM(MESA_SHADER_GEOMETRY),
 +   ENUM(MESA_SHADER_FRAGMENT),
 +   ENUM(MESA_SHADER_COMPUTE),
 +};
>>>
>>> Won't this bloat the binary by including this in every object file? I
>>> don't know that the array will get merged. (The strings will though.)
>>> Normally these things live in c files so that they're stored in only
>>> one object.
>>>
>> The linker (with its garbage collector) will sort it out for us. Seems
>> like we do get a small increase from the series
>>
>>textdata bss dec hex filename
>> 5103374  204048   27648 5335070  51681e i965_dri.so.after
>> 5104590  204208   27648 5336446  516d7e i965_dri.so.before
>>
>> Namely - we gain ~1.2k of text. Which imho doesn't sound that bad ?
>
> In exchange for what? From what I can tell... nothing. The array
> definition needs to live in a c file. You can move the function to
> look up from it into a header, that's fine.

Nasty bug in(?) autohell [1]. If you're happy to dive in the auto*
boat and fix it, I would gladly purge this series :-)

Emil

[1] http://lists.freedesktop.org/archives/mesa-dev/2015-October/096499.html
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 01/12] i965: Move brw_dump_ir() out of brw_*_emit() functions

2015-10-08 Thread Kristian Høgsberg
On Thu, Oct 8, 2015 at 4:42 AM, Iago Toral  wrote:
> On Thu, 2015-10-08 at 12:32 +0100, Chris Wilson wrote:
>> On Thu, Oct 08, 2015 at 01:23:27PM +0200, Iago Toral wrote:
>> > Well, this is weird this patch makes this crash:
>> >
>> > INTEL_DEBUG=vs glxgears
>> >
>> > because that uses a vertex program, so &vs->base is a NULL pointer
>> > dereference in this call:
>> >
>> > brw_dump_ir("vertex", prog, &vs->base, &vp->program.Base);
>> >
>>
>> No, the crash is:
>>
>> > +   if (unlikely(INTEL_DEBUG & DEBUG_VS) && vs->base.ir)
>>
>> and friends.
>> -Chris
>
> Correct. We still need to patch calls to brw_dump_ir to fix this though.

No, what happened was I rebased this across Jasons recent cleanup and
didn't remove the vs->base.ir checks. I've removed them and verified
that glxgears works with INTEL_DEBUG=vs.

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


Re: [Mesa-dev] [PATCH 1/3] mesa: remove unneeded error check in create_textures()

2015-10-08 Thread Mark Janes
Brian Paul  writes:

> You tested with all 3 patches and everything's OK now?

Sorry, I should have been more clear:

Series is

Tested-by: Mark Janes 

>
> I guess I'd still like an R-b on the 3rd patch ("mesa,meta: move 
> gl_texture_object::TargetIndex initializations") from someone before 
> pushing.
>
> -Brian
>
> On 10/08/2015 11:57 AM, Mark Janes wrote:
>> Tested-by: Mark Janes 
>>
>> Brian Paul  writes:
>>
>>> Callers of create_texture() will either pass target=0 or a validated
>>> GL texture target enum so no need to do another error check inside
>>> the loop.
>>> ---
>>>   src/mesa/main/texobj.c | 11 ++-
>>>   1 file changed, 2 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
>>> index 173e43c..aa4b38c 100644
>>> --- a/src/mesa/main/texobj.c
>>> +++ b/src/mesa/main/texobj.c
>>> @@ -1211,6 +1211,7 @@ _mesa_create_nameless_texture(struct gl_context *ctx, 
>>> GLenum target)
>>>* 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.
>>> + * \param target  either 0 or a a valid / error-checked texture target enum
>>>*/
>>>   static void
>>>   create_textures(struct gl_context *ctx, GLenum target,
>>> @@ -1219,6 +1220,7 @@ create_textures(struct gl_context *ctx, GLenum target,
>>>  GLuint first;
>>>  GLint i;
>>>  const char *func = dsa ? "Create" : "Gen";
>>> +   const GLint targetIndex = _mesa_tex_target_to_index(ctx, target);
>>>
>>>  if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
>>> _mesa_debug(ctx, "gl%sTextures %d\n", func, n);
>>> @@ -1241,7 +1243,6 @@ create_textures(struct gl_context *ctx, GLenum target,
>>>  /* Allocate new, empty texture objects */
>>>  for (i = 0; i < n; i++) {
>>> struct gl_texture_object *texObj;
>>> -  GLint targetIndex;
>>> GLuint name = first + i;
>>> texObj = ctx->Driver.NewTextureObject(ctx, name, target);
>>> if (!texObj) {
>>> @@ -1252,14 +1253,6 @@ create_textures(struct gl_context *ctx, GLenum 
>>> target,
>>>
>>> /* 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 = %s)",
>>> -func, _mesa_enum_to_string(texObj->Target));
>>> -return;
>>> - }
>>> - assert(targetIndex < NUM_TEXTURE_TARGETS);
>>>texObj->TargetIndex = targetIndex;
>>> }
>>>
>>> --
>>> 1.9.1
>>>
>>> ___
>>> mesa-dev mailing list
>>> mesa-dev@lists.freedesktop.org
>>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.freedesktop.org_mailman_listinfo_mesa-2Ddev&d=BQIBAg&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=T0t4QG7chq2ZwJo6wilkFznRSFy-8uDKartPGbomVj8&m=wH7wzPfX3yNt9F68zI5o07hlcSlDR3G_FNCKDirtQ2Y&s=cqrFZKT8ppra0ur69BB8607q0TMHVG6Z44hRctrib9k&e=
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/3] mesa: remove unneeded error check in create_textures()

2015-10-08 Thread Mark Janes
Brian Paul  writes:

> On 10/07/2015 04:47 PM, Mark Janes wrote:
>> Brian Paul  writes:
>>
>>> On 10/05/2015 05:18 PM, Mark Janes wrote:
 I tested this patch and found:

 regressions:
 spec.arb_shader_storage_buffer_object.layout-std140-write-shader  (BDW 
 only)
   expected[1] = 1.00. Read value: 0.00

 spec.arb_copy_image.arb_copy_image-srgb-copy  (assertion)
   arb_copy_image-srgb-copy: src/mesa/main/texobj.c:1739:
 _mesa_BindTexture: Assertion `newTexObj->TargetIndex == 
 targetIndex'
 failed.
>>>
>>> Can you provide the stack trace from gdb at least?
>>
>> #0  0x758e0107 in __GI_raise (sig=sig@entry=6) at 
>> ../nptl/sysdeps/unix/sysv/linux/raise.c:56
>> #1  0x758e14e8 in __GI_abort () at abort.c:89
>> #2  0x758d9226 in __assert_fail_base (fmt=0x75a0fd08 "%s%s%s:%u: 
>> %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x722a1bea 
>> "index < NUM_TEXTURE_TARGETS", file=file@entry=0x722a2048 
>> "/home/majanes/src/mesa_jenkins/repos/mesa/src/mesa/main/texobj.c", 
>> line=line@entry=1368, function=function@entry=0x722a2770 
>> <__PRETTY_FUNCTION__.37205> "unbind_texobj_from_texunits") at assert.c:92
>> #3  0x758d92d2 in __GI___assert_fail 
>> (assertion=assertion@entry=0x722a1bea "index < NUM_TEXTURE_TARGETS", 
>> file=file@entry=0x722a2048 
>> "/home/majanes/src/mesa_jenkins/repos/mesa/src/mesa/main/texobj.c", 
>> line=line@entry=1368, function=function@entry=0x722a2770 
>> <__PRETTY_FUNCTION__.37205> "unbind_texobj_from_texunits") at assert.c:101
>> #4  0x71f6119f in unbind_texobj_from_texunits (ctx=0x77fce040, 
>> texObj=0x956470) at 
>> /home/majanes/src/mesa_jenkins/repos/mesa/src/mesa/main/texobj.c:1368
>> #5  0x71f62195 in _mesa_DeleteTextures (n=n@entry=1, 
>> textures=textures@entry=0x7fffd24c) at 
>> /home/majanes/src/mesa_jenkins/repos/mesa/src/mesa/main/texobj.c:1483
>> #6  0x7201e2ff in _mesa_meta_CopyImageSubData_uncompressed 
>> (ctx=ctx@entry=0x77fce040, src_tex_image=src_tex_image@entry=0x95de80, 
>> src_renderbuffer=src_renderbuffer@entry=0x0, src_x=src_x@entry=0, 
>> src_y=src_y@entry=0, src_z=src_z@entry=0, dst_tex_image=0x956bc0, 
>> dst_renderbuffer=0x0, dst_x=0, dst_y=0, dst_z=0, src_width=32, 
>> src_height=32) at 
>> /home/majanes/src/mesa_jenkins/repos/mesa/src/mesa/drivers/common/meta_copy_image.c:289
>> #7  0x72251275 in intel_copy_image_sub_data (ctx=0x77fce040, 
>> src_image=0x95de80, src_renderbuffer=0x0, src_x=0, src_y=0, src_z=0, 
>> dst_image=0x956bc0, dst_renderbuffer=0x0, dst_x=0, dst_y=0, dst_z=0, 
>> src_width=32, src_height=32) at 
>> /home/majanes/src/mesa_jenkins/repos/mesa/src/mesa/drivers/dri/i965/intel_copy_image.c:216
>> #8  0x71e7ae38 in _mesa_CopyImageSubData (srcName=, 
>> srcTarget=, srcLevel=0, srcX=0, srcY=0, srcZ=, 
>> dstName=3, dstTarget=3553, dstLevel=0, dstX=0, dstY=0, dstZ=0, srcWidth=32, 
>> srcHeight=32, srcDepth=1) at 
>> /home/majanes/src/mesa_jenkins/repos/mesa/src/mesa/main/copyimage.c:528
>> #9  0x77ab3933 in stub_glCopyImageSubData (srcName=2, 
>> srcTarget=3553, srcLevel=0, srcX=0, srcY=0, srcZ=0, dstName=3, 
>> dstTarget=3553, dstLevel=0, dstX=0, dstY=0, dstZ=0, srcWidth=32, 
>> srcHeight=32, srcDepth=1) at 
>> /home/majanes/src/mesa_jenkins/repos/piglit/build_m64/tests/util/piglit-dispatch-gen.c:7769
>> #10 0x00401001 in test_srgb_copy () at 
>> /home/majanes/src/mesa_jenkins/repos/piglit/tests/spec/arb_copy_image/srgb-copy.c:80
>> #11 0x0040 in piglit_display () at 
>> /home/majanes/src/mesa_jenkins/repos/piglit/tests/spec/arb_copy_image/srgb-copy.c:115
>> #12 0x77b42de7 in run_test (gl_fw=0x613c20, argc=1, 
>> argv=0x7fffe728) at 
>> /home/majanes/src/mesa_jenkins/repos/piglit/tests/util/piglit-framework-gl/piglit_fbo_framework.c:52
>> #13 0x77b2962c in piglit_gl_test_run (argc=1, argv=0x7fffe728, 
>> config=0x7fffe5f0) at 
>> /home/majanes/src/mesa_jenkins/repos/piglit/tests/util/piglit-framework-gl.c:199
>> #14 0x00400e80 in main (argc=1, argv=0x7fffe728) at 
>> /home/majanes/src/mesa_jenkins/repos/piglit/tests/spec/arb_copy_image/srgb-copy.c:43
>>
>> in "assert(index < NUM_TEXTURE_TARGETS);", index = NUM_TEXTURE_TARGETS.
>
> OK, it looks like some meta code sets the gl_texture_object::Target 
> field but not the TargetIndex field.  I'll post a v2 patch.  Please retest.

I've sent my tested-by for the series.

I'd like to get out of the business of testing patches.  A few non-Intel
developers have expressed interest in getting limited access to our
continuous integration system.  I'm working to enable that access so
developers can test their own branches sending to the list.

Currently, the CI tests GL conformance, piglit, and dEQP on a wide array
of Intel platforms.  If you'd like to know more about it, you can watch
my presentation at XDC:

https://www.youtube.co

Re: [Mesa-dev] [PATCH 1/3] mesa: remove unneeded error check in create_textures()

2015-10-08 Thread Brian Paul

You tested with all 3 patches and everything's OK now?

I guess I'd still like an R-b on the 3rd patch ("mesa,meta: move 
gl_texture_object::TargetIndex initializations") from someone before 
pushing.


-Brian

On 10/08/2015 11:57 AM, Mark Janes wrote:

Tested-by: Mark Janes 

Brian Paul  writes:


Callers of create_texture() will either pass target=0 or a validated
GL texture target enum so no need to do another error check inside
the loop.
---
  src/mesa/main/texobj.c | 11 ++-
  1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 173e43c..aa4b38c 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -1211,6 +1211,7 @@ _mesa_create_nameless_texture(struct gl_context *ctx, 
GLenum target)
   * 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.
+ * \param target  either 0 or a a valid / error-checked texture target enum
   */
  static void
  create_textures(struct gl_context *ctx, GLenum target,
@@ -1219,6 +1220,7 @@ create_textures(struct gl_context *ctx, GLenum target,
 GLuint first;
 GLint i;
 const char *func = dsa ? "Create" : "Gen";
+   const GLint targetIndex = _mesa_tex_target_to_index(ctx, target);

 if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
_mesa_debug(ctx, "gl%sTextures %d\n", func, n);
@@ -1241,7 +1243,6 @@ create_textures(struct gl_context *ctx, GLenum target,
 /* Allocate new, empty texture objects */
 for (i = 0; i < n; i++) {
struct gl_texture_object *texObj;
-  GLint targetIndex;
GLuint name = first + i;
texObj = ctx->Driver.NewTextureObject(ctx, name, target);
if (!texObj) {
@@ -1252,14 +1253,6 @@ create_textures(struct gl_context *ctx, GLenum target,

/* 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 = %s)",
-func, _mesa_enum_to_string(texObj->Target));
-return;
- }
- assert(targetIndex < NUM_TEXTURE_TARGETS);
   texObj->TargetIndex = targetIndex;
}

--
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.freedesktop.org_mailman_listinfo_mesa-2Ddev&d=BQIBAg&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=T0t4QG7chq2ZwJo6wilkFznRSFy-8uDKartPGbomVj8&m=wH7wzPfX3yNt9F68zI5o07hlcSlDR3G_FNCKDirtQ2Y&s=cqrFZKT8ppra0ur69BB8607q0TMHVG6Z44hRctrib9k&e=


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


Re: [Mesa-dev] [PATCH 05/12] i965/cs: Split out helper for building local id payload

2015-10-08 Thread Kristian Høgsberg
On Thu, Oct 8, 2015 at 1:34 AM, Pohjolainen, Topi
 wrote:
> On Wed, Oct 07, 2015 at 07:11:45AM -0700, Kristian H?gsberg Kristensen wrote:
>> The initial motivation for this patch was to avoid calling
>> brw_cs_prog_local_id_payload_dwords() in gen7_cs_state.c from the
>> compiler. This commit ends up refactoring things a bit more so as to
>> split out the logic to build the local id payload to brw_fs.cpp. This
>> moves the payload building closer to the compiler code that uses the
>> payload layout and makes it avaiable to other users of the compiler.
>   ^
>
>   available

Thanks, fixed.

>>
>> Signed-off-by: Kristian Høgsberg Kristensen 
>> ---
>>  src/mesa/drivers/dri/i965/brw_context.h   |  1 +
>>  src/mesa/drivers/dri/i965/brw_cs.h|  5 +-
>>  src/mesa/drivers/dri/i965/brw_fs.cpp  | 68 --
>>  src/mesa/drivers/dri/i965/gen7_cs_state.c | 80 
>> ---
>>  4 files changed, 76 insertions(+), 78 deletions(-)
>>
>> diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
>> b/src/mesa/drivers/dri/i965/brw_context.h
>> index 0a29a69..1869f28 100644
>> --- a/src/mesa/drivers/dri/i965/brw_context.h
>> +++ b/src/mesa/drivers/dri/i965/brw_context.h
>> @@ -484,6 +484,7 @@ struct brw_cs_prog_data {
>> unsigned simd_size;
>> bool uses_barrier;
>> bool uses_num_work_groups;
>> +   unsigned local_invocation_id_regs;
>>
>> struct {
>>/** @{
>> diff --git a/src/mesa/drivers/dri/i965/brw_cs.h 
>> b/src/mesa/drivers/dri/i965/brw_cs.h
>> index 0c0ed2b..c07eb6c 100644
>> --- a/src/mesa/drivers/dri/i965/brw_cs.h
>> +++ b/src/mesa/drivers/dri/i965/brw_cs.h
>> @@ -48,8 +48,9 @@ brw_cs_emit(struct brw_context *brw,
>>  struct gl_shader_program *prog,
>>  unsigned *final_assembly_size);
>>
>> -unsigned
>> -brw_cs_prog_local_id_payload_dwords(unsigned dispatch_width);
>> +void
>> +brw_cs_fill_local_id_payload(const struct brw_cs_prog_data *cs_prog_data,
>> + void *buffer, uint32_t threads, uint32_t 
>> stride);
>>
>>  #ifdef __cplusplus
>>  }
>> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
>> b/src/mesa/drivers/dri/i965/brw_fs.cpp
>> index 1dee888..b4125aa 100644
>> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
>> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
>> @@ -4718,20 +4718,43 @@ fs_visitor::setup_vs_payload()
>> payload.num_regs = 2;
>>  }
>>
>> +/**
>> + * We are building the local ID push constant data using the simplest 
>> possible
>> + * method. We simply push the local IDs directly as they should appear in 
>> the
>> + * registers for the uvec3 gl_LocalInvocationID variable.
>> + *
>> + * Therefore, for SIMD8, we use 3 full registers, and for SIMD16 we use 6
>> + * registers worth of push constant space.
>> + *
>> + * Note: Any updates to brw_cs_prog_local_id_payload_dwords,
>> + * fill_local_id_payload or fs_visitor::emit_cs_local_invocation_id_setup 
>> need
>> + * to coordinated.
>> + *
>> + * FINISHME: There are a few easy optimizations to consider.
>> + *
>> + * 1. If gl_WorkGroupSize x, y or z is 1, we can just use zero, and there is
>> + *no need for using push constant space for that dimension.
>> + *
>> + * 2. Since GL_MAX_COMPUTE_WORK_GROUP_SIZE is currently 1024 or less, we can
>> + *easily use 16-bit words rather than 32-bit dwords in the push constant
>> + *data.
>> + *
>> + * 3. If gl_WorkGroupSize x, y or z is small, then we can use bytes for
>> + *conveying the data, and thereby reduce push constant usage.
>> + *
>> + */
>>  void
>>  fs_visitor::setup_cs_payload()
>>  {
>> assert(devinfo->gen >= 7);
>> +   brw_cs_prog_data *prog_data = (brw_cs_prog_data*) this->prog_data;
>>
>> payload.num_regs = 1;
>>
>> if (nir->info.system_values_read & SYSTEM_BIT_LOCAL_INVOCATION_ID) {
>> -  const unsigned local_id_dwords =
>> - brw_cs_prog_local_id_payload_dwords(dispatch_width);
>> -  assert((local_id_dwords & 0x7) == 0);
>> -  const unsigned local_id_regs = local_id_dwords / 8;
>> +  prog_data->local_invocation_id_regs = dispatch_width * 3 / 8;
>
> Subtle change in functionality here. Before this was fixed to 3 without
> taking the dispatch width into account. Might be worth to note in the commit
> message.

brw_cs_prog_local_id_payload_dwords() used to return 3 *
dispatch_width, which the code above then divided by 8. Did I miss
sommething?

Kristian

>>payload.local_invocation_id_reg = payload.num_regs;
>> -  payload.num_regs += local_id_regs;
>> +  payload.num_regs += prog_data->local_invocation_id_regs;
>> }
>>  }
>>
>> @@ -5171,6 +5194,41 @@ brw_wm_fs_emit(struct brw_context *brw,
>> return g.get_assembly(final_assembly_size);
>>  }
>>
>> +void
>> +brw_cs_fill_local_id_payload(const struct brw_cs_prog_data *prog_data,
>> + void *buffer, uint32_t threads, uint32_t 
>> stride)
>> +{
>> +   if (prog_data->local_i

Re: [Mesa-dev] [PATCH 05/12] i965/cs: Split out helper for building local id payload

2015-10-08 Thread Pohjolainen, Topi
On Thu, Oct 08, 2015 at 10:53:59AM -0700, Kristian H?gsberg wrote:
> On Thu, Oct 8, 2015 at 1:53 AM, Pohjolainen, Topi
>  wrote:
> > On Wed, Oct 07, 2015 at 07:11:45AM -0700, Kristian H?gsberg Kristensen 
> > wrote:
> >> The initial motivation for this patch was to avoid calling
> >> brw_cs_prog_local_id_payload_dwords() in gen7_cs_state.c from the
> >> compiler. This commit ends up refactoring things a bit more so as to
> >> split out the logic to build the local id payload to brw_fs.cpp. This
> >> moves the payload building closer to the compiler code that uses the
> >> payload layout and makes it avaiable to other users of the compiler.
> >>
> >> Signed-off-by: Kristian Høgsberg Kristensen 
> >> ---
> >>  src/mesa/drivers/dri/i965/brw_context.h   |  1 +
> >>  src/mesa/drivers/dri/i965/brw_cs.h|  5 +-
> >>  src/mesa/drivers/dri/i965/brw_fs.cpp  | 68 --
> >>  src/mesa/drivers/dri/i965/gen7_cs_state.c | 80 
> >> ---
> >>  4 files changed, 76 insertions(+), 78 deletions(-)
> >>
> >> diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
> >> b/src/mesa/drivers/dri/i965/brw_context.h
> >> index 0a29a69..1869f28 100644
> >> --- a/src/mesa/drivers/dri/i965/brw_context.h
> >> +++ b/src/mesa/drivers/dri/i965/brw_context.h
> >> @@ -484,6 +484,7 @@ struct brw_cs_prog_data {
> >> unsigned simd_size;
> >> bool uses_barrier;
> >> bool uses_num_work_groups;
> >> +   unsigned local_invocation_id_regs;
> >>
> >> struct {
> >>/** @{
> >> diff --git a/src/mesa/drivers/dri/i965/brw_cs.h 
> >> b/src/mesa/drivers/dri/i965/brw_cs.h
> >> index 0c0ed2b..c07eb6c 100644
> >> --- a/src/mesa/drivers/dri/i965/brw_cs.h
> >> +++ b/src/mesa/drivers/dri/i965/brw_cs.h
> >> @@ -48,8 +48,9 @@ brw_cs_emit(struct brw_context *brw,
> >>  struct gl_shader_program *prog,
> >>  unsigned *final_assembly_size);
> >>
> >> -unsigned
> >> -brw_cs_prog_local_id_payload_dwords(unsigned dispatch_width);
> >> +void
> >> +brw_cs_fill_local_id_payload(const struct brw_cs_prog_data *cs_prog_data,
> >> + void *buffer, uint32_t threads, uint32_t 
> >> stride);
> >>
> >>  #ifdef __cplusplus
> >>  }
> >> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
> >> b/src/mesa/drivers/dri/i965/brw_fs.cpp
> >> index 1dee888..b4125aa 100644
> >> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
> >> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
> >> @@ -4718,20 +4718,43 @@ fs_visitor::setup_vs_payload()
> >> payload.num_regs = 2;
> >>  }
> >>
> >> +/**
> >> + * We are building the local ID push constant data using the simplest 
> >> possible
> >> + * method. We simply push the local IDs directly as they should appear in 
> >> the
> >> + * registers for the uvec3 gl_LocalInvocationID variable.
> >> + *
> >> + * Therefore, for SIMD8, we use 3 full registers, and for SIMD16 we use 6
> >> + * registers worth of push constant space.
> >> + *
> >> + * Note: Any updates to brw_cs_prog_local_id_payload_dwords,
> >> + * fill_local_id_payload or fs_visitor::emit_cs_local_invocation_id_setup 
> >> need
> >> + * to coordinated.
> >> + *
> >> + * FINISHME: There are a few easy optimizations to consider.
> >> + *
> >> + * 1. If gl_WorkGroupSize x, y or z is 1, we can just use zero, and there 
> >> is
> >> + *no need for using push constant space for that dimension.
> >> + *
> >> + * 2. Since GL_MAX_COMPUTE_WORK_GROUP_SIZE is currently 1024 or less, we 
> >> can
> >> + *easily use 16-bit words rather than 32-bit dwords in the push 
> >> constant
> >> + *data.
> >> + *
> >> + * 3. If gl_WorkGroupSize x, y or z is small, then we can use bytes for
> >> + *conveying the data, and thereby reduce push constant usage.
> >> + *
> >> + */
> >>  void
> >>  fs_visitor::setup_cs_payload()
> >>  {
> >> assert(devinfo->gen >= 7);
> >> +   brw_cs_prog_data *prog_data = (brw_cs_prog_data*) this->prog_data;
> >>
> >> payload.num_regs = 1;
> >>
> >> if (nir->info.system_values_read & SYSTEM_BIT_LOCAL_INVOCATION_ID) {
> >> -  const unsigned local_id_dwords =
> >> - brw_cs_prog_local_id_payload_dwords(dispatch_width);
> >> -  assert((local_id_dwords & 0x7) == 0);
> >> -  const unsigned local_id_regs = local_id_dwords / 8;
> >> +  prog_data->local_invocation_id_regs = dispatch_width * 3 / 8;
> >>payload.local_invocation_id_reg = payload.num_regs;
> >> -  payload.num_regs += local_id_regs;
> >> +  payload.num_regs += prog_data->local_invocation_id_regs;
> >> }
> >>  }
> >>
> >> @@ -5171,6 +5194,41 @@ brw_wm_fs_emit(struct brw_context *brw,
> >> return g.get_assembly(final_assembly_size);
> >>  }
> >>
> >> +void
> >> +brw_cs_fill_local_id_payload(const struct brw_cs_prog_data *prog_data,
> >> + void *buffer, uint32_t threads, uint32_t 
> >> stride)
> >> +{
> >> +   if (prog_data->local_invocation_id_regs == 0)
> >> +  return;
> >> +
> >> +   /* stride should be an intege

Re: [Mesa-dev] [PATCH 1/7] glsl: move gl_shader_stage_name() definition to shader_enums.h

2015-10-08 Thread Ilia Mirkin
On Thu, Oct 8, 2015 at 1:52 PM, Emil Velikov  wrote:
> On 8 October 2015 at 18:08, Ilia Mirkin  wrote:
>> On Thu, Oct 8, 2015 at 1:09 PM, Emil Velikov  
>> wrote:
>>> This is a trivial enough function that can live in the header. While
>>> we're here, add a STATIC_ASSERT for good measure.
>>>
>>> Signed-off-by: Emil Velikov 
>>> ---
>>>  src/glsl/shader_enums.c | 13 -
>>>  src/glsl/shader_enums.h | 23 +--
>>>  2 files changed, 21 insertions(+), 15 deletions(-)
>>>
>>> diff --git a/src/glsl/shader_enums.c b/src/glsl/shader_enums.c
>>> index c196b79..b3da3e9 100644
>>> --- a/src/glsl/shader_enums.c
>>> +++ b/src/glsl/shader_enums.c
>>> @@ -32,19 +32,6 @@
>>>  #define ENUM(x) [x] = #x
>>>  #define NAME(val) val) < ARRAY_SIZE(names)) && names[(val)]) ? 
>>> names[(val)] : "UNKNOWN")
>>>
>>> -const char * gl_shader_stage_name(gl_shader_stage stage)
>>> -{
>>> -   static const char *names[] = {
>>> -  ENUM(MESA_SHADER_VERTEX),
>>> -  ENUM(MESA_SHADER_TESS_CTRL),
>>> -  ENUM(MESA_SHADER_TESS_EVAL),
>>> -  ENUM(MESA_SHADER_GEOMETRY),
>>> -  ENUM(MESA_SHADER_FRAGMENT),
>>> -  ENUM(MESA_SHADER_COMPUTE),
>>> -   };
>>> -   return NAME(stage);
>>> -}
>>> -
>>>  const char * gl_vert_attrib_name(gl_vert_attrib attrib)
>>>  {
>>> static const char *names[] = {
>>> diff --git a/src/glsl/shader_enums.h b/src/glsl/shader_enums.h
>>> index 2a5d2c5..fbd2744 100644
>>> --- a/src/glsl/shader_enums.h
>>> +++ b/src/glsl/shader_enums.h
>>> @@ -43,10 +43,27 @@ typedef enum
>>> MESA_SHADER_COMPUTE = 5,
>>>  } gl_shader_stage;
>>>
>>> -const char * gl_shader_stage_name(gl_shader_stage stage);
>>> -
>>>  #define MESA_SHADER_STAGES (MESA_SHADER_COMPUTE + 1)
>>>
>>> +#define ENUM(x) [x] = #x
>>> +
>>> +static const char *gl_shader_stage_names[] = {
>>> +   ENUM(MESA_SHADER_VERTEX),
>>> +   ENUM(MESA_SHADER_TESS_CTRL),
>>> +   ENUM(MESA_SHADER_TESS_EVAL),
>>> +   ENUM(MESA_SHADER_GEOMETRY),
>>> +   ENUM(MESA_SHADER_FRAGMENT),
>>> +   ENUM(MESA_SHADER_COMPUTE),
>>> +};
>>
>> Won't this bloat the binary by including this in every object file? I
>> don't know that the array will get merged. (The strings will though.)
>> Normally these things live in c files so that they're stored in only
>> one object.
>>
> The linker (with its garbage collector) will sort it out for us. Seems
> like we do get a small increase from the series
>
>textdata bss dec hex filename
> 5103374  204048   27648 5335070  51681e i965_dri.so.after
> 5104590  204208   27648 5336446  516d7e i965_dri.so.before
>
> Namely - we gain ~1.2k of text. Which imho doesn't sound that bad ?

In exchange for what? From what I can tell... nothing. The array
definition needs to live in a c file. You can move the function to
look up from it into a header, that's fine.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 1/3] mesa: remove unneeded error check in create_textures()

2015-10-08 Thread Mark Janes
Tested-by: Mark Janes 

Brian Paul  writes:

> Callers of create_texture() will either pass target=0 or a validated
> GL texture target enum so no need to do another error check inside
> the loop.
> ---
>  src/mesa/main/texobj.c | 11 ++-
>  1 file changed, 2 insertions(+), 9 deletions(-)
>
> diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
> index 173e43c..aa4b38c 100644
> --- a/src/mesa/main/texobj.c
> +++ b/src/mesa/main/texobj.c
> @@ -1211,6 +1211,7 @@ _mesa_create_nameless_texture(struct gl_context *ctx, 
> GLenum target)
>   * 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.
> + * \param target  either 0 or a a valid / error-checked texture target enum
>   */
>  static void
>  create_textures(struct gl_context *ctx, GLenum target,
> @@ -1219,6 +1220,7 @@ create_textures(struct gl_context *ctx, GLenum target,
> GLuint first;
> GLint i;
> const char *func = dsa ? "Create" : "Gen";
> +   const GLint targetIndex = _mesa_tex_target_to_index(ctx, target);
>  
> if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
>_mesa_debug(ctx, "gl%sTextures %d\n", func, n);
> @@ -1241,7 +1243,6 @@ create_textures(struct gl_context *ctx, GLenum target,
> /* Allocate new, empty texture objects */
> for (i = 0; i < n; i++) {
>struct gl_texture_object *texObj;
> -  GLint targetIndex;
>GLuint name = first + i;
>texObj = ctx->Driver.NewTextureObject(ctx, name, target);
>if (!texObj) {
> @@ -1252,14 +1253,6 @@ create_textures(struct gl_context *ctx, GLenum target,
>  
>/* 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 = %s)",
> -func, _mesa_enum_to_string(texObj->Target));
> -return;
> - }
> - assert(targetIndex < NUM_TEXTURE_TARGETS);
>   texObj->TargetIndex = targetIndex;
>}
>  
> -- 
> 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 05/12] i965/cs: Split out helper for building local id payload

2015-10-08 Thread Kristian Høgsberg
On Thu, Oct 8, 2015 at 1:53 AM, Pohjolainen, Topi
 wrote:
> On Wed, Oct 07, 2015 at 07:11:45AM -0700, Kristian H?gsberg Kristensen wrote:
>> The initial motivation for this patch was to avoid calling
>> brw_cs_prog_local_id_payload_dwords() in gen7_cs_state.c from the
>> compiler. This commit ends up refactoring things a bit more so as to
>> split out the logic to build the local id payload to brw_fs.cpp. This
>> moves the payload building closer to the compiler code that uses the
>> payload layout and makes it avaiable to other users of the compiler.
>>
>> Signed-off-by: Kristian Høgsberg Kristensen 
>> ---
>>  src/mesa/drivers/dri/i965/brw_context.h   |  1 +
>>  src/mesa/drivers/dri/i965/brw_cs.h|  5 +-
>>  src/mesa/drivers/dri/i965/brw_fs.cpp  | 68 --
>>  src/mesa/drivers/dri/i965/gen7_cs_state.c | 80 
>> ---
>>  4 files changed, 76 insertions(+), 78 deletions(-)
>>
>> diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
>> b/src/mesa/drivers/dri/i965/brw_context.h
>> index 0a29a69..1869f28 100644
>> --- a/src/mesa/drivers/dri/i965/brw_context.h
>> +++ b/src/mesa/drivers/dri/i965/brw_context.h
>> @@ -484,6 +484,7 @@ struct brw_cs_prog_data {
>> unsigned simd_size;
>> bool uses_barrier;
>> bool uses_num_work_groups;
>> +   unsigned local_invocation_id_regs;
>>
>> struct {
>>/** @{
>> diff --git a/src/mesa/drivers/dri/i965/brw_cs.h 
>> b/src/mesa/drivers/dri/i965/brw_cs.h
>> index 0c0ed2b..c07eb6c 100644
>> --- a/src/mesa/drivers/dri/i965/brw_cs.h
>> +++ b/src/mesa/drivers/dri/i965/brw_cs.h
>> @@ -48,8 +48,9 @@ brw_cs_emit(struct brw_context *brw,
>>  struct gl_shader_program *prog,
>>  unsigned *final_assembly_size);
>>
>> -unsigned
>> -brw_cs_prog_local_id_payload_dwords(unsigned dispatch_width);
>> +void
>> +brw_cs_fill_local_id_payload(const struct brw_cs_prog_data *cs_prog_data,
>> + void *buffer, uint32_t threads, uint32_t 
>> stride);
>>
>>  #ifdef __cplusplus
>>  }
>> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
>> b/src/mesa/drivers/dri/i965/brw_fs.cpp
>> index 1dee888..b4125aa 100644
>> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
>> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
>> @@ -4718,20 +4718,43 @@ fs_visitor::setup_vs_payload()
>> payload.num_regs = 2;
>>  }
>>
>> +/**
>> + * We are building the local ID push constant data using the simplest 
>> possible
>> + * method. We simply push the local IDs directly as they should appear in 
>> the
>> + * registers for the uvec3 gl_LocalInvocationID variable.
>> + *
>> + * Therefore, for SIMD8, we use 3 full registers, and for SIMD16 we use 6
>> + * registers worth of push constant space.
>> + *
>> + * Note: Any updates to brw_cs_prog_local_id_payload_dwords,
>> + * fill_local_id_payload or fs_visitor::emit_cs_local_invocation_id_setup 
>> need
>> + * to coordinated.
>> + *
>> + * FINISHME: There are a few easy optimizations to consider.
>> + *
>> + * 1. If gl_WorkGroupSize x, y or z is 1, we can just use zero, and there is
>> + *no need for using push constant space for that dimension.
>> + *
>> + * 2. Since GL_MAX_COMPUTE_WORK_GROUP_SIZE is currently 1024 or less, we can
>> + *easily use 16-bit words rather than 32-bit dwords in the push constant
>> + *data.
>> + *
>> + * 3. If gl_WorkGroupSize x, y or z is small, then we can use bytes for
>> + *conveying the data, and thereby reduce push constant usage.
>> + *
>> + */
>>  void
>>  fs_visitor::setup_cs_payload()
>>  {
>> assert(devinfo->gen >= 7);
>> +   brw_cs_prog_data *prog_data = (brw_cs_prog_data*) this->prog_data;
>>
>> payload.num_regs = 1;
>>
>> if (nir->info.system_values_read & SYSTEM_BIT_LOCAL_INVOCATION_ID) {
>> -  const unsigned local_id_dwords =
>> - brw_cs_prog_local_id_payload_dwords(dispatch_width);
>> -  assert((local_id_dwords & 0x7) == 0);
>> -  const unsigned local_id_regs = local_id_dwords / 8;
>> +  prog_data->local_invocation_id_regs = dispatch_width * 3 / 8;
>>payload.local_invocation_id_reg = payload.num_regs;
>> -  payload.num_regs += local_id_regs;
>> +  payload.num_regs += prog_data->local_invocation_id_regs;
>> }
>>  }
>>
>> @@ -5171,6 +5194,41 @@ brw_wm_fs_emit(struct brw_context *brw,
>> return g.get_assembly(final_assembly_size);
>>  }
>>
>> +void
>> +brw_cs_fill_local_id_payload(const struct brw_cs_prog_data *prog_data,
>> + void *buffer, uint32_t threads, uint32_t 
>> stride)
>> +{
>> +   if (prog_data->local_invocation_id_regs == 0)
>> +  return;
>> +
>> +   /* stride should be an integer number of registers, that is, a multiple 
>> of
>> +* 32 bytes. */
>
> Comment closing on its own line and you could start the sentence with a
> capital 'S' as well.

I fixed the comment closing, but 'stride' refers to the argument named
'stride' and I wanted to keep it the same. How about I put it in
quotes to make it cle

Re: [Mesa-dev] [PATCH 1/7] glsl: move gl_shader_stage_name() definition to shader_enums.h

2015-10-08 Thread Emil Velikov
On 8 October 2015 at 18:08, Ilia Mirkin  wrote:
> On Thu, Oct 8, 2015 at 1:09 PM, Emil Velikov  wrote:
>> This is a trivial enough function that can live in the header. While
>> we're here, add a STATIC_ASSERT for good measure.
>>
>> Signed-off-by: Emil Velikov 
>> ---
>>  src/glsl/shader_enums.c | 13 -
>>  src/glsl/shader_enums.h | 23 +--
>>  2 files changed, 21 insertions(+), 15 deletions(-)
>>
>> diff --git a/src/glsl/shader_enums.c b/src/glsl/shader_enums.c
>> index c196b79..b3da3e9 100644
>> --- a/src/glsl/shader_enums.c
>> +++ b/src/glsl/shader_enums.c
>> @@ -32,19 +32,6 @@
>>  #define ENUM(x) [x] = #x
>>  #define NAME(val) val) < ARRAY_SIZE(names)) && names[(val)]) ? 
>> names[(val)] : "UNKNOWN")
>>
>> -const char * gl_shader_stage_name(gl_shader_stage stage)
>> -{
>> -   static const char *names[] = {
>> -  ENUM(MESA_SHADER_VERTEX),
>> -  ENUM(MESA_SHADER_TESS_CTRL),
>> -  ENUM(MESA_SHADER_TESS_EVAL),
>> -  ENUM(MESA_SHADER_GEOMETRY),
>> -  ENUM(MESA_SHADER_FRAGMENT),
>> -  ENUM(MESA_SHADER_COMPUTE),
>> -   };
>> -   return NAME(stage);
>> -}
>> -
>>  const char * gl_vert_attrib_name(gl_vert_attrib attrib)
>>  {
>> static const char *names[] = {
>> diff --git a/src/glsl/shader_enums.h b/src/glsl/shader_enums.h
>> index 2a5d2c5..fbd2744 100644
>> --- a/src/glsl/shader_enums.h
>> +++ b/src/glsl/shader_enums.h
>> @@ -43,10 +43,27 @@ typedef enum
>> MESA_SHADER_COMPUTE = 5,
>>  } gl_shader_stage;
>>
>> -const char * gl_shader_stage_name(gl_shader_stage stage);
>> -
>>  #define MESA_SHADER_STAGES (MESA_SHADER_COMPUTE + 1)
>>
>> +#define ENUM(x) [x] = #x
>> +
>> +static const char *gl_shader_stage_names[] = {
>> +   ENUM(MESA_SHADER_VERTEX),
>> +   ENUM(MESA_SHADER_TESS_CTRL),
>> +   ENUM(MESA_SHADER_TESS_EVAL),
>> +   ENUM(MESA_SHADER_GEOMETRY),
>> +   ENUM(MESA_SHADER_FRAGMENT),
>> +   ENUM(MESA_SHADER_COMPUTE),
>> +};
>
> Won't this bloat the binary by including this in every object file? I
> don't know that the array will get merged. (The strings will though.)
> Normally these things live in c files so that they're stored in only
> one object.
>
The linker (with its garbage collector) will sort it out for us. Seems
like we do get a small increase from the series

   textdata bss dec hex filename
5103374  204048   27648 5335070  51681e i965_dri.so.after
5104590  204208   27648 5336446  516d7e i965_dri.so.before

Namely - we gain ~1.2k of text. Which imho doesn't sound that bad ?

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


Re: [Mesa-dev] [PATCH 02/12] util: Move DRI parse_debug_string() to util

2015-10-08 Thread Kristian Høgsberg
On Thu, Oct 8, 2015 at 6:43 AM, Iago Toral  wrote:
> Moe than moving, this patch is duplicating it... wouldn't it be better
> if we moved it for real? Seems like it would only be a matter of adding
> #include "util/debug.h" s/driParseDebugString/parse_debug_string/ in the
> following files:
>
> ./src/mesa/drivers/dri/radeon/radeon_debug.c
> ./src/mesa/drivers/dri/radeon/radeon_debug.c
> ./src/mesa/drivers/dri/i915/intel_context.c
> ./src/mesa/drivers/dri/r200/radeon_debug.c
>
> And then we could remove the version in
> src/mesa/drivers/dri/common/utils.c

Yeah, sure. Fixed locally.

Kristian

> Iago
>
> On Wed, 2015-10-07 at 07:11 -0700, Kristian Høgsberg Kristensen wrote:
>> We want to use intel_debug.c in code that doesn't link to dri common.
>>
>> Signed-off-by: Kristian Høgsberg Kristensen 
>> ---
>>  src/mesa/drivers/dri/i965/intel_debug.c |  5 ++--
>>  src/util/Makefile.sources   |  2 ++
>>  src/util/debug.c| 53 
>> +
>>  src/util/debug.h| 47 +
>>  4 files changed, 105 insertions(+), 2 deletions(-)
>>  create mode 100644 src/util/debug.c
>>  create mode 100644 src/util/debug.h
>>
>> diff --git a/src/mesa/drivers/dri/i965/intel_debug.c 
>> b/src/mesa/drivers/dri/i965/intel_debug.c
>> index 5a9c953..3120189 100644
>> --- a/src/mesa/drivers/dri/i965/intel_debug.c
>> +++ b/src/mesa/drivers/dri/i965/intel_debug.c
>> @@ -33,10 +33,11 @@
>>  #include "intel_debug.h"
>>  #include "utils.h"
>>  #include "util/u_atomic.h" /* for p_atomic_cmpxchg */
>> +#include "util/debug.h"
>>
>>  uint64_t INTEL_DEBUG = 0;
>>
>> -static const struct dri_debug_control debug_control[] = {
>> +static const struct debug_control debug_control[] = {
>> { "tex", DEBUG_TEXTURE},
>> { "state",   DEBUG_STATE},
>> { "blit",DEBUG_BLIT},
>> @@ -93,7 +94,7 @@ intel_debug_flag_for_shader_stage(gl_shader_stage stage)
>>  void
>>  brw_process_intel_debug_variable(struct intel_screen *screen)
>>  {
>> -   uint64_t intel_debug = driParseDebugString(getenv("INTEL_DEBUG"), 
>> debug_control);
>> +   uint64_t intel_debug = parse_debug_string(getenv("INTEL_DEBUG"), 
>> debug_control);
>> (void) p_atomic_cmpxchg(&INTEL_DEBUG, 0, intel_debug);
>>
>> if (INTEL_DEBUG & DEBUG_BUFMGR)
>> diff --git a/src/util/Makefile.sources b/src/util/Makefile.sources
>> index ef38b5a..e45431d 100644
>> --- a/src/util/Makefile.sources
>> +++ b/src/util/Makefile.sources
>> @@ -1,5 +1,7 @@
>>  MESA_UTIL_FILES :=   \
>>   bitset.h \
>> + debug.c \
>> + debug.h \
>>   format_srgb.h \
>>   hash_table.c\
>>   hash_table.h \
>> diff --git a/src/util/debug.c b/src/util/debug.c
>> new file mode 100644
>> index 000..3729ce8
>> --- /dev/null
>> +++ b/src/util/debug.c
>> @@ -0,0 +1,53 @@
>> +/*
>> + * Copyright © 2015 Intel Corporation
>> + *
>> + * Permission is hereby granted, free of charge, to any person obtaining a
>> + * copy of this software and associated documentation files (the 
>> "Software"),
>> + * to deal in the Software without restriction, including without limitation
>> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
>> + * and/or sell copies of the Software, and to permit persons to whom the
>> + * Software is furnished to do so, subject to the following conditions:
>> + *
>> + * The above copyright notice and this permission notice (including the next
>> + * paragraph) shall be included in all copies or substantial portions of the
>> + * Software.
>> + *
>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
>> OR
>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
>> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 
>> OTHER
>> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
>> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
>> DEALINGS
>> + * IN THE SOFTWARE.
>> + */
>> +
>> +#include 
>> +#include "main/macros.h"
>> +#include "debug.h"
>> +
>> +uint64_t
>> +parse_debug_string(const char *debug,
>> +   const struct debug_control *control)
>> +{
>> +   uint64_t flag = 0;
>> +
>> +   if (debug != NULL) {
>> +  for (; control->string != NULL; control++) {
>> + if (!strcmp(debug, "all")) {
>> +flag |= control->flag;
>> +
>> + } else {
>> +const char *s = debug;
>> +unsigned n;
>> +
>> +for (; n = strcspn(s, ", "), *s; s += MAX2(1, n)) {
>> +   if (strlen(control->string) == n &&
>> +   !strncmp(control->string, s, n))
>> +  flag |= control->flag;
>> +}
>> + }
>> +  }
>> +   }
>> +
>> +   return flag;
>> +}
>> diff --git a/src/util/debug.h b/src/util/debug.h
>> new file mode 100644
>> index 0

Re: [Mesa-dev] [PATCH 02/12] util: Move DRI parse_debug_string() to util

2015-10-08 Thread Kristian Høgsberg
On Thu, Oct 8, 2015 at 12:03 AM, Pohjolainen, Topi
 wrote:
> On Wed, Oct 07, 2015 at 07:11:42AM -0700, Kristian H?gsberg Kristensen wrote:
>> We want to use intel_debug.c in code that doesn't link to dri common.
>>
>> Signed-off-by: Kristian Høgsberg Kristensen 
>> ---
>>  src/mesa/drivers/dri/i965/intel_debug.c |  5 ++--
>>  src/util/Makefile.sources   |  2 ++
>>  src/util/debug.c| 53 
>> +
>>  src/util/debug.h| 47 +
>>  4 files changed, 105 insertions(+), 2 deletions(-)
>>  create mode 100644 src/util/debug.c
>>  create mode 100644 src/util/debug.h
>>
>> diff --git a/src/mesa/drivers/dri/i965/intel_debug.c 
>> b/src/mesa/drivers/dri/i965/intel_debug.c
>> index 5a9c953..3120189 100644
>> --- a/src/mesa/drivers/dri/i965/intel_debug.c
>> +++ b/src/mesa/drivers/dri/i965/intel_debug.c
>> @@ -33,10 +33,11 @@
>>  #include "intel_debug.h"
>>  #include "utils.h"
>>  #include "util/u_atomic.h" /* for p_atomic_cmpxchg */
>> +#include "util/debug.h"
>>
>>  uint64_t INTEL_DEBUG = 0;
>>
>> -static const struct dri_debug_control debug_control[] = {
>> +static const struct debug_control debug_control[] = {
>> { "tex", DEBUG_TEXTURE},
>> { "state",   DEBUG_STATE},
>> { "blit",DEBUG_BLIT},
>> @@ -93,7 +94,7 @@ intel_debug_flag_for_shader_stage(gl_shader_stage stage)
>>  void
>>  brw_process_intel_debug_variable(struct intel_screen *screen)
>>  {
>> -   uint64_t intel_debug = driParseDebugString(getenv("INTEL_DEBUG"), 
>> debug_control);
>> +   uint64_t intel_debug = parse_debug_string(getenv("INTEL_DEBUG"), 
>> debug_control);
>> (void) p_atomic_cmpxchg(&INTEL_DEBUG, 0, intel_debug);
>>
>> if (INTEL_DEBUG & DEBUG_BUFMGR)
>> diff --git a/src/util/Makefile.sources b/src/util/Makefile.sources
>> index ef38b5a..e45431d 100644
>> --- a/src/util/Makefile.sources
>> +++ b/src/util/Makefile.sources
>> @@ -1,5 +1,7 @@
>>  MESA_UTIL_FILES :=   \
>>   bitset.h \
>> + debug.c \
>> + debug.h \
>>   format_srgb.h \
>>   hash_table.c\
>>   hash_table.h \
>> diff --git a/src/util/debug.c b/src/util/debug.c
>> new file mode 100644
>> index 000..3729ce8
>> --- /dev/null
>> +++ b/src/util/debug.c
>> @@ -0,0 +1,53 @@
>> +/*
>> + * Copyright © 2015 Intel Corporation
>> + *
>> + * Permission is hereby granted, free of charge, to any person obtaining a
>> + * copy of this software and associated documentation files (the 
>> "Software"),
>> + * to deal in the Software without restriction, including without limitation
>> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
>> + * and/or sell copies of the Software, and to permit persons to whom the
>> + * Software is furnished to do so, subject to the following conditions:
>> + *
>> + * The above copyright notice and this permission notice (including the next
>> + * paragraph) shall be included in all copies or substantial portions of the
>> + * Software.
>> + *
>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
>> OR
>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
>> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 
>> OTHER
>> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
>> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
>> DEALINGS
>> + * IN THE SOFTWARE.
>> + */
>> +
>> +#include 
>> +#include "main/macros.h"
>> +#include "debug.h"
>> +
>> +uint64_t
>> +parse_debug_string(const char *debug,
>> +   const struct debug_control *control)
>> +{
>> +   uint64_t flag = 0;
>> +
>> +   if (debug != NULL) {
>> +  for (; control->string != NULL; control++) {
>> + if (!strcmp(debug, "all")) {
>> +flag |= control->flag;
>> +
>> + } else {
>> +const char *s = debug;
>> +unsigned n;
>> +
>> +for (; n = strcspn(s, ", "), *s; s += MAX2(1, n)) {
>> +   if (strlen(control->string) == n &&
>> +   !strncmp(control->string, s, n))
>> +  flag |= control->flag;
>> +}
>> + }
>> +  }
>> +   }
>> +
>> +   return flag;
>> +}
>> diff --git a/src/util/debug.h b/src/util/debug.h
>> new file mode 100644
>> index 000..929cebb
>> --- /dev/null
>> +++ b/src/util/debug.h
>> @@ -0,0 +1,47 @@
>> +/*
>> + * Copyright © 2015 Intel Corporation
>> + *
>> + * Permission is hereby granted, free of charge, to any person obtaining a
>> + * copy of this software and associated documentation files (the 
>> "Software"),
>> + * to deal in the Software without restriction, including without limitation
>> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
>> + * and/or sell copies of the Software, and to permit persons to whom the
>> + 

Re: [Mesa-dev] [PATCH 4/4] glsl: In later GLSL versions, sequence operator is cannot be a constant expression

2015-10-08 Thread Ian Romanick
On 10/08/2015 03:31 AM, Iago Toral wrote:
> On Wed, 2015-10-07 at 14:34 -0700, Ian Romanick wrote:
>> From: Ian Romanick 
>>
>> Fixes:
>> ES3-CTS.shaders.negative.constant_sequence
>>
>> spec/glsl-es-3.00/compiler/global-initializer/from-sequence.vert
>> spec/glsl-es-3.00/compiler/global-initializer/from-sequence.frag
>>
>> Signed-off-by: Ian Romanick 
>> ---
>>  src/glsl/ast_to_hir.cpp | 43 ++-
>>  1 file changed, 42 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
>> index 6af0f80..c7444ed 100644
>> --- a/src/glsl/ast_to_hir.cpp
>> +++ b/src/glsl/ast_to_hir.cpp
>> @@ -3311,8 +3311,49 @@ process_initializer(ir_variable *var, ast_declaration 
>> *decl,
>>if (new_rhs != NULL) {
>>   rhs = new_rhs;
>>  
>> + /* Section 4.3.3 (Constant Expressions) of the GLSL ES 3.00.4 spec
>> +  * says:
>> +  *
>> +  * "A constant expression is one of
>> +  *
>> +  *...
>> +  *
>> +  *- an expression formed by an operator on operands that 
>> are
>> +  *  all constant expressions, including getting an element 
>> of
>> +  *  a constant array, or a field of a constant structure, 
>> or
>> +  *  components of a constant vector.  However, the sequence
>> +  *  operator ( , ) and the assignment operators ( =, +=, 
>> ...)
>> +  *  are not included in the operators that can create a
>> +  *  constant expression."
>> +  *
>> +  * Section 12.43 (Sequence operator and constant expressions) says:
>> +  *
>> +  * "Should the following construct be allowed?
>> +  *
>> +  * float a[2,3];
>> +  *
>> +  * The expression within the brackets uses the sequence 
>> operator
>> +  * (',') and returns the integer 3 so the construct is decl 
>> aring
>> +  * a single-dimensional array of size 3.  In some languages, 
>> the
>> +  * construct declares a two-dimensional array.  It would be
>> +  * preferable to make this construct illegal to avoid 
>> confusion.
>> +  *
>> +  * One possibility is to change the definition of the sequence
>> +  * operator so that it does not return a constant- expression 
>> and
>> +  * hence cannot be used to declare an array size.
>> +  *
>> +  * RESOLUTION: The result of a sequence operator is not a
>> +  * constant-expression."
>> +  *
>> +  * Section 4.3.3 (Constant Expressions) of the GLSL 4.30.9 spec
>> +  * contains language almost identical to the section 4.3.3 fomr the
>> +  * GLSL ES 3.00.4 spec.  This is a new limitation for these GLSL
>> +  * versions.
>> +  */
>>   ir_constant *constant_value = rhs->constant_expression_value();
>> - if (!constant_value) {
>> + if (!constant_value ||
>> + (state->is_version(430, 300) &&
>> +  decl->initializer->has_sequence_subexpression())) {
>>  const char *const variable_mode =
>> (type->qualifier.flags.q.constant)
>> ? "const"
> 
> This only seems to handle the case of sequence operators used in
> declaration initializers. Maybe this is all we really care about in
> practice, but the spec says that in code such as:
> 
> float b = ... ;
> ...
> b = (a++, a > 0.0 ? 2.0 : 0.0);
> 
> the RHS in the assignment is not a constant expression, and this patch
> would not address that, right? I wonder if this distinction has any
> actual implications in practice though.

That's fine, but there is another case that is not caught.  There are
only a few places where a constant expression is required.  Some
initializers (global variables in GLSL ES, uniforms, const-decorated
global variabes, and const-decorated local variables before GLSL 4.20),
array sizes, and maybe one other thing... that I can't think of right now.

I sent a test,
spec/glsl-es-3.00/compiler/array-sized-by-sequence-in-parenthesis.vert,
for the array size case.  This patch does not cover that, but I have one
on the way.

> Iago

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


Re: [Mesa-dev] [PATCH] mesa: Correctly handle GL_BGRA_EXT in ES3 format_and_type checks

2015-10-08 Thread Mark Janes
No regressions were indicated by this patch.  However, the initial
regression did not trigger any test failures, either.

It is unacceptable for such an obvious regression to pass Mesa's
automated test suites.  I re-opened the bug, pending the creation of
suitable tests.

-Mark

Emil Velikov  writes:

> On 07/10/15 23:58, Jason Ekstrand wrote:
>> The EXT_texture_format_BGRA extension (which mesa supports
>> unconditionally) adds a new format and internal format called GL_BGRA_EXT.
>> Previously, this was not really handled at all in
>> _mesa_ex3_error_check_format_and_type.  When the checks were tightened in
>> commit f15a7f3c, we accidentally tightened things too far and GL_BGRA_EXT
>> would always cause an error to be thrown.
>> 
>> There were two primary issues here.  First, is that
>> _mesa_es3_effective_internal_format_for_format_and_type didn't handle the
>> GL_BGRA_EXT format.  Second is that it blindly uses _mesa_base_tex_format
>> which returns GL_RGBA for GL_BGRA_EXT.  This commit fixes both of these
>> issues as well as adds explicit checks that GL_BGRA_EXT is only ever used
>> with GL_BGRA_EXT and GL_UNSIGNED_BYTE.
>> 
>> Signed-off-by: Jason Ekstrand 
>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92265
>> Cc: Eduardo Lima Mitev 
> Thanks for the fix Jason.
>
> Mark, can you give this patch a spin on jenkins ? It's in master so
> chances are that it's already been tested :)
>
> Cheers,
> Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] make distclean failing

2015-10-08 Thread Emil Velikov
On 8 October 2015 at 16:56, Rob Clark  wrote:
> On Thu, Oct 8, 2015 at 11:39 AM, Emil Velikov  
> wrote:
>> On 8 October 2015 at 16:12, Matt Turner  wrote:
>>> On Thu, Oct 8, 2015 at 6:56 AM, Rob Clark  wrote:
 On Wed, Oct 7, 2015 at 6:00 PM, Andy Furniss  wrote:
> Noticed recently that make distclean is failing for me -
>
> Making distclean in mesa
> make[2]: Entering directory '/mnt/sdb1/Src64/Mesa-git/mesa/src/mesa'
> Makefile:2486: ../glsl/.deps/shader_enums.Plo: No such file or directory
> make[2]: *** No rule to make target '../glsl/.deps/shader_enums.Plo'.  
> Stop.
> make[2]: Leaving directory '/mnt/sdb1/Src64/Mesa-git/mesa/src/mesa'
> Makefile:684: recipe for target 'distclean-recursive' failed
> make[1]: *** [distclean-recursive] Error 1
> make[1]: Leaving directory '/mnt/sdb1/Src64/Mesa-git/mesa/src'
> Makefile:615: recipe for target 'distclean-recursive' failed
> make: *** [distclean-recursive] Error 1

 I think the problem is that shader_enums gets cleaned twice, since it
 is built both into libglsl_util.la (for non-mesa state trackers, from
 src/Makefile.am), and into libmesa.la/libmesagallium.la (for mesa and
 mesa state tracker, from src/mesa/Makefile.am)..  the arrangement with
 nir depending on some parts from glsl is a bit unfortunate.
>>>
>>> Ugh, yeah, that seems very plausible. The intention of adding that
>>> convenience library was to avoid this very problem. :(
>> Fwiw I'm inclined to move the functions as static inline, considering
>> they are pretty trivial.
>> It should resolve the issue, plus we'll remove ../ from the sources list.
>>
>> I'll send a patch in a minute
>
> functions are trivial but bunch of const string data that I was hoping
> to avoid duplicating in many object files..
Was under the impression that the linker will kindly clean it up for
us ? Let me check the numbers.

> I guess it would be an ok
> temporary solution.  Although maybe we should just move everything
> that nir depends on into nir and have glsl depend on nir rather than
> other way around..
>
That would be amazing. I would gladly review any patches in that area.

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


[Mesa-dev] [Bug 92265] Black windows in weston after update mesa to 11.0.2-1

2015-10-08 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=92265

Mark Janes  changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 Resolution|FIXED   |---
   Assignee|mesa-dev@lists.freedesktop. |el...@igalia.com
   |org |

--- Comment #14 from Mark Janes  ---
No piglit, dEQP, or CTS tests indicated this regression.  However, a major
consumer of Mesa was debilitated due to this bug.

This bug cannot be marked fixed until there exists a piglit test which prevents
future regressions of this type.

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


Re: [Mesa-dev] [PATCH 1/7] glsl: move gl_shader_stage_name() definition to shader_enums.h

2015-10-08 Thread Ilia Mirkin
On Thu, Oct 8, 2015 at 1:09 PM, Emil Velikov  wrote:
> This is a trivial enough function that can live in the header. While
> we're here, add a STATIC_ASSERT for good measure.
>
> Signed-off-by: Emil Velikov 
> ---
>  src/glsl/shader_enums.c | 13 -
>  src/glsl/shader_enums.h | 23 +--
>  2 files changed, 21 insertions(+), 15 deletions(-)
>
> diff --git a/src/glsl/shader_enums.c b/src/glsl/shader_enums.c
> index c196b79..b3da3e9 100644
> --- a/src/glsl/shader_enums.c
> +++ b/src/glsl/shader_enums.c
> @@ -32,19 +32,6 @@
>  #define ENUM(x) [x] = #x
>  #define NAME(val) val) < ARRAY_SIZE(names)) && names[(val)]) ? 
> names[(val)] : "UNKNOWN")
>
> -const char * gl_shader_stage_name(gl_shader_stage stage)
> -{
> -   static const char *names[] = {
> -  ENUM(MESA_SHADER_VERTEX),
> -  ENUM(MESA_SHADER_TESS_CTRL),
> -  ENUM(MESA_SHADER_TESS_EVAL),
> -  ENUM(MESA_SHADER_GEOMETRY),
> -  ENUM(MESA_SHADER_FRAGMENT),
> -  ENUM(MESA_SHADER_COMPUTE),
> -   };
> -   return NAME(stage);
> -}
> -
>  const char * gl_vert_attrib_name(gl_vert_attrib attrib)
>  {
> static const char *names[] = {
> diff --git a/src/glsl/shader_enums.h b/src/glsl/shader_enums.h
> index 2a5d2c5..fbd2744 100644
> --- a/src/glsl/shader_enums.h
> +++ b/src/glsl/shader_enums.h
> @@ -43,10 +43,27 @@ typedef enum
> MESA_SHADER_COMPUTE = 5,
>  } gl_shader_stage;
>
> -const char * gl_shader_stage_name(gl_shader_stage stage);
> -
>  #define MESA_SHADER_STAGES (MESA_SHADER_COMPUTE + 1)
>
> +#define ENUM(x) [x] = #x
> +
> +static const char *gl_shader_stage_names[] = {
> +   ENUM(MESA_SHADER_VERTEX),
> +   ENUM(MESA_SHADER_TESS_CTRL),
> +   ENUM(MESA_SHADER_TESS_EVAL),
> +   ENUM(MESA_SHADER_GEOMETRY),
> +   ENUM(MESA_SHADER_FRAGMENT),
> +   ENUM(MESA_SHADER_COMPUTE),
> +};

Won't this bloat the binary by including this in every object file? I
don't know that the array will get merged. (The strings will though.)
Normally these things live in c files so that they're stored in only
one object.

> +
> +static inline const char *gl_shader_stage_name(gl_shader_stage stage)
> +{
> +   STATIC_ASSERT(ARRAY_SIZE(gl_shader_stage_names) == MESA_SHADER_STAGES);
> +   if (stage < ARRAY_SIZE(gl_shader_stage_names))
> +  return gl_shader_stage_names[stage];
> +   else
> +  return "UNKNOWN";
> +}
>
>  /**
>   * Indexes for vertex program attributes.
> @@ -473,4 +490,6 @@ typedef enum
>
>  const char * gl_frag_result_name(gl_frag_result result);
>
> +#undef ENUM
> +
>  #endif /* SHADER_ENUMS_H */
> --
> 2.5.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/4] glsl: Only set ir_variable::constant_value for const-decorated variables

2015-10-08 Thread Ian Romanick
On 10/08/2015 02:50 AM, Iago Toral wrote:
> On Wed, 2015-10-07 at 14:34 -0700, Ian Romanick wrote:
>> From: Ian Romanick 
>>
>> Right now we're also setting for uniforms, and that doesn't seem to hurt
>> things.  The next patch will make general global variables in GLSL ES,
>> and those definitely should not have constant_value set!
> 
> I think this breaks uniforms initializers in desktop GLSL (which are
> allowed). See link_uniform_initializers.cpp, that code expects uniforms
> with constant_value set.

You are correct.  The run through that CI system that I started when I
sent the patches out confirms... all the uniform initializer tests fail.
 I'm not sure why the linker doesn't just use constant_initializer
instead.  I knew the linker needed this data (because I wrote that
part), but I was not expecting it to use constant_value.  I'll dig more.

> Verified with this quick test:
> 
> --- vertex shader:
> #version 330
> layout(location = 0) in vec3 inVertexPosition;
> uniform mat4 MVP;
> uniform float test = 1.0;
> out float v2f;
> 
> void main()
> {
>gl_Position = MVP * vec4(inVertexPosition, 1);
>v2f = test;
> }
> 
> --- fragment shader:
> #version 330
> in float v2f;
> out vec3 color;
> 
> void main()
> {
>color = vec3(v2f);
> }
> 
> Without your patch, the constant initialization of 'test' is handled by
> linker::set_uniform_initializer, which won't happen with this patch
> applied.
> 
> Iago
> 
>> Signed-off-by: Ian Romanick 
>> ---
>>  src/glsl/ast_to_hir.cpp | 9 ++---
>>  1 file changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
>> index 9511440..e3d4c44 100644
>> --- a/src/glsl/ast_to_hir.cpp
>> +++ b/src/glsl/ast_to_hir.cpp
>> @@ -3238,17 +3238,20 @@ process_initializer(ir_variable *var, 
>> ast_declaration *decl,
>>  decl->identifier);
>> if (var->type->is_numeric()) {
>>/* Reduce cascading errors. */
>> -  var->constant_value = ir_constant::zero(state, var->type);
>> +  var->constant_value = type->qualifier.flags.q.constant
>> + ? ir_constant::zero(state, var->type) : NULL;
>> }
>>  }
>>   } else {
>>  rhs = constant_value;
>> -var->constant_value = constant_value;
>> +var->constant_value = type->qualifier.flags.q.constant
>> +   ? constant_value : NULL;
>>   }
>>} else {
>>   if (var->type->is_numeric()) {
>>  /* Reduce cascading errors. */
>> -var->constant_value = ir_constant::zero(state, var->type);
>> +var->constant_value = type->qualifier.flags.q.constant
>> +   ? ir_constant::zero(state, var->type) : NULL;
>>   }
>>}
>> }
> 
> 

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


[Mesa-dev] [PATCH 7/7] glsl: remove shader_enums.c

2015-10-08 Thread Emil Velikov
It's an empty file now.

Signed-off-by: Emil Velikov 
---
 src/Makefile.am   |  1 -
 src/glsl/shader_enums.c   | 34 --
 src/mesa/Makefile.sources |  4 +---
 3 files changed, 1 insertion(+), 38 deletions(-)
 delete mode 100644 src/glsl/shader_enums.c

diff --git a/src/Makefile.am b/src/Makefile.am
index 9e15cca..0d49bcd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -62,7 +62,6 @@ AM_CPPFLAGS = \
 noinst_LTLIBRARIES = libglsl_util.la
 
 libglsl_util_la_SOURCES = \
-   glsl/shader_enums.c \
mesa/main/imports.c \
mesa/program/prog_hash_table.c \
mesa/program/symbol_table.c \
diff --git a/src/glsl/shader_enums.c b/src/glsl/shader_enums.c
deleted file mode 100644
index f998cb8..000
--- a/src/glsl/shader_enums.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright © 2015 Red Hat
- *
- * 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:
- *Rob Clark 
- */
-
-#include "glsl/shader_enums.h"
-#include "util/macros.h"
-
-#define ENUM(x) [x] = #x
-#define NAME(val) val) < ARRAY_SIZE(names)) && names[(val)]) ? 
names[(val)] : "UNKNOWN")
-
diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
index 0915594..b40ee4d 100644
--- a/src/mesa/Makefile.sources
+++ b/src/mesa/Makefile.sources
@@ -525,9 +525,7 @@ PROGRAM_FILES = \
program/sampler.h \
program/string_to_uint_map.cpp \
program/symbol_table.c \
-   program/symbol_table.h \
-   ../glsl/shader_enums.c \
-   ../glsl/shader_enums.h
+   program/symbol_table.h
 
 PROGRAM_NIR_FILES = \
program/prog_to_nir.c \
-- 
2.5.0

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


[Mesa-dev] [PATCH 6/7] glsl: move gl_frag_result_name() definition to shader_enums.h

2015-10-08 Thread Emil Velikov
This is a trivial enough function that can live in the header. While
we're here, add a STATIC_ASSERT for good measure.

Move FRAG_RESULT_MAX macro to shader_enums.h

Signed-off-by: Emil Velikov 
---
 src/glsl/shader_enums.c | 18 --
 src/glsl/shader_enums.h | 26 +-
 src/mesa/main/mtypes.h  |  1 -
 3 files changed, 25 insertions(+), 20 deletions(-)

diff --git a/src/glsl/shader_enums.c b/src/glsl/shader_enums.c
index 1e8ea66..f998cb8 100644
--- a/src/glsl/shader_enums.c
+++ b/src/glsl/shader_enums.c
@@ -32,21 +32,3 @@
 #define ENUM(x) [x] = #x
 #define NAME(val) val) < ARRAY_SIZE(names)) && names[(val)]) ? 
names[(val)] : "UNKNOWN")
 
-const char * gl_frag_result_name(gl_frag_result result)
-{
-   static const char *names[] = {
-  ENUM(FRAG_RESULT_DEPTH),
-  ENUM(FRAG_RESULT_STENCIL),
-  ENUM(FRAG_RESULT_COLOR),
-  ENUM(FRAG_RESULT_SAMPLE_MASK),
-  ENUM(FRAG_RESULT_DATA0),
-  ENUM(FRAG_RESULT_DATA1),
-  ENUM(FRAG_RESULT_DATA2),
-  ENUM(FRAG_RESULT_DATA3),
-  ENUM(FRAG_RESULT_DATA4),
-  ENUM(FRAG_RESULT_DATA5),
-  ENUM(FRAG_RESULT_DATA6),
-  ENUM(FRAG_RESULT_DATA7),
-   };
-   return NAME(result);
-}
diff --git a/src/glsl/shader_enums.h b/src/glsl/shader_enums.h
index 0305f5d..7d4e573 100644
--- a/src/glsl/shader_enums.h
+++ b/src/glsl/shader_enums.h
@@ -643,7 +643,31 @@ typedef enum
FRAG_RESULT_DATA7,
 } gl_frag_result;
 
-const char * gl_frag_result_name(gl_frag_result result);
+#define FRAG_RESULT_MAX (FRAG_RESULT_DATA7 + 1)
+
+static const char *gl_frag_result_names[] = {
+   ENUM(FRAG_RESULT_DEPTH),
+   ENUM(FRAG_RESULT_STENCIL),
+   ENUM(FRAG_RESULT_COLOR),
+   ENUM(FRAG_RESULT_SAMPLE_MASK),
+   ENUM(FRAG_RESULT_DATA0),
+   ENUM(FRAG_RESULT_DATA1),
+   ENUM(FRAG_RESULT_DATA2),
+   ENUM(FRAG_RESULT_DATA3),
+   ENUM(FRAG_RESULT_DATA4),
+   ENUM(FRAG_RESULT_DATA5),
+   ENUM(FRAG_RESULT_DATA6),
+   ENUM(FRAG_RESULT_DATA7),
+};
+
+static inline const char *gl_frag_result_name(gl_frag_result result)
+{
+   STATIC_ASSERT(ARRAY_SIZE(gl_frag_result_names) == FRAG_RESULT_MAX);
+   if (result < ARRAY_SIZE(gl_frag_result_names))
+  return gl_frag_result_names[result];
+   else
+  return "UNKNOWN";
+}
 
 #undef ENUM
 
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 00a4edc..929fe64 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -96,7 +96,6 @@ struct vbo_context;
 
 #define VARYING_SLOT_PATCH0(VARYING_SLOT_MAX)
 #define VARYING_SLOT_TESS_MAX  (VARYING_SLOT_PATCH0 + MAX_VARYING)
-#define FRAG_RESULT_MAX(FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS)
 
 /**
  * Determine if the given gl_varying_slot appears in the fragment shader.
-- 
2.5.0

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


[Mesa-dev] [PATCH 2/7] glsl: move gl_vert_attrib_name() definition to shader_enums.h

2015-10-08 Thread Emil Velikov
This is a trivial enough function that can live in the header. While
we're here, add a STATIC_ASSERT for good measure.

Signed-off-by: Emil Velikov 
---
 src/glsl/shader_enums.c | 40 
 src/glsl/shader_enums.h | 45 -
 2 files changed, 44 insertions(+), 41 deletions(-)

diff --git a/src/glsl/shader_enums.c b/src/glsl/shader_enums.c
index b3da3e9..4abdc328 100644
--- a/src/glsl/shader_enums.c
+++ b/src/glsl/shader_enums.c
@@ -32,46 +32,6 @@
 #define ENUM(x) [x] = #x
 #define NAME(val) val) < ARRAY_SIZE(names)) && names[(val)]) ? 
names[(val)] : "UNKNOWN")
 
-const char * gl_vert_attrib_name(gl_vert_attrib attrib)
-{
-   static const char *names[] = {
-  ENUM(VERT_ATTRIB_POS),
-  ENUM(VERT_ATTRIB_WEIGHT),
-  ENUM(VERT_ATTRIB_NORMAL),
-  ENUM(VERT_ATTRIB_COLOR0),
-  ENUM(VERT_ATTRIB_COLOR1),
-  ENUM(VERT_ATTRIB_FOG),
-  ENUM(VERT_ATTRIB_COLOR_INDEX),
-  ENUM(VERT_ATTRIB_EDGEFLAG),
-  ENUM(VERT_ATTRIB_TEX0),
-  ENUM(VERT_ATTRIB_TEX1),
-  ENUM(VERT_ATTRIB_TEX2),
-  ENUM(VERT_ATTRIB_TEX3),
-  ENUM(VERT_ATTRIB_TEX4),
-  ENUM(VERT_ATTRIB_TEX5),
-  ENUM(VERT_ATTRIB_TEX6),
-  ENUM(VERT_ATTRIB_TEX7),
-  ENUM(VERT_ATTRIB_POINT_SIZE),
-  ENUM(VERT_ATTRIB_GENERIC0),
-  ENUM(VERT_ATTRIB_GENERIC1),
-  ENUM(VERT_ATTRIB_GENERIC2),
-  ENUM(VERT_ATTRIB_GENERIC3),
-  ENUM(VERT_ATTRIB_GENERIC4),
-  ENUM(VERT_ATTRIB_GENERIC5),
-  ENUM(VERT_ATTRIB_GENERIC6),
-  ENUM(VERT_ATTRIB_GENERIC7),
-  ENUM(VERT_ATTRIB_GENERIC8),
-  ENUM(VERT_ATTRIB_GENERIC9),
-  ENUM(VERT_ATTRIB_GENERIC10),
-  ENUM(VERT_ATTRIB_GENERIC11),
-  ENUM(VERT_ATTRIB_GENERIC12),
-  ENUM(VERT_ATTRIB_GENERIC13),
-  ENUM(VERT_ATTRIB_GENERIC14),
-  ENUM(VERT_ATTRIB_GENERIC15),
-   };
-   return NAME(attrib);
-}
-
 const char * gl_varying_slot_name(gl_varying_slot slot)
 {
static const char *names[] = {
diff --git a/src/glsl/shader_enums.h b/src/glsl/shader_enums.h
index fbd2744..7ea953b 100644
--- a/src/glsl/shader_enums.h
+++ b/src/glsl/shader_enums.h
@@ -110,7 +110,50 @@ typedef enum
VERT_ATTRIB_MAX = 33
 } gl_vert_attrib;
 
-const char * gl_vert_attrib_name(gl_vert_attrib attrib);
+static const char *gl_vert_attrib_names[] = {
+   ENUM(VERT_ATTRIB_POS),
+   ENUM(VERT_ATTRIB_WEIGHT),
+   ENUM(VERT_ATTRIB_NORMAL),
+   ENUM(VERT_ATTRIB_COLOR0),
+   ENUM(VERT_ATTRIB_COLOR1),
+   ENUM(VERT_ATTRIB_FOG),
+   ENUM(VERT_ATTRIB_COLOR_INDEX),
+   ENUM(VERT_ATTRIB_EDGEFLAG),
+   ENUM(VERT_ATTRIB_TEX0),
+   ENUM(VERT_ATTRIB_TEX1),
+   ENUM(VERT_ATTRIB_TEX2),
+   ENUM(VERT_ATTRIB_TEX3),
+   ENUM(VERT_ATTRIB_TEX4),
+   ENUM(VERT_ATTRIB_TEX5),
+   ENUM(VERT_ATTRIB_TEX6),
+   ENUM(VERT_ATTRIB_TEX7),
+   ENUM(VERT_ATTRIB_POINT_SIZE),
+   ENUM(VERT_ATTRIB_GENERIC0),
+   ENUM(VERT_ATTRIB_GENERIC1),
+   ENUM(VERT_ATTRIB_GENERIC2),
+   ENUM(VERT_ATTRIB_GENERIC3),
+   ENUM(VERT_ATTRIB_GENERIC4),
+   ENUM(VERT_ATTRIB_GENERIC5),
+   ENUM(VERT_ATTRIB_GENERIC6),
+   ENUM(VERT_ATTRIB_GENERIC7),
+   ENUM(VERT_ATTRIB_GENERIC8),
+   ENUM(VERT_ATTRIB_GENERIC9),
+   ENUM(VERT_ATTRIB_GENERIC10),
+   ENUM(VERT_ATTRIB_GENERIC11),
+   ENUM(VERT_ATTRIB_GENERIC12),
+   ENUM(VERT_ATTRIB_GENERIC13),
+   ENUM(VERT_ATTRIB_GENERIC14),
+   ENUM(VERT_ATTRIB_GENERIC15),
+};
+
+static inline const char *gl_vert_attrib_name(gl_vert_attrib attrib)
+{
+   STATIC_ASSERT(ARRAY_SIZE(gl_vert_attrib_names) == VERT_ATTRIB_MAX);
+   if (attrib < ARRAY_SIZE(gl_vert_attrib_names))
+  return gl_vert_attrib_names[attrib];
+   else
+  return "UNKNOWN";
+}
 
 /**
  * Symbolic constats to help iterating over
-- 
2.5.0

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


[Mesa-dev] [PATCH 5/7] glsl: move glsl_interp_qualifier_name() definition to shader_enums.h

2015-10-08 Thread Emil Velikov
This is a trivial enough function that can live in the header. While
we're here, add a STATIC_ASSERT for good measure.

Signed-off-by: Emil Velikov 
---
 src/glsl/shader_enums.c | 11 ---
 src/glsl/shader_enums.h | 16 +++-
 2 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/src/glsl/shader_enums.c b/src/glsl/shader_enums.c
index 9b9ec2b..1e8ea66 100644
--- a/src/glsl/shader_enums.c
+++ b/src/glsl/shader_enums.c
@@ -32,17 +32,6 @@
 #define ENUM(x) [x] = #x
 #define NAME(val) val) < ARRAY_SIZE(names)) && names[(val)]) ? 
names[(val)] : "UNKNOWN")
 
-const char * glsl_interp_qualifier_name(enum glsl_interp_qualifier qual)
-{
-   static const char *names[] = {
-  ENUM(INTERP_QUALIFIER_NONE),
-  ENUM(INTERP_QUALIFIER_SMOOTH),
-  ENUM(INTERP_QUALIFIER_FLAT),
-  ENUM(INTERP_QUALIFIER_NOPERSPECTIVE),
-   };
-   return NAME(qual);
-}
-
 const char * gl_frag_result_name(gl_frag_result result)
 {
static const char *names[] = {
diff --git a/src/glsl/shader_enums.h b/src/glsl/shader_enums.h
index a560017..0305f5d 100644
--- a/src/glsl/shader_enums.h
+++ b/src/glsl/shader_enums.h
@@ -598,7 +598,21 @@ enum glsl_interp_qualifier
INTERP_QUALIFIER_COUNT /**< Number of interpolation qualifiers */
 };
 
-const char * glsl_interp_qualifier_name(enum glsl_interp_qualifier qual);
+static const char *glsl_interp_qualifier_names[] = {
+   ENUM(INTERP_QUALIFIER_NONE),
+   ENUM(INTERP_QUALIFIER_SMOOTH),
+   ENUM(INTERP_QUALIFIER_FLAT),
+   ENUM(INTERP_QUALIFIER_NOPERSPECTIVE),
+};
+
+static inline const char *glsl_interp_qualifier_name(enum 
glsl_interp_qualifier qual)
+{
+   STATIC_ASSERT(ARRAY_SIZE(glsl_interp_qualifier_names) == 
INTERP_QUALIFIER_COUNT);
+   if (qual < ARRAY_SIZE(glsl_interp_qualifier_names))
+  return glsl_interp_qualifier_names[qual];
+   else
+  return "UNKNOWN";
+}
 
 /**
  * Fragment program results
-- 
2.5.0

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


[Mesa-dev] [PATCH 1/7] glsl: move gl_shader_stage_name() definition to shader_enums.h

2015-10-08 Thread Emil Velikov
This is a trivial enough function that can live in the header. While
we're here, add a STATIC_ASSERT for good measure.

Signed-off-by: Emil Velikov 
---
 src/glsl/shader_enums.c | 13 -
 src/glsl/shader_enums.h | 23 +--
 2 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/src/glsl/shader_enums.c b/src/glsl/shader_enums.c
index c196b79..b3da3e9 100644
--- a/src/glsl/shader_enums.c
+++ b/src/glsl/shader_enums.c
@@ -32,19 +32,6 @@
 #define ENUM(x) [x] = #x
 #define NAME(val) val) < ARRAY_SIZE(names)) && names[(val)]) ? 
names[(val)] : "UNKNOWN")
 
-const char * gl_shader_stage_name(gl_shader_stage stage)
-{
-   static const char *names[] = {
-  ENUM(MESA_SHADER_VERTEX),
-  ENUM(MESA_SHADER_TESS_CTRL),
-  ENUM(MESA_SHADER_TESS_EVAL),
-  ENUM(MESA_SHADER_GEOMETRY),
-  ENUM(MESA_SHADER_FRAGMENT),
-  ENUM(MESA_SHADER_COMPUTE),
-   };
-   return NAME(stage);
-}
-
 const char * gl_vert_attrib_name(gl_vert_attrib attrib)
 {
static const char *names[] = {
diff --git a/src/glsl/shader_enums.h b/src/glsl/shader_enums.h
index 2a5d2c5..fbd2744 100644
--- a/src/glsl/shader_enums.h
+++ b/src/glsl/shader_enums.h
@@ -43,10 +43,27 @@ typedef enum
MESA_SHADER_COMPUTE = 5,
 } gl_shader_stage;
 
-const char * gl_shader_stage_name(gl_shader_stage stage);
-
 #define MESA_SHADER_STAGES (MESA_SHADER_COMPUTE + 1)
 
+#define ENUM(x) [x] = #x
+
+static const char *gl_shader_stage_names[] = {
+   ENUM(MESA_SHADER_VERTEX),
+   ENUM(MESA_SHADER_TESS_CTRL),
+   ENUM(MESA_SHADER_TESS_EVAL),
+   ENUM(MESA_SHADER_GEOMETRY),
+   ENUM(MESA_SHADER_FRAGMENT),
+   ENUM(MESA_SHADER_COMPUTE),
+};
+
+static inline const char *gl_shader_stage_name(gl_shader_stage stage)
+{
+   STATIC_ASSERT(ARRAY_SIZE(gl_shader_stage_names) == MESA_SHADER_STAGES);
+   if (stage < ARRAY_SIZE(gl_shader_stage_names))
+  return gl_shader_stage_names[stage];
+   else
+  return "UNKNOWN";
+}
 
 /**
  * Indexes for vertex program attributes.
@@ -473,4 +490,6 @@ typedef enum
 
 const char * gl_frag_result_name(gl_frag_result result);
 
+#undef ENUM
+
 #endif /* SHADER_ENUMS_H */
-- 
2.5.0

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


[Mesa-dev] [PATCH 3/7] glsl: move gl_varying_slot_name() definition to shader_enums.h

2015-10-08 Thread Emil Velikov
This is a trivial enough function that can live in the header. While
we're here, add a STATIC_ASSERT for good measure.

Move VARYING_SLOT_MAX macro to shader_enums.h

Signed-off-by: Emil Velikov 
---
 src/glsl/shader_enums.c | 65 
 src/glsl/shader_enums.h | 72 -
 src/mesa/main/mtypes.h  |  1 -
 3 files changed, 71 insertions(+), 67 deletions(-)

diff --git a/src/glsl/shader_enums.c b/src/glsl/shader_enums.c
index 4abdc328..61c1fa6 100644
--- a/src/glsl/shader_enums.c
+++ b/src/glsl/shader_enums.c
@@ -32,71 +32,6 @@
 #define ENUM(x) [x] = #x
 #define NAME(val) val) < ARRAY_SIZE(names)) && names[(val)]) ? 
names[(val)] : "UNKNOWN")
 
-const char * gl_varying_slot_name(gl_varying_slot slot)
-{
-   static const char *names[] = {
-  ENUM(VARYING_SLOT_POS),
-  ENUM(VARYING_SLOT_COL0),
-  ENUM(VARYING_SLOT_COL1),
-  ENUM(VARYING_SLOT_FOGC),
-  ENUM(VARYING_SLOT_TEX0),
-  ENUM(VARYING_SLOT_TEX1),
-  ENUM(VARYING_SLOT_TEX2),
-  ENUM(VARYING_SLOT_TEX3),
-  ENUM(VARYING_SLOT_TEX4),
-  ENUM(VARYING_SLOT_TEX5),
-  ENUM(VARYING_SLOT_TEX6),
-  ENUM(VARYING_SLOT_TEX7),
-  ENUM(VARYING_SLOT_PSIZ),
-  ENUM(VARYING_SLOT_BFC0),
-  ENUM(VARYING_SLOT_BFC1),
-  ENUM(VARYING_SLOT_EDGE),
-  ENUM(VARYING_SLOT_CLIP_VERTEX),
-  ENUM(VARYING_SLOT_CLIP_DIST0),
-  ENUM(VARYING_SLOT_CLIP_DIST1),
-  ENUM(VARYING_SLOT_PRIMITIVE_ID),
-  ENUM(VARYING_SLOT_LAYER),
-  ENUM(VARYING_SLOT_VIEWPORT),
-  ENUM(VARYING_SLOT_FACE),
-  ENUM(VARYING_SLOT_PNTC),
-  ENUM(VARYING_SLOT_TESS_LEVEL_OUTER),
-  ENUM(VARYING_SLOT_TESS_LEVEL_INNER),
-  ENUM(VARYING_SLOT_VAR0),
-  ENUM(VARYING_SLOT_VAR1),
-  ENUM(VARYING_SLOT_VAR2),
-  ENUM(VARYING_SLOT_VAR3),
-  ENUM(VARYING_SLOT_VAR4),
-  ENUM(VARYING_SLOT_VAR5),
-  ENUM(VARYING_SLOT_VAR6),
-  ENUM(VARYING_SLOT_VAR7),
-  ENUM(VARYING_SLOT_VAR8),
-  ENUM(VARYING_SLOT_VAR9),
-  ENUM(VARYING_SLOT_VAR10),
-  ENUM(VARYING_SLOT_VAR11),
-  ENUM(VARYING_SLOT_VAR12),
-  ENUM(VARYING_SLOT_VAR13),
-  ENUM(VARYING_SLOT_VAR14),
-  ENUM(VARYING_SLOT_VAR15),
-  ENUM(VARYING_SLOT_VAR16),
-  ENUM(VARYING_SLOT_VAR17),
-  ENUM(VARYING_SLOT_VAR18),
-  ENUM(VARYING_SLOT_VAR19),
-  ENUM(VARYING_SLOT_VAR20),
-  ENUM(VARYING_SLOT_VAR21),
-  ENUM(VARYING_SLOT_VAR22),
-  ENUM(VARYING_SLOT_VAR23),
-  ENUM(VARYING_SLOT_VAR24),
-  ENUM(VARYING_SLOT_VAR25),
-  ENUM(VARYING_SLOT_VAR26),
-  ENUM(VARYING_SLOT_VAR27),
-  ENUM(VARYING_SLOT_VAR28),
-  ENUM(VARYING_SLOT_VAR29),
-  ENUM(VARYING_SLOT_VAR30),
-  ENUM(VARYING_SLOT_VAR31),
-   };
-   return NAME(slot);
-}
-
 const char * gl_system_value_name(gl_system_value sysval)
 {
static const char *names[] = {
diff --git a/src/glsl/shader_enums.h b/src/glsl/shader_enums.h
index 7ea953b..9afbb8d 100644
--- a/src/glsl/shader_enums.h
+++ b/src/glsl/shader_enums.h
@@ -293,7 +293,77 @@ typedef enum
VARYING_SLOT_VAR31,
 } gl_varying_slot;
 
-const char * gl_varying_slot_name(gl_varying_slot slot);
+#define VARYING_SLOT_MAX (VARYING_SLOT_VAR31 + 1)
+
+static const char *gl_varying_slot_names[] = {
+   ENUM(VARYING_SLOT_POS),
+   ENUM(VARYING_SLOT_COL0),
+   ENUM(VARYING_SLOT_COL1),
+   ENUM(VARYING_SLOT_FOGC),
+   ENUM(VARYING_SLOT_TEX0),
+   ENUM(VARYING_SLOT_TEX1),
+   ENUM(VARYING_SLOT_TEX2),
+   ENUM(VARYING_SLOT_TEX3),
+   ENUM(VARYING_SLOT_TEX4),
+   ENUM(VARYING_SLOT_TEX5),
+   ENUM(VARYING_SLOT_TEX6),
+   ENUM(VARYING_SLOT_TEX7),
+   ENUM(VARYING_SLOT_PSIZ),
+   ENUM(VARYING_SLOT_BFC0),
+   ENUM(VARYING_SLOT_BFC1),
+   ENUM(VARYING_SLOT_EDGE),
+   ENUM(VARYING_SLOT_CLIP_VERTEX),
+   ENUM(VARYING_SLOT_CLIP_DIST0),
+   ENUM(VARYING_SLOT_CLIP_DIST1),
+   ENUM(VARYING_SLOT_PRIMITIVE_ID),
+   ENUM(VARYING_SLOT_LAYER),
+   ENUM(VARYING_SLOT_VIEWPORT),
+   ENUM(VARYING_SLOT_FACE),
+   ENUM(VARYING_SLOT_PNTC),
+   ENUM(VARYING_SLOT_TESS_LEVEL_OUTER),
+   ENUM(VARYING_SLOT_TESS_LEVEL_INNER),
+   ENUM(VARYING_SLOT_VAR0),
+   ENUM(VARYING_SLOT_VAR1),
+   ENUM(VARYING_SLOT_VAR2),
+   ENUM(VARYING_SLOT_VAR3),
+   ENUM(VARYING_SLOT_VAR4),
+   ENUM(VARYING_SLOT_VAR5),
+   ENUM(VARYING_SLOT_VAR6),
+   ENUM(VARYING_SLOT_VAR7),
+   ENUM(VARYING_SLOT_VAR8),
+   ENUM(VARYING_SLOT_VAR9),
+   ENUM(VARYING_SLOT_VAR10),
+   ENUM(VARYING_SLOT_VAR11),
+   ENUM(VARYING_SLOT_VAR12),
+   ENUM(VARYING_SLOT_VAR13),
+   ENUM(VARYING_SLOT_VAR14),
+   ENUM(VARYING_SLOT_VAR15),
+   ENUM(VARYING_SLOT_VAR16),
+   ENUM(VARYING_SLOT_VAR17),
+   ENUM(VARYING_SLOT_VAR18),
+   ENUM(VARYING_SLOT_VAR19),
+   ENUM(VARYING_SLOT_VAR20),
+   ENUM(VARYING_SLOT_VAR21),
+   ENUM(VARYING_SLOT_VAR22),
+   ENUM(VARYING_SLOT_VAR23),
+   ENUM(VARYING_SLOT_VAR24),
+   ENUM(VARYING_SLOT_VAR25),
+   ENUM(VARYING_SLOT_VAR26),
+   ENUM(VARYING_SLOT_VAR27),
+   ENUM(VARYING_SLOT_VAR28),
+   ENUM(VARYING_SLOT_VAR29),
+   ENUM(VAR

[Mesa-dev] [PATCH 4/7] glsl: move gl_system_value_name() definition to shader_enums.h

2015-10-08 Thread Emil Velikov
This is a trivial enough function that can live in the header. While
we're here, add a STATIC_ASSERT for good measure.

Add the missing SYSTEM_VALUE_NUM_WORK_GROUPS enum.

Signed-off-by: Emil Velikov 
---
 src/glsl/shader_enums.c | 24 
 src/glsl/shader_enums.h | 30 +-
 2 files changed, 29 insertions(+), 25 deletions(-)

diff --git a/src/glsl/shader_enums.c b/src/glsl/shader_enums.c
index 61c1fa6..9b9ec2b 100644
--- a/src/glsl/shader_enums.c
+++ b/src/glsl/shader_enums.c
@@ -32,30 +32,6 @@
 #define ENUM(x) [x] = #x
 #define NAME(val) val) < ARRAY_SIZE(names)) && names[(val)]) ? 
names[(val)] : "UNKNOWN")
 
-const char * gl_system_value_name(gl_system_value sysval)
-{
-   static const char *names[] = {
- ENUM(SYSTEM_VALUE_VERTEX_ID),
- ENUM(SYSTEM_VALUE_INSTANCE_ID),
- ENUM(SYSTEM_VALUE_VERTEX_ID_ZERO_BASE),
- ENUM(SYSTEM_VALUE_BASE_VERTEX),
- ENUM(SYSTEM_VALUE_INVOCATION_ID),
- ENUM(SYSTEM_VALUE_FRONT_FACE),
- ENUM(SYSTEM_VALUE_SAMPLE_ID),
- ENUM(SYSTEM_VALUE_SAMPLE_POS),
- ENUM(SYSTEM_VALUE_SAMPLE_MASK_IN),
- ENUM(SYSTEM_VALUE_TESS_COORD),
- ENUM(SYSTEM_VALUE_VERTICES_IN),
- ENUM(SYSTEM_VALUE_PRIMITIVE_ID),
- ENUM(SYSTEM_VALUE_TESS_LEVEL_OUTER),
- ENUM(SYSTEM_VALUE_TESS_LEVEL_INNER),
- ENUM(SYSTEM_VALUE_LOCAL_INVOCATION_ID),
- ENUM(SYSTEM_VALUE_WORK_GROUP_ID),
- ENUM(SYSTEM_VALUE_VERTEX_CNT),
-   };
-   return NAME(sysval);
-}
-
 const char * glsl_interp_qualifier_name(enum glsl_interp_qualifier qual)
 {
static const char *names[] = {
diff --git a/src/glsl/shader_enums.h b/src/glsl/shader_enums.h
index 9afbb8d..a560017 100644
--- a/src/glsl/shader_enums.h
+++ b/src/glsl/shader_enums.h
@@ -552,7 +552,35 @@ typedef enum
SYSTEM_VALUE_MAX /**< Number of values */
 } gl_system_value;
 
-const char * gl_system_value_name(gl_system_value sysval);
+static const char *gl_system_value_names[] = {
+   ENUM(SYSTEM_VALUE_VERTEX_ID),
+   ENUM(SYSTEM_VALUE_INSTANCE_ID),
+   ENUM(SYSTEM_VALUE_VERTEX_ID_ZERO_BASE),
+   ENUM(SYSTEM_VALUE_BASE_VERTEX),
+   ENUM(SYSTEM_VALUE_INVOCATION_ID),
+   ENUM(SYSTEM_VALUE_FRONT_FACE),
+   ENUM(SYSTEM_VALUE_SAMPLE_ID),
+   ENUM(SYSTEM_VALUE_SAMPLE_POS),
+   ENUM(SYSTEM_VALUE_SAMPLE_MASK_IN),
+   ENUM(SYSTEM_VALUE_TESS_COORD),
+   ENUM(SYSTEM_VALUE_VERTICES_IN),
+   ENUM(SYSTEM_VALUE_PRIMITIVE_ID),
+   ENUM(SYSTEM_VALUE_TESS_LEVEL_OUTER),
+   ENUM(SYSTEM_VALUE_TESS_LEVEL_INNER),
+   ENUM(SYSTEM_VALUE_LOCAL_INVOCATION_ID),
+   ENUM(SYSTEM_VALUE_WORK_GROUP_ID),
+   ENUM(SYSTEM_VALUE_NUM_WORK_GROUPS),
+   ENUM(SYSTEM_VALUE_VERTEX_CNT),
+};
+
+static inline const char *gl_system_value_name(gl_system_value sysval)
+{
+   STATIC_ASSERT(ARRAY_SIZE(gl_system_value_names) == SYSTEM_VALUE_MAX);
+   if (sysval < ARRAY_SIZE(gl_system_value_names))
+  return gl_system_value_names[sysval];
+   else
+  return "UNKNOWN";
+}
 
 /**
  * The possible interpolation qualifiers that can be applied to a fragment
-- 
2.5.0

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


[Mesa-dev] [Bug 92122] [bisected, cts] Regression with Assault Android Cactus

2015-10-08 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=92122

Alex Deucher  changed:

   What|Removed |Added

 CC||kylesiefr...@gmail.com

--- Comment #18 from Alex Deucher  ---
*** Bug 92203 has been marked as a duplicate of this bug. ***

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


Re: [Mesa-dev] [PATCH 03/12] i965: Configure bufmgr debug options from intel_screen.c

2015-10-08 Thread Kristian Høgsberg
On Thu, Oct 8, 2015 at 6:52 AM, Iago Toral  wrote:
> On Thu, 2015-10-08 at 10:07 +0300, Pohjolainen, Topi wrote:
>> On Wed, Oct 07, 2015 at 07:11:43AM -0700, Kristian H?gsberg Kristensen wrote:
>> > We need the debug flag parsing and INTEL_DEBUG in the compiler, but we
>> > don't want the dependency on bufmgr (libdrm_intel) in there. Move to
>> > intel_screen.c.
>> >
>> > Signed-off-by: Kristian Høgsberg Kristensen 
>> > ---
>> >  src/mesa/drivers/dri/i965/intel_debug.c  | 14 +-
>> >  src/mesa/drivers/dri/i965/intel_debug.h  |  4 +---
>> >  src/mesa/drivers/dri/i965/intel_screen.c | 14 +-
>> >  3 files changed, 15 insertions(+), 17 deletions(-)
>> >
>> > diff --git a/src/mesa/drivers/dri/i965/intel_debug.c 
>> > b/src/mesa/drivers/dri/i965/intel_debug.c
>> > index 3120189..f7c02c8 100644
>> > --- a/src/mesa/drivers/dri/i965/intel_debug.c
>> > +++ b/src/mesa/drivers/dri/i965/intel_debug.c
>> > @@ -92,22 +92,10 @@ intel_debug_flag_for_shader_stage(gl_shader_stage 
>> > stage)
>> >  }
>> >
>> >  void
>> > -brw_process_intel_debug_variable(struct intel_screen *screen)
>> > +brw_process_intel_debug_variable(void)
>> >  {
>> > uint64_t intel_debug = parse_debug_string(getenv("INTEL_DEBUG"), 
>> > debug_control);
>> > (void) p_atomic_cmpxchg(&INTEL_DEBUG, 0, intel_debug);
>> > -
>> > -   if (INTEL_DEBUG & DEBUG_BUFMGR)
>> > -  dri_bufmgr_set_debug(screen->bufmgr, true);
>> > -
>> > -   if ((INTEL_DEBUG & DEBUG_SHADER_TIME) && screen->devinfo->gen < 7) {
>> > -  fprintf(stderr,
>> > -  "shader_time debugging requires gen7 (Ivybridge) or 
>> > better.\n");
>> > -  INTEL_DEBUG &= ~DEBUG_SHADER_TIME;
>> > -   }
>> > -
>> > -   if (INTEL_DEBUG & DEBUG_AUB)
>> > -  drm_intel_bufmgr_gem_set_aub_dump(screen->bufmgr, true);
>> >  }
>> >
>> >  /**
>> > diff --git a/src/mesa/drivers/dri/i965/intel_debug.h 
>> > b/src/mesa/drivers/dri/i965/intel_debug.h
>> > index b7d0c82..0a6e1b9 100644
>> > --- a/src/mesa/drivers/dri/i965/intel_debug.h
>> > +++ b/src/mesa/drivers/dri/i965/intel_debug.h
>> > @@ -115,8 +115,6 @@ extern uint64_t INTEL_DEBUG;
>> >
>> >  extern uint64_t intel_debug_flag_for_shader_stage(gl_shader_stage stage);
>> >
>> > -struct intel_screen;
>> > -
>> > -extern void brw_process_intel_debug_variable(struct intel_screen *);
>> > +extern void brw_process_intel_debug_variable(void);
>> >
>> >  extern bool brw_env_var_as_boolean(const char *var_name, bool 
>> > default_value);
>> > diff --git a/src/mesa/drivers/dri/i965/intel_screen.c 
>> > b/src/mesa/drivers/dri/i965/intel_screen.c
>> > index 1783835..590c45d 100644
>> > --- a/src/mesa/drivers/dri/i965/intel_screen.c
>> > +++ b/src/mesa/drivers/dri/i965/intel_screen.c
>> > @@ -1421,7 +1421,19 @@ __DRIconfig **intelInitScreen2(__DRIscreen *psp)
>> > if (!intelScreen->devinfo)
>> >return false;
>> >
>> > -   brw_process_intel_debug_variable(intelScreen);
>> > +   brw_process_intel_debug_variable();
>>
>> This is the only caller for brw_process_intel_debug_variable(). Are you
>> planning to use it from somewhere else or could we just move the two lines
>> left in it directly here?
>
> Nothing else in this series will call that function so I think it is
> probably okay to just move the two remaining lines here and remove the
> function.
>
> With that change (or an argument against) this is
> Reviewed-by: Iago Toral Quiroga 

I agree that the split is a little funny and I was on the fence about
what to do here. In the end, I left the tiny function in intel_debug.c
so I wouldn't have to export the 'debug_control' variable outside
intel_debug.c.

Kristian

>> > +
>> > +   if (INTEL_DEBUG & DEBUG_BUFMGR)
>> > +  dri_bufmgr_set_debug(intelScreen->bufmgr, true);
>> > +
>> > +   if ((INTEL_DEBUG & DEBUG_SHADER_TIME) && intelScreen->devinfo->gen < 
>> > 7) {
>> > +  fprintf(stderr,
>> > +  "shader_time debugging requires gen7 (Ivybridge) or 
>> > better.\n");
>> > +  INTEL_DEBUG &= ~DEBUG_SHADER_TIME;
>> > +   }
>> > +
>> > +   if (INTEL_DEBUG & DEBUG_AUB)
>> > +  drm_intel_bufmgr_gem_set_aub_dump(intelScreen->bufmgr, true);
>> >
>> > intelScreen->hw_must_use_separate_stencil = intelScreen->devinfo->gen 
>> > >= 7;
>> >
>> > --
>> > 2.4.3
>> >
>> > ___
>> > mesa-dev mailing list
>> > mesa-dev@lists.freedesktop.org
>> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>> ___
>> mesa-dev mailing list
>> mesa-dev@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/3] mesa: remove unused _mesa_create_nameless_texture()

2015-10-08 Thread Anuj Phogat
On Thu, Oct 8, 2015 at 7:20 AM, Brian Paul  wrote:
> ---
>  src/mesa/main/texobj.c | 20 
>  src/mesa/main/texobj.h |  3 ---
>  2 files changed, 23 deletions(-)
>
> diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
> index aa4b38c..66eacf8 100644
> --- a/src/mesa/main/texobj.c
> +++ b/src/mesa/main/texobj.c
> @@ -1185,26 +1185,6 @@ invalidate_tex_image_error_check(struct gl_context 
> *ctx, GLuint texture,
> return t;
>  }
>
> -/**
> - * Wrapper for the driver function. Need this because 
> _mesa_new_texture_object
> - * permits a target of 0 and does not initialize targetIndex.
> - */
> -struct gl_texture_object *
> -_mesa_create_nameless_texture(struct gl_context *ctx, GLenum target)
> -{
> -   struct gl_texture_object *texObj = NULL;
> -   GLint targetIndex;
> -
> -   if (target == 0)
> -  return texObj;
> -
> -   texObj = ctx->Driver.NewTextureObject(ctx, 0, target);
> -   targetIndex = _mesa_tex_target_to_index(ctx, texObj->Target);
> -   assert(targetIndex < NUM_TEXTURE_TARGETS);
> -   texObj->TargetIndex = targetIndex;
> -
> -   return texObj;
> -}
>
>  /**
>   * Helper function for glCreateTextures and glGenTextures. Need this because
> diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h
> index 690878c..8421337 100644
> --- a/src/mesa/main/texobj.h
> +++ b/src/mesa/main/texobj.h
> @@ -202,9 +202,6 @@ _mesa_unlock_context_textures( struct gl_context *ctx );
>  extern void
>  _mesa_lock_context_textures( struct gl_context *ctx );
>
> -extern struct gl_texture_object *
> -_mesa_create_nameless_texture(struct gl_context *ctx, GLenum target);
> -
>  extern void
>  _mesa_delete_nameless_texture(struct gl_context *ctx,
>struct gl_texture_object *texObj);
> --
> 1.9.1
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev

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


Re: [Mesa-dev] [PATCH 1/3] mesa: remove unneeded error check in create_textures()

2015-10-08 Thread Anuj Phogat
On Thu, Oct 8, 2015 at 7:20 AM, Brian Paul  wrote:
> Callers of create_texture() will either pass target=0 or a validated
> GL texture target enum so no need to do another error check inside
> the loop.
> ---
>  src/mesa/main/texobj.c | 11 ++-
>  1 file changed, 2 insertions(+), 9 deletions(-)
>
> diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
> index 173e43c..aa4b38c 100644
> --- a/src/mesa/main/texobj.c
> +++ b/src/mesa/main/texobj.c
> @@ -1211,6 +1211,7 @@ _mesa_create_nameless_texture(struct gl_context *ctx, 
> GLenum target)
>   * 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.
> + * \param target  either 0 or a a valid / error-checked texture target enum
>   */
>  static void
>  create_textures(struct gl_context *ctx, GLenum target,
> @@ -1219,6 +1220,7 @@ create_textures(struct gl_context *ctx, GLenum target,
> GLuint first;
> GLint i;
> const char *func = dsa ? "Create" : "Gen";
> +   const GLint targetIndex = _mesa_tex_target_to_index(ctx, target);
>
> if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
>_mesa_debug(ctx, "gl%sTextures %d\n", func, n);
> @@ -1241,7 +1243,6 @@ create_textures(struct gl_context *ctx, GLenum target,
> /* Allocate new, empty texture objects */
> for (i = 0; i < n; i++) {
>struct gl_texture_object *texObj;
> -  GLint targetIndex;
>GLuint name = first + i;
>texObj = ctx->Driver.NewTextureObject(ctx, name, target);
>if (!texObj) {
> @@ -1252,14 +1253,6 @@ create_textures(struct gl_context *ctx, GLenum target,
>
>/* 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 = %s)",
> -func, _mesa_enum_to_string(texObj->Target));
> -return;
> - }
> - assert(targetIndex < NUM_TEXTURE_TARGETS);
>   texObj->TargetIndex = targetIndex;
>}
>
> --
> 1.9.1
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev

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


Re: [Mesa-dev] [PATCH 4/6] nir: add shader_clock intrinsic

2015-10-08 Thread Connor Abbott
On Thu, Oct 8, 2015 at 10:09 AM, Emil Velikov  wrote:
> On 8 October 2015 at 14:20, Connor Abbott  wrote:
>> On Thu, Oct 8, 2015 at 6:54 AM, Emil Velikov  
>> wrote:
>>> On 7 October 2015 at 23:50, Connor Abbott  wrote:
 On Wed, Oct 7, 2015 at 4:48 PM, Emil Velikov  
 wrote:
> On 7 October 2015 at 18:04, Connor Abbott  wrote:
>> On Wed, Oct 7, 2015 at 7:51 AM, Emil Velikov  
>> wrote:
>>> XXX: commit message, comment in nir_intrinsics.h
>>>
>>> Signed-off-by: Emil Velikov 
>>> ---
>>>  src/glsl/nir/glsl_to_nir.cpp  | 6 ++
>>>  src/glsl/nir/nir_intrinsics.h | 2 ++
>>>  2 files changed, 8 insertions(+)
>>>
>>> diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp
>>> index efaa73e..231bdbf 100644
>>> --- a/src/glsl/nir/glsl_to_nir.cpp
>>> +++ b/src/glsl/nir/glsl_to_nir.cpp
>>> @@ -698,6 +698,8 @@ nir_visitor::visit(ir_call *ir)
>>>   op = nir_intrinsic_ssbo_atomic_exchange;
>>>} else if (strcmp(ir->callee_name(), 
>>> "__intrinsic_ssbo_atomic_comp_swap_internal") == 0) {
>>>   op = nir_intrinsic_ssbo_atomic_comp_swap;
>>> +  } else if (strcmp(ir->callee_name(), "__intrinsic_shader_clock") 
>>> == 0) {
>>> + op = nir_intrinsic_shader_clock;
>>>} else {
>>>   unreachable("not reached");
>>>}
>>> @@ -802,6 +804,10 @@ nir_visitor::visit(ir_call *ir)
>>>case nir_intrinsic_memory_barrier:
>>>   nir_instr_insert_after_cf_list(this->cf_node_list, 
>>> &instr->instr);
>>>   break;
>>> +  case nir_intrinsic_shader_clock:
>>> + nir_ssa_dest_init(&instr->instr, &instr->dest, 1, NULL);
>>> + nir_instr_insert_after_cf_list(this->cf_node_list, 
>>> &instr->instr);
>>> + break;
>>>case nir_intrinsic_store_ssbo: {
>>>   exec_node *param = ir->actual_parameters.get_head();
>>>   ir_rvalue *block = ((ir_instruction *)param)->as_rvalue();
>>> diff --git a/src/glsl/nir/nir_intrinsics.h 
>>> b/src/glsl/nir/nir_intrinsics.h
>>> index 263d8c1..4b32215 100644
>>> --- a/src/glsl/nir/nir_intrinsics.h
>>> +++ b/src/glsl/nir/nir_intrinsics.h
>>> @@ -83,6 +83,8 @@ BARRIER(discard)
>>>   */
>>>  BARRIER(memory_barrier)
>>>
>>> +INTRINSIC(shader_clock, 0, ARR(), true, 1, 1, 0, 0 /* flags ? */)
>>
>> This should have NIR_INTRINSIC_CAN_DELETE, since if the result is
>> unused we can safely delete it (i.e. it has no side effects), but we
>> can't safely reorder it.
>>
> Thanks. Will do.
>
>> Side note: NIR's current model, as well as any more flexible memory
>> model we might adopt in the future, assumes that intrinsics which are
>> marked as reorderable, as well as ALU operations which are implicitly
>> reorderable, can be freely reordered with respect to *any* other
>> operation, even one that's explicitly not reorderable. So, for
>> example, if you do:
>>
>> ... = clock();
>> a = b + c;
>> ... = clock();
>>
>> then there are no guarantees that the addition won't get moved outside
>> the clock() calls. Currently, this will only happen if the addition
>> becomes involved in some algebraic optimization or CSE, but in the
>> future with passes like GCM that move code around indiscriminately
>> it's going to be much more of a problem. I don't think we could really
>> solve this problem in a useful and general way without making the rest
>> of NIR significantly more complicated and slower, which I definitely
>> don't want. I think the best answer is to say "really these tools are
>> unreliable and meant mainly for driver developers and people who know
>> what they're doing, and if you use them you have to be prepared to
>> look at the assembly source and see if it matches what you expected."
>>
> I haven't looked at the optimisations closely and I assumed that all
> intrinsics act as motion barriers. Seems like I was mistaking.
> Can we call it a "where sub-group is implementation dependent" and be
> done with it ;-)

 Or even "The units of time are not defined and need not be constant"
 -- I guess "return 0;" would be a legal implementation ;).

>>> Bikeshedding aside - the spec is quite clear about the motion barrier
>>> part. Personally I'm fine either way - leave it as is or look closer
>>> at NIR. Just let know how you feel on the topic.
>>
>> It's my opinion, and Jason's as well, that implementing a "code motion
>> barrier" as the spec describes is practically impossible in NIR or
>> really any decent SSA-based IR. So we just can't follow that part of
>> the spec.
>>
>>>
 But really the issue isn't with spec lawyering, it's with people
 potentially using it without knowing the caveats about the underlying
 compiler stack a

Re: [Mesa-dev] make distclean failing

2015-10-08 Thread Rob Clark
On Thu, Oct 8, 2015 at 11:39 AM, Emil Velikov  wrote:
> On 8 October 2015 at 16:12, Matt Turner  wrote:
>> On Thu, Oct 8, 2015 at 6:56 AM, Rob Clark  wrote:
>>> On Wed, Oct 7, 2015 at 6:00 PM, Andy Furniss  wrote:
 Noticed recently that make distclean is failing for me -

 Making distclean in mesa
 make[2]: Entering directory '/mnt/sdb1/Src64/Mesa-git/mesa/src/mesa'
 Makefile:2486: ../glsl/.deps/shader_enums.Plo: No such file or directory
 make[2]: *** No rule to make target '../glsl/.deps/shader_enums.Plo'.  
 Stop.
 make[2]: Leaving directory '/mnt/sdb1/Src64/Mesa-git/mesa/src/mesa'
 Makefile:684: recipe for target 'distclean-recursive' failed
 make[1]: *** [distclean-recursive] Error 1
 make[1]: Leaving directory '/mnt/sdb1/Src64/Mesa-git/mesa/src'
 Makefile:615: recipe for target 'distclean-recursive' failed
 make: *** [distclean-recursive] Error 1
>>>
>>> I think the problem is that shader_enums gets cleaned twice, since it
>>> is built both into libglsl_util.la (for non-mesa state trackers, from
>>> src/Makefile.am), and into libmesa.la/libmesagallium.la (for mesa and
>>> mesa state tracker, from src/mesa/Makefile.am)..  the arrangement with
>>> nir depending on some parts from glsl is a bit unfortunate.
>>
>> Ugh, yeah, that seems very plausible. The intention of adding that
>> convenience library was to avoid this very problem. :(
> Fwiw I'm inclined to move the functions as static inline, considering
> they are pretty trivial.
> It should resolve the issue, plus we'll remove ../ from the sources list.
>
> I'll send a patch in a minute

functions are trivial but bunch of const string data that I was hoping
to avoid duplicating in many object files..  I guess it would be an ok
temporary solution.  Although maybe we should just move everything
that nir depends on into nir and have glsl depend on nir rather than
other way around..

BR,
-R

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


Re: [Mesa-dev] make distclean failing

2015-10-08 Thread Emil Velikov
On 8 October 2015 at 16:12, Matt Turner  wrote:
> On Thu, Oct 8, 2015 at 6:56 AM, Rob Clark  wrote:
>> On Wed, Oct 7, 2015 at 6:00 PM, Andy Furniss  wrote:
>>> Noticed recently that make distclean is failing for me -
>>>
>>> Making distclean in mesa
>>> make[2]: Entering directory '/mnt/sdb1/Src64/Mesa-git/mesa/src/mesa'
>>> Makefile:2486: ../glsl/.deps/shader_enums.Plo: No such file or directory
>>> make[2]: *** No rule to make target '../glsl/.deps/shader_enums.Plo'.  Stop.
>>> make[2]: Leaving directory '/mnt/sdb1/Src64/Mesa-git/mesa/src/mesa'
>>> Makefile:684: recipe for target 'distclean-recursive' failed
>>> make[1]: *** [distclean-recursive] Error 1
>>> make[1]: Leaving directory '/mnt/sdb1/Src64/Mesa-git/mesa/src'
>>> Makefile:615: recipe for target 'distclean-recursive' failed
>>> make: *** [distclean-recursive] Error 1
>>
>> I think the problem is that shader_enums gets cleaned twice, since it
>> is built both into libglsl_util.la (for non-mesa state trackers, from
>> src/Makefile.am), and into libmesa.la/libmesagallium.la (for mesa and
>> mesa state tracker, from src/mesa/Makefile.am)..  the arrangement with
>> nir depending on some parts from glsl is a bit unfortunate.
>
> Ugh, yeah, that seems very plausible. The intention of adding that
> convenience library was to avoid this very problem. :(
Fwiw I'm inclined to move the functions as static inline, considering
they are pretty trivial.
It should resolve the issue, plus we'll remove ../ from the sources list.

I'll send a patch in a minute
-Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH V7 21/24] glsl: build ubo name and indexing offset for AoA

2015-10-08 Thread Samuel Iglesias Gonsálvez
On 07/10/15 00:47, Timothy Arceri wrote:
> ---
>  src/glsl/lower_ubo_reference.cpp | 119 
> ---
>  1 file changed, 87 insertions(+), 32 deletions(-)
> 
> diff --git a/src/glsl/lower_ubo_reference.cpp 
> b/src/glsl/lower_ubo_reference.cpp
> index 247620e..7e983d0 100644
> --- a/src/glsl/lower_ubo_reference.cpp
> +++ b/src/glsl/lower_ubo_reference.cpp
> @@ -203,55 +203,113 @@ static const char *
>  interface_field_name(void *mem_ctx, char *base_name, ir_rvalue *d,
>   ir_rvalue **nonconst_block_index)
>  {
> -   ir_rvalue *previous_index = NULL;
> *nonconst_block_index = NULL;
> +   char *name_copy = NULL;
> +   size_t base_length = 0;
> +
> +   /* Loop back through the IR until we find the uniform block */
> +   ir_rvalue *ir = d;
> +   while (ir != NULL) {
> +  switch (ir->ir_type) {
> +  case ir_type_dereference_variable: {
> + /* Exit loop */
> + ir = NULL;
> + break;
> +  }
> +
> +  case ir_type_dereference_record: {
> + ir_dereference_record *r = (ir_dereference_record *) ir;
> + ir = r->record->as_dereference();
> +
> + /* If we got here it means any previous array subscripts belong to
> +  * block members and not the block itself so skip over them in the
> +  * next pass.
> +  */
> + d = ir;
> + break;
> +  }
> +
> +  case ir_type_dereference_array: {
> + ir_dereference_array *a = (ir_dereference_array *) ir;
> + ir = a->array->as_dereference();
> + break;
> +  }
> +
> +  case ir_type_swizzle: {
> + ir_swizzle *s = (ir_swizzle *) ir;
> + ir = s->val->as_dereference();
> + break;
> +  }
> +
> +  default:
> + assert(!"Should not get here.");
> + break;
> +  }
> +   }
>  
> while (d != NULL) {
>switch (d->ir_type) {
>case ir_type_dereference_variable: {
>   ir_dereference_variable *v = (ir_dereference_variable *) d;
> - if (previous_index
> - && v->var->is_interface_instance()
> - && v->var->type->is_array()) {
> -
> -ir_constant *const_index = previous_index->as_constant();
> -if (!const_index) {
> -   *nonconst_block_index = previous_index;
> -   return ralloc_asprintf(mem_ctx, "%s[0]", base_name);
> -} else {
> -   return ralloc_asprintf(mem_ctx,
> -  "%s[%d]",
> -  base_name,
> -  const_index->get_uint_component(0));
> -}
> + if (name_copy != NULL &&
> + v->var->is_interface_instance() &&
> + v->var->type->is_array()) {
> +return name_copy;
>   } else {
> +*nonconst_block_index = NULL;
>  return base_name;
>   }
>  
>   break;
>}
>  
> -  case ir_type_dereference_record: {
> - ir_dereference_record *r = (ir_dereference_record *) d;
> -
> - d = r->record->as_dereference();
> - break;
> -  }
> -
>case ir_type_dereference_array: {
>   ir_dereference_array *a = (ir_dereference_array *) d;
> + size_t new_length;
> +
> + if (name_copy == NULL) {
> +name_copy = ralloc_strdup(mem_ctx, base_name);
> +base_length = strlen(name_copy);
> + }
> +
> + /* For arrays of arrays we start at the innermost array and work our
> +  * way out so we need to insert the subscript at the base of the
> +  * name string rather than just attaching it to the end.
> +  */
> + new_length = base_length;
> + ir_constant *const_index = a->array_index->as_constant();
> + char *end = ralloc_strdup(NULL, &name_copy[new_length]);
> + if (!const_index) {
> +ir_rvalue *array_index = a->array_index;
> +if (array_index->type != glsl_type::uint_type)
> +   array_index = i2u(array_index);
> +
> +if (a->array->type->fields.array->is_array()) {
> +   ir_constant *base_size = new(mem_ctx)
> +  
> ir_constant(a->array->type->fields.array->arrays_of_arrays_size());
> +   array_index = mul(array_index, base_size);
> +}
> +
> +if (*nonconst_block_index) {
> +   *nonconst_block_index = add(*nonconst_block_index, 
> array_index);
> +} else {
> +   *nonconst_block_index = array_index;
> +}
> +
> +ralloc_asprintf_rewrite_tail(&name_copy, &new_length, "[0]%s",
> + end);
> + } else {
> +ralloc_asprintf_rewrite_tail(&name_copy, &new_length, "[%d]%s",
> + const_index->get_uint_component(0),
> + end);

Re: [Mesa-dev] make distclean failing

2015-10-08 Thread Matt Turner
On Thu, Oct 8, 2015 at 6:56 AM, Rob Clark  wrote:
> On Wed, Oct 7, 2015 at 6:00 PM, Andy Furniss  wrote:
>> Noticed recently that make distclean is failing for me -
>>
>> Making distclean in mesa
>> make[2]: Entering directory '/mnt/sdb1/Src64/Mesa-git/mesa/src/mesa'
>> Makefile:2486: ../glsl/.deps/shader_enums.Plo: No such file or directory
>> make[2]: *** No rule to make target '../glsl/.deps/shader_enums.Plo'.  Stop.
>> make[2]: Leaving directory '/mnt/sdb1/Src64/Mesa-git/mesa/src/mesa'
>> Makefile:684: recipe for target 'distclean-recursive' failed
>> make[1]: *** [distclean-recursive] Error 1
>> make[1]: Leaving directory '/mnt/sdb1/Src64/Mesa-git/mesa/src'
>> Makefile:615: recipe for target 'distclean-recursive' failed
>> make: *** [distclean-recursive] Error 1
>
> I think the problem is that shader_enums gets cleaned twice, since it
> is built both into libglsl_util.la (for non-mesa state trackers, from
> src/Makefile.am), and into libmesa.la/libmesagallium.la (for mesa and
> mesa state tracker, from src/mesa/Makefile.am)..  the arrangement with
> nir depending on some parts from glsl is a bit unfortunate.

Ugh, yeah, that seems very plausible. The intention of adding that
convenience library was to avoid this very problem. :(
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] nir: Mark the shader name during nir_sweep

2015-10-08 Thread Jason Ekstrand
On Thu, Oct 8, 2015 at 7:58 AM, Neil Roberts  wrote:
> Previously the name of the nir shader was being freed prematurely
> during nir_sweep. Since 756613ed35d the name was later being used to
> generate filenames for the optimiser debug output and these would end
> up with garbage from the dangling pointer.

I sent this patch yesterday.  Your commit message is better but mine
adds a cast to avoid compiler warnings.  If you'd like to add the cast
below, you can go ahead and push with my

Reviewed-by: Jason Ekstrand 

I'm sure you can steal Matt's R-B from mine as well.

Or, for that matter, I can steal your commit message and turn this
into an R-B?  I don't care...
--Jason

> ---
>  src/glsl/nir/nir_sweep.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/src/glsl/nir/nir_sweep.c b/src/glsl/nir/nir_sweep.c
> index d354975..082403f 100644
> --- a/src/glsl/nir/nir_sweep.c
> +++ b/src/glsl/nir/nir_sweep.c
> @@ -154,6 +154,9 @@ nir_sweep(nir_shader *nir)
> /* First, move ownership of all the memory to a temporary context; assume 
> dead. */
> ralloc_adopt(rubbish, nir);
>
> +   /* The shader name is not dead */
> +   ralloc_steal(nir, nir->info.name);

You need to cast the const away from nir->info.name or you'll get
compiler warnings.

> +
> /* Variables and registers are not dead.  Steal them back. */
> steal_list(nir, nir_variable, &nir->uniforms);
> steal_list(nir, nir_variable, &nir->inputs);
> --
> 1.9.3
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] nir/sweep: Reparent the shader name

2015-10-08 Thread Neil Roberts
Oops, I just made a similar patch without noticing this one. Feel free
to take the commit message from my patch if you want. Either way this
one is:

Reviewed-by: Neil Roberts 

http://patchwork.freedesktop.org/patch/61369/

Sorry for the noise.

Regards,
- Neil

Jason Ekstrand  writes:

> ---
>  src/glsl/nir/nir_sweep.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/src/glsl/nir/nir_sweep.c b/src/glsl/nir/nir_sweep.c
> index d354975..b6ce43b 100644
> --- a/src/glsl/nir/nir_sweep.c
> +++ b/src/glsl/nir/nir_sweep.c
> @@ -154,6 +154,8 @@ nir_sweep(nir_shader *nir)
> /* First, move ownership of all the memory to a temporary context; assume 
> dead. */
> ralloc_adopt(rubbish, nir);
>  
> +   ralloc_steal(nir, (char *)nir->info.name);
> +
> /* Variables and registers are not dead.  Steal them back. */
> steal_list(nir, nir_variable, &nir->uniforms);
> steal_list(nir, nir_variable, &nir->inputs);
> -- 
> 2.5.0.400.gff86faf
>
> ___
> 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 10/17] st/mesa: make Z/S drawpix shaders independent of variants, don't use Mesa IR

2015-10-08 Thread Roland Scheidegger
Am 08.10.2015 um 16:46 schrieb Marek Olšák:
> 
> On Oct 8, 2015 4:03 PM, "Roland Scheidegger"  > wrote:
>>
>> Was that because stencil used sampler 1 but sview 0 which looks
>> definitely wrong as there needs o be a 1:1 mapping between these when
>> the tex opcodes are used?
> 
> I don't remember how the SVIEW declarations work. It was TEX and there
> were 2 declarations, one was float and the other one was int. I think
> it's only required for freedreno with TEX.

I was just saying the sampler index (for stencil texturing) was 1, but
the sview declaration was only for index 0. Thus probably the reason why
it broke (llvmpipe should handle sview declarations just fine even with
tex opcodes, but if you have them they MUST be correct and they must be
present for either all or none of the samplers). Thus what probably
happened was since there was a sview declaration, llvmpipe tried to
figure out the texture from it rather than using the sampler decl, but
there wasn't any for index 1 (thus skipping texturing completely). But
in any case, I'm fine without using them (though I forgot if freedreno
would require it for this particular case).


Roland


> Marek
> 
>>
>> Roland
>>
>> Am 08.10.2015 um 10:45 schrieb Marek Olšák:
>> > The problem was that it declared SVIEW but llvmpipe didn't like that for
>> > some reason.
>> >
>> > Marek
>> >
>> > On Oct 8, 2015 5:12 AM, "Roland Scheidegger"  
>> > >> wrote:
>> >
>> > Am 08.10.2015 um 02:02 schrieb Marek Olšák:
>> > > Hi Brian,
>> > >
>> > > This is the commit that broke DrawPixels on llvmpipe, but not
> radeonsi
>> > > and softpipe. It's fixed in v2, which is attached.
>> > >
>> > > Marek
>> > >
>> > > On Tue, Oct 6, 2015 at 3:26 AM, Marek Olšák  
>> > >> wrote:
>> > >> From: Marek Olšák    >>
>> > >>
>> > >> - there is no connection to user fragment shaders, so having
> these as
>> > >>   shader variants makes no sense
>> > >> - don't use Mesa IR, use TGSI
>> > >> - don't create gl_fragment_program, just create the shader CSO
>> > >> ---
>> > >>
>> >
>> > I don't quite get from the differences, was the shader actually
>> > incorrect or is this something which should be fixed in llvmpipe?
>> >
>> > Roland
>> >
>>
> 

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


[Mesa-dev] [PATCH] nir: Mark the shader name during nir_sweep

2015-10-08 Thread Neil Roberts
Previously the name of the nir shader was being freed prematurely
during nir_sweep. Since 756613ed35d the name was later being used to
generate filenames for the optimiser debug output and these would end
up with garbage from the dangling pointer.
---
 src/glsl/nir/nir_sweep.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/glsl/nir/nir_sweep.c b/src/glsl/nir/nir_sweep.c
index d354975..082403f 100644
--- a/src/glsl/nir/nir_sweep.c
+++ b/src/glsl/nir/nir_sweep.c
@@ -154,6 +154,9 @@ nir_sweep(nir_shader *nir)
/* First, move ownership of all the memory to a temporary context; assume 
dead. */
ralloc_adopt(rubbish, nir);
 
+   /* The shader name is not dead */
+   ralloc_steal(nir, nir->info.name);
+
/* Variables and registers are not dead.  Steal them back. */
steal_list(nir, nir_variable, &nir->uniforms);
steal_list(nir, nir_variable, &nir->inputs);
-- 
1.9.3

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


Re: [Mesa-dev] [PATCH 10/17] st/mesa: make Z/S drawpix shaders independent of variants, don't use Mesa IR

2015-10-08 Thread Marek Olšák
On Oct 8, 2015 4:03 PM, "Roland Scheidegger"  wrote:
>
> Was that because stencil used sampler 1 but sview 0 which looks
> definitely wrong as there needs o be a 1:1 mapping between these when
> the tex opcodes are used?

I don't remember how the SVIEW declarations work. It was TEX and there were
2 declarations, one was float and the other one was int. I think it's only
required for freedreno with TEX.

Marek

>
> Roland
>
> Am 08.10.2015 um 10:45 schrieb Marek Olšák:
> > The problem was that it declared SVIEW but llvmpipe didn't like that for
> > some reason.
> >
> > Marek
> >
> > On Oct 8, 2015 5:12 AM, "Roland Scheidegger"  > > wrote:
> >
> > Am 08.10.2015 um 02:02 schrieb Marek Olšák:
> > > Hi Brian,
> > >
> > > This is the commit that broke DrawPixels on llvmpipe, but not
radeonsi
> > > and softpipe. It's fixed in v2, which is attached.
> > >
> > > Marek
> > >
> > > On Tue, Oct 6, 2015 at 3:26 AM, Marek Olšák  > > wrote:
> > >> From: Marek Olšák >
> > >>
> > >> - there is no connection to user fragment shaders, so having
these as
> > >>   shader variants makes no sense
> > >> - don't use Mesa IR, use TGSI
> > >> - don't create gl_fragment_program, just create the shader CSO
> > >> ---
> > >>
> >
> > I don't quite get from the differences, was the shader actually
> > incorrect or is this something which should be fixed in llvmpipe?
> >
> > Roland
> >
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 0/4] program: removal of Mesa IR functions

2015-10-08 Thread Brian Paul

On 10/07/2015 06:11 PM, Marek Olšák wrote:

Hi,

Some of these functions became unused after I made the big st/mesa patch 
series. Hopefully, nobody will miss them.

The last one is a cleanup.

Please review.


LGTM.
Reviewed-by: Brian Paul 

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


Re: [Mesa-dev] [PATCH 10/17] st/mesa: make Z/S drawpix shaders independent of variants, don't use Mesa IR

2015-10-08 Thread Brian Paul

On 10/07/2015 06:02 PM, Marek Olšák wrote:

Hi Brian,

This is the commit that broke DrawPixels on llvmpipe, but not radeonsi
and softpipe. It's fixed in v2, which is attached.


Thanks.  That fixes the conform and piglit regressions.

For the series,

Reviewed-by: Brian Paul 
Tested-by: Brian Paul 

-Brian


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


[Mesa-dev] [PATCH 2/3] mesa: remove unused _mesa_create_nameless_texture()

2015-10-08 Thread Brian Paul
---
 src/mesa/main/texobj.c | 20 
 src/mesa/main/texobj.h |  3 ---
 2 files changed, 23 deletions(-)

diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index aa4b38c..66eacf8 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -1185,26 +1185,6 @@ invalidate_tex_image_error_check(struct gl_context *ctx, 
GLuint texture,
return t;
 }
 
-/**
- * Wrapper for the driver function. Need this because _mesa_new_texture_object
- * permits a target of 0 and does not initialize targetIndex.
- */
-struct gl_texture_object *
-_mesa_create_nameless_texture(struct gl_context *ctx, GLenum target)
-{
-   struct gl_texture_object *texObj = NULL;
-   GLint targetIndex;
-
-   if (target == 0)
-  return texObj;
-
-   texObj = ctx->Driver.NewTextureObject(ctx, 0, target);
-   targetIndex = _mesa_tex_target_to_index(ctx, texObj->Target);
-   assert(targetIndex < NUM_TEXTURE_TARGETS);
-   texObj->TargetIndex = targetIndex;
-
-   return texObj;
-}
 
 /**
  * Helper function for glCreateTextures and glGenTextures. Need this because
diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h
index 690878c..8421337 100644
--- a/src/mesa/main/texobj.h
+++ b/src/mesa/main/texobj.h
@@ -202,9 +202,6 @@ _mesa_unlock_context_textures( struct gl_context *ctx );
 extern void
 _mesa_lock_context_textures( struct gl_context *ctx );
 
-extern struct gl_texture_object *
-_mesa_create_nameless_texture(struct gl_context *ctx, GLenum target);
-
 extern void
 _mesa_delete_nameless_texture(struct gl_context *ctx,
   struct gl_texture_object *texObj);
-- 
1.9.1

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


[Mesa-dev] [PATCH 1/3] mesa: remove unneeded error check in create_textures()

2015-10-08 Thread Brian Paul
Callers of create_texture() will either pass target=0 or a validated
GL texture target enum so no need to do another error check inside
the loop.
---
 src/mesa/main/texobj.c | 11 ++-
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 173e43c..aa4b38c 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -1211,6 +1211,7 @@ _mesa_create_nameless_texture(struct gl_context *ctx, 
GLenum target)
  * 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.
+ * \param target  either 0 or a a valid / error-checked texture target enum
  */
 static void
 create_textures(struct gl_context *ctx, GLenum target,
@@ -1219,6 +1220,7 @@ create_textures(struct gl_context *ctx, GLenum target,
GLuint first;
GLint i;
const char *func = dsa ? "Create" : "Gen";
+   const GLint targetIndex = _mesa_tex_target_to_index(ctx, target);
 
if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
   _mesa_debug(ctx, "gl%sTextures %d\n", func, n);
@@ -1241,7 +1243,6 @@ create_textures(struct gl_context *ctx, GLenum target,
/* Allocate new, empty texture objects */
for (i = 0; i < n; i++) {
   struct gl_texture_object *texObj;
-  GLint targetIndex;
   GLuint name = first + i;
   texObj = ctx->Driver.NewTextureObject(ctx, name, target);
   if (!texObj) {
@@ -1252,14 +1253,6 @@ create_textures(struct gl_context *ctx, GLenum target,
 
   /* 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 = %s)",
-func, _mesa_enum_to_string(texObj->Target));
-return;
- }
- assert(targetIndex < NUM_TEXTURE_TARGETS);
  texObj->TargetIndex = targetIndex;
   }
 
-- 
1.9.1

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


  1   2   >