Re: [Mesa-dev] [PATCH] nir: Remove nir_array from lower_locals_to_regs

2016-12-15 Thread Thomas Helland
Could I bother one of you to push it?
I haven't yet acquired commit access.

2016-12-16 7:26 GMT+01:00 Jason Ekstrand :
> Thanks! Rb.
>
> On Dec 15, 2016 3:30 PM, "Eric Anholt"  wrote:
>>
>> Thomas Helland  writes:
>>
>> > We do nothing but initialize it, add to it, and delete it.
>> > This is a fallout from removing constant initializer support.
>>
>> Maybe in the summary do s/nir_array/derefs_array/, but either way:
>>
>> Reviewed-by: Eric Anholt 
>>
>> ___
>> 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] nir: Remove nir_array from lower_locals_to_regs

2016-12-15 Thread Jason Ekstrand
Thanks! Rb.

On Dec 15, 2016 3:30 PM, "Eric Anholt"  wrote:

> Thomas Helland  writes:
>
> > We do nothing but initialize it, add to it, and delete it.
> > This is a fallout from removing constant initializer support.
>
> Maybe in the summary do s/nir_array/derefs_array/, but either way:
>
> Reviewed-by: Eric Anholt 
>
> ___
> 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] anv: Fix uniform and storage buffer offset alignment limits.

2016-12-15 Thread Jason Ekstrand
On Dec 15, 2016 3:22 PM, "Francisco Jerez"  wrote:

This fixes an apparent regression in a bunch of image store vulkan CTS
tests from commit ad38ba113491869ab0dffed937f7b3dd50e8a735, which
started using OWORD block read messages to implement UBO loads.  The
reason for the failure is that we were giving bogus buffer alignment
limits to the application (1B), so the CTS would happily come back
with descriptor sets pointing at not even word-aligned uniform buffer
addresses.  No idea how these tests could possibly work before while
we were using the sampler to fetch pull constants.


Fun fact: the sampler has very few requirements when it comes to linear
surfaces (including buffers).  One notable exception is that it doesn't
seem to care about alignment... at all.  A bit surprising, I know, but I've
seen other cases where it's totally fine with nonaligned offsets and
strides (in the case of 2D).

That is for fixing this!

Reviewed-by: Jason Ekstrand 


Cc: 
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99097
Reported-by: Mark Janes 
---
 src/intel/vulkan/anv_device.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index e3d278d..9245e5c 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -582,8 +582,8 @@ void anv_GetPhysicalDeviceProperties(
   .viewportSubPixelBits = 13, /* We take a float?
*/
   .minMemoryMapAlignment= 4096, /* A page */
   .minTexelBufferOffsetAlignment= 1,
-  .minUniformBufferOffsetAlignment  = 1,
-  .minStorageBufferOffsetAlignment  = 1,
+  .minUniformBufferOffsetAlignment  = 16,
+  .minStorageBufferOffsetAlignment  = 4,
   .minTexelOffset   = -8,
   .maxTexelOffset   = 7,
   .minTexelGatherOffset = -32,
--
2.10.2

___
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] nir: Turn imov/fmov of undef into undef

2016-12-15 Thread Jason Ekstrand
On Dec 15, 2016 4:26 PM, "Kenneth Graunke"  wrote:

On Friday, December 16, 2016 10:17:33 AM PST Timothy Arceri wrote:
> Reverting the previous attempt at this a5502a721fd30fd resulted in
> the following Vulkan test failing.
>
> dEQP-VK.glsl.return.return_in_dynamic_loop_dynamic_vertex
>
> This time we use the num_components from the alu dest rather than
> num_inputs to the op to determine the size of the undef.
>
> Cc: "13.0" 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99100
> ---
>  src/compiler/nir/nir_opt_undef.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/src/compiler/nir/nir_opt_undef.c b/src/compiler/nir/nir_opt_
undef.c
> index c4777a8..8d3210c 100644
> --- a/src/compiler/nir/nir_opt_undef.c
> +++ b/src/compiler/nir/nir_opt_undef.c
> @@ -79,22 +79,22 @@ opt_undef_vecN(nir_builder *b, nir_alu_instr *alu)
>  {
> if (alu->op != nir_op_vec2 &&
> alu->op != nir_op_vec3 &&
> -   alu->op != nir_op_vec4)
> +   alu->op != nir_op_vec4 &&
> +   alu->op != nir_op_fmov &&
> +   alu->op != nir_op_imov)
>return false;
>
> assert(alu->dest.dest.is_ssa);
>
> -   unsigned num_components = nir_op_infos[alu->op].num_inputs;
> -
> -   for (unsigned i = 0; i < num_components; i++) {
> +   for (unsigned 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)
>   return false;
> }
>
> b->cursor = nir_before_instr(>instr);
> -   nir_ssa_def *undef =
> -  nir_ssa_undef(b, num_components, nir_dest_bit_size(alu->dest.
dest));
> +   nir_ssa_def *undef = nir_ssa_undef(b, alu->dest.dest.ssa.num_
components,
> +  nir_dest_bit_size(alu->dest.dest));
> nir_ssa_def_rewrite_uses(>dest.dest.ssa, nir_src_for_ssa(undef));
>
> return true;
>

I don't understand why that test regressed...I suspect this is just
hiding an actual bug.


Agreed.  We should probably look into that.

Reviewed-by: Jason Ekstrand 

  But the optimization looks right to me, so

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


[Mesa-dev] [PATCH 07/19] glsl: Mark a set of array elements as accessed using a list of array_deref_range

2016-12-15 Thread Ian Romanick
From: Ian Romanick 

Signed-off-by: Ian Romanick 
Cc: mesa-sta...@lists.freedesktop.org
---
 src/compiler/glsl/ir_array_refcount.cpp |  55 +
 src/compiler/glsl/ir_array_refcount.h   |  49 
 src/compiler/glsl/tests/array_refcount_test.cpp | 149 
 3 files changed, 253 insertions(+)

diff --git a/src/compiler/glsl/ir_array_refcount.cpp 
b/src/compiler/glsl/ir_array_refcount.cpp
index fa26128..75dca0a 100644
--- a/src/compiler/glsl/ir_array_refcount.cpp
+++ b/src/compiler/glsl/ir_array_refcount.cpp
@@ -60,6 +60,14 @@ ir_array_refcount_entry::ir_array_refcount_entry(ir_variable 
*var)
num_bits = MAX2(1, var->type->arrays_of_arrays_size());
bits = new BITSET_WORD[BITSET_WORDS(num_bits)];
memset(bits, 0, BITSET_WORDS(num_bits) * sizeof(bits[0]));
+
+   /* Count the "depth" of the arrays-of-arrays. */
+   array_depth = 0;
+   for (const glsl_type *type = var->type;
+type->is_array();
+type = type->fields.array) {
+  array_depth++;
+   }
 }
 
 
@@ -69,6 +77,53 @@ ir_array_refcount_entry::~ir_array_refcount_entry()
 }
 
 
