Re: [Mesa-dev] [PATCH v2 13/21] nir/linker: Add gl_nir_link_uniforms()

2018-06-05 Thread Timothy Arceri



On 12/05/18 19:40, Alejandro Piñeiro wrote:

From: Eduardo Lima Mitev 

This function will be the entry point for linking the uniforms from
the nir_shader objects associated with the gl_linked_shaders of a
program.

This patch includes initial support for linking uniforms from NIR
shaders. It is tailored for the ARB_gl_spirv needs, and it is far from
complete, but it should handle most cases of uniforms, array
uniforms, structs, samplers and images.

There are some FIXMEs related to specific features that will be
implemented in following patches, like atomic counters, UBOs and
SSBOs.

Also, note that ARB_gl_spirv makes mandatory explicit location for
normal uniforms, so this code only handles uniforms with explicit
location. But there are cases, like uniform atomic counters, that
doesn't have a location from the OpenGL point of view (they have a
binding), but that Mesa assign internally a location. That will be
handled on following patches.

A nir_linker.h file is also added. More NIR-linking related API will
be added in subsequent patches and those will include stuff from Mesa,
so reusing nir.h didn't seem a good idea.

v2: move from compiler/nir to compiler/glsl (Timothy Arceri)

Signed-off-by: Eduardo Lima 
Signed-off-by: Neil Roberts 
---
  src/compiler/Makefile.sources|   2 +
  src/compiler/glsl/gl_nir_link_uniforms.c | 460 +++
  src/compiler/glsl/gl_nir_linker.h|  41 +++
  src/compiler/glsl/meson.build|   2 +
  4 files changed, 505 insertions(+)
  create mode 100644 src/compiler/glsl/gl_nir_link_uniforms.c
  create mode 100644 src/compiler/glsl/gl_nir_linker.h

diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources
index 96af23fcd2c..ee2a25d53ac 100644
--- a/src/compiler/Makefile.sources
+++ b/src/compiler/Makefile.sources
@@ -28,6 +28,8 @@ LIBGLSL_FILES = \
glsl/gl_nir_lower_atomics.c \
glsl/gl_nir_lower_samplers.c \
glsl/gl_nir_lower_samplers_as_deref.c \
+   glsl/gl_nir_link_uniforms.c \
+   glsl/gl_nir_linker.h \
glsl/gl_nir.h \
glsl/glsl_parser_extras.cpp \
glsl/glsl_parser_extras.h \
diff --git a/src/compiler/glsl/gl_nir_link_uniforms.c 
b/src/compiler/glsl/gl_nir_link_uniforms.c
new file mode 100644
index 000..a8ebde73270
--- /dev/null
+++ b/src/compiler/glsl/gl_nir_link_uniforms.c
@@ -0,0 +1,460 @@
+/*
+ * Copyright © 2018 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.h"
+#include "gl_nir_linker.h"
+#include "compiler/glsl/ir_uniform.h" /* for gl_uniform_storage */
+#include "linker_util.h"
+#include "main/context.h"
+#include "main/mtypes.h"
+
+/* This file do the common link for GLSL uniforms, using NIR, instead of IR as
+ * the counter-part glsl/link_uniforms.cpp
+ *
+ * Also note that this is tailored for ARB_gl_spirv needs and particularities
+ * (like need to work/link without name available, explicit location for
+ * normal uniforms as mandatory, and so on).
+ */
+
+static void
+nir_setup_uniform_remap_tables(struct gl_context *ctx,
+   struct gl_shader_program *prog)
+{
+   prog->UniformRemapTable = rzalloc_array(prog,
+   struct gl_uniform_storage *,
+   prog->NumUniformRemapTable);
+   union gl_constant_value *data =
+  rzalloc_array(prog->data,
+union gl_constant_value, prog->data->NumUniformDataSlots);
+   if (!prog->UniformRemapTable || !data) {
+  linker_error(prog, "Out of memory during linking.\n");
+  return;
+   }
+   prog->data->UniformDataSlots = data;
+
+   unsigned data_pos = 0;
+
+   /* Reserve all the explicit locations of the active uniforms. */
+   for (unsigned i = 0; i < prog->data->NumUniformStorage; i++) {
+  struct gl_uniform_storage *uniform = >data->UniformStorage[i];
+
+  

Re: [Mesa-dev] [PATCH v2 11/21] spirv: Set nir_variable->explicit_binding

2018-06-05 Thread Timothy Arceri

Seems reasonable.

Reviewed-by: Timothy Arceri 

On 12/05/18 19:40, Alejandro Piñeiro wrote:

From: Neil Roberts 

When SpvDecorationBinding is encountered in the SPIR-V source it now
sets explicit_binding on the nir_variable. This will be used to
determine whether to initialise sampler and image uniforms with the
binding value.
---
  src/compiler/spirv/vtn_private.h   | 1 +
  src/compiler/spirv/vtn_variables.c | 2 ++
  2 files changed, 3 insertions(+)

diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h
index 98bec389fcd..5fc34f43809 100644
--- a/src/compiler/spirv/vtn_private.h
+++ b/src/compiler/spirv/vtn_private.h
@@ -452,6 +452,7 @@ struct vtn_variable {
  
 unsigned descriptor_set;

 unsigned binding;
+   bool explicit_binding;
 unsigned input_attachment_index;
 bool patch;
  
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c

index 6d1eede5ed0..902b2373015 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -1503,6 +1503,7 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value 
*val, int member,
 switch (dec->decoration) {
 case SpvDecorationBinding:
vtn_var->binding = dec->literals[0];
+  vtn_var->explicit_binding = true;
return;
 case SpvDecorationDescriptorSet:
vtn_var->descriptor_set = dec->literals[0];
@@ -1926,6 +1927,7 @@ vtn_create_variable(struct vtn_builder *b, struct 
vtn_value *val,
 * for these. We should fix that.
 */
var->var->data.binding = var->binding;
+  var->var->data.explicit_binding = var->explicit_binding;
var->var->data.descriptor_set = var->descriptor_set;
var->var->data.index = var->input_attachment_index;
  


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


Re: [Mesa-dev] [PATCH v2 10/21] anv/nir: Use nir_variable's type if interface_type is null

2018-06-05 Thread Timothy Arceri



On 12/05/18 19:40, Alejandro Piñeiro wrote:

From: Eduardo Lima Mitev 

Previous patch 'spirv: Get rid of vtn_variable_mode_image/sampler'
made possible that interface_type of image/sampler nir_variable may be
null. This patch accounts for it and make use of the type of the
variable instead of the interface_type.

This prevents a number of crash regressions in Vulkan tests.

Signed-off-by: Eduardo Lima 
Signed-off-by: Neil Roberts 
---
  src/intel/vulkan/anv_nir_apply_pipeline_layout.c | 7 +--
  1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/intel/vulkan/anv_nir_apply_pipeline_layout.c 
b/src/intel/vulkan/anv_nir_apply_pipeline_layout.c
index d5a08f712f1..25e892a676d 100644
--- a/src/intel/vulkan/anv_nir_apply_pipeline_layout.c
+++ b/src/intel/vulkan/anv_nir_apply_pipeline_layout.c
@@ -427,10 +427,13 @@ anv_nir_apply_pipeline_layout(struct anv_pipeline 
*pipeline,
 }
  
 nir_foreach_variable(var, >uniforms) {

-  if (!glsl_type_is_image(var->interface_type))
+  const struct glsl_type *glsl_type = (var->interface_type ?
+   var->interface_type :
+   glsl_without_array(var->type));


glsl_get_sampler_dim() contains the following:

   assert(glsl_type_is_sampler(type) || glsl_type_is_image(type));

Which leads me to believe the code above should just be:

const struct glsl_type *glsl_type = glsl_without_array(var->type);

If you agree please squash this patch into the previous patch where you 
can keep my r-b.



+  if (!glsl_type_is_image(glsl_type))
   continue;
  
-  enum glsl_sampler_dim dim = glsl_get_sampler_dim(var->interface_type);

+  enum glsl_sampler_dim dim = glsl_get_sampler_dim(glsl_type);
  
const uint32_t set = var->data.descriptor_set;

const uint32_t binding = var->data.binding;


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


Re: [Mesa-dev] [PATCH v2 09/21] spirv: Get rid of vtn_variable_mode_image/sampler

2018-06-05 Thread Timothy Arceri

Looks ok to me.

Reviewed-by: Timothy Arceri 

On 12/05/18 19:40, Alejandro Piñeiro wrote:

From: Neil Roberts 

vtn_variable_mode_image and _sampler are instead replaced with
vtn_variable_mode_uniform which encompasses both of them. In the few
places where it was neccessary to distinguish between the two, the
GLSL type of the pointer is used instead.

The main reason to do this is that on OpenGL it is permitted to put
images and samplers into structs and declare a uniform with them. That
means that variables can now have a mix of uniform, sampler and image
modes so picking a single one of those modes for a variable no longer
makes sense.

This fixes OpLoad on a sampler within a struct which was previously
using the variable mode to determine whether it was a sampler or not.
The type of the variable is a struct so it was not being considered to
be uniform mode even though the member being loaded should be sampler
mode.

Signed-off-by: Eduardo Lima 
Signed-off-by: Neil Roberts 
---
  src/compiler/spirv/spirv_to_nir.c  |  4 ++--
  src/compiler/spirv/vtn_cfg.c   |  4 ++--
  src/compiler/spirv/vtn_private.h   |  2 --
  src/compiler/spirv/vtn_variables.c | 43 +++---
  4 files changed, 16 insertions(+), 37 deletions(-)

diff --git a/src/compiler/spirv/spirv_to_nir.c 
b/src/compiler/spirv/spirv_to_nir.c
index 78437428aa7..7d4fbbc1909 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -3722,10 +3722,10 @@ vtn_handle_body_instruction(struct vtn_builder *b, 
SpvOp opcode,
 case SpvOpImageQuerySize: {
struct vtn_pointer *image =
   vtn_value(b, w[3], vtn_value_type_pointer)->pointer;
-  if (image->mode == vtn_variable_mode_image) {
+  if (glsl_type_is_image(image->type->type)) {
   vtn_handle_image(b, opcode, w, count);
} else {
- vtn_assert(image->mode == vtn_variable_mode_sampler);
+ vtn_assert(glsl_type_is_sampler(image->type->type));
   vtn_handle_texture(b, opcode, w, count);
}
break;
diff --git a/src/compiler/spirv/vtn_cfg.c b/src/compiler/spirv/vtn_cfg.c
index e7d2f9ea614..2c3bf698cc2 100644
--- a/src/compiler/spirv/vtn_cfg.c
+++ b/src/compiler/spirv/vtn_cfg.c
@@ -124,10 +124,10 @@ vtn_cfg_handle_prepass_instruction(struct vtn_builder *b, 
SpvOp opcode,
  without_array = without_array->array_element;
  
   if (glsl_type_is_image(without_array->type)) {

-vtn_var->mode = vtn_variable_mode_image;
+vtn_var->mode = vtn_variable_mode_uniform;
  param->interface_type = without_array->type;
   } else if (glsl_type_is_sampler(without_array->type)) {
-vtn_var->mode = vtn_variable_mode_sampler;
+vtn_var->mode = vtn_variable_mode_uniform;
  param->interface_type = without_array->type;
   } else {
  vtn_var->mode = vtn_variable_mode_param;
diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h
index 183024e14f4..98bec389fcd 100644
--- a/src/compiler/spirv/vtn_private.h
+++ b/src/compiler/spirv/vtn_private.h
@@ -406,8 +406,6 @@ enum vtn_variable_mode {
 vtn_variable_mode_ubo,
 vtn_variable_mode_ssbo,
 vtn_variable_mode_push_constant,
-   vtn_variable_mode_image,
-   vtn_variable_mode_sampler,
 vtn_variable_mode_workgroup,
 vtn_variable_mode_input,
 vtn_variable_mode_output,
diff --git a/src/compiler/spirv/vtn_variables.c 
b/src/compiler/spirv/vtn_variables.c
index eb8a9ca0084..6d1eede5ed0 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -1544,9 +1544,7 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value 
*val, int member,
   vtn_var->mode == vtn_variable_mode_output) {
   is_vertex_input = false;
   location += vtn_var->patch ? VARYING_SLOT_PATCH0 : VARYING_SLOT_VAR0;
-  } else if (vtn_var->mode != vtn_variable_mode_uniform &&
- vtn_var->mode != vtn_variable_mode_sampler &&
- vtn_var->mode != vtn_variable_mode_image) {
+  } else if (vtn_var->mode != vtn_variable_mode_uniform) {
   vtn_warn("Location must be on input, output, uniform, sampler or "
"image variable");
   return;
@@ -1624,12 +1622,7 @@ vtn_storage_class_to_mode(struct vtn_builder *b,
nir_mode = 0;
break;
 case SpvStorageClassUniformConstant:
-  if (glsl_type_is_image(interface_type->type))
- mode = vtn_variable_mode_image;
-  else if (glsl_type_is_sampler(interface_type->type))
- mode = vtn_variable_mode_sampler;
-  else
- mode = vtn_variable_mode_uniform;
+  mode = vtn_variable_mode_uniform;
nir_mode = nir_var_uniform;
break;
 case SpvStorageClassPushConstant:
@@ -1772,11 +1765,11 @@ vtn_create_variable(struct vtn_builder *b, struct 
vtn_value *val,
 case vtn_variable_mode_ssbo:

Re: [Mesa-dev] [PATCH v2 07/21] nir/types: Add a utility wrapper to glsl_type::sampler_index()

2018-06-05 Thread Timothy Arceri

Reviewed-by: Timothy Arceri 

On 12/05/18 19:40, Alejandro Piñeiro wrote:

From: Eduardo Lima Mitev 

I think it is more accurate to call it a sampler target (?).
---
  src/compiler/nir_types.cpp | 7 +++
  src/compiler/nir_types.h   | 1 +
  2 files changed, 8 insertions(+)

diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp
index 51ca797497e..d2b2a93b207 100644
--- a/src/compiler/nir_types.cpp
+++ b/src/compiler/nir_types.cpp
@@ -150,6 +150,13 @@ glsl_get_sampler_result_type(const struct glsl_type *type)
 return (glsl_base_type)type->sampled_type;
  }
  
+unsigned

+glsl_get_sampler_target(const struct glsl_type *type)
+{
+   assert(glsl_type_is_sampler(type));
+   return type->sampler_index();
+}
+
  unsigned
  glsl_get_record_location_offset(const struct glsl_type *type,
  unsigned length)
diff --git a/src/compiler/nir_types.h b/src/compiler/nir_types.h
index 9c81980042f..1107cfd73f2 100644
--- a/src/compiler/nir_types.h
+++ b/src/compiler/nir_types.h
@@ -80,6 +80,7 @@ const char *glsl_get_struct_elem_name(const struct glsl_type 
*type,
  
  enum glsl_sampler_dim glsl_get_sampler_dim(const struct glsl_type *type);

  enum glsl_base_type glsl_get_sampler_result_type(const struct glsl_type 
*type);
+unsigned glsl_get_sampler_target(const struct glsl_type *type);
  
  unsigned glsl_get_record_location_offset(const struct glsl_type *type,

   unsigned length);


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


Re: [Mesa-dev] [PATCH v2 05/21] nir/lower_samplers: Limit assert to GLSL shader programs

2018-06-05 Thread Timothy Arceri
I guess this will need to be rewritten with all the deref stuff almost 
ready to land. If you manage to get this stuff in before then you can 
have a:


Reviewed-by: Timothy Arceri 

On 12/05/18 19:40, Alejandro Piñeiro wrote:

From: Eduardo Lima Mitev 

Vulkan has the concept of separate image and sampler objects in the
SPIR-V code whereas GL conflates them into one. nir_lower_samplers
contains an assert to verify that sampler operand is not being set on
the nir instruction. However when the code comes from spirv_to_nir the
sampler operand is always set. GL_arb_gl_spirv explicitly states that
OpTypeSampler is not supported so it retains the GL behaviour of not
being able to seperate them. Therefore the sampler will always be the
same as the texture. This GL version of the lowering code ignores
instr->sampler and sets instr->sampler_index to the same value as
instr->texture_index. Some other places in the code (such as in
nir_print) assume that once the instruction is lowered then both
instr->texture and instr->sampler will be NULL, so to keep this
behaviour we now set instr->sampler to NULL after ignoring it to fill
in instr->sampler_index.

Signed-off-by: Eduardo Lima 
Signed-off-by: Neil Roberts 
---
  src/compiler/glsl/gl_nir_lower_samplers.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/compiler/glsl/gl_nir_lower_samplers.c 
b/src/compiler/glsl/gl_nir_lower_samplers.c
index a53fabb7e62..c54455f91de 100644
--- a/src/compiler/glsl/gl_nir_lower_samplers.c
+++ b/src/compiler/glsl/gl_nir_lower_samplers.c
@@ -93,7 +93,7 @@ lower_sampler(nir_tex_instr *instr, const struct 
gl_shader_program *shader_progr
return false;
  
 /* In GLSL, we only fill out the texture field.  The sampler is inferred */

-   assert(instr->sampler == NULL);
+   assert(instr->sampler == NULL || shader_program->data->spirv);
  
 instr->texture_index = 0;

 unsigned location = instr->texture->var->data.location;
@@ -125,6 +125,7 @@ lower_sampler(nir_tex_instr *instr, const struct 
gl_shader_program *shader_progr
 instr->sampler_index = instr->texture_index;
  
 instr->texture = NULL;

+   nir_instr_rewrite_deref(>instr, >sampler, NULL);
  
 return true;

  }


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


Re: [Mesa-dev] [PATCH v2 02/21] i965: use gl_shader_program_data::spirv

2018-06-05 Thread Timothy Arceri

I still dislike the idea of this bool but in the name of progress.

Patches 1-2 are:

Reviewed-by: Timothy Arceri 

On 12/05/18 19:40, Alejandro Piñeiro wrote:

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

diff --git a/src/mesa/drivers/dri/i965/brw_program.c 
b/src/mesa/drivers/dri/i965/brw_program.c
index fc77926d6e0..39c2d2a3581 100644
--- a/src/mesa/drivers/dri/i965/brw_program.c
+++ b/src/mesa/drivers/dri/i965/brw_program.c
@@ -77,7 +77,7 @@ brw_create_nir(struct brw_context *brw,
  
 /* First, lower the GLSL/Mesa IR or SPIR-V to NIR */

 if (shader_prog) {
-  if (shader_prog->_LinkedShaders[stage]->spirv_data)
+  if (shader_prog->data->spirv)
   nir = _mesa_spirv_to_nir(ctx, shader_prog, stage, options);
else
   nir = glsl_to_nir(shader_prog, stage, options);


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


Re: [Mesa-dev] [PATCH] glcpp: Sync line number for macro

2018-06-05 Thread Timothy Arceri

There aren't to many people familiar with this part of the compiler.

CCing Ian and Ken in case they missed this patch.


On 29/05/18 04:21, zhaowei yuan wrote:

Line number of a predefined macro should be set
as where it is referenced rather than declared

Signed-off-by: zhaowei yuan 
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106590
---
  src/compiler/glsl/glcpp/glcpp-lex.l   |  1 +
  src/compiler/glsl/glcpp/glcpp-parse.y | 55 ++-
  src/compiler/glsl/glcpp/glcpp.h   |  4 ++-
  src/compiler/glsl/glcpp/pp.c  |  3 +-
  4 files changed, 54 insertions(+), 9 deletions(-)

diff --git a/src/compiler/glsl/glcpp/glcpp-lex.l 
b/src/compiler/glsl/glcpp/glcpp-lex.l
index 9cfcc12..86b82c2 100644
--- a/src/compiler/glsl/glcpp/glcpp-lex.l
+++ b/src/compiler/glsl/glcpp/glcpp-lex.l
@@ -50,6 +50,7 @@ void glcpp_set_column (int  column_no , yyscan_t yyscanner);
yylloc->first_line = yylloc->last_line = yylineno;\
yycolumn += yyleng; \
yylloc->last_column = yycolumn + 1;  \
+   yylloc->position = (yytext - 
YY_CURRENT_BUFFER_LVALUE->yy_ch_buf); \
parser->has_new_line_number = 0; \
parser->has_new_source_number = 0;   \
} while(0);
diff --git a/src/compiler/glsl/glcpp/glcpp-parse.y 
b/src/compiler/glsl/glcpp/glcpp-parse.y
index ccb3aa1..68f8477 100644
--- a/src/compiler/glsl/glcpp/glcpp-parse.y
+++ b/src/compiler/glsl/glcpp/glcpp-parse.y
@@ -1021,7 +1021,7 @@ _token_list_append_list(token_list_t *list, token_list_t 
*tail)
  }
  
  static token_list_t *

-_token_list_copy(glcpp_parser_t *parser, token_list_t *other)
+_token_list_copy(glcpp_parser_t *parser, token_list_t *other, token_node_t 
*macro_node)
  {
 token_list_t *copy;
 token_node_t *node;
@@ -1033,6 +1033,12 @@ _token_list_copy(glcpp_parser_t *parser, token_list_t 
*other)
 for (node = other->head; node; node = node->next) {
token_t *new_token = linear_alloc_child(parser->linalloc, 
sizeof(token_t));
*new_token = *node->token;
+
+  if(macro_node) {
+ new_token->location.first_line = 
macro_node->token->location.first_line;
+ new_token->location.last_line = macro_node->token->location.last_line;
+  }
+
_token_list_append (parser, copy, new_token);
 }
  
@@ -1349,7 +1355,7 @@ add_builtin_define(glcpp_parser_t *parser, const char *name, int value)
  
  glcpp_parser_t *

  glcpp_parser_create(const struct gl_extensions *extension_list,
-glcpp_extension_iterator extensions, void *state, gl_api 
api)
+glcpp_extension_iterator extensions, void *state, gl_api 
api, const char *input)
  {
 glcpp_parser_t *parser;
  
@@ -1377,6 +1383,11 @@ glcpp_parser_create(const struct gl_extensions *extension_list,

 parser->lex_from_list = NULL;
 parser->lex_from_node = NULL;
  
+   parser->input = _mesa_string_buffer_create(parser, strlen(input) + 1);

+   strcpy(parser->input->buf, input);
+   parser->input->buf[strlen(input)] = '\0';
+   parser->input->length = strlen(input);
+
 parser->output = _mesa_string_buffer_create(parser,
 INITIAL_PP_OUTPUT_BUF_SIZE);
 parser->info_log = _mesa_string_buffer_create(parser,
@@ -1441,7 +1452,7 @@ typedef enum function_status
  static function_status_t
  _arguments_parse(glcpp_parser_t *parser,
   argument_list_t *arguments, token_node_t *node,
- token_node_t **last)
+ token_node_t **last, int *end_position)
  {
 token_list_t *argument;
 int paren_count;
@@ -1465,8 +1476,10 @@ _arguments_parse(glcpp_parser_t *parser,
   paren_count++;
} else if (node->token->type == ')') {
   paren_count--;
- if (paren_count == 0)
+ if (paren_count == 0) {
+*end_position = node->token->location.position;
  break;
+ }
}
  
if (node->token->type == ',' && paren_count == 1) {

@@ -1702,6 +1715,28 @@ _glcpp_parser_apply_pastes(glcpp_parser_t *parser, 
token_list_t *list)
 list->non_space_tail = list->tail;
  }
  
+static int

+_glcpp_parser_get_line(glcpp_parser_t *parser, int offset)
+{
+   int line = 1;
+   int i;
+
+   for(i = 0; parser->input->buf[i] && i <= offset; i++) {
+  if(parser->input->buf[i] == '\n' || parser->input->buf[i] == '\r')
+ line++;
+   }
+
+   return line;
+}
+
+static void
+_glcpp_sync_location(glcpp_parser_t *parser, token_t *token, token_t 
*macro_token)
+{
+   token->location.source = macro_token->location.source;
+   token->location.first_line = _glcpp_parser_get_line(parser, 
token->location.position);
+   token->location.last_line = token->location.first_line;
+}
+
  /* This is a helper function that's essentially part of the
   * implementation of 

Re: [Mesa-dev] [PATCH] glsl: Take 'double' as reserved after GLSL ES 1.0

2018-06-05 Thread Ian Romanick
Reviewed-by: Ian Romanick 

On 06/04/2018 02:33 PM, zhaowei yuan wrote:
> GLSL ES 1.0.17 specifies that "double" is a keyword reserved
> 
> Signed-off-by: zhaowei yuan 
> ---
>  src/compiler/glsl/glsl_lexer.ll | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/compiler/glsl/glsl_lexer.ll b/src/compiler/glsl/glsl_lexer.ll
> index b7cf100..de6dc64 100644
> --- a/src/compiler/glsl/glsl_lexer.ll
> +++ b/src/compiler/glsl/glsl_lexer.ll
> @@ -600,7 +600,7 @@ external  KEYWORD(110, 100, 0, 0, EXTERNAL);
>  interfaceKEYWORD(110, 100, 0, 0, INTERFACE);
>  long KEYWORD(110, 100, 0, 0, LONG_TOK);
>  shortKEYWORD(110, 100, 0, 0, SHORT_TOK);
> -double   TYPE_WITH_ALT(130, 300, 130, 300, 
> yyextra->ARB_gpu_shader_fp64_enable, glsl_type::double_type);
> +double   TYPE_WITH_ALT(130, 100, 130, 300, 
> yyextra->ARB_gpu_shader_fp64_enable, glsl_type::double_type);
>  half KEYWORD(110, 100, 0, 0, HALF);
>  fixedKEYWORD(110, 100, 0, 0, FIXED_TOK);
>  unsigned KEYWORD(110, 100, 0, 0, UNSIGNED);
> 

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


[Mesa-dev] [Bug 106823] Failed to recongnize keyword of shader code

2018-06-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106823

--- Comment #5 from Zhaowei Yuan  ---
patch has been posted here:
https://patchwork.freedesktop.org/patch/227593/
please review it

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


Re: [Mesa-dev] [PATCH] intel/eu: Use a struct copy instead of a memcpy

2018-06-05 Thread Matt Turner
Reviewed-by: Matt Turner 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 106810] ProgramBinary does not switch program correctly when using transform feedback

2018-06-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106810

Timothy Arceri  changed:

   What|Removed |Added

  Component|Drivers/DRI/i965|Mesa core
 QA Contact|intel-3d-bugs@lists.freedes |mesa-dev@lists.freedesktop.
   |ktop.org|org
   Assignee|intel-3d-bugs@lists.freedes |mesa-dev@lists.freedesktop.
   |ktop.org|org

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


[Mesa-dev] [PATCH] amd/common: Fix number of coords for getlod.

2018-06-05 Thread Bas Nieuwenhuizen
The LLVM 6 code reduced it to a non-array call. We need to do that
with the new code too.

This fixes dEQP-VK.glsl.texture_functions.query.texturequerylod.*array* for 
radv.

Fixes: a9a79934412 "amd/common: use the dimension-aware image intrinsics on 
LLVM 7+"
---
 src/amd/common/ac_llvm_build.c | 21 ++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
index a686b72287b..4052488f03a 100644
--- a/src/amd/common/ac_llvm_build.c
+++ b/src/amd/common/ac_llvm_build.c
@@ -1662,6 +1662,7 @@ LLVMValueRef ac_build_image_opcode(struct ac_llvm_context 
*ctx,
unsigned num_overloads = 0;
LLVMValueRef args[18];
unsigned num_args = 0;
+   enum ac_image_dim dim = a->dim;
 
assert(!a->lod || a->lod == ctx->i32_0 || a->lod == ctx->f32_0 ||
   !a->level_zero);
@@ -1681,6 +1682,20 @@ LLVMValueRef ac_build_image_opcode(struct 
ac_llvm_context *ctx,
if (HAVE_LLVM < 0x0700)
return ac_build_image_opcode_llvm6(ctx, a);
 
+   if (a->opcode == ac_image_get_lod) {
+   switch (dim) {
+   case ac_image_1darray:
+   dim = ac_image_1d;
+   break;
+   case ac_image_2darray:
+   case ac_image_cube:
+   dim = ac_image_2d;
+   break;
+   default:
+   break;
+   }
+   }
+
bool sample = a->opcode == ac_image_sample ||
  a->opcode == ac_image_gather4 ||
  a->opcode == ac_image_get_lod;
@@ -1706,13 +1721,13 @@ LLVMValueRef ac_build_image_opcode(struct 
ac_llvm_context *ctx,
if (a->compare)
args[num_args++] = ac_to_float(ctx, a->compare);
if (a->derivs[0]) {
-   unsigned count = ac_num_derivs(a->dim);
+   unsigned count = ac_num_derivs(dim);
for (unsigned i = 0; i < count; ++i)
args[num_args++] = ac_to_float(ctx, a->derivs[i]);
overload[num_overloads++] = ".f32";
}
unsigned num_coords =
-   a->opcode != ac_image_get_resinfo ? ac_num_coords(a->dim) : 0;
+   a->opcode != ac_image_get_resinfo ? ac_num_coords(dim) : 0;
for (unsigned i = 0; i < num_coords; ++i)
args[num_args++] = LLVMBuildBitCast(ctx->builder, a->coords[i], 
coord_type, "");
if (a->lod)
@@ -1751,7 +1766,7 @@ LLVMValueRef ac_build_image_opcode(struct ac_llvm_context 
*ctx,
}
 
const char *dimname;
-   switch (a->dim) {
+   switch (dim) {
case ac_image_1d: dimname = "1d"; break;
case ac_image_2d: dimname = "2d"; break;
case ac_image_3d: dimname = "3d"; break;
-- 
2.17.0

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


[Mesa-dev] [Bug 106774] GLSL IR copy propagates loads of SSBOs

2018-06-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106774

--- Comment #9 from Jason Ekstrand  ---
(In reply to Ian Romanick from comment #8)
> (In reply to Ian Romanick from comment #7)
> > (In reply to Jason Ekstrand from comment #6)
> > > Also, please turn your test case there into a piglit test.  Extra points 
> > > if
> > > it's a CTS test so we force everyone else to be correct too. :-)
> > 
> > I'm not sure if you looked at it, but it is a piglit shader_runner test. 
> > The current failure mode is many (recoverable) GPU hangs.

I figured.  What other kind of simple shader test is there?  That was more of a
"Once you fix it, please commit to piglit".

> Which I should point out are caused by infinite loops in the shader... not
> some other problem. :)

Those are very good source of hangs.  They're actually debuggable. :)

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


[Mesa-dev] [Bug 106774] GLSL IR copy propagates loads of SSBOs

2018-06-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106774

--- Comment #8 from Ian Romanick  ---
(In reply to Ian Romanick from comment #7)
> (In reply to Jason Ekstrand from comment #6)
> > Also, please turn your test case there into a piglit test.  Extra points if
> > it's a CTS test so we force everyone else to be correct too. :-)
> 
> I'm not sure if you looked at it, but it is a piglit shader_runner test. 
> The current failure mode is many (recoverable) GPU hangs.

Which I should point out are caused by infinite loops in the shader... not some
other problem. :)

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


[Mesa-dev] [Bug 106774] GLSL IR copy propagates loads of SSBOs

2018-06-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106774

--- Comment #7 from Ian Romanick  ---
(In reply to Jason Ekstrand from comment #6)
> Also, please turn your test case there into a piglit test.  Extra points if
> it's a CTS test so we force everyone else to be correct too. :-)

I'm not sure if you looked at it, but it is a piglit shader_runner test.  The
current failure mode is many (recoverable) GPU hangs.

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


[Mesa-dev] [Bug 106774] GLSL IR copy propagates loads of SSBOs

2018-06-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106774

--- Comment #6 from Jason Ekstrand  ---
Also, please turn your test case there into a piglit test.  Extra points if
it's a CTS test so we force everyone else to be correct too. :-)

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


[Mesa-dev] [Bug 106774] GLSL IR copy propagates loads of SSBOs

2018-06-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106774

--- Comment #5 from Jason Ekstrand  ---
I'd be a fan of just making GLSL IR bail in copy propagation of anything that
isn't a local, global, or uniform.  We could try to make it smart enough to
handle barriers correctly with SSBOs and shared variables but that's very hard
to get right.

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


[Mesa-dev] [Bug 106774] GLSL IR copy propagates loads of SSBOs

2018-06-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106774

--- Comment #4 from Ilia Mirkin  ---
(In reply to Ian Romanick from comment #3)
> (In reply to Ilia Mirkin from comment #2)
> > Are you sure that's illegal? I'd imagine that you'd need that variable to be
> > marked as coherent, or to introduce a compiler barrier somehow.
> 
> Legality isn't really relevant.  The shader source contains one instance of
> a very, very expensive operation, and we decide to do it four times.  That's
> unacceptable.

Oh wait. I totally misread. Copy propagate. And it does so ACROSS an atomic, no
less! That's definitely broken

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


[Mesa-dev] [Bug 106774] GLSL IR copy propagates loads of SSBOs

2018-06-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106774

--- Comment #3 from Ian Romanick  ---
(In reply to Ilia Mirkin from comment #2)
> Are you sure that's illegal? I'd imagine that you'd need that variable to be
> marked as coherent, or to introduce a compiler barrier somehow.

Legality isn't really relevant.  The shader source contains one instance of a
very, very expensive operation, and we decide to do it four times.  That's
unacceptable.

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


[Mesa-dev] [Bug 106687] radv: Fast color clears use incorrect format

2018-06-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106687

Bas Nieuwenhuizen  changed:

   What|Removed |Added

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

--- Comment #2 from Bas Nieuwenhuizen  ---
Looks correct to me and no CTS regressions here, so

https://cgit.freedesktop.org/mesa/mesa/commit/?id=cc21e96d5f412aae5d3982dde0d4c926e8d049e8

Thanks!

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


[Mesa-dev] [PATCH] intel/eu: Use a struct copy instead of a memcpy

2018-06-05 Thread Jason Ekstrand
The memcpy had the wrong size and this was causing crashes on 32-bit
builds of the driver.

Fixes: 6a9525bf6729a8 "intel/eu: Switch to a logical state stack"
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106830
---
 src/intel/compiler/brw_eu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/intel/compiler/brw_eu.c b/src/intel/compiler/brw_eu.c
index d0e4ea20704..6ef0a6a577c 100644
--- a/src/intel/compiler/brw_eu.c
+++ b/src/intel/compiler/brw_eu.c
@@ -289,7 +289,7 @@ void brw_set_default_acc_write_control(struct brw_codegen 
*p, unsigned value)
 void brw_push_insn_state( struct brw_codegen *p )
 {
assert(p->current != >stack[BRW_EU_MAX_INSN_STACK-1]);
-   memcpy(p->current + 1, p->current, sizeof(brw_inst));
+   *(p->current + 1) = *p->current;
p->current++;
 }
 
-- 
2.17.1

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


[Mesa-dev] [Bug 106823] Failed to recongnize keyword of shader code

2018-06-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106823

--- Comment #4 from Kenneth Graunke  ---
(In reply to Mark Janes from comment #3)
> Mesa passes the GLES3 variant of this test.  Also, the test is listed in the
> following dEQP source file:
> 
>   android/cts/master/src/gles2-failures.txt
> 
> Are we sure that this test should pass on GLES2?

Yes.  That just means the test isn't required as part of the Android
conformance process (i.e. on the must-pass list).  The spec is pretty clear.

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


[Mesa-dev] [PATCH v4 14/15] mesa/st/tests: Add array life range tests infrastructure to common test class

2018-06-05 Thread Gert Wollny
Signed-off-by: Gert Wollny 
---
 src/mesa/state_tracker/tests/st_tests_common.cpp | 181 ---
 src/mesa/state_tracker/tests/st_tests_common.h   |  32 +++-
 2 files changed, 186 insertions(+), 27 deletions(-)

diff --git a/src/mesa/state_tracker/tests/st_tests_common.cpp 
b/src/mesa/state_tracker/tests/st_tests_common.cpp
index e80519f691..873fffccd1 100644
--- a/src/mesa/state_tracker/tests/st_tests_common.cpp
+++ b/src/mesa/state_tracker/tests/st_tests_common.cpp
@@ -46,7 +46,8 @@ void *FakeCodeline::mem_ctx = nullptr;
 FakeCodeline::FakeCodeline(tgsi_opcode _op, const vector& _dst,
const vector& _src, const vector&_to):
op(_op),
-   max_temp_id(0)
+   max_temp_id(0),
+   max_array_id(0)
 {
transform(_dst.begin(), _dst.end(), std::back_inserter(dst),
  [this](int i) { return create_dst_register(i);});
@@ -64,7 +65,8 @@ FakeCodeline::FakeCodeline(tgsi_opcode _op, const 
vector>& _dst,
const vector>&_to,
SWZ with_swizzle):
op(_op),
-   max_temp_id(0)
+   max_temp_id(0),
+   max_array_id(0)
 {
(void)with_swizzle;
 
@@ -88,7 +90,8 @@ FakeCodeline::FakeCodeline(tgsi_opcode _op, const 
vector>& _d
const vector>& _src,
const vector>&_to, RA 
with_reladdr):
op(_op),
-   max_temp_id(0)
+   max_temp_id(0),
+   max_array_id(0)
 {
(void)with_reladdr;
 
@@ -108,9 +111,35 @@ FakeCodeline::FakeCodeline(tgsi_opcode _op, const 
vector>& _d
});
 }
 
+FakeCodeline::FakeCodeline(tgsi_opcode _op, const vector>& 
_dst,
+   const vector>& _src,
+   const vector>&_to,
+   ARR with_array):
+   FakeCodeline(_op)
+{
+   (void)with_array;
+
+   transform(_dst.begin(), _dst.end(), std::back_inserter(dst),
+ [this](const tuple& r) {
+  return create_array_dst_register(r);
+   });
+
+   transform(_src.begin(), _src.end(), std::back_inserter(src),
+ [this](const tuple& r) {
+  return create_array_src_register(r);
+   });
+
+   transform(_to.begin(), _to.end(), std::back_inserter(tex_offsets),
+ [this](const tuple& r) {
+  return create_array_src_register(r);
+   });
+
+}
+
 FakeCodeline::FakeCodeline(const glsl_to_tgsi_instruction& instr):
op(instr.op),
-   max_temp_id(0)
+   max_temp_id(0),
+   max_array_id(0)
 {
int nsrc = num_inst_src_regs();
int ndst = num_inst_dst_regs();
@@ -129,7 +158,14 @@ FakeCodeline::FakeCodeline(const glsl_to_tgsi_instruction& 
instr):
 template 
 void FakeCodeline::read_reg(const st_reg& s)
 {
-   if (s.file == PROGRAM_TEMPORARY) {
+   if (s.file == PROGRAM_ARRAY) {
+  if (s.array_id > max_array_id)
+ max_array_id = s.array_id;
+  if (s.reladdr)
+ read_reg(*s.reladdr);
+  if (s.reladdr2)
+ read_reg(*s.reladdr2);
+   } else  if (s.file == PROGRAM_TEMPORARY) {
   if (s.index > max_temp_id)
  max_temp_id = s.index;
}
@@ -207,6 +243,8 @@ st_src_reg FakeCodeline::create_src_register(int src_idx, 
gl_register_file file)
  max_temp_id = src_idx;
} else if (file == PROGRAM_ARRAY) {
   retval.array_id = 1;
+  if (max_array_id < 1)
+  max_array_id = 1;
}
retval.swizzle = SWIZZLE_XYZW;
retval.type = GLSL_TYPE_INT;
@@ -223,6 +261,48 @@ st_src_reg *FakeCodeline::create_rel_src_register(int idx)
return retval;
 }
 
+st_src_reg FakeCodeline::create_array_src_register(const tuple& r)
+{
+
+   int array_id = std::get<0>(r);
+   int idx = std::get<1>(r);
+
+   st_src_reg retval = create_src_register(idx, std::get<2>(r));
+
+   if (array_id > 0) {
+  retval.file = PROGRAM_ARRAY;
+
+  retval.array_id = array_id;
+  if (max_array_id < array_id)
+ max_array_id = array_id;
+   } else {
+  if (max_temp_id < idx)
+ max_temp_id = idx;
+   }
+
+   return retval;
+}
+
+st_dst_reg FakeCodeline::create_array_dst_register(const tuple& r)
+{
+
+   int array_id = std::get<0>(r);
+   int idx = std::get<1>(r);
+
+   st_dst_reg retval = create_dst_register(idx, std::get<2>(r));
+
+   if (array_id > 0) {
+  retval.file = PROGRAM_ARRAY;
+  retval.array_id = array_id;
+  if (max_array_id < array_id)
+ max_array_id = array_id;
+   } else {
+  if (max_temp_id < idx)
+ max_temp_id = idx;
+   }
+   return retval;
+}
+
 st_src_reg FakeCodeline::create_src_register(const tuple& src)
 {
int src_idx = std::get<0>(src);
@@ -286,6 +366,8 @@ st_dst_reg FakeCodeline::create_dst_register(int dst_idx, 
gl_register_file file)
  max_temp_id = dst_idx;
} else if (file == PROGRAM_ARRAY) {
   retval.array_id = 1;
+  if (max_array_id < 1)
+  max_array_id = 1;
}
retval.writemask = 0xF;
retval.type = GLSL_TYPE_INT;
@@ -350,30 +432,43 @@ void FakeCodeline::set_mem_ctx(void *ctx)
 
 FakeShader::FakeShader(const vector& source):

[Mesa-dev] [PATCH v4 15/15] mesa/st/tests: Add array life range estimation and renumbering tests

2018-06-05 Thread Gert Wollny
Signed-off-by: Gert Wollny 
---
 .../tests/test_glsl_to_tgsi_array_merge.cpp| 211 +
 1 file changed, 211 insertions(+)

diff --git a/src/mesa/state_tracker/tests/test_glsl_to_tgsi_array_merge.cpp 
b/src/mesa/state_tracker/tests/test_glsl_to_tgsi_array_merge.cpp
index ca4b5d26a2..f4705a8639 100644
--- a/src/mesa/state_tracker/tests/test_glsl_to_tgsi_array_merge.cpp
+++ b/src/mesa/state_tracker/tests/test_glsl_to_tgsi_array_merge.cpp
@@ -749,3 +749,214 @@ TEST_F(ArrayMergeTest, MergeAndInterleave5)
EXPECT_EQ(result[5], expect[4]);
 
 }
+
+/* Test two arrays life time simple */
+TEST_F(LifetimeEvaluatorExactTest, TwoArraysSimple)
+{
+   const vector code = {
+  { TGSI_OPCODE_MOV , {MT(1, 1, WRITEMASK_XYZW)}, {MT(0, in0, "")}, {}, 
ARR()},
+  { TGSI_OPCODE_MOV , {MT(2, 1, WRITEMASK_XYZW)}, {MT(0, in1, "")}, {}, 
ARR()},
+  { TGSI_OPCODE_ADD , {MT(0,out0, WRITEMASK_XYZW)}, {MT(1,1,"xyzw"), 
MT(2,1,"xyzw")}, {}, ARR()},
+  { TGSI_OPCODE_END}
+   };
+   run (code, array_lt_expect({{1,2,0,2, WRITEMASK_XYZW}, {2,2,1,2, 
WRITEMASK_XYZW}}));
+}
+
+/* Test two arrays life time simple */
+TEST_F(LifetimeEvaluatorExactTest, TwoArraysSimpleSwizzleX_Y)
+{
+   const vector code = {
+  { TGSI_OPCODE_MOV , {MT(1, 1, WRITEMASK_X)}, {MT(0, in0, "")}, {}, 
ARR()},
+  { TGSI_OPCODE_MOV , {MT(2, 1, WRITEMASK_Y)}, {MT(0, in1, "")}, {}, 
ARR()},
+  { TGSI_OPCODE_ADD , {MT(0,out0,1)}, {MT(1,1,"x"), MT(2,1,"y")}, {}, 
ARR()},
+  { TGSI_OPCODE_END}
+   };
+   run (code, array_lt_expect({{1, 2, 0, 2, WRITEMASK_X}, {2, 2, 1, 2, 
WRITEMASK_Y}}));
+}
+
+/* Test array written before loop and read inside, must survive the loop */
+TEST_F(LifetimeEvaluatorExactTest, ArraysWriteBeforLoopReadInside)
+{
+   const vector code = {
+  { TGSI_OPCODE_MOV, {1}, {in1}, {}},
+  { TGSI_OPCODE_MOV, {MT(1, 1, WRITEMASK_X)}, {MT(0, in0, "")}, {}, ARR()},
+  { TGSI_OPCODE_BGNLOOP },
+  { TGSI_OPCODE_ADD, {MT(0,1, WRITEMASK_X)}, {MT(1,1,"x"), {MT(0,1, 
"x")}}, {}, ARR()},
+  { TGSI_OPCODE_ENDLOOP },
+  { TGSI_OPCODE_MOV, {out0}, {1}, {}},
+  { TGSI_OPCODE_END}
+   };
+   run (code, array_lt_expect({{1, 1, 1, 4, WRITEMASK_X}}));
+}
+
+/* Test array written conditionally in loop must survive the whole loop */
+TEST_F(LifetimeEvaluatorExactTest, ArraysConditionalWriteInNestedLoop)
+{
+   const vector code = {
+  { TGSI_OPCODE_MOV, {1}, {in1}, {}},
+  { TGSI_OPCODE_BGNLOOP },
+  {   TGSI_OPCODE_BGNLOOP },
+  { TGSI_OPCODE_IF, {}, {1}, {}},
+  {   TGSI_OPCODE_MOV, {MT(1, 1, WRITEMASK_Z)}, {MT(0, in0, "")}, {}, 
ARR()},
+  { TGSI_OPCODE_ENDIF },
+  { TGSI_OPCODE_ADD, {MT(0,1, WRITEMASK_X)}, {MT(1,1,"z"), {MT(0,1, 
"x")}}, {}, ARR()},
+  {   TGSI_OPCODE_ENDLOOP },
+  { TGSI_OPCODE_ENDLOOP },
+  { TGSI_OPCODE_MOV, {out0}, {1}, {}},
+  { TGSI_OPCODE_END}
+   };
+   run (code, array_lt_expect({{1, 1, 1, 8, WRITEMASK_Z}}));
+}
+
+/* Test array read conditionally in loop before write must
+ * survive the whole loop
+ */
+TEST_F(LifetimeEvaluatorExactTest, 
ArraysConditionalReadBeforeWriteInNestedLoop)
+{
+   const vector code = {
+  { TGSI_OPCODE_MOV, {1}, {in1}, {}},
+  { TGSI_OPCODE_BGNLOOP },
+  {   TGSI_OPCODE_BGNLOOP },
+  { TGSI_OPCODE_IF, {}, {1}, {}},
+  { TGSI_OPCODE_ADD, {MT(0,1, WRITEMASK_X)}, {MT(1,1,"z"), {MT(0,1, 
"x")}}, {}, ARR()},
+  { TGSI_OPCODE_ENDIF },
+  {   TGSI_OPCODE_MOV, {MT(1, 1, WRITEMASK_Z)}, {MT(0, in0, "")}, {}, 
ARR()},
+  {   TGSI_OPCODE_ENDLOOP },
+  { TGSI_OPCODE_ENDLOOP },
+  { TGSI_OPCODE_MOV, {out0}, {1}, {}},
+  { TGSI_OPCODE_END}
+   };
+   run (code, array_lt_expect({{1, 1, 1, 8, WRITEMASK_Z}}));
+}
+
+
+/* Test array written conditionally in loop must survive the whole loop */
+TEST_F(LifetimeEvaluatorExactTest, ArraysConditionalWriteInNestedLoop2)
+{
+   const vector code = {
+  { TGSI_OPCODE_MOV, {1}, {in1}, {}},
+  { TGSI_OPCODE_BGNLOOP },
+  {   TGSI_OPCODE_BGNLOOP },
+  { TGSI_OPCODE_IF, {}, {1}, {}},
+  {   TGSI_OPCODE_BGNLOOP },
+  { TGSI_OPCODE_MOV, {MT(1, 1, WRITEMASK_Z)}, {MT(0, in0, "")}, 
{}, ARR()},
+  {   TGSI_OPCODE_ENDLOOP },
+  { TGSI_OPCODE_ENDIF },
+  { TGSI_OPCODE_ADD, {MT(0,1, WRITEMASK_X)}, {MT(1,1,"z"), {MT(0,1, 
"x")}}, {}, ARR()},
+  {   TGSI_OPCODE_ENDLOOP },
+  { TGSI_OPCODE_ENDLOOP },
+  { TGSI_OPCODE_MOV, {out0}, {1}, {}},
+  { TGSI_OPCODE_END}
+   };
+   run (code, array_lt_expect({{1, 1, 1, 10, WRITEMASK_Z}}));
+}
+
+
+/* Test distinct loops */
+TEST_F(LifetimeEvaluatorExactTest, ArraysReadWriteInSeparateScopes)
+{
+   const vector code = {
+  { TGSI_OPCODE_MOV, {1}, {in1}, {}},
+  { TGSI_OPCODE_BGNLOOP },
+  {   TGSI_OPCODE_MOV, {MT(1, 1, WRITEMASK_W)}, {MT(0, in0, "")}, {}, 
ARR()},
+  { TGSI_OPCODE_ENDLOOP },
+  { TGSI_OPCODE_BGNLOOP },
+  {   TGSI_OPCODE_ADD, {MT(0,1, WRITEMASK_X)}, 

[Mesa-dev] [PATCH v4 12/15] mesa/st/glsl_to_tgsi: add array life range evaluation into tracking code

2018-06-05 Thread Gert Wollny
v4: Also track the register given in inst->resource. (thanks: Benedikt Schemmer 
for testing the patches on radeonsi, which revealed that I was missing 
tracking this)
Signed-off-by: Gert Wollny 
---
 .../state_tracker/st_glsl_to_tgsi_temprename.cpp   | 62 +-
 1 file changed, 50 insertions(+), 12 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp
index 94bcc3abd2..40631ff0b9 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp
@@ -1009,28 +1009,34 @@ public:
 
 class access_recorder {
 public:
-   access_recorder(int _ntemps);
+   access_recorder(int _ntemps, int _narrays);
~access_recorder();
 
void record_read(const st_src_reg& src, int line, prog_scope *scope);
-   void record_write(const st_dst_reg& src, int line, prog_scope *scope);
+   void record_write(const st_dst_reg& src, int line, prog_scope *scope,
+ bool no_reswizzle);
 
-   void get_required_live_ranges(register_live_range *register_live_ranges);
+   void get_required_live_ranges(register_live_range *register_live_ranges,
+ array_live_range *array_live_ranges);
 private:
 
int ntemps;
+   int narrays;
temp_access *temp_acc;
-
+   array_access *array_acc;
 };
 
-access_recorder::access_recorder(int _ntemps):
-   ntemps(_ntemps)
+access_recorder::access_recorder(int _ntemps, int _narrays):
+   ntemps(_ntemps),
+   narrays(_narrays)
 {
temp_acc = new temp_access[ntemps];
+   array_acc = new array_access[narrays];
 }
 
 access_recorder::~access_recorder()
 {
+   delete[] array_acc;
delete[] temp_acc;
 }
 
@@ -1046,6 +1052,11 @@ void access_recorder::record_read(const st_src_reg& src, 
int line,
if (src.file == PROGRAM_TEMPORARY)
   temp_acc[src.index].record_read(line, scope, readmask);
 
+   if (src.file == PROGRAM_ARRAY) {
+  assert(src.array_id <= narrays);
+  array_acc[src.array_id - 1].record_access(line, scope, readmask);
+   }
+
if (src.reladdr)
   record_read(*src.reladdr, line, scope);
if (src.reladdr2)
@@ -1053,18 +1064,30 @@ void access_recorder::record_read(const st_src_reg& 
src, int line,
 }
 
 void access_recorder::record_write(const st_dst_reg& dst, int line,
-   prog_scope *scope)
+   prog_scope *scope, bool can_reswizzle)
 {
if (dst.file == PROGRAM_TEMPORARY)
   temp_acc[dst.index].record_write(line, scope, dst.writemask);
 
+   if (dst.file == PROGRAM_ARRAY) {
+  assert(dst.array_id <= narrays);
+
+  /* If the array is written as dst of a multi-dst operation, we must not
+   * reswizzle the access, because we would have to reswizzle also the
+   * other dst. For now just fill the mask to make interleaving impossible.
+   */
+  array_acc[dst.array_id - 1].record_access(line, scope,
+can_reswizzle ? dst.writemask: 
0xF);
+   }
+
if (dst.reladdr)
   record_read(*dst.reladdr, line, scope);
if (dst.reladdr2)
   record_read(*dst.reladdr2, line, scope);
 }
 
-void access_recorder::get_required_live_ranges(struct register_live_range 
*register_live_ranges)
+void access_recorder::get_required_live_ranges(struct register_live_range 
*register_live_ranges,
+   struct array_live_range 
*array_live_ranges)
 {
RENAME_DEBUG(debug_log << "== register live ranges ==\n");
for(int i = 0; i < ntemps; ++i) {
@@ -1074,6 +1097,15 @@ void access_recorder::get_required_live_ranges(struct 
register_live_range *regis
<< register_live_ranges[i].end << "]\n");
}
RENAME_DEBUG(debug_log << "==\n\n");
+
+   RENAME_DEBUG(debug_log << "== array live ranges ==\n");
+   for(int i = 0; i < narrays; ++i) {
+  RENAME_DEBUG(debug_log<< setw(4) << i);
+  array_acc[i].get_required_live_range(array_live_ranges[i]);
+  RENAME_DEBUG(debug_log << ": [" tex_offsets[j], line, cur_scope);
  }
- for (unsigned j = 0; j < num_inst_dst_regs(inst); j++) {
-access.record_write(inst->dst[j], line, cur_scope);
+ unsigned ndst = num_inst_dst_regs(inst);
+ for (unsigned j = 0; j < ndst; j++) {
+access.record_write(inst->dst[j], line, cur_scope, ndst == 1);
  }
+ access.record_read(inst->resource, line, cur_scope);
   }
   }
   ++line;
@@ -1256,7 +1294,7 @@ get_temp_registers_required_live_ranges(void *mem_ctx, 
exec_list *instructions,
if (cur_scope->end() < 0)
   cur_scope->set_end(line - 1);
 
-   access.get_required_live_ranges(register_live_ranges);
+   access.get_required_live_ranges(register_live_ranges, array_live_ranges);
return 

[Mesa-dev] [PATCH v4 10/15] mesa/st/glsl_to_tgsi: move evaluation of read mask up in the call hierarchy

2018-06-05 Thread Gert Wollny
In preparation of the array live range tracking the evaluation of the read
mask is moved out the register live range tracking to the enclosing call
of the generalized read access tracking.

Signed-off-by: Gert Wollny 
---
 src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp
index e80138e312..121552a721 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp
@@ -494,13 +494,8 @@ void temp_access::record_write(int line, prog_scope 
*scope, int writemask)
   comp[3].record_write(line, scope);
 }
 
-void temp_access::record_read(int line, prog_scope *scope, int swizzle)
+void temp_access::record_read(int line, prog_scope *scope, int readmask)
 {
-   int readmask = 0;
-   for (int idx = 0; idx < 4; ++idx) {
-  int swz = GET_SWZ(swizzle, idx);
-  readmask |= (1 << swz) & 0xF;
-   }
update_access_mask(readmask);
 
if (readmask & WRITEMASK_X)
@@ -940,8 +935,14 @@ access_recorder::~access_recorder()
 void access_recorder::record_read(const st_src_reg& src, int line,
   prog_scope *scope)
 {
+   int readmask = 0;
+   for (int idx = 0; idx < 4; ++idx) {
+  int swz = GET_SWZ(src.swizzle, idx);
+  readmask |= (1 << swz) & 0xF;
+   }
+
if (src.file == PROGRAM_TEMPORARY)
-  temp_acc[src.index].record_read(line, scope, src.swizzle);
+  temp_acc[src.index].record_read(line, scope, readmask);
 
if (src.reladdr)
   record_read(*src.reladdr, line, scope);
-- 
2.16.4

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


[Mesa-dev] [PATCH v4 13/15] mesa/st/glsl_to_tgsi: Expose array live range tracking and merging

2018-06-05 Thread Gert Wollny
This patch ties in the array split, merge, and interleave code.

shader-db changes in the TGSI code are:

  original code  |  array-merge  |   change
  mean  max  |  meanmax  | best  mean %  worst
  ---
  arrays   0.05   2  |   0.00 0  |  -2   -100  0
total temps5.05  21  |   4.9220  | -15   -2.59 1
  instr   55.33 988  |  55.20   988  | -15   -0.24 0

Evaluation:

Run shader-db in single thread mode (otherwise the output is
not ordered and the best and worst column don't make sense) to
get results pre-stats.txt and post-stats.txt. Then using
python pandas:

 import pandas as pd
 old_stats = pd.read_csv('pre-stats.txt')
 new_stats = pd.read_csv('post-stats.txt')
 omean = old_stats.mean()
 omax = old_stats.max()
 nmean = new_stats.mean()
 nmax = new_stats.max()
 delta =  new_stats - old_stats
 pd.concat([omean, omax, nmean, nmax, delta.min(),
delta.mean()/old_stats.mean()*100, delta.max()],
axis=1, keys=['mean', 'max', 'mean', 'max', 'best',
'avg change %', 'worst'])

v4: - Correct typo and add bugs that are fixed by this series.
- Update stats and describe stats evaluation

Bugzilla:
  https://bugs.freedesktop.org/show_bug.cgi?id=105371
  https://bugs.freedesktop.org/show_bug.cgi?id=100200
Signed-off-by: Gert Wollny 
---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp| 19 +--
 src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.h  |  5 -
 src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp |  7 ++-
 src/mesa/state_tracker/st_glsl_to_tgsi_temprename.h   | 11 +--
 src/mesa/state_tracker/tests/st_tests_common.cpp  | 13 +++--
 5 files changed, 39 insertions(+), 16 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index f88a01fd39..43052af8d3 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -5521,17 +5521,32 @@ glsl_to_tgsi_visitor::split_arrays(void)
 void
 glsl_to_tgsi_visitor::merge_registers(void)
 {
+   struct array_live_range *arr_live_ranges = NULL;
+
struct register_live_range *reg_live_ranges =
  rzalloc_array(mem_ctx, struct register_live_range, this->next_temp);
 
+   if (this->next_array > 0) {
+  arr_live_ranges = new array_live_range[this->next_array];
+  for (unsigned i = 0; i < this->next_array; ++i)
+ arr_live_ranges[i] = array_live_range(i+1, this->array_sizes[i+1]);
+   }
+
+
if (get_temp_registers_required_live_ranges(reg_live_ranges, 
>instructions,
- this->next_temp, 
reg_live_ranges)) {
+   this->next_temp, 
reg_live_ranges,
+   this->next_array, 
arr_live_ranges)) {
   struct rename_reg_pair *renames =
 rzalloc_array(reg_live_ranges, struct rename_reg_pair, 
this->next_temp);
   get_temp_registers_remapping(reg_live_ranges, this->next_temp,
reg_live_ranges, renames);
   rename_temp_registers(renames);
-  ralloc_free(renames);
+
+  this->next_array =  merge_arrays(this->next_array, this->array_sizes,
+   >instructions, arr_live_ranges);
+
+  if (arr_live_ranges)
+ delete[] arr_live_ranges;
}
ralloc_free(reg_live_ranges);
 }
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.h 
b/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.h
index 66da0c379c..28c40389aa 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.h
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.h
@@ -146,6 +146,9 @@ public:
 const array_remapping& rhs);
 
 private:
+
+   void interleave(int trgt_access_mask, int src_access_mask);
+
unsigned target_id;
int8_t read_swizzle_map[4];
 };
@@ -182,4 +185,4 @@ int merge_arrays(int narrays,
  unsigned *array_sizes,
  exec_list *instructions,
  struct array_live_range *arr_live_ranges);
-#endif
\ No newline at end of file
+#endif
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp
index 40631ff0b9..01c57cf181 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp
@@ -1121,7 +1121,8 @@ static void dump_instruction(ostream& os, int line, 
prog_scope *scope,
  */
 bool
 get_temp_registers_required_live_ranges(void *mem_ctx, exec_list *instructions,
-  int ntemps, struct register_live_range *register_live_ranges)
+  int ntemps, struct register_live_range *register_live_ranges,
+  int narrays, struct array_live_range *array_live_ranges)
 {
int 

[Mesa-dev] [PATCH v4 09/15] mesa/st/glsl_to_tgsi: rename access_record to register_merge_record and some more renames

2018-06-05 Thread Gert Wollny
In preparartion of adding the tracking of the live range the classes that refer
to temporary registers are renamed.

Reviewed-by: Nicolai Hähnle 
Signed-off-by: Gert Wollny 
---
 .../state_tracker/st_glsl_to_tgsi_temprename.cpp   | 61 +++---
 .../state_tracker/st_glsl_to_tgsi_temprename.h |  2 +-
 2 files changed, 32 insertions(+), 31 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp
index 3107f0cf62..e80138e312 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp
@@ -898,14 +898,14 @@ register_live_range 
temp_comp_access::get_required_live_range()
 
 /* Helper class for sorting and searching the registers based
  * on live ranges. */
-class access_record {
+class register_merge_record {
 public:
int begin;
int end;
int reg;
bool erase;
 
-   bool operator < (const access_record& rhs) const {
+   bool operator < (const register_merge_record& rhs) const {
   return begin < rhs.begin;
}
 };
@@ -918,30 +918,30 @@ public:
void record_read(const st_src_reg& src, int line, prog_scope *scope);
void record_write(const st_dst_reg& src, int line, prog_scope *scope);
 
-   void get_required_live_ranges(register_live_range *live_ranges);
+   void get_required_live_ranges(register_live_range *register_live_ranges);
 private:
 
int ntemps;
-   temp_access *acc;
+   temp_access *temp_acc;
 
 };
 
 access_recorder::access_recorder(int _ntemps):
ntemps(_ntemps)
 {
-   acc = new temp_access[ntemps];
+   temp_acc = new temp_access[ntemps];
 }
 
 access_recorder::~access_recorder()
 {
-   delete[] acc;
+   delete[] temp_acc;
 }
 
 void access_recorder::record_read(const st_src_reg& src, int line,
   prog_scope *scope)
 {
if (src.file == PROGRAM_TEMPORARY)
-  acc[src.index].record_read(line, scope, src.swizzle);
+  temp_acc[src.index].record_read(line, scope, src.swizzle);
 
if (src.reladdr)
   record_read(*src.reladdr, line, scope);
@@ -953,7 +953,7 @@ void access_recorder::record_write(const st_dst_reg& dst, 
int line,
prog_scope *scope)
 {
if (dst.file == PROGRAM_TEMPORARY)
-  acc[dst.index].record_write(line, scope, dst.writemask);
+  temp_acc[dst.index].record_write(line, scope, dst.writemask);
 
if (dst.reladdr)
   record_read(*dst.reladdr, line, scope);
@@ -961,14 +961,14 @@ void access_recorder::record_write(const st_dst_reg& dst, 
int line,
   record_read(*dst.reladdr2, line, scope);
 }
 
-void access_recorder::get_required_live_ranges(struct register_live_range 
*live_ranges)
+void access_recorder::get_required_live_ranges(struct register_live_range 
*register_live_ranges)
 {
-   RENAME_DEBUG(debug_log << "=live_ranges ==\n");
+   RENAME_DEBUG(debug_log << "== register live ranges ==\n");
for(int i = 0; i < ntemps; ++i) {
   RENAME_DEBUG(debug_log << setw(4) << i);
-  live_ranges[i] = acc[i].get_required_live_range();
-  RENAME_DEBUG(debug_log << ": [" << live_ranges[i].begin << ", "
-   << live_ranges[i].end << "]\n");
+  register_live_ranges[i] = temp_acc[i].get_required_live_range();
+  RENAME_DEBUG(debug_log << ": [" << register_live_ranges[i].begin << ", "
+   << register_live_ranges[i].end << "]\n");
}
RENAME_DEBUG(debug_log << "==\n\n");
 }
@@ -986,7 +986,7 @@ static void dump_instruction(ostream& os, int line, 
prog_scope *scope,
  */
 bool
 get_temp_registers_required_live_ranges(void *mem_ctx, exec_list *instructions,
-int ntemps, struct register_live_range 
*live_ranges)
+  int ntemps, struct register_live_range *register_live_ranges)
 {
int line = 0;
int loop_id = 1;
@@ -1153,7 +1153,7 @@ get_temp_registers_required_live_ranges(void *mem_ctx, 
exec_list *instructions,
if (cur_scope->end() < 0)
   cur_scope->set_end(line - 1);
 
-   access.get_required_live_ranges(live_ranges);
+   access.get_required_live_ranges(register_live_ranges);
return true;
 }
 
@@ -1163,14 +1163,14 @@ get_temp_registers_required_live_ranges(void *mem_ctx, 
exec_list *instructions,
  * end points at the element past the end of the search range, and
  * the array comprising [start, end) must be sorted in ascending order.
  */
-static access_record*
-find_next_rename(access_record* start, access_record* end, int bound)
+static register_merge_record*
+find_next_rename(register_merge_record* start, register_merge_record* end, int 
bound)
 {
int delta = (end - start);
 
while (delta > 0) {
   int half = delta >> 1;
-  access_record* middle = start + half;
+  register_merge_record* middle = start + half;
 
   if (bound <= middle->begin) {
  delta = half;
@@ -1185,9 +1185,9 @@ 

[Mesa-dev] [PATCH v4 11/15] mesa/st/glsl_to_tgsi: add class for array access tracking

2018-06-05 Thread Gert Wollny
Because of the indirect access it is impossible to obtain an accurate per
component and array element tracking. Therefore, the tracking is simplified
to only track whether any element was accessed, whether this happend
conditionally in a loop. In addition, while tracking of temporaries requires
a per-componet tracking that is later fused, for arrays only the components
access mask is neede. The resulting tracking code and evaluation of the array
live range is sufficiently different from the evaluation of the live range of
temporaries to justify implementing this in a different class instead of
adding more complexity to the already existing code for temporary life
range evaluation.

v4: Update commit message to make it clearer why this class is seperate from
the tracking of temporaries.
Signed-off-by: Gert Wollny 
---
 .../state_tracker/st_glsl_to_tgsi_temprename.cpp   | 102 +
 1 file changed, 102 insertions(+)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp
index 121552a721..94bcc3abd2 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp
@@ -22,6 +22,7 @@
  */
 
 #include "st_glsl_to_tgsi_temprename.h"
+#include "st_glsl_to_tgsi_array_merge.h"
 #include "tgsi/tgsi_info.h"
 #include "tgsi/tgsi_strings.h"
 #include "program/prog_instruction.h"
@@ -239,6 +240,27 @@ private:
bool needs_component_tracking;
 };
 
+/* Class to track array access.
+ * Compared to the temporary tracking this is very simplified, mainly because
+ * with the likely indirect access one can not really establish access
+ * patterns for individual elements. Instead the life range evaluation is
+ * always for the whole array, handles only loops and the fact whether a
+ * value was accessed conditionally in a loop.
+ */
+class array_access {
+public:
+   array_access();
+   void record_access(int line, prog_scope *scope, int swizzle);
+   void get_required_live_range(array_live_range );
+private:
+   int first_access;
+   int last_access;
+   prog_scope *first_access_scope;
+   prog_scope *last_access_scope;
+   unsigned accumulated_swizzle:4;
+   int conditional_access_in_loop:1;
+};
+
 prog_scope_storage::prog_scope_storage(void *mc, int n):
mem_ctx(mc),
current_slot(0)
@@ -508,6 +530,86 @@ void temp_access::record_read(int line, prog_scope *scope, 
int readmask)
   comp[3].record_read(line, scope);
 }
 
+array_access::array_access():
+   first_access(-1),
+   last_access(-1),
+   first_access_scope(nullptr),
+   last_access_scope(nullptr),
+   accumulated_swizzle(0),
+   conditional_access_in_loop(false)
+{
+}
+
+void array_access::record_access(int line, prog_scope *scope, int swizzle)
+{
+   if (!first_access_scope) {
+  first_access = line;
+  first_access_scope = scope;
+   }
+   last_access_scope = scope;
+   last_access = line;
+   accumulated_swizzle |= swizzle;
+   if (scope->in_ifelse_scope() && scope->innermost_loop())
+  conditional_access_in_loop = true;
+}
+
+void array_access::get_required_live_range(array_live_range& lr)
+{
+   RENAME_DEBUG(debug_log << "first_access_scope=" << first_access_scope << 
"\n");
+   RENAME_DEBUG(debug_log << "last_access_scope=" << last_access_scope << 
"\n");
+
+   if (first_access_scope == last_access_scope) {
+  lr.set_live_range(first_access, last_access);
+  lr.set_access_mask(accumulated_swizzle);
+  return;
+   }
+
+   const prog_scope *shared_scope = first_access_scope;
+   const prog_scope *other_scope = last_access_scope;
+
+   assert(shared_scope);
+   RENAME_DEBUG(debug_log << "shared_scope=" << shared_scope << "\n");
+
+   if (conditional_access_in_loop) {
+  const prog_scope *help = shared_scope->outermost_loop();
+  if (help) {
+ shared_scope = help;
+  } else {
+ help = other_scope->outermost_loop();
+ if (help)
+other_scope = help;
+  }
+  if (first_access > shared_scope->begin())
+ first_access = shared_scope->begin();
+  if (last_access < shared_scope->end())
+ last_access = shared_scope->end();
+   }
+
+   /* See if any of the two is the parent of the other. */
+   if (other_scope->contains_range_of(*shared_scope)) {
+  shared_scope = other_scope;
+   } else while (!shared_scope->contains_range_of(*other_scope)) {
+  assert(shared_scope->parent());
+  if (shared_scope->type() == loop_body) {
+ if (last_access < shared_scope->end())
+ last_access = shared_scope->end();
+  }
+  shared_scope = shared_scope->parent();
+   }
+
+   while (shared_scope != other_scope) {
+  if (other_scope->type() == loop_body) {
+ if (last_access < other_scope->end())
+ last_access = other_scope->end();
+  }
+  other_scope = other_scope->parent();
+   }
+
+   lr.set_live_range(first_access, last_access);
+   

[Mesa-dev] [PATCH v4 06/15] mesa/st/glsl_to_tgsi: Add helper classes to apply array merging and interleaving

2018-06-05 Thread Gert Wollny
  v4: - Remove logic for evaluation of swizzles and merges since this
was moved to array_live_range. This class now only handles the
actual remapping.

Signed-off-by: Gert Wollny 
---
 .../state_tracker/st_glsl_to_tgsi_array_merge.cpp  | 100 +
 .../state_tracker/st_glsl_to_tgsi_array_merge.h|  65 +-
 2 files changed, 164 insertions(+), 1 deletion(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp
index d84a71ba39..a6c54c43df 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp
@@ -215,3 +215,103 @@ bool array_live_range::time_doesnt_overlap(const 
array_live_range& other) const
return (other.last_access < first_access ||
last_access < other.first_access);
 }
+
+namespace tgsi_array_merge {
+
+array_remapping::array_remapping():
+   target_id(0)
+{
+   for (int i = 0; i < 4; ++i) {
+  read_swizzle_map[i] = i;
+   }
+}
+
+array_remapping::array_remapping(int trgt_array_id, const int8_t swizzle[]):
+   target_id(trgt_array_id)
+{
+   for (int i = 0; i < 4; ++i) {
+  read_swizzle_map[i] = swizzle[i];
+   }
+}
+
+void array_remapping::init_from(const array_live_range& range)
+{
+   target_id = range.is_mapped() ? range.final_target()->array_id(): 0;
+   for (int i = 0; i < 4; ++i)
+  read_swizzle_map[i] = range.remap_one_swizzle(i);
+}
+
+
+int array_remapping::map_writemask(int write_mask) const
+{
+   assert(is_valid());
+   int result_write_mask = 0;
+   for (int i = 0; i < 4; ++i) {
+  if (1 << i & write_mask) {
+ assert(read_swizzle_map[i] >= 0);
+ result_write_mask |= 1 << read_swizzle_map[i];
+  }
+   }
+   return result_write_mask;
+}
+
+uint16_t array_remapping::move_read_swizzles(uint16_t original_swizzle) const
+{
+   assert(is_valid());
+   /* Since
+*
+*   dst.zw = src.xy in glsl actually is MOV dst.__zw src.__xy
+*
+* when interleaving the arrays the source swizzles must be moved
+* according to the changed dst write mask.
+*/
+   uint16_t out_swizzle = 0;
+   for (int idx = 0; idx < 4; ++idx) {
+  uint16_t orig_swz = GET_SWZ(original_swizzle, idx);
+  int new_idx = read_swizzle_map[idx];
+  if (new_idx >= 0)
+ out_swizzle |= orig_swz << 3 * new_idx;
+   }
+   return out_swizzle;
+}
+
+uint16_t array_remapping::map_swizzles(uint16_t old_swizzle) const
+{
+   uint16_t out_swizzle = 0;
+   for (int idx = 0; idx < 4; ++idx) {
+  uint16_t swz = read_swizzle_map[GET_SWZ(old_swizzle, idx)];
+  out_swizzle |= swz << 3 * idx;
+   }
+   return out_swizzle;
+}
+
+void array_remapping::print(std::ostream& os) const
+{
+   if (is_valid()) {
+  os << "[aid: " << target_id << " swz: ";
+  for (int i = 0; i < 4; ++i)
+ os << (read_swizzle_map[i] >= 0 ? xyzw[read_swizzle_map[i]] : '_');
+  os << "]";
+   } else {
+  os << "[unused]";
+   }
+}
+
+/* Required by the unit tests */
+bool operator == (const array_remapping& lhs, const array_remapping& rhs)
+{
+   if (lhs.target_id != rhs.target_id)
+  return false;
+
+   if (lhs.target_id == 0)
+  return true;
+
+   for (int i = 0; i < 4; ++i) {
+  if (lhs.read_swizzle_map[i] != rhs.read_swizzle_map[i])
+ return false;
+   }
+   return true;
+}
+
+/* end namespace tgsi_array_merge */
+}
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.h 
b/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.h
index 2234d2a97a..9915bc2e4b 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.h
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.h
@@ -95,4 +95,67 @@ std::ostream& operator << (std::ostream& os, const 
array_live_range& lt) {
lt.print(os);
return os;
 }
-#endif
\ No newline at end of file
+
+namespace tgsi_array_merge {
+
+/* Helper class to apply array merge and interleav to the shader.
+ * The interface is exposed here to make unit tests possible.
+ */
+class array_remapping {
+public:
+
+   /** Create an invalid mapping that is used as place-holder for
+* arrays that are not mapped at all.
+*/
+   array_remapping();
+
+   /* Predefined remapping, needed for testing */
+   array_remapping(int trgt_array_id, const int8_t swizzle[]);
+
+   /* Initialiaze the mapping from an array_live_range that has been
+* processed by the array merge and interleave algorithm.
+*/
+   void init_from(const array_live_range& range);
+
+   /* (Re)-set target id, needed when the mapping is resolved */
+   void set_target_id(int tid) {target_id = tid;}
+
+   /* Defines a valid remapping */
+   bool is_valid() const {return target_id > 0;}
+
+   /* Translates the write mask to the new, interleaved component
+* position
+*/
+   int map_writemask(int original_write_mask) const;
+
+   /* Translates all read swizzles to the new, interleaved component
+* swizzles
+*/
+   uint16_t 

[Mesa-dev] [PATCH v4 08/15] mesa/st/tests: Add tests for array merge helper classes.

2018-06-05 Thread Gert Wollny
v2: - Define tests also in the meson.build file.
v4: - Check no-op mapping of all bits.
- Convert tests to the new class layout used in the merge evaulation.
- remove dependency on llvm in meson build (Thanks Dylan Baker for pointing 
   out that this might not needed)
Signed-off-by: Gert Wollny 
---
 src/mesa/state_tracker/tests/Makefile.am   |  20 +-
 src/mesa/state_tracker/tests/meson.build   |  16 +-
 src/mesa/state_tracker/tests/st_tests_common.h |   7 +-
 .../tests/test_glsl_to_tgsi_array_merge.cpp| 751 +
 4 files changed, 787 insertions(+), 7 deletions(-)
 create mode 100644 
src/mesa/state_tracker/tests/test_glsl_to_tgsi_array_merge.cpp

diff --git a/src/mesa/state_tracker/tests/Makefile.am 
b/src/mesa/state_tracker/tests/Makefile.am
index a49ad3ee10..0665a88084 100644
--- a/src/mesa/state_tracker/tests/Makefile.am
+++ b/src/mesa/state_tracker/tests/Makefile.am
@@ -17,8 +17,10 @@ AM_CPPFLAGS = \
 
 if HAVE_STD_CXX11
 if HAVE_SHARED_GLAPI
-TESTS = st-renumerate-test
-check_PROGRAMS = st-renumerate-test
+TESTS = st-renumerate-test \
+   st-array-merge-test
+check_PROGRAMS = st-renumerate-test \
+   st-array-merge-test
 
 check_LIBRARIES = libmesa-st-tests-common.a
 endif
@@ -34,7 +36,13 @@ st_renumerate_test_SOURCES = \
 st_renumerate_test_LDFLAGS = \
$(LLVM_LDFLAGS)
 
-st_renumerate_test_LDADD = \
+st_array_merge_test_SOURCES = \
+   test_glsl_to_tgsi_array_merge.cpp
+
+st_array_merge_test_LDFLAGS = \
+   $(LLVM_LDFLAGS)
+
+st_common_LDADD = \
libmesa-st-tests-common.a \
$(top_builddir)/src/mesa/libmesagallium.la \
$(top_builddir)/src/mapi/shared-glapi/libglapi.la \
@@ -44,4 +52,10 @@ st_renumerate_test_LDADD = \
$(GALLIUM_COMMON_LIB_DEPS) \
$(LLVM_LIBS)
 
+st_renumerate_test_LDADD = \
+   $(st_common_LDADD)
+
+st_array_merge_test_LDADD = \
+   $(st_common_LDADD)
+
 EXTRA_DIST = meson.build
diff --git a/src/mesa/state_tracker/tests/meson.build 
b/src/mesa/state_tracker/tests/meson.build
index 0f84513209..5c472104d8 100644
--- a/src/mesa/state_tracker/tests/meson.build
+++ b/src/mesa/state_tracker/tests/meson.build
@@ -35,6 +35,20 @@ test(
   libmesa_st_test_common, libmesa_gallium, libglapi, libgallium,
   libmesa_util,
 ],
-dependencies : [idep_gtest, dep_thread, dep_llvm]
+dependencies : [idep_gtest, dep_thread]
+  )
+)
+
+test(
+  'st-array-merge-test',
+  executable(
+'st_array_merge_test',
+['test_glsl_to_tgsi_array_merge.cpp', ir_expression_operation_h],
+include_directories : inc_common,
+link_with : [
+  libmesa_st_test_common, libmesa_gallium, libglapi, libgallium,
+  libmesa_util,
+],
+dependencies : [idep_gtest, dep_thread]
   )
 )
diff --git a/src/mesa/state_tracker/tests/st_tests_common.h 
b/src/mesa/state_tracker/tests/st_tests_common.h
index 03baf50753..a4fe65947e 100644
--- a/src/mesa/state_tracker/tests/st_tests_common.h
+++ b/src/mesa/state_tracker/tests/st_tests_common.h
@@ -24,14 +24,15 @@
 #ifndef mesa_st_tests_h
 #define mesa_st_tests_h
 
-#include 
-#include 
+#include "state_tracker/st_glsl_to_tgsi_temprename.h"
+#include "state_tracker/st_glsl_to_tgsi_array_merge.h"
+#include "gtest/gtest.h"
+
 #include 
 
 #define MP(X, W) std::make_pair(X, W)
 #define MT(X,Y,Z) std::make_tuple(X,Y,Z)
 
-
 /* Use this to make the compiler pick the swizzle constructor below */
 struct SWZ {};
 
diff --git a/src/mesa/state_tracker/tests/test_glsl_to_tgsi_array_merge.cpp 
b/src/mesa/state_tracker/tests/test_glsl_to_tgsi_array_merge.cpp
new file mode 100644
index 00..ca4b5d26a2
--- /dev/null
+++ b/src/mesa/state_tracker/tests/test_glsl_to_tgsi_array_merge.cpp
@@ -0,0 +1,751 @@
+/*
+ * Copyright © 2017 Gert Wollny
+ *
+ * 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 "st_tests_common.h"
+
+#include "tgsi/tgsi_ureg.h"

[Mesa-dev] [PATCH v4 07/15] mesa/st/glsl_to_tgsi: Add array merge logic

2018-06-05 Thread Gert Wollny
v4: - Update the code to use the new merge logic.
- Use a cleaner, class-based approach for the evaluation of merges.
Signed-off-by: Gert Wollny 
---
 .../state_tracker/st_glsl_to_tgsi_array_merge.cpp  | 383 -
 .../state_tracker/st_glsl_to_tgsi_array_merge.h|  26 +-
 2 files changed, 407 insertions(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp
index a6c54c43df..0bdb42b75b 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp
@@ -21,6 +21,109 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
+/* A short overview on how the array merging works:
+ *
+ * Inputs:
+ *   - per array information: live range, access mask, size
+ *   - the program
+ *
+ * Output:
+ *   - the program with updated array addressing
+ *
+ * Pseudo algorithm:
+ *
+ * repeat
+ *for all pairs of arrays:
+ *   if they have non-overlapping live ranges and equal access masks:
+ *  - pick shorter array
+ *  - merge its live range into the longer array
+ *  - set its merge target array to the longer array
+ *  - mark the shorter array as processed
+ *
+ *for all pairs of arrays:
+ *   if they have overlapping live ranges use in sum at most four 
components:
+ *  - pick shorter array
+ *  - evaluate reswizzle map to move its components into the components
+ *that are not used by the longer array
+ *  - set its merge target array to the longer array
+ *  - mark the shorter array as processed
+ *  - bail out loop
+ *  until no more successfull merges were found
+ *
+ *  for all pairs of arrays:
+ * if they have non-overlapping live ranges:
+ *  - pick shorter array
+ *  - merge its live range into the longer array
+ *  - set its merge target array to the longer array
+ *  - mark the shorter array as processed
+ *
+ * Finalize remapping map so that target arrays are always final, i.e. have
+ * themselfes no merge target set.
+ *
+ * Example:
+ *   ID  | Length | Live range | access mask | target id | reswizzle
+ *   
+ *   1   3   3-10  x___0
+ *   2   4  13-20  x___0
+ *   3   8   3-20  x___0
+ *   4   6  21-40  xy__0
+ *   5   7  12-30  xy__0
+ *
+ * 1. merge live ranges 1 and 2
+ *
+ *   ID  | Length | Live range | access mask | target id | reswizzle
+ *   
+ *   1   --x___2
+ *   2   4   3-20  x___0
+ *   3   8   3-20  x___0
+ *   4   6  21-40  xy__0
+ *   5   7  12-30  xy__0
+ *
+ *
+ *  3. interleave 2 and 3
+ *
+ *   ID  | Length | Live range | access mask | target id | reswizzle
+ *   
+ *   1   --x___2
+ *   2   --x___3_x__
+ *   3   8   3-20  xy__0
+ *   4   6  21-40  xy__0
+ *   5   7  12-30  xy__0
+ *
+ *   3. merge live ranges 3 and 4
+ *
+ *   ID  | Length | Live range | access mask | target id | reswizzle
+ *   
+ *   1   --x___2
+ *   2   --x___3_x__
+ *   3   8   3-40  xy__0
+ *   4   --xy__3
+ *   5   7   3-21  xy__0
+ *
+ *   4. interleave 3 and 5
+ *
+ *   ID  | Length | Live range | access mask | target id | reswizzle
+ *   
+ *   1   --x___2
+ *   2   --x___3_x__
+ *   3   8   3-40  xy__0
+ *   4   --xy__3
+ *   5   --xy__3__xy
+ *
+ *   5. finalize remapping
+ *   (Array 1 has been merged with 2 that was later interleaved, so
+ *   the reswizzeling must be propagated.
+ *
+ *   ID  | Length | Live range | new access mask | target id | reswizzle
+ *   
+ *   1   --

[Mesa-dev] [PATCH v4 05/15] mesa/st/glsl_to_tgsi: Add helper class for array live range merging and interleaving

2018-06-05 Thread Gert Wollny
This class holds the array length, live range, and accessed components, and
it implements the logic for evaluating how arrays are merged and interleaved.

v4: - Add logic to evaluate merge and interleave of a pair of arrays to
  the class array_live_range.
- document class
- update commit message

Thanks Nicolai Hähnle for the pointers given.

Signed-off-by: Gert Wollny 
---
 src/mesa/Makefile.sources  |   2 +
 src/mesa/meson.build   |   2 +
 .../state_tracker/st_glsl_to_tgsi_array_merge.cpp  | 217 +
 .../state_tracker/st_glsl_to_tgsi_array_merge.h|  98 ++
 4 files changed, 319 insertions(+)
 create mode 100644 src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp
 create mode 100644 src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.h

diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
index 00aba0a2f7..dfead3e0a4 100644
--- a/src/mesa/Makefile.sources
+++ b/src/mesa/Makefile.sources
@@ -521,6 +521,8 @@ STATETRACKER_FILES = \
state_tracker/st_glsl_to_nir.cpp \
state_tracker/st_glsl_to_tgsi.cpp \
state_tracker/st_glsl_to_tgsi.h \
+   state_tracker/st_glsl_to_tgsi_array_merge.cpp \
+   state_tracker/st_glsl_to_tgsi_array_merge.h \
state_tracker/st_glsl_to_tgsi_private.cpp \
state_tracker/st_glsl_to_tgsi_private.h \
state_tracker/st_glsl_to_tgsi_temprename.cpp \
diff --git a/src/mesa/meson.build b/src/mesa/meson.build
index cba361c098..4a39a8e514 100644
--- a/src/mesa/meson.build
+++ b/src/mesa/meson.build
@@ -566,6 +566,8 @@ files_libmesa_gallium = files(
   'state_tracker/st_glsl_to_nir.cpp',
   'state_tracker/st_glsl_to_tgsi.cpp',
   'state_tracker/st_glsl_to_tgsi.h',
+  'state_tracker/st_glsl_to_tgsi_array_merge.cpp',
+  'state_tracker/st_glsl_to_tgsi_array_merge.h',
   'state_tracker/st_glsl_to_tgsi_private.cpp',
   'state_tracker/st_glsl_to_tgsi_private.h',
   'state_tracker/st_glsl_to_tgsi_temprename.cpp',
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp
new file mode 100644
index 00..d84a71ba39
--- /dev/null
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_array_merge.cpp
@@ -0,0 +1,217 @@
+/*
+ * Copyright © 2017 Gert Wollny
+ *
+ * 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 "program/prog_instruction.h"
+#include "util/u_math.h"
+#include 
+#include 
+#include 
+
+#include 
+
+#include "st_glsl_to_tgsi_array_merge.h"
+
+#if __cplusplus >= 201402L
+#include 
+using std::unique_ptr;
+using std::make_unique;
+#endif
+
+#define ARRAY_MERGE_DEBUG 0
+
+#if ARRAY_MERGE_DEBUG > 0
+#define ARRAY_MERGE_DUMP(x) do std::cerr << x; while (0)
+#define ARRAY_MERGE_DUMP_BLOCK(x) do { x } while (0)
+#else
+#define ARRAY_MERGE_DUMP(x)
+#define ARRAY_MERGE_DUMP_BLOCK(x)
+#endif
+
+static const char xyzw[] = "xyzw";
+
+array_live_range::array_live_range():
+   id(0),
+   length(0),
+   first_access(0),
+   last_access(0),
+   component_access_mask(0),
+   used_component_count(0),
+   target_array(nullptr)
+{
+   init_swizzles();
+}
+
+array_live_range::array_live_range(unsigned aid, unsigned alength):
+   id(aid),
+   length(alength),
+   first_access(0),
+   last_access(0),
+   component_access_mask(0),
+   used_component_count(0),
+   target_array(nullptr)
+{
+   init_swizzles();
+}
+
+array_live_range::array_live_range(unsigned aid, unsigned alength, int begin,
+   int end, int sw):
+   id(aid),
+   length(alength),
+   first_access(begin),
+   last_access(end),
+   component_access_mask(sw),
+   used_component_count(util_bitcount(sw)),
+   target_array(nullptr)
+{
+   init_swizzles();
+}
+
+void array_live_range::init_swizzles()
+{
+   for (int i = 0; i < 4; ++i)
+  swizzle_map[i] = i;
+}
+
+void array_live_range::set_live_range(int _begin, int _end)
+{
+   

[Mesa-dev] [PATCH v4 03/15] mesa/st/glsl_to_tgsi: Properly resolve life times simple if/else + use constructs

2018-06-05 Thread Gert Wollny
in constructs like below, currently the live range estimation extends the live 
range
of t unecessarily to the whole loop because it was not detected that t is
unconditional written and later read only in the "if (a)" scope.

  while (foo)  {
...
if (a) {
   ...
   if (b)
 t = ...
   else
 t = ...
   x = t;
   ...
}
 ...
  }

This patch adds a unit test for this case and corrects the minimal live range 
estimation
accordingly.

v4: update comments
Signed-off-by: Gert Wollny 
---
 .../state_tracker/st_glsl_to_tgsi_temprename.cpp   | 14 
 .../tests/test_glsl_to_tgsi_lifetime.cpp   | 25 ++
 2 files changed, 39 insertions(+)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp
index 6921a643b7..56f812c8bf 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp
@@ -741,6 +741,20 @@ void temp_comp_access::record_else_write(const prog_scope& 
scope)
  } else {
 current_unpaired_if_write_scope = nullptr;
  }
+ /* Promote the first write scope to the enclosing scope because
+  * the current IF/ELSE pair is now irrelevant for the analysis.
+  * This is also required to evaluate the minimum life time for t in
+  * {
+  *var t;
+  *if (a)
+  *  t = ...
+  *else
+  *  t = ...
+  *x = t;
+  *...
+  * }
+  */
+ first_write_scope = scope.parent();
 
  /* If some parent is IF/ELSE and in a loop then propagate the
   * write to that scope. Otherwise the write is unconditional
diff --git a/src/mesa/state_tracker/tests/test_glsl_to_tgsi_lifetime.cpp 
b/src/mesa/state_tracker/tests/test_glsl_to_tgsi_lifetime.cpp
index bb56ebcd8a..3afa45ea6e 100644
--- a/src/mesa/state_tracker/tests/test_glsl_to_tgsi_lifetime.cpp
+++ b/src/mesa/state_tracker/tests/test_glsl_to_tgsi_lifetime.cpp
@@ -794,6 +794,31 @@ TEST_F(LifetimeEvaluatorExactTest, 
WriteInIfElseBranchSecondIfInLoop)
run (code, temp_lt_expect({{-1,-1}, {2,9}}));
 }
 
+/* Within an IF clause within a loop test that if a write occured in both
+ * branches of a nested IF/ELSE clause, followed by the last read within the 
+ * enclosing IF or ELSE clause, the combined read is registered as 
unconditional,
+ * i.e.that it doesn't extend its live range beyond that enclosing IF or ELSE
+ * clause.
+ */
+TEST_F(LifetimeEvaluatorExactTest, DeeplyNestedinLoop)
+{
+   const vector code = {
+  { TGSI_OPCODE_BGNLOOP },
+  {   TGSI_OPCODE_UIF, {}, {in0}, {}},
+  { TGSI_OPCODE_FSEQ, {1}, {in1,in2}, {}},
+  { TGSI_OPCODE_UIF, {}, {1}, {}},
+  {   TGSI_OPCODE_MOV, {2}, {in1}, {}},
+  { TGSI_OPCODE_ELSE },
+  {   TGSI_OPCODE_MOV, {2}, {in2}, {}},
+  { TGSI_OPCODE_ENDIF },
+  { TGSI_OPCODE_MOV, {3}, {2}, {}},
+  {   TGSI_OPCODE_ENDIF },
+  {   TGSI_OPCODE_ADD, {out0}, {3, in1}, {}},
+  { TGSI_OPCODE_ENDLOOP }
+   };
+   run (code, temp_lt_expect({{-1,-1}, {2,3}, {4, 8}, {0,11}}));
+}
+
 /** Regression test for bug #104803,
  *  Read and write in if/else path outside loop and later read in conditional
  *  within a loop. The first write is to be considered the dominant write.
-- 
2.16.4

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


[Mesa-dev] [PATCH v4 01/15] mesa/st/glsl_to_tgsi: Add method to collect some TGSI statistics

2018-06-05 Thread Gert Wollny
When mesa is compiled in debug mode then this adds the possibility
to print out some statistics about the translated and optimized TGSI
shaders to a file.

The functionality is enabled by setting the environment variable

   GLSL_TO_TGSI_PRINT_STATS

to the file name where the statistics should be collected. The file is
opened in append mode so that statistics from various runs will be
accumulated.

v4: Make accress to log file thread save (thanks for pointing this out Nicolai 
Hähnle)
Signed-off-by: Gert Wollny 
---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 68 ++
 1 file changed, 68 insertions(+)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index b321112cf8..df29f3d1d6 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -66,6 +66,49 @@
 
 #define MAX_GLSL_TEXTURE_OFFSET 4
 
+#ifndef NDEBUG
+#include "util/u_atomic.h"
+#include "util/simple_mtx.h"
+#include 
+#include 
+
+/* Prepare to make it possible to specify log file */
+static std::ofstream stats_log;
+
+/* Helper function to check whether we want to write some statistics
+ * of the shader conversion.
+ */
+
+static simple_mtx_t print_stats_mutex = _SIMPLE_MTX_INITIALIZER_NP;
+
+static inline bool print_stats_enabled ()
+{
+   static int stats_enabled = 0;
+
+   if (!stats_enabled) {
+  simple_mtx_lock(_stats_mutex);
+  if (!stats_enabled) {
+ const char *stats_filename = getenv("GLSL_TO_TGSI_PRINT_STATS");
+ if (stats_filename) {
+bool write_header = std::ifstream(stats_filename).fail();
+stats_log.open(stats_filename, std::ios_base::out | 
std::ios_base::app);
+stats_enabled = stats_log.good() ? 1 : -1;
+if (write_header)
+   stats_log << "arrays,temps,temps in 
arrays,total,instructions\n";
+ } else {
+stats_enabled = -1;
+ }
+  }
+  simple_mtx_unlock(_stats_mutex);
+   }
+   return stats_enabled > 0;
+}
+#define PRINT_STATS(X) if (print_stats_enabled()) do { X; } while (false);
+#else
+#define PRINT_STATS(X)
+#endif
+
+
 static unsigned is_precise(const ir_variable *ir)
 {
if (!ir)
@@ -345,6 +388,8 @@ public:
st_dst_reg *l, st_src_reg *r,
st_src_reg *cond, bool cond_swap);
 
+   void print_stats();
+
void *mem_ctx;
 };
 
@@ -5419,6 +5464,27 @@ glsl_to_tgsi_visitor::renumber_registers(void)
ralloc_free(first_writes);
 }
 
+#ifndef NDEBUG
+void glsl_to_tgsi_visitor::print_stats()
+{
+   int narray_registers = 0;
+   for (unsigned i = 0; i < this->next_array; ++i)
+  narray_registers += this->array_sizes[i];
+
+   int ninstructions = 0;
+   foreach_in_list(glsl_to_tgsi_instruction, inst, ) {
+  ++ninstructions;
+   }
+
+   simple_mtx_lock(_stats_mutex);
+   stats_log << next_array << ", "
+ << next_temp << ", "
+ << narray_registers << ", "
+ << next_temp + narray_registers << ", "
+ << ninstructions << "\n";
+   simple_mtx_unlock(_stats_mutex);
+}
+#endif
 /* - TGSI conversion stuff -- 
*/
 
 /**
@@ -6928,6 +6994,8 @@ get_mesa_program_tgsi(struct gl_context *ctx,
   return NULL;
}
 
+   PRINT_STATS(v->print_stats());
+
return prog;
 }
 
-- 
2.16.4

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


[Mesa-dev] [PATCH v4 04/15] mesa/st/glsl_to_tgsi:rename lifetime to register_live_range

2018-06-05 Thread Gert Wollny
On one hand "live range" is the term used in the literature, and on the
other hand a distinction is needed from the array live ranges.

v4: Fix indentions and white spaces

Reviewed-by: Nicolai Hähnle  (v3)
Signed-off-by: Gert Wollny 
---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 16 ++---
 .../state_tracker/st_glsl_to_tgsi_temprename.cpp   | 82 +++---
 .../state_tracker/st_glsl_to_tgsi_temprename.h | 36 +-
 src/mesa/state_tracker/tests/st_tests_common.cpp   | 16 +++--
 src/mesa/state_tracker/tests/st_tests_common.h | 13 ++--
 .../tests/test_glsl_to_tgsi_lifetime.cpp   | 10 +--
 6 files changed, 90 insertions(+), 83 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 09e037bf50..f88a01fd39 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -5521,19 +5521,19 @@ glsl_to_tgsi_visitor::split_arrays(void)
 void
 glsl_to_tgsi_visitor::merge_registers(void)
 {
-   struct lifetime *lifetimes =
- rzalloc_array(mem_ctx, struct lifetime, this->next_temp);
+   struct register_live_range *reg_live_ranges =
+ rzalloc_array(mem_ctx, struct register_live_range, this->next_temp);
 
-   if (get_temp_registers_required_lifetimes(mem_ctx, >instructions,
- this->next_temp, lifetimes)) {
+   if (get_temp_registers_required_live_ranges(reg_live_ranges, 
>instructions,
+ this->next_temp, 
reg_live_ranges)) {
   struct rename_reg_pair *renames =
-rzalloc_array(mem_ctx, struct rename_reg_pair, this->next_temp);
-  get_temp_registers_remapping(mem_ctx, this->next_temp, lifetimes, 
renames);
+rzalloc_array(reg_live_ranges, struct rename_reg_pair, 
this->next_temp);
+  get_temp_registers_remapping(reg_live_ranges, this->next_temp,
+   reg_live_ranges, renames);
   rename_temp_registers(renames);
   ralloc_free(renames);
}
-
-   ralloc_free(lifetimes);
+   ralloc_free(reg_live_ranges);
 }
 
 /* Reassign indices to temporary registers by reusing unused indices created
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp
index 56f812c8bf..3107f0cf62 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi_temprename.cpp
@@ -154,9 +154,9 @@ public:
 
void record_read(int line, prog_scope *scope);
void record_write(int line, prog_scope *scope);
-   lifetime get_required_lifetime();
+   register_live_range get_required_live_range();
 private:
-   void propagate_lifetime_to_dominant_write_scope();
+   void propagate_live_range_to_dominant_write_scope();
bool conditional_ifelse_write_in_loop() const;
 
void record_ifelse_write(const prog_scope& scope);
@@ -230,7 +230,7 @@ public:
temp_access();
void record_read(int line, prog_scope *scope, int swizzle);
void record_write(int line, prog_scope *scope, int writemask);
-   lifetime get_required_lifetime();
+   register_live_range get_required_live_range();
 private:
void update_access_mask(int mask);
 
@@ -513,22 +513,22 @@ void temp_access::record_read(int line, prog_scope 
*scope, int swizzle)
   comp[3].record_read(line, scope);
 }
 
-inline static lifetime make_lifetime(int b, int e)
+inline static register_live_range make_live_range(int b, int e)
 {
-   lifetime lt;
+   register_live_range lt;
lt.begin = b;
lt.end = e;
return lt;
 }
 
-lifetime temp_access::get_required_lifetime()
+register_live_range temp_access::get_required_live_range()
 {
-   lifetime result = make_lifetime(-1, -1);
+   register_live_range result = make_live_range(-1, -1);
 
unsigned mask = access_mask;
while (mask) {
   unsigned chan = u_bit_scan();
-  lifetime lt = comp[chan].get_required_lifetime();
+  register_live_range lt = comp[chan].get_required_live_range();
 
   if (lt.begin >= 0) {
  if ((result.begin < 0) || (result.begin > lt.begin))
@@ -780,7 +780,7 @@ bool temp_comp_access::conditional_ifelse_write_in_loop() 
const
return conditionality_in_loop_id <= conditionality_unresolved;
 }
 
-void temp_comp_access::propagate_lifetime_to_dominant_write_scope()
+void temp_comp_access::propagate_live_range_to_dominant_write_scope()
 {
first_write = first_write_scope->begin();
int lr = first_write_scope->end();
@@ -789,7 +789,7 @@ void 
temp_comp_access::propagate_lifetime_to_dominant_write_scope()
   last_read = lr;
 }
 
-lifetime temp_comp_access::get_required_lifetime()
+register_live_range temp_comp_access::get_required_live_range()
 {
bool keep_for_full_loop = false;
 
@@ -799,7 +799,7 @@ lifetime temp_comp_access::get_required_lifetime()
 * eliminating registers that are not written to.
 */
if (last_write < 0)
-  return 

[Mesa-dev] [PATCH v4 02/15] mesa/st/glsl_to_tgsi: Split arrays whose elements are only accessed directly

2018-06-05 Thread Gert Wollny
Array whose elements are only accessed directly are replaced by the
according number of temporary registers. By doing so the otherwise
reserved register range becomes subject to further optimizations like
copy propagation and register merging.

Thanks to the resulting reduced register pressure this patch makes
the piglits

  spec/glsl-1.50/execution -
  variable-indexing/vs-output-array-vec3-index-wr-before-gs
  geometry/max-input-components

pass on r600 (barts) where they would fail before with a "GPR limit exceeded"
error (even with the spilling that was recently added).

v2: * rename method dissolve_arrays to split_arrays
* unify the tracking and remapping methods for src and dst registers
* also track access to arrays via reladdr*

v3: * enable this optimization only if the driver requests register merge

v4: * Correct comments
* Also update inst->resource if it is an array element 
  (thanks: Benedikt Schemmer for testing the patches on radeonsi, which 
   revealed that I was missing tracking this)

Signed-off-by: Gert Wollny 
---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 113 -
 1 file changed, 112 insertions(+), 1 deletion(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp 
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index df29f3d1d6..09e037bf50 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -380,6 +380,7 @@ public:
void copy_propagate(void);
int eliminate_dead_code(void);
 
+   void split_arrays(void);
void merge_two_dsts(void);
void merge_registers(void);
void renumber_registers(void);
@@ -5411,6 +5412,107 @@ glsl_to_tgsi_visitor::merge_two_dsts(void)
}
 }
 
+template 
+void test_indirect_access(const st_reg& reg, bool *has_indirect_access)
+{
+   if (reg.file == PROGRAM_ARRAY) {
+  if (reg.reladdr || reg.reladdr2 || reg.has_index2) {
+ has_indirect_access[reg.array_id] = true;
+ if (reg.reladdr)
+test_indirect_access(*reg.reladdr, has_indirect_access);
+ if (reg.reladdr2)
+test_indirect_access(*reg.reladdr, has_indirect_access);
+  }
+   }
+}
+
+template 
+void remap_array(st_reg& reg, const int *array_remap_info,
+ const bool *has_indirect_access)
+{
+   if (reg.file == PROGRAM_ARRAY) {
+  if (!has_indirect_access[reg.array_id]) {
+ reg.file = PROGRAM_TEMPORARY;
+ reg.index = reg.index + array_remap_info[reg.array_id];
+ reg.array_id = 0;
+  } else {
+ reg.array_id = array_remap_info[reg.array_id];
+  }
+
+  if (reg.reladdr)
+ remap_array(*reg.reladdr, array_remap_info, has_indirect_access);
+
+  if (reg.reladdr2)
+ remap_array(*reg.reladdr2, array_remap_info, has_indirect_access);
+   }
+}
+
+/* One-dimensional arrays whose elements are only accessed directly are
+ * replaced by an according set of temporary registers that then can become
+ * subject to further optimization steps like copy propagation and
+ * register merging.
+ */
+void
+glsl_to_tgsi_visitor::split_arrays(void)
+{
+   if (!next_array)
+  return;
+
+   bool *has_indirect_access = rzalloc_array(mem_ctx, bool, next_array + 1);
+
+   foreach_in_list(glsl_to_tgsi_instruction, inst, >instructions) {
+  for (unsigned j = 0; j < num_inst_src_regs(inst); j++)
+ test_indirect_access(inst->src[j], has_indirect_access);
+
+  for (unsigned j = 0; j < inst->tex_offset_num_offset; j++)
+ test_indirect_access(inst->tex_offsets[j], has_indirect_access);
+
+  for (unsigned j = 0; j < num_inst_dst_regs(inst); j++)
+ test_indirect_access(inst->dst[j], has_indirect_access);
+
+  test_indirect_access(inst->resource, has_indirect_access);
+   }
+
+   unsigned array_offset = 0;
+   unsigned n_remaining_arrays = 0;
+
+   /* Double use: For arrays that get split this value will contain
+* the base index of the temporary registers this array is replaced
+* with. For arrays that remain it contains the new array ID.
+*/
+   int *array_remap_info = rzalloc_array(has_indirect_access, int,
+ next_array + 1);
+
+   for (unsigned i = 1; i <= next_array; ++i) {
+  if (!has_indirect_access[i]) {
+ array_remap_info[i] = this->next_temp + array_offset;
+ array_offset += array_sizes[i - 1];
+  } else {
+ array_sizes[n_remaining_arrays] = array_sizes[i-1];
+ array_remap_info[i] = ++n_remaining_arrays;
+  }
+   }
+
+   if (next_array !=  n_remaining_arrays) {
+  foreach_in_list(glsl_to_tgsi_instruction, inst, >instructions) {
+ for (unsigned j = 0; j < num_inst_src_regs(inst); j++)
+remap_array(inst->src[j], array_remap_info, has_indirect_access);
+
+ for (unsigned j = 0; j < inst->tex_offset_num_offset; j++)
+remap_array(inst->tex_offsets[j], array_remap_info, 
has_indirect_access);
+
+ 

[Mesa-dev] [PATCH v4 00/15] TGSI: improved live range tracking, also including arrays

2018-06-05 Thread Gert Wollny
taking the comments of Nicolai Hähnle into account I've updated the series. I'd 
also 
like to thank Benedikt Schemmer for going out on the adventure to these these 
patches
on radeonsi for which this code path is actually not relevant. It made me 
realize, 
that I was not tracking the inst->resources register. I think, however, that 
r600 and 
llvmpipe are not really using that register, so I cannot test whether there are 
any 
fixes or regressions coming with this (for me the piglit results didn't change).

v4: 
 - make the TGSI statistics collection routine thread save, 
 - rework the classes that are used to evaluate and apply the array merging (I 
   did not follow Nicolais suggestion to handle the array live range also 
within 
   the class that tracks temporary registers because I think the handling is 
   sufficiently different, and because the temporary register live range 
   evaluation code is already difficult enough, no need to add more complexity 
   to also handle arrays), 
 - inst->resource to be also taken into account in the live range tracking and 
   array remapping
 - add two patches that add test infrastructure and unit tests for array live 
   range tracking and remapping

v3: 
 - Add new test mesa/st/tests/meson.build
 - rebase patches to latest HEAD

this is the merged version of two series [1] (TGSI: split, merge 
and interleave arrays) and [2] (mesa/st/glsl_to_tgsi: Properly 
resolve life times for simple if/else + use constructs) I sent
earlier. Considering that both parts target the same optimization 
step and fix a bug if both are applied, I thought it is better to 
add this second patch to the series. Changes refer to v1 of [1]: 

v2: 
 - rebase patches to latest HEAD
 - add some code that allows obtaining some statistics about register
   and instruction usage
 - Add patch [2] that improves resolving the live range estimation with 
   simple if/else and use constructs. By adding this patch the series 
   fixes https://bugs.freedesktop.org/show_bug.cgi?id=105371

 v1: 
Patch 1: Split arrays that are only accessed directly:  
I posted a first version off the the array splitting in patch 1 some 
time ago. Eric Anholt pointed out that this might be done in 
opt_array_splitting.cpp, but in another comment Timothy pointed out 
that this is far from trivial, and he also pointed out that he was 
proposing similar patches for NIR, but since currently no NIR->TGSI 
transformation is available, TGSI based drivers can't make use of this. 

While the reminder off the series could be applied without this patch, I 
think it makes less sense to do all the optimizations on arrays that could 
simply be split into individual registers, so I repost the patch with some 
changes. 

I tried to be exhaustive with comments and make the variable any type names 
self-explaining, but since I've been staring at this code for a long time I
don't think I am capable of seeing any problems any more, so comments are very 
welcome.

Many thanks for reviews and comments, 
Gert 

PS: I have no commit rights. 

Gert Wollny (15):
  mesa/st/glsl_to_tgsi: Add method to collect some TGSI statistics
  mesa/st/glsl_to_tgsi: Split arrays whose elements are only accessed
directly
  mesa/st/glsl_to_tgsi: Properly resolve life times simple if/else + use
constructs
  mesa/st/glsl_to_tgsi:rename lifetime to register_live_range
  mesa/st/glsl_to_tgsi: Add helper class for array live range merging
and interleaving
  mesa/st/glsl_to_tgsi: Add helper classes to apply array merging and
interleaving
  mesa/st/glsl_to_tgsi: Add array merge logic
  mesa/st/tests: Add tests for array merge helper classes.
  mesa/st/glsl_to_tgsi: rename access_record to register_merge_record
and some more renames
  mesa/st/glsl_to_tgsi: move evaluation of read mask up in the call
hierarchy
  mesa/st/glsl_to_tgsi: add class for array access tracking
  mesa/st/glsl_to_tgsi: add array life range evaluation into tracking
code
  mesa/st/glsl_to_tgsi: Expose array live range tracking  and merging
  mesa/st/tests: Add array life range tests infrastructure to common
test class
  mesa/st/tests: Add array life range estimation and renumbering tests

 src/mesa/Makefile.sources  |   2 +
 src/mesa/meson.build   |   2 +
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 214 -
 .../state_tracker/st_glsl_to_tgsi_array_merge.cpp  | 698 +++
 .../state_tracker/st_glsl_to_tgsi_array_merge.h| 188 
 .../state_tracker/st_glsl_to_tgsi_temprename.cpp   | 307 +--
 .../state_tracker/st_glsl_to_tgsi_temprename.h |  45 +-
 src/mesa/state_tracker/tests/Makefile.am   |  20 +-
 src/mesa/state_tracker/tests/meson.build   |  16 +-
 src/mesa/state_tracker/tests/st_tests_common.cpp   | 190 +++-
 src/mesa/state_tracker/tests/st_tests_common.h |  52 +-
 .../tests/test_glsl_to_tgsi_array_merge.cpp| 962 +
 

[Mesa-dev] [PATCH] nv50/ir: fix image stores with indirect handles

2018-06-05 Thread Rhys Perry
Having this if statement here prevented the next if statement from being
reached in the case of image stores, which is needed for instructions with
indirect bindless handles like "STORE TEMP[ADDR[2].x+1](1) ...".

Signed-off-by: Rhys Perry 
---
 src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp 
b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
index 3c5bad05fe..7712963c53 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
@@ -1563,6 +1563,11 @@ bool Source::scanInstruction(const struct 
tgsi_full_instruction *inst)
if (insn.dstCount()) {
   Instruction::DstRegister dst = insn.getDst(0);
 
+  if (insn.getOpcode() == TGSI_OPCODE_STORE &&
+  dst.getFile() != TGSI_FILE_MEMORY) {
+ info->io.globalAccess |= 0x2;
+  }
+
   if (dst.getFile() == TGSI_FILE_OUTPUT) {
  if (dst.isIndirect(0))
 for (unsigned i = 0; i < info->numOutputs; ++i)
@@ -1580,10 +1585,6 @@ bool Source::scanInstruction(const struct 
tgsi_full_instruction *inst)
  if (isEdgeFlagPassthrough(insn))
 info->io.edgeFlagIn = insn.getSrc(0).getIndex(0);
   } else
-  if (dst.getFile() != TGSI_FILE_MEMORY &&
-  insn.getOpcode() == TGSI_OPCODE_STORE) {
- info->io.globalAccess |= 0x2;
-  } else
   if (dst.getFile() == TGSI_FILE_TEMPORARY) {
  if (dst.isIndirect(0))
 indirectTempArrays.insert(dst.getArrayId());
 
-- 
2.14.4

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


[Mesa-dev] [Bug 106774] GLSL IR copy propagates loads of SSBOs

2018-06-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106774

--- Comment #2 from Ilia Mirkin  ---
Are you sure that's illegal? I'd imagine that you'd need that variable to be
marked as coherent, or to introduce a compiler barrier somehow.

One could also argue that an atomic should introduce such a barrier explicitly
-- I think in C they tend to act as compiler barriers.

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


[Mesa-dev] [PATCH 2/2] travis: Add the v3d driver to the automake build.

2018-06-05 Thread Eric Anholt
Hopefully this reduces the number of fixup commits we need for the
automake build.
---
 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 3a88b24bdbec..c53d74ea44ca 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -159,7 +159,7 @@ matrix:
 - DRI_LOADERS="--disable-glx --disable-gbm --disable-egl"
 - DRI_DRIVERS=""
 - GALLIUM_ST="--enable-dri --disable-opencl --disable-xa 
--disable-nine --disable-xvmc --disable-vdpau --disable-va 
--disable-omx-bellagio --disable-gallium-osmesa"
-- 
GALLIUM_DRIVERS="i915,nouveau,pl111,r300,r600,freedreno,svga,swrast,vc4,virgl,etnaviv,imx"
+- 
GALLIUM_DRIVERS="i915,nouveau,pl111,r300,r600,freedreno,svga,swrast,v3d,vc4,virgl,etnaviv,imx"
 - VULKAN_DRIVERS=""
 - LIBUNWIND_FLAGS="--enable-libunwind"
   addons:
-- 
2.17.0

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


[Mesa-dev] [PATCH 1/2] travis: Do our automake build tests with srcdir != builddir.

2018-06-05 Thread Eric Anholt
This will catch many automake bugs that end-users get to experience first,
otherwise.
---
 .travis.yml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 1f83f5b8d74d..3a88b24bdbec 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -591,7 +591,9 @@ script:
 
   export CFLAGS="$CFLAGS -isystem`pwd`";
 
-  ./autogen.sh --enable-debug
+  mkdir build &&
+  cd build &&
+  ../autogen.sh --enable-debug
 $LIBUNWIND_FLAGS
 $DRI_LOADERS
 --with-dri-drivers=$DRI_DRIVERS
-- 
2.17.0

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


[Mesa-dev] [Bug 106806] Fast clear for VK_FORMAT_R8G8_SNORM not implemented

2018-06-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106806

Bas Nieuwenhuizen  changed:

   What|Removed |Added

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

--- Comment #1 from Bas Nieuwenhuizen  ---
Should be fixed by

https://cgit.freedesktop.org/mesa/mesa/commit/?id=2a10fd902d71e7991c1dc81be16e5d61982f8e6e

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


[Mesa-dev] [Bug 106774] GLSL IR copy propagates loads of SSBOs

2018-06-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106774

Ian Romanick  changed:

   What|Removed |Added

Summary|NIR "copy propagates" loads |GLSL IR copy propagates
   |of SSBOs|loads of SSBOs

--- Comment #1 from Ian Romanick  ---
Upon further inspection, it turns out this happens before NIR even sees it.

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


Re: [Mesa-dev] [PATCH] wayland/egl: initialize window surface size to window size

2018-06-05 Thread Emil Velikov
Hi everyone,

Throwing a small suggestion here:

Once a consensus is reached, do add some beefy comments inline. Mostly
of any parts that are different from the X11/GBM/other backends.
A reference to this thread might also be a good idea.

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


Re: [Mesa-dev] [Mesa-stable] [PATCH 1/5] wayland-egl: allow shipping the library or not

2018-06-05 Thread Emil Velikov
On 5 June 2018 at 18:13, Matt Turner  wrote:
> On Tue, Jun 5, 2018 at 8:24 AM, Emil Velikov  wrote:
>> On 5 June 2018 at 16:07, Eric Engestrom  wrote:
>>> On Tuesday, 2018-06-05 15:14:30 +0100, Emil Velikov wrote:
 From: Emil Velikov 

 Recently the wayland-egl library and pkg-config file were moved to the
 Wayland repository. With that a strange conflict came to be - which one
 should be used and when.

 The long term goal is to remove the Mesa copies, but with this patch we
 allow builders to explicitly select if they want it.

 Note: since the header (wayland-egl-backend.h) is now used by C++
 people, s/private/driver_private/ was applied.

 Cc: Eric Engestrom 
 CC: 18.0 18.1 
 Signed-off-by: Emil Velikov 
 ---
  configure.ac| 17 +
  meson.build | 12 
  meson_options.txt   |  6 ++
  src/Makefile.am |  2 ++
  src/egl/Makefile.am |  1 +
  src/egl/drivers/dri2/platform_wayland.c | 12 
  src/egl/meson.build |  2 +-
  src/meson.build |  2 +-
  8 files changed, 52 insertions(+), 2 deletions(-)

 diff --git a/configure.ac b/configure.ac
 index 02dca4547c8..5ea52242bd1 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -89,6 +89,7 @@ LIBOMXIL_BELLAGIO_REQUIRED=0.0
  LIBOMXIL_TIZONIA_REQUIRED=0.10.0
  LIBVA_REQUIRED=0.39.0
  VDPAU_REQUIRED=1.1
 +# TODO: Bump to 1.15 -> the first version that ships wayland-egl-backend
  WAYLAND_REQUIRED=1.11
  WAYLAND_PROTOCOLS_REQUIRED=1.8
  XCB_REQUIRED=1.9.3
 @@ -1766,6 +1767,18 @@ if test "x$enable_glx_read_only_text" = xyes; then
  DEFINES="$DEFINES -DGLX_X86_READONLY_TEXT"
  fi

 +dnl
 +dnl TEMPORARY: mostly for stable releases
 +dnl
 +dnl It will allow easier management as the wayland-egl library was
 +dnl moved to the Wayland project
 +dnl
 +AC_ARG_ENABLE(bundled-wayland-egl,
 +   [AS_HELP_STRING([--disable-bundled-wayland-egl],
 +[disable shipping of the wayland-egl library and 
 pkg-config file @<:@default=enabled@:>@])],
 +   [enable_wayland_egl=$enableval], [enable_wayland_egl=yes])
 +AM_CONDITIONAL(BUILD_WAYLAND_EGL, test "x$enable_wayland_egl" = xyes)
>>>
>>> I'm not sure I see the benefit of your variant of adding all the
>>> complexity of a new option and immediately making it an error to use it.
>>> Could you explain your logic?
>>>
>> In all fairness, it should have been introduced when wayland-egl was
>> proposed for Wayland inclusion.
>> Back then I was under the naive assumption that, distribution maintainers 
>> will:
>>  - read mesa-maintainers@ or the wayland release notes
>>  - will know how to address the multiple copies of libwayland-egl.so
>>
>> Since then a distribution (wish shall remain unnamed), kind of
>> foobar'd both of the above.
>
> This is not a productive way to talk to people, and as a distro
> maintainer that has been aware of the change and has been asking you
> specifically for guidance for months it really rubs me the wrong way.
>
As you may have noticed I took a ~month away from Mesa, since despite
by best of intentions I manage to get under your skin :-(


> Neither your email to mesa-maintainers@ nor the Wayland release notes
> told distros what to do... because there wasn't anything that could be
> done since you never finished the Mesa bits. As for knowing how to
> address multiple copies of a library: we do. We delete the one we
> don't need and we ask upstream to sort their crap out.
>
Offline I've asked a couple of distribution packagers, admittedly not
the ones handling mesa/wayland:
"Do you have a way of dealing when library X moves from project A to B?"

The answer was a categorical, "yes" although the specifics varied.
One preferred to use B as early as possible, while another A for as
long as possible.

Both suggested against upstream telling them which route to opt for.
Now you know why the "will be removed" message was given without
explicit instructions.

The series sent earlier is effectively Eric's work with his authorship
preserved. There are some important fixes as mentioned earlier.

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


[Mesa-dev] [PATCH 2/2] i965: disable unsupported image format

2018-06-05 Thread Lionel Landwerlin
We have no corresponding ISL format for XBGR2101010.

Signed-off-by: Lionel Landwerlin 
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106642
---
 src/mesa/drivers/dri/i965/intel_screen.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_screen.c 
b/src/mesa/drivers/dri/i965/intel_screen.c
index 9f20347d512..a29778dc20b 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -193,9 +193,6 @@ static const struct intel_image_format 
intel_image_formats[] = {
{ __DRI_IMAGE_FOURCC_ABGR2101010, __DRI_IMAGE_COMPONENTS_RGBA, 1,
  { { 0, 0, 0, __DRI_IMAGE_FORMAT_ABGR2101010, 4 } } },
 
-   { __DRI_IMAGE_FOURCC_XBGR2101010, __DRI_IMAGE_COMPONENTS_RGB, 1,
- { { 0, 0, 0, __DRI_IMAGE_FORMAT_XBGR2101010, 4 } } },
-
{ __DRI_IMAGE_FOURCC_ARGB, __DRI_IMAGE_COMPONENTS_RGBA, 1,
  { { 0, 0, 0, __DRI_IMAGE_FORMAT_ARGB, 4 } } },
 
-- 
2.17.1

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


[Mesa-dev] [PATCH 1/2] i965: verify intermediate steps when converting format

2018-06-05 Thread Lionel Landwerlin
An invalid format could be computed through the
modifier_is_supported() helper. Better verify each step.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106642
Signed-off-by: Lionel Landwerlin 
---
 src/mesa/drivers/dri/i965/intel_mipmap_tree.c |  4 
 src/mesa/drivers/dri/i965/intel_screen.c  | 10 --
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c 
b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index 69024c0678b..cf39d91246f 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -265,6 +265,8 @@ format_ccs_e_compat_with_miptree(const struct 
gen_device_info *devinfo,
 
mesa_format linear_format = _mesa_get_srgb_format_linear(mt->format);
enum isl_format isl_format = brw_isl_format_for_mesa_format(linear_format);
+   if (isl_format == ISL_FORMAT_UNSUPPORTED)
+  return false;
return isl_formats_are_ccs_e_compatible(devinfo, isl_format, access_format);
 }
 
@@ -296,6 +298,8 @@ intel_miptree_supports_ccs_e(struct brw_context *brw,
 */
mesa_format linear_format = _mesa_get_srgb_format_linear(mt->format);
enum isl_format isl_format = brw_isl_format_for_mesa_format(linear_format);
+   if (isl_format == ISL_FORMAT_UNSUPPORTED)
+  return false;
return isl_format_supports_ccs_e(>screen->devinfo, isl_format);
 }
 
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c 
b/src/mesa/drivers/dri/i965/intel_screen.c
index 935711106c0..9f20347d512 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -342,8 +342,14 @@ modifier_is_supported(const struct gen_device_info 
*devinfo,
 
   mesa_format format = driImageFormatToGLFormat(dri_format);
   format = _mesa_get_srgb_format_linear(format);
-  if (!isl_format_supports_ccs_e(devinfo,
- brw_isl_format_for_mesa_format(format)))
+  if (format == MESA_FORMAT_NONE)
+ return false;
+
+  enum isl_format isl_format = brw_isl_format_for_mesa_format(format);
+  if (isl_format == ISL_FORMAT_UNSUPPORTED)
+ return false;
+
+  if (!isl_format_supports_ccs_e(devinfo, isl_format))
  return false;
}
 
-- 
2.17.1

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


[Mesa-dev] [Bug 106801] vma_random_test.cpp:239:18: error: non-constant-expression cannot be narrowed from type 'unsigned long' to 'uint_fast32_t' (aka 'unsigned int') in initializer list [-Wc++11-nar

2018-06-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106801

Scott D Phillips  changed:

   What|Removed |Added

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

--- Comment #1 from Scott D Phillips  ---
pushed 

commit 7d9cb8d5b6e35318fc7f8ef0cefb5c47b9c729cf
Author: Scott D Phillips 
Date:   Tue Jun 5 09:29:43 2018 -0700

util/tests/vma: Fix warning c++11-narrowing

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106801
Fixes: 943fecc569 ("util: Add a randomized test for the virtual memory
allocator")
Reviewed-by: Dylan Baker 

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


[Mesa-dev] [Bug 106776] vma_random unrecognized command line option "-std=c++11"

2018-06-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106776

--- Comment #4 from Scott D Phillips  ---
oops, I meant this one:

commit db9cec5689bfc4031e0ddcc5b177c09f2deabb07
Author: Scott D Phillips 
Date:   Fri Jun 1 16:26:56 2018 -0700

util: tests: vma test depends on C++11 support

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106776
Fixes: 943fecc569 ("util: Add a randomized test for the virtual memory
allocator")
Tested-by: Vinson Lee 
Reviewed-by: Dylan Baker 

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


[Mesa-dev] [Bug 106776] vma_random unrecognized command line option "-std=c++11"

2018-06-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106776

Scott D Phillips  changed:

   What|Removed |Added

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

--- Comment #3 from Scott D Phillips  ---
pushed

commit 7d9cb8d5b6e35318fc7f8ef0cefb5c47b9c729cf
Author: Scott D Phillips 
Date:   Tue Jun 5 09:29:43 2018 -0700

util/tests/vma: Fix warning c++11-narrowing

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106801
Fixes: 943fecc569 ("util: Add a randomized test for the virtual memory
allocator")
Reviewed-by: Dylan Baker 

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


[Mesa-dev] [Bug 106778] Files missing from tarball - intel_sanitize_gpu.*

2018-06-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106778

Scott D Phillips  changed:

   What|Removed |Added

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

--- Comment #5 from Scott D Phillips  ---
pushed:

commit a6446ce3957cb5f5552cac7269f3a7d3af631b77
Author: Scott D Phillips 
Date:   Tue Jun 5 09:33:49 2018 -0700

intel/tools: add intel_sanitize_gpu to EXTRA_DIST

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106778
Fixes: cc41603d6d ("intel/tools: new intel_sanitize_gpu tool")
Reviewed-by: Dylan Baker 

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


Re: [Mesa-dev] [PATCH] wayland/egl: initialize window surface size to window size

2018-06-05 Thread Juan A. Suarez Romero
On Tue, 2018-06-05 at 12:41 +0100, Daniel Stone wrote:
> Hi Juan,
> 
> On 5 June 2018 at 09:51, Juan A. Suarez Romero  wrote:
> > On Mon, 2018-06-04 at 13:22 +0100, Daniel Stone wrote:
> > > The first query will correctly return (w1,h1). The second query will
> > > incorrectly also return (w1,h1), even though the surface will never
> > > have that size. The third query will return (w2,h2) as the
> > > last-attached size, even though the surface will be (w3,h3) on next
> > > draw. The fourth query will correctly return (w3,h3).
> > > 
> > > I would like this to be consistent: my suggestion is that a query for
> > > the surface size always returns the size that the surface will become
> > > on the next eglSwapBuffers.
> > 
> > I've been re-reading again EGL 1.5 spec, and found this interesting parts 
> > that
> > can bring some clarification to this mess:
> 
> 'Mess' is right. :) Probably because the spec is clearly written from
> platforms which actually have a native window size outside of client
> control. e.g. on X11, the window manager can resize a window and from
> the client's point of view this is something which just happens to it:
> neither the application code nor EGL has any say at all on it. Wayland
> doesn't have this constraint, and puts the client (in this case, the
> EGL implementation) in full control of the size at all times.
> 

:)

> > - Section 3.10.1.1 ("Native Window Resizing"): if the native window
> > corresponding to _surface_ has been resized prior to the swap, _surface_ 
> > must be
> > resized to match. _surface_ will normally be resized by the EGL 
> > implementation
> > at the time the native window is resized. If the implementation cannot do 
> > this
> > transparently to the client, then *eglSwapBuffers* must detect the change 
> > and
> > resize surface prior to copying its pixels to the native window.
> > 
> > - Section 3.5.6 ("Surface Attributes"): querying `EGL_WIDTH` and 
> > `EGL_HEIGHT`
> > returns respectively the width and height, in pixels, of the surface. For a
> > window or pixmap surface, these values are initially equal to the width and
> > height of the native window or pixmap with respect to which surface was 
> > created.
> > If a native window is resized, the corresponding window surface will 
> > eventually
> > be resized by the implementation to match (as discussed in section 3.10.1). 
> > If
> > there is a discrepancy because EGL has not yet resized the window surface, 
> > the
> > size returned by *eglQuerySurface* will always be that of the EGL surface, 
> > not
> > the corresponding native window.
> > 
> > 
> > From the previous parts, I extract the following conclusions:
> > 
> > - Surface size value is indeed initialized with the native window size, as 
> > we
> > are doing in our patch.
> 
> Agree.
> 

Nice.

> > - In Wayland/Mesa, the surface is not resized at the time the native window 
> > is
> > resized; this is done in *eglSwapBuffers*, following 3.10.1.1.
> 
> Disagree, given that we are in charge of exactly when the native
> window is 'resized'. It's unclear to me what 'resize the surface prior
> to copying its pixels to the native window' even means: does this
> require we do a scale blit, or a crop blit, or?
> 
> The semantics Mesa has interpreted until recently is that
> wl_egl_resize_window() constitutes a resize _request_, and that the
> last submitted request is acted upon and latched at the first draw
> call. This then constitutes the native surface size up until the next
> first draw call. I think these are good semantics, and we have to be
> quite picky about what exactly we implement, since clients rely on
> them. Not just cosmetically (atomic resizing of subsurface chains),
> but also because if you get your window sizing wrong on the desktop,
> you'll catch a fatal error from the compositor (X11 just shrugs and
> does nothing).
> 
> I think these are good semantics (as to exactly when resize takes
> effect), but for the moment we only update the EGL_{WIDTH,HEIGHT}
> surface query results after the first draw call. I would suggest that
> in the period after eglSwapBuffers but before the first draw call, we
> also update those values, and that we update them after eglSwapBuffers
> has executed as well. This makes the semantics that any native window
> resize requests take effect immediately after eglSwapBuffers (or just
> immediately, if no swap has ever been executed) and before the first
> draw call (or buffer_age query ... cf. 9ca6711faa03) for a given
> frame; in between the first draw call and eglSwapBuffers, the native
> resize requests will be queued until after eglSwapBuffers.
> 


I see. The surface size should be updated inmediately, after a window resize is
done, as you said.

I'll send then a new patch version. Actually I'll split this patch in two: one
to correctly initialize the surface size (there is no doubt on this, and this
patch alone will fix the test), and another patch to correctly update the
surface size 

Re: [Mesa-dev] [Piglit] GitLab migration of Piglit

2018-06-05 Thread Emil Velikov
Hi Dan,

Sharing a couple of small ideas.

On 5 June 2018 at 18:02, Daniel Stone  wrote:

>>> drm-gralloc.git
Empty - please nuke, alongside bugzilla & other infra.

>>> drm.git
Out of curiosity - this and others (say igt) projects are accessible
as mesa/$foo and drm/$foo.
I'd image the same approach will be adopted in gitlab?

>>> llvm.git
Empty - nuke?

>>> mesa-test.git
Plain copy/paste just like xserver-test. There were no extra
branches/patches wrt the usual repos.
Nuke?

>>> libwsbm.git
>>> linux-agp-compat.git
>>> vmwgfx.git

Might want to check with the VMware people about these.
I'm suspecting that the developers are not keeping a close eye on mesa-dev@

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


Re: [Mesa-dev] [Mesa-stable] [PATCH 1/5] wayland-egl: allow shipping the library or not

2018-06-05 Thread Matt Turner
On Tue, Jun 5, 2018 at 8:24 AM, Emil Velikov  wrote:
> On 5 June 2018 at 16:07, Eric Engestrom  wrote:
>> On Tuesday, 2018-06-05 15:14:30 +0100, Emil Velikov wrote:
>>> From: Emil Velikov 
>>>
>>> Recently the wayland-egl library and pkg-config file were moved to the
>>> Wayland repository. With that a strange conflict came to be - which one
>>> should be used and when.
>>>
>>> The long term goal is to remove the Mesa copies, but with this patch we
>>> allow builders to explicitly select if they want it.
>>>
>>> Note: since the header (wayland-egl-backend.h) is now used by C++
>>> people, s/private/driver_private/ was applied.
>>>
>>> Cc: Eric Engestrom 
>>> CC: 18.0 18.1 
>>> Signed-off-by: Emil Velikov 
>>> ---
>>>  configure.ac| 17 +
>>>  meson.build | 12 
>>>  meson_options.txt   |  6 ++
>>>  src/Makefile.am |  2 ++
>>>  src/egl/Makefile.am |  1 +
>>>  src/egl/drivers/dri2/platform_wayland.c | 12 
>>>  src/egl/meson.build |  2 +-
>>>  src/meson.build |  2 +-
>>>  8 files changed, 52 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/configure.ac b/configure.ac
>>> index 02dca4547c8..5ea52242bd1 100644
>>> --- a/configure.ac
>>> +++ b/configure.ac
>>> @@ -89,6 +89,7 @@ LIBOMXIL_BELLAGIO_REQUIRED=0.0
>>>  LIBOMXIL_TIZONIA_REQUIRED=0.10.0
>>>  LIBVA_REQUIRED=0.39.0
>>>  VDPAU_REQUIRED=1.1
>>> +# TODO: Bump to 1.15 -> the first version that ships wayland-egl-backend
>>>  WAYLAND_REQUIRED=1.11
>>>  WAYLAND_PROTOCOLS_REQUIRED=1.8
>>>  XCB_REQUIRED=1.9.3
>>> @@ -1766,6 +1767,18 @@ if test "x$enable_glx_read_only_text" = xyes; then
>>>  DEFINES="$DEFINES -DGLX_X86_READONLY_TEXT"
>>>  fi
>>>
>>> +dnl
>>> +dnl TEMPORARY: mostly for stable releases
>>> +dnl
>>> +dnl It will allow easier management as the wayland-egl library was
>>> +dnl moved to the Wayland project
>>> +dnl
>>> +AC_ARG_ENABLE(bundled-wayland-egl,
>>> +   [AS_HELP_STRING([--disable-bundled-wayland-egl],
>>> +[disable shipping of the wayland-egl library and 
>>> pkg-config file @<:@default=enabled@:>@])],
>>> +   [enable_wayland_egl=$enableval], [enable_wayland_egl=yes])
>>> +AM_CONDITIONAL(BUILD_WAYLAND_EGL, test "x$enable_wayland_egl" = xyes)
>>
>> I'm not sure I see the benefit of your variant of adding all the
>> complexity of a new option and immediately making it an error to use it.
>> Could you explain your logic?
>>
> In all fairness, it should have been introduced when wayland-egl was
> proposed for Wayland inclusion.
> Back then I was under the naive assumption that, distribution maintainers 
> will:
>  - read mesa-maintainers@ or the wayland release notes
>  - will know how to address the multiple copies of libwayland-egl.so
>
> Since then a distribution (wish shall remain unnamed), kind of
> foobar'd both of the above.

This is not a productive way to talk to people, and as a distro
maintainer that has been aware of the change and has been asking you
specifically for guidance for months it really rubs me the wrong way.

Neither your email to mesa-maintainers@ nor the Wayland release notes
told distros what to do... because there wasn't anything that could be
done since you never finished the Mesa bits. As for knowing how to
address multiple copies of a library: we do. We delete the one we
don't need and we ask upstream to sort their crap out.

I asked on May 8th on #dri-devel:

 xexaxo1: are distros supposed to stop building Mesa with
--with-platforms=...,wayland with wayland 1.15 providing
libwayland-egl?
 I don't typically read the wayland ml, so I was surprised
to find out that there was a packaging change required like this

Never got a response.

The same day I replied to the Wayland 1.15 announcement email which says:

> libwayland-egl is now part of libwayland, and will presumably be removed
> from mesa in the not too distant future.

and asked the same question, Cc'ing you.

Never got a response.

Pekka replied on the 14th and asked you for advice.

Never got a response.

I asked Eric on the 21st if he wouldn't mind taking over. He sends
patches, and now you decide it's the time to offer a competing patch
series.

Please, let's just take Eric's series and move on with life.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH mesa] vma/tests: cast away implementation detail of using strtoul()

2018-06-05 Thread Eric Engestrom
On MacOS, the build fails because of a compiler complaint about
a downcast:

  vma_random_test.cpp:239:18: error: non-constant-expression cannot be narrowed 
from type 'unsigned long' to 'uint_fast32_t' (aka 'unsigned int') in 
initializer list [-Wc++11-narrowing]
 random_test r{seed};
   ^~~~
  vma_random_test.cpp:239:18: note: insert an explicit cast to silence this 
issue
 random_test r{seed};
   ^~~~
   static_cast( )

Let's take the compiler's suggestion, as we only needed a long here to
use strtoul().

Cc: Scott D Phillips 
Signed-off-by: Eric Engestrom 
---
 src/util/tests/vma/vma_random_test.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/tests/vma/vma_random_test.cpp 
b/src/util/tests/vma/vma_random_test.cpp
index 88beb0838614acadbb34..da3f9de1669aa47e56ce 100644
--- a/src/util/tests/vma/vma_random_test.cpp
+++ b/src/util/tests/vma/vma_random_test.cpp
@@ -236,7 +236,7 @@ int main(int argc, char **argv)
   errx(1, "USAGE: %s seed iter_count\n", argv[0]);
}
 
-   random_test r{seed};
+   random_test r{static_cast(seed)};
r.test(count);
 
printf("ok\n");
-- 
Cheers,
  Eric

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


[Mesa-dev] [PATCH v8 16/21] clover/spirv: Add functions for validating SPIR-V binaries

2018-06-05 Thread Pierre Moreau
Signed-off-by: Pierre Moreau 
---

Notes:
Changes in:
* v8: Add DEFINES to libclspirv and libclover, in autotools, as they would
  otherwise never know whether CLOVER_ALLOW_SPIRV has been defined 
(Dave Airlie)
* v7: Update the dependency name (meson) and the libs variable (Makefile) 
due
  to the replacement of llvm-spirv to the new official 
SPIRV-LLVM-Translator

 src/gallium/state_trackers/clover/Makefile.am |  17 ++-
 .../state_trackers/clover/Makefile.sources|   4 +
 src/gallium/state_trackers/clover/meson.build |  10 +-
 .../clover/spirv/invocation.cpp   | 138 ++
 .../clover/spirv/invocation.hpp   |  47 ++
 5 files changed, 213 insertions(+), 3 deletions(-)
 create mode 100644 src/gallium/state_trackers/clover/spirv/invocation.cpp
 create mode 100644 src/gallium/state_trackers/clover/spirv/invocation.hpp

diff --git a/src/gallium/state_trackers/clover/Makefile.am 
b/src/gallium/state_trackers/clover/Makefile.am
index 2f42011104f..9bc078609fd 100644
--- a/src/gallium/state_trackers/clover/Makefile.am
+++ b/src/gallium/state_trackers/clover/Makefile.am
@@ -28,7 +28,7 @@ cl_HEADERS = \
$(top_srcdir)/include/CL/opencl.h
 endif
 
-noinst_LTLIBRARIES = libclover.la libclllvm.la
+noinst_LTLIBRARIES = libclover.la libclllvm.la libclspirv.la
 
 libclllvm_la_CXXFLAGS = \
$(CXX11_CXXFLAGS) \
@@ -47,13 +47,26 @@ libclllvm_la_SOURCES = $(LLVM_SOURCES)
 libclllvm_la_LDFLAGS = \
$(LLVMSPIRVLIB_LIBS)
 
+libclspirv_la_CXXFLAGS = \
+   $(CXX11_CXXFLAGS) \
+   $(CLOVER_STD_OVERRIDE) \
+   $(DEFINES) \
+   $(VISIBILITY_CXXFLAGS) \
+   $(SPIRV_TOOLS_CFLAGS)
+
+libclspirv_la_SOURCES = $(SPIRV_SOURCES)
+
+libclspirv_la_LDFLAGS = \
+   $(SPIRV_TOOLS_LIBS)
+
 libclover_la_CXXFLAGS = \
$(CXX11_CXXFLAGS) \
$(CLOVER_STD_OVERRIDE) \
+   $(DEFINES) \
$(VISIBILITY_CXXFLAGS)
 
 libclover_la_LIBADD = \
-   libclllvm.la
+   libclllvm.la libclspirv.la
 
 libclover_la_SOURCES = $(CPP_SOURCES)
 
diff --git a/src/gallium/state_trackers/clover/Makefile.sources 
b/src/gallium/state_trackers/clover/Makefile.sources
index 5167ca75af4..38f94981fb6 100644
--- a/src/gallium/state_trackers/clover/Makefile.sources
+++ b/src/gallium/state_trackers/clover/Makefile.sources
@@ -62,3 +62,7 @@ LLVM_SOURCES := \
llvm/invocation.hpp \
llvm/metadata.hpp \
llvm/util.hpp
+
+SPIRV_SOURCES := \
+   spirv/invocation.cpp \
+   spirv/invocation.hpp
diff --git a/src/gallium/state_trackers/clover/meson.build 
b/src/gallium/state_trackers/clover/meson.build
index ff9ed044f3c..230553e8001 100644
--- a/src/gallium/state_trackers/clover/meson.build
+++ b/src/gallium/state_trackers/clover/meson.build
@@ -51,6 +51,14 @@ libclllvm = static_library(
   dependencies : [dep_llvm, dep_elf, dep_llvmspirvlib],
 )
 
+libclspirv = static_library(
+  'clspirv',
+  files('spirv/invocation.cpp', 'spirv/invocation.hpp'),
+  include_directories : clover_incs,
+  cpp_args : [cpp_vis_args],
+  dependencies : [dep_spirv_tools],
+)
+
 clover_files = files(
   'api/context.cpp',
   'api/device.cpp',
@@ -111,5 +119,5 @@ libclover = static_library(
   clover_files,
   include_directories : clover_incs,
   cpp_args : [clover_cpp_args, cpp_vis_args],
-  link_with : [libclllvm],
+  link_with : [libclllvm, libclspirv],
 )
diff --git a/src/gallium/state_trackers/clover/spirv/invocation.cpp 
b/src/gallium/state_trackers/clover/spirv/invocation.cpp
new file mode 100644
index 000..93cc49931d5
--- /dev/null
+++ b/src/gallium/state_trackers/clover/spirv/invocation.cpp
@@ -0,0 +1,138 @@
+//
+// Copyright 2018 Pierre Moreau
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#include "invocation.hpp"
+
+#ifdef CLOVER_ALLOW_SPIRV
+#include 
+#endif
+
+#include "util/u_math.h"
+
+#include "compiler/spirv/spirv.h"
+
+using namespace clover;
+
+namespace {
+
+#ifdef 

[Mesa-dev] [PATCH v8 13/21] configure.ac, meson: Check for SPIRV-Tools and llvm-spirv

2018-06-05 Thread Pierre Moreau
Reviewed-by: Karol Herbst 
Reviewed-by: Dylan Baker 
Signed-off-by: Pierre Moreau 
---

Notes:
Changes in:
* v8: * Properly align LLVMSPIRVLib comment (Dylan Baker)
  * Only define CLOVER_ALLOW_SPIRV when **both** dependencies are found:
autotools was only requiring one or the other.
* v7: Replace the llvm-spirv repository by the new official
  SPIRV-LLVM-Translator

 configure.ac | 18 ++
 meson.build  |  8 
 2 files changed, 26 insertions(+)

diff --git a/configure.ac b/configure.ac
index 62063c1c8a7..f615d98645e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2439,6 +2439,24 @@ AM_CONDITIONAL(HAVE_CLOVER_ICD, test 
"x$enable_opencl_icd" = xyes)
 AC_SUBST([OPENCL_LIBNAME])
 AC_SUBST([CLANG_RESOURCE_DIR])
 
+AS_IF([test "x$enable_opencl" = xyes], [
+PKG_CHECK_MODULES([SPIRV_TOOLS], [SPIRV-Tools >= 2018.0],
+  [have_spirv_tools=yes], [have_spirv_tools=no])])
+AC_SUBST([SPIRV_TOOLS_CFLAGS])
+AC_SUBST([SPIRV_TOOLS_LIBS])
+
+# LLVMSPIRVLib is available at 
https://github.com/KhronosGroup/SPIRV-LLVM-Translator
+AS_IF([test "x$enable_opencl" = xyes], [
+PKG_CHECK_MODULES([LLVMSPIRVLIB], [LLVMSPIRVLib >= 0.2.1],
+  [have_llvmspirvlib=yes], [have_llvmspirvlib=no])])
+AC_SUBST([LLVMSPIRVLIB_CFLAGS])
+AC_SUBST([LLVMSPIRVLIB_LIBS])
+
+if test "x$have_spirv_tools" = xyes -a \
+"x$have_llvmspirvlib" = xyes; then
+DEFINES="$DEFINES -DCLOVER_ALLOW_SPIRV"
+fi
+
 dnl
 dnl Gallium configuration
 dnl
diff --git a/meson.build b/meson.build
index d0cb8961638..f35c86a9b91 100644
--- a/meson.build
+++ b/meson.build
@@ -639,10 +639,18 @@ if _opencl != 'disabled'
 
   # TODO: alitvec?
   dep_clc = dependency('libclc')
+  dep_spirv_tools = dependency('SPIRV-Tools', required : false, version : '>= 
2018.0')
+  # LLVMSPIRVLib is available at 
https://github.com/KhronosGroup/SPIRV-LLVM-Translator
+  dep_llvmspirvlib = dependency('LLVMSPIRVLib', required : false, version : 
'>= 0.2.1')
+  if dep_spirv_tools.found() and dep_llvmspirvlib.found()
+pre_args += '-DCLOVER_ALLOW_SPIRV'
+  endif
   with_gallium_opencl = true
   with_opencl_icd = _opencl == 'icd'
 else
   dep_clc = null_dep
+  dep_spirv_tools = null_dep
+  dep_llvmspirvlib = null_dep
   with_gallium_opencl = false
   with_gallium_icd = false
 endif
-- 
2.17.1

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


Re: [Mesa-dev] [Piglit] GitLab migration of Piglit

2018-06-05 Thread Daniel Stone
On 5 June 2018 at 17:55, Eric Engestrom  wrote:
> On Tuesday, 2018-06-05 17:52:17 +0100, Daniel Stone wrote:
>> > I assume that's now mesa, libdrm, piglit, shader-db, crucible, kmscube,
>> > mesa-demos; what about igt? Anything else?
>>
>> We currently have under /git/mesa:
>> clover.git
>> crucible.git
>> demos.git
>> drm-gralloc.git
>> drm.git
>> glu.git
>> glut.git
>> glw.git
>> kmscube.git
>> libwsbm.git
>> linux-agp-compat.git
>> llvm.git
>> mesa-test.git
>> mesa.git
>> r600_demo.git
>> rbug-gui
>> shader-db.git
>> tasks.git
>> vkpipeline-db.git
>> vmwgfx.git
>
> This might just be my outsider impression, but aren't most of those
> dead/no longer maintained?

Some of them very certainly are, but keeping everything in one place
still seems like it might be a reasonable ide.

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


[Mesa-dev] [Bug 106823] Failed to recongnize keyword of shader code

2018-06-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106823

--- Comment #3 from Mark Janes  ---
Mesa passes the GLES3 variant of this test.  Also, the test is listed in the
following dEQP source file:

  android/cts/master/src/gles2-failures.txt

Are we sure that this test should pass on GLES2?

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


Re: [Mesa-dev] [Piglit] GitLab migration of Piglit

2018-06-05 Thread Eric Engestrom
On Tuesday, 2018-06-05 17:52:17 +0100, Daniel Stone wrote:
> Hi Eric,
> 
> On 5 June 2018 at 17:49, Eric Engestrom  wrote:
> > On Tuesday, 2018-06-05 09:11:58 -0700, Jason Ekstrand wrote:
> >> Given the discussion below, I think we'll make piglit a sub-project of
> >> mesa.  Those who need commit access to piglit but not mesa can be added
> >> directly to the piglit project.
> >>
> >> Unless someone objects strongly, I'll plan to migrate piglit on Thursday
> >> along with all the other mesa repos.
> >
> > "all the other mesa repos"
> > -> could we get a list? :)
> >
> > I assume that's now mesa, libdrm, piglit, shader-db, crucible, kmscube,
> > mesa-demos; what about igt? Anything else?
> 
> We currently have under /git/mesa:
> clover.git
> crucible.git
> demos.git
> drm-gralloc.git
> drm.git
> glu.git
> glut.git
> glw.git
> kmscube.git
> libwsbm.git
> linux-agp-compat.git
> llvm.git
> mesa-test.git
> mesa.git
> r600_demo.git
> rbug-gui
> shader-db.git
> tasks.git
> vkpipeline-db.git
> vmwgfx.git

This might just be my outsider impression, but aren't most of those
dead/no longer maintained?

> 
> Of those, kmscube and crucible have already been migrated.
> 
> Cheers,
> Daniel
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [Mesa-stable] [PATCH 1/5] wayland-egl: allow shipping the library or not

2018-06-05 Thread Eric Engestrom
On Tuesday, 2018-06-05 17:17:03 +0100, Emil Velikov wrote:
> On 5 June 2018 at 16:38, Eric Engestrom  wrote:
> > On Tuesday, 2018-06-05 16:24:59 +0100, Emil Velikov wrote:
> >> On 5 June 2018 at 16:07, Eric Engestrom  wrote:
> >> > On Tuesday, 2018-06-05 15:14:30 +0100, Emil Velikov wrote:
> >> >> From: Emil Velikov 
> >> >>
> >> >> Recently the wayland-egl library and pkg-config file were moved to the
> >> >> Wayland repository. With that a strange conflict came to be - which one
> >> >> should be used and when.
> >> >>
> >> >> The long term goal is to remove the Mesa copies, but with this patch we
> >> >> allow builders to explicitly select if they want it.
> >> >>
> >> >> Note: since the header (wayland-egl-backend.h) is now used by C++
> >> >> people, s/private/driver_private/ was applied.
> >> >>
> >> >> Cc: Eric Engestrom 
> >> >> CC: 18.0 18.1 
> >> >> Signed-off-by: Emil Velikov 
> >> >> ---
> >> >>  configure.ac| 17 +
> >> >>  meson.build | 12 
> >> >>  meson_options.txt   |  6 ++
> >> >>  src/Makefile.am |  2 ++
> >> >>  src/egl/Makefile.am |  1 +
> >> >>  src/egl/drivers/dri2/platform_wayland.c | 12 
> >> >>  src/egl/meson.build |  2 +-
> >> >>  src/meson.build |  2 +-
> >> >>  8 files changed, 52 insertions(+), 2 deletions(-)
> >> >>
> >> >> diff --git a/configure.ac b/configure.ac
> >> >> index 02dca4547c8..5ea52242bd1 100644
> >> >> --- a/configure.ac
> >> >> +++ b/configure.ac
> >> >> @@ -89,6 +89,7 @@ LIBOMXIL_BELLAGIO_REQUIRED=0.0
> >> >>  LIBOMXIL_TIZONIA_REQUIRED=0.10.0
> >> >>  LIBVA_REQUIRED=0.39.0
> >> >>  VDPAU_REQUIRED=1.1
> >> >> +# TODO: Bump to 1.15 -> the first version that ships 
> >> >> wayland-egl-backend
> >> >>  WAYLAND_REQUIRED=1.11
> >> >>  WAYLAND_PROTOCOLS_REQUIRED=1.8
> >> >>  XCB_REQUIRED=1.9.3
> >> >> @@ -1766,6 +1767,18 @@ if test "x$enable_glx_read_only_text" = xyes; 
> >> >> then
> >> >>  DEFINES="$DEFINES -DGLX_X86_READONLY_TEXT"
> >> >>  fi
> >> >>
> >> >> +dnl
> >> >> +dnl TEMPORARY: mostly for stable releases
> >> >> +dnl
> >> >> +dnl It will allow easier management as the wayland-egl library was
> >> >> +dnl moved to the Wayland project
> >> >> +dnl
> >> >> +AC_ARG_ENABLE(bundled-wayland-egl,
> >> >> +   [AS_HELP_STRING([--disable-bundled-wayland-egl],
> >> >> +[disable shipping of the wayland-egl library and 
> >> >> pkg-config file @<:@default=enabled@:>@])],
> >> >> +   [enable_wayland_egl=$enableval], [enable_wayland_egl=yes])
> >> >> +AM_CONDITIONAL(BUILD_WAYLAND_EGL, test "x$enable_wayland_egl" = xyes)
> >> >
> >> > I'm not sure I see the benefit of your variant of adding all the
> >> > complexity of a new option and immediately making it an error to use it.
> >> > Could you explain your logic?
> >> >
> >> In all fairness, it should have been introduced when wayland-egl was
> >> proposed for Wayland inclusion.
> >
> > Would've made sense back then, but not nowadays IMO.
> >
> Hindsight is always 20-20 :-\
> 
> >> Back then I was under the naive assumption that, distribution maintainers 
> >> will:
> >>  - read mesa-maintainers@ or the wayland release notes
> >>  - will know how to address the multiple copies of libwayland-egl.so
> >>
> >> Since then a distribution (wish shall remain unnamed), kind of
> >> foobar'd both of the above.
> >>
> >> All the complexity is ~40loc, with ~30 of which #idef guards. The
> >> annoyance might be far greater though.
> >>
> >> If you think it's too much, sure - I'll more or less squash 1+2.
> >
> > squashing 1+2 is basically my patch, plus an option that can't be used 
> > ¯\_(ツ)_/¯
> >
> Almost. The devil is in the detail - egl{,-backend}, version, removed
> over-linking.

OK, I'll look carefully at the devil^Wdetails tomorrow :)

> 
> > Like you said though, it's not so much code complexity as it is annoyance
> > I think; I can live with it if there's a benefit, I just don't see it :)
> >
> In case you've missed it - this patch is for stable@ due to the fun
> distros are having.

It's too late for distros, they've had to manually delete
libwayland-egl.so for several months now. I don't think adding code to
change the behaviour of 18.1 mid-cycle is a good idea at this point, I'd
rather leave that branch as is, and delete cleanly for 18.2

> 
> Just remembered that we'd want this for modular distros like Gentoo.
> I don't think there's other way of keeping track of when to rm -rf
> *wayland-egl*. The only solution is the toggle + the following, fairly
> obvious, two-liner.
> 
> bundled-wayland-egl? (
> <=dev-libs/wayland-1.15.0:=[${MULTILIB_USEDEP}]
> )
> 
> Plus distros can drop their rm hacks as well ;-)
> 
> Did I manage to sway you to the dark side?
> Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org

Re: [Mesa-dev] [Piglit] GitLab migration of Piglit

2018-06-05 Thread Daniel Stone
Hi Eric,

On 5 June 2018 at 17:49, Eric Engestrom  wrote:
> On Tuesday, 2018-06-05 09:11:58 -0700, Jason Ekstrand wrote:
>> Given the discussion below, I think we'll make piglit a sub-project of
>> mesa.  Those who need commit access to piglit but not mesa can be added
>> directly to the piglit project.
>>
>> Unless someone objects strongly, I'll plan to migrate piglit on Thursday
>> along with all the other mesa repos.
>
> "all the other mesa repos"
> -> could we get a list? :)
>
> I assume that's now mesa, libdrm, piglit, shader-db, crucible, kmscube,
> mesa-demos; what about igt? Anything else?

We currently have under /git/mesa:
clover.git
crucible.git
demos.git
drm-gralloc.git
drm.git
glu.git
glut.git
glw.git
kmscube.git
libwsbm.git
linux-agp-compat.git
llvm.git
mesa-test.git
mesa.git
r600_demo.git
rbug-gui
shader-db.git
tasks.git
vkpipeline-db.git
vmwgfx.git

Of those, kmscube and crucible have already been migrated.

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


Re: [Mesa-dev] [PATCH 1/5] wayland-egl: allow shipping the library or not

2018-06-05 Thread Matt Turner
On Tue, Jun 5, 2018 at 7:14 AM, Emil Velikov  wrote:
> From: Emil Velikov 
>
> Recently the wayland-egl library and pkg-config file were moved to the
> Wayland repository. With that a strange conflict came to be - which one
> should be used and when.
>
> The long term goal is to remove the Mesa copies, but with this patch we
> allow builders to explicitly select if they want it.

I understand the intention here, and it's a good idea, but the new
switch doesn't really help at this point. It probably would have made
sense back in February when the Wayland patches went in.

Distros can just remove libwayland-egl at install time to get the same
effect, and it's not a problem to require wayland-1.15 for 18.2.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [Piglit] GitLab migration of Piglit

2018-06-05 Thread Eric Engestrom
On Tuesday, 2018-06-05 09:11:58 -0700, Jason Ekstrand wrote:
> Given the discussion below, I think we'll make piglit a sub-project of
> mesa.  Those who need commit access to piglit but not mesa can be added
> directly to the piglit project.
> 
> Unless someone objects strongly, I'll plan to migrate piglit on Thursday
> along with all the other mesa repos.

"all the other mesa repos"
-> could we get a list? :)

I assume that's now mesa, libdrm, piglit, shader-db, crucible, kmscube,
mesa-demos; what about igt? Anything else?

> 
> On Mon, Jun 4, 2018 at 3:29 PM, Eric Anholt  wrote:
> 
> > Jason Ekstrand  writes:
> >
> > > All,
> > >
> > > Sorry for the mess of GitLab e-mails but there are a lot of questions to
> > > ask as this process moves forward.  Today, we're discussing piglit.  I've
> > > included both the mesa and piglit list in the hopes that people will
> > > actually see this e-mail.
> > >
> > > Honestly, I expect the migration of piglit to have much less impact on
> > most
> > > people's daily lives than moving the mesa repo.
> > >
> > > The biggest question I have is whether we actually want to continue to
> > have
> > > a separate "piglit" group.  With GitLab, we can already give someone
> > > developer access to piglit without giving them developer access to mesa.
> > > Mostly, this is a question of whether we consider piglit to be it's own
> > > project on freedesktop or a sub-project of mesa.  I don't know the answer
> > > to that question.
> >
> > So far, having it be a separate group has just been a pain in getting
> > people to contribute to piglit, when we mistakenly forget to add mesa
> > devs to it.  I don't think we need it to be a separate committer group.
> >

> ___
> Piglit mailing list
> pig...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/piglit

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


[Mesa-dev] [PATCH] i965: verify intermediate steps when converting format

2018-06-05 Thread Lionel Landwerlin
An invalid format could be computed through the
modifier_is_supported() helper. Better verify each step.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=10664
Signed-off-by: Lionel Landwerlin 
---
 src/mesa/drivers/dri/i965/intel_mipmap_tree.c |  4 
 src/mesa/drivers/dri/i965/intel_screen.c  | 10 --
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c 
b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index 69024c0678b..cf39d91246f 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -265,6 +265,8 @@ format_ccs_e_compat_with_miptree(const struct 
gen_device_info *devinfo,
 
mesa_format linear_format = _mesa_get_srgb_format_linear(mt->format);
enum isl_format isl_format = brw_isl_format_for_mesa_format(linear_format);
+   if (isl_format == ISL_FORMAT_UNSUPPORTED)
+  return false;
return isl_formats_are_ccs_e_compatible(devinfo, isl_format, access_format);
 }
 
@@ -296,6 +298,8 @@ intel_miptree_supports_ccs_e(struct brw_context *brw,
 */
mesa_format linear_format = _mesa_get_srgb_format_linear(mt->format);
enum isl_format isl_format = brw_isl_format_for_mesa_format(linear_format);
+   if (isl_format == ISL_FORMAT_UNSUPPORTED)
+  return false;
return isl_format_supports_ccs_e(>screen->devinfo, isl_format);
 }
 
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c 
b/src/mesa/drivers/dri/i965/intel_screen.c
index 935711106c0..9f20347d512 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -342,8 +342,14 @@ modifier_is_supported(const struct gen_device_info 
*devinfo,
 
   mesa_format format = driImageFormatToGLFormat(dri_format);
   format = _mesa_get_srgb_format_linear(format);
-  if (!isl_format_supports_ccs_e(devinfo,
- brw_isl_format_for_mesa_format(format)))
+  if (format == MESA_FORMAT_NONE)
+ return false;
+
+  enum isl_format isl_format = brw_isl_format_for_mesa_format(format);
+  if (isl_format == ISL_FORMAT_UNSUPPORTED)
+ return false;
+
+  if (!isl_format_supports_ccs_e(devinfo, isl_format))
  return false;
}
 
-- 
2.17.1

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


Re: [Mesa-dev] [PATCH] virgl: enable ARB_gpu_shader_fp64

2018-06-05 Thread Gurchetan Singh
Tested-by: Gurchetan Singh 
Reviewed-by: Gurchetan Singh 
On Mon, Jun 4, 2018 at 9:32 PM Dave Airlie  wrote:
>
> From: Dave Airlie 
>
> This enables ARB_gpu_shader_fp64 if the host provides it.
> ---
>  src/gallium/drivers/virgl/virgl_screen.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/virgl/virgl_screen.c 
> b/src/gallium/drivers/virgl/virgl_screen.c
> index e8d1c751779..2ba9708ebac 100644
> --- a/src/gallium/drivers/virgl/virgl_screen.c
> +++ b/src/gallium/drivers/virgl/virgl_screen.c
> @@ -213,6 +213,8 @@ virgl_get_param(struct pipe_screen *screen, enum pipe_cap 
> param)
>return vscreen->caps.caps.v1.bset.transform_feedback_overflow_query;
> case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT:
>return vscreen->caps.caps.v2.shader_buffer_offset_alignment;
> +   case PIPE_CAP_DOUBLES:
> +  return vscreen->caps.caps.v1.bset.has_fp64;
> case PIPE_CAP_TEXTURE_GATHER_SM5:
> case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
> case PIPE_CAP_FAKE_SW_MSAA:
> @@ -268,7 +270,6 @@ virgl_get_param(struct pipe_screen *screen, enum pipe_cap 
> param)
> case PIPE_CAP_POLYGON_MODE_FILL_RECTANGLE:
> case PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE:
> case PIPE_CAP_TGSI_BALLOT:
> -   case PIPE_CAP_DOUBLES:
> case PIPE_CAP_TGSI_TES_LAYER_VIEWPORT:
> case PIPE_CAP_CAN_BIND_CONST_BUFFER_AS_VERTEX:
> case PIPE_CAP_ALLOW_MAPPED_BUFFERS_DURING_EXECUTION:
> --
> 2.14.3
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [Mesa-stable] [PATCH 1/5] wayland-egl: allow shipping the library or not

2018-06-05 Thread Emil Velikov
On 5 June 2018 at 16:38, Eric Engestrom  wrote:
> On Tuesday, 2018-06-05 16:24:59 +0100, Emil Velikov wrote:
>> On 5 June 2018 at 16:07, Eric Engestrom  wrote:
>> > On Tuesday, 2018-06-05 15:14:30 +0100, Emil Velikov wrote:
>> >> From: Emil Velikov 
>> >>
>> >> Recently the wayland-egl library and pkg-config file were moved to the
>> >> Wayland repository. With that a strange conflict came to be - which one
>> >> should be used and when.
>> >>
>> >> The long term goal is to remove the Mesa copies, but with this patch we
>> >> allow builders to explicitly select if they want it.
>> >>
>> >> Note: since the header (wayland-egl-backend.h) is now used by C++
>> >> people, s/private/driver_private/ was applied.
>> >>
>> >> Cc: Eric Engestrom 
>> >> CC: 18.0 18.1 
>> >> Signed-off-by: Emil Velikov 
>> >> ---
>> >>  configure.ac| 17 +
>> >>  meson.build | 12 
>> >>  meson_options.txt   |  6 ++
>> >>  src/Makefile.am |  2 ++
>> >>  src/egl/Makefile.am |  1 +
>> >>  src/egl/drivers/dri2/platform_wayland.c | 12 
>> >>  src/egl/meson.build |  2 +-
>> >>  src/meson.build |  2 +-
>> >>  8 files changed, 52 insertions(+), 2 deletions(-)
>> >>
>> >> diff --git a/configure.ac b/configure.ac
>> >> index 02dca4547c8..5ea52242bd1 100644
>> >> --- a/configure.ac
>> >> +++ b/configure.ac
>> >> @@ -89,6 +89,7 @@ LIBOMXIL_BELLAGIO_REQUIRED=0.0
>> >>  LIBOMXIL_TIZONIA_REQUIRED=0.10.0
>> >>  LIBVA_REQUIRED=0.39.0
>> >>  VDPAU_REQUIRED=1.1
>> >> +# TODO: Bump to 1.15 -> the first version that ships wayland-egl-backend
>> >>  WAYLAND_REQUIRED=1.11
>> >>  WAYLAND_PROTOCOLS_REQUIRED=1.8
>> >>  XCB_REQUIRED=1.9.3
>> >> @@ -1766,6 +1767,18 @@ if test "x$enable_glx_read_only_text" = xyes; then
>> >>  DEFINES="$DEFINES -DGLX_X86_READONLY_TEXT"
>> >>  fi
>> >>
>> >> +dnl
>> >> +dnl TEMPORARY: mostly for stable releases
>> >> +dnl
>> >> +dnl It will allow easier management as the wayland-egl library was
>> >> +dnl moved to the Wayland project
>> >> +dnl
>> >> +AC_ARG_ENABLE(bundled-wayland-egl,
>> >> +   [AS_HELP_STRING([--disable-bundled-wayland-egl],
>> >> +[disable shipping of the wayland-egl library and 
>> >> pkg-config file @<:@default=enabled@:>@])],
>> >> +   [enable_wayland_egl=$enableval], [enable_wayland_egl=yes])
>> >> +AM_CONDITIONAL(BUILD_WAYLAND_EGL, test "x$enable_wayland_egl" = xyes)
>> >
>> > I'm not sure I see the benefit of your variant of adding all the
>> > complexity of a new option and immediately making it an error to use it.
>> > Could you explain your logic?
>> >
>> In all fairness, it should have been introduced when wayland-egl was
>> proposed for Wayland inclusion.
>
> Would've made sense back then, but not nowadays IMO.
>
Hindsight is always 20-20 :-\

>> Back then I was under the naive assumption that, distribution maintainers 
>> will:
>>  - read mesa-maintainers@ or the wayland release notes
>>  - will know how to address the multiple copies of libwayland-egl.so
>>
>> Since then a distribution (wish shall remain unnamed), kind of
>> foobar'd both of the above.
>>
>> All the complexity is ~40loc, with ~30 of which #idef guards. The
>> annoyance might be far greater though.
>>
>> If you think it's too much, sure - I'll more or less squash 1+2.
>
> squashing 1+2 is basically my patch, plus an option that can't be used 
> ¯\_(ツ)_/¯
>
Almost. The devil is in the detail - egl{,-backend}, version, removed
over-linking.

> Like you said though, it's not so much code complexity as it is annoyance
> I think; I can live with it if there's a benefit, I just don't see it :)
>
In case you've missed it - this patch is for stable@ due to the fun
distros are having.

Just remembered that we'd want this for modular distros like Gentoo.
I don't think there's other way of keeping track of when to rm -rf
*wayland-egl*. The only solution is the toggle + the following, fairly
obvious, two-liner.

bundled-wayland-egl? (
<=dev-libs/wayland-1.15.0:=[${MULTILIB_USEDEP}]
)

Plus distros can drop their rm hacks as well ;-)

Did I manage to sway you to the dark side?
Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [Piglit] GitLab migration of Piglit

2018-06-05 Thread Jason Ekstrand
Given the discussion below, I think we'll make piglit a sub-project of
mesa.  Those who need commit access to piglit but not mesa can be added
directly to the piglit project.

Unless someone objects strongly, I'll plan to migrate piglit on Thursday
along with all the other mesa repos.

On Mon, Jun 4, 2018 at 3:29 PM, Eric Anholt  wrote:

> Jason Ekstrand  writes:
>
> > All,
> >
> > Sorry for the mess of GitLab e-mails but there are a lot of questions to
> > ask as this process moves forward.  Today, we're discussing piglit.  I've
> > included both the mesa and piglit list in the hopes that people will
> > actually see this e-mail.
> >
> > Honestly, I expect the migration of piglit to have much less impact on
> most
> > people's daily lives than moving the mesa repo.
> >
> > The biggest question I have is whether we actually want to continue to
> have
> > a separate "piglit" group.  With GitLab, we can already give someone
> > developer access to piglit without giving them developer access to mesa.
> > Mostly, this is a question of whether we consider piglit to be it's own
> > project on freedesktop or a sub-project of mesa.  I don't know the answer
> > to that question.
>
> So far, having it be a separate group has just been a pain in getting
> people to contribute to piglit, when we mistakenly forget to add mesa
> devs to it.  I don't think we need it to be a separate committer group.
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 106784] 18.1.1 autotools build fail without mako

2018-06-05 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=106784

Eric Engestrom  changed:

   What|Removed |Added

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

--- Comment #9 from Eric Engestrom  ---
I just pushed the "radv needed mako all along" patch with Bas' blessing:

commit c765c39ea73178c81a8bf88fe57c8d39a01dc57d
Author: Eric Engestrom 
Date:   Mon Jun 4 12:08:15 2018 +0100

configure: radv depends on mako

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=106784
Fixes: 17201a2eb0b1b85387136 "radv: port to using updated anv
  entrypoint/extension generator."
Acked-by: Bas Nieuwenhuizen 
Signed-off-by: Eric Engestrom 

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


Re: [Mesa-dev] [PATCH 06/21] etnaviv: nir: hardwire position location

2018-06-05 Thread Rob Clark
On Tue, Jun 5, 2018 at 10:38 AM, Philipp Zabel  wrote:
> The temporary input/output register 0 is reserved for position in the
> fragment shader. Hardwire it to 0 and start other input/output variables
> at 1. The intrinsic input load and output store base corresponds to the
> temporary register number.

I didn't look at this very closely, but at RA time you can pre-color
(pre-assign) specific registers, see ra_set_node_reg().. not sure if
this would be a better approach.  I do this for a few frag shader
registers, mostly because at the time I hadn't found the cmdstream
register/bitfield to configure it to something other than r0.x..

BR,
-R

>
> Signed-off-by: Philipp Zabel 
> Signed-off-by: Michael Tretter 
> ---
>  src/gallium/drivers/etnaviv/etnaviv_nir.c | 76 +++
>  1 file changed, 76 insertions(+)
>
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir.c 
> b/src/gallium/drivers/etnaviv/etnaviv_nir.c
> index 1ddfbb818922..3b29ea9a0e76 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_nir.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_nir.c
> @@ -81,6 +81,81 @@ etna_optimize_loop(nir_shader *s)
> } while (progress);
>  }
>
> +/* The temporary PS input/output register 0 is reserved for the position */
> +static void
> +etna_hardwire_io_position(nir_shader *shader)
> +{
> +   bool fixup_needed = false;
> +   int pos_in = -1, pos_out = -1;
> +   int max_in = 0, max_out = 0;
> +
> +   if (shader->info.stage != MESA_SHADER_FRAGMENT)
> +  return;
> +
> +   nir_foreach_variable(var, >inputs) {
> +  if (var->data.location == VARYING_SLOT_POS) {
> + pos_in = var->data.driver_location;
> +  } else {
> + max_in = MAX2(max_in, var->data.driver_location);
> + if (var->data.driver_location == 0)
> +fixup_needed = true;
> +  }
> +   }
> +   nir_foreach_variable(var, >outputs) {
> +  if (var->data.location == FRAG_RESULT_DEPTH) {
> + pos_out = var->data.driver_location;
> +  } else {
> + max_out = MAX2(max_out, var->data.driver_location);
> + if (var->data.driver_location == 0)
> +fixup_needed = true;
> +  }
> +   }
> +
> +   fixup_needed |= (pos_in > 0) || (pos_out > 0);
> +   if (!fixup_needed)
> +  return;
> +
> +   if (pos_in == -1)
> +  pos_in = max_in + 1;
> +   if (pos_out == -1)
> +  pos_out = max_out + 1;
> +
> +   nir_foreach_variable(var, >inputs) {
> +  if (var->data.location == VARYING_SLOT_POS)
> + var->data.driver_location = 0;
> +  else if (var->data.driver_location < pos_in)
> + var->data.driver_location++;
> +   }
> +   nir_foreach_variable(var, >outputs) {
> +  if (var->data.location == FRAG_RESULT_DEPTH)
> + var->data.driver_location = 0;
> +  else if (var->data.driver_location < pos_out)
> + var->data.driver_location++;
> +   }
> +
> +   nir_foreach_function(function, shader) {
> +  nir_foreach_block(block, function->impl) {
> + nir_foreach_instr(instr, block) {
> +if (instr->type != nir_instr_type_intrinsic)
> +   continue;
> +nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
> +unsigned pos;
> +if (intr->intrinsic == nir_intrinsic_load_input)
> +   pos = pos_in;
> +else if (intr->intrinsic == nir_intrinsic_store_output)
> +   pos = pos_out;
> +else
> +   continue;
> +unsigned base = nir_intrinsic_base(intr);
> +if (base <= pos)
> +   nir_intrinsic_set_base(intr, (base == pos) ? 0 : (base + 1));
> + }
> +  }
> +  nir_metadata_preserve(function->impl,
> +nir_metadata_block_index | 
> nir_metadata_dominance);
> +   }
> +}
> +
>  /* Move const loads, input load intrinsics, and uniform load intrinsics to 
> the
>   * beginning of the function implementation.
>   *
> @@ -545,6 +620,7 @@ etna_optimize_nir(struct etna_shader *shader,
> NIR_PASS_V(s, nir_opt_global_to_local);
> NIR_PASS_V(s, nir_lower_regs_to_ssa);
> NIR_PASS_V(s, etna_move_load_intrinsics);
> +   NIR_PASS_V(s, etna_hardwire_io_position);
>
> etna_optimize_loop(s);
>
> --
> 2.17.1
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH mesa] travis: use correct form for array options

2018-06-05 Thread Eric Engestrom
On Tuesday, 2018-06-05 08:37:55 -0700, Dylan Baker wrote:
> You might also be interested in this:
> https://github.com/mesonbuild/meson/pull/3696

I am, thanks for doing this :)

> 
> Quoting Eric Engestrom (2018-06-05 03:59:40)
> > I'd like to eventually drop support for the confusing "an array of
> > a single empty string is meant to be interpreted as an empty array", so
> > let's start by not using it anymore.
> > 
> > Signed-off-by: Eric Engestrom 
> > ---
> >  .travis.yml | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/.travis.yml b/.travis.yml
> > index d05c40bf9d74545fa777..1f83f5b8d74d8d8c1e8c 100644
> > --- a/.travis.yml
> > +++ b/.travis.yml
> > @@ -33,7 +33,7 @@ matrix:
> >  - env:
> >  - LABEL="meson Vulkan"
> >  - BUILD=meson
> > -- MESON_OPTIONS="-Ddri-drivers= -Dgallium-drivers="
> > +- MESON_OPTIONS="-Ddri-drivers=[] -Dgallium-drivers=[]"
> >  - LLVM_VERSION=5.0
> >  - LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
> >addons:
> > @@ -53,7 +53,7 @@ matrix:
> >  - env:
> >  - LABEL="meson loaders/classic DRI"
> >  - BUILD=meson
> > -- MESON_OPTIONS="-Dvulkan-drivers= -Dgallium-drivers="
> > +- MESON_OPTIONS="-Dvulkan-drivers=[] -Dgallium-drivers=[]"
> >addons:
> >  apt:
> >packages:
> > -- 
> > Cheers,
> >   Eric
> > 


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


Re: [Mesa-dev] [PATCH 00/21] Towards NIR support for etnaviv

2018-06-05 Thread Christian Gmeiner
Am Di., 5. Juni 2018 um 16:40 Uhr schrieb Philipp Zabel
:
>
> Hi!
>
> we have been interested in NIR support for etnaviv for a while, for the
> obvious reasons: gaining access to common optimizations, better support
> for non-trivial code transformations, better register allocation, and
> the promise of OpenCL and SPIR-V support in the future.
>
> Michael and I have used our annual exploratory "tech week" last year
> and last week to get acquainted with NIR and the Vivante GPUs a bit and
> to get started compiling NIR shaders from the GLSL compiler to Vivante
> machine code.
>
> The following patches are still very much work in progress. Until now,
> this has only been tested with kmscube, weston, and glmark2 (and some
> benchmarks are not working yet, missing instruction implementations).
> We haven't even dared to run piglit yet. At this point we'd very much
> like some feedback on where we are on the right path, and where things
> could be done in a better way.
> The NIR compiler is placed next to the current TGSI translation layer,
> and still uses the same backend for code emission. NIR support is
> disabled by default, and can be enabled using the etnaviv environment
> option: ETNA_MESA_DEBUG="nir", so this could be merged without side
> effects, once it is deemed acceptable, to support further development
> in-tree.
>
> Due to the shared global register file, reducing the amount of temporary
> registers used by a shader is important for parallelism. We have added
> added a layer of virtual registers with less than four components over
> each vec4 base register using the register allocator utility, and use
> source swizzles and destination write masks to reuse the free components
> of partially occupied registers if possible.
> We use the NIR global registers, indexed to represent the registers in
> the global temporary register file, which allows us to do register
> assignment in NIR and then reuse the current code emitter without
> introducing another intermediate representation.
>
> There are already a few Vivante specific lowering passes, but we
> notably are still missing support for loops, and for lowering sin,
> cos and log functions to the Vivante specific hardware instructions
> that need prescaling and post-multiplication of the results' x and
> y components (or to replace them with approximations where the
> instructions are not supported).
>

Thanks for this nice patch series. I have been working for too long on
the nir topic
for etnaviv and never pushed any patches (which is quite sad). I have taken
another route to tackle it. I have started with a low level library to
generate valid
Vivante binaries and to be able to disassemble them. On top of this, I
have an eir
library which is a simple block based ir which makes use of the low-level lib.
And the last thing is the actual compiler which is nir based. All life outside
of the gallium driver and have some gtest based unit tests. My main goal was to
start from a green field without looking at the current tgsi based compiler.

I will have a deeper look at your patches and review them. I am quite
unsure what I
will do with my current code. I think the best would be to clean it up
and push it.

Hopefully, we can incorporate each work into a really nice new compiler.

> The patches can also be found at:
>
>   git://git.pengutronix.de/pza/mesa.git etnaviv-nir
>
> regards
> Philipp
>
> Michael Tretter (10):
>   etnaviv: extract get_mystery_meat_load_balancing
>   etnaviv: compiler: extract compile shader from tgsi
>   etnaviv: compiler: setup registers from nir
>   etnaviv: compiler: avoid using tgsi_shader_info
>   etnaviv: compiler: add code emitter for alu operations
>   etnaviv: compiler: generate instructions for log2
>   etnaviv: nir: remove undefined variables
>   etnaviv: compiler: ignore nir_instr_type_ssa_undef
>   etnaviv: nir: add extra mov for uniforms used as output
>   etnaviv: nir: avoid multiple uniform src for alu ops
>
> Philipp Zabel (11):
>   etnaviv: prefix COMPARE_FUNC enum values in rnndb
>   etnaviv: add debug option to report NIR as supported and preferred
> shader IR
>   etnaviv: generate and optimize NIR
>   etnaviv: nir: hardwire position location
>   etnaviv: nir: merge mov of result into alu op
>   etnaviv: nir: add virtual register classes
>   etnaviv: nir: add a nop intrinsic to empty shaders
>   etnaviv: compiler: generate texture loads
>   etnaviv: nir: add texture fixup path before register assignment
>   etnaviv: nir: implement conditionals
>   etnaviv: nir: globalize local registers
>
>  src/gallium/drivers/etnaviv/Makefile.am   |5 +-
>  src/gallium/drivers/etnaviv/Makefile.sources  |2 +
>  .../drivers/etnaviv/etnaviv_compiler.c|  816 +++-
>  src/gallium/drivers/etnaviv/etnaviv_debug.h   |3 +
>  src/gallium/drivers/etnaviv/etnaviv_nir.c | 1108 +
>  src/gallium/drivers/etnaviv/etnaviv_nir.h |   39 +
>  src/gallium/drivers/etnaviv/etnaviv_screen.c  

Re: [Mesa-dev] [Mesa-stable] [PATCH 1/5] wayland-egl: allow shipping the library or not

2018-06-05 Thread Eric Engestrom
On Tuesday, 2018-06-05 16:24:59 +0100, Emil Velikov wrote:
> On 5 June 2018 at 16:07, Eric Engestrom  wrote:
> > On Tuesday, 2018-06-05 15:14:30 +0100, Emil Velikov wrote:
> >> From: Emil Velikov 
> >>
> >> Recently the wayland-egl library and pkg-config file were moved to the
> >> Wayland repository. With that a strange conflict came to be - which one
> >> should be used and when.
> >>
> >> The long term goal is to remove the Mesa copies, but with this patch we
> >> allow builders to explicitly select if they want it.
> >>
> >> Note: since the header (wayland-egl-backend.h) is now used by C++
> >> people, s/private/driver_private/ was applied.
> >>
> >> Cc: Eric Engestrom 
> >> CC: 18.0 18.1 
> >> Signed-off-by: Emil Velikov 
> >> ---
> >>  configure.ac| 17 +
> >>  meson.build | 12 
> >>  meson_options.txt   |  6 ++
> >>  src/Makefile.am |  2 ++
> >>  src/egl/Makefile.am |  1 +
> >>  src/egl/drivers/dri2/platform_wayland.c | 12 
> >>  src/egl/meson.build |  2 +-
> >>  src/meson.build |  2 +-
> >>  8 files changed, 52 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/configure.ac b/configure.ac
> >> index 02dca4547c8..5ea52242bd1 100644
> >> --- a/configure.ac
> >> +++ b/configure.ac
> >> @@ -89,6 +89,7 @@ LIBOMXIL_BELLAGIO_REQUIRED=0.0
> >>  LIBOMXIL_TIZONIA_REQUIRED=0.10.0
> >>  LIBVA_REQUIRED=0.39.0
> >>  VDPAU_REQUIRED=1.1
> >> +# TODO: Bump to 1.15 -> the first version that ships wayland-egl-backend
> >>  WAYLAND_REQUIRED=1.11
> >>  WAYLAND_PROTOCOLS_REQUIRED=1.8
> >>  XCB_REQUIRED=1.9.3
> >> @@ -1766,6 +1767,18 @@ if test "x$enable_glx_read_only_text" = xyes; then
> >>  DEFINES="$DEFINES -DGLX_X86_READONLY_TEXT"
> >>  fi
> >>
> >> +dnl
> >> +dnl TEMPORARY: mostly for stable releases
> >> +dnl
> >> +dnl It will allow easier management as the wayland-egl library was
> >> +dnl moved to the Wayland project
> >> +dnl
> >> +AC_ARG_ENABLE(bundled-wayland-egl,
> >> +   [AS_HELP_STRING([--disable-bundled-wayland-egl],
> >> +[disable shipping of the wayland-egl library and 
> >> pkg-config file @<:@default=enabled@:>@])],
> >> +   [enable_wayland_egl=$enableval], [enable_wayland_egl=yes])
> >> +AM_CONDITIONAL(BUILD_WAYLAND_EGL, test "x$enable_wayland_egl" = xyes)
> >
> > I'm not sure I see the benefit of your variant of adding all the
> > complexity of a new option and immediately making it an error to use it.
> > Could you explain your logic?
> >
> In all fairness, it should have been introduced when wayland-egl was
> proposed for Wayland inclusion.

Would've made sense back then, but not nowadays IMO.

> Back then I was under the naive assumption that, distribution maintainers 
> will:
>  - read mesa-maintainers@ or the wayland release notes
>  - will know how to address the multiple copies of libwayland-egl.so
> 
> Since then a distribution (wish shall remain unnamed), kind of
> foobar'd both of the above.
> 
> All the complexity is ~40loc, with ~30 of which #idef guards. The
> annoyance might be far greater though.
> 
> If you think it's too much, sure - I'll more or less squash 1+2.

squashing 1+2 is basically my patch, plus an option that can't be used ¯\_(ツ)_/¯

Like you said though, it's not so much code complexity as it is annoyance
I think; I can live with it if there's a benefit, I just don't see it :)

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


Re: [Mesa-dev] [PATCH 08/21] etnaviv: nir: add virtual register classes

2018-06-05 Thread Rob Clark
On Tue, Jun 5, 2018 at 10:38 AM, Philipp Zabel  wrote:
> Since all threads share a global temporary vec4 register file, it is
> important to reduce temporary register use of shaders.
> Using source swizzles and destination write mask of ALU operations we
> can layer smaller virtual registers on top of the physical base
> registers that overlap with their base register and partially with each
> other:
>
>  ++-+-+-+
>  |VEC4|  VEC3   |VEC2 | SCALAR  |
>  ++-+-+-+
>  |  X | X X X   | X X X   | X   |
>  |  Y | Y Y   Y | Y Y Y   |   Y |
>  |  Z | Z   Z Z |   Z   Z   Z | Z   |
>  |  W |   W W W | W   W W |   W |
>  ++-+-+-+
>
> There are four possible virtual vec3 registers that leave the remaining
> component usable as a scalar virtual register, six possible vec2
> registers, and four possible scalar registers that only use a single
> component.
>
> This patch adds an interference graph for virtual registers to the
> register allocator, using information about SSA interference and virtual
> register overlap. If possible, SSAs with smaller num_components are
> allocated from the unused components of already partially used temporary
> registers.
>
> Signed-off-by: Philipp Zabel 
> Signed-off-by: Michael Tretter 
> ---

so one quick note, constructing the register classes can be
expensive.. you probably only want to do this once and then re-use for
each shader

BR,
-R

>  src/gallium/drivers/etnaviv/etnaviv_nir.c | 282 --
>  1 file changed, 259 insertions(+), 23 deletions(-)
>
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir.c 
> b/src/gallium/drivers/etnaviv/etnaviv_nir.c
> index b73d4be31bc6..752e87248e31 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_nir.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_nir.c
> @@ -375,11 +375,111 @@ etna_instr_replaceable_ssa_dest(nir_instr *instr)
> return NULL;
>  }
>
> -/* Return the NIR global register corresponding to a given temporary 
> register,
> - * creating it if necessary.
> +/* Swizzles and write masks can be used to layer virtual non-interfering
> + * registers on top of the real VEC4 registers. For example, the virtual
> + * VEC3_XYZ register and the virtual SCALAR_W register that use the same
> + * physical VEC4 base register do not interfere.
> + */
> +enum {
> +   ETNA_REG_CLASS_VEC4,
> +   ETNA_REG_CLASS_VIRT_VEC3,
> +   ETNA_REG_CLASS_VIRT_VEC2,
> +   ETNA_REG_CLASS_VIRT_SCALAR,
> +   ETNA_NUM_REG_CLASSES,
> +} etna_reg_class;
> +
> +enum {
> +   ETNA_REG_TYPE_VEC4,
> +   ETNA_REG_TYPE_VIRT_VEC3_XYZ,
> +   ETNA_REG_TYPE_VIRT_VEC3_XYW,
> +   ETNA_REG_TYPE_VIRT_VEC3_XZW,
> +   ETNA_REG_TYPE_VIRT_VEC3_YZW,
> +   ETNA_REG_TYPE_VIRT_VEC2_XY,
> +   ETNA_REG_TYPE_VIRT_VEC2_XZ,
> +   ETNA_REG_TYPE_VIRT_VEC2_XW,
> +   ETNA_REG_TYPE_VIRT_VEC2_YZ,
> +   ETNA_REG_TYPE_VIRT_VEC2_YW,
> +   ETNA_REG_TYPE_VIRT_VEC2_ZW,
> +   ETNA_REG_TYPE_VIRT_SCALAR_X,
> +   ETNA_REG_TYPE_VIRT_SCALAR_Y,
> +   ETNA_REG_TYPE_VIRT_SCALAR_Z,
> +   ETNA_REG_TYPE_VIRT_SCALAR_W,
> +   ETNA_NUM_REG_TYPES,
> +} etna_reg_type;
> +
> +static const uint8_t
> +etna_reg_writemask[ETNA_NUM_REG_TYPES] = {
> +   [ETNA_REG_TYPE_VEC4] = 0xf,
> +   [ETNA_REG_TYPE_VIRT_SCALAR_X] = 0x1,
> +   [ETNA_REG_TYPE_VIRT_SCALAR_Y] = 0x2,
> +   [ETNA_REG_TYPE_VIRT_VEC2_XY] = 0x3,
> +   [ETNA_REG_TYPE_VIRT_SCALAR_Z] = 0x4,
> +   [ETNA_REG_TYPE_VIRT_VEC2_XZ] = 0x5,
> +   [ETNA_REG_TYPE_VIRT_VEC2_YZ] = 0x6,
> +   [ETNA_REG_TYPE_VIRT_VEC3_XYZ] = 0x7,
> +   [ETNA_REG_TYPE_VIRT_SCALAR_W] = 0x8,
> +   [ETNA_REG_TYPE_VIRT_VEC2_XW] = 0x9,
> +   [ETNA_REG_TYPE_VIRT_VEC2_YW] = 0xa,
> +   [ETNA_REG_TYPE_VIRT_VEC3_XYW] = 0xb,
> +   [ETNA_REG_TYPE_VIRT_VEC2_ZW] = 0xc,
> +   [ETNA_REG_TYPE_VIRT_VEC3_XZW] = 0xd,
> +   [ETNA_REG_TYPE_VIRT_VEC3_YZW] = 0xe,
> +};
> +
> +static inline int etna_reg_get_type(int virt_reg)
> +{
> +   return virt_reg % ETNA_NUM_REG_TYPES;
> +}
> +
> +static inline int etna_reg_get_base(int virt_reg)
> +{
> +   return virt_reg / ETNA_NUM_REG_TYPES;
> +}
> +
> +static inline int etna_reg_get_class(int virt_reg)
> +{
> +   switch (etna_reg_get_type(virt_reg)) {
> +   case ETNA_REG_TYPE_VEC4:
> +  return ETNA_REG_CLASS_VEC4;
> +   case ETNA_REG_TYPE_VIRT_VEC3_XYZ:
> +   case ETNA_REG_TYPE_VIRT_VEC3_XYW:
> +   case ETNA_REG_TYPE_VIRT_VEC3_XZW:
> +   case ETNA_REG_TYPE_VIRT_VEC3_YZW:
> +  return ETNA_REG_CLASS_VIRT_VEC3;
> +   case ETNA_REG_TYPE_VIRT_VEC2_XY:
> +   case ETNA_REG_TYPE_VIRT_VEC2_XZ:
> +   case ETNA_REG_TYPE_VIRT_VEC2_XW:
> +   case ETNA_REG_TYPE_VIRT_VEC2_YZ:
> +   case ETNA_REG_TYPE_VIRT_VEC2_YW:
> +   case ETNA_REG_TYPE_VIRT_VEC2_ZW:
> +  return ETNA_REG_CLASS_VIRT_VEC2;
> +   case ETNA_REG_TYPE_VIRT_SCALAR_X:
> +   case ETNA_REG_TYPE_VIRT_SCALAR_Y:
> +   case ETNA_REG_TYPE_VIRT_SCALAR_Z:
> +   case ETNA_REG_TYPE_VIRT_SCALAR_W:
> +  return ETNA_REG_CLASS_VIRT_SCALAR;
> +   }
> +
> +   assert(false);
> +}
> +
> +/* Q values 

Re: [Mesa-dev] [PATCH mesa] travis: use correct form for array options

2018-06-05 Thread Dylan Baker
You might also be interested in this:
https://github.com/mesonbuild/meson/pull/3696

Quoting Eric Engestrom (2018-06-05 03:59:40)
> I'd like to eventually drop support for the confusing "an array of
> a single empty string is meant to be interpreted as an empty array", so
> let's start by not using it anymore.
> 
> Signed-off-by: Eric Engestrom 
> ---
>  .travis.yml | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/.travis.yml b/.travis.yml
> index d05c40bf9d74545fa777..1f83f5b8d74d8d8c1e8c 100644
> --- a/.travis.yml
> +++ b/.travis.yml
> @@ -33,7 +33,7 @@ matrix:
>  - env:
>  - LABEL="meson Vulkan"
>  - BUILD=meson
> -- MESON_OPTIONS="-Ddri-drivers= -Dgallium-drivers="
> +- MESON_OPTIONS="-Ddri-drivers=[] -Dgallium-drivers=[]"
>  - LLVM_VERSION=5.0
>  - LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
>addons:
> @@ -53,7 +53,7 @@ matrix:
>  - env:
>  - LABEL="meson loaders/classic DRI"
>  - BUILD=meson
> -- MESON_OPTIONS="-Dvulkan-drivers= -Dgallium-drivers="
> +- MESON_OPTIONS="-Dvulkan-drivers=[] -Dgallium-drivers=[]"
>addons:
>  apt:
>packages:
> -- 
> Cheers,
>   Eric
> 


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


[Mesa-dev] [PATCH] FIXUP: nir: convert lower_io_arrays_to_elements to deref instructions

2018-06-05 Thread Bas Nieuwenhuizen
---

Forgot this one ...

 src/amd/vulkan/radv_pipeline.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
index 34249bf843d..375f7c357d3 100644
--- a/src/amd/vulkan/radv_pipeline.c
+++ b/src/amd/vulkan/radv_pipeline.c
@@ -2039,8 +2039,6 @@ void radv_create_shaders(struct radv_pipeline *pipeline,
radv_optimize_nir(nir[i], false);
}
}
-
-   NIR_PASS_V(nir[i], nir_lower_deref_instrs, ~0);
}
 
if (nir[MESA_SHADER_TESS_CTRL]) {
-- 
2.17.0

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


Re: [Mesa-dev] [PATCH 5/5] travis: bump the wayland version to 1.15.0

2018-06-05 Thread Emil Velikov
On 5 June 2018 at 16:15, Eric Engestrom  wrote:
> On Tuesday, 2018-06-05 16:03:14 +0100, Emil Velikov wrote:
>> On 5 June 2018 at 15:36, Eric Engestrom  wrote:
>> > On Tuesday, 2018-06-05 15:14:34 +0100, Emil Velikov wrote:
>> >> From: Emil Velikov 
>> >>
>> >> As covered earlier - this is the version which ships
>> >> wayland-egl{,-backend} and associated files.
>> >>
>> >> Signed-off-by: Emil Velikov 
>> >> ---
>> >>  .travis.yml | 2 +-
>> >>  1 file changed, 1 insertion(+), 1 deletion(-)
>> >>
>> >> diff --git a/.travis.yml b/.travis.yml
>> >> index d05c40bf9d7..7d3d6d1e10d 100644
>> >> --- a/.travis.yml
>> >> +++ b/.travis.yml
>> >> @@ -22,7 +22,7 @@ env:
>> >>  - LIBXSHMFENCE_VERSION=libxshmfence-1.2
>> >>  - LIBVDPAU_VERSION=libvdpau-1.1
>> >>  - LIBVA_VERSION=libva-1.7.0
>> >> -- LIBWAYLAND_VERSION=wayland-1.11.1
>> >> +- LIBWAYLAND_VERSION=wayland-1.15.0
>> >
>> > This needs to be the first patch in the series, otherwise the rest of
>> > the series is broken in travis.
>> >
>> Was kind of split on this.
>>
>> On one hand I wanted a clear example of the breakage that will happen
>> if we don't bump 1.11 (around the branchpoint).
>> Yet, intermittent breakage is not good - so I'll move it to as 2/5.
>
> Sounds good.
>
>>
>> Speaking of Travis - meson seems to be failing, are there some patches for 
>> that?
>
> Meson?  I'm seeing dri_sw_winsys fail to build scons because of pointer
> arithmetics, and the macos autotools build doesn't like a long to int
> downcast, but the meson builds are all fine for me.
>
My bad, got confused with some of the WIP meson patches.

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


Re: [Mesa-dev] [Mesa-stable] [PATCH 1/5] wayland-egl: allow shipping the library or not

2018-06-05 Thread Emil Velikov
On 5 June 2018 at 16:07, Eric Engestrom  wrote:
> On Tuesday, 2018-06-05 15:14:30 +0100, Emil Velikov wrote:
>> From: Emil Velikov 
>>
>> Recently the wayland-egl library and pkg-config file were moved to the
>> Wayland repository. With that a strange conflict came to be - which one
>> should be used and when.
>>
>> The long term goal is to remove the Mesa copies, but with this patch we
>> allow builders to explicitly select if they want it.
>>
>> Note: since the header (wayland-egl-backend.h) is now used by C++
>> people, s/private/driver_private/ was applied.
>>
>> Cc: Eric Engestrom 
>> CC: 18.0 18.1 
>> Signed-off-by: Emil Velikov 
>> ---
>>  configure.ac| 17 +
>>  meson.build | 12 
>>  meson_options.txt   |  6 ++
>>  src/Makefile.am |  2 ++
>>  src/egl/Makefile.am |  1 +
>>  src/egl/drivers/dri2/platform_wayland.c | 12 
>>  src/egl/meson.build |  2 +-
>>  src/meson.build |  2 +-
>>  8 files changed, 52 insertions(+), 2 deletions(-)
>>
>> diff --git a/configure.ac b/configure.ac
>> index 02dca4547c8..5ea52242bd1 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -89,6 +89,7 @@ LIBOMXIL_BELLAGIO_REQUIRED=0.0
>>  LIBOMXIL_TIZONIA_REQUIRED=0.10.0
>>  LIBVA_REQUIRED=0.39.0
>>  VDPAU_REQUIRED=1.1
>> +# TODO: Bump to 1.15 -> the first version that ships wayland-egl-backend
>>  WAYLAND_REQUIRED=1.11
>>  WAYLAND_PROTOCOLS_REQUIRED=1.8
>>  XCB_REQUIRED=1.9.3
>> @@ -1766,6 +1767,18 @@ if test "x$enable_glx_read_only_text" = xyes; then
>>  DEFINES="$DEFINES -DGLX_X86_READONLY_TEXT"
>>  fi
>>
>> +dnl
>> +dnl TEMPORARY: mostly for stable releases
>> +dnl
>> +dnl It will allow easier management as the wayland-egl library was
>> +dnl moved to the Wayland project
>> +dnl
>> +AC_ARG_ENABLE(bundled-wayland-egl,
>> +   [AS_HELP_STRING([--disable-bundled-wayland-egl],
>> +[disable shipping of the wayland-egl library and pkg-config 
>> file @<:@default=enabled@:>@])],
>> +   [enable_wayland_egl=$enableval], [enable_wayland_egl=yes])
>> +AM_CONDITIONAL(BUILD_WAYLAND_EGL, test "x$enable_wayland_egl" = xyes)
>
> I'm not sure I see the benefit of your variant of adding all the
> complexity of a new option and immediately making it an error to use it.
> Could you explain your logic?
>
In all fairness, it should have been introduced when wayland-egl was
proposed for Wayland inclusion.
Back then I was under the naive assumption that, distribution maintainers will:
 - read mesa-maintainers@ or the wayland release notes
 - will know how to address the multiple copies of libwayland-egl.so

Since then a distribution (wish shall remain unnamed), kind of
foobar'd both of the above.

All the complexity is ~40loc, with ~30 of which #idef guards. The
annoyance might be far greater though.

If you think it's too much, sure - I'll more or less squash 1+2.

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


Re: [Mesa-dev] [PATCH mesa] travis: use correct form for array options

2018-06-05 Thread Dylan Baker
This seems fine to me,

Reviewed-by: Dylan Baker 

Quoting Eric Engestrom (2018-06-05 03:59:40)
> I'd like to eventually drop support for the confusing "an array of
> a single empty string is meant to be interpreted as an empty array", so
> let's start by not using it anymore.
> 
> Signed-off-by: Eric Engestrom 
> ---
>  .travis.yml | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/.travis.yml b/.travis.yml
> index d05c40bf9d74545fa777..1f83f5b8d74d8d8c1e8c 100644
> --- a/.travis.yml
> +++ b/.travis.yml
> @@ -33,7 +33,7 @@ matrix:
>  - env:
>  - LABEL="meson Vulkan"
>  - BUILD=meson
> -- MESON_OPTIONS="-Ddri-drivers= -Dgallium-drivers="
> +- MESON_OPTIONS="-Ddri-drivers=[] -Dgallium-drivers=[]"
>  - LLVM_VERSION=5.0
>  - LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
>addons:
> @@ -53,7 +53,7 @@ matrix:
>  - env:
>  - LABEL="meson loaders/classic DRI"
>  - BUILD=meson
> -- MESON_OPTIONS="-Dvulkan-drivers= -Dgallium-drivers="
> +- MESON_OPTIONS="-Dvulkan-drivers=[] -Dgallium-drivers=[]"
>addons:
>  apt:
>packages:
> -- 
> Cheers,
>   Eric
> 


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


Re: [Mesa-dev] [PATCH 5/5] travis: bump the wayland version to 1.15.0

2018-06-05 Thread Eric Engestrom
On Tuesday, 2018-06-05 16:03:14 +0100, Emil Velikov wrote:
> On 5 June 2018 at 15:36, Eric Engestrom  wrote:
> > On Tuesday, 2018-06-05 15:14:34 +0100, Emil Velikov wrote:
> >> From: Emil Velikov 
> >>
> >> As covered earlier - this is the version which ships
> >> wayland-egl{,-backend} and associated files.
> >>
> >> Signed-off-by: Emil Velikov 
> >> ---
> >>  .travis.yml | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/.travis.yml b/.travis.yml
> >> index d05c40bf9d7..7d3d6d1e10d 100644
> >> --- a/.travis.yml
> >> +++ b/.travis.yml
> >> @@ -22,7 +22,7 @@ env:
> >>  - LIBXSHMFENCE_VERSION=libxshmfence-1.2
> >>  - LIBVDPAU_VERSION=libvdpau-1.1
> >>  - LIBVA_VERSION=libva-1.7.0
> >> -- LIBWAYLAND_VERSION=wayland-1.11.1
> >> +- LIBWAYLAND_VERSION=wayland-1.15.0
> >
> > This needs to be the first patch in the series, otherwise the rest of
> > the series is broken in travis.
> >
> Was kind of split on this.
> 
> On one hand I wanted a clear example of the breakage that will happen
> if we don't bump 1.11 (around the branchpoint).
> Yet, intermittent breakage is not good - so I'll move it to as 2/5.

Sounds good.

> 
> Speaking of Travis - meson seems to be failing, are there some patches for 
> that?

Meson?  I'm seeing dri_sw_winsys fail to build scons because of pointer
arithmetics, and the macos autotools build doesn't like a long to int
downcast, but the meson builds are all fine for me.

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


Re: [Mesa-dev] [PATCH 1/5] wayland-egl: allow shipping the library or not

2018-06-05 Thread Eric Engestrom
On Tuesday, 2018-06-05 15:14:30 +0100, Emil Velikov wrote:
> From: Emil Velikov 
> 
> Recently the wayland-egl library and pkg-config file were moved to the
> Wayland repository. With that a strange conflict came to be - which one
> should be used and when.
> 
> The long term goal is to remove the Mesa copies, but with this patch we
> allow builders to explicitly select if they want it.
> 
> Note: since the header (wayland-egl-backend.h) is now used by C++
> people, s/private/driver_private/ was applied.
> 
> Cc: Eric Engestrom 
> CC: 18.0 18.1 
> Signed-off-by: Emil Velikov 
> ---
>  configure.ac| 17 +
>  meson.build | 12 
>  meson_options.txt   |  6 ++
>  src/Makefile.am |  2 ++
>  src/egl/Makefile.am |  1 +
>  src/egl/drivers/dri2/platform_wayland.c | 12 
>  src/egl/meson.build |  2 +-
>  src/meson.build |  2 +-
>  8 files changed, 52 insertions(+), 2 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 02dca4547c8..5ea52242bd1 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -89,6 +89,7 @@ LIBOMXIL_BELLAGIO_REQUIRED=0.0
>  LIBOMXIL_TIZONIA_REQUIRED=0.10.0
>  LIBVA_REQUIRED=0.39.0
>  VDPAU_REQUIRED=1.1
> +# TODO: Bump to 1.15 -> the first version that ships wayland-egl-backend
>  WAYLAND_REQUIRED=1.11
>  WAYLAND_PROTOCOLS_REQUIRED=1.8
>  XCB_REQUIRED=1.9.3
> @@ -1766,6 +1767,18 @@ if test "x$enable_glx_read_only_text" = xyes; then
>  DEFINES="$DEFINES -DGLX_X86_READONLY_TEXT"
>  fi
>  
> +dnl
> +dnl TEMPORARY: mostly for stable releases
> +dnl
> +dnl It will allow easier management as the wayland-egl library was
> +dnl moved to the Wayland project
> +dnl
> +AC_ARG_ENABLE(bundled-wayland-egl,
> +   [AS_HELP_STRING([--disable-bundled-wayland-egl],
> +[disable shipping of the wayland-egl library and pkg-config 
> file @<:@default=enabled@:>@])],
> +   [enable_wayland_egl=$enableval], [enable_wayland_egl=yes])
> +AM_CONDITIONAL(BUILD_WAYLAND_EGL, test "x$enable_wayland_egl" = xyes)

I'm not sure I see the benefit of your variant of adding all the
complexity of a new option and immediately making it an error to use it.
Could you explain your logic?

> +
>  dnl
>  dnl DEPRECATED: EGL Platforms configuration
>  dnl
> @@ -1807,6 +1820,10 @@ for plat in $platforms; do
>  
>  PKG_CHECK_MODULES([WAYLAND_CLIENT], [wayland-client >= 
> $WAYLAND_REQUIRED])
>  PKG_CHECK_MODULES([WAYLAND_SERVER], [wayland-server >= 
> $WAYLAND_REQUIRED])
> +if test "x$enable_egl" = xyes -a "x$enable_wayland_egl" != xyes; then
> +PKG_CHECK_MODULES([WAYLAND_EGL], [wayland-egl-backend >= 3])
> +DEFINES="$DEFINES -DUSE_EXTERNAL_WAYLAND_EGL"
> +fi
>  PKG_CHECK_MODULES([WAYLAND_PROTOCOLS], [wayland-protocols >= 
> $WAYLAND_PROTOCOLS_REQUIRED])
>  WAYLAND_PROTOCOLS_DATADIR=`$PKG_CONFIG --variable=pkgdatadir 
> wayland-protocols`
>  
> diff --git a/meson.build b/meson.build
> index 4aafba802a5..a4c72dad41a 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -1229,8 +1229,19 @@ endif
>  if with_platform_wayland
>prog_wl_scanner = find_program('wayland-scanner')
>dep_wl_protocols = dependency('wayland-protocols', version : '>= 1.8')
> +  # TODO: Bump to 1.15 -> the first version that ships wayland-egl-backend
>dep_wayland_client = dependency('wayland-client', version : '>=1.11')
>dep_wayland_server = dependency('wayland-server', version : '>=1.11')
> +  build_wayland_egl = get_option('bundled-wayland-egl')
> +  if with_egl and not build_wayland_egl
> +dep_wayland_egl = dependency('wayland-egl-backend', version : '>= 3')
> +dep_wayland_egl_headers = declare_dependency(
> +  compile_args : run_command(prog_pkgconfig, ['wayland-egl-backend', 
> '--cflags']).stdout().split()
> +)
> +pre_args += ['-DUSE_EXTERNAL_WAYLAND_EGL']
> +  else
> +dep_wayland_egl_headers = null_dep
> +  endif
>wayland_dmabuf_xml = join_paths(
>  dep_wl_protocols.get_pkgconfig_variable('pkgdatadir'), 'unstable',
>  'linux-dmabuf', 'linux-dmabuf-unstable-v1.xml'
> @@ -1241,6 +1252,7 @@ else
>dep_wl_protocols = null_dep
>dep_wayland_client = null_dep
>dep_wayland_server = null_dep
> +  dep_wayland_egl_headers = null_dep
>wayland_dmabuf_xml = ''
>  endif
>  
> diff --git a/meson_options.txt b/meson_options.txt
> index 2c1f514debe..77d7c283fc9 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -212,6 +212,12 @@ option(
>choices : ['auto', 'true', 'false'],
>description : 'Build support for EGL platform'
>  )
> +option(
> +  'bundled-wayland-egl',
> +  type : 'boolean',
> +  value : true,
> +  description : 'Build/ship the wayland-egl library and pkg-config file'
> +)
>  option(
>'glvnd',
>type : 'boolean',
> diff --git a/src/Makefile.am b/src/Makefile.am
> index 

Re: [Mesa-dev] [PATCH 5/5] travis: bump the wayland version to 1.15.0

2018-06-05 Thread Emil Velikov
On 5 June 2018 at 15:36, Eric Engestrom  wrote:
> On Tuesday, 2018-06-05 15:14:34 +0100, Emil Velikov wrote:
>> From: Emil Velikov 
>>
>> As covered earlier - this is the version which ships
>> wayland-egl{,-backend} and associated files.
>>
>> Signed-off-by: Emil Velikov 
>> ---
>>  .travis.yml | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/.travis.yml b/.travis.yml
>> index d05c40bf9d7..7d3d6d1e10d 100644
>> --- a/.travis.yml
>> +++ b/.travis.yml
>> @@ -22,7 +22,7 @@ env:
>>  - LIBXSHMFENCE_VERSION=libxshmfence-1.2
>>  - LIBVDPAU_VERSION=libvdpau-1.1
>>  - LIBVA_VERSION=libva-1.7.0
>> -- LIBWAYLAND_VERSION=wayland-1.11.1
>> +- LIBWAYLAND_VERSION=wayland-1.15.0
>
> This needs to be the first patch in the series, otherwise the rest of
> the series is broken in travis.
>
Was kind of split on this.

On one hand I wanted a clear example of the breakage that will happen
if we don't bump 1.11 (around the branchpoint).
Yet, intermittent breakage is not good - so I'll move it to as 2/5.

Speaking of Travis - meson seems to be failing, are there some patches for that?

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


Re: [Mesa-dev] [PATCH v4 000/129] nir: Move to using instructions for derefs

2018-06-05 Thread Jason Ekstrand
On Sun, Jun 3, 2018 at 4:18 PM, Bas Nieuwenhuizen 
wrote:

> On Sat, Jun 2, 2018 at 2:48 AM, Rob Clark  wrote:
> > On Fri, Jun 1, 2018 at 1:01 AM, Jason Ekstrand 
> wrote:
> >> This is something that Connor and I have been talking about for some
> time
> >> now.  The basic idea is to replace the current singly linked nir_deref
> list
> >> with deref instructions.  This is similar to what LLVM does and it
> offers
> >> quite a bit more freedom when we start getting more realistic pointers
> from
> >> compute applications.
> >>
> >> Right now, we still have a fully "logical" pointer model where pointer
> >> chains eventually terminate at variable dereferences.  In future, we'd
> like
> >> to be able to use nir_deref_instrs for things like UBOs and SSBOs where
> tha
> >> tmay not be the case.  There are still a couple open questions around
> how
> >> we want to handle "raw" pointers in SPIR-V for OpenCL drivers
> particularly
> >> around casting.  However, the hard part is getting the deref
> instructions
> >> and getting everything switched over to them.  Now that we've done that,
> >> some of those other details can be sorted out later.
> >>
> >> This series is, as far as Rob, Bas, and I can tell, a complete and
> correct
> >> transition for all NIR-based drivers.  The final patch deletes the data
> >> structures and helpers for the older deref chains.
> >>
> >> A massive thank you goes out to Rob for putting the final patch set
> >> together and trying to get things in an order that will hopefully not
> >> regress anyone.  Thanks also to Bas for fixing up the radeon and radv
> >> bits.
> >>
> >> This series can be found as a branch on gitlab:
> >>
> >> https://gitlab.freedesktop.org/jekstrand/mesa/commits/
> review/nir-deref-instr-v4
> >>
> >> Ideally, I'd like the series to get some amount of real review before it
> >> lands.  Honestly, it's been baking long enough and tested by enough
> people
> >> on enough drivers that we can probably throw a bunch of Acked-by and
> >> Tested-bys on it and call it a day but I'd rather not.  I plan to review
> >> all of the patches I didn't write but that will have to wait until
> >> tomorrow.
> >>
> >> At the very least, I'd like some sort of an ACK from a variety of the
> >> people that use NIR on the core concept and the sort of general shape of
> >> things at the end of the series.  A lot of work has gone into this but
> it's
> >> also a big change and the more positive feedback it gets, the more
> >> comfortable I'll be pulling the trigger.
> >
> > fwiw, with the issues that Bas hit, strong a-b from me..
>
> With the fixups I just sent (and which the list will hopefully pick up
> soon ...) and the mentioned patch moves in the cover letter (and Daves
> r-b applied on the original AMD patches?), this series is acked-by me.
>

Cool.  I've applied your patches and they are now in my
wip/nir-deref-instrs branch.  Please double-check that I applied them
correctly.

--Jason


> - Bas
>
> >
> > I've been working with the patchset for a while, (and a big stack of
> > compute related patches on top that I'd like to be able to start
> > sending to list) and the handful of comments made on irc in the early
> > stages have been addressed.  This makes for a much cleaner base to
> > start adding "real" pointer support for compute, so I'm totally happy,
> > it works out much cleaner than earlier attempts based on working
> > around deref chains :-)
> >
> > not a traditional patch-by-patch review, so not really sure r-b is
> > appropriate, but I'm pretty happy with the result (and the amount of
> > churn involved does make tranditional patch-by-patch review difficult)
> >
> > BR,
> > -R
> >
> >>
> >> Thanks,
> >>
> >> --Jason Ekstrand
> >>
> >>
> >>
> >> Cc: Rob Clark 
> >> Cc: Timothy Arceri 
> >> Cc: Eric Anholt 
> >> Cc: Connor Abbott 
> >> Cc: Bas Nieuwenhuizen 
> >> Cc: Karol Herbst 
> >> Cc: Matt Turner 
> >> Cc: Kenneth Graunke 
> >> Cc: Ian Romanick 
> >>
> >> Bas Nieuwenhuizen (16):
> >>   ac/nir: Implement the deref instr for shared memory.
> >>   ac/nir: Support deref instructions in get_sampler_desc.
> >>   ac/nir: Support deref instructions in tex instructions.
> >>   ac/nir: Implement derefs for integer gather4 lowering.
> >>   ac/nir: Add deref support to image intrinsics.
> >>   radv: Add shader info support for image deref instructions.
> >>   ac/nir: Add deref based var loads/stores.
> >>   radv: Gather info for deref instr based load/store.
> >>   ac/nir: Add shared atomic deref instr support.
> >>   ac/nir: Add deref interp support.
> >>   radv: Use deref instructions for tex derefs in meta shaders.
> >>   radv: Remove image_var stores.
> >>   radeonsi: Add deref support to the nir scan pass.
> >>   ac/nir: Remove deref chain support.
> >>   radv: Remove deref chain support in radv shader info pass.
> >>   radeonsi: Remove deref chain support in nir scan pass.
> >>
> >> Eric Anholt (1):
> >>   broadcom/vc4: Remove deref chain support from nir_lower_txf_ms.
> >>

[Mesa-dev] [PATCH 15/21] etnaviv: compiler: ignore nir_instr_type_ssa_undef

2018-06-05 Thread Philipp Zabel
From: Michael Tretter 

Ignore ssa_undef nir instructions when generating code, because all
users of the undefined values are removed and undefined values are not
used. The instructions should be removed while rewriting the users of
undefined variables, but are not removed yet.

Signed-off-by: Michael Tretter 
Signed-off-by: Philipp Zabel 
---
 src/gallium/drivers/etnaviv/etnaviv_compiler.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
index 66553199fe19..f17b9979b705 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
@@ -2199,6 +2199,9 @@ etna_emit_instr(struct etna_compile *c, nir_instr *instr)
case nir_instr_type_load_const:
   /* Nothing to do */
   break;
+   case nir_instr_type_ssa_undef:
+  /* TODO: ssa_undef should be removed already */
+  break;
default:
   BUG("Unhandled nir_instr: %d", instr->type);
   assert(0);
-- 
2.17.1

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


[Mesa-dev] [PATCH 21/21] etnaviv: nir: globalize local registers

2018-06-05 Thread Philipp Zabel
We represent allocated temporaries as NIR global registers. Turn local
registers left over by the nir_convert_from_ssa pass into global
registers with the correct temporary number.

Signed-off-by: Philipp Zabel 
---
 src/gallium/drivers/etnaviv/etnaviv_nir.c | 21 +
 1 file changed, 21 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir.c 
b/src/gallium/drivers/etnaviv/etnaviv_nir.c
index 36ec21fbd623..b50c9f16a456 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_nir.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_nir.c
@@ -920,6 +920,26 @@ etna_assign_registers(nir_shader *shader)
ralloc_free(regs);
 }
 
+/* Replace local registers created by the nir_convert_from_ssa pass to global
+ * registers, order them after the global registers created by register
+ * assignment.
+ */
+static void
+etna_globalize_local_registers(nir_shader *shader)
+{
+   nir_foreach_function(function, shader) {
+  nir_foreach_register_safe(reg, >impl->registers) {
+ nir_register *global_reg = nir_global_reg_create(shader);
+ global_reg->num_components = reg->num_components;
+ nir_foreach_use_safe(src, reg)
+nir_instr_rewrite_src(src->parent_instr, src, 
nir_src_for_reg(global_reg));
+ nir_foreach_def_safe(dest, reg)
+nir_instr_rewrite_dest(dest->reg.parent_instr, dest, 
nir_dest_for_reg(global_reg));
+ nir_reg_remove(reg);
+  }
+   }
+}
+
 /* Uniforms cannot directly be used as output. Add a move to register for
  * uniforms that are used as output. */
 static void
@@ -1062,6 +1082,7 @@ etna_optimize_nir(struct etna_shader *shader,
NIR_PASS_V(s, etna_fix_alu_uniform_src);
NIR_PASS_V(s, etna_add_mov_for_uniform_output);
NIR_PASS_V(s, etna_assign_registers);
+   NIR_PASS_V(s, etna_globalize_local_registers);
NIR_PASS_V(s, etna_remove_io_intrinsics);
 
NIR_PASS_V(s, nir_opt_dce);
-- 
2.17.1

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


[Mesa-dev] [PATCH 06/21] etnaviv: nir: hardwire position location

2018-06-05 Thread Philipp Zabel
The temporary input/output register 0 is reserved for position in the
fragment shader. Hardwire it to 0 and start other input/output variables
at 1. The intrinsic input load and output store base corresponds to the
temporary register number.

Signed-off-by: Philipp Zabel 
Signed-off-by: Michael Tretter 
---
 src/gallium/drivers/etnaviv/etnaviv_nir.c | 76 +++
 1 file changed, 76 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir.c 
b/src/gallium/drivers/etnaviv/etnaviv_nir.c
index 1ddfbb818922..3b29ea9a0e76 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_nir.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_nir.c
@@ -81,6 +81,81 @@ etna_optimize_loop(nir_shader *s)
} while (progress);
 }
 
+/* The temporary PS input/output register 0 is reserved for the position */
+static void
+etna_hardwire_io_position(nir_shader *shader)
+{
+   bool fixup_needed = false;
+   int pos_in = -1, pos_out = -1;
+   int max_in = 0, max_out = 0;
+
+   if (shader->info.stage != MESA_SHADER_FRAGMENT)
+  return;
+
+   nir_foreach_variable(var, >inputs) {
+  if (var->data.location == VARYING_SLOT_POS) {
+ pos_in = var->data.driver_location;
+  } else {
+ max_in = MAX2(max_in, var->data.driver_location);
+ if (var->data.driver_location == 0)
+fixup_needed = true;
+  }
+   }
+   nir_foreach_variable(var, >outputs) {
+  if (var->data.location == FRAG_RESULT_DEPTH) {
+ pos_out = var->data.driver_location;
+  } else {
+ max_out = MAX2(max_out, var->data.driver_location);
+ if (var->data.driver_location == 0)
+fixup_needed = true;
+  }
+   }
+
+   fixup_needed |= (pos_in > 0) || (pos_out > 0);
+   if (!fixup_needed)
+  return;
+
+   if (pos_in == -1)
+  pos_in = max_in + 1;
+   if (pos_out == -1)
+  pos_out = max_out + 1;
+
+   nir_foreach_variable(var, >inputs) {
+  if (var->data.location == VARYING_SLOT_POS)
+ var->data.driver_location = 0;
+  else if (var->data.driver_location < pos_in)
+ var->data.driver_location++;
+   }
+   nir_foreach_variable(var, >outputs) {
+  if (var->data.location == FRAG_RESULT_DEPTH)
+ var->data.driver_location = 0;
+  else if (var->data.driver_location < pos_out)
+ var->data.driver_location++;
+   }
+
+   nir_foreach_function(function, shader) {
+  nir_foreach_block(block, function->impl) {
+ nir_foreach_instr(instr, block) {
+if (instr->type != nir_instr_type_intrinsic)
+   continue;
+nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
+unsigned pos;
+if (intr->intrinsic == nir_intrinsic_load_input)
+   pos = pos_in;
+else if (intr->intrinsic == nir_intrinsic_store_output)
+   pos = pos_out;
+else
+   continue;
+unsigned base = nir_intrinsic_base(intr);
+if (base <= pos)
+   nir_intrinsic_set_base(intr, (base == pos) ? 0 : (base + 1));
+ }
+  }
+  nir_metadata_preserve(function->impl,
+nir_metadata_block_index | nir_metadata_dominance);
+   }
+}
+
 /* Move const loads, input load intrinsics, and uniform load intrinsics to the
  * beginning of the function implementation.
  *
@@ -545,6 +620,7 @@ etna_optimize_nir(struct etna_shader *shader,
NIR_PASS_V(s, nir_opt_global_to_local);
NIR_PASS_V(s, nir_lower_regs_to_ssa);
NIR_PASS_V(s, etna_move_load_intrinsics);
+   NIR_PASS_V(s, etna_hardwire_io_position);
 
etna_optimize_loop(s);
 
-- 
2.17.1

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


[Mesa-dev] [PATCH 19/21] etnaviv: nir: add extra mov for uniforms used as output

2018-06-05 Thread Philipp Zabel
From: Michael Tretter 

If a uniform is source to an output store operation, we have to emit an
actual mov instruction that copies from the uniform register into the
temporary register that is used as a shader output.

Signed-off-by: Michael Tretter 
Signed-off-by: Philipp Zabel 
---
 src/gallium/drivers/etnaviv/etnaviv_nir.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir.c 
b/src/gallium/drivers/etnaviv/etnaviv_nir.c
index d8bd282eaeca..988b4bd62b6e 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_nir.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_nir.c
@@ -920,6 +920,28 @@ etna_assign_registers(nir_shader *shader)
ralloc_free(regs);
 }
 
+/* Uniforms cannot directly be used as output. Add a move to register for
+ * uniforms that are used as output. */
+static void
+etna_add_mov_for_uniform_output(nir_shader *shader)
+{
+   nir_foreach_function(function, shader) {
+  nir_foreach_block(block, function->impl) {
+ nir_foreach_instr_safe(instr, block) {
+if (instr->type != nir_instr_type_intrinsic)
+   continue;
+
+nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
+if (intr->intrinsic != nir_intrinsic_store_output ||
+!nir_src_is_dynamically_uniform(intr->src[0]))
+   continue;
+insert_mov(>instr, >src[0], shader);
+ }
+  }
+  nir_metadata_preserve(function->impl, nir_metadata_block_index);
+   }
+}
+
 /* Remove input_load and output_store intrinsics after global register
  * allocation. After the SSA destinations are replaced, these contain no useful
  * information anymore.
@@ -1002,6 +1024,7 @@ etna_optimize_nir(struct etna_shader *shader,
 
NIR_PASS_V(s, nir_convert_from_ssa, true);
NIR_PASS_V(s, etna_fixup_tex);
+   NIR_PASS_V(s, etna_add_mov_for_uniform_output);
NIR_PASS_V(s, etna_assign_registers);
NIR_PASS_V(s, etna_remove_io_intrinsics);
 
-- 
2.17.1

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


[Mesa-dev] [PATCH 20/21] etnaviv: nir: avoid multiple uniform src for alu ops

2018-06-05 Thread Philipp Zabel
From: Michael Tretter 

The hardware does not allow two different uniform registers to be used
as sources in the same ALU instruction. Emit mov instructions to
temporary registers for all but one uniform register in this case.

Signed-off-by: Michael Tretter 
Signed-off-by: Philipp Zabel 
---
 src/gallium/drivers/etnaviv/etnaviv_nir.c | 36 +++
 1 file changed, 36 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir.c 
b/src/gallium/drivers/etnaviv/etnaviv_nir.c
index 988b4bd62b6e..36ec21fbd623 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_nir.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_nir.c
@@ -942,6 +942,41 @@ etna_add_mov_for_uniform_output(nir_shader *shader)
}
 }
 
+/* Accessing two different uniforms from one alu instruction is illegal.
+ * Insert a mov for all but one uniform before alu instructions.
+ */
+static void
+etna_fix_alu_uniform_src(nir_shader *shader)
+{
+   nir_foreach_function(function, shader) {
+  nir_foreach_block(block, function->impl) {
+ nir_foreach_instr_safe(instr, block) {
+if (instr->type != nir_instr_type_alu)
+   continue;
+nir_alu_instr *alu = nir_instr_as_alu(instr);
+
+unsigned i;
+bool needs_fixup = false;
+
+for (i = 0; i < nir_op_infos[alu->op].num_inputs; i++) {
+   nir_src *src = >src[i].src;
+   if (!src->is_ssa || !nir_src_is_dynamically_uniform(*src))
+  continue;
+
+   /* FIXME The fixup unnecessarily fixes instructions where the
+* same uniform is used twice, which is allowed.
+*/
+   if (needs_fixup) {
+  insert_mov(>instr, src, shader);
+   } else
+  needs_fixup = true;
+}
+ }
+  }
+  nir_metadata_preserve(function->impl, nir_metadata_block_index);
+   }
+}
+
 /* Remove input_load and output_store intrinsics after global register
  * allocation. After the SSA destinations are replaced, these contain no useful
  * information anymore.
@@ -1024,6 +1059,7 @@ etna_optimize_nir(struct etna_shader *shader,
 
NIR_PASS_V(s, nir_convert_from_ssa, true);
NIR_PASS_V(s, etna_fixup_tex);
+   NIR_PASS_V(s, etna_fix_alu_uniform_src);
NIR_PASS_V(s, etna_add_mov_for_uniform_output);
NIR_PASS_V(s, etna_assign_registers);
NIR_PASS_V(s, etna_remove_io_intrinsics);
-- 
2.17.1

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


[Mesa-dev] [PATCH 12/21] etnaviv: compiler: generate instructions for log2

2018-06-05 Thread Philipp Zabel
From: Michael Tretter 

flog2 is implemented as 2 instructions in the Vivante machine code. The
log calculates x and y, which have to be multiplied to get the actual
log result.

We need to allocate a temporary register for this, which will fail if to
many flog2 instructions are used (e.g. in the glmark2 ideas benchmark).

TODO: move this up into NIR as a lowering step.

Signed-off-by: Michael Tretter 
Signed-off-by: Philipp Zabel 
---
 src/gallium/drivers/etnaviv/etnaviv_compiler.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
index 129c9115e783..66553199fe19 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
@@ -2101,6 +2101,24 @@ etna_emit_alu(struct etna_compile *c, nir_alu_instr 
*instr)
  .src[2] = src[0],
   });
   break;
+   case nir_op_flog2:
+  {
+  struct etna_native_reg temp = etna_compile_get_inner_temp(c); /* only 
using .xy */
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_LOG,
+ .sat = 0,
+ .dst = etna_native_to_dst(temp, INST_COMPS_X | INST_COMPS_Y),
+ .src[2] = src[0],
+ .tex = { .amode=1 }, /* Unknown bit needs to be set */
+  });
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_MUL,
+ .dst = dst,
+ .src[0] = etna_native_to_src(temp, SWIZZLE(X, X, X, X)),
+ .src[1] = etna_native_to_src(temp, SWIZZLE(Y, Y, Y, Y)),
+  });
+  }
+  break;
case nir_op_fexp2:
   emit_inst(c, &(struct etna_inst) {
  .opcode = INST_OPCODE_EXP,
-- 
2.17.1

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


[Mesa-dev] [PATCH 04/21] etnaviv: add debug option to report NIR as supported and preferred shader IR

2018-06-05 Thread Philipp Zabel
Add a debug option ETNA_MESA_DEBUG="nir" that will cause the etnaviv
gallium pipe driver to advertise support and preference for NIR shaders.

Signed-off-by: Philipp Zabel 
Signed-off-by: Michael Tretter 
---
 src/gallium/drivers/etnaviv/etnaviv_debug.h  |  3 +++
 src/gallium/drivers/etnaviv/etnaviv_screen.c | 11 +--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_debug.h 
b/src/gallium/drivers/etnaviv/etnaviv_debug.h
index 4051e95dd5fb..8dacf6b2433e 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_debug.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_debug.h
@@ -54,6 +54,9 @@
 #define ETNA_DBG_SHADERDB0x80 /* dump program compile information 
*/
 #define ETNA_DBG_NO_SINGLEBUF0x100 /* disable single buffer feature */
 
+/* Experimental features */
+#define ETNA_DBG_NIR   0x1000 /* Enable NIR compiler */
+
 extern int etna_mesa_debug; /* set in etna_screen.c from ETNA_DEBUG */
 
 #define DBG_ENABLED(flag) unlikely(etna_mesa_debug & (flag))
diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c 
b/src/gallium/drivers/etnaviv/etnaviv_screen.c
index e031807117c0..d3b3f507adf0 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
@@ -65,6 +65,7 @@ static const struct debug_named_value debug_options[] = {
{"cflush_all", ETNA_DBG_CFLUSH_ALL, "Flush every cash before state 
update"},
{"msaa2x", ETNA_DBG_MSAA_2X, "Force 2x msaa"},
{"msaa4x", ETNA_DBG_MSAA_4X, "Force 4x msaa"},
+   {"nir",ETNA_DBG_NIR, "Enable experimental NIR compiler"},
{"flush_all",  ETNA_DBG_FLUSH_ALL, "Flush after every rendered 
primitive"},
{"zero",   ETNA_DBG_ZERO, "Zero all resources after allocation"},
{"draw_stall", ETNA_DBG_DRAW_STALL, "Stall FE/PE after each rendered 
primitive"},
@@ -454,7 +455,10 @@ etna_screen_get_shader_param(struct pipe_screen *pscreen,
 ? screen->specs.fragment_sampler_count
 : screen->specs.vertex_sampler_count;
case PIPE_SHADER_CAP_PREFERRED_IR:
-  return PIPE_SHADER_IR_TGSI;
+  if (etna_mesa_debug & ETNA_DBG_NIR)
+ return PIPE_SHADER_IR_NIR;
+  else
+ return PIPE_SHADER_IR_TGSI;
case PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE:
   return 4096;
case PIPE_SHADER_CAP_TGSI_DROUND_SUPPORTED:
@@ -464,7 +468,10 @@ etna_screen_get_shader_param(struct pipe_screen *pscreen,
case PIPE_SHADER_CAP_TGSI_ANY_INOUT_DECL_RANGE:
   return false;
case PIPE_SHADER_CAP_SUPPORTED_IRS:
-  return 0;
+  if (etna_mesa_debug & ETNA_DBG_NIR)
+ return (1 << PIPE_SHADER_IR_TGSI) | (1 << PIPE_SHADER_IR_NIR);
+  else
+ return (1 << PIPE_SHADER_IR_TGSI);
case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS_HINT:
   return 32;
case PIPE_SHADER_CAP_MAX_SHADER_BUFFERS:
-- 
2.17.1

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


[Mesa-dev] [PATCH 11/21] etnaviv: compiler: add code emitter for alu operations

2018-06-05 Thread Philipp Zabel
From: Michael Tretter 

Start emitting ALU instructions for nir_alu_instr structures from the
NIR shader's main function implementation.

Signed-off-by: Michael Tretter 
Signed-off-by: Philipp Zabel 
---
 .../drivers/etnaviv/etnaviv_compiler.c| 290 ++
 1 file changed, 290 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
index 59caff435e64..129c9115e783 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
@@ -1937,6 +1937,293 @@ etna_compile_pass_generate_code(struct etna_compile *c)
tgsi_parse_free();
 }
 
+static void
+translate_alu_sources(struct etna_compile *c, struct nir_alu_instr *instr,
+  struct etna_inst_src src[3])
+{
+   const nir_op_info *info = _op_infos[instr->op];
+
+   for (unsigned i = 0; i < info->num_inputs; i++) {
+  nir_alu_src nir_src = instr->src[i];
+  if (nir_src.src.is_ssa) {
+ nir_const_value *val = NULL;
+ if (nir_src.src.ssa->parent_instr->type == nir_instr_type_intrinsic) {
+nir_intrinsic_instr *intr = 
nir_instr_as_intrinsic(nir_src.src.ssa->parent_instr);
+// int indirect_offset = intr->src[0];
+src[i].use = 1;
+src[i].swiz = INST_SWIZ(nir_src.swizzle[0], nir_src.swizzle[1],
+   nir_src.swizzle[2], nir_src.swizzle[3]);
+src[i].reg = nir_intrinsic_base(intr);
+src[i].rgroup = INST_RGROUP_UNIFORM_0;
+ } else {
+val = nir_src_as_const_value(nir_src.src);
+src[i] = alloc_imm_vec4u(c, ETNA_IMMEDIATE_CONSTANT, val->u32);
+src[i].swiz = INST_SWIZ(nir_src.swizzle[0], nir_src.swizzle[1],
+   nir_src.swizzle[2], nir_src.swizzle[3]);
+ }
+  } else {
+ src[i].use = 1;
+ src[i].swiz = INST_SWIZ(nir_src.swizzle[0], nir_src.swizzle[1],
+   nir_src.swizzle[2], nir_src.swizzle[3]);
+ src[i].rgroup = INST_RGROUP_TEMP;
+ src[i].reg = nir_src.src.reg.reg->index;
+ src[i].amode = INST_AMODE_DIRECT;
+ src[i].neg = nir_src.negate;
+  }
+   }
+}
+
+static void
+etna_emit_alu(struct etna_compile *c, nir_alu_instr *instr)
+{
+   const nir_op_info *info = _op_infos[instr->op];
+
+   struct etna_inst_dst dst;
+   struct etna_inst_src src[3] = {};
+
+   nir_alu_dest nir_dest = instr->dest;
+
+   dst.use = 1;
+   dst.reg = nir_dest.dest.reg.reg->index;
+   dst.comps = nir_dest.write_mask;
+
+   translate_alu_sources(c, instr, src);
+
+   switch (instr->op) {
+   case nir_op_fceil:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_CEIL,
+ .dst = dst,
+ .src[2] = src[0],
+  });
+  break;
+   case nir_op_ffloor:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_FLOOR,
+ .dst = dst,
+ .src[2] = src[0],
+  });
+  break;
+   case nir_op_fmov:
+   case nir_op_imov:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_MOV,
+ .dst = dst,
+ .src[2] = src[0],
+  });
+  break;
+   case nir_op_frcp:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_RCP,
+ .dst = dst,
+ .src[2] = src[0],
+  });
+  break;
+   case nir_op_frsq:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_RSQ,
+ .dst = dst,
+ .src[2] = src[0],
+  });
+  break;
+   case nir_op_fmul:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_MUL,
+ .dst = dst,
+ .src[0] = src[0],
+ .src[1] = src[1],
+  });
+  break;
+   case nir_op_fadd:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_ADD,
+ .dst = dst,
+ .src[0] = src[0],
+ .src[2] = src[1],
+  });
+  break;
+   case nir_op_fdot2:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_DP2,
+ .dst = dst,
+ .src[0] = src[0],
+ .src[1] = src[1],
+  });
+  break;
+   case nir_op_fdot3:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_DP3,
+ .dst = dst,
+ .src[0] = src[0],
+ .src[1] = src[1],
+  });
+  break;
+   case nir_op_ffma:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_MAD,
+ .dst = dst,
+ .src[0] = src[0],
+ .src[1] = src[1],
+ .src[2] = src[2],
+  });
+  break;
+   case nir_op_fmin:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_SELECT,
+ .cond = INST_CONDITION_GT,
+ .dst = dst,
+ .src[0] = src[0],
+ .src[1] = src[1],
+ .src[2] = src[0],
+  });
+  break;
+   case nir_op_fmax:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_SELECT,
+ .cond = INST_CONDITION_LT,
+

[Mesa-dev] [PATCH 16/21] etnaviv: compiler: generate texture loads

2018-06-05 Thread Philipp Zabel
Emit TEXLD, TEXLDB, and TEXLDL instructions from nir_texop_tex,
nir_texop_txb, and nir_texop_txl texture loads, respectively.

Signed-off-by: Philipp Zabel 
Signed-off-by: Michael Tretter 
---
 .../drivers/etnaviv/etnaviv_compiler.c| 65 +++
 1 file changed, 65 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
index f17b9979b705..b2499a7e2f6c 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
@@ -2186,6 +2186,68 @@ etna_emit_intr(struct etna_compile *c, 
nir_intrinsic_instr *intr)
}
 }
 
+static void
+etna_emit_tex(struct etna_compile *c, nir_tex_instr *instr)
+{
+   struct etna_inst_dst dst;
+   struct etna_inst_tex tex;
+   struct etna_inst_src src;
+
+   dst.use = 1;
+   dst.amode = 0;
+   dst.reg = instr->dest.is_ssa ? 0 : instr->dest.reg.reg->index;
+   /* nir_tex_instr does not support write mask */
+   dst.comps = INST_COMPS_X | INST_COMPS_Y | INST_COMPS_Z | INST_COMPS_W;
+
+   assert(!instr->texture);
+   assert(nir_tex_instr_src_index(instr, nir_tex_src_texture_offset) == -1);
+   tex.id = instr->texture_index;
+   tex.amode = 0;
+   tex.swiz = INST_SWIZ_IDENTITY;
+
+   src.use = 1;
+   src.reg = instr->src[0].src.is_ssa ? 0 : instr->src[0].src.reg.reg->index;
+   src.swiz = INST_SWIZ_IDENTITY;
+   src.neg = 0;
+   src.abs = 0;
+   src.amode = 0;
+   src.rgroup = 0;
+
+   switch (instr->op) {
+   case nir_texop_tex:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_TEXLD,
+ .sat = 0,
+ .dst = dst,
+ .tex = tex,
+ .src[0] = src,
+  });
+  break;
+   case nir_texop_txb:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_TEXLDB,
+ .sat = 0,
+ .dst = dst,
+ .tex = tex,
+ .src[0] = src,
+  });
+  break;
+   case nir_texop_txl:
+  emit_inst(c, &(struct etna_inst) {
+ .opcode = INST_OPCODE_TEXLDL,
+ .sat = 0,
+ .dst = dst,
+ .tex = tex,
+ .src[0] = src,
+  });
+  break;
+   default:
+  BUG("Unhandled nir_tex_instr: %d\n", instr->op);
+  assert(0);
+  break;
+   }
+}
+
 static void
 etna_emit_instr(struct etna_compile *c, nir_instr *instr)
 {
@@ -2193,6 +2255,9 @@ etna_emit_instr(struct etna_compile *c, nir_instr *instr)
case nir_instr_type_alu:
   etna_emit_alu(c, nir_instr_as_alu(instr));
   break;
+   case nir_instr_type_tex:
+  etna_emit_tex(c, nir_instr_as_tex(instr));
+  break;
case nir_instr_type_intrinsic:
   etna_emit_intr(c, nir_instr_as_intrinsic(instr));
   break;
-- 
2.17.1

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


[Mesa-dev] [PATCH 18/21] etnaviv: nir: implement conditionals

2018-06-05 Thread Philipp Zabel
Emit conditional branches for nir_cf_code_if blocks following a
comparison operation. The NIR compiler does not assign registers to
the comparison operations, and the emitter does not emit any
instructions for them.
Instead, the nir_cf_code_if blocks cause emission of a conditional
branch instruction using the sources and condition flags from the
preceding conditional operation.

Signed-off-by: Philipp Zabel 
Signed-off-by: Michael Tretter 
---
 .../drivers/etnaviv/etnaviv_compiler.c| 75 +++
 src/gallium/drivers/etnaviv/etnaviv_nir.c | 18 +
 2 files changed, 93 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
index b2499a7e2f6c..0db961c5a751 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
@@ -2162,6 +2162,12 @@ etna_emit_alu(struct etna_compile *c, nir_alu_instr 
*instr)
  .src[1] = src[1],
   });
   break;
