Mesa (master): mesa/formatquery: remove online compression check on is_resource_supported

2018-05-08 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: b6648798cf3c4b0f970c468aed7ac1ee7eb82109
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b6648798cf3c4b0f970c468aed7ac1ee7eb82109

Author: Alejandro Piñeiro 
Date:   Fri May  4 16:44:44 2018 +0200

mesa/formatquery: remove online compression check on is_resource_supported

is_resource_supported returns if the combination of
target/internalformat is supported in at least one operation. Online
compression is only mandatory for glTexImage2D. Some formats doesn't
support online compression, but can be used in any case, with
glCompressed*D methods.

Without this commit, ETC2 internalformats were returning FALSE, even
for the drivers supporting it. So any other query (like
TEXTURE_COMPRESSED) was returning FALSE/NONE instead of the proper
value.

Reviewed-by: Marek Olšák 

---

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

diff --git a/src/mesa/main/formatquery.c b/src/mesa/main/formatquery.c
index 3b000fac5c..84b5f512ba 100644
--- a/src/mesa/main/formatquery.c
+++ b/src/mesa/main/formatquery.c
@@ -501,8 +501,7 @@ _is_resource_supported(struct gl_context *ctx, GLenum 
target,
 
   /* additional checks for compressed textures */
   if (_mesa_is_compressed_format(ctx, internalformat) &&
-  (!_mesa_target_can_be_compressed(ctx, target, internalformat, NULL) 
||
-   _mesa_format_no_online_compression(internalformat)))
+  !_mesa_target_can_be_compressed(ctx, target, internalformat, NULL))
  return false;
 
   break;

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


Mesa (master): mesa/glspirv: Add a _mesa_spirv_to_nir() function

2018-03-30 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: abb6d0797c8a0c32f45d38d7a41e96b2db47a47d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=abb6d0797c8a0c32f45d38d7a41e96b2db47a47d

Author: Eduardo Lima Mitev 
Date:   Fri Oct 13 10:31:50 2017 +0200

mesa/glspirv: Add a _mesa_spirv_to_nir() function

This is basically a wrapper around spirv_to_nir() that includes
arguments setup and post-conversion validation.

v2: * Rebase update (SpirVCapabilities not a pointer anymore,
spirv_to_nir_options added, and others).
* Code-style improvements and remove debug hunk. (Timothy Arceri)

Reviewed-by: Timothy Arceri 

---

 src/mesa/main/glspirv.c | 58 +
 src/mesa/main/glspirv.h |  7 ++
 2 files changed, 65 insertions(+)

diff --git a/src/mesa/main/glspirv.c b/src/mesa/main/glspirv.c
index 7aa06f8e8c..71dc9154ef 100644
--- a/src/mesa/main/glspirv.c
+++ b/src/mesa/main/glspirv.c
@@ -174,6 +174,64 @@ _mesa_spirv_link_shaders(struct gl_context *ctx, struct 
gl_shader_program *prog)
}
 }
 
+nir_shader *
+_mesa_spirv_to_nir(struct gl_context *ctx,
+   const struct gl_shader_program *prog,
+   gl_shader_stage stage,
+   const nir_shader_compiler_options *options)
+{
+   nir_shader *nir = NULL;
+
+   struct gl_linked_shader *linked_shader = prog->_LinkedShaders[stage];
+   assert (linked_shader);
+
+   struct gl_shader_spirv_data *spirv_data = linked_shader->spirv_data;
+   assert(spirv_data);
+
+   struct gl_spirv_module *spirv_module = spirv_data->SpirVModule;
+   assert (spirv_module != NULL);
+
+   const char *entry_point_name = spirv_data->SpirVEntryPoint;
+   assert(entry_point_name);
+
+   struct nir_spirv_specialization *spec_entries =
+  calloc(sizeof(*spec_entries),
+ spirv_data->NumSpecializationConstants);
+
+   for (unsigned i = 0; i < spirv_data->NumSpecializationConstants; ++i) {
+  spec_entries[i].id = spirv_data->SpecializationConstantsIndex[i];
+  spec_entries[i].data32 = spirv_data->SpecializationConstantsValue[i];
+  spec_entries[i].defined_on_module = false;
+   }
+
+   const struct spirv_to_nir_options spirv_options = {
+  .caps = ctx->Const.SpirVCapabilities
+   };
+
+   nir_function *entry_point =
+  spirv_to_nir((const uint32_t *) _module->Binary[0],
+   spirv_module->Length / 4,
+   spec_entries, spirv_data->NumSpecializationConstants,
+   stage, entry_point_name,
+   _options,
+   options);
+   free(spec_entries);
+
+   assert (entry_point);
+   nir = entry_point->shader;
+   assert(nir->info.stage == stage);
+
+   nir->options = options;
+
+   nir->info.name =
+  ralloc_asprintf(nir, "SPIRV:%s:%d",
+  _mesa_shader_stage_to_abbrev(nir->info.stage),
+  prog->Name);
+   nir_validate_shader(nir);
+
+   return nir;
+}
+
 void GLAPIENTRY
 _mesa_SpecializeShaderARB(GLuint shader,
   const GLchar *pEntryPoint,
diff --git a/src/mesa/main/glspirv.h b/src/mesa/main/glspirv.h
index 0f03b75c11..81626ce75b 100644
--- a/src/mesa/main/glspirv.h
+++ b/src/mesa/main/glspirv.h
@@ -24,6 +24,7 @@
 #ifndef GLSPIRV_H
 #define GLSPIRV_H
 
+#include "compiler/nir/nir.h"
 #include "mtypes.h"
 
 #ifdef __cplusplus
@@ -80,6 +81,12 @@ void
 _mesa_spirv_link_shaders(struct gl_context *ctx,
  struct gl_shader_program *prog);
 
+nir_shader *
+_mesa_spirv_to_nir(struct gl_context *ctx,
+   const struct gl_shader_program *prog,
+   gl_shader_stage stage,
+   const nir_shader_compiler_options *options);
+
 /**
  * \name API functions
  */

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


Mesa (master): i965: Call spirv_to_nir() instead of glsl_to_nir() for SPIR-V shaders

2018-03-30 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: e7d97aa75ded652a36e8addad52d075c51b58c33
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e7d97aa75ded652a36e8addad52d075c51b58c33

Author: Eduardo Lima Mitev 
Date:   Tue Oct 10 14:55:56 2017 +0200

i965: Call spirv_to_nir() instead of glsl_to_nir() for SPIR-V shaders

This is the main fork of the shader compilation code-path, where a NIR
shader is obtained by calling spirv_to_nir() or glsl_to_nir(),
depending on its nature..

v2: Use 'spirv_data' member from gl_linked_shader to know which method
   to call. (Timothy Arceri)

Reviewed-by: Timothy Arceri 

---

 src/mesa/drivers/dri/i965/brw_program.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_program.c 
b/src/mesa/drivers/dri/i965/brw_program.c
index 4579a58b82..fc77926d6e 100644
--- a/src/mesa/drivers/dri/i965/brw_program.c
+++ b/src/mesa/drivers/dri/i965/brw_program.c
@@ -31,6 +31,7 @@
 
 #include 
 #include "main/imports.h"
+#include "main/glspirv.h"
 #include "program/prog_parameter.h"
 #include "program/prog_print.h"
 #include "program/prog_to_nir.h"
@@ -74,9 +75,14 @@ brw_create_nir(struct brw_context *brw,
   ctx->Const.ShaderCompilerOptions[stage].NirOptions;
nir_shader *nir;
 
-   /* First, lower the GLSL IR or Mesa IR to NIR */
+   /* First, lower the GLSL/Mesa IR or SPIR-V to NIR */
if (shader_prog) {
-  nir = glsl_to_nir(shader_prog, stage, options);
+  if (shader_prog->_LinkedShaders[stage]->spirv_data)
+ nir = _mesa_spirv_to_nir(ctx, shader_prog, stage, options);
+  else
+ nir = glsl_to_nir(shader_prog, stage, options);
+  assert (nir);
+
   nir_remove_dead_variables(nir, nir_var_shader_in | nir_var_shader_out);
   nir_lower_returns(nir);
   nir_validate_shader(nir);

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


Mesa (master): mesa: Implement glSpecializeShaderARB

2018-03-30 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: ba975140d3c99b60c63846c3c08bd158f7c95d42
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ba975140d3c99b60c63846c3c08bd158f7c95d42

Author: Nicolai Hähnle 
Date:   Sat Jun 10 21:36:24 2017 +0200

mesa: Implement glSpecializeShaderARB

v2:
  * Use gl_spirv_validation instead of spirv_to_nir.  This method just
validates the shader. The conversion to NIR will happen later,
during linking. (Alejandro Piñeiro)
  * Use gl_shader_spirv_data struct to store the SPIR-V data.
(Eduardo Lima)
  * Use the 'spirv_data' member to tell if the gl_shader is a SPIR-V
shader, instead of a dedicated flag. (Timothy Arceri)

Signed-off-by: Nicolai Hähnle 
Signed-off-by: Alejandro Piñeiro 
Signed-off-by: Eduardo Lima Mitev 

Reviewed-by: Timothy Arceri 

---

 src/mesa/main/glspirv.c | 107 +++-
 1 file changed, 105 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/glspirv.c b/src/mesa/main/glspirv.c
index 03f761219b..b1185ca5fd 100644
--- a/src/mesa/main/glspirv.c
+++ b/src/mesa/main/glspirv.c
@@ -23,6 +23,11 @@
 
 #include "glspirv.h"
 #include "errors.h"
+#include "shaderobj.h"
+
+#include "compiler/nir/nir.h"
+#include "compiler/spirv/nir_spirv.h"
+
 #include "util/u_atomic.h"
 
 void
@@ -106,7 +111,105 @@ _mesa_SpecializeShaderARB(GLuint shader,
   const GLuint *pConstantValue)
 {
GET_CURRENT_CONTEXT(ctx);
+   struct gl_shader *sh;
+   bool has_entry_point;
+   struct nir_spirv_specialization *spec_entries = NULL;
+
+   if (!ctx->Extensions.ARB_gl_spirv) {
+  _mesa_error(ctx, GL_INVALID_OPERATION, "glSpecializeShaderARB");
+  return;
+   }
+
+   sh = _mesa_lookup_shader_err(ctx, shader, "glSpecializeShaderARB");
+   if (!sh)
+  return;
+
+   if (!sh->spirv_data) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "glSpecializeShaderARB(not SPIR-V)");
+  return;
+   }
+
+   if (sh->CompileStatus) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "glSpecializeShaderARB(already specialized)");
+  return;
+   }
+
+   struct gl_shader_spirv_data *spirv_data = sh->spirv_data;
+
+   /* From the GL_ARB_gl_spirv spec:
+*
+*"The OpenGL API expects the SPIR-V module to have already been
+* validated, and can return an error if it discovers anything invalid
+* in the module. An invalid SPIR-V module is allowed to result in
+* undefined behavior."
+*
+* However, the following errors still need to be detected (from the same
+* spec):
+*
+*"INVALID_VALUE is generated if  does not name a valid
+* entry point for .
+*
+* INVALID_VALUE is generated if any element of 
+* refers to a specialization constant that does not exist in the
+* shader module contained in ."
+*
+* We cannot flag those errors a-priori because detecting them requires
+* parsing the module. However, flagging them during specialization is okay,
+* since it makes no difference in terms of application-visible state.
+*/
+   spec_entries = calloc(sizeof(*spec_entries), numSpecializationConstants);
+
+   for (unsigned i = 0; i < numSpecializationConstants; ++i) {
+  spec_entries[i].id = pConstantIndex[i];
+  spec_entries[i].data32 = pConstantValue[i];
+  spec_entries[i].defined_on_module = false;
+   }
+
+   has_entry_point =
+  gl_spirv_validation((uint32_t *)_data->SpirVModule->Binary[0],
+  spirv_data->SpirVModule->Length / 4,
+  spec_entries, numSpecializationConstants,
+  sh->Stage, pEntryPoint);
+
+   /* See previous spec comment */
+   if (!has_entry_point) {
+  _mesa_error(ctx, GL_INVALID_VALUE,
+  "glSpecializeShaderARB(\"%s\" is not a valid entry point"
+  " for shader)", pEntryPoint);
+  goto end;
+   }
+
+   for (unsigned i = 0; i < numSpecializationConstants; ++i) {
+  if (spec_entries[i].defined_on_module == false) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glSpecializeShaderARB(constant \"%i\" does not exist "
+ "in shader)", spec_entries[i].id);
+ goto end;
+  }
+   }
+
+   spirv_data->SpirVEntryPoint = ralloc_strdup(spirv_data, pEntryPoint);
+
+   /* Note that we didn't make a real compilation of the module (spirv_to_nir),
+* but just checked some error conditions. Real "compilation" will be done
+* later, upon linking.
+*/
+   sh->CompileStatus = COMPILE_SUCCESS;
+
+   spirv_data->NumSpecializationConstants = numSpecializationConstants;
+   spirv_data->SpecializationConstantsIndex =
+  rzalloc_array_size(spirv_data, sizeof(GLuint),
+ numSpecializationConstants);
+   spirv_data->SpecializationConstantsValue =
+  

Mesa (master): mesa/glspirv: Add _mesa_spirv_link_shaders() function

2018-03-30 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 9c36e9f8626fb2b02736abbd11e783b61a40959c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9c36e9f8626fb2b02736abbd11e783b61a40959c

Author: Eduardo Lima Mitev 
Date:   Tue Oct 10 10:46:29 2017 +0200

mesa/glspirv: Add _mesa_spirv_link_shaders() function

This is the equivalent to link_shaders() from
src/compiler/glsl/linker.cpp, but for SPIR-V programs. It just
creates the program and its gl_linked_shader objects, giving drivers
the opportunity to implement any linking of SPIR-V shaders they choose,
at a later stage.

v2: Bail out if we see more that one shader for the same stage, and
add a corresponding comment. (Timothy Arceri)

v3:
  * Adds also a linker error log to the condition above, with a
reference to the specification issue. (Timothy Arceri)
  * Squash with the patch adding the function boilerplate (Timothy
Arceri)

Reviewed-by: Timothy Arceri 

---

 src/mesa/main/glspirv.c | 71 +
 src/mesa/main/glspirv.h |  4 +++
 2 files changed, 75 insertions(+)

diff --git a/src/mesa/main/glspirv.c b/src/mesa/main/glspirv.c
index b1185ca5fd..7aa06f8e8c 100644
--- a/src/mesa/main/glspirv.c
+++ b/src/mesa/main/glspirv.c
@@ -28,6 +28,8 @@
 #include "compiler/nir/nir.h"
 #include "compiler/spirv/nir_spirv.h"
 
+#include "program/program.h"
+
 #include "util/u_atomic.h"
 
 void
@@ -103,6 +105,75 @@ _mesa_spirv_shader_binary(struct gl_context *ctx,
}
 }
 
+/**
+ * This is the equivalent to compiler/glsl/linker.cpp::link_shaders()
+ * but for SPIR-V programs.
+ *
+ * This method just creates the gl_linked_shader structs with a reference to
+ * the SPIR-V data collected during previous steps.
+ *
+ * The real linking happens later in the driver-specifc call LinkShader().
+ * This is so backends can implement different linking strategies for
+ * SPIR-V programs.
+ */
+void
+_mesa_spirv_link_shaders(struct gl_context *ctx, struct gl_shader_program 
*prog)
+{
+   prog->data->LinkStatus = LINKING_SUCCESS;
+   prog->data->Validated = false;
+
+   for (unsigned i = 0; i < prog->NumShaders; i++) {
+  struct gl_shader *shader = prog->Shaders[i];
+  gl_shader_stage shader_type = shader->Stage;
+
+  /* We only support one shader per stage. The gl_spirv spec doesn't seem
+   * to prevent this, but the way the API is designed, requiring all 
shaders
+   * to be specialized with an entry point, makes supporting this quite
+   * undefined.
+   *
+   * TODO: Turn this into a proper error once the spec bug
+   *  is resolved.
+   */
+  if (prog->_LinkedShaders[shader_type]) {
+ ralloc_strcat(>data->InfoLog,
+   "\nError trying to link more than one SPIR-V shader "
+   "per stage.\n");
+ prog->data->LinkStatus = LINKING_FAILURE;
+ return;
+  }
+
+  assert(shader->spirv_data);
+
+  struct gl_linked_shader *linked = rzalloc(NULL, struct gl_linked_shader);
+  linked->Stage = shader_type;
+
+  /* Create program and attach it to the linked shader */
+  struct gl_program *gl_prog =
+ ctx->Driver.NewProgram(ctx,
+_mesa_shader_stage_to_program(shader_type),
+prog->Name, false);
+  if (!gl_prog) {
+ prog->data->LinkStatus = LINKING_FAILURE;
+ _mesa_delete_linked_shader(ctx, linked);
+ return;
+  }
+
+  _mesa_reference_shader_program_data(ctx,
+  _prog->sh.data,
+  prog->data);
+
+  /* Don't use _mesa_reference_program() just take ownership */
+  linked->Program = gl_prog;
+
+  /* Reference the SPIR-V data from shader to the linked shader */
+  _mesa_shader_spirv_data_reference(>spirv_data,
+shader->spirv_data);
+
+  prog->_LinkedShaders[shader_type] = linked;
+  prog->data->linked_stages |= 1 << shader_type;
+   }
+}
+
 void GLAPIENTRY
 _mesa_SpecializeShaderARB(GLuint shader,
   const GLchar *pEntryPoint,
diff --git a/src/mesa/main/glspirv.h b/src/mesa/main/glspirv.h
index ba281f68be..0f03b75c11 100644
--- a/src/mesa/main/glspirv.h
+++ b/src/mesa/main/glspirv.h
@@ -76,6 +76,10 @@ _mesa_spirv_shader_binary(struct gl_context *ctx,
   unsigned n, struct gl_shader **shaders,
   const void* binary, size_t length);
 
+void
+_mesa_spirv_link_shaders(struct gl_context *ctx,
+ struct gl_shader_program *prog);
+
 /**
  * \name API functions
  */

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


Mesa (master): mesa: add gl_constants::SpirVCapabilities

2018-03-30 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: ca5cc78206b993c8d7e765ed4350a1f62a2ee5ed
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ca5cc78206b993c8d7e765ed4350a1f62a2ee5ed

Author: Nicolai Hähnle 
Date:   Sat Jun 10 21:35:26 2017 +0200

mesa: add gl_constants::SpirVCapabilities

For drivers to declare which SPIR-V features they support.

v2: Don't use a pointer (Ian Romanick)

Reviewed-by: Timothy Arceri 

---

 src/mesa/main/mtypes.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 08db8062ec..9ded02500d 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -4135,6 +4135,9 @@ struct gl_constants
 
/** Is the drivers uniform storage packed or padded to 16 bytes. */
bool PackedDriverUniformStorage;
+
+   /** GL_ARB_gl_spirv */
+   struct spirv_supported_capabilities SpirVCapabilities;
 };
 
 

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


Mesa (master): i965: initialize SPIR-V capabilities

2018-03-30 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 3761e675e27b85f43fe86afe37326c9012577e4b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3761e675e27b85f43fe86afe37326c9012577e4b

Author: Alejandro Piñeiro 
Date:   Sat Oct 14 09:23:24 2017 +0200

i965: initialize SPIR-V capabilities

Needed for ARB_gl_spirv. Those are not the same that the Intel vulkan
driver. From the ARB_spirv_extensions spec:

   "3. If a new GL extension is added that includes SPIR-V support via
   a new SPIR-V extension does it's SPIR-V extension also get
   enumerated by the SPIR_V_EXTENSIONS_ARB query?.

   RESOLVED. Yes. It's good to include it for consistency. Any SPIR-V
   functionality supported beyond the SPIR-V version that is required
   for the GL API version should be enumerated."

So in addition to the core SPIR-V support, there is the possibility of
specific GL extensions enabling specific SPIR-V extensions (so
capabilities). That would mean that it is possible that OpenGL and
Vulkan not having the same capabilities supported, even for the same
driver. For this reason it is better to keep them separated.

As an example: at the time of this patch writing Intel vulkan driver
support multiview, but there isn't any OpenGL multiview GL extension
supported.

Note: we initialize SPIR-V capabilities at brwCreateContext instead of
the usual brw_initialize_context_constants because we want to do that
only if the extension is enabled.

v2:
   * Rebase update (SpirVCapabilities not a pointer anymore)
   * Fill spirv capabilities for OpenGL >= 3.3 (Ian Romanick)

v3:
   * Drop multiview support, as i965 doesn't support any multiview GL
 extension (Jason)
   * Fill spirv capabilities only if the extension is enabled (Jason)

v4: Capabilities are supported only on gen7+. Added comment and assert
(Jason)

---

 src/mesa/drivers/dri/i965/brw_context.c | 25 +
 1 file changed, 25 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index 4e37425099..2e961a1ef6 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -78,6 +78,7 @@
 
 #include "common/gen_defines.h"
 
+#include "compiler/spirv/nir_spirv.h"
 /***
  * Mesa's Driver Functions
  ***/
@@ -344,6 +345,26 @@ brw_init_driver_functions(struct brw_context *brw,
 }
 
 static void
+brw_initialize_spirv_supported_capabilities(struct brw_context *brw)
+{
+   const struct gen_device_info *devinfo = >screen->devinfo;
+   struct gl_context *ctx = >ctx;
+
+   /* The following SPIR-V capabilities are only supported on gen7+. In theory
+* you should enable the extension only on gen7+, but just in case let's
+* assert it.
+*/
+   assert(devinfo->gen >= 7);
+
+   ctx->Const.SpirVCapabilities.float64 = devinfo->gen >= 8;
+   ctx->Const.SpirVCapabilities.int64 = devinfo->gen >= 8;
+   ctx->Const.SpirVCapabilities.tessellation = true;
+   ctx->Const.SpirVCapabilities.draw_parameters = true;
+   ctx->Const.SpirVCapabilities.image_write_without_format = true;
+   ctx->Const.SpirVCapabilities.variable_pointers = true;
+}
+
+static void
 brw_initialize_context_constants(struct brw_context *brw)
 {
const struct gen_device_info *devinfo = >screen->devinfo;
@@ -1062,6 +1083,10 @@ brwCreateContext(gl_api api,
_mesa_override_extensions(ctx);
_mesa_compute_version(ctx);
 
+   /* GL_ARB_gl_spirv */
+   if (ctx->Extensions.ARB_gl_spirv)
+  brw_initialize_spirv_supported_capabilities(brw);
+
_mesa_initialize_dispatch_tables(ctx);
_mesa_initialize_vbo_vtxfmt(ctx);
 

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


Mesa (master): mesa/program: Link SPIR-V shaders using the SPIR-V code-path

2018-03-30 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 16f6634e7fb5ada308e55b852cd49251e7f3f8b1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=16f6634e7fb5ada308e55b852cd49251e7f3f8b1

Author: Eduardo Lima Mitev 
Date:   Tue Oct 10 14:01:45 2017 +0200

mesa/program: Link SPIR-V shaders using the SPIR-V code-path

Reviewed-by: Timothy Arceri 

---

 src/mesa/program/ir_to_mesa.cpp | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index b0b322865b..49ef5ea52d 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -35,6 +35,7 @@
 #include "main/shaderapi.h"
 #include "main/shaderobj.h"
 #include "main/uniforms.h"
+#include "main/glspirv.h"
 #include "compiler/glsl/ast.h"
 #include "compiler/glsl/ir.h"
 #include "compiler/glsl/ir_expression_flattening.h"
@@ -3154,7 +3155,10 @@ _mesa_glsl_link_shader(struct gl_context *ctx, struct 
gl_shader_program *prog)
}
 
if (prog->data->LinkStatus) {
-  link_shaders(ctx, prog);
+  if (!spirv)
+ link_shaders(ctx, prog);
+  else
+ _mesa_spirv_link_shaders(ctx, prog);
}
 
/* If LinkStatus is LINKING_SUCCESS, then reset sampler validated to true.

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


Mesa (master): mesa: Add a reference to gl_shader_spirv_data to gl_linked_shader

2018-03-30 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 22b6b3d0a75406f577dcb6d554c96ed42ee35aff
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=22b6b3d0a75406f577dcb6d554c96ed42ee35aff

Author: Eduardo Lima Mitev 
Date:   Mon Nov 13 19:44:47 2017 +0100

mesa: Add a reference to gl_shader_spirv_data to gl_linked_shader

This is a reference to the spirv_data object stored in gl_shader, which
stores shader SPIR-V data that is needed during linking too.

Reviewed-by: Timothy Arceri 

---

 src/mesa/main/mtypes.h| 8 
 src/mesa/main/shaderobj.c | 1 +
 2 files changed, 9 insertions(+)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 9ded02500d..801bd17666 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2651,6 +2651,14 @@ struct gl_linked_shader
struct exec_list *packed_varyings;
struct exec_list *fragdata_arrays;
struct glsl_symbol_table *symbols;
+
+   /**
+* ARB_gl_spirv related data.
+*
+* This is actually a reference to the gl_shader::spirv_data, which
+* stores information that is also needed during linking.
+*/
+   struct gl_shader_spirv_data *spirv_data;
 };
 
 
diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index 5c1cdd6b27..834e2a92ec 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -137,6 +137,7 @@ void
 _mesa_delete_linked_shader(struct gl_context *ctx,
struct gl_linked_shader *sh)
 {
+   _mesa_shader_spirv_data_reference(>spirv_data, NULL);
_mesa_reference_program(ctx, >Program, NULL);
ralloc_free(sh);
 }

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


Mesa (master): spirv: add vtn_create_builder

2018-03-30 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: bebe3d626e562bd2dd027f9bcd5fdeeab62997cd
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=bebe3d626e562bd2dd027f9bcd5fdeeab62997cd

Author: Alejandro Piñeiro 
Date:   Thu Jan 18 12:24:38 2018 +0100

spirv: add vtn_create_builder

Refactored from spirv_to_nir, in order to be reused later.

Reviewed-by: Timothy Arceri 

v2: renamed method (from vtn_builder_create), add explanatory comment
(Timothy)

---

 src/compiler/spirv/spirv_to_nir.c | 51 ++-
 src/compiler/spirv/vtn_private.h  |  4 +++
 2 files changed, 38 insertions(+), 17 deletions(-)

diff --git a/src/compiler/spirv/spirv_to_nir.c 
b/src/compiler/spirv/spirv_to_nir.c
index 4297622979..d895d82055 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -3972,14 +3972,12 @@ vtn_handle_body_instruction(struct vtn_builder *b, 
SpvOp opcode,
return true;
 }
 