+void
+ir_array_refcount_entry::mark_array_elements_referenced(const 
array_deref_range *dr,
+unsigned count)
+{
+   if (count != array_depth)
+  return;
+
+   mark_array_elements_referenced(dr, count, 1, 0);
+}
+
+void
+ir_array_refcount_entry::mark_array_elements_referenced(const 
array_deref_range *dr,
+unsigned count,
+unsigned scale,
+unsigned 
linearized_index)
+{
+   /* Walk through the list of array dereferences in least- to
+* most-significant order.  Along the way, accumulate the current
+* linearized offset and the scale factor for each array-of-.
+*/
+   for (unsigned i = 0; i < count; i++) {
+  if (dr[i].index < dr[i].size) {
+ linearized_index += dr[i].index * scale;
+ scale *= dr[i].size;
+  } else {
+ /* For each element in the current array, update the count and
+  * offset, then recurse to process the remaining arrays.
+  *
+  * There is some inefficency here if the last element in the
+  * array_deref_range list specifies the entire array.  In that case,
+  * the loop will make recursive calls with count == 0.  In the call,
+  * all that will happen is the bit will be set.
+  */
+ for (unsigned j = 0; j < dr[i].size; j++) {
+mark_array_elements_referenced([i + 1],
+   count - (i + 1),
+   scale * dr[i].size,
+   linearized_index + (j * scale));
+ }
+
+ return;
+  }
+   }
+
+   BITSET_SET(bits, linearized_index);
+}
+
 ir_array_refcount_entry *
 ir_array_refcount_visitor::get_variable_entry(ir_variable *var)
 {
diff --git a/src/compiler/glsl/ir_array_refcount.h 
b/src/compiler/glsl/ir_array_refcount.h
index 1e7f343..2988046 100644
--- a/src/compiler/glsl/ir_array_refcount.h
+++ b/src/compiler/glsl/ir_array_refcount.h
@@ -60,6 +60,34 @@ public:
/** Has the variable been referenced? */
bool is_referenced;
 
+   /**
+* Mark a set of array elements as accessed.
+*
+* If every \c array_deref_range is for a single index, only a single
+* element will be marked.  If any \c array_deref_range is for an entire
+* array-of-, then multiple elements will be marked.
+*
+* Items in the \c array_deref_range list appear in least- to
+* most-significant order.  This is the \b opposite order the indices
+* appear in the GLSL shader text.  An array access like
+*
+* x = y[1][i][3];
+*
+* would appear as
+*
+* { { 3, n }, { m, m }, { 1, p } }
+*
+* where n, m, and p are the sizes of the arrays-of-arrays.
+*
+* The set of marked array elements can later be queried by
+* \c ::is_linearized_index_referenced.
+*
+* \param dr List of array_deref_range elements to be processed.
+* \param count  Number of array_deref_range elements to be processed.
+*/
+   void mark_array_elements_referenced(const array_deref_range *dr,
+   unsigned count);
+
/** Has a linearized array index been referenced? */
bool is_linearized_index_referenced(unsigned linearized_index) const
{
@@ -80,6 +108,27 @@ private:
 */
unsigned num_bits;
 
+   /** Count of nested arrays in the type. */
+   unsigned array_depth;
+
+   /**
+* Recursive part of the public mark_array_elements_referenced method.
+*
+* The recursion occurs when an entire array-of- is accessed.  See the
+* implementation for more details.
+*
+* \param dr 

[Mesa-dev] [PATCH 19/19] nir: Trivial clean ups in the generated nir_constant_expressions.c

2016-12-15 Thread Ian Romanick
From: Ian Romanick 

Signed-off-by: Ian Romanick 
Reviewed-by: Kenneth Graunke 
---
 src/compiler/nir/nir_constant_expressions.py | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/compiler/nir/nir_constant_expressions.py 
b/src/compiler/nir/nir_constant_expressions.py
index 2cc106d..273d6ce 100644
--- a/src/compiler/nir/nir_constant_expressions.py
+++ b/src/compiler/nir/nir_constant_expressions.py
@@ -291,7 +291,7 @@ evaluate_${name}(MAYBE_UNUSED unsigned num_components, 
unsigned bit_size,
 <% continue %>
  %endif
 
- struct ${input_types[j]}_vec src${j} = {
+ const struct ${input_types[j]}_vec src${j} = {
  % for k in range(op.input_sizes[j]):
 % if input_types[j] == "bool32":
_src[${j}].u32[${k}] != 0,
@@ -319,9 +319,9 @@ evaluate_${name}(MAYBE_UNUSED unsigned num_components, 
unsigned bit_size,
   ## Avoid unused variable warnings
   <% continue %>
% elif input_types[j] == "bool32":
-  bool src${j} = _src[${j}].u32[_i] != 0;
+  const bool src${j} = _src[${j}].u32[_i] != 0;
% else:
-  ${input_types[j]}_t src${j} =
+  const ${input_types[j]}_t src${j} =
  _src[${j}].${get_const_field(input_types[j])}[_i];
% endif
 % endfor
@@ -331,6 +331,7 @@ evaluate_${name}(MAYBE_UNUSED unsigned num_components, 
unsigned bit_size,
 ## writes to dst, just include const_expr directly.
 % if "dst" in op.const_expr:
${output_type}_t dst;
+
${op.const_expr}
 % else:
${output_type}_t dst = ${op.const_expr};
@@ -392,10 +393,8 @@ nir_eval_const_opcode(nir_op op, unsigned num_components,
 {
switch (op) {
 % for name in sorted(opcodes.iterkeys()):
-   case nir_op_${name}: {
+   case nir_op_${name}:
   return evaluate_${name}(num_components, bit_width, src);
-  break;
-   }
 % endfor
default:
   unreachable("shouldn't get here");
-- 
2.7.4

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


[Mesa-dev] [PATCH 16/19] glsl: Silence "unused parameter" warnings in ast_type.cpp

2016-12-15 Thread Ian Romanick
From: Ian Romanick 

glsl/ast_type.cpp: In function ‘bool validate_point_mode(YYLTYPE*, 
_mesa_glsl_parse_state*, const ast_type_qualifier&, const ast_type_qualifier&)’:
glsl/ast_type.cpp:173:30: warning: unused parameter ‘loc’ [-Wunused-parameter]
 validate_point_mode(YYLTYPE *loc,
  ^~~
glsl/ast_type.cpp:174:45: warning: unused parameter ‘state’ [-Wunused-parameter]
 _mesa_glsl_parse_state *state,
 ^

Signed-off-by: Ian Romanick 
Cc: Andres Gomez 
---
 src/compiler/glsl/ast_type.cpp | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/compiler/glsl/ast_type.cpp b/src/compiler/glsl/ast_type.cpp
index d68e6e2..e3f06a9 100644
--- a/src/compiler/glsl/ast_type.cpp
+++ b/src/compiler/glsl/ast_type.cpp
@@ -170,10 +170,8 @@ validate_ordering(YYLTYPE *loc,
 }
 
 static bool
-validate_point_mode(YYLTYPE *loc,
-_mesa_glsl_parse_state *state,
-const ast_type_qualifier ,
-const ast_type_qualifier _qualifier)
+validate_point_mode(MAYBE_UNUSED const ast_type_qualifier ,
+MAYBE_UNUSED const ast_type_qualifier _qualifier)
 {
/* Point mode can only be true if the flag is set. */
assert (!qualifier.flags.q.point_mode || !new_qualifier.flags.q.point_mode
@@ -367,7 +365,7 @@ ast_type_qualifier::merge_qualifier(YYLTYPE *loc,
}
 
if (q.flags.q.point_mode) {
-  r &= validate_point_mode(loc, state, *this, q);
+  r &= validate_point_mode(*this, q);
   this->flags.q.point_mode = 1;
   this->point_mode = q.point_mode;
}
@@ -607,7 +605,7 @@ ast_type_qualifier::validate_in_qualifier(YYLTYPE *loc,
r &= validate_prim_type(loc, state, *state->in_qualifier, *this);
r &= validate_vertex_spacing(loc, state, *state->in_qualifier, *this);
r &= validate_ordering(loc, state, *state->in_qualifier, *this);
-   r &= validate_point_mode(loc, state, *state->in_qualifier, *this);
+   r &= validate_point_mode(*state->in_qualifier, *this);
 
return r;
 }
-- 
2.7.4

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


[Mesa-dev] [PATCH 03/19] glsl: Track the linearized array index for each UBO instance array element

2016-12-15 Thread Ian Romanick
From: Ian Romanick 

Signed-off-by: Ian Romanick 
Cc: mesa-sta...@lists.freedesktop.org
---
 src/compiler/glsl/link_uniform_blocks.cpp | 17 ++---
 src/mesa/main/mtypes.h| 15 +++
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/src/compiler/glsl/link_uniform_blocks.cpp 
b/src/compiler/glsl/link_uniform_blocks.cpp
index 41b26e7..9adfbd5 100644
--- a/src/compiler/glsl/link_uniform_blocks.cpp
+++ b/src/compiler/glsl/link_uniform_blocks.cpp
@@ -209,13 +209,19 @@ static void process_block_array_leaf(char **name, 
gl_uniform_block *blocks,
  struct gl_context *ctx,
  struct gl_shader_program *prog);
 
+/**
+ *
+ * \param first_index Value of \c block_index for the first element of the
+ *array.
+ */
 static void
 process_block_array(struct uniform_block_array_elements *ub_array, char **name,
 size_t name_length, gl_uniform_block *blocks,
 ubo_visitor *parcel, gl_uniform_buffer_variable *variables,
 const struct link_uniform_block_active *const b,
 unsigned *block_index, unsigned *binding_offset,
-struct gl_context *ctx, struct gl_shader_program *prog)
+struct gl_context *ctx, struct gl_shader_program *prog,
+unsigned first_index)
 {
for (unsigned j = 0; j < ub_array->num_array_elements; j++) {
   size_t new_length = name_length;
@@ -227,11 +233,15 @@ process_block_array(struct uniform_block_array_elements 
*ub_array, char **name,
   if (ub_array->array) {
  process_block_array(ub_array->array, name, new_length, blocks,
  parcel, variables, b, block_index,
- binding_offset, ctx, prog);
+ binding_offset, ctx, prog, first_index);
   } else {
+ const unsigned i = *block_index;
+
  process_block_array_leaf(name, blocks,
   parcel, variables, b, block_index,
   binding_offset, ctx, prog);
+
+ blocks[i].linearized_array_index = i - first_index;
   }
}
 }
@@ -359,7 +369,8 @@ create_buffer_blocks(void *mem_ctx, struct gl_context *ctx,
 
 assert(b->has_instance_name);
 process_block_array(b->array, , name_length, blocks, ,
-variables, b, , _offset, ctx, prog);
+variables, b, , _offset, ctx, prog,
+i);
 ralloc_free(name);
  } else {
 blocks[i].Name = ralloc_strdup(blocks, block_type->name);
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 36d48e2..ac4cac0 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2493,6 +2493,21 @@ struct gl_uniform_block
uint8_t stageref;
 
/**
+* Linearized array index for uniform block instance arrays
+*
+* Given a uniform block instance array declared with size
+* blk[s_0][s_1]..[s_m], the block referenced by blk[i_0][i_1]..[i_m] will
+* have the linearized array index
+*
+*   m-1   m
+* i_m + ∑   i_j * ∏ s_k
+*   j=0   k=j+1
+*
+* For a uniform block instance that is not an array, this is always 0.
+*/
+   uint8_t linearized_array_index;
+
+   /**
 * Layout specified in the shader
 *
 * This isn't accessible through the API, but it is used while
-- 
2.7.4

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


[Mesa-dev] [PATCH 13/19] glsl: Minor formatting fixes in link_uniform_blocks.cpp

2016-12-15 Thread Ian Romanick
From: Ian Romanick 

Signed-off-by: Ian Romanick 
---
 src/compiler/glsl/link_uniform_blocks.cpp | 79 ---
 1 file changed, 42 insertions(+), 37 deletions(-)

diff --git a/src/compiler/glsl/link_uniform_blocks.cpp 
b/src/compiler/glsl/link_uniform_blocks.cpp
index 9adfbd5..7912443 100644
--- a/src/compiler/glsl/link_uniform_blocks.cpp
+++ b/src/compiler/glsl/link_uniform_blocks.cpp
@@ -36,8 +36,8 @@ public:
ubo_visitor(void *mem_ctx, gl_uniform_buffer_variable *variables,
unsigned num_variables, struct gl_shader_program *prog)
   : index(0), offset(0), buffer_size(0), variables(variables),
-num_variables(num_variables), mem_ctx(mem_ctx), 
is_array_instance(false),
-prog(prog)
+num_variables(num_variables), mem_ctx(mem_ctx),
+is_array_instance(false), prog(prog)
{
   /* empty */
}
@@ -61,7 +61,9 @@ public:
 
 private:
virtual void enter_record(const glsl_type *type, const char *,
- bool row_major, const enum glsl_interface_packing 
packing) {
+ bool row_major,
+ const enum glsl_interface_packing packing)
+   {
   assert(type->is_record());
   if (packing == GLSL_INTERFACE_PACKING_STD430)
  this->offset = glsl_align(
@@ -72,15 +74,17 @@ private:
}
 
virtual void leave_record(const glsl_type *type, const char *,
- bool row_major, const enum glsl_interface_packing 
packing) {
+ bool row_major,
+ const enum glsl_interface_packing packing)
+   {
   assert(type->is_record());
 
   /* If this is the last field of a structure, apply rule #9.  The
-   * GL_ARB_uniform_buffer_object spec says:
+   * ARB_uniform_buffer_object spec says:
*
-   * "The structure may have padding at the end; the base offset of
-   * the member following the sub-structure is rounded up to the next
-   * multiple of the base alignment of the structure."
+   *The structure may have padding at the end; the base offset of the
+   *member following the sub-structure is rounded up to the next
+   *multiple of the base alignment of the structure.
*/
   if (packing == GLSL_INTERFACE_PACKING_STD430)
  this->offset = glsl_align(
@@ -129,15 +133,16 @@ private:
   unsigned alignment = 0;
   unsigned size = 0;
 
-  /* From ARB_program_interface_query:
+  /* The ARB_program_interface_query spec says:
*
-   * "If the final member of an active shader storage block is array
-   *  with no declared size, the minimum buffer size is computed
-   *  assuming the array was declared as an array with one element."
+   *If the final member of an active shader storage block is array
+   *with no declared size, the minimum buffer size is computed
+   *assuming the array was declared as an array with one element.
*
-   * For that reason, we use the base type of the unsized array to 
calculate
-   * its size. We don't need to check if the unsized array is the last 
member
-   * of a shader storage block (that check was already done by the parser).
+   * For that reason, we use the base type of the unsized array to
+   * calculate its size. We don't need to check if the unsized array is
+   * the last member of a shader storage block (that check was already
+   * done by the parser).
*/
   const glsl_type *type_for_size = type;
   if (type->is_unsized_array()) {
@@ -158,15 +163,15 @@ private:
 
   this->offset += size;
 
-  /* From the GL_ARB_uniform_buffer_object spec:
+  /* The ARB_uniform_buffer_object spec says:
*
-   * "For uniform blocks laid out according to [std140] rules, the
-   *  minimum buffer object size returned by the
-   *  UNIFORM_BLOCK_DATA_SIZE query is derived by taking the offset of
-   *  the last basic machine unit consumed by the last uniform of the
-   *  uniform block (including any end-of-array or end-of-structure
-   *  padding), adding one, and rounding up to the next multiple of
-   *  the base alignment required for a vec4."
+   *For uniform blocks laid out according to [std140] rules, the
+   *minimum buffer object size returned by the UNIFORM_BLOCK_DATA_SIZE
+   *query is derived by taking the offset of the last basic machine
+   *unit consumed by the last uniform of the uniform block (including
+   *any end-of-array or end-of-structure padding), adding one, and
+   *rounding up to the next multiple of the base alignment required
+   *for a vec4.
*/
   this->buffer_size = glsl_align(this->offset, 16);
}
@@ -260,12 +265,12 @@ 

[Mesa-dev] [PATCH 06/19] glsl: Add structures to track accessed elements of a single array

2016-12-15 Thread Ian Romanick
From: Ian Romanick 

Signed-off-by: Ian Romanick 
Cc: mesa-sta...@lists.freedesktop.org
---
 src/compiler/glsl/ir_array_refcount.cpp | 21 
 src/compiler/glsl/ir_array_refcount.h   | 35 +
 2 files changed, 56 insertions(+)

diff --git a/src/compiler/glsl/ir_array_refcount.cpp 
b/src/compiler/glsl/ir_array_refcount.cpp
index fd831a8..fa26128 100644
--- a/src/compiler/glsl/ir_array_refcount.cpp
+++ b/src/compiler/glsl/ir_array_refcount.cpp
@@ -34,6 +34,7 @@
 #include "util/hash_table.h"
 
 ir_array_refcount_visitor::ir_array_refcount_visitor()
+   : derefs(0), num_derefs(0), derefs_size(0)
 {
this->mem_ctx = ralloc_context(NULL);
this->ht = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
@@ -84,6 +85,26 @@ ir_array_refcount_visitor::get_variable_entry(ir_variable 
*var)
 }
 
 
+array_deref_range *
+ir_array_refcount_visitor::get_array_deref()
+{
+   if ((num_derefs + 1) * sizeof(array_deref_range) > derefs_size) {
+  void *ptr = reralloc_size(mem_ctx, derefs, derefs_size + 4096);
+
+  if (ptr == NULL)
+ return NULL;
+
+  derefs_size += 4096;
+  derefs = (array_deref_range *)ptr;
+   }
+
+   array_deref_range *d = [num_derefs];
+   num_derefs++;
+
+   return d;
+}
+
+
 ir_visitor_status
 ir_array_refcount_visitor::visit(ir_dereference_variable *ir)
 {
diff --git a/src/compiler/glsl/ir_array_refcount.h 
b/src/compiler/glsl/ir_array_refcount.h
index 4296e4b..1e7f343 100644
--- a/src/compiler/glsl/ir_array_refcount.h
+++ b/src/compiler/glsl/ir_array_refcount.h
@@ -32,6 +32,23 @@
 #include "compiler/glsl_types.h"
 #include "util/bitset.h"
 
+/**
+ * Describes an access of an array element or an access of the whole array
+ */
+struct array_deref_range {
+   /**
+* Index that was accessed.
+*
+* All valid array indices are less than the size of the array.  If index
+* is equal to the size of the array, this means the entire array has been
+* accessed (e.g., due to use of a non-constant index).
+*/
+   unsigned index;
+
+   /** Size of the array.  Used for offset calculations. */
+   unsigned size;
+};
+
 class ir_array_refcount_entry
 {
 public:
@@ -86,4 +103,22 @@ public:
struct hash_table *ht;
 
void *mem_ctx;
+
+private:
+   /** Get an array_deref_range element from private tracking. */
+   array_deref_range *get_array_deref();
+
+   /**
+* \name array_deref_range tracking
+*/
+   /*@{*/
+   /** Currently allocated block of derefs. */
+   array_deref_range *derefs;
+
+   /** Number of derefs used in current processing. */
+   unsigned num_derefs;
+
+   /** Size of the derefs buffer in bytes. */
+   unsigned derefs_size;
+   /*@}*/
 };
-- 
2.7.4

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


[Mesa-dev] [PATCH 12/19] glsl: Fix all the whitespace errors in link_uniform_block_active_visitor.cpp

2016-12-15 Thread Ian Romanick
From: Ian Romanick 

Signed-off-by: Ian Romanick 
---
 .../glsl/link_uniform_block_active_visitor.cpp | 46 ++
 1 file changed, 21 insertions(+), 25 deletions(-)

diff --git a/src/compiler/glsl/link_uniform_block_active_visitor.cpp 
b/src/compiler/glsl/link_uniform_block_active_visitor.cpp
index df8b221..cd1baf7 100644
--- a/src/compiler/glsl/link_uniform_block_active_visitor.cpp
+++ b/src/compiler/glsl/link_uniform_block_active_visitor.cpp
@@ -40,7 +40,7 @@ process_block(void *mem_ctx, struct hash_table *ht, 
ir_variable *var)
 */
if (existing_block == NULL) {
   link_uniform_block_active *const b =
-rzalloc(mem_ctx, struct link_uniform_block_active);
+ rzalloc(mem_ctx, struct link_uniform_block_active);
 
   b->type = block_type;
   b->has_instance_name = var->is_interface_instance();
@@ -58,13 +58,13 @@ process_block(void *mem_ctx, struct hash_table *ht, 
ir_variable *var)
   return b;
} else {
   link_uniform_block_active *const b =
-(link_uniform_block_active *) existing_block->data;
+ (link_uniform_block_active *) existing_block->data;
 
   if (b->type != block_type
- || b->has_instance_name != var->is_interface_instance())
-return NULL;
+  || b->has_instance_name != var->is_interface_instance())
+ return NULL;
   else
-return b;
+ return b;
}
 
assert(!"Should not get here.");
@@ -89,8 +89,8 @@ process_block(void *mem_ctx, struct hash_table *ht, 
ir_variable *var)
  *   }
  *
  * There are only 2 active blocks above but for the sake of indirect indexing
- * and not over complicating the code we will end up with a count of 8.
- * Here each dimension has 2 different indices counted so we end up with 2*2*2
+ * and not over complicating the code we will end up with a count of 8.  Here
+ * each dimension has 2 different indices counted so we end up with 2*2*2
  */
 static struct uniform_block_array_elements **
 process_arrays(void *mem_ctx, ir_dereference_array *ir,
@@ -107,8 +107,8 @@ process_arrays(void *mem_ctx, ir_dereference_array *ir,
   struct uniform_block_array_elements *ub_array = *ub_array_ptr;
   ir_constant *c = ir->array_index->as_constant();
   if (c) {
- /* Index is a constant, so mark just that element used,
-  * if not already.
+ /* Index is a constant, so mark just that element used, if not
+  * already.
   */
  const unsigned idx = c->get_uint_component(0);
 
@@ -131,9 +131,7 @@ process_arrays(void *mem_ctx, ir_dereference_array *ir,
 ub_array->num_array_elements++;
  }
   } else {
- /* The array index is not a constant,
-  * so mark the entire array used.
-  */
+ /* The array index is not a constant, so mark the entire array used. 
*/
  assert(ir->array->type->is_array());
  if (ub_array->num_array_elements < ir->array->type->length) {
 ub_array->num_array_elements = ir->array->type->length;
@@ -147,6 +145,7 @@ process_arrays(void *mem_ctx, ir_dereference_array *ir,
 }
  }
   }
+
   return _array->array;
} else {
   return >array;
@@ -170,8 +169,7 @@ link_uniform_block_active_visitor::visit(ir_variable *var)
if (var->get_interface_type_packing() == GLSL_INTERFACE_PACKING_PACKED)
   return visit_continue;
 
-   /* Process the block.  Bail if there was an error.
-*/
+   /* Process the block.  Bail if there was an error. */
link_uniform_block_active *const b =
   process_block(this->mem_ctx, this->ht, var);
if (b == NULL) {
@@ -236,14 +234,13 @@ 
link_uniform_block_active_visitor::visit_enter(ir_dereference_array *ir)
|| !var->is_interface_instance())
   return visit_continue;
 
-   /* Process the block.  Bail if there was an error.
-*/
+   /* Process the block.  Bail if there was an error. */
link_uniform_block_active *const b =
   process_block(this->mem_ctx, this->ht, var);
if (b == NULL) {
   linker_error(prog,
-  "uniform block `%s' has mismatching definitions",
-  var->get_interface_type()->name);
+   "uniform block `%s' has mismatching definitions",
+   var->get_interface_type()->name);
   this->success = false;
   return visit_stop;
}
@@ -253,9 +250,9 @@ 
link_uniform_block_active_visitor::visit_enter(ir_dereference_array *ir)
assert(b->has_instance_name);
assert(b->type != NULL);
 
-   /* If the block array was declared with a shared or
-* std140 layout qualifier, all its instances have been already marked
-* as used in link_uniform_block_active_visitor::visit(ir_variable *).
+   /* If the block array was declared with a shared or std140 layout
+* qualifier, all its instances have been already marked as used in
+* 

[Mesa-dev] [PATCH 05/19] glsl: Add tracking for elements of an array-of-arrays that have been accessed

2016-12-15 Thread Ian Romanick
From: Ian Romanick 

If there's a better way to provide access to ir_array_refcount_entry
private members to the test functions, I am very interested to know
about it.

Signed-off-by: Ian Romanick 
Cc: Francisco Jerez 
Cc: mesa-sta...@lists.freedesktop.org
---
 src/compiler/Makefile.glsl.am   |   1 +
 src/compiler/glsl/ir_array_refcount.cpp |  10 +-
 src/compiler/glsl/ir_array_refcount.h   |  24 
 src/compiler/glsl/tests/array_refcount_test.cpp | 143 
 4 files changed, 177 insertions(+), 1 deletion(-)
 create mode 100644 src/compiler/glsl/tests/array_refcount_test.cpp

diff --git a/src/compiler/Makefile.glsl.am b/src/compiler/Makefile.glsl.am
index 5b1d74e..5520aca 100644
--- a/src/compiler/Makefile.glsl.am
+++ b/src/compiler/Makefile.glsl.am
@@ -69,6 +69,7 @@ glsl_tests_cache_test_LDADD = \
$(PTHREAD_LIBS)
 
 glsl_tests_general_ir_test_SOURCES =   \
+   glsl/tests/array_refcount_test.cpp  \
glsl/tests/builtin_variable_test.cpp\
glsl/tests/invalidate_locations_test.cpp\
glsl/tests/general_ir_test.cpp  \
diff --git a/src/compiler/glsl/ir_array_refcount.cpp 
b/src/compiler/glsl/ir_array_refcount.cpp
index 41a0914..fd831a8 100644
--- a/src/compiler/glsl/ir_array_refcount.cpp
+++ b/src/compiler/glsl/ir_array_refcount.cpp
@@ -56,7 +56,15 @@ ir_array_refcount_visitor::~ir_array_refcount_visitor()
 ir_array_refcount_entry::ir_array_refcount_entry(ir_variable *var)
: var(var), is_referenced(false)
 {
-   /* empty */
+   num_bits = MAX2(1, var->type->arrays_of_arrays_size());
+   bits = new BITSET_WORD[BITSET_WORDS(num_bits)];
+   memset(bits, 0, BITSET_WORDS(num_bits) * sizeof(bits[0]));
+}
+
+
+ir_array_refcount_entry::~ir_array_refcount_entry()
+{
+   delete [] bits;
 }
 
 
diff --git a/src/compiler/glsl/ir_array_refcount.h 
b/src/compiler/glsl/ir_array_refcount.h
index 9ec46d2..4296e4b 100644
--- a/src/compiler/glsl/ir_array_refcount.h
+++ b/src/compiler/glsl/ir_array_refcount.h
@@ -30,16 +30,40 @@
 #include "ir.h"
 #include "ir_visitor.h"
 #include "compiler/glsl_types.h"
+#include "util/bitset.h"
 
 class ir_array_refcount_entry
 {
 public:
ir_array_refcount_entry(ir_variable *var);
+   ~ir_array_refcount_entry();
 
ir_variable *var; /* The key: the variable's pointer. */
 
/** Has the variable been referenced? */
bool is_referenced;
+
+   /** Has a linearized array index been referenced? */
+   bool is_linearized_index_referenced(unsigned linearized_index) const
+   {
+  assert(bits != 0);
+  assert(linearized_index <= num_bits);
+
+  return BITSET_TEST(bits, linearized_index);
+   }
+
+private:
+   /** Set of bit-flags to note which array elements have been accessed. */
+   BITSET_WORD *bits;
+
+   /**
+* Total number of bits referenced by \c bits.
+*
+* Also the total number of array(s-of-arrays) elements of \c var.
+*/
+   unsigned num_bits;
+
+   friend class array_refcount_test;
 };
 
 class ir_array_refcount_visitor : public ir_hierarchical_visitor {
diff --git a/src/compiler/glsl/tests/array_refcount_test.cpp 
b/src/compiler/glsl/tests/array_refcount_test.cpp
new file mode 100644
index 000..d80ea81
--- /dev/null
+++ b/src/compiler/glsl/tests/array_refcount_test.cpp
@@ -0,0 +1,143 @@
+/*
+ * Copyright © 2016 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+#include 
+#include "ir.h"
+#include "ir_array_refcount.h"
+
+class array_refcount_test : public ::testing::Test {
+public:
+   virtual void SetUp();
+   virtual void TearDown();
+
+   void *mem_ctx;
+
+   /**
+* glsl_type for a vec4[3][4][5].
+*
+* The exceptionally verbose name is picked because it matches the syntax
+* of http://cdecl.org/.
+  

[Mesa-dev] [PATCH 15/19] glsl: Trivial whitespace fixes in link_uniforms.cpp

2016-12-15 Thread Ian Romanick
From: Ian Romanick 

Signed-off-by: Ian Romanick 
---
 src/compiler/glsl/link_uniforms.cpp | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/compiler/glsl/link_uniforms.cpp 
b/src/compiler/glsl/link_uniforms.cpp
index 87e9392..396b445 100644
--- a/src/compiler/glsl/link_uniforms.cpp
+++ b/src/compiler/glsl/link_uniforms.cpp
@@ -194,8 +194,10 @@ program_resource_visitor::recursion(const glsl_type *t, 
char **name,
  record_type = t->fields.array;
 
   unsigned length = t->length;
+
   /* Shader storage block unsized arrays: add subscript [0] to variable
-   * names */
+   * names.
+   */
   if (t->is_unsized_array())
  length = 1;
 
@@ -470,8 +472,7 @@ public:
 }
  } else {
 for (unsigned i = 0; i < num_blks; i++) {
-   if (strcmp(var->get_interface_type()->name, blks[i].Name) ==
-   0) {
+   if (strcmp(var->get_interface_type()->name, blks[i].Name) == 0) 
{
   buffer_block_index = i;
   break;
}
-- 
2.7.4

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


[Mesa-dev] [PATCH 11/19] mesa: Silence numerous "unused parameter" warnings in dlist.c

2016-12-15 Thread Ian Romanick
From: Ian Romanick 

main/dlist.c: In function ‘save_DrawArraysInstancedARB’:
main/dlist.c:1748:36: warning: unused parameter ‘mode’ [-Wunused-parameter]
 save_DrawArraysInstancedARB(GLenum mode,
^~~~
main/dlist.c:1749:35: warning: unused parameter ‘first’ [-Wunused-parameter]
 GLint first,
   ^
main/dlist.c:1750:37: warning: unused parameter ‘count’ [-Wunused-parameter]
 GLsizei count,
 ^
main/dlist.c:1751:37: warning: unused parameter ‘primcount’ [-Wunused-parameter]
 GLsizei primcount)
 ^
main/dlist.c: In function ‘save_DrawElementsInstancedARB’:
main/dlist.c:1759:38: warning: unused parameter ‘mode’ [-Wunused-parameter]
 save_DrawElementsInstancedARB(GLenum mode,
  ^~~~
main/dlist.c:1760:39: warning: unused parameter ‘count’ [-Wunused-parameter]
   GLsizei count,
   ^
main/dlist.c:1761:38: warning: unused parameter ‘type’ [-Wunused-parameter]
   GLenum type,
  ^~~~
main/dlist.c:1762:45: warning: unused parameter ‘indices’ [-Wunused-parameter]
   const GLvoid *indices,
 ^~~
main/dlist.c:1763:39: warning: unused parameter ‘primcount’ [-Wunused-parameter]
   GLsizei primcount)
   ^
main/dlist.c: In function ‘save_DrawElementsInstancedBaseVertexARB’:
main/dlist.c:1771:48: warning: unused parameter ‘mode’ [-Wunused-parameter]
 save_DrawElementsInstancedBaseVertexARB(GLenum mode,
^~~~
main/dlist.c:1772:49: warning: unused parameter ‘count’ [-Wunused-parameter]
 GLsizei count,
 ^
main/dlist.c:1773:48: warning: unused parameter ‘type’ [-Wunused-parameter]
 GLenum type,
^~~~
main/dlist.c:1774:55: warning: unused parameter ‘indices’ [-Wunused-parameter]
 const GLvoid *indices,
   ^~~
main/dlist.c:1775:49: warning: unused parameter ‘primcount’ [-Wunused-parameter]
 GLsizei primcount,
 ^
main/dlist.c:1776:47: warning: unused parameter ‘basevertex’ 
[-Wunused-parameter]
 GLint basevertex)
   ^~
main/dlist.c: In function ‘save_DrawArraysInstancedBaseInstance’:
main/dlist.c:1785:45: warning: unused parameter ‘mode’ [-Wunused-parameter]
 save_DrawArraysInstancedBaseInstance(GLenum mode,
 ^~~~
main/dlist.c:1786:44: warning: unused parameter ‘first’ [-Wunused-parameter]
  GLint first,
^
main/dlist.c:1787:46: warning: unused parameter ‘count’ [-Wunused-parameter]
  GLsizei count,
  ^
main/dlist.c:1788:46: warning: unused parameter ‘primcount’ [-Wunused-parameter]
  GLsizei primcount,
  ^
main/dlist.c:1789:45: warning: unused parameter ‘baseinstance’ 
[-Wunused-parameter]
  GLuint baseinstance)
 ^~~~
main/dlist.c: In function ‘save_DrawElementsInstancedBaseInstance’:
main/dlist.c:1797:47: warning: unused parameter ‘mode’ [-Wunused-parameter]
 save_DrawElementsInstancedBaseInstance(GLenum mode,
   ^~~~
main/dlist.c:1798:48: warning: unused parameter ‘count’ [-Wunused-parameter]
GLsizei count,
^
main/dlist.c:1799:47: warning: unused parameter ‘type’ [-Wunused-parameter]
GLenum type,
   ^~~~
main/dlist.c:1800:52: warning: unused parameter ‘indices’ [-Wunused-parameter]
const void *indices,
^~~
main/dlist.c:1801:48: warning: unused parameter ‘primcount’ [-Wunused-parameter]
GLsizei primcount,
^
main/dlist.c:1802:47: warning: unused parameter ‘baseinstance’ 

[Mesa-dev] [PATCH 17/19] nir: Silence missing field initializer warnings for vectors in nir_constant_expressions

2016-12-15 Thread Ian Romanick
From: Ian Romanick 

nir/nir_constant_expressions.c: In function 'evaluate_ball2':
nir/nir_constant_expressions.c:279:7: warning: missing initializer for field 
'z' of 'struct bool_vec' [-Wmissing-field-initializers]
   };
   ^
nir/nir_constant_expressions.c:234:10: note: 'z' declared here
bool z;
  ^

Number of total warnings in my build reduced from 2532 to 2304
(reduction of 228).

v2: Initialize bool vectors with 0 instead of false to keep the
generator simpler.  Suggested by Ken.

Signed-off-by: Ian Romanick 
---
 src/compiler/nir/nir_constant_expressions.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/compiler/nir/nir_constant_expressions.py 
b/src/compiler/nir/nir_constant_expressions.py
index 96d5255..6b4d071 100644
--- a/src/compiler/nir/nir_constant_expressions.py
+++ b/src/compiler/nir/nir_constant_expressions.py
@@ -299,6 +299,9 @@ evaluate_${name}(unsigned num_components, unsigned bit_size,
_src[${j}].${get_const_field(input_types[j])}[${k}],
 % endif
  % endfor
+ % for k in range(op.input_sizes[j], 4):
+0,
+ % endfor
  };
   % endfor
 
-- 
2.7.4

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


[Mesa-dev] [PATCH 01/19] glsl: Split process_block_array into two functions

2016-12-15 Thread Ian Romanick
From: Ian Romanick 

One for the array parts and one for the leaf members.  This will
simplify later changes.

The indentation is wonkey after this patch.  This was done to make it
more obvious that the function is just getting split.  The next patch
will fix the indentation.

Signed-off-by: Ian Romanick 
Cc: mesa-sta...@lists.freedesktop.org
---
 src/compiler/glsl/link_uniform_blocks.cpp | 34 +--
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/src/compiler/glsl/link_uniform_blocks.cpp 
b/src/compiler/glsl/link_uniform_blocks.cpp
index a73b2d2..8544b90 100644
--- a/src/compiler/glsl/link_uniform_blocks.cpp
+++ b/src/compiler/glsl/link_uniform_blocks.cpp
@@ -200,6 +200,15 @@ struct block {
bool has_instance_name;
 };
 
+static void process_block_array_leaf(char **name, gl_uniform_block *blocks,
+ ubo_visitor *parcel,
+ gl_uniform_buffer_variable *variables,
+ const struct link_uniform_block_active 
*const b,
+ unsigned *block_index,
+ unsigned *binding_offset,
+ struct gl_context *ctx,
+ struct gl_shader_program *prog);
+
 static void
 process_block_array(struct uniform_block_array_elements *ub_array, char **name,
 size_t name_length, gl_uniform_block *blocks,
@@ -208,7 +217,6 @@ process_block_array(struct uniform_block_array_elements 
*ub_array, char **name,
 unsigned *block_index, unsigned *binding_offset,
 struct gl_context *ctx, struct gl_shader_program *prog)
 {
-   if (ub_array) {
   for (unsigned j = 0; j < ub_array->num_array_elements; j++) {
  size_t new_length = name_length;
 
@@ -216,11 +224,26 @@ process_block_array(struct uniform_block_array_elements 
*ub_array, char **name,
  ralloc_asprintf_rewrite_tail(name, _length, "[%u]",
   ub_array->array_elements[j]);
 
- process_block_array(ub_array->array, name, new_length, blocks,
- parcel, variables, b, block_index,
- binding_offset, ctx, prog);
+ if (ub_array->array) {
+process_block_array(ub_array->array, name, new_length, blocks,
+parcel, variables, b, block_index,
+binding_offset, ctx, prog);
+ } else {
+process_block_array_leaf(name, blocks,
+ parcel, variables, b, block_index,
+ binding_offset, ctx, prog);
+ }
   }
-   } else {
+}
+
+static void
+process_block_array_leaf(char **name,
+ gl_uniform_block *blocks,
+ ubo_visitor *parcel, gl_uniform_buffer_variable 
*variables,
+ const struct link_uniform_block_active *const b,
+ unsigned *block_index, unsigned *binding_offset,
+ struct gl_context *ctx, struct gl_shader_program 
*prog)
+{
   unsigned i = *block_index;
   const glsl_type *type =  b->type->without_array();
 
@@ -259,7 +282,6 @@ process_block_array(struct uniform_block_array_elements 
*ub_array, char **name,
 
   *block_index = *block_index + 1;
   *binding_offset = *binding_offset + 1;
-   }
 }
 
 /* This function resizes the array types of the block so that later we can use
-- 
2.7.4

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


[Mesa-dev] [PATCH 04/19] glsl: Use simpler visitor to determine which UBO and SSBO blocks are used

2016-12-15 Thread Ian Romanick
From: Ian Romanick 

Very soon this visitor will get more complicated.  The users of the
existing ir_variable_refcount visitor won't need the coming
functionality, and this use doesn't need much of the functionality of
ir_variable_refcount.

Signed-off-by: Ian Romanick 
Cc: mesa-sta...@lists.freedesktop.org
---
 src/compiler/Makefile.sources   |   2 +
 src/compiler/glsl/ir_array_refcount.cpp | 100 
 src/compiler/glsl/ir_array_refcount.h   |  65 +
 src/compiler/glsl/link_uniforms.cpp |  10 ++--
 4 files changed, 172 insertions(+), 5 deletions(-)
 create mode 100644 src/compiler/glsl/ir_array_refcount.cpp
 create mode 100644 src/compiler/glsl/ir_array_refcount.h

diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources
index 17b15de..15f410f 100644
--- a/src/compiler/Makefile.sources
+++ b/src/compiler/Makefile.sources
@@ -29,6 +29,8 @@ LIBGLSL_FILES = \
glsl/glsl_to_nir.cpp \
glsl/glsl_to_nir.h \
glsl/hir_field_selection.cpp \
+   glsl/ir_array_refcount.cpp \
+   glsl/ir_array_refcount.h \
glsl/ir_basic_block.cpp \
glsl/ir_basic_block.h \
glsl/ir_builder.cpp \
diff --git a/src/compiler/glsl/ir_array_refcount.cpp 
b/src/compiler/glsl/ir_array_refcount.cpp
new file mode 100644
index 000..41a0914
--- /dev/null
+++ b/src/compiler/glsl/ir_array_refcount.cpp
@@ -0,0 +1,100 @@
+/*
+ * Copyright © 2016 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file ir_array_refcount.cpp
+ *
+ * Provides a visitor which produces a list of variables referenced.
+ */
+
+#include "ir.h"
+#include "ir_visitor.h"
+#include "ir_array_refcount.h"
+#include "compiler/glsl_types.h"
+#include "util/hash_table.h"
+
+ir_array_refcount_visitor::ir_array_refcount_visitor()
+{
+   this->mem_ctx = ralloc_context(NULL);
+   this->ht = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
+  _mesa_key_pointer_equal);
+}
+
+static void
+free_entry(struct hash_entry *entry)
+{
+   ir_array_refcount_entry *ivre = (ir_array_refcount_entry *) entry->data;
+   delete ivre;
+}
+
+ir_array_refcount_visitor::~ir_array_refcount_visitor()
+{
+   ralloc_free(this->mem_ctx);
+   _mesa_hash_table_destroy(this->ht, free_entry);
+}
+
+ir_array_refcount_entry::ir_array_refcount_entry(ir_variable *var)
+   : var(var), is_referenced(false)
+{
+   /* empty */
+}
+
+
+ir_array_refcount_entry *
+ir_array_refcount_visitor::get_variable_entry(ir_variable *var)
+{
+   assert(var);
+
+   struct hash_entry *e = _mesa_hash_table_search(this->ht, var);
+   if (e)
+  return (ir_array_refcount_entry *)e->data;
+
+   ir_array_refcount_entry *entry = new ir_array_refcount_entry(var);
+   _mesa_hash_table_insert(this->ht, var, entry);
+
+   return entry;
+}
+
+
+ir_visitor_status
+ir_array_refcount_visitor::visit(ir_dereference_variable *ir)
+{
+   ir_variable *const var = ir->variable_referenced();
+   ir_array_refcount_entry *entry = this->get_variable_entry(var);
+
+   if (entry)
+  entry->is_referenced = true;
+
+   return visit_continue;
+}
+
+
+ir_visitor_status
+ir_array_refcount_visitor::visit_enter(ir_function_signature *ir)
+{
+   /* We don't want to descend into the function parameters and
+* dead-code eliminate them, so just accept the body here.
+*/
+   visit_list_elements(this, >body);
+   return visit_continue_with_parent;
+}
diff --git a/src/compiler/glsl/ir_array_refcount.h 
b/src/compiler/glsl/ir_array_refcount.h
new file mode 100644
index 000..9ec46d2
--- /dev/null
+++ b/src/compiler/glsl/ir_array_refcount.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright © 2016 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),

[Mesa-dev] [PATCH 02/19] glsl: Fix wonkey indentation left from previous commit

2016-12-15 Thread Ian Romanick
From: Ian Romanick 

Signed-off-by: Ian Romanick 
Cc: mesa-sta...@lists.freedesktop.org
---
 src/compiler/glsl/link_uniform_blocks.cpp | 89 +++
 1 file changed, 44 insertions(+), 45 deletions(-)

diff --git a/src/compiler/glsl/link_uniform_blocks.cpp 
b/src/compiler/glsl/link_uniform_blocks.cpp
index 8544b90..41b26e7 100644
--- a/src/compiler/glsl/link_uniform_blocks.cpp
+++ b/src/compiler/glsl/link_uniform_blocks.cpp
@@ -217,23 +217,23 @@ process_block_array(struct uniform_block_array_elements 
*ub_array, char **name,
 unsigned *block_index, unsigned *binding_offset,
 struct gl_context *ctx, struct gl_shader_program *prog)
 {
-  for (unsigned j = 0; j < ub_array->num_array_elements; j++) {
- size_t new_length = name_length;
+   for (unsigned j = 0; j < ub_array->num_array_elements; j++) {
+  size_t new_length = name_length;
 
- /* Append the subscript to the current variable name */
- ralloc_asprintf_rewrite_tail(name, _length, "[%u]",
-  ub_array->array_elements[j]);
+  /* Append the subscript to the current variable name */
+  ralloc_asprintf_rewrite_tail(name, _length, "[%u]",
+   ub_array->array_elements[j]);
 
- if (ub_array->array) {
-process_block_array(ub_array->array, name, new_length, blocks,
-parcel, variables, b, block_index,
-binding_offset, ctx, prog);
- } else {
-process_block_array_leaf(name, blocks,
- parcel, variables, b, block_index,
- binding_offset, ctx, prog);
- }
+  if (ub_array->array) {
+ process_block_array(ub_array->array, name, new_length, blocks,
+ parcel, variables, b, block_index,
+ binding_offset, ctx, prog);
+  } else {
+ process_block_array_leaf(name, blocks,
+  parcel, variables, b, block_index,
+  binding_offset, ctx, prog);
   }
+   }
 }
 
 static void
@@ -244,44 +244,43 @@ process_block_array_leaf(char **name,
  unsigned *block_index, unsigned *binding_offset,
  struct gl_context *ctx, struct gl_shader_program 
*prog)
 {
-  unsigned i = *block_index;
-  const glsl_type *type =  b->type->without_array();
+   unsigned i = *block_index;
+   const glsl_type *type =  b->type->without_array();
 
-  blocks[i].Name = ralloc_strdup(blocks, *name);
-  blocks[i].Uniforms = [(*parcel).index];
+   blocks[i].Name = ralloc_strdup(blocks, *name);
+   blocks[i].Uniforms = [(*parcel).index];
 
-  /* The GL_ARB_shading_language_420pack spec says:
-   *
-   * "If the binding identifier is used with a uniform block
-   * instanced as an array then the first element of the array
-   * takes the specified block binding and each subsequent
-   * element takes the next consecutive uniform block binding
-   * point."
-   */
-  blocks[i].Binding = (b->has_binding) ? b->binding + *binding_offset : 0;
+   /* The GL_ARB_shading_language_420pack spec says:
+*
+* "If the binding identifier is used with a uniform block instanced as
+* an array then the first element of the array takes the specified
+* block binding and each subsequent element takes the next consecutive
+* uniform block binding point."
+*/
+   blocks[i].Binding = (b->has_binding) ? b->binding + *binding_offset : 0;
 
-  blocks[i].UniformBufferSize = 0;
-  blocks[i]._Packing = gl_uniform_block_packing(type->interface_packing);
-  blocks[i]._RowMajor = type->get_interface_row_major();
+   blocks[i].UniformBufferSize = 0;
+   blocks[i]._Packing = gl_uniform_block_packing(type->interface_packing);
+   blocks[i]._RowMajor = type->get_interface_row_major();
 
-  parcel->process(type, blocks[i].Name);
+   parcel->process(type, blocks[i].Name);
 
-  blocks[i].UniformBufferSize = parcel->buffer_size;
+   blocks[i].UniformBufferSize = parcel->buffer_size;
 
-  /* Check SSBO size is lower than maximum supported size for SSBO */
-  if (b->is_shader_storage &&
-  parcel->buffer_size > ctx->Const.MaxShaderStorageBlockSize) {
- linker_error(prog, "shader storage block `%s' has size %d, "
-  "which is larger than than the maximum allowed (%d)",
-  b->type->name,
-  parcel->buffer_size,
-  ctx->Const.MaxShaderStorageBlockSize);
-  }
-  blocks[i].NumUniforms =
- (unsigned)(ptrdiff_t)([parcel->index] - blocks[i].Uniforms);
+   /* Check SSBO size is lower than maximum supported size for SSBO */
+   if 

[Mesa-dev] [PATCH 18/19] nir: Silence unused parameter warnings in nir_constant_expression.c

2016-12-15 Thread Ian Romanick
From: Ian Romanick 

nir/nir_constant_expressions.c:290:25: warning: unused parameter 
'num_components' [-Wunused-parameter]
 evaluate_ball3(unsigned num_components, nir_const_value *_src)
 ^
nir/nir_constant_expressions.c: In function 'evaluate_fddx':
nir/nir_constant_expressions.c:1282:57: warning: unused parameter '_src' 
[-Wunused-parameter]
 evaluate_fddx(unsigned num_components, nir_const_value *_src)
 ^

v2: Unconditionally mark the parameters as MAYBE_UNUSED instead of
conditionally adding (void) casts to keep the generator simple.
Suggested by Jason.

Number of total warnings in my build reduced from 1575 to 1485
(reduction of 89).

Signed-off-by: Ian Romanick 
---
 src/compiler/nir/nir_constant_expressions.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/compiler/nir/nir_constant_expressions.py 
b/src/compiler/nir/nir_constant_expressions.py
index 6b4d071..2cc106d 100644
--- a/src/compiler/nir/nir_constant_expressions.py
+++ b/src/compiler/nir/nir_constant_expressions.py
@@ -267,8 +267,8 @@ struct bool32_vec {
 
 % for name, op in sorted(opcodes.iteritems()):
 static nir_const_value
-evaluate_${name}(unsigned num_components, unsigned bit_size,
- nir_const_value *_src)
+evaluate_${name}(MAYBE_UNUSED unsigned num_components, unsigned bit_size,
+ MAYBE_UNUSED nir_const_value *_src)
 {
nir_const_value _dst_val = { {0, } };
 
-- 
2.7.4

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


[Mesa-dev] [PATCH 14/19] glsl: Silence unused parameter warning in propagate_invariance.cpp

2016-12-15 Thread Ian Romanick
From: Ian Romanick 

glsl/propagate_invariance.cpp: In member function ‘virtual ir_visitor_status 
{anonymous}::ir_invariance_propagation_visitor::visit_leave(ir_assignment*)’:
glsl/propagate_invariance.cpp:86:63: warning: unused parameter ‘ir’ 
[-Wunused-parameter]
 ir_invariance_propagation_visitor::visit_leave(ir_assignment *ir)
   ^~

Signed-off-by: Ian Romanick 
---
 src/compiler/glsl/propagate_invariance.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compiler/glsl/propagate_invariance.cpp 
b/src/compiler/glsl/propagate_invariance.cpp
index b834b49..b3f1d81 100644
--- a/src/compiler/glsl/propagate_invariance.cpp
+++ b/src/compiler/glsl/propagate_invariance.cpp
@@ -83,7 +83,7 @@ ir_invariance_propagation_visitor::visit_enter(ir_assignment 
*ir)
 }
 
 ir_visitor_status
-ir_invariance_propagation_visitor::visit_leave(ir_assignment *ir)
+ir_invariance_propagation_visitor::visit_leave(ir_assignment *)
 {
this->dst_var = NULL;
 
-- 
2.7.4

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


[Mesa-dev] [PATCH 09/19] linker: Accurately mark a uniform block instance array element as used in a stage

2016-12-15 Thread Ian Romanick
From: Ian Romanick 

Now that information about which array-of-arrays elements are accessed
is tracked, use that information to only mark an instance array element
as used-by-stage if, in fact, it is.

Fixes GL45-CTS.program_interface_query.uniform-block-types.

Signed-off-by: Ian Romanick 
Cc: mesa-sta...@lists.freedesktop.org
---
 src/compiler/glsl/link_uniforms.cpp | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/compiler/glsl/link_uniforms.cpp 
b/src/compiler/glsl/link_uniforms.cpp
index 2f851ce..87e9392 100644
--- a/src/compiler/glsl/link_uniforms.cpp
+++ b/src/compiler/glsl/link_uniforms.cpp
@@ -905,7 +905,9 @@ link_update_uniform_buffer_variables(struct 
gl_linked_shader *shader,
  shader->UniformBlocks : shader->ShaderStorageBlocks;
 
   if (var->is_interface_instance()) {
- if (variable_is_referenced(v, var)) {
+ const ir_array_refcount_entry *const entry = 
v.get_variable_entry(var);
+
+ if (entry->is_referenced) {
 /* Since this is an interface instance, the instance type will be
  * same as the array-stripped variable type.  If the variable type
  * is an array, then the block names will be suffixed with [0]
@@ -931,7 +933,9 @@ link_update_uniform_buffer_variables(struct 
gl_linked_shader *shader,
 * be an array of instances, and all elements of the array need
 * to be marked as referenced.
 */
-   if (strncmp(begin, var->get_interface_type()->name, len) == 0) {
+   if (strncmp(begin, var->get_interface_type()->name, len) == 0 &&
+   (!var->type->is_array() ||
+
entry->is_linearized_index_referenced(blks[i]->linearized_array_index))) {
   blks[i]->stageref |= 1U << stage;
}
 }
-- 
2.7.4

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


[Mesa-dev] [PATCH 10/19] mesa: Fix all the whitespace errors in dlist.c

2016-12-15 Thread Ian Romanick
From: Ian Romanick 

Signed-off-by: Ian Romanick 
---
 src/mesa/main/dlist.c | 373 +-
 1 file changed, 186 insertions(+), 187 deletions(-)

diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 9d9e319..54ef0b1 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -110,67 +110,66 @@ struct gl_list_extensions
  * Checks if dd_function_table::SaveNeedFlush is marked to flush
  * stored (save) vertices, and calls vbo_save_SaveFlushVertices if so.
  */
-#define SAVE_FLUSH_VERTICES(ctx)   \
-do {   \
-   if (ctx->Driver.SaveNeedFlush)  \
-  vbo_save_SaveFlushVertices(ctx);   \
-} while (0)
+#define SAVE_FLUSH_VERTICES(ctx) \
+   do {  \
+  if (ctx->Driver.SaveNeedFlush) \
+ vbo_save_SaveFlushVertices(ctx);\
+   } while (0)
 
 
 /**
  * Macro to assert that the API call was made outside the
  * glBegin()/glEnd() pair, with return value.
- * 
+ *
  * \param ctx GL context.
  * \param retval value to return value in case the assertion fails.
  */
-#define ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval) \
-do {   \
-   if (ctx->Driver.CurrentSavePrimitive <= PRIM_MAX) { \
-  _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glBegin/End" ); \
-  return retval;   \
-   }   \
-} while (0)
+#define ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval)  \
+   do { \
+  if (ctx->Driver.CurrentSavePrimitive <= PRIM_MAX) {   \
+ _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glBegin/End" ); \
+ return retval; \
+  } \
+   } while (0)
 
 /**
  * Macro to assert that the API call was made outside the
  * glBegin()/glEnd() pair.
- * 
+ *
  * \param ctx GL context.
  */
-#define ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx) \
-do {   \
-   if (ctx->Driver.CurrentSavePrimitive <= PRIM_MAX) { \
-  _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glBegin/End" ); \
-  return;  \
-   }   \
-} while (0)
+#define ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx)  \
+   do { \
+  if (ctx->Driver.CurrentSavePrimitive <= PRIM_MAX) {   \
+ _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glBegin/End" ); \
+ return;\
+  } \
+   } while (0)
 
 /**
  * Macro to assert that the API call was made outside the
  * glBegin()/glEnd() pair and flush the vertices.
- * 
+ *
  * \param ctx GL context.
  */
-#define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx)   \
-do {   \
-   ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx); \
-   SAVE_FLUSH_VERTICES(ctx);   \
-} while (0)
+#define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx)\
+   do { \
+  ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx);   \
+  SAVE_FLUSH_VERTICES(ctx); \
+   } while (0)
 
 /**
  * Macro to assert that the API call was made outside the
  * glBegin()/glEnd() pair and flush the vertices, with return value.
- * 
+ *
  * \param ctx GL context.
  * \param retval value to return value in case the assertion fails.
  */
-#define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval)\
-do {   \
-   ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval); \
-   SAVE_FLUSH_VERTICES(ctx);   \
-} while (0)
-
+#define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval) \
+   do { \
+  ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval);   \
+  SAVE_FLUSH_VERTICES(ctx); \
+   } while (0)
 
 
 /**
@@ -1272,7 +1271,7 @@ unpack_image(struct gl_context *ctx, GLuint dimensions,
 
   

[Mesa-dev] [PATCH 08/19] glsl: Walk a list of ir_dereference_array to mark array elements as accessed

2016-12-15 Thread Ian Romanick
From: Ian Romanick 

Signed-off-by: Ian Romanick 
Cc: mesa-sta...@lists.freedesktop.org
---
 src/compiler/glsl/ir_array_refcount.cpp |  73 +++-
 src/compiler/glsl/ir_array_refcount.h   |  10 +
 src/compiler/glsl/tests/array_refcount_test.cpp | 425 
 3 files changed, 507 insertions(+), 1 deletion(-)

diff --git a/src/compiler/glsl/ir_array_refcount.cpp 
b/src/compiler/glsl/ir_array_refcount.cpp
index 75dca0a..7c9ab8e 100644
--- a/src/compiler/glsl/ir_array_refcount.cpp
+++ b/src/compiler/glsl/ir_array_refcount.cpp
@@ -34,7 +34,7 @@
 #include "util/hash_table.h"
 
 ir_array_refcount_visitor::ir_array_refcount_visitor()
-   : derefs(0), num_derefs(0), derefs_size(0)
+   : last_array_deref(0), derefs(0), num_derefs(0), derefs_size(0)
 {
this->mem_ctx = ralloc_context(NULL);
this->ht = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
@@ -159,6 +159,77 @@ ir_array_refcount_visitor::get_array_deref()
return d;
 }
 
+ir_visitor_status
+ir_array_refcount_visitor::visit_enter(ir_dereference_array *ir)
+{
+   /* It could also be a vector or a matrix.  Individual elements of vectors
+* are natrices are not tracked, so bail.
+*/
+   if (!ir->array->type->is_array())
+  return visit_continue;
+
+   /* If this array dereference is a child of an array dereference that was
+* already visited, just continue on.  Otherwise, for an arrays-of-arrays
+* dereference like x[1][2][3][4], we'd process the [1][2][3][4] sequence,
+* the [1][2][3] sequence, the [1][2] sequence, and the [1] sequence.  This
+* ensures that we only process the full sequence.
+*/
+   if (last_array_deref && last_array_deref->array == ir) {
+  last_array_deref = ir;
+  return visit_continue;
+   }
+
+   last_array_deref = ir;
+
+   num_derefs = 0;
+
+   ir_rvalue *rv = ir;
+   while (rv->ir_type == ir_type_dereference_array) {
+  ir_dereference_array *const deref = rv->as_dereference_array();
+
+  assert(deref != NULL);
+  assert(deref->array->type->is_array());
+
+  ir_rvalue *const array = deref->array;
+  const ir_constant *const idx = deref->array_index->as_constant();
+  array_deref_range *const dr = get_array_deref();
+
+  dr->size = array->type->array_size();
+
+  if (idx != NULL) {
+ dr->index = idx->get_int_component(0);
+  } else {
+ /* An unsized array can occur at the end of an SSBO.  We can't track
+  * accesses to such an array, so bail.
+  */
+ if (array->type->array_size() == 0)
+return visit_continue;
+
+ dr->index = dr->size;
+  }
+
+  rv = array;
+   }
+
+   ir_dereference_variable *const var_deref = rv->as_dereference_variable();
+
+   /* If the array being dereferenced is not a variable, bail.  At the very
+* least, ir_constant and ir_dereference_record are possible.
+*/
+   if (var_deref == NULL)
+  return visit_continue;
+
+   ir_array_refcount_entry *const entry =
+  this->get_variable_entry(var_deref->var);
+
+   if (entry == NULL)
+  return visit_stop;
+
+   entry->mark_array_elements_referenced(derefs, num_derefs);
+
+   return visit_continue;
+}
+
 
 ir_visitor_status
 ir_array_refcount_visitor::visit(ir_dereference_variable *ir)
diff --git a/src/compiler/glsl/ir_array_refcount.h 
b/src/compiler/glsl/ir_array_refcount.h
index 2988046..46ba36c 100644
--- a/src/compiler/glsl/ir_array_refcount.h
+++ b/src/compiler/glsl/ir_array_refcount.h
@@ -140,6 +140,7 @@ public:
virtual ir_visitor_status visit(ir_dereference_variable *);
 
virtual ir_visitor_status visit_enter(ir_function_signature *);
+   virtual ir_visitor_status visit_enter(ir_dereference_array *);
 
/**
 * Find variable in the hash table, and insert it if not present
@@ -158,6 +159,15 @@ private:
array_deref_range *get_array_deref();
 
/**
+* Last ir_dereference_array that was visited
+*
+* Used to prevent some redundant calculations.
+*
+* \sa ::visit_enter(ir_dereference_array *)
+*/
+   ir_dereference_array *last_array_deref;
+
+   /**
 * \name array_deref_range tracking
 */
/*@{*/
diff --git a/src/compiler/glsl/tests/array_refcount_test.cpp 
b/src/compiler/glsl/tests/array_refcount_test.cpp
index 29bb133..ecd7f46 100644
--- a/src/compiler/glsl/tests/array_refcount_test.cpp
+++ b/src/compiler/glsl/tests/array_refcount_test.cpp
@@ -23,12 +23,18 @@
 #include 
 #include "ir.h"
 #include "ir_array_refcount.h"
+#include "ir_builder.h"
+#include "util/hash_table.h"
+
+using namespace ir_builder;
 
 class array_refcount_test : public ::testing::Test {
 public:
virtual void SetUp();
virtual void TearDown();
 
+   exec_list instructions;
+   ir_factory *body;
void *mem_ctx;
 
/**
@@ -40,6 +46,14 @@ public:
const glsl_type *array_3_of_array_4_of_array_5_of_vec4;
 
/**
+* glsl_type for a int[3].
+*
+* The exceptionally 

[Mesa-dev] [PATCH 00/19] Track block instance array access per element

2016-12-15 Thread Ian Romanick
This series can also be found at:


https://cgit.freedesktop.org/~idr/mesa/log/?h=fix-GL45-CTS.program_interface_query.uniform-block-types

The first 9 patches in the series are the bug fix.  This conformance
test expects per-block used-by tracking for UBO and SSBO instance array
blocks.  So, a block like

uniform Block {
...
} block[3];

will have 3 blocks, Block[0] .. Block[2], reported via program interface
queries.  Each of these may have a different set of per-stage used-by
flags.  We were not tracking this.  If any member was used by a stage,
we would report that all members were used by the stage.

Arrays-of-arrays and non-constant indexing make this non-trivial.  I
expect that's why we didn't do it before. :) I think I have a nice
solution to the problem.  I thought of a couple simlpler soultions, but
each fell victim to various corner cases.  I have tried to capture these
corner cases in the unit tests.

The remaining patches just clean up various bits of trivium.  A couple
of them are quite old.  There was more in that series, but they're not
ready to re-send.

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


Re: [Mesa-dev] Problem using GLVND enabled mesa with Intel DDX

2016-12-15 Thread Yu, Qiang

Thanks for your info, Emil. Same bug as 98428.

Regards,
Qiang


From: Emil Velikov 
Sent: Thursday, December 15, 2016 9:58:34 PM
To: Yu, Qiang
Cc: mesa-dev@lists.freedesktop.org; kbrenne...@nvidia.com; Daenzer, Michel
Subject: Re: [Mesa-dev] Problem using GLVND enabled mesa with Intel DDX

On 15 December 2016 at 09:01, Yu, Qiang  wrote:
>
> Hi guys,
>
> I'm trying GLVND with mesa, but the Intel DDX seems have some problem with it:
> [  2970.834] (EE) AIGLX error: dlopen of 
> /usr/lib/x86_64-linux-gnu/dri/i965_dri.so failed 
> (/usr/lib/x86_64-linux-gnu/dri/i965_dri.so: undefined symbol: 
> _glapi_tls_Dispatch)
> [  2970.834] (EE) AIGLX: reverting to software rendering
> [  2970.889] (EE) AIGLX error: dlopen of 
> /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so failed 
> (/usr/lib/x86_64-linux-gnu/dri/swrast_dri.so: undefined symbol: 
> _glapi_tls_Dispatch)
> [  2970.889] (EE) GLX: could not load software renderer
> [  2970.889] (II) GLX: no usable GL providers found for screen 0
>
> I find the _glapi_tls_Dispatch is in libglapi.so which is depended by 
> libGLX_mesa.so.
> But in Intel DDX's case, no libGLX_mesa.so/libglapi.so is loaded, i965_dri.so 
> is loaded directly.
>
Sounds like https://bugs.freedesktop.org/show_bug.cgi?id=98428

There's a bunch of ideas on how to tackle this, ranging from:
 - retro "fix" xserver - comment 2
 - link against glapi.so (it can have implications) - comment 3
 - reuse GLdispatch.so for the symbols - comment 3 and others

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


Re: [Mesa-dev] [PATCH] Mesa: Fix error code for glTexImage3D in GLES

2016-12-15 Thread Edward O'Callaghan
Reviewed-by: Edward O'Callaghan 

On 12/16/2016 12:56 PM, Randy Xu wrote:
> From: "Xu,Randy" 
> 
> The ES specification says that TexImage3D should return GL_INVALID_OPERATION
> if the internal format is DEPTH_COMPONENT, DEPTH_-STENCIL or STENCIL_INDEX.
> The current code returns INVALID_ENUM as _mesa_error_check_format_and_type is
> used by glReadPixels also and the GL specification defines "INVALID_ENUM is
> generated if format is DEPTH_STENCIL and type is not UNSIGNED_INT_24_8 or
> FLOAT_32_UNSIGNED_INT_24_8_- REV".
> 
> This patch only impacts GLES, which can generate GL_INVALID_OPERATION because
> glReadPixels cannot be used to read depth or stencil buffer.
> Fixes dEQP-GLES3.functional.negative_api.texture.teximage3d.
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99076
> 
> Signed-off-by: Xu,Randy 
> ---
>  src/mesa/main/glformats.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
> index a95909c..66b 100644
> --- a/src/mesa/main/glformats.c
> +++ b/src/mesa/main/glformats.c
> @@ -2087,6 +2087,8 @@ _mesa_error_check_format_and_type(const struct 
> gl_context *ctx,
>   else if (ctx->Extensions.ARB_depth_buffer_float &&
>   type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV)
>  return GL_NO_ERROR;
> + else if (!_mesa_is_desktop_gl(ctx))
> +return GL_INVALID_OPERATION;
>   else
>  return GL_INVALID_ENUM;
>  
> 



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


Re: [Mesa-dev] [PATCH 3/3] nir: Rewrite lower_regs_to_ssa to use the phi builder

2016-12-15 Thread Jason Ekstrand
On Dec 15, 2016 3:08 PM, "Eric Anholt"  wrote:

Jason Ekstrand  writes:

> This keeps some of Connor's original code.  However, while I was at it,
> I updated this very old pass to a bit more modern NIR.

I love how much smaller this code is.  Assuming that the phi builder
does that job correctly, this is pretty trivial to read and understand.


The bigger vars_to_ssa has been using the phi builder for some time now and
it's handled everything we've ever thrown at it.

The only things I saw were:

- It doesn't call nir_metadata_preserve() like the old pass did, while
  it adds new SSA values.  Seems like it should.


Yup.   I'll get that fixed.

- It asserts that reg->num_array_elems == 0, while the old pass would
  just skip those.  It looks like the only source of arrays would be
  nir_lower_locals_to_regs(), which only i965 is calling.  Is that
  something we should be using?  Should we be handling the array reg
  case in this pass and in our drivers?


I've got a patch for that.  I needed it for my hack testing.  I'll as it to
the pass.  Incidentally, I don't think the old pass handles either of those
correctly, it just assumed everything was a "normal" register.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] Mesa: Fix error code for glTexImage3D in GLES

2016-12-15 Thread Randy Xu
From: "Xu,Randy" 

The ES specification says that TexImage3D should return GL_INVALID_OPERATION
if the internal format is DEPTH_COMPONENT, DEPTH_-STENCIL or STENCIL_INDEX.
The current code returns INVALID_ENUM as _mesa_error_check_format_and_type is
used by glReadPixels also and the GL specification defines "INVALID_ENUM is
generated if format is DEPTH_STENCIL and type is not UNSIGNED_INT_24_8 or
FLOAT_32_UNSIGNED_INT_24_8_- REV".

This patch only impacts GLES, which can generate GL_INVALID_OPERATION because
glReadPixels cannot be used to read depth or stencil buffer.
Fixes dEQP-GLES3.functional.negative_api.texture.teximage3d.

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

Signed-off-by: Xu,Randy 
---
 src/mesa/main/glformats.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index a95909c..66b 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -2087,6 +2087,8 @@ _mesa_error_check_format_and_type(const struct gl_context 
*ctx,
  else if (ctx->Extensions.ARB_depth_buffer_float &&
  type == GL_FLOAT_32_UNSIGNED_INT_24_8_REV)
 return GL_NO_ERROR;
+ else if (!_mesa_is_desktop_gl(ctx))
+return GL_INVALID_OPERATION;
  else
 return GL_INVALID_ENUM;
 
-- 
2.7.4

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


[Mesa-dev] [PATCH] radv: fix dual source blending

2016-12-15 Thread Fredrik Höglund
Add the index to the location when assigning driver locations for
output variables.

Otherwise two fragment shader outputs declared as:

   layout (location = 0, index = 0) out vec4 output1;
   layout (location = 0, index = 1) out vec4 output2;

will end up aliasing one another.

Note that this patch will make the second output variable in the above
example alias a possible third output variable with location = 1 and
index = 0. But this shouldn't be a problem in practice since only one
color attachment is supported when dual-source blending is used.
---
 src/amd/common/ac_nir_to_llvm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index d66fefb..90ee917 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -4125,7 +4125,7 @@ static void
 handle_shader_output_decl(struct nir_to_llvm_context *ctx,
  struct nir_variable *variable)
 {
-   int idx = variable->data.location;
+   int idx = variable->data.location + variable->data.index;
unsigned attrib_count = glsl_count_attribute_slots(variable->type, 
false);
 
variable->data.driver_location = idx * 4;
@@ -4155,7 +4155,7 @@ handle_shader_output_decl(struct nir_to_llvm_context *ctx,
   si_build_alloca_undef(ctx, ctx->f32, "");
}
}
-   ctx->output_mask |= ((1ull << attrib_count) - 1) << 
variable->data.location;
+   ctx->output_mask |= ((1ull << attrib_count) - 1) << idx;
 }
 
 static void
-- 
2.1.4

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


Re: [Mesa-dev] [PATCH] Mesa: Return GL error INVALID_OPERATION in case invalid format/type

2016-12-15 Thread Xu, Randy
Thanks, Matt

I have run "git config --global user.name "Randy Xu"" and see it in ~/.gitconfig
[user]
email = randy...@intel.com
name = Randy Xu

While I don’t know why the "git send-email --smtp-server=smtp.intel.com 
--to=mesa-dev@lists.freedesktop.org 0001-.patch" 
command always cc the email to x...@freedesktop.org , which is not valid. Do 
you know why?

Thanks,
Randy

-Original Message-
From: Matt Turner [mailto:matts...@gmail.com] 
Sent: Friday, December 16, 2016 9:20 AM
To: Xu, Randy 
Cc: mesa-dev@lists.freedesktop.org; x...@freedesktop.org
Subject: Re: [Mesa-dev] [PATCH] Mesa: Return GL error INVALID_OPERATION in case 
invalid format/type

On Wed, Dec 14, 2016 at 5:10 PM, Randy Xu  wrote:
> From: "Xu,Randy" 

Reminder to fix your configured name.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] Mesa: Return GL error INVALID_OPERATION in case invalid format/type

2016-12-15 Thread Matt Turner
On Thu, Dec 15, 2016 at 5:19 PM, Matt Turner  wrote:
> On Wed, Dec 14, 2016 at 5:10 PM, Randy Xu  wrote:
>> From: "Xu,Randy" 
>
> Reminder to fix your configured name.

And also please stop Cc'ing the non-existent x...@freedesktop.org on
your patches. Everyone who has replied to your mail has inevitably
gotten a bounce message.

s/Mesa/mesa/ in the summary as well.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] Mesa: Return GL error INVALID_OPERATION in case invalid format/type

2016-12-15 Thread Matt Turner
On Wed, Dec 14, 2016 at 5:10 PM, Randy Xu  wrote:
> From: "Xu,Randy" 

Reminder to fix your configured name.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] Mesa: Return GL error INVALID_OPERATION in case invalid format/type

2016-12-15 Thread Xu, Randy
Thanks, Emil & Ilia

I will revise the patch per your suggestion below. 
1. Refer 19f13b2096a9fdd986e5a12d4e9d8b0d6a4632f3 to update comment
2. s/can fix/fixes/
3. s/failure//
4. s/Bug/Bugzilla/
5. Cc: "13.0" 

As for "Matt pointed out that desktop GL actually has similar text.", it's 
true, but the _mesa_error_check_format_and_type function under change 
is not only used by glTexImage3D, but also glReadPixel. Per GL spec 
https://www.opengl.org/registry/doc/glspec45.core.pdf  in page 510 
An INVALID_ENUM error is generated if format is DEPTH_STENCIL and type is not 
UNSIGNED_INT_24_8 or FLOAT_32_UNSIGNED_INT_24_8_- REV

So I limit the impact of this patch to GLES, which can generate 
GL_INVALID_OPERATION because glReadPixels cannot be used to read depth or 
stencil in that API.

Thanks
Randy

-Original Message-
From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On Behalf Of 
Ilia Mirkin
Sent: Thursday, December 15, 2016 10:01 PM
To: Emil Velikov 
Cc: ML mesa-dev ; Xu, Randy 
; x...@freedesktop.org
Subject: Re: [Mesa-dev] [PATCH] Mesa: Return GL error INVALID_OPERATION in case 
invalid format/type

On Thu, Dec 15, 2016 at 6:45 AM, Emil Velikov  wrote:
> On 15 December 2016 at 01:10, Randy Xu  wrote:
>> From: "Xu,Randy" 
>>
>> Refer to GLES3.2 spec in 8.5
>> Textures with a base internal format of DEPTH_COMPONENT, DEPTH_- 
>> STENCIL or STENCIL_INDEX are supported by texture image specification 
>> commands only if target is TEXTURE_2D, TEXTURE_2D_MULTISAMPLE, 
>> TEXTURE_2D_ARRAY, TEXTURE_2D_MULTISAMPLE_ARRAY, TEXTURE_CUBE_- MAP or 
>> TEXTURE_CUBE_MAP_ARRAY. Using these formats in conjunction with any 
>> other target will result in an INVALID_OPERATION error.
>> This patch can fix 
>> dEQP-GLES3.functional.negative_api.texture.teximage3d

s/can fix/fixes/

>> failure.

s/failure//

>>
> I think others have alluded it with referencing other commits, but it 
> might have been too subtle.
>  - please use the cannonical format [1] to add a spec quote in the 
> code
>  - your commit message should explain why rather than a simple spec quote.
> You can draw some inspirations from 
> 19f13b2096a9fdd986e5a12d4e9d8b0d6a4632f3

And #3 - Matt pointed out that desktop GL actually has similar text.
So the condition needs to be different (and will require some trudging through 
specs to figure out what happened). [Unless I misunderstood what he was saying, 
in which case, disregard.]

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


Re: [Mesa-dev] [PATCH] swr: Implement fence attached work queues for deferred deletion.

2016-12-15 Thread Kyriazis, George

Reviewed-by: George Kyriazis 

> -Original Message-
> From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On
> Behalf Of Bruce Cherniak
> Sent: Monday, December 12, 2016 7:25 PM
> To: mesa-dev@lists.freedesktop.org
> Subject: [Mesa-dev] [PATCH] swr: Implement fence attached work queues
> for deferred deletion.
> 
> Work can now be added to fences and triggered by fence completion. This
> allows for deferred resource deletion, and other asynchronous tasks.
> ---
>  src/gallium/drivers/swr/Makefile.sources   |   2 +
>  src/gallium/drivers/swr/swr_context.cpp|   7 +-
>  src/gallium/drivers/swr/swr_fence.cpp  |  14 ++-
>  src/gallium/drivers/swr/swr_fence.h|   8 ++
>  src/gallium/drivers/swr/swr_fence_work.cpp | 148
> +
>  src/gallium/drivers/swr/swr_fence_work.h   |  47 +
>  src/gallium/drivers/swr/swr_scratch.cpp|  32 +++
>  src/gallium/drivers/swr/swr_screen.cpp |  35 ---
>  src/gallium/drivers/swr/swr_state.cpp  |  16 ++--
>  9 files changed, 255 insertions(+), 54 deletions(-)
>  create mode 100644 src/gallium/drivers/swr/swr_fence_work.cpp
>  create mode 100644 src/gallium/drivers/swr/swr_fence_work.h
> 
> diff --git a/src/gallium/drivers/swr/Makefile.sources
> b/src/gallium/drivers/swr/Makefile.sources
> index d81d458..1afb532 100644
> --- a/src/gallium/drivers/swr/Makefile.sources
> +++ b/src/gallium/drivers/swr/Makefile.sources
> @@ -42,6 +42,8 @@ CXX_SOURCES := \
>   swr_memory.h \
>   swr_fence.h \
>   swr_fence.cpp \
> + swr_fence_work.h \
> + swr_fence_work.cpp \
>   swr_query.h \
>   swr_query.cpp
> 
> diff --git a/src/gallium/drivers/swr/swr_context.cpp
> b/src/gallium/drivers/swr/swr_context.cpp
> index b8c87fa..8933085 100644
> --- a/src/gallium/drivers/swr/swr_context.cpp
> +++ b/src/gallium/drivers/swr/swr_context.cpp
> @@ -355,9 +355,6 @@ swr_destroy(struct pipe_context *pipe)
> if (ctx->blitter)
>util_blitter_destroy(ctx->blitter);
> 
> -   /* Idle core before deleting context */
> -   SwrWaitForIdle(ctx->swrContext);
> -
> for (unsigned i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
>pipe_surface_reference(>framebuffer.cbufs[i], NULL);
> }
> @@ -372,6 +369,10 @@ swr_destroy(struct pipe_context *pipe)
>pipe_sampler_view_reference(
> >sampler_views[PIPE_SHADER_VERTEX][i], NULL);
> }
> 
> +   /* Idle core after destroying buffer resources, but before deleting
> +* context.  Destroying resources has potentially called StoreTiles.*/
> +   SwrWaitForIdle(ctx->swrContext);
> +
> if (ctx->swrContext)
>SwrDestroyContext(ctx->swrContext);
> 
> diff --git a/src/gallium/drivers/swr/swr_fence.cpp
> b/src/gallium/drivers/swr/swr_fence.cpp
> index 7fe2470..c73bbbf 100644
> --- a/src/gallium/drivers/swr/swr_fence.cpp
> +++ b/src/gallium/drivers/swr/swr_fence.cpp
> @@ -38,10 +38,13 @@
>   * to SwrSync call.
>   */
>  static void
> -swr_sync_cb(uint64_t userData, uint64_t userData2, uint64_t userData3)
> +swr_fence_cb(uint64_t userData, uint64_t userData2, uint64_t userData3)
>  {
> struct swr_fence *fence = (struct swr_fence *)userData;
> 
> +   /* Complete all work attached to the fence */
> +   swr_fence_do_work(fence);
> +
> /* Correct value is in SwrSync data, and not the fence write field. */
> fence->read = userData2;
>  }
> @@ -56,7 +59,7 @@ swr_fence_submit(struct swr_context *ctx, struct
> pipe_fence_handle *fh)
> 
> fence->write++;
> fence->pending = TRUE;
> -   SwrSync(ctx->swrContext, swr_sync_cb, (uint64_t)fence, fence->write,
> 0);
> +   SwrSync(ctx->swrContext, swr_fence_cb, (uint64_t)fence, fence->write,
> 0);
>  }
> 
>  /*
> @@ -72,6 +75,7 @@ swr_fence_create()
> 
> pipe_reference_init(>reference, 1);
> fence->id = fence_id++;
> +   fence->work.tail = >work.head;
> 
> return (struct pipe_fence_handle *)fence;
>  }
> @@ -80,6 +84,8 @@ swr_fence_create()
>  static void
>  swr_fence_destroy(struct swr_fence *fence)
>  {
> +   /* Complete any work left if fence was not submitted */
> +   swr_fence_do_work(fence);
> FREE(fence);
>  }
> 
> @@ -101,8 +107,10 @@ swr_fence_reference(struct pipe_screen *screen,
>old = NULL;
> }
> 
> -   if (pipe_reference(>reference, >reference))
> +   if (pipe_reference(>reference, >reference)) {
> +  swr_fence_finish(screen, NULL, (struct pipe_fence_handle *) old, 0);
>swr_fence_destroy(old);
> +   }
>  }
> 
> 
> diff --git a/src/gallium/drivers/swr/swr_fence.h
> b/src/gallium/drivers/swr/swr_fence.h
> index 80a4345..4766b5b 100644
> --- a/src/gallium/drivers/swr/swr_fence.h
> +++ b/src/gallium/drivers/swr/swr_fence.h
> @@ -25,6 +25,8 @@
>  #include "pipe/p_state.h"
>  #include "util/u_inlines.h"
> 
> +#include "swr_fence_work.h"
> +
>  struct pipe_screen;
> 
>  struct swr_fence {
> @@ -36,6 +38,12 @@ struct swr_fence {
> unsigned pending;
> 
> unsigned id; /* Just for reference */
> +
> +   struct {
> +  

Re: [Mesa-dev] [PATCH] nir: Turn imov/fmov of undef into undef

2016-12-15 Thread Kenneth Graunke
On Friday, December 16, 2016 10:17:33 AM PST Timothy Arceri wrote:
> Reverting the previous attempt at this a5502a721fd30fd resulted in
> the following Vulkan test failing.
> 
> dEQP-VK.glsl.return.return_in_dynamic_loop_dynamic_vertex
> 
> This time we use the num_components from the alu dest rather than
> num_inputs to the op to determine the size of the undef.
> 
> Cc: "13.0" 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99100
> ---
>  src/compiler/nir/nir_opt_undef.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/src/compiler/nir/nir_opt_undef.c 
> b/src/compiler/nir/nir_opt_undef.c
> index c4777a8..8d3210c 100644
> --- a/src/compiler/nir/nir_opt_undef.c
> +++ b/src/compiler/nir/nir_opt_undef.c
> @@ -79,22 +79,22 @@ opt_undef_vecN(nir_builder *b, nir_alu_instr *alu)
>  {
> if (alu->op != nir_op_vec2 &&
> alu->op != nir_op_vec3 &&
> -   alu->op != nir_op_vec4)
> +   alu->op != nir_op_vec4 &&
> +   alu->op != nir_op_fmov &&
> +   alu->op != nir_op_imov)
>return false;
>  
> assert(alu->dest.dest.is_ssa);
>  
> -   unsigned num_components = nir_op_infos[alu->op].num_inputs;
> -
> -   for (unsigned i = 0; i < num_components; i++) {
> +   for (unsigned 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)
>   return false;
> }
>  
> b->cursor = nir_before_instr(>instr);
> -   nir_ssa_def *undef =
> -  nir_ssa_undef(b, num_components, nir_dest_bit_size(alu->dest.dest));
> +   nir_ssa_def *undef = nir_ssa_undef(b, alu->dest.dest.ssa.num_components,
> +  nir_dest_bit_size(alu->dest.dest));
> nir_ssa_def_rewrite_uses(>dest.dest.ssa, nir_src_for_ssa(undef));
>  
> return true;
> 

I don't understand why that test regressed...I suspect this is just
hiding an actual bug.  But the optimization looks right to me, so

Reviewed-by: Kenneth Graunke 


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


Re: [Mesa-dev] [PATCH 45/84] st/nine: Pass size of memory to nine_state

2016-12-15 Thread Axel Davy

This patch breaks build because it doesn't replace some calls.
The replacements are introduced by the patch after.

I suggest to just merge the two patches. I'm not so sure this patch
makes sense alone.

Axel

On 07/12/2016 23:55, Axel Davy wrote:

From: Patrick Rudolph 

Required for CSMT.

Signed-off-by: Patrick Rudolph 
---
  src/gallium/state_trackers/nine/device9.c| 20 ++--
  src/gallium/state_trackers/nine/nine_state.c | 18 ++
  src/gallium/state_trackers/nine/nine_state.h |  6 ++
  3 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/src/gallium/state_trackers/nine/device9.c 
b/src/gallium/state_trackers/nine/device9.c
index b959793..df96e88 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -3240,7 +3240,9 @@ NineDevice9_SetVertexShaderConstantF( struct NineDevice9 
*This,
 pConstantData,
 Vector4fCount * 4 * sizeof(state->vs_const_f[0]));
  
-nine_context_set_vertex_shader_constant_f(This, StartRegister, pConstantData, Vector4fCount);

+nine_context_set_vertex_shader_constant_f(This, StartRegister, 
pConstantData,
+  Vector4fCount * 4 * 
sizeof(state->vs_const_f[0]),
+  Vector4fCount);
  
  return D3D_OK;

  }
@@ -3306,7 +3308,8 @@ NineDevice9_SetVertexShaderConstantI( struct NineDevice9 
*This,
 >range_pool);
  state->changed.group |= NINE_STATE_VS_CONST;
  } else
-nine_context_set_vertex_shader_constant_i(This, StartRegister, 
pConstantData, Vector4iCount);
+nine_context_set_vertex_shader_constant_i(This, StartRegister, 
pConstantData,
+  Vector4iCount * 
sizeof(int[4]), Vector4iCount);
  
  return D3D_OK;

  }
@@ -3380,7 +3383,8 @@ NineDevice9_SetVertexShaderConstantB( struct NineDevice9 
*This,
 >range_pool);
  state->changed.group |= NINE_STATE_VS_CONST;
  } else
-nine_context_set_vertex_shader_constant_b(This, StartRegister, 
pConstantData, BoolCount);
+nine_context_set_vertex_shader_constant_b(This, StartRegister, 
pConstantData,
+  sizeof(BOOL) * BoolCount, 
BoolCount);
  
  return D3D_OK;

  }
@@ -3644,7 +3648,9 @@ NineDevice9_SetPixelShaderConstantF( struct NineDevice9 
*This,
 pConstantData,
 Vector4fCount * 4 * sizeof(state->ps_const_f[0]));
  
-nine_context_set_pixel_shader_constant_f(This, StartRegister, pConstantData, Vector4fCount);

+nine_context_set_pixel_shader_constant_f(This, StartRegister, 
pConstantData,
+ Vector4fCount * 4 * 
sizeof(state->ps_const_f[0]),
+ Vector4fCount);
  
  return D3D_OK;

  }
@@ -3706,7 +3712,8 @@ NineDevice9_SetPixelShaderConstantI( struct NineDevice9 
*This,
  state->changed.ps_const_i |= ((1 << Vector4iCount) - 1) << 
StartRegister;
  state->changed.group |= NINE_STATE_PS_CONST;
  } else
-nine_context_set_pixel_shader_constant_i(This, StartRegister, 
pConstantData, Vector4iCount);
+nine_context_set_pixel_shader_constant_i(This, StartRegister, 
pConstantData,
+ sizeof(state->ps_const_i[0]) 
* Vector4iCount, Vector4iCount);
  
  return D3D_OK;

  }
@@ -3774,7 +3781,8 @@ NineDevice9_SetPixelShaderConstantB( struct NineDevice9 
*This,
  state->changed.ps_const_b |= ((1 << BoolCount) - 1) << StartRegister;
  state->changed.group |= NINE_STATE_PS_CONST;
  } else
-nine_context_set_pixel_shader_constant_b(This, StartRegister, 
pConstantData, BoolCount);
+nine_context_set_pixel_shader_constant_b(This, StartRegister, 
pConstantData,
+ sizeof(BOOL) * BoolCount, 
BoolCount);
  
  return D3D_OK;

  }
diff --git a/src/gallium/state_trackers/nine/nine_state.c 
b/src/gallium/state_trackers/nine/nine_state.c
index 9bc6f81..076a959 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -1342,6 +1342,7 @@ void
  nine_context_set_vertex_shader_constant_f(struct NineDevice9 *device,
UINT StartRegister,
const float *pConstantData,
+  const unsigned pConstantData_size,
UINT Vector4fCount)
  {
  struct nine_context *context = >context;
@@ -1349,7 +1350,7 @@ nine_context_set_vertex_shader_constant_f(struct 
NineDevice9 *device,
  
  memcpy(_const_f[StartRegister * 4],

 pConstantData,
-   Vector4fCount * 4 * sizeof(context->vs_const_f[0]));
+   

[Mesa-dev] [PATCH 39/84 v2] st/nine: Reimplement nine_context_apply_stateblock

2016-12-15 Thread Axel Davy
The new version uses nine_context functions instead of
applying the changes directly to nine_context.
This will enable it to work with CSMT.

v2: Fix nine_context_light_enable_stateblock.
The memcpy arguments were wrong, and the state
wasn't set dirty.

Signed-off-by: Axel Davy 
---
 src/gallium/state_trackers/nine/nine_state.c | 206 +++
 1 file changed, 206 insertions(+)

diff --git a/src/gallium/state_trackers/nine/nine_state.c 
b/src/gallium/state_trackers/nine/nine_state.c
index 97b2c12..352843e 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -1446,6 +1446,23 @@ nine_context_set_pixel_shader_constant_f(struct 
NineDevice9 *device,
 context->changed.group |= NINE_STATE_PS_CONST;
 }
 
+/* For stateblocks */
+static void
+nine_context_set_pixel_shader_constant_i_transformed(struct NineDevice9 
*device,
+ UINT StartRegister,
+ const int *pConstantData,
+ UINT Vector4iCount)
+{
+struct nine_context *context = >context;
+
+memcpy(>ps_const_i[StartRegister][0],
+   pConstantData,
+   Vector4iCount * sizeof(context->ps_const_i[0]));
+
+context->changed.ps_const_i = TRUE;
+context->changed.group |= NINE_STATE_PS_CONST;
+}
+
 void
 nine_context_set_pixel_shader_constant_i(struct NineDevice9 *device,
  UINT StartRegister,
@@ -1587,6 +1604,20 @@ nine_context_set_light(struct NineDevice9 *device,
 context->changed.group |= NINE_STATE_FF_LIGHTING;
 }
 
+
+/* For stateblocks */
+static void
+nine_context_light_enable_stateblock(struct NineDevice9 *device,
+ const uint16_t 
active_light[NINE_MAX_LIGHTS_ACTIVE], /* TODO: use pointer that convey size for 
csmt */
+ unsigned int num_lights_active)
+{
+struct nine_context *context = >context;
+
+memcpy(context->ff.active_light, active_light, NINE_MAX_LIGHTS_ACTIVE * 
sizeof(context->ff.active_light[0]));
+context->ff.num_lights_active = num_lights_active;
+context->changed.group |= NINE_STATE_FF_LIGHTING;
+}
+
 void
 nine_context_light_enable(struct NineDevice9 *device,
   DWORD Index,
@@ -1653,6 +1684,8 @@ nine_context_set_clip_plane(struct NineDevice9 *device,
 context->changed.ucp = TRUE;
 }
 
+#if 0
+
 void
 nine_context_apply_stateblock(struct NineDevice9 *device,
   const struct nine_state *src)
@@ -1878,6 +1911,179 @@ nine_context_apply_stateblock(struct NineDevice9 
*device,
 }
 }
 
+#endif
+
+/* Do not write to nine_context directly. Slower,
+ * but works with csmt. TODO: write a special csmt version that
+ * would record the list of commands as much as possible,
+ * and use the version above else.
+ */
+void
+nine_context_apply_stateblock(struct NineDevice9 *device,
+  const struct nine_state *src)
+{
+int i;
+
+/* No need to apply src->changed.group, since all calls do
+* set context->changed.group */
+
+for (i = 0; i < ARRAY_SIZE(src->changed.rs); ++i) {
+uint32_t m = src->changed.rs[i];
+while (m) {
+const int r = ffs(m) - 1;
+m &= ~(1 << r);
+nine_context_set_render_state(device, i * 32 + r, 
src->rs_advertised[i * 32 + r]);
+}
+}
+
+/* Textures */
+if (src->changed.texture) {
+uint32_t m = src->changed.texture;
+unsigned s;
+
+for (s = 0; m; ++s, m >>= 1) {
+struct NineBaseTexture9 *tex = src->texture[s];
+if (!(m & 1))
+continue;
+nine_context_set_texture(device, s, tex);
+}
+}
+
+/* Sampler state */
+if (src->changed.group & NINE_STATE_SAMPLER) {
+unsigned s;
+
+for (s = 0; s < NINE_MAX_SAMPLERS; ++s) {
+uint32_t m = src->changed.sampler[s];
+while (m) {
+const int i = ffs(m) - 1;
+m &= ~(1 << i);
+nine_context_set_sampler_state(device, s, i, 
src->samp_advertised[s][i]);
+}
+}
+}
+
+/* Vertex buffers */
+if (src->changed.vtxbuf | src->changed.stream_freq) {
+uint32_t m = src->changed.vtxbuf | src->changed.stream_freq;
+for (i = 0; m; ++i, m >>= 1) {
+if (src->changed.vtxbuf & (1 << i))
+nine_context_set_stream_source(device, i, src->stream[i], 
src->vtxbuf[i].buffer_offset, src->vtxbuf[i].stride);
+if (src->changed.stream_freq & (1 << i))
+nine_context_set_stream_source_freq(device, i, 
src->stream_freq[i]);
+}
+}
+
+/* Index buffer */
+if (src->changed.group & NINE_STATE_IDXBUF)
+nine_context_set_indices(device, src->idxbuf);
+
+/* Vertex 

Re: [Mesa-dev] [PATCH] nir: Remove nir_array from lower_locals_to_regs

2016-12-15 Thread Eric Anholt
Thomas Helland  writes:

> We do nothing but initialize it, add to it, and delete it.
> This is a fallout from removing constant initializer support.

Maybe in the summary do s/nir_array/derefs_array/, but either way:

Reviewed-by: Eric Anholt 


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


[Mesa-dev] [PATCH] anv: Fix uniform and storage buffer offset alignment limits.

2016-12-15 Thread Francisco Jerez
This fixes an apparent regression in a bunch of image store vulkan CTS
tests from commit ad38ba113491869ab0dffed937f7b3dd50e8a735, which
started using OWORD block read messages to implement UBO loads.  The
reason for the failure is that we were giving bogus buffer alignment
limits to the application (1B), so the CTS would happily come back
with descriptor sets pointing at not even word-aligned uniform buffer
addresses.  No idea how these tests could possibly work before while
we were using the sampler to fetch pull constants.

Cc: 
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99097
Reported-by: Mark Janes 
---
 src/intel/vulkan/anv_device.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index e3d278d..9245e5c 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -582,8 +582,8 @@ void anv_GetPhysicalDeviceProperties(
   .viewportSubPixelBits = 13, /* We take a float? */
   .minMemoryMapAlignment= 4096, /* A page */
   .minTexelBufferOffsetAlignment= 1,
-  .minUniformBufferOffsetAlignment  = 1,
-  .minStorageBufferOffsetAlignment  = 1,
+  .minUniformBufferOffsetAlignment  = 16,
+  .minStorageBufferOffsetAlignment  = 4,
   .minTexelOffset   = -8,
   .maxTexelOffset   = 7,
   .minTexelGatherOffset = -32,
-- 
2.10.2

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


[Mesa-dev] [PATCH] nir: Turn imov/fmov of undef into undef

2016-12-15 Thread Timothy Arceri
Reverting the previous attempt at this a5502a721fd30fd resulted in
the following Vulkan test failing.

dEQP-VK.glsl.return.return_in_dynamic_loop_dynamic_vertex

This time we use the num_components from the alu dest rather than
num_inputs to the op to determine the size of the undef.

Cc: "13.0" 
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99100
---
 src/compiler/nir/nir_opt_undef.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/compiler/nir/nir_opt_undef.c b/src/compiler/nir/nir_opt_undef.c
index c4777a8..8d3210c 100644
--- a/src/compiler/nir/nir_opt_undef.c
+++ b/src/compiler/nir/nir_opt_undef.c
@@ -79,22 +79,22 @@ opt_undef_vecN(nir_builder *b, nir_alu_instr *alu)
 {
if (alu->op != nir_op_vec2 &&
alu->op != nir_op_vec3 &&
-   alu->op != nir_op_vec4)
+   alu->op != nir_op_vec4 &&
+   alu->op != nir_op_fmov &&
+   alu->op != nir_op_imov)
   return false;
 
assert(alu->dest.dest.is_ssa);
 
-   unsigned num_components = nir_op_infos[alu->op].num_inputs;
-
-   for (unsigned i = 0; i < num_components; i++) {
+   for (unsigned 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)
  return false;
}
 
b->cursor = nir_before_instr(>instr);
-   nir_ssa_def *undef =
-  nir_ssa_undef(b, num_components, nir_dest_bit_size(alu->dest.dest));
+   nir_ssa_def *undef = nir_ssa_undef(b, alu->dest.dest.ssa.num_components,
+  nir_dest_bit_size(alu->dest.dest));
nir_ssa_def_rewrite_uses(>dest.dest.ssa, nir_src_for_ssa(undef));
 
return true;
-- 
2.7.4

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


Re: [Mesa-dev] [PATCH 3/3] nir: Rewrite lower_regs_to_ssa to use the phi builder

2016-12-15 Thread Eric Anholt
Jason Ekstrand  writes:

> This keeps some of Connor's original code.  However, while I was at it,
> I updated this very old pass to a bit more modern NIR.

I love how much smaller this code is.  Assuming that the phi builder
does that job correctly, this is pretty trivial to read and understand.

The only things I saw were:

- It doesn't call nir_metadata_preserve() like the old pass did, while
  it adds new SSA values.  Seems like it should.

- It asserts that reg->num_array_elems == 0, while the old pass would
  just skip those.  It looks like the only source of arrays would be
  nir_lower_locals_to_regs(), which only i965 is calling.  Is that
  something we should be using?  Should we be handling the array reg
  case in this pass and in our drivers?


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


[Mesa-dev] [PATCH] nir: Remove nir_array from lower_locals_to_regs

2016-12-15 Thread Thomas Helland
We do nothing but initialize it, add to it, and delete it.
This is a fallout from removing constant initializer support.

CC: Jason Ekstrand 
---
 src/compiler/nir/nir_lower_locals_to_regs.c | 9 -
 1 file changed, 9 deletions(-)

diff --git a/src/compiler/nir/nir_lower_locals_to_regs.c 
b/src/compiler/nir/nir_lower_locals_to_regs.c
index 25a62b3..f1af237 100644
--- a/src/compiler/nir/nir_lower_locals_to_regs.c
+++ b/src/compiler/nir/nir_lower_locals_to_regs.c
@@ -35,12 +35,6 @@ struct locals_to_regs_state {
/* A hash table mapping derefs to registers */
struct hash_table *regs_table;
 
-   /* A growing array of derefs that we have encountered.  There is exactly
-* one element of this array per element in the hash table.  This is
-* used to make adding register initialization code deterministic.
-*/
-   nir_array derefs_array;
-
bool progress;
 };
 
@@ -124,7 +118,6 @@ get_reg_for_deref(nir_deref_var *deref, struct 
locals_to_regs_state *state)
reg->bit_size = glsl_get_bit_size(tail->type);
 
_mesa_hash_table_insert_pre_hashed(state->regs_table, hash, deref, reg);
-   nir_array_add(>derefs_array, nir_deref_var *, deref);
 
return reg;
 }
@@ -280,7 +273,6 @@ nir_lower_locals_to_regs_impl(nir_function_impl *impl)
state.impl = impl;
state.progress = false;
state.regs_table = _mesa_hash_table_create(NULL, hash_deref, derefs_equal);
-   nir_array_init(_array, NULL);
 
nir_metadata_require(impl, nir_metadata_dominance);
 
@@ -291,7 +283,6 @@ nir_lower_locals_to_regs_impl(nir_function_impl *impl)
nir_metadata_preserve(impl, nir_metadata_block_index |
nir_metadata_dominance);
 
-   nir_array_fini(_array);
_mesa_hash_table_destroy(state.regs_table, NULL);
 
return state.progress;
-- 
2.9.3

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


Re: [Mesa-dev] [PATCH 0/3] nir: Rewrite the register-based into-SSA pass to use

2016-12-15 Thread Eric Anholt
Jason Ekstrand  writes:

> Ever since I wrote the phi builder and converted vars_to_ssa to use it,
> I've been meaning to convert the other into-SSA pass to use it as well.
> This little series does just that.  While I was at it, I also renamed it to
> nir_lower_regs_to_ssa to match nir_lower_vars_to_ssa.
>
> Since the third commit is basically a full rewrite (I kept a few bits but
> not many), it's probably easiest to just pull my branch and review it as if
> it's a new pass.  Fortunately, this one is way easier to read/review than
> the old one thanks to using the phi builder.
>
> https://cgit.freedesktop.org/~jekstrand/mesa/log/?h=review/regs-to-ssa
>
> Rob & Eric, I would like you to at least test this as I can only test it
> with ARB programs which don't have control-flow.

I haven't run a full piglit, but no changes on shader-db.


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


[Mesa-dev] [PATCH] radeonsi: Use build_buffer_load helper function for geometry shaders

2016-12-15 Thread Tom Stellard
Also add a need_range_checks parameter to this function, which can be
set to false to enable some additional optimizations.  Currently, this
will cause the compiler to emit the llvm.SI.buffer.load.dword intrinsic
instead of llvm.amdgcn.buffer.load.  Eventually, this information
will be passed to LLVM to enable more agressive addressing mode optimizations.
---
 src/gallium/drivers/radeonsi/si_shader.c | 79 
 1 file changed, 29 insertions(+), 50 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index 72cf827..5b15ad4 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -825,12 +825,13 @@ static LLVMValueRef build_buffer_load(struct 
si_shader_context *ctx,
   LLVMValueRef soffset,
   unsigned inst_offset,
   unsigned glc,
-  unsigned slc)
+  unsigned slc,
+  bool need_range_checks)
 {
struct gallivm_state *gallivm = >gallivm;
unsigned func = CLAMP(num_channels, 1, 3) - 1;
 
-   if (HAVE_LLVM >= 0x309) {
+   if (need_range_checks && HAVE_LLVM >= 0x309) {
LLVMValueRef args[] = {
LLVMBuildBitCast(gallivm->builder, rsrc, ctx->v4i32, 
""),
vindex ? vindex : LLVMConstInt(ctx->i32, 0, 0),
@@ -896,7 +897,7 @@ static LLVMValueRef build_buffer_load(struct 
si_shader_context *ctx,
 static LLVMValueRef buffer_load(struct lp_build_tgsi_context *bld_base,
 enum tgsi_opcode_type type, unsigned swizzle,
 LLVMValueRef buffer, LLVMValueRef offset,
-LLVMValueRef base)
+LLVMValueRef base, bool need_range_checks)
 {
struct si_shader_context *ctx = si_shader_context(bld_base);
struct gallivm_state *gallivm = bld_base->base.gallivm;
@@ -906,14 +907,14 @@ static LLVMValueRef buffer_load(struct 
lp_build_tgsi_context *bld_base,
 
if (swizzle == ~0) {
value = build_buffer_load(ctx, buffer, 4, NULL, base, offset,
- 0, 1, 0);
+ 0, 1, 0, need_range_checks);
 
return LLVMBuildBitCast(gallivm->builder, value, vec_type, "");
}
 
if (!tgsi_type_is_64bit(type)) {
value = build_buffer_load(ctx, buffer, 4, NULL, base, offset,
- 0, 1, 0);
+ 0, 1, 0, need_range_checks);
 
value = LLVMBuildBitCast(gallivm->builder, value, vec_type, "");
return LLVMBuildExtractElement(gallivm->builder, value,
@@ -921,10 +922,10 @@ static LLVMValueRef buffer_load(struct 
lp_build_tgsi_context *bld_base,
}
 
value = build_buffer_load(ctx, buffer, 1, NULL, base, offset,
- swizzle * 4, 1, 0);
+ swizzle * 4, 1, 0, need_range_checks);
 
value2 = build_buffer_load(ctx, buffer, 1, NULL, base, offset,
-  swizzle * 4 + 4, 1, 0);
+  swizzle * 4 + 4, 1, 0, need_range_checks);
 
return si_llvm_emit_fetch_64bit(bld_base, type, value, value2);
 }
@@ -1044,7 +1045,7 @@ static LLVMValueRef fetch_input_tes(
base = LLVMGetParam(ctx->main_fn, ctx->param_oc_lds);
addr = get_tcs_tes_buffer_address_from_reg(ctx, NULL, reg);
 
-   return buffer_load(bld_base, type, swizzle, buffer, base, addr);
+   return buffer_load(bld_base, type, swizzle, buffer, base, addr, true);
 }
 
 static void store_output_tcs(struct lp_build_tgsi_context *bld_base,
@@ -1125,13 +1126,12 @@ static LLVMValueRef fetch_input_gs(
struct lp_build_context *uint = >soa.bld_base.uint_bld;
struct gallivm_state *gallivm = base->gallivm;
LLVMValueRef vtx_offset;
-   LLVMValueRef args[9];
unsigned vtx_offset_param;
struct tgsi_shader_info *info = >selector->info;
unsigned semantic_name = info->input_semantic_name[reg->Register.Index];
unsigned semantic_index = 
info->input_semantic_index[reg->Register.Index];
unsigned param;
-   LLVMValueRef value;
+   LLVMValueRef soffset, value;
 
if (swizzle != ~0 && semantic_name == TGSI_SEMANTIC_PRIMID)
return get_primitive_id(bld_base, swizzle);
@@ -1163,27 +1163,15 @@ static LLVMValueRef fetch_input_gs(
  4);
 
param = si_shader_io_get_unique_index(semantic_name, semantic_index);
-   args[0] = ctx->esgs_ring;
-   args[1] = vtx_offset;
-   args[2] = lp_build_const_int32(gallivm, (param * 4 + swizzle) * 256);
-  

Re: [Mesa-dev] [PATCH v2 2/4] nir: Add foreach_register helper macros

2016-12-15 Thread Jason Ekstrand
On Dec 15, 2016 9:45 AM, "Gustaw Smolarczyk"  wrote:

15 gru 2016 18:19 "Jason Ekstrand" napisał(a):

---
 src/compiler/nir/nir.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index f1c99ce..4a9fe65 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -373,6 +373,11 @@ typedef struct nir_register {
struct list_head if_uses;
 } nir_register;

+#define nir_foreach_register(var, reg_list) \
+   foreach_list_typed(nir_register, reg, node, reg_list)

Shouldn't the macro definition use the var parameter? Below too.


Yes... The only reason it worked was that I always called the iteration
parameter "reg".  Good catch!  I'll Gary that fixed.

Regards,
Gustaw

+#define nir_foreach_register_safe(var, reg_list) \
+   foreach_list_typed_safe(nir_register, reg, node, reg_list)
+
 typedef enum {
nir_instr_type_alu,
nir_instr_type_call,
--
2.5.0.400.gff86faf

___
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


[Mesa-dev] [PATCH] radeonsi: Set datalayout on the llvm module

2016-12-15 Thread Tom Stellard
This prevents LLVM from using sext instructions for local memory offsets
and allows the backend to fold immediate offsets into the instruction.

This also prevents some incorrect code generation for ptrtoint and
inttoptr instructions.
---
 src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c 
b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
index 2f38949..b6cb00f 100644
--- a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
+++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c
@@ -1231,6 +1231,8 @@ void si_llvm_context_init(struct si_shader_context *ctx,
  const struct tgsi_token *tokens)
 {
struct lp_type type;
+   LLVMTargetDataRef data_layout = LLVMCreateTargetDataLayout(tm);
+   char *data_layout_str = LLVMCopyStringRepOfTargetData(data_layout);
 
/* Initialize the gallivm object:
 * We are only using the module, context, and builder fields of this 
struct.
@@ -1248,6 +1250,10 @@ void si_llvm_context_init(struct si_shader_context *ctx,
ctx->gallivm.context);
LLVMSetTarget(ctx->gallivm.module, "amdgcn--");
 
+   LLVMSetDataLayout(ctx->gallivm.module, data_layout_str);
+   LLVMDisposeTargetData(data_layout);
+   LLVMDisposeMessage(data_layout_str);
+
bool unsafe_fpmath = (sscreen->b.debug_flags & DBG_UNSAFE_MATH) != 0;
ctx->gallivm.builder = lp_create_builder(ctx->gallivm.context,
 unsafe_fpmath);
-- 
2.7.4

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


Re: [Mesa-dev] [PATCH v2 4/4] nir: Rewrite lower_regs_to_ssa to use the phi builder

2016-12-15 Thread Gustaw Smolarczyk
15 gru 2016 18:19 "Jason Ekstrand"  napisał(a):

This keeps some of Connor's original code.  However, while I was at it,
I updated this very old pass to a bit more modern NIR.
---
 src/compiler/nir/nir_lower_regs_to_ssa.c | 582
---
 1 file changed, 155 insertions(+), 427 deletions(-)

diff --git a/src/compiler/nir/nir_lower_regs_to_ssa.c
b/src/compiler/nir/nir_lower_regs_to_ssa.c
index 74c1961..3c8fd876 100644
--- a/src/compiler/nir/nir_lower_regs_to_ssa.c
+++ b/src/compiler/nir/nir_lower_regs_to_ssa.c
@@ -26,513 +26,241 @@
  */

 #include "nir.h"
-#include 
+#include "nir_builder.h"
+#include "nir_phi_builder.h"
+#include "nir_vla.h"

-/*
- * Implements the classic to-SSA algorithm described by Cytron et. al. in
- * "Efficiently Computing Static Single Assignment Form and the Control
- * Dependence Graph."
- */
+struct regs_to_ssa_state {
+   nir_shader *shader;

-/* inserts a phi node of the form reg = phi(reg, reg, reg, ...) */
+   struct nir_phi_builder_value **values;
+};

-static void
-insert_trivial_phi(nir_register *reg, nir_block *block, void *mem_ctx)
-{
-   nir_phi_instr *instr = nir_phi_instr_create(mem_ctx);
-
-   instr->dest.reg.reg = reg;
-   struct set_entry *entry;
-   set_foreach(block->predecessors, entry) {
-  nir_block *pred = (nir_block *) entry->key;
-
-  nir_phi_src *src = ralloc(instr, nir_phi_src);
-  src->pred = pred;
-  src->src.is_ssa = false;
-  src->src.reg.base_offset = 0;
-  src->src.reg.indirect = NULL;
-  src->src.reg.reg = reg;
-  exec_list_push_tail(>srcs, >node);
-   }
-
-   nir_instr_insert_before_block(block, >instr);
-}
-
-static void
-insert_phi_nodes(nir_function_impl *impl)
+static bool
+rewrite_src(nir_src *src, void *_state)
 {
-   void *mem_ctx = ralloc_parent(impl);
-
-   unsigned *work = calloc(impl->num_blocks, sizeof(unsigned));
-   unsigned *has_already = calloc(impl->num_blocks, sizeof(unsigned));
-
-   /*
-* Since the work flags already prevent us from inserting a node that
has
-* ever been inserted into W, we don't need to use a set to represent W.
-* Also, since no block can ever be inserted into W more than once, we
know
-* that the maximum size of W is the number of basic blocks in the
-* function. So all we need to handle W is an array and a pointer to the
-* next element to be inserted and the next element to be removed.
-*/
-   nir_block **W = malloc(impl->num_blocks * sizeof(nir_block *));
-   unsigned w_start, w_end;
-
-   unsigned iter_count = 0;
-
-   nir_index_blocks(impl);
-
-   foreach_list_typed(nir_register, reg, node, >registers) {
-  if (reg->num_array_elems != 0)
- continue;
-
-  w_start = w_end = 0;
-  iter_count++;
-
-  nir_foreach_def(dest, reg) {
- nir_instr *def = dest->reg.parent_instr;
- if (work[def->block->index] < iter_count)
-W[w_end++] = def->block;
- work[def->block->index] = iter_count;
-  }
+   struct regs_to_ssa_state *state = _state;

-  while (w_start != w_end) {
- nir_block *cur = W[w_start++];
- struct set_entry *entry;
- set_foreach(cur->dom_frontier, entry) {
-nir_block *next = (nir_block *) entry->key;
-
-/*
- * If there's more than one return statement, then the end
block
- * can be a join point for some definitions. However, there are
- * no instructions in the end block, so nothing would use those
- * phi nodes. Of course, we couldn't place those phi nodes
- * anyways due to the restriction of having no instructions in
the
- * end block...
- */
-if (next == impl->end_block)
-   continue;
-
-if (has_already[next->index] < iter_count) {
-   insert_trivial_phi(reg, next, mem_ctx);
-   has_already[next->index] = iter_count;
-   if (work[next->index] < iter_count) {
-  work[next->index] = iter_count;
-  W[w_end++] = next;
-   }
-}
- }
-  }
-   }
+   if (src->is_ssa)
+  return true;

-   free(work);
-   free(has_already);
-   free(W);
-}
+   nir_instr *instr = src->parent_instr;
+   nir_register *reg = src->reg.reg;
+   struct nir_phi_builder_value *value = state->values[reg->index];

-typedef struct {
-   nir_ssa_def **stack;
-   int index;
-   unsigned num_defs; /** < used to add indices to debug names */
-#ifndef NDEBUG
-   unsigned stack_size;
-#endif
-} reg_state;
-
-typedef struct {
-   reg_state *states;
-   void *mem_ctx;
-   nir_instr *parent_instr;
-   nir_if *parent_if;
-   nir_function_impl *impl;
-
-   /* map from SSA value -> original register */
-   struct hash_table *ssa_map;
-} rewrite_state;
-
-static nir_ssa_def *get_ssa_src(nir_register *reg, rewrite_state *state)
-{
-   unsigned index = reg->index;
+   nir_ssa_def *def = 

Re: [Mesa-dev] [PATCH v2 2/4] nir: Add foreach_register helper macros

2016-12-15 Thread Gustaw Smolarczyk
15 gru 2016 18:19 "Jason Ekstrand" napisał(a):

---
 src/compiler/nir/nir.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index f1c99ce..4a9fe65 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -373,6 +373,11 @@ typedef struct nir_register {
struct list_head if_uses;
 } nir_register;

+#define nir_foreach_register(var, reg_list) \
+   foreach_list_typed(nir_register, reg, node, reg_list)

Shouldn't the macro definition use the var parameter? Below too.

Regards,
Gustaw

+#define nir_foreach_register_safe(var, reg_list) \
+   foreach_list_typed_safe(nir_register, reg, node, reg_list)
+
 typedef enum {
nir_instr_type_alu,
nir_instr_type_call,
--
2.5.0.400.gff86faf

___
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


[Mesa-dev] [PATCH v2 4/4] nir: Rewrite lower_regs_to_ssa to use the phi builder

2016-12-15 Thread Jason Ekstrand
This keeps some of Connor's original code.  However, while I was at it,
I updated this very old pass to a bit more modern NIR.
---
 src/compiler/nir/nir_lower_regs_to_ssa.c | 582 ---
 1 file changed, 155 insertions(+), 427 deletions(-)

diff --git a/src/compiler/nir/nir_lower_regs_to_ssa.c 
b/src/compiler/nir/nir_lower_regs_to_ssa.c
index 74c1961..3c8fd876 100644
--- a/src/compiler/nir/nir_lower_regs_to_ssa.c
+++ b/src/compiler/nir/nir_lower_regs_to_ssa.c
@@ -26,513 +26,241 @@
  */
 
 #include "nir.h"
-#include 
+#include "nir_builder.h"
+#include "nir_phi_builder.h"
+#include "nir_vla.h"
 
-/*
- * Implements the classic to-SSA algorithm described by Cytron et. al. in
- * "Efficiently Computing Static Single Assignment Form and the Control
- * Dependence Graph."
- */
+struct regs_to_ssa_state {
+   nir_shader *shader;
 
-/* inserts a phi node of the form reg = phi(reg, reg, reg, ...) */
+   struct nir_phi_builder_value **values;
+};
 
-static void
-insert_trivial_phi(nir_register *reg, nir_block *block, void *mem_ctx)
-{
-   nir_phi_instr *instr = nir_phi_instr_create(mem_ctx);
-
-   instr->dest.reg.reg = reg;
-   struct set_entry *entry;
-   set_foreach(block->predecessors, entry) {
-  nir_block *pred = (nir_block *) entry->key;
-
-  nir_phi_src *src = ralloc(instr, nir_phi_src);
-  src->pred = pred;
-  src->src.is_ssa = false;
-  src->src.reg.base_offset = 0;
-  src->src.reg.indirect = NULL;
-  src->src.reg.reg = reg;
-  exec_list_push_tail(>srcs, >node);
-   }
-
-   nir_instr_insert_before_block(block, >instr);
-}
-
-static void
-insert_phi_nodes(nir_function_impl *impl)
+static bool
+rewrite_src(nir_src *src, void *_state)
 {
-   void *mem_ctx = ralloc_parent(impl);
-
-   unsigned *work = calloc(impl->num_blocks, sizeof(unsigned));
-   unsigned *has_already = calloc(impl->num_blocks, sizeof(unsigned));
-
-   /*
-* Since the work flags already prevent us from inserting a node that has
-* ever been inserted into W, we don't need to use a set to represent W.
-* Also, since no block can ever be inserted into W more than once, we know
-* that the maximum size of W is the number of basic blocks in the
-* function. So all we need to handle W is an array and a pointer to the
-* next element to be inserted and the next element to be removed.
-*/
-   nir_block **W = malloc(impl->num_blocks * sizeof(nir_block *));
-   unsigned w_start, w_end;
-
-   unsigned iter_count = 0;
-
-   nir_index_blocks(impl);
-
-   foreach_list_typed(nir_register, reg, node, >registers) {
-  if (reg->num_array_elems != 0)
- continue;
-
-  w_start = w_end = 0;
-  iter_count++;
-
-  nir_foreach_def(dest, reg) {
- nir_instr *def = dest->reg.parent_instr;
- if (work[def->block->index] < iter_count)
-W[w_end++] = def->block;
- work[def->block->index] = iter_count;
-  }
+   struct regs_to_ssa_state *state = _state;
 
-  while (w_start != w_end) {
- nir_block *cur = W[w_start++];
- struct set_entry *entry;
- set_foreach(cur->dom_frontier, entry) {
-nir_block *next = (nir_block *) entry->key;
-
-/*
- * If there's more than one return statement, then the end block
- * can be a join point for some definitions. However, there are
- * no instructions in the end block, so nothing would use those
- * phi nodes. Of course, we couldn't place those phi nodes
- * anyways due to the restriction of having no instructions in the
- * end block...
- */
-if (next == impl->end_block)
-   continue;
-
-if (has_already[next->index] < iter_count) {
-   insert_trivial_phi(reg, next, mem_ctx);
-   has_already[next->index] = iter_count;
-   if (work[next->index] < iter_count) {
-  work[next->index] = iter_count;
-  W[w_end++] = next;
-   }
-}
- }
-  }
-   }
+   if (src->is_ssa)
+  return true;
 
-   free(work);
-   free(has_already);
-   free(W);
-}
+   nir_instr *instr = src->parent_instr;
+   nir_register *reg = src->reg.reg;
+   struct nir_phi_builder_value *value = state->values[reg->index];
 
-typedef struct {
-   nir_ssa_def **stack;
-   int index;
-   unsigned num_defs; /** < used to add indices to debug names */
-#ifndef NDEBUG
-   unsigned stack_size;
-#endif
-} reg_state;
-
-typedef struct {
-   reg_state *states;
-   void *mem_ctx;
-   nir_instr *parent_instr;
-   nir_if *parent_if;
-   nir_function_impl *impl;
-
-   /* map from SSA value -> original register */
-   struct hash_table *ssa_map;
-} rewrite_state;
-
-static nir_ssa_def *get_ssa_src(nir_register *reg, rewrite_state *state)
-{
-   unsigned index = reg->index;
+   nir_ssa_def *def = nir_phi_builder_value_get_block_def(value, instr->block);
+   nir_instr_rewrite_src(instr, 

[Mesa-dev] [PATCH v2 2/4] nir: Add foreach_register helper macros

2016-12-15 Thread Jason Ekstrand
---
 src/compiler/nir/nir.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index f1c99ce..4a9fe65 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -373,6 +373,11 @@ typedef struct nir_register {
struct list_head if_uses;
 } nir_register;
 
+#define nir_foreach_register(var, reg_list) \
+   foreach_list_typed(nir_register, reg, node, reg_list)
+#define nir_foreach_register_safe(var, reg_list) \
+   foreach_list_typed_safe(nir_register, reg, node, reg_list)
+
 typedef enum {
nir_instr_type_alu,
nir_instr_type_call,
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH v2 3/4] nir/phi-builder: Set the value in the block when creating a phi

2016-12-15 Thread Jason Ekstrand
After we figure out the value that we are going to return, we have a
loop that walks up the dominance tree and sets the value in each of the
blocks that doesn't have one yet.  In the case of the phi, the def is
set to NEEDS_PHI not NULL, so the last one where the phi node actually
goes never gets filled out.  This can lead to duplicating the phi node
unnecessarily.
---
 src/compiler/nir/nir_phi_builder.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_phi_builder.c 
b/src/compiler/nir/nir_phi_builder.c
index 6b4b693..acfc771 100644
--- a/src/compiler/nir/nir_phi_builder.c
+++ b/src/compiler/nir/nir_phi_builder.c
@@ -216,7 +216,7 @@ nir_phi_builder_value_get_block_def(struct 
nir_phi_builder_value *val,
 val->bit_size, NULL);
   phi->instr.block = dom;
   exec_list_push_tail(>phis, >instr.node);
-  def = >dest.ssa;
+  def = val->defs[dom->index] = >dest.ssa;
} else {
   /* In this case, we have an actual SSA def.  It's either the result of a
* phi node created by the case above or one passed to us through
-- 
2.5.0.400.gff86faf

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


[Mesa-dev] [PATCH v2 1/4] nir: Rename convert_to_ssa lower_regs_to_ssa

2016-12-15 Thread Jason Ekstrand
This matches the naming of nir_lower_vars_to_ssa, the other to-SSA pass.
---
 src/compiler/Makefile.sources  | 2 +-
 src/compiler/nir/nir.h | 4 +---
 src/compiler/nir/{nir_to_ssa.c => nir_lower_regs_to_ssa.c} | 8 
 src/gallium/drivers/freedreno/ir3/ir3_nir.c| 2 +-
 src/gallium/drivers/vc4/vc4_program.c  | 2 +-
 src/mesa/drivers/dri/i965/brw_program.c| 2 +-
 6 files changed, 9 insertions(+), 11 deletions(-)
 rename src/compiler/nir/{nir_to_ssa.c => nir_lower_regs_to_ssa.c} (99%)

diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources
index 17b15de..33d6b2d 100644
--- a/src/compiler/Makefile.sources
+++ b/src/compiler/Makefile.sources
@@ -215,6 +215,7 @@ NIR_FILES = \
nir/nir_lower_io_types.c \
nir/nir_lower_passthrough_edgeflags.c \
nir/nir_lower_phis_to_scalar.c \
+   nir/nir_lower_regs_to_ssa.c \
nir/nir_lower_returns.c \
nir/nir_lower_samplers.c \
nir/nir_lower_system_values.c \
@@ -251,7 +252,6 @@ NIR_FILES = \
nir/nir_search_helpers.h \
nir/nir_split_var_copies.c \
nir/nir_sweep.c \
-   nir/nir_to_ssa.c \
nir/nir_validate.c \
nir/nir_vla.h \
nir/nir_worklist.c \
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index ba88a24..f1c99ce 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2307,6 +2307,7 @@ nir_src *nir_get_io_vertex_index_src(nir_intrinsic_instr 
*instr);
 bool nir_is_per_vertex_io(nir_variable *var, gl_shader_stage stage);
 
 void nir_lower_io_types(nir_shader *shader);
+void nir_lower_regs_to_ssa(nir_shader *shader);
 void nir_lower_vars_to_ssa(nir_shader *shader);
 
 bool nir_remove_dead_variables(nir_shader *shader, nir_variable_mode modes);
@@ -2481,9 +2482,6 @@ bool nir_normalize_cubemap_coords(nir_shader *shader);
 void nir_live_ssa_defs_impl(nir_function_impl *impl);
 bool nir_ssa_defs_interfere(nir_ssa_def *a, nir_ssa_def *b);
 
-void nir_convert_to_ssa_impl(nir_function_impl *impl);
-void nir_convert_to_ssa(nir_shader *shader);
-
 bool nir_repair_ssa_impl(nir_function_impl *impl);
 bool nir_repair_ssa(nir_shader *shader);
 
diff --git a/src/compiler/nir/nir_to_ssa.c 
b/src/compiler/nir/nir_lower_regs_to_ssa.c
similarity index 99%
rename from src/compiler/nir/nir_to_ssa.c
rename to src/compiler/nir/nir_lower_regs_to_ssa.c
index e0998d4..74c1961 100644
--- a/src/compiler/nir/nir_to_ssa.c
+++ b/src/compiler/nir/nir_lower_regs_to_ssa.c
@@ -510,8 +510,8 @@ destroy_rewrite_state(rewrite_state *state)
ralloc_free(state->states);
 }
 
-void
-nir_convert_to_ssa_impl(nir_function_impl *impl)
+static void
+lower_regs_to_ssa_impl(nir_function_impl *impl)
 {
nir_metadata_require(impl, nir_metadata_dominance);
 
@@ -531,10 +531,10 @@ nir_convert_to_ssa_impl(nir_function_impl *impl)
 }
 
 void
-nir_convert_to_ssa(nir_shader *shader)
+nir_lower_regs_to_ssa(nir_shader *shader)
 {
nir_foreach_function(function, shader) {
   if (function->impl)
- nir_convert_to_ssa_impl(function->impl);
+ lower_regs_to_ssa_impl(function->impl);
}
 }
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_nir.c 
b/src/gallium/drivers/freedreno/ir3/ir3_nir.c
index 2d86a52..336fa95 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_nir.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_nir.c
@@ -142,7 +142,7 @@ ir3_optimize_nir(struct ir3_shader *shader, nir_shader *s,
}
 
OPT_V(s, nir_opt_global_to_local);
-   OPT_V(s, nir_convert_to_ssa);
+   OPT_V(s, nir_lower_regs_to_ssa);
 
if (key) {
if (s->stage == MESA_SHADER_VERTEX) {
diff --git a/src/gallium/drivers/vc4/vc4_program.c 
b/src/gallium/drivers/vc4/vc4_program.c
index 611c90d..ce2a962 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -2404,7 +2404,7 @@ vc4_shader_state_create(struct pipe_context *pctx,
 }
 
 NIR_PASS_V(s, nir_opt_global_to_local);
-NIR_PASS_V(s, nir_convert_to_ssa);
+NIR_PASS_V(s, nir_lower_regs_to_ssa);
 NIR_PASS_V(s, nir_normalize_cubemap_coords);
 
 NIR_PASS_V(s, nir_lower_load_const_to_scalar);
diff --git a/src/mesa/drivers/dri/i965/brw_program.c 
b/src/mesa/drivers/dri/i965/brw_program.c
index a502b8e..f4df6c0 100644
--- a/src/mesa/drivers/dri/i965/brw_program.c
+++ b/src/mesa/drivers/dri/i965/brw_program.c
@@ -82,7 +82,7 @@ brw_create_nir(struct brw_context *brw,
  nir_shader_get_entrypoint(nir), true, false);
} else {
   nir = prog_to_nir(prog, options);
-  NIR_PASS_V(nir, nir_convert_to_ssa); /* turn registers into SSA */
+  NIR_PASS_V(nir, nir_lower_regs_to_ssa); /* turn registers into SSA */
}
nir_validate_shader(nir);
 
-- 
2.5.0.400.gff86faf

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

[Mesa-dev] [PATCH v2 0/4] Rewrite the register-based into-SSA pass to use the phi builder API

2016-12-15 Thread Jason Ekstrand
This is a quick v2 of the regs_to_ssa rewrite.  Immediately after sending
it out and asking Rob and Eric to test it because we didn't use it for
anything with control-flow, I realized I could easily test it by hacking
our driver to call regs_to_ssa immediately after going out of SSA and then
go out of SSA again.  When I did, I found bugs.  This version has those
bugs fixed and passes Jenkins with that hack and another to silently ignore
indirects on registers.

Jason Ekstrand (4):
  nir: Rename convert_to_ssa lower_regs_to_ssa
  nir: Add foreach_register helper macros
  nir/phi-builder: Set the value in the block when creating a phi
  nir: Rewrite lower_regs_to_ssa to use the phi builder

 src/compiler/Makefile.sources   |   2 +-
 src/compiler/nir/nir.h  |   9 +-
 src/compiler/nir/nir_lower_regs_to_ssa.c| 268 ++
 src/compiler/nir/nir_phi_builder.c  |   2 +-
 src/compiler/nir/nir_to_ssa.c   | 540 
 src/gallium/drivers/freedreno/ir3/ir3_nir.c |   2 +-
 src/gallium/drivers/vc4/vc4_program.c   |   2 +-
 src/mesa/drivers/dri/i965/brw_program.c |   2 +-
 8 files changed, 279 insertions(+), 548 deletions(-)
 create mode 100644 src/compiler/nir/nir_lower_regs_to_ssa.c
 delete mode 100644 src/compiler/nir/nir_to_ssa.c

-- 
2.5.0.400.gff86faf

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


Re: [Mesa-dev] [PATCH 1/3] i965/blit: Break the guts of intel_miptree_blit into a helper

2016-12-15 Thread Jason Ekstrand
On Thu, Dec 15, 2016 at 8:42 AM, Emil Velikov 
wrote:

> Hi Jason,
>
> Double-checking things and I've noticed that this has gone under the
> radar since due to simple typo - mesa-dev vs mesa-stable.
> Regardless, the patch in question seems to depend on at least


Sorry about that


> 174f4900b294f939c85cfa94f5d8401ce73e5522
>

Yes, this one is required


> b7979a849bc185fbcab93a841eed692a10d61e25\
>

This one shouldn't be


> 80d3af812935978f01c9bb6d02102140383c4034
>

This one is


> 44760c100c3793718cc8d6cfb66852c4f72d7057
>

This one shouldn't be.


>
> Where all of the above are refactoring/feature/performance patches.
> The interest in perf. improvements is understandable, yet in those we
> had at least one bug/issue fixed with commit
> 157971e450c34ec430c295ff922c2e597294aba3.
>

Yes, there was.  Only a bug in release mode but still...


> So barring a very compelling reason these won't be in 13.0.
>

They do fix bugs... They're just not crushing "the universe is broken"
sorts of bugs.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/2] radeonsi: fix gl_ClipDistance and gl_ClipVertex for points

2016-12-15 Thread Ilia Mirkin
On Thu, Dec 15, 2016 at 11:45 AM, Nicolai Hähnle  wrote:
> On 15.12.2016 17:19, Ilia Mirkin wrote:
>>
>> Perhaps this is a point-specific function, but if this is applying to
>> all primitives, won't this end up culling primitives that have *any*
>> clip distance value < 0?
>
>
> Setting the cull bit here just enables the normal gl_CullDistance logic for
> whatever the current primitive type happens to be.
>
> Cull distance logic is a subset of clip distance logic: when there's some
> distance value which is < 0 for all vertices, cull the primitive. Clipping
> also does that (+ of course it does more complicated things when only a
> subset of of the vertices have < 0 for a distance value). Just that for
> whatever reason, the hardware folks decided that clipping should just do
> nothing at all for points.

Just to close the loop - I had misremembered how culling worked. I
thought if any vertex touched the cull space, the primitive was gone.
But it's actually if the whole primitive is in the cull space, it's
culled out (which, tbh, makes more sense...). So other than doing a
teensy bit of extra work, which is most likely ~free since it's all
hw, this change should work as advertised. Thanks for taking the time
to explain it to me :)

And I sympathize with the hw folks - clip distances on points is
nonsense - it's not like they can be interpolated with a point sprite
type of thing.

Cheers,

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


Re: [Mesa-dev] [PATCH 1/3] i965/blit: Break the guts of intel_miptree_blit into a helper

2016-12-15 Thread Emil Velikov
On 15 December 2016 at 16:42, Emil Velikov  wrote:
> Hi Jason,
>
> Double-checking things and I've noticed that this has gone under the
> radar since due to simple typo - mesa-dev vs mesa-stable.
JFYI skimming through the nominations - there are ~5 missing ones for
13.0 and ~20 for 12.0.
Many of those are yours, but others have been unfortunate as well.

Regardless I'll prepare a script to catch such typos for the future.

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/2] i965/blit: Fix the src dimension sanity check in miptree_copy

2016-12-15 Thread Emil Velikov
Hi Jason,

On 6 December 2016 at 20:37, Jason Ekstrand  wrote:
> Cc: "13.0" 
> ---
>  src/mesa/drivers/dri/i965/intel_blit.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/intel_blit.c 
> b/src/mesa/drivers/dri/i965/intel_blit.c
> index 03a35ee..5f0cf74 100644
> --- a/src/mesa/drivers/dri/i965/intel_blit.c
> +++ b/src/mesa/drivers/dri/i965/intel_blit.c
> @@ -421,8 +421,10 @@ intel_miptree_copy(struct brw_context *brw,
>
>assert(src_x % bw == 0);
>assert(src_y % bh == 0);
> -  assert(src_width % bw == 0);
> -  assert(src_height % bh == 0);
> +  assert(src_width % bw == 0 ||
> + src_x + src_width == minify(src_mt->logical_width0, src_level));
> +  assert(src_height % bh == 0 ||
> + src_y + src_height == minify(src_mt->logical_height0, 
> src_level));
>
This and 2/2 depend on earlier work, as mentioned a minute ago.
So depending on how that one goes, will determine whether we get these
in -stable.

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


Re: [Mesa-dev] [PATCH 2/2] radeonsi: fix gl_ClipDistance and gl_ClipVertex for points

2016-12-15 Thread Nicolai Hähnle

On 15.12.2016 17:19, Ilia Mirkin wrote:

Perhaps this is a point-specific function, but if this is applying to
all primitives, won't this end up culling primitives that have *any*
clip distance value < 0?


Setting the cull bit here just enables the normal gl_CullDistance logic 
for whatever the current primitive type happens to be.


Cull distance logic is a subset of clip distance logic: when there's 
some distance value which is < 0 for all vertices, cull the primitive. 
Clipping also does that (+ of course it does more complicated things 
when only a subset of of the vertices have < 0 for a distance value). 
Just that for whatever reason, the hardware folks decided that clipping 
should just do nothing at all for points.


Cheers,
Nicolai



On Thu, Dec 15, 2016 at 10:42 AM, Nicolai Hähnle  wrote:

From: Nicolai Hähnle 

The clipper hardware doesn't consider points as primitives that can be
clipped. Simply setting the corresponding cull bits works, and should not
have an adverse effect on other primitive types according to the hardware
team.
---
 src/gallium/drivers/radeonsi/si_state.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_state.c 
b/src/gallium/drivers/radeonsi/si_state.c
index d86b99f..f6f61a6 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -671,34 +671,42 @@ static void si_emit_clip_regs(struct si_context *sctx, 
struct r600_atom *atom)
unsigned total_mask;
bool misc_vec_ena;

if (vs->key.opt.hw_vs.clip_disable) {
assert(!info->culldist_writemask);
clipdist_mask = 0;
culldist_mask = 0;
}
total_mask = clipdist_mask | culldist_mask;

+   /* Clip distances on points have no effect, so need to be implemented
+* as cull distances. This applies for the clipvertex case as well.
+*
+* Setting this for primitives other than points should have no adverse
+* effects.
+*/
+   clipdist_mask &= rs->clip_plane_enable;
+   culldist_mask |= clipdist_mask;
+
misc_vec_ena = info->writes_psize || info->writes_edgeflag ||
   info->writes_layer || info->writes_viewport_index;

radeon_set_context_reg(cs, R_02881C_PA_CL_VS_OUT_CNTL,
S_02881C_USE_VTX_POINT_SIZE(info->writes_psize) |
S_02881C_USE_VTX_EDGE_FLAG(info->writes_edgeflag) |
S_02881C_USE_VTX_RENDER_TARGET_INDX(info->writes_layer) |
S_02881C_USE_VTX_VIEWPORT_INDX(info->writes_viewport_index) |
S_02881C_VS_OUT_CCDIST0_VEC_ENA((total_mask & 0x0F) != 0) |
S_02881C_VS_OUT_CCDIST1_VEC_ENA((total_mask & 0xF0) != 0) |
S_02881C_VS_OUT_MISC_VEC_ENA(misc_vec_ena) |
S_02881C_VS_OUT_MISC_SIDE_BUS_ENA(misc_vec_ena) |
-   (rs->clip_plane_enable &
-clipdist_mask) | (culldist_mask << 8));
+   clipdist_mask | (culldist_mask << 8));
radeon_set_context_reg(cs, R_028810_PA_CL_CLIP_CNTL,
rs->pa_cl_clip_cntl |
ucp_mask |
S_028810_CLIP_DISABLE(window_space));

/* reuse needs to be set off if we write oViewport */
radeon_set_context_reg(cs, R_028AB4_VGT_REUSE_OFF,
   S_028AB4_REUSE_OFF(info->writes_viewport_index));
 }

--
2.7.4

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

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


Re: [Mesa-dev] [PATCH 1/3] i965/blit: Break the guts of intel_miptree_blit into a helper

2016-12-15 Thread Emil Velikov
Hi Jason,

Double-checking things and I've noticed that this has gone under the
radar since due to simple typo - mesa-dev vs mesa-stable.
Regardless, the patch in question seems to depend on at least

174f4900b294f939c85cfa94f5d8401ce73e5522
b7979a849bc185fbcab93a841eed692a10d61e25
80d3af812935978f01c9bb6d02102140383c4034
44760c100c3793718cc8d6cfb66852c4f72d7057

Where all of the above are refactoring/feature/performance patches.
The interest in perf. improvements is understandable, yet in those we
had at least one bug/issue fixed with commit
157971e450c34ec430c295ff922c2e597294aba3.

So barring a very compelling reason these won't be in 13.0.

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


Re: [Mesa-dev] [PATCH 2/2] radeonsi: fix gl_ClipDistance and gl_ClipVertex for points

2016-12-15 Thread Ilia Mirkin
Perhaps this is a point-specific function, but if this is applying to
all primitives, won't this end up culling primitives that have *any*
clip distance value < 0?

On Thu, Dec 15, 2016 at 10:42 AM, Nicolai Hähnle  wrote:
> From: Nicolai Hähnle 
>
> The clipper hardware doesn't consider points as primitives that can be
> clipped. Simply setting the corresponding cull bits works, and should not
> have an adverse effect on other primitive types according to the hardware
> team.
> ---
>  src/gallium/drivers/radeonsi/si_state.c | 12 ++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_state.c 
> b/src/gallium/drivers/radeonsi/si_state.c
> index d86b99f..f6f61a6 100644
> --- a/src/gallium/drivers/radeonsi/si_state.c
> +++ b/src/gallium/drivers/radeonsi/si_state.c
> @@ -671,34 +671,42 @@ static void si_emit_clip_regs(struct si_context *sctx, 
> struct r600_atom *atom)
> unsigned total_mask;
> bool misc_vec_ena;
>
> if (vs->key.opt.hw_vs.clip_disable) {
> assert(!info->culldist_writemask);
> clipdist_mask = 0;
> culldist_mask = 0;
> }
> total_mask = clipdist_mask | culldist_mask;
>
> +   /* Clip distances on points have no effect, so need to be implemented
> +* as cull distances. This applies for the clipvertex case as well.
> +*
> +* Setting this for primitives other than points should have no 
> adverse
> +* effects.
> +*/
> +   clipdist_mask &= rs->clip_plane_enable;
> +   culldist_mask |= clipdist_mask;
> +
> misc_vec_ena = info->writes_psize || info->writes_edgeflag ||
>info->writes_layer || info->writes_viewport_index;
>
> radeon_set_context_reg(cs, R_02881C_PA_CL_VS_OUT_CNTL,
> S_02881C_USE_VTX_POINT_SIZE(info->writes_psize) |
> S_02881C_USE_VTX_EDGE_FLAG(info->writes_edgeflag) |
> S_02881C_USE_VTX_RENDER_TARGET_INDX(info->writes_layer) |
> S_02881C_USE_VTX_VIEWPORT_INDX(info->writes_viewport_index) |
> S_02881C_VS_OUT_CCDIST0_VEC_ENA((total_mask & 0x0F) != 0) |
> S_02881C_VS_OUT_CCDIST1_VEC_ENA((total_mask & 0xF0) != 0) |
> S_02881C_VS_OUT_MISC_VEC_ENA(misc_vec_ena) |
> S_02881C_VS_OUT_MISC_SIDE_BUS_ENA(misc_vec_ena) |
> -   (rs->clip_plane_enable &
> -clipdist_mask) | (culldist_mask << 8));
> +   clipdist_mask | (culldist_mask << 8));
> radeon_set_context_reg(cs, R_028810_PA_CL_CLIP_CNTL,
> rs->pa_cl_clip_cntl |
> ucp_mask |
> S_028810_CLIP_DISABLE(window_space));
>
> /* reuse needs to be set off if we write oViewport */
> radeon_set_context_reg(cs, R_028AB4_VGT_REUSE_OFF,
>
> S_028AB4_REUSE_OFF(info->writes_viewport_index));
>  }
>
> --
> 2.7.4
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [Mesa-stable] [PATCH 2/2] i965/mt: Disable HiZ when sharing depth buffer externally (v2)

2016-12-15 Thread Emil Velikov
Hi Chad,

On 10 December 2016 at 00:40, Chad Versace  wrote:
> intel_miptree_make_shareable() discarded and disabled CCS. Fix it so
> that it discards and disables HiZ too.
>
> Fixes 
> dEQP-EGL.functional.image.render_multiple_contexts.gles2_renderbuffer_depth16_depth_buffer
> on Skylake.
>
> v2: Actually do what the commit message says. Discard the HiZ buffer.
>
Afaict the commit depends (at least partially) on
0041169cacb300a882b4dc38cd341f98bf2a7c38 and the ~4 follow-up commits
from Ben.
If I'm mistaking and please send a backport for stable.

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


Re: [Mesa-dev] Documenting with Sphinx

2016-12-15 Thread Jason Ekstrand
On Dec 15, 2016 6:40 AM, "Jani Nikula"  wrote:

On Thu, 15 Dec 2016, Robert Bragg  wrote:
> On Wed, Dec 14, 2016 at 7:17 PM, Jani Nikula
>  wrote:
>> On Wed, 14 Dec 2016, Robert Bragg  wrote:
>> The AST does include comments right above each cursor, but it falls
>> short for comments not attached to cursors. You have to walk the tokens
>> for that. I think I have most of this solved, though it hasn't seen much
>> testing.
>
> Right, what I was thinking of though is that clang itself can actually
> parse doxygen style comment sections like \brief, \param and \returns:
>
> http://clang.llvm.org/doxygen/classclang_1_1comments_1_1Parser.html
>
> Seems a bit mad, but this e.g. helps enable a -Wdocumentation warning
> to check \params match actual function arguments
>
> I was wondering if that can somehow be exposed via the AST accessible
> through the python bindings.

AFAICT this is not available via libclang or its python bindings; you
can only get at the \brief paragraph, which does seems to indicate some
parsing under the hood. I don't know if the information is available via
some other clang interface, but even if it is, venturing outside of what
python-clang provides makes both writing the tool and interfacing with
Sphinx an order of magnitude more painful.

Obviously -Wdocumentation working out of the box is nice, but apparently
you'd have to use Doxygen anyway. Personally, I'm not interested in
Doxygen compatibility or format. If you want that, you should probably
use Doxygen.

Oh, there's also cldoc [1], a documentation generator based on
python-clang, but that invents another markdown based comment format and
produces XML, neither of which work that great with Sphinx.

I've looked at all of this before, and for *my* needs, aiming at a
minimal python-clang based comment extractor that's mostly passthrough
with some Sphinx C Domain directives sprinkled on top is the right
choice. Kind of like autodoc for C, with no format conversions in
between. And this is, of course, taking Sphinx for granted. Maybe even
that is still open for you.


Dylan and I talked about a couple of possibilities for how to tie things
into sphinx.  One was to come up with some regex and do a mass conversion
of the tree from doxygen to sphinx rst. Another was use that same regex as
a filter that gets applied as you pull from the source.  I think we'll have
to do since experimentation to figure out the best approach.  Right now,
Mesa doesn't really make full use of doxygen so regex is probably tractable.

We've also talked about some of the doxygen-based solutions such as
breathe.  Personally, though, I'd rather get rid of the middle man.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/2] radeonsi: fix gl_ClipDistance and gl_ClipVertex for points

2016-12-15 Thread Nicolai Hähnle
From: Nicolai Hähnle 

The clipper hardware doesn't consider points as primitives that can be
clipped. Simply setting the corresponding cull bits works, and should not
have an adverse effect on other primitive types according to the hardware
team.
---
 src/gallium/drivers/radeonsi/si_state.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_state.c 
b/src/gallium/drivers/radeonsi/si_state.c
index d86b99f..f6f61a6 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -671,34 +671,42 @@ static void si_emit_clip_regs(struct si_context *sctx, 
struct r600_atom *atom)
unsigned total_mask;
bool misc_vec_ena;
 
if (vs->key.opt.hw_vs.clip_disable) {
assert(!info->culldist_writemask);
clipdist_mask = 0;
culldist_mask = 0;
}
total_mask = clipdist_mask | culldist_mask;
 
+   /* Clip distances on points have no effect, so need to be implemented
+* as cull distances. This applies for the clipvertex case as well.
+*
+* Setting this for primitives other than points should have no adverse
+* effects.
+*/
+   clipdist_mask &= rs->clip_plane_enable;
+   culldist_mask |= clipdist_mask;
+
misc_vec_ena = info->writes_psize || info->writes_edgeflag ||
   info->writes_layer || info->writes_viewport_index;
 
radeon_set_context_reg(cs, R_02881C_PA_CL_VS_OUT_CNTL,
S_02881C_USE_VTX_POINT_SIZE(info->writes_psize) |
S_02881C_USE_VTX_EDGE_FLAG(info->writes_edgeflag) |
S_02881C_USE_VTX_RENDER_TARGET_INDX(info->writes_layer) |
S_02881C_USE_VTX_VIEWPORT_INDX(info->writes_viewport_index) |
S_02881C_VS_OUT_CCDIST0_VEC_ENA((total_mask & 0x0F) != 0) |
S_02881C_VS_OUT_CCDIST1_VEC_ENA((total_mask & 0xF0) != 0) |
S_02881C_VS_OUT_MISC_VEC_ENA(misc_vec_ena) |
S_02881C_VS_OUT_MISC_SIDE_BUS_ENA(misc_vec_ena) |
-   (rs->clip_plane_enable &
-clipdist_mask) | (culldist_mask << 8));
+   clipdist_mask | (culldist_mask << 8));
radeon_set_context_reg(cs, R_028810_PA_CL_CLIP_CNTL,
rs->pa_cl_clip_cntl |
ucp_mask |
S_028810_CLIP_DISABLE(window_space));
 
/* reuse needs to be set off if we write oViewport */
radeon_set_context_reg(cs, R_028AB4_VGT_REUSE_OFF,
   S_028AB4_REUSE_OFF(info->writes_viewport_index));
 }
 
-- 
2.7.4

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


[Mesa-dev] [PATCH 1/2] radeonsi: only set VS_OUT_MISC_SIDE_BUS_ENA when the misc vector is used

2016-12-15 Thread Nicolai Hähnle
From: Nicolai Hähnle 

Should have no effect (other than perhaps on power consumption), but
Vulkan does this.
---
 src/gallium/drivers/radeonsi/si_state.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_state.c 
b/src/gallium/drivers/radeonsi/si_state.c
index 984540d..d86b99f 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -662,40 +662,41 @@ static void si_emit_clip_regs(struct si_context *sctx, 
struct r600_atom *atom)
struct si_shader *vs = si_get_vs_state(sctx);
struct tgsi_shader_info *info = si_get_vs_info(sctx);
struct si_state_rasterizer *rs = sctx->queued.named.rasterizer;
unsigned window_space =
   info->properties[TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION];
unsigned clipdist_mask =
info->writes_clipvertex ? SIX_BITS : info->clipdist_writemask;
unsigned ucp_mask = clipdist_mask ? 0 : rs->clip_plane_enable & 
SIX_BITS;
unsigned culldist_mask = info->culldist_writemask << 
info->num_written_clipdistance;
unsigned total_mask;
+   bool misc_vec_ena;
 
if (vs->key.opt.hw_vs.clip_disable) {
assert(!info->culldist_writemask);
clipdist_mask = 0;
culldist_mask = 0;
}
total_mask = clipdist_mask | culldist_mask;
 
+   misc_vec_ena = info->writes_psize || info->writes_edgeflag ||
+  info->writes_layer || info->writes_viewport_index;
+
radeon_set_context_reg(cs, R_02881C_PA_CL_VS_OUT_CNTL,
S_02881C_USE_VTX_POINT_SIZE(info->writes_psize) |
S_02881C_USE_VTX_EDGE_FLAG(info->writes_edgeflag) |
S_02881C_USE_VTX_RENDER_TARGET_INDX(info->writes_layer) |
S_02881C_USE_VTX_VIEWPORT_INDX(info->writes_viewport_index) |
S_02881C_VS_OUT_CCDIST0_VEC_ENA((total_mask & 0x0F) != 0) |
S_02881C_VS_OUT_CCDIST1_VEC_ENA((total_mask & 0xF0) != 0) |
-   S_02881C_VS_OUT_MISC_VEC_ENA(info->writes_psize ||
-   info->writes_edgeflag ||
-   info->writes_layer ||
-info->writes_viewport_index) |
-   S_02881C_VS_OUT_MISC_SIDE_BUS_ENA(1) |
+   S_02881C_VS_OUT_MISC_VEC_ENA(misc_vec_ena) |
+   S_02881C_VS_OUT_MISC_SIDE_BUS_ENA(misc_vec_ena) |
(rs->clip_plane_enable &
 clipdist_mask) | (culldist_mask << 8));
radeon_set_context_reg(cs, R_028810_PA_CL_CLIP_CNTL,
rs->pa_cl_clip_cntl |
ucp_mask |
S_028810_CLIP_DISABLE(window_space));
 
/* reuse needs to be set off if we write oViewport */
radeon_set_context_reg(cs, R_028AB4_VGT_REUSE_OFF,
   S_028AB4_REUSE_OFF(info->writes_viewport_index));
-- 
2.7.4

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


[Mesa-dev] [Bug 98428] Undefined non-weak-symbol in dri-drivers

2016-12-15 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=98428

Eugene A. Shatokhin  changed:

   What|Removed |Added

 CC||eugene.shatok...@rosalab.ru

-- 
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 99027] gtk+ apps segfault on Xvfb with mesa 13

2016-12-15 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=99027

--- Comment #9 from Emil Velikov  ---
Almost but not quite:

getVisualConfigs() seems to fail since the xserver advertises zero visuals
(reply.numVisuals). Which in itself is not at all surprising.

For both 24 and 8 bpp glxinfo correctly handle things printing the following
error message:
  name of display: :10
  Error: couldn't find RGB GLX visual or fbconfig

At the same time, on 24bpp gnome-terminal/gedit we seems to be hitting
different codepath, since we don't even get into libGL.so (__glXInitialize).

Leaning towards NOTOURBUG, but if anyone has further tips and suggestions I'll
gladly hear them out.

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


Re: [Mesa-dev] Proposal of date-based Mesa versioning for 2017

2016-12-15 Thread Andreas Boll
2016-12-12 20:01 GMT+01:00 Emil Velikov :
> [Re-adding mesa-maintainers]
>
> On 12 December 2016 at 18:08, Laurent Carlier  wrote:
>> Le lundi 12 décembre 2016, 17:57:28 CET Marek Olšák a écrit :
>>>
>>> I second that. YY.AA where YY=year, AA \in {0,1,2,3}.
>>>
>>> Marek
>>
>> I agree, using month is really confusing
>>
> Similar to the "libudev is no longer required by mesa" in the 13.0.0
> release notes ;-)
> Sorry I could not resist.
>
> So barring any compelling reason(s) to use month and a bunch of
> volunteers to clear the confusion things will be YY.A.P.
> I.e. the only difference between the new scheme is that major is
> bumped to reflect the year.
>
> Gents, please don't forget to cast your ack/nack on the secondary
> topic - dropping $VERSION directory in the URL.
>
> Thanks
> Emil

Ack on both topics (changing versioning to YY.A.P and dropping
$VERSION directory in the URL).

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


[Mesa-dev] [Bug 99027] gtk+ apps segfault on Xvfb with mesa 13

2016-12-15 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=99027

--- Comment #8 from Emil Velikov  ---
Using 8bpp, not sure if that's supposed to work even ;-)
Joking aside, the bisect result is a surprise and from a quick look the only
thing that might be wrong on our end is __glXQueryServerString().

If anything else flags up I'm wondering if it's not an xserver issue - namely,
it does not advertise any FB/Visuals. Let me try in x8 and see if I can track
it down precisely.

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


Re: [Mesa-dev] Documenting with Sphinx

2016-12-15 Thread Jani Nikula
On Thu, 15 Dec 2016, Robert Bragg  wrote:
> On Wed, Dec 14, 2016 at 7:17 PM, Jani Nikula
>  wrote:
>> On Wed, 14 Dec 2016, Robert Bragg  wrote:
>> The AST does include comments right above each cursor, but it falls
>> short for comments not attached to cursors. You have to walk the tokens
>> for that. I think I have most of this solved, though it hasn't seen much
>> testing.
>
> Right, what I was thinking of though is that clang itself can actually
> parse doxygen style comment sections like \brief, \param and \returns:
>
> http://clang.llvm.org/doxygen/classclang_1_1comments_1_1Parser.html
>
> Seems a bit mad, but this e.g. helps enable a -Wdocumentation warning
> to check \params match actual function arguments
>
> I was wondering if that can somehow be exposed via the AST accessible
> through the python bindings.

AFAICT this is not available via libclang or its python bindings; you
can only get at the \brief paragraph, which does seems to indicate some
parsing under the hood. I don't know if the information is available via
some other clang interface, but even if it is, venturing outside of what
python-clang provides makes both writing the tool and interfacing with
Sphinx an order of magnitude more painful.

Obviously -Wdocumentation working out of the box is nice, but apparently
you'd have to use Doxygen anyway. Personally, I'm not interested in
Doxygen compatibility or format. If you want that, you should probably
use Doxygen.

Oh, there's also cldoc [1], a documentation generator based on
python-clang, but that invents another markdown based comment format and
produces XML, neither of which work that great with Sphinx.

I've looked at all of this before, and for *my* needs, aiming at a
minimal python-clang based comment extractor that's mostly passthrough
with some Sphinx C Domain directives sprinkled on top is the right
choice. Kind of like autodoc for C, with no format conversions in
between. And this is, of course, taking Sphinx for granted. Maybe even
that is still open for you.


BR,
Jani.


[1] https://jessevdk.github.io/cldoc/

-- 
Jani Nikula, Intel Open Source Technology Center
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 4/4] st/xvmc: remove dead code

2016-12-15 Thread Nayan Deshmukh
My apologies for sending the wrong series.



On Thu, Dec 15, 2016 at 7:45 PM, Christian König
 wrote:
> Am 15.12.2016 um 15:07 schrieb Emil Velikov:
>>
>> On 15 December 2016 at 13:57, Nayan Deshmukh 
>> wrote:
>>>
>>> I send out the wrong series, the earlier one. I am sending the v2.
>>>
>>> I am not sure of the reason as to why it was returning a bool anyways.
>>> So I was hoping that someone could point out the reason.
>>>
>> Looking within... strictly speaking pipe_buffer_create() and
>> vl_compositor_set_csc_matrix() can fail.
>> Christian seems to be the author back in 2012, so not sure if he still
>> recalls the details.
>
>
> My best guess is that the function used to have error handling or at least
> should have error handling, but this was never properly implemented.
>
> If you want to clean this up I suggest to either follow Ilia's comment as
> well and make the function return void, or go into the other direction and
> implement proper error handling (preferred).
>
I will send in a patch with error handling.

Regards,
Nayan
> Regards,
> Christian.
>
>>
>> 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 4/4] st/xvmc: remove dead code

2016-12-15 Thread Christian König

Am 15.12.2016 um 15:07 schrieb Emil Velikov:

On 15 December 2016 at 13:57, Nayan Deshmukh  wrote:

I send out the wrong series, the earlier one. I am sending the v2.

I am not sure of the reason as to why it was returning a bool anyways.
So I was hoping that someone could point out the reason.


Looking within... strictly speaking pipe_buffer_create() and
vl_compositor_set_csc_matrix() can fail.
Christian seems to be the author back in 2012, so not sure if he still
recalls the details.


My best guess is that the function used to have error handling or at 
least should have error handling, but this was never properly implemented.


If you want to clean this up I suggest to either follow Ilia's comment 
as well and make the function return void, or go into the other 
direction and implement proper error handling (preferred).


Regards,
Christian.



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


[Mesa-dev] [PATCH v2 4/4] st/xvmc: remove dead code

2016-12-15 Thread Nayan Deshmukh
vl_compositor_init_state always return true so we don't
need to handle false case

Signed-off-by: Nayan Deshmukh 
---
 src/gallium/state_trackers/xvmc/context.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/src/gallium/state_trackers/xvmc/context.c 
b/src/gallium/state_trackers/xvmc/context.c
index fb9f435..057085d 100644
--- a/src/gallium/state_trackers/xvmc/context.c
+++ b/src/gallium/state_trackers/xvmc/context.c
@@ -262,11 +262,7 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int 
surface_type_id,
   goto no_compositor;
}
 
-   if (!vl_compositor_init_state(_priv->cstate, pipe)) {
-  XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL compositor state.\n");
-  goto no_compositor_state;
-   }
-
+   vl_compositor_init_state(_priv->cstate, pipe);
 
context_priv->color_standard =
   debug_get_bool_option("G3DVL_NO_CSC", FALSE) ?
@@ -299,8 +295,6 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int 
surface_type_id,
 
return Success;
 
-no_compositor_state:
-   vl_compositor_cleanup(_priv->compositor);
 no_compositor:
context_priv->decoder->destroy(context_priv->decoder);
 no_decoder:
-- 
2.9.3

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


[Mesa-dev] [PATCH v2 3/4] st/vdpau: check if compositor is initilized successfully

2016-12-15 Thread Nayan Deshmukh
Signed-off-by: Nayan Deshmukh 
---
 src/gallium/state_trackers/vdpau/device.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/vdpau/device.c 
b/src/gallium/state_trackers/vdpau/device.c
index 81b7582..8bae064 100644
--- a/src/gallium/state_trackers/vdpau/device.c
+++ b/src/gallium/state_trackers/vdpau/device.c
@@ -128,13 +128,19 @@ vdp_imp_device_create_x11(Display *display, int screen, 
VdpDevice *device,
   goto no_handle;
}
 
-   vl_compositor_init(>compositor, dev->context);
+   if (!vl_compositor_init(>compositor, dev->context)) {
+   ret = VDP_STATUS_ERROR;
+   goto no_compositor;
+   }
+
pipe_mutex_init(dev->mutex);
 
*get_proc_address = 
 
return VDP_STATUS_OK;
 
+no_compositor:
+   vlRemoveDataHTAB(*device);
 no_handle:
pipe_sampler_view_reference(>dummy_sv, NULL);
 no_resource:
-- 
2.9.3

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


[Mesa-dev] [PATCH v2 1/4] st/xvmc: use goto to make code more readable

2016-12-15 Thread Nayan Deshmukh
Signed-off-by: Nayan Deshmukh 
---
 src/gallium/state_trackers/xvmc/context.c | 40 +++
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git a/src/gallium/state_trackers/xvmc/context.c 
b/src/gallium/state_trackers/xvmc/context.c
index e9014c8..fb9f435 100644
--- a/src/gallium/state_trackers/xvmc/context.c
+++ b/src/gallium/state_trackers/xvmc/context.c
@@ -226,23 +226,20 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int 
surface_type_id,
 
context_priv = CALLOC(1, sizeof(XvMCContextPrivate));
if (!context_priv)
-  return BadAlloc;
+  goto no_context_priv;
 
/* TODO: Reuse screen if process creates another context */
vscreen = vl_dri2_screen_create(dpy, scrn);
 
if (!vscreen) {
   XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL screen.\n");
-  FREE(context_priv);
-  return BadAlloc;
+  goto no_screen;
}
 
pipe = vscreen->pscreen->context_create(vscreen->pscreen, vscreen, 0);
if (!pipe) {
   XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL context.\n");
-  vscreen->destroy(vscreen);
-  FREE(context_priv);
-  return BadAlloc;
+  goto no_context;
}
 
templat.profile = ProfileToPipe(mc_type);
@@ -257,29 +254,17 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int 
surface_type_id,
 
if (!context_priv->decoder) {
   XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL decoder.\n");
-  pipe->destroy(pipe);
-  vscreen->destroy(vscreen);
-  FREE(context_priv);
-  return BadAlloc;
+  goto no_decoder;
}
 
if (!vl_compositor_init(_priv->compositor, pipe)) {
   XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL compositor.\n");
-  context_priv->decoder->destroy(context_priv->decoder);
-  pipe->destroy(pipe);
-  vscreen->destroy(vscreen);
-  FREE(context_priv);
-  return BadAlloc;
+  goto no_compositor;
}
 
if (!vl_compositor_init_state(_priv->cstate, pipe)) {
   XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL compositor state.\n");
-  vl_compositor_cleanup(_priv->compositor);
-  context_priv->decoder->destroy(context_priv->decoder);
-  pipe->destroy(pipe);
-  vscreen->destroy(vscreen);
-  FREE(context_priv);
-  return BadAlloc;
+  goto no_compositor_state;
}
 
 
@@ -313,6 +298,19 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int 
surface_type_id,
XVMC_MSG(XVMC_TRACE, "[XvMC] Context %p created.\n", context);
 
return Success;
+
+no_compositor_state:
+   vl_compositor_cleanup(_priv->compositor);
+no_compositor:
+   context_priv->decoder->destroy(context_priv->decoder);
+no_decoder:
+   pipe->destroy(pipe);
+no_context:
+   vscreen->destroy(vscreen);
+no_screen:
+   FREE(context_priv);
+no_context_priv:
+   return BadAlloc;
 }
 
 PUBLIC
-- 
2.9.3

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


[Mesa-dev] [PATCH v2 2/4] st/vdpau: remove dead code

2016-12-15 Thread Nayan Deshmukh
vl_compositor_init_state always return true so we don't
need to handle false case

v2: add missing semicolon

Signed-off-by: Nayan Deshmukh 
---
 src/gallium/state_trackers/vdpau/presentation.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/src/gallium/state_trackers/vdpau/presentation.c 
b/src/gallium/state_trackers/vdpau/presentation.c
index f35d73a..c1e1054 100644
--- a/src/gallium/state_trackers/vdpau/presentation.c
+++ b/src/gallium/state_trackers/vdpau/presentation.c
@@ -66,11 +66,7 @@ vlVdpPresentationQueueCreate(VdpDevice device,
pq->drawable = pqt->drawable;
 
pipe_mutex_lock(dev->mutex);
-   if (!vl_compositor_init_state(>cstate, dev->context)) {
-  pipe_mutex_unlock(dev->mutex);
-  ret = VDP_STATUS_ERROR;
-  goto no_compositor;
-   }
+   vl_compositor_init_state(>cstate, dev->context);
pipe_mutex_unlock(dev->mutex);
 
*presentation_queue = vlAddDataHTAB(pq);
@@ -82,7 +78,6 @@ vlVdpPresentationQueueCreate(VdpDevice device,
return VDP_STATUS_OK;
 
 no_handle:
-no_compositor:
DeviceReference(>device, NULL);
FREE(pq);
return ret;
-- 
2.9.3

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


Re: [Mesa-dev] [PATCH 4/4] st/xvmc: remove dead code

2016-12-15 Thread Emil Velikov
On 15 December 2016 at 13:57, Nayan Deshmukh  wrote:
> I send out the wrong series, the earlier one. I am sending the v2.
>
> I am not sure of the reason as to why it was returning a bool anyways.
> So I was hoping that someone could point out the reason.
>
Looking within... strictly speaking pipe_buffer_create() and
vl_compositor_set_csc_matrix() can fail.
Christian seems to be the author back in 2012, so not sure if he still
recalls the details.

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


Re: [Mesa-dev] [PATCH] Mesa: Return GL error INVALID_OPERATION in case invalid format/type

2016-12-15 Thread Ilia Mirkin
On Thu, Dec 15, 2016 at 6:45 AM, Emil Velikov  wrote:
> On 15 December 2016 at 01:10, Randy Xu  wrote:
>> From: "Xu,Randy" 
>>
>> Refer to GLES3.2 spec in 8.5
>> Textures with a base internal format of DEPTH_COMPONENT, DEPTH_-
>> STENCIL or STENCIL_INDEX are supported by texture image specification
>> commands only if target is TEXTURE_2D, TEXTURE_2D_MULTISAMPLE,
>> TEXTURE_2D_ARRAY, TEXTURE_2D_MULTISAMPLE_ARRAY, TEXTURE_CUBE_-
>> MAP or TEXTURE_CUBE_MAP_ARRAY. Using these formats in conjunction with
>> any other target will result in an INVALID_OPERATION error.
>> This patch can fix dEQP-GLES3.functional.negative_api.texture.teximage3d

s/can fix/fixes/

>> failure.

s/failure//

>>
> I think others have alluded it with referencing other commits, but it
> might have been too subtle.
>  - please use the cannonical format [1] to add a spec quote in the code
>  - your commit message should explain why rather than a simple spec quote.
> You can draw some inspirations from 19f13b2096a9fdd986e5a12d4e9d8b0d6a4632f3

And #3 - Matt pointed out that desktop GL actually has similar text.
So the condition needs to be different (and will require some trudging
through specs to figure out what happened). [Unless I misunderstood
what he was saying, in which case, disregard.]

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


Re: [Mesa-dev] Problem using GLVND enabled mesa with Intel DDX

2016-12-15 Thread Emil Velikov
On 15 December 2016 at 09:01, Yu, Qiang  wrote:
>
> Hi guys,
>
> I'm trying GLVND with mesa, but the Intel DDX seems have some problem with it:
> [  2970.834] (EE) AIGLX error: dlopen of 
> /usr/lib/x86_64-linux-gnu/dri/i965_dri.so failed 
> (/usr/lib/x86_64-linux-gnu/dri/i965_dri.so: undefined symbol: 
> _glapi_tls_Dispatch)
> [  2970.834] (EE) AIGLX: reverting to software rendering
> [  2970.889] (EE) AIGLX error: dlopen of 
> /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so failed 
> (/usr/lib/x86_64-linux-gnu/dri/swrast_dri.so: undefined symbol: 
> _glapi_tls_Dispatch)
> [  2970.889] (EE) GLX: could not load software renderer
> [  2970.889] (II) GLX: no usable GL providers found for screen 0
>
> I find the _glapi_tls_Dispatch is in libglapi.so which is depended by 
> libGLX_mesa.so.
> But in Intel DDX's case, no libGLX_mesa.so/libglapi.so is loaded, i965_dri.so 
> is loaded directly.
>
Sounds like https://bugs.freedesktop.org/show_bug.cgi?id=98428

There's a bunch of ideas on how to tackle this, ranging from:
 - retro "fix" xserver - comment 2
 - link against glapi.so (it can have implications) - comment 3
 - reuse GLdispatch.so for the symbols - comment 3 and others

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


Re: [Mesa-dev] [PATCH 4/4] st/xvmc: remove dead code

2016-12-15 Thread Nayan Deshmukh
I send out the wrong series, the earlier one. I am sending the v2.

I am not sure of the reason as to why it was returning a bool anyways.
So I was hoping that someone could point out the reason.

Regards,
Nayan


On Thu, Dec 15, 2016 at 7:24 PM, Ilia Mirkin  wrote:
> Also, please at least *compile test* your patches. This patch doesn't compile.
>
> On Thu, Dec 15, 2016 at 8:54 AM, Ilia Mirkin  wrote:
>> Should there be a patch 5 which makes vl_compositor_init_state return void?
>>
>> On Thu, Dec 15, 2016 at 8:34 AM, Nayan Deshmukh
>>  wrote:
>>> vl_compositor_init_state always return true so we don't
>>> need to handle false case
>>>
>>> Signed-off-by: Nayan Deshmukh 
>>> ---
>>>  src/gallium/state_trackers/xvmc/context.c | 8 +---
>>>  1 file changed, 1 insertion(+), 7 deletions(-)
>>>
>>> diff --git a/src/gallium/state_trackers/xvmc/context.c 
>>> b/src/gallium/state_trackers/xvmc/context.c
>>> index 469e1c1..4ae7d7b 100644
>>> --- a/src/gallium/state_trackers/xvmc/context.c
>>> +++ b/src/gallium/state_trackers/xvmc/context.c
>>> @@ -262,11 +262,7 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, 
>>> int surface_type_id,
>>>goto no_compositor;
>>> }
>>>
>>> -   if (!vl_compositor_init_state(_priv->cstate, pipe)) {
>>> -  XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL compositor state.\n");
>>> -  goto no_compositor_state;
>>> -   }
>>> -
>>> +   vl_compositor_init_state(_priv->cstate, pipe)
>>>
>>> context_priv->color_standard =
>>>debug_get_bool_option("G3DVL_NO_CSC", FALSE) ?
>>> @@ -299,8 +295,6 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, 
>>> int surface_type_id,
>>>
>>> return Success;
>>>
>>> -no_compositor_state:
>>> -   vl_compositor_cleanup(_priv->compositor);
>>>  no_compositor:
>>> context_priv->decoder->destroy(context_priv->decoder);
>>>  no_decoder:
>>> --
>>> 2.9.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] [PATCH 4/4] st/xvmc: remove dead code

2016-12-15 Thread Ilia Mirkin
Also, please at least *compile test* your patches. This patch doesn't compile.

On Thu, Dec 15, 2016 at 8:54 AM, Ilia Mirkin  wrote:
> Should there be a patch 5 which makes vl_compositor_init_state return void?
>
> On Thu, Dec 15, 2016 at 8:34 AM, Nayan Deshmukh
>  wrote:
>> vl_compositor_init_state always return true so we don't
>> need to handle false case
>>
>> Signed-off-by: Nayan Deshmukh 
>> ---
>>  src/gallium/state_trackers/xvmc/context.c | 8 +---
>>  1 file changed, 1 insertion(+), 7 deletions(-)
>>
>> diff --git a/src/gallium/state_trackers/xvmc/context.c 
>> b/src/gallium/state_trackers/xvmc/context.c
>> index 469e1c1..4ae7d7b 100644
>> --- a/src/gallium/state_trackers/xvmc/context.c
>> +++ b/src/gallium/state_trackers/xvmc/context.c
>> @@ -262,11 +262,7 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, 
>> int surface_type_id,
>>goto no_compositor;
>> }
>>
>> -   if (!vl_compositor_init_state(_priv->cstate, pipe)) {
>> -  XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL compositor state.\n");
>> -  goto no_compositor_state;
>> -   }
>> -
>> +   vl_compositor_init_state(_priv->cstate, pipe)
>>
>> context_priv->color_standard =
>>debug_get_bool_option("G3DVL_NO_CSC", FALSE) ?
>> @@ -299,8 +295,6 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, 
>> int surface_type_id,
>>
>> return Success;
>>
>> -no_compositor_state:
>> -   vl_compositor_cleanup(_priv->compositor);
>>  no_compositor:
>> context_priv->decoder->destroy(context_priv->decoder);
>>  no_decoder:
>> --
>> 2.9.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] [PATCH 4/4] st/xvmc: remove dead code

2016-12-15 Thread Ilia Mirkin
Should there be a patch 5 which makes vl_compositor_init_state return void?

On Thu, Dec 15, 2016 at 8:34 AM, Nayan Deshmukh
 wrote:
> vl_compositor_init_state always return true so we don't
> need to handle false case
>
> Signed-off-by: Nayan Deshmukh 
> ---
>  src/gallium/state_trackers/xvmc/context.c | 8 +---
>  1 file changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/src/gallium/state_trackers/xvmc/context.c 
> b/src/gallium/state_trackers/xvmc/context.c
> index 469e1c1..4ae7d7b 100644
> --- a/src/gallium/state_trackers/xvmc/context.c
> +++ b/src/gallium/state_trackers/xvmc/context.c
> @@ -262,11 +262,7 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, 
> int surface_type_id,
>goto no_compositor;
> }
>
> -   if (!vl_compositor_init_state(_priv->cstate, pipe)) {
> -  XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL compositor state.\n");
> -  goto no_compositor_state;
> -   }
> -
> +   vl_compositor_init_state(_priv->cstate, pipe)
>
> context_priv->color_standard =
>debug_get_bool_option("G3DVL_NO_CSC", FALSE) ?
> @@ -299,8 +295,6 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int 
> surface_type_id,
>
> return Success;
>
> -no_compositor_state:
> -   vl_compositor_cleanup(_priv->compositor);
>  no_compositor:
> context_priv->decoder->destroy(context_priv->decoder);
>  no_decoder:
> --
> 2.9.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] Documenting with Sphinx

2016-12-15 Thread Robert Bragg
On Wed, Dec 14, 2016 at 7:17 PM, Jani Nikula
 wrote:
> On Wed, 14 Dec 2016, Robert Bragg  wrote:
>> On Tue, Dec 13, 2016 at 11:08 PM, Rob Clark  wrote:
>>> On Tue, Dec 13, 2016 at 5:47 PM, Eric Anholt  wrote:
 Jason Ekstrand  writes:

> Hey All,
> I don't figure this will be terribly controversial (I'm about to be wrong,
> aren't I?) but how do people feel about switching our "primary"
> documentation focus, as far as we have one, to sphinx?  Right now, Gallium
> uses sphinx for documenting all of it's "public" interfaces.  A while ago,
> Connor wrote some nice NIR documentation using sphinx that never got
> merged.  I've also spent some time this year and written some additional
> documentation about Intel surface layout that I'd like to have a place to
> put.  The thing that's in common with each of these is that they contain
> quite a bit of prose about the general theory of how things work and not
> just code comments so sphinx seems like a fairly good fit.  There are also
> some sort-of "architectural" things in the Vulkan driver that I would like
> to document better and we don't have a good place for that right now.
>
> Here's what I have in mind:
>
> Each component that we care to document (this may not be everything!) 
> would
> have a docs/ or sphinx/ folder.  In that folder would be any side-band 
> (not
> in code comments) documentation.  We would also set up some sort of
> source-scraping tool to turn inline comments into sphinx documentation.  
> At
> the component maintainer's discretion, that code could either be imported
> into sphinx whole-sale or curated by importing bits into other
> documentation files in a more carefully curated manner.  Of course, a
> maintainer could also choose to do all of their documentation side-band
> (sphinx allows for this) or to not document at all. :-)
>>>
>>> So, +100 to sphinx... I've been quite happy with it (and would be nice
>>> to merge the NIR docs too while where at it).  Maybe someday we'll
>>> have a "mesa book" after all ;-)
>>>
>>>
 I've written doxygen-style comments in my code for a long time, but
 never really looked at the doxygen output, so I wouldn't say I'm wedded
 to doxygen.  I think some side-band docs for architectural descriptions
 (like NIR needs) would be great, and if sphinx would help with
 encouraging those to be written and merged, then that's pretty good with
 me.

 I'm a little skeptical of sphinx due to not being able to extract docs
 From C comments in code in the base tool.  Apparently Breathe can chain
 doxygen into sphinx, so hopefully a "let's get excited about sphinx"
 patch series would convert our doxygen-based docs generation to using
 that.