+   case nir_op_feq:
+   case nir_op_fne:
+   case nir_op_flt:
+   case nir_op_fge:
+  /* Nothing to do, will be handled by the following nir_if */
+  break;
default:
   BUG("Unhandled nir_alu_instr: %s\n", info->name);
   assert(0);
@@ -2282,6 +2288,72 @@ etna_emit_block(struct etna_compile *c, nir_block 
*nblock)
}
 }
 
+static void etna_emit_cf_list(struct etna_compile *c, struct exec_list *list);
+
+static void
+etna_emit_if(struct etna_compile *c, nir_if *nif)
+{
+   struct etna_inst_src src[3] = {};
+
+   assert(nif->condition.is_ssa);
+
+   assert(nif->condition.ssa->parent_instr->type == nir_instr_type_alu);
+   nir_alu_instr *instr = nir_instr_as_alu(nif->condition.ssa->parent_instr);
+
+   assert(instr->op == nir_op_fne || instr->op == nir_op_feq);
+
+   translate_alu_sources(c, instr, src);
+
+   /* The NIR layer should have taken care of this */
+   assert(!etna_src_uniforms_conflict(src[0], src[1]));
+
+   unsigned sp = c->frame_sp++;
+   struct etna_compile_frame *f = >frame_stack[sp];
+   /* push IF to stack */
+   f->type = ETNA_COMPILE_FRAME_IF;
+   /* create "else" label */
+   f->lbl_else_idx = alloc_new_label(c);
+   f->lbl_endif_idx = -1;
+
+   /* mark position in instruction stream of label reference so that it can be
+* filled in in next pass */
+   label_mark_use(c, f->lbl_else_idx);
+
+   /* create conditional branch to else label if not src0 COND src1 */
+   emit_inst(c, &(struct etna_inst){
+  .opcode = INST_OPCODE_BRANCH,
+  .cond = (instr->op == nir_op_fne) ? INST_CONDITION_EQ : 
INST_CONDITION_NE,
+  .src[0] = src[0],
+  .src[1] = src[1],
+  /* imm is filled in later */
+   });
+
+   etna_emit_cf_list(c, >then_list);
+
+   /* create "endif" label, and branch to endif label */
+   f->lbl_endif_idx = alloc_new_label(c);
+   label_mark_use(c, f->lbl_endif_idx);
+   emit_inst(c, &(struct etna_inst) {
+  .opcode = INST_OPCODE_BRANCH,
+  .cond = INST_CONDITION_TRUE,
+  /* imm is filled in later */
+   });
+
+   /* mark "else" label at this position in instruction stream */
+   label_place(c, >labels[f->lbl_else_idx]);
+
+   etna_emit_cf_list(c, >else_list);
+
+   assert(--c->frame_sp == sp);
+
+   /* assign "endif" or "else" (if no ELSE) label to current position in
+* instruction stream, pop IF */
+   if (f->lbl_endif_idx != -1)
+  label_place(c, >labels[f->lbl_endif_idx]);
+   else
+  label_place(c, >labels[f->lbl_else_idx]);
+}
+
 static void
 etna_emit_cf_list(struct etna_compile *c, struct exec_list *list)
 {
@@ -2290,6 +2362,9 @@ etna_emit_cf_list(struct etna_compile *c, struct 
exec_list *list)
   case nir_cf_node_block:
  etna_emit_block(c, nir_cf_node_as_block(node));
  break;
+  case nir_cf_node_if:
+ etna_emit_if(c, nir_cf_node_as_if(node));
+ break;
   default:
  BUG("Unhandled nir node type %d\n", node->type);
  assert(0);
diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir.c 
b/src/gallium/drivers/etnaviv/etnaviv_nir.c
index af1684ed9091..d8bd282eaeca 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_nir.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_nir.c
@@ -399,6 +399,20 @@ etna_fixup_tex(nir_shader *shader)
}
 }
 