-nir_function *
-spirv_to_nir(const uint32_t *words, size_t word_count,
- struct nir_spirv_specialization *spec, unsigned num_spec,
- gl_shader_stage stage, const char *entry_point_name,
- const struct spirv_to_nir_options *options,
- const nir_shader_compiler_options *nir_options)
+struct vtn_builder*
+vtn_create_builder(const uint32_t *words, size_t word_count,
+   gl_shader_stage stage, const char *entry_point_name,
+   const struct spirv_to_nir_options *options)
 {
-   /* Initialize the stn_builder object */
+   /* Initialize the vtn_builder object */
struct vtn_builder *b = rzalloc(NULL, struct vtn_builder);
b->spirv = words;
b->spirv_word_count = word_count;
@@ -3991,14 +3989,6 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
b->entry_point_name = entry_point_name;
b->options = options;
 
-   /* See also _vtn_fail() */
-   if (setjmp(b->fail_jump)) {
-  ralloc_free(b);
-  return NULL;
-   }
-
-   const uint32_t *word_end = words + word_count;
-
/* Handle the SPIR-V header (first 4 dwords)  */
vtn_assert(word_count > 5);
 
@@ -4008,11 +3998,38 @@ spirv_to_nir(const uint32_t *words, size_t word_count,
unsigned value_id_bound = words[3];
vtn_assert(words[4] == 0);
 
-   words+= 5;
-
b->value_id_bound = value_id_bound;
b->values = rzalloc_array(b, struct vtn_value, value_id_bound);
 
+   return b;
+}
+
+nir_function *
+spirv_to_nir(const uint32_t *words, size_t word_count,
+ struct nir_spirv_specialization *spec, unsigned num_spec,
+ gl_shader_stage stage, const char *entry_point_name,
+ const struct spirv_to_nir_options *options,
+ const nir_shader_compiler_options *nir_options)
+
+{
+   const uint32_t *word_end = words + word_count;
+
+   struct vtn_builder *b = vtn_create_builder(words, word_count,
+  stage, entry_point_name,
+  options);
+
+   if (b == NULL)
+  return NULL;
+
+   /* See also _vtn_fail() */
+   if (setjmp(b->fail_jump)) {
+  ralloc_free(b);
+  return NULL;
+   }
+
+   /* Skip the SPIR-V header, handled at vtn_create_builder */
+   words+= 5;
+
/* Handle all the preamble instructions */
words = vtn_foreach_instruction(b, words, word_end,
vtn_handle_preamble_instruction);
diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h
index bbc63ad20d..47d06f0f91 100644
--- a/src/compiler/spirv/vtn_private.h
+++ b/src/compiler/spirv/vtn_private.h
@@ -719,6 +719,10 @@ void vtn_handle_subgroup(struct vtn_builder *b, SpvOp 
opcode,
 bool vtn_handle_glsl450_instruction(struct vtn_builder *b, uint32_t ext_opcode,
 const uint32_t *words, unsigned count);
 
+struct vtn_builder* vtn_create_builder(const uint32_t *words, size_t 
word_count,
+   gl_shader_stage stage, const char 
*entry_point_name,
+   const struct spirv_to_nir_options 
*options);
+
 static inline uint32_t
 vtn_align_u32(uint32_t v, uint32_t a)
 {

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


Mesa (master): nir/spirv: add gl_spirv_validation method

2018-03-30 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 9063bf7ad8a9175c4eddba5d06d887c507f6b5be
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9063bf7ad8a9175c4eddba5d06d887c507f6b5be

Author: Alejandro Piñeiro 
Date:   Thu Jan 18 12:31:52 2018 +0100

nir/spirv: add gl_spirv_validation method

ARB_gl_spirv adds the ability to use SPIR-V binaries, and a new
method, glSpecializeShader. Here we add a new function to do the
validation for this function:

From OpenGL 4.6 spec, section 7.2.1"

   "Shader Specialization", error table:

INVALID_VALUE is generated if  does not name a valid
entry point for .

INVALID_VALUE is generated if any element of 
refers to a specialization constant that does not exist in the
shader module contained in .""

v2: rebase update (spirv_to_nir options added, changes on the warning
logging, and others)

v3: include passing options on common initialization, doesn't call
setjmp on common_initialization

v4: (after Jason comments):
  * Rename common_initialization to vtn_builder_create
  * Move validation method and their helpers to own source file.
  * Create own handle_constant_decoration_cb instead of reuse existing one

v5: put vtn_build_create refactoring to their own patch (Jason)

v6: update after vtn_builder_create method renamed, add explanatory
comment, tweak existing comment and commit message (Timothy)

---

 src/compiler/Makefile.sources |   1 +
 src/compiler/nir/meson.build  |   1 +
 src/compiler/spirv/gl_spirv.c | 271 ++
 src/compiler/spirv/nir_spirv.h|   5 +
 src/compiler/spirv/spirv_to_nir.c |  35 +++--
 src/compiler/spirv/vtn_private.h  |   6 +
 6 files changed, 305 insertions(+), 14 deletions(-)

diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources
index 273ce4cde4..aca9dab476 100644
--- a/src/compiler/Makefile.sources
+++ b/src/compiler/Makefile.sources
@@ -297,6 +297,7 @@ SPIRV_GENERATED_FILES = \
 SPIRV_FILES = \
spirv/GLSL.ext.AMD.h \
spirv/GLSL.std.450.h \
+   spirv/gl_spirv.c \
spirv/nir_spirv.h \
spirv/spirv.h \
spirv/spirv_info.h \
diff --git a/src/compiler/nir/meson.build b/src/compiler/nir/meson.build
index db89e27613..b28a565d0c 100644
--- a/src/compiler/nir/meson.build
+++ b/src/compiler/nir/meson.build
@@ -186,6 +186,7 @@ files_libnir = files(
   'nir_worklist.h',
   '../spirv/GLSL.ext.AMD.h',
   '../spirv/GLSL.std.450.h',
+  '../spirv/gl_spirv.c',
   '../spirv/nir_spirv.h',
   '../spirv/spirv.h',
   '../spirv/spirv_info.h',
diff --git a/src/compiler/spirv/gl_spirv.c b/src/compiler/spirv/gl_spirv.c
new file mode 100644
index 00..edb635a09d
--- /dev/null
+++ b/src/compiler/spirv/gl_spirv.c
@@ -0,0 +1,271 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ *
+ */
+
+#include "nir_spirv.h"
+
+#include "vtn_private.h"
+#include "spirv_info.h"
+
+static bool
+vtn_validate_preamble_instruction(struct vtn_builder *b, SpvOp opcode,
+  const uint32_t *w, unsigned count)
+{
+   switch (opcode) {
+   case SpvOpSource:
+   case SpvOpSourceExtension:
+   case SpvOpSourceContinued:
+   case SpvOpExtension:
+   case SpvOpCapability:
+   case SpvOpExtInstImport:
+   case SpvOpMemoryModel:
+   case SpvOpString:
+   case SpvOpName:
+   case SpvOpMemberName:
+   case SpvOpExecutionMode:
+   case SpvOpDecorationGroup:
+   case SpvOpMemberDecorate:
+   case SpvOpGroupDecorate:
+   case SpvOpGroupMemberDecorate:
+  break;
+
+   case SpvOpEntryPoint:
+  vtn_handle_entry_point(b, w, count);
+  break;
+
+   case SpvOpDecorate:
+  vtn_handle_decoration(b, opcode, w, count);
+  break;
+
+   default:
+  return false; /* End of preamble */
+   }
+
+   return true;
+}
+
+static void
+spec_constant_decoration_cb(struct vtn_builder *b, struct vtn_value 

Mesa (master): i965: Don't call process_glsl_ir() for SPIR-V shaders

2018-03-30 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: e7fc18097ef5770f0da4186050f772518f28174a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e7fc18097ef5770f0da4186050f772518f28174a

Author: Eduardo Lima Mitev 
Date:   Tue Oct 10 14:08:35 2017 +0200

i965: Don't call process_glsl_ir() for SPIR-V shaders

v2: Use 'spirv_data' from gl_linked_shader instead, to check if shader
   is SPIR-V. (Timothy Arceri)

Reviewed-by: Timothy Arceri 

---

 src/mesa/drivers/dri/i965/brw_link.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_link.cpp 
b/src/mesa/drivers/dri/i965/brw_link.cpp
index 274a738cbb..7841626dc3 100644
--- a/src/mesa/drivers/dri/i965/brw_link.cpp
+++ b/src/mesa/drivers/dri/i965/brw_link.cpp
@@ -237,7 +237,8 @@ brw_link_shader(struct gl_context *ctx, struct 
gl_shader_program *shProg)
   struct gl_program *prog = shader->Program;
   prog->Parameters = _mesa_new_parameter_list();
 
-  process_glsl_ir(brw, shProg, shader);
+  if (!shader->spirv_data)
+ process_glsl_ir(brw, shProg, shader);
 
   _mesa_copy_linked_program_data(shProg, shader);
 

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


Mesa (master): spirv/radv: add AMD_gcn_shader capability, remove current extensions

2018-03-15 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 50767214a790889120975bf0f598996c4f887dfc
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=50767214a790889120975bf0f598996c4f887dfc

Author: Alejandro Piñeiro 
Date:   Thu Mar  8 12:43:00 2018 +0100

spirv/radv: add AMD_gcn_shader capability, remove current extensions

So now, during spirv_to_nir, it uses the capability instead of the
extension. Note that we are really doing here is treating
SPV_AMD_gcn_shader as other supported extensions. SPV_AMD_gcn_shader
is not the first SPV extension supported. For example, the capability
draw_parameters infers if the extension SPV_KHR_shader_draw_parameters
is supported or not.

This could be seen as counter-intuitive, and that it would be easier
to define which extensions are supported, and based our checks on
that, but we need to take into account that some capabilities are
optional from core, and others came from new extensions.

Also this commit would make the implementation of ARB_spirv_extensions
easier.

v2: AMD_gcn_shader capability renamed to gcn_shader (Daniel Schürmann)

Reviewed-by: Daniel Schürmann 
Reviewed-by: Bas Nieuwenhuizen 

---

 src/amd/vulkan/radv_shader.c  | 4 +---
 src/compiler/shader_info.h| 6 +-
 src/compiler/spirv/nir_spirv.h| 1 -
 src/compiler/spirv/spirv_to_nir.c | 2 +-
 4 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c
index 3eddc089d4..2fc7060d6c 100644
--- a/src/amd/vulkan/radv_shader.c
+++ b/src/amd/vulkan/radv_shader.c
@@ -214,9 +214,7 @@ radv_shader_compile_to_nir(struct radv_device *device,
.multiview = true,
.subgroup_basic = true,
.variable_pointers = true,
-   },
-   .exts = {
-   .AMD_gcn_shader = true,
+   .gcn_shader = true,
},
};
entry_point = spirv_to_nir(spirv, module->size / 4,
diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h
index b1e200070f..0eeb2ca58e 100644
--- a/src/compiler/shader_info.h
+++ b/src/compiler/shader_info.h
@@ -51,11 +51,7 @@ struct spirv_supported_capabilities {
bool subgroup_quad;
bool subgroup_shuffle;
bool subgroup_vote;
-};
-
-/* The supported extensions which add extended instructions */
-struct spirv_supported_extensions {
-   bool AMD_gcn_shader;
+   bool gcn_shader;
 };
 
 typedef struct shader_info {
diff --git a/src/compiler/spirv/nir_spirv.h b/src/compiler/spirv/nir_spirv.h
index 2b0bdaec01..a2c40e57d1 100644
--- a/src/compiler/spirv/nir_spirv.h
+++ b/src/compiler/spirv/nir_spirv.h
@@ -59,7 +59,6 @@ struct spirv_to_nir_options {
bool lower_workgroup_access_to_offsets;
 
struct spirv_supported_capabilities caps;
-   struct spirv_supported_extensions exts;
 
struct {
   void (*func)(void *private_data,
diff --git a/src/compiler/spirv/spirv_to_nir.c 
b/src/compiler/spirv/spirv_to_nir.c
index df01f4ff4a..f06dca90ef 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -376,7 +376,7 @@ vtn_handle_extension(struct vtn_builder *b, SpvOp opcode,
   if (strcmp((const char *)[2], "GLSL.std.450") == 0) {
  val->ext_handler = vtn_handle_glsl450_instruction;
   } else if ((strcmp((const char *)[2], "SPV_AMD_gcn_shader") == 0)
-&& (b->options && b->options->exts.AMD_gcn_shader)) {
+&& (b->options && b->options->caps.gcn_shader)) {
  val->ext_handler = vtn_handle_amd_gcn_shader_instruction;
   } else {
  vtn_fail("Unsupported extension");

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


Mesa (master): nir/serialize: handle var->name being NULL

2018-02-28 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: e72fb4e61128684efc28647931a793910e190656
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e72fb4e61128684efc28647931a793910e190656

Author: Alejandro Piñeiro 
Date:   Wed Feb 28 13:01:56 2018 +0100

nir/serialize: handle var->name being NULL

var->name could be NULL under ARB_gl_spirv for example. And in any
case, the code is already handing var name being NULL when reading a
variable, so it is consistent to do it writing a variable too.

Reviewed-by: Timothy Arceri 

---

 src/compiler/nir/nir_serialize.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_serialize.c b/src/compiler/nir/nir_serialize.c
index 9fe46a675f..00df49c2ef 100644
--- a/src/compiler/nir/nir_serialize.c
+++ b/src/compiler/nir/nir_serialize.c
@@ -137,7 +137,8 @@ write_variable(write_ctx *ctx, const nir_variable *var)
write_add_object(ctx, var);
encode_type_to_blob(ctx->blob, var->type);
blob_write_uint32(ctx->blob, !!(var->name));
-   blob_write_string(ctx->blob, var->name);
+   if (var->name)
+  blob_write_string(ctx->blob, var->name);
blob_write_bytes(ctx->blob, (uint8_t *) >data, sizeof(var->data));
blob_write_uint32(ctx->blob, var->num_state_slots);
blob_write_bytes(ctx->blob, (uint8_t *) var->state_slots,

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


Mesa (master): glsl/linker: remove ubo explicit binding handling

2018-02-08 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: f32b01ca435c5eb4268919f984e6e3d63c28828f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f32b01ca435c5eb4268919f984e6e3d63c28828f

Author: Alejandro Piñeiro 
Date:   Wed Jan 24 11:03:00 2018 +0100

glsl/linker: remove ubo explicit binding handling

This is already handled at link_uniform_blocks, specifically at
process_block_array_leaf.

Additionally, this code was not handling correctly arrays of
arrays. When creating the name of the block to set the binding, it
only took into account the first level, so any attempt to set a
explicit binding on a array of array ubo would trigger an assertion.

Reviewed-by: Timothy Arceri 

---

 src/compiler/glsl/link_uniform_initializers.cpp | 58 +
 1 file changed, 2 insertions(+), 56 deletions(-)

diff --git a/src/compiler/glsl/link_uniform_initializers.cpp 
b/src/compiler/glsl/link_uniform_initializers.cpp
index 97796e721b..35522f7646 100644
--- a/src/compiler/glsl/link_uniform_initializers.cpp
+++ b/src/compiler/glsl/link_uniform_initializers.cpp
@@ -182,26 +182,6 @@ set_opaque_binding(void *mem_ctx, gl_shader_program *prog,
}
 }
 
-static void
-set_block_binding(gl_shader_program *prog, const char *block_name,
-  unsigned mode, int binding)
-{
-   unsigned num_blocks = mode == ir_var_uniform ?
-  prog->data->NumUniformBlocks :
-  prog->data->NumShaderStorageBlocks;
-   struct gl_uniform_block *blks = mode == ir_var_uniform ?
-  prog->data->UniformBlocks : prog->data->ShaderStorageBlocks;
-
-   for (unsigned i = 0; i < num_blocks; i++) {
-  if (!strcmp(blks[i].Name, block_name)) {
- blks[i].Binding = binding;
- return;
-  }
-   }
-
-   unreachable("Failed to initialize block binding");
-}
-
 void
 set_uniform_initializer(void *mem_ctx, gl_shader_program *prog,
 const char *name, const glsl_type *type,
@@ -307,43 +287,9 @@ link_set_uniform_initializers(struct gl_shader_program 
*prog,
linker::set_opaque_binding(mem_ctx, prog, var, var->type,
   var->name, );
 } else if (var->is_in_buffer_block()) {
-   const glsl_type *const iface_type = var->get_interface_type();
-
-   /* If the variable is an array and it is an interface instance,
-* we need to set the binding for each array element.  Just
-* checking that the variable is an array is not sufficient.
-* The variable could be an array element of a uniform block
-* that lacks an instance name.  For example:
-*
-* uniform U {
-* float f[4];
-* };
-*
-* In this case "f" would pass is_in_buffer_block (above) and
-* type->is_array(), but it will fail is_interface_instance().
+   /* This case is handled by link_uniform_blocks (at
+* process_block_array_leaf)
 */
-   if (var->is_interface_instance() && var->type->is_array()) {
-  for (unsigned i = 0; i < var->type->length; i++) {
- const char *name =
-ralloc_asprintf(mem_ctx, "%s[%u]", iface_type->name, 
i);
-
- /* Section 4.4.3 (Uniform Block Layout Qualifiers) of the
-  * GLSL 4.20 spec says:
-  *
-  * "If the binding identifier is used with a uniform
-  * block instanced as an array then the first element
-  * of the array takes the specified block binding and
-  * each subsequent element takes the next consecutive
-  * uniform block binding point."
-  */
- linker::set_block_binding(prog, name, var->data.mode,
-   var->data.binding + i);
-  }
-   } else {
-  linker::set_block_binding(prog, iface_type->name,
-var->data.mode,
-var->data.binding);
-   }
 } else if (type->contains_atomic()) {
/* we don't actually need to do anything. */
 } else {

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


Mesa (master): glsl/standalone: set MaxTransformFeedbackBuffers

2018-01-04 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 2719467eb66a559a8529ac29bb658d345c155031
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2719467eb66a559a8529ac29bb658d345c155031

Author: Alejandro Piñeiro 
Date:   Thu Jan  4 17:13:07 2018 +0100

glsl/standalone: set MaxTransformFeedbackBuffers

Using 4, as it is the default value on mesa. See mesa/main/config.h
and the following commit that introduced the value:
15ac66e331abdab12e882d80a6b4f647bc905298

Reviewed-by: Ian Romanick 

---

 src/compiler/glsl/standalone.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/compiler/glsl/standalone.cpp b/src/compiler/glsl/standalone.cpp
index 6c05b866d2..6ece074641 100644
--- a/src/compiler/glsl/standalone.cpp
+++ b/src/compiler/glsl/standalone.cpp
@@ -231,6 +231,7 @@ initialize_context(struct gl_context *ctx, gl_api api)
   ctx->Const.MaxTextureUnits = 2;
   ctx->Const.MaxUniformBufferBindings = 84;
   ctx->Const.MaxVertexStreams = 4;
+  ctx->Const.MaxTransformFeedbackBuffers = 4;
 
   ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs = 16;
   ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits = 16;
@@ -266,6 +267,7 @@ initialize_context(struct gl_context *ctx, gl_api api)
   ctx->Const.MaxTextureUnits = 2;
   ctx->Const.MaxUniformBufferBindings = 84;
   ctx->Const.MaxVertexStreams = 4;
+  ctx->Const.MaxTransformFeedbackBuffers = 4;
 
   ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs = 16;
   ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits = 16;
@@ -309,6 +311,7 @@ initialize_context(struct gl_context *ctx, gl_api api)
   ctx->Const.MaxTextureUnits = 0;
   ctx->Const.MaxUniformBufferBindings = 84;
   ctx->Const.MaxVertexStreams = 4;
+  ctx->Const.MaxTransformFeedbackBuffers = 4;
 
   ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs = 16;
   ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits = 16;

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


Mesa (master): glsl/standalone: set MaxUniformBufferBindings

2018-01-04 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 8dcf131f04cf0fd540de127481985010ae61a4ea
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8dcf131f04cf0fd540de127481985010ae61a4ea

Author: Alejandro Piñeiro 
Date:   Thu Jan  4 16:51:19 2018 +0100

glsl/standalone: set MaxUniformBufferBindings

Used to handle how many ubo you can define on the context. Minimimum
defined as 36 on ARB_uniform_buffer_object spec, up to 84 on OpenGL
4.6 (12 per stage at each moment).

Reviewed-by: Ian Romanick 

---

 src/compiler/glsl/standalone.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/compiler/glsl/standalone.cpp b/src/compiler/glsl/standalone.cpp
index 85e94a1095..5035cbdce4 100644
--- a/src/compiler/glsl/standalone.cpp
+++ b/src/compiler/glsl/standalone.cpp
@@ -229,6 +229,7 @@ initialize_context(struct gl_context *ctx, gl_api api)
   ctx->Const.MaxLights = 8;
   ctx->Const.MaxTextureCoordUnits = 8;
   ctx->Const.MaxTextureUnits = 2;
+  ctx->Const.MaxUniformBufferBindings = 84;
 
   ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs = 16;
   ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits = 16;
@@ -262,6 +263,7 @@ initialize_context(struct gl_context *ctx, gl_api api)
   ctx->Const.MaxLights = 8;
   ctx->Const.MaxTextureCoordUnits = 8;
   ctx->Const.MaxTextureUnits = 2;
+  ctx->Const.MaxUniformBufferBindings = 84;
 
   ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs = 16;
   ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits = 16;
@@ -303,6 +305,7 @@ initialize_context(struct gl_context *ctx, gl_api api)
   ctx->Const.MaxLights = 0;
   ctx->Const.MaxTextureCoordUnits = 0;
   ctx->Const.MaxTextureUnits = 0;
+  ctx->Const.MaxUniformBufferBindings = 84;
 
   ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs = 16;
   ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits = 16;

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


Mesa (master): glsl/standalone: set MaxVertexStreams

2018-01-04 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 0ba3de2ad767686948c70feb85b3305c3c20e757
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0ba3de2ad767686948c70feb85b3305c3c20e757

Author: Alejandro Piñeiro 
Date:   Thu Jan  4 17:04:33 2018 +0100

glsl/standalone: set MaxVertexStreams

ARB_transform_feedback3 sets a minimum of 1, ARB_gpu_shader5 a minimum
of 4. It shouldn't matter too much, so choosing the later.

Reviewed-by: Ian Romanick 

---

 src/compiler/glsl/standalone.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/compiler/glsl/standalone.cpp b/src/compiler/glsl/standalone.cpp
index 5035cbdce4..6c05b866d2 100644
--- a/src/compiler/glsl/standalone.cpp
+++ b/src/compiler/glsl/standalone.cpp
@@ -230,6 +230,7 @@ initialize_context(struct gl_context *ctx, gl_api api)
   ctx->Const.MaxTextureCoordUnits = 8;
   ctx->Const.MaxTextureUnits = 2;
   ctx->Const.MaxUniformBufferBindings = 84;
+  ctx->Const.MaxVertexStreams = 4;
 
   ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs = 16;
   ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits = 16;
@@ -264,6 +265,7 @@ initialize_context(struct gl_context *ctx, gl_api api)
   ctx->Const.MaxTextureCoordUnits = 8;
   ctx->Const.MaxTextureUnits = 2;
   ctx->Const.MaxUniformBufferBindings = 84;
+  ctx->Const.MaxVertexStreams = 4;
 
   ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs = 16;
   ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits = 16;
@@ -306,6 +308,7 @@ initialize_context(struct gl_context *ctx, gl_api api)
   ctx->Const.MaxTextureCoordUnits = 0;
   ctx->Const.MaxTextureUnits = 0;
   ctx->Const.MaxUniformBufferBindings = 84;
+  ctx->Const.MaxVertexStreams = 4;
 
   ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs = 16;
   ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits = 16;

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


Mesa (master): glsl/standalone: point which arguments are mandatory

2018-01-04 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 937b210551ef7c243976f0c0240395827a72ef8b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=937b210551ef7c243976f0c0240395827a72ef8b

Author: Alejandro Piñeiro 
Date:   Thu Jan  4 16:38:00 2018 +0100

glsl/standalone: point which arguments are mandatory

Every now and then I execute the standalone compiler, get the
non-version error, and need to remember what I'm doing wrong

Reviewed-by: Ian Romanick 

---

 src/compiler/glsl/main.cpp | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/compiler/glsl/main.cpp b/src/compiler/glsl/main.cpp
index 123e41f9dc..e082bd6975 100644
--- a/src/compiler/glsl/main.cpp
+++ b/src/compiler/glsl/main.cpp
@@ -62,7 +62,10 @@ usage_fail(const char *name)
   "Possible options are:\n";
printf(header, name);
for (const struct option *o = compiler_opts; o->name != 0; ++o) {
-  printf("--%s\n", o->name);
+  printf("--%s", o->name);
+  if (o->has_arg == required_argument)
+ printf(" (mandatory)");
+  printf("\n");
}
exit(EXIT_FAILURE);
 }

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


Mesa (master): mesa/spirv: move and rename nir_spirv_supported_capabilities

2017-12-07 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 25e56b2ebafe2bcebb23819cc355e1b079a839d6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=25e56b2ebafe2bcebb23819cc355e1b079a839d6

Author: Alejandro Piñeiro 
Date:   Thu Dec  7 09:38:41 2017 +0100

mesa/spirv: move and rename nir_spirv_supported_capabilities

To avoid any vulkan driver to include the GL mtypes.h. Renamed as
eventually this could be used by drivers not using nir.

v2: remove compiler/spirv/spirv.h from mtypes (Alejandro)
v3: added the definition at compiler/shader_info.h (Jason Ekstrand)

Reviewed-by: Jason Ekstrand 

---

 src/compiler/shader_info.h | 13 +
 src/compiler/spirv/nir_spirv.h |  4 ++--
 src/mesa/main/mtypes.h | 13 -
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/src/compiler/shader_info.h b/src/compiler/shader_info.h
index bcb3f0fffa..c9140ba975 100644
--- a/src/compiler/shader_info.h
+++ b/src/compiler/shader_info.h
@@ -31,6 +31,19 @@
 extern "C" {
 #endif
 
+struct spirv_supported_capabilities {
+   bool float64;
+   bool image_ms_array;
+   bool tessellation;
+   bool draw_parameters;
+   bool image_read_without_format;
+   bool image_write_without_format;
+   bool int64;
+   bool multiview;
+   bool variable_pointers;
+   bool storage_16bit;
+};
+
 typedef struct shader_info {
const char *name;
 
diff --git a/src/compiler/spirv/nir_spirv.h b/src/compiler/spirv/nir_spirv.h
index 113bd710a0..a2c40e57d1 100644
--- a/src/compiler/spirv/nir_spirv.h
+++ b/src/compiler/spirv/nir_spirv.h
@@ -29,7 +29,7 @@
 #define _NIR_SPIRV_H_
 
 #include "compiler/nir/nir.h"
-#include "main/mtypes.h"
+#include "compiler/shader_info.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -58,7 +58,7 @@ struct spirv_to_nir_options {
 */
bool lower_workgroup_access_to_offsets;
 
-   struct nir_spirv_supported_capabilities caps;
+   struct spirv_supported_capabilities caps;
 
struct {
   void (*func)(void *private_data,
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 7b7137624c..397b113dfb 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3578,19 +3578,6 @@ struct gl_program_constants
GLuint MaxShaderStorageBlocks;
 };
 
-struct nir_spirv_supported_capabilities {
-   bool float64;
-   bool image_ms_array;
-   bool tessellation;
-   bool draw_parameters;
-   bool image_read_without_format;
-   bool image_write_without_format;
-   bool int64;
-   bool multiview;
-   bool variable_pointers;
-   bool storage_16bit;
-};
-
 /**
  * Constants which may be overridden by device driver during context creation
  * but are never changed after that.

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


Mesa (master): mesa: remove set_entry from forward type declarations

2017-12-07 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: be2c434308ea9dedd6033a590cc072951d8ba469
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=be2c434308ea9dedd6033a590cc072951d8ba469

Author: Alejandro Piñeiro 
Date:   Wed Dec  6 11:38:59 2017 +0100

mesa: remove set_entry from forward type declarations

This type was used at gl_sync_object, but it is not used anymore.

Reviewed-by: Timothy Arceri 

---

 src/mesa/main/mtypes.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 7da05aa3ee..7b7137624c 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -99,7 +99,6 @@ struct gl_uniform_storage;
 struct prog_instruction;
 struct gl_program_parameter_list;
 struct set;
-struct set_entry;
 struct vbo_context;
 /*@}*/
 

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


Mesa (master): mesa: define nir_spirv_supported_capabilities

2017-12-06 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 0398b31d1d49a4f9f369052b4ce3c0cf8fce176b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0398b31d1d49a4f9f369052b4ce3c0cf8fce176b

Author: Alejandro Piñeiro 
Date:   Wed Dec  6 09:57:18 2017 +0100

mesa: define nir_spirv_supported_capabilities

Until now it was part of spirv_to_nir_options. But it will be used on
the implementation of ARB_gl_spirv and ARB_spirv_extensions, and added
to the OpenGL context, as a way to save what SPIR-V capabilities the
current OpenGL implementation supports.

Reviewed-by: Ian Romanick 

---

 src/compiler/spirv/nir_spirv.h | 16 +++-
 src/mesa/main/mtypes.h | 12 
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/src/compiler/spirv/nir_spirv.h b/src/compiler/spirv/nir_spirv.h
index 43ec19d5a5..113bd710a0 100644
--- a/src/compiler/spirv/nir_spirv.h
+++ b/src/compiler/spirv/nir_spirv.h
@@ -28,7 +28,8 @@
 #ifndef _NIR_SPIRV_H_
 #define _NIR_SPIRV_H_
 
-#include "nir/nir.h"
+#include "compiler/nir/nir.h"
+#include "main/mtypes.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -57,18 +58,7 @@ struct spirv_to_nir_options {
 */
bool lower_workgroup_access_to_offsets;
 
-   struct {
-  bool float64;
-  bool image_ms_array;
-  bool tessellation;
-  bool draw_parameters;
-  bool image_read_without_format;
-  bool image_write_without_format;
-  bool int64;
-  bool multiview;
-  bool variable_pointers;
-  bool storage_16bit;
-   } caps;
+   struct nir_spirv_supported_capabilities caps;
 
struct {
   void (*func)(void *private_data,
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index b478f6158e..7da05aa3ee 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3579,6 +3579,18 @@ struct gl_program_constants
GLuint MaxShaderStorageBlocks;
 };
 
+struct nir_spirv_supported_capabilities {
+   bool float64;
+   bool image_ms_array;
+   bool tessellation;
+   bool draw_parameters;
+   bool image_read_without_format;
+   bool image_write_without_format;
+   bool int64;
+   bool multiview;
+   bool variable_pointers;
+   bool storage_16bit;
+};
 
 /**
  * Constants which may be overridden by device driver during context creation

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


Mesa (master): 27 new commits

2017-12-06 Thread Alejandro Pinheiro
1e0
Author: Jose Maria Casanova Crespo <jmcasan...@igalia.com>
Date:   Sat Jul 1 08:11:58 2017 +0200

i965: Add support for control register

Control register cr0 in i965 can be used to change the rounding modes
in 32-bit to 16-bit floating-point conversions.

From intel Skylake PRM, vol 07, section "Register and Tegister Regions",
 subsection "Control Register" (page 754):

"Subregister cr0.0:ud contains normal operation control fields such as the
 floating-point mode ... "

Floating-point Rounding mode is changed at bits 5:4 of cr0.0:

"Rounding Mode. This field specifies the FPU rounding mode. It is
initialized by Thread Dispatch."
  00b = Round to Nearest or Even (RTNE)
  01b = Round Up, toward +inf (RU)
  10b = Round Down, toward -inf (RD)
  11b = Round Toward Zero (RTZ)"

Reviewed-by: Jason Ekstrand <ja...@jlekstrand.net>

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5d5ee507fb4a385f98ba19bd901ce4e3aca7def4
Author: Alejandro Piñeiro <apinhe...@igalia.com>
Date:   Sat Jul 1 08:11:05 2017 +0200

i965/fs: Handle 32-bit to 16-bit conversions

Conversions to 16-bit need having aligment between the 16-bit
and 32-bit types. So the conversion operations unpack 16-bit types
to with an stride=2 and then applies a MOV with the conversion.

v2 (Jason Ekstrand):
  - Avoid the general use of stride=2 for 16-bit register types.

v3 (Topi Pohjolainen)
  - Code style fix
   (Jason Ekstrand)
  - Now nir_op_f2f16 was renamed to nir_op_f2f16_undef
because conversion to f16 with undefined rounding is explicit

Signed-off-by: Eduardo Lima <el...@igalia.com>
Signed-off-by: Alejandro Piñeiro <apinhe...@igalia.com>
Signed-off-by: Jose Maria Casanova Crespo <jmcasan...@igalia.com>
Reviewed-by: Jason Ekstrand <ja...@jlekstrand.net>

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a05b6f25bf4bfad7bb56d20aca0d2424607f9004
Author: Alejandro Piñeiro <apinhe...@igalia.com>
Date:   Sat Jul 1 08:08:20 2017 +0200

i965/fs: Remove BRW_REGISTER_TYPE_HF assert at get_exec_type

Note that we don't remove the assert at i965/vec4. At this point half
float support is only for the scalar backend.

Reviewed-by: Jason Ekstrand <ja...@jlekstrand.net>

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=75a88d85671e03f6913dcc8bd288515e8ee8a99b
Author: Jose Maria Casanova Crespo <jmcasan...@igalia.com>
Date:   Sat Jul 1 08:06:45 2017 +0200

i965: Support for 16-bit base types in helper functions

v2: Fixed calculation of scalar size for 16-bit types. (Jason Ekstrand)
v3: Fix coding style (Topi Pohjolainen)

Signed-off-by: Jose Maria Casanova Crespo <jmcasan...@igalia.com>
Signed-off-by: Eduardo Lima <el...@igalia.com>
Reviewed-by: Jason Ekstrand <ja...@jlekstrand.net>

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2d28ca70005968c7becb4e598b97e72c8e4890a2
Author: Alejandro Piñeiro <apinhe...@igalia.com>
Date:   Sat Jul 1 08:06:17 2017 +0200

i965/vec4: Handle 16-bit types at type_size_xvec4

These types have similar vec4 sizes as their 32-bit counterparts.

The vec4 backend doesn't support 16-bit types and probably never will,
but this method is called by the scalar backend at
fs_visitor::nir_setup_outputs(), so we still need to provide valid vec4
sizes for 16-bit types. In the future, something different should be
implemented to avoid this dependency.

Reviewed-by: Jason Ekstrand <ja...@jlekstrand.net>

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4049c041221e614c64641fcbeb5b396fd3daa507
Author: Eduardo Lima Mitev <el...@igalia.com>
Date:   Sat Jul 1 08:02:45 2017 +0200

spirv/nir: Add support for SPV_KHR_16bit_storage

v2: Minor changes after rebase against recent master (Alejandro
Pinheiro)

Reviewed-by: Jason Ekstrand <ja...@jlekstrand.net>

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e0667a8bd8029936aed5b97b5ceef7c58526e53c
Author: Jose Maria Casanova Crespo <jmcasan...@igalia.com>
Date:   Sat Jul 1 08:05:55 2017 +0200

spirv: Enable FPRoundingMode decorator to nir operations

SpvOpFConvert now manages the FPRoundingMode decorator for the
returning values enabling the nir_rounding_mode in the conversion
operation to fp16 values.

v2: Fixed breaking of specialization constants. (Jason Ekstrand)

v3: Avoid nir_rounding_mode * casting. (Jason Ekstrand)

Reviewed-by: Jason Ekstrand <ja...@jlekstrand.net>

URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=549894a681cce2c96006b740a10a36c005d05d0b
Author: Eduardo Lima Mitev <el...@igalia.com>
Date:   Sat Jul 1 08:04:40 2017 +0200


Mesa (master): spirv: fix typo on DO NOT EDIT header

2017-11-14 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: b498172d0eace0c448b199c94730d2551786bb1b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b498172d0eace0c448b199c94730d2551786bb1b

Author: Alejandro Piñeiro 
Date:   Tue Nov 14 08:32:18 2017 +0100

spirv: fix typo on DO NOT EDIT header

Introduced on commit 157c9a13414b524ce98ea0ea07fce819efc1ba65

Reviewed-by: Iago Toral Quiroga 

---

 src/compiler/spirv/spirv_info_c.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compiler/spirv/spirv_info_c.py 
b/src/compiler/spirv/spirv_info_c.py
index 11235cfa3e..d898bf0131 100644
--- a/src/compiler/spirv/spirv_info_c.py
+++ b/src/compiler/spirv/spirv_info_c.py
@@ -52,7 +52,7 @@ def parse_args():
 return p.parse_args()
 
 TEMPLATE  = Template("""\
-/* DO NOT EDIT - This file generated automatically by spirv_info_c.py script */
+/* DO NOT EDIT - This file is generated automatically by spirv_info_c.py 
script */
 
 """ + COPYRIGHT + """\
 #include "spirv_info.h"

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


Mesa (master): spirv: add DO NOT EDIT warning on generated spirv_info.c

2017-11-13 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 157c9a13414b524ce98ea0ea07fce819efc1ba65
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=157c9a13414b524ce98ea0ea07fce819efc1ba65

Author: Alejandro Piñeiro 
Date:   Fri Oct 13 16:17:14 2017 +0200

spirv: add DO NOT EDIT warning on generated spirv_info.c

Reviewed-by: Eric Engestrom 

---

 src/compiler/spirv/spirv_info_c.py | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/compiler/spirv/spirv_info_c.py 
b/src/compiler/spirv/spirv_info_c.py
index c5e11dfc83..11235cfa3e 100644
--- a/src/compiler/spirv/spirv_info_c.py
+++ b/src/compiler/spirv/spirv_info_c.py
@@ -51,7 +51,10 @@ def parse_args():
 p.add_argument("out")
 return p.parse_args()
 
-TEMPLATE  = Template(COPYRIGHT + """\
+TEMPLATE  = Template("""\
+/* DO NOT EDIT - This file generated automatically by spirv_info_c.py script */
+
+""" + COPYRIGHT + """\
 #include "spirv_info.h"
 % for kind,values in info:
 

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


Mesa (master): formatquery: use correct target check for IMAGE_FORMAT_COMPATIBILITY_TYPE

2017-10-27 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: fd011376cb3d7713297e057eafbd1d0ef1df3667
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fd011376cb3d7713297e057eafbd1d0ef1df3667

Author: Alejandro Piñeiro 
Date:   Wed Oct 25 14:35:36 2017 +0200

formatquery: use correct target check for IMAGE_FORMAT_COMPATIBILITY_TYPE

From the spec:
   "IMAGE_FORMAT_COMPATIBILITY_TYPE: The matching criteria use for the
resource when used as an image textures is returned in
. This is equivalent to calling GetTexParameter"

So we would need to return None for any target not supported by
GetTexParameter. By mistake, we were using the target check for
GetTexLevelParameter.

v2: fix typo (GetTextParameter vs GetTexParemeter) on comment (Illia Mirkin)

Reviewed-by: Antia Puentes 
Reviewed-by: Marek Olšák 

---

 src/mesa/main/formatquery.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/formatquery.c b/src/mesa/main/formatquery.c
index 77c7faa225..61f798c88f 100644
--- a/src/mesa/main/formatquery.c
+++ b/src/mesa/main/formatquery.c
@@ -1430,7 +1430,13 @@ _mesa_GetInternalformativ(GLenum target, GLenum 
internalformat, GLenum pname,
   if (!_mesa_has_ARB_shader_image_load_store(ctx))
  goto end;
 
-  if (!_mesa_legal_get_tex_level_parameter_target(ctx, target, true))
+  /* As pointed by the spec quote below, this pname query should return
+   * the same value that GetTexParameter. So if the target is not valid
+   * for GetTexParameter we return the unsupported value. The check below
+   * is the same target check used by GetTexParameter.
+   */
+  int targetIndex = _mesa_tex_target_to_index(ctx, target);
+  if (targetIndex < 0 || targetIndex == TEXTURE_BUFFER_INDEX)
  goto end;
 
   /* From spec: "Equivalent to calling GetTexParameter with  set

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


Mesa (master): egl: remove unused err variable

2017-07-13 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 57671025b0795d7f32f434dfd30d1264dbe1ebc7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=57671025b0795d7f32f434dfd30d1264dbe1ebc7

Author: Alejandro Piñeiro 
Date:   Thu Jul 13 11:38:48 2017 +0200

egl: remove unused err variable

Fixes: 81e95924ea1 ("egl: call _eglError within _eglParseImageAttribList")

Reviewed-by: Daniel Stone 

---

 src/egl/drivers/dri2/egl_dri2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 2392bfbb2a..5bf36bf309 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1910,7 +1910,7 @@ dri2_create_image_mesa_drm_buffer(_EGLDisplay *disp, 
_EGLContext *ctx,
   EGLClientBuffer buffer, const EGLint 
*attr_list)
 {
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
-   EGLint format, name, pitch, err;
+   EGLint format, name, pitch;
_EGLImageAttribs attrs;
__DRIimage *dri_image;
 

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


Mesa (master): i965: expose BRW_OPCODE_[F32TO16/F16TO32] name on gen8+

2017-03-29 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 2f8d6bd57844f86547b95d1381c82aaceb83c356
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2f8d6bd57844f86547b95d1381c82aaceb83c356

Author: Alejandro Piñeiro 
Date:   Tue Mar 28 19:24:12 2017 +0200

i965: expose BRW_OPCODE_[F32TO16/F16TO32] name on gen8+

Technically those hw operations are only available on gen7, as gen8+
support the conversion on the MOV. But, when using the builder to
implement nir operations (example: nir_op_fquantize2f16), it is not
needed to do the gen check. This check is done later, on the final
emission at brw_F32TO16 (brw_eu_emit), choosing between the MOV or the
specific operation accordingly.

So in the middle, during optimization phases those hw operations can
be around for gen8+ too.

Without this patch, several (at least 95) vulkan-cts quantize tests
crashes when using INTEL_DEBUG=optimizer. For example:
dEQP-VK.spirv_assembly.instruction.graphics.opquantize.too_small_vert

v2: simplify the code using GEN_GE (Ilia Mirkin)
v3: tweak brw_instruction_name instead of changing opcode_descs
table, that is used for validation (Matt Turner)

Reviewed-by: Matt Turner 

---

 src/intel/compiler/brw_shader.cpp | 9 +
 1 file changed, 9 insertions(+)

diff --git a/src/intel/compiler/brw_shader.cpp 
b/src/intel/compiler/brw_shader.cpp
index bfaa5e7bfe..73bbc93135 100644
--- a/src/intel/compiler/brw_shader.cpp
+++ b/src/intel/compiler/brw_shader.cpp
@@ -157,6 +157,15 @@ brw_instruction_name(const struct gen_device_info 
*devinfo, enum opcode op)
   if (devinfo->gen >= 6 && op == BRW_OPCODE_DO)
  return "do";
 
+  /* The following conversion opcodes doesn't exist on Gen8+, but we use
+   * then to mark that we want to do the conversion.
+   */
+  if (devinfo->gen > 7 && op == BRW_OPCODE_F32TO16)
+ return "f32to16";
+
+  if (devinfo->gen > 7 && op == BRW_OPCODE_F16TO32)
+ return "f16to32";
+
   assert(brw_opcode_desc(devinfo, op)->name);
   return brw_opcode_desc(devinfo, op)->name;
case FS_OPCODE_FB_WRITE:

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


Mesa (master): mesa/main: *TextureSubImage* generates INVALID_OPERATION on wrong target

2017-03-02 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: a54f0ad6d3217394e597ea66b9a71a6584532638
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a54f0ad6d3217394e597ea66b9a71a6584532638

Author: Alejandro Piñeiro 
Date:   Thu Mar  2 17:18:14 2017 +0100

mesa/main: *TextureSubImage* generates INVALID_OPERATION on wrong target

Equivalent *TexSubImage* methods generates INVALID_ENUM.

From OpenGL 4.5 spec, section 8.6 Alternate Texture Image
Specification Commands:

   "An INVALID_ENUM error is generated by *TexSubImage* if target does
not match the command, as shown in table 8.15."

And:

   "An INVALID_OPERATION error is generated by *TextureSubImage* if
the effective target of texture does not match the command, as
shown in table 8.15."

Fixes:
GL45-CTS.direct_state_access.textures_copy_errors

v2: slightly change commit summary (Samuel)

Reviewed-by: Samuel Pitoiset 

---

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

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 25c5f82..89f6921 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -3939,7 +3939,7 @@ _mesa_CopyTextureSubImage1D(GLuint texture, GLint level,
 
/* Check target (proxies not allowed). */
if (!legal_texsubimage_target(ctx, 1, texObj->Target, true)) {
-  _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid target %s)", self,
+  _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid target %s)", self,
   _mesa_enum_to_string(texObj->Target));
   return;
}
@@ -3963,7 +3963,7 @@ _mesa_CopyTextureSubImage2D(GLuint texture, GLint level,
 
/* Check target (proxies not allowed). */
if (!legal_texsubimage_target(ctx, 2, texObj->Target, true)) {
-  _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid target %s)", self,
+  _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid target %s)", self,
   _mesa_enum_to_string(texObj->Target));
   return;
}
@@ -3990,7 +3990,7 @@ _mesa_CopyTextureSubImage3D(GLuint texture, GLint level,
 
/* Check target (proxies not allowed). */
if (!legal_texsubimage_target(ctx, 3, texObj->Target, true)) {
-  _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid target %s)", self,
+  _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid target %s)", self,
   _mesa_enum_to_string(texObj->Target));
   return;
}

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


Mesa (master): mesa/formatquery: use consistent local function names

2017-02-17 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 966ddd5d3d02974a05bfab43cfebcea4df9a41f2
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=966ddd5d3d02974a05bfab43cfebcea4df9a41f2

Author: Alejandro Piñeiro 
Date:   Sat Feb 11 17:21:35 2017 +0100

mesa/formatquery: use consistent local function names

Reviewed-by: Samuel Iglesias Gonsálvez 

---

 src/mesa/main/formatquery.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/mesa/main/formatquery.c b/src/mesa/main/formatquery.c
index 29df958..598d34d 100644
--- a/src/mesa/main/formatquery.c
+++ b/src/mesa/main/formatquery.c
@@ -718,8 +718,8 @@ _mesa_query_internal_format_default(struct gl_context *ctx, 
GLenum target,
  * arb_internalformat_query2 spec.
  */
 static GLenum
-equivalentSizePname(GLenum target,
-GLenum pname)
+_equivalent_size_pname(GLenum target,
+   GLenum pname)
 {
switch (target) {
case GL_TEXTURE_1D:
@@ -763,7 +763,7 @@ equivalentSizePname(GLenum target,
  * per-se, so we can't just call _mesa_get_texture_dimension directly.
  */
 static GLint
-get_target_dimensions(GLenum target)
+_get_target_dimensions(GLenum target)
 {
switch(target) {
case GL_TEXTURE_BUFFER:
@@ -788,7 +788,7 @@ get_target_dimensions(GLenum target)
  *  ."
  */
 static GLint
-get_min_dimensions(GLenum pname)
+_get_min_dimensions(GLenum pname)
 {
switch(pname) {
case GL_MAX_WIDTH:
@@ -807,7 +807,7 @@ get_min_dimensions(GLenum pname)
  * dimensions.
  */
 static bool
-is_multisample_target(GLenum target)
+_is_multisample_target(GLenum target)
 {
switch(target) {
case GL_TEXTURE_2D_MULTISAMPLE:
@@ -1016,12 +1016,12 @@ _mesa_GetInternalformativ(GLenum target, GLenum 
internalformat, GLenum pname,
* "If the resource does not have at least two dimensions, or if the
* resource is unsupported, zero is returned."
*/
-  dimensions = get_target_dimensions(target);
-  min_dimensions = get_min_dimensions(pname);
+  dimensions = _get_target_dimensions(target);
+  min_dimensions = _get_min_dimensions(pname);
   if (dimensions < min_dimensions)
  goto end;
 
-  get_pname = equivalentSizePname(target, pname);
+  get_pname = _equivalent_size_pname(target, pname);
   if (get_pname == 0)
  goto end;
 
@@ -1055,7 +1055,7 @@ _mesa_GetInternalformativ(GLenum target, GLenum 
internalformat, GLenum pname,
* returned as MAX_HEIGHT or MAX_DEPTH */
   for (i = 0; i < 4; i++) {
  if (max_dimensions_pnames[i] == GL_SAMPLES &&
- !is_multisample_target(target))
+ !_is_multisample_target(target))
 continue;
 
  _mesa_GetInternalformativ(target, internalformat,

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


Mesa (master): main/fbobject: implement new 4.5 pnames for GetFramebufferParameter

2017-02-05 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 0fb0c57b15aa6b5f48ab3f8596241248e02d55e5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0fb0c57b15aa6b5f48ab3f8596241248e02d55e5

Author: Alejandro Piñeiro 
Date:   Fri Jan 13 16:23:05 2017 -0200

main/fbobject: implement new 4.5 pnames for GetFramebufferParameter

4.5 added new pnames allowed for GetFramebufferParameter, and
GetNamedFramebufferParameter.

From OpenGL 4.5 spec, section 9.2.3 "Framebuffer Object Queries" (quoting
the paragraph with only the new pnames, not all the supported):

   "pname may also be one of DOUBLEBUFFER,
IMPLEMENTATION_COLOR_READ_FORMAT, IMPLEMENTATION_COLOR_READ_TYPE,
SAMPLES, SAMPLE_BUFFERS, or STEREO, indicating the corresponding
framebuffer-dependent state from table 23.73. Values of
framebuffer-dependent state are identical to those that would be
obtained were the framebuffer object bound and queried using the
simple state queries in that table. These values may be queried
from either a framebuffer object or a default framebuffer."

Fixes:
GL45-CTS.direct_state_access.framebuffers_get_parameters

Reviewed-by: Anuj Phogat 

---

 src/mesa/main/fbobject.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index f32f931..bed5b25 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -1505,6 +1505,24 @@ get_framebuffer_parameteriv(struct gl_context *ctx, 
struct gl_framebuffer *fb,
case GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS:
   *params = fb->DefaultGeometry.FixedSampleLocations;
   break;
+   case GL_DOUBLEBUFFER:
+  *params = fb->Visual.doubleBufferMode;
+  break;
+   case GL_IMPLEMENTATION_COLOR_READ_FORMAT:
+  *params = _mesa_get_color_read_format(ctx, fb, func);
+  break;
+   case GL_IMPLEMENTATION_COLOR_READ_TYPE:
+  *params = _mesa_get_color_read_type(ctx, fb, func);
+  break;
+   case GL_SAMPLES:
+  *params = _mesa_geometric_samples(fb);
+  break;
+   case GL_SAMPLE_BUFFERS:
+  *params = _mesa_geometric_samples(fb) > 0;
+  break;
+   case GL_STEREO:
+  *params = fb->Visual.stereoMode;
+  break;
default:
   _mesa_error(ctx, GL_INVALID_ENUM,
   "%s(pname=0x%x)", func, pname);

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


Mesa (master): main/framebuffer: refactor _mesa_get_color_read_format/type

2017-02-05 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 0cd2a4737eb189fb37ff53c7583c8e4aa2d5a630
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0cd2a4737eb189fb37ff53c7583c8e4aa2d5a630

Author: Alejandro Piñeiro 
Date:   Tue Jan 17 18:06:36 2017 -0200

main/framebuffer: refactor _mesa_get_color_read_format/type

Current implementation returns the value for the currently bound read
framebuffer. GetNamedFramebufferParameteriv allows to get it for any
given framebuffer. GetFramebufferParameteriv would be also interested
on that method

It was refactored by allowing to pass a given framebuffer. If NULL is
passed, it used the currently bound framebuffer.

It also adds a call to _mesa_update_state. When used only by
GetIntegerv, this one was called as part of the extra checks defined
at get_hash. But now that the method is used by more methods, and the
update is needed, it makes sense (and it is safer) just calling it on
the method itself, instead of rely on the caller.

Reviewed-by: Anuj Phogat 

---

 src/mesa/main/framebuffer.c | 77 +++--
 src/mesa/main/framebuffer.h |  8 +++--
 src/mesa/main/get.c |  4 +--
 src/mesa/main/readpix.c |  4 +--
 4 files changed, 71 insertions(+), 22 deletions(-)

diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index c06130d..9002020 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -44,6 +44,7 @@
 #include "renderbuffer.h"
 #include "texobj.h"
 #include "glformats.h"
+#include "state.h"
 
 
 
@@ -835,22 +836,54 @@ _mesa_dest_buffer_exists(struct gl_context *ctx, GLenum 
format)
 
 
 /**
- * Used to answer the GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES query.
+ * Used to answer the GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES queries (using
+ * GetIntegerv, GetFramebufferParameteriv, etc)
+ *
+ * If @fb is NULL, the method returns the value for the current bound
+ * framebuffer.
  */
 GLenum
-_mesa_get_color_read_format(struct gl_context *ctx)
+_mesa_get_color_read_format(struct gl_context *ctx,
+struct gl_framebuffer *fb,
+const char *caller)
 {
-   if (!ctx->ReadBuffer || !ctx->ReadBuffer->_ColorReadBuffer) {
-  /* The spec is unclear how to handle this case, but NVIDIA's
-   * driver generates GL_INVALID_OPERATION.
+   if (ctx->NewState)
+  _mesa_update_state(ctx);
+
+   if (fb == NULL)
+  fb = ctx->ReadBuffer;
+
+   if (!fb || !fb->_ColorReadBuffer) {
+  /*
+   * From OpenGL 4.5 spec, section 18.2.2 "ReadPixels":
+   *
+   *"An INVALID_OPERATION error is generated by GetIntegerv if pname
+   * is IMPLEMENTATION_COLOR_READ_FORMAT or IMPLEMENTATION_COLOR_-
+   * READ_TYPE and any of:
+   *  * the read framebuffer is not framebuffer complete.
+   *  * the read framebuffer is a framebuffer object, and the selected
+   *read buffer (see section 18.2.1) has no image attached.
+   *  * the selected read buffer is NONE."
+   *
+   * There is not equivalent quote for GetFramebufferParameteriv or
+   * GetNamedFramebufferParameteriv, but from section 9.2.3 "Framebuffer
+   * Object Queries":
+   *
+   *"Values of framebuffer-dependent state are identical to those that
+   * would be obtained were the framebuffer object bound and queried
+   * using the simple state queries in that table."
+   *
+   * Where "using the simple state queries" refer to use GetIntegerv. So
+   * we will assume that on that situation the same error should be
+   * triggered too.
*/
   _mesa_error(ctx, GL_INVALID_OPERATION,
-  "glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT: "
-  "no GL_READ_BUFFER)");
+  "%s(GL_IMPLEMENTATION_COLOR_READ_FORMAT: no GL_READ_BUFFER)",
+  caller);
   return GL_NONE;
}
else {
-  const mesa_format format = ctx->ReadBuffer->_ColorReadBuffer->Format;
+  const mesa_format format = fb->_ColorReadBuffer->Format;
   const GLenum data_type = _mesa_get_format_datatype(format);
 
   if (format == MESA_FORMAT_B8G8R8A8_UNORM)
@@ -872,22 +905,34 @@ _mesa_get_color_read_format(struct gl_context *ctx)
 
 
 /**
- * Used to answer the GL_IMPLEMENTATION_COLOR_READ_TYPE_OES query.
+ * Used to answer the GL_IMPLEMENTATION_COLOR_READ_TYPE_OES queries (using
+ * GetIntegerv, GetFramebufferParameteriv, etc)
+ *
+ * If @fb is NULL, the method returns the value for the current bound
+ * framebuffer.
  */
 GLenum
-_mesa_get_color_read_type(struct gl_context *ctx)
+_mesa_get_color_read_type(struct gl_context *ctx,
+  struct gl_framebuffer *fb,
+  const char *caller)
 {
-   if (!ctx->ReadBuffer || !ctx->ReadBuffer->_ColorReadBuffer) {
-  /* The spec is unclear how to handle this case, but NVIDIA's
-   * driver generates 

Mesa (master): main/fboject: default_framebuffer allowed for GetFramebufferParameter

2017-02-05 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: dfb1b543f36410fb01ba202076550e1259c89ed1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=dfb1b543f36410fb01ba202076550e1259c89ed1

Author: Alejandro Piñeiro 
Date:   Fri Jan 13 15:53:13 2017 -0200

main/fboject: default_framebuffer allowed for GetFramebufferParameter

Before 4.5, the default framebuffer was not allowed for
GetFramebufferParameter, so it should return INVALID_OPERATION for any
call using the default framebuffer.

4.5 included new pnames, and some of them are allowed for the default
framebuffer. For the rest, INVALID_OPERATION. From OpenGL 4.5 spec,
section 9.2.3 "Framebuffer Object Queries:

   "An INVALID_OPERATION error is generated by GetFramebufferParameteriv
if the default framebuffer is bound to target and pname is not one
of the accepted values from table 23.73, other than
SAMPLE_POSITION."

Fixes:
GL45-CTS.direct_state_access.framebuffers_get_parameter_errors

Reviewed-by: Anuj Phogat 

---

 src/mesa/main/fbobject.c | 44 +---
 1 file changed, 37 insertions(+), 7 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index bed5b25..c8ec8e6 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -1477,10 +1477,47 @@ _mesa_FramebufferParameteri(GLenum target, GLenum 
pname, GLint param)
framebuffer_parameteri(ctx, fb, pname, param, "glFramebufferParameteri");
 }
 
+static bool
+_pname_valid_for_default_framebuffer(struct gl_context *ctx,
+ GLenum pname)
+{
+   if (!_mesa_is_desktop_gl(ctx))
+  return false;
+
+   switch (pname) {
+   case GL_DOUBLEBUFFER:
+   case GL_IMPLEMENTATION_COLOR_READ_FORMAT:
+   case GL_IMPLEMENTATION_COLOR_READ_TYPE:
+   case GL_SAMPLES:
+   case GL_SAMPLE_BUFFERS:
+   case GL_STEREO:
+  return true;
+   default:
+  return false;
+   }
+}
+
 static void
 get_framebuffer_parameteriv(struct gl_context *ctx, struct gl_framebuffer *fb,
 GLenum pname, GLint *params, const char *func)
 {
+   /* From OpenGL 4.5 spec, section 9.2.3 "Framebuffer Object Queries:
+*
+*"An INVALID_OPERATION error is generated by GetFramebufferParameteriv
+* if the default framebuffer is bound to target and pname is not one
+* of the accepted values from table 23.73, other than
+* SAMPLE_POSITION."
+*
+* For OpenGL ES, using default framebuffer still raises INVALID_OPERATION
+* for any pname.
+*/
+   if (_mesa_is_winsys_fbo(fb) &&
+   !_pname_valid_for_default_framebuffer(ctx, pname)) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "%s(invalid pname=0x%x for default framebuffer)", func, 
pname);
+  return;
+   }
+
switch (pname) {
case GL_FRAMEBUFFER_DEFAULT_WIDTH:
   *params = fb->DefaultGeometry.Width;
@@ -1549,13 +1586,6 @@ _mesa_GetFramebufferParameteriv(GLenum target, GLenum 
pname, GLint *params)
   return;
}
 
-   /* check framebuffer binding */
-   if (_mesa_is_winsys_fbo(fb)) {
-  _mesa_error(ctx, GL_INVALID_OPERATION,
-  "glGetFramebufferParameteriv");
-  return;
-   }
-
get_framebuffer_parameteriv(ctx, fb, pname, params,
"glGetFramebufferParameteriv");
 }

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


Mesa (master): mesa/main: Fix FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE for NONE attachment type

2017-01-19 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 905961452ad3e7e29745dad78d70b2973377982b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=905961452ad3e7e29745dad78d70b2973377982b

Author: Alejandro Piñeiro 
Date:   Fri Jan 13 11:39:24 2017 -0200

mesa/main: Fix FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE for NONE attachment type

When the attachment type is NONE (att->Type),
FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE should be NONE always.

Note that technically, the current behaviour follows the spec. From
OpenGL 4.5 spec, Section 9.2.3 "Framebuffer Object Queries":

   "If the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is NONE, then
either no framebuffer is bound to target; or the default
framebuffer is bound, attachment is DEPTH or STENCIL, and the
number of depth or stencil bits, respectively, is zero."

Reading literally this paragraph, for the default framebuffer, NONE
should be only returned if attachment is DEPTH and STENCIL without
being allocated.

But it doesn't makes too much sense to return DEFAULT_FRAMEBUFFER if
the attachment type is NONE. For example, this can happens if the
attachment is FRONT_RIGHT run on monoscopic mode, as that attachment
is only available on stereo mode.

With the current behaviour, defensive querying of the object type
would not work properly. So you could query the object type checking
for NONE, get DEFAULT_FRAMEBUFFER, and then get and INVALID_OPERATION
when requesting other pnames (like RED_SIZE), as the real attachment
type is NONE.

This fixes:
GL45-CTS.direct_state_access.framebuffers_get_attachment_parameters

v2: don't change the behaviour for att->Type != GL_NONE, as caused
some ES CTS regressions
v3: simplify condition (Iago)

Reviewed-by: Iago Toral Quiroga 

---

 src/mesa/main/fbobject.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 044bd63..6934805 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -3754,11 +3754,13 @@ _mesa_get_framebuffer_attachment_parameter(struct 
gl_context *ctx,
*  either no framebuffer is bound to target; or the default framebuffer
*  is bound, attachment is DEPTH or STENCIL, and the number of depth or
*  stencil bits, respectively, is zero."
+   *
+   * Note that we don't need explicit checks on DEPTH and STENCIL, because
+   * on the case the spec is pointing, att->Type is already NONE, so we
+   * just need to check att->Type.
*/
-  *params = (_mesa_is_winsys_fbo(buffer) &&
- ((attachment != GL_DEPTH && attachment != GL_STENCIL) ||
-  (att->Type != GL_NONE)))
- ? GL_FRAMEBUFFER_DEFAULT : att->Type;
+  *params = (_mesa_is_winsys_fbo(buffer) && att->Type != GL_NONE) ?
+ GL_FRAMEBUFFER_DEFAULT : att->Type;
   return;
case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT:
   if (att->Type == GL_RENDERBUFFER_EXT) {

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


Mesa (master): main/fbobject: throw invalid operation when get_attachment fails if needed

2017-01-13 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 84e3e12b2582f4707a837ebb960ea7ce19e1c263
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=84e3e12b2582f4707a837ebb960ea7ce19e1c263

Author: Alejandro Piñeiro 
Date:   Thu Jan 12 16:09:17 2017 -0200

main/fbobject: throw invalid operation when get_attachment fails if needed

In most cases, if a call to get_attachment fails is because attachment
is a INVALID_ENUM. But for some specific cases, if COLOR_ATTACHMENTm
(where m >= MAX_COLOR_ATTACHMENTS) is used, it should raise an
INVALID_OPERATION exception instead.

Fixes:
GL45-CTS.direct_state_access.framebuffers_get_attachment_parameter_errors
GL45-CTS.direct_state_access.framebuffers_renderbuffer_attachment_errors

v2: extra new line before quote block. Include "color attachment" on both
new message errors (Nicolai).

Reviewed-by: Nicolai Hähnle 

---

 src/mesa/main/fbobject.c | 49 +---
 1 file changed, 42 insertions(+), 7 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index ce5eeae..044bd63 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -3495,6 +3495,7 @@ framebuffer_renderbuffer(struct gl_context *ctx,
  const char *func)
 {
struct gl_renderbuffer_attachment *att;
+   bool is_color_attachment;
 
if (_mesa_is_winsys_fbo(fb)) {
   /* Can't attach new renderbuffers to a window system framebuffer */
@@ -3503,11 +3504,29 @@ framebuffer_renderbuffer(struct gl_context *ctx,
   return;
}
 
-   att = get_attachment(ctx, fb, attachment, NULL);
+   att = get_attachment(ctx, fb, attachment, _color_attachment);
if (att == NULL) {
-  _mesa_error(ctx, GL_INVALID_ENUM,
-  "%s(invalid attachment %s)", func,
-  _mesa_enum_to_string(attachment));
+  /*
+   * From OpenGL 4.5 spec, section 9.2.7 "Attaching Renderbuffer Images to
+   * a Framebuffer":
+   *
+   *"An INVALID_OPERATION error is generated if attachment is COLOR_-
+   * ATTACHMENTm where m is greater than or equal to the value of
+   * MAX_COLOR_- ATTACHMENTS ."
+   *
+   * If we are at this point, is because the attachment is not valid, so
+   * if is_color_attachment is true, is because of the previous reason.
+   */
+  if (is_color_attachment) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(invalid color attachment %s)", func,
+ _mesa_enum_to_string(attachment));
+  } else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "%s(invalid attachment %s)", func,
+ _mesa_enum_to_string(attachment));
+  }
+
   return;
}
 
@@ -3609,6 +3628,7 @@ _mesa_get_framebuffer_attachment_parameter(struct 
gl_context *ctx,
GLint *params, const char *caller)
 {
const struct gl_renderbuffer_attachment *att;
+   bool is_color_attachment;
GLenum err;
 
/* The error code for an attachment type of GL_NONE differs between APIs.
@@ -3676,12 +3696,27 @@ _mesa_get_framebuffer_attachment_parameter(struct 
gl_context *ctx,
}
else {
   /* user-created framebuffer FBO */
-  att = get_attachment(ctx, buffer, attachment, NULL);
+  att = get_attachment(ctx, buffer, attachment, _color_attachment);
}
 
if (att == NULL) {
-  _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid attachment %s)", caller,
-  _mesa_enum_to_string(attachment));
+  /*
+   * From OpenGL 4.5 spec, section 9.2.3 "Framebuffer Object Queries":
+   *
+   *"An INVALID_OPERATION error is generated if a framebuffer object
+   * is bound to target and attachment is COLOR_ATTACHMENTm where m is
+   * greater than or equal to the value of MAX_COLOR_ATTACHMENTS."
+   *
+   * If we are at this point, is because the attachment is not valid, so
+   * if is_color_attachment is true, is because of the previous reason.
+   */
+  if (is_color_attachment) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid color attachment 
%s)",
+ caller, _mesa_enum_to_string(attachment));
+  } else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid attachment %s)", caller,
+ _mesa_enum_to_string(attachment));
+  }
   return;
}
 

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


Mesa (master): main/fboject: return if it is color_attachment on get_attachment

2017-01-13 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: c6eb3aeba530fe82087c1c3c06ded23cb79bc199
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c6eb3aeba530fe82087c1c3c06ded23cb79bc199

Author: Alejandro Piñeiro 
Date:   Thu Jan 12 16:03:00 2017 -0200

main/fboject: return if it is color_attachment on get_attachment

Some callers would need that info to know if they should raise
INVALID_ENUM or INVALID_OPERATION. An alternative would be the caller
to check if the attachment is a GL_COLOR_ATTACHMENTm, but that seems
redundant as get_attachment is already doing that.

Reviewed-by: Nicolai Hähnle 

---

 src/mesa/main/fbobject.c | 30 +++---
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 26fc15d..ce5eeae 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -222,15 +222,21 @@ get_framebuffer_target(struct gl_context *ctx, GLenum 
target)
  * default / window-system FB object.
  * If \p attachment is GL_DEPTH_STENCIL_ATTACHMENT, return a pointer to
  * the depth buffer attachment point.
+ * Returns if the attachment is a GL_COLOR_ATTACHMENTm_EXT on
+ * is_color_attachment, because several callers would return different errors
+ * if they don't find the attachment.
  */
 static struct gl_renderbuffer_attachment *
 get_attachment(struct gl_context *ctx, struct gl_framebuffer *fb,
-   GLenum attachment)
+   GLenum attachment, bool *is_color_attachment)
 {
GLuint i;
 
assert(_mesa_is_user_fbo(fb));
 
+   if (is_color_attachment)
+  *is_color_attachment = false;
+
switch (attachment) {
case GL_COLOR_ATTACHMENT0_EXT:
case GL_COLOR_ATTACHMENT1_EXT:
@@ -248,6 +254,8 @@ get_attachment(struct gl_context *ctx, struct 
gl_framebuffer *fb,
case GL_COLOR_ATTACHMENT13_EXT:
case GL_COLOR_ATTACHMENT14_EXT:
case GL_COLOR_ATTACHMENT15_EXT:
+  if (is_color_attachment)
+ *is_color_attachment = true;
   /* Only OpenGL ES 1.x forbids color attachments other than
* GL_COLOR_ATTACHMENT0.  For all other APIs the limit set by the
* hardware is used.
@@ -543,13 +551,13 @@ _mesa_FramebufferRenderbuffer_sw(struct gl_context *ctx,
 
mtx_lock(>Mutex);
 
-   att = get_attachment(ctx, fb, attachment);
+   att = get_attachment(ctx, fb, attachment, NULL);
assert(att);
if (rb) {
   set_renderbuffer_attachment(ctx, att, rb);
   if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
  /* do stencil attachment here (depth already done above) */
- att = get_attachment(ctx, fb, GL_STENCIL_ATTACHMENT_EXT);
+ att = get_attachment(ctx, fb, GL_STENCIL_ATTACHMENT_EXT, NULL);
  assert(att);
  set_renderbuffer_attachment(ctx, att, rb);
   }
@@ -559,7 +567,7 @@ _mesa_FramebufferRenderbuffer_sw(struct gl_context *ctx,
   remove_attachment(ctx, att);
   if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
  /* detach stencil (depth was detached above) */
- att = get_attachment(ctx, fb, GL_STENCIL_ATTACHMENT_EXT);
+ att = get_attachment(ctx, fb, GL_STENCIL_ATTACHMENT_EXT, NULL);
  assert(att);
  remove_attachment(ctx, att);
   }
@@ -1219,7 +1227,7 @@ _mesa_test_framebuffer_completeness(struct gl_context 
*ctx,
   for (j = 0; j < ctx->Const.MaxDrawBuffers; j++) {
  if (fb->ColorDrawBuffer[j] != GL_NONE) {
 const struct gl_renderbuffer_attachment *att
-   = get_attachment(ctx, fb, fb->ColorDrawBuffer[j]);
+   = get_attachment(ctx, fb, fb->ColorDrawBuffer[j], NULL);
 assert(att);
 if (att->Type == GL_NONE) {
fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT;
@@ -1232,7 +1240,7 @@ _mesa_test_framebuffer_completeness(struct gl_context 
*ctx,
   /* Check that the ReadBuffer is present */
   if (fb->ColorReadBuffer != GL_NONE) {
  const struct gl_renderbuffer_attachment *att
-= get_attachment(ctx, fb, fb->ColorReadBuffer);
+= get_attachment(ctx, fb, fb->ColorReadBuffer, NULL);
  assert(att);
  if (att->Type == GL_NONE) {
 fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT;
@@ -3151,7 +3159,7 @@ _mesa_framebuffer_texture(struct gl_context *ctx, struct 
gl_framebuffer *fb,
}
 
/* Not a hash lookup, so we can afford to get the attachment here. */
-   att = get_attachment(ctx, fb, attachment);
+   att = get_attachment(ctx, fb, attachment, NULL);
if (att == NULL) {
   _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid attachment %s)", caller,
   _mesa_enum_to_string(attachment));
@@ -3495,7 +3503,7 @@ framebuffer_renderbuffer(struct gl_context *ctx,
   return;
}
 
-   att = get_attachment(ctx, fb, attachment);
+   att = get_attachment(ctx, fb, attachment, NULL);
if (att == NULL) {
   _mesa_error(ctx, GL_INVALID_ENUM,

Mesa (master): main/buffers: update error handling on DrawBuffers for 4.5

2017-01-12 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: d54bc7e01f3f2e3178adecf53ea243470a3d5d93
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d54bc7e01f3f2e3178adecf53ea243470a3d5d93

Author: Alejandro Piñeiro 
Date:   Tue Dec 13 08:58:59 2016 -0200

main/buffers: update error handling on DrawBuffers for 4.5

Before 4.5, GL_BACK was not allowed as a value of bufs. Since 4.5 it
is allowed under some circumstances:

From the OpenGL 4.5 specification, Section 17.4.1 "Selecting Buffers
for Writing", page 493 (page 515 of the PDF):
 "An INVALID_ENUM error is generated if any value in bufs is FRONT,
  LEFT, RIGHT, or FRONT_AND_BACK . This restriction applies to both
  the de- fault framebuffer and framebuffer objects, and exists
  because these constants may themselves refer to multiple buffers, as
  shown in table 17.4."

And on page 492 (page 514 of the PDF):
 "If the default framebuffer is affected, then each of the constants
  must be one of the values listed in table 17.6 or the special value
  BACK . When BACK is used, n must be 1 and color values are written
  into the left buffer for single-buffered contexts, or into the back
  left buffer for double-buffered contexts."

This patch keeps the same behaviour if OpenGL version is < 4. We
assume that for 4.x this is the intended behaviour, so a fix, but for
3.x the intended behaviour is the already in place.

Part of the fix for:
GL45-CTS.direct_state_access.framebuffers_draw_read_buffers_errors

v2: remove forgot printf
v3: remove spaces before commas on spec quote, split line too
long (Anuj)

Reviewed-by: Anuj Phogat 

---

 src/mesa/main/buffers.c | 46 +-
 1 file changed, 33 insertions(+), 13 deletions(-)

diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index 2b24e5a..bba5e7e 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -343,7 +343,9 @@ _mesa_NamedFramebufferDrawBuffer(GLuint framebuffer, GLenum 
buf)
  * \param n  number of outputs
  * \param buffers  array [n] of renderbuffer names.  Unlike glDrawBuffer, the
  * names cannot specify more than one buffer.  For example,
- * GL_FRONT_AND_BACK is illegal.
+ * GL_FRONT_AND_BACK is illegal. The only exception is GL_BACK
+ * that is considered special and allowed as far as n is one
+ * since 4.5.
  */
 static void
 draw_buffers(struct gl_context *ctx, struct gl_framebuffer *fb,
@@ -401,20 +403,38 @@ draw_buffers(struct gl_context *ctx, struct 
gl_framebuffer *fb,
  return;
   }
 
-  /* From the OpenGL 4.0 specification, page 256:
-   * "For both the default framebuffer and framebuffer objects, the
-   *  constants FRONT, BACK, LEFT, RIGHT, and FRONT_AND_BACK are not
-   *  valid in the bufs array passed to DrawBuffers, and will result in
-   *  the error INVALID_ENUM. This restriction is because these
-   *  constants may themselves refer to multiple buffers, as shown in
-   *  table 4.4."
-   *  Previous versions of the OpenGL specification say INVALID_OPERATION,
-   *  but the Khronos conformance tests expect INVALID_ENUM.
+  /* From the OpenGL 4.5 specification, page 493 (page 515 of the PDF)
+   * "An INVALID_ENUM error is generated if any value in bufs is FRONT,
+   *  LEFT, RIGHT, or FRONT_AND_BACK . This restriction applies to both
+   *  the default framebuffer and framebuffer objects, and exists because
+   *  these constants may themselves refer to multiple buffers, as shown
+   *  in table 17.4."
+   *
+   * And on page 492 (page 514 of the PDF):
+   * "If the default framebuffer is affected, then each of the constants
+   *  must be one of the values listed in table 17.6 or the special value
+   *  BACK. When BACK is used, n must be 1 and color values are written
+   *  into the left buffer for single-buffered contexts, or into the back
+   *  left buffer for double-buffered contexts."
+   *
+   * Note "special value BACK". GL_BACK also refers to multiple buffers,
+   * but it is consider a special case here. This is a change on 4.5. For
+   * OpenGL 4.x we check that behaviour. For any previous version we keep
+   * considering it wrong (as INVALID_ENUM).
*/
   if (_mesa_bitcount(destMask[output]) > 1) {
- _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid buffer %s)",
- caller, _mesa_enum_to_string(buffers[output]));
- return;
+ if (_mesa_is_winsys_fbo(fb) && ctx->Version >= 40 &&
+ buffers[output] == GL_BACK) {
+if (n != 1) {
+   _mesa_error(ctx, GL_INVALID_OPERATION, "%s(with GL_BACK n must 
be 1)",
+   caller);
+   return;
+}
+ } else {
+_mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid buffer %s)",
+

Mesa (master): main/buffers: take into account FRONT_AND_BACK on ReadBuffer

2017-01-12 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: f354cd5c69b0b1fe7db87473240a51ecc7369c03
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f354cd5c69b0b1fe7db87473240a51ecc7369c03

Author: Alejandro Piñeiro 
Date:   Wed Jan 11 18:11:55 2017 -0200

main/buffers: take into account FRONT_AND_BACK on ReadBuffer

From OpenGL 3.1 spec, section 4.3.1 "Reading Pixels", page 190 (203 PDF)

  "When READ FRAMEBUFFER BINDING is zero, i.e. the default
   framebuffer, src must be one of the values listed in table 4.4,
   including NONE . FRONT_AND_BACK , FRONT , and LEFT refer to the
   front left buffer."

There is an equivalent text on OpenGL 4.5 spec, section 18.2.1
"Selecting Buffers for Reading", page 502 (524 PDF), so the behaviour
is still the same.

Part of the fix for:
GL45-CTS.direct_state_access.framebuffers_draw_read_buffers_errors

Reviewed-by: Anuj Phogat 

---

 src/mesa/main/buffers.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index bba5e7e..7d17ae9 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -204,6 +204,8 @@ read_buffer_enum_to_index(const struct gl_context *ctx, 
GLenum buffer)
  return BUFFER_FRONT_LEFT;
   case GL_AUX0:
  return BUFFER_AUX0;
+  case GL_FRONT_AND_BACK:
+ return BUFFER_FRONT_LEFT;
   case GL_AUX1:
   case GL_AUX2:
   case GL_AUX3:

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


Mesa (master): i965: check for GL_TEXTURE_EXTERNAL_OES at miptree_create_for_teximage

2016-09-12 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 6165603209f08cd95dc687363034f54978fe2c77
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6165603209f08cd95dc687363034f54978fe2c77

Author: Alejandro Piñeiro 
Date:   Sun Sep 11 00:07:30 2016 +0200

i965: check for GL_TEXTURE_EXTERNAL_OES at miptree_create_for_teximage

Forgotten on commit "i965: Fix calculation of the image height at start level".

Thanks to Ilia Mirkin for point it.

Fixes the following regressions on Haswell and Broadwell:
ES2-CTS.gtf.GL2ExtensionTests.egl_image_external.TestSimpleUnassociated (crash 
back to pass)
ES2-CTS.gtf.GL2ExtensionTests.egl_image_external.TestSimple (crash back to fail)
ES2-CTS.gtf.GL2ExtensionTests.egl_image_external.TestVertexShader (crash back 
to fail)

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

Reviewed-by: Jason Ekstrand 

---

 src/mesa/drivers/dri/i965/intel_tex_image.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c 
b/src/mesa/drivers/dri/i965/intel_tex_image.c
index 6142a5f..f204db3 100644
--- a/src/mesa/drivers/dri/i965/intel_tex_image.c
+++ b/src/mesa/drivers/dri/i965/intel_tex_image.c
@@ -50,6 +50,7 @@ intel_miptree_create_for_teximage(struct brw_context *brw,
case GL_TEXTURE_2D_MULTISAMPLE:
case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
case GL_TEXTURE_RECTANGLE:
+   case GL_TEXTURE_EXTERNAL_OES:
   assert(intelImage->base.Base.Level == 0);
   break;
case GL_TEXTURE_3D:

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


Mesa (master): i965: remove unused variable at intel_miptree_create_for_teximage

2016-09-11 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: e77bf3247524df31d19cf4c09a19fb8b52fd9d9d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e77bf3247524df31d19cf4c09a19fb8b52fd9d9d

Author: Alejandro Piñeiro 
Date:   Sun Sep 11 00:07:31 2016 +0200

i965: remove unused variable at intel_miptree_create_for_teximage

After commit "i965: Fix calculation of the image height at start level", it is
not needed. This commit removes the "warning: unused variable ‘i’" warning.

Reviewed-by: Timothy Arceri 

---

 src/mesa/drivers/dri/i965/intel_tex_image.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c 
b/src/mesa/drivers/dri/i965/intel_tex_image.c
index 65962eb..6142a5f 100644
--- a/src/mesa/drivers/dri/i965/intel_tex_image.c
+++ b/src/mesa/drivers/dri/i965/intel_tex_image.c
@@ -40,7 +40,6 @@ intel_miptree_create_for_teximage(struct brw_context *brw,
 {
GLuint lastLevel;
int width, height, depth;
-   GLuint i;
 
intel_get_image_dims(>base.Base, , , );
 

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


Mesa (master): mesa/main: Fix missing return in non void function

2016-08-26 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: bc5be5323f14c4f790ecaf29991158be1f5435b0
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=bc5be5323f14c4f790ecaf29991158be1f5435b0

Author: Tobias Klausmann 
Date:   Thu Aug 25 23:48:31 2016 +0200

mesa/main: Fix missing return in non void function

This was found by obs:
I: Program returns random data in a function
E: Mesa no-return-in-nonvoid-function main/program_resource.c:109

v2: Remove the ! on the string (Ian Romanick)

Signed-off-by: Tobias Klausmann 
Reviewed-by: Ian Romanick 

---

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

diff --git a/src/mesa/main/program_resource.c b/src/mesa/main/program_resource.c
index 6ddbdad..5726ce1 100644
--- a/src/mesa/main/program_resource.c
+++ b/src/mesa/main/program_resource.c
@@ -104,7 +104,7 @@ stage_from_program_interface(GLenum programInterface)
case GL_COMPUTE_SUBROUTINE_UNIFORM:
   return MESA_SHADER_COMPUTE;
default:
-  assert(!"unexpected programInterface value");
+  unreachable("unexpected programInterface value");
}
 }
 

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


Mesa (master): shaderapi: don' t generate not linked error on GetProgramStage in general

2016-08-24 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: b4959e17f18aff68465f4b3445b6a53ee0227b16
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b4959e17f18aff68465f4b3445b6a53ee0227b16

Author: Alejandro Piñeiro 
Date:   Tue Aug 23 17:00:54 2016 +0200

shaderapi: don't generate not linked error on GetProgramStage in general

Both ARB_shader_subroutine and the GL core spec doesn't list any
error when the program is not linked.

We left a error generation for the uniform location, in order to be
consistent with other methods from the spec that generate them.

Reviewed-by: Tapani Pälli 

---

 src/mesa/main/shaderapi.c | 19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 8b19c01..d969955 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -2725,8 +2725,25 @@ _mesa_GetProgramStageiv(GLuint program, GLenum 
shadertype,
 
stage = _mesa_shader_enum_to_shader_stage(shadertype);
sh = shProg->_LinkedShaders[stage];
+
+   /* ARB_shader_subroutine doesn't ask the program to be linked, or list any
+* INVALID_OPERATION in the case of not be linked.
+*
+* And for some pnames, like GL_ACTIVE_SUBROUTINE_UNIFORMS, you can ask the
+* same info using other specs (ARB_program_interface_query), without the
+* need of the program to be linked, being the value for that case 0.
+*
+* But at the same time, some other methods require the program to be
+* linked for pname related to locations, so it would be inconsistent to
+* not do the same here. So we are:
+*   * Return GL_INVALID_OPERATION if not linked only for locations.
+*   * Setting a default value of 0, to be returned if not linked.
+*/
if (!sh) {
-  _mesa_error(ctx, GL_INVALID_OPERATION, "%s", api_name);
+  values[0] = 0;
+  if (pname == GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s", api_name);
+  }
   return;
}
 

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


Mesa (master): program_resource: subroutine active uniforms should return NumSubroutineUniforms

2016-08-24 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 07fe2d565bb117e8ae0a96b084633cc5a18b029d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=07fe2d565bb117e8ae0a96b084633cc5a18b029d

Author: Alejandro Piñeiro 
Date:   Thu Aug 18 19:44:55 2016 +0200

program_resource: subroutine active uniforms should return NumSubroutineUniforms

Before this commit, GetProgramInterfaceiv for pname ACTIVE_RESOURCES
and all the _SUBROUTINE_UNIFORM programInterface were
returning the count of resources on the shader program using that
interface, instead of the num of uniform resources. This would get a
wrong value (for example) if the shader has an array of subroutine
uniforms.

Note that this means that in order to get a proper value, the shader
needs to be linked, something that is not explicitly mentioned on
ARB_program_interface_query spec, but comes from the general
definition of active uniform. If the program is not linked we
return 0.

v2: don't generate an error if the program is not linked, returning 0
active uniforms instead, plus extra spec references (Tapani Palli)

Fixes GL44-CTS.program_interface_query.subroutines-compute

Reviewed-by: Tapani Pälli 

---

 src/mesa/main/program_resource.c | 141 ---
 1 file changed, 118 insertions(+), 23 deletions(-)

diff --git a/src/mesa/main/program_resource.c b/src/mesa/main/program_resource.c
index f2a9f00..6ddbdad 100644
--- a/src/mesa/main/program_resource.c
+++ b/src/mesa/main/program_resource.c
@@ -66,6 +66,79 @@ supported_interface_enum(struct gl_context *ctx, GLenum 
iface)
}
 }
 
+static struct gl_shader_program *
+lookup_linked_program(GLuint program,
+  const char *caller,
+  bool raise_link_error)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_shader_program *prog =
+  _mesa_lookup_shader_program_err(ctx, program, caller);
+
+   if (!prog)
+  return NULL;
+
+   if (prog->LinkStatus == GL_FALSE) {
+  if (raise_link_error)
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(program not linked)",
+ caller);
+  return NULL;
+   }
+   return prog;
+}
+
+static GLenum
+stage_from_program_interface(GLenum programInterface)
+{
+   switch(programInterface) {
+   case GL_VERTEX_SUBROUTINE_UNIFORM:
+  return MESA_SHADER_VERTEX;
+   case GL_TESS_CONTROL_SUBROUTINE_UNIFORM:
+  return MESA_SHADER_TESS_CTRL;
+   case GL_TESS_EVALUATION_SUBROUTINE_UNIFORM:
+  return MESA_SHADER_TESS_EVAL;
+   case GL_GEOMETRY_SUBROUTINE_UNIFORM:
+  return MESA_SHADER_GEOMETRY;
+   case GL_FRAGMENT_SUBROUTINE_UNIFORM:
+  return MESA_SHADER_FRAGMENT;
+   case GL_COMPUTE_SUBROUTINE_UNIFORM:
+  return MESA_SHADER_COMPUTE;
+   default:
+  assert(!"unexpected programInterface value");
+   }
+}
+
+static struct gl_linked_shader *
+lookup_linked_shader(GLuint program,
+ GLenum programInterface,
+ const char *caller)
+{
+   struct gl_shader_program *shLinkedProg =
+  lookup_linked_program(program, caller, false);
+   gl_shader_stage stage = stage_from_program_interface(programInterface);
+
+   if (!shLinkedProg)
+  return NULL;
+
+   return shLinkedProg->_LinkedShaders[stage];
+}
+
+static bool
+is_subroutine_uniform_program_interface(GLenum programInterface)
+{
+   switch(programInterface) {
+   case GL_VERTEX_SUBROUTINE_UNIFORM:
+   case GL_TESS_CONTROL_SUBROUTINE_UNIFORM:
+   case GL_TESS_EVALUATION_SUBROUTINE_UNIFORM:
+   case GL_GEOMETRY_SUBROUTINE_UNIFORM:
+   case GL_FRAGMENT_SUBROUTINE_UNIFORM:
+   case GL_COMPUTE_SUBROUTINE_UNIFORM:
+  return true;
+   default:
+  return false;
+   }
+}
+
 void GLAPIENTRY
 _mesa_GetProgramInterfaceiv(GLuint program, GLenum programInterface,
 GLenum pname, GLint *params)
@@ -101,9 +174,49 @@ _mesa_GetProgramInterfaceiv(GLuint program, GLenum 
programInterface,
/* Validate pname against interface. */
switch(pname) {
case GL_ACTIVE_RESOURCES:
-  for (i = 0, *params = 0; i < shProg->NumProgramResourceList; i++)
- if (shProg->ProgramResourceList[i].Type == programInterface)
-(*params)++;
+  if (is_subroutine_uniform_program_interface(programInterface)) {
+ /* ARB_program_interface_query doesn't explicitly says that those
+  * uniforms would need a linked shader, or that should fail if it is
+  * not the case, but Section 7.6 (Uniform Variables) of the OpenGL
+  * 4.4 Core Profile says:
+  *
+  *"A uniform is considered an active uniform if the compiler and
+  * linker determine that the uniform will actually be accessed
+  * when the executable code is executed. In cases where the
+  * compiler and linker cannot make a conclusive determination,
+  * the uniform will be considered active."
+  *
+  * So in order to know the real number of active 

Mesa (master): mesa/main: fix error checking logic on CopyImageSubData

2016-07-02 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: da7efadf040dafe5d925962c88a7189dcf058b25
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=da7efadf040dafe5d925962c88a7189dcf058b25

Author: Alejandro Piñeiro 
Date:   Thu Jun 30 14:41:01 2016 +0200

mesa/main: fix error checking logic on CopyImageSubData

For the case (both src or dst) where we had a texobject, but the
texobject target was not the same that the method target, this spec
paragraph was appplied:

 /* Section 18.3.2 (Copying Between Images) of the OpenGL 4.5 Core
  * Profile spec says:
  *
  * "An INVALID_VALUE error is generated if either name does not
  * correspond to a valid renderbuffer or texture object according
  * to the corresponding target parameter."
  */

But for that case, the correct spec paragraph should be:
 /* Section 18.3.2 (Copying Between Images) of the OpenGL 4.5 Core
  * Profile spec says:
  *
  * "An INVALID_ENUM error is generated if either target is
  *  not RENDERBUFFER or a valid non-proxy texture target;
  *  is TEXTURE_BUFFER or one of the cubemap face selectors
  *  described in table 8.18; or if the target does not
  *  match the type of the object."
  */

specifically the last sentence: "or if the target does not match the
type of the object".

This patch fixes the error returned (s/INVALID/ENUM) for that case,
and moves up the INVALID_VALUE spec paragraph, as that case (invalid
texture object) was handled before.

Fixes:
GL44-CTS.copy_image.target_miss_match

Reviewed-by: Nicolai Hähnle 

---

 src/mesa/main/copyimage.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/mesa/main/copyimage.c b/src/mesa/main/copyimage.c
index 7e5df61..cf25159 100644
--- a/src/mesa/main/copyimage.c
+++ b/src/mesa/main/copyimage.c
@@ -138,6 +138,12 @@ prepare_target(struct gl_context *ctx, GLuint name, GLenum 
target,
   struct gl_texture_object *texObj = _mesa_lookup_texture(ctx, name);
 
   if (!texObj) {
+ /*
+  * From GL_ARB_copy_image specification:
+  * "INVALID_VALUE is generated if either  or  does
+  * not correspond to a valid renderbuffer or texture object according
+  * to the corresponding target parameter."
+  */
  _mesa_error(ctx, GL_INVALID_VALUE,
  "glCopyImageSubData(%sName = %u)", dbg_prefix, name);
  return false;
@@ -154,12 +160,11 @@ prepare_target(struct gl_context *ctx, GLuint name, 
GLenum target,
   /* Note that target will not be a cube face name */
   if (texObj->Target != target) {
  /*
-  * From GL_ARB_copy_image specification:
-  * "INVALID_VALUE is generated if either  or  does
-  * not correspond to a valid renderbuffer or texture object according
-  * to the corresponding target parameter."
+  * From GL_ARB_copy_image_specification:
+  * "INVALID_ENUM is generated if the target does not match the type
+  * of the object."
   */
- _mesa_error(ctx, GL_INVALID_VALUE,
+ _mesa_error(ctx, GL_INVALID_ENUM,
  "glCopyImageSubData(%sTarget = %s)", dbg_prefix,
  _mesa_enum_to_string(target));
  return false;

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


Mesa (master): docs: update MESA_DEBUG envvar documentation.

2016-07-01 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: a97ee60926f6c08cb4cdd26a2746c483d8782547
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a97ee60926f6c08cb4cdd26a2746c483d8782547

Author: Alejandro Piñeiro 
Date:   Mon Jun 27 10:00:58 2016 +0200

docs: update MESA_DEBUG envvar documentation.

silent, flush, incomplete_tex and incomplete_fbo flags were not
documented (see src/mesa/main.debug.c for more info).

FP is not checked anymore.

v2 (Brian Paul):
 * MESA_DEBUG accepts a comma-separated list of parameters.
 * Clarify how MESA_DEBUG behaves with mesa debug and release builds.
 * Updated wording.

v3: Better wording for one paragraph (Brian Paul)

Reviewed-by: Brian Paul 

---

 docs/envvars.html | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/docs/envvars.html b/docs/envvars.html
index 2d9a289..6d79398 100644
--- a/docs/envvars.html
+++ b/docs/envvars.html
@@ -50,8 +50,17 @@ sometimes be useful for debugging end-user issues.
if the application generates a GL_INVALID_ENUM error, a corresponding error
message indicating where the error occurred, and possibly why, will be
printed to stderr.
-   If the value of MESA_DEBUG is 'FP' floating point arithmetic errors will
-   generate exceptions.
+
+   For release builds, MESA_DEBUG defaults to off (no debug output).
+
+   MESA_DEBUG accepts the following comma-separated list of named
+   flags, which adds extra behaviour to just set MESA_DEBUG=1:
+   
+ silent - turn off debug messages. Only useful for debug builds.
+ flush - flush after each drawing command
+ incomplete_tex - extra debug messages when a texture is 
incomplete
+ incomplete_fbo - extra debug messages when a fbo is incomplete
+   
 MESA_LOG_FILE - specifies a file name for logging all errors, warnings,
 etc., rather than stderr
 MESA_TEX_PROG - if set, implement conventional texture env modes with

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


Mesa (master): i965: intel_texture_barrier reimplemented

2016-07-01 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 5e553a6bb31cc205e43bde48a19399284ce3d5e1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5e553a6bb31cc205e43bde48a19399284ce3d5e1

Author: Alejandro Piñeiro 
Date:   Tue Jun 28 13:16:33 2016 +0200

i965: intel_texture_barrier reimplemented

Fixes:
GL44-CTS.texture_barrier_ARB.same-texel-rw-multipass

On Haswell, Broadwell and Skylake (note that in order to execute that
test, it is needed to override GL and GLSL versions).

On gen6 this test was already working without this change. It keeps
working after it.

This commit replaces the call to brw_emit_mi_flush for gen6+ with two
calls to brw_emit_pipe_control_flush:

 * The first one with RENDER_TARGET_FLUSH and CS_STALL set to initiate
   a render cache flush after any concurrent rendering completes and
   cause the CS to stop parsing commands until the render cache
   becomes coherent with memory.

 * The second one have TEXTURE_CACHE_INVALIDATE set (and no CS stall)
   to clean up any stale data from the sampler caches before rendering
   continues.

Didn't touch gen4-5, basically because I don't have a way to test
them.

More info on commits:
0aa4f99f562a05880a779707cbcd46be459863bf
72473658c51d5e074ce219c1e6385a4cce29f467

Thanks to Curro to help to tracking this down, as the root case was a
hw race condition.

v2: use two calls to pipe_control_flush instead of a combination of
gen7_emit_cs_stall_flush and brw_emit_mi_flush calls (Curro)
v3: no need to const cache invalidation (Curro)

Reviewed-by: Francisco Jerez 

---

 src/mesa/drivers/dri/i965/intel_tex.c | 21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/intel_tex.c 
b/src/mesa/drivers/dri/i965/intel_tex.c
index cac33ac..a802d5a 100644
--- a/src/mesa/drivers/dri/i965/intel_tex.c
+++ b/src/mesa/drivers/dri/i965/intel_tex.c
@@ -9,6 +9,7 @@
 #include "intel_mipmap_tree.h"
 #include "intel_tex.h"
 #include "intel_fbo.h"
+#include "intel_reg.h"
 
 #define FILE_DEBUG_FLAG DEBUG_TEXTURE
 
@@ -362,7 +363,25 @@ intel_texture_barrier(struct gl_context *ctx)
 {
struct brw_context *brw = brw_context(ctx);
 
-   brw_emit_mi_flush(brw);
+   if (brw->gen >= 6) {
+  if (brw->gen == 6) {
+ /* [Dev-SNB{W/A}]: Before a PIPE_CONTROL with Write Cache
+  * Flush Enable = 1, a PIPE_CONTROL with any non-zero
+  * post-sync-op is required.
+  */
+ brw_emit_post_sync_nonzero_flush(brw);
+  }
+
+  brw_emit_pipe_control_flush(brw,
+  PIPE_CONTROL_DEPTH_CACHE_FLUSH |
+  PIPE_CONTROL_RENDER_TARGET_FLUSH |
+  PIPE_CONTROL_CS_STALL);
+
+  brw_emit_pipe_control_flush(brw,
+  PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE);
+   } else {
+  brw_emit_mi_flush(brw);
+   }
 }
 
 void

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


Mesa (master): mesa/formatquery: expand NUM_SAMPLE_COUNTS OpenGL ES comment

2016-06-02 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 9bdbb9c0e0d0fb73831c590eb9626a3298f55982
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9bdbb9c0e0d0fb73831c590eb9626a3298f55982

Author: Alejandro Piñeiro 
Date:   Fri May  6 16:13:26 2016 +0200

mesa/formatquery: expand NUM_SAMPLE_COUNTS OpenGL ES comment

For ES 3.0 NUM_SAMPLE_COUNTS spec points that some formats will be
always zero. But on ES 3.1 can be different to zero.

The current code is correctly checking exactly against version 3.0,
but the comment only mentions 3.0 spec. It is clearer mentioning both.

v2: better wording on the comment (Ian Romanick)

Acked-by: Eduardo Lima 
Acked-by: Antia Puentes 

Reviewed-by: Ian Romanick 

---

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

diff --git a/src/mesa/main/formatquery.c b/src/mesa/main/formatquery.c
index 1f21d17..f524619 100644
--- a/src/mesa/main/formatquery.c
+++ b/src/mesa/main/formatquery.c
@@ -877,6 +877,9 @@ _mesa_GetInternalformativ(GLenum target, GLenum 
internalformat, GLenum pname,
* "Since multisampling is not supported for signed and unsigned
* integer internal formats, the value of NUM_SAMPLE_COUNTS will be
* zero for such formats.
+   *
+   * Since OpenGL ES 3.1 adds support for multisampled integer formats, we
+   * have to check the version for 30 exactly.
*/
   if (pname == GL_NUM_SAMPLE_COUNTS && ctx->API == API_OPENGLES2 &&
   ctx->Version == 30 && _mesa_is_enum_format_integer(internalformat)) {

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


Mesa (master): i965/formatquery: remove INTERNALFORMAT_PREFERRED implementation

2016-06-02 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: c1ceee6cc966e25fb1e68d267bafdeb4528bc980
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c1ceee6cc966e25fb1e68d267bafdeb4528bc980

Author: Alejandro Piñeiro 
Date:   Thu May  5 11:28:37 2016 +0200

i965/formatquery: remove INTERNALFORMAT_PREFERRED implementation

Right now the implementation only checks if the internalformat is
supported or not. But that implementation is wrong, returning
unsupported for some internalformats. Additionally, checking if
the internalformat is supported or not is already done at mesa/main
before calling the driver hook, so this new check is not needed.

Acked-by: Eduardo Lima 
Acked-by: Antia Puentes 

Reviewed-by: Ian Romanick 

---

 src/mesa/drivers/dri/i965/brw_formatquery.c | 71 -
 1 file changed, 71 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_formatquery.c 
b/src/mesa/drivers/dri/i965/brw_formatquery.c
index 210109b..8f7a910 100644
--- a/src/mesa/drivers/dri/i965/brw_formatquery.c
+++ b/src/mesa/drivers/dri/i965/brw_formatquery.c
@@ -65,46 +65,6 @@ brw_query_samples_for_format(struct gl_context *ctx, GLenum 
target,
}
 }
 
-/**
- * Returns a generic GL type from an internal format, so that it can be used
- * together with the base format to obtain a mesa_format by calling
- * mesa_format_from_format_and_type().
- */
-static GLenum
-get_generic_type_for_internal_format(GLenum internalFormat)
-{
-   if (_mesa_is_color_format(internalFormat)) {
-  if (_mesa_is_enum_format_unsigned_int(internalFormat))
- return GL_UNSIGNED_BYTE;
-  else if (_mesa_is_enum_format_signed_int(internalFormat))
- return GL_BYTE;
-   } else {
-  switch (internalFormat) {
-  case GL_STENCIL_INDEX:
-  case GL_STENCIL_INDEX8:
- return GL_UNSIGNED_BYTE;
-  case GL_DEPTH_COMPONENT:
-  case GL_DEPTH_COMPONENT16:
- return GL_UNSIGNED_SHORT;
-  case GL_DEPTH_COMPONENT24:
-  case GL_DEPTH_COMPONENT32:
- return GL_UNSIGNED_INT;
-  case GL_DEPTH_COMPONENT32F:
- return GL_FLOAT;
-  case GL_DEPTH_STENCIL:
-  case GL_DEPTH24_STENCIL8:
- return GL_UNSIGNED_INT_24_8;
-  case GL_DEPTH32F_STENCIL8:
- return GL_FLOAT_32_UNSIGNED_INT_24_8_REV;
-  default:
- /* fall-through */
- break;
-  }
-   }
-
-   return GL_FLOAT;
-}
-
 void
 brw_query_internal_format(struct gl_context *ctx, GLenum target,
   GLenum internalFormat, GLenum pname, GLint *params)
@@ -129,37 +89,6 @@ brw_query_internal_format(struct gl_context *ctx, GLenum 
target,
   break;
}
 
-   case GL_INTERNALFORMAT_PREFERRED: {
-  params[0] = GL_NONE;
-
-  /* We need to resolve an internal format that is compatible with
-   * the passed internal format, and optimal to the driver. By now,
-   * we just validate that the passed internal format is supported by
-   * the driver, and if so return the same internal format, otherwise
-   * return GL_NONE.
-   *
-   * For validating the internal format, we use the
-   * ctx->TextureFormatSupported map to check that a BRW surface format
-   * exists, that can be derived from the internal format. But this
-   * expects a mesa_format, not an internal format. So we need to "come up"
-   * with a type that is generic enough, to resolve the mesa_format first.
-   */
-  GLenum type = get_generic_type_for_internal_format(internalFormat);
-
-  /* Get a mesa_format from the internal format and type. */
-  GLint base_format = _mesa_base_tex_format(ctx, internalFormat);
-  if (base_format != -1) {
- mesa_format mesa_format =
-_mesa_format_from_format_and_type(base_format, type);
-
- if (mesa_format < MESA_FORMAT_COUNT &&
- ctx->TextureFormatSupported[mesa_format]) {
-params[0] = internalFormat;
- }
-  }
-  break;
-   }
-
default:
   /* By default, we call the driver hook's fallback function from the 
frontend,
* which has generic implementation for all pnames.

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


Mesa (master): mesa/formatquery: add a comment to clarify INTERNALFORMAT_PREFERRED

2016-06-02 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: b48c42cd1f81bf9a411d19aea2660d75622a1350
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b48c42cd1f81bf9a411d19aea2660d75622a1350

Author: Alejandro Piñeiro 
Date:   Thu May  5 11:27:05 2016 +0200

mesa/formatquery: add a comment to clarify INTERNALFORMAT_PREFERRED

The comment clarifies that the driver is called only to try to get
a preferred internalformat, and that it was already checked if the
format is supported or not.

Acked-by: Eduardo Lima 
Acked-by: Antia Puentes 

Reviewed-by: Ian Romanick 

---

 src/mesa/main/formatquery.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/formatquery.c b/src/mesa/main/formatquery.c
index 215c14f..1f21d17 100644
--- a/src/mesa/main/formatquery.c
+++ b/src/mesa/main/formatquery.c
@@ -902,7 +902,10 @@ _mesa_GetInternalformativ(GLenum target, GLenum 
internalformat, GLenum pname,
* format for representing resources of the specified 
 is
* returned in .
*
-   * Therefore, we let the driver answer.
+   * Therefore, we let the driver answer. Note that if we reach this
+   * point, it means that the internalformat is supported, so the driver
+   * is called just to try to get a preferred format. If not supported,
+   * GL_NONE was already returned and the driver is not called.
*/
   ctx->Driver.QueryInternalFormat(ctx, target, internalformat, pname,
   buffer);

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


Mesa (master): i965/eu: use simd8 when exec_size != EXECUTE_16

2016-06-02 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 58617bcebe1d0d5e8d360fec2c9dabf8771b0f7a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=58617bcebe1d0d5e8d360fec2c9dabf8771b0f7a

Author: Alejandro Piñeiro 
Date:   Wed Jun  1 18:49:29 2016 +0200

i965/eu: use simd8 when exec_size != EXECUTE_16

Among other thigs, fix a gpu hang when using INTEL_DEBUG=shader_time
for any shader.

Signed-off-by: Jason Ekstrand 
Signed-off-by: Alejandro Piñeiro 

Reviewed-by: Francisco Jerez 

---

 src/mesa/drivers/dri/i965/brw_eu_emit.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c 
b/src/mesa/drivers/dri/i965/brw_eu_emit.c
index 2538f0d..8218f9c 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c
@@ -2909,7 +2909,7 @@ brw_set_dp_untyped_atomic_message(struct brw_codegen *p,
 
if (devinfo->gen >= 8 || devinfo->is_haswell) {
   if (brw_inst_access_mode(devinfo, p->current) == BRW_ALIGN_1) {
- if (brw_inst_exec_size(devinfo, p->current) == BRW_EXECUTE_8)
+ if (brw_inst_exec_size(devinfo, p->current) != BRW_EXECUTE_16)
 msg_control |= 1 << 4; /* SIMD8 mode */
 
  brw_inst_set_dp_msg_type(devinfo, insn,
@@ -2922,7 +2922,7 @@ brw_set_dp_untyped_atomic_message(struct brw_codegen *p,
   brw_inst_set_dp_msg_type(devinfo, insn,
GEN7_DATAPORT_DC_UNTYPED_ATOMIC_OP);
 
-  if (brw_inst_exec_size(devinfo, p->current) == BRW_EXECUTE_8)
+  if (brw_inst_exec_size(devinfo, p->current) != BRW_EXECUTE_16)
  msg_control |= 1 << 4; /* SIMD8 mode */
}
 

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


Mesa (master): glsl: add unit tests data vertex/ expected outcome for uninitialized warning

2016-05-26 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 2ed9563e79670ba2430f0827050e9a851fc56e79
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2ed9563e79670ba2430f0827050e9a851fc56e79

Author: Alejandro Piñeiro 
Date:   Wed Apr 20 10:02:45 2016 +0200

glsl: add unit tests data vertex/expected outcome for uninitialized warning

v2: fix 025 test. Add three more tests (Ian Romanick)

Reviewed-by: Ian Romanick 

---

 .../glsl/tests/warnings/000-basic-test.vert| 10 
 .../tests/warnings/000-basic-test.vert.expected|  1 +
 .../warnings/001-use-undefined-then-define.vert| 12 ++
 .../001-use-undefined-then-define.vert.expected|  1 +
 src/compiler/glsl/tests/warnings/002-loop.vert | 23 ++
 .../glsl/tests/warnings/002-loop.vert.expected |  3 +++
 src/compiler/glsl/tests/warnings/003-less.vert | 17 +
 .../glsl/tests/warnings/003-less.vert.expected |  1 +
 src/compiler/glsl/tests/warnings/004-greater.vert  | 17 +
 .../glsl/tests/warnings/004-greater.vert.expected  |  1 +
 src/compiler/glsl/tests/warnings/005-lequal.vert   | 17 +
 .../glsl/tests/warnings/005-lequal.vert.expected   |  1 +
 src/compiler/glsl/tests/warnings/006-gequal.vert   | 17 +
 .../glsl/tests/warnings/006-gequal.vert.expected   |  1 +
 src/compiler/glsl/tests/warnings/007-test-mod.vert | 25 +++
 .../glsl/tests/warnings/007-test-mod.vert.expected |  3 +++
 .../glsl/tests/warnings/008-mulassign.vert | 12 ++
 .../tests/warnings/008-mulassign.vert.expected |  1 +
 .../glsl/tests/warnings/009-div-assign.vert| 12 ++
 .../tests/warnings/009-div-assign.vert.expected|  1 +
 .../glsl/tests/warnings/010-add-assign.vert| 12 ++
 .../tests/warnings/010-add-assign.vert.expected|  1 +
 .../glsl/tests/warnings/011-sub-assign.vert| 12 ++
 .../tests/warnings/011-sub-assign.vert.expected|  1 +
 .../glsl/tests/warnings/012-modassign.vert | 12 ++
 .../tests/warnings/012-modassign.vert.expected |  1 +
 src/compiler/glsl/tests/warnings/013-lsassign.vert | 12 ++
 .../glsl/tests/warnings/013-lsassign.vert.expected |  1 +
 src/compiler/glsl/tests/warnings/014-rsassign.vert | 12 ++
 .../glsl/tests/warnings/014-rsassign.vert.expected |  1 +
 .../glsl/tests/warnings/015-andassign.vert | 12 ++
 .../tests/warnings/015-andassign.vert.expected |  1 +
 src/compiler/glsl/tests/warnings/016-orassign.vert | 12 ++
 .../glsl/tests/warnings/016-orassign.vert.expected |  1 +
 .../glsl/tests/warnings/017-xorassign.vert | 12 ++
 .../tests/warnings/017-xorassign.vert.expected |  1 +
 src/compiler/glsl/tests/warnings/018-bitand.vert   | 24 +++
 .../glsl/tests/warnings/018-bitand.vert.expected   |  3 +++
 src/compiler/glsl/tests/warnings/019-array.vert| 23 ++
 .../glsl/tests/warnings/019-array.vert.expected|  5 
 .../glsl/tests/warnings/020-array-length.vert  | 12 ++
 .../tests/warnings/020-array-length.vert.expected  |  0
 src/compiler/glsl/tests/warnings/021-lshift.vert   | 25 +++
 .../glsl/tests/warnings/021-lshift.vert.expected   |  3 +++
 src/compiler/glsl/tests/warnings/022-rshift.vert   | 25 +++
 .../glsl/tests/warnings/022-rshift.vert.expected   |  3 +++
 src/compiler/glsl/tests/warnings/023-switch.vert   | 28 ++
 .../glsl/tests/warnings/023-switch.vert.expected   |  3 +++
 .../glsl/tests/warnings/024-shaderout.vert | 19 +++
 .../tests/warnings/024-shaderout.vert.expected |  2 ++
 .../tests/warnings/025-function-parameters.vert| 16 +
 .../warnings/025-function-parameters.vert.expected |  2 ++
 .../026-out-function-parameter-shaderout.vert  | 14 +++
 ...-out-function-parameter-shaderout.vert.expected |  0
 .../027-inout-function-parameter-shaderout.vert| 14 +++
 ...nout-function-parameter-shaderout.vert.expected |  1 +
 .../glsl/tests/warnings/028-conditional.vert   | 17 +
 .../tests/warnings/028-conditional.vert.expected   |  6 +
 .../glsl/tests/warnings/029-fieldselection.vert| 23 ++
 .../warnings/029-fieldselection.vert.expected  |  1 +
 .../warnings/030-array-as-function-parameter.vert  | 17 +
 .../030-array-as-function-parameter.vert.expected  |  7 ++
 62 files changed, 573 insertions(+)

diff --git a/src/compiler/glsl/tests/warnings/000-basic-test.vert 
b/src/compiler/glsl/tests/warnings/000-basic-test.vert
new file mode 100644
index 000..266eed6
--- /dev/null
+++ b/src/compiler/glsl/tests/warnings/000-basic-test.vert
@@ -0,0 +1,10 @@
+#version 130
+
+void main()
+{
+  float foo;
+  float undefined;
+
+  foo = undefined;
+}
+
diff --git a/src/compiler/glsl/tests/warnings/000-basic-test.vert.expected 

Mesa (master): glsl: add a empty set_is_lhs on ast_node

2016-05-26 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: b9f90ef652dae687a5aff97f9132b374320638a5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b9f90ef652dae687a5aff97f9132b374320638a5

Author: Alejandro Piñeiro 
Date:   Tue Apr 19 11:15:54 2016 +0200

glsl: add a empty set_is_lhs on ast_node

Just to allow to call set_is_lhs on any ast_node without a casting. Useful
when processing a ast_node list that we know it contain ast_expression.

v2: comment out new_value to avoid unused parameter warning (Ian Romanick)

Reviewed-by: Ian Romanick 

---

 src/compiler/glsl/ast.h  | 2 ++
 src/compiler/glsl/ast_to_hir.cpp | 5 +
 2 files changed, 7 insertions(+)

diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h
index fb25bb3..ca98ed2 100644
--- a/src/compiler/glsl/ast.h
+++ b/src/compiler/glsl/ast.h
@@ -126,6 +126,8 @@ public:
 
exec_node link;
 
+   virtual void set_is_lhs(bool);
+
 protected:
/**
 * The only constructor is protected so that only derived class objects can
diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index 22bc008..e1e26f8 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -1054,6 +1054,11 @@ ast_node::has_sequence_subexpression() const
 }
 
 void
+ast_node::set_is_lhs(bool /* new_value */)
+{
+}
+
+void
 ast_function_expression::hir_no_rvalue(exec_list *instructions,
struct _mesa_glsl_parse_state *state)
 {

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


Mesa (master): glsl: add just-log option for the standalone compiler.

2016-05-26 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 68c23d2d046b6419c7b3bd273278235095e29dae
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=68c23d2d046b6419c7b3bd273278235095e29dae

Author: Alejandro Piñeiro 
Date:   Tue Apr 19 20:26:32 2016 +0200

glsl: add just-log option for the standalone compiler.

Add an option in order to ask to just print the InfoLog, without any
header or separator. Useful if we want to use the standalone compiler
to track only the warning/error messages.

v2: all printfs goes on its own line (Ian Romanick)
v3: rebasing: move just_log to standalone.h/cpp

Reviewed-by: Ian Romanick 

---

 src/compiler/glsl/main.cpp   |  1 +
 src/compiler/glsl/standalone.cpp | 20 
 src/compiler/glsl/standalone.h   |  1 +
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/compiler/glsl/main.cpp b/src/compiler/glsl/main.cpp
index f65b185..1e5e0fe 100644
--- a/src/compiler/glsl/main.cpp
+++ b/src/compiler/glsl/main.cpp
@@ -43,6 +43,7 @@ const struct option compiler_opts[] = {
{ "dump-hir", no_argument, _hir, 1 },
{ "dump-lir", no_argument, _lir, 1 },
{ "link", no_argument, _link,  1 },
+   { "just-log", no_argument, _log, 1 },
{ "version",  required_argument, NULL, 'v' },
{ NULL, 0, NULL, 0 }
 };
diff --git a/src/compiler/glsl/standalone.cpp b/src/compiler/glsl/standalone.cpp
index e5b9057..c9f20e4 100644
--- a/src/compiler/glsl/standalone.cpp
+++ b/src/compiler/glsl/standalone.cpp
@@ -381,8 +381,14 @@ standalone_compile_shader(const struct standalone_options 
*_options,
 
   compile_shader(ctx, shader);
 
-  if (strlen(shader->InfoLog) > 0)
- printf("Info log for %s:\n%s\n", files[i], shader->InfoLog);
+  if (strlen(shader->InfoLog) > 0) {
+ if (!options->just_log)
+printf("Info log for %s:\n", files[i]);
+
+ printf("%s", shader->InfoLog);
+ if (!options->just_log)
+printf("\n");
+  }
 
   if (!shader->CompileStatus) {
  status = EXIT_FAILURE;
@@ -396,8 +402,14 @@ standalone_compile_shader(const struct standalone_options 
*_options,
   link_shaders(ctx, whole_program);
   status = (whole_program->LinkStatus) ? EXIT_SUCCESS : EXIT_FAILURE;
 
-  if (strlen(whole_program->InfoLog) > 0)
- printf("Info log for linking:\n%s\n", whole_program->InfoLog);
+  if (strlen(whole_program->InfoLog) > 0) {
+ printf("\n");
+ if (!options->just_log)
+printf("Info log for linking:\n");
+ printf("%s", whole_program->InfoLog);
+ if (!options->just_log)
+printf("\n");
+  }
 
   for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
  struct gl_shader *shader = whole_program->_LinkedShaders[i];
diff --git a/src/compiler/glsl/standalone.h b/src/compiler/glsl/standalone.h
index 5b387c5..648cedb 100644
--- a/src/compiler/glsl/standalone.h
+++ b/src/compiler/glsl/standalone.h
@@ -34,6 +34,7 @@ struct standalone_options {
int dump_hir;
int dump_lir;
int do_link;
+   int just_log;
 };
 
 struct gl_shader_program;

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


Mesa (master): glsl: add warning-test

2016-05-26 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: eee00274fa330edfa536da039ba9116bdceb9990
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=eee00274fa330edfa536da039ba9116bdceb9990

Author: Alejandro Piñeiro 
Date:   Tue Apr 19 21:03:07 2016 +0200

glsl: add warning-test

It executes compiler-glsl on all the available shaders, and it checks
that the outcome is the expected.

Bash code based on the already existing optimization-test

v2: rebasing: use --version option

Reviewed-by: Ian Romanick 

---

 src/compiler/Makefile.glsl.am |  3 ++-
 src/compiler/glsl/tests/warnings-test | 31 +++
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/src/compiler/Makefile.glsl.am b/src/compiler/Makefile.glsl.am
index 23c2a6b..4e90f16 100644
--- a/src/compiler/Makefile.glsl.am
+++ b/src/compiler/Makefile.glsl.am
@@ -35,7 +35,8 @@ TESTS += glsl/glcpp/tests/glcpp-test  \
glsl/tests/general-ir-test  \
glsl/tests/optimization-test\
glsl/tests/sampler-types-test   \
-   glsl/tests/uniform-initializer-test
+   glsl/tests/uniform-initializer-test \
+   glsl/tests/warnings-test
 
 TESTS_ENVIRONMENT= \
export PYTHON2=$(PYTHON2); \
diff --git a/src/compiler/glsl/tests/warnings-test 
b/src/compiler/glsl/tests/warnings-test
new file mode 100755
index 000..1bea466
--- /dev/null
+++ b/src/compiler/glsl/tests/warnings-test
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+
+# Execute several shaders, and check that the InfoLog outcome is the expected.
+
+compiler=./glsl_compiler
+total=0
+pass=0
+
+echo "== Testing compilation output =="
+for test in `find . -iname '*.vert'`; do
+echo -n "Testing $test..."
+$compiler --just-log --version 150 "$test" > "$test.out" 2>&1
+total=$((total+1))
+if diff "$test.expected" "$test.out" >/dev/null 2>&1; then
+echo "PASS"
+pass=$((pass+1))
+else
+echo "FAIL"
+diff "$test.expected" "$test.out"
+fi
+done
+
+echo ""
+echo "$pass/$total tests returned correct results"
+echo ""
+
+if [[ $pass == $total ]]; then
+exit 0
+else
+exit 1
+fi

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


Mesa (master): glsl: do not raise uninitialized warning with out function parameters

2016-05-26 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 66ff04322e80d14d9b1c8a4d1ef8cf63440242af
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=66ff04322e80d14d9b1c8a4d1ef8cf63440242af

Author: Alejandro Piñeiro 
Date:   Tue Apr 19 11:17:27 2016 +0200

glsl: do not raise uninitialized warning with out function parameters

It silence by default warnings with function parameters, as the
parameters need to be processed in order to have the actual and the
formal parameter, and the function signature. Then it raises the
warning if needed at verify_parameter_modes where other in/out/inout modes
checks are done.

v2: fix comment style, multi-line condition style, simplify check,
remove extra blank (Ian Romanick)
v3: inout function parameters can raise the warning too (Ian
Romanick)

Reviewed-by: Ian Romanick 

---

 src/compiler/glsl/ast_function.cpp | 28 
 1 file changed, 28 insertions(+)

diff --git a/src/compiler/glsl/ast_function.cpp 
b/src/compiler/glsl/ast_function.cpp
index 4433fdd..a97e6c9 100644
--- a/src/compiler/glsl/ast_function.cpp
+++ b/src/compiler/glsl/ast_function.cpp
@@ -43,6 +43,12 @@ process_parameters(exec_list *instructions, exec_list 
*actual_parameters,
unsigned count = 0;
 
foreach_list_typed(ast_node, ast, link, parameters) {
+  /* We need to process the parameters first in order to know if we can
+   * raise or not a unitialized warning. Calling set_is_lhs silence the
+   * warning for now. Raising the warning or not will be checked at
+   * verify_parameter_modes.
+   */
+  ast->set_is_lhs(true);
   ir_rvalue *result = ast->hir(instructions, state);
 
   ir_constant *const constant = result->constant_expression_value();
@@ -257,6 +263,16 @@ verify_parameter_modes(_mesa_glsl_parse_state *state,
 }
 
 ir_variable *var = actual->variable_referenced();
+
+ if (var && formal->data.mode == ir_var_function_inout) {
+if ((var->data.mode == ir_var_auto || var->data.mode == 
ir_var_shader_out) &&
+!var->data.assigned &&
+!is_gl_identifier(var->name)) {
+   _mesa_glsl_warning(, state, "`%s' used uninitialized",
+  var->name);
+}
+ }
+
 if (var)
var->data.assigned = true;
 
@@ -273,6 +289,18 @@ verify_parameter_modes(_mesa_glsl_parse_state *state,
  mode, formal->name);
 return false;
 }
+  } else {
+ assert(formal->data.mode == ir_var_function_in ||
+formal->data.mode == ir_var_const_in);
+ ir_variable *var = actual->variable_referenced();
+ if (var) {
+if ((var->data.mode == ir_var_auto || var->data.mode == 
ir_var_shader_out) &&
+!var->data.assigned &&
+!is_gl_identifier(var->name)) {
+   _mesa_glsl_warning(, state, "`%s' used uninitialized",
+  var->name);
+}
+ }
   }
 
   if (formal->type->is_image() &&

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


Mesa (master): i965/fs: take into account doubles when emitting system values

2016-05-25 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 8c29bba242062a01e73743ca5086604a57c0efc5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8c29bba242062a01e73743ca5086604a57c0efc5

Author: Alejandro Piñeiro 
Date:   Tue May 24 15:00:30 2016 +0200

i965/fs: take into account doubles when emitting system values

Fixes the following cts test:
GL42-CTS.vertex_attrib_64bit.limits_test

Reviewed-by: Kenneth Graunke 

---

 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 012492c..c220f1c 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -36,7 +36,8 @@ fs_reg *
 fs_visitor::emit_vs_system_value(int location)
 {
fs_reg *reg = new(this->mem_ctx)
-  fs_reg(ATTR, 4 * _mesa_bitcount_64(nir->info.inputs_read),
+  fs_reg(ATTR, 4 * (_mesa_bitcount_64(nir->info.inputs_read) +
+_mesa_bitcount_64(nir->info.double_inputs_read)),
  BRW_REGISTER_TYPE_D);
brw_vs_prog_data *vs_prog_data = (brw_vs_prog_data *) prog_data;
 

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


Mesa (master): configure: added xcb to dri3 modules to pkg-conf

2016-05-23 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 4424bf5da4f9cd18bb30fc14d1d8403e4ec6caff
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4424bf5da4f9cd18bb30fc14d1d8403e4ec6caff

Author: Andres Gomez 
Date:   Fri May 20 16:54:35 2016 +0300

configure: added xcb to dri3 modules to pkg-conf

This fixes a recent linking error in libvulkan_common

Reviewed-by: Emil Velikov 
Signed-off-by: Andres Gomez 

---

 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 6eee2bc..de62e8b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1319,7 +1319,7 @@ xdri)
 
 if test x"$enable_dri3" = xyes; then
PKG_CHECK_EXISTS([xcb >= $XCB_REQUIRED], [], AC_MSG_ERROR([DRI3 
requires xcb >= $XCB_REQUIRED]))
-   dri3_modules="xcb-dri3 xcb-present xcb-sync xshmfence >= 
$XSHMFENCE_REQUIRED"
+   dri3_modules="xcb xcb-dri3 xcb-present xcb-sync xshmfence >= 
$XSHMFENCE_REQUIRED"
PKG_CHECK_MODULES([XCB_DRI3], [$dri3_modules])
 fi
 fi

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


Mesa (master): glsl/linker: dvec3/ dvec4 consume twice input vertex attributes

2016-05-23 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 3c9096eea46fc79e5d734ea0629673d1889966d7
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3c9096eea46fc79e5d734ea0629673d1889966d7

Author: Juan A. Suarez Romero 
Date:   Mon May 23 10:46:42 2016 +0200

glsl/linker: dvec3/dvec4 consume twice input vertex attributes

From the GL 4.5 core spec, section 11.1.1 (Vertex Attributes):

"A program with more than the value of MAX_VERTEX_ATTRIBS
active attribute variables may fail to link, unless
device-dependent optimizations are able to make the program
fit within available hardware resources. For the purposes
of this test, attribute variables of the type dvec3, dvec4,
dmat2x3, dmat2x4, dmat3, dmat3x4, dmat4x3, and dmat4 may
count as consuming twice as many attributes as equivalent
single-precision types. While these types use the same number
of generic attributes as their single-precision equivalents,
implementations are permitted to consume two single-precision
vectors of internal storage for each three- or four-component
double-precision vector."

This commits makes dvec3, dvec4, dmat2x3, dmat2x4, dmat3, dmat3x4,
dmat4x3 and dmat4 consume twice as many attributes as equivalent
single-precision types.

v3: count doubles as consuming two attributes (Dave Airlie)
v4: make reference to spec (Michael Schellenberger Costa)

Reviewed-by: Kenneth Graunke 
Reviewed-by: Dave Airlie 

Signed-off-by: Antia Puentes 
Signed-off-by: Juan A. Suarez Romero 

---

 src/compiler/glsl/linker.cpp | 20 
 1 file changed, 20 insertions(+)

diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index 0b8c494..5e59ae3 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -2873,6 +2873,26 @@ assign_attribute_or_color_locations(gl_shader_program 
*prog,
   to_assign[i].var->data.location = generic_base + location;
   to_assign[i].var->data.is_unmatched_generic_inout = 0;
   used_locations |= (use_mask << location);
+
+  if (to_assign[i].var->type->without_array()->is_dual_slot_double())
+ double_storage_locations |= (use_mask << location);
+   }
+
+   /* Now that we have all the locations, from the GL 4.5 core spec, section
+* 11.1.1 (Vertex Attributes), dvec3, dvec4, dmat2x3, dmat2x4, dmat3,
+* dmat3x4, dmat4x3, and dmat4 count as consuming twice as many attributes
+* as equivalent single-precision types.
+*/
+   if (target_index == MESA_SHADER_VERTEX) {
+  unsigned total_attribs_size =
+ _mesa_bitcount(used_locations & ((1 << max_index) - 1)) +
+ _mesa_bitcount(double_storage_locations);
+  if (total_attribs_size > max_index) {
+linker_error(prog,
+ "attempt to use %d vertex attribute slots only %d 
available ",
+ total_attribs_size, max_index);
+return false;
+  }
}
 
return true;

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


Mesa (master): i965: get the proper vertex surface type for doubles on gen8+

2016-05-17 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 71150b73c81a58dc06057ced561d10332aecc803
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=71150b73c81a58dc06057ced561d10332aecc803

Author: Alejandro Piñeiro 
Date:   Tue Mar 15 12:53:07 2016 +0100

i965: get the proper vertex surface type for doubles on gen8+

This commit adds support for PASSTHRU format when pushing
double-precision attributes.

Check glarray->Doubles in order to know if we should choose a format
that does a conversion to float, or just passthru the 64-bit double.

Reviewed-by: Kenneth Graunke 

---

 src/mesa/drivers/dri/i965/brw_draw_upload.c | 30 ++---
 1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c 
b/src/mesa/drivers/dri/i965/brw_draw_upload.c
index 58e0516..5af4583 100644
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
@@ -37,7 +37,7 @@
 #include "intel_batchbuffer.h"
 #include "intel_buffer_objects.h"
 
-static const GLuint double_types[5] = {
+static const GLuint double_types_float[5] = {
0,
BRW_SURFACEFORMAT_R64_FLOAT,
BRW_SURFACEFORMAT_R64G64_FLOAT,
@@ -45,6 +45,14 @@ static const GLuint double_types[5] = {
BRW_SURFACEFORMAT_R64G64B64A64_FLOAT
 };
 
+static const GLuint double_types_passthru[5] = {
+   0,
+   BRW_SURFACEFORMAT_R64_PASSTHRU,
+   BRW_SURFACEFORMAT_R64G64_PASSTHRU,
+   BRW_SURFACEFORMAT_R64G64B64_PASSTHRU,
+   BRW_SURFACEFORMAT_R64G64B64A64_PASSTHRU
+};
+
 static const GLuint float_types[5] = {
0,
BRW_SURFACEFORMAT_R32_FLOAT,
@@ -213,6 +221,22 @@ static const GLuint byte_types_scale[5] = {
BRW_SURFACEFORMAT_R8G8B8A8_SSCALED
 };
 
+static GLuint
+double_types(struct brw_context *brw,
+ int size,
+ GLboolean doubles)
+{
+   /* From the BDW PRM, Volume 2d, page 588 (VERTEX_ELEMENT_STATE):
+* "When SourceElementFormat is set to one of the *64*_PASSTHRU formats,
+* 64-bit components are stored in the URB without any conversion."
+* Also included on BDW PRM, Volume 7, page 470, table "Source Element
+* Formats Supported in VF Unit"
+* Previous PRMs don't include those references.
+*/
+   return (brw->gen >= 8 && doubles
+   ? double_types_passthru[size]
+   : double_types_float[size]);
+}
 
 /**
  * Given vertex array type/size/format/normalized info, return
@@ -245,7 +269,7 @@ brw_get_vertex_surface_type(struct brw_context *brw,
   return BRW_SURFACEFORMAT_R11G11B10_FLOAT;
} else if (glarray->Normalized) {
   switch (glarray->Type) {
-  case GL_DOUBLE: return double_types[size];
+  case GL_DOUBLE: return double_types(brw, size, glarray->Doubles);
   case GL_FLOAT: return float_types[size];
   case GL_HALF_FLOAT: return half_float_types[size];
   case GL_INT: return int_types_norm[size];
@@ -319,7 +343,7 @@ brw_get_vertex_surface_type(struct brw_context *brw,
   }
   assert(glarray->Format == GL_RGBA); /* sanity check */
   switch (glarray->Type) {
-  case GL_DOUBLE: return double_types[size];
+  case GL_DOUBLE: return double_types(brw, size, glarray->Doubles);
   case GL_FLOAT: return float_types[size];
   case GL_HALF_FLOAT: return half_float_types[size];
   case GL_INT: return int_types_scale[size];

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


Mesa (master): i965/vec4: use attribute slots to calculate URB read length

2016-05-17 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: b7423b485e11b768f68e8d5865fbc74b07ee6d48
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b7423b485e11b768f68e8d5865fbc74b07ee6d48

Author: Juan A. Suarez Romero 
Date:   Mon Apr  4 12:47:57 2016 +0200

i965/vec4: use attribute slots to calculate URB read length

Do not use total attributes because a dvec3/dvec4 attribute requires two
slots. So rather use total attribute slots.

v2: do not use loop to calculate required attribute slots (Kenneth
Graunke)

Reviewed-by: Kenneth Graunke 

---

 src/mesa/drivers/dri/i965/brw_vec4.cpp | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index 385afc1..ac8dd6f 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -2104,14 +2104,20 @@ brw_compile_vs(const struct brw_compiler *compiler, 
void *log_data,
   nr_attributes++;
}
 
+   unsigned nr_attribute_slots =
+  nr_attributes +
+  _mesa_bitcount_64(shader->info.double_inputs_read);
+
/* The 3DSTATE_VS documentation lists the lower bound on "Vertex URB Entry
 * Read Length" as 1 in vec4 mode, and 0 in SIMD8 mode.  Empirically, in
 * vec4 mode, the hardware appears to wedge unless we read something.
 */
if (is_scalar)
-  prog_data->base.urb_read_length = DIV_ROUND_UP(nr_attributes, 2);
+  prog_data->base.urb_read_length =
+ DIV_ROUND_UP(nr_attribute_slots, 2);
else
-  prog_data->base.urb_read_length = DIV_ROUND_UP(MAX2(nr_attributes, 1), 
2);
+  prog_data->base.urb_read_length =
+ DIV_ROUND_UP(MAX2(nr_attribute_slots, 1), 2);
 
prog_data->nr_attributes = nr_attributes;
 
@@ -2120,7 +2126,7 @@ brw_compile_vs(const struct brw_compiler *compiler, void 
*log_data,
 * the larger of the two.
 */
const unsigned vue_entries =
-  MAX2(nr_attributes, (unsigned)prog_data->base.vue_map.num_slots);
+  MAX2(nr_attribute_slots, (unsigned)prog_data->base.vue_map.num_slots);
 
if (compiler->devinfo->gen == 6)
   prog_data->base.urb_entry_size = DIV_ROUND_UP(vue_entries, 8);

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


Mesa (master): docs: Mark ARB_vertex_attrib_64bit as done for i965/gen8+

2016-05-17 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: f051eae25a820638b6e9712a6e8936b4eb04bc5b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f051eae25a820638b6e9712a6e8936b4eb04bc5b

Author: Alejandro Piñeiro 
Date:   Tue Apr 26 14:37:38 2016 +0200

docs: Mark ARB_vertex_attrib_64bit as done for i965/gen8+

v2: label as done for i965/gen8+ instead of i965 (Kenneth Graunke)

Reviewed-by: Kenneth Graunke 

---

 docs/GL3.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/GL3.txt b/docs/GL3.txt
index 1ac6235..78e4c4e 100644
--- a/docs/GL3.txt
+++ b/docs/GL3.txt
@@ -142,7 +142,7 @@ GL 4.1, GLSL 4.10 --- all DONE: nvc0, r600, radeonsi
   GL_ARB_get_program_binary DONE (0 binary formats)
   GL_ARB_separate_shader_objectsDONE (all drivers)
   GL_ARB_shader_precision   DONE (all drivers that 
support GLSL 4.10)
-  GL_ARB_vertex_attrib_64bitDONE (llvmpipe, 
softpipe)
+  GL_ARB_vertex_attrib_64bitDONE (i965/gen8+, 
llvmpipe, softpipe)
   GL_ARB_viewport_array DONE (i965, nv50, 
llvmpipe, softpipe)
 
 

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


Mesa (master): i965: passthru formats cannot be used width edge flag enabled

2016-05-17 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 1ff32ae8b2367950c543770ee5e6e459312cebce
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1ff32ae8b2367950c543770ee5e6e459312cebce

Author: Alejandro Piñeiro 
Date:   Thu Mar 24 11:49:53 2016 +0100

i965: passthru formats cannot be used width edge flag enabled

Add an assertion to detect this case.

Reviewed-by: Kenneth Graunke 

---

 src/mesa/drivers/dri/i965/gen8_draw_upload.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/gen8_draw_upload.c 
b/src/mesa/drivers/dri/i965/gen8_draw_upload.c
index c862f05..dce11dd 100644
--- a/src/mesa/drivers/dri/i965/gen8_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/gen8_draw_upload.c
@@ -34,6 +34,20 @@
 #include "intel_batchbuffer.h"
 #include "intel_buffer_objects.h"
 
+static bool
+is_passthru_format(uint32_t format)
+{
+   switch (format) {
+   case BRW_SURFACEFORMAT_R64_PASSTHRU:
+   case BRW_SURFACEFORMAT_R64G64_PASSTHRU:
+   case BRW_SURFACEFORMAT_R64G64B64_PASSTHRU:
+   case BRW_SURFACEFORMAT_R64G64B64A64_PASSTHRU:
+  return true;
+   default:
+  return false;
+   }
+}
+
 static void
 gen8_emit_vertices(struct brw_context *brw)
 {
@@ -193,6 +207,12 @@ gen8_emit_vertices(struct brw_context *brw)
   uint32_t comp2 = BRW_VE1_COMPONENT_STORE_SRC;
   uint32_t comp3 = BRW_VE1_COMPONENT_STORE_SRC;
 
+  /* From the BDW PRM, Volume 2d, page 588 (VERTEX_ELEMENT_STATE):
+   * "Any SourceElementFormat of *64*_PASSTHRU cannot be used with an
+   * element which has edge flag enabled."
+   */
+  assert(!(is_passthru_format(format) && uses_edge_flag));
+
   /* The gen4 driver expects edgeflag to come in as a float, and passes
* that float on to the tests in the clipper.  Mesa's current vertex
* attribute value for EdgeFlag is stored as a float, which works out.

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


Mesa (master): i965: take care of doubles when remapping VS attributes

2016-05-17 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: b0fb08e179d784ca319c3c547a874fd24ce93c3f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b0fb08e179d784ca319c3c547a874fd24ce93c3f

Author: Juan A. Suarez Romero 
Date:   Fri Apr  1 17:25:03 2016 +0200

i965: take care of doubles when remapping VS attributes

Double-precision types require 1 slot in VUE for double and dvec2, and 2 slots 
for
anything else.

Reviewed-by: Kenneth Graunke 

---

 src/mesa/drivers/dri/i965/brw_nir.c | 26 +++---
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_nir.c 
b/src/mesa/drivers/dri/i965/brw_nir.c
index c501bc1..f37bf3a 100644
--- a/src/mesa/drivers/dri/i965/brw_nir.c
+++ b/src/mesa/drivers/dri/i965/brw_nir.c
@@ -96,7 +96,7 @@ add_const_offset_to_base(nir_shader *nir, nir_variable_mode 
mode)
 }
 
 static bool
-remap_vs_attrs(nir_block *block, GLbitfield64 inputs_read)
+remap_vs_attrs(nir_block *block, struct nir_shader_info *nir_info)
 {
nir_foreach_instr(instr, block) {
   if (instr->type != nir_instr_type_intrinsic)
@@ -111,9 +111,11 @@ remap_vs_attrs(nir_block *block, GLbitfield64 inputs_read)
   * before it and counting the bits.
   */
  int attr = intrin->const_index[0];
- int slot = _mesa_bitcount_64(inputs_read & BITFIELD64_MASK(attr));
-
- intrin->const_index[0] = 4 * slot;
+ int slot = _mesa_bitcount_64(nir_info->inputs_read &
+  BITFIELD64_MASK(attr));
+ int dslot = _mesa_bitcount_64(nir_info->double_inputs_read &
+   BITFIELD64_MASK(attr));
+ intrin->const_index[0] = 4 * (slot + dslot);
   }
}
return true;
@@ -199,9 +201,9 @@ brw_nir_lower_vs_inputs(nir_shader *nir,
   var->data.driver_location = var->data.location;
}
 
-   /* Now use nir_lower_io to walk dereference chains.  Attribute arrays
-* are loaded as one vec4 per element (or matrix column), so we use
-* type_size_vec4 here.
+   /* Now use nir_lower_io to walk dereference chains.  Attribute arrays are
+* loaded as one vec4 or dvec4 per element (or matrix column), depending on
+* whether it is a double-precision type or not.
 */
nir_lower_io(nir, nir_var_shader_in, type_size_vec4);
 
@@ -214,18 +216,12 @@ brw_nir_lower_vs_inputs(nir_shader *nir,
vs_attrib_wa_flags);
 
if (is_scalar) {
-  /* Finally, translate VERT_ATTRIB_* values into the actual registers.
-   *
-   * Note that we can use nir->info.inputs_read instead of
-   * key->inputs_read since the two are identical aside from Gen4-5
-   * edge flag differences.
-   */
-  GLbitfield64 inputs_read = nir->info.inputs_read;
+  /* Finally, translate VERT_ATTRIB_* values into the actual registers. */
 
   nir_foreach_function(function, nir) {
  if (function->impl) {
 nir_foreach_block(block, function->impl) {
-   remap_vs_attrs(block, inputs_read);
+   remap_vs_attrs(block, >info);
 }
  }
   }

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


Mesa (master): i965: Enable ARB_vertex_attrib_64bit for gen8+

2016-05-17 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 59b5441fd9dc9b99341381153cd1cc8510fa8e8a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=59b5441fd9dc9b99341381153cd1cc8510fa8e8a

Author: Alejandro Piñeiro 
Date:   Sat Mar 12 12:34:06 2016 +0100

i965: Enable ARB_vertex_attrib_64bit for gen8+

Reviewed-by: Kenneth Graunke 

---

 src/mesa/drivers/dri/i965/intel_extensions.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c 
b/src/mesa/drivers/dri/i965/intel_extensions.c
index cae53f2..957e363 100644
--- a/src/mesa/drivers/dri/i965/intel_extensions.c
+++ b/src/mesa/drivers/dri/i965/intel_extensions.c
@@ -378,6 +378,7 @@ intelInitExtensions(struct gl_context *ctx)
   ctx->Extensions.ARB_stencil_texturing = true;
   ctx->Extensions.ARB_texture_stencil8 = true;
   ctx->Extensions.ARB_gpu_shader_fp64 = true;
+  ctx->Extensions.ARB_vertex_attrib_64bit = true;
}
 
if (brw->gen >= 9) {

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


Mesa (master): i965/fs: half exec_size when dealing with 64 bits attributes

2016-05-17 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 96c276dda909ddf12714b9e64b7207156e8fd4bb
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=96c276dda909ddf12714b9e64b7207156e8fd4bb

Author: Alejandro Piñeiro 
Date:   Wed Mar 23 12:20:05 2016 +0100

i965/fs: half exec_size when dealing with 64 bits attributes

The HW has a restriction that only vertical stride may cross register
boundaries. Until now this was only handled on VGRFs at
rw_reg_from_fs_reg, but it is also needed for attributes.

v2:
 * Remove reference to commit id on commit message (Juan Suarez)
 * Simplify code that compute final exec_size (Ian Romanick)
 * Use REG_SIZE on that same code (Kenneth Graunke)

Reviewed-by: Kenneth Graunke 

---

 src/mesa/drivers/dri/i965/brw_fs.cpp | 21 +++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 06a5de1..e8baf6c 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -1729,11 +1729,28 @@ fs_visitor::convert_attr_sources_to_hw_regs(fs_inst 
*inst)
inst->src[i].nr +
inst->src[i].reg_offset;
 
- unsigned width = inst->src[i].stride == 0 ? 1 : inst->exec_size;
+ /* As explained at brw_reg_from_fs_reg, From the Haswell PRM:
+  *
+  * VertStride must be used to cross GRF register boundaries. This
+  * rule implies that elements within a 'Width' cannot cross GRF
+  * boundaries.
+  *
+  * So, for registers that are large enough, we have to split the exec
+  * size in two and trust the compression state to sort it out.
+  */
+ unsigned total_size = inst->exec_size *
+   inst->src[i].stride *
+   type_sz(inst->src[i].type);
+
+ assert(total_size <= 2 * REG_SIZE);
+ const unsigned exec_size =
+(total_size <= REG_SIZE) ? inst->exec_size : inst->exec_size / 2;
+
+ unsigned width = inst->src[i].stride == 0 ? 1 : exec_size;
  struct brw_reg reg =
 stride(byte_offset(retype(brw_vec8_grf(grf, 0), inst->src[i].type),
inst->src[i].subreg_offset),
-   inst->exec_size * inst->src[i].stride,
+   exec_size * inst->src[i].stride,
width, inst->src[i].stride);
  reg.abs = inst->src[i].abs;
  reg.negate = inst->src[i].negate;

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


Mesa (master): i965: Configure how to store *64*PASSTHRU vertex components

2016-05-17 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 8b0a334b5ef0fb324c61f5757989d715f4b531f6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8b0a334b5ef0fb324c61f5757989d715f4b531f6

Author: Antia Puentes 
Date:   Fri Apr 15 11:32:46 2016 +0200

i965: Configure how to store *64*PASSTHRU vertex components

From the Broadwell specification, structure VERTEX_ELEMENT_STATE
description:

   "When SourceElementFormat is set to one of the *64*_PASSTHRU
formats,  64-bit components are stored in the URB without any
conversion. In this case, vertex elements must be written as 128
or 256 bits, with VFCOMP_STORE_0 being used to pad the output
as required. E.g., if R64_PASSTHRU is used to copy a 64-bit Red component 
into
the URB, Component 1 must be specified as VFCOMP_STORE_0 (with
Components 2,3 set to VFCOMP_NOSTORE) in order to output a 128-bit
vertex element, or Components 1-3 must be specified as VFCOMP_STORE_0
in order to output a 256-bit vertex element. Likewise, use of
R64G64B64_PASSTHRU requires Component 3 to be specified as VFCOMP_STORE_0
in order to output a 256-bit vertex element."

Uses 128-bits to write double and dvec2 vertex elements, and 256-bits for
dvec3 and dvec4 vertex elements.

Signed-off-by: Juan A. Suarez Romero 
Signed-off-by: Antia Puentes 

Reviewed-by: Kenneth Graunke 

---

 src/mesa/drivers/dri/i965/gen8_draw_upload.c | 35 
 1 file changed, 35 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/gen8_draw_upload.c 
b/src/mesa/drivers/dri/i965/gen8_draw_upload.c
index fe5ed35..c862f05 100644
--- a/src/mesa/drivers/dri/i965/gen8_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/gen8_draw_upload.c
@@ -217,6 +217,41 @@ gen8_emit_vertices(struct brw_context *brw)
  break;
   }
 
+  /* From the BDW PRM, Volume 2d, page 586 (VERTEX_ELEMENT_STATE):
+   *
+   * "When SourceElementFormat is set to one of the *64*_PASSTHRU
+   * formats, 64-bit components are stored in the URB without any
+   * conversion. In this case, vertex elements must be written as 128
+   * or 256 bits, with VFCOMP_STORE_0 being used to pad the output
+   * as required. E.g., if R64_PASSTHRU is used to copy a 64-bit Red
+   * component into the URB, Component 1 must be specified as
+   * VFCOMP_STORE_0 (with Components 2,3 set to VFCOMP_NOSTORE)
+   * in order to output a 128-bit vertex element, or Components 1-3 
must
+   * be specified as VFCOMP_STORE_0 in order to output a 256-bit vertex
+   * element. Likewise, use of R64G64B64_PASSTHRU requires Component 3
+   * to be specified as VFCOMP_STORE_0 in order to output a 256-bit 
vertex
+   * element."
+   */
+  if (input->glarray->Doubles) {
+ switch (input->glarray->Size) {
+ case 0:
+ case 1:
+ case 2:
+/*  Use 128-bits instead of 256-bits to write double and dvec2
+ *  vertex elements.
+ */
+comp2 = BRW_VE1_COMPONENT_NOSTORE;
+comp3 = BRW_VE1_COMPONENT_NOSTORE;
+break;
+ case 3:
+/* Pad the output using VFCOMP_STORE_0 as suggested
+ * by the BDW PRM.
+ */
+comp3 = BRW_VE1_COMPONENT_STORE_0;
+break;
+ }
+  }
+
   OUT_BATCH((input->buffer << GEN6_VE0_INDEX_SHIFT) |
 GEN6_VE0_VALID |
 (format << BRW_VE0_FORMAT_SHIFT) |

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


Mesa (master): i965: take care of doubles when lowering VS inputs

2016-05-17 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: d6281a9d955ad97f993927bc214e4b641cfbe359
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d6281a9d955ad97f993927bc214e4b641cfbe359

Author: Juan A. Suarez Romero 
Date:   Fri Apr 15 12:51:05 2016 +0200

i965: take care of doubles when lowering VS inputs

Input attributes can require 2 vec4 or 1 vec4 depending on whether they
are double-precision or not.

Reviewed-by: Kenneth Graunke 

---

 src/mesa/drivers/dri/i965/brw_fs.cpp   | 13 +
 src/mesa/drivers/dri/i965/brw_nir.c|  3 ++-
 src/mesa/drivers/dri/i965/brw_shader.h |  1 +
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
b/src/mesa/drivers/dri/i965/brw_fs.cpp
index bf3a467..e62f2fe 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -545,6 +545,19 @@ type_size_vec4_times_4(const struct glsl_type *type)
return 4 * type_size_vec4(type);
 }
 
+/* Attribute arrays are loaded as one vec4 per element (or matrix column),
+ * except for double-precision types, which are loaded as one dvec4.
+ */
+extern "C" int
+type_size_vs_input(const struct glsl_type *type)
+{
+   if (type->is_double()) {
+  return type_size_vec4(type) / 2;
+   } else {
+  return type_size_vec4(type);
+   }
+}
+
 /**
  * Create a MOV to read the timestamp register.
  *
diff --git a/src/mesa/drivers/dri/i965/brw_nir.c 
b/src/mesa/drivers/dri/i965/brw_nir.c
index f37bf3a..9afd036 100644
--- a/src/mesa/drivers/dri/i965/brw_nir.c
+++ b/src/mesa/drivers/dri/i965/brw_nir.c
@@ -23,6 +23,7 @@
 
 #include "brw_nir.h"
 #include "brw_shader.h"
+#include "compiler/glsl_types.h"
 #include "compiler/nir/glsl_to_nir.h"
 #include "compiler/nir/nir_builder.h"
 #include "program/prog_to_nir.h"
@@ -205,7 +206,7 @@ brw_nir_lower_vs_inputs(nir_shader *nir,
 * loaded as one vec4 or dvec4 per element (or matrix column), depending on
 * whether it is a double-precision type or not.
 */
-   nir_lower_io(nir, nir_var_shader_in, type_size_vec4);
+   nir_lower_io(nir, nir_var_shader_in, type_size_vs_input);
 
/* This pass needs actual constants */
nir_opt_constant_folding(nir);
diff --git a/src/mesa/drivers/dri/i965/brw_shader.h 
b/src/mesa/drivers/dri/i965/brw_shader.h
index 35e7d7a..60f3b5f 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.h
+++ b/src/mesa/drivers/dri/i965/brw_shader.h
@@ -294,6 +294,7 @@ struct gl_shader *brw_new_shader(struct gl_context *ctx, 
GLuint name, GLuint typ
 int type_size_scalar(const struct glsl_type *type);
 int type_size_vec4(const struct glsl_type *type);
 int type_size_vec4_times_4(const struct glsl_type *type);
+int type_size_vs_input(const struct glsl_type *type);
 
 unsigned tesslevel_outer_components(GLenum tes_primitive_mode);
 unsigned tesslevel_inner_components(GLenum tes_primitive_mode);

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


Mesa (master): i965: Expose OpenGL 4.2 for gen8+

2016-05-17 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: e5e412cd272989fa801a027ab5dce7de48eb79c6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e5e412cd272989fa801a027ab5dce7de48eb79c6

Author: Alejandro Piñeiro 
Date:   Tue Apr 26 14:35:24 2016 +0200

i965: Expose OpenGL 4.2 for gen8+

ARB_vertex_attrib_64bit was the only feature missing.

v2: we can expose 4.2 instead of 4.1 (Ian Romanick)

Reviewed-by: Kenneth Graunke 

---

 src/mesa/drivers/dri/i965/intel_extensions.c | 2 +-
 src/mesa/drivers/dri/i965/intel_screen.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c 
b/src/mesa/drivers/dri/i965/intel_extensions.c
index 957e363..8b4f685 100644
--- a/src/mesa/drivers/dri/i965/intel_extensions.c
+++ b/src/mesa/drivers/dri/i965/intel_extensions.c
@@ -268,7 +268,7 @@ intelInitExtensions(struct gl_context *ctx)
ctx->Extensions.OES_texture_half_float_linear = true;
 
if (brw->gen >= 8)
-  ctx->Const.GLSLVersion = 400;
+  ctx->Const.GLSLVersion = 420;
else if (brw->gen >= 6)
   ctx->Const.GLSLVersion = 330;
else
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c 
b/src/mesa/drivers/dri/i965/intel_screen.c
index c2efc6e..1a0541a 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -1376,7 +1376,7 @@ set_max_gl_versions(struct intel_screen *screen)
switch (screen->devinfo->gen) {
case 9:
case 8:
-  psp->max_gl_core_version = 40;
+  psp->max_gl_core_version = 42;
   psp->max_gl_compat_version = 30;
   psp->max_gl_es1_version = 11;
   psp->max_gl_es2_version = 31;

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


Mesa (master): i965/fs: calculate first non-payload GRF using attrib slots

2016-05-17 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 7ea09511ca4f58640063cc1ee08386cce5300535
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7ea09511ca4f58640063cc1ee08386cce5300535

Author: Juan A. Suarez Romero 
Date:   Mon Apr  4 12:47:57 2016 +0200

i965/fs: calculate first non-payload GRF using attrib slots

When computing where the first non-payload GRF starts, we can't rely on
the number of attributes, as each attribute can be using 1 or 2 slots
depending on whether they are a dvec3/4 or other.

Instead, we need to use the number of slots used by the attributes.

Reviewed-by: Kenneth Graunke 

---

 src/mesa/drivers/dri/i965/brw_compiler.h | 1 +
 src/mesa/drivers/dri/i965/brw_fs.cpp | 2 +-
 src/mesa/drivers/dri/i965/brw_vec4.cpp   | 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_compiler.h 
b/src/mesa/drivers/dri/i965/brw_compiler.h
index a2148ae..0db1d0d 100644
--- a/src/mesa/drivers/dri/i965/brw_compiler.h
+++ b/src/mesa/drivers/dri/i965/brw_compiler.h
@@ -611,6 +611,7 @@ struct brw_vs_prog_data {
GLbitfield64 inputs_read;
 
unsigned nr_attributes;
+   unsigned nr_attribute_slots;
 
bool uses_vertexid;
bool uses_instanceid;
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
b/src/mesa/drivers/dri/i965/brw_fs.cpp
index e8baf6c..bf3a467 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -1768,7 +1768,7 @@ fs_visitor::assign_vs_urb_setup()
assert(stage == MESA_SHADER_VERTEX);
 
/* Each attribute is 4 regs. */
-   this->first_non_payload_grf += 4 * vs_prog_data->nr_attributes;
+   this->first_non_payload_grf += 4 * vs_prog_data->nr_attribute_slots;
 
assert(vs_prog_data->base.urb_read_length <= 15);
 
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index ac8dd6f..162b481 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -2120,6 +2120,7 @@ brw_compile_vs(const struct brw_compiler *compiler, void 
*log_data,
  DIV_ROUND_UP(MAX2(nr_attribute_slots, 1), 2);
 
prog_data->nr_attributes = nr_attributes;
+   prog_data->nr_attribute_slots = nr_attribute_slots;
 
/* Since vertex shaders reuse the same VUE entry for inputs and outputs
 * (overwriting the original contents), we need to make sure the size is

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


Mesa (master): i965/fs: shuffle 32bits into 64bits for doubles

2016-05-17 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: ccfe25f7583dd8d0ff0609de3728c8b15fb0f8fb
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ccfe25f7583dd8d0ff0609de3728c8b15fb0f8fb

Author: Juan A. Suarez Romero 
Date:   Thu Mar 31 11:49:53 2016 +0100

i965/fs: shuffle 32bits into 64bits for doubles

VS Thread Payload handles attributes in URB as vec4, no matter if they
are actually single or double precision.

So with double-precision types, value ends up in the registers split in
32bits chunks, in different positions.

We need to shuffle the chunks to get the doubles correctly.

v2:
 * Extra blank line. Add { } on if body (Ian Romanick)
 * Use dest directly (Kenneth Graunke)

Reviewed-by: Kenneth Graunke 

---

 src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 8 
 1 file changed, 8 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
index 59a7a56..ad20dc8 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
@@ -3711,6 +3711,14 @@ fs_visitor::nir_emit_intrinsic(const fs_builder , 
nir_intrinsic_instr *instr
   for (unsigned j = 0; j < instr->num_components; j++) {
  bld.MOV(offset(dest, bld, j), offset(src, bld, j));
   }
+
+  if (type_sz(src.type) == 8) {
+ shuffle_32bit_load_result_to_64bit_data(bld,
+ dest,
+ retype(dest, 
BRW_REGISTER_TYPE_F),
+ instr->num_components);
+  }
+
   break;
}
 

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


Mesa (master): nir: add double input bitmap

2016-05-17 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 80535873bbed9d6fda7bb0d2cca3d0950afb8431
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=80535873bbed9d6fda7bb0d2cca3d0950afb8431

Author: Juan A. Suarez Romero 
Date:   Fri Apr 15 12:30:54 2016 +0200

nir: add double input bitmap

This bitmap tracks which input attributes are double-precision.

Reviewed-by: Kenneth Graunke 

---

 src/compiler/nir/glsl_to_nir.cpp | 1 +
 src/compiler/nir/nir.h   | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/src/compiler/nir/glsl_to_nir.cpp b/src/compiler/nir/glsl_to_nir.cpp
index d28fe41..b25f065 100644
--- a/src/compiler/nir/glsl_to_nir.cpp
+++ b/src/compiler/nir/glsl_to_nir.cpp
@@ -152,6 +152,7 @@ glsl_to_nir(const struct gl_shader_program *shader_prog,
shader->info.num_ssbos = sh->NumShaderStorageBlocks;
shader->info.num_images = sh->NumImages;
shader->info.inputs_read = sh->Program->InputsRead;
+   shader->info.double_inputs_read = sh->Program->DoubleInputsRead;
shader->info.outputs_written = sh->Program->OutputsWritten;
shader->info.patch_inputs_read = sh->Program->PatchInputsRead;
shader->info.patch_outputs_written = sh->Program->PatchOutputsWritten;
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 2cfca3e..d4edea7 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -1704,6 +1704,8 @@ typedef struct nir_shader_info {
 
/* Which inputs are actually read */
uint64_t inputs_read;
+   /* Which inputs are actually read and are double */
+   uint64_t double_inputs_read;
/* Which outputs are actually written */
uint64_t outputs_written;
/* Which system values are actually read */

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


Mesa (master): glsl: fixed uninitialized pointer

2016-05-12 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 18f7c88dd692409935bd74f82dc48f524cf951f6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=18f7c88dd692409935bd74f82dc48f524cf951f6

Author: Jakob Sinclair 
Date:   Wed May 11 14:10:19 2016 +0200

glsl: fixed uninitialized pointer

Class "ir_constant" had a bunch of constructors where the pointer member
"array_elements" had not been initialized. This could have lead to unsafe
code if something had tried to write anything to it. This patch fixes
this issue by initializing the pointer to NULL in all the constructors.
This issue was discovered by Coverity.

CID: 401603, 401604, 401605, 401610

Signed-off-by: Jakob Sinclair 
Reviewed-by: Alejandro Piñeiro 

---

 src/compiler/glsl/ir.cpp | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/compiler/glsl/ir.cpp b/src/compiler/glsl/ir.cpp
index d69ab13..9637d7a 100644
--- a/src/compiler/glsl/ir.cpp
+++ b/src/compiler/glsl/ir.cpp
@@ -663,12 +663,15 @@ ir_expression::variable_referenced() const
 ir_constant::ir_constant()
: ir_rvalue(ir_type_constant)
 {
+   this->array_elements = NULL;
 }
 
 ir_constant::ir_constant(const struct glsl_type *type,
 const ir_constant_data *data)
: ir_rvalue(ir_type_constant)
 {
+   this->array_elements = NULL;
+
assert((type->base_type >= GLSL_TYPE_UINT)
  && (type->base_type <= GLSL_TYPE_BOOL));
 
@@ -744,6 +747,7 @@ ir_constant::ir_constant(bool b, unsigned vector_elements)
 ir_constant::ir_constant(const ir_constant *c, unsigned i)
: ir_rvalue(ir_type_constant)
 {
+   this->array_elements = NULL;
this->type = c->type->get_base_type();
 
switch (this->type->base_type) {
@@ -759,6 +763,7 @@ ir_constant::ir_constant(const ir_constant *c, unsigned i)
 ir_constant::ir_constant(const struct glsl_type *type, exec_list *value_list)
: ir_rvalue(ir_type_constant)
 {
+   this->array_elements = NULL;
this->type = type;
 
assert(type->is_scalar() || type->is_vector() || type->is_matrix()

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


Mesa (master): isl: move -lm at the end of tests_ldadd

2016-04-27 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: b1dcedf393e2464fb70e793b9224c5ad438e2914
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b1dcedf393e2464fb70e793b9224c5ad438e2914

Author: Alejandro Piñeiro 
Date:   Wed Apr 27 19:54:40 2016 +0200

isl: move -lm at the end of tests_ldadd

The test was failing to build with "undefined reference to `roundf'" errors,
so Make check on mesa was failing.

Reviewed-by: Jason Ekstrand 

---

 src/intel/isl/Makefile.am | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/intel/isl/Makefile.am b/src/intel/isl/Makefile.am
index 806934e..1427e7b 100644
--- a/src/intel/isl/Makefile.am
+++ b/src/intel/isl/Makefile.am
@@ -110,9 +110,9 @@ check_PROGRAMS = $(TESTS)
 
 # Link tests to lib965_compiler.la for brw_get_device_info().
 tests_ldadd =  \
-   -lm \
libisl.la   \
-   $(top_builddir)/src/mesa/drivers/dri/i965/libi965_compiler.la
+   $(top_builddir)/src/mesa/drivers/dri/i965/libi965_compiler.la \
+   -lm
 
 tests_isl_surf_get_image_offset_test_SOURCES = \
tests/isl_surf_get_image_offset_test.c

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


Mesa (master): xlib: remove MESA_GLX_VISUAL_HACK

2016-04-15 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: f8752e0d95b0b562ca64e8064e98a0b66e5d1591
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f8752e0d95b0b562ca64e8064e98a0b66e5d1591

Author: John Sheu 
Date:   Fri Apr  1 16:52:22 2016 -0700

xlib: remove MESA_GLX_VISUAL_HACK

This removes a hack introduced in 1999 in the first version of
fakeglx.c, with the comment:

  /* XXX revisit this after 3.0 is finished. */

Mesa 4.0 was released in 2001.  It is now 2016, and Mesa 11.0 was
released last year.

Reviewed-by: Alejandro Piñeiro 

---

 src/mesa/drivers/x11/fakeglx.c | 42 +++---
 1 file changed, 19 insertions(+), 23 deletions(-)

diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c
index 508dc65..394800f 100644
--- a/src/mesa/drivers/x11/fakeglx.c
+++ b/src/mesa/drivers/x11/fakeglx.c
@@ -283,29 +283,25 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo,
if (getenv("MESA_GLX_FORCE_ALPHA"))
   alphaFlag = GL_TRUE;
 
-   /* Comparing IDs uses less memory but sometimes fails. */
-   /* XXX revisit this after 3.0 is finished. */
-   if (!getenv("MESA_GLX_VISUAL_HACK")) {
-  /* First check if a matching visual is already in the list */
-  for (i=0; idisplay == dpy
- && v->mesa_visual.level == level
- && v->mesa_visual.numAuxBuffers == numAuxBuffers
- && v->ximage_flag == ximageFlag
- && v->mesa_visual.doubleBufferMode == dbFlag
- && v->mesa_visual.stereoMode == stereoFlag
- && (v->mesa_visual.alphaBits > 0) == alphaFlag
- && (v->mesa_visual.depthBits >= depth_size || depth_size == 0)
- && (v->mesa_visual.stencilBits >= stencil_size || stencil_size == 
0)
- && (v->mesa_visual.accumRedBits >= accumRedSize || accumRedSize 
== 0)
- && (v->mesa_visual.accumGreenBits >= accumGreenSize || 
accumGreenSize == 0)
- && (v->mesa_visual.accumBlueBits >= accumBlueSize || 
accumBlueSize == 0)
- && (v->mesa_visual.accumAlphaBits >= accumAlphaSize || 
accumAlphaSize == 0)) {
-/* now compare visual IDs */
-if (v->visinfo->visualid == vinfo->visualid) {
-   return v;
-}
+   /* First check if a matching visual is already in the list */
+   for (i=0; idisplay == dpy
+  && v->mesa_visual.level == level
+  && v->mesa_visual.numAuxBuffers == numAuxBuffers
+  && v->ximage_flag == ximageFlag
+  && v->mesa_visual.doubleBufferMode == dbFlag
+  && v->mesa_visual.stereoMode == stereoFlag
+  && (v->mesa_visual.alphaBits > 0) == alphaFlag
+  && (v->mesa_visual.depthBits >= depth_size || depth_size == 0)
+  && (v->mesa_visual.stencilBits >= stencil_size || stencil_size == 0)
+  && (v->mesa_visual.accumRedBits >= accumRedSize || accumRedSize == 0)
+  && (v->mesa_visual.accumGreenBits >= accumGreenSize || 
accumGreenSize == 0)
+  && (v->mesa_visual.accumBlueBits >= accumBlueSize || accumBlueSize 
== 0)
+  && (v->mesa_visual.accumAlphaBits >= accumAlphaSize || 
accumAlphaSize == 0)) {
+ /* now compare visual IDs */
+ if (v->visinfo->visualid == vinfo->visualid) {
+return v;
  }
   }
}

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


Mesa (master): xlib: do not cache return value of glXChooseVisual/ glXGetVisualFromFBConfig

2016-04-15 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: fe9d8cd79e9380e29eb92f97903e8cb79d25371a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fe9d8cd79e9380e29eb92f97903e8cb79d25371a

Author: John Sheu 
Date:   Wed Apr 13 13:57:42 2016 -0700

xlib: do not cache return value of glXChooseVisual/glXGetVisualFromFBConfig

The returned XVisualInfo from glXChooseVisual/glXGetVisualFromFBConfig
is being cached in XMesaVisual.vishandle (and unconditionally
overwritten on subsequent calls).  However, these entry points are
specified to return XVisualInfo instances to be owned by the caller and
freed with XFree(), so the return values should not be retained.

With this change, XMesaVisual.vishandle is essentially unused and will
be removed in a subsequent change.

v2: update commit message

Reviewed-by: Alejandro Piñeiro 

---

 src/mesa/drivers/x11/fakeglx.c | 26 --
 1 file changed, 8 insertions(+), 18 deletions(-)

diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c
index 2f4d966..d62d5ab 100644
--- a/src/mesa/drivers/x11/fakeglx.c
+++ b/src/mesa/drivers/x11/fakeglx.c
@@ -1241,16 +1241,11 @@ Fake_glXChooseVisual( Display *dpy, int screen, int 
*list )
 
xmvis = choose_visual(dpy, screen, list, GL_FALSE);
if (xmvis) {
-#if 0
-  return xmvis->vishandle;
-#else
-  /* create a new vishandle - the cached one may be stale */
-  xmvis->vishandle = malloc(sizeof(XVisualInfo));
-  if (xmvis->vishandle) {
- memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo));
+  XVisualInfo* visinfo = malloc(sizeof(XVisualInfo));
+  if (visinfo) {
+ memcpy(visinfo, xmvis->visinfo, sizeof(XVisualInfo));
   }
-  return xmvis->vishandle;
-#endif
+  return visinfo;
}
else
   return NULL;
@@ -1974,16 +1969,11 @@ Fake_glXGetVisualFromFBConfig( Display *dpy, 
GLXFBConfig config )
 {
if (dpy && config) {
   XMesaVisual xmvis = (XMesaVisual) config;
-#if 0  
-  return xmvis->vishandle;
-#else
-  /* create a new vishandle - the cached one may be stale */
-  xmvis->vishandle = malloc(sizeof(XVisualInfo));
-  if (xmvis->vishandle) {
- memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo));
+  XVisualInfo* visinfo = malloc(sizeof(XVisualInfo));
+  if (visinfo) {
+ memcpy(visinfo, xmvis->visinfo, sizeof(XVisualInfo));
   }
-  return xmvis->vishandle;
-#endif
+  return visinfo;
}
else {
   return NULL;

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


Mesa (master): xlib: fix memory leak of and remove vishandle from XMesaVisualInfo

2016-04-15 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 781232e0ac48bf608757bbd270c593a90173f951
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=781232e0ac48bf608757bbd270c593a90173f951

Author: John Sheu 
Date:   Fri Apr  1 16:52:20 2016 -0700

xlib: fix memory leak of and remove vishandle from XMesaVisualInfo

The vishandle member of XMesaVisualInfo is used to support the
comparison of XVisualInfo instances by pointer value, in
find_glx_visual().  The comparison however will always be false, as in
every case the comparison is made, the VisualInfo instance being
compared to is a new allocation passed in through a GLX API call.

In addition, the XVisualInfo instance pointed to by vishandle is itself
never freed, causing a memory leak.  Since vishandle is essentially
useless, we just remove it and thereby also fix the leak.

Reviewed-by: Alejandro Piñeiro 

---

 src/mesa/drivers/x11/fakeglx.c | 62 --
 src/mesa/drivers/x11/xmesaP.h  |  1 -
 2 files changed, 24 insertions(+), 39 deletions(-)

diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c
index d62d5ab..208fc5b 100644
--- a/src/mesa/drivers/x11/fakeglx.c
+++ b/src/mesa/drivers/x11/fakeglx.c
@@ -256,7 +256,6 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo,
GLboolean ximageFlag = GL_TRUE;
XMesaVisual xmvis;
GLint i;
-   GLboolean comparePointers;
 
if (dbFlag) {
   /* Check if the MESA_BACK_BUFFER env var is set */
@@ -279,37 +278,34 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo,
   return NULL;
}
 
-   /* Comparing IDs uses less memory but sometimes fails. */
-   /* XXX revisit this after 3.0 is finished. */
-   if (getenv("MESA_GLX_VISUAL_HACK"))
-  comparePointers = GL_TRUE;
-   else
-  comparePointers = GL_FALSE;
 
/* Force the visual to have an alpha channel */
if (getenv("MESA_GLX_FORCE_ALPHA"))
   alphaFlag = GL_TRUE;
 
-   /* First check if a matching visual is already in the list */
-   for (i=0; idisplay == dpy
-  && v->mesa_visual.level == level
-  && v->mesa_visual.numAuxBuffers == numAuxBuffers
-  && v->ximage_flag == ximageFlag
-  && v->mesa_visual.doubleBufferMode == dbFlag
-  && v->mesa_visual.stereoMode == stereoFlag
-  && (v->mesa_visual.alphaBits > 0) == alphaFlag
-  && (v->mesa_visual.depthBits >= depth_size || depth_size == 0)
-  && (v->mesa_visual.stencilBits >= stencil_size || stencil_size == 0)
-  && (v->mesa_visual.accumRedBits >= accumRedSize || accumRedSize == 0)
-  && (v->mesa_visual.accumGreenBits >= accumGreenSize || 
accumGreenSize == 0)
-  && (v->mesa_visual.accumBlueBits >= accumBlueSize || accumBlueSize 
== 0)
-  && (v->mesa_visual.accumAlphaBits >= accumAlphaSize || 
accumAlphaSize == 0)) {
- /* now either compare XVisualInfo pointers or visual IDs */
- if ((!comparePointers && v->visinfo->visualid == vinfo->visualid)
- || (comparePointers && v->vishandle == vinfo)) {
-return v;
+   /* Comparing IDs uses less memory but sometimes fails. */
+   /* XXX revisit this after 3.0 is finished. */
+   if (!getenv("MESA_GLX_VISUAL_HACK")) {
+  /* First check if a matching visual is already in the list */
+  for (i=0; idisplay == dpy
+ && v->mesa_visual.level == level
+ && v->mesa_visual.numAuxBuffers == numAuxBuffers
+ && v->ximage_flag == ximageFlag
+ && v->mesa_visual.doubleBufferMode == dbFlag
+ && v->mesa_visual.stereoMode == stereoFlag
+ && (v->mesa_visual.alphaBits > 0) == alphaFlag
+ && (v->mesa_visual.depthBits >= depth_size || depth_size == 0)
+ && (v->mesa_visual.stencilBits >= stencil_size || stencil_size == 
0)
+ && (v->mesa_visual.accumRedBits >= accumRedSize || accumRedSize 
== 0)
+ && (v->mesa_visual.accumGreenBits >= accumGreenSize || 
accumGreenSize == 0)
+ && (v->mesa_visual.accumBlueBits >= accumBlueSize || 
accumBlueSize == 0)
+ && (v->mesa_visual.accumAlphaBits >= accumAlphaSize || 
accumAlphaSize == 0)) {
+/* now compare visual IDs */
+if (v->visinfo->visualid == vinfo->visualid) {
+   return v;
+}
  }
   }
}
@@ -323,10 +319,6 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo,
   accumBlueSize, accumAlphaSize, 0, level,
   GLX_NONE_EXT );
if (xmvis) {
-  /* Save a copy of the pointer now so we can find this visual again
-   * if we need to search for it in find_glx_visual().
-   */
-  xmvis->vishandle = vinfo;
   /* Allocate more space for additional visual */
   VisualTable = 

Mesa (master): xlib: fix leaks of returned values from XGetVisualInfo

2016-04-15 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 8a9c0f102540f64c4a3523f6b4e11eaa2071e0a3
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8a9c0f102540f64c4a3523f6b4e11eaa2071e0a3

Author: John Sheu 
Date:   Fri Apr  1 16:52:21 2016 -0700

xlib: fix leaks of returned values from XGetVisualInfo

Reviewed-by: Alejandro Piñeiro 

---

 src/mesa/drivers/x11/fakeglx.c | 29 +
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c
index 208fc5b..508dc65 100644
--- a/src/mesa/drivers/x11/fakeglx.c
+++ b/src/mesa/drivers/x11/fakeglx.c
@@ -730,27 +730,39 @@ choose_x_overlay_visual( Display *dpy, int scr,
   vislist = XGetVisualInfo( dpy, VisualIDMask | VisualScreenMask,
 ,  );
 
+  if (!vislist) {
+ /* no matches */
+ continue;
+  }
+
   if (count!=1) {
  /* something went wrong */
+ free(vislist);
  continue;
   }
   if (preferred_class!=DONT_CARE && preferred_class!=vislist->CLASS) {
  /* wrong visual class */
+ free(vislist);
  continue;
   }
 
   /* Color-index rendering is not supported.  Make sure we have 
True/DirectColor */
-  if (vislist->CLASS != TrueColor && vislist->CLASS != DirectColor)
+  if (vislist->CLASS != TrueColor && vislist->CLASS != DirectColor) {
+ free(vislist);
  continue;
+  }
 
-  if (deepvis==NULL || vislist->depth > deepest) {
- /* YES!  found a satisfactory visual */
- free(deepvis);
- deepest = vislist->depth;
- deepvis = vislist;
- /* DEBUG  tt = ov->transparent_type;*/
- /* DEBUG  tv = ov->value; */
+  if (deepvis!=NULL && vislist->depth <= deepest) {
+ free(vislist);
+ continue;
   }
+
+  /* YES!  found a satisfactory visual */
+  free(deepvis);
+  deepest = vislist->depth;
+  deepvis = vislist;
+  /* DEBUG  tt = ov->transparent_type;*/
+  /* DEBUG  tv = ov->value; */
}
 
 /*DEBUG
@@ -1912,6 +1924,7 @@ Fake_glXGetFBConfigs( Display *dpy, int screen, int 
*nelements )
   for (i = 0; i < *nelements; i++) {
  results[i] = create_glx_visual(dpy, visuals + i);
   }
+  free(visuals);
   return (GLXFBConfig *) results;
}
return NULL;

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


Mesa (master): nir/types: Add a wrapper for count_attribute_slots

2016-04-07 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 05db68024853fe3613480ca164485ccf67f1a7cc
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=05db68024853fe3613480ca164485ccf67f1a7cc

Author: Jason Ekstrand 
Date:   Fri Mar 25 16:12:19 2016 -0700

nir/types: Add a wrapper for count_attribute_slots

Reviewed-by: Rob Clark 

---

 src/compiler/nir_types.cpp | 7 +++
 src/compiler/nir_types.h   | 3 +++
 2 files changed, 10 insertions(+)

diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp
index 3669cfe..70e9cd3 100644
--- a/src/compiler/nir_types.cpp
+++ b/src/compiler/nir_types.cpp
@@ -124,6 +124,13 @@ glsl_get_aoa_size(const struct glsl_type *type)
return type->arrays_of_arrays_size();
 }
 
+unsigned
+glsl_count_attribute_slots(const struct glsl_type *type,
+   bool vertex_input_slots)
+{
+   return type->count_attribute_slots(vertex_input_slots);
+}
+
 const char *
 glsl_get_struct_elem_name(const struct glsl_type *type, unsigned index)
 {
diff --git a/src/compiler/nir_types.h b/src/compiler/nir_types.h
index 0748783..5efdd85 100644
--- a/src/compiler/nir_types.h
+++ b/src/compiler/nir_types.h
@@ -68,6 +68,9 @@ unsigned glsl_get_length(const struct glsl_type *type);
 
 unsigned glsl_get_aoa_size(const struct glsl_type *type);
 
+unsigned glsl_count_attribute_slots(const struct glsl_type *type,
+bool vertex_input_slots);
+
 const char *glsl_get_struct_elem_name(const struct glsl_type *type,
   unsigned index);
 

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


Mesa (master): glsl: do not raise unitialized variable warnings on builtins/ reserved GL variables

2016-04-01 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: cd7d631c71bb1342a6607a193918ccb3289c0bbf
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cd7d631c71bb1342a6607a193918ccb3289c0bbf

Author: Alejandro Piñeiro 
Date:   Fri Apr  1 09:11:15 2016 +0200

glsl: do not raise unitialized variable warnings on builtins/reserved GL 
variables

Needed because not all the built-in variables are marked as system
values, so they still have the mode ir_var_auto. Right now it fixes
raising the warning when gl_GlobalInvocationID and
gl_LocalInvocationIndex are used.

v2: use is_gl_identifier instead of filtering for some names (Ilia
Mirkin)

Reviewed-by: Kenneth Graunke 

---

 src/compiler/glsl/ast_to_hir.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index a031231..3fe9007 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -1905,7 +1905,8 @@ ast_expression::do_hir(exec_list *instructions,
 
  if ((var->data.mode == ir_var_auto || var->data.mode == 
ir_var_shader_out)
  && !this->is_lhs
- && result->variable_referenced()->data.assigned != true) {
+ && result->variable_referenced()->data.assigned != true
+ && !is_gl_identifier(var->name)) {
 _mesa_glsl_warning(, state, "`%s' used uninitialized",
this->primary_expression.identifier);
  }

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


Mesa (master): glsl: add is_lhs bool on ast_expression

2016-03-29 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 8568d02498d12ebde6a6245056eebfbfe18aaf8f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8568d02498d12ebde6a6245056eebfbfe18aaf8f

Author: Alejandro Piñeiro 
Date:   Thu Feb 25 11:11:54 2016 +0100

glsl: add is_lhs bool on ast_expression

Useful to know if a expression is the recipient of an assignment
or not, that would be used to (for example) raise warnings of
"use of uninitialized variable" without getting a false positive
when assigning first a variable.

By default the value is false, and it is assigned to true on
the following cases:
 * The lhs assignments subexpression
 * At ast_array_index, on the array itself.
 * While handling the method on an array, to avoid the warning
   calling array.length
 * When computed the cached test expression at test_to_hir, to
   avoid a duplicate warning on the test expression of a switch.

set_is_lhs setter is added, because in some cases (like ast_field_selection)
the value need to be propagated on the expression tree. To avoid doing the
propatagion if not needed, it skips if no primary_expression.identifier is
available.

v2: use a new bool on ast_expression, instead of a new parameter
on ast_expression::hir (Timothy Arceri)

v3: fix style and some typos on comments, initialize is_lhs default value
on constructor, to avoid a c++11 feature (Ian Romanick)

v4: some tweaks on comments (Timothy Arceri)

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

Reviewed-by: Timothy Arceri 

---

 src/compiler/glsl/ast.h  |  6 ++
 src/compiler/glsl/ast_function.cpp   |  4 
 src/compiler/glsl/ast_to_hir.cpp | 33 
 src/compiler/glsl/glsl_parser_extras.cpp |  1 +
 4 files changed, 44 insertions(+)

diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h
index 727aa43..9f46340 100644
--- a/src/compiler/glsl/ast.h
+++ b/src/compiler/glsl/ast.h
@@ -214,6 +214,7 @@ public:
   subexpressions[2] = NULL;
   primary_expression.identifier = identifier;
   this->non_lvalue_description = NULL;
+  this->is_lhs = false;
}
 
static const char *operator_string(enum ast_operators op);
@@ -263,6 +264,11 @@ public:
 * This pointer may be \c NULL.
 */
const char *non_lvalue_description;
+
+   void set_is_lhs(bool new_value);
+
+private:
+   bool is_lhs;
 };
 
 class ast_expression_bin : public ast_expression {
diff --git a/src/compiler/glsl/ast_function.cpp 
b/src/compiler/glsl/ast_function.cpp
index 1a44020..db68d5d 100644
--- a/src/compiler/glsl/ast_function.cpp
+++ b/src/compiler/glsl/ast_function.cpp
@@ -1727,6 +1727,10 @@ ast_function_expression::handle_method(exec_list 
*instructions,
const char *method;
method = field->primary_expression.identifier;
 
+   /* This would prevent to raise "uninitialized variable" warnings when
+* calling array.length.
+*/
+   field->subexpressions[0]->set_is_lhs(true);
op = field->subexpressions[0]->hir(instructions, state);
if (strcmp(method, "length") == 0) {
   if (!this->expressions.is_empty()) {
diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index 35def8e..e162203 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -1248,6 +1248,24 @@ ast_expression::hir_no_rvalue(exec_list *instructions,
do_hir(instructions, state, false);
 }
 
+void
+ast_expression::set_is_lhs(bool new_value)
+{
+   /* is_lhs is tracked only to print "variable used uninitialized" warnings,
+* if we lack a identifier we can just skip it.
+*/
+   if (this->primary_expression.identifier == NULL)
+  return;
+
+   this->is_lhs = new_value;
+
+   /* We need to go through the subexpressions tree to cover cases like
+* ast_field_selection
+*/
+   if (this->subexpressions[0] != NULL)
+  this->subexpressions[0]->set_is_lhs(new_value);
+}
+
 ir_rvalue *
 ast_expression::do_hir(exec_list *instructions,
struct _mesa_glsl_parse_state *state,
@@ -1323,6 +1341,7 @@ ast_expression::do_hir(exec_list *instructions,
   break;
 
case ast_assign: {
+  this->subexpressions[0]->set_is_lhs(true);
   op[0] = this->subexpressions[0]->hir(instructions, state);
   op[1] = this->subexpressions[1]->hir(instructions, state);
 
@@ -1592,6 +1611,7 @@ ast_expression::do_hir(exec_list *instructions,
case ast_div_assign:
case ast_add_assign:
case ast_sub_assign: {
+  this->subexpressions[0]->set_is_lhs(true);
   op[0] = this->subexpressions[0]->hir(instructions, state);
   op[1] = this->subexpressions[1]->hir(instructions, state);
 
@@ -1618,6 +1638,7 @@ ast_expression::do_hir(exec_list *instructions,
}
 
case ast_mod_assign: {
+  this->subexpressions[0]->set_is_lhs(true);
   op[0] = this->subexpressions[0]->hir(instructions, state);
   op[1] = this->subexpressions[1]->hir(instructions, 

Mesa (master): glsl: raise warning when using uninitialized variables

2016-03-29 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: dcd41ca87a06199184eb8ada654aec985185189c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=dcd41ca87a06199184eb8ada654aec985185189c

Author: Alejandro Piñeiro 
Date:   Tue Feb 23 11:48:52 2016 +0100

glsl: raise warning when using uninitialized variables

v2:
 * Take into account out varyings too (Timothy Arceri)
 * Fix style (Timothy Arceri)
 * Use a new ast_expression variable, instead of an
   ast_expression::hir new parameter (Timothy Arceri)

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

Reviewed-by: Timothy Arceri 

---

 src/compiler/glsl/ast_to_hir.cpp | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index e162203..29a4642 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -1901,6 +1901,13 @@ ast_expression::do_hir(exec_list *instructions,
   if (var != NULL) {
  var->data.used = true;
  result = new(ctx) ir_dereference_variable(var);
+
+ if ((var->data.mode == ir_var_auto || var->data.mode == 
ir_var_shader_out)
+ && !this->is_lhs
+ && result->variable_referenced()->data.assigned != true) {
+_mesa_glsl_warning(, state, "`%s' used uninitialized",
+   this->primary_expression.identifier);
+ }
   } else {
  _mesa_glsl_error(& loc, state, "`%s' undeclared",
   this->primary_expression.identifier);

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


Mesa (master): doc: add 'vec4' option in INTEL_DEBUG

2016-03-18 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 7a712e64d6d59c3543fd307f9e029ad0886be622
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7a712e64d6d59c3543fd307f9e029ad0886be622

Author: Juan A. Suarez Romero 
Date:   Fri Mar 18 17:29:55 2016 +0100

doc: add 'vec4' option in INTEL_DEBUG

Reviewed-by: Iago Toral Quiroga 

---

 docs/envvars.html | 1 +
 1 file changed, 1 insertion(+)

diff --git a/docs/envvars.html b/docs/envvars.html
index 06aa0ac..e21b7c1 100644
--- a/docs/envvars.html
+++ b/docs/envvars.html
@@ -163,6 +163,7 @@ See the Xlib software driver 
page for details.
blorp - emit messages about the blorp operations (blits  
clears)
nodualobj - suppress generation of dual-object geometry shader code
optimizer - dump shader assembly to files at each optimization pass and 
iteration that make progress
+   vec4 - force vec4 mode in vertex shader
 
 
 

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


Mesa (master): i965/fs/nir: "surface_access::" prefix not needed

2016-03-08 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: ef76ea4ba97d0ac122491fd3f1b2bbb8e4163150
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ef76ea4ba97d0ac122491fd3f1b2bbb8e4163150

Author: Alejandro Piñeiro 
Date:   Fri Mar  4 20:38:41 2016 +0100

i965/fs/nir: "surface_access::" prefix not needed

"using namespace brw::surface_access" is already present at the
top of the source file.

Reviewed-by: Iago Toral Quiroga 

---

 src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 24 ++--
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp 
b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
index 04e9b8f..cde8f0b 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
@@ -2345,8 +2345,6 @@ fs_visitor::nir_emit_intrinsic(const fs_builder , 
nir_intrinsic_instr *instr
case nir_intrinsic_atomic_counter_inc:
case nir_intrinsic_atomic_counter_dec:
case nir_intrinsic_atomic_counter_read: {
-  using namespace surface_access;
-
   /* Get the arguments of the atomic intrinsic. */
   const fs_reg offset = get_nir_src(instr->src[0]);
   const unsigned surface = (stage_prog_data->binding_table.abo_start +
@@ -2932,12 +2930,11 @@ fs_visitor::nir_emit_ssbo_atomic(const fs_builder ,
 
/* Emit the actual atomic operation operation */
 
-   fs_reg atomic_result =
-  surface_access::emit_untyped_atomic(bld, surface, offset,
-  data1, data2,
-  1 /* dims */, 1 /* rsize */,
-  op,
-  BRW_PREDICATE_NONE);
+   fs_reg atomic_result = emit_untyped_atomic(bld, surface, offset,
+  data1, data2,
+  1 /* dims */, 1 /* rsize */,
+  op,
+  BRW_PREDICATE_NONE);
dest.type = atomic_result.type;
bld.MOV(dest, atomic_result);
 }
@@ -2959,12 +2956,11 @@ fs_visitor::nir_emit_shared_atomic(const fs_builder 
,
 
/* Emit the actual atomic operation operation */
 
-   fs_reg atomic_result =
-  surface_access::emit_untyped_atomic(bld, surface, offset,
-  data1, data2,
-  1 /* dims */, 1 /* rsize */,
-  op,
-  BRW_PREDICATE_NONE);
+   fs_reg atomic_result = emit_untyped_atomic(bld, surface, offset,
+  data1, data2,
+  1 /* dims */, 1 /* rsize */,
+  op,
+  BRW_PREDICATE_NONE);
dest.type = atomic_result.type;
bld.MOV(dest, atomic_result);
 }

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


Mesa (master): i965/vec4/nir: remove emit_untyped_surface_read and emit_untyped_atomic at brw_vec4_visitor

2016-03-07 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: d3a89a7c494d577fdf8f45c0d8735004a571e86b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d3a89a7c494d577fdf8f45c0d8735004a571e86b

Author: Alejandro Piñeiro 
Date:   Fri Mar  4 17:32:08 2016 +0100

i965/vec4/nir: remove emit_untyped_surface_read and emit_untyped_atomic at 
brw_vec4_visitor

surface_access emit_untyped_read and emit_untyped_atomic provides the same
functionality.

v2: surface parameter of emit_untyped_atomic is a const, no need to
specify default predicate on emit_untyped_atomic, use retype
(Francisco Jerez).

Reviewed-by: Francisco Jerez 

---

 src/mesa/drivers/dri/i965/brw_vec4.h   |  7 
 src/mesa/drivers/dri/i965/brw_vec4_nir.cpp | 36 +++--
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 55 --
 3 files changed, 23 insertions(+), 75 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h 
b/src/mesa/drivers/dri/i965/brw_vec4.h
index 91771b8..d43a5a8 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -276,13 +276,6 @@ public:
void emit_shader_time_end();
void emit_shader_time_write(int shader_time_subindex, src_reg value);
 
-   void emit_untyped_atomic(unsigned atomic_op, unsigned surf_index,
-dst_reg dst, src_reg offset, src_reg src0,
-src_reg src1);
-
-   void emit_untyped_surface_read(unsigned surf_index, dst_reg dst,
-  src_reg offset);
-
src_reg get_scratch_offset(bblock_t *block, vec4_instruction *inst,
  src_reg *reladdr, int reg_offset);
src_reg get_pull_constant_offset(bblock_t *block, vec4_instruction *inst,
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
index 9b721e5..0e716cf 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
@@ -724,24 +724,34 @@ vec4_visitor::nir_emit_intrinsic(nir_intrinsic_instr 
*instr)
  (unsigned) instr->const_index[0];
   src_reg offset = get_nir_src(instr->src[0], nir_type_int,
instr->num_components);
+  const src_reg surface = brw_imm_ud(surf_index);
+  const vec4_builder bld =
+ vec4_builder(this).at_end().annotate(current_annotation, base_ir);
+  src_reg tmp;
+
   dest = get_nir_dest(instr->dest);
 
   switch (instr->intrinsic) {
- case nir_intrinsic_atomic_counter_inc:
-emit_untyped_atomic(BRW_AOP_INC, surf_index, dest, offset,
-src_reg(), src_reg());
-break;
- case nir_intrinsic_atomic_counter_dec:
-emit_untyped_atomic(BRW_AOP_PREDEC, surf_index, dest, offset,
-src_reg(), src_reg());
-break;
- case nir_intrinsic_atomic_counter_read:
-emit_untyped_surface_read(surf_index, dest, offset);
-break;
- default:
-unreachable("Unreachable");
+  case nir_intrinsic_atomic_counter_inc:
+ tmp = emit_untyped_atomic(bld, surface, offset,
+   src_reg(), src_reg(),
+   1, 1,
+   BRW_AOP_INC);
+ break;
+  case nir_intrinsic_atomic_counter_dec:
+ tmp = emit_untyped_atomic(bld, surface, offset,
+   src_reg(), src_reg(),
+   1, 1,
+   BRW_AOP_PREDEC);
+ break;
+  case nir_intrinsic_atomic_counter_read:
+ tmp = emit_untyped_read(bld, surface, offset, 1, 1);
+ break;
+  default:
+ unreachable("Unreachable");
   }
 
+  bld.MOV(retype(dest, tmp.type), tmp);
   brw_mark_surface_used(stage_prog_data, surf_index);
   break;
}
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index cfd4d9b..d30330a 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -1115,61 +1115,6 @@ vec4_visitor::gs_end_primitive()
 }
 
 void
-vec4_visitor::emit_untyped_atomic(unsigned atomic_op, unsigned surf_index,
-  dst_reg dst, src_reg surf_offset,
-  src_reg src0, src_reg src1)
-{
-   unsigned mlen = 1 + (src0.file != BAD_FILE) + (src1.file != BAD_FILE);
-   src_reg src_payload(this, glsl_type::uint_type, mlen);
-   dst_reg payload(src_payload);
-   payload.writemask = WRITEMASK_X;
-
-   /* Set the atomic operation offset. */
-   emit(MOV(offset(payload, 0), surf_offset));
-   unsigned i = 1;
-
-   /* Set the atomic operation arguments. */
-   if (src0.file != BAD_FILE) {
-  emit(MOV(offset(payload, i), src0));
-  i++;
-   }
-
-   if 

Mesa (master): i965/vec4/nir: no need to use surface_access:: to call emit_untyped_atomic

2016-03-07 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 0548844e866e4fe326432116f84fdf7e885fba9f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0548844e866e4fe326432116f84fdf7e885fba9f

Author: Alejandro Piñeiro 
Date:   Fri Mar  4 18:20:09 2016 +0100

i965/vec4/nir: no need to use surface_access:: to call emit_untyped_atomic

Now that brw_vec4_visitor::emit_untyped_atomic was removed, there is no need
to explicitly set it.

Reviewed-by: Francisco Jerez 

---

 src/mesa/drivers/dri/i965/brw_vec4_nir.cpp | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
index 0e716cf..52977f1 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
@@ -878,12 +878,11 @@ vec4_visitor::nir_emit_ssbo_atomic(int op, 
nir_intrinsic_instr *instr)
const vec4_builder bld =
   vec4_builder(this).at_end().annotate(current_annotation, base_ir);
 
-   src_reg atomic_result =
-  surface_access::emit_untyped_atomic(bld, surface, offset,
-  data1, data2,
-  1 /* dims */, 1 /* rsize */,
-  op,
-  BRW_PREDICATE_NONE);
+   src_reg atomic_result = emit_untyped_atomic(bld, surface, offset,
+   data1, data2,
+   1 /* dims */, 1 /* rsize */,
+   op,
+   BRW_PREDICATE_NONE);
dest.type = atomic_result.type;
bld.MOV(dest, atomic_result);
 }

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


Mesa (master): i965/vec4: pass the correct src_sz to emit_send at emit_untyped_atomic

2016-03-07 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 0c5c2e2c936a933d4e78acb36d1f5e56d020043c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0c5c2e2c936a933d4e78acb36d1f5e56d020043c

Author: Alejandro Piñeiro 
Date:   Fri Mar  4 19:20:27 2016 +0100

i965/vec4: pass the correct src_sz to emit_send at emit_untyped_atomic

If the src is invalid, so src size is zero, the src_sz passed to emit
send should be zero too, instead of a default 1 if we are in a simd4x2
case. This can happens if using emit_untyped_atomic for an atomic
dec/inc.

v2: use the proper src_sz when calling emit_send, instead of just
avoid loading src at emit_send if BAD_FILE (Francisco Jerez)

Reviewed-by: Francisco Jerez 

---

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

diff --git a/src/mesa/drivers/dri/i965/brw_vec4_surface_builder.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_surface_builder.cpp
index 28002c5..1db349a 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_surface_builder.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_surface_builder.cpp
@@ -221,7 +221,7 @@ namespace brw {
   emit_insert(bld, addr, dims, has_simd4x2),
   has_simd4x2 ? 1 : dims,
   emit_insert(bld, src_reg(srcs), size, has_simd4x2),
-  has_simd4x2 ? 1 : size,
+  has_simd4x2 && size ? 1 : size,
   surface, op, rsize, pred);
   }
 

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


Mesa (master): docs: document MESA_GLES_VERSION_OVERRIDE envvar

2016-02-13 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: a150101125111bfdead2fcf59d5eb3b37c22031a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a150101125111bfdead2fcf59d5eb3b37c22031a

Author: Alejandro Piñeiro 
Date:   Sat Feb 13 19:05:49 2016 +0100

docs: document MESA_GLES_VERSION_OVERRIDE envvar

v2: Removed reference to FC not being an allowed suffix (Brian Paul)

Reviewed-by: Brian Paul 

---

 docs/envvars.html | 8 
 1 file changed, 8 insertions(+)

diff --git a/docs/envvars.html b/docs/envvars.html
index ba83335..8c4597c 100644
--- a/docs/envvars.html
+++ b/docs/envvars.html
@@ -91,6 +91,14 @@ This is only valid for versions = 3.0.
  Mesa may not really implement all the features of the given version.
 (for developers only)
 
+MESA_GLES_VERSION_OVERRIDE - changes the value returned by
+glGetString(GL_VERSION) for OpenGL ES.
+
+ The format should be MAJOR.MINOR
+ Examples: 2.0, 3.0, 3.1
+ Mesa may not really implement all the features of the given version.
+(for developers only)
+
 MESA_GLSL_VERSION_OVERRIDE - changes the value returned by
 glGetString(GL_SHADING_LANGUAGE_VERSION). Valid values are integers, such as
 "130".  Mesa will not really implement all the features of the given language 
version

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


Mesa (master): i965/blorp: Fix hiz ops on MSAA surfaces

2016-02-10 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 43d23e879c797fa9b6cbbae15e101f2a3ee64751
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=43d23e879c797fa9b6cbbae15e101f2a3ee64751

Author: Chris Forbes 
Date:   Tue Nov 18 21:49:53 2014 +1300

i965/blorp: Fix hiz ops on MSAA surfaces

Two things were broken here:
- The depth/stencil surface dimensions were broken for MSAA.
- Sample count was programmed incorrectly.

Result was the depth resolve didn't work correctly on MSAA surfaces, and
so sampling the surface later produced garbage.

Fixes the new piglit test arb_texture_multisample-sample-depth, and
various artifacts in 'tesseract' with msaa=4 glineardepth=0.

Fixes freedesktop bug #76396.

Not observed any piglit regressions on Haswell.

v2: Just set brw_hiz_op_params::dst.num_samples rather than adding a
helper function (Ken).

Signed-off-by: Chris Forbes 

v3: moved the alignment needed for hiz+msaa to brw_blorp.cpp, as
suggested by Chad Versace (Alejandro Piñeiro on behalf of Chris
Forbes)

Signed-off-by: Alejandro Piñeiro 

Reviewed-by: Ben Widawsky 

Tested-by: Jordan Justen 
Reviewed-by: Jordan Justen 

---

 src/mesa/drivers/dri/i965/brw_blorp.cpp | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_blorp.cpp 
b/src/mesa/drivers/dri/i965/brw_blorp.cpp
index 1bc6d15..4497eab 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp.cpp
@@ -319,8 +319,14 @@ brw_hiz_op_params::brw_hiz_op_params(struct 
intel_mipmap_tree *mt,
 * not 8. But commit 1f112cc increased the alignment from 4 to 8, which
 * prevents the clobbering.
 */
-   depth.width = ALIGN(depth.width, 8);
-   depth.height = ALIGN(depth.height, 4);
+   dst.num_samples = mt->num_samples;
+   if (dst.num_samples > 1) {
+  depth.width = ALIGN(mt->logical_width0, 8);
+  depth.height = ALIGN(mt->logical_height0, 4);
+   } else {
+  depth.width = ALIGN(depth.width, 8);
+  depth.height = ALIGN(depth.height, 4);
+   }
 
x1 = depth.width;
y1 = depth.height;

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


Mesa (master): i965: use _mesa_is_array_texture instead of _mesa_tex_target_is_array

2015-12-07 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: b16e0ff34e7824bb7f44e7afb78334fcfb0f7264
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b16e0ff34e7824bb7f44e7afb78334fcfb0f7264

Author: Alejandro Piñeiro 
Date:   Sat Dec  5 20:46:30 2015 +0100

i965: use _mesa_is_array_texture instead of _mesa_tex_target_is_array

Both methods provide the same functionality, so one would be
removed.

v2: use _mesa_is_array_texture and not the other way (Brian Paul)

Reviewed-by: Brian Paul 

---

 src/mesa/drivers/dri/i965/gen7_wm_surface_state.c |2 +-
 src/mesa/drivers/dri/i965/gen8_surface_state.c|2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c 
b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
index 2aa395b..7918256 100644
--- a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
@@ -500,7 +500,7 @@ gen7_update_renderbuffer_surface(struct brw_context *brw,
   /* fallthrough */
default:
   surftype = translate_tex_target(gl_target);
-  is_array = _mesa_tex_target_is_array(gl_target);
+  is_array = _mesa_is_array_texture(gl_target);
   break;
}
 
diff --git a/src/mesa/drivers/dri/i965/gen8_surface_state.c 
b/src/mesa/drivers/dri/i965/gen8_surface_state.c
index 80252a5..85e1285 100644
--- a/src/mesa/drivers/dri/i965/gen8_surface_state.c
+++ b/src/mesa/drivers/dri/i965/gen8_surface_state.c
@@ -452,7 +452,7 @@ gen8_update_renderbuffer_surface(struct brw_context *brw,
   /* fallthrough */
default:
   surf_type = translate_tex_target(gl_target);
-  is_array = _mesa_tex_target_is_array(gl_target);
+  is_array = _mesa_is_array_texture(gl_target);
   break;
}
 

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


Mesa (master): mesa: remove _mesa_tex_target_is_array

2015-12-07 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 3d260cc653966298bb217d028797a2c4ecb33c52
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3d260cc653966298bb217d028797a2c4ecb33c52

Author: Alejandro Piñeiro 
Date:   Sat Dec  5 20:47:33 2015 +0100

mesa: remove _mesa_tex_target_is_array

_mesa_is_array_texture provides the same functionality and:

1. it returns bool instead of GLboolean
2. it's not related to the texture format (texformat.c)
3. the name's a little shorter

v2: remove _mesa_tex_target_is_array instead (Brian Paul)

Reviewed-by: Brian Paul 

---

 src/mesa/main/texformat.c |   14 --
 src/mesa/main/texformat.h |3 ---
 2 files changed, 17 deletions(-)

diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
index fd9f335..419fd78 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -782,17 +782,3 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum 
target,
  _mesa_enum_to_string(internalFormat));
return MESA_FORMAT_NONE;
 }
-
-GLboolean
-_mesa_tex_target_is_array(GLenum target)
-{
-   switch (target) {
-   case GL_TEXTURE_1D_ARRAY_EXT:
-   case GL_TEXTURE_2D_ARRAY_EXT:
-   case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
-   case GL_TEXTURE_CUBE_MAP_ARRAY:
-  return GL_TRUE;
-   default:
-  return GL_FALSE;
-   }
-}
diff --git a/src/mesa/main/texformat.h b/src/mesa/main/texformat.h
index 32e2099..ed965f8 100644
--- a/src/mesa/main/texformat.h
+++ b/src/mesa/main/texformat.h
@@ -35,7 +35,4 @@ extern mesa_format
 _mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
 GLint internalFormat, GLenum format, GLenum type);
 
-extern GLboolean
-_mesa_tex_target_is_array(GLenum target);
-
 #endif

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


Mesa (master): nir/glsl_to_nir: use _mesa_fls() to compute num_textures

2015-11-16 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 40c2acef5cfe28f4ac371203bd70bfc7a222ba26
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=40c2acef5cfe28f4ac371203bd70bfc7a222ba26

Author: Juan A. Suarez Romero 
Date:   Fri Nov  6 12:23:17 2015 +

nir/glsl_to_nir: use _mesa_fls() to compute num_textures

Replace the current loop by a direct call to _mesa_fls() function.

It also fixes an implicit bug in the current code where num_textures
seems to be one value less than it should be when sh->Program->SamplersUsed > 0.

For instance, num_textures is 0 instead of 1 when
sh->Program->SamplersUsed is 1.

Signed-off-by: Juan A. Suarez Romero 
Reviewed-by: Matt Turner 

---

 src/glsl/nir/glsl_to_nir.cpp |9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp
index b10d192..38b8390 100644
--- a/src/glsl/nir/glsl_to_nir.cpp
+++ b/src/glsl/nir/glsl_to_nir.cpp
@@ -31,6 +31,7 @@
 #include "ir_visitor.h"
 #include "ir_hierarchical_visitor.h"
 #include "ir.h"
+#include "main/imports.h"
 
 /*
  * pass to lower GLSL IR to NIR
@@ -145,16 +146,10 @@ glsl_to_nir(const struct gl_shader_program *shader_prog,
 
nir_lower_outputs_to_temporaries(shader);
 
-   /* TODO: Use _mesa_fls instead */
-   unsigned num_textures = 0;
-   for (unsigned i = 0; i < 8 * sizeof(sh->Program->SamplersUsed); i++)
-  if (sh->Program->SamplersUsed & (1 << i))
- num_textures = i;
-
shader->info.name = ralloc_asprintf(shader, "GLSL%d", shader_prog->Name);
if (shader_prog->Label)
   shader->info.label = ralloc_strdup(shader, shader_prog->Label);
-   shader->info.num_textures = num_textures;
+   shader->info.num_textures = _mesa_fls(sh->Program->SamplersUsed);
shader->info.num_ubos = sh->NumUniformBlocks;
shader->info.num_abos = shader_prog->NumAtomicBuffers;
shader->info.num_ssbos = sh->NumShaderStorageBlocks;

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


Mesa (master): i965/vec4: check opcode on vec4_instruction::reads_flag( channel)

2015-10-23 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 2f1bc1da864f8d169427b911bf60e1023321e420
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2f1bc1da864f8d169427b911bf60e1023321e420

Author: Alejandro Piñeiro 
Date:   Fri Oct 23 15:32:30 2015 +0200

i965/vec4: check opcode on vec4_instruction::reads_flag(channel)

Commit f17b78 added an alternative reads_flag(channel) that returned
if the instruction was reading a specific channel flag. By mistake it
only took into account the predicate, but when the opcode is
VS_OPCODE_UNPACK_FLAGS_SIMD4X2 there isn't any predicate, but the flag
are used.

That mistake caused some regressions on old hw. More information on
this bug:
https://bugs.freedesktop.org/show_bug.cgi?id=92621

Reviewed-by: Kenneth Graunke 

---

 src/mesa/drivers/dri/i965/brw_ir_vec4.h |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_ir_vec4.h 
b/src/mesa/drivers/dri/i965/brw_ir_vec4.h
index 74e9733..cc4104c 100644
--- a/src/mesa/drivers/dri/i965/brw_ir_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_ir_vec4.h
@@ -188,8 +188,8 @@ public:
 
bool reads_flag(unsigned c)
{
-  if (!reads_flag())
- return false;
+  if (opcode == VS_OPCODE_UNPACK_FLAGS_SIMD4X2)
+ return true;
 
   switch (predicate) {
   case BRW_PREDICATE_NONE:

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


Mesa (master): i965/vec4: use an envvar to decide to print the assembly on cmod_propagation tests

2015-10-22 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 92ae101ed0dff689f207abf61f68167009de4e29
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=92ae101ed0dff689f207abf61f68167009de4e29

Author: Alejandro Piñeiro 
Date:   Thu Oct  1 16:41:30 2015 +0200

i965/vec4: use an envvar to decide to print the assembly on cmod_propagation 
tests

The complete way to do this would be parse INTEL_DEBUG and
print the output if DEBUG_VS (or a new one) is present
(see intel_debug.c).

But that seems like an overkill for the unit tests, that
after all, the most common use case is being run when
calling make check.

v2: use the same idea for the fs counterpart too, as suggested by
Matt Turner

Reviewed-by: Matt Turner 

---

 src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp   |2 +-
 src/mesa/drivers/dri/i965/test_vec4_cmod_propagation.cpp |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp 
b/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp
index 5f80f90..62d39f7 100644
--- a/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp
@@ -84,7 +84,7 @@ instruction(bblock_t *block, int num)
 static bool
 cmod_propagation(fs_visitor *v)
 {
-   const bool print = false;
+   const bool print = getenv("TEST_DEBUG");
 
if (print) {
   fprintf(stderr, "= Before =\n");
diff --git a/src/mesa/drivers/dri/i965/test_vec4_cmod_propagation.cpp 
b/src/mesa/drivers/dri/i965/test_vec4_cmod_propagation.cpp
index 5ca697a..9aa2fcc 100644
--- a/src/mesa/drivers/dri/i965/test_vec4_cmod_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/test_vec4_cmod_propagation.cpp
@@ -122,7 +122,7 @@ instruction(bblock_t *block, int num)
 static bool
 cmod_propagation(vec4_visitor *v)
 {
-   const bool print = false;
+   const bool print = getenv("TEST_DEBUG");
 
if (print) {
   fprintf(stderr, "= Before =\n");

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


Mesa (master): i965/vec4: nir_emit_if doesn' t need to predicate based on all the channels

2015-10-22 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 8ac3b525c77cb5aae9e61bd984b78f6cbbffdc1c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8ac3b525c77cb5aae9e61bd984b78f6cbbffdc1c

Author: Alejandro Piñeiro 
Date:   Fri Oct  9 16:59:20 2015 +0200

i965/vec4: nir_emit_if doesn't need to predicate based on all the channels

v2: changed comment, as suggested by Matt Turner

Reviewed-by: Matt Turner 
Reviewed-by: Jason Ekstrand 

---

 src/mesa/drivers/dri/i965/brw_vec4_nir.cpp |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
index ea1e3e7..0f04f65 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
@@ -193,7 +193,9 @@ vec4_visitor::nir_emit_if(nir_if *if_stmt)
vec4_instruction *inst = emit(MOV(dst_null_d(), condition));
inst->conditional_mod = BRW_CONDITIONAL_NZ;
 
-   emit(IF(BRW_PREDICATE_NORMAL));
+   /* We can just predicate based on the X channel, as the condition only
+* goes on its own line */
+   emit(IF(BRW_PREDICATE_ALIGN16_REPLICATE_X));
 
nir_emit_cf_list(_stmt->then_list);
 

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


Mesa (master): i965/vec4: Add unit tests for cmod propagation pass

2015-10-22 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 8fc8fcc04f584b32cd5bf633da8e3508249e339d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8fc8fcc04f584b32cd5bf633da8e3508249e339d

Author: Alejandro Piñeiro 
Date:   Wed Sep 30 13:39:30 2015 +0200

i965/vec4: Add unit tests for cmod propagation pass

This include the same tests coming from test_fs_cmod_propagation, (non
vector glsl types included) plus some new with vec4 types, inspired on
the regressions found while the optimization was a work in progress.

Additionally, the check of number of instructions after the
optimization was changed from EXPECT_EQ to ASSERT_EQ. This was done to
avoid a crash on failing tests that expected no optimization, as after
checking the number of instructions, there were some checks related to
this last instruction opcode/conditional mod.

v2: update tests after Matt Turner's review of the optimization pass
v3: tweaks on the tests (mostly on the comments), after Matt Turner's
review

Reviewed-by: Matt Turner 

---

 src/mesa/drivers/dri/i965/Makefile.am  |7 +
 .../dri/i965/test_vec4_cmod_propagation.cpp|  822 
 2 files changed, 829 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/Makefile.am 
b/src/mesa/drivers/dri/i965/Makefile.am
index 04b3f9c..9d003e4 100644
--- a/src/mesa/drivers/dri/i965/Makefile.am
+++ b/src/mesa/drivers/dri/i965/Makefile.am
@@ -59,6 +59,7 @@ TESTS = \
test_fs_saturate_propagation \
 test_eu_compact \
test_vf_float_conversions \
+   test_vec4_cmod_propagation \
 test_vec4_copy_propagation \
 test_vec4_register_coalesce
 
@@ -94,6 +95,12 @@ test_vec4_copy_propagation_LDADD = \
 $(top_builddir)/src/gtest/libgtest.la \
 $(TEST_LIBS)
 
+test_vec4_cmod_propagation_SOURCES = \
+   test_vec4_cmod_propagation.cpp
+test_vec4_cmod_propagation_LDADD = \
+   $(top_builddir)/src/gtest/libgtest.la \
+   $(TEST_LIBS)
+
 test_eu_compact_SOURCES = \
test_eu_compact.c
 nodist_EXTRA_test_eu_compact_SOURCES = dummy.cpp
diff --git a/src/mesa/drivers/dri/i965/test_vec4_cmod_propagation.cpp 
b/src/mesa/drivers/dri/i965/test_vec4_cmod_propagation.cpp
new file mode 100644
index 000..5ca697a
--- /dev/null
+++ b/src/mesa/drivers/dri/i965/test_vec4_cmod_propagation.cpp
@@ -0,0 +1,822 @@
+/*
+ * Copyright © 2015 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Based on test_fs_cmod_propagation.cpp
+ */
+
+#include 
+#include "brw_vec4.h"
+#include "brw_vec4_builder.h"
+#include "brw_cfg.h"
+#include "program/program.h"
+
+using namespace brw;
+
+class cmod_propagation_test : public ::testing::Test {
+   virtual void SetUp();
+
+public:
+   struct brw_compiler *compiler;
+   struct brw_device_info *devinfo;
+   struct gl_context *ctx;
+   struct gl_shader_program *shader_prog;
+   struct brw_vertex_program *vp;
+   vec4_visitor *v;
+};
+
+class cmod_propagation_vec4_visitor : public vec4_visitor
+{
+public:
+   cmod_propagation_vec4_visitor(struct brw_compiler *compiler,
+ nir_shader *shader)
+  : vec4_visitor(compiler, NULL, NULL, NULL, shader, NULL,
+ false, -1) {}
+
+protected:
+   /* Dummy implementation for pure virtual methods */
+   virtual dst_reg *make_reg_for_system_value(int location,
+  const glsl_type *type)
+   {
+  unreachable("Not reached");
+   }
+
+   virtual void setup_payload()
+   {
+  unreachable("Not reached");
+   }
+
+   virtual void emit_prolog()
+   {
+  unreachable("Not reached");
+   }
+
+   virtual void emit_program_code()
+   {
+  unreachable("Not reached");
+   }
+
+   virtual void emit_thread_end()
+   {
+  unreachable("Not reached");
+   }
+
+   virtual void emit_urb_write_header(int mrf)
+   {
+  unreachable("Not 

Mesa (master): i965/vec4: adding vec4_cmod_propagation optimization

2015-10-22 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 627f94b72e0e9443ad116f072599a7342269f297
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=627f94b72e0e9443ad116f072599a7342269f297

Author: Alejandro Piñeiro 
Date:   Mon Sep 28 17:00:19 2015 +0200

i965/vec4: adding vec4_cmod_propagation optimization

vec4 port of fs_cmod_propagation.

Shader-db results (no vec4 grepping):
total instructions in shared programs: 6240413 -> 6235841 (-0.07%)
instructions in affected programs: 401933 -> 397361 (-1.14%)
total loops in shared programs:1979 -> 1979 (0.00%)
helped:2265
HURT:  0

v2: remove extra space and combine two if blocks, as suggested by
Matt Turner
v3: add condition check to bail out if current inst and inst being
scanned has different writemask, as pointed by Matt Turner
v3: updated shader-db numbers
v4: remove block from foreach_inst_in_block_*_starting_from after
commit 801f151917fedb13c5c6e96281a18d833dd6901f

Reviewed-by: Matt Turner 

---

 src/mesa/drivers/dri/i965/Makefile.sources |1 +
 src/mesa/drivers/dri/i965/brw_vec4.cpp |1 +
 src/mesa/drivers/dri/i965/brw_vec4.h   |1 +
 .../drivers/dri/i965/brw_vec4_cmod_propagation.cpp |  157 
 4 files changed, 160 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/Makefile.sources 
b/src/mesa/drivers/dri/i965/Makefile.sources
index c2438bd..434583d 100644
--- a/src/mesa/drivers/dri/i965/Makefile.sources
+++ b/src/mesa/drivers/dri/i965/Makefile.sources
@@ -57,6 +57,7 @@ i965_compiler_FILES = \
brw_util.c \
brw_util.h \
brw_vec4_builder.h \
+   brw_vec4_cmod_propagation.cpp \
brw_vec4_copy_propagation.cpp \
brw_vec4.cpp \
brw_vec4_cse.cpp \
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index 3e7078d..c8923ef 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -1862,6 +1862,7 @@ vec4_visitor::run()
   OPT(dead_code_eliminate);
   OPT(dead_control_flow_eliminate, this);
   OPT(opt_copy_propagation);
+  OPT(opt_cmod_propagation);
   OPT(opt_cse);
   OPT(opt_algebraic);
   OPT(opt_register_coalesce);
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h 
b/src/mesa/drivers/dri/i965/brw_vec4.h
index d861b2e..89b6f91 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -149,6 +149,7 @@ public:
int var_range_start(unsigned v, unsigned n) const;
int var_range_end(unsigned v, unsigned n) const;
bool virtual_grf_interferes(int a, int b);
+   bool opt_cmod_propagation();
bool opt_copy_propagation(bool do_constant_prop = true);
bool opt_cse_local(bblock_t *block);
bool opt_cse();
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_cmod_propagation.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_cmod_propagation.cpp
new file mode 100644
index 000..329f242
--- /dev/null
+++ b/src/mesa/drivers/dri/i965/brw_vec4_cmod_propagation.cpp
@@ -0,0 +1,157 @@
+/*
+ * Copyright © 2015 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+
+/** @file brw_vec4_cmod_propagation.cpp
+ *
+ * Really similar to brw_fs_cmod_propagation but adapted to vec4 needs. Check
+ * brw_fs_cmod_propagation for further details on the rationale behind this
+ * optimization.
+ */
+
+#include "brw_vec4.h"
+#include "brw_cfg.h"
+
+namespace brw {
+
+static bool
+opt_cmod_propagation_local(bblock_t *block)
+{
+   bool progress = false;
+   int ip = block->end_ip + 1;
+
+   foreach_inst_in_block_reverse_safe(vec4_instruction, inst, block) {
+  ip--;
+
+  if ((inst->opcode != BRW_OPCODE_AND &&
+   inst->opcode != BRW_OPCODE_CMP &&
+   inst->opcode != BRW_OPCODE_MOV) ||
+  

Mesa (master): i965/vec4: print predicate control at brw_vec4 dump_instruction

2015-10-22 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 8cf84a7e470dbd3b46ce4081459d2ecfab22c2d5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8cf84a7e470dbd3b46ce4081459d2ecfab22c2d5

Author: Alejandro Piñeiro 
Date:   Fri Oct  9 18:39:42 2015 +0200

i965/vec4: print predicate control at brw_vec4 dump_instruction

v2: externalize pred_ctrl_align16 from brw_disasm.c instead of adding
a copy on brw_vec4.c, as suggested by Matt Turner

Reviewed-by: Matt Turner 

---

 src/mesa/drivers/dri/i965/brw_context.h |1 +
 src/mesa/drivers/dri/i965/brw_disasm.c  |2 +-
 src/mesa/drivers/dri/i965/brw_vec4.cpp  |5 +++--
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
b/src/mesa/drivers/dri/i965/brw_context.h
index 4f503ae..0fdc83e 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1680,6 +1680,7 @@ struct opcode_desc {
 
 extern const struct opcode_desc opcode_descs[128];
 extern const char * const conditional_modifier[16];
+extern const char *const pred_ctrl_align16[16];
 
 void
 brw_emit_depthbuffer(struct brw_context *brw);
diff --git a/src/mesa/drivers/dri/i965/brw_disasm.c 
b/src/mesa/drivers/dri/i965/brw_disasm.c
index db23a18..35cf99e 100644
--- a/src/mesa/drivers/dri/i965/brw_disasm.c
+++ b/src/mesa/drivers/dri/i965/brw_disasm.c
@@ -252,7 +252,7 @@ static const char *const pred_inv[2] = {
[1] = "-"
 };
 
-static const char *const pred_ctrl_align16[16] = {
+const char *const pred_ctrl_align16[16] = {
[1] = "",
[2] = ".x",
[3] = ".y",
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index c8923ef..71a5a44 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -1370,9 +1370,10 @@ vec4_visitor::dump_instruction(backend_instruction 
*be_inst, FILE *file)
vec4_instruction *inst = (vec4_instruction *)be_inst;
 
if (inst->predicate) {
-  fprintf(file, "(%cf0.%d) ",
+  fprintf(file, "(%cf0.%d%s) ",
   inst->predicate_inverse ? '-' : '+',
-  inst->flag_subreg);
+  inst->flag_subreg,
+  pred_ctrl_align16[inst->predicate]);
}
 
fprintf(file, "%s", brw_instruction_name(inst->opcode));

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


Mesa (master): i965/vec4: track and use independently each flag channel

2015-10-22 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: a59359ecd22154cc2b3f88bb8c599f21af8a3934
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a59359ecd22154cc2b3f88bb8c599f21af8a3934

Author: Alejandro Piñeiro 
Date:   Wed Oct 14 20:26:43 2015 +0200

i965/vec4: track and use independently each flag channel

vec4_live_variables tracks now each flag channel independently, so
vec4_dead_code_eliminate can update the writemask of null registers,
based on which component are alive at the moment. This would allow
vec4_cmod_propagation to optimize out several movs involving null
registers.

v2: added support to track each flag channel independently at vec4
live_variables, as v1 assumed that it was already doing it, as
pointed by Francisco Jerez
v3: general cleaningn after Matt Turner's review

Reviewed-by: Matt Turner 

---

 src/mesa/drivers/dri/i965/brw_ir_vec4.h|   21 +
 .../dri/i965/brw_vec4_dead_code_eliminate.cpp  |   31 ++--
 .../drivers/dri/i965/brw_vec4_live_variables.cpp   |   14 +
 3 files changed, 52 insertions(+), 14 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_ir_vec4.h 
b/src/mesa/drivers/dri/i965/brw_ir_vec4.h
index 1b57b65..74e9733 100644
--- a/src/mesa/drivers/dri/i965/brw_ir_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_ir_vec4.h
@@ -186,6 +186,27 @@ public:
   return predicate || opcode == VS_OPCODE_UNPACK_FLAGS_SIMD4X2;
}
 
+   bool reads_flag(unsigned c)
+   {
+  if (!reads_flag())
+ return false;
+
+  switch (predicate) {
+  case BRW_PREDICATE_NONE:
+ return false;
+  case BRW_PREDICATE_ALIGN16_REPLICATE_X:
+ return c == 0;
+  case BRW_PREDICATE_ALIGN16_REPLICATE_Y:
+ return c == 1;
+  case BRW_PREDICATE_ALIGN16_REPLICATE_Z:
+ return c == 2;
+  case BRW_PREDICATE_ALIGN16_REPLICATE_W:
+ return c == 3;
+  default:
+ return true;
+  }
+   }
+
bool writes_flag()
{
   return (conditional_mod && (opcode != BRW_OPCODE_SEL &&
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_dead_code_eliminate.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_dead_code_eliminate.cpp
index 8fc7a36..284e0a8 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_dead_code_eliminate.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_dead_code_eliminate.cpp
@@ -78,13 +78,19 @@ vec4_visitor::dead_code_eliminate()
  sizeof(BITSET_WORD));
 
   foreach_inst_in_block_reverse(vec4_instruction, inst, block) {
- if (inst->dst.file == GRF && !inst->has_side_effects()) {
+ if ((inst->dst.file == GRF && !inst->has_side_effects()) ||
+ (inst->dst.is_null() && inst->writes_flag())){
 bool result_live[4] = { false };
 
-for (unsigned i = 0; i < inst->regs_written; i++) {
-   for (int c = 0; c < 4; c++)
-  result_live[c] |= BITSET_TEST(
- live, var_from_reg(alloc, offset(inst->dst, i), c));
+if (inst->dst.file == GRF) {
+   for (unsigned i = 0; i < inst->regs_written; i++) {
+  for (int c = 0; c < 4; c++)
+ result_live[c] |= BITSET_TEST(
+live, var_from_reg(alloc, offset(inst->dst, i), c));
+   }
+} else {
+   for (unsigned c = 0; c < 4; c++)
+  result_live[c] = BITSET_TEST(flag_live, c);
 }
 
 /* If the instruction can't do writemasking, then it's all or
@@ -117,7 +123,11 @@ vec4_visitor::dead_code_eliminate()
  }
 
  if (inst->dst.is_null() && inst->writes_flag()) {
-if (!BITSET_TEST(flag_live, 0)) {
+bool combined_live = false;
+for (unsigned c = 0; c < 4; c++)
+   combined_live |= BITSET_TEST(flag_live, c);
+
+if (!combined_live) {
inst->opcode = BRW_OPCODE_NOP;
progress = true;
continue;
@@ -136,7 +146,8 @@ vec4_visitor::dead_code_eliminate()
  }
 
  if (inst->writes_flag()) {
-BITSET_CLEAR(flag_live, 0);
+for (unsigned c = 0; c < 4; c++)
+   BITSET_CLEAR(flag_live, c);
  }
 
  for (int i = 0; i < 3; i++) {
@@ -150,8 +161,10 @@ vec4_visitor::dead_code_eliminate()
 }
  }
 
- if (inst->reads_flag()) {
-BITSET_SET(flag_live, 0);
+ for (unsigned c = 0; c < 4; c++) {
+if (inst->reads_flag(c)) {
+   BITSET_SET(flag_live, c);
+}
  }
   }
}
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_live_variables.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_live_variables.cpp
index 6782379..aa9a657 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_live_variables.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_live_variables.cpp
@@ -86,9 +86,10 @@ vec4_live_variables::setup_def_use()
}
 

Mesa (master): i965/vec4: check swizzle before discarding a uniform on a 3src operand

2015-09-24 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 7fee23569b0e3a4d4636a83fb6751ee82987ec5f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7fee23569b0e3a4d4636a83fb6751ee82987ec5f

Author: Alejandro Piñeiro 
Date:   Wed Sep 23 19:22:17 2015 +0200

i965/vec4: check swizzle before discarding a uniform on a 3src operand

Without this commit, copy propagation is discarded if it involves
a uniform with an instruction that has 3 sources. But 3 sourced
instructions can access scalar values.

For example, this is what vec4_visitor::fix_3src_operand() is already
doing:

   if (src.file == UNIFORM && brw_is_single_value_swizzle(src.swizzle))
  return src;

Shader-db results (unfiltered) on NIR:
total instructions in shared programs: 6259650 -> 6241985 (-0.28%)
instructions in affected programs: 812755 -> 795090 (-2.17%)
helped:7930
HURT:  0

Shader-db results (unfiltered) on IR:
total instructions in shared programs: 6445822 -> 6441788 (-0.06%)
instructions in affected programs: 296630 -> 292596 (-1.36%)
helped:2533
HURT:  0

v2:
- Updated commit message, using Matt Turner suggestions
- Move the check after we've created the final value, as Jason
  Ekstrand suggested
- Clean up the condition

v3:
- Move the check back to the original place, to keep things
  tidy, as suggested by Jason Ekstrand

v4:
- Fixed missing is_single_value_swizzle() as pointed by Jason Ekstrand

Reviewed-by: Matt Turner 

---

 src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp |9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
index d3f0ddd..5b6444e 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
@@ -325,7 +325,11 @@ try_copy_propagate(const struct brw_device_info *devinfo,
inst->opcode == SHADER_OPCODE_GEN4_SCRATCH_WRITE)
   return false;
 
-   if (inst->is_3src() && value.file == UNIFORM)
+   unsigned composed_swizzle = brw_compose_swizzle(inst->src[arg].swizzle,
+   value.swizzle);
+   if (inst->is_3src() &&
+   value.file == UNIFORM &&
+   !brw_is_single_value_swizzle(composed_swizzle))
   return false;
 
if (inst->is_send_from_grf())
@@ -380,8 +384,7 @@ try_copy_propagate(const struct brw_device_info *devinfo,
if (inst->src[arg].negate)
   value.negate = !value.negate;
 
-   value.swizzle = brw_compose_swizzle(inst->src[arg].swizzle,
-   value.swizzle);
+   value.swizzle = composed_swizzle;
if (has_source_modifiers &&
value.type != inst->src[arg].type) {
   assert(can_change_source_types(inst));

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


Mesa (master): i965/vec4: refactor brw_vec4_copy_propagation.

2015-09-22 Thread Alejandro Pinheiro
Module: Mesa
Branch: master
Commit: 1bd89db921105dbe76047144b4719d4617aee1d8
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1bd89db921105dbe76047144b4719d4617aee1d8

Author: Alejandro Piñeiro 
Date:   Wed Sep 16 17:19:50 2015 +0200

i965/vec4: refactor brw_vec4_copy_propagation.

Now it is more similar to brw_fs_copy_propagation, with three
clear stages:

1) Build up the value we are propagating as if it were the source of a
single MOV:
2) Check that we can propagate that value
3) Build the final value

Previously everything was somewhat messed up, making the
implementation on some specific cases, like knowing if you can
propagate from a previous instruction even with type mismatches, even
messier (for example, with the need of maintaining more of one
has_source_modifiers). The refactoring clears stuff, and gives
support to this mentioned use case without doing anything extra
(for example, only one has_source_modifiers is used).

Shader-db results for vec4 programs on Haswell:
total instructions in shared programs: 1683842 -> 1669037 (-0.88%)
instructions in affected programs: 739837 -> 725032 (-2.00%)
helped:6237
HURT:  0

v2: using 'arg' index to get the from inst was wrong
v3: rebased against last change on the previous patch of the series
v4: don't need to track instructions on struct copy_entry, as we
only set the source on a direct copy
v5: change the approach for a refactoring
v6: tweaked comments

Reviewed-by: Jason Ekstrand 

---

 .../drivers/dri/i965/brw_vec4_copy_propagation.cpp |   32 +++-
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp 
b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
index 1522eea..d3f0ddd 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_copy_propagation.cpp
@@ -265,6 +265,9 @@ try_copy_propagate(const struct brw_device_info *devinfo,
vec4_instruction *inst,
int arg, struct copy_entry *entry)
 {
+   /* Build up the value we are propagating as if it were the source of a
+* single MOV
+*/
/* For constant propagation, we only handle the same constant
 * across all 4 channels.  Some day, we should handle the 8-bit
 * float vector format, which would let us constant propagate
@@ -291,9 +294,9 @@ try_copy_propagate(const struct brw_device_info *devinfo,
for (int i = 0; i < 4; i++) {
   s[i] = BRW_GET_SWZ(entry->value[i]->swizzle, i);
}
-   value.swizzle = brw_compose_swizzle(inst->src[arg].swizzle,
-   BRW_SWIZZLE4(s[0], s[1], s[2], s[3]));
+   value.swizzle = BRW_SWIZZLE4(s[0], s[1], s[2], s[3]);
 
+   /* Check that we can propagate that value */
if (value.file != UNIFORM &&
value.file != GRF &&
value.file != ATTR)
@@ -304,13 +307,6 @@ try_copy_propagate(const struct brw_device_info *devinfo,
   return false;
}
 
-   if (inst->src[arg].abs) {
-  value.negate = false;
-  value.abs = true;
-   }
-   if (inst->src[arg].negate)
-  value.negate = !value.negate;
-
bool has_source_modifiers = value.negate || value.abs;
 
/* gen6 math and gen7+ SENDs from GRFs ignore source modifiers on
@@ -376,19 +372,27 @@ try_copy_propagate(const struct brw_device_info *devinfo,
   }
}
 
+   /* Build the final value */
+   if (inst->src[arg].abs) {
+  value.negate = false;
+  value.abs = true;
+   }
+   if (inst->src[arg].negate)
+  value.negate = !value.negate;
+
+   value.swizzle = brw_compose_swizzle(inst->src[arg].swizzle,
+   value.swizzle);
if (has_source_modifiers &&
value.type != inst->src[arg].type) {
-  /* We are propagating source modifiers from a MOV with a different
-   * type.  If we got here, then we can just change the source and
-   * destination types of the instruction and keep going.
-   */
   assert(can_change_source_types(inst));
   for (int i = 0; i < 3; i++) {
  inst->src[i].type = value.type;
   }
   inst->dst.type = value.type;
-   } else
+   } else {
   value.type = inst->src[arg].type;
+   }
+
inst->src[arg] = value;
return true;
 }

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


  1   2   >