>>>
>>> So as far as I understand on kernel side we are *somehow* extracting
>>> out C comment docs and combining w/ sphinx stuff..  maybe there is
>>> something to re-use from that.
>>
>> The actual parsing, extraction and generation of reStructureText for
>> the kernel is handled by scripts/kernel-doc, which is a perl script
>> based around regex parsing of C code. Jani Nikula has also written a
>> sphinx extension for using this script which can be seen in
>> Documentation/sphinx/. As you can probably guess kernel-doc is pretty
>> linux kernel specific. The script existed before the recent adoption
>> of sphinx and has support for docbook and man page generation. Being
>> based on regex parsing it has a somewhat limited understanding of the
>> underlying types of symbols being documented.
>>
>> I recently raised the idea of using clang's python bindings to extract
>> kerneldoc on dri-devel due to some of the limitations of kernel-doc I
>> was hitting and pointed at an experimental tool I wrote last year for
>> generating reStructureText based on gtk-doc comments:
>> https://github.com/rib/clib/blob/master/site/rst-from-c.py Probably
>> not developed enough to be very useful here, but provides one basic
>> example of generating reStructuredText from structured comments.
>>
>> Jani mentioned he had a bit of a side project going to use the same
>> clang bindings to support extracting doxygen comments, so maybe what
>> he's been working on could be useful for Mesa too, but I think maybe
>> that was for doxygen itself so maybe nothing to do with generating
>> reStructureText.
>
> I'm afraid what I have is really not ready for consumption by
> anyone. The idea is to basically have a Sphinx extension to extract
> documentation comments from source using python-clang. The goal is to
> keep it *very* simple, and *not* do any of the bloat Doxygen has. If you
> want to bolt stuff into Sphinx, why have the complexity of Doxygen, and
> the format conversion with inevitable hickups, when the documentation
> 