+static bool
+nir_op_is_comparison(nir_op op)
+{
+   switch (op) {
+   case nir_op_flt:
+   case nir_op_fge:
+   case nir_op_feq:
+   case nir_op_fne:
+  return true;
+   default:
+  return false;
+   }
+}
+
 /* Return the destination SSA if it should be replaced with a global register,
  * or NULL.
  */
@@ -423,6 +437,10 @@ etna_instr_replaceable_ssa_dest(nir_instr *instr)
if (instr->type == nir_instr_type_alu) {
   nir_alu_instr *alu = nir_instr_as_alu(instr);
 
+  /* Comparisons will be turned into conditional jumps */
+  if (nir_op_is_comparison(alu->op))
+ return NULL;
+
   return alu->dest.dest.is_ssa ? >dest.dest.ssa : NULL;
}
 
-- 
2.17.1

___

[Mesa-dev] [PATCH 17/21] etnaviv: nir: add texture fixup path before register assignment

2018-06-05 Thread Philipp Zabel
The texture instructions expect the source register to have the correct number
of components. Since we only have vec4 hardware registers, rewrite the number
of components to 4 and insert a mov instruction to a new vec4 SSA right before
the texture load instruction.

TODO: To support destination registers with the correct num_components
we have to add additional virtual scalar, vec2, and vec3 register
classes that only allow to use the X, XY, and XYZ components.

