Re: [Mesa-dev] [PATCH v3] isl: Replace bash generator with python generator

2016-06-13 Thread Jason Ekstrand
On Mon, Jun 13, 2016 at 11:19 AM, Dylan Baker  wrote:

> This replaces the current bash generator with a python based generator
> using mako. It's quite fast and works with both python 2.7 and python
> 3.5, and should work with 3.3+ and maybe even 3.2.
>
> It produces an almost identical file except for a minor layout changes,
> and the addition of a "generated file, do not edit" warning.
>
> Cc: "12.0" 
> Signed-off-by: Dylan Baker 
> Reviewed-by: Jason Ekstrand 
> Reviewed-by: Emil Velikov 
> ---
>
> I don't have commit access to Mesa, so it would be great if someone
> could commit this for me.
>
> v2: - Provide the python file with the csvfile and output location as
>   arguments (Jason, Emil)
> - Put the mako template in the python file (Jason)
> - Merge Emil's Android.mk changes
> v3: - use builddir for the output of isl_format_layout.c (Jason, Emil)
>
>  src/intel/isl/Android.mk |   6 +-
>  src/intel/isl/Makefile.am|  13 +-
>  src/intel/isl/gen_format_layout.py   | 207
> +++
>  src/intel/isl/isl_format_layout_gen.bash | 129 ---
>  4 files changed, 218 insertions(+), 137 deletions(-)
>  create mode 100644 src/intel/isl/gen_format_layout.py
>  delete mode 100755 src/intel/isl/isl_format_layout_gen.bash
>
> diff --git a/src/intel/isl/Android.mk b/src/intel/isl/Android.mk
> index 3134981..ec3c656 100644
> --- a/src/intel/isl/Android.mk
> +++ b/src/intel/isl/Android.mk
> @@ -139,14 +139,14 @@ LOCAL_GENERATED_SOURCES += $(addprefix
> $(intermediates)/, $(ISL_GENERATED_FILES)
>  define bash-gen
> @mkdir -p $(dir $@)
> @echo "Gen Bash: $(PRIVATE_MODULE) <= $(notdir $(@))"
> -   $(hide) $(PRIVATE_SCRIPT) < $(PRIVATE_CSV) > $@
> +   $(hide) $(PRIVATE_SCRIPT) --csv $(PRIVATE_CSV) --out
> $(ISL_GENERATED_FILES)
>

I just pushed this with one quick tweak to use $@ here instead of
$(ISL_GENERATED_FILES) and one other place below.

--Jason


>  endef
>
>  isl_format_layout_deps := \
> -   $(LOCAL_PATH)/isl_format_layout_gen.bash \
> +   $(LOCAL_PATH)/gen_format_layout.py \
> $(LOCAL_PATH)/isl_format_layout.csv
>
> -$(intermediates)/isl_format_layout.c: PRIVATE_SCRIPT := bash -c
> $(LOCAL_PATH)/isl_format_layout_gen.bash
> +$(intermediates)/isl_format_layout.c: PRIVATE_SCRIPT := $(MESA_PYTHON2)
> $(LOCAL_PATH)/gen_format_layout.py
>  $(intermediates)/isl_format_layout.c: PRIVATE_CSV :=
> $(LOCAL_PATH)/isl_format_layout.csv
>  $(intermediates)/isl_format_layout.c: $(isl_format_layout_deps)
> $(call bash-gen)
> diff --git a/src/intel/isl/Makefile.am b/src/intel/isl/Makefile.am
> index 74f863a..812 100644
> --- a/src/intel/isl/Makefile.am
> +++ b/src/intel/isl/Makefile.am
> @@ -1,4 +1,4 @@
> -# Copyright 2015 Intel Corporation
> +# Copyright 2015-2016 Intel Corporation
>  #
>  # Permission is hereby granted, free of charge, to any person obtaining a
>  # copy of this software and associated documentation files (the
> "Software"),
> @@ -66,10 +66,13 @@ libisl_gen9_la_CFLAGS = $(libisl_la_CFLAGS)
> -DGEN_VERSIONx10=90
>
>  BUILT_SOURCES = $(ISL_GENERATED_FILES)
>
> -isl_format_layout.c: isl_format_layout_gen.bash \
> +PYTHON_GEN = $(AM_V_GEN)$(PYTHON2) $(PYTHON_FLAGS)
> +
> +isl_format_layout.c: gen_format_layout.py \
>   isl_format_layout.csv
> -   $(AM_V_GEN)$(srcdir)/isl_format_layout_gen.bash \
> -   <$(srcdir)/isl_format_layout.csv >$@
> +   $(PYTHON_GEN) $(srcdir)/gen_format_layout.py \
> +   --csv $(srcdir)/isl_format_layout.csv \
> +   --out $(builddir)/isl_format_layout.c
>
>  #
> 
>  #  Tests
> @@ -87,6 +90,6 @@ tests_isl_surf_get_image_offset_test_LDADD = \
>  #
> 
>
>  EXTRA_DIST = \
> -   isl_format_layout_gen.bash \
> +   gen_format_layout.py \
> isl_format_layout.csv \
> README
> diff --git a/src/intel/isl/gen_format_layout.py
> b/src/intel/isl/gen_format_layout.py
> new file mode 100644
> index 000..d7f3900
> --- /dev/null
> +++ b/src/intel/isl/gen_format_layout.py
> @@ -0,0 +1,207 @@
> +# encoding=utf-8
> +# Copyright © 2016 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 shall be included
> in
> +# all 

[Mesa-dev] [PATCH 09/29] mesa: Track enabled lights in a bitmask

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

This enables some optimizations afterwards.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/main/enable.c | 2 ++
 src/mesa/main/light.c  | 1 +
 src/mesa/main/mtypes.h | 2 ++
 3 files changed, 5 insertions(+)

diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 1d674bf..bc59280 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -402,10 +402,12 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, 
GLboolean state)
  FLUSH_VERTICES(ctx, _NEW_LIGHT);
  ctx->Light.Light[cap-GL_LIGHT0].Enabled = state;
  if (state) {
+ctx->Light._EnabledLights |= 1u << (cap - GL_LIGHT0);
 insert_at_tail(>Light.EnabledList,
>Light.Light[cap-GL_LIGHT0]);
  }
  else {
+ctx->Light._EnabledLights &= ~(1u << (cap - GL_LIGHT0));
 remove_from_list(>Light.Light[cap-GL_LIGHT0]);
  }
  break;
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index 4a8dee3..a52efdb 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -1171,6 +1171,7 @@ _mesa_init_lighting( struct gl_context *ctx )
GLuint i;
 
/* Lighting group */
+   ctx->Light._EnabledLights = 0;
for (i = 0; i < MAX_LIGHTS; i++) {
   init_light( >Light.Light[i], i );
}
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 16d6e57..a0b1a86 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -630,6 +630,8 @@ struct gl_light_attrib
 * Derived state for optimizations: 
 */
/*@{*/
+   GLbitfield _EnabledLights;  /**< bitmask containing enabled lights */
+
GLboolean _NeedEyeCoords;   
GLboolean _NeedVertices;/**< Use fast shader? */
struct gl_light EnabledList; /**< List sentinel */
-- 
2.5.5

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


[Mesa-dev] [PATCH 27/29] mesa: Use bitmask/ffs to iterate the active_samplers bitmask.

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Replaces an iterate and test bit in a bitmask loop by a
loop only iterating over the bits set in the bitmask.

v2: Use _mesa_bit_scan{,64} instead of open coding.
v3: Use u_bit_scan{,64} instead of _mesa_bit_scan{,64}.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/main/uniform_query.cpp | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index eea611b..127f097 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -36,6 +36,7 @@
 #include "compiler/glsl/glsl_parser_extras.h"
 #include "compiler/glsl/program.h"
 #include "program/hash_table.h"
+#include "util/bitscan.h"
 
 
 extern "C" void GLAPIENTRY