[Mesa-dev] [PATCH 3/4] st/vdpau: check if compositor is initilized successfully

2016-12-15 Thread Nayan Deshmukh
Signed-off-by: Nayan Deshmukh 
---
 src/gallium/state_trackers/vdpau/device.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/vdpau/device.c 
b/src/gallium/state_trackers/vdpau/device.c
index 81b7582..62709e3 100644
--- a/src/gallium/state_trackers/vdpau/device.c
+++ b/src/gallium/state_trackers/vdpau/device.c
@@ -128,13 +128,19 @@ vdp_imp_device_create_x11(Display *display, int screen, 
VdpDevice *device,
   goto no_handle;
}
 
-   vl_compositor_init(>compositor, dev->context);
+   if (!vl_compositor_init(>compositor, dev->context)) {
+   ret = VDP_STATUS_ERROR;
+   goto no_compositor;
+   }
+
pipe_mutex_init(dev->mutex);
 
*get_proc_address = 
 
return VDP_STATUS_OK;
 
+no_compositor:
+   vlRemoveDataHTAB(dev);
 no_handle:
pipe_sampler_view_reference(>dummy_sv, NULL);
 no_resource:
-- 
2.9.3

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


[Mesa-dev] [PATCH 2/4] st/vdpau: remove dead code