Signed-off-by: Philipp Zabel 
Signed-off-by: Michael Tretter 
---
 src/gallium/drivers/etnaviv/etnaviv_nir.c | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir.c 
b/src/gallium/drivers/etnaviv/etnaviv_nir.c
index 7889adf473ab..af1684ed9091 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_nir.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_nir.c
@@ -373,6 +373,32 @@ etna_lower_store_intrinsics(nir_shader *shader)
}
 }
 
+/* The hardware only has vec4 registers, so rewrite all texture load
+ * instructions to require vec4 sources.
+ */
+static void
+etna_fixup_tex(nir_shader *shader)
+{
+   nir_foreach_function(function, shader) {
+  nir_metadata_require(function->impl, nir_metadata_live_ssa_defs);
+  nir_foreach_block(block, function->impl) {
+ nir_foreach_instr(instr, block) {
+if (instr->type != nir_instr_type_tex)
+   continue;
+
+nir_tex_instr *tex = nir_instr_as_tex(instr);
+
+if (tex->src[0].src_type == nir_tex_src_coord) {
+   tex->coord_components = 4;
+   insert_mov(>instr, >src[0].src, shader);
+}
+ }
+  }
+  nir_metadata_preserve(function->impl,
+nir_metadata_block_index | nir_metadata_dominance);
+   }
+}
+
 /* Return the destination SSA if it should be replaced with a global register,
  * or NULL.
  */
