Mesa (master): anv/pipeline: lower constant initializers on output variables earlier

2018-01-29 Thread Iago Toral Quiroga
Module: Mesa
Branch: master
Commit: 99b57daf4a8289430728bec69f7dadfab457d990
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=99b57daf4a8289430728bec69f7dadfab457d990

Author: Iago Toral Quiroga 
Date:   Tue Jan 16 09:37:11 2018 +0100

anv/pipeline: lower constant initializers on output variables earlier

If a shader only writes to an output via a constant initializer we
need to lower it before we call nir_remove_dead_variables so that
this pass sees the stores from the initializer and doesn't kill the
output.

Fixes test failures in new work-in-progress CTS tests:
dEQP-VK.spirv_assembly.instruction.graphics.variable_init.output_vert
dEQP-VK.spirv_assembly.instruction.graphics.variable_init.output_frag

Reviewed-by: Jason Ekstrand 

---

 src/intel/vulkan/anv_pipeline.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c
index 48eefe828a..e16a7a1994 100644
--- a/src/intel/vulkan/anv_pipeline.c
+++ b/src/intel/vulkan/anv_pipeline.c
@@ -179,6 +179,11 @@ anv_shader_compile_to_nir(struct anv_pipeline *pipeline,
assert(exec_list_length(>functions) == 1);
entry_point->name = ralloc_strdup(entry_point, "main");
 
+   /* Make sure we lower constant initializers on output variables so that
+* nir_remove_dead_variables below sees the corresponding stores
+*/
+   NIR_PASS_V(nir, nir_lower_constant_initializers, nir_var_shader_out);
+
NIR_PASS_V(nir, nir_remove_dead_variables,
   nir_var_shader_in | nir_var_shader_out | nir_var_system_value);
 

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


Mesa (master): i965: move disk cache from brw_context to intel_screen

2018-01-29 Thread Tapani Pälli
Module: Mesa
Branch: master
Commit: 6316c2ecbda6d9370f1f876981ebcc35393c04e8
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6316c2ecbda6d9370f1f876981ebcc35393c04e8

Author: Tapani Pälli 
Date:   Fri Jan 26 08:20:07 2018 +0200

i965: move disk cache from brw_context to intel_screen

Now every context refers to same disk_cache instance in screen.

Signed-off-by: Tapani Pälli 
Suggested-by: Emil Velikov 
Reviewed-by: Emil Velikov 
Reviewed-by: Jordan Justen 

---

 src/mesa/drivers/dri/i965/brw_context.c| 4 +---
 src/mesa/drivers/dri/i965/brw_disk_cache.c | 6 +++---
 src/mesa/drivers/dri/i965/brw_state.h  | 2 +-
 src/mesa/drivers/dri/i965/intel_screen.c   | 5 +
 src/mesa/drivers/dri/i965/intel_screen.h   | 2 ++
 5 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index 07a234b367..addacf2cf8 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -1066,7 +1066,7 @@ brwCreateContext(gl_api api,
vbo_use_buffer_objects(ctx);
vbo_always_unmap_buffers(ctx);
 
-   brw_disk_cache_init(brw);
+   brw->ctx.Cache = brw->screen->disk_cache;
 
return true;
 }
@@ -1130,8 +1130,6 @@ intelDestroyContext(__DRIcontext * driContextPriv)
 
driDestroyOptionCache(>optionCache);
 
-   disk_cache_destroy(brw->ctx.Cache);
-
/* free the Mesa context */
_mesa_free_context_data(>ctx);
 
diff --git a/src/mesa/drivers/dri/i965/brw_disk_cache.c 
b/src/mesa/drivers/dri/i965/brw_disk_cache.c
index 6196386425..f989456bcd 100644
--- a/src/mesa/drivers/dri/i965/brw_disk_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_disk_cache.c
@@ -404,7 +404,7 @@ brw_disk_cache_write_compute_program(struct brw_context 
*brw)
 }
 
 void
-brw_disk_cache_init(struct brw_context *brw)
+brw_disk_cache_init(struct intel_screen *screen)
 {
 #ifdef ENABLE_SHADER_CACHE
if (env_var_as_boolean("MESA_GLSL_CACHE_DISABLE", true))
@@ -412,7 +412,7 @@ brw_disk_cache_init(struct brw_context *brw)
 
char renderer[10];
MAYBE_UNUSED int len = snprintf(renderer, sizeof(renderer), "i965_%04x",
-   brw->screen->deviceID);
+   screen->deviceID);
assert(len == sizeof(renderer) - 1);
 
const struct build_id_note *note =
@@ -425,6 +425,6 @@ brw_disk_cache_init(struct brw_context *brw)
char timestamp[41];
_mesa_sha1_format(timestamp, id_sha1);
 
-   brw->ctx.Cache = disk_cache_create(renderer, timestamp, 0);
+   screen->disk_cache = disk_cache_create(renderer, timestamp, 0);
 #endif
 }
diff --git a/src/mesa/drivers/dri/i965/brw_state.h 
b/src/mesa/drivers/dri/i965/brw_state.h
index ad508950f7..d29ae6b972 100644
--- a/src/mesa/drivers/dri/i965/brw_state.h
+++ b/src/mesa/drivers/dri/i965/brw_state.h
@@ -125,7 +125,7 @@ void gen8_write_pma_stall_bits(struct brw_context *brw,
uint32_t pma_stall_bits);
 
 /* brw_disk_cache.c */
-void brw_disk_cache_init(struct brw_context *brw);
+void brw_disk_cache_init(struct intel_screen *screen);
 bool brw_disk_cache_upload_program(struct brw_context *brw,
gl_shader_stage stage);
 void brw_disk_cache_write_compute_program(struct brw_context *brw);
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c 
b/src/mesa/drivers/dri/i965/intel_screen.c
index a4e34e9f2c..e1e520bc89 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -41,6 +41,7 @@
 #include "compiler/nir/nir.h"
 
 #include "utils.h"
+#include "util/disk_cache.h"
 #include "util/xmlpool.h"
 
 static const __DRIconfigOptionsExtension brw_config_options = {
@@ -1572,6 +1573,8 @@ intelDestroyScreen(__DRIscreen * sPriv)
brw_bufmgr_destroy(screen->bufmgr);
driDestroyOptionInfo(>optionCache);
 
+   disk_cache_destroy(screen->disk_cache);
+
ralloc_free(screen);
sPriv->driverPrivate = NULL;
 }
@@ -2683,6 +2686,8 @@ __DRIconfig **intelInitScreen2(__DRIscreen *dri_screen)
   }
}
 
+   brw_disk_cache_init(screen);
+
return (const __DRIconfig**) intel_screen_make_configs(dri_screen);
 }
 
diff --git a/src/mesa/drivers/dri/i965/intel_screen.h 
b/src/mesa/drivers/dri/i965/intel_screen.h
index 7948617b7f..ef2d08974e 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.h
+++ b/src/mesa/drivers/dri/i965/intel_screen.h
@@ -117,6 +117,8 @@ struct intel_screen
bool mesa_format_supports_texture[MESA_FORMAT_COUNT];
bool mesa_format_supports_render[MESA_FORMAT_COUNT];
enum isl_format mesa_to_isl_render_format[MESA_FORMAT_COUNT];
+
+   struct disk_cache *disk_cache;
 };
 
 extern void intelDestroyContext(__DRIcontext * driContextPriv);

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

Mesa (master): mesa: Correctly print glTexImage dimensions

2018-01-29 Thread Tapani Pälli
Module: Mesa
Branch: master
Commit: 6f8518e068718d48cc62402e7e739502e0bbde48
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6f8518e068718d48cc62402e7e739502e0bbde48

Author: Elie Tournier 
Date:   Thu Jan 25 15:18:10 2018 +

mesa: Correctly print glTexImage dimensions

texture_format_error_check_gles() displays error like "glTexImage%dD".
This patch just replace the %d by the correct dimension.

Signed-off-by: Elie Tournier 
Reviewed-by: Tapani Pälli 