2016-12-15 Thread Nayan Deshmukh
vl_compositor_init_state always return true so we don't
need to handle false case

Signed-off-by: Nayan Deshmukh 
---
We may as well make vl_compositor_init_state a void function
but I don't know the reason as to why it is there in first 
place so haven't touched it yet
---
 src/gallium/state_trackers/vdpau/presentation.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/src/gallium/state_trackers/vdpau/presentation.c 
b/src/gallium/state_trackers/vdpau/presentation.c
index f35d73a..980d5cb 100644
--- a/src/gallium/state_trackers/vdpau/presentation.c
+++ b/src/gallium/state_trackers/vdpau/presentation.c
@@ -66,11 +66,7 @@ vlVdpPresentationQueueCreate(VdpDevice device,
pq->drawable = pqt->drawable;
 
pipe_mutex_lock(dev->mutex);
-   if (!vl_compositor_init_state(>cstate, dev->context)) {
-  pipe_mutex_unlock(dev->mutex);
-  ret = VDP_STATUS_ERROR;
-  goto no_compositor;
-   }
+   vl_compositor_init_state(>cstate, dev->context)
pipe_mutex_unlock(dev->mutex);
 
*presentation_queue = vlAddDataHTAB(pq);
@@ -82,7 +78,6 @@ vlVdpPresentationQueueCreate(VdpDevice device,
return VDP_STATUS_OK;
 
 no_handle:
-no_compositor:
DeviceReference(>device, NULL);
FREE(pq);
return ret;
-- 
2.9.3

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


[Mesa-dev] [PATCH 1/4] st/xvmc: use goto to make code more readable

2016-12-15 Thread Nayan Deshmukh
Signed-off-by: Nayan Deshmukh 
---
 src/gallium/state_trackers/xvmc/context.c | 40 +++
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git a/src/gallium/state_trackers/xvmc/context.c 
b/src/gallium/state_trackers/xvmc/context.c
index e9014c8..469e1c1 100644
--- a/src/gallium/state_trackers/xvmc/context.c
+++ b/src/gallium/state_trackers/xvmc/context.c
@@ -226,23 +226,20 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int 
surface_type_id,
 
context_priv = CALLOC(1, sizeof(XvMCContextPrivate));
if (!context_priv)
-  return BadAlloc;
+  goto no_context_priv;
 
/* TODO: Reuse screen if process creates another context */
vscreen = vl_dri2_screen_create(dpy, scrn);
 
if (!vscreen) {
   XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL screen.\n");
-  FREE(context_priv);
-  return BadAlloc;
+  goto no_screen;
}
 
pipe = vscreen->pscreen->context_create(vscreen->pscreen, vscreen, 0);
if (!pipe) {
   XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL context.\n");
-  vscreen->destroy(vscreen);
-  FREE(context_priv);
-  return BadAlloc;
+  goto no_context;
}
 
templat.profile = ProfileToPipe(mc_type);
@@ -257,29 +254,17 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int 
surface_type_id,
 
if (!context_priv->decoder) {
   XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL decoder.\n");
-  pipe->destroy(pipe);
-  vscreen->destroy(vscreen);
-  FREE(context_priv);
-  return BadAlloc;
+  goto no_decoder:
}
 
if (!vl_compositor_init(_priv->compositor, pipe)) {
   XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL compositor.\n");
-  context_priv->decoder->destroy(context_priv->decoder);
-  pipe->destroy(pipe);
-  vscreen->destroy(vscreen);
-  FREE(context_priv);
-  return BadAlloc;
+  goto no_compositor;
}
 
if (!vl_compositor_init_state(_priv->cstate, pipe)) {
   XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL compositor state.\n");
-  vl_compositor_cleanup(_priv->compositor);
-  context_priv->decoder->destroy(context_priv->decoder);
-  pipe->destroy(pipe);
-  vscreen->destroy(vscreen);
-  FREE(context_priv);
-  return BadAlloc;
+  goto no_compositor_state;
}
 
 
@@ -313,6 +298,19 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int 
surface_type_id,
XVMC_MSG(XVMC_TRACE, "[XvMC] Context %p created.\n", context);
 
return Success;
+
+no_compositor_state:
+   vl_compositor_cleanup(_priv->compositor);
+no_compositor:
+   context_priv->decoder->destroy(context_priv->decoder);
+no_decoder:
+   pipe->destroy(pipe);
+no_context:
+   vscreen->destroy(vscreen);
+no_screen:
+   FREE(context_priv);
+no_context_priv:
+   return BadAlloc;
 }
 
 PUBLIC
-- 
2.9.3

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


[Mesa-dev] [PATCH 4/4] st/xvmc: remove dead code

2016-12-15 Thread Nayan Deshmukh
vl_compositor_init_state always return true so we don't
need to handle false case

Signed-off-by: Nayan Deshmukh 
---
 src/gallium/state_trackers/xvmc/context.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/src/gallium/state_trackers/xvmc/context.c 
b/src/gallium/state_trackers/xvmc/context.c
index 469e1c1..4ae7d7b 100644
--- a/src/gallium/state_trackers/xvmc/context.c
+++ b/src/gallium/state_trackers/xvmc/context.c
@@ -262,11 +262,7 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int 
surface_type_id,
   goto no_compositor;
}
 