@@ -957,6 +983,7 @@ etna_optimize_nir(struct etna_shader *shader,
NIR_PASS_V(s, etna_lower_store_intrinsics);
 
NIR_PASS_V(s, nir_convert_from_ssa, true);
+   NIR_PASS_V(s, etna_fixup_tex);
NIR_PASS_V(s, etna_assign_registers);
NIR_PASS_V(s, etna_remove_io_intrinsics);
 
-- 
2.17.1

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


[Mesa-dev] [PATCH 14/21] etnaviv: nir: remove undefined variables

2018-06-05 Thread Philipp Zabel
From: Michael Tretter 

If the source to a mov instruction is undefined, the result is undefined
as well. In that case it is valid to drop the mov instruction.

Signed-off-by: Michael Tretter 
Signed-off-by: Philipp Zabel 
---
 src/gallium/drivers/etnaviv/etnaviv_nir.c | 35 +++
 1 file changed, 35 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir.c 
b/src/gallium/drivers/etnaviv/etnaviv_nir.c
index 1a71459c3a20..7889adf473ab 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_nir.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_nir.c
@@ -198,6 +198,40 @@ etna_opt_merge_alu_mov_pair(nir_shader *shader)
}
 }
 
+/* Remove mov alu_ops from undefined variables, because the destination will
+ * be undefined as well and the write is unnecessary.
+ */
+static void
+etna_opt_remove_mov_undef(nir_shader *shader)
+{
+   nir_foreach_function(function, shader) {
+  nir_foreach_block(block, function->impl) {
+ nir_foreach_instr_safe(instr, block) {
+if (instr->type != nir_instr_type_alu)
+   continue;
+
+nir_alu_instr *alu = nir_instr_as_alu(instr);
+if (alu->op != nir_op_imov)
+   continue;
+
+unsigned i;
+for (i = 0; i < nir_op_infos[alu->op].num_inputs; i++) {
+   if (!alu->src[i].src.is_ssa ||
+   alu->src[i].src.ssa->parent_instr->type != 
nir_instr_type_ssa_undef)
+  break;
+}
+if (i != nir_op_infos[alu->op].num_inputs)
+   continue;
+
+nir_instr_remove(instr);
+/* TODO Remove nir_instr_type_ssa_undef instruction */
+ }
+  }
+  nir_metadata_preserve(function->impl, nir_metadata_block_index |
+nir_metadata_dominance);
+   }
+}
+
 /* Move const loads, input load intrinsics, and uniform load intrinsics to the
  * beginning of the function implementation.
  *
@@ -935,6 +969,7 @@ etna_optimize_nir(struct etna_shader *shader,
NIR_PASS_V(s, nir_move_vec_src_uses_to_dest);
NIR_PASS_V(s, nir_lower_vec_to_movs);
NIR_PASS_V(s, etna_opt_merge_alu_mov_pair);
+   NIR_PASS_V(s, etna_opt_remove_mov_undef);
 
nir_sweep(s);
 
-- 
2.17.1

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


[Mesa-dev] [PATCH 13/21] etnaviv: nir: add a nop intrinsic to empty shaders

2018-06-05 Thread Philipp Zabel
The Vivante instruction set does not allow empty shaders.
If the shader is empty, add a nop to allow execution.

Signed-off-by: Philipp Zabel 
Signed-off-by: Michael Tretter 
---
 src/gallium/drivers/etnaviv/etnaviv_nir.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir.c 
b/src/gallium/drivers/etnaviv/etnaviv_nir.c
index 752e87248e31..1a71459c3a20 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_nir.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_nir.c
@@ -888,6 +888,21 @@ etna_remove_io_intrinsics(nir_shader *shader)
}
 }
 
+static void
+etna_add_nop_if_empty(nir_shader *shader)
+{
+   /* TODO: add nop label if needed as jump target at the end of a function */
+   nir_foreach_function(function, shader) {
+  if (nir_index_instrs(function->impl) == 0) {
+ nir_intrinsic_instr *nop;
+
+ nop = nir_intrinsic_instr_create(shader, nir_intrinsic_nop);
+ nir_instr_insert_after_block(nir_start_block(function->impl),
+  >instr);
+  }
+   }
+}
+
 struct nir_shader *
 etna_optimize_nir(struct etna_shader *shader,
   struct nir_shader *s,
@@ -912,6 +927,7 @@ etna_optimize_nir(struct etna_shader *shader,
NIR_PASS_V(s, etna_remove_io_intrinsics);
 
NIR_PASS_V(s, nir_opt_dce);
+   NIR_PASS_V(s, etna_add_nop_if_empty);
 
/* Do this after register assignment to avoid creating temporary registers
 * that cause suboptimal register assignment.
-- 
2.17.1

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


[Mesa-dev] [PATCH 08/21] etnaviv: nir: add virtual register classes

2018-06-05 Thread Philipp Zabel
Since all threads share a global temporary vec4 register file, it is
important to reduce temporary register use of shaders.
Using source swizzles and destination write mask of ALU operations we
can layer smaller virtual registers on top of the physical base
registers that overlap with their base register and partially with each
other:

 ++-+-+-+
 |VEC4|  VEC3   |VEC2 | SCALAR  |
 ++-+-+-+
 |  X | X X X   | X X X   | X   |
 |  Y | Y Y   Y | Y Y Y   |   Y |
 |  Z | Z   Z Z |   Z   Z   Z | Z   |
 |  W |   W W W | W   W W |   W |
 ++-+-+-+

There are four possible virtual vec3 registers that leave the remaining
component usable as a scalar virtual register, six possible vec2
registers, and four possible scalar registers that only use a single
component.

This patch adds an interference graph for virtual registers to the
register allocator, using information about SSA interference and virtual
register overlap. If possible, SSAs with smaller num_components are
allocated from the unused components of already partially used temporary
registers.

Signed-off-by: Philipp Zabel 
Signed-off-by: Michael Tretter 
---
 src/gallium/drivers/etnaviv/etnaviv_nir.c | 282 --
 1 file changed, 259 insertions(+), 23 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_nir.c 
b/src/gallium/drivers/etnaviv/etnaviv_nir.c
index b73d4be31bc6..752e87248e31 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_nir.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_nir.c
@@ -375,11 +375,111 @@ etna_instr_replaceable_ssa_dest(nir_instr *instr)
return NULL;
 }
 
-/* Return the NIR global register corresponding to a given temporary register,
- * creating it if necessary.
+/* Swizzles and write masks can be used to layer virtual non-interfering
+ * registers on top of the real VEC4 registers. For example, the virtual
+ * VEC3_XYZ register and the virtual SCALAR_W register that use the same
+ * physical VEC4 base register do not interfere.
+ */
+enum {
+   ETNA_REG_CLASS_VEC4,
+   ETNA_REG_CLASS_VIRT_VEC3,
+   ETNA_REG_CLASS_VIRT_VEC2,
+   ETNA_REG_CLASS_VIRT_SCALAR,
+   ETNA_NUM_REG_CLASSES,
+} etna_reg_class;
+
+enum {
+   ETNA_REG_TYPE_VEC4,
+   ETNA_REG_TYPE_VIRT_VEC3_XYZ,
+   ETNA_REG_TYPE_VIRT_VEC3_XYW,
+   ETNA_REG_TYPE_VIRT_VEC3_XZW,
+   ETNA_REG_TYPE_VIRT_VEC3_YZW,
+   ETNA_REG_TYPE_VIRT_VEC2_XY,
+   ETNA_REG_TYPE_VIRT_VEC2_XZ,
+   ETNA_REG_TYPE_VIRT_VEC2_XW,
+   ETNA_REG_TYPE_VIRT_VEC2_YZ,
+   ETNA_REG_TYPE_VIRT_VEC2_YW,
+   ETNA_REG_TYPE_VIRT_VEC2_ZW,
+   ETNA_REG_TYPE_VIRT_SCALAR_X,
+   ETNA_REG_TYPE_VIRT_SCALAR_Y,
+   ETNA_REG_TYPE_VIRT_SCALAR_Z,
+   ETNA_REG_TYPE_VIRT_SCALAR_W,
+   ETNA_NUM_REG_TYPES,
+} etna_reg_type;
+
+static const uint8_t
+etna_reg_writemask[ETNA_NUM_REG_TYPES] = {
+   [ETNA_REG_TYPE_VEC4] = 0xf,
+   [ETNA_REG_TYPE_VIRT_SCALAR_X] = 0x1,
+   [ETNA_REG_TYPE_VIRT_SCALAR_Y] = 0x2,
+   [ETNA_REG_TYPE_VIRT_VEC2_XY] = 0x3,
+   [ETNA_REG_TYPE_VIRT_SCALAR_Z] = 0x4,
+   [ETNA_REG_TYPE_VIRT_VEC2_XZ] = 0x5,
+   [ETNA_REG_TYPE_VIRT_VEC2_YZ] = 0x6,
+   [ETNA_REG_TYPE_VIRT_VEC3_XYZ] = 0x7,
+   [ETNA_REG_TYPE_VIRT_SCALAR_W] = 0x8,
+   [ETNA_REG_TYPE_VIRT_VEC2_XW] = 0x9,
+   [ETNA_REG_TYPE_VIRT_VEC2_YW] = 0xa,
+   [ETNA_REG_TYPE_VIRT_VEC3_XYW] = 0xb,
+   [ETNA_REG_TYPE_VIRT_VEC2_ZW] = 0xc,
+   [ETNA_REG_TYPE_VIRT_VEC3_XZW] = 0xd,
+   [ETNA_REG_TYPE_VIRT_VEC3_YZW] = 0xe,
+};
+
+static inline int etna_reg_get_type(int virt_reg)
+{
+   return virt_reg % ETNA_NUM_REG_TYPES;
+}
+
+static inline int etna_reg_get_base(int virt_reg)
+{
+   return virt_reg / ETNA_NUM_REG_TYPES;
+}
+
+static inline int etna_reg_get_class(int virt_reg)
+{
+   switch (etna_reg_get_type(virt_reg)) {
+   case ETNA_REG_TYPE_VEC4:
+  return ETNA_REG_CLASS_VEC4;
+   case ETNA_REG_TYPE_VIRT_VEC3_XYZ:
+   case ETNA_REG_TYPE_VIRT_VEC3_XYW:
+   case ETNA_REG_TYPE_VIRT_VEC3_XZW:
+   case ETNA_REG_TYPE_VIRT_VEC3_YZW:
+  return ETNA_REG_CLASS_VIRT_VEC3;
+   case ETNA_REG_TYPE_VIRT_VEC2_XY:
+   case ETNA_REG_TYPE_VIRT_VEC2_XZ:
+   case ETNA_REG_TYPE_VIRT_VEC2_XW:
+   case ETNA_REG_TYPE_VIRT_VEC2_YZ:
+   case ETNA_REG_TYPE_VIRT_VEC2_YW:
+   case ETNA_REG_TYPE_VIRT_VEC2_ZW:
+  return ETNA_REG_CLASS_VIRT_VEC2;
+   case ETNA_REG_TYPE_VIRT_SCALAR_X:
+   case ETNA_REG_TYPE_VIRT_SCALAR_Y:
+   case ETNA_REG_TYPE_VIRT_SCALAR_Z:
+   case ETNA_REG_TYPE_VIRT_SCALAR_W:
+  return ETNA_REG_CLASS_VIRT_SCALAR;
+   }
+
+   assert(false);
+}
+
+/* Q values for the full set. Each virtual register interferes
+ * with exactly one base register. And possibly with other virtual
+ * registers on top of the same base register.
+ */
+static const unsigned int
+q_val[ETNA_NUM_REG_CLASSES][ETNA_NUM_REG_CLASSES] = {
+   { 0, 4, 6, 4 },
+   { 1, 3, 6, 3 },
+   { 1, 4, 4, 2 },
+   { 1, 3, 3, 0 },
+};
+
+/* Return a NIR global register corresponding to a given temporary register.
+ * The register is created if necessary.
  */
 

[Mesa-dev] [PATCH 10/21] etnaviv: compiler: avoid using tgsi_shader_info

2018-06-05 Thread Philipp Zabel
From: Michael Tretter 

For NIR shaders, get the shader stage from the nir_shader structure
instead from tgsi_shader_info.

Signed-off-by: Michael Tretter 
Signed-off-by: Philipp Zabel 
---
 .../drivers/etnaviv/etnaviv_compiler.c| 37 ++-
 1 file changed, 35 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c 
b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
index f87708d33f03..59caff435e64 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c
@@ -255,6 +255,39 @@ sort_rec_compar(const struct sort_rec *a, const struct 
sort_rec *b)
return 0;
 }
 
+static inline enum pipe_shader_type
+st_shader_stage_to_ptarget(gl_shader_stage stage)
+{
+   switch (stage) {
+   case MESA_SHADER_VERTEX:
+  return PIPE_SHADER_VERTEX;
+   case MESA_SHADER_FRAGMENT:
+  return PIPE_SHADER_FRAGMENT;
+   case MESA_SHADER_GEOMETRY:
+  return PIPE_SHADER_GEOMETRY;
+   case MESA_SHADER_TESS_CTRL:
+  return PIPE_SHADER_TESS_CTRL;
+   case MESA_SHADER_TESS_EVAL:
+  return PIPE_SHADER_TESS_EVAL;
+   case MESA_SHADER_COMPUTE:
+  return PIPE_SHADER_COMPUTE;
+   default:
+  break;
+   }
+
+   assert(!"Invalid shader type");
+   return PIPE_SHADER_VERTEX;
+}
+
+static inline bool
+etna_shader_is_stage(struct etna_compile *c, gl_shader_stage stage)
+{
+   if (!c->s)
+  return c->info.processor == st_shader_stage_to_ptarget(stage);
+   else
+  return c->s->info.stage == stage;
+}
+
 /* Calculate "mystery meat" load balancing value. This value determines how
  * work is scheduled between VS and PS in the unified shader architecture.
  * More precisely, it is determined from the number of VS outputs, as well as
@@ -658,7 +691,7 @@ etna_compile_pass_check_usage(struct etna_compile *c)
 static void
 assign_special_inputs(struct etna_compile *c)
 {
-   if (c->info.processor == PIPE_SHADER_FRAGMENT) {
+   if (etna_shader_is_stage(c, MESA_SHADER_FRAGMENT)) {
   /* never assign t0 as it is the position output, start assigning at t1 */
   c->next_free_native = 1;
 
@@ -2424,7 +2457,7 @@ fill_in_vs_outputs(struct etna_shader_variant *sobj, 
struct etna_compile *c)
 static bool
 etna_compile_check_limits(struct etna_compile *c)
 {
-   int max_uniforms = (c->info.processor == PIPE_SHADER_VERTEX)
+   int max_uniforms = etna_shader_is_stage(c, MESA_SHADER_VERTEX)
  ? c->specs->max_vs_uniforms
  : c->specs->max_ps_uniforms;
/* round up number of uniforms, including immediates, in units of four */
-- 
2.17.1

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


  1   2   >