@@ -843,9 +844,10 @@ _mesa_uniform(struct gl_context *ctx, struct 
gl_shader_program *shProg,
  * been modified.
  */
 bool changed = false;
-for (unsigned j = 0; j < ARRAY_SIZE(prog->SamplerUnits); j++) {
-   if ((sh->active_samplers & (1U << j)) != 0
-   && (prog->SamplerUnits[j] != sh->SamplerUnits[j])) {
+GLbitfield mask = sh->active_samplers;
+while (mask) {
+   const int j = u_bit_scan();
+   if (prog->SamplerUnits[j] != sh->SamplerUnits[j]) {
   changed = true;
   break;
}
-- 
2.5.5

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


[Mesa-dev] [PATCH 24/29] mesa: Use bitmask/ffs to iterate SamplersUsed

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Replaces an iterate and test bit in a bitmask loop by a
loop only iterating over the bits set in the bitmask.

v2: Use _mesa_bit_scan{,64} instead of open coding.
v3: Use u_bit_scan{,64} instead of _mesa_bit_scan{,64}.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/main/uniforms.c | 42 +-
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index 35b93d3..d02f92e 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -46,6 +46,7 @@
 #include "compiler/glsl/ir_uniform.h"
 #include "compiler/glsl_types.h"
 #include "program/program.h"
+#include "util/bitscan.h"
 
 /**
  * Update the vertex/fragment program's TexturesUsed array.
@@ -66,7 +67,7 @@ void
 _mesa_update_shader_textures_used(struct gl_shader_program *shProg,
  struct gl_program *prog)
 {
-   GLuint s;
+   GLbitfield mask = prog->SamplersUsed;
struct gl_shader *shader =
   shProg->_LinkedShaders[_mesa_program_enum_to_shader_stage(prog->Target)];
 
@@ -77,26 +78,25 @@ _mesa_update_shader_textures_used(struct gl_shader_program 
*shProg,
 
shProg->SamplersValidated = GL_TRUE;
 
-   for (s = 0; s < MAX_SAMPLERS; s++) {
-  if (prog->SamplersUsed & (1u << s)) {
- GLuint unit = shader->SamplerUnits[s];
- GLuint tgt = shader->SamplerTargets[s];
- assert(unit < ARRAY_SIZE(prog->TexturesUsed));
- assert(tgt < NUM_TEXTURE_TARGETS);
-
- /* The types of the samplers associated with a particular texture
-  * unit must be an exact match.  Page 74 (page 89 of the PDF) of the
-  * OpenGL 3.3 core spec says:
-  *
-  * "It is not allowed to have variables of different sampler
-  * types pointing to the same texture image unit within a program
-  * object."
-  */
- if (prog->TexturesUsed[unit] & ~(1 << tgt))
-shProg->SamplersValidated = GL_FALSE;
-
- prog->TexturesUsed[unit] |= (1 << tgt);
-  }
+   while (mask) {
+  const int s = u_bit_scan();
+  GLuint unit = shader->SamplerUnits[s];
+  GLuint tgt = shader->SamplerTargets[s];
+  assert(unit < ARRAY_SIZE(prog->TexturesUsed));
+  assert(tgt < NUM_TEXTURE_TARGETS);
+
+  /* The types of the samplers associated with a particular texture
+   * unit must be an exact match.  Page 74 (page 89 of the PDF) of the
+   * OpenGL 3.3 core spec says:
+   *
+   * "It is not allowed to have variables of different sampler
+   * types pointing to the same texture image unit within a program
+   * object."
+   */
+  if (prog->TexturesUsed[unit] & ~(1 << tgt))
+ shProg->SamplersValidated = GL_FALSE;
+
+  prog->TexturesUsed[unit] |= (1 << tgt);
}
 }
 
-- 
2.5.5

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


[Mesa-dev] [PATCH 29/29] vbo: Use a bitmask to track the active arrays in vbo_save*.

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

The use of a bitmask makes functions iterating only active
attributes less visible in profiles.

v2: Use _mesa_bit_scan{,64} instead of open coding.
v3: Use u_bit_scan{,64} instead of _mesa_bit_scan{,64}.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/vbo/vbo_save.h  |  2 ++
 src/mesa/vbo/vbo_save_api.c  | 67 +---
 src/mesa/vbo/vbo_save_draw.c | 55 +++-
 3 files changed, 69 insertions(+), 55 deletions(-)

diff --git a/src/mesa/vbo/vbo_save.h b/src/mesa/vbo/vbo_save.h
index 8032db8..2843b3c 100644
--- a/src/mesa/vbo/vbo_save.h
+++ b/src/mesa/vbo/vbo_save.h
@@ -61,6 +61,7 @@ struct vbo_save_copied_vtx {
  * compiled using the fallback opcode mechanism provided by dlist.c.
  */
 struct vbo_save_vertex_list {
+   GLbitfield64 enabled; /**< mask of enabled vbo arrays. */
GLubyte attrsz[VBO_ATTRIB_MAX];
GLenum attrtype[VBO_ATTRIB_MAX];
GLuint vertex_size;  /**< size in GLfloats */
@@ -126,6 +127,7 @@ struct vbo_save_context {
struct gl_client_array arrays[VBO_ATTRIB_MAX];
const struct gl_client_array *inputs[VBO_ATTRIB_MAX];
 
+   GLbitfield64 enabled; /**< mask of enabled vbo arrays. */
GLubyte attrsz[VBO_ATTRIB_MAX];  /**< 1, 2, 3 or 4 */
GLenum attrtype[VBO_ATTRIB_MAX];  /**< GL_FLOAT, GL_INT, etc */
GLubyte active_sz[VBO_ATTRIB_MAX];  /**< 1, 2, 3 or 4 */
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index 97a1dfd..650c9b6 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -78,6 +78,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/api_arrayelt.h"
 #include "main/vtxfmt.h"
 #include "main/dispatch.h"
+#include "util/bitscan.h"
 
 #include "vbo_context.h"
 #include "vbo_noop.h"
@@ -429,6 +430,7 @@ _save_compile_vertex_list(struct gl_context *ctx)
 
/* Duplicate our template, increment refcounts to the storage structs:
 */
+   node->enabled = save->enabled;
memcpy(node->attrsz, save->attrsz, sizeof(node->attrsz));
memcpy(node->attrtype, save->attrtype, sizeof(node->attrtype));
node->vertex_size = save->vertex_size;
@@ -624,14 +626,15 @@ static void
 _save_copy_to_current(struct gl_context *ctx)
 {
struct vbo_save_context *save = _context(ctx)->save;
-   GLuint i;
+   GLbitfield64 enabled = save->enabled & (~BITFIELD64_BIT(VBO_ATTRIB_POS));
 
-   for (i = VBO_ATTRIB_POS + 1; i < VBO_ATTRIB_MAX; i++) {
-  if (save->attrsz[i]) {
- save->currentsz[i][0] = save->attrsz[i];
- COPY_CLEAN_4V_TYPE_AS_UNION(save->current[i], save->attrsz[i],
- save->attrptr[i], save->attrtype[i]);
-  }
+   while (enabled) {
+  const int i = u_bit_scan64();
+  assert(save->attrsz[i]);
+
+  save->currentsz[i][0] = save->attrsz[i];
+  COPY_CLEAN_4V_TYPE_AS_UNION(save->current[i], save->attrsz[i],
+  save->attrptr[i], save->attrtype[i]);
}
 }
 
@@ -640,9 +643,11 @@ static void
 _save_copy_from_current(struct gl_context *ctx)
 {
struct vbo_save_context *save = _context(ctx)->save;
-   GLint i;
+   GLbitfield64 enabled = save->enabled & (~BITFIELD64_BIT(VBO_ATTRIB_POS));
+
+   while (enabled) {
+  const int i = u_bit_scan64();
 
-   for (i = VBO_ATTRIB_POS + 1; i < VBO_ATTRIB_MAX; i++) {
   switch (save->attrsz[i]) {
   case 4:
  save->attrptr[i][3] = save->current[i][3];
@@ -652,7 +657,9 @@ _save_copy_from_current(struct gl_context *ctx)
  save->attrptr[i][1] = save->current[i][1];
   case 1:
  save->attrptr[i][0] = save->current[i][0];
+ break;
   case 0:
+ assert(0);
  break;
   }
}
@@ -691,6 +698,7 @@ _save_upgrade_vertex(struct gl_context *ctx, GLuint attr, 
GLuint newsz)
 */
oldsz = save->attrsz[attr];
save->attrsz[attr] = newsz;
+   save->enabled |= BITFIELD64_BIT(attr);
 
save->vertex_size += newsz - oldsz;
save->max_vert = ((VBO_SAVE_BUFFER_SIZE - save->vertex_store->used) /
@@ -723,7 +731,6 @@ _save_upgrade_vertex(struct gl_context *ctx, GLuint attr, 
GLuint newsz)
if (save->copied.nr) {
   const fi_type *data = save->copied.buffer;
   fi_type *dest = save->buffer;
-  GLuint j;
 
   /* Need to note this and fix up at runtime (or loopback):
*/
@@ -733,27 +740,28 @@ _save_upgrade_vertex(struct gl_context *ctx, GLuint attr, 
GLuint newsz)
   }
 
   for (i = 0; i < save->copied.nr; i++) {
- for (j = 0; j < VBO_ATTRIB_MAX; j++) {
-if (save->attrsz[j]) {
-   if (j == attr) {
-  if (oldsz) {
- COPY_CLEAN_4V_TYPE_AS_UNION(dest, oldsz, data,
- save->attrtype[j]);
- data += oldsz;
- dest += newsz;
-  }
- 

[Mesa-dev] [PATCH 28/29] vbo: Use a bitmask to track the active arrays in vbo_exec*.

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

The use of a bitmask makes functions iterating only active
attributes less visible in profiles.

v2: Use _mesa_bit_scan{,64} instead of open coding.
v3: Use u_bit_scan{,64} instead of _mesa_bit_scan{,64}.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/vbo/vbo_exec.h  |   1 +
 src/mesa/vbo/vbo_exec_api.c  | 146 ++-
 src/mesa/vbo/vbo_exec_draw.c |   2 +
 3 files changed, 79 insertions(+), 70 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h
index 27bff4a..5e20cf6 100644
--- a/src/mesa/vbo/vbo_exec.h
+++ b/src/mesa/vbo/vbo_exec.h
@@ -101,6 +101,7 @@ struct vbo_exec_context
   GLuint max_vert; /**< Max number of vertices allowed in buffer */
   struct vbo_exec_copied_vtx copied;
 
+  GLbitfield64 enabled; /**< mask of enabled vbo arrays. */
   GLubyte attrsz[VBO_ATTRIB_MAX];   /**< nr. of attrib components (1..4) */
   GLenum attrtype[VBO_ATTRIB_MAX];  /**< GL_FLOAT, GL_DOUBLE, GL_INT, etc 
*/
   GLubyte active_sz[VBO_ATTRIB_MAX];  /**< attrib size (nr. 32-bit words) 
*/
diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
index 7534599..e02bb90 100644
--- a/src/mesa/vbo/vbo_exec_api.c
+++ b/src/mesa/vbo/vbo_exec_api.c
@@ -42,6 +42,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/api_arrayelt.h"
 #include "main/api_validate.h"
 #include "main/dispatch.h"
+#include "util/bitscan.h"
 
 #include "vbo_context.h"
 #include "vbo_noop.h"
@@ -167,54 +168,56 @@ static void vbo_exec_copy_to_current( struct 
vbo_exec_context *exec )
 {
struct gl_context *ctx = exec->ctx;
struct vbo_context *vbo = vbo_context(ctx);
-   GLuint i;
+   GLbitfield64 enabled = exec->vtx.enabled & 
(~BITFIELD64_BIT(VBO_ATTRIB_POS));
 
-   for (i = VBO_ATTRIB_POS+1 ; i < VBO_ATTRIB_MAX ; i++) {
-  if (exec->vtx.attrsz[i]) {
- /* Note: the exec->vtx.current[i] pointers point into the
-  * ctx->Current.Attrib and ctx->Light.Material.Attrib arrays.
-  */
-GLfloat *current = (GLfloat *)vbo->currval[i].Ptr;
- fi_type tmp[8]; /* space for doubles */
- int dmul = exec->vtx.attrtype[i] == GL_DOUBLE ? 2 : 1;
-
- if (exec->vtx.attrtype[i] == GL_DOUBLE) {
-memset(tmp, 0, sizeof(tmp));
-memcpy(tmp, exec->vtx.attrptr[i], exec->vtx.attrsz[i] * 
sizeof(GLfloat));
- } else {
-COPY_CLEAN_4V_TYPE_AS_UNION(tmp,
-exec->vtx.attrsz[i],
-exec->vtx.attrptr[i],
-exec->vtx.attrtype[i]);
- }
+   while (enabled) {
+  const int i = u_bit_scan64();
+
+  /* Note: the exec->vtx.current[i] pointers point into the
+   * ctx->Current.Attrib and ctx->Light.Material.Attrib arrays.
+   */
+  GLfloat *current = (GLfloat *)vbo->currval[i].Ptr;
+  fi_type tmp[8]; /* space for doubles */
+  int dmul = exec->vtx.attrtype[i] == GL_DOUBLE ? 2 : 1;
+
+  assert(exec->vtx.attrsz[i]);
+
+  if (exec->vtx.attrtype[i] == GL_DOUBLE) {
+ memset(tmp, 0, sizeof(tmp));
+ memcpy(tmp, exec->vtx.attrptr[i], exec->vtx.attrsz[i] * 
sizeof(GLfloat));
+  } else {
+ COPY_CLEAN_4V_TYPE_AS_UNION(tmp,
+ exec->vtx.attrsz[i],
+ exec->vtx.attrptr[i],
+ exec->vtx.attrtype[i]);
+  }
 
- if (exec->vtx.attrtype[i] != vbo->currval[i].Type ||
- memcmp(current, tmp, 4 * sizeof(GLfloat) * dmul) != 0) {
-memcpy(current, tmp, 4 * sizeof(GLfloat) * dmul);
+  if (exec->vtx.attrtype[i] != vbo->currval[i].Type ||
+  memcmp(current, tmp, 4 * sizeof(GLfloat) * dmul) != 0) {
+ memcpy(current, tmp, 4 * sizeof(GLfloat) * dmul);
 
-/* Given that we explicitly state size here, there is no need
- * for the COPY_CLEAN above, could just copy 16 bytes and be
- * done.  The only problem is when Mesa accesses ctx->Current
- * directly.
- */
-/* Size here is in components - not bytes */
-vbo->currval[i].Size = exec->vtx.attrsz[i] / dmul;
-vbo->currval[i]._ElementSize = vbo->currval[i].Size * 
sizeof(GLfloat) * dmul;
-vbo->currval[i].Type = exec->vtx.attrtype[i];
-vbo->currval[i].Integer =
-  vbo_attrtype_to_integer_flag(exec->vtx.attrtype[i]);
-vbo->currval[i].Doubles =
-  vbo_attrtype_to_double_flag(exec->vtx.attrtype[i]);
-
-/* This triggers rather too much recalculation of Mesa state
- * that doesn't get used (eg light positions).
- */
-if (i >= VBO_ATTRIB_MAT_FRONT_AMBIENT &&
-i <= 

[Mesa-dev] [PATCH 11/29] mesa: Use bitmask/ffs to iterate enabled lights for ff shader keys.

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Replaces a loop that iterates all lights and test
which of them is enabled by a loop only iterating over
the bits set in the enabled bitmask.

v2: Use _mesa_bit_scan{,64} instead of open coding.
v3: Use u_bit_scan{,64} instead of _mesa_bit_scan{,64}.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/main/ffvertex_prog.c | 28 +++-
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c
index ecdd018..ca72554 100644
--- a/src/mesa/main/ffvertex_prog.c
+++ b/src/mesa/main/ffvertex_prog.c
@@ -44,6 +44,7 @@
 #include "program/prog_parameter.h"
 #include "program/prog_print.h"
 #include "program/prog_statevars.h"
+#include "util/bitscan.h"
 
 
 /** Max of number of lights and texture coord units */
@@ -148,6 +149,7 @@ static GLboolean check_active_shininess( struct gl_context 
*ctx,
 static void make_state_key( struct gl_context *ctx, struct state_key *key )
 {
const struct gl_fragment_program *fp;
+   GLbitfield mask;
GLuint i;
 
memset(key, 0, sizeof(struct state_key));
@@ -183,23 +185,23 @@ static void make_state_key( struct gl_context *ctx, 
struct state_key *key )
 key->light_color_material_mask = ctx->Light._ColorMaterialBitmask;
   }
 
-  for (i = 0; i < MAX_LIGHTS; i++) {
-struct gl_light *light = >Light.Light[i];
+  mask = ctx->Light._EnabledLights;
+  while (mask) {
+ const int i = u_bit_scan();
+ struct gl_light *light = >Light.Light[i];
 
-if (light->Enabled) {
-   key->unit[i].light_enabled = 1;
+ key->unit[i].light_enabled = 1;
 
-   if (light->EyePosition[3] == 0.0F)
-  key->unit[i].light_eyepos3_is_zero = 1;
+ if (light->EyePosition[3] == 0.0F)
+key->unit[i].light_eyepos3_is_zero = 1;
 
-   if (light->SpotCutoff == 180.0F)
-  key->unit[i].light_spotcutoff_is_180 = 1;
+ if (light->SpotCutoff == 180.0F)
+key->unit[i].light_spotcutoff_is_180 = 1;
 
-   if (light->ConstantAttenuation != 1.0F ||
-   light->LinearAttenuation != 0.0F ||
-   light->QuadraticAttenuation != 0.0F)
-  key->unit[i].light_attenuated = 1;
-}
+ if (light->ConstantAttenuation != 1.0F ||
+ light->LinearAttenuation != 0.0F ||
+ light->QuadraticAttenuation != 0.0F)
+key->unit[i].light_attenuated = 1;
   }
 
   if (check_active_shininess(ctx, key, 0)) {
-- 
2.5.5

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


[Mesa-dev] [PATCH 08/29] mesa: Rename CoordReplaceBits back to CoordReplace.

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

It used to be called like that and fits better with 80 columns.

Reviewed-by: Brian Paul 
Reviewed-by: Ian Romanick 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/drivers/dri/i915/i915_state.c  |  2 +-
 src/mesa/drivers/dri/i965/brw_sf.c  |  2 +-
 src/mesa/drivers/dri/i965/brw_vs.c  |  2 +-
 src/mesa/drivers/dri/i965/gen6_sf_state.c   |  2 +-
 src/mesa/drivers/dri/r200/r200_state.c  |  2 +-
 src/mesa/main/attrib.c  |  2 +-
 src/mesa/main/ffvertex_prog.c   |  2 +-
 src/mesa/main/mtypes.h  |  2 +-
 src/mesa/main/points.c  |  2 +-
 src/mesa/main/texenv.c  | 12 ++--
 src/mesa/state_tracker/st_atom_rasterizer.c |  2 +-
 src/mesa/swrast/s_points.c  |  2 +-
 12 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/src/mesa/drivers/dri/i915/i915_state.c 
b/src/mesa/drivers/dri/i915/i915_state.c
index 4c4bb09..39abe1b 100644
--- a/src/mesa/drivers/dri/i915/i915_state.c
+++ b/src/mesa/drivers/dri/i915/i915_state.c
@@ -657,7 +657,7 @@ i915_update_sprite_point_enable(struct gl_context *ctx)
 
/* _NEW_POINT */
if (ctx->Point.PointSprite)
-  coord_replace_bits = ctx->Point.CoordReplaceBits;
+  coord_replace_bits = ctx->Point.CoordReplace;
 
GLuint tex_coord_unit_bits =
   (GLuint)((inputsRead & VARYING_BITS_TEX_ANY) >> VARYING_SLOT_TEX0);
diff --git a/src/mesa/drivers/dri/i965/brw_sf.c 
b/src/mesa/drivers/dri/i965/brw_sf.c
index bbfa2c6..dff3461 100644
--- a/src/mesa/drivers/dri/i965/brw_sf.c
+++ b/src/mesa/drivers/dri/i965/brw_sf.c
@@ -190,7 +190,7 @@ brw_upload_sf_prog(struct brw_context *brw)
/* _NEW_POINT */
key.do_point_sprite = ctx->Point.PointSprite;
if (key.do_point_sprite) {
-  key.point_sprite_coord_replace = ctx->Point.CoordReplaceBits & 0xff;
+  key.point_sprite_coord_replace = ctx->Point.CoordReplace & 0xff;
}
if (brw->fragment_program->Base.InputsRead & 
BITFIELD64_BIT(VARYING_SLOT_PNTC))
   key.do_point_coord = 1;
diff --git a/src/mesa/drivers/dri/i965/brw_vs.c 
b/src/mesa/drivers/dri/i965/brw_vs.c
index fb52990..e9a1b6d 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -329,7 +329,7 @@ brw_vs_populate_key(struct brw_context *brw,
 
/* _NEW_POINT */
if (brw->gen < 6 && ctx->Point.PointSprite) {
-  key->point_coord_replace = ctx->Point.CoordReplaceBits & 0xff;
+  key->point_coord_replace = ctx->Point.CoordReplace & 0xff;
}
 
/* _NEW_TEXTURE */
diff --git a/src/mesa/drivers/dri/i965/gen6_sf_state.c 
b/src/mesa/drivers/dri/i965/gen6_sf_state.c
index 309464f..32dd8c4 100644
--- a/src/mesa/drivers/dri/i965/gen6_sf_state.c
+++ b/src/mesa/drivers/dri/i965/gen6_sf_state.c
@@ -214,7 +214,7 @@ calculate_attr_overrides(const struct brw_context *brw,
   if (drawing_points) {
  if (brw->ctx.Point.PointSprite &&
  (attr >= VARYING_SLOT_TEX0 && attr <= VARYING_SLOT_TEX7) &&
- (brw->ctx.Point.CoordReplaceBits & (1u << (attr - 
VARYING_SLOT_TEX0 {
+ (brw->ctx.Point.CoordReplace & (1u << (attr - 
VARYING_SLOT_TEX0 {
 point_sprite = true;
  }
 
diff --git a/src/mesa/drivers/dri/r200/r200_state.c 
b/src/mesa/drivers/dri/r200/r200_state.c
index e2a56d5..f0693ba 100644
--- a/src/mesa/drivers/dri/r200/r200_state.c
+++ b/src/mesa/drivers/dri/r200/r200_state.c
@@ -1852,7 +1852,7 @@ static void r200Enable( struct gl_context *ctx, GLenum 
cap, GLboolean state )
   R200_STATECHANGE( rmesa, spr );
   if ( state ) {
 rmesa->hw.spr.cmd[SPR_POINT_SPRITE_CNTL] |= R200_PS_GEN_TEX_MASK &
-(ctx->Point.CoordReplaceBits << R200_PS_GEN_TEX_0_SHIFT);
+(ctx->Point.CoordReplace << R200_PS_GEN_TEX_0_SHIFT);
   } else {
 rmesa->hw.spr.cmd[SPR_POINT_SPRITE_CNTL] &= ~R200_PS_GEN_TEX_MASK;
   }
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 6f39cb0..52a8ba6 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1247,7 +1247,7 @@ _mesa_PopAttrib(void)
   GLuint u;
   for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
  _mesa_TexEnvi(GL_POINT_SPRITE_NV, GL_COORD_REPLACE_NV,
-   !!(point->CoordReplaceBits & (1u << u)));
+   !!(point->CoordReplace & (1u << u)));
   }
   _mesa_set_enable(ctx, GL_POINT_SPRITE_NV,point->PointSprite);
   if (ctx->Extensions.NV_point_sprite)
diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c
index adf71dc..ecdd018 100644
--- a/src/mesa/main/ffvertex_prog.c
+++ b/src/mesa/main/ffvertex_prog.c
@@ -243,7 +243,7 @@ static void make_state_key( struct gl_context *ctx, struct 
state_key *key )
  

[Mesa-dev] [PATCH 07/29] mesa: Remove the now unused CoordsReplace array.

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Now that all users are converted, remove the array.

Reviewed-by: Brian Paul 
Reviewed-by: Ian Romanick 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/main/mtypes.h | 1 -
 src/mesa/main/points.c | 5 -
 src/mesa/main/texenv.c | 2 --
 3 files changed, 8 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 4abe55b..2da8f3f 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -756,7 +756,6 @@ struct gl_point_attrib
GLboolean SmoothFlag;   /**< True if GL_POINT_SMOOTH is enabled */
GLboolean _Attenuated;  /**< True if Params != [1, 0, 0] */
GLboolean PointSprite;  /**< GL_NV/ARB_point_sprite */
-   GLboolean CoordReplace[MAX_TEXTURE_COORD_UNITS]; /**< GL_ARB_point_sprite*/
GLbitfield CoordReplaceBits; /**< GL_ARB_point_sprite*/
GLenum SpriteRMode; /**< GL_NV_point_sprite (only!) */
GLenum SpriteOrigin;/**< GL_ARB_point_sprite */
diff --git a/src/mesa/main/points.c b/src/mesa/main/points.c
index 3fbd5d3..6bb1ce6 100644
--- a/src/mesa/main/points.c
+++ b/src/mesa/main/points.c
@@ -225,8 +225,6 @@ _mesa_PointParameterfv( GLenum pname, const GLfloat *params)
 void
 _mesa_init_point(struct gl_context *ctx)
 {
-   GLuint i;
-
ctx->Point.SmoothFlag = GL_FALSE;
ctx->Point.Size = 1.0;
ctx->Point.Params[0] = 1.0;
@@ -253,8 +251,5 @@ _mesa_init_point(struct gl_context *ctx)
 
ctx->Point.SpriteRMode = GL_ZERO; /* GL_NV_point_sprite (only!) */
ctx->Point.SpriteOrigin = GL_UPPER_LEFT; /* GL_ARB_point_sprite */
-   for (i = 0; i < ARRAY_SIZE(ctx->Point.CoordReplace); i++) {
-  ctx->Point.CoordReplace[i] = GL_FALSE; /* GL_ARB/NV_point_sprite */
-   }
ctx->Point.CoordReplaceBits = 0; /* GL_ARB/NV_point_sprite */
 }
diff --git a/src/mesa/main/texenv.c b/src/mesa/main/texenv.c
index 2cf322d..1aa0d6c 100644
--- a/src/mesa/main/texenv.c
+++ b/src/mesa/main/texenv.c
@@ -467,12 +467,10 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const 
GLfloat *param )
 if (ctx->Point.CoordReplaceBits & (1u << ctx->Texture.CurrentUnit))
return;
 ctx->Point.CoordReplaceBits |= (1u << ctx->Texture.CurrentUnit);
-ctx->Point.CoordReplace[ctx->Texture.CurrentUnit] = GL_TRUE;
  } else if (iparam0 == GL_FALSE) {
 if (~(ctx->Point.CoordReplaceBits) & (1u << 
ctx->Texture.CurrentUnit))
return;
 ctx->Point.CoordReplaceBits &= ~(1u << ctx->Texture.CurrentUnit);
-ctx->Point.CoordReplace[ctx->Texture.CurrentUnit] = GL_FALSE;
  } else {
 _mesa_error( ctx, GL_INVALID_VALUE, "glTexEnv(param=0x%x)", 
iparam0);
 return;
-- 
2.5.5

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


[Mesa-dev] [PATCH 26/29] mesa: Use bitmask/ffs to iterate the enabled textures.

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Replaces an iterate and test bit in a bitmask loop by a
loop only iterating over the bits set in the bitmask.

v2: Use _mesa_bit_scan{,64} instead of open coding.
v3: Use u_bit_scan{,64} instead of _mesa_bit_scan{,64}.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/main/texstate.c | 31 ---
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 3543369..94caf2a 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -38,6 +38,7 @@
 #include "teximage.h"
 #include "texstate.h"
 #include "mtypes.h"
+#include "util/bitscan.h"
 #include "util/bitset.h"
 
 
@@ -611,7 +612,7 @@ update_ff_texture_state(struct gl_context *ctx,
 
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
   struct gl_texture_unit *texUnit = >Texture.Unit[unit];
-  GLuint texIndex;
+  GLbitfield mask;
   bool complete;
 
   if (texUnit->Enabled == 0x0)
@@ -651,20 +652,20 @@ update_ff_texture_state(struct gl_context *ctx,
*  undefined."
*/
   complete = false;
-  for (texIndex = 0; texIndex < NUM_TEXTURE_TARGETS; texIndex++) {
- if (texUnit->Enabled & (1 << texIndex)) {
-struct gl_texture_object *texObj = texUnit->CurrentTex[texIndex];
-struct gl_sampler_object *sampler = texUnit->Sampler ?
-   texUnit->Sampler : >Sampler;
-
-if (!_mesa_is_texture_complete(texObj, sampler)) {
-   _mesa_test_texobj_completeness(ctx, texObj);
-}
-if (_mesa_is_texture_complete(texObj, sampler)) {
-   _mesa_reference_texobj(>_Current, texObj);
-   complete = true;
-   break;
-}
+  mask = texUnit->Enabled;
+  while (mask) {
+ const int texIndex = u_bit_scan();
+ struct gl_texture_object *texObj = texUnit->CurrentTex[texIndex];
+ struct gl_sampler_object *sampler = texUnit->Sampler ?
+texUnit->Sampler : >Sampler;
+
+ if (!_mesa_is_texture_complete(texObj, sampler)) {
+_mesa_test_texobj_completeness(ctx, texObj);
+ }
+ if (_mesa_is_texture_complete(texObj, sampler)) {
+_mesa_reference_texobj(>_Current, texObj);
+complete = true;
+break;
  }
   }
 
-- 
2.5.5

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


[Mesa-dev] [PATCH 05/29] i915: Convert i915 to use CoordsReplaceBits.

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Switch over to use the CoordsReplaceBits bitmask.

Reviewed-by: Brian Paul 
Reviewed-by: Ian Romanick 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/drivers/dri/i915/i915_state.c | 17 +++--
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/src/mesa/drivers/dri/i915/i915_state.c 
b/src/mesa/drivers/dri/i915/i915_state.c
index 4c83073..4c4bb09 100644
--- a/src/mesa/drivers/dri/i915/i915_state.c
+++ b/src/mesa/drivers/dri/i915/i915_state.c
@@ -653,17 +653,14 @@ i915_update_sprite_point_enable(struct gl_context *ctx)
const GLbitfield64 inputsRead = p->FragProg.Base.InputsRead;
struct i915_context *i915 = i915_context(ctx);
GLuint s4 = i915->state.Ctx[I915_CTXREG_LIS4] & ~S4_VFMT_MASK;
-   int i;
GLuint coord_replace_bits = 0x0;
-   GLuint tex_coord_unit_bits = 0x0;
-
-   for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
-  /* _NEW_POINT */
-  if (ctx->Point.CoordReplace[i] && ctx->Point.PointSprite)
- coord_replace_bits |= (1 << i);
-  if (inputsRead & VARYING_BIT_TEX(i))
- tex_coord_unit_bits |= (1 << i);
-   }
+
+   /* _NEW_POINT */
+   if (ctx->Point.PointSprite)
+  coord_replace_bits = ctx->Point.CoordReplaceBits;
+
+   GLuint tex_coord_unit_bits =
+  (GLuint)((inputsRead & VARYING_BITS_TEX_ANY) >> VARYING_SLOT_TEX0);
 
/*
 * Here we can't enable the SPRITE_POINT_ENABLE bit when the mis-match
-- 
2.5.5

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


[Mesa-dev] [PATCH 03/29] gallium: Convert the state_tracker to use CoordsReplaceBits.

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Switch over to use the CoordsReplaceBits bitmask.

Reviewed-by: Brian Paul 
Reviewed-by: Ian Romanick 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/state_tracker/st_atom_rasterizer.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c 
b/src/mesa/state_tracker/st_atom_rasterizer.c
index ab5fa8f..37a3598 100644
--- a/src/mesa/state_tracker/st_atom_rasterizer.c
+++ b/src/mesa/state_tracker/st_atom_rasterizer.c
@@ -64,7 +64,6 @@ static void update_raster_state( struct st_context *st )
struct pipe_rasterizer_state *raster = >state.rasterizer;
const struct gl_vertex_program *vertProg = ctx->VertexProgram._Current;
const struct gl_fragment_program *fragProg = ctx->FragmentProgram._Current;
-   uint i;
 
memset(raster, 0, sizeof(*raster));
 
@@ -181,11 +180,8 @@ static void update_raster_state( struct st_context *st )
* that we need to replace GENERIC[k] attrib with an automatically
* computed texture coord.
*/
-  for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
- if (ctx->Point.CoordReplace[i]) {
-raster->sprite_coord_enable |= 1 << i;
- }
-  }
+  raster->sprite_coord_enable = ctx->Point.CoordReplaceBits &
+ ((1u << MAX_TEXTURE_COORD_UNITS) - 1);
   if (!st->needs_texcoord_semantic &&
   fragProg->Base.InputsRead & VARYING_BIT_PNTC) {
  raster->sprite_coord_enable |=
-- 
2.5.5

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


[Mesa-dev] [PATCH 01/29] mesa: Add gl_point_attrib::CoordReplaceBits bitfield.

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

The aim is to replace the CoordReplace array by
a bitfield. Until all drivers are converted,
establish the bitfield in parallel to the
CoordReplace array.

v2: Fix bitmask logic.

Reviewed-by: Brian Paul 
Reviewed-by: Ian Romanick 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/main/attrib.c|  2 +-
 src/mesa/main/ffvertex_prog.c |  2 +-
 src/mesa/main/mtypes.h|  1 +
 src/mesa/main/points.c|  1 +
 src/mesa/main/texenv.c| 34 ++
 5 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 61f7036..6f39cb0 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1247,7 +1247,7 @@ _mesa_PopAttrib(void)
   GLuint u;
   for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
  _mesa_TexEnvi(GL_POINT_SPRITE_NV, GL_COORD_REPLACE_NV,
-   (GLint) point->CoordReplace[u]);
+   !!(point->CoordReplaceBits & (1u << u)));
   }
   _mesa_set_enable(ctx, GL_POINT_SPRITE_NV,point->PointSprite);
   if (ctx->Extensions.NV_point_sprite)
diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c
index d72bc71..adf71dc 100644
--- a/src/mesa/main/ffvertex_prog.c
+++ b/src/mesa/main/ffvertex_prog.c
@@ -243,7 +243,7 @@ static void make_state_key( struct gl_context *ctx, struct 
state_key *key )
 key->unit[i].texunit_really_enabled = 1;
 
   if (ctx->Point.PointSprite)
-if (ctx->Point.CoordReplace[i])
+if (ctx->Point.CoordReplaceBits & (1u << i))
key->unit[i].coord_replace = 1;
 
   if (ctx->Texture._TexMatEnabled & ENABLE_TEXMAT(i))
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 471d41d..4abe55b 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -757,6 +757,7 @@ struct gl_point_attrib
GLboolean _Attenuated;  /**< True if Params != [1, 0, 0] */
GLboolean PointSprite;  /**< GL_NV/ARB_point_sprite */
GLboolean CoordReplace[MAX_TEXTURE_COORD_UNITS]; /**< GL_ARB_point_sprite*/
+   GLbitfield CoordReplaceBits; /**< GL_ARB_point_sprite*/
GLenum SpriteRMode; /**< GL_NV_point_sprite (only!) */
GLenum SpriteOrigin;/**< GL_ARB_point_sprite */
 };
diff --git a/src/mesa/main/points.c b/src/mesa/main/points.c
index c2f2b63..3fbd5d3 100644
--- a/src/mesa/main/points.c
+++ b/src/mesa/main/points.c
@@ -256,4 +256,5 @@ _mesa_init_point(struct gl_context *ctx)
for (i = 0; i < ARRAY_SIZE(ctx->Point.CoordReplace); i++) {
   ctx->Point.CoordReplace[i] = GL_FALSE; /* GL_ARB/NV_point_sprite */
}
+   ctx->Point.CoordReplaceBits = 0; /* GL_ARB/NV_point_sprite */
 }
diff --git a/src/mesa/main/texenv.c b/src/mesa/main/texenv.c
index 93c6806..2cf322d 100644
--- a/src/mesa/main/texenv.c
+++ b/src/mesa/main/texenv.c
@@ -460,20 +460,24 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const 
GLfloat *param )
 return;
   }
   if (pname == GL_COORD_REPLACE_NV) {
- if (iparam0 == GL_TRUE || iparam0 == GL_FALSE) {
-/* It's kind of weird to set point state via glTexEnv,
- * but that's what the spec calls for.
- */
-const GLboolean state = (GLboolean) iparam0;
-if (ctx->Point.CoordReplace[ctx->Texture.CurrentUnit] == state)
+ /* It's kind of weird to set point state via glTexEnv,
+  * but that's what the spec calls for.
+  */
+ if (iparam0 == GL_TRUE) {
+if (ctx->Point.CoordReplaceBits & (1u << ctx->Texture.CurrentUnit))
return;
-FLUSH_VERTICES(ctx, _NEW_POINT);
-ctx->Point.CoordReplace[ctx->Texture.CurrentUnit] = state;
- }
- else {
+ctx->Point.CoordReplaceBits |= (1u << ctx->Texture.CurrentUnit);
+ctx->Point.CoordReplace[ctx->Texture.CurrentUnit] = GL_TRUE;
+ } else if (iparam0 == GL_FALSE) {
+if (~(ctx->Point.CoordReplaceBits) & (1u << 
ctx->Texture.CurrentUnit))
+   return;
+ctx->Point.CoordReplaceBits &= ~(1u << ctx->Texture.CurrentUnit);
+ctx->Point.CoordReplace[ctx->Texture.CurrentUnit] = GL_FALSE;
+ } else {
 _mesa_error( ctx, GL_INVALID_VALUE, "glTexEnv(param=0x%x)", 
iparam0);
 return;
  }
+ FLUSH_VERTICES(ctx, _NEW_POINT);
   }
   else {
  _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname=0x%x)", pname );
@@ -675,7 +679,10 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat 
*params )
  return;
   }
   if (pname == GL_COORD_REPLACE_NV) {
- *params = (GLfloat) ctx->Point.CoordReplace[ctx->Texture.CurrentUnit];
+ if 

[Mesa-dev] [PATCH 02/29] swrast: Convert swrast to use CoordsReplaceBits.

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Switch over to use the CoordsReplaceBits bitmask.

Reviewed-by: Brian Paul 
Reviewed-by: Ian Romanick 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/swrast/s_points.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c
index 3163b04..8212850 100644
--- a/src/mesa/swrast/s_points.c
+++ b/src/mesa/swrast/s_points.c
@@ -139,8 +139,8 @@ sprite_point(struct gl_context *ctx, const SWvertex *vert)
  if (attr >= VARYING_SLOT_TEX0 && attr <= VARYING_SLOT_TEX7) {
 /* a texcoord attribute */
 const GLuint u = attr - VARYING_SLOT_TEX0;
-assert(u < ARRAY_SIZE(ctx->Point.CoordReplace));
-if (ctx->Point.CoordReplace[u]) {
+assert(u < MAX_TEXTURE_COORD_UNITS);
+if (ctx->Point.CoordReplaceBits & (1u << u)) {
tCoords[numTcoords++] = attr;
 
if (ctx->Point.SpriteRMode == GL_ZERO)
-- 
2.5.5

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


[Mesa-dev] [PATCH 06/29] i965: Convert i965 to use CoordsReplaceBits.

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Switch over to use the CoordsReplaceBits bitmask.

Reviewed-by: Brian Paul 
Reviewed-by: Ian Romanick 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/drivers/dri/i965/brw_sf.c| 7 +--
 src/mesa/drivers/dri/i965/brw_vs.c| 6 +-
 src/mesa/drivers/dri/i965/gen6_sf_state.c | 2 +-
 3 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_sf.c 
b/src/mesa/drivers/dri/i965/brw_sf.c
index c85d8bc..bbfa2c6 100644
--- a/src/mesa/drivers/dri/i965/brw_sf.c
+++ b/src/mesa/drivers/dri/i965/brw_sf.c
@@ -190,12 +190,7 @@ brw_upload_sf_prog(struct brw_context *brw)
/* _NEW_POINT */
key.do_point_sprite = ctx->Point.PointSprite;
if (key.do_point_sprite) {
-  int i;
-
-  for (i = 0; i < 8; i++) {
-if (ctx->Point.CoordReplace[i])
-   key.point_sprite_coord_replace |= (1 << i);
-  }
+  key.point_sprite_coord_replace = ctx->Point.CoordReplaceBits & 0xff;
}
if (brw->fragment_program->Base.InputsRead & 
BITFIELD64_BIT(VARYING_SLOT_PNTC))
   key.do_point_coord = 1;
diff --git a/src/mesa/drivers/dri/i965/brw_vs.c 
b/src/mesa/drivers/dri/i965/brw_vs.c
index d929f9b..fb52990 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -299,7 +299,6 @@ brw_vs_populate_key(struct brw_context *brw,
struct brw_vertex_program *vp =
   (struct brw_vertex_program *)brw->vertex_program;
struct gl_program *prog = (struct gl_program *) brw->vertex_program;
-   int i;
 
memset(key, 0, sizeof(*key));
 
@@ -330,10 +329,7 @@ brw_vs_populate_key(struct brw_context *brw,
 
/* _NEW_POINT */
if (brw->gen < 6 && ctx->Point.PointSprite) {
-  for (i = 0; i < 8; i++) {
-if (ctx->Point.CoordReplace[i])
-key->point_coord_replace |= (1 << i);
-  }
+  key->point_coord_replace = ctx->Point.CoordReplaceBits & 0xff;
}
 
/* _NEW_TEXTURE */
diff --git a/src/mesa/drivers/dri/i965/gen6_sf_state.c 
b/src/mesa/drivers/dri/i965/gen6_sf_state.c
index 0538ab7..309464f 100644
--- a/src/mesa/drivers/dri/i965/gen6_sf_state.c
+++ b/src/mesa/drivers/dri/i965/gen6_sf_state.c
@@ -214,7 +214,7 @@ calculate_attr_overrides(const struct brw_context *brw,
   if (drawing_points) {
  if (brw->ctx.Point.PointSprite &&
  (attr >= VARYING_SLOT_TEX0 && attr <= VARYING_SLOT_TEX7) &&
- brw->ctx.Point.CoordReplace[attr - VARYING_SLOT_TEX0]) {
+ (brw->ctx.Point.CoordReplaceBits & (1u << (attr - 
VARYING_SLOT_TEX0 {
 point_sprite = true;
  }
 
-- 
2.5.5

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


[Mesa-dev] [PATCH 04/29] r200: convert r200 to use CoordsReplaceBits.

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Switch over to use the CoordsReplaceBits bitmask.

Reviewed-by: Brian Paul 
Reviewed-by: Ian Romanick 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/drivers/dri/r200/r200_state.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/r200/r200_state.c 
b/src/mesa/drivers/dri/r200/r200_state.c
index b4acf98..e2a56d5 100644
--- a/src/mesa/drivers/dri/r200/r200_state.c
+++ b/src/mesa/drivers/dri/r200/r200_state.c
@@ -1851,11 +1851,8 @@ static void r200Enable( struct gl_context *ctx, GLenum 
cap, GLboolean state )
case GL_POINT_SPRITE_ARB:
   R200_STATECHANGE( rmesa, spr );
   if ( state ) {
-int i;
-for (i = 0; i < 6; i++) {
-   rmesa->hw.spr.cmd[SPR_POINT_SPRITE_CNTL] |=
-   ctx->Point.CoordReplace[i] << (R200_PS_GEN_TEX_0_SHIFT + i);
-}
+rmesa->hw.spr.cmd[SPR_POINT_SPRITE_CNTL] |= R200_PS_GEN_TEX_MASK &
+(ctx->Point.CoordReplaceBits << R200_PS_GEN_TEX_0_SHIFT);
   } else {
 rmesa->hw.spr.cmd[SPR_POINT_SPRITE_CNTL] &= ~R200_PS_GEN_TEX_MASK;
   }
-- 
2.5.5

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


[Mesa-dev] [PATCH 15/29] mesa: Switch to bitmask based enabled lights in gen_matypes.c

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/x86/gen_matypes.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/mesa/x86/gen_matypes.c b/src/mesa/x86/gen_matypes.c
index 18ffb72..fc06dc7 100644
--- a/src/mesa/x86/gen_matypes.c
+++ b/src/mesa/x86/gen_matypes.c
@@ -125,7 +125,7 @@ int main( int argc, char **argv )
OFFSET( "CTX_LIGHT_COLOR_MAT_MODE", struct gl_context, 
Light.ColorMaterialMode );
OFFSET( "CTX_LIGHT_COLOR_MAT_MASK", struct gl_context, 
Light._ColorMaterialBitmask );
OFFSET( "CTX_LIGHT_COLOR_MAT_ENABLED ", struct gl_context, 
Light.ColorMaterialEnabled );
-   OFFSET( "CTX_LIGHT_ENABLED_LIST  ", struct gl_context, 
Light.EnabledList );
+   OFFSET( "CTX_LIGHT_ENABLED_LIGHTS", struct gl_context, 
Light._EnabledLights );
OFFSET( "CTX_LIGHT_NEED_VERTS", struct gl_context, 
Light._NeedVertices );
OFFSET( "CTX_LIGHT_BASE_COLOR", struct gl_context, Light._BaseColor 
);
 
@@ -208,8 +208,6 @@ int main( int argc, char **argv )
 */
OFFSET_HEADER( "struct gl_light" );
 
-   OFFSET( "LIGHT_NEXT  ", struct gl_light, next );
-   OFFSET( "LIGHT_PREV  ", struct gl_light, prev );
printf( "\n" );
OFFSET( "LIGHT_AMBIENT   ", struct gl_light, Ambient );
OFFSET( "LIGHT_DIFFUSE   ", struct gl_light, Diffuse );
-- 
2.5.5

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


[Mesa-dev] [PATCH 18/29] mesa: Use bitmask/ffs to build ff fragment shader keys.

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Replaces an iterate and test bit in a bitmask loop by a
loop only iterating over the bits set in the bitmask.
The bitmask used here for iteration is a combination
of different enabled masks present for texture units.

v2: Use _mesa_bit_scan{,64} instead of open coding.
v3: Use u_bit_scan{,64} instead of _mesa_bit_scan{,64}.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/main/ff_fragment_shader.cpp | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/ff_fragment_shader.cpp 
b/src/mesa/main/ff_fragment_shader.cpp
index 26bf162..9e18e30 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -49,6 +49,7 @@
 #include "program/prog_parameter.h"
 #include "program/prog_print.h"
 #include "program/prog_statevars.h"
+#include "util/bitscan.h"
 
 using namespace ir_builder;
 
@@ -398,22 +399,25 @@ static GLbitfield get_fp_input_mask( struct gl_context 
*ctx )
  */
 static GLuint make_state_key( struct gl_context *ctx,  struct state_key *key )
 {
-   GLuint i, j;
+   GLuint j;
GLbitfield inputs_referenced = VARYING_BIT_COL0;
const GLbitfield inputs_available = get_fp_input_mask( ctx );
+   GLbitfield mask;
GLuint keySize;
 
memset(key, 0, sizeof(*key));
 
/* _NEW_TEXTURE */
-   for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
+   mask = ctx->Texture._EnabledCoordUnits;
+   while (mask) {
+  const int i = u_bit_scan();
   const struct gl_texture_unit *texUnit = >Texture.Unit[i];
   const struct gl_texture_object *texObj = texUnit->_Current;
   const struct gl_tex_env_combine_state *comb = texUnit->_CurrentCombine;
   const struct gl_sampler_object *samp;
   GLenum format;
 
-  if (!texUnit->_Current || !texUnit->Enabled)
+  if (!texObj)
  continue;
 
   samp = _mesa_get_samplerobj(ctx, i);
-- 
2.5.5

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


[Mesa-dev] [PATCH 16/29] mesa: Remove the linked list of enabled lights

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Clean up after conversion to bitmasks.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/main/context.c | 11 +--
 src/mesa/main/enable.c  |  4 
 src/mesa/main/light.c   |  4 
 src/mesa/main/mtypes.h  |  4 
 4 files changed, 1 insertion(+), 22 deletions(-)

diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 85cd779..c30031e 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -120,7 +120,6 @@
 #include "shared.h"
 #include "shaderobj.h"
 #include "shaderimage.h"
-#include "util/simple_list.h"
 #include "util/strtod.h"
 #include "state.h"
 #include "stencil.h"
@@ -1413,16 +1412,8 @@ _mesa_copy_context( const struct gl_context *src, struct 
gl_context *dst,
   dst->Hint = src->Hint;
}
if (mask & GL_LIGHTING_BIT) {
-  GLuint i;
-  /* begin with memcpy */
+  /* OK to memcpy */
   dst->Light = src->Light;
-  /* fixup linked lists to prevent pointer insanity */
-  make_empty_list( &(dst->Light.EnabledList) );
-  for (i = 0; i < MAX_LIGHTS; i++) {
- if (dst->Light.Light[i].Enabled) {
-insert_at_tail(&(dst->Light.EnabledList), &(dst->Light.Light[i]));
- }
-  }
}
if (mask & GL_LINE_BIT) {
   /* OK to memcpy */
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index bc59280..1468a45 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -35,7 +35,6 @@
 #include "enable.h"
 #include "errors.h"
 #include "light.h"
-#include "util/simple_list.h"
 #include "mtypes.h"
 #include "enums.h"
 #include "api_arrayelt.h"
@@ -403,12 +402,9 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, 
GLboolean state)
  ctx->Light.Light[cap-GL_LIGHT0].Enabled = state;
  if (state) {
 ctx->Light._EnabledLights |= 1u << (cap - GL_LIGHT0);
-insert_at_tail(>Light.EnabledList,
-   >Light.Light[cap-GL_LIGHT0]);
  }
  else {
 ctx->Light._EnabledLights &= ~(1u << (cap - GL_LIGHT0));
-remove_from_list(>Light.Light[cap-GL_LIGHT0]);
  }
  break;
   case GL_LIGHTING:
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index c9e2fc2..ad9cef1 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -31,7 +31,6 @@
 #include "enums.h"
 #include "light.h"
 #include "macros.h"
-#include "util/simple_list.h"
 #include "mtypes.h"
 #include "math/m_matrix.h"
 #include "util/bitscan.h"
@@ -1122,8 +1121,6 @@ _mesa_allow_light_in_model( struct gl_context *ctx, 
GLboolean flag )
 static void
 init_light( struct gl_light *l, GLuint n )
 {
-   make_empty_list( l );
-
ASSIGN_4V( l->Ambient, 0.0, 0.0, 0.0, 1.0 );
if (n==0) {
   ASSIGN_4V( l->Diffuse, 1.0, 1.0, 1.0, 1.0 );
@@ -1197,7 +1194,6 @@ _mesa_init_lighting( struct gl_context *ctx )
for (i = 0; i < MAX_LIGHTS; i++) {
   init_light( >Light.Light[i], i );
}
-   make_empty_list( >Light.EnabledList );
 
init_lightmodel( >Light.Model );
init_material( >Light.Material );
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index a0b1a86..af0aac9 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -333,9 +333,6 @@ struct gl_material
  */
 struct gl_light
 {
-   struct gl_light *next;  /**< double linked list with sentinel */
-   struct gl_light *prev;
-
GLfloat Ambient[4]; /**< ambient color */
GLfloat Diffuse[4]; /**< diffuse color */
GLfloat Specular[4];/**< specular color */
@@ -634,7 +631,6 @@ struct gl_light_attrib
 
GLboolean _NeedEyeCoords;   
GLboolean _NeedVertices;/**< Use fast shader? */
-   struct gl_light EnabledList; /**< List sentinel */
 
GLfloat _BaseColor[2][3];
/*@}*/
-- 
2.5.5

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


[Mesa-dev] [PATCH 20/29] mesa: Use bitmask/ffs to iterate enabled clip planes.

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Replaces an iterate and test bit in a bitmask loop by a
loop only iterating over the bits set in the bitmask.

v2: Use _mesa_bit_scan{,64} instead of open coding.
v3: Use u_bit_scan{,64} instead of _mesa_bit_scan{,64}.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/drivers/common/meta.c | 22 +++---
 src/mesa/main/matrix.c | 19 ++--
 src/mesa/main/rastpos.c| 21 +++---
 src/mesa/tnl/t_vb_cliptmp.h| 51 -
 src/mesa/tnl/t_vb_program.c| 65 +-
 src/mesa/tnl/t_vb_render.c |  1 +
 src/mesa/tnl/t_vb_vertex.c | 59 +++---
 7 files changed, 117 insertions(+), 121 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 6dcbc8b..1a4191f 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -85,6 +85,7 @@
 #include "drivers/common/meta.h"
 #include "main/enums.h"
 #include "main/glformats.h"
+#include "util/bitscan.h"
 #include "util/ralloc.h"
 
 /** Return offset in bytes of the field within a vertex struct */
@@ -682,12 +683,12 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
}
 
if (state & MESA_META_CLIP) {
+  GLbitfield mask;
   save->ClipPlanesEnabled = ctx->Transform.ClipPlanesEnabled;
-  if (ctx->Transform.ClipPlanesEnabled) {
- GLuint i;
- for (i = 0; i < ctx->Const.MaxClipPlanes; i++) {
-_mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_FALSE);
- }
+  mask = ctx->Transform.ClipPlanesEnabled;
+  while (mask) {
+ const int i = u_bit_scan();
+ _mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_FALSE);
   }
}
 
@@ -1090,13 +1091,10 @@ _mesa_meta_end(struct gl_context *ctx)
}
 
if (state & MESA_META_CLIP) {
-  if (save->ClipPlanesEnabled) {
- GLuint i;
- for (i = 0; i < ctx->Const.MaxClipPlanes; i++) {
-if (save->ClipPlanesEnabled & (1 << i)) {
-   _mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_TRUE);
-}
- }
+  GLbitfield mask = save->ClipPlanesEnabled;
+  while (mask) {
+ const int i = u_bit_scan();
+ _mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_TRUE);
   }
}
 
diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c
index 5ff5ac5..293d50c 100644
--- a/src/mesa/main/matrix.c
+++ b/src/mesa/main/matrix.c
@@ -43,6 +43,7 @@
 #include "matrix.h"
 #include "mtypes.h"
 #include "math/m_matrix.h"
+#include "util/bitscan.h"
 
 
 /**
@@ -554,20 +555,20 @@ _mesa_MultTransposeMatrixd( const GLdouble *m )
 static void
 update_projection( struct gl_context *ctx )
 {
+   GLbitfield mask;
+
_math_matrix_analyse( ctx->ProjectionMatrixStack.Top );
 
/* Recompute clip plane positions in clipspace.  This is also done
 * in _mesa_ClipPlane().
 */
-   if (ctx->Transform.ClipPlanesEnabled) {
-  GLuint p;
-  for (p = 0; p < ctx->Const.MaxClipPlanes; p++) {
-if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
-   _mesa_transform_vector( ctx->Transform._ClipUserPlane[p],
-ctx->Transform.EyeUserPlane[p],
-ctx->ProjectionMatrixStack.Top->inv );
-}
-  }
+   mask = ctx->Transform.ClipPlanesEnabled;
+   while (mask) {
+  const int p = u_bit_scan();
+
+  _mesa_transform_vector( ctx->Transform._ClipUserPlane[p],
+  ctx->Transform.EyeUserPlane[p],
+  ctx->ProjectionMatrixStack.Top->inv );
}
 }
 
diff --git a/src/mesa/main/rastpos.c b/src/mesa/main/rastpos.c
index 8f971f5..4fddad1 100644
--- a/src/mesa/main/rastpos.c
+++ b/src/mesa/main/rastpos.c
@@ -91,17 +91,16 @@ viewclip_point_z( const GLfloat v[] )
 static GLuint
 userclip_point( struct gl_context *ctx, const GLfloat v[] )
 {
-   GLuint p;
-
-   for (p = 0; p < ctx->Const.MaxClipPlanes; p++) {
-  if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
-GLfloat dot = v[0] * ctx->Transform._ClipUserPlane[p][0]
-+ v[1] * ctx->Transform._ClipUserPlane[p][1]
-+ v[2] * ctx->Transform._ClipUserPlane[p][2]
-+ v[3] * ctx->Transform._ClipUserPlane[p][3];
- if (dot < 0.0F) {
-return 0;
- }
+   GLbitfield mask = ctx->Transform.ClipPlanesEnabled;
+   while (mask) {
+  const int p = u_bit_scan();
+  GLfloat dot = v[0] * ctx->Transform._ClipUserPlane[p][0]
+ + v[1] * ctx->Transform._ClipUserPlane[p][1]
+ + v[2] * ctx->Transform._ClipUserPlane[p][2]
+ + v[3] * ctx->Transform._ClipUserPlane[p][3];
+
+  if (dot < 0.0F) {
+ return 0;
   }
}
 
diff --git a/src/mesa/tnl/t_vb_cliptmp.h b/src/mesa/tnl/t_vb_cliptmp.h
index 12181f0..c654666 100644
--- 

[Mesa-dev] [PATCH 14/29] radeon/r200: Use bitmask/ffs to iterate enabled lights

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Replaces a loop that iterates all lights and test
which of them is enabled by a loop only iterating over
the bits set in the enabled bitmask.

v2: Use _mesa_bit_scan{,64} instead of open coding.
v3: Use u_bit_scan{,64} instead of _mesa_bit_scan{,64}.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/drivers/dri/r200/r200_state.c | 40 ++--
 src/mesa/drivers/dri/radeon/radeon_state.c | 42 +++---
 2 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/src/mesa/drivers/dri/r200/r200_state.c 
b/src/mesa/drivers/dri/r200/r200_state.c
index f0693ba..0e38afc 100644
--- a/src/mesa/drivers/dri/r200/r200_state.c
+++ b/src/mesa/drivers/dri/r200/r200_state.c
@@ -49,6 +49,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
SOFTWARE.
 #include "tnl/t_pipeline.h"
 #include "swrast_setup/swrast_setup.h"
 #include "drivers/common/meta.h"
+#include "util/bitscan.h"
 
 #include "radeon_common.h"
 #include "radeon_mipmap_tree.h"
@@ -1112,27 +1113,26 @@ static void update_light( struct gl_context *ctx )
 
 
if (ctx->Light.Enabled) {
-  GLint p;
-  for (p = 0 ; p < MAX_LIGHTS; p++) {
-if (ctx->Light.Light[p].Enabled) {
-   struct gl_light *l = >Light.Light[p];
-   GLfloat *fcmd = (GLfloat *)R200_DB_STATE( lit[p] );
-
-   if (l->EyePosition[3] == 0.0) {
-  COPY_3FV( [LIT_POSITION_X], l->_VP_inf_norm );
-  COPY_3FV( [LIT_DIRECTION_X], l->_h_inf_norm );
-  fcmd[LIT_POSITION_W] = 0;
-  fcmd[LIT_DIRECTION_W] = 0;
-   } else {
-  COPY_4V( [LIT_POSITION_X], l->_Position );
-  fcmd[LIT_DIRECTION_X] = -l->_NormSpotDirection[0];
-  fcmd[LIT_DIRECTION_Y] = -l->_NormSpotDirection[1];
-  fcmd[LIT_DIRECTION_Z] = -l->_NormSpotDirection[2];
-  fcmd[LIT_DIRECTION_W] = 0;
-   }
+  GLbitfield mask = ctx->Light._EnabledLights;
+  while (mask) {
+ const int p = u_bit_scan();
+ struct gl_light *l = >Light.Light[p];
+ GLfloat *fcmd = (GLfloat *)R200_DB_STATE( lit[p] );
+
+ if (l->EyePosition[3] == 0.0) {
+COPY_3FV( [LIT_POSITION_X], l->_VP_inf_norm );
+COPY_3FV( [LIT_DIRECTION_X], l->_h_inf_norm );
+fcmd[LIT_POSITION_W] = 0;
+fcmd[LIT_DIRECTION_W] = 0;
+ } else {
+COPY_4V( [LIT_POSITION_X], l->_Position );
+fcmd[LIT_DIRECTION_X] = -l->_NormSpotDirection[0];
+fcmd[LIT_DIRECTION_Y] = -l->_NormSpotDirection[1];
+fcmd[LIT_DIRECTION_Z] = -l->_NormSpotDirection[2];
+fcmd[LIT_DIRECTION_W] = 0;
+ }
 
-   R200_DB_STATECHANGE( rmesa, >hw.lit[p] );
-}
+ R200_DB_STATECHANGE( rmesa, >hw.lit[p] );
   }
}
 }
diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c 
b/src/mesa/drivers/dri/radeon/radeon_state.c
index 8a1b81d..93bc0f9 100644
--- a/src/mesa/drivers/dri/radeon/radeon_state.c
+++ b/src/mesa/drivers/dri/radeon/radeon_state.c
@@ -51,6 +51,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
SOFTWARE.
 #include "tnl/t_pipeline.h"
 #include "swrast_setup/swrast_setup.h"
 #include "drivers/common/meta.h"
+#include "util/bitscan.h"
 
 #include "radeon_context.h"
 #include "radeon_mipmap_tree.h"
@@ -892,27 +893,26 @@ static void update_light( struct gl_context *ctx )
 
 
if (ctx->Light.Enabled) {
-  GLint p;
-  for (p = 0 ; p < MAX_LIGHTS; p++) {
-if (ctx->Light.Light[p].Enabled) {
-   struct gl_light *l = >Light.Light[p];
-   GLfloat *fcmd = (GLfloat *)RADEON_DB_STATE( lit[p] );
-
-   if (l->EyePosition[3] == 0.0) {
-  COPY_3FV( [LIT_POSITION_X], l->_VP_inf_norm );
-  COPY_3FV( [LIT_DIRECTION_X], l->_h_inf_norm );
-  fcmd[LIT_POSITION_W] = 0;
-  fcmd[LIT_DIRECTION_W] = 0;
-   } else {
-  COPY_4V( [LIT_POSITION_X], l->_Position );
-  fcmd[LIT_DIRECTION_X] = -l->_NormSpotDirection[0];
-  fcmd[LIT_DIRECTION_Y] = -l->_NormSpotDirection[1];
-  fcmd[LIT_DIRECTION_Z] = -l->_NormSpotDirection[2];
-  fcmd[LIT_DIRECTION_W] = 0;
-   }
-
-   RADEON_DB_STATECHANGE( rmesa, >hw.lit[p] );
-}
+  GLbitfield mask = ctx->Light._EnabledLights;
+  while (mask) {
+ const int p = u_bit_scan();
+ struct gl_light *l = >Light.Light[p];
+ GLfloat *fcmd = (GLfloat *)RADEON_DB_STATE( lit[p] );
+
+ if (l->EyePosition[3] == 0.0) {
+COPY_3FV( [LIT_POSITION_X], l->_VP_inf_norm );
+COPY_3FV( [LIT_DIRECTION_X], l->_h_inf_norm );
+fcmd[LIT_POSITION_W] = 0;
+fcmd[LIT_DIRECTION_W] = 0;
+ } else {
+COPY_4V( [LIT_POSITION_X], l->_Position );
+

[Mesa-dev] [PATCH 17/29] mesa: Use bitmask/ffs to build ff vertex shader keys.

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Replaces an iterate and test bit in a bitmask loop by a
loop only iterating over the bits set in the bitmask.
The bitmask used here for iteration is a combination
of different enabled masks present for texture units.

v2: Use _mesa_bit_scan{,64} instead of open coding.
v3: Use u_bit_scan{,64} instead of _mesa_bit_scan{,64}.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/main/ffvertex_prog.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c
index ca72554..f4ae690 100644
--- a/src/mesa/main/ffvertex_prog.c
+++ b/src/mesa/main/ffvertex_prog.c
@@ -150,7 +150,6 @@ static void make_state_key( struct gl_context *ctx, struct 
state_key *key )
 {
const struct gl_fragment_program *fp;
GLbitfield mask;
-   GLuint i;
 
memset(key, 0, sizeof(struct state_key));
fp = ctx->FragmentProgram._Current;
@@ -238,7 +237,10 @@ static void make_state_key( struct gl_context *ctx, struct 
state_key *key )
ctx->Texture._MaxEnabledTexImageUnit != -1)
   key->texture_enabled_global = 1;
 
-   for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
+   mask = ctx->Texture._EnabledCoordUnits | ctx->Texture._TexGenEnabled
+  | ctx->Texture._TexMatEnabled | ctx->Point.CoordReplace;
+   while (mask) {
+  const int i = u_bit_scan();
   struct gl_texture_unit *texUnit = >Texture.Unit[i];
 
   if (texUnit->_Current)
-- 
2.5.5

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


[Mesa-dev] [PATCH 19/29] mesa: Use bitmask/ffs to iterate color material attributes.

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Replaces an iterate and test bit in a bitmask loop by a
loop only iterating over the bits set in the bitmask.

v2: Use _mesa_bit_scan{,64} instead of open coding.
v3: Use u_bit_scan{,64} instead of _mesa_bit_scan{,64}.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/main/light.c | 11 ++-
 src/mesa/tnl/t_vb_light.c | 10 ++
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index ad9cef1..87a06db 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -706,13 +706,14 @@ _mesa_update_material( struct gl_context *ctx, GLuint 
bitmask )
 void
 _mesa_update_color_material( struct gl_context *ctx, const GLfloat color[4] )
 {
-   const GLbitfield bitmask = ctx->Light._ColorMaterialBitmask;
+   GLbitfield bitmask = ctx->Light._ColorMaterialBitmask;
struct gl_material *mat = >Light.Material;
-   int i;
 
-   for (i = 0 ; i < MAT_ATTRIB_MAX ; i++) 
-  if (bitmask & (1<Attrib[i], color );
+   while (bitmask) {
+  const int i = u_bit_scan();
+
+  COPY_4FV( mat->Attrib[i], color );
+   }
 
_mesa_update_material( ctx, bitmask );
 }
diff --git a/src/mesa/tnl/t_vb_light.c b/src/mesa/tnl/t_vb_light.c
index 4342b6e..8d13712 100644
--- a/src/mesa/tnl/t_vb_light.c
+++ b/src/mesa/tnl/t_vb_light.c
@@ -233,10 +233,12 @@ prepare_materials(struct gl_context *ctx,
 * with the color pointer for each one.
 */
if (ctx->Light.ColorMaterialEnabled) {
-  const GLuint bitmask = ctx->Light._ColorMaterialBitmask;
-  for (i = 0 ; i < MAT_ATTRIB_MAX ; i++)
-if (bitmask & (1<AttribPtr[_TNL_ATTRIB_MAT_FRONT_AMBIENT + i] = 
VB->AttribPtr[_TNL_ATTRIB_COLOR0];
+  GLbitfield bitmask = ctx->Light._ColorMaterialBitmask;
+  while (bitmask) {
+ const int i = u_bit_scan();
+ VB->AttribPtr[_TNL_ATTRIB_MAT_FRONT_AMBIENT + i] =
+VB->AttribPtr[_TNL_ATTRIB_COLOR0];
+  }
}
 
/* Now, for each material attribute that's tracking vertex color, save
-- 
2.5.5

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


[Mesa-dev] [PATCH 23/29] i965: Use bitmask/ffs to iterate used vertex attributes.

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Replaces an iterate and test bit in a bitmask loop by a
loop only iterating over the bits set in the bitmask.

v2: Use _mesa_bit_scan{,64} instead of open coding.
v3: Use u_bit_scan{,64} instead of _mesa_bit_scan{,64}.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/drivers/dri/i965/brw_draw.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_draw.c 
b/src/mesa/drivers/dri/i965/brw_draw.c
index fa3ff5f..d7a1ba3 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -38,6 +38,7 @@
 #include "swrast/swrast.h"
 #include "swrast_setup/swrast_setup.h"
 #include "drivers/common/meta.h"
+#include "util/bitscan.h"
 
 #include "brw_blorp.h"
 #include "brw_draw.h"
@@ -301,16 +302,15 @@ brw_merge_inputs(struct brw_context *brw,
}
 
if (brw->gen < 8 && !brw->is_haswell) {
-  struct gl_program *vp = >VertexProgram._Current->Base;
+  GLbitfield64 mask = ctx->VertexProgram._Current->Base.InputsRead;
   /* Prior to Haswell, the hardware can't natively support GL_FIXED or
* 2_10_10_10_REV vertex formats.  Set appropriate workaround flags.
*/
-  for (i = 0; i < VERT_ATTRIB_MAX; i++) {
- if (!(vp->InputsRead & BITFIELD64_BIT(i)))
-continue;
-
+  while (mask) {
  uint8_t wa_flags = 0;
 
+ i = u_bit_scan64();
+
  switch (brw->vb.inputs[i].glarray->Type) {
 
  case GL_FIXED:
-- 
2.5.5

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


[Mesa-dev] [PATCH 21/29] radeon/r200: Use bitmask/ffs to iterate enabled clip planes.

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Replaces an iterate and test bit in a bitmask loop by a
loop only iterating over the bits set in the bitmask.

v2: Use _mesa_bit_scan{,64} instead of open coding.
v3: Use u_bit_scan{,64} instead of _mesa_bit_scan{,64}.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/drivers/dri/r200/r200_state.c | 19 +--
 src/mesa/drivers/dri/radeon/radeon_state.c | 19 +--
 2 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/src/mesa/drivers/dri/r200/r200_state.c 
b/src/mesa/drivers/dri/r200/r200_state.c
index 0e38afc..3671231 100644
--- a/src/mesa/drivers/dri/r200/r200_state.c
+++ b/src/mesa/drivers/dri/r200/r200_state.c
@@ -1360,18 +1360,17 @@ static void r200ClipPlane( struct gl_context *ctx, 
GLenum plane, const GLfloat *
 static void r200UpdateClipPlanes( struct gl_context *ctx )
 {
r200ContextPtr rmesa = R200_CONTEXT(ctx);
-   GLuint p;
+   GLbitfield mask = ctx->Transform.ClipPlanesEnabled;
 
-   for (p = 0; p < ctx->Const.MaxClipPlanes; p++) {
-  if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
-GLint *ip = (GLint *)ctx->Transform._ClipUserPlane[p];
+   while (mask) {
+  const int p = u_bit_scan();
+  GLint *ip = (GLint *)ctx->Transform._ClipUserPlane[p];
 
-R200_STATECHANGE( rmesa, ucp[p] );
-rmesa->hw.ucp[p].cmd[UCP_X] = ip[0];
-rmesa->hw.ucp[p].cmd[UCP_Y] = ip[1];
-rmesa->hw.ucp[p].cmd[UCP_Z] = ip[2];
-rmesa->hw.ucp[p].cmd[UCP_W] = ip[3];
-  }
+  R200_STATECHANGE( rmesa, ucp[p] );
+  rmesa->hw.ucp[p].cmd[UCP_X] = ip[0];
+  rmesa->hw.ucp[p].cmd[UCP_Y] = ip[1];
+  rmesa->hw.ucp[p].cmd[UCP_Z] = ip[2];
+  rmesa->hw.ucp[p].cmd[UCP_W] = ip[3];
}
 }
 
diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c 
b/src/mesa/drivers/dri/radeon/radeon_state.c
index 93bc0f9..c6b1f38 100644
--- a/src/mesa/drivers/dri/radeon/radeon_state.c
+++ b/src/mesa/drivers/dri/radeon/radeon_state.c
@@ -1134,18 +1134,17 @@ static void radeonClipPlane( struct gl_context *ctx, 
GLenum plane, const GLfloat
 static void radeonUpdateClipPlanes( struct gl_context *ctx )
 {
r100ContextPtr rmesa = R100_CONTEXT(ctx);
-   GLuint p;
+   GLbitfield mask = ctx->Transform.ClipPlanesEnabled;
 
-   for (p = 0; p < ctx->Const.MaxClipPlanes; p++) {
-  if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
-GLint *ip = (GLint *)ctx->Transform._ClipUserPlane[p];
+   while (mask) {
+  const int p = u_bit_scan();
+  GLint *ip = (GLint *)ctx->Transform._ClipUserPlane[p];
 
-RADEON_STATECHANGE( rmesa, ucp[p] );
-rmesa->hw.ucp[p].cmd[UCP_X] = ip[0];
-rmesa->hw.ucp[p].cmd[UCP_Y] = ip[1];
-rmesa->hw.ucp[p].cmd[UCP_Z] = ip[2];
-rmesa->hw.ucp[p].cmd[UCP_W] = ip[3];
-  }
+  RADEON_STATECHANGE( rmesa, ucp[p] );
+  rmesa->hw.ucp[p].cmd[UCP_X] = ip[0];
+  rmesa->hw.ucp[p].cmd[UCP_Y] = ip[1];
+  rmesa->hw.ucp[p].cmd[UCP_Z] = ip[2];
+  rmesa->hw.ucp[p].cmd[UCP_W] = ip[3];
}
 }
 
-- 
2.5.5

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


[Mesa-dev] [PATCH 22/29] i965: Use bitmask/ffs to iterate enabled clip planes.

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Replaces an iterate and test bit in a bitmask loop by a
loop only iterating over the bits set in the bitmask.

v2: Use _mesa_bit_scan{,64} instead of open coding.
v3: Use u_bit_scan{,64} instead of _mesa_bit_scan{,64}.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/drivers/dri/i965/brw_curbe.c | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_curbe.c 
b/src/mesa/drivers/dri/i965/brw_curbe.c
index dfb90b1..02c4e38 100644
--- a/src/mesa/drivers/dri/i965/brw_curbe.c
+++ b/src/mesa/drivers/dri/i965/brw_curbe.c
@@ -56,6 +56,7 @@
 #include "program/prog_parameter.h"
 #include "program/prog_print.h"
 #include "program/prog_statevars.h"
+#include "util/bitscan.h"
 #include "intel_batchbuffer.h"
 #include "intel_buffer_objects.h"
 #include "brw_context.h"
@@ -84,7 +85,7 @@ static void calculate_curbe_offsets( struct brw_context *brw )
 
/* _NEW_TRANSFORM */
if (ctx->Transform.ClipPlanesEnabled) {
-  GLuint nr_planes = 6 + 
_mesa_bitcount_64(ctx->Transform.ClipPlanesEnabled);
+  GLuint nr_planes = 6 + _mesa_bitcount(ctx->Transform.ClipPlanesEnabled);
   nr_clip_regs = (nr_planes * 4 + 15) / 16;
}
 
@@ -226,7 +227,7 @@ brw_upload_constant_buffer(struct brw_context *brw)
/* clipper constants */
if (brw->curbe.clip_size) {
   GLuint offset = brw->curbe.clip_start * 16;
-  GLuint j;
+  GLbitfield mask;
 
   /* If any planes are going this way, send them all this way:
*/
@@ -241,14 +242,14 @@ brw_upload_constant_buffer(struct brw_context *brw)
* clip-space:
*/
   clip_planes = brw_select_clip_planes(ctx);
-  for (j = 0; j < MAX_CLIP_PLANES; j++) {
-if (ctx->Transform.ClipPlanesEnabled & (1<Transform.ClipPlanesEnabled;
+  while (mask) {
+ const int j = u_bit_scan();
+ buf[offset + i * 4 + 0].f = clip_planes[j][0];
+ buf[offset + i * 4 + 1].f = clip_planes[j][1];
+ buf[offset + i * 4 + 2].f = clip_planes[j][2];
+ buf[offset + i * 4 + 3].f = clip_planes[j][3];
+ i++;
   }
}
 
-- 
2.5.5

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


[Mesa-dev] [PATCH 13/29] nouveau: Use bitmask/ffs to iterate enabled lights

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Replaces a loop that iterates all lights and test
which of them is enabled by a loop only iterating over
the bits set in the enabled bitmask.

v2: Use _mesa_bit_scan{,64} instead of open coding.
v3: Use u_bit_scan{,64} instead of _mesa_bit_scan{,64}.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/drivers/dri/nouveau/nouveau_state.c  | 10 ++
 src/mesa/drivers/dri/nouveau/nv10_state_tnl.c | 27 ---
 src/mesa/drivers/dri/nouveau/nv20_state_tnl.c | 27 ---
 3 files changed, 38 insertions(+), 26 deletions(-)

diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c 
b/src/mesa/drivers/dri/nouveau/nouveau_state.c
index 3aad10e..6189997 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_state.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_state.c
@@ -31,6 +31,7 @@
 
 #include "swrast/swrast.h"
 #include "tnl/tnl.h"
+#include "util/bitscan.h"
 
 static void
 nouveau_alpha_func(struct gl_context *ctx, GLenum func, GLfloat ref)
@@ -122,7 +123,7 @@ nouveau_draw_buffers(struct gl_context *ctx, GLsizei n, 
const GLenum *buffers)
 static void
 nouveau_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
 {
-   int i;
+   GLbitfield mask;
 
switch (cap) {
case GL_ALPHA_TEST:
@@ -187,9 +188,10 @@ nouveau_enable(struct gl_context *ctx, GLenum cap, 
GLboolean state)
context_dirty(ctx, LIGHT_MODEL);
context_dirty(ctx, LIGHT_ENABLE);
 
-   for (i = 0; i < MAX_LIGHTS; i++) {
-   if (ctx->Light.Light[i].Enabled)
-   context_dirty_i(ctx, LIGHT_SOURCE, i);
+   mask = ctx->Light._EnabledLights;
+   while (mask) {
+   const int i = u_bit_scan();
+   context_dirty_i(ctx, LIGHT_SOURCE, i);
}
 
context_dirty(ctx, MATERIAL_FRONT_AMBIENT);
diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c 
b/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c
index 1398385..9f80e41 100644
--- a/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c
+++ b/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c
@@ -30,8 +30,7 @@
 #include "nouveau_util.h"
 #include "nv10_3d.xml.h"
 #include "nv10_driver.h"
-
-#include "util/simple_list.h"
+#include "util/bitscan.h"
 
 void
 nv10_emit_clip_plane(struct gl_context *ctx, int emit)
@@ -323,7 +322,7 @@ nv10_emit_material_ambient(struct gl_context *ctx, int emit)
struct nouveau_pushbuf *push = context_push(ctx);
float (*mat)[4] = ctx->Light.Material.Attrib;
float c_scene[3], c_factor[3];
-   struct gl_light *l;
+   GLbitfield mask;
 
if (USE_COLOR_MATERIAL(AMBIENT)) {
COPY_3V(c_scene, ctx->Light.Model.Ambient);
@@ -347,8 +346,10 @@ nv10_emit_material_ambient(struct gl_context *ctx, int 
emit)
PUSH_DATAp(push, c_factor, 3);
}
 
-   foreach(l, >Light.EnabledList) {
-   const int i = l - ctx->Light.Light;
+   mask = ctx->Light._EnabledLights;
+   while (mask) {
+   const int i = u_bit_scan();
+   struct gl_light *l = >Light.Light[i];
float *c_light = (USE_COLOR_MATERIAL(AMBIENT) ?
  l->Ambient :
  l->_MatAmbient[0]);
@@ -363,13 +364,15 @@ nv10_emit_material_diffuse(struct gl_context *ctx, int 
emit)
 {
struct nouveau_pushbuf *push = context_push(ctx);
GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
-   struct gl_light *l;
+   GLbitfield mask;
 
BEGIN_NV04(push, NV10_3D(MATERIAL_FACTOR_A), 1);
PUSH_DATAf(push, mat[MAT_ATTRIB_FRONT_DIFFUSE][3]);
 
-   foreach(l, >Light.EnabledList) {
-   const int i = l - ctx->Light.Light;
+   mask = ctx->Light._EnabledLights;
+   while (mask) {
+   const int i = u_bit_scan();
+   struct gl_light *l = >Light.Light[i];
float *c_light = (USE_COLOR_MATERIAL(DIFFUSE) ?
  l->Diffuse :
  l->_MatDiffuse[0]);
@@ -383,10 +386,12 @@ void
 nv10_emit_material_specular(struct gl_context *ctx, int emit)
 {
struct nouveau_pushbuf *push = context_push(ctx);
-   struct gl_light *l;
+   GLbitfield mask;
 
-   foreach(l, >Light.EnabledList) {
-   const int i = l - ctx->Light.Light;
+   mask = ctx->Light._EnabledLights;
+   while (mask) {
+   const int i = u_bit_scan();
+   struct gl_light *l = >Light.Light[i];
float *c_light = (USE_COLOR_MATERIAL(SPECULAR) ?
  l->Specular :
  l->_MatSpecular[0]);
diff --git a/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c 
b/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c
index 

[Mesa-dev] [PATCH 25/29] mesa: Use designated bool value to check texture unit completeness.

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

The change helps to use the bitmask/ffs in the next change.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/main/texstate.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 9ee5c69..3543369 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -612,6 +612,7 @@ update_ff_texture_state(struct gl_context *ctx,
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
   struct gl_texture_unit *texUnit = >Texture.Unit[unit];
   GLuint texIndex;
+  bool complete;
 
   if (texUnit->Enabled == 0x0)
  continue;
@@ -649,6 +650,7 @@ update_ff_texture_state(struct gl_context *ctx,
*  another unit, then the results of texture blending are
*  undefined."
*/
+  complete = false;
   for (texIndex = 0; texIndex < NUM_TEXTURE_TARGETS; texIndex++) {
  if (texUnit->Enabled & (1 << texIndex)) {
 struct gl_texture_object *texObj = texUnit->CurrentTex[texIndex];
@@ -660,12 +662,13 @@ update_ff_texture_state(struct gl_context *ctx,
 }
 if (_mesa_is_texture_complete(texObj, sampler)) {
_mesa_reference_texobj(>_Current, texObj);
+   complete = true;
break;
 }
  }
   }
 
-  if (texIndex == NUM_TEXTURE_TARGETS)
+  if (!complete)
  continue;
 
   /* if we get here, we know this texture unit is enabled */
-- 
2.5.5

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


[Mesa-dev] [PATCH 10/29] mesa: Use bitmask/ffs to iterate enabled lights

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Replaces loops that iterate all lights and test
which of them is enabled by a loop only iterating over
the bits set in the enabled bitmask.

v2: Use _mesa_bit_scan{,64} instead of open coding.
v3: Use u_bit_scan{,64} instead of _mesa_bit_scan{,64}.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/main/light.c   | 44 +---
 src/mesa/main/rastpos.c |  9 ++---
 2 files changed, 39 insertions(+), 14 deletions(-)

diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index a52efdb..c9e2fc2 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -34,6 +34,7 @@
 #include "util/simple_list.h"
 #include "mtypes.h"
 #include "math/m_matrix.h"
+#include "util/bitscan.h"
 
 
 void GLAPIENTRY
@@ -612,7 +613,6 @@ _mesa_material_bitmask( struct gl_context *ctx, GLenum 
face, GLenum pname,
 void
 _mesa_update_material( struct gl_context *ctx, GLuint bitmask )
 {
-   struct gl_light *light, *list = >Light.EnabledList;
GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
 
if (MESA_VERBOSE & VERBOSE_MATERIAL) 
@@ -623,14 +623,20 @@ _mesa_update_material( struct gl_context *ctx, GLuint 
bitmask )
 
/* update material ambience */
if (bitmask & MAT_BIT_FRONT_AMBIENT) {
-  foreach (light, list) {
+  GLbitfield mask = ctx->Light._EnabledLights;
+  while (mask) {
+ const int i = u_bit_scan();
+ struct gl_light *light = >Light.Light[i];
  SCALE_3V( light->_MatAmbient[0], light->Ambient, 
   mat[MAT_ATTRIB_FRONT_AMBIENT]);
   }
}
 
if (bitmask & MAT_BIT_BACK_AMBIENT) {
-  foreach (light, list) {
+  GLbitfield mask = ctx->Light._EnabledLights;
+  while (mask) {
+ const int i = u_bit_scan();
+ struct gl_light *light = >Light.Light[i];
  SCALE_3V( light->_MatAmbient[1], light->Ambient, 
   mat[MAT_ATTRIB_BACK_AMBIENT]);
   }
@@ -651,14 +657,20 @@ _mesa_update_material( struct gl_context *ctx, GLuint 
bitmask )
 
/* update material diffuse values */
if (bitmask & MAT_BIT_FRONT_DIFFUSE) {
-  foreach (light, list) {
+  GLbitfield mask = ctx->Light._EnabledLights;
+  while (mask) {
+ const int i = u_bit_scan();
+ struct gl_light *light = >Light.Light[i];
 SCALE_3V( light->_MatDiffuse[0], light->Diffuse, 
   mat[MAT_ATTRIB_FRONT_DIFFUSE] );
   }
}
 
if (bitmask & MAT_BIT_BACK_DIFFUSE) {
-  foreach (light, list) {
+  GLbitfield mask = ctx->Light._EnabledLights;
+  while (mask) {
+ const int i = u_bit_scan();
+ struct gl_light *light = >Light.Light[i];
 SCALE_3V( light->_MatDiffuse[1], light->Diffuse, 
   mat[MAT_ATTRIB_BACK_DIFFUSE] );
   }
@@ -666,14 +678,20 @@ _mesa_update_material( struct gl_context *ctx, GLuint 
bitmask )
 
/* update material specular values */
if (bitmask & MAT_BIT_FRONT_SPECULAR) {
-  foreach (light, list) {
+  GLbitfield mask = ctx->Light._EnabledLights;
+  while (mask) {
+ const int i = u_bit_scan();
+ struct gl_light *light = >Light.Light[i];
 SCALE_3V( light->_MatSpecular[0], light->Specular, 
   mat[MAT_ATTRIB_FRONT_SPECULAR]);
   }
}
 
if (bitmask & MAT_BIT_BACK_SPECULAR) {
-  foreach (light, list) {
+  GLbitfield mask = ctx->Light._EnabledLights;
+  while (mask) {
+ const int i = u_bit_scan();
+ struct gl_light *light = >Light.Light[i];
 SCALE_3V( light->_MatSpecular[1], light->Specular,
   mat[MAT_ATTRIB_BACK_SPECULAR]);
   }
@@ -864,13 +882,15 @@ void
 _mesa_update_lighting( struct gl_context *ctx )
 {
GLbitfield flags = 0;
-   struct gl_light *light;
ctx->Light._NeedEyeCoords = GL_FALSE;
 
if (!ctx->Light.Enabled)
   return;
 
-   foreach(light, >Light.EnabledList) {
+   GLbitfield mask = ctx->Light._EnabledLights;
+   while (mask) {
+  const int i = u_bit_scan();
+  struct gl_light *light = >Light.Light[i];
   flags |= light->_Flags;
}
 
@@ -926,7 +946,6 @@ _mesa_update_lighting( struct gl_context *ctx )
 static void
 compute_light_positions( struct gl_context *ctx )
 {
-   struct gl_light *light;
static const GLfloat eye_z[3] = { 0, 0, 1 };
 
if (!ctx->Light.Enabled)
@@ -939,7 +958,10 @@ compute_light_positions( struct gl_context *ctx )
   TRANSFORM_NORMAL( ctx->_EyeZDir, eye_z, ctx->ModelviewMatrixStack.Top->m 
);
}
 
-   foreach (light, >Light.EnabledList) {
+   GLbitfield mask = ctx->Light._EnabledLights;
+   while (mask) {
+  const int i = u_bit_scan();
+  struct gl_light *light = >Light.Light[i];
 
   if (ctx->_NeedEyeCoords) {
  /* _Position is in eye coordinate space */
diff --git a/src/mesa/main/rastpos.c b/src/mesa/main/rastpos.c
index b468219..8f971f5 100644
--- 

[Mesa-dev] [PATCH 00/29] Make more use of bitmasks v3

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 


Hi all,

following a series with performance improvements
for cpu/draw bound applications. This part makes
more use of the bitmask/ffs technique for iterating
a set of enabled items. The gains are not huge
but they are noticable for some of my favourite
workloads.

Changes in v2:

Past the suggestion from Brian Paul and the
discussion about maintainability I
switched to gallium/u_bit_scan{,64} style
functions for the series of changes.
Providing them and using them in some places
in core mesa make up the two new patches upfront.

Appart from that the problem spotted
by Roland Scheidegger is fixed and the changes
requested all around are incorporated.

Changes in v3:

Rename _mesa_bit_scan* to u_bit_scan*.
Comment formating changes.
Rebase to master.

Ok to push?

Thanks

Mathias


Mathias Fröhlich (29):
  mesa: Add gl_point_attrib::CoordReplaceBits bitfield.
  swrast: Convert swrast to use CoordsReplaceBits.
  gallium: Convert the state_tracker to use CoordsReplaceBits.
  r200: convert r200 to use CoordsReplaceBits.
  i915: Convert i915 to use CoordsReplaceBits.
  i965: Convert i965 to use CoordsReplaceBits.
  mesa: Remove the now unused CoordsReplace array.
  mesa: Rename CoordReplaceBits back to CoordReplace.
  mesa: Track enabled lights in a bitmask
  mesa: Use bitmask/ffs to iterate enabled lights
  mesa: Use bitmask/ffs to iterate enabled lights for ff shader keys.
  tnl: Use bitmask/ffs to iterate enabled lights
  nouveau: Use bitmask/ffs to iterate enabled lights
  radeon/r200: Use bitmask/ffs to iterate enabled lights
  mesa: Switch to bitmask based enabled lights in gen_matypes.c
  mesa: Remove the linked list of enabled lights
  mesa: Use bitmask/ffs to build ff vertex shader keys.
  mesa: Use bitmask/ffs to build ff fragment shader keys.
  mesa: Use bitmask/ffs to iterate color material attributes.
  mesa: Use bitmask/ffs to iterate enabled clip planes.
  radeon/r200: Use bitmask/ffs to iterate enabled clip planes.
  i965: Use bitmask/ffs to iterate enabled clip planes.
  i965: Use bitmask/ffs to iterate used vertex attributes.
  mesa: Use bitmask/ffs to iterate SamplersUsed
  mesa: Use designated bool value to check texture unit completeness.
  mesa: Use bitmask/ffs to iterate the enabled textures.
  mesa: Use bitmask/ffs to iterate the active_samplers bitmask.
  vbo: Use a bitmask to track the active arrays in vbo_exec*.
  vbo: Use a bitmask to track the active arrays in vbo_save*.

 src/mesa/drivers/common/meta.c|  22 ++--
 src/mesa/drivers/dri/i915/i915_state.c|  17 ++-
 src/mesa/drivers/dri/i965/brw_curbe.c |  21 ++--
 src/mesa/drivers/dri/i965/brw_draw.c  |  10 +-
 src/mesa/drivers/dri/i965/brw_sf.c|   7 +-
 src/mesa/drivers/dri/i965/brw_vs.c|   6 +-
 src/mesa/drivers/dri/i965/gen6_sf_state.c |   2 +-
 src/mesa/drivers/dri/nouveau/nouveau_state.c  |  10 +-
 src/mesa/drivers/dri/nouveau/nv10_state_tnl.c |  27 +++--
 src/mesa/drivers/dri/nouveau/nv20_state_tnl.c |  27 +++--
 src/mesa/drivers/dri/r200/r200_state.c|  66 ++--
 src/mesa/drivers/dri/radeon/radeon_state.c|  61 ++-
 src/mesa/main/attrib.c|   2 +-
 src/mesa/main/context.c   |  11 +-
 src/mesa/main/enable.c|   6 +-
 src/mesa/main/ff_fragment_shader.cpp  |  10 +-
 src/mesa/main/ffvertex_prog.c |  36 ---
 src/mesa/main/light.c |  60 +++
 src/mesa/main/matrix.c|  19 ++--
 src/mesa/main/mtypes.h|   8 +-
 src/mesa/main/points.c|   6 +-
 src/mesa/main/rastpos.c   |  28 ++---
 src/mesa/main/texenv.c|  32 +++---
 src/mesa/main/texstate.c  |  34 +++---
 src/mesa/main/uniform_query.cpp   |   8 +-
 src/mesa/main/uniforms.c  |  42 
 src/mesa/state_tracker/st_atom_rasterizer.c   |   8 +-
 src/mesa/swrast/s_points.c|   4 +-
 src/mesa/tnl/t_vb_cliptmp.h   |  51 +
 src/mesa/tnl/t_vb_light.c |  15 ++-
 src/mesa/tnl/t_vb_lighttmp.h  |  24 +++--
 src/mesa/tnl/t_vb_program.c   |  65 ++--
 src/mesa/tnl/t_vb_render.c|   1 +
 src/mesa/tnl/t_vb_vertex.c|  59 ++-
 src/mesa/vbo/vbo_exec.h   |   1 +
 src/mesa/vbo/vbo_exec_api.c   | 146 ++
 src/mesa/vbo/vbo_exec_draw.c  |   2 +
 src/mesa/vbo/vbo_save.h   |   2 +
 src/mesa/vbo/vbo_save_api.c   |  67 +++-
 src/mesa/vbo/vbo_save_draw.c  |  55 +-
 src/mesa/x86/gen_matypes.c|   4 +-
 41 files changed, 567 insertions(+), 515 deletions(-)

-- 
2.5.5


[Mesa-dev] [PATCH 12/29] tnl: Use bitmask/ffs to iterate enabled lights

2016-06-13 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Replaces loops that iterate all lights and test
which of them is enabled by a loop only iterating over
the bits set in the enabled bitmask.

v2: Use _mesa_bit_scan{,64} instead of open coding.
v3: Use u_bit_scan{,64} instead of _mesa_bit_scan{,64}.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 
---
 src/mesa/tnl/t_vb_light.c|  5 -
 src/mesa/tnl/t_vb_lighttmp.h | 24 +---
 2 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/src/mesa/tnl/t_vb_light.c b/src/mesa/tnl/t_vb_light.c
index 029265a..4342b6e 100644
--- a/src/mesa/tnl/t_vb_light.c
+++ b/src/mesa/tnl/t_vb_light.c
@@ -33,6 +33,8 @@
 
 #include "math/m_translate.h"
 
+#include "util/bitscan.h"
+
 #include "t_context.h"
 #include "t_pipeline.h"
 #include "tnl.h"
@@ -394,7 +396,8 @@ static void validate_lighting( struct gl_context *ctx,
 tab = _tnl_light_tab;
}
else {
-  if (ctx->Light.EnabledList.next == ctx->Light.EnabledList.prev)
+  /* Power of two means only a single active light. */
+  if (_mesa_is_pow_two(ctx->Light._EnabledLights))
 tab = _tnl_light_fast_single_tab;
   else
 tab = _tnl_light_fast_tab;
diff --git a/src/mesa/tnl/t_vb_lighttmp.h b/src/mesa/tnl/t_vb_lighttmp.h
index 3aebcd4..ac88095 100644
--- a/src/mesa/tnl/t_vb_lighttmp.h
+++ b/src/mesa/tnl/t_vb_lighttmp.h
@@ -87,7 +87,7 @@ static void TAG(light_rgba_spec)( struct gl_context *ctx,
 
for (j = 0; j < nr; j++,STRIDE_F(vertex,vstride),STRIDE_F(normal,nstride)) {
   GLfloat sum[2][3], spec[2][3];
-  struct gl_light *light;
+  GLbitfield mask;
 
 #if IDX & LIGHT_MATERIAL
   update_materials( ctx, store );
@@ -106,7 +106,10 @@ static void TAG(light_rgba_spec)( struct gl_context *ctx,
 #endif
 
   /* Add contribution from each enabled light source */
-  foreach (light, >Light.EnabledList) {
+  mask = ctx->Light._EnabledLights;
+  while (mask) {
+ const int l = u_bit_scan();
+ struct gl_light *light = >Light.Light[l];
 GLfloat n_dot_h;
 GLfloat correction;
 GLint side;
@@ -265,7 +268,7 @@ static void TAG(light_rgba)( struct gl_context *ctx,
 
for (j = 0; j < nr; j++,STRIDE_F(vertex,vstride),STRIDE_F(normal,nstride)) {
   GLfloat sum[2][3];
-  struct gl_light *light;
+  GLbitfield mask;
 
 #if IDX & LIGHT_MATERIAL
   update_materials( ctx, store );
@@ -282,7 +285,10 @@ static void TAG(light_rgba)( struct gl_context *ctx,
 #endif
 
   /* Add contribution from each enabled light source */
-  foreach (light, >Light.EnabledList) {
+  mask = ctx->Light._EnabledLights;
+  while (mask) {
+ const int l = u_bit_scan();
+ struct gl_light *light = >Light.Light[l];
 GLfloat n_dot_h;
 GLfloat correction;
 GLint side;
@@ -417,7 +423,8 @@ static void TAG(light_fast_rgba_single)( struct gl_context 
*ctx,
 #if IDX & LIGHT_TWOSIDE
GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data;
 #endif
-   const struct gl_light *light = ctx->Light.EnabledList.next;
+   const struct gl_light *light =
+  >Light.Light[ffs(ctx->Light._EnabledLights) - 1];
GLuint j = 0;
GLfloat base[2][4];
 #if IDX & LIGHT_MATERIAL
@@ -528,7 +535,6 @@ static void TAG(light_fast_rgba)( struct gl_context *ctx,
 #else
const GLuint nr = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->count;
 #endif
-   const struct gl_light *light;
 
 #ifdef TRACE
fprintf(stderr, "%s %d\n", __func__, nr );
@@ -556,6 +562,7 @@ static void TAG(light_fast_rgba)( struct gl_context *ctx,
for (j = 0; j < nr; j++, STRIDE_F(normal,nstride)) {
 
   GLfloat sum[2][3];
+  GLbitfield mask;
 
 #if IDX & LIGHT_MATERIAL
   update_materials( ctx, store );
@@ -572,7 +579,10 @@ static void TAG(light_fast_rgba)( struct gl_context *ctx,
   COPY_3V(sum[1], ctx->Light._BaseColor[1]);
 #endif
 
-  foreach (light, >Light.EnabledList) {
+  mask = ctx->Light._EnabledLights;
+  while (mask) {
+ const int l = u_bit_scan();
+ const struct gl_light *light = >Light.Light[l];
 GLfloat n_dot_h, n_dot_VP, spec;
 
 ACC_3V(sum[0], light->_MatAmbient[0]);
-- 
2.5.5

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


Re: [Mesa-dev] [PATCH 0/2] Move u_bit_scan from gallium to util.

2016-06-13 Thread Mathias Fröhlich
Hi Brian,

On Friday, June 10, 2016 12:41:29 Brian Paul wrote:
> Long term, I'd like to get away from imports.h defining or including a 
> bunch of stuff that a lot of .c files don't need.  So I'd prefer to 
> include bitscan.h where needed, but I agree with your concerns.
In that case, ideally we would also have a u_ffs then so that missing includes
get detected early.

> The patch as you have it now is fine.  I tested it with MSVC.
Pushed this part now. Thanks for review and testing.

> I see there's some _mesa_fsl() functions still in imports.h.  I think 
> those should probably go into bitscan.h too.  A follow-on commit would 
> be OK.
Ok.

Thanks

Mathias___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2] glsl: reuse main extension table to appropriate restrict extensions

2016-06-13 Thread Ilia Mirkin
Previously we were only restricting based on ES/non-ES-ness and whether
the overall enable bit had been flipped on. However we have been adding
more fine-grained restrictions, such as based on compat profiles, as
well as specific ES versions. Most of the time this doesn't matter, but
it can create awkward situations and duplication of logic.

Here we separate the main extension table into a separate object file,
linked to the glsl compiler, which makes use of it with a custom
function which takes the ES-ness of the shader into account (thus
allowing desktop shaders to properly use ES extensions that would
otherwise have been disallowed.)

The effect of this change should be nil in most cases.

Signed-off-by: Ilia Mirkin 
---

v1 -> v2:
 - use a final enum to obtain number of extensions
 - move calculation of the gl version to be once per shader, for better reuse
 - bake GL version into the "supported_versions" struct
 - while we're at it, fix supported_versions size, it was off by 1 since ES 3.20
   "support" was added.

 src/Makefile.am  |   1 +
 src/compiler/SConscript.glsl |   2 +
 src/compiler/glsl/glsl_parser_extras.cpp | 244 +++
 src/compiler/glsl/glsl_parser_extras.h   |   4 +-
 src/mesa/Android.libmesa_glsl_utils.mk   |   2 +
 src/mesa/Makefile.sources|   1 +
 src/mesa/main/extensions.c   |  33 +
 src/mesa/main/extensions.h   |   1 +
 src/mesa/main/extensions_table.c |  51 +++
 9 files changed, 190 insertions(+), 149 deletions(-)
 create mode 100644 src/mesa/main/extensions_table.c

diff --git a/src/Makefile.am b/src/Makefile.am
index 32372da..d38f7c4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -114,6 +114,7 @@ AM_CPPFLAGS = \
 noinst_LTLIBRARIES = libglsl_util.la
 
 libglsl_util_la_SOURCES = \
+   mesa/main/extensions_table.c \
mesa/main/imports.c \
mesa/program/prog_hash_table.c \
mesa/program/symbol_table.c \
diff --git a/src/compiler/SConscript.glsl b/src/compiler/SConscript.glsl
index 4252ce1..31d8f6d 100644
--- a/src/compiler/SConscript.glsl
+++ b/src/compiler/SConscript.glsl
@@ -70,6 +70,7 @@ if env['msvc']:
 # Copy these files to avoid generation object files into src/mesa/program
 env.Prepend(CPPPATH = ['#src/mesa/main'])
 env.Command('glsl/imports.c', '#src/mesa/main/imports.c', Copy('$TARGET', 
'$SOURCE'))
+env.Command('glsl/extensions_table.c', '#src/mesa/main/extensions_table.c', 
Copy('$TARGET', '$SOURCE'))
 # Copy these files to avoid generation object files into src/mesa/program
 env.Prepend(CPPPATH = ['#src/mesa/program'])
 env.Command('glsl/prog_hash_table.c', '#src/mesa/program/prog_hash_table.c', 
Copy('$TARGET', '$SOURCE'))
@@ -79,6 +80,7 @@ env.Command('glsl/dummy_errors.c', 
'#src/mesa/program/dummy_errors.c', Copy('$TA
 compiler_objs = env.StaticObject(source_lists['GLSL_COMPILER_CXX_FILES'])
 
 mesa_objs = env.StaticObject([
+'glsl/extensions_table.c',
 'glsl/imports.c',
 'glsl/prog_hash_table.c',
 'glsl/symbol_table.c',
diff --git a/src/compiler/glsl/glsl_parser_extras.cpp 
b/src/compiler/glsl/glsl_parser_extras.cpp
index ce2c3e8..0e9f152 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -50,6 +50,8 @@ glsl_compute_version_string(void *mem_ctx, bool is_es, 
unsigned version)
 
 static const unsigned known_desktop_glsl_versions[] =
{ 110, 120, 130, 140, 150, 330, 400, 410, 420, 430, 440, 450 };
+static const unsigned known_desktop_gl_versions[] =
+   {  20,  21,  30,  31,  32,  33,  40,  41,  42,  43,  44,  45 };
 
 
 _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
@@ -74,6 +76,7 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct 
gl_context *_ctx,
/* Set default language version and extensions */
this->language_version = 110;
this->forced_language_version = ctx->Const.ForceGLSLVersion;
+   this->gl_version = 20;
this->es_shader = false;
this->ARB_texture_rectangle_enable = true;
 
@@ -194,9 +197,9 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct 
gl_context *_ctx,
this->subroutine_types = NULL;
 
/* supported_versions should be large enough to support the known desktop
-* GLSL versions plus 3 GLES versions (ES 1.00, ES 3.00, and ES 3.10))
+* GLSL versions plus 4 GLES versions (ES 1.00, ES 3.00, ES 3.10, ES 3.20)
 */
-   STATIC_ASSERT((ARRAY_SIZE(known_desktop_glsl_versions) + 3) ==
+   STATIC_ASSERT((ARRAY_SIZE(known_desktop_glsl_versions) + 4) ==
  ARRAY_SIZE(this->supported_versions));
 
/* Populate the list of supported GLSL versions */
@@ -211,6 +214,8 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct 
gl_context *_ctx,
  if (known_desktop_glsl_versions[i] <= ctx->Const.GLSLVersion) {
 this->supported_versions[this->num_supported_versions].ver
= known_desktop_glsl_versions[i];
+   

Re: [Mesa-dev] [PATCH] clover: Include generated sources in AM_CPPFLAGS

2016-06-13 Thread Francisco Jerez
Michel Dänzer  writes:

> On 14.06.2016 11:46, Aaron Watry wrote:
>> git_sha1.c is generated in $(top_builddir)/src.
>> 
>> Fixes out-of-tree builds since 4825264f75c83576.
>> 
>> Signed-off-by: Aaron Watry 
>> ---
>>  src/gallium/state_trackers/clover/Makefile.am | 1 +
>>  1 file changed, 1 insertion(+)
>> 
>> diff --git a/src/gallium/state_trackers/clover/Makefile.am 
>> b/src/gallium/state_trackers/clover/Makefile.am
>> index 4c9d7d9..d0b1914 100644
>> --- a/src/gallium/state_trackers/clover/Makefile.am
>> +++ b/src/gallium/state_trackers/clover/Makefile.am
>> @@ -7,6 +7,7 @@ AM_CPPFLAGS = \
>>  -I$(top_srcdir)/src/gallium/drivers \
>>  -I$(top_srcdir)/src/gallium/auxiliary \
>>  -I$(top_srcdir)/src/gallium/winsys \
>> +-I$(top_builddir)/src \
>>  -I$(srcdir)
>>  
>>  if HAVE_CLOVER_ICD
>> 
>
> Pushed, thanks.
>
Emil, would you mind picking up this bugfix for 12.0?  The patch that
introduced the problem was marked for inclusion in the stable branch so
this patch should probably have Cc'ed mesa-stable too.

Thanks!

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


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


Re: [Mesa-dev] [PATCH] clover: Include generated sources in AM_CPPFLAGS

2016-06-13 Thread Michel Dänzer
On 14.06.2016 11:46, Aaron Watry wrote:
> git_sha1.c is generated in $(top_builddir)/src.
> 
> Fixes out-of-tree builds since 4825264f75c83576.
> 
> Signed-off-by: Aaron Watry 
> ---
>  src/gallium/state_trackers/clover/Makefile.am | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/gallium/state_trackers/clover/Makefile.am 
> b/src/gallium/state_trackers/clover/Makefile.am
> index 4c9d7d9..d0b1914 100644
> --- a/src/gallium/state_trackers/clover/Makefile.am
> +++ b/src/gallium/state_trackers/clover/Makefile.am
> @@ -7,6 +7,7 @@ AM_CPPFLAGS = \
>   -I$(top_srcdir)/src/gallium/drivers \
>   -I$(top_srcdir)/src/gallium/auxiliary \
>   -I$(top_srcdir)/src/gallium/winsys \
> + -I$(top_builddir)/src \
>   -I$(srcdir)
>  
>  if HAVE_CLOVER_ICD
> 

Pushed, thanks.


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


[Mesa-dev] [Bug 96516] [bisected: 482526] "clover: Update OpenCL version string to match OpenGL": clover's build fails because of missing git_sha1.h

2016-06-13 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=96516

Michel Dänzer  changed:

   What|Removed |Added

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

--- Comment #6 from Michel Dänzer  ---
Module: Mesa
Branch: master
Commit: fafe026dbe0680c971bf3ba2452954eea84287f2
URL:   
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fafe026dbe0680c971bf3ba2452954eea84287f2

Author: Aaron Watry 
Date:   Mon Jun 13 21:46:33 2016 -0500

clover: Include generated sources in AM_CPPFLAGS

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


Re: [Mesa-dev] [PATCH] glsl: reuse main extension table to appropriate restrict extensions

2016-06-13 Thread Ilia Mirkin
On Mon, Jun 13, 2016 at 1:27 PM, Eric Engestrom
 wrote:
> On Mon, Jun 13, 2016 at 09:39:39AM -0700, Nanley Chery wrote:
>> You can add an entry to the end of the enum defined in extensions.h called
>> "MESA_EXTENSION_COUNT"  or similar.
>
> This is a good idea, but with one caveat:
> I've seen twice already bugs caused by people using ALL_CAPS counter
> entries in enums, and then someone trying to use them in #if conditions,
> where it resolves as `0` since the preprocessor doesn't know them.
>
> I would strongly advise to use lower case names, so as to avoid this
> confusion.

I see where you're coming from, but that's not the convention in mesa.
The enums are already MESA_EXTENSION_ARB_foo, so it'd be odd to call
the last thing "mesa_extension_count". I also can't think of a legit
scenario where someone would want to use MESA_EXTENSION_COUNT in a
preprocessor macro. So I'm going to leave it upper-cased.

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


Re: [Mesa-dev] [PATCH] mesa/glsl: stop using GL shader type internally

2016-06-13 Thread Jan Vesely
On Tue, 2016-06-14 at 10:59 +1000, Timothy Arceri wrote:
> Ping.

just FYI, I occasionally find your patches posted to mesa-dev in spam
(gmail) with message:
"Why is this message in Spam? It has a from address in yahoo.com.au but
has failed yahoo.com.au's required tests for authentication."

Jan

> 
> On Sun, 2016-06-05 at 13:17 +1000, Timothy Arceri wrote:
> > 
> > Instead use the internal gl_shader_stage enum everywhere. This
> > makes things more consistent and gets rid of unnecessary
> > conversions.
> > Ideally it would be nice to remove the Type field from gl_shader
> > altogether but currently it is used to differentiate between
> > gl_shader and gl_shader_program in the ShaderObjects hash table.
> > ---
> >  src/compiler/glsl/builtin_functions.cpp  |  2 +-
> >  src/compiler/glsl/link_varyings.cpp  |  2 +-
> >  src/compiler/glsl/linker.cpp |  2 +-
> >  src/compiler/glsl/standalone.cpp |  2 +-
> >  src/compiler/glsl/standalone_scaffolding.cpp |  7 +++
> >  src/compiler/glsl/standalone_scaffolding.h   |  2 +-
> >  src/mesa/drivers/common/meta.c   | 12 +--
> >  src/mesa/drivers/common/meta.h   |  5 -
> >  src/mesa/drivers/dri/i965/brw_link.cpp   |  5 ++---
> >  src/mesa/drivers/dri/i965/brw_shader.h   |  3 ++-
> >  src/mesa/main/dd.h   |  2 +-
> >  src/mesa/main/ff_fragment_shader.cpp |  2 +-
> >  src/mesa/main/shaderapi.c| 20 ++--
> > ---
> >  src/mesa/main/shaderobj.c|  6 ++
> >  src/mesa/state_tracker/st_glsl_to_nir.cpp|  6 +++---
> >  src/mesa/state_tracker/st_glsl_to_tgsi.cpp   | 30 ++--
> > 
> >  16 files changed, 51 insertions(+), 57 deletions(-)
> > 
> > diff --git a/src/compiler/glsl/builtin_functions.cpp
> > b/src/compiler/glsl/builtin_functions.cpp
> > index edd02bb..87d22e6 100644
> > --- a/src/compiler/glsl/builtin_functions.cpp
> > +++ b/src/compiler/glsl/builtin_functions.cpp
> > @@ -948,7 +948,7 @@ builtin_builder::create_shader()
> >  * GLSL utility code that could be linked against any stage, so
> > just
> >  * arbitrarily pick GL_VERTEX_SHADER.
> >  */
> > -   shader = _mesa_new_shader(NULL, 0, GL_VERTEX_SHADER);
> > +   shader = _mesa_new_shader(NULL, 0, MESA_SHADER_VERTEX);
> > shader->symbols = new(mem_ctx) glsl_symbol_table;
> >  
> > gl_ModelViewProjectionMatrix =
> > diff --git a/src/compiler/glsl/link_varyings.cpp
> > b/src/compiler/glsl/link_varyings.cpp
> > index a286e77..2ff7d80 100644
> > --- a/src/compiler/glsl/link_varyings.cpp
> > +++ b/src/compiler/glsl/link_varyings.cpp
> > @@ -2111,7 +2111,7 @@ assign_varying_locations(struct gl_context
> > *ctx,
> >    * within a patch and can be used as shared memory.
> >    */
> >   if (input_var || (prog->SeparateShader && consumer ==
> > NULL)
> > > 
> > > > 
> > > > 
> > - producer->Type == GL_TESS_CONTROL_SHADER) {
> > + producer->Stage == MESA_SHADER_TESS_CTRL) {
> >  matches.record(output_var, input_var);
> >   }
> >  
> > diff --git a/src/compiler/glsl/linker.cpp
> > b/src/compiler/glsl/linker.cpp
> > index 43719f4..e0e09e9 100644
> > --- a/src/compiler/glsl/linker.cpp
> > +++ b/src/compiler/glsl/linker.cpp
> > @@ -2237,7 +2237,7 @@ link_intrastage_shaders(void *mem_ctx,
> >    return NULL;
> > }
> >  
> > -   gl_shader *linked = ctx->Driver.NewShader(NULL, 0, main->Type);
> > +   gl_shader *linked = ctx->Driver.NewShader(NULL, 0,
> > shader_list[0]->Stage);
> > linked->ir = new(linked) exec_list;
> > clone_ir_list(mem_ctx, linked->ir, main->ir);
> >  
> > diff --git a/src/compiler/glsl/standalone.cpp
> > b/src/compiler/glsl/standalone.cpp
> > index c3afbc3..9b77b3a 100644
> > --- a/src/compiler/glsl/standalone.cpp
> > +++ b/src/compiler/glsl/standalone.cpp
> > @@ -419,7 +419,7 @@ standalone_compile_shader(const struct
> > standalone_options *_options,
> >  continue;
> >  
> >   shader->Program = rzalloc(shader, gl_program);
> > - init_gl_program(shader->Program, shader->Type);
> > + init_gl_program(shader->Program, shader->Stage);
> >    }
> > }
> >  
> > diff --git a/src/compiler/glsl/standalone_scaffolding.cpp
> > b/src/compiler/glsl/standalone_scaffolding.cpp
> > index e7f6555..94938ef 100644
> > --- a/src/compiler/glsl/standalone_scaffolding.cpp
> > +++ b/src/compiler/glsl/standalone_scaffolding.cpp
> > @@ -76,17 +76,16 @@ _mesa_shader_debug(struct gl_context *, GLenum,
> > GLuint *,
> >  }
> >  
> >  struct gl_shader *
> > -_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type)
> > +_mesa_new_shader(struct gl_context *ctx, GLuint name,
> > gl_shader_stage stage)
> >  {
> > struct gl_shader *shader;
> >  
> > (void) ctx;
> >  
> > -   assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER);
> > +   assert(stage == MESA_SHADER_FRAGMENT || stage ==

Re: [Mesa-dev] [PATCH] Avoid ASan new-delete-type-mismatch

2016-06-13 Thread Ilia Mirkin
On Fri, Jun 10, 2016 at 11:34 AM, Stephan Bergmann  wrote:
> On 06/10/2016 05:20 PM, Ilia Mirkin wrote:
>>
>> It's pretty easy for me to fix up before I apply it too, but if I "git
>> am" your email, it'll be attributed to the one you sent it from,
>> unless that From line is there as line 1 of the email body. Just let
>> me know if you want me to fix it up. Despite the fact that the patch
>> is a 1-liner, I need to spend a few minutes carefully going through
>> things to ensure that it really is OK to make that destructor virtual
>> - I should get the time tonight or tomorrow.
>
>
> I'm fine with the From as is, no need for any fixup.  Thanks for taking care
> of the patch.

Stephan,

I've pushed this out now. Thanks for contributing!

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


[Mesa-dev] [PATCH] clover: Include generated sources in AM_CPPFLAGS

2016-06-13 Thread Aaron Watry
git_sha1.c is generated in $(top_builddir)/src.

Fixes out-of-tree builds since 4825264f75c83576.

Signed-off-by: Aaron Watry 
---
 src/gallium/state_trackers/clover/Makefile.am | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/state_trackers/clover/Makefile.am 
b/src/gallium/state_trackers/clover/Makefile.am
index 4c9d7d9..d0b1914 100644
--- a/src/gallium/state_trackers/clover/Makefile.am
+++ b/src/gallium/state_trackers/clover/Makefile.am
@@ -7,6 +7,7 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/src/gallium/drivers \
-I$(top_srcdir)/src/gallium/auxiliary \
-I$(top_srcdir)/src/gallium/winsys \
+   -I$(top_builddir)/src \
-I$(srcdir)
 
 if HAVE_CLOVER_ICD
-- 
2.7.4

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


[Mesa-dev] [Bug 96516] [bisected: 482526] "clover: Update OpenCL version string to match OpenGL": clover's build fails because of missing git_sha1.h

2016-06-13 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=96516

--- Comment #5 from Aaron Watry  ---
The issue manifests itself with an out-of-tree build that includes clover. 
I'll be sending a patch to the list momentarily.

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


[Mesa-dev] [Bug 50976] Fails to build with error: git_sha1.h: No such file or directory

2016-06-13 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=50976

Alexandre Demers  changed:

   What|Removed |Added

   See Also||https://bugs.freedesktop.or
   ||g/show_bug.cgi?id=96516

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


[Mesa-dev] [Bug 96516] [bisected: 482526] "clover: Update OpenCL version string to match OpenGL": clover's build fails because of missing git_sha1.h

2016-06-13 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=96516

Alexandre Demers  changed:

   What|Removed |Added

   See Also||https://bugs.freedesktop.or
   ||g/show_bug.cgi?id=50976

--- Comment #4 from Alexandre Demers  ---
As a cue, it may be similar to bug 50976.

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


[Mesa-dev] [Bug 96516] [bisected: 482526] "clover: Update OpenCL version string to match OpenGL": clover's build fails because of missing git_sha1.h

2016-06-13 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=96516

--- Comment #3 from Alexandre Demers  ---
(In reply to Emil Velikov from comment #2)
> Vedran friendly advice - changing assignee to yourself, limits notifications
> to others as the bug evolves. Some people just state that they're working on
> it, without changing the status. Feel free to proceed as you wish.
> 
> Alexandre, I take it that things were working just before that patch ? Are
> you using git checkouts, git archive or any other means to get (and build)
> mesa ?

Building mesa from git through git checkout, pull, and so on. Bisected in no
time because I had just built mesa (64bit) (from culprit commit's parent) when
I saw there was a new commit in the tree once I moved to build the 32 bit
version. Previous commit was building without problem (and is still, I just
tested it). It happened that I had made a clean up of the repo to build against
an updated LLVM and I was lucky to find there was a missing git_sha1.h file.

If needed, I can provide my build script and/or autogen.sh command, but
building from a clean repo should be enough to reproduce the problem.

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


[Mesa-dev] [Bug 96518] [llvmpipe] piglit linestipple regression

2016-06-13 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=96518

--- Comment #1 from Roland Scheidegger  ---
I suppose I missed that when I did a piglit run...
This is fairly interesting, it seems to be due to inaccurate float math.
The stipple code gets for position x0,x1 10.5, 34.5 leading to a length 24.
However, with the MADs used for vertex transform replaced by fmas, I get
position 10.52, 34.50 instead. Hence length 23.98. And subsequently
patterns getting different (I think it makes no difference on the first
segment, but the second due to the stipple->counter += length line).

Not sure though why the results would be seemingly less accurate with fma. (And
not sure there shouldn't be some different behavior wrt rounding in the line
stipple code?)

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


Re: [Mesa-dev] [PATCH] glsl/builtin_variables: Populate MaxCombinedShaderStorageBlocks on GLSL 4.40

2016-06-13 Thread Kenneth Graunke
On Monday, June 13, 2016 12:50:12 PM PDT Eduardo Lima Mitev wrote:
> Built-in variable "MaxCombinedShaderStorageBlocks" was added to GLSL 4.40
> revision 9.
> 
> Section "1.2.1 Changes since revision 8 of GLSL version 4.40",
> page 3 of the PDF states:
> 
> "Bug 11734: Add gl_MaxCombinedShaderOutputResources and mark
> gl_MaxCombinedImageUnitsAndFragmentOutputs  as deprecated."
> 
> Fixes: GL44-CTS.shader_image_load_store.basic-glsl-const
> ---
>  src/compiler/glsl/builtin_variables.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/compiler/glsl/builtin_variables.cpp 
> b/src/compiler/glsl/builtin_variables.cpp
> index 05b3b0b..e5e7380 100644
> --- a/src/compiler/glsl/builtin_variables.cpp
> +++ b/src/compiler/glsl/builtin_variables.cpp
> @@ -864,7 +864,7 @@ builtin_variable_generator::generate_constants()
>}
> }
>  
> -   if (state->is_version(450, 310) ||
> +   if (state->is_version(440, 310) ||
> state->ARB_ES3_1_compatibility_enable) {
>add_const("gl_MaxCombinedShaderOutputResources",
>  state->Const.MaxCombinedShaderOutputResources);
> 

Interesting, it's definitely not in revision 6, and I see it in the
"changes since revision 8" part of the spec.

Reviewed-by: Kenneth Graunke 


signature.asc
Description: This is a digitally signed message part.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] gallium/util: don't use blocksize for minify for assertions

2016-06-13 Thread sroland
From: Roland Scheidegger 

The previous assertions required for texture sizes smaller than block_size
that src_box.x + src_box.width still be block size.
(e.g. for a texture with width 3, and src_box.x = 0, src_box.width would
have to be 4 to not assert.)
This caused some assertions with some other state tracker.
It looks though like callers aren't expected to round up widths to block sizes
(for sizes larger than block size the assertion would still have verified it
wouldn't have been rounded up) so we simply shouldn't use a minify which
rounds up to block size.
(No piglit change with llvmpipe.)
---
 src/gallium/auxiliary/util/u_surface.c | 28 
 1 file changed, 8 insertions(+), 20 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_surface.c 
b/src/gallium/auxiliary/util/u_surface.c
index b9d2da0..8408aa8 100644
--- a/src/gallium/auxiliary/util/u_surface.c
+++ b/src/gallium/auxiliary/util/u_surface.c
@@ -238,14 +238,6 @@ util_fill_box(ubyte * dst,
 }
 
 
-/** Mipmap level size computation, with minimum block size */
-static inline unsigned
-minify(unsigned value, unsigned levels, unsigned blocksize)
-{
-   return MAX2(blocksize, value >> levels);
-}
-
-
 /**
  * Fallback function for pipe->resource_copy_region().
  * We support copying between different formats (including compressed/
@@ -333,25 +325,21 @@ util_resource_copy_region(struct pipe_context *pipe,
assert(src_box.x % src_bw == 0);
assert(src_box.y % src_bh == 0);
assert(src_box.width % src_bw == 0 ||
-  src_box.x + src_box.width == minify(src->width0, src_level, src_bw));
+  src_box.x + src_box.width == u_minify(src->width0, src_level));
assert(src_box.height % src_bh == 0 ||
-  src_box.y + src_box.height == minify(src->height0, src_level, 
src_bh));
+  src_box.y + src_box.height == u_minify(src->height0, src_level));
assert(dst_box.x % dst_bw == 0);
assert(dst_box.y % dst_bh == 0);
assert(dst_box.width % dst_bw == 0 ||
-  dst_box.x + dst_box.width == minify(dst->width0, dst_level, dst_bw));
+  dst_box.x + dst_box.width == u_minify(dst->width0, dst_level));
assert(dst_box.height % dst_bh == 0 ||
-  dst_box.y + dst_box.height == minify(dst->height0, dst_level, 
dst_bh));
+  dst_box.y + dst_box.height == u_minify(dst->height0, dst_level));
 
/* check that region boxes are not out of bounds */
-   assert(src_box.x + src_box.width <=
-  minify(src->width0, src_level, src_bw));
-   assert(src_box.y + src_box.height <=
-  minify(src->height0, src_level, src_bh));
-   assert(dst_box.x + dst_box.width <=
-  minify(dst->width0, dst_level, dst_bw));
-   assert(dst_box.y + dst_box.height <=
-  minify(dst->height0, dst_level, dst_bh));
+   assert(src_box.x + src_box.width <= u_minify(src->width0, src_level));
+   assert(src_box.y + src_box.height <= u_minify(src->height0, src_level));
+   assert(dst_box.x + dst_box.width <= u_minify(dst->width0, dst_level));
+   assert(dst_box.y + dst_box.height <= u_minify(dst->height0, dst_level));
 
/* check that total number of src, dest bytes match */
assert((src_box.width / src_bw) * (src_box.height / src_bh) * src_bs ==
-- 
2.1.4

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


Re: [Mesa-dev] [PATCH] glsl: make sure UBO arrays are sized in ES

2016-06-13 Thread Dave Airlie
Oops,

Reviewed-by: Dave Airlie 

On 14 June 2016 at 10:49, Timothy Arceri  wrote:
> This check was removed in 5b2675093e86 add it back in.
>
> Cc: Dave Airlie 
> https://bugs.freedesktop.org/show_bug.cgi?id=96349
> ---
>  src/compiler/glsl/ast_to_hir.cpp | 14 ++
>  1 file changed, 14 insertions(+)
>
> diff --git a/src/compiler/glsl/ast_to_hir.cpp 
> b/src/compiler/glsl/ast_to_hir.cpp
> index 3d34ecf..551d004 100644
> --- a/src/compiler/glsl/ast_to_hir.cpp
> +++ b/src/compiler/glsl/ast_to_hir.cpp
> @@ -7597,6 +7597,20 @@ ast_interface_block::hir(exec_list *instructions,
> if (is_unsized_array_last_element(var)) {
>var->data.from_ssbo_unsized_array = true;
> }
> +} else {
> +   /* From GLSL ES 3.10 spec, section 4.1.9 "Arrays":
> +*
> +* "If an array is declared as the last member of a shader 
> storage
> +* block and the size is not specified at compile-time, it is
> +* sized at run-time. In all other cases, arrays are sized 
> only
> +* at compile-time."
> +*/
> +   if (state->es_shader) {
> +  _mesa_glsl_error(, state, "unsized array `%s' "
> +   "definition: only last member of a shader 
> "
> +   "storage block can be defined as unsized "
> +   "array", fields[i].name);
> +   }
>  }
>   }
>
> --
> 2.5.5
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2] swr: automake: don't ship LLVM version specific generated sources

2016-06-13 Thread Rowley, Timothy O
A clean tree build works with this version, but distcheck fails:

...
rm -f config.status config.cache config.log configure.lineno 
config.status.lineno
rm -f Makefile
ERROR: files left in build directory after distclean:
./src/gallium/drivers/swr/rasterizer/jitter/builder_gen.cpp
./src/gallium/drivers/swr/rasterizer/jitter/builder_x86.cpp
./src/gallium/drivers/swr/rasterizer/jitter/builder_gen.h
make[1]: *** [distcleancheck] Error 1
make[1]: Leaving directory 
`/home/torowley/work/mesa-opt/mesa-12.1.0-devel/_build'
make: *** [distcheck] Error 1

Not sure how builder_x86.cpp managed to change its status.

> On Jun 13, 2016, at 6:46 PM, Emil Velikov  wrote:
> 
> From: Emil Velikov 
> 
> Otherwise things will fail to build, if the builder is using another
> version of LLVM.
> 
> v2: annotate all the dependencies of builder_gen.h
> 
> Cc: "12.0" 
> Cc: Tim Rowley 
> Cc: Chuck Atkins 
> Reported-by: Chuck Atkins 
> Signed-off-by: Emil Velikov 
> ---
> Unlike v1, this ones seems to work. Please give it a try and let me know
> how it fares on your end.
> 
> Thanks
> Emil
> ---
> src/gallium/drivers/swr/Makefile.am | 37 +++--
> 1 file changed, 35 insertions(+), 2 deletions(-)
> 
> diff --git a/src/gallium/drivers/swr/Makefile.am 
> b/src/gallium/drivers/swr/Makefile.am
> index 8151e4a..63dadbf 100644
> --- a/src/gallium/drivers/swr/Makefile.am
> +++ b/src/gallium/drivers/swr/Makefile.am
> @@ -52,8 +52,6 @@ BUILT_SOURCES = \
>   rasterizer/scripts/gen_knobs.cpp \
>   rasterizer/scripts/gen_knobs.h \
>   rasterizer/jitter/state_llvm.h \
> - rasterizer/jitter/builder_gen.h \
> - rasterizer/jitter/builder_gen.cpp \
>   rasterizer/jitter/builder_x86.h \
>   rasterizer/jitter/builder_x86.cpp
> 
> @@ -122,6 +120,23 @@ COMMON_LDFLAGS = \
>   $(NO_UNDEFINED) \
>   $(LLVM_LDFLAGS)
> 
> +
> +# XXX: As we cannot use BUILT_SOURCES (the files will end up in the dist
> +# tarball) just annotate the dependency directly.
> +# As the single direct user of builder_gen.h is a header (builder.h) trace 
> all
> +# the translusive users (one that use the latter header).
> +#
> +# Note: one should really clean the includes a bit, according to Tim there's
> +# only 4 users of the builder_gen methods/API.
> +rasterizer/jitter/blend_jit.cpp: rasterizer/jitter/builder_gen.h
> +rasterizer/jitter/builder.cpp: rasterizer/jitter/builder_gen.h
> +rasterizer/jitter/builder_gen.cpp: rasterizer/jitter/builder_gen.h
> +rasterizer/jitter/builder_x86.cpp: rasterizer/jitter/builder_gen.h
> +rasterizer/jitter/builder_misc.cpp: rasterizer/jitter/builder_gen.h
> +rasterizer/jitter/fetch_jit.cpp: rasterizer/jitter/builder_gen.h
> +rasterizer/jitter/streamout_jit.cpp: rasterizer/jitter/builder_gen.h
> +swr_shader.cpp: rasterizer/jitter/builder_gen.h
> +
> lib_LTLIBRARIES = libswrAVX.la libswrAVX2.la
> 
> libswrAVX_la_CXXFLAGS = \
> @@ -132,6 +147,15 @@ libswrAVX_la_CXXFLAGS = \
> libswrAVX_la_SOURCES = \
>   $(COMMON_SOURCES)
> 
> +# XXX: Don't ship these generated sources for now, since they are specific
> +# to the LLVM version they are generated from. Thus a release tarball
> +# containing the said files, generated against eg. LLVM 3.8 will fail to 
> build
> +# on systems with other versions of LLVM eg. 3.7 or 3.6.
> +# Move these back to BUILT_SOURCES once that is resolved.
> +nodist_libswrAVX_la_SOURCES = \
> + rasterizer/jitter/builder_gen.h \
> + rasterizer/jitter/builder_gen.cpp
> +
> libswrAVX_la_LIBADD = \
>   $(COMMON_LIBADD)
> 
> @@ -146,6 +170,15 @@ libswrAVX2_la_CXXFLAGS = \
> libswrAVX2_la_SOURCES = \
>   $(COMMON_SOURCES)
> 
> +# XXX: Don't ship these generated sources for now, since they are specific
> +# to the LLVM version they are generated from. Thus a release tarball
> +# containing the said files, generated against eg. LLVM 3.8 will fail to 
> build
> +# on systems with other versions of LLVM eg. 3.7 or 3.6.
> +# Move these back to BUILT_SOURCES once that is resolved.
> +nodist_libswrAVX2_la_SOURCES = \
> + rasterizer/jitter/builder_gen.h \
> + rasterizer/jitter/builder_gen.cpp
> +
> libswrAVX2_la_LIBADD = \
>   $(COMMON_LIBADD)
> 
> -- 
> 2.8.2
> 

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


Re: [Mesa-dev] [PATCH] mesa/glsl: stop using GL shader type internally

2016-06-13 Thread Timothy Arceri
Ping.

On Sun, 2016-06-05 at 13:17 +1000, Timothy Arceri wrote:
> Instead use the internal gl_shader_stage enum everywhere. This
> makes things more consistent and gets rid of unnecessary
> conversions.
> Ideally it would be nice to remove the Type field from gl_shader
> altogether but currently it is used to differentiate between
> gl_shader and gl_shader_program in the ShaderObjects hash table.
> ---
>  src/compiler/glsl/builtin_functions.cpp  |  2 +-
>  src/compiler/glsl/link_varyings.cpp  |  2 +-
>  src/compiler/glsl/linker.cpp |  2 +-
>  src/compiler/glsl/standalone.cpp |  2 +-
>  src/compiler/glsl/standalone_scaffolding.cpp |  7 +++
>  src/compiler/glsl/standalone_scaffolding.h   |  2 +-
>  src/mesa/drivers/common/meta.c   | 12 +--
>  src/mesa/drivers/common/meta.h   |  5 -
>  src/mesa/drivers/dri/i965/brw_link.cpp   |  5 ++---
>  src/mesa/drivers/dri/i965/brw_shader.h   |  3 ++-
>  src/mesa/main/dd.h   |  2 +-
>  src/mesa/main/ff_fragment_shader.cpp |  2 +-
>  src/mesa/main/shaderapi.c| 20 ++--
> ---
>  src/mesa/main/shaderobj.c|  6 ++
>  src/mesa/state_tracker/st_glsl_to_nir.cpp|  6 +++---
>  src/mesa/state_tracker/st_glsl_to_tgsi.cpp   | 30 ++--
> 
>  16 files changed, 51 insertions(+), 57 deletions(-)
> 
> diff --git a/src/compiler/glsl/builtin_functions.cpp
> b/src/compiler/glsl/builtin_functions.cpp
> index edd02bb..87d22e6 100644
> --- a/src/compiler/glsl/builtin_functions.cpp
> +++ b/src/compiler/glsl/builtin_functions.cpp
> @@ -948,7 +948,7 @@ builtin_builder::create_shader()
>  * GLSL utility code that could be linked against any stage, so
> just
>  * arbitrarily pick GL_VERTEX_SHADER.
>  */
> -   shader = _mesa_new_shader(NULL, 0, GL_VERTEX_SHADER);
> +   shader = _mesa_new_shader(NULL, 0, MESA_SHADER_VERTEX);
> shader->symbols = new(mem_ctx) glsl_symbol_table;
>  
> gl_ModelViewProjectionMatrix =
> diff --git a/src/compiler/glsl/link_varyings.cpp
> b/src/compiler/glsl/link_varyings.cpp
> index a286e77..2ff7d80 100644
> --- a/src/compiler/glsl/link_varyings.cpp
> +++ b/src/compiler/glsl/link_varyings.cpp
> @@ -2111,7 +2111,7 @@ assign_varying_locations(struct gl_context
> *ctx,
>    * within a patch and can be used as shared memory.
>    */
>   if (input_var || (prog->SeparateShader && consumer == NULL)
> ||
> - producer->Type == GL_TESS_CONTROL_SHADER) {
> + producer->Stage == MESA_SHADER_TESS_CTRL) {
>  matches.record(output_var, input_var);
>   }
>  
> diff --git a/src/compiler/glsl/linker.cpp
> b/src/compiler/glsl/linker.cpp
> index 43719f4..e0e09e9 100644
> --- a/src/compiler/glsl/linker.cpp
> +++ b/src/compiler/glsl/linker.cpp
> @@ -2237,7 +2237,7 @@ link_intrastage_shaders(void *mem_ctx,
>    return NULL;
> }
>  
> -   gl_shader *linked = ctx->Driver.NewShader(NULL, 0, main->Type);
> +   gl_shader *linked = ctx->Driver.NewShader(NULL, 0,
> shader_list[0]->Stage);
> linked->ir = new(linked) exec_list;
> clone_ir_list(mem_ctx, linked->ir, main->ir);
>  
> diff --git a/src/compiler/glsl/standalone.cpp
> b/src/compiler/glsl/standalone.cpp
> index c3afbc3..9b77b3a 100644
> --- a/src/compiler/glsl/standalone.cpp
> +++ b/src/compiler/glsl/standalone.cpp
> @@ -419,7 +419,7 @@ standalone_compile_shader(const struct
> standalone_options *_options,
>  continue;
>  
>   shader->Program = rzalloc(shader, gl_program);
> - init_gl_program(shader->Program, shader->Type);
> + init_gl_program(shader->Program, shader->Stage);
>    }
> }
>  
> diff --git a/src/compiler/glsl/standalone_scaffolding.cpp
> b/src/compiler/glsl/standalone_scaffolding.cpp
> index e7f6555..94938ef 100644
> --- a/src/compiler/glsl/standalone_scaffolding.cpp
> +++ b/src/compiler/glsl/standalone_scaffolding.cpp
> @@ -76,17 +76,16 @@ _mesa_shader_debug(struct gl_context *, GLenum,
> GLuint *,
>  }
>  
>  struct gl_shader *
> -_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type)
> +_mesa_new_shader(struct gl_context *ctx, GLuint name,
> gl_shader_stage stage)
>  {
> struct gl_shader *shader;
>  
> (void) ctx;
>  
> -   assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER);
> +   assert(stage == MESA_SHADER_FRAGMENT || stage ==
> MESA_SHADER_VERTEX);
> shader = rzalloc(NULL, struct gl_shader);
> if (shader) {
> -  shader->Type = type;
> -  shader->Stage = _mesa_shader_enum_to_shader_stage(type);
> +  shader->Stage = stage;
>    shader->Name = name;
>    shader->RefCount = 1;
> }
> diff --git a/src/compiler/glsl/standalone_scaffolding.h
> b/src/compiler/glsl/standalone_scaffolding.h
> index 6cef784..cfac883 100644
> --- a/src/compiler/glsl/standalone_scaffolding.h
> +++ b/src/compiler/glsl/standalone_scaffolding.h
> @@ -47,7 

[Mesa-dev] [PATCH] glsl: make sure UBO arrays are sized in ES

2016-06-13 Thread Timothy Arceri
This check was removed in 5b2675093e86 add it back in.

Cc: Dave Airlie 
https://bugs.freedesktop.org/show_bug.cgi?id=96349
---
 src/compiler/glsl/ast_to_hir.cpp | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index 3d34ecf..551d004 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -7597,6 +7597,20 @@ ast_interface_block::hir(exec_list *instructions,
if (is_unsized_array_last_element(var)) {
   var->data.from_ssbo_unsized_array = true;
}
+} else {
+   /* From GLSL ES 3.10 spec, section 4.1.9 "Arrays":
+*
+* "If an array is declared as the last member of a shader 
storage
+* block and the size is not specified at compile-time, it is
+* sized at run-time. In all other cases, arrays are sized only
+* at compile-time."
+*/
+   if (state->es_shader) {
+  _mesa_glsl_error(, state, "unsized array `%s' "
+   "definition: only last member of a shader "
+   "storage block can be defined as unsized "
+   "array", fields[i].name);
+   }
 }
  }
 
-- 
2.5.5

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


Re: [Mesa-dev] [PATCH] fixup! genxml: Add enough XML for gens 4, 4.5, and 5 to get SURFACE_STATE

2016-06-13 Thread Mauro Rossi
>The patch that I've sent was a "fixup" (i.e. is to be squashed with
>the commit name that follows). That very same has the headers in the
>Makefiles.sources

Hi, I had missed that src/intel/genxml/Makefile.sources was already OK
in original Jason's patch,
so there's no need for changes there.

Good news and last update for tonight, I found a way to simplify the
generated headers rules
and avoid the warnings about dummy.c recipe.

I did one last desperate try by moving dummy.c generation part after
all .h generated headers rules
and guess what, the warnings disappeared.

Tested and working Ok, please consider that the following is
equivalent to Emil's fixup! patch:


From 83078aa616c429c496b467d23fa2390f1a6008bc Mon Sep 17 00:00:00 2001
From: Mauro Rossi 
Date: Tue, 14 Jun 2016 02:26:30 +0200
Subject: [PATCH] android: genxml: optimize autogenerated headers rules

Simplifications in the rules that generate
gen{*}_pack.h headers in Android builds.
---
 src/intel/genxml/Android.mk | 42 --
 1 file changed, 8 insertions(+), 34 deletions(-)

diff --git a/src/intel/genxml/Android.mk b/src/intel/genxml/Android.mk
index e5b7597..cbae83a 100644
--- a/src/intel/genxml/Android.mk
+++ b/src/intel/genxml/Android.mk
@@ -32,6 +32,14 @@ LOCAL_MODULE_CLASS := STATIC_LIBRARIES

 intermediates := $(call local-generated-sources-dir)

+# This is the list of auto-generated files headers
+LOCAL_GENERATED_SOURCES += $(addprefix $(intermediates)/genxml/,
$(GENXML_GENERATED_FILES))
+
+$(LOCAL_GENERATED_SOURCES): PRIVATE_PYTHON := $(MESA_PYTHON2)
+$(LOCAL_GENERATED_SOURCES): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PYTHON) $^ > $@
+$(LOCAL_GENERATED_SOURCES): $(intermediates)/genxml/%_pack.h:
$(LOCAL_PATH)/gen_pack_header.py $(LOCAL_PATH)/%.xml
+ $(transform-generated-source)
+
 # dummy.c source file is generated to meet the build system's rules.
 LOCAL_GENERATED_SOURCES += $(intermediates)/dummy.c

@@ -40,40 +48,6 @@ $(intermediates)/dummy.c:
  @echo "Gen Dummy: $(PRIVATE_MODULE) <= $(notdir $(@))"
  $(hide) touch $@

-# This is the list of auto-generated files headers
-LOCAL_GENERATED_SOURCES += $(addprefix $(intermediates)/genxml/,
$(GENXML_GENERATED_FILES))
-
-define header-gen
- @mkdir -p $(dir $@)
- @echo "Gen Header: $(PRIVATE_MODULE) <= $(notdir $(@))"
- $(hide) $(PRIVATE_SCRIPT) $(PRIVATE_XML) > $@
-endef
-
-$(intermediates)/genxml/gen6_pack.h: PRIVATE_SCRIPT :=
$(MESA_PYTHON2) $(LOCAL_PATH)/gen_pack_header.py
-$(intermediates)/genxml/gen6_pack.h: PRIVATE_XML := $(LOCAL_PATH)/gen6.xml
-$(intermediates)/genxml/gen6_pack.h: $(LOCAL_PATH)/gen6.xml
$(LOCAL_PATH)/gen_pack_header.py
- $(call header-gen)
-
-$(intermediates)/genxml/gen7_pack.h: PRIVATE_SCRIPT :=
$(MESA_PYTHON2) $(LOCAL_PATH)/gen_pack_header.py
-$(intermediates)/genxml/gen7_pack.h: PRIVATE_XML := $(LOCAL_PATH)/gen7.xml
-$(intermediates)/genxml/gen7_pack.h: $(LOCAL_PATH)/gen7.xml
$(LOCAL_PATH)/gen_pack_header.py
- $(call header-gen)
-
-$(intermediates)/genxml/gen75_pack.h: PRIVATE_SCRIPT :=
$(MESA_PYTHON2) $(LOCAL_PATH)/gen_pack_header.py
-$(intermediates)/genxml/gen75_pack.h: PRIVATE_XML := $(LOCAL_PATH)/gen75.xml
-$(intermediates)/genxml/gen75_pack.h: $(LOCAL_PATH)/gen75.xml
$(LOCAL_PATH)/gen_pack_header.py
- $(call header-gen)
-
-$(intermediates)/genxml/gen8_pack.h: PRIVATE_SCRIPT :=
$(MESA_PYTHON2) $(LOCAL_PATH)/gen_pack_header.py
-$(intermediates)/genxml/gen8_pack.h: PRIVATE_XML := $(LOCAL_PATH)/gen8.xml
-$(intermediates)/genxml/gen8_pack.h: $(LOCAL_PATH)/gen8.xml
$(LOCAL_PATH)/gen_pack_header.py
- $(call header-gen)
-
-$(intermediates)/genxml/gen9_pack.h: PRIVATE_SCRIPT :=
$(MESA_PYTHON2) $(LOCAL_PATH)/gen_pack_header.py
-$(intermediates)/genxml/gen9_pack.h: PRIVATE_XML := $(LOCAL_PATH)/gen9.xml
-$(intermediates)/genxml/gen9_pack.h: $(LOCAL_PATH)/gen9.xml
$(LOCAL_PATH)/gen_pack_header.py
- $(call header-gen)
-
 LOCAL_EXPORT_C_INCLUDE_DIRS := \
  $(MESA_TOP)/src/intel \
  $(intermediates)
-- 
2.7.4
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] clover: fix getting struct args api size

2016-06-13 Thread Francisco Jerez
Serge Martin  writes:

> This fix getting the size of a struct arg. vec3 types still work ok.
> Only buit-in args need to have power of two alignment, getTypeAllocSize
> reports the correct size.
> ---
>  src/gallium/state_trackers/clover/llvm/invocation.cpp | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
> b/src/gallium/state_trackers/clover/llvm/invocation.cpp
> index 03487d6..9af51539 100644
> --- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
> +++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
> @@ -472,7 +472,8 @@ namespace {
>   // aligned to the next larger power of two".  We need this
>   // alignment for three element vectors, which have
>   // non-power-of-2 store size.
> - const unsigned arg_api_size = 
> util_next_power_of_two(arg_store_size);
> + const unsigned arg_api_size = arg_type->isStructTy() ?
> +   arg_store_size : util_next_power_of_two(arg_store_size);
>  
Hm...  Isn't this still going to be broken if you pass a struct argument
to a kernel function and the alignment of any of the struct members
doesn't match the target-specific data layout?  Not sure we can fix this
sensibly without requiring the target's data layout to match the CL API
exactly.  Any suggestions Tom?

>   llvm::Type *target_type = arg_type->isIntegerTy() ?
> TD.getSmallestLegalIntType(mod->getContext(), arg_store_size 
> * 8)
> -- 
> 2.5.5


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


[Mesa-dev] [Bug 96519] radeon r400 GPU locks on ppc64

2016-06-13 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=96519

--- Comment #1 from herminio.hernande...@gmail.com ---
Created attachment 124519
  --> https://bugs.freedesktop.org/attachment.cgi?id=124519=edit
xorg log

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


[Mesa-dev] [Bug 96519] radeon r400 GPU locks on ppc64

2016-06-13 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=96519

Bug ID: 96519
   Summary: radeon r400 GPU locks on ppc64
   Product: Mesa
   Version: 11.0
  Hardware: PowerPC
OS: Linux (All)
Status: NEW
  Severity: normal
  Priority: medium
 Component: Mesa core
  Assignee: mesa-dev@lists.freedesktop.org
  Reporter: herminio.hernande...@gmail.com
QA Contact: mesa-dev@lists.freedesktop.org

Created attachment 124518
  --> https://bugs.freedesktop.org/attachment.cgi?id=124518=edit
dmesg

I have Gentoo Linux install on my PowerMac G5 7,2. I noticed that the GPU was
locking up afer boot even with radeon.agpmode=-1 being set. To mitigate this I
turned off acceleration on my xorg.conf file and I can now load XFCE. I am
attaching the dmesg and Xorg.0.log file.

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


[Mesa-dev] [Bug 96516] [bisected: 482526] "clover: Update OpenCL version string to match OpenGL": clover's build fails because of missing git_sha1.h

2016-06-13 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=96516

--- Comment #2 from Emil Velikov  ---
Vedran friendly advice - changing assignee to yourself, limits notifications to
others as the bug evolves. Some people just state that they're working on it,
without changing the status. Feel free to proceed as you wish.

Alexandre, I take it that things were working just before that patch ? Are you
using git checkouts, git archive or any other means to get (and build) mesa ?

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


[Mesa-dev] [Bug 96516] [bisected: 482526] "clover: Update OpenCL version string to match OpenGL": clover's build fails because of missing git_sha1.h

2016-06-13 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=96516

Vedran Miletić  changed:

   What|Removed |Added

   Assignee|mesa-dev@lists.freedesktop. |ved...@miletic.net
   |org |

--- Comment #1 from Vedran Miletić  ---
I am not very familiar with Mesa's build system, but will try to reproduce and
fix this.

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


[Mesa-dev] [Bug 96518] [llvmpipe] piglit linestipple regression

2016-06-13 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=96518

Bug ID: 96518
   Summary: [llvmpipe] piglit linestipple regression
   Product: Mesa
   Version: git
  Hardware: x86-64 (AMD64)
OS: Linux (All)
Status: NEW
  Keywords: bisected, regression
  Severity: normal
  Priority: medium
 Component: Mesa core
  Assignee: mesa-dev@lists.freedesktop.org
  Reporter: v...@freedesktop.org
QA Contact: mesa-dev@lists.freedesktop.org
CC: jfons...@vmware.com, srol...@vmware.com

mesa: 4825264f75c83576f251290547f121f066b46a70 (master 12.1.0-devel)

$ ./bin/linestipple -auto
Testing Baseline:
PIGLIT: {"subtest": {"Baseline" : "pass"}}
Testing Restarting lines within a single Begin-End block:
PIGLIT: {"subtest": {"Restarting lines within a single Begin-End block" :
"pass"}}
Testing Line strip:
Probe color at (34,20)
  Expected: 0.00 0.00 0.00
  Observed: 1.00 1.00 0.00
PIGLIT: {"subtest": {"Line strip" : "fail"}}
Testing Line loop:
PIGLIT: {"subtest": {"Line loop" : "pass"}}
Testing Factor 2x:
PIGLIT: {"subtest": {"Factor 2x" : "pass"}}
Testing Factor 3x:
PIGLIT: {"subtest": {"Factor 3x" : "pass"}}
PIGLIT: {"result": "fail" }


320d1191c61a0a82444605c12e5c4b2ee0b241eb is the first bad commit
commit 320d1191c61a0a82444605c12e5c4b2ee0b241eb
Author: Jose Fonseca 
Date:   Mon Apr 4 00:05:33 2016 +0100

gallivm: Use llvm.fmuladd.*.

Reviewed-by: Roland Scheidegger 

:04 04 31dca10c80a2741d596cb6d81cd6015e1312dc2e
e24948d177adab4b2fc35cd186d8dbffec3f3a0d M  src
bisect run success

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


[Mesa-dev] [Bug 96517] [llvmpipe] piglit arb_uniform_buffer_object-rendering-dsa regression

2016-06-13 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=96517

--- Comment #4 from Ilia Mirkin  ---
\(In reply to Roland Scheidegger from comment #2)
> (In reply to Ilia Mirkin from comment #1)
> > This is a llvmpipe bug, see discussion starting with
> > 
> > https://lists.freedesktop.org/archives/mesa-dev/2016-June/119829.html
> 
> Well technically it's not a llvmpipe bug since the state tracker violates
> the bind flag contract. Albeit that might be hair splitting since the state

Right, all the other driver backends cope with the reality that
pipe_resource->bind is only there to lull the backend author into a false sense
of comfort, while llvmpipe drank the blue pill :)

In any case, my change is not wrong, it merely stopped dirtying constbufs when
they weren't dirty. There were plenty of ways to hit this issue without my
change. In this case, dirtying array buffers (with piglit_draw_rect) caused the
constbufs to also be marked dirty, which happened to work out in this case.

-- 
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
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2] swr: automake: don't ship LLVM version specific generated sources

2016-06-13 Thread Emil Velikov
From: Emil Velikov 

Otherwise things will fail to build, if the builder is using another
version of LLVM.

v2: annotate all the dependencies of builder_gen.h

Cc: "12.0" 
Cc: Tim Rowley 
Cc: Chuck Atkins 
Reported-by: Chuck Atkins 
Signed-off-by: Emil Velikov 
---
Unlike v1, this ones seems to work. Please give it a try and let me know
how it fares on your end.

Thanks
Emil
---
 src/gallium/drivers/swr/Makefile.am | 37 +++--
 1 file changed, 35 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/swr/Makefile.am 
b/src/gallium/drivers/swr/Makefile.am
index 8151e4a..63dadbf 100644
--- a/src/gallium/drivers/swr/Makefile.am
+++ b/src/gallium/drivers/swr/Makefile.am
@@ -52,8 +52,6 @@ BUILT_SOURCES = \
rasterizer/scripts/gen_knobs.cpp \
rasterizer/scripts/gen_knobs.h \
rasterizer/jitter/state_llvm.h \
-   rasterizer/jitter/builder_gen.h \
-   rasterizer/jitter/builder_gen.cpp \
rasterizer/jitter/builder_x86.h \
rasterizer/jitter/builder_x86.cpp
 
@@ -122,6 +120,23 @@ COMMON_LDFLAGS = \
$(NO_UNDEFINED) \
$(LLVM_LDFLAGS)
 
+
+# XXX: As we cannot use BUILT_SOURCES (the files will end up in the dist
+# tarball) just annotate the dependency directly.
+# As the single direct user of builder_gen.h is a header (builder.h) trace all
+# the translusive users (one that use the latter header).
+#
+# Note: one should really clean the includes a bit, according to Tim there's
+# only 4 users of the builder_gen methods/API.
+rasterizer/jitter/blend_jit.cpp: rasterizer/jitter/builder_gen.h
+rasterizer/jitter/builder.cpp: rasterizer/jitter/builder_gen.h
+rasterizer/jitter/builder_gen.cpp: rasterizer/jitter/builder_gen.h
+rasterizer/jitter/builder_x86.cpp: rasterizer/jitter/builder_gen.h
+rasterizer/jitter/builder_misc.cpp: rasterizer/jitter/builder_gen.h
+rasterizer/jitter/fetch_jit.cpp: rasterizer/jitter/builder_gen.h
+rasterizer/jitter/streamout_jit.cpp: rasterizer/jitter/builder_gen.h
+swr_shader.cpp: rasterizer/jitter/builder_gen.h
+
 lib_LTLIBRARIES = libswrAVX.la libswrAVX2.la
 
 libswrAVX_la_CXXFLAGS = \
@@ -132,6 +147,15 @@ libswrAVX_la_CXXFLAGS = \
 libswrAVX_la_SOURCES = \
$(COMMON_SOURCES)
 
+# XXX: Don't ship these generated sources for now, since they are specific
+# to the LLVM version they are generated from. Thus a release tarball
+# containing the said files, generated against eg. LLVM 3.8 will fail to build
+# on systems with other versions of LLVM eg. 3.7 or 3.6.
+# Move these back to BUILT_SOURCES once that is resolved.
+nodist_libswrAVX_la_SOURCES = \
+   rasterizer/jitter/builder_gen.h \
+   rasterizer/jitter/builder_gen.cpp
+
 libswrAVX_la_LIBADD = \
$(COMMON_LIBADD)
 
@@ -146,6 +170,15 @@ libswrAVX2_la_CXXFLAGS = \
 libswrAVX2_la_SOURCES = \
$(COMMON_SOURCES)
 
+# XXX: Don't ship these generated sources for now, since they are specific
+# to the LLVM version they are generated from. Thus a release tarball
+# containing the said files, generated against eg. LLVM 3.8 will fail to build
+# on systems with other versions of LLVM eg. 3.7 or 3.6.
+# Move these back to BUILT_SOURCES once that is resolved.
+nodist_libswrAVX2_la_SOURCES = \
+   rasterizer/jitter/builder_gen.h \
+   rasterizer/jitter/builder_gen.cpp
+
 libswrAVX2_la_LIBADD = \
$(COMMON_LIBADD)
 
-- 
2.8.2

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


[Mesa-dev] [Bug 96517] [llvmpipe] piglit arb_uniform_buffer_object-rendering-dsa regression

2016-06-13 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=96517

--- Comment #3 from Roland Scheidegger  ---
(In reply to Roland Scheidegger from comment #2)
> tracker never did and other state trackers have to cope with it too.
Sorry, that should have been drivers here.

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


[Mesa-dev] [Bug 96517] [llvmpipe] piglit arb_uniform_buffer_object-rendering-dsa regression

2016-06-13 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=96517

--- Comment #2 from Roland Scheidegger  ---
(In reply to Ilia Mirkin from comment #1)
> This is a llvmpipe bug, see discussion starting with
> 
> https://lists.freedesktop.org/archives/mesa-dev/2016-June/119829.html

Well technically it's not a llvmpipe bug since the state tracker violates the
bind flag contract. Albeit that might be hair splitting since the state tracker
never did and other state trackers have to cope with it too.
In any case, a fix (more a workaround) is proposed here:
https://lists.freedesktop.org/archives/mesa-dev/2016-June/120299.html

-- 
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
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] fixup! genxml: Add enough XML for gens 4, 4.5, and 5 to get SURFACE_STATE

2016-06-13 Thread Mauro Rossi
> Jason, feel free to pick whichever patch you like - the annoyingly
> verbose from me or the shorter (en route to victory) from Mauro.
>
> -Emil

Hi, just one final warning my condensed PATCH 1/2 works, but I just
noticed now that it produces the following Warnings

including ./external/mesa/Android.mk ...
external/mesa/src/intel/genxml/Android.mk:48: target
'out/target/product/x86/gen/STATIC_LIBRARIES/libmesa_genxml_intermediates/dummy.c'
doesn't match the target pattern
external/mesa/src/intel/genxml/Android.mk:49: warning: overriding
recipe for target
'out/target/product/x86/gen/STATIC_LIBRARIES/libmesa_genxml_intermediates/dummy.c'
external/mesa/src/intel/genxml/Android.mk:39: warning: ignoring old
recipe for target
'out/target/product/x86/gen/STATIC_LIBRARIES/libmesa_genxml_intermediates/dummy.c'

The thing is that I don't know how to remove those warnings, because
if I remove the rules for dummy.c generation
I just get the building errors of missing gen*pack.h headers.

This Android build system is really a beast with headers only projects
like genxml

If you know how to avoid those warnings do as you may, if not It is
better to stick to Emil fixup! patch that was already resolving and
without warnings.

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


[Mesa-dev] [Bug 96517] [llvmpipe] piglit arb_uniform_buffer_object-rendering-dsa regression

2016-06-13 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=96517

Ilia Mirkin  changed:

   What|Removed |Added

 CC|imir...@alum.mit.edu|

--- Comment #1 from Ilia Mirkin  ---
This is a llvmpipe bug, see discussion starting with

https://lists.freedesktop.org/archives/mesa-dev/2016-June/119829.html

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


[Mesa-dev] [Bug 96517] [llvmpipe] piglit arb_uniform_buffer_object-rendering-dsa regression

2016-06-13 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=96517

Bug ID: 96517
   Summary: [llvmpipe] piglit
arb_uniform_buffer_object-rendering-dsa regression
   Product: Mesa
   Version: git
  Hardware: x86-64 (AMD64)
OS: Linux (All)
Status: NEW
  Keywords: bisected, regression
  Severity: normal
  Priority: medium
 Component: Mesa core
  Assignee: mesa-dev@lists.freedesktop.org
  Reporter: v...@freedesktop.org
QA Contact: mesa-dev@lists.freedesktop.org
CC: imir...@alum.mit.edu, prefe...@gmx.net

mesa: 4825264f75c83576f251290547f121f066b46a70 (master 12.1.0-devel)


$ ./bin/arb_uniform_buffer_object-rendering-dsa -auto
GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT = 16
UBO ub_pos_size: index = 1, size = 16
UBO ub_color: index = 2, size = 32
UBO ub_rot: index = 0, size = 16
Probe color at (120,40)
  Expected: 0.00 1.00 0.00 0.25
  Observed: 1.00 0.00 0.00 0.501961
Probe color at (40,120)
  Expected: 0.00 0.00 1.00 0.20
  Observed: 1.00 0.00 0.00 0.501961
Probe color at (120,120)
  Expected: 1.00 1.00 1.00 1.00
  Observed: 1.00 0.00 0.00 0.501961
PIGLIT: {"result": "fail" }


6e6fd911da8a1d9cd62fe0a8a4cc0fb7bdccfe02 is the first bad commit
commit 6e6fd911da8a1d9cd62fe0a8a4cc0fb7bdccfe02
Author: Ilia Mirkin 
Date:   Sat Jun 4 13:26:46 2016 -0400

st/mesa: use buffer usage history to set dirty flags for revalidation

We were previously unconditionally doing this for arrays and ubo's, and
ignoring texture/storage/atomic buffers. Instead use the usage history
to determine which atoms need to be revalidated.

Signed-off-by: Ilia Mirkin 
Reviewed-by: Nicolai Hähnle 
Cc: "12.0" 

:04 04 8376e8592f88901d5100ed9cea8ee9d38162bbca
09bc7466f259ab6c0094f1368660f6b9ef25c481 M  src
bisect run success

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


[Mesa-dev] [Bug 96516] [bisected: 482526] "clover: Update OpenCL version string to match OpenGL": clover's build fails because of missing git_sha1.h

2016-06-13 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=96516

Bug ID: 96516
   Summary: [bisected: 482526] "clover: Update OpenCL version
string to match OpenGL": clover's build fails because
of missing git_sha1.h
   Product: Mesa
   Version: git
  Hardware: Other
OS: All
Status: NEW
  Severity: normal
  Priority: medium
 Component: Other
  Assignee: mesa-dev@lists.freedesktop.org
  Reporter: alexandre.f.dem...@gmail.com
QA Contact: mesa-dev@lists.freedesktop.org

git_sha1.h is missing when clover's build is being called. git_sha1.h is either
not built yet or the dependency it is looking for is at the wrong place.

You may need to git clean first to reproduce this, otherwise it may work with a
previously generated git_sha1.h.

---
../../../../.././src/gallium/state_trackers/clover/api/platform.cpp:25:22:
fatal error: git_sha1.h: No such file or directory
 #include "git_sha1.h"
  ^
compilation terminated.
Makefile:932: recipe for target 'api/libclover_la-platform.lo' failed
make[4]: *** [api/libclover_la-platform.lo] Error 1
---

First bad commit

clover: Update OpenCL version string to match OpenGL
Committer Francisco Jerez
Author Vedran Miletić
Author date 16-06-06 06:43
Parent i965/fs: Fix regs_written for SIMD-lowered instructions s...

clover: Update OpenCL version string to match OpenGL

Change MESA into Mesa in CL_PLATFORM_VERSION and CL_DEVICE_VERSION. For
both, always append git version suffix from git_sha1.h.

v5: move semicolon to same line as MESA_GIT_SHA1.
v4: drop #ifdef guards.
v3: add missing include.
v2: change CL_DEVICE_VERSION as well.

Cc: 
Reviewed-by: Francisco Jerez 

-- 
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
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 96516] [bisected: 482526] "clover: Update OpenCL version string to match OpenGL": clover's build fails because of missing git_sha1.h

2016-06-13 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=96516

Alexandre Demers  changed:

   What|Removed |Added

 CC||curroje...@riseup.net,
   ||ved...@miletic.net

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


Re: [Mesa-dev] [PATCH] fixup! genxml: Add enough XML for gens 4, 4.5, and 5 to get SURFACE_STATE

2016-06-13 Thread Emil Velikov
Hi Mauro,

On 13 June 2016 at 23:15, Mauro Rossi  wrote:
> Hi Jason, Emil,
>
> Jason patch  equires additional changes to correctly complete the
> builld as the new generated headers gen{4,45,5}_pack.h need also to be
> added to src/intel/Makefile.sources in GENXML_GENERATED_FILES variable
>
The patch that I've sent was a "fixup" (i.e. is to be squashed with
the commit name that follows). That very same has the headers in the
Makefiles.sources

> I've not been able to explore the reuse if autoconf rules, because it
> is a task too complex for me,
> but I've found a way to reduce the complexity in genxml Android.mk by
> using wildcards and $(call transform-generated-source) macro like in
> src/mesa/util Android.mk makefile.
>
> Emil, when you talk about reusing autoconf rules, do you mean to use
> androgenizer (from collabora?) as a mean to generate the Android.mk
> (on the fly)?
>
Last time I've tried that androgenizer wasn't worth it for a couple of reasons:
 - one needs to explicitly run ./autogen.sh && make android (iirc) to
generate the android makefiles
 - but most importantly, all the difference(s) between android and
autoconf had to be moved in the Makefile.am

What I'm saying is that there's not need for all the Android abstraction imho.

1) Take the newly (reduced) hunk

$(LOCAL_GENERATED_SOURCES): PRIVATE_PYTHON := $(MESA_PYTHON2)
$(LOCAL_GENERATED_SOURCES): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PYTHON) $^ > $@
$(LOCAL_GENERATED_SOURCES): $(intermediates)/genxml/%_pack.h:
$(LOCAL_PATH)/gen_pack_header.py $(LOCAL_PATH)/%.xml
   $(transform-generated-source)

2) Strip out all the Androidisms and you'll get something like:

$(LOCAL_GENERATED_SOURCES): $(intermediates)/genxml/%_pack.h:
$(LOCAL_PATH)/gen_pack_header.py $(LOCAL_PATH)/%.xml
  $(MESA_PYTHON2) $^ > $@

3) Now if we assume that Android hasn't borken SUFFIX rules, that could become

SUFFIXES = _pack.h .xml

$(LOCAL_GENERATED_SOURCES): $(LOCAL_PATH)/gen_pack_header.py
.xml_pack.h:
$(MESA_PYTHON2) $(LOCAL_PATH)/gen_pack_header.py $< > $@

4) and a similar looking autoconf one

SUFFIXES = _pack.h .xml

$(BUILT_SOURCES): gen_pack_header.py
.xml_pack.h:
   $(PYTHON_GEN) $(srcdir)/gen_pack_header.py $< > $@

Step 5 and onwards entails expanding (add srcdir for both
gen_pack_header.py) and moving the autoconf one to another file (might
need to prefix gen_pack_header.py. And finally doing flexing the
android and autoconf variables (PYTHON_GEN := MESA_PYTHON2 and/or
alike) and including the rule file into the android build.

Note: most of the above is approximation, but should serve as nice
guide what I have in mind.

Please don't worry to much if you cannot test on autoconf side of
things. Just post some patch(es) once things are working on Android
side.

> In the meantime this is what I can provide now.
> Emil fixup! can be skipped and, as a proposal, can be replaced by the
> following two addendum patches to Jason's
>
> The first was tested and build was completed correctly, for the second
> it should be ok, but please review them.
> KR
>
Jason, feel free to pick whichever patch you like - the annoyingly
verbose from me or the shorter (en route to victory) from Mauro.

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


Re: [Mesa-dev] [PATCH] mesa: Make TexSubImage check negative dimensions sooner.

2016-06-13 Thread Kenneth Graunke
On Wednesday, June 8, 2016 4:57:14 PM PDT Patrick Baggett wrote:
> Sorry, didn't CC mesa-dev, trying again...
> 
> On Wed, Jun 8, 2016 at 4:11 PM, Kenneth Graunke  wrote:
> > Two dEQP tests expect INVALID_VALUE errors for negative width/height
> > parameters, but get INVALID_OPERATION because they haven't actually
> > created a destination image.  This is arguably not a bug in Mesa, as
> > there's no specified ordering of error conditions.
> >
> > However, it's also really easy to make the tests pass, and there's
> > no real harm in doing these checks earlier.
> >
> > Fixes:
> > dEQP-GLES3.functional.negative_api.texture.texsubimage3d_neg_width_height
> > dEQP-GLES31.functional.debug.negative_coverage.get_error.texture.texsubimage3d_neg_width_height
> >
> > Signed-off-by: Kenneth Graunke 
> > ---
> >  src/mesa/main/teximage.c | 68 
> > ++--
> >  1 file changed, 49 insertions(+), 19 deletions(-)
> >
> > diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
> > index 58b7f27..d4f8278 100644
> > --- a/src/mesa/main/teximage.c
> > +++ b/src/mesa/main/teximage.c
> > @@ -1102,6 +1102,32 @@ _mesa_legal_texture_dimensions(struct gl_context 
> > *ctx, GLenum target,
> > }
> >  }
> >
> > +static bool
> > +error_check_subtexture_negative_dimensions(struct gl_context *ctx,
> > +   GLuint dims,
> > +   GLsizei subWidth,
> > +   GLsizei subHeight,
> > +   GLsizei subDepth,
> > +   const char *func)
> > +{
> > +   /* Check size */
> > +   if (subWidth < 0) {
> > +  _mesa_error(ctx, GL_INVALID_VALUE, "%s(width=%d)", func, subWidth);
> > +  return true;
> > +   }
> > +
> > +   if (dims > 1 && subHeight < 0) {
> > +  _mesa_error(ctx, GL_INVALID_VALUE, "%s(height=%d)", func, subHeight);
> > +  return true;
> > +   }
> > +
> > +   if (dims > 2 && subDepth < 0) {
> > +  _mesa_error(ctx, GL_INVALID_VALUE, "%s(depth=%d)", func, subDepth);
> > +  return true;
> > +   }
> > +
> 
> What do you think of a structure like:
> 
> switch(dims) {
> case 3:
> if(subDepth < 0) {
> ...
> }
> /* fall through */
> case 2:
> if(subHeight < 0) {
> ...
> }
>/* fall through *
> default:
> if(subWidth < 0) {
> ...
> }
> }
> return true;
> 
> I think this would reduce the overall number of expressions to check.

This seems like a reasonable plan.  If you'd like to send a patch to do
this, I'd be happy to review and commit it for you.

> If you just want to check whether any are < 0, you can OR the sign
> bits:
> 
> 
> int result = 0;
> switch(dims) {
> case 3: result |= subDepth & (1 << 31);
> case 2: result |= subHeight & (1 << 31);
> default: result |= subWidth & (1 << 31);
> }
> return (bool)(result>>31);
> 
> ...then later call that function to generate a more detailed error
> message about specifically which dimension was negative.

That probably is cheaper :)  Frankly, I'm not sure how useful it is to
specifically call out negative width vs. height vs. depth in an error
message.  In other words, we could probably just check this, and then
make the error message "width, height, or depth are negative" or
"subregion has negative dimensions" or such.

I'm happy to review a patch to do that as well.


signature.asc
Description: This is a digitally signed message part.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] mesa: Make TexSubImage check negative dimensions sooner.

2016-06-13 Thread Anuj Phogat
On Mon, Jun 13, 2016 at 3:25 PM, Kenneth Graunke  wrote:
> On Monday, June 13, 2016 2:19:36 PM PDT Anuj Phogat wrote:
>> On Wed, Jun 8, 2016 at 2:11 PM, Kenneth Graunke  
>> wrote:
>> > Two dEQP tests expect INVALID_VALUE errors for negative width/height
>> > parameters, but get INVALID_OPERATION because they haven't actually
>> > created a destination image.  This is arguably not a bug in Mesa, as
>> > there's no specified ordering of error conditions.
>> >
>> > However, it's also really easy to make the tests pass, and there's
>> > no real harm in doing these checks earlier.
>> >
>> > Fixes:
>> > dEQP-GLES3.functional.negative_api.texture.texsubimage3d_neg_width_height
>> > dEQP-GLES31.functional.debug.negative_coverage.get_error.texture.texsubimage3d_neg_width_height
>> >
>> > Signed-off-by: Kenneth Graunke 
>> > ---
>> >  src/mesa/main/teximage.c | 68 
>> > ++--
>> >  1 file changed, 49 insertions(+), 19 deletions(-)
>> >
>> > diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
>> > index 58b7f27..d4f8278 100644
>> > --- a/src/mesa/main/teximage.c
>> > +++ b/src/mesa/main/teximage.c
>> > @@ -1102,6 +1102,32 @@ _mesa_legal_texture_dimensions(struct gl_context 
>> > *ctx, GLenum target,
>> > }
>> >  }
>> >
>> > +static bool
>> > +error_check_subtexture_negative_dimensions(struct gl_context *ctx,
>> > +   GLuint dims,
>> > +   GLsizei subWidth,
>> > +   GLsizei subHeight,
>> > +   GLsizei subDepth,
>> > +   const char *func)
>> > +{
>> > +   /* Check size */
>> > +   if (subWidth < 0) {
>> > +  _mesa_error(ctx, GL_INVALID_VALUE, "%s(width=%d)", func, subWidth);
>> > +  return true;
>> > +   }
>> > +
>> > +   if (dims > 1 && subHeight < 0) {
>> > +  _mesa_error(ctx, GL_INVALID_VALUE, "%s(height=%d)", func, 
>> > subHeight);
>> > +  return true;
>> > +   }
>> > +
>> > +   if (dims > 2 && subDepth < 0) {
>> > +  _mesa_error(ctx, GL_INVALID_VALUE, "%s(depth=%d)", func, subDepth);
>> > +  return true;
>> > +   }
>> > +
>> > +   return false;
>> > +}
>> >
>> >  /**
>> >   * Do error checking of xoffset, yoffset, zoffset, width, height and depth
>> > @@ -1119,25 +1145,6 @@ error_check_subtexture_dimensions(struct gl_context 
>> > *ctx, GLuint dims,
>> > const GLenum target = destImage->TexObject->Target;
>> > GLuint bw, bh, bd;
>> >
>> > -   /* Check size */
>> > -   if (subWidth < 0) {
>> > -  _mesa_error(ctx, GL_INVALID_VALUE,
>> > -  "%s(width=%d)", func, subWidth);
>> > -  return GL_TRUE;
>> > -   }
>> > -
>> > -   if (dims > 1 && subHeight < 0) {
>> > -  _mesa_error(ctx, GL_INVALID_VALUE,
>> > -  "%s(height=%d)", func, subHeight);
>> > -  return GL_TRUE;
>> > -   }
>> > -
>> > -   if (dims > 2 && subDepth < 0) {
>> > -  _mesa_error(ctx, GL_INVALID_VALUE,
>> > -  "%s(depth=%d)", func, subDepth);
>> > -  return GL_TRUE;
>> > -   }
>> > -
>> > /* check xoffset and width */
>> > if (xoffset < - (GLint) destImage->Border) {
>> >_mesa_error(ctx, GL_INVALID_VALUE, "%s(xoffset)", func);
>> > @@ -2104,6 +2111,12 @@ texsubimage_error_check(struct gl_context *ctx, 
>> > GLuint dimensions,
>> >return GL_TRUE;
>> > }
>> >
>> > +   if (error_check_subtexture_negative_dimensions(ctx, dimensions,
>> > +  width, height, depth,
>> > +  callerName)) {
>> > +  return GL_TRUE;
>> > +   }
>> > +
>> > texImage = _mesa_select_tex_image(texObj, target, level);
>> > if (!texImage) {
>> >/* non-existant texture level */
>> > @@ -2140,6 +2153,12 @@ texsubimage_error_check(struct gl_context *ctx, 
>> > GLuint dimensions,
>> >return GL_TRUE;
>> > }
>> >
>> > +   if (error_check_subtexture_negative_dimensions(ctx, dimensions,
>> > +  width, height, depth,
>> > +  callerName)) {
>> > +  return GL_TRUE;
>> > +   }
>> > +
>> It's not obvious why we need to check twice for the negative dimensions
>> in texsubimage_error_check(). Adding a comment here will avoid confusion.
>
> This was a mistake - I accidentally added a second call.  I've dropped
> this copy (the second call) in my local patch.
>
With this call dropped, patch is:
Reviewed-by: Anuj Phogat 

>> > if (error_check_subtexture_dimensions(ctx, dimensions,
>> >   texImage, xoffset, yoffset, 
>> > zoffset,
>> >   width, height, depth, 
>> > callerName)) {
>> > @@ -2497,6 +2516,11 @@ 

Re: [Mesa-dev] [PATCH] mesa: Make TexSubImage check negative dimensions sooner.

2016-06-13 Thread Kenneth Graunke
On Monday, June 13, 2016 2:19:36 PM PDT Anuj Phogat wrote:
> On Wed, Jun 8, 2016 at 2:11 PM, Kenneth Graunke  wrote:
> > Two dEQP tests expect INVALID_VALUE errors for negative width/height
> > parameters, but get INVALID_OPERATION because they haven't actually
> > created a destination image.  This is arguably not a bug in Mesa, as
> > there's no specified ordering of error conditions.
> >
> > However, it's also really easy to make the tests pass, and there's
> > no real harm in doing these checks earlier.
> >
> > Fixes:
> > dEQP-GLES3.functional.negative_api.texture.texsubimage3d_neg_width_height
> > dEQP-GLES31.functional.debug.negative_coverage.get_error.texture.texsubimage3d_neg_width_height
> >
> > Signed-off-by: Kenneth Graunke 
> > ---
> >  src/mesa/main/teximage.c | 68 
> > ++--
> >  1 file changed, 49 insertions(+), 19 deletions(-)
> >
> > diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
> > index 58b7f27..d4f8278 100644
> > --- a/src/mesa/main/teximage.c
> > +++ b/src/mesa/main/teximage.c
> > @@ -1102,6 +1102,32 @@ _mesa_legal_texture_dimensions(struct gl_context 
> > *ctx, GLenum target,
> > }
> >  }
> >
> > +static bool
> > +error_check_subtexture_negative_dimensions(struct gl_context *ctx,
> > +   GLuint dims,
> > +   GLsizei subWidth,
> > +   GLsizei subHeight,
> > +   GLsizei subDepth,
> > +   const char *func)
> > +{
> > +   /* Check size */
> > +   if (subWidth < 0) {
> > +  _mesa_error(ctx, GL_INVALID_VALUE, "%s(width=%d)", func, subWidth);
> > +  return true;
> > +   }
> > +
> > +   if (dims > 1 && subHeight < 0) {
> > +  _mesa_error(ctx, GL_INVALID_VALUE, "%s(height=%d)", func, subHeight);
> > +  return true;
> > +   }
> > +
> > +   if (dims > 2 && subDepth < 0) {
> > +  _mesa_error(ctx, GL_INVALID_VALUE, "%s(depth=%d)", func, subDepth);
> > +  return true;
> > +   }
> > +
> > +   return false;
> > +}
> >
> >  /**
> >   * Do error checking of xoffset, yoffset, zoffset, width, height and depth
> > @@ -1119,25 +1145,6 @@ error_check_subtexture_dimensions(struct gl_context 
> > *ctx, GLuint dims,
> > const GLenum target = destImage->TexObject->Target;
> > GLuint bw, bh, bd;
> >
> > -   /* Check size */
> > -   if (subWidth < 0) {
> > -  _mesa_error(ctx, GL_INVALID_VALUE,
> > -  "%s(width=%d)", func, subWidth);
> > -  return GL_TRUE;
> > -   }
> > -
> > -   if (dims > 1 && subHeight < 0) {
> > -  _mesa_error(ctx, GL_INVALID_VALUE,
> > -  "%s(height=%d)", func, subHeight);
> > -  return GL_TRUE;
> > -   }
> > -
> > -   if (dims > 2 && subDepth < 0) {
> > -  _mesa_error(ctx, GL_INVALID_VALUE,
> > -  "%s(depth=%d)", func, subDepth);
> > -  return GL_TRUE;
> > -   }
> > -
> > /* check xoffset and width */
> > if (xoffset < - (GLint) destImage->Border) {
> >_mesa_error(ctx, GL_INVALID_VALUE, "%s(xoffset)", func);
> > @@ -2104,6 +2111,12 @@ texsubimage_error_check(struct gl_context *ctx, 
> > GLuint dimensions,
> >return GL_TRUE;
> > }
> >
> > +   if (error_check_subtexture_negative_dimensions(ctx, dimensions,
> > +  width, height, depth,
> > +  callerName)) {
> > +  return GL_TRUE;
> > +   }
> > +
> > texImage = _mesa_select_tex_image(texObj, target, level);
> > if (!texImage) {
> >/* non-existant texture level */
> > @@ -2140,6 +2153,12 @@ texsubimage_error_check(struct gl_context *ctx, 
> > GLuint dimensions,
> >return GL_TRUE;
> > }
> >
> > +   if (error_check_subtexture_negative_dimensions(ctx, dimensions,
> > +  width, height, depth,
> > +  callerName)) {
> > +  return GL_TRUE;
> > +   }
> > +
> It's not obvious why we need to check twice for the negative dimensions
> in texsubimage_error_check(). Adding a comment here will avoid confusion.

This was a mistake - I accidentally added a second call.  I've dropped
this copy (the second call) in my local patch.

> > if (error_check_subtexture_dimensions(ctx, dimensions,
> >   texImage, xoffset, yoffset, 
> > zoffset,
> >   width, height, depth, 
> > callerName)) {
> > @@ -2497,6 +2516,11 @@ copytexsubimage_error_check(struct gl_context *ctx, 
> > GLuint dimensions,
> >return GL_TRUE;
> > }
> >
> > +   if (error_check_subtexture_negative_dimensions(ctx, dimensions,
> > +  width, height, 1, 
> > caller)) {
> > +  return GL_TRUE;
> > +   }
> > 

Re: [Mesa-dev] [PATCH] fixup! genxml: Add enough XML for gens 4, 4.5, and 5 to get SURFACE_STATE

2016-06-13 Thread Mauro Rossi
Hi Jason, Emil,

Jason patch  equires additional changes to correctly complete the
builld as the new generated headers gen{4,45,5}_pack.h need also to be
added to src/intel/Makefile.sources in GENXML_GENERATED_FILES variable

I've not been able to explore the reuse if autoconf rules, because it
is a task too complex for me,
but I've found a way to reduce the complexity in genxml Android.mk by
using wildcards and $(call transform-generated-source) macro like in
src/mesa/util Android.mk makefile.

Emil, when you talk about reusing autoconf rules, do you mean to use
androgenizer (from collabora?) as a mean to generate the Android.mk
(on the fly)?

In the meantime this is what I can provide now.
Emil fixup! can be skipped and, as a proposal, can be replaced by the
following two addendum patches to Jason's

The first was tested and build was completed correctly, for the second
it should be ok, but please review them.
KR

Mauro

From 92d78d17e3b99cf7a94e3942788be347bd7dffe6 Mon Sep 17 00:00:00 2001
From: Mauro Rossi 
Date: Mon, 13 Jun 2016 23:50:05 +0200
Subject: [PATCH 1/2] android: genxml: optimize autogenerated headers rules

Simplifications in the rules that generate
gen{*}_pack.h headers in Android builds.
---
 src/intel/genxml/Android.mk | 34 --
 1 file changed, 4 insertions(+), 30 deletions(-)

diff --git a/src/intel/genxml/Android.mk b/src/intel/genxml/Android.mk
index e5b7597..b99a495 100644
--- a/src/intel/genxml/Android.mk
+++ b/src/intel/genxml/Android.mk
@@ -43,36 +43,10 @@ $(intermediates)/dummy.c:
 # This is the list of auto-generated files headers
 LOCAL_GENERATED_SOURCES += $(addprefix $(intermediates)/genxml/,
$(GENXML_GENERATED_FILES))

-define header-gen
- @mkdir -p $(dir $@)
- @echo "Gen Header: $(PRIVATE_MODULE) <= $(notdir $(@))"
- $(hide) $(PRIVATE_SCRIPT) $(PRIVATE_XML) > $@
-endef
-
-$(intermediates)/genxml/gen6_pack.h: PRIVATE_SCRIPT :=
$(MESA_PYTHON2) $(LOCAL_PATH)/gen_pack_header.py
-$(intermediates)/genxml/gen6_pack.h: PRIVATE_XML := $(LOCAL_PATH)/gen6.xml
-$(intermediates)/genxml/gen6_pack.h: $(LOCAL_PATH)/gen6.xml
$(LOCAL_PATH)/gen_pack_header.py
- $(call header-gen)
-
-$(intermediates)/genxml/gen7_pack.h: PRIVATE_SCRIPT :=
$(MESA_PYTHON2) $(LOCAL_PATH)/gen_pack_header.py
-$(intermediates)/genxml/gen7_pack.h: PRIVATE_XML := $(LOCAL_PATH)/gen7.xml
-$(intermediates)/genxml/gen7_pack.h: $(LOCAL_PATH)/gen7.xml
$(LOCAL_PATH)/gen_pack_header.py
- $(call header-gen)
-
-$(intermediates)/genxml/gen75_pack.h: PRIVATE_SCRIPT :=
$(MESA_PYTHON2) $(LOCAL_PATH)/gen_pack_header.py
-$(intermediates)/genxml/gen75_pack.h: PRIVATE_XML := $(LOCAL_PATH)/gen75.xml
-$(intermediates)/genxml/gen75_pack.h: $(LOCAL_PATH)/gen75.xml
$(LOCAL_PATH)/gen_pack_header.py
- $(call header-gen)
-
-$(intermediates)/genxml/gen8_pack.h: PRIVATE_SCRIPT :=
$(MESA_PYTHON2) $(LOCAL_PATH)/gen_pack_header.py
-$(intermediates)/genxml/gen8_pack.h: PRIVATE_XML := $(LOCAL_PATH)/gen8.xml
-$(intermediates)/genxml/gen8_pack.h: $(LOCAL_PATH)/gen8.xml
$(LOCAL_PATH)/gen_pack_header.py
- $(call header-gen)
-
-$(intermediates)/genxml/gen9_pack.h: PRIVATE_SCRIPT :=
$(MESA_PYTHON2) $(LOCAL_PATH)/gen_pack_header.py
-$(intermediates)/genxml/gen9_pack.h: PRIVATE_XML := $(LOCAL_PATH)/gen9.xml
-$(intermediates)/genxml/gen9_pack.h: $(LOCAL_PATH)/gen9.xml
$(LOCAL_PATH)/gen_pack_header.py
- $(call header-gen)
+$(LOCAL_GENERATED_SOURCES): PRIVATE_PYTHON := $(MESA_PYTHON2)
+$(LOCAL_GENERATED_SOURCES): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PYTHON) $^ > $@
+$(LOCAL_GENERATED_SOURCES): $(intermediates)/genxml/%_pack.h:
$(LOCAL_PATH)/gen_pack_header.py $(LOCAL_PATH)/%.xml
+ $(transform-generated-source)

 LOCAL_EXPORT_C_INCLUDE_DIRS := \
  $(MESA_TOP)/src/intel \
-- 
2.7.4


From d30d1fc43081caf06c6e7d380b54da4c175ba99c Mon Sep 17 00:00:00 2001
From: Mauro Rossi 
Date: Tue, 14 Jun 2016 00:05:23 +0200
Subject: [PATCH 2/2] android: genxml: update Makefile.sources with
 gen{4,45,5}_pack.h

Makefile.sources need to be updated to correctly build Android.
---
 src/intel/genxml/Makefile.sources | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/intel/genxml/Makefile.sources
b/src/intel/genxml/Makefile.sources
index 9298b4a..86c0bbe 100644
--- a/src/intel/genxml/Makefile.sources
+++ b/src/intel/genxml/Makefile.sources
@@ -1,4 +1,7 @@
 GENXML_GENERATED_FILES = \
+ gen4_pack.h \
+ gen45_pack.h \
+ gen5_pack.h \
  gen6_pack.h \
  gen7_pack.h \
  gen75_pack.h \
-- 
2.7.4
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] mesa: Make TexSubImage check negative dimensions sooner.

2016-06-13 Thread Anuj Phogat
On Wed, Jun 8, 2016 at 2:11 PM, Kenneth Graunke  wrote:
> Two dEQP tests expect INVALID_VALUE errors for negative width/height
> parameters, but get INVALID_OPERATION because they haven't actually
> created a destination image.  This is arguably not a bug in Mesa, as
> there's no specified ordering of error conditions.
>
> However, it's also really easy to make the tests pass, and there's
> no real harm in doing these checks earlier.
>
> Fixes:
> dEQP-GLES3.functional.negative_api.texture.texsubimage3d_neg_width_height
> dEQP-GLES31.functional.debug.negative_coverage.get_error.texture.texsubimage3d_neg_width_height
>
> Signed-off-by: Kenneth Graunke 
> ---
>  src/mesa/main/teximage.c | 68 
> ++--
>  1 file changed, 49 insertions(+), 19 deletions(-)
>
> diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
> index 58b7f27..d4f8278 100644
> --- a/src/mesa/main/teximage.c
> +++ b/src/mesa/main/teximage.c
> @@ -1102,6 +1102,32 @@ _mesa_legal_texture_dimensions(struct gl_context *ctx, 
> GLenum target,
> }
>  }
>
> +static bool
> +error_check_subtexture_negative_dimensions(struct gl_context *ctx,
> +   GLuint dims,
> +   GLsizei subWidth,
> +   GLsizei subHeight,
> +   GLsizei subDepth,
> +   const char *func)
> +{
> +   /* Check size */
> +   if (subWidth < 0) {
> +  _mesa_error(ctx, GL_INVALID_VALUE, "%s(width=%d)", func, subWidth);
> +  return true;
> +   }
> +
> +   if (dims > 1 && subHeight < 0) {
> +  _mesa_error(ctx, GL_INVALID_VALUE, "%s(height=%d)", func, subHeight);
> +  return true;
> +   }
> +
> +   if (dims > 2 && subDepth < 0) {
> +  _mesa_error(ctx, GL_INVALID_VALUE, "%s(depth=%d)", func, subDepth);
> +  return true;
> +   }
> +
> +   return false;
> +}
>
>  /**
>   * Do error checking of xoffset, yoffset, zoffset, width, height and depth
> @@ -1119,25 +1145,6 @@ error_check_subtexture_dimensions(struct gl_context 
> *ctx, GLuint dims,
> const GLenum target = destImage->TexObject->Target;
> GLuint bw, bh, bd;
>
> -   /* Check size */
> -   if (subWidth < 0) {
> -  _mesa_error(ctx, GL_INVALID_VALUE,
> -  "%s(width=%d)", func, subWidth);
> -  return GL_TRUE;
> -   }
> -
> -   if (dims > 1 && subHeight < 0) {
> -  _mesa_error(ctx, GL_INVALID_VALUE,
> -  "%s(height=%d)", func, subHeight);
> -  return GL_TRUE;
> -   }
> -
> -   if (dims > 2 && subDepth < 0) {
> -  _mesa_error(ctx, GL_INVALID_VALUE,
> -  "%s(depth=%d)", func, subDepth);
> -  return GL_TRUE;
> -   }
> -
> /* check xoffset and width */
> if (xoffset < - (GLint) destImage->Border) {
>_mesa_error(ctx, GL_INVALID_VALUE, "%s(xoffset)", func);
> @@ -2104,6 +2111,12 @@ texsubimage_error_check(struct gl_context *ctx, GLuint 
> dimensions,
>return GL_TRUE;
> }
>
> +   if (error_check_subtexture_negative_dimensions(ctx, dimensions,
> +  width, height, depth,
> +  callerName)) {
> +  return GL_TRUE;
> +   }
> +
> texImage = _mesa_select_tex_image(texObj, target, level);
> if (!texImage) {
>/* non-existant texture level */
> @@ -2140,6 +2153,12 @@ texsubimage_error_check(struct gl_context *ctx, GLuint 
> dimensions,
>return GL_TRUE;
> }
>
> +   if (error_check_subtexture_negative_dimensions(ctx, dimensions,
> +  width, height, depth,
> +  callerName)) {
> +  return GL_TRUE;
> +   }
> +
It's not obvious why we need to check twice for the negative dimensions
in texsubimage_error_check(). Adding a comment here will avoid confusion.

> if (error_check_subtexture_dimensions(ctx, dimensions,
>   texImage, xoffset, yoffset, zoffset,
>   width, height, depth, callerName)) {
> @@ -2497,6 +2516,11 @@ copytexsubimage_error_check(struct gl_context *ctx, 
> GLuint dimensions,
>return GL_TRUE;
> }
>
> +   if (error_check_subtexture_negative_dimensions(ctx, dimensions,
> +  width, height, 1, caller)) 
> {
> +  return GL_TRUE;
> +   }
> +
> if (error_check_subtexture_dimensions(ctx, dimensions, texImage,
>   xoffset, yoffset, zoffset,
>   width, height, 1, caller)) {
> @@ -4387,6 +4411,12 @@ compressed_subtexture_error_check(struct gl_context 
> *ctx, GLint dims,
>return GL_TRUE;
> }
>
> +   if (error_check_subtexture_negative_dimensions(ctx, dims,
> + 

Re: [Mesa-dev] [PATCH] Android: add missing u_math.h include path for libmesa_isl

2016-06-13 Thread Kenneth Graunke
On Monday, June 13, 2016 1:45:53 PM PDT Rob Herring wrote:
> Commit 87d062a94080 ("i965: Fix shared local memory size for Gen9+.")
> added u_math.h include which broke the Android build:
> 
> In file included from external/mesa3d/src/intel/isl/isl_storage_image.c:25:
> In file included from 
> external/mesa3d/src/mesa/drivers/dri/i965/brw_compiler.h:29:
> external/mesa3d/src/mesa/main/macros.h:35:10: fatal error: 'util/u_math.h' 
> file not found
>  ^
> 
> Add the missing include paths for libmesa_isl.
> 
> Cc: Kenneth Graunke 
> Cc: Emil Velikov 
> Signed-off-by: Rob Herring 
> ---
>  src/intel/isl/Android.mk | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/intel/isl/Android.mk b/src/intel/isl/Android.mk
> index 3134981..98e244f 100644
> --- a/src/intel/isl/Android.mk
> +++ b/src/intel/isl/Android.mk
> @@ -116,6 +116,8 @@ LOCAL_MODULE := libmesa_isl
>  LOCAL_SRC_FILES := $(ISL_FILES)
>  
>  LOCAL_C_INCLUDES := \
> + $(MESA_TOP)/src/gallium/include \
> + $(MESA_TOP)/src/gallium/auxiliary \
>   $(MESA_TOP)/src/mapi \
>   $(MESA_TOP)/src/mesa \
>   $(MESA_TOP)/src/mesa/drivers/dri/i965 \
> 

Sorry about that!  Thanks for the fix!

Reviewed-by: Kenneth Garunke 


signature.asc
Description: This is a digitally signed message part.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] Android: add missing u_math.h include path for libmesa_isl

2016-06-13 Thread Rob Herring
Commit 87d062a94080 ("i965: Fix shared local memory size for Gen9+.")
added u_math.h include which broke the Android build:

In file included from external/mesa3d/src/intel/isl/isl_storage_image.c:25:
In file included from 
external/mesa3d/src/mesa/drivers/dri/i965/brw_compiler.h:29:
external/mesa3d/src/mesa/main/macros.h:35:10: fatal error: 'util/u_math.h' file 
not found
 ^

Add the missing include paths for libmesa_isl.

Cc: Kenneth Graunke 
Cc: Emil Velikov 
Signed-off-by: Rob Herring 
---
 src/intel/isl/Android.mk | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/intel/isl/Android.mk b/src/intel/isl/Android.mk
index 3134981..98e244f 100644
--- a/src/intel/isl/Android.mk
+++ b/src/intel/isl/Android.mk
@@ -116,6 +116,8 @@ LOCAL_MODULE := libmesa_isl
 LOCAL_SRC_FILES := $(ISL_FILES)
 
 LOCAL_C_INCLUDES := \
+   $(MESA_TOP)/src/gallium/include \
+   $(MESA_TOP)/src/gallium/auxiliary \
$(MESA_TOP)/src/mapi \
$(MESA_TOP)/src/mesa \
$(MESA_TOP)/src/mesa/drivers/dri/i965 \
-- 
2.7.4

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


Re: [Mesa-dev] [PATCH] glsl: reuse main extension table to appropriate restrict extensions

2016-06-13 Thread Nanley Chery


On Mon, Jun 13, 2016 at 9:08 AM, Ilia Mirkin  wrote:

> On Mon, Jun 13, 2016 at 12:03 PM, Nanley Chery  
> wrote:
> >
> >
> > On Sun, Jun 12, 2016 at 4:23 PM, Ilia Mirkin  
> wrote:
> >>
> >> Previously we were only restricting based on ES/non-ES-ness and whether
> >> the overall enable bit had been flipped on. However we have been adding
> >> more fine-grained restrictions, such as based on compat profiles, as
> >> well as specific ES versions. Most of the time this doesn't matter, but
> >> it can create awkward situations and duplication of logic.
> >>
> >> Here we separate the main extension table into a separate object file,
> >> linked to the glsl compiler, which makes use of it with a custom
> >> function which takes the ES-ness of the shader into account (thus
> >> allowing desktop shaders to properly use ES extensions that would
> >> otherwise have been disallowed.)
> >>
> >> The effect of this change should be nil in most cases.
> >>
> >> Signed-off-by: Ilia Mirkin 
> >> ---
> >>  src/Makefile.am  |   1 +
> >>  src/compiler/SConscript.glsl |   2 +
> >>  src/compiler/glsl/glsl_parser_extras.cpp | 238
> >> ---
> >>  src/mesa/Android.libmesa_glsl_utils.mk   |   2 +
> >>  src/mesa/Makefile.sources|   1 +
> >>  src/mesa/main/extensions.c   |  30 ++--
> >>  src/mesa/main/extensions_table.c |  51 +++
> >>  7 files changed, 191 insertions(+), 134 deletions(-)
> >>  create mode 100644 src/mesa/main/extensions_table.c
> >>
> >> diff --git a/src/Makefile.am b/src/Makefile.am
> >> index 0527a31..a749bf6 100644
> >> --- a/src/Makefile.am
> >> +++ b/src/Makefile.am
> >> @@ -114,6 +114,7 @@ AM_CPPFLAGS = \
> >>  noinst_LTLIBRARIES = libglsl_util.la
> >>
> >>  libglsl_util_la_SOURCES = \
> >> +   mesa/main/extensions_table.c \
> >> mesa/main/imports.c \
> >> mesa/program/prog_hash_table.c \
> >> mesa/program/symbol_table.c \
> >> diff --git a/src/compiler/SConscript.glsl b/src/compiler/SConscript.glsl
> >> index 4252ce1..31d8f6d 100644
> >> --- a/src/compiler/SConscript.glsl
> >> +++ b/src/compiler/SConscript.glsl
> >> @@ -70,6 +70,7 @@ if env['msvc']:
> >>  # Copy these files to avoid generation object files into 
> src/mesa/program
> >>  env.Prepend(CPPPATH = ['#src/mesa/main'])
> >>  env.Command('glsl/imports.c', '#src/mesa/main/imports.c', 
> Copy('$TARGET',
> >> '$SOURCE'))
> >> +env.Command('glsl/extensions_table.c',
> >> '#src/mesa/main/extensions_table.c', Copy('$TARGET', '$SOURCE'))
> >>  # Copy these files to avoid generation object files into 
> src/mesa/program
> >>  env.Prepend(CPPPATH = ['#src/mesa/program'])
> >>  env.Command('glsl/prog_hash_table.c',
> >> '#src/mesa/program/prog_hash_table.c', Copy('$TARGET', '$SOURCE'))
> >> @@ -79,6 +80,7 @@ env.Command('glsl/dummy_errors.c',
> >> '#src/mesa/program/dummy_errors.c', Copy('$TA
> >>  compiler_objs = 
> env.StaticObject(source_lists['GLSL_COMPILER_CXX_FILES'])
> >>
> >>  mesa_objs = env.StaticObject([
> >> +'glsl/extensions_table.c',
> >>  'glsl/imports.c',
> >>  'glsl/prog_hash_table.c',
> >>  'glsl/symbol_table.c',
> >> diff --git a/src/compiler/glsl/glsl_parser_extras.cpp
> >> b/src/compiler/glsl/glsl_parser_extras.cpp
> >> index ce2c3e8..1f65412 100644
> >> --- a/src/compiler/glsl/glsl_parser_extras.cpp
> >> +++ b/src/compiler/glsl/glsl_parser_extras.cpp
> >> @@ -510,28 +510,12 @@ struct _mesa_glsl_extension {
> >>  */
> >> const char *name;
> >>
> >> -   /** True if this extension is available to desktop GL shaders */
> >> -   bool avail_in_GL;
> >> -
> >> -   /** True if this extension is available to GLES shaders */
> >> -   bool avail_in_ES;
> >> -
> >> /**
> >> -* Flag in the gl_extensions struct indicating whether this
> >> -* extension is supported by the driver, or
> >> -* _extensions::dummy_true if supported by all drivers.
> >> -*
> >> -* Note: the type (GLboolean gl_extensions::*) is a "pointer to
> >> -* member" type, the type-safe alternative to the "offsetof" macro.
> >> -* In a nutshell:
> >> -*
> >> -* - foo bar::* p declares p to be an "offset" to a field of type
> >> -*   foo that exists within struct bar
> >> -* - ::baz computes the "offset" of field baz within struct bar
> >> -* - x.*p accesses the field of x that exists at "offset" p
> >> -* - x->*p is equivalent to (*x).*p
> >> +* Predicate that checks whether the relevant extension is available
> >> for
> >> +* this context.
> >>  */
> >> -   const GLboolean gl_extensions::* supported_flag;
> >> +   bool (*available_pred)(const struct gl_context *,
> >> +  gl_api api, uint8_t version);
> >>
> >> /**
> >>  * Flag in the _mesa_glsl_parse_state struct that should be set
> >> @@ -556,8 +540,19 @@ struct _mesa_glsl_extension {
> >> 

[Mesa-dev] [PATCH v3] isl: Replace bash generator with python generator

2016-06-13 Thread Dylan Baker
This replaces the current bash generator with a python based generator
using mako. It's quite fast and works with both python 2.7 and python
3.5, and should work with 3.3+ and maybe even 3.2.

It produces an almost identical file except for a minor layout changes,
and the addition of a "generated file, do not edit" warning.

Cc: "12.0" 
Signed-off-by: Dylan Baker 
Reviewed-by: Jason Ekstrand 
Reviewed-by: Emil Velikov 
---

I don't have commit access to Mesa, so it would be great if someone
could commit this for me.

v2: - Provide the python file with the csvfile and output location as
  arguments (Jason, Emil)
- Put the mako template in the python file (Jason)
- Merge Emil's Android.mk changes
v3: - use builddir for the output of isl_format_layout.c (Jason, Emil)

 src/intel/isl/Android.mk |   6 +-
 src/intel/isl/Makefile.am|  13 +-
 src/intel/isl/gen_format_layout.py   | 207 +++
 src/intel/isl/isl_format_layout_gen.bash | 129 ---
 4 files changed, 218 insertions(+), 137 deletions(-)
 create mode 100644 src/intel/isl/gen_format_layout.py
 delete mode 100755 src/intel/isl/isl_format_layout_gen.bash

diff --git a/src/intel/isl/Android.mk b/src/intel/isl/Android.mk
index 3134981..ec3c656 100644
--- a/src/intel/isl/Android.mk
+++ b/src/intel/isl/Android.mk
@@ -139,14 +139,14 @@ LOCAL_GENERATED_SOURCES += $(addprefix $(intermediates)/, 
$(ISL_GENERATED_FILES)
 define bash-gen
@mkdir -p $(dir $@)
@echo "Gen Bash: $(PRIVATE_MODULE) <= $(notdir $(@))"
-   $(hide) $(PRIVATE_SCRIPT) < $(PRIVATE_CSV) > $@
+   $(hide) $(PRIVATE_SCRIPT) --csv $(PRIVATE_CSV) --out 
$(ISL_GENERATED_FILES)
 endef
 
 isl_format_layout_deps := \
-   $(LOCAL_PATH)/isl_format_layout_gen.bash \
+   $(LOCAL_PATH)/gen_format_layout.py \
$(LOCAL_PATH)/isl_format_layout.csv
 
-$(intermediates)/isl_format_layout.c: PRIVATE_SCRIPT := bash -c 
$(LOCAL_PATH)/isl_format_layout_gen.bash
+$(intermediates)/isl_format_layout.c: PRIVATE_SCRIPT := $(MESA_PYTHON2) 
$(LOCAL_PATH)/gen_format_layout.py
 $(intermediates)/isl_format_layout.c: PRIVATE_CSV := 
$(LOCAL_PATH)/isl_format_layout.csv
 $(intermediates)/isl_format_layout.c: $(isl_format_layout_deps)
$(call bash-gen)
diff --git a/src/intel/isl/Makefile.am b/src/intel/isl/Makefile.am
index 74f863a..812 100644
--- a/src/intel/isl/Makefile.am
+++ b/src/intel/isl/Makefile.am
@@ -1,4 +1,4 @@
-# Copyright 2015 Intel Corporation
+# Copyright 2015-2016 Intel Corporation
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # copy of this software and associated documentation files (the "Software"),
@@ -66,10 +66,13 @@ libisl_gen9_la_CFLAGS = $(libisl_la_CFLAGS) 
-DGEN_VERSIONx10=90
 
 BUILT_SOURCES = $(ISL_GENERATED_FILES)
 
-isl_format_layout.c: isl_format_layout_gen.bash \
+PYTHON_GEN = $(AM_V_GEN)$(PYTHON2) $(PYTHON_FLAGS)
+
+isl_format_layout.c: gen_format_layout.py \
  isl_format_layout.csv
-   $(AM_V_GEN)$(srcdir)/isl_format_layout_gen.bash \
-   <$(srcdir)/isl_format_layout.csv >$@
+   $(PYTHON_GEN) $(srcdir)/gen_format_layout.py \
+   --csv $(srcdir)/isl_format_layout.csv \
+   --out $(builddir)/isl_format_layout.c
 
 # 
 #  Tests
@@ -87,6 +90,6 @@ tests_isl_surf_get_image_offset_test_LDADD = \
 # 
 
 EXTRA_DIST = \
-   isl_format_layout_gen.bash \
+   gen_format_layout.py \
isl_format_layout.csv \
README
diff --git a/src/intel/isl/gen_format_layout.py 
b/src/intel/isl/gen_format_layout.py
new file mode 100644
index 000..d7f3900
--- /dev/null
+++ b/src/intel/isl/gen_format_layout.py
@@ -0,0 +1,207 @@
+# encoding=utf-8
+# Copyright ?? 2016 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 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, 

Re: [Mesa-dev] [PATCH v2 1/2] vl: Fix trivial sign compare warnings

2016-06-13 Thread Jan Vesely
On Mon, 2016-06-13 at 15:55 +0100, Emil Velikov wrote:
> Hi Jan,
> 
> On 10 June 2016 at 04:01, Jan Vesely  wrote:
> > From: Jan Vesely 
> > 
> > v2: add whitepace fixes
> I've squashed a couple more and pushed the patch to master.
> 
> Can you please check through the patchwork list [1] and ping/resend
> any outstanding patches.

thanks, updated.
Jan

> 
> Thanks
> Emil
> 
> [1] https://patchwork.freedesktop.org/project/mesa/patches/?submitter
> =15173
-- 
Jan Vesely 

signature.asc
Description: This is a digitally signed message part
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] swr: automake: don't ship LLVM version specific generated sources

2016-06-13 Thread Emil Velikov
From: Emil Velikov 

Otherwise things will fail to build, if the builder is using another
version of LLVM.

Cc: "12.0" 
Cc: Tim Rowley 
Cc: Chuck Atkins 
Reported-by: Chuck Atkins 
Signed-off-by: Emil Velikov 
---
Tim, Chuck,

Can anyone confirm if these are the only files that need this workaround
? If you want I can whip up (and upload) an Archlinux generated tarball
for you to test.

Thanks
Emil
---
 src/gallium/drivers/swr/Makefile.am | 20 ++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/swr/Makefile.am 
b/src/gallium/drivers/swr/Makefile.am
index 8151e4a..b6c58b0 100644
--- a/src/gallium/drivers/swr/Makefile.am
+++ b/src/gallium/drivers/swr/Makefile.am
@@ -52,8 +52,6 @@ BUILT_SOURCES = \
rasterizer/scripts/gen_knobs.cpp \
rasterizer/scripts/gen_knobs.h \
rasterizer/jitter/state_llvm.h \
-   rasterizer/jitter/builder_gen.h \
-   rasterizer/jitter/builder_gen.cpp \
rasterizer/jitter/builder_x86.h \
rasterizer/jitter/builder_x86.cpp
 
@@ -132,6 +130,15 @@ libswrAVX_la_CXXFLAGS = \
 libswrAVX_la_SOURCES = \
$(COMMON_SOURCES)
 
+# XXX: Don't ship these generated sources for now, since they are specific
+# to the LLVM version they are generated from. Thus a release tarball
+# containing the said files, generated against eg. LLVM 3.8 will fail to build
+# on systems with other versions of LLVM eg. 3.7 or 3.6.
+# Move these back to BUILT_SOURCES once that is resolved.
+nodist_libswrAVX_la_SOURCES = \
+   rasterizer/jitter/builder_gen.h \
+   rasterizer/jitter/builder_gen.cpp
+
 libswrAVX_la_LIBADD = \
$(COMMON_LIBADD)
 
@@ -146,6 +153,15 @@ libswrAVX2_la_CXXFLAGS = \
 libswrAVX2_la_SOURCES = \
$(COMMON_SOURCES)
 
+# XXX: Don't ship these generated sources for now, since they are specific
+# to the LLVM version they are generated from. Thus a release tarball
+# containing the said files, generated against eg. LLVM 3.8 will fail to build
+# on systems with other versions of LLVM eg. 3.7 or 3.6.
+# Move these back to BUILT_SOURCES once that is resolved.
+nodist_libswrAVX2_la_SOURCES = \
+   rasterizer/jitter/builder_gen.h \
+   rasterizer/jitter/builder_gen.cpp
+
 libswrAVX2_la_LIBADD = \
$(COMMON_LIBADD)
 
-- 
2.8.2

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


[Mesa-dev] [PATCH 1/2] gallium/util: import the multithreaded job queue from amdgpu winsys

2016-06-13 Thread Marek Olšák
From: Marek Olšák 

---
 src/gallium/auxiliary/Makefile.sources|   2 +
 src/gallium/auxiliary/util/u_queue.c  | 129 ++
 src/gallium/auxiliary/util/u_queue.h  |  80 
 src/gallium/winsys/amdgpu/drm/amdgpu_cs.c |  23 ++---
 src/gallium/winsys/amdgpu/drm/amdgpu_cs.h |   4 +-
 src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c |  63 +
 src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h |  11 +--
 7 files changed, 229 insertions(+), 83 deletions(-)
 create mode 100644 src/gallium/auxiliary/util/u_queue.c
 create mode 100644 src/gallium/auxiliary/util/u_queue.h

diff --git a/src/gallium/auxiliary/Makefile.sources 
b/src/gallium/auxiliary/Makefile.sources
index 7b3853e..ab58358 100644
--- a/src/gallium/auxiliary/Makefile.sources
+++ b/src/gallium/auxiliary/Makefile.sources
@@ -274,6 +274,8 @@ C_SOURCES := \
util/u_pstipple.c \
util/u_pstipple.h \
util/u_pwr8.h \
+   util/u_queue.c \
+   util/u_queue.h \
util/u_range.h \
util/u_rect.h \
util/u_resource.c \
diff --git a/src/gallium/auxiliary/util/u_queue.c 
b/src/gallium/auxiliary/util/u_queue.c
new file mode 100644
index 000..311b591
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_queue.c
@@ -0,0 +1,129 @@
+/*
+ * Copyright © 2016 Advanced Micro Devices, Inc.
+ * All Rights Reserved.
+ *
+ * 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, sub license, 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 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
+ * AND/OR ITS SUPPLIERS 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.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ */
+
+#include "u_queue.h"
+
+static PIPE_THREAD_ROUTINE(util_queue_thread_func, param)
+{
+   struct util_queue *queue = (struct util_queue*)param;
+   unsigned i;
+
+   while (1) {
+  struct util_queue_job job;
+
+  pipe_semaphore_wait(>queued);
+  if (queue->kill_thread)
+ break;
+
+  pipe_mutex_lock(queue->lock);
+  job = queue->jobs[0];
+  for (i = 1; i < queue->num_jobs; i++)
+ queue->jobs[i - 1] = queue->jobs[i];
+  queue->jobs[--queue->num_jobs].job = NULL;
+  pipe_mutex_unlock(queue->lock);
+
+  pipe_semaphore_signal(>has_space);
+
+  if (job.job) {
+ queue->execute_job(job.job);
+ pipe_semaphore_signal(>done);
+  }
+   }
+
+   /* signal remaining jobs before terminating */
+   pipe_mutex_lock(queue->lock);
+   for (i = 0; i < queue->num_jobs; i++) {
+  pipe_semaphore_signal(>jobs[i].event->done);
+  queue->jobs[i].job = NULL;
+   }
+   queue->num_jobs = 0;
+   pipe_mutex_unlock(queue->lock);
+   return 0;
+}
+
+void
+util_queue_init(struct util_queue *queue,
+void (*execute_job)(void *))
+{
+   memset(queue, 0, sizeof(*queue));
+   queue->execute_job = execute_job;
+   pipe_mutex_init(queue->lock);
+   pipe_semaphore_init(>has_space, ARRAY_SIZE(queue->jobs));
+   pipe_semaphore_init(>queued, 0);
+   queue->thread = pipe_thread_create(util_queue_thread_func, queue);
+}
+
+void
+util_queue_destroy(struct util_queue *queue)
+{
+   queue->kill_thread = 1;
+   pipe_semaphore_signal(>queued);
+   pipe_thread_wait(queue->thread);
+   pipe_semaphore_destroy(>has_space);
+   pipe_semaphore_destroy(>queued);
+   pipe_mutex_destroy(queue->lock);
+}
+
+void
+util_queue_event_init(struct util_queue_event *event)
+{
+   pipe_semaphore_init(>done, 1);
+}
+
+void
+util_queue_event_destroy(struct util_queue_event *event)
+{
+   pipe_semaphore_destroy(>done);
+}
+
+void
+util_queue_add_job(struct util_queue *queue,
+   void *job,
+   struct util_queue_event *event)
+{
+   /* Set the semaphore to "busy". */
+   pipe_semaphore_wait(>done);
+
+   /* if the queue is full, wait until there is space */
+   pipe_semaphore_wait(>has_space);
+
+   pipe_mutex_lock(queue->lock);
+   assert(queue->num_jobs < ARRAY_SIZE(queue->jobs));
+   queue->jobs[queue->num_jobs].job = job;
+   queue->jobs[queue->num_jobs].event = event;
+   queue->num_jobs++;
+   pipe_mutex_unlock(queue->lock);
+   

[Mesa-dev] [PATCH 2/2] winsys/radeon: use the common job queue for multithreaded command submission

2016-06-13 Thread Marek Olšák
From: Marek Olšák 

---
 src/gallium/winsys/radeon/drm/radeon_drm_cs.c | 22 
 src/gallium/winsys/radeon/drm/radeon_drm_cs.h |  4 +-
 src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 63 ++-
 src/gallium/winsys/radeon/drm/radeon_drm_winsys.h | 12 ++---
 4 files changed, 19 insertions(+), 82 deletions(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
index e9ab53d..d735612 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
@@ -177,7 +177,7 @@ radeon_drm_cs_create(struct radeon_winsys_ctx *ctx,
 if (!cs) {
 return NULL;
 }
-pipe_semaphore_init(>flush_completed, 1);
+util_queue_event_init(>flush_completed);
 
 cs->ws = ws;
 cs->flush_cs = flush;
@@ -427,8 +427,9 @@ static unsigned radeon_drm_cs_get_buffer_list(struct 
radeon_winsys_cs *rcs,
 return cs->csc->crelocs;
 }
 
-void radeon_drm_cs_emit_ioctl_oneshot(struct radeon_drm_cs *cs, struct 
radeon_cs_context *csc)
+void radeon_drm_cs_emit_ioctl_oneshot(void *job)
 {
+struct radeon_cs_context *csc = ((struct radeon_drm_cs*)job)->cst;
 unsigned i;
 int r;
 
@@ -463,11 +464,9 @@ void radeon_drm_cs_sync_flush(struct radeon_winsys_cs *rcs)
 {
 struct radeon_drm_cs *cs = radeon_drm_cs(rcs);
 
-/* Wait for any pending ioctl to complete. */
-if (cs->ws->thread) {
-pipe_semaphore_wait(>flush_completed);
-pipe_semaphore_signal(>flush_completed);
-}
+/* Wait for any pending ioctl of this CS to complete. */
+if (util_queue_is_initialized(>ws->cs_queue))
+util_queue_job_wait(>flush_completed);
 }
 
 DEBUG_GET_ONCE_BOOL_OPTION(noop, "RADEON_NOOP", FALSE)
@@ -586,13 +585,12 @@ static void radeon_drm_cs_flush(struct radeon_winsys_cs 
*rcs,
 break;
 }
 
-if (cs->ws->thread) {
-pipe_semaphore_wait(>flush_completed);
-radeon_drm_ws_queue_cs(cs->ws, cs);
+if (util_queue_is_initialized(>ws->cs_queue)) {
+util_queue_add_job(>ws->cs_queue, cs, >flush_completed);
 if (!(flags & RADEON_FLUSH_ASYNC))
 radeon_drm_cs_sync_flush(rcs);
 } else {
-radeon_drm_cs_emit_ioctl_oneshot(cs, cs->cst);
+radeon_drm_cs_emit_ioctl_oneshot(cs);
 }
 } else {
 radeon_cs_context_cleanup(cs->cst);
@@ -610,7 +608,7 @@ static void radeon_drm_cs_destroy(struct radeon_winsys_cs 
*rcs)
 struct radeon_drm_cs *cs = radeon_drm_cs(rcs);
 
 radeon_drm_cs_sync_flush(rcs);
-pipe_semaphore_destroy(>flush_completed);
+util_queue_event_destroy(>flush_completed);
 radeon_cs_context_cleanup(>csc1);
 radeon_cs_context_cleanup(>csc2);
 p_atomic_dec(>ws->num_cs);
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_cs.h 
b/src/gallium/winsys/radeon/drm/radeon_drm_cs.h
index 8056e72..5a0b56b 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_cs.h
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_cs.h
@@ -78,7 +78,7 @@ struct radeon_drm_cs {
 void (*flush_cs)(void *ctx, unsigned flags, struct pipe_fence_handle 
**fence);
 void *flush_data;
 
-pipe_semaphore flush_completed;
+struct util_queue_event flush_completed;
 };
 
 int radeon_lookup_buffer(struct radeon_cs_context *csc, struct radeon_bo *bo);
@@ -122,6 +122,6 @@ radeon_bo_is_referenced_by_any_cs(struct radeon_bo *bo)
 
 void radeon_drm_cs_sync_flush(struct radeon_winsys_cs *rcs);
 void radeon_drm_cs_init_functions(struct radeon_drm_winsys *ws);
-void radeon_drm_cs_emit_ioctl_oneshot(struct radeon_drm_cs *cs, struct 
radeon_cs_context *csc);
+void radeon_drm_cs_emit_ioctl_oneshot(void *job);
 
 #endif
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
index 5c85c8f..1f296f4 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
@@ -534,16 +534,11 @@ static void radeon_winsys_destroy(struct radeon_winsys 
*rws)
 {
 struct radeon_drm_winsys *ws = (struct radeon_drm_winsys*)rws;
 
-if (ws->thread) {
-ws->kill_thread = 1;
-pipe_semaphore_signal(>cs_queued);
-pipe_thread_wait(ws->thread);
-}
-pipe_semaphore_destroy(>cs_queued);
+if (util_queue_is_initialized(>cs_queue))
+util_queue_destroy(>cs_queue);
 
 pipe_mutex_destroy(ws->hyperz_owner_mutex);
 pipe_mutex_destroy(ws->cmask_owner_mutex);
-pipe_mutex_destroy(ws->cs_stack_lock);
 
 pb_cache_deinit(>bo_cache);
 
@@ -686,55 +681,7 @@ static int compare_fd(void *key1, void *key2)
stat1.st_rdev != stat2.st_rdev;
 }
 
-void radeon_drm_ws_queue_cs(struct radeon_drm_winsys *ws, struct radeon_drm_cs 
*cs)
-{
-retry:
-pipe_mutex_lock(ws->cs_stack_lock);
-if (ws->ncs >= RING_LAST) {
-/* no room left for a flush */
-

[Mesa-dev] [PATCH 2/2] radeonsi: use u_blitter for mipmap generation

2016-06-13 Thread Marek Olšák
From: Marek Olšák 

This reduces time spend in glGenerateMipmap by a half.
---
 src/gallium/drivers/radeonsi/si_blit.c | 37 +-
 src/gallium/drivers/radeonsi/si_pipe.c |  2 +-
 2 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_blit.c 
b/src/gallium/drivers/radeonsi/si_blit.c
index f2f1ef5..25d531b 100644
--- a/src/gallium/drivers/radeonsi/si_blit.c
+++ b/src/gallium/drivers/radeonsi/si_blit.c
@@ -690,7 +690,8 @@ static void si_clear_depth_stencil(struct pipe_context *ctx,
  * rendering. */
 static void si_decompress_subresource(struct pipe_context *ctx,
  struct pipe_resource *tex,
- unsigned planes, unsigned level,
+ unsigned planes,
+ unsigned first_level, unsigned last_level,
  unsigned first_layer, unsigned last_layer)
 {
struct si_context *sctx = (struct si_context *)ctx;
@@ -703,10 +704,10 @@ static void si_decompress_subresource(struct pipe_context 
*ctx,
planes &= ~PIPE_MASK_S;
 
si_blit_decompress_zs_in_place(sctx, rtex, planes,
-  level, level,
+  first_level, last_level,
   first_layer, last_layer);
} else if (rtex->fmask.size || rtex->cmask.size || rtex->dcc_offset) {
-   si_blit_decompress_color(ctx, rtex, level, level,
+   si_blit_decompress_color(ctx, rtex, first_level, last_level,
 first_layer, last_layer, false);
}
 }
@@ -746,7 +747,7 @@ void si_resource_copy_region(struct pipe_context *ctx,
 
/* The driver doesn't decompress resources automatically while
 * u_blitter is rendering. */
-   si_decompress_subresource(ctx, src, PIPE_MASK_RGBAZS, src_level,
+   si_decompress_subresource(ctx, src, PIPE_MASK_RGBAZS, src_level, 
src_level,
  src_box->z, src_box->z + src_box->depth - 1);
 
dst_width = u_minify(dst->width0, dst_level);
@@ -1005,7 +1006,7 @@ static void si_blit(struct pipe_context *ctx,
/* The driver doesn't decompress resources automatically while
 * u_blitter is rendering. */
si_decompress_subresource(ctx, info->src.resource, info->mask,
- info->src.level,
+ info->src.level, info->src.level,
  info->src.box.z,
  info->src.box.z + info->src.box.depth - 1);
 
@@ -1019,6 +1020,31 @@ static void si_blit(struct pipe_context *ctx,
si_blitter_end(ctx);
 }
 
+static boolean si_generate_mipmap(struct pipe_context *ctx,
+ struct pipe_resource *tex,
+ enum pipe_format format,
+ unsigned base_level, unsigned last_level,
+ unsigned first_layer, unsigned last_layer)
+{
+   struct si_context *sctx = (struct si_context*)ctx;
+
+   if (!util_blitter_is_copy_supported(sctx->blitter, tex, tex))
+   return false;
+
+   /* The driver doesn't decompress resources automatically while
+* u_blitter is rendering. */
+   si_decompress_subresource(ctx, tex, PIPE_MASK_RGBAZS,
+ base_level, last_level,
+ first_layer, last_layer);
+
+   si_blitter_begin(ctx, SI_BLIT | SI_DISABLE_RENDER_COND);
+   util_blitter_generate_mipmap(sctx->blitter, tex, format,
+base_level, last_level,
+first_layer, last_layer);
+   si_blitter_end(ctx);
+   return true;
+}
+
 static void si_flush_resource(struct pipe_context *ctx,
  struct pipe_resource *res)
 {
@@ -1113,6 +1139,7 @@ void si_init_blit_functions(struct si_context *sctx)
sctx->b.b.resource_copy_region = si_resource_copy_region;
sctx->b.b.blit = si_blit;
sctx->b.b.flush_resource = si_flush_resource;
+   sctx->b.b.generate_mipmap = si_generate_mipmap;
sctx->b.blit_decompress_depth = si_blit_decompress_depth;
sctx->b.decompress_dcc = si_decompress_dcc;
 }
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c 
b/src/gallium/drivers/radeonsi/si_pipe.c
index 0c601da..1ee1877 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -357,6 +357,7 @@ static int si_get_param(struct pipe_screen* pscreen, enum 
pipe_cap param)
case PIPE_CAP_TGSI_PACK_HALF_FLOAT:
case PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT:
case PIPE_CAP_ROBUST_BUFFER_ACCESS_BEHAVIOR:
+   case PIPE_CAP_GENERATE_MIPMAP:

[Mesa-dev] [PATCH 1/2] gallium/u_blitter: implement mipmap generation

2016-06-13 Thread Marek Olšák
From: Marek Olšák 

for pipe_context::generate_mipmap

first move some of the blit code from util_blitter_blit_generic
to a separate function, then use it from util_blitter_generate_mipmap
---
 src/gallium/auxiliary/util/u_blitter.c | 346 ++---
 src/gallium/auxiliary/util/u_blitter.h |   6 +
 2 files changed, 238 insertions(+), 114 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_blitter.c 
b/src/gallium/auxiliary/util/u_blitter.c
index ad645ad..1257bb6 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -1501,6 +1501,135 @@ void util_blitter_copy_texture(struct blitter_context 
*blitter,
pipe_sampler_view_reference(_view, NULL);
 }
 
+static void do_blits(struct blitter_context_priv *ctx,
+ struct pipe_surface *dst,
+ const struct pipe_box *dstbox,
+ struct pipe_sampler_view *src,
+ unsigned src_width0,
+ unsigned src_height0,
+ const struct pipe_box *srcbox,
+ bool is_zsbuf)
+{
+   struct pipe_context *pipe = ctx->base.pipe;
+   unsigned src_samples = src->texture->nr_samples;
+   unsigned dst_samples = dst->texture->nr_samples;
+   enum pipe_texture_target src_target = src->texture->target;
+   struct pipe_framebuffer_state fb_state = {0};
+
+   /* Initialize framebuffer state. */
+   fb_state.width = dst->width;
+   fb_state.height = dst->height;
+   fb_state.nr_cbufs = is_zsbuf ? 0 : 1;
+
+   blitter_set_dst_dimensions(ctx, fb_state.width, fb_state.height);
+
+   if ((src_target == PIPE_TEXTURE_1D ||
+src_target == PIPE_TEXTURE_2D ||
+src_target == PIPE_TEXTURE_RECT) &&
+   src_samples <= 1) {
+  /* Draw the quad with the draw_rectangle callback. */
+
+  /* Set texture coordinates. - use a pipe color union
+   * for interface purposes.
+   * XXX pipe_color_union is a wrong name since we use that to set
+   * texture coordinates too.
+   */
+  union pipe_color_union coord;
+  get_texcoords(src, src_width0, src_height0, srcbox->x, srcbox->y,
+srcbox->x+srcbox->width, srcbox->y+srcbox->height, 
coord.f);
+
+  /* Set framebuffer state. */
+  if (is_zsbuf) {
+ fb_state.zsbuf = dst;
+  } else {
+ fb_state.cbufs[0] = dst;
+  }
+  pipe->set_framebuffer_state(pipe, _state);
+
+  /* Draw. */
+  pipe->set_sample_mask(pipe, ~0);
+  ctx->base.draw_rectangle(>base, dstbox->x, dstbox->y,
+   dstbox->x + dstbox->width,
+   dstbox->y + dstbox->height, 0,
+   UTIL_BLITTER_ATTRIB_TEXCOORD, );
+   } else {
+  /* Draw the quad with the generic codepath. */
+  int dst_z;
+  for (dst_z = 0; dst_z < dstbox->depth; dst_z++) {
+ struct pipe_surface *old;
+ float dst2src_scale = srcbox->depth / (float)dstbox->depth;
+
+ /* Scale Z properly if the blit is scaled.
+  *
+  * When downscaling, we want the coordinates centered, so that
+  * mipmapping works for 3D textures. For example, when generating
+  * a 4x4x4 level, this wouldn't average the pixels:
+  *
+  *   src Z:  0 1 2 3 4 5 6 7
+  *   dst Z:  0   1   2   3
+  *
+  * Because the pixels are not centered below the pixels of the higher
+  * level. Therefore, we want this:
+  *   src Z:  0 1 2 3 4 5 6 7
+  *   dst Z:   0   1   2   3
+  *
+  * dst_offset defines the offset needed for centering the pixels and
+  * it works with any scaling (not just 2x).
+  */
+ float dst_offset = ((srcbox->depth - 1) -
+ (dstbox->depth - 1) * dst2src_scale) * 0.5;
+ float src_z = (dst_z + dst_offset) * dst2src_scale;
+
+ /* Set framebuffer state. */
+ if (is_zsbuf) {
+fb_state.zsbuf = dst;
+ } else {
+fb_state.cbufs[0] = dst;
+ }
+ pipe->set_framebuffer_state(pipe, _state);
+
+ /* See if we need to blit a multisample or singlesample buffer. */
+ if (src_samples == dst_samples && dst_samples > 1) {
+/* MSAA copy. */
+unsigned i, max_sample = dst_samples - 1;
+
+for (i = 0; i <= max_sample; i++) {
+   pipe->set_sample_mask(pipe, 1 << i);
+   blitter_set_texcoords(ctx, src, src_width0, src_height0,
+ srcbox->z + src_z,
+ i, srcbox->x, srcbox->y,
+ srcbox->x + srcbox->width,
+ srcbox->y + srcbox->height);
+   blitter_draw(ctx, dstbox->x, dstbox->y,
+dstbox->x + dstbox->width,
+dstbox->y + 

Re: [Mesa-dev] [PATCH] glsl: reuse main extension table to appropriate restrict extensions

2016-06-13 Thread Eric Engestrom
On Mon, Jun 13, 2016 at 09:39:39AM -0700, Nanley Chery wrote:
> You can add an entry to the end of the enum defined in extensions.h called
> "MESA_EXTENSION_COUNT"  or similar.

This is a good idea, but with one caveat:
I've seen twice already bugs caused by people using ALL_CAPS counter
entries in enums, and then someone trying to use them in #if conditions,
where it resolves as `0` since the preprocessor doesn't know them.

I would strongly advise to use lower case names, so as to avoid this
confusion.

Cheers,
  Eric
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [Mesa-stable] [PATCH] swr: fix -march flag for AVX

2016-06-13 Thread Emil Velikov
On 13 June 2016 at 15:43, Rowley, Timothy O  wrote:
>
>> On Jun 12, 2016, at 3:56 AM, Steven Newbury  wrote:
>>
>> On Fri, 2016-06-10 at 16:05 -0400, Ilia Mirkin wrote:
>>> On Fri, Jun 10, 2016 at 3:43 PM, Tim Rowley >> om> wrote:

 Previously used core-avx-i was for ivybridge;
 corei7-avx allows sandybridge.
 ---
  src/gallium/drivers/swr/Makefile.am | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/src/gallium/drivers/swr/Makefile.am
 b/src/gallium/drivers/swr/Makefile.am
 index d211f2e..8156cf2 100644
 --- a/src/gallium/drivers/swr/Makefile.am
 +++ b/src/gallium/drivers/swr/Makefile.am
 @@ -124,7 +124,7 @@ COMMON_LDFLAGS = \
  lib_LTLIBRARIES = libswrAVX.la libswrAVX2.la

  libswrAVX_la_CXXFLAGS = \
 -   -march=core-avx-i \
 +   -march=corei7-avx \
>>> Just wondering if it'd be enough to say like
>>>
>>> -march=x86_64
>>> -mavx
>>>
>>> and add -mavx2 for libswrAVX2.
>>>
>>> I suspect you've iterated through this 20 times and this has some
>>> shortcoming I'm not thinking of, but figured I'd point it out just in
>>> case it helps.
>>>
>>>   -ilia
>>>
>> Maybe I'm the only one who finds it horrible to override -march from
>> within project build systems.

>> It causes no end of problems with LTO,
>> and results in objects being built inappropriately for the target as
>> specified by the builder.
Can you please elaborate on the exact problem ? Is there link where
one can read more on the topic ?

> I agree that the way swr is built can be improved and welcome 
> ideas/discussion for work on the master branch, but for the moment I’m trying 
> to get the 12.0 branch in good shape for swr with non-invasive changes (as 
> we’ve tested the current setup pretty extensively).
>
Fully agree. Getting something more robust and less evasive for 12.0
and work for 'the best' in master. Perhaps attribute((target)) perhaps
folding the multiple binaries into one, or maybe something else ?

>> Why not use function attributes?  Either compile a function
>> specifically for a particular target, or specifically enable AVX though
>> "__attribute__ ((__target__ ("avx")))"
Is this going to produce correct binary if one provides -mno-avx
and/or alike ? I believe for some CPUs one should (or the compiler
does it for them) explicitly disable avx but honestly I've never
looked if cpuid for the said CPUs shows avx as supported.

In the latter case (cpuid listing AVX as supported, while one is
recommended building with -mno-avx) how do you suggest we should
handle things ?

>> (ideally with a fall-back
>> implementation detected at run-time when the instruction set isn't
>> supported).  Even better, have it also protected at build-time by a
>> simple check for __AVX__ so the code can be compiled out entirely where
>> the package builder has specified -march(=native) as a build flag.
The idea here is to have the binary build explicitly with avx/avx2 (if
compiler is capable), even when doing generic builds. The picky part
comes when one has to establish if the user provided one is 'more
generic' or not (as per your example).

Then again, based on my limited 'testing', building mesa with native
and LTO brings us little to no improvements. 'Tested' running glxgears
in small window.

> One problem with the function attribute path is that as far as I know, MSVC 
> does not have a similar feature.
>
Afaict MSVC has optimise pragma [1], just like GCC. Ideally they'll
add an equivalent to attribute((target)) soon ?

Even without that, swr (as seen in mesa) does not build MSVC. When
that cases it should be a matter of factoring the attribute target as
a macro and leaving it empty for the !GCC build ?

TL;DR: IMHO fix is ok for now, but for the future we might want to
explode other options.

-Emil
[1] https://msdn.microsoft.com/en-us/library/chh3fb0k.aspx
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] util: update some assertions in util_resource_copy_region()

2016-06-13 Thread Jose Fonseca

On 13/06/16 17:35, Brian Paul wrote:

To cope with copies of compressed images which are not multiples of
the block size.  Suggested by Jose.
---
  src/gallium/auxiliary/util/u_surface.c | 12 
  1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_surface.c 
b/src/gallium/auxiliary/util/u_surface.c
index e48e47c..b9d2da0 100644
--- a/src/gallium/auxiliary/util/u_surface.c
+++ b/src/gallium/auxiliary/util/u_surface.c
@@ -332,12 +332,16 @@ util_resource_copy_region(struct pipe_context *pipe,
 /* check that region boxes are block aligned */
 assert(src_box.x % src_bw == 0);
 assert(src_box.y % src_bh == 0);
-   assert(src_box.width % src_bw == 0 || src_box.width < src_bw);
-   assert(src_box.height % src_bh == 0 || src_box.height < src_bh);
+   assert(src_box.width % src_bw == 0 ||
+  src_box.x + src_box.width == minify(src->width0, src_level, src_bw));
+   assert(src_box.height % src_bh == 0 ||
+  src_box.y + src_box.height == minify(src->height0, src_level, 
src_bh));
 assert(dst_box.x % dst_bw == 0);
 assert(dst_box.y % dst_bh == 0);
-   assert(dst_box.width % dst_bw == 0 || dst_box.width < dst_bw);
-   assert(dst_box.height % dst_bh == 0 || dst_box.height < src_bh);
+   assert(dst_box.width % dst_bw == 0 ||
+  dst_box.x + dst_box.width == minify(dst->width0, dst_level, dst_bw));
+   assert(dst_box.height % dst_bh == 0 ||
+  dst_box.y + dst_box.height == minify(dst->height0, dst_level, 
dst_bh));

 /* check that region boxes are not out of bounds */
 assert(src_box.x + src_box.width <=



Looks great to me.  Thanks.

Reviewed-by: Jose Fonseca 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] util: update some assertions in util_resource_copy_region()

2016-06-13 Thread Roland Scheidegger
Am 13.06.2016 um 18:35 schrieb Brian Paul:
> To cope with copies of compressed images which are not multiples of
> the block size.  Suggested by Jose.
> ---
>  src/gallium/auxiliary/util/u_surface.c | 12 
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/src/gallium/auxiliary/util/u_surface.c 
> b/src/gallium/auxiliary/util/u_surface.c
> index e48e47c..b9d2da0 100644
> --- a/src/gallium/auxiliary/util/u_surface.c
> +++ b/src/gallium/auxiliary/util/u_surface.c
> @@ -332,12 +332,16 @@ util_resource_copy_region(struct pipe_context *pipe,
> /* check that region boxes are block aligned */
> assert(src_box.x % src_bw == 0);
> assert(src_box.y % src_bh == 0);
> -   assert(src_box.width % src_bw == 0 || src_box.width < src_bw);
> -   assert(src_box.height % src_bh == 0 || src_box.height < src_bh);
> +   assert(src_box.width % src_bw == 0 ||
> +  src_box.x + src_box.width == minify(src->width0, src_level, 
> src_bw));
> +   assert(src_box.height % src_bh == 0 ||
> +  src_box.y + src_box.height == minify(src->height0, src_level, 
> src_bh));
> assert(dst_box.x % dst_bw == 0);
> assert(dst_box.y % dst_bh == 0);
> -   assert(dst_box.width % dst_bw == 0 || dst_box.width < dst_bw);
> -   assert(dst_box.height % dst_bh == 0 || dst_box.height < src_bh);
> +   assert(dst_box.width % dst_bw == 0 ||
> +  dst_box.x + dst_box.width == minify(dst->width0, dst_level, 
> dst_bw));
> +   assert(dst_box.height % dst_bh == 0 ||
> +  dst_box.y + dst_box.height == minify(dst->height0, dst_level, 
> dst_bh));
>  
> /* check that region boxes are not out of bounds */
> assert(src_box.x + src_box.width <=
> 

Looks good to me. Albeit at least half the code in that function is
assertions ;-).

Reviewed-by: Roland Scheidegger 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] glsl: reuse main extension table to appropriate restrict extensions

2016-06-13 Thread Ilia Mirkin
On Mon, Jun 13, 2016 at 12:39 PM, Nanley Chery  wrote:
>
>
> On Mon, Jun 13, 2016 at 9:16 AM, Ilia Mirkin  wrote:
>>
>> On Mon, Jun 13, 2016 at 12:11 PM, Emil Velikov 
>> wrote:
>> > Hi Ilia,
>> >
>> > On 13 June 2016 at 00:23, Ilia Mirkin  wrote:
>> >
>> >> @@ -81,6 +81,7 @@ MAIN_FILES = \
>> >> main/execmem.c \
>> >> main/extensions.c \
>> >> main/extensions.h \
>> >> +   main/extensions_table.c \
>> > From a build perspective everything looks amazing. Thank you !
>>
>> Thanks for checking.
>>
>> >
>> >
>> >> --- a/src/mesa/main/extensions.c
>> >> +++ b/src/mesa/main/extensions.c
>> >> @@ -49,25 +49,15 @@ static char *extra_extensions = NULL;
>> >>  #define o(x) offsetof(struct gl_extensions, x)
>> >>
>> >>
>> >> -/**
>> >> - * \brief Table of supported OpenGL extensions for all API's.
>> >> - */
>> >> -const struct mesa_extension _mesa_extension_table[] = {
>> >> +static bool extension_table_size[] = {
>> >>  #define EXT(name_str, driver_cap, gll_ver, glc_ver, gles_ver,
>> >> gles2_ver, ) \
>> >> -{ .name = "GL_" #name_str, .offset = o(driver_cap), \
>> >> -  .version = { \
>> >> -[API_OPENGL_COMPAT] = gll_ver, \
>> >> -[API_OPENGL_CORE]   = glc_ver, \
>> >> -[API_OPENGLES]  = gles_ver, \
>> >> -[API_OPENGLES2] = gles2_ver, \
>> >> -   }, \
>> >> -   .year =  \
>> >> -},
>> >> +   0,
>> >> +
>> >>  #include "extensions_table.h"
>> >>  #undef EXT
>> >>  };
>> >>
>> > An alternative idea to the one proposed by Eric:
>> > Explicitly set the array size (ideally as a macro in the relevant
>> > header) and use that instead of having a dummy array, only to know the
>> > array size.
>>
>> I couldn't come up with a non-horrible way of doing that. Are you
>> basically suggesting I add a
>>
>> #define EXTENSIONS_COUNT 1
>>
>> in extensions_table.h, and expect someone to increment it every time
>> an extension was being added?
>>
>> I guess it could be enforced via a STATIC_ASSERT in the new
>> extensions_table.c, but it feels really dirty. I guess a cleverer
>> thing would be to count by doing something horrible for the compiler,
>> e.g.
>>
>> static const int foo = 0 +1+1+1+1+1+1..
>>
>> Probably nicer than my array of 0's though. Open to other ideas.
>>
>
> You can add an entry to the end of the enum defined in extensions.h called
> "MESA_EXTENSION_COUNT"  or similar.

Duh. Of course. Much better!
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] glsl: reuse main extension table to appropriate restrict extensions

2016-06-13 Thread Emil Velikov
On 13 June 2016 at 17:16, Ilia Mirkin  wrote:
> On Mon, Jun 13, 2016 at 12:11 PM, Emil Velikov  
> wrote:
>> Hi Ilia,
>>
>> On 13 June 2016 at 00:23, Ilia Mirkin  wrote:
>>
>>> @@ -81,6 +81,7 @@ MAIN_FILES = \
>>> main/execmem.c \
>>> main/extensions.c \
>>> main/extensions.h \
>>> +   main/extensions_table.c \
>> From a build perspective everything looks amazing. Thank you !
>
> Thanks for checking.
>
>>
>>
>>> --- a/src/mesa/main/extensions.c
>>> +++ b/src/mesa/main/extensions.c
>>> @@ -49,25 +49,15 @@ static char *extra_extensions = NULL;
>>>  #define o(x) offsetof(struct gl_extensions, x)
>>>
>>>
>>> -/**
>>> - * \brief Table of supported OpenGL extensions for all API's.
>>> - */
>>> -const struct mesa_extension _mesa_extension_table[] = {
>>> +static bool extension_table_size[] = {
>>>  #define EXT(name_str, driver_cap, gll_ver, glc_ver, gles_ver, gles2_ver, 
>>> ) \
>>> -{ .name = "GL_" #name_str, .offset = o(driver_cap), \
>>> -  .version = { \
>>> -[API_OPENGL_COMPAT] = gll_ver, \
>>> -[API_OPENGL_CORE]   = glc_ver, \
>>> -[API_OPENGLES]  = gles_ver, \
>>> -[API_OPENGLES2] = gles2_ver, \
>>> -   }, \
>>> -   .year =  \
>>> -},
>>> +   0,
>>> +
>>>  #include "extensions_table.h"
>>>  #undef EXT
>>>  };
>>>
>> An alternative idea to the one proposed by Eric:
>> Explicitly set the array size (ideally as a macro in the relevant
>> header) and use that instead of having a dummy array, only to know the
>> array size.
>
> I couldn't come up with a non-horrible way of doing that. Are you
> basically suggesting I add a
>
> #define EXTENSIONS_COUNT 1
>
> in extensions_table.h, and expect someone to increment it every time
> an extension was being added?
>
Yes, pretty much (with the correct count of course)

> I guess it could be enforced via a STATIC_ASSERT in the new
> extensions_table.c, but it feels really dirty.
Personally a big fat warning at the top of the file + a STATIC_ASSERT
feels like a more elegant solution.

Even without the STATIC_ASSERT the compiler gives us a nice warning as
we attempt to assign more data than the actual array size.

> I guess a cleverer
> thing would be to count by doing something horrible for the compiler,
> e.g.
>
> static const int foo = 0 +1+1+1+1+1+1..
>
The following does work, although it does feel a bit nasty.

static const int foo =
#define EXT(...) 1 +
#include far.h
0;

> Probably nicer than my array of 0's though. Open to other ideas.
>
At the end of the day, it's not my call so feel free to go with
whichever, as long as others are happy.

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


Re: [Mesa-dev] [PATCH] glsl: reuse main extension table to appropriate restrict extensions

2016-06-13 Thread Nanley Chery
On Mon, Jun 13, 2016 at 9:16 AM, Ilia Mirkin  wrote:

> On Mon, Jun 13, 2016 at 12:11 PM, Emil Velikov 
> wrote:
> > Hi Ilia,
> >
> > On 13 June 2016 at 00:23, Ilia Mirkin  wrote:
> >
> >> @@ -81,6 +81,7 @@ MAIN_FILES = \
> >> main/execmem.c \
> >> main/extensions.c \
> >> main/extensions.h \
> >> +   main/extensions_table.c \
> > From a build perspective everything looks amazing. Thank you !
>
> Thanks for checking.
>
> >
> >
> >> --- a/src/mesa/main/extensions.c
> >> +++ b/src/mesa/main/extensions.c
> >> @@ -49,25 +49,15 @@ static char *extra_extensions = NULL;
> >>  #define o(x) offsetof(struct gl_extensions, x)
> >>
> >>
> >> -/**
> >> - * \brief Table of supported OpenGL extensions for all API's.
> >> - */
> >> -const struct mesa_extension _mesa_extension_table[] = {
> >> +static bool extension_table_size[] = {
> >>  #define EXT(name_str, driver_cap, gll_ver, glc_ver, gles_ver,
> gles2_ver, ) \
> >> -{ .name = "GL_" #name_str, .offset = o(driver_cap), \
> >> -  .version = { \
> >> -[API_OPENGL_COMPAT] = gll_ver, \
> >> -[API_OPENGL_CORE]   = glc_ver, \
> >> -[API_OPENGLES]  = gles_ver, \
> >> -[API_OPENGLES2] = gles2_ver, \
> >> -   }, \
> >> -   .year =  \
> >> -},
> >> +   0,
> >> +
> >>  #include "extensions_table.h"
> >>  #undef EXT
> >>  };
> >>
> > An alternative idea to the one proposed by Eric:
> > Explicitly set the array size (ideally as a macro in the relevant
> > header) and use that instead of having a dummy array, only to know the
> > array size.
>
> I couldn't come up with a non-horrible way of doing that. Are you
> basically suggesting I add a
>
> #define EXTENSIONS_COUNT 1
>
> in extensions_table.h, and expect someone to increment it every time
> an extension was being added?
>
> I guess it could be enforced via a STATIC_ASSERT in the new
> extensions_table.c, but it feels really dirty. I guess a cleverer
> thing would be to count by doing something horrible for the compiler,
> e.g.
>
> static const int foo = 0 +1+1+1+1+1+1..
>
> Probably nicer than my array of 0's though. Open to other ideas.
>
>
You can add an entry to the end of the enum defined in extensions.h called
"MESA_EXTENSION_COUNT"  or similar.

- Nanley


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


Re: [Mesa-dev] [PATCH] radeonsi: add a debug flag for unsafe math LLVM optimizations

2016-06-13 Thread Matt Arsenault

> On Jun 13, 2016, at 09:27, Marek Olšák  wrote:
> 
> + { "unsafemath", DBG_UNSAFE_MATH, "Enable unsafe math shader 
> optimizations" },

Perhaps one for each of the individual fast math options as well (no nans, no 
signed zeros etc.)?___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] util: update some assertions in util_resource_copy_region()

2016-06-13 Thread Brian Paul
To cope with copies of compressed images which are not multiples of
the block size.  Suggested by Jose.
---
 src/gallium/auxiliary/util/u_surface.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_surface.c 
b/src/gallium/auxiliary/util/u_surface.c
index e48e47c..b9d2da0 100644
--- a/src/gallium/auxiliary/util/u_surface.c
+++ b/src/gallium/auxiliary/util/u_surface.c
@@ -332,12 +332,16 @@ util_resource_copy_region(struct pipe_context *pipe,
/* check that region boxes are block aligned */
assert(src_box.x % src_bw == 0);
assert(src_box.y % src_bh == 0);
-   assert(src_box.width % src_bw == 0 || src_box.width < src_bw);
-   assert(src_box.height % src_bh == 0 || src_box.height < src_bh);
+   assert(src_box.width % src_bw == 0 ||
+  src_box.x + src_box.width == minify(src->width0, src_level, src_bw));
+   assert(src_box.height % src_bh == 0 ||
+  src_box.y + src_box.height == minify(src->height0, src_level, 
src_bh));
assert(dst_box.x % dst_bw == 0);
assert(dst_box.y % dst_bh == 0);
-   assert(dst_box.width % dst_bw == 0 || dst_box.width < dst_bw);
-   assert(dst_box.height % dst_bh == 0 || dst_box.height < src_bh);
+   assert(dst_box.width % dst_bw == 0 ||
+  dst_box.x + dst_box.width == minify(dst->width0, dst_level, dst_bw));
+   assert(dst_box.height % dst_bh == 0 ||
+  dst_box.y + dst_box.height == minify(dst->height0, dst_level, 
dst_bh));
 
/* check that region boxes are not out of bounds */
assert(src_box.x + src_box.width <=
-- 
1.9.1

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


[Mesa-dev] [PATCH] radeonsi: add a debug flag for unsafe math LLVM optimizations

2016-06-13 Thread Marek Olšák
From: Marek Olšák 

---
 src/gallium/drivers/radeon/r600_pipe_common.c |  1 +
 src/gallium/drivers/radeon/r600_pipe_common.h |  1 +
 src/gallium/drivers/radeonsi/si_shader.c  | 16 
 3 files changed, 18 insertions(+)

diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c 
b/src/gallium/drivers/radeon/r600_pipe_common.c
index fa9f70d..5d4a679 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.c
+++ b/src/gallium/drivers/radeon/r600_pipe_common.c
@@ -482,6 +482,7 @@ static const struct debug_named_value 
common_debug_options[] = {
{ "sisched", DBG_SI_SCHED, "Enable LLVM SI Machine Instruction 
Scheduler." },
{ "mono", DBG_MONOLITHIC_SHADERS, "Use old-style monolithic shaders 
compiled on demand" },
{ "noce", DBG_NO_CE, "Disable the constant engine"},
+   { "unsafemath", DBG_UNSAFE_MATH, "Enable unsafe math shader 
optimizations" },
 
DEBUG_NAMED_VALUE_END /* must be last */
 };
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h 
b/src/gallium/drivers/radeon/r600_pipe_common.h
index 77dfc4f..263ef5e 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.h
+++ b/src/gallium/drivers/radeon/r600_pipe_common.h
@@ -99,6 +99,7 @@
 #define DBG_SI_SCHED   (1llu << 46)
 #define DBG_MONOLITHIC_SHADERS (1llu << 47)
 #define DBG_NO_CE  (1llu << 48)
+#define DBG_UNSAFE_MATH(1llu << 49)
 
 #define R600_MAP_BUFFER_ALIGNMENT 64
 #define R600_MAX_VIEWPORTS16
diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index 6dc4985..bba6a55 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -5255,6 +5255,22 @@ static void si_create_function(struct si_shader_context 
*ctx,
else
LLVMAddAttribute(P, LLVMInRegAttribute);
}
+
+   if (ctx->screen->b.debug_flags & DBG_UNSAFE_MATH) {
+   /* These were copied from some LLVM test. */
+   LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
+  "less-precise-fpmad",
+  "true");
+   LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
+  "no-infs-fp-math",
+  "true");
+   LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
+  "no-nans-fp-math",
+  "true");
+   LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
+  "unsafe-fp-math",
+  "true");
+   }
 }
 
 static void create_meta_data(struct si_shader_context *ctx)
-- 
2.7.4

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


Re: [Mesa-dev] [PATCH] radeonsi: don't generate "ret void undef"

2016-06-13 Thread Bas Nieuwenhuizen
Reviewed-by: Bas Nieuwenhuizen 

On Mon, Jun 13, 2016 at 6:17 PM, Marek Olšák  wrote:
> From: Marek Olšák 
>
> Use LLVMBuildRetVoid in epilogs and the GS copy shader and
> si_llvm_build_ret otherwise.
> ---
>  src/gallium/drivers/radeonsi/si_shader.c | 20 ++--
>  1 file changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
> b/src/gallium/drivers/radeonsi/si_shader.c
> index f2bd337..6dc4985 100644
> --- a/src/gallium/drivers/radeonsi/si_shader.c
> +++ b/src/gallium/drivers/radeonsi/si_shader.c
> @@ -6230,6 +6230,14 @@ int si_compile_llvm(struct si_screen *sscreen,
> return r;
>  }
>
> +static void si_llvm_build_ret(struct si_shader_context *ctx, LLVMValueRef 
> ret)
> +{
> +   if (LLVMGetTypeKind(LLVMTypeOf(ret)) == LLVMVoidTypeKind)
> +   LLVMBuildRetVoid(ctx->radeon_bld.gallivm.builder);
> +   else
> +   LLVMBuildRet(ctx->radeon_bld.gallivm.builder, ret);
> +}
> +
>  /* Generate code for the hardware VS shader stage to go with a geometry 
> shader */
>  static int si_generate_gs_copy_shader(struct si_screen *sscreen,
>   struct si_shader_context *ctx,
> @@ -6291,7 +6299,7 @@ static int si_generate_gs_copy_shader(struct si_screen 
> *sscreen,
>
> si_llvm_export_vs(bld_base, outputs, gsinfo->num_outputs);
>
> -   LLVMBuildRet(gallivm->builder, ctx->return_value);
> +   LLVMBuildRetVoid(gallivm->builder);
>
> /* Dump LLVM IR before any optimization passes */
> if (sscreen->b.debug_flags & DBG_PREOPT_IR &&
> @@ -6572,7 +6580,7 @@ int si_compile_tgsi_shader(struct si_screen *sscreen,
> goto out;
> }
>
> -   LLVMBuildRet(bld_base->base.gallivm->builder, ctx.return_value);
> +   si_llvm_build_ret(, ctx.return_value);
> mod = bld_base->base.gallivm->module;
>
> /* Dump LLVM IR before any optimization passes */
> @@ -6807,7 +6815,7 @@ static bool si_compile_vs_prolog(struct si_screen 
> *sscreen,
> }
>
> /* Compile. */
> -   LLVMBuildRet(gallivm->builder, ret);
> +   si_llvm_build_ret(, ret);
> radeon_llvm_finalize_module(_bld);
>
> if (si_compile_llvm(sscreen, >binary, >config, tm,
> @@ -6880,7 +6888,7 @@ static bool si_compile_vs_epilog(struct si_screen 
> *sscreen,
> }
>
> /* Compile. */
> -   LLVMBuildRet(gallivm->builder, ctx.return_value);
> +   LLVMBuildRetVoid(gallivm->builder);
> radeon_llvm_finalize_module(_bld);
>
> if (si_compile_llvm(sscreen, >binary, >config, tm,
> @@ -7035,7 +7043,7 @@ static bool si_compile_tcs_epilog(struct si_screen 
> *sscreen,
>   LLVMGetParam(func, last_sgpr + 3));
>
> /* Compile. */
> -   LLVMBuildRet(gallivm->builder, ctx.return_value);
> +   LLVMBuildRetVoid(gallivm->builder);
> radeon_llvm_finalize_module(_bld);
>
> if (si_compile_llvm(sscreen, >binary, >config, tm,
> @@ -7228,7 +7236,7 @@ static bool si_compile_ps_prolog(struct si_screen 
> *sscreen,
> }
>
> /* Compile. */
> -   LLVMBuildRet(gallivm->builder, ret);
> +   si_llvm_build_ret(, ret);
> radeon_llvm_finalize_module(_bld);
>
> if (si_compile_llvm(sscreen, >binary, >config, tm,
> --
> 2.7.4
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] Mesa (master): st/mesa: use buffer usage history to set dirty flags for revalidation

2016-06-13 Thread Brian Paul

On 06/13/2016 10:04 AM, Marek Olšák wrote:

On Mon, Jun 13, 2016 at 5:17 PM, Roland Scheidegger  wrote:

Am 13.06.2016 um 14:53 schrieb Marek Olšák:

On Mon, Jun 13, 2016 at 1:14 PM, Jose Fonseca  wrote:

On 10/06/16 15:40, Roland Scheidegger wrote:


Am 10.06.2016 um 12:38 schrieb Marek Olšák:


On Fri, Jun 10, 2016 at 6:19 AM, Roland Scheidegger 
wrote:


Am 10.06.2016 um 05:14 schrieb Ilia Mirkin:


On Thu, Jun 9, 2016 at 11:13 PM, Roland Scheidegger
 wrote:


Am 10.06.2016 um 04:58 schrieb Roland Scheidegger:


Am 10.06.2016 um 03:11 schrieb Ilia Mirkin:


On Thu, Jun 9, 2016 at 9:07 PM, Ilia Mirkin 
wrote:


On Wed, Jun 8, 2016 at 5:48 PM, Fredrik Höglund 
wrote:


On Wednesday 08 June 2016, Ilia Mirkin wrote:


Glancing at the code (I don't even have a piglit checkout here):

static void
set_ubo_binding(struct gl_context *ctx, ...)
...
 /* If this is a real buffer object, mark it has having been
used
  * at some point as a UBO.
  */
 if (size >= 0)
bufObj->UsageHistory |= USAGE_UNIFORM_BUFFER;

That seems bogus - what if the current size is 0 (unallocated),
the
buffer object gets bound to a UBO endpoint, and then someone goes
in
and does glBufferData()? Same for set_ssbo_binding.

-ilia



The test is greater than or equal to zero, so the UsageHistory
should
be set even when the buffer is unallocated.



Right, duh.



But the piglit test doesn't bind the buffer as a uniform buffer
before
it allocates it.  It allocates the buffer first with
glNamedBufferData(),
and then binds it.  The UsageHistory is still set to the default
value in
the glNamedBufferData() call, since the buffer has never been
bound
at that point.  But the uniform buffer state should still be
marked as
dirty in the glBindBufferRange() call.  I think this failure
suggests
that that doesn't happen for some reason.



I haven't looked in GREAT detail, but the test does pass on nv50,
nvc0, and softpipe. It only fails on llvmpipe.

Brian, this might be out of my comfort area to figure out... Given
that it's working on the other drivers, that seems more likely to
be a
failing of llvmpipe somehow.



Another observation is that the square sizes/shapes are all correct.
However the colors are all of the first square (red). So it seems
like
some issue is happening for the fragment shader, but not vertex.



I've looked at this briefly and I'm not sure who's to blame.
It goes something like this:
- we don't get any set_constant_buffer calls anymore when the
contents
of the buffer change. I don't think that's ok, looks like a bug to
me?
Granted it's still the same buffer, just modfying a bound one.

- when the contents are updated, it ends up in some transfer stuff as
expected, in the end llvmpipe_transfer_map(). This checks if the
resource is referenced in the current scene, if so it would flush -
however this is only done for textures and rts (because UBO contents
are
indeed copied to the scene, not referenced, this is quite ok here, we
don't want to flush).

- on the next draw, we'd check the dirty bits - we never got
set_constant_buffer (which would set LP_NEW_CONSTANTS and in turn
LP_SETUP_NEW_CONSTANTS), and llvmpipe_transfer_map didn't do
anything,
so we don't pick up the changed contents, and continue to use the old
copied ones.

We could check if buffers are referenced in the scene and set the
LP_NEW_CONSTANTS bit accordingly, but I'm not sure what the st is
doing
is really ok? (For vs, it doesn't matter that we miss the update - as
the offsets etc. are all the same the vs will just pick up the
changes
automatically as we don't copy anything since this stuff all runs
synchronously.)




Err actually this analysis is flawed.
llvmpipe would indeed check in llvmpipe_transfer_map() if a currently
bound constant buffer is changed and hence set LP_NEW_CONSTANTS
accordingly.
But it doesn't because the buffer doesn't have the
PIPE_BIND_CONSTANT_BUFFER usage flag set (so, strictly speaking, it
would be illegal to bind it as such, but this is never enforced). In
fact it doesn't have _any_ bind flag set.
So I blame the GL api, but I don't know how to fix this mess cleanly
(we
don't really want to ignore bind flags completely).



Ah yeah, rookie mistake. pipe_resource->bind is only there to confuse
you. If you use it for anything after resource creation, that's a bug.



This was designed in gallium with dx10 in mind, which has a proper api
for this. But I suppose the only way to fix it in the mesa state tracker
would be to just set ALL possible bind flags for buffers always...



Or you can assume bind == 0 means all flags are set.



Yes in this case, but I don't think that really helps. Even when using
the old gl api for setting this, the target (and hence the bind flag)
may be something completely different than the actual usage.



I'd rather have GL renderer set all possible bind flags.

And 

Re: [Mesa-dev] [PATCH] glsl: reuse main extension table to appropriate restrict extensions

2016-06-13 Thread Eric Engestrom
On Mon, Jun 13, 2016 at 12:08:24PM +0100, Eric Engestrom wrote:
> 
> > diff --git a/src/mesa/main/extensions_table.c 
> > b/src/mesa/main/extensions_table.c
> > new file mode 100644
> > index 000..1e37fbc
> > --- /dev/null
> > +++ b/src/mesa/main/extensions_table.c
> > @@ -0,0 +1,51 @@
> > +/*
> > + * Mesa 3-D graphics library
> > + *
> > + * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
> > + * Copyright (C) 2009  VMware, Inc.  All Rights Reserved.
> > + *
> > + * 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 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 "main/mtypes.h"
> > +#include "main/extensions.h"
> > +
> > +/**
> > + * Given a member \c x of struct gl_extensions, return offset of
> > + * \c x in bytes.
> > + */
> > +#define o(x) offsetof(struct gl_extensions, x)
> > +
> > +/**
> > + * \brief Table of supported OpenGL extensions for all API's.
> > + */
> > +const struct mesa_extension _mesa_extension_table[] = {
> > +#define EXT(name_str, driver_cap, gll_ver, glc_ver, gles_ver, gles2_ver, 
> > ) \
> > +{ .name = "GL_" #name_str, .offset = o(driver_cap), \
> > +  .version = { \
> > +[API_OPENGL_COMPAT] = gll_ver, \
> > +[API_OPENGL_CORE]   = glc_ver, \
> > +[API_OPENGLES]  = gles_ver, \
> > +[API_OPENGLES2] = gles2_ver, \
> > +   }, \
> > +   .year =  \
> > +},
> > +#include "extensions_table.h"
> > +#undef EXT
> 
> I'm not sure this macro is useful in the first place, but:
> 
>   #undef o

Second errata:
I just realised this is a .c, not a .h, so the dangling #define doesn't matter.
Please disregard my earlier comment about it, and I apologise :)
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] gallium/radeon: num-cs-flushes query should display per-frame average

2016-06-13 Thread Marek Olšák
From: Marek Olšák 

---
 src/gallium/drivers/radeon/r600_query.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/radeon/r600_query.c 
b/src/gallium/drivers/radeon/r600_query.c
index f090f1c..2e06746 100644
--- a/src/gallium/drivers/radeon/r600_query.c
+++ b/src/gallium/drivers/radeon/r600_query.c
@@ -1171,7 +1171,7 @@ static struct pipe_driver_query_info 
r600_driver_query_list[] = {
X("requested-VRAM", REQUESTED_VRAM, BYTES, AVERAGE),
X("requested-GTT",  REQUESTED_GTT,  BYTES, AVERAGE),
X("buffer-wait-time",   BUFFER_WAIT_TIME,   MICROSECONDS, 
CUMULATIVE),
-   X("num-cs-flushes", NUM_CS_FLUSHES, UINT64, 
CUMULATIVE),
+   X("num-cs-flushes", NUM_CS_FLUSHES, UINT64, 
AVERAGE),
X("num-bytes-moved",NUM_BYTES_MOVED,BYTES, 
CUMULATIVE),
X("VRAM-usage", VRAM_USAGE, BYTES, AVERAGE),
X("GTT-usage",  GTT_USAGE,  BYTES, AVERAGE),
-- 
2.7.4

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


[Mesa-dev] [PATCH] gallium/radeon: add driver queries for compute/dma call stats and spills

2016-06-13 Thread Marek Olšák
From: Marek Olšák 

also print the average count per frame
---
 src/gallium/drivers/radeon/r600_pipe_common.h |  3 +++
 src/gallium/drivers/radeon/r600_query.c   | 30 ++-
 src/gallium/drivers/radeon/r600_query.h   |  4 
 src/gallium/drivers/radeonsi/si_compute.c |  6 ++
 src/gallium/drivers/radeonsi/si_pipe.h|  1 +
 src/gallium/drivers/radeonsi/si_state_draw.c  |  2 ++
 6 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h 
b/src/gallium/drivers/radeon/r600_pipe_common.h
index eb8a25a..77dfc4f 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.h
+++ b/src/gallium/drivers/radeon/r600_pipe_common.h
@@ -509,6 +509,9 @@ struct r600_common_context {
unsignedmax_db; /* for OQ */
/* Misc stats. */
unsignednum_draw_calls;
+   unsignednum_spill_draw_calls;
+   unsignednum_compute_calls;
+   unsignednum_spill_compute_calls;
unsignednum_dma_calls;
uint64_tnum_alloc_tex_transfer_bytes;
 
diff --git a/src/gallium/drivers/radeon/r600_query.c 
b/src/gallium/drivers/radeon/r600_query.c
index e362614..f090f1c 100644
--- a/src/gallium/drivers/radeon/r600_query.c
+++ b/src/gallium/drivers/radeon/r600_query.c
@@ -75,6 +75,18 @@ static boolean r600_query_sw_begin(struct 
r600_common_context *rctx,
case R600_QUERY_DRAW_CALLS:
query->begin_result = rctx->num_draw_calls;
break;
+   case R600_QUERY_SPILL_DRAW_CALLS:
+   query->begin_result = rctx->num_spill_draw_calls;
+   break;
+   case R600_QUERY_COMPUTE_CALLS:
+   query->begin_result = rctx->num_compute_calls;
+   break;
+   case R600_QUERY_SPILL_COMPUTE_CALLS:
+   query->begin_result = rctx->num_spill_compute_calls;
+   break;
+   case R600_QUERY_DMA_CALLS:
+   query->begin_result = rctx->num_dma_calls;
+   break;
case R600_QUERY_REQUESTED_VRAM:
case R600_QUERY_REQUESTED_GTT:
case R600_QUERY_VRAM_USAGE:
@@ -127,6 +139,18 @@ static bool r600_query_sw_end(struct r600_common_context 
*rctx,
case R600_QUERY_DRAW_CALLS:
query->end_result = rctx->num_draw_calls;
break;
+   case R600_QUERY_SPILL_DRAW_CALLS:
+   query->end_result = rctx->num_spill_draw_calls;
+   break;
+   case R600_QUERY_COMPUTE_CALLS:
+   query->end_result = rctx->num_compute_calls;
+   break;
+   case R600_QUERY_SPILL_COMPUTE_CALLS:
+   query->end_result = rctx->num_spill_compute_calls;
+   break;
+   case R600_QUERY_DMA_CALLS:
+   query->end_result = rctx->num_dma_calls;
+   break;
case R600_QUERY_REQUESTED_VRAM:
case R600_QUERY_REQUESTED_GTT:
case R600_QUERY_VRAM_USAGE:
@@ -1139,7 +1163,11 @@ err:
 static struct pipe_driver_query_info r600_driver_query_list[] = {
X("num-compilations",   NUM_COMPILATIONS,   UINT64, 
CUMULATIVE),
X("num-shaders-created",NUM_SHADERS_CREATED,UINT64, 
CUMULATIVE),
-   X("draw-calls", DRAW_CALLS, UINT64, 
CUMULATIVE),
+   X("draw-calls", DRAW_CALLS, UINT64, 
AVERAGE),
+   X("spill-draw-calls",   SPILL_DRAW_CALLS,   UINT64, 
AVERAGE),
+   X("compute-calls",  COMPUTE_CALLS,  UINT64, 
AVERAGE),
+   X("spill-compute-calls",SPILL_COMPUTE_CALLS,UINT64, 
AVERAGE),
+   X("dma-calls",  DMA_CALLS,  UINT64, 
AVERAGE),
X("requested-VRAM", REQUESTED_VRAM, BYTES, AVERAGE),
X("requested-GTT",  REQUESTED_GTT,  BYTES, AVERAGE),
X("buffer-wait-time",   BUFFER_WAIT_TIME,   MICROSECONDS, 
CUMULATIVE),
diff --git a/src/gallium/drivers/radeon/r600_query.h 
b/src/gallium/drivers/radeon/r600_query.h
index a3c9aa2..b573a17 100644
--- a/src/gallium/drivers/radeon/r600_query.h
+++ b/src/gallium/drivers/radeon/r600_query.h
@@ -42,6 +42,10 @@ struct r600_resource;
 
 enum {
R600_QUERY_DRAW_CALLS = PIPE_QUERY_DRIVER_SPECIFIC,
+   R600_QUERY_SPILL_DRAW_CALLS,
+   R600_QUERY_COMPUTE_CALLS,
+   R600_QUERY_SPILL_COMPUTE_CALLS,
+   R600_QUERY_DMA_CALLS,
R600_QUERY_REQUESTED_VRAM,
R600_QUERY_REQUESTED_GTT,
R600_QUERY_BUFFER_WAIT_TIME,
diff --git a/src/gallium/drivers/radeonsi/si_compute.c 
b/src/gallium/drivers/radeonsi/si_compute.c
index 09cbe13..2f7e172 100644
--- a/src/gallium/drivers/radeonsi/si_compute.c
+++ b/src/gallium/drivers/radeonsi/si_compute.c
@@ -308,6 +308,8 @@ static bool 

[Mesa-dev] [PATCH] radeonsi: don't generate "ret void undef"

2016-06-13 Thread Marek Olšák
From: Marek Olšák 

Use LLVMBuildRetVoid in epilogs and the GS copy shader and
si_llvm_build_ret otherwise.
---
 src/gallium/drivers/radeonsi/si_shader.c | 20 ++--
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index f2bd337..6dc4985 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -6230,6 +6230,14 @@ int si_compile_llvm(struct si_screen *sscreen,
return r;
 }
 
+static void si_llvm_build_ret(struct si_shader_context *ctx, LLVMValueRef ret)
+{
+   if (LLVMGetTypeKind(LLVMTypeOf(ret)) == LLVMVoidTypeKind)
+   LLVMBuildRetVoid(ctx->radeon_bld.gallivm.builder);
+   else
+   LLVMBuildRet(ctx->radeon_bld.gallivm.builder, ret);
+}
+
 /* Generate code for the hardware VS shader stage to go with a geometry shader 
*/
 static int si_generate_gs_copy_shader(struct si_screen *sscreen,
  struct si_shader_context *ctx,
@@ -6291,7 +6299,7 @@ static int si_generate_gs_copy_shader(struct si_screen 
*sscreen,
 
si_llvm_export_vs(bld_base, outputs, gsinfo->num_outputs);
 
-   LLVMBuildRet(gallivm->builder, ctx->return_value);
+   LLVMBuildRetVoid(gallivm->builder);
 
/* Dump LLVM IR before any optimization passes */
if (sscreen->b.debug_flags & DBG_PREOPT_IR &&
@@ -6572,7 +6580,7 @@ int si_compile_tgsi_shader(struct si_screen *sscreen,
goto out;
}
 
-   LLVMBuildRet(bld_base->base.gallivm->builder, ctx.return_value);
+   si_llvm_build_ret(, ctx.return_value);
mod = bld_base->base.gallivm->module;
 
/* Dump LLVM IR before any optimization passes */
@@ -6807,7 +6815,7 @@ static bool si_compile_vs_prolog(struct si_screen 
*sscreen,
}
 
/* Compile. */
-   LLVMBuildRet(gallivm->builder, ret);
+   si_llvm_build_ret(, ret);
radeon_llvm_finalize_module(_bld);
 
if (si_compile_llvm(sscreen, >binary, >config, tm,
@@ -6880,7 +6888,7 @@ static bool si_compile_vs_epilog(struct si_screen 
*sscreen,
}
 
/* Compile. */
-   LLVMBuildRet(gallivm->builder, ctx.return_value);
+   LLVMBuildRetVoid(gallivm->builder);
radeon_llvm_finalize_module(_bld);
 
if (si_compile_llvm(sscreen, >binary, >config, tm,
@@ -7035,7 +7043,7 @@ static bool si_compile_tcs_epilog(struct si_screen 
*sscreen,
  LLVMGetParam(func, last_sgpr + 3));
 
/* Compile. */
-   LLVMBuildRet(gallivm->builder, ctx.return_value);
+   LLVMBuildRetVoid(gallivm->builder);
radeon_llvm_finalize_module(_bld);
 
if (si_compile_llvm(sscreen, >binary, >config, tm,
@@ -7228,7 +7236,7 @@ static bool si_compile_ps_prolog(struct si_screen 
*sscreen,
}
 
/* Compile. */
-   LLVMBuildRet(gallivm->builder, ret);
+   si_llvm_build_ret(, ret);
radeon_llvm_finalize_module(_bld);
 
if (si_compile_llvm(sscreen, >binary, >config, tm,
-- 
2.7.4

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


[Mesa-dev] [PATCH 1/3] gallium/radeon: add micro_tile_mode to radeon_surf

2016-06-13 Thread Marek Olšák
From: Marek Olšák 

for easier access
---
 src/gallium/drivers/radeon/radeon_winsys.h |  1 +
 src/gallium/winsys/amdgpu/drm/amdgpu_surface.c | 15 +++
 src/gallium/winsys/radeon/drm/radeon_drm_surface.c | 30 +++---
 3 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/radeon/radeon_winsys.h 
b/src/gallium/drivers/radeon/radeon_winsys.h
index c2d1f9e..bbf91a8 100644
--- a/src/gallium/drivers/radeon/radeon_winsys.h
+++ b/src/gallium/drivers/radeon/radeon_winsys.h
@@ -398,6 +398,7 @@ struct radeon_surf {
 uint32_tpipe_config;
 uint32_tnum_banks;
 uint32_tmacro_tile_index;
+uint32_tmicro_tile_mode; /* displayable, thin, depth, 
rotated */
 
 uint64_tdcc_size;
 uint64_tdcc_alignment;
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_surface.c 
b/src/gallium/winsys/amdgpu/drm/amdgpu_surface.c
index 68a5820..081f0e1 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_surface.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_surface.c
@@ -255,6 +255,20 @@ static int compute_level(struct amdgpu_winsys *ws,
return 0;
 }
 
+#define   G_009910_MICRO_TILE_MODE(x)  (((x) >> 0) & 0x03)
+#define   G_009910_MICRO_TILE_MODE_NEW(x)  (((x) >> 22) & 0x07)
+
+static void set_micro_tile_mode(struct radeon_surf *surf,
+struct radeon_info *info)
+{
+   uint32_t tile_mode = info->si_tile_mode_array[surf->tiling_index[0]];
+
+   if (info->chip_class >= CIK)
+  surf->micro_tile_mode = G_009910_MICRO_TILE_MODE_NEW(tile_mode);
+   else
+  surf->micro_tile_mode = G_009910_MICRO_TILE_MODE(tile_mode);
+}
+
 static int amdgpu_surface_init(struct radeon_winsys *rws,
struct radeon_surf *surf)
 {
@@ -410,6 +424,7 @@ static int amdgpu_surface_init(struct radeon_winsys *rws,
   if (level == 0) {
  surf->bo_alignment = AddrSurfInfoOut.baseAlign;
  surf->pipe_config = AddrSurfInfoOut.pTileInfo->pipeConfig - 1;
+ set_micro_tile_mode(surf, >info);
 
  /* For 2D modes only. */
  if (AddrSurfInfoOut.tileMode >= ADDR_TM_2D_TILED_THIN1) {
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_surface.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_surface.c
index 6fb8774..c6025ff 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_surface.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_surface.c
@@ -45,6 +45,27 @@ static unsigned cik_get_macro_tile_index(struct radeon_surf 
*surf)
return index;
 }
 
+#define   G_009910_MICRO_TILE_MODE(x)  (((x) >> 0) & 0x03)
+#define   G_009910_MICRO_TILE_MODE_NEW(x)  (((x) >> 22) & 0x07)
+
+static void set_micro_tile_mode(struct radeon_surf *surf,
+struct radeon_info *info)
+{
+uint32_t tile_mode;
+
+if (info->chip_class < SI) {
+surf->micro_tile_mode = 0;
+return;
+}
+
+tile_mode = info->si_tile_mode_array[surf->tiling_index[0]];
+
+if (info->chip_class >= CIK)
+surf->micro_tile_mode = G_009910_MICRO_TILE_MODE_NEW(tile_mode);
+else
+surf->micro_tile_mode = G_009910_MICRO_TILE_MODE(tile_mode);
+}
+
 static void surf_level_winsys_to_drm(struct radeon_surface_level *level_drm,
  const struct radeon_surf_level *level_ws)
 {
@@ -114,7 +135,8 @@ static void surf_winsys_to_drm(struct radeon_surface 
*surf_drm,
 }
 }
 
-static void surf_drm_to_winsys(struct radeon_surf *surf_ws,
+static void surf_drm_to_winsys(struct radeon_drm_winsys *ws,
+   struct radeon_surf *surf_ws,
const struct radeon_surface *surf_drm)
 {
 int i;
@@ -153,6 +175,8 @@ static void surf_drm_to_winsys(struct radeon_surf *surf_ws,
 surf_ws->tiling_index[i] = surf_drm->tiling_index[i];
 surf_ws->stencil_tiling_index[i] = surf_drm->stencil_tiling_index[i];
 }
+
+set_micro_tile_mode(surf_ws, >info);
 }
 
 static int radeon_winsys_surface_init(struct radeon_winsys *rws,
@@ -168,7 +192,7 @@ static int radeon_winsys_surface_init(struct radeon_winsys 
*rws,
 if (r)
 return r;
 
-surf_drm_to_winsys(surf_ws, _drm);
+surf_drm_to_winsys(ws, surf_ws, _drm);
 return 0;
 }
 
@@ -185,7 +209,7 @@ static int radeon_winsys_surface_best(struct radeon_winsys 
*rws,
 if (r)
 return r;
 
-surf_drm_to_winsys(surf_ws, _drm);
+surf_drm_to_winsys(ws, surf_ws, _drm);
 return 0;
 }
 
-- 
2.7.4

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


  1   2   >