-   if (!vl_compositor_init_state(_priv->cstate, pipe)) {
-  XVMC_MSG(XVMC_ERR, "[XvMC] Could not create VL compositor state.\n");
-  goto no_compositor_state;
-   }
-
+   vl_compositor_init_state(_priv->cstate, pipe)
 
context_priv->color_standard =
   debug_get_bool_option("G3DVL_NO_CSC", FALSE) ?
@@ -299,8 +295,6 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int 
surface_type_id,
 
return Success;
 
-no_compositor_state:
-   vl_compositor_cleanup(_priv->compositor);
 no_compositor:
context_priv->decoder->destroy(context_priv->decoder);
 no_decoder:
-- 
2.9.3

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


Re: [Mesa-dev] [PATCH mesa] egl/x11: cleanup init code

2016-12-15 Thread Emil Velikov
On 13 December 2016 at 18:40, Eric Engestrom  wrote:
> On Thursday, 2016-12-08 20:17:21 +, Emil Velikov wrote:
>> On 8 December 2016 at 00:30, Eric Engestrom  wrote:
>> > No functional change, just rewriting it in an easier-to-understand way.
>> >
>> I might be mislead by the diff, but it seems that there's functionality 
>> change.
>
> Diffs are not always the easiest to read, let's see if code and english
> work better :)
>
>>
>> > Signed-off-by: Eric Engestrom 
>> > ---
>> >  src/egl/drivers/dri2/platform_x11.c | 24 ++--
>> >  1 file changed, 10 insertions(+), 14 deletions(-)
>> >
>> > diff --git a/src/egl/drivers/dri2/platform_x11.c 
>> > b/src/egl/drivers/dri2/platform_x11.c
>> > index df39ca8..db7d3b9 100644
>> > --- a/src/egl/drivers/dri2/platform_x11.c
>> > +++ b/src/egl/drivers/dri2/platform_x11.c
>> > @@ -1467,24 +1467,20 @@ dri2_initialize_x11_dri2(_EGLDriver *drv, 
>> > _EGLDisplay *disp)
>> >  EGLBoolean
>> >  dri2_initialize_x11(_EGLDriver *drv, _EGLDisplay *disp)
>> >  {
>> > -   EGLBoolean initialized = EGL_TRUE;
>> > +   EGLBoolean initialized = EGL_FALSE;
>> >
>> > -   int x11_dri2_accel = (getenv("LIBGL_ALWAYS_SOFTWARE") == NULL);
>> > -
>> > -   if (x11_dri2_accel) {
>> > +   if (!getenv("LIBGL_ALWAYS_SOFTWARE")) {
>> >  #ifdef HAVE_DRI3
>> > -  if (getenv("LIBGL_DRI3_DISABLE") != NULL ||
>> > -  !dri2_initialize_x11_dri3(drv, disp)) {
>> > +  if (!getenv("LIBGL_DRI3_DISABLE"))
>> > + initialized = dri2_initialize_x11_dri3(drv, disp);
>> >  #endif
>> > +
>> > +  if (!initialized)
>> > - if (!dri2_initialize_x11_dri2(drv, disp)) {
>> > + initialized = dri2_initialize_x11_dri2(drv, disp);
>> > -initialized = dri2_initialize_x11_swrast(drv, disp);
>> > - }
>> > -#ifdef HAVE_DRI3
>> > -  }
>> > -#endif
>> > -   } else {
>> > +   }
>> > +
>> > +   if (!initialized)
>> Namely here: by dropping the else, we fall-back to swrast if dri3/dri2 fails.
>
> The current code looks like this:
>
> EGLBoolean
> dri2_initialize_x11(_EGLDriver *drv, _EGLDisplay *disp)
> {
>EGLBoolean initialized = EGL_TRUE;
>
>int x11_dri2_accel = (getenv("LIBGL_ALWAYS_SOFTWARE") == NULL);
>
>if (x11_dri2_accel) {
> #ifdef HAVE_DRI3
>   if (getenv("LIBGL_DRI3_DISABLE") != NULL ||
>   !dri2_initialize_x11_dri3(drv, disp)) {
> #endif
>  if (!dri2_initialize_x11_dri2(drv, disp)) {
> initialized = dri2_initialize_x11_swrast(drv, disp);
Seems like I've missed this line in the original code.

Thanks for the patience and correction Eric ! R-b and pushed the patch.

>> Not too sure how much we should care bth, although I have been
>> wondering if we should not start honouring
>> _egl_display::Options::UseFallback.
>
> I didn't know about that option. The way I understand its usage, this
> would mean changing the last `if` (the swrast one) to:
> if (!initialized && disp->Options.UseFallback)
>
> Is that correct?
>
I think it should be something like

if (UseFallback)
   return init_swrast();

if (!getenv(DRI3_DISABLE)
  initialized = init_dri3();

if (!initialized)
  initialized = init_dri2();

return initialized;

> Although if I understand [1] correctly, the only effect this would have
> would be to always call init() once for dri3 then dri2, then if that
> failed dri3 again, dri2 again and then swrast...
>
> (I could also have the first `if` include a `!disp->Options.UseFallback`
> if that helps.)
>
With my understanding (above) one will get direct, explicit control
and relation between the main code and the backend.

At the same time not sure how much one should care, so...
Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 99055] Games hang / freeze completely

2016-12-15 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=99055

--- Comment #19 from Eero Tamminen  ---
There are also few other libraries which too old versions can cause problems. 
E.g. some X ones, if you're using DRI3.  Could you attach the list of libraries
used by your game?

You can find out the DRI version with:
  LIBGL_DEBUG=verbose glxgears

It will print out whether DRI2 or DRI3 is used.  If it's DRI3, try running
steam with:
LIBGL_DRI3_DISABLE=1 steam

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


[Mesa-dev] [Bug 99055] Games hang / freeze completely

2016-12-15 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=99055

--- Comment #18 from Etienne Bruines  ---
It turns out to be using this library (and nothing that shipped with it) :
/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22

The libraries in use are all part of the distro.

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


Re: [Mesa-dev] [PATCH] Mesa: Return GL error INVALID_OPERATION in case invalid format/type

2016-12-15 Thread Emil Velikov
On 15 December 2016 at 01:10, Randy Xu  wrote:
> From: "Xu,Randy" 
>
> Refer to GLES3.2 spec in 8.5
> Textures with a base internal format of DEPTH_COMPONENT, DEPTH_-
> STENCIL or STENCIL_INDEX are supported by texture image specification
> commands only if target is TEXTURE_2D, TEXTURE_2D_MULTISAMPLE,
> TEXTURE_2D_ARRAY, TEXTURE_2D_MULTISAMPLE_ARRAY, TEXTURE_CUBE_-
> MAP or TEXTURE_CUBE_MAP_ARRAY. Using these formats in conjunction with
> any other target will result in an INVALID_OPERATION error.
> This patch can fix dEQP-GLES3.functional.negative_api.texture.teximage3d
> failure.
>
I think others have alluded it with referencing other commits, but it
might have been too subtle.
 - please use the cannonical format [1] to add a spec quote in the code
 - your commit message should explain why rather than a simple spec quote.
You can draw some inspirations from 19f13b2096a9fdd986e5a12d4e9d8b0d6a4632f3

> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=99076
>
Nit: s/Bug/Bugzilla/

Please also add the following so we get this in the stable release.
Cc: "13.0" 

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


[Mesa-dev] Problem using GLVND enabled mesa with Intel DDX

2016-12-15 Thread Yu, Qiang

Hi guys,

I'm trying GLVND with mesa, but the Intel DDX seems have some problem with it:
[  2970.834] (EE) AIGLX error: dlopen of 
/usr/lib/x86_64-linux-gnu/dri/i965_dri.so failed 
(/usr/lib/x86_64-linux-gnu/dri/i965_dri.so: undefined symbol: 
_glapi_tls_Dispatch)
[  2970.834] (EE) AIGLX: reverting to software rendering
[  2970.889] (EE) AIGLX error: dlopen of 
/usr/lib/x86_64-linux-gnu/dri/swrast_dri.so failed 
(/usr/lib/x86_64-linux-gnu/dri/swrast_dri.so: undefined symbol: 
_glapi_tls_Dispatch)
[  2970.889] (EE) GLX: could not load software renderer
[  2970.889] (II) GLX: no usable GL providers found for screen 0

I find the _glapi_tls_Dispatch is in libglapi.so which is depended by 
libGLX_mesa.so.
But in Intel DDX's case, no libGLX_mesa.so/libglapi.so is loaded, i965_dri.so 
is loaded directly.

Regards,
Qiang

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


Re: [Mesa-dev] [PATCH] egl: Fix crashes in eglCreate*Surface()

2016-12-15 Thread Emil Velikov
On 14 December 2016 at 20:01, Chad Versace  wrote:
> On Wed 14 Dec 2016, Emil Velikov wrote:
>> On 13 December 2016 at 22:40, Chad Versace  wrote:
>> > Don't dereference a null EGLDisplay.
>> >
>> > Fixes tests
>> >   dEQP-EGL.functional.negative_api.create_pbuffer_surface
>> >   dEQP-EGL.functional.negative_api.create_pixmap_surface
>> >
>> > Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=99038
>> > ---
>> >  src/egl/main/eglapi.c | 4 ++--
>> >  1 file changed, 2 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
>> > index 33d562042f..a349992c46 100644
>> > --- a/src/egl/main/eglapi.c
>> > +++ b/src/egl/main/eglapi.c
>> > @@ -856,7 +856,7 @@ _eglCreateWindowSurfaceCommon(_EGLDisplay *disp, 
>> > EGLConfig config,
>> >RETURN_EGL_ERROR(disp, EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE);
>> >
>> >  #ifdef HAVE_SURFACELESS_PLATFORM
>> > -   if (disp->Platform == _EGL_PLATFORM_SURFACELESS) {
>> > +   if (disp && disp->Platform == _EGL_PLATFORM_SURFACELESS) {
>> >/* From the EGL_MESA_platform_surfaceless spec (v1):
>> > *
>> > *eglCreatePlatformWindowSurface fails when called with a 
>> > 
>> > @@ -977,7 +977,7 @@ _eglCreatePixmapSurfaceCommon(_EGLDisplay *disp, 
>> > EGLConfig config,
>> > EGLSurface ret;
>> >
>> >  #if HAVE_SURFACELESS_PLATFORM
>> > -   if (disp->Platform == _EGL_PLATFORM_SURFACELESS) {
>> > +   if (disp && disp->Platform == _EGL_PLATFORM_SURFACELESS) {
>
>> Afaict we want to return EGL_FALSE + EGL_BAD_DISPLAY, right ?
>
> We do want to emit EGL_BAD_DISPLAY. And the code will do that if disp is
> null. Below my hunks is a call to _EGL_CHECK_CONFIG(disp, ...), which
> emits EGL_BAD_DISPLAY in that case.
>
You're spot on. I wasn't expecting _eglCheckConfig to call _eglCheckDisplay.
Pardon for the noise.

Reviewed-by: Emil Velikov 

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


[Mesa-dev] [Bug 99055] Games hang / freeze completely

2016-12-15 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=99055

--- Comment #17 from Eero Tamminen  ---
(In reply to Kenneth Graunke from comment #15)
> Renaming the binaries or editing scripts installed with the game is liable
> to break when new updates for the game comes out, because Steam will
> overwrite those changes.

Only very few (if any) games include their own libstdc++, so the main issue is
one included with Steam's Ubuntu 12.04 snapshot.  Does that get (ever) updated?


> (In reply to Eero Tamminen from comment #14)
> > It's harder to guarantee that the environment variable gets always passed to
> > the game, better just to rename the offending binary to be sure.
> 
> It's really easy, actually, you just right click on the game in Steam, hit
> properties, click the [Set Launch Options...] and enter
> 
> LD_PRELOAD='/usr/$LIB/libstdc++.so.6':$LD_PRELOAD %command%
> 
> (or whatever you want before/after %command%)

With people having more games, editing launch options for every one of them 
would be really tedious.


(In reply to Michel Dänzer from comment #16)
> Setting LD_PRELOAD when launching Steam has worked for every game I've tried
> so far. YMMV.

Good to know.  In general, it would get lost if there's any suid binary or
something sets LD_PRELOAD, but those would be really ugly things to do in
release versions.

-- 
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