---

 src/mesa/main/teximage.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index e5f8bb0718..cc329e6410 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1787,7 +1787,6 @@ texture_formats_agree(GLenum internalFormat,
  * \param format pixel data format given by the user.
  * \param type pixel data type given by the user.
  * \param internalFormat internal format given by the user.
- * \param dimensions texture image dimensions (must be 1, 2 or 3).
  * \param callerName name of the caller function to print in the error message
  *
  * \return true if a error is found, false otherwise
@@ -1796,8 +1795,7 @@ texture_formats_agree(GLenum internalFormat,
  */
 static bool
 texture_format_error_check_gles(struct gl_context *ctx, GLenum format,
-GLenum type, GLenum internalFormat,
-GLuint dimensions, const char *callerName)
+GLenum type, GLenum internalFormat, const char 
*callerName)
 {
GLenum err = _mesa_es3_error_check_format_and_type(ctx, format, type,
   internalFormat);
@@ -1911,9 +1909,11 @@ texture_error_check( struct gl_context *ctx,
 * Formats and types that require additional extensions (e.g., GL_FLOAT
 * requires GL_OES_texture_float) are filtered elsewhere.
 */
+   char bufCallerName[20];
+   snprintf(bufCallerName, 20, "glTexImage%dD", dimensions);
if (_mesa_is_gles(ctx) &&
-   texture_format_error_check_gles(ctx, format, type, internalFormat,
-   dimensions, "glTexImage%dD")) {
+   texture_format_error_check_gles(ctx, format, type,
+   internalFormat, bufCallerName)) {
   return GL_TRUE;
}
 
@@ -2234,8 +2234,7 @@ texsubimage_error_check(struct gl_context *ctx, GLuint 
dimensions,
 */
if (_mesa_is_gles(ctx) &&
texture_format_error_check_gles(ctx, format, type,
-   internalFormat,
-   dimensions, callerName)) {
+   internalFormat, callerName)) {
   return GL_TRUE;
}
 

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


Mesa (master): mesa: shrink gl_vertex_array

2018-01-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 79cafa0df342f9fdc142ad2ed7d910044f5f4c4f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=79cafa0df342f9fdc142ad2ed7d910044f5f4c4f

Author: Brian Paul 
Date:   Fri Jan 26 14:49:41 2018 -0700

mesa: shrink gl_vertex_array

Inspired by Marek's earlier patch, but goes a little further.
Sort fields from largest to smallest.  Use bitfields.

Reduced from 48 bytes to 32.  Also reduces size of gl_vertex_array_object
from 4144 to 3632

Reviewed-by: Marek Olšák 

---

 src/mesa/main/mtypes.h | 21 +++--
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index b0eeeafbcd..78132de425 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1497,18 +1497,19 @@ struct gl_pixelstore_attrib
  */
 struct gl_vertex_array
 {
-   GLint Size;  /**< components per element (1,2,3,4) */
-   GLenum16 Type;   /**< datatype: GL_FLOAT, GL_INT, etc */
-   GLenum16 Format; /**< default: GL_RGBA, but may be GL_BGRA */
+   /** if NULL, vertex data are in user memory */
+   struct gl_buffer_object *BufferObj;
+   /** Pointer into user memory, or offset into the BufferObj */
+   const GLubyte *Ptr;
GLsizei StrideB;/**< actual stride in bytes */
-   GLuint _ElementSize; /**< size of each element in bytes */
-   const GLubyte *Ptr;  /**< Points to array data */
-   GLboolean Normalized;/**< GL_ARB_vertex_program */
-   GLboolean Integer;   /**< Integer-valued? */
-   GLboolean Doubles;   /**< double precision values are not converted to 
floats */
GLuint InstanceDivisor;  /**< GL_ARB_instanced_arrays */
-
-   struct gl_buffer_object *BufferObj;/**< GL_ARB_vertex_buffer_object */
+   GLenum16 Type;   /**< datatype: GL_FLOAT, GL_INT, etc */
+   GLenum16 Format; /**< default: GL_RGBA, but may be GL_BGRA */
+   unsigned Size:4; /**< components per element (1,2,3,4) */
+   unsigned _ElementSize:8; /**< in bytes, up to 4*sizeof(GLdouble) */
+   unsigned Normalized:1;   /**< GL_ARB_vertex_program */
+   unsigned Integer:1;  /**< Integer-valued? */
+   unsigned Doubles:1;  /**< doubles not converted to floats */
 };
 
 

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


Mesa (master): mesa: shrink size of gl_array_attributes (v2)

2018-01-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: d5f42f96e16f4b1242e51fb9eec6f608b221a1c4
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d5f42f96e16f4b1242e51fb9eec6f608b221a1c4

Author: Brian Paul 
Date:   Mon Jan 29 14:09:54 2018 -0700

mesa: shrink size of gl_array_attributes (v2)

Inspired by Marek's earlier patch, but even smaller.  Sort fields from
largest to smallest.  Use bitfields for more fields (sometimes with an
extra bit for MSVC).  Reduce Stride field to GLshort.

Note that some fields cannot be bitfields because they're accessed via
pointers (such as for glEnableClientState(GL_VERTEX_ARRAY) to set the
Enabled field).

Reduces size from 48 to 24 bytes.
Also reduces size of gl_vertex_array_object from 3632 to 2864 bytes.

And add some assertions in init_array().

v2: use s/GLuint/unsigned/, improve commit comments.

Reviewed-by: Marek Olšák 

---

 src/mesa/main/arrayobj.c |  4 
 src/mesa/main/mtypes.h   | 21 -
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 2810647c7e..9d3ddbfcbf 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -233,7 +233,9 @@ init_array(struct gl_context *ctx,
struct gl_vertex_array_object *vao,
GLuint index, GLint size, GLint type)
 {
+   assert(index < ARRAY_SIZE(vao->VertexAttrib));
struct gl_array_attributes *array = >VertexAttrib[index];
+   assert(index < ARRAY_SIZE(vao->BufferBinding));
struct gl_vertex_buffer_binding *binding = >BufferBinding[index];
 
array->Size = size;
@@ -247,6 +249,8 @@ init_array(struct gl_context *ctx,
array->Integer = GL_FALSE;
array->Doubles = GL_FALSE;
array->_ElementSize = size * _mesa_sizeof_type(type);
+   ASSERT_BITFIELD_SIZE(struct gl_array_attributes, BufferBindingIndex,
+VERT_ATTRIB_MAX - 1);
array->BufferBindingIndex = index;
 
binding->Offset = 0;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 78132de425..dccc152ad8 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1528,18 +1528,21 @@ struct gl_vertex_array
  */
 struct gl_array_attributes
 {
-   GLint Size;  /**< Components per element (1,2,3,4) */
+   /** Points to client array data. Not used when a VBO is bound */
+   const GLubyte *Ptr;
+   /** Offset of the first element relative to the binding offset */
+   GLuint RelativeOffset;
+   GLshort Stride;  /**< Stride as specified with gl*Pointer() */
GLenum16 Type;   /**< Datatype: GL_FLOAT, GL_INT, etc */
GLenum16 Format; /**< Default: GL_RGBA, but may be GL_BGRA */
-   GLsizei Stride;  /**< Stride as specified with gl*Pointer() */
-   const GLubyte *Ptr;  /**< Points to client array data. Not used when a 
VBO is bound */
-   GLintptr RelativeOffset; /**< Offset of the first element relative to the 
binding offset */
GLboolean Enabled;   /**< Whether the array is enabled */
-   GLboolean Normalized;/**< Fixed-point values are normalized when 
converted to floats */
-   GLboolean Integer;   /**< Fixed-point values are not converted to 
floats */
-   GLboolean Doubles;   /**< double precision values are not converted to 
floats */
-   GLuint _ElementSize; /**< Size of each element in bytes */
-   GLuint BufferBindingIndex;/**< Vertex buffer binding */
+   GLubyte Size;/**< Components per element (1,2,3,4) */
+   unsigned Normalized:1;   /**< Fixed-point values are normalized when 
converted to floats */
+   unsigned Integer:1;  /**< Fixed-point values are not converted to 
floats */
+   unsigned Doubles:1;  /**< double precision values are not converted to 
floats */
+   unsigned _ElementSize:8; /**< Size of each element in bytes */
+   /** Index into gl_vertex_array_object::BufferBinding[] array */
+   unsigned BufferBindingIndex:6;
 };
 
 

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


Mesa (master): mesa: replace GLenum with GLenum16 in common structures (v4)

2018-01-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: f96a69f916aed40519e755d0460a83940a58780e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f96a69f916aed40519e755d0460a83940a58780e

Author: Marek Olšák 
Date:   Fri Jan 26 14:25:53 2018 -0700

mesa: replace GLenum with GLenum16 in common structures (v4)

v2: - fix glGet*
- also use GLenum16 for DrawBuffers
v3: - rebase to top of tree (BrianP) and incorporate Ian's suggestions
v4: - fix a GLenum16 bug in VBO/save code, add some STATIC_ASSERT()s

gl_context = 152432 -> 136840 bytes
vbo_context = 22096 -> 20608 bytes

Reviewed-by: Brian Paul 
Reviewed-by: Nicolai Hähnle 

---

 src/mesa/drivers/common/meta.h |   2 +-
 src/mesa/drivers/dri/nouveau/nv04_state_frag.c |   4 +-
 src/mesa/drivers/dri/nouveau/nv10_state_frag.c |   4 +-
 src/mesa/main/attrib.c |  13 +-
 src/mesa/main/buffers.c|  12 +-
 src/mesa/main/buffers.h|   2 +-
 src/mesa/main/context.c|   2 +-
 src/mesa/main/get.c|  38 +
 src/mesa/main/get_hash_params.py   | 152 +-
 src/mesa/main/glheader.h   |   1 +
 src/mesa/main/mtypes.h | 204 -
 src/mesa/vbo/vbo_exec.h|   2 +-
 src/mesa/vbo/vbo_save.h|   4 +-
 src/mesa/vbo/vbo_save_api.c|   2 +
 src/mesa/vbo/vbo_save_draw.c   |   4 +-
 15 files changed, 250 insertions(+), 196 deletions(-)

Diff:   
http://cgit.freedesktop.org/mesa/mesa/diff/?id=f96a69f916aed40519e755d0460a83940a58780e
___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): mesa: fix incorrect size/error test in _mesa_GetUnsignedBytevEXT()

2018-01-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 94843e60562c52975325f59f21cb1c8e89f2fe20
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=94843e60562c52975325f59f21cb1c8e89f2fe20

Author: Brian Paul 
Date:   Mon Jan 29 14:19:44 2018 -0700

mesa: fix incorrect size/error test in _mesa_GetUnsignedBytevEXT()

get_value_size() returns -1 for an error.  The similar check in
_mesa_GetUnsignedBytei_vEXT() is correct.

Found by chance.  There are apparently no Piglit tests which exercise
glGetUnsignedBytei_vEXT() or glGetUnsignedBytevEXT().

Reviewed-by: Andres Rodriguez 
Reviewed-by: Marek Olšák 

---

 src/mesa/main/get.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 5fee9a60bc..bafd1e35b2 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -2064,7 +2064,7 @@ _mesa_GetUnsignedBytevEXT(GLenum pname, GLubyte *data)
 
d = find_value(func, pname, , );
size = get_value_size(d->type, );
-   if (size >= 0) {
+   if (size <= 0) {
   _mesa_problem(ctx, "invalid value type in GetUnsignedBytevEXT()");
}
 

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


Mesa (master): mesa/st/glsl_to_tgsi: Mark first write as unconditional when appropriate

2018-01-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 6a7d1ca2c49ae06bbb323936f1e1c17ba7e2c9a1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6a7d1ca2c49ae06bbb323936f1e1c17ba7e2c9a1

Author: Gert Wollny 
Date:   Mon Jan 29 05:24:00 2018 -0700

mesa/st/glsl_to_tgsi: Mark first write as unconditional when appropriate

In the register lifetime estimation if the first write is unconditional or
conditional but not within a loop then this is an unconditional dominant
write in the sense of register life time estimation.
Add a test case and record the write accordingly.

Fixes: 807e2539e512ca6c96f059da855473eb7be99ba1 ("mesa/st/glsl_to_tgsi: Add
tracking of ifelse writes in register merging")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104803
Signed-off-by: Gert Wollny 
Reviewed-by: Brian Paul 

---

 .../state_tracker/st_glsl_to_tgsi_temprename.cpp   | 24 +-
 .../tests/test_glsl_to_tgsi_lifetime.cpp   | 24 ++
 2 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp
index 3a00b33749..6921a643b7 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp
@@ -197,6 +197,7 @@ private:
static const int write_is_conditional = -1;
static const int conditionality_unresolved = 0;
static const int conditionality_untouched;
+   static const int write_is_unconditional;
 
/* A bit field tracking the nexting levels of if-else clauses where the
 * temporary has (so far) been written to in the if branch, but not in the
@@ -220,6 +221,9 @@ private:
 const int
 temp_comp_access::conditionality_untouched = numeric_limits::max();
 
+const int
+temp_comp_access::write_is_unconditional = numeric_limits::max() - 1;
+
 /* Class to track the access to all components of a temporary register. */
 class temp_access {
 public:
@@ -566,6 +570,13 @@ void temp_comp_access::record_read(int line, prog_scope 
*scope)
   first_read_scope = scope;
}
 
+   /* If the conditionality of the first write is already resolved then
+* no further checks are required.
+*/
+   if (conditionality_in_loop_id == write_is_unconditional ||
+   conditionality_in_loop_id == write_is_conditional)
+  return;
+
/* Check whether we are in a condition within a loop */
const prog_scope *ifelse_scope = scope->in_ifelse_scope();
const prog_scope *enclosing_loop;
@@ -612,9 +623,20 @@ void temp_comp_access::record_write(int line, prog_scope 
*scope)
if (first_write < 0) {
   first_write = line;
   first_write_scope = scope;
+
+  /* If the first write we encounter is not in a conditional branch, or
+   * the conditional write is not within a loop, then this is to be
+   * considered an unconditional dominant write.
+   */
+  const prog_scope *conditional = scope->enclosing_conditional();
+  if (!conditional || !conditional->innermost_loop()) {
+ conditionality_in_loop_id = write_is_unconditional;
+  }
}
 
-   if (conditionality_in_loop_id == write_is_conditional)
+   /* The conditionality of the first write is already resolved. */
+   if (conditionality_in_loop_id == write_is_unconditional ||
+   conditionality_in_loop_id == write_is_conditional)
   return;
 
/* If the nesting depth is larger than the supported level,
diff --git a/src/mesa/state_tracker/tests/test_glsl_to_tgsi_lifetime.cpp 
b/src/mesa/state_tracker/tests/test_glsl_to_tgsi_lifetime.cpp
index a3b0f0e02f..acebfb8293 100644
--- a/src/mesa/state_tracker/tests/test_glsl_to_tgsi_lifetime.cpp
+++ b/src/mesa/state_tracker/tests/test_glsl_to_tgsi_lifetime.cpp
@@ -794,6 +794,30 @@ TEST_F(LifetimeEvaluatorExactTest, 
WriteInIfElseBranchSecondIfInLoop)
run (code, temp_lt_expect({{-1,-1}, {2,9}}));
 }
 
+/** Regression test for bug #104803,
+ *  Read and write in if/else path outside loop and later read in conditional
+ *  within a loop. The first write is to be considered the dominant write.
+ */
+TEST_F(LifetimeEvaluatorExactTest, 
IfElseWriteInBothOutsideLoopReadInElseInLoop)
+{
+   const vector code = {
+  { TGSI_OPCODE_IF, {}, {in0}, {} },
+  {   TGSI_OPCODE_MOV, {1}, {in0}, {} },
+  { TGSI_OPCODE_ELSE, {}, {}, {} },
+  {   TGSI_OPCODE_MOV, {1}, {in1}, {} },
+  { TGSI_OPCODE_ENDIF, {}, {}, {} },
+  { TGSI_OPCODE_BGNLOOP },
+  {   TGSI_OPCODE_IF, {}, {in0}, {} },
+  { TGSI_OPCODE_MOV, {2}, {in1}, {} },
+  {   TGSI_OPCODE_ELSE, {}, {}, {} },
+  { TGSI_OPCODE_MOV, {2}, {1}, {} },
+  {   TGSI_OPCODE_ENDIF, {}, {}, {} },
+  { TGSI_OPCODE_ENDLOOP },
+  { TGSI_OPCODE_MOV, {out0}, {2}, {}},
+  { TGSI_OPCODE_END}
+   };
+   run (code, temp_lt_expect({{-1,-1}, {1,11}, {7, 12}}));
+}
 
 /* A continue in the loop is not relevant */
 

Mesa (master): svga: Check rasterization state object before checking poly_stipple_enable

2018-01-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: e4ca1d64565b4d665bcaf5d08922bfbe1d920e7a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e4ca1d64565b4d665bcaf5d08922bfbe1d920e7a

Author: Neha Bhende 
Date:   Mon Jan 22 15:01:20 2018 -0800

svga: Check rasterization state object before checking poly_stipple_enable

Sometimes rasterization state object could be empty. This is causing
segfault on hw8,9,10 for some traces.

This patch fixes enemy_territory_quake_wars_high,
enemy_territory_quake_wars_low, etqw-demo, lightsmark2008, quake1
glretrace crashes on hw 8,9,10.

Tested with mtt-glretrace and mtt-piglit.

Reviewed-by: Charmaine Lee 
Reviewed-by: Brian Paul 

---

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

diff --git a/src/gallium/drivers/svga/svga_state_tss.c 
b/src/gallium/drivers/svga/svga_state_tss.c
index 63f3c8c858..d598d23c4e 100644
--- a/src/gallium/drivers/svga/svga_state_tss.c
+++ b/src/gallium/drivers/svga/svga_state_tss.c
@@ -256,7 +256,7 @@ svga_reemit_tss_bindings(struct svga_context *svga)
}
 
/* Polygon stipple */
-   if (svga->curr.rast->templ.poly_stipple_enable) {
+   if (svga->curr.rast && svga->curr.rast->templ.poly_stipple_enable) {
   const unsigned unit = svga->state.hw_draw.fs->pstipple_sampler_unit;
   struct svga_hw_view_state *view = >state.hw_draw.views[unit];
 

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


Mesa (master): svga: Adjust alpha for S3TC_DXT1_EXT RGB formats

2018-01-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: d4a5e14fae17c7ea7bb8d1d0d6467fd4e0706dd1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d4a5e14fae17c7ea7bb8d1d0d6467fd4e0706dd1

Author: Neha Bhende 
Date:   Mon Jan 29 09:32:19 2018 -0700

svga: Adjust alpha for S3TC_DXT1_EXT RGB formats

According to spec, S3TC_DXT1_EXT RGB formats are supposed to be
opaque. Correspoding svga formats are not handling it so explicitly
setting it to 1.0.
This fixes piglit test spec@ext_texture_compression_s3tc@s3tc-targeted
Note: This test is testcase for freedesktop bug 100925

Tested with mtt-piglit and mtt-glretrace on 8,9,10,11 and 15

Reviewed-by: Brian Paul 

---

 src/gallium/drivers/svga/svga_shader.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/gallium/drivers/svga/svga_shader.c 
b/src/gallium/drivers/svga/svga_shader.c
index 9e2b65771c..c9cc0f739a 100644
--- a/src/gallium/drivers/svga/svga_shader.c
+++ b/src/gallium/drivers/svga/svga_shader.c
@@ -234,6 +234,10 @@ svga_init_shader_key_common(const struct svga_context 
*svga,
  svga_texture_device_format_has_alpha(view->texture)) ?
 set_alpha : copy_alpha;
 
+ if (view->texture->format == PIPE_FORMAT_DXT1_RGB ||
+ view->texture->format == PIPE_FORMAT_DXT1_SRGB)
+swizzle_tab = set_alpha;
+
  key->tex[i].swizzle_r = swizzle_tab[view->swizzle_r];
  key->tex[i].swizzle_g = swizzle_tab[view->swizzle_g];
  key->tex[i].swizzle_b = swizzle_tab[view->swizzle_b];

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


Mesa (master): mesa: restrict formats being supported by target type for formatquery

2018-01-29 Thread Roland Scheidegger
Module: Mesa
Branch: master
Commit: 21fe02d1d369d25021d0be7f558063e103e2dce7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=21fe02d1d369d25021d0be7f558063e103e2dce7

Author: Roland Scheidegger 
Date:   Sat Jan 27 01:25:26 2018 +0100

mesa: restrict formats being supported by target type for formatquery

The code just considered all formats as being supported if they were either
a valid fbo or texture format.
This was quite awkward since then the query would return "supported" for
e.g. GL_RGB9E5 or compressed formats and target RENDERBUFFER (albeit the driver
could still refuse it in theory). However, when then querying for instance the
internalformat sizes, it would just return 0 (due to the checks being more
strict there).
It was also a problem for texture buffer targets, which have a more restricted
list of formats which are allowed (and again, it would return supported but
then querying sizes would return 0).
So only take validation of formats into account which make sense for a given
target.
Can also toss out some special checks for rgb9e5 later, since we'd never get
there if it wasn't supported in the first place.

Reviewed-by: Alejandro Piñeiro 

---

 src/mesa/main/formatquery.c | 31 +--
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/src/mesa/main/formatquery.c b/src/mesa/main/formatquery.c
index 1846fbc688..303e7b2f8c 100644
--- a/src/mesa/main/formatquery.c
+++ b/src/mesa/main/formatquery.c
@@ -558,15 +558,29 @@ _is_internalformat_supported(struct gl_context *ctx, 
GLenum target,
 * implementation accepts it for any texture specification 
commands, and
 * - unsized or base internal format, if the implementation accepts
 * it for texture or image specification.
+*
+* But also:
+* "If the particualar  and  combination do not make
+* sense, or if a particular type of  is not supported by the
+* implementation the "unsupported" answer should be given. This is not an
+* error.
 */
GLint buffer[1];
 
-   /* At this point an internalformat is valid if it is valid as a texture or
-* as a renderbuffer format. The checks are different because those methods
-* return different values when passing non supported internalformats */
-   if (_mesa_base_tex_format(ctx, internalformat) < 0 &&
-   _mesa_base_fbo_format(ctx, internalformat) == 0)
-  return false;
+   if (target == GL_RENDERBUFFER) {
+  if (_mesa_base_fbo_format(ctx, internalformat) == 0) {
+ return false;
+  }
+   } else if (target == GL_TEXTURE_BUFFER) {
+  if (_mesa_validate_texbuffer_format(ctx, internalformat) ==
+  MESA_FORMAT_NONE) {
+ return false;
+  }
+   } else {
+  if (_mesa_base_tex_format(ctx, internalformat) < 0) {
+ return false;
+  }
+   }
 
/* Let the driver have the final word */
ctx->Driver.QueryInternalFormat(ctx, target, internalformat,
@@ -969,10 +983,7 @@ _mesa_GetInternalformativ(GLenum target, GLenum 
internalformat, GLenum pname,
* and glGetRenderbufferParameteriv functions.
*/
   if (pname == GL_INTERNALFORMAT_SHARED_SIZE) {
- if (_mesa_has_EXT_texture_shared_exponent(ctx) &&
- target != GL_TEXTURE_BUFFER &&
- target != GL_RENDERBUFFER &&
- texformat == MESA_FORMAT_R9G9B9E5_FLOAT) {
+ if (texformat == MESA_FORMAT_R9G9B9E5_FLOAT) {
 buffer[0] = 5;
  }
  goto end;

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


Mesa (master): mesa: remove misleading gles checks for formatquery

2018-01-29 Thread Roland Scheidegger
Module: Mesa
Branch: master
Commit: 09dc4f9012b12c51972e32db653f507448b29490
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=09dc4f9012b12c51972e32db653f507448b29490

Author: Roland Scheidegger 
Date:   Sat Jan 27 01:12:52 2018 +0100

mesa: remove misleading gles checks for formatquery

Testing for gles there is just confusing - this is about target being
supported, if it was valid at all was already determined earlier
(in _legal_parameters). It didn't make sense at all in any case, since
it would only have said false there for gles for 2d but not 2d arrays etc.

Reviewed-by: Alejandro Piñeiro 

---

 src/mesa/main/formatquery.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/mesa/main/formatquery.c b/src/mesa/main/formatquery.c
index 61f798c88f..9174fb6b27 100644
--- a/src/mesa/main/formatquery.c
+++ b/src/mesa/main/formatquery.c
@@ -392,14 +392,12 @@ _is_target_supported(struct gl_context *ctx, GLenum 
target)
 * implementation the "unsupported" answer should be given.
 * This is not an error."
 *
-* For OpenGL ES, queries can only be used with GL_RENDERBUFFER or MS.
+* Note that legality of targets has already been verified.
 */
switch(target){
case GL_TEXTURE_1D:
case GL_TEXTURE_2D:
case GL_TEXTURE_3D:
-  if (!_mesa_is_desktop_gl(ctx))
- return false;
   break;
 
case GL_TEXTURE_1D_ARRAY:

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


Mesa (master): mesa: skip validation of legality of size/type queries for format queries

2018-01-29 Thread Roland Scheidegger
Module: Mesa
Branch: master
Commit: 3c7aa242f5df6ba45acc7338bad088910e4b7330
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3c7aa242f5df6ba45acc7338bad088910e4b7330

Author: Roland Scheidegger 
Date:   Sat Jan 27 01:39:35 2018 +0100

mesa: skip validation of legality of size/type queries for format queries

The size/type query is always legal (if we made it that far).
Removing this causes a difference for GL_TEXTURE_BUFFER - the reason is that
these parameters are valid only with GetTexLevelParameter() if gl 3.1 is
supported, but not if only ARB_texture_buffer_object is supported.
However, while the spec says that these queries return "the same information
as querying GetTexLevelParameter" I believe we're not expected to return just
zeros here. By definition, these pnames are always valid (unlike for the
GetTexLevelParameter() function which would return an error without GL 3.1).
The spec is a bit inconsistent there and open to interpretation - while
mentioning the "same information as querying GetTexLevelParameter" is
returned, it also mentions that 0 is returned for size/type if the
target/format is not supported - implying correct results to be returned
if it is supported, regardless that GetTexLevelParameter would return
an error. (Also, the bit about this returning the same as
GetTexLevelParameter also includes querying stencil type, which isn't
even possible with GetTexLevelParameter.)

This breaks some piglit arb_internalformat_query2 tests (which I believe to
be wrong).

Reviewed-by: Alejandro Piñeiro §

---

 src/mesa/main/formatquery.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/mesa/main/formatquery.c b/src/mesa/main/formatquery.c
index 303e7b2f8c..834f8e 100644
--- a/src/mesa/main/formatquery.c
+++ b/src/mesa/main/formatquery.c
@@ -960,9 +960,6 @@ _mesa_GetInternalformativ(GLenum target, GLenum 
internalformat, GLenum pname,
   mesa_format texformat;
 
   if (target != GL_RENDERBUFFER) {
- if (!_mesa_legal_get_tex_level_parameter_target(ctx, target, true))
-goto end;
-
  baseformat = _mesa_base_tex_format(ctx, internalformat);
   } else {
  baseformat = _mesa_base_fbo_format(ctx, internalformat);

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


Mesa (master): mesa: (trivial) add TODO comment for default results for internal queries

2018-01-29 Thread Roland Scheidegger
Module: Mesa
Branch: master
Commit: 272e7e1bd5c12a3ef36027f0071065b7ce04e9e9
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=272e7e1bd5c12a3ef36027f0071065b7ce04e9e9

Author: Roland Scheidegger 
Date:   Tue Jan 30 01:03:49 2018 +0100

mesa: (trivial) add TODO comment for default results for internal queries

---

 src/mesa/main/formatquery.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/mesa/main/formatquery.c b/src/mesa/main/formatquery.c
index 9174fb6b27..1846fbc688 100644
--- a/src/mesa/main/formatquery.c
+++ b/src/mesa/main/formatquery.c
@@ -700,6 +700,12 @@ _mesa_query_internal_format_default(struct gl_context 
*ctx, GLenum target,
case GL_FRAMEBUFFER_RENDERABLE_LAYERED:
case GL_FRAMEBUFFER_BLEND:
case GL_FILTER:
+  /*
+   * TODO seems a tad optimistic just saying yes to everything here.
+   * Even for combinations which make no sense...
+   * And things like TESS_CONTROL_TEXTURE should definitely default to
+   * NONE if the driver doesn't even support tessellation...
+   */
   params[0] = GL_FULL_SUPPORT;
   break;
case GL_NUM_TILING_TYPES_EXT:

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


Mesa (master): i965: Emit PIPE_CONTROL with ISP bit on older platforms.

2018-01-29 Thread Rafael Antognolli
Module: Mesa
Branch: master
Commit: e7ecc5e1600a9463f3f2fff9a9cdaa35c2f68c04
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e7ecc5e1600a9463f3f2fff9a9cdaa35c2f68c04

Author: Rafael Antognolli 
Date:   Thu Jan 25 17:14:47 2018 -0800

i965: Emit PIPE_CONTROL with ISP bit on older platforms.

Emit it on all platforms since gen7.

Signed-off-by: Rafael Antognolli 
Reviewed-by: Jason Ekstrand 

---

 src/mesa/drivers/dri/i965/intel_batchbuffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c 
b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
index 86d88a701f..8e89963f2f 100644
--- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
@@ -766,7 +766,7 @@ brw_finish_batch(struct brw_context *brw)
   }
 
   /* Do not restore push constant packets during context restore. */
-  if (devinfo->gen == 10)
+  if (devinfo->gen >= 7)
  gen10_emit_isp_disable(brw);
}
 

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


Mesa (master): anv/cmd_buffer: Emit PIPE_CONTROL with ISP bit on older platforms.

2018-01-29 Thread Rafael Antognolli
Module: Mesa
Branch: master
Commit: fa21ddf7b1a672f05fc10f91a15215d607a7a873
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fa21ddf7b1a672f05fc10f91a15215d607a7a873

Author: Rafael Antognolli 
Date:   Thu Jan 25 17:13:26 2018 -0800

anv/cmd_buffer: Emit PIPE_CONTROL with ISP bit on older platforms.

Emit it on all platforms since gen7.

Signed-off-by: Rafael Antognolli 
Reviewed-by: Jason Ekstrand 

---

 src/intel/vulkan/genX_cmd_buffer.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/intel/vulkan/genX_cmd_buffer.c 
b/src/intel/vulkan/genX_cmd_buffer.c
index 3691b4bdec..fc1b6ffe0f 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -975,8 +975,7 @@ genX(BeginCommandBuffer)(
 * emit push constants again before any rendering operation. So we
 * flag them dirty here to make sure they get emitted.
 */
-   if (GEN_GEN == 10)
-  cmd_buffer->state.push_constants_dirty |= VK_SHADER_STAGE_ALL_GRAPHICS;
+   cmd_buffer->state.push_constants_dirty |= VK_SHADER_STAGE_ALL_GRAPHICS;
 
VkResult result = VK_SUCCESS;
if (cmd_buffer->usage_flags &
@@ -1074,8 +1073,7 @@ genX(EndCommandBuffer)(
 
genX(cmd_buffer_apply_pipe_flushes)(cmd_buffer);
 
-   if (GEN_GEN == 10)
-  emit_isp_disable(cmd_buffer);
+   emit_isp_disable(cmd_buffer);
 
anv_cmd_buffer_end_batch_buffer(cmd_buffer);
 

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


Mesa (master): st/glsl_to_nir: remove dead io after conversion to nir

2018-01-29 Thread Timothy Arceri
Module: Mesa
Branch: master
Commit: 2b4afaef1c4e0aeb75be570651bacf3ac7c9838d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2b4afaef1c4e0aeb75be570651bacf3ac7c9838d

Author: Timothy Arceri 
Date:   Mon Jan 29 17:33:57 2018 +1100

st/glsl_to_nir: remove dead io after conversion to nir

This fixes an assert in nir_lower_var_copies() for some bioshock
shaders where an unused clipdistance array has no size.

Reviewed-by: Marek Olšák 

---

 src/mesa/state_tracker/st_glsl_to_nir.cpp | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp 
b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index 2de767625a..8639544142 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -319,6 +319,10 @@ st_glsl_to_nir(struct st_context *st, struct gl_program 
*prog,
 
nir_shader *nir = glsl_to_nir(shader_program, stage, options);
 
+   nir_variable_mode mask =
+  (nir_variable_mode) (nir_var_shader_in | nir_var_shader_out);
+   nir_remove_dead_variables(nir, mask);
+
st_nir_opts(nir);
 
return nir;

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


Mesa (master): nir: partially revert c2acf97fcc9b32e

2018-01-29 Thread Timothy Arceri
Module: Mesa
Branch: master
Commit: 09cd484d6113b76572fd16a2ad834d2660c62cf7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=09cd484d6113b76572fd16a2ad834d2660c62cf7

Author: Timothy Arceri 
Date:   Thu Dec 14 17:22:23 2017 +1100

nir: partially revert c2acf97fcc9b32e

c2acf97fcc9b32e changed the use of double_inputs_read to be
inconsitent with its previous meaning. Here we re-enable the
gather info code that was removed as the modified code from
c2acf97fcc9b32e now uses the double_inputs member rather than
double_inputs_read.

This change allows us to use double_inputs_read with gallium
drivers without impacting double_inputs which is used by i965.

We also make use of the compiler option vs_inputs_dual_locations
to allow for the difference in behaviour between drivers that handle
vs inputs as taking up two locations for doubles, versus those that
treat them as taking a single location.

Reviewed-by: Karol Herbst 

---

 src/compiler/nir/nir_gather_info.c | 29 +++--
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/src/compiler/nir/nir_gather_info.c 
b/src/compiler/nir/nir_gather_info.c
index e98129b22c..743f968035 100644
--- a/src/compiler/nir/nir_gather_info.c
+++ b/src/compiler/nir/nir_gather_info.c
@@ -54,6 +54,11 @@ set_io_mask(nir_shader *shader, nir_variable *var, int 
offset, int len,
  else
 shader->info.inputs_read |= bitfield;
 
+ /* double inputs read is only for vertex inputs */
+ if (shader->info.stage == MESA_SHADER_VERTEX &&
+ glsl_type_is_dual_slot(glsl_without_array(var->type)))
+shader->info.vs.double_inputs_read |= bitfield;
+
  if (shader->info.stage == MESA_SHADER_FRAGMENT) {
 shader->info.fs.uses_sample_qualifier |= var->data.sample;
  }
@@ -88,21 +93,27 @@ static void
 mark_whole_variable(nir_shader *shader, nir_variable *var, bool is_output_read)
 {
const struct glsl_type *type = var->type;
+   bool is_vertex_input = false;
 
if (nir_is_per_vertex_io(var, shader->info.stage)) {
   assert(glsl_type_is_array(type));
   type = glsl_get_array_element(type);
}
 
+   if (!shader->options->vs_inputs_dual_locations &&
+   shader->info.stage == MESA_SHADER_VERTEX &&
+   var->data.mode == nir_var_shader_in)
+  is_vertex_input = true;
+
const unsigned slots =
   var->data.compact ? DIV_ROUND_UP(glsl_get_length(type), 4)
-: glsl_count_attribute_slots(type, false);
+: glsl_count_attribute_slots(type, is_vertex_input);
 
set_io_mask(shader, var, 0, slots, is_output_read);
 }
 
 static unsigned
-get_io_offset(nir_deref_var *deref)
+get_io_offset(nir_deref_var *deref, bool is_vertex_input)
 {
unsigned offset = 0;
 
@@ -117,7 +128,7 @@ get_io_offset(nir_deref_var *deref)
 return -1;
  }
 
- offset += glsl_count_attribute_slots(tail->type, false) *
+ offset += glsl_count_attribute_slots(tail->type, is_vertex_input) *
 deref_array->base_offset;
   }
   /* TODO: we can get the offset for structs here see nir_lower_io() */
@@ -163,7 +174,13 @@ try_mask_partial_io(nir_shader *shader, nir_deref_var 
*deref, bool is_output_rea
   return false;
}
 
-   unsigned offset = get_io_offset(deref);
+   bool is_vertex_input = false;
+   if (!shader->options->vs_inputs_dual_locations &&
+   shader->info.stage == MESA_SHADER_VERTEX &&
+   var->data.mode == nir_var_shader_in)
+  is_vertex_input = true;
+
+   unsigned offset = get_io_offset(deref, is_vertex_input);
if (offset == -1)
   return false;
 
@@ -179,7 +196,8 @@ try_mask_partial_io(nir_shader *shader, nir_deref_var 
*deref, bool is_output_rea
}
 
/* double element width for double types that takes two slots */
-   if (glsl_type_is_dual_slot(glsl_without_array(type))) {
+   if (!is_vertex_input &&
+   glsl_type_is_dual_slot(glsl_without_array(type))) {
   elem_width *= 2;
}
 
@@ -235,7 +253,6 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, 
nir_shader *shader)
 for (uint i = 0; i < glsl_count_attribute_slots(var->type, false); 
i++) {
int idx = var->data.location + i;
shader->info.vs.double_inputs |= BITFIELD64_BIT(idx);
-   shader->info.vs.double_inputs_read |= BITFIELD64_BIT(idx);
 }
  }
   }

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


Mesa (master): radeonsi/nir: add support vs double inputs

2018-01-29 Thread Timothy Arceri
Module: Mesa
Branch: master
Commit: 327c1a7fb3c30b639112f0d3f7c4a9b768434381
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=327c1a7fb3c30b639112f0d3f7c4a9b768434381

Author: Timothy Arceri 
Date:   Fri Dec 15 14:22:16 2017 +1100

radeonsi/nir: add support vs double inputs

Reviewed-by: Marek Olšák 

---

 src/gallium/drivers/radeonsi/si_shader_nir.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c 
b/src/gallium/drivers/radeonsi/si_shader_nir.c
index 94d8def814..453d31bd13 100644
--- a/src/gallium/drivers/radeonsi/si_shader_nir.c
+++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
@@ -681,6 +681,11 @@ bool si_nir_build_llvm(struct si_shader_context *ctx, 
struct nir_shader *nir)
if (nir->info.stage == MESA_SHADER_VERTEX) {
declare_nir_input_vs(ctx, variable, input_idx / 
4, data);
bitcast_inputs(ctx, data, input_idx);
+   if (glsl_type_is_dual_slot(variable->type)) {
+   input_idx += 4;
+   declare_nir_input_vs(ctx, variable, 
input_idx / 4, data);
+   bitcast_inputs(ctx, data, input_idx);
+   }
} else if (nir->info.stage == MESA_SHADER_FRAGMENT) {
declare_nir_input_fs(ctx, variable, input_idx / 
4, data);
bitcast_inputs(ctx, data, input_idx);

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


Mesa (master): compiler: tidy up double_inputs_read uses

2018-01-29 Thread Timothy Arceri
Module: Mesa
Branch: master
Commit: f63e05ae9ea0be38a8fb2dd0ae8f391b8699e757
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f63e05ae9ea0be38a8fb2dd0ae8f391b8699e757

Author: Timothy Arceri 
Date:   Sat Dec 16 14:06:23 2017 +1100

compiler: tidy up double_inputs_read uses

First we move double_inputs_read into a vs struct in the union,
double_inputs_read is only used for vs inputs so this will
save space and also allows us to add a new double_inputs field.

We add the new field because c2acf97fcc9b changed the behaviour
of double_inputs_read, and while it's no longer used to track
actual reads in i965 we do still want to track this for gallium
drivers.

Reviewed-by: Marek Olšák 

---

 src/compiler/glsl/glsl_to_nir.cpp   |  9 +
 src/compiler/glsl/ir_set_program_inouts.cpp |  2 +-
 src/compiler/nir/nir_gather_info.c  |  8 ++--
 src/compiler/shader_info.h  | 10 --
 src/intel/compiler/brw_vec4.cpp |  2 +-
 src/mesa/state_tracker/st_glsl_to_nir.cpp   |  2 +-
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp  |  2 +-
 src/mesa/state_tracker/st_program.c |  2 +-
 8 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/src/compiler/glsl/glsl_to_nir.cpp 
b/src/compiler/glsl/glsl_to_nir.cpp
index c4ef4f5ce1..29e32cde53 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -133,13 +133,13 @@ static void
 nir_remap_attributes(nir_shader *shader)
 {
nir_foreach_variable(var, >inputs) {
-  var->data.location += _mesa_bitcount_64(shader->info.double_inputs_read &
+  var->data.location += _mesa_bitcount_64(shader->info.vs.double_inputs &
   
BITFIELD64_MASK(var->data.location));
}
 
/* Once the remap is done, reset double_inputs_read, so later it will have
 * which location/slots are doubles */
-   shader->info.double_inputs_read = 0;
+   shader->info.vs.double_inputs = 0;
 }
 
 nir_shader *
@@ -363,10 +363,11 @@ nir_visitor::visit(ir_variable *ir)
   }
 
   /* Mark all the locations that require two slots */
-  if (glsl_type_is_dual_slot(glsl_without_array(var->type))) {
+  if (shader->info.stage == MESA_SHADER_VERTEX &&
+  glsl_type_is_dual_slot(glsl_without_array(var->type))) {
  for (uint i = 0; i < glsl_count_attribute_slots(var->type, true); 
i++) {
 uint64_t bitfield = BITFIELD64_BIT(var->data.location + i);
-shader->info.double_inputs_read |= bitfield;
+shader->info.vs.double_inputs |= bitfield;
  }
   }
   break;
diff --git a/src/compiler/glsl/ir_set_program_inouts.cpp 
b/src/compiler/glsl/ir_set_program_inouts.cpp
index 90b06b9f41..1b6c8d750b 100644
--- a/src/compiler/glsl/ir_set_program_inouts.cpp
+++ b/src/compiler/glsl/ir_set_program_inouts.cpp
@@ -118,7 +118,7 @@ mark(struct gl_program *prog, ir_variable *var, int offset, 
int len,
  /* double inputs read is only for vertex inputs */
  if (stage == MESA_SHADER_VERTEX &&
  var->type->without_array()->is_dual_slot())
-prog->info.double_inputs_read |= bitfield;
+prog->info.vs.double_inputs_read |= bitfield;
 
  if (stage == MESA_SHADER_FRAGMENT) {
 prog->info.fs.uses_sample_qualifier |= var->data.sample;
diff --git a/src/compiler/nir/nir_gather_info.c 
b/src/compiler/nir/nir_gather_info.c
index 946939657e..e98129b22c 100644
--- a/src/compiler/nir/nir_gather_info.c
+++ b/src/compiler/nir/nir_gather_info.c
@@ -234,7 +234,8 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, 
nir_shader *shader)
  glsl_type_is_dual_slot(glsl_without_array(var->type))) {
 for (uint i = 0; i < glsl_count_attribute_slots(var->type, false); 
i++) {
int idx = var->data.location + i;
-   shader->info.double_inputs_read |= BITFIELD64_BIT(idx);
+   shader->info.vs.double_inputs |= BITFIELD64_BIT(idx);
+   shader->info.vs.double_inputs_read |= BITFIELD64_BIT(idx);
 }
  }
   }
@@ -356,10 +357,13 @@ nir_shader_gather_info(nir_shader *shader, 
nir_function_impl *entrypoint)
shader->info.outputs_written = 0;
shader->info.outputs_read = 0;
shader->info.patch_outputs_read = 0;
-   shader->info.double_inputs_read = 0;
shader->info.patch_inputs_read = 0;
shader->info.patch_outputs_written = 0;
shader->info.system_values_read = 0;
+   if (shader->info.stage == MESA_SHADER_VERTEX) {
+  shader->info.vs.double_inputs = 0;
+  shader->info.vs.double_inputs_read = 0;
+   }
if (shader->info.stage == MESA_SHADER_FRAGMENT) {
   shader->info.fs.uses_sample_qualifier = false;
}
diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h
index 4492cad0e8..f6dedb8d62 100644
--- a/src/compiler/shader_info.h
+++ b/src/compiler/shader_info.h
@@ -67,8 +67,6 @@ typedef struct 

Mesa (master): radeonsi: pass input_idx to declare_nir_input_vs()

2018-01-29 Thread Timothy Arceri
Module: Mesa
Branch: master
Commit: 44067d6f0d3822bfe7cef449bb5920a986a66cdc
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=44067d6f0d3822bfe7cef449bb5920a986a66cdc

Author: Timothy Arceri 
Date:   Fri Dec 15 14:16:01 2017 +1100

radeonsi: pass input_idx to declare_nir_input_vs()

This make it consistent with declare_nir_input_fs() and will allow
us to support doubles.

Reviewed-by: Marek Olšák 

---

 src/gallium/drivers/radeonsi/si_shader_nir.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c 
b/src/gallium/drivers/radeonsi/si_shader_nir.c
index e05548c1b8..94d8def814 100644
--- a/src/gallium/drivers/radeonsi/si_shader_nir.c
+++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
@@ -554,9 +554,10 @@ si_lower_nir(struct si_shader_selector* sel)
 
 static void declare_nir_input_vs(struct si_shader_context *ctx,
 struct nir_variable *variable,
+unsigned input_index,
 LLVMValueRef out[4])
 {
-   si_llvm_load_input_vs(ctx, variable->data.driver_location / 4, out);
+   si_llvm_load_input_vs(ctx, input_index, out);
 }
 
 static void declare_nir_input_fs(struct si_shader_context *ctx,
@@ -678,7 +679,7 @@ bool si_nir_build_llvm(struct si_shader_context *ctx, 
struct nir_shader *nir)
continue;
 
if (nir->info.stage == MESA_SHADER_VERTEX) {
-   declare_nir_input_vs(ctx, variable, data);
+   declare_nir_input_vs(ctx, variable, input_idx / 
4, data);
bitcast_inputs(ctx, data, input_idx);
} else if (nir->info.stage == MESA_SHADER_FRAGMENT) {
declare_nir_input_fs(ctx, variable, input_idx / 
4, data);

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


Mesa (master): nir: add vs_inputs_dual_locations compiler option

2018-01-29 Thread Timothy Arceri
Module: Mesa
Branch: master
Commit: 5b8de4bdffa1f0caed55a7a3f615dae9f625c53e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5b8de4bdffa1f0caed55a7a3f615dae9f625c53e

Author: Timothy Arceri 
Date:   Mon Jan  8 10:37:27 2018 +1100

nir: add vs_inputs_dual_locations compiler option

Allows nir drivers to either use a single or dual locations for
vs double inputs.

i965 uses dual locations for both OpenGL and Vulkan drivers, for
now gallium OpenGL drivers only use a single location.

The following patch will also make use of this option when
calling nir_shader_gather_info().

Reviewed-by: Karol Herbst 

---

 src/amd/vulkan/radv_shader.c  |  1 +
 src/compiler/glsl/glsl_to_nir.cpp | 14 +-
 src/compiler/nir/nir.h|  6 ++
 src/intel/compiler/brw_compiler.c |  3 +++
 4 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c
index 620effe50e..af094e6220 100644
--- a/src/amd/vulkan/radv_shader.c
+++ b/src/amd/vulkan/radv_shader.c
@@ -67,6 +67,7 @@ static const struct nir_shader_compiler_options nir_options = 
{
.lower_extract_byte = true,
.lower_extract_word = true,
.lower_ffma = true,
+   .vs_inputs_dual_locations = true,
.max_unroll_iterations = 32
 };
 
diff --git a/src/compiler/glsl/glsl_to_nir.cpp 
b/src/compiler/glsl/glsl_to_nir.cpp
index 29e32cde53..1a579f41cd 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -130,11 +130,15 @@ private:
 } /* end of anonymous namespace */
 
 static void
-nir_remap_attributes(nir_shader *shader)
+nir_remap_attributes(nir_shader *shader,
+ const nir_shader_compiler_options *options)
 {
-   nir_foreach_variable(var, >inputs) {
-  var->data.location += _mesa_bitcount_64(shader->info.vs.double_inputs &
-  
BITFIELD64_MASK(var->data.location));
+   if (options->vs_inputs_dual_locations) {
+  nir_foreach_variable(var, >inputs) {
+ var->data.location +=
+_mesa_bitcount_64(shader->info.vs.double_inputs &
+  BITFIELD64_MASK(var->data.location));
+  }
}
 
/* Once the remap is done, reset double_inputs_read, so later it will have
@@ -164,7 +168,7 @@ glsl_to_nir(const struct gl_shader_program *shader_prog,
 * location 0 and vec4 attr1 in location 1, in NIR attr0 will use
 * locations/slots 0 and 1, and attr1 will use location/slot 2 */
if (shader->info.stage == MESA_SHADER_VERTEX)
-  nir_remap_attributes(shader);
+  nir_remap_attributes(shader, options);
 
shader->info.name = ralloc_asprintf(shader, "GLSL%d", shader_prog->Name);
if (shader_prog->Label)
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 41a07b0b48..4bb96c3c95 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -1892,6 +1892,12 @@ typedef struct nir_shader_compiler_options {
 */
bool use_interpolated_input_intrinsics;
 
+   /**
+* Do vertex shader double inputs use two locations? The Vulkan spec
+* requires two locations to be used, OpenGL allows a single location.
+*/
+   bool vs_inputs_dual_locations;
+
unsigned max_unroll_iterations;
 } nir_shader_compiler_options;
 
diff --git a/src/intel/compiler/brw_compiler.c 
b/src/intel/compiler/brw_compiler.c
index e89aeacc7d..e515559acb 100644
--- a/src/intel/compiler/brw_compiler.c
+++ b/src/intel/compiler/brw_compiler.c
@@ -57,6 +57,7 @@ static const struct nir_shader_compiler_options 
scalar_nir_options = {
.lower_unpack_snorm_4x8 = true,
.lower_unpack_unorm_2x16 = true,
.lower_unpack_unorm_4x8 = true,
+   .vs_inputs_dual_locations = true,
.max_unroll_iterations = 32,
 };
 
@@ -78,6 +79,7 @@ static const struct nir_shader_compiler_options 
vector_nir_options = {
.lower_unpack_unorm_2x16 = true,
.lower_extract_byte = true,
.lower_extract_word = true,
+   .vs_inputs_dual_locations = true,
.max_unroll_iterations = 32,
 };
 
@@ -96,6 +98,7 @@ static const struct nir_shader_compiler_options 
vector_nir_options_gen6 = {
.lower_unpack_unorm_2x16 = true,
.lower_extract_byte = true,
.lower_extract_word = true,
+   .vs_inputs_dual_locations = true,
.max_unroll_iterations = 32,
 };
 

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


Mesa (master): radeonsi/nir: fix num_inputs for doubles in vs

2018-01-29 Thread Timothy Arceri
Module: Mesa
Branch: master
Commit: 96cfd4bd7ed8c04b154ad7a855e3c1488cc5fedb
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=96cfd4bd7ed8c04b154ad7a855e3c1488cc5fedb

Author: Timothy Arceri 
Date:   Fri Dec 15 11:22:56 2017 +1100

radeonsi/nir: fix num_inputs for doubles in vs

Reviewed-by: Marek Olšák 

---

 src/gallium/drivers/radeonsi/si_shader_nir.c | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c 
b/src/gallium/drivers/radeonsi/si_shader_nir.c
index 8784117833..34d28b7a72 100644
--- a/src/gallium/drivers/radeonsi/si_shader_nir.c
+++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
@@ -209,8 +209,13 @@ void si_nir_scan_shader(const struct nir_shader *nir,
 * tracker has already mapped them to attributes via
 * variable->data.driver_location.
 */
-   if (nir->info.stage == MESA_SHADER_VERTEX)
+   if (nir->info.stage == MESA_SHADER_VERTEX) {
+   if (glsl_type_is_dual_slot(variable->type))
+   num_inputs += 2;
+   else
+   num_inputs++;
continue;
+   }
 
assert(nir->info.stage != MESA_SHADER_FRAGMENT ||
   (attrib_count == 1 && "not implemented"));
@@ -303,10 +308,8 @@ void si_nir_scan_shader(const struct nir_shader *nir,
info->colors_read |= 0xf0;
}
 
-   if (nir->info.stage != MESA_SHADER_VERTEX)
-   info->num_inputs = num_inputs;
-   else
-   info->num_inputs = nir->num_inputs;
+   info->num_inputs = num_inputs;
+
 
i = 0;
uint64_t processed_outputs = 0;

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


Mesa (master): radeonsi: add bitcast_inputs() helper

2018-01-29 Thread Timothy Arceri
Module: Mesa
Branch: master
Commit: cf75ee3ab1cf95cb19d925821f71b353d394956d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cf75ee3ab1cf95cb19d925821f71b353d394956d

Author: Timothy Arceri 
Date:   Fri Dec 15 14:13:11 2017 +1100

radeonsi: add bitcast_inputs() helper

Will be used in a following patch to help support doubles.

Reviewed-by: Marek Olšák 

---

 src/gallium/drivers/radeonsi/si_shader_nir.c | 21 +++--
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c 
b/src/gallium/drivers/radeonsi/si_shader_nir.c
index 34d28b7a72..e05548c1b8 100644
--- a/src/gallium/drivers/radeonsi/si_shader_nir.c
+++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
@@ -644,6 +644,16 @@ si_nir_load_sampler_desc(struct ac_shader_abi *abi,
return si_load_sampler_desc(ctx, list, index, desc_type);
 }
 
+static void bitcast_inputs(struct si_shader_context *ctx,
+  LLVMValueRef data[4],
+  unsigned input_idx)
+{
+   for (unsigned chan = 0; chan < 4; chan++) {
+   ctx->inputs[input_idx + chan] =
+   LLVMBuildBitCast(ctx->ac.builder, data[chan], 
ctx->ac.i32, "");
+   }
+}
+
 bool si_nir_build_llvm(struct si_shader_context *ctx, struct nir_shader *nir)
 {
struct tgsi_shader_info *info = >shader->selector->info;
@@ -667,15 +677,14 @@ bool si_nir_build_llvm(struct si_shader_context *ctx, 
struct nir_shader *nir)
if (processed_inputs & ((uint64_t)1 << loc))
continue;
 
-   if (nir->info.stage == MESA_SHADER_VERTEX)
+   if (nir->info.stage == MESA_SHADER_VERTEX) {
declare_nir_input_vs(ctx, variable, data);
-   else if (nir->info.stage == MESA_SHADER_FRAGMENT)
+   bitcast_inputs(ctx, data, input_idx);
+   } else if (nir->info.stage == MESA_SHADER_FRAGMENT) {
declare_nir_input_fs(ctx, variable, input_idx / 
4, data);
-
-   for (unsigned chan = 0; chan < 4; chan++) {
-   ctx->inputs[input_idx + chan] =
-   LLVMBuildBitCast(ctx->ac.builder, 
data[chan], ctx->ac.i32, "");
+   bitcast_inputs(ctx, data, input_idx);
}
+
processed_inputs |= ((uint64_t)1 << loc);
}
}

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


Mesa (master): radv/gfx9: fix block compression texture views. (v2)

2018-01-29 Thread Dave Airlie
Module: Mesa
Branch: master
Commit: f6cc15dccd54ff70be987457af790cac1c8fe5bb
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f6cc15dccd54ff70be987457af790cac1c8fe5bb

Author: Dave Airlie 
Date:   Mon Jan 29 04:15:09 2018 +

radv/gfx9: fix block compression texture views. (v2)

This ports a fix from amdvlk, to fix the sizing for mip levels
when block compressed images are viewed using uncompressed views.

My original fix didn't power the clamping, but it looks like
the clamping is required to stop the sizing going too large.

Fixes:
dEQP-VK.image.texel_view_compatible.graphic.extended*bc*
Doesn't crash DOW3 anymore.

Reviewed-by: Bas Nieuwenhuizen 
Fixes: e38685cc62e 'Revert "radv: disable support for VEGA for now."'
Signed-off-by: Dave Airlie 

---

 src/amd/vulkan/radv_image.c | 53 +
 1 file changed, 49 insertions(+), 4 deletions(-)

diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c
index 7babcb4e50..b4de7255c7 100644
--- a/src/amd/vulkan/radv_image.c
+++ b/src/amd/vulkan/radv_image.c
@@ -1069,10 +1069,55 @@ radv_image_view_init(struct radv_image_view *iview,
}
 
if (iview->vk_format != image->vk_format) {
-   iview->extent.width = round_up_u32(iview->extent.width * 
vk_format_get_blockwidth(iview->vk_format),
-  
vk_format_get_blockwidth(image->vk_format));
-   iview->extent.height = round_up_u32(iview->extent.height * 
vk_format_get_blockheight(iview->vk_format),
-   
vk_format_get_blockheight(image->vk_format));
+   unsigned view_bw = vk_format_get_blockwidth(iview->vk_format);
+   unsigned view_bh = vk_format_get_blockheight(iview->vk_format);
+   unsigned img_bw = vk_format_get_blockwidth(image->vk_format);
+   unsigned img_bh = vk_format_get_blockheight(image->vk_format);
+
+   iview->extent.width = round_up_u32(iview->extent.width * 
view_bw, img_bw);
+   iview->extent.height = round_up_u32(iview->extent.height * 
view_bh, img_bh);
+
+   /* Comment ported from amdvlk -
+* If we have the following image:
+*  Uncompressed pixels   Compressed block sizes 
(4x4)
+*  mip0:   22 x 22   6 x 6
+*  mip1:   11 x 11   3 x 3
+*  mip2:5 x  5   2 x 2
+*  mip3:2 x  2   1 x 1
+*  mip4:1 x  1   1 x 1
+*
+* On GFX9 the descriptor is always programmed with the WIDTH 
and HEIGHT of the base level and the HW is
+* calculating the degradation of the block sizes down the 
mip-chain as follows (straight-up
+* divide-by-two integer math):
+*  mip0:  6x6
+*  mip1:  3x3
+*  mip2:  1x1
+*  mip3:  1x1
+*
+* This means that mip2 will be missing texels.
+*
+* Fix this by calculating the base mip's width and height, 
then convert that, and round it
+* back up to get the level 0 size.
+* Clamp the converted size between the original values, and 
next power of two, which
+* means we don't oversize the image.
+*/
+if (device->physical_device->rad_info.chip_class >= GFX9 &&
+vk_format_is_compressed(image->vk_format) &&
+!vk_format_is_compressed(iview->vk_format)) {
+unsigned rounded_img_w = 
util_next_power_of_two(iview->extent.width);
+unsigned rounded_img_h = 
util_next_power_of_two(iview->extent.height);
+unsigned lvl_width  = radv_minify(image->info.width , 
range->baseMipLevel);
+unsigned lvl_height = radv_minify(image->info.height, 
range->baseMipLevel);
+
+lvl_width = round_up_u32(lvl_width * view_bw, img_bw);
+lvl_height = round_up_u32(lvl_height * view_bh, 
img_bh);
+
+lvl_width <<= range->baseMipLevel;
+lvl_height <<= range->baseMipLevel;
+
+iview->extent.width = CLAMP(lvl_width, 
iview->extent.width, rounded_img_w);
+iview->extent.height = CLAMP(lvl_height, 
iview->extent.height, rounded_img_h);
+}
}
 
iview->base_layer = range->baseArrayLayer;

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


Mesa (master): radv: Signal fence correctly after sparse binding.

2018-01-29 Thread Bas Nieuwenhuizen
Module: Mesa
Branch: master
Commit: 0347a83bbfd8d993742e125335c6ae46a6aa5a15
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0347a83bbfd8d993742e125335c6ae46a6aa5a15

Author: Bas Nieuwenhuizen 
Date:   Sat Jan 27 14:51:12 2018 +0100

radv: Signal fence correctly after sparse binding.

It did not signal syncobjs in the fence, and also signalled too early
if there was work on the queue already, as we have to wait till that
work is done.

Fixes: d27aaae4d2 "radv: Add external fence support."
Reviewed-by: Samuel Pitoiset 

---

 src/amd/vulkan/radv_device.c | 46 ++--
 1 file changed, 32 insertions(+), 14 deletions(-)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 4463e6945e..2ce667fd21 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -1996,6 +1996,32 @@ VkResult radv_alloc_sem_info(struct radv_winsys_sem_info 
*sem_info,
return ret;
 }
 
+/* Signals fence as soon as all the work currently put on queue is done. */
+static VkResult radv_signal_fence(struct radv_queue *queue,
+  struct radv_fence *fence)
+{
+   int ret;
+   VkResult result;
+   struct radv_winsys_sem_info sem_info;
+
+   result = radv_alloc_sem_info(_info, 0, NULL, 0, NULL,
+radv_fence_to_handle(fence));
+   if (result != VK_SUCCESS)
+   return result;
+
+   ret = queue->device->ws->cs_submit(queue->hw_ctx, queue->queue_idx,
+  
>device->empty_cs[queue->queue_family_index],
+  1, NULL, NULL, _info,
+  false, fence->fence);
+   radv_free_sem_info(_info);
+
+   /* TODO: find a better error */
+   if (ret)
+   return vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY);
+
+   return VK_SUCCESS;
+}
+
 VkResult radv_QueueSubmit(
VkQueue _queue,
uint32_tsubmitCount,
@@ -2124,18 +2150,7 @@ VkResult radv_QueueSubmit(
 
if (fence) {
if (!fence_emitted) {
-   struct radv_winsys_sem_info sem_info;
-
-   result = radv_alloc_sem_info(_info, 0, NULL, 0, 
NULL,
-_fence);
-   if (result != VK_SUCCESS)
-   return result;
-
-   ret = queue->device->ws->cs_submit(ctx, 
queue->queue_idx,
-  
>device->empty_cs[queue->queue_family_index],
-  1, NULL, NULL, 
_info,
-  false, base_fence);
-   radv_free_sem_info(_info);
+   radv_signal_fence(queue, fence);
}
fence->submitted = true;
}
@@ -2656,8 +2671,11 @@ radv_sparse_image_opaque_bind_memory(struct radv_device 
*device,
 
}
 
-   if (fence && !fence_emitted) {
-   fence->signalled = true;
+   if (fence) {
+   if (!fence_emitted) {
+   radv_signal_fence(queue, fence);
+   }
+   fence->submitted = true;
}
 
return VK_SUCCESS;

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


Mesa (master): vbo: s/cl/array/ in vbo_context.c

2018-01-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 35e0ff5bd5cf4e8c5755b0f93cc739a4b68b91e1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=35e0ff5bd5cf4e8c5755b0f93cc739a4b68b91e1

Author: Brian Paul 
Date:   Fri Jan 19 10:52:57 2018 -0700

vbo: s/cl/array/ in vbo_context.c

I think 'cl' used to mean client array.

Reviewed-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_context.c | 30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index dbeb6871e7..f516c67843 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -51,19 +51,19 @@ check_size(const GLfloat *attr)
  * Helper for initializing a vertex array.
  */
 static void
-init_array(struct gl_context *ctx, struct gl_vertex_array *cl,
+init_array(struct gl_context *ctx, struct gl_vertex_array *array,
unsigned size, const void *pointer)
 {
-   memset(cl, 0, sizeof(*cl));
+   memset(array, 0, sizeof(*array));
 
-   cl->Size = size;
-   cl->Type = GL_FLOAT;
-   cl->Format = GL_RGBA;
-   cl->StrideB = 0;
-   cl->_ElementSize = cl->Size * sizeof(GLfloat);
-   cl->Ptr = pointer;
+   array->Size = size;
+   array->Type = GL_FLOAT;
+   array->Format = GL_RGBA;
+   array->StrideB = 0;
+   array->_ElementSize = array->Size * sizeof(GLfloat);
+   array->Ptr = pointer;
 
-   _mesa_reference_buffer_object(ctx, >BufferObj,
+   _mesa_reference_buffer_object(ctx, >BufferObj,
  ctx->Shared->NullBufferObj);
 }
 
@@ -82,9 +82,9 @@ init_legacy_currval(struct gl_context *ctx)
 * attribute:
 */
for (i = 0; i < VERT_ATTRIB_FF_MAX; i++) {
-  struct gl_vertex_array *cl = >currval[VERT_ATTRIB_FF(i)];
+  struct gl_vertex_array *array = >currval[VERT_ATTRIB_FF(i)];
 
-  init_array(ctx, cl,
+  init_array(ctx, array,
  check_size(ctx->Current.Attrib[i]),
  ctx->Current.Attrib[i]);
}
@@ -98,9 +98,9 @@ init_generic_currval(struct gl_context *ctx)
GLuint i;
 
for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++) {
-  struct gl_vertex_array *cl = >currval[VBO_ATTRIB_GENERIC0 + i];
+  struct gl_vertex_array *array = >currval[VBO_ATTRIB_GENERIC0 + i];
 
-  init_array(ctx, cl, 1, ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + i]);
+  init_array(ctx, array, 1, ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + i]);
}
 }
 
@@ -115,7 +115,7 @@ init_mat_currval(struct gl_context *ctx)
 * attribute:
 */
for (i = 0; i < MAT_ATTRIB_MAX; i++) {
-  struct gl_vertex_array *cl =
+  struct gl_vertex_array *array =
  >currval[VBO_ATTRIB_MAT_FRONT_AMBIENT + i];
   unsigned size;
 
@@ -136,7 +136,7 @@ init_mat_currval(struct gl_context *ctx)
  break;
   }
 
-  init_array(ctx, cl, size, ctx->Light.Material.Attrib[i]);
+  init_array(ctx, array, size, ctx->Light.Material.Attrib[i]);
}
 }
 

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


Mesa (master): vbo: minor clean-ups in vbo_exec.h

2018-01-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 425da3bbfc598d3b64a025e0c43b1bcb63f845e9
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=425da3bbfc598d3b64a025e0c43b1bcb63f845e9

Author: Brian Paul 
Date:   Fri Jan 19 21:16:19 2018 -0700

vbo: minor clean-ups in vbo_exec.h

Reviewed-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_exec.h | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h
index 5f28e70ebe..dc18889b6b 100644
--- a/src/mesa/vbo/vbo_exec.h
+++ b/src/mesa/vbo/vbo_exec.h
@@ -31,14 +31,15 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  */
 
-#ifndef __VBO_EXEC_H__
-#define __VBO_EXEC_H__
+#ifndef VBO_EXEC_H
+#define VBO_EXEC_H
+
 
 #include "main/mtypes.h"
+#include "main/imports.h"
 #include "vbo.h"
 #include "vbo_attrib.h"
 
-#include "main/imports.h"
 
 /**
  * Max number of primitives (number of glBegin/End pairs) per VBO.
@@ -47,9 +48,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 
 /**
- * Size of the VBO to use for glBegin/glVertex/glEnd-style rendering.
+ * Size (in bytes) of the VBO to use for glBegin/glVertex/glEnd-style 
rendering.
  */
-#define VBO_VERT_BUFFER_SIZE (1024*64) /* bytes */
+#define VBO_VERT_BUFFER_SIZE (1024 * 64)
 
 
 struct vbo_exec_eval1_map {

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


Mesa (master): vbo: s/[0]/[VERT_ATTRIB_POS]/ in recalculate_input_bindings()

2018-01-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: d9894ede02d13735c62da3e0ace9e9c647e2956a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d9894ede02d13735c62da3e0ace9e9c647e2956a

Author: Brian Paul 
Date:   Wed Jan 24 13:31:11 2018 -0700

vbo: s/[0]/[VERT_ATTRIB_POS]/ in recalculate_input_bindings()

Reviewed-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_exec_array.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index b11da09dd1..43362db2c7 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -369,11 +369,11 @@ recalculate_input_bindings(struct gl_context *ctx)
*/
   if (ctx->API == API_OPENGL_COMPAT) {
  if (array[VERT_ATTRIB_GENERIC0].Enabled)
-inputs[0] = [VERT_ATTRIB_GENERIC0];
+inputs[VERT_ATTRIB_POS] = [VERT_ATTRIB_GENERIC0];
  else if (array[VERT_ATTRIB_POS].Enabled)
-inputs[0] = [VERT_ATTRIB_POS];
+inputs[VERT_ATTRIB_POS] = [VERT_ATTRIB_POS];
  else {
-inputs[0] = >currval[VBO_ATTRIB_GENERIC0];
+inputs[VERT_ATTRIB_POS] = >currval[VBO_ATTRIB_GENERIC0];
 const_inputs |= VERT_BIT_POS;
  }
 

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


Mesa (master): vbo: move, rename vp_mode enums, get_program_mode() function

2018-01-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: b080fc6199cd47ff2da632521b5baf52e747745f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b080fc6199cd47ff2da632521b5baf52e747745f

Author: Brian Paul 
Date:   Fri Jan 19 21:03:07 2018 -0700

vbo: move, rename vp_mode enums, get_program_mode() function

Instead of NONE/ARB use FF/SHADER.  Move the enum declaration to
vbo_private.h where it's used.

Reviewed-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_exec.h   |  7 ---
 src/mesa/vbo/vbo_exec_array.c |  6 +++---
 src/mesa/vbo/vbo_exec_draw.c  |  7 ---
 src/mesa/vbo/vbo_private.h| 22 --
 src/mesa/vbo/vbo_save_draw.c  |  7 ---
 5 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h
index f1e3881b1f..f02f4591fc 100644
--- a/src/mesa/vbo/vbo_exec.h
+++ b/src/mesa/vbo/vbo_exec.h
@@ -52,13 +52,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define VBO_VERT_BUFFER_SIZE (1024*64) /* bytes */
 
 
-/** Current vertex program mode */
-enum vp_mode {
-   VP_NONE,   /**< fixed function */
-   VP_ARB /**< ARB vertex program or GLSL vertex shader */
-};
-
-
 struct vbo_exec_eval1_map {
struct gl_1d_map *map;
GLuint sz;
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index d990fdf7a8..b11da09dd1 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -319,8 +319,8 @@ recalculate_input_bindings(struct gl_context *ctx)
GLbitfield const_inputs = 0x0;
GLuint i;
 
-   switch (get_program_mode(ctx)) {
-   case VP_NONE:
+   switch (get_vp_mode(ctx)) {
+   case VP_FF:
   /* When no vertex program is active (or the vertex program is generated
* from fixed-function state).  We put the material values into the
* generic slots.  This is the only situation where material values
@@ -351,7 +351,7 @@ recalculate_input_bindings(struct gl_context *ctx)
   }
   break;
 
-   case VP_ARB:
+   case VP_SHADER:
   /* There are no shaders in OpenGL ES 1.x, so this code path should be
* impossible to reach.  The meta code is careful to not use shaders in
* ES1.
diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
index 653a05ad0f..5cea7fe879 100644
--- a/src/mesa/vbo/vbo_exec_draw.c
+++ b/src/mesa/vbo/vbo_exec_draw.c
@@ -185,8 +185,9 @@ vbo_exec_bind_arrays(struct gl_context *ctx)
}
 
/* Overlay other active attributes */
-   switch (get_program_mode(exec->ctx)) {
-   case VP_NONE:
+   switch (get_vp_mode(exec->ctx)) {
+   case VP_FF:
+  /* Point the generic attributes at the legacy material values */
   for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) {
  assert(VERT_ATTRIB_GENERIC(attr) < ARRAY_SIZE(exec->vtx.inputs));
  exec->vtx.inputs[VERT_ATTRIB_GENERIC(attr)] =
@@ -194,7 +195,7 @@ vbo_exec_bind_arrays(struct gl_context *ctx)
   }
   map = vbo->map_vp_none;
   break;
-   case VP_ARB:
+   case VP_SHADER:
   for (attr = 0; attr < VERT_ATTRIB_GENERIC_MAX; attr++) {
  assert(VERT_ATTRIB_GENERIC(attr) < ARRAY_SIZE(exec->vtx.inputs));
  exec->vtx.inputs[VERT_ATTRIB_GENERIC(attr)] =
diff --git a/src/mesa/vbo/vbo_private.h b/src/mesa/vbo/vbo_private.h
index 353525644a..d78593c7fa 100644
--- a/src/mesa/vbo/vbo_private.h
+++ b/src/mesa/vbo/vbo_private.h
@@ -73,18 +73,28 @@ vbo_context(struct gl_context *ctx)
 
 
 /**
- * Return VP_x token to indicate whether we're running fixed-function
- * vertex transformation, an NV vertex program or ARB vertex program/shader.
+ * Current vertex processing mode: fixed function vs. shader.
+ * In reality, fixed function is probably implemented by a shader but that's
+ * not what we care about here.
+ */
+enum vp_mode {
+   VP_FF,/**< legacy / fixed function */
+   VP_SHADER /**< ARB vertex program or GLSL vertex shader */
+};
+
+
+/**
+ * Get current vertex processing mode (fixed function vs. shader).
  */
 static inline enum vp_mode
-get_program_mode( struct gl_context *ctx )
+get_vp_mode( struct gl_context *ctx )
 {
if (!ctx->VertexProgram._Current)
-  return VP_NONE;
+  return VP_FF;
else if (ctx->VertexProgram._Current == ctx->VertexProgram._TnlProgram)
-  return VP_NONE;
+  return VP_FF;
else
-  return VP_ARB;
+  return VP_SHADER;
 }
 
 
diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index 8cfe10bdc5..60405d54ea 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -164,15 +164,16 @@ bind_vertex_list(struct gl_context *ctx,
}
 
/* Overlay other active attributes */
-   switch (get_program_mode(ctx)) {
-   case VP_NONE:
+   switch (get_vp_mode(ctx)) {
+   case VP_FF:
+  /* Point the generic attributes at the legacy material values */
   for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) {
  save->inputs[VERT_ATTRIB_GENERIC(attr)] =
 

Mesa (master): mesa/vbo: replace vbo_draw_method() with _mesa_set_drawing_arrays()

2018-01-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 0d044f7d619c56c67d8235312363d93e2362248f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0d044f7d619c56c67d8235312363d93e2362248f

Author: Brian Paul 
Date:   Wed Jan 24 09:14:35 2018 -0700

mesa/vbo: replace vbo_draw_method() with _mesa_set_drawing_arrays()

The arrays specified by ctx->Array._DrawArrays are used for all
vertex drawing via vbo_context::draw_prims().  Different arrays are
used for immediate mode, vertex arrays, display lists, etc.  Changing
from one to another requires updating derived/driver array state.

Before, we indirectly specifid the arrays with the gl_draw_method values.
Now we just directly specify the arrays instead.  This is simpler and
will allow a subsequent display list optimization.

In the future, it might make sense to get rid of ctx->Array._DrawArrays
entirely and just pass the arrays as another parameter to
vbo_context::draw_prims().

Reviewed-by: Mathias Fröhlich 

---

 src/mesa/main/arrayobj.c  | 25 +++--
 src/mesa/main/attrib.c|  5 ++---
 src/mesa/main/mtypes.h| 16 
 src/mesa/main/varray.h| 15 +++
 src/mesa/vbo/vbo_exec_api.c   |  2 +-
 src/mesa/vbo/vbo_exec_array.c |  2 +-
 src/mesa/vbo/vbo_private.h| 37 -
 src/mesa/vbo/vbo_save_draw.c  |  6 --
 8 files changed, 34 insertions(+), 74 deletions(-)

diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 0f474243a7..2810647c7e 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -433,20 +433,17 @@ bind_vertex_array(struct gl_context *ctx, GLuint id, bool 
no_error)
   newObj->EverBound = GL_TRUE;
}
 
-   if (ctx->Array.DrawMethod == DRAW_ARRAYS) {
-  /* The _DrawArrays pointer is pointing at the VAO being unbound and
-   * that VAO may be in the process of being deleted. If it's not going
-   * to be deleted, this will have no effect, because the pointer needs
-   * to be updated by the VBO module anyway.
-   *
-   * Before the VBO module can update the pointer, we have to set it
-   * to NULL for drivers not to set up arrays which are not bound,
-   * or to prevent a crash if the VAO being unbound is going to be
-   * deleted.
-   */
-  ctx->Array._DrawArrays = NULL;
-  ctx->Array.DrawMethod = DRAW_NONE;
-   }
+   /* The _DrawArrays pointer is pointing at the VAO being unbound and
+* that VAO may be in the process of being deleted. If it's not going
+* to be deleted, this will have no effect, because the pointer needs
+* to be updated by the VBO module anyway.
+*
+* Before the VBO module can update the pointer, we have to set it
+* to NULL for drivers not to set up arrays which are not bound,
+* or to prevent a crash if the VAO being unbound is going to be
+* deleted.
+*/
+   _mesa_set_drawing_arrays(ctx, NULL);
 
ctx->NewState |= _NEW_ARRAY;
_mesa_reference_vao(ctx, >Array.VAO, newObj);
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 0fdadaf0aa..50b65c413e 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1538,9 +1538,8 @@ copy_array_attrib(struct gl_context *ctx,
/* skip ArrayBufferObj */
/* skip IndexBufferObj */
 
-   /* Invalidate draw state. It will be updated during the next draw. */
-   dest->DrawMethod = DRAW_NONE;
-   dest->_DrawArrays = NULL;
+   /* Invalidate array state. It will be updated during the next draw. */
+   _mesa_set_drawing_arrays(ctx, NULL);
 }
 
 /**
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 361b63c1c4..9cd32c3aaa 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1604,19 +1604,6 @@ struct gl_vertex_array_object
 
 
 /**
- * Used to signal when transitioning from one kind of drawing method
- * to another.
- */
-typedef enum
-{
-   DRAW_NONE,  /**< Initial value only */
-   DRAW_BEGIN_END,
-   DRAW_DISPLAY_LIST,
-   DRAW_ARRAYS
-} gl_draw_method;
-
-
-/**
  * Enum for the OpenGL APIs we know about and may support.
  *
  * NOTE: This must match the api_enum table in
@@ -1666,9 +1653,6 @@ struct gl_array_attrib
GLuint RestartIndex;
/*@}*/
 
-   /** One of the DRAW_xxx flags, not consumed by drivers */
-   gl_draw_method DrawMethod;
-
/* GL_ARB_vertex_buffer_object */
struct gl_buffer_object *ArrayBufferObj;
 
diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h
index 65e0f7b56c..93f2f477fa 100644
--- a/src/mesa/main/varray.h
+++ b/src/mesa/main/varray.h
@@ -78,6 +78,21 @@ _mesa_attr_zero_aliases_vertex(const struct gl_context *ctx)
return ctx->_AttribZeroAliasesVertex;
 }
 
+
+/**
+ * This specifies the set of vertex arrays used by the driver for drawing.
+ */
+static inline void
+_mesa_set_drawing_arrays(struct gl_context *ctx,
+ const struct gl_vertex_array **arrays)
+{
+   if (ctx->Array._DrawArrays != 

Mesa (master): vbo: whitespace/formatting fixes in vbo_exec.h

2018-01-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 094a80db4c9478391f78cae852c3a482a2f98ada
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=094a80db4c9478391f78cae852c3a482a2f98ada

Author: Brian Paul 
Date:   Fri Jan 19 21:13:52 2018 -0700

vbo: whitespace/formatting fixes in vbo_exec.h

Reviewed-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_exec.h | 33 ++---
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h
index f02f4591fc..5f28e70ebe 100644
--- a/src/mesa/vbo/vbo_exec.h
+++ b/src/mesa/vbo/vbo_exec.h
@@ -136,28 +136,31 @@ struct vbo_exec_context
 
 
 
-/* External API:
- */
-void vbo_exec_init( struct gl_context *ctx );
-void vbo_exec_destroy( struct gl_context *ctx );
+void
+vbo_exec_init(struct gl_context *ctx);
 
+void
+vbo_exec_destroy(struct gl_context *ctx);
 
-/* Internal functions:
- */
-void vbo_exec_vtx_init( struct vbo_exec_context *exec );
-void vbo_exec_vtx_destroy( struct vbo_exec_context *exec );
+void
+vbo_exec_vtx_init(struct vbo_exec_context *exec);
 
+void
+vbo_exec_vtx_destroy(struct vbo_exec_context *exec);
 
-void vbo_exec_vtx_flush( struct vbo_exec_context *exec, GLboolean unmap );
-void vbo_exec_vtx_map( struct vbo_exec_context *exec );
+void
+vbo_exec_vtx_flush(struct vbo_exec_context *exec, GLboolean unmap);
 
+void
+vbo_exec_vtx_map(struct vbo_exec_context *exec);
 
-void vbo_exec_eval_update( struct vbo_exec_context *exec );
+void
+vbo_exec_eval_update(struct vbo_exec_context *exec);
 
-void vbo_exec_do_EvalCoord2f( struct vbo_exec_context *exec, 
-GLfloat u, GLfloat v );
+void
+vbo_exec_do_EvalCoord2f(struct vbo_exec_context *exec, GLfloat u, GLfloat v);
 
-void vbo_exec_do_EvalCoord1f( struct vbo_exec_context *exec,
-GLfloat u);
+void
+vbo_exec_do_EvalCoord1f(struct vbo_exec_context *exec, GLfloat u);
 
 #endif

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


Mesa (master): vbo: s/VBO_ATTRIB_INDEX/VBO_ATTRIB_COLOR_INDEX/

2018-01-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 41cd3ee5a2bcb8b542c58e886442eb752b013ec7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=41cd3ee5a2bcb8b542c58e886442eb752b013ec7

Author: Brian Paul 
Date:   Fri Jan 19 21:44:20 2018 -0700

vbo: s/VBO_ATTRIB_INDEX/VBO_ATTRIB_COLOR_INDEX/

To match the VERT_ATTRIB_COLOR_INDEX name.
Give a name to the previously anonymous enum of VBO_ATTRIB_x values.
Update the comment on the enum.

Reviewed-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_attrib.h | 21 +++--
 src/mesa/vbo/vbo_attrib_tmp.h |  4 ++--
 2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/src/mesa/vbo/vbo_attrib.h b/src/mesa/vbo/vbo_attrib.h
index fb11596e88..ba36ab75aa 100644
--- a/src/mesa/vbo/vbo_attrib.h
+++ b/src/mesa/vbo/vbo_attrib.h
@@ -34,22 +34,23 @@
 
 
 /*
- * Note: The first attributes match the VERT_ATTRIB_* definitions
- * in mtypes.h.  However, the tnl module has additional attributes
- * for materials, color indexes, edge flags, etc.
+ * Note: The first 32 attributes match the VERT_ATTRIB_* definitions.
+ * However, we have extra attributes for storing per-vertex glMaterial
+ * values.  The material attributes get shifted into the generic positions
+ * at draw time.
+ *
+ * One reason we can't alias materials and generics here is display lists.
+ * A display list might contain both generic attributes and material
+ * attributes which are selected at draw time depending on whether we're
+ * using fixed function or a shader.  
  */
-/* Although it's nice to use these as bit indexes in a DWORD flag, we
- * could manage without if necessary.  Another limit currently is the
- * number of bits allocated for these numbers in places like vertex
- * program instruction formats and register layouts.
- */
-enum {
+enum vbo_attrib {
VBO_ATTRIB_POS,
VBO_ATTRIB_NORMAL,
VBO_ATTRIB_COLOR0,
VBO_ATTRIB_COLOR1,
VBO_ATTRIB_FOG,
-   VBO_ATTRIB_INDEX,
+   VBO_ATTRIB_COLOR_INDEX,
VBO_ATTRIB_EDGEFLAG,
VBO_ATTRIB_TEX0,
VBO_ATTRIB_TEX1,
diff --git a/src/mesa/vbo/vbo_attrib_tmp.h b/src/mesa/vbo/vbo_attrib_tmp.h
index 126e4ef0d6..fd24e571c7 100644
--- a/src/mesa/vbo/vbo_attrib_tmp.h
+++ b/src/mesa/vbo/vbo_attrib_tmp.h
@@ -445,14 +445,14 @@ static void GLAPIENTRY
 TAG(Indexf)(GLfloat f)
 {
GET_CURRENT_CONTEXT(ctx);
-   ATTR1F(VBO_ATTRIB_INDEX, f);
+   ATTR1F(VBO_ATTRIB_COLOR_INDEX, f);
 }
 
 static void GLAPIENTRY
 TAG(Indexfv)(const GLfloat * f)
 {
GET_CURRENT_CONTEXT(ctx);
-   ATTR1FV(VBO_ATTRIB_INDEX, f);
+   ATTR1FV(VBO_ATTRIB_COLOR_INDEX, f);
 }
 
 

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


Mesa (master): vbo: add new VBO_ATTRIBS_ masks to vbo_attrib.h

2018-01-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: 48a6ab472a4759c93cf5c84e6e123704c8240135
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=48a6ab472a4759c93cf5c84e6e123704c8240135

Author: Brian Paul 
Date:   Thu Jan 18 12:28:11 2018 -0700

vbo: add new VBO_ATTRIBS_ masks to vbo_attrib.h

These will be used in a later patch.

Reviewed-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_attrib.h | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/src/mesa/vbo/vbo_attrib.h b/src/mesa/vbo/vbo_attrib.h
index ba36ab75aa..fb178e17d6 100644
--- a/src/mesa/vbo/vbo_attrib.h
+++ b/src/mesa/vbo/vbo_attrib.h
@@ -32,6 +32,7 @@
 #ifndef VBO_ATTRIB_H
 #define VBO_ATTRIB_H
 
+#include "main/mtypes.h"
 
 /*
  * Note: The first 32 attributes match the VERT_ATTRIB_* definitions.
@@ -103,6 +104,20 @@ enum vbo_attrib {
 #define VBO_ATTRIB_FIRST_MATERIAL VBO_ATTRIB_MAT_FRONT_AMBIENT
 #define VBO_ATTRIB_LAST_MATERIAL VBO_ATTRIB_MAT_BACK_INDEXES
 
+
+/** VBO_ATTRIB_POS .. VBO_ATTRIB_POINT_SIZE */
+#define VBO_ATTRIBS_LEGACY  BITFIELD64_MASK(VBO_ATTRIB_GENERIC0)
+
+/** VBO_ATTRIB_MAT_FRONT_AMBIENT .. VBO_ATTRIB_MAT_BACK_INDEXES */
+#define VBO_ATTRIBS_MATERIALS BITFIELD64_RANGE(VBO_ATTRIB_MAT_FRONT_AMBIENT, \
+ VBO_ATTRIB_LAST_MATERIAL - VBO_ATTRIB_FIRST_MATERIAL + 1)
+
+/** Shift to move legacy material attribs into generic slots */
+#define VBO_MATERIAL_SHIFT (VBO_ATTRIB_FIRST_MATERIAL - VBO_ATTRIB_GENERIC0)
+
+
+
+
 #define VBO_MAX_COPIED_VERTS 3
 
 #endif

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


Mesa (master): vbo: s/_API_NOOP_H/VBO_NOOP_H/ in vbo_noop.h

2018-01-29 Thread Brian Paul
Module: Mesa
Branch: master
Commit: d631ea3a2327019105239421bd8bd214f796e94f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d631ea3a2327019105239421bd8bd214f796e94f

Author: Brian Paul 
Date:   Fri Jan 19 21:14:49 2018 -0700

vbo: s/_API_NOOP_H/VBO_NOOP_H/ in vbo_noop.h

Reviewed-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_noop.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/mesa/vbo/vbo_noop.h b/src/mesa/vbo/vbo_noop.h
index f61cd5136d..8aa17ce9ed 100644
--- a/src/mesa/vbo/vbo_noop.h
+++ b/src/mesa/vbo/vbo_noop.h
@@ -23,8 +23,8 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
-#ifndef _API_NOOP_H
-#define _API_NOOP_H
+#ifndef VBO_NOOP_H
+#define VBO_NOOP_H
 
 
 #include "main/mtypes.h"
@@ -37,4 +37,4 @@ extern GLboolean
 _mesa_using_noop_vtxfmt(const struct _glapi_table *dispatch);
 
 
-#endif /* _API_NOOP_H */
+#endif /* VBO_NOOP_H */

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


Mesa: tag mesa-18.0.0-rc3: mesa-18.0.0-rc3

2018-01-29 Thread Emil Velikov
Module: Mesa
Branch: refs/tags/mesa-18.0.0-rc3
Tag:96aa32abc3e341d9f12107b963e6642a0fcb6904
URL:
http://cgit.freedesktop.org/mesa/mesa/tag/?id=96aa32abc3e341d9f12107b963e6642a0fcb6904

Tagger: Emil Velikov 
Date:   Mon Jan 29 11:33:33 2018 +

mesa-18.0.0-rc3
___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (18.0): 55 new commits

2018-01-29 Thread Emil Velikov
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=17c0e248d75fc40efbca13164e897a009b2e3b23
Author: Emil Velikov 
Date:   Mon Jan 29 11:27:18 2018 +

Update version to 18.0.0-rc3

Signed-off-by: Emil Velikov 

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=92a332ed1a0d4753f78a6c5d58615ef1e5512dc6
Author: Emil Velikov 
Date:   Fri Jan 26 19:06:46 2018 +

cherry-ignore: add patches picked without -x

Signed-off-by: Emil Velikov 

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=74b39c0bbf2467799b2b225c8059ce56413147cb
Author: Maxin B. John 
Date:   Thu Jan 18 13:33:37 2018 +0200

anv_icd.py: improve reproducible builds

Sort the output to ensure build reproducibility

Signed-off-by: Maxin B. John 
Reviewed-by: Emil Velikov 
Fixes: 0ab04ba979b ("anv: Use python to generate ICD json files")
Reviewed-by: Dylan Baker 
Reviewed-by: Jason Ekstrand 
(cherry picked from commit 8116b9170bc36bb15512f97a7680ad97bddd56a8)

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a5bdf2abf9d87c34ab5ebec5a2bbf78b4e19db5b
Author: Bas Nieuwenhuizen 
Date:   Thu Jan 25 16:48:17 2018 +0100

radeonsi: Export signalled sync file instead of -1.

-1 is considered an error for EGL_ANDROID_native_fence_sync, so
we need to actually create a sync file.

Fixes: f536f45250 "radeonsi: implement sync_file import/export"
Reviewed-by: Dave Airlie 
(cherry picked from commit 5a3404d443e0c6e8e9a44d7f8dccf96c5ac18f0f)

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=305b0b135612dfe80b95f20e22fb5a526f8fa886
Author: Dave Airlie 
Date:   Thu Jan 25 09:29:55 2018 +1000

radv: don't enable tc compat for d32s8 + 4/8 samples (v1.1)

This seems to be broken, at least the cts tests fail.

This fixes:
dEQP-VK.renderpass.suballocation.multisample.d32_sfloat_s8_uint.samples_4
dEQP-VK.renderpass.suballocation.multisample.d32_sfloat_s8_uint.samples_8

2 samples seems to pass fine, amdvlk doesn't appear to enable TC for
possibly some other reasons here.

This is most likely a hack.

v1.1: add a bit of explaination text. (Samuel)
Fixes: ad3d98da9 (radv: enable tc compatible htile for d32s8 also.)
Signed-off-by: Dave Airlie 
Reviewed-by: Samuel Pitoiset 
(cherry picked from commit f4c534ef68a479055190f8ec8d551be0f56ef361)

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=28680e72b87aa29fa7542c5a55eceb6ccb356204
Author: Emil Velikov 
Date:   Wed Dec 20 17:34:55 2017 +

configure.ac: correct driglx-direct help text

The default was toggled a while back, but the text wasn't updated.

Fixes: bd526ec9e1b ("configure: Always default to
--enable-driglx-direct")
Cc: Jon TURNEY 
Signed-off-by: Emil Velikov 
Reviewed-by: Daniel Stone 
(cherry picked from commit 6aeef5464497a2dfd2eb63c7e4aa3349c7794eae)

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=32b2c0da59ec97e0f524430209992d01498a29a6
Author: Roland Scheidegger 
Date:   Thu Jan 25 04:30:41 2018 +0100

gallivm: fix crash with seamless cube filtering with different min/mag 
filter

We are not allowed to modify the incoming coords values, or things may
crash (as we may be inside a llvm conditional and the values may be used
in another branch).
I recently broke this when fixing an issue with NaNs and seamless cube
map filtering, and it causes crashes when doing cubemap filtering
if the min and mag filters are different.
Add const to the pointers passed in to prevent this mishap in the future.

Fixes: a485ad0bcd ("gallivm: fix an issue with NaNs with seamless cube 
filtering")

Reviewed-by: Jose Fonseca 
(cherry picked from commit 4fe662c58f6453b3558de479e7c2bfe4158dc26c)

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b01ea9701e328896659a5ffad79f2762f177a087
Author: Greg V 
Date:   Wed Jan 24 21:02:43 2018 +0300

meson: handle LLVM 'x.x.xgit-revision' versions

When LLVM is built inside of a git repo (even way below, e.g. 
/usr/ports/.git
exists, and LLVM is built in /usr/ports/devel/llvm50/work), its version
becomes something like 5.0.0git-f8ab206b2176.

New meson versions already handle this, but we support older versions too.

Fixes: 673dda8330769 ("meson: build "radv" vulkan driver for radeon 
hardware")
Reviewed-by: Dylan Baker