Re: [Mesa-dev] [PATCH 2/5] mesa: implement GL_NVX_gpu_memory_info

2016-02-02 Thread Marek Olšák
On Tue, Feb 2, 2016 at 4:02 PM, Roland Scheidegger  wrote:
> Does anyone use these extensions?
> I suppose maybe to get the total amount of video memory?
> From the dynamic counts, I would have thought the eviction one would be
> the most interesting, but this one isn't implemented. Ah well I guess a
> sloppily implemented extension is better than none.

I know from personal experience that Unreal Engine 3 uses one of them
(or maybe both), because it crashed when I had a bug there. I've heard
the Source engine uses them too.

The use case for modern games is to support texture paging, i.e.
loading texture pages on demand based on on-screen visibility of
textures and available memory.

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


Re: [Mesa-dev] [PATCH 2/3] radeonsi: implement PK2H and UP2H opcodes

2016-02-02 Thread Marek Olšák
On Sat, Jan 30, 2016 at 12:46 AM, Marek Olšák  wrote:
> From: Marek Olšák 
>
> Based on a gallivm patch by Ilia Mirkin.
>
> +8 piglit regressions due to precision issues
> ---
>  .../drivers/radeon/radeon_setup_tgsi_llvm.c| 72 
> ++
>  src/gallium/drivers/radeonsi/si_pipe.c |  2 +-
>  2 files changed, 73 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c 
> b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
> index 76be376..d8e05ce 100644
> --- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
> +++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
> @@ -1452,6 +1452,74 @@ static void emit_minmax_int(const struct 
> lp_build_tgsi_action *action,
> emit_data->args[1], "");
>  }
>
> +static void pk2h_fetch_args(struct lp_build_tgsi_context * bld_base,
> +   struct lp_build_emit_data * emit_data)
> +{
> +   emit_data->args[0] = lp_build_emit_fetch(bld_base, emit_data->inst,
> +0, TGSI_CHAN_X);
> +   emit_data->args[1] = lp_build_emit_fetch(bld_base, emit_data->inst,
> +0, TGSI_CHAN_Y);
> +}
> +
> +static void emit_pk2h(const struct lp_build_tgsi_action *action,
> + struct lp_build_tgsi_context *bld_base,
> + struct lp_build_emit_data *emit_data)
> +{
> +   LLVMBuilderRef builder = bld_base->base.gallivm->builder;
> +   LLVMContextRef context = bld_base->base.gallivm->context;
> +   struct lp_build_context *uint_bld = _base->uint_bld;
> +   LLVMTypeRef fp16, i16;
> +   LLVMValueRef const16, comp[2];
> +   unsigned i;
> +
> +   fp16 = LLVMHalfTypeInContext(context);
> +   i16 = LLVMInt16TypeInContext(context);
> +   const16 = lp_build_const_int32(uint_bld->gallivm, 16);
> +
> +   for (i = 0; i < 2; i++) {
> +   comp[i] = LLVMBuildFPTrunc(builder, emit_data->args[i], fp16, 
> "");
> +   comp[i] = LLVMBuildBitCast(builder, comp[i], i16, "");
> +   comp[i] = LLVMBuildZExt(builder, comp[i], 
> uint_bld->elem_type, "");
> +   }
> +
> +   comp[1] = LLVMBuildShl(builder, comp[1], const16, "");
> +   comp[0] = LLVMBuildOr(builder, comp[0], comp[1], "");
> +
> +   emit_data->output[emit_data->chan] = comp[0];
> +}
> +
> +static void up2h_fetch_args(struct lp_build_tgsi_context * bld_base,
> +   struct lp_build_emit_data * emit_data)
> +{
> +   emit_data->args[0] = lp_build_emit_fetch(bld_base, emit_data->inst,
> +0, TGSI_CHAN_X);
> +}
> +
> +static void emit_up2h(const struct lp_build_tgsi_action *action,
> + struct lp_build_tgsi_context *bld_base,
> + struct lp_build_emit_data *emit_data)
> +{
> +   LLVMBuilderRef builder = bld_base->base.gallivm->builder;
> +   LLVMContextRef context = bld_base->base.gallivm->context;
> +   struct lp_build_context *uint_bld = _base->uint_bld;
> +   LLVMTypeRef fp16, i16;
> +   LLVMValueRef const16, input, val;
> +   unsigned i;
> +
> +   fp16 = LLVMHalfTypeInContext(context);
> +   i16 = LLVMInt16TypeInContext(context);
> +   const16 = lp_build_const_int32(uint_bld->gallivm, 16);
> +   input = emit_data->args[0];
> +
> +   for (i = 0; i < 2; i++) {
> +   val = i == 1 ? LLVMBuildLShr(builder, input, const16, "") : 
> input;
> +   val = LLVMBuildTrunc(builder, val, i16, "");
> +   val = LLVMBuildBitCast(builder, val, fp16, "");
> +   emit_data->output[i] =
> +   LLVMBuildFPExt(builder, val, 
> bld_base->base.elem_type, "");
> +   }
> +}
> +
>  void radeon_llvm_context_init(struct radeon_llvm_context * ctx)
>  {
> struct lp_type type;
> @@ -1581,6 +1649,8 @@ void radeon_llvm_context_init(struct 
> radeon_llvm_context * ctx)
> bld_base->op_actions[TGSI_OPCODE_UMSB].emit = emit_umsb;
> bld_base->op_actions[TGSI_OPCODE_NOT].emit = emit_not;
> bld_base->op_actions[TGSI_OPCODE_OR].emit = emit_or;
> +   bld_base->op_actions[TGSI_OPCODE_PK2H].fetch_args = pk2h_fetch_args;
> +   bld_base->op_actions[TGSI_OPCODE_PK2H].emit = emit_pk2h;
> bld_base->op_actions[TGSI_OPCODE_POPC].emit = 
> build_tgsi_intrinsic_nomem;
> bld_base->op_actions[TGSI_OPCODE_POPC].intr_name = "llvm.ctpop.i32";
> bld_base->op_actions[TGSI_OPCODE_POW].emit = 
> build_tgsi_intrinsic_nomem;
> @@ -1618,6 +1688,8 @@ void radeon_llvm_context_init(struct 
> radeon_llvm_context * ctx)
> bld_base->op_actions[TGSI_OPCODE_U2F].emit = emit_u2f;
> bld_base->op_actions[TGSI_OPCODE_XOR].emit = emit_xor;
> bld_base->op_actions[TGSI_OPCODE_UCMP].emit = emit_ucmp;
> +   

[Mesa-dev] [PATCH 08b/11] nir: passthrough-edgeflags support

2016-02-02 Thread Rob Clark
From: Rob Clark 

Handled by tgsi_emulate for glsl->tgsi case.

Signed-off-by: Rob Clark 
---
 src/compiler/Makefile.sources  |  1 +
 src/compiler/nir/nir.h |  2 +
 src/compiler/nir/nir_lower_passthrough_edgeflags.c | 86 ++
 3 files changed, 89 insertions(+)
 create mode 100644 src/compiler/nir/nir_lower_passthrough_edgeflags.c

diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources
index e85cde5..e493ab0 100644
--- a/src/compiler/Makefile.sources
+++ b/src/compiler/Makefile.sources
@@ -194,6 +194,7 @@ NIR_FILES = \
nir/nir_lower_idiv.c \
nir/nir_lower_io.c \
nir/nir_lower_outputs_to_temporaries.c \
+   nir/nir_lower_passthrough_edgeflags.c \
nir/nir_lower_phis_to_scalar.c \
nir/nir_lower_samplers.c \
nir/nir_lower_system_values.c \
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index dc31a67..6601346 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2121,6 +2121,8 @@ void nir_lower_two_sided_color(nir_shader *shader);
 
 void nir_lower_clamp_color_outputs(nir_shader *shader);
 
+void nir_lower_passthrough_edgeflags(nir_shader *shader);
+
 typedef struct nir_lower_wpos_ytransform_options {
int state_tokens[5];
bool fs_coord_origin_upper_left :1;
diff --git a/src/compiler/nir/nir_lower_passthrough_edgeflags.c 
b/src/compiler/nir/nir_lower_passthrough_edgeflags.c
new file mode 100644
index 000..6476c80
--- /dev/null
+++ b/src/compiler/nir/nir_lower_passthrough_edgeflags.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright © 2015 Red Hat
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
THE
+ * SOFTWARE.
+ */
+
+#include "nir.h"
+#include "nir_builder.h"
+
+typedef struct {
+   nir_shader *shader;
+   nir_builder b;
+   bool emitted;
+   nir_variable *in, *out;
+} lower_state;
+
+static nir_variable *
+create_edgeflag_var(nir_shader *shader, bool output)
+{
+   nir_variable_mode mode = output ? nir_var_shader_out : nir_var_shader_in;
+   nir_variable *var = nir_variable_create(shader, mode, glsl_vec4_type(),
+   output ? "edgeflag_out" : 
"edgeflag_in");
+   var->data.location = output ? VARYING_SLOT_EDGE : VERT_ATTRIB_EDGEFLAG;
+   return var;
+}
+
+static bool
+lower_block(nir_block *block, void *_state)
+{
+   lower_state *state = _state;
+   nir_builder *b = >b;
+   nir_ssa_def *def;
+
+   if (!state->in)
+  state->in = create_edgeflag_var(state->shader, false);
+
+   if (!state->out)
+  state->out = create_edgeflag_var(state->shader, true);
+
+   b->cursor = nir_before_block(block);
+
+   def = nir_load_var(b, state->in);
+   nir_store_var(b, state->out, def, 0xf);
+
+   /* only do this for first block: */
+   return false;
+}
+
+static void
+lower_impl(lower_state *state, nir_function_impl *impl)
+{
+   nir_builder_init(>b, impl);
+
+   nir_foreach_block(impl, lower_block, state);
+   nir_metadata_preserve(impl, nir_metadata_block_index |
+   nir_metadata_dominance);
+}
+
+void nir_lower_passthrough_edgeflags(nir_shader *shader)
+{
+   lower_state state = {
+  .shader = shader,
+   };
+
+   nir_foreach_function(shader, function) {
+  if (function->impl)
+ lower_impl(, function->impl);
+   }
+}
-- 
2.5.0

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


Re: [Mesa-dev] [PATCH 7/7] st/mesa: enable GL image extensions when backend supports them

2016-02-02 Thread Ilia Mirkin
On Tue, Feb 2, 2016 at 2:28 PM, Marek Olšák  wrote:
> On Tue, Feb 2, 2016 at 8:16 PM, Ilia Mirkin  wrote:
>> Thanks! From discussion with Dave re r600 needs, it sounds like we
>> need to throw a "writable" property into pipe_image_view, and I need
>> to do a proper job of setting the WR flag on the image in patch 6.
>> I'll do those as add-on patches.
>>
>> Did you leave patch 6 unreviewed because you had issues with it, or
>> because it was long and touched glsl_to_tgsi?
>
> Mostly a lack of focus today and not remembering the small details of
> glsl_to_tgsi.

OK, just making sure there were no explicit issues.

>
> I don't think r600 needs changes as long as it can analyze TGSI for
> store instructions.

Well, Dave was saying that he might want to use texturing for
read-only images, in which case it'd be convenient to know at
set_shader_images() time as well (or, well when writing that state
out). And you'd want to generate different shader code depending on
its read-only-ness.

Anyways, I'm perfectly happy to let you and Dave fight it out :)

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


Re: [Mesa-dev] [PATCH 0/5] NIR vectorization

2016-02-02 Thread Connor Abbott
On Mon, Feb 1, 2016 at 6:13 AM, Alejandro Piñeiro  wrote:
> While doing some code checking, I realized that nir vectorization was
> not on master, in spite my memory saying the opposite. So I searched on
> the mailing list, and I found the original series (this one). My memory
> was correct that the introduced HURT shaders was accepted as a lesser
> evil, but not the patch itself (patch 4/5 was reviewed but not updated).
>
> So an awkward ping here (as this is not my series), because even if
> Connor doesn't have time to update patch 4/5, I think that it would be
> good to push patch 1 and 2, that were reviewed but not pushed on master.
>
> BR

Whoops, sorry! I've pushed 1 and 2. It seems like I never responded to
Jason's comments :( so I'll go back and try to sort it out.

>
> On 15/11/15 03:59, Connor Abbott wrote:
>> This series adds an optimization to detect things like:
>>
>> foo.x = bar.x + baz.x;
>> foo.y = bar.y + baz.y;
>> foo.z = bar.z + baz.z;
>> foo.w = bar.w + baz.w;
>>
>> and turn them into:
>>
>> foo = bar + baz;
>>
>> which shows up distressingly often in shaders translated from D3D
>> bytecode, or by people who seemingly don't know that GLSL can do all
>> that vector-y stuff for you. There is a similar pass in GLSL IR, but it
>> can only handle operations on uniforms/inputs since it would've been too
>> difficult to handle more complicated cases. But now that we have NIR,
>> and the i965 vec4 backend uses NIR, we can write a much better pass
>> using the magic of SSA. Shader-db results are in the last patch.
>>
>> Series is also available as the 'nir-vectorize' branch of my FDO repository.
>>
>> Connor Abbott (5):
>>   util/set: don't compare against deleted entries
>>   util/hash_table: don't compare deleted entries
>>   nir/array: add a few more helpers
>>   nir: add a vectorization pass
>>   i965/nir: use vectorization for non-scalar stages
>>
>>  src/glsl/Makefile.sources   |   1 +
>>  src/glsl/nir/nir.h  |   2 +
>>  src/glsl/nir/nir_array.h|  21 ++
>>  src/glsl/nir/nir_opt_vectorize.c| 447 
>> 
>>  src/mesa/drivers/dri/i965/brw_nir.c |   8 +
>>  src/util/hash_table.c   |   3 +-
>>  src/util/set.c  |   3 +-
>>  7 files changed, 483 insertions(+), 2 deletions(-)
>>  create mode 100644 src/glsl/nir/nir_opt_vectorize.c
>>
>
> --
> Alejandro Piñeiro (apinhe...@igalia.com)
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/3] radeonsi: implement PK2H and UP2H opcodes

2016-02-02 Thread Marek Olšák
On Tue, Feb 2, 2016 at 9:23 PM, Roland Scheidegger  wrote:
> Am 02.02.2016 um 21:15 schrieb Marek Olšák:
>> On Sat, Jan 30, 2016 at 12:46 AM, Marek Olšák  wrote:
>>> From: Marek Olšák 
>>>
>>> Based on a gallivm patch by Ilia Mirkin.
>>>
>>> +8 piglit regressions due to precision issues
>>> ---
>>>  .../drivers/radeon/radeon_setup_tgsi_llvm.c| 72 
>>> ++
>>>  src/gallium/drivers/radeonsi/si_pipe.c |  2 +-
>>>  2 files changed, 73 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c 
>>> b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
>>> index 76be376..d8e05ce 100644
>>> --- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
>>> +++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
>>> @@ -1452,6 +1452,74 @@ static void emit_minmax_int(const struct 
>>> lp_build_tgsi_action *action,
>>> emit_data->args[1], "");
>>>  }
>>>
>>> +static void pk2h_fetch_args(struct lp_build_tgsi_context * bld_base,
>>> +   struct lp_build_emit_data * emit_data)
>>> +{
>>> +   emit_data->args[0] = lp_build_emit_fetch(bld_base, emit_data->inst,
>>> +0, TGSI_CHAN_X);
>>> +   emit_data->args[1] = lp_build_emit_fetch(bld_base, emit_data->inst,
>>> +0, TGSI_CHAN_Y);
>>> +}
>>> +
>>> +static void emit_pk2h(const struct lp_build_tgsi_action *action,
>>> + struct lp_build_tgsi_context *bld_base,
>>> + struct lp_build_emit_data *emit_data)
>>> +{
>>> +   LLVMBuilderRef builder = bld_base->base.gallivm->builder;
>>> +   LLVMContextRef context = bld_base->base.gallivm->context;
>>> +   struct lp_build_context *uint_bld = _base->uint_bld;
>>> +   LLVMTypeRef fp16, i16;
>>> +   LLVMValueRef const16, comp[2];
>>> +   unsigned i;
>>> +
>>> +   fp16 = LLVMHalfTypeInContext(context);
>>> +   i16 = LLVMInt16TypeInContext(context);
>>> +   const16 = lp_build_const_int32(uint_bld->gallivm, 16);
>>> +
>>> +   for (i = 0; i < 2; i++) {
>>> +   comp[i] = LLVMBuildFPTrunc(builder, emit_data->args[i], 
>>> fp16, "");
>>> +   comp[i] = LLVMBuildBitCast(builder, comp[i], i16, "");
>>> +   comp[i] = LLVMBuildZExt(builder, comp[i], 
>>> uint_bld->elem_type, "");
>>> +   }
>>> +
>>> +   comp[1] = LLVMBuildShl(builder, comp[1], const16, "");
>>> +   comp[0] = LLVMBuildOr(builder, comp[0], comp[1], "");
>>> +
>>> +   emit_data->output[emit_data->chan] = comp[0];
>>> +}
>>> +
>>> +static void up2h_fetch_args(struct lp_build_tgsi_context * bld_base,
>>> +   struct lp_build_emit_data * emit_data)
>>> +{
>>> +   emit_data->args[0] = lp_build_emit_fetch(bld_base, emit_data->inst,
>>> +0, TGSI_CHAN_X);
>>> +}
>>> +
>>> +static void emit_up2h(const struct lp_build_tgsi_action *action,
>>> + struct lp_build_tgsi_context *bld_base,
>>> + struct lp_build_emit_data *emit_data)
>>> +{
>>> +   LLVMBuilderRef builder = bld_base->base.gallivm->builder;
>>> +   LLVMContextRef context = bld_base->base.gallivm->context;
>>> +   struct lp_build_context *uint_bld = _base->uint_bld;
>>> +   LLVMTypeRef fp16, i16;
>>> +   LLVMValueRef const16, input, val;
>>> +   unsigned i;
>>> +
>>> +   fp16 = LLVMHalfTypeInContext(context);
>>> +   i16 = LLVMInt16TypeInContext(context);
>>> +   const16 = lp_build_const_int32(uint_bld->gallivm, 16);
>>> +   input = emit_data->args[0];
>>> +
>>> +   for (i = 0; i < 2; i++) {
>>> +   val = i == 1 ? LLVMBuildLShr(builder, input, const16, "") : 
>>> input;
>>> +   val = LLVMBuildTrunc(builder, val, i16, "");
>>> +   val = LLVMBuildBitCast(builder, val, fp16, "");
>>> +   emit_data->output[i] =
>>> +   LLVMBuildFPExt(builder, val, 
>>> bld_base->base.elem_type, "");
>>> +   }
>>> +}
>>> +
>>>  void radeon_llvm_context_init(struct radeon_llvm_context * ctx)
>>>  {
>>> struct lp_type type;
>>> @@ -1581,6 +1649,8 @@ void radeon_llvm_context_init(struct 
>>> radeon_llvm_context * ctx)
>>> bld_base->op_actions[TGSI_OPCODE_UMSB].emit = emit_umsb;
>>> bld_base->op_actions[TGSI_OPCODE_NOT].emit = emit_not;
>>> bld_base->op_actions[TGSI_OPCODE_OR].emit = emit_or;
>>> +   bld_base->op_actions[TGSI_OPCODE_PK2H].fetch_args = pk2h_fetch_args;
>>> +   bld_base->op_actions[TGSI_OPCODE_PK2H].emit = emit_pk2h;
>>> bld_base->op_actions[TGSI_OPCODE_POPC].emit = 
>>> build_tgsi_intrinsic_nomem;
>>> bld_base->op_actions[TGSI_OPCODE_POPC].intr_name = "llvm.ctpop.i32";
>>> bld_base->op_actions[TGSI_OPCODE_POW].emit = 
>>> 

[Mesa-dev] [PATCH 08a/11] nir: clamp-color-output support

2016-02-02 Thread Rob Clark
From: Rob Clark 

Handled by tgsi_emulate for glsl->tgsi case.

Signed-off-by: Rob Clark 
---
 src/compiler/Makefile.sources|   1 +
 src/compiler/nir/nir.h   |   1 +
 src/compiler/nir/nir_lower_clamp_color_outputs.c | 121 +++
 3 files changed, 123 insertions(+)
 create mode 100644 src/compiler/nir/nir_lower_clamp_color_outputs.c

diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources
index d859493..e85cde5 100644
--- a/src/compiler/Makefile.sources
+++ b/src/compiler/Makefile.sources
@@ -184,6 +184,7 @@ NIR_FILES = \
nir/nir_lower_alu_to_scalar.c \
nir/nir_lower_atomics.c \
nir/nir_lower_bitmap.c \
+   nir/nir_lower_clamp_color_outputs.c \
nir/nir_lower_clip.c \
nir/nir_lower_drawpixels.c \
nir/nir_lower_global_vars_to_local.c \
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 29c8631..dc31a67 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -2119,6 +2119,7 @@ void nir_lower_clip_fs(nir_shader *shader, unsigned 
ucp_enables);
 
 void nir_lower_two_sided_color(nir_shader *shader);
 
+void nir_lower_clamp_color_outputs(nir_shader *shader);
 
 typedef struct nir_lower_wpos_ytransform_options {
int state_tokens[5];
diff --git a/src/compiler/nir/nir_lower_clamp_color_outputs.c 
b/src/compiler/nir/nir_lower_clamp_color_outputs.c
new file mode 100644
index 000..0e1add0
--- /dev/null
+++ b/src/compiler/nir/nir_lower_clamp_color_outputs.c
@@ -0,0 +1,121 @@
+/*
+ * Copyright © 2015 Red Hat
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
THE
+ * SOFTWARE.
+ */
+
+
+#include "nir.h"
+#include "nir_builder.h"
+
+typedef struct {
+   nir_shader *shader;
+   nir_builder b;
+} lower_state;
+
+static bool
+is_color_output(lower_state *state, nir_variable *out)
+{
+   switch (state->shader->stage) {
+   case MESA_SHADER_VERTEX:
+   case MESA_SHADER_GEOMETRY:
+  switch (out->data.location) {
+  case VARYING_SLOT_COL0:
+  case VARYING_SLOT_COL1:
+  case VARYING_SLOT_BFC0:
+  case VARYING_SLOT_BFC1:
+ return true;
+  default:
+ return false;
+  }
+  break;
+   case MESA_SHADER_FRAGMENT:
+  switch (out->data.location) {
+  case FRAG_RESULT_COLOR:
+ return true;
+  default:
+ return false;
+  }
+  break;
+   default:
+  return false;
+   }
+}
+
+static void
+lower_intrinsic(lower_state *state, nir_intrinsic_instr *intr)
+{
+   nir_variable *out;
+   nir_builder *b = >b;
+   nir_ssa_def *s;
+
+   if (intr->intrinsic != nir_intrinsic_store_var)
+  return;
+
+   out = intr->variables[0]->var;
+
+   if (out->data.mode != nir_var_shader_out)
+  return;
+
+   /* NOTE: 'out' can be null for types larger than vec4,
+* but these will never be color out's so we can ignore
+*/
+
+   if (out && is_color_output(state, out)) {
+  b->cursor = nir_before_instr(>instr);
+  s = nir_ssa_for_src(b, intr->src[0], intr->num_components);
+  s = nir_fsat(b, s);
+  nir_instr_rewrite_src(>instr, >src[0], nir_src_for_ssa(s));
+   }
+}
+
+static bool
+lower_block(nir_block *block, void *_state)
+{
+   lower_state *state = _state;
+
+   nir_foreach_instr_safe(block, instr) {
+  if (instr->type == nir_instr_type_intrinsic)
+ lower_intrinsic(state, nir_instr_as_intrinsic(instr));
+   }
+
+   return true;
+}
+static void
+lower_impl(lower_state *state, nir_function_impl *impl)
+{
+   nir_builder_init(>b, impl);
+
+   nir_foreach_block(impl, lower_block, state);
+   nir_metadata_preserve(impl, nir_metadata_block_index |
+   nir_metadata_dominance);
+}
+
+void nir_lower_clamp_color_outputs(nir_shader *shader)
+{
+   lower_state state = {
+  .shader = shader,
+   };
+
+   nir_foreach_function(shader, function) {
+  if 

Re: [Mesa-dev] [PATCH 3/3] mesa: invalidate framebuffer when changing parameters

2016-02-02 Thread Marek Olšák
For the series:

Reviewed-by: Marek Olšák 

Marek

On Sun, Jan 31, 2016 at 6:58 AM, Ilia Mirkin  wrote:
> This fixes dEQP-GLES31.functional.fbo.completeness.no_attachments
>
> When the width or height are 0, the framebuffer is incomplete. We may
> also not have been passing the new state down to the driver when the
> widths/heights/etc changed. Make sure to dirty the state so that the
> framebuffer state is revalidated at draw time.
>
> Signed-off-by: Ilia Mirkin 
> ---
>
>  src/mesa/main/fbobject.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
> index 3be216d..2d4acb3 100644
> --- a/src/mesa/main/fbobject.c
> +++ b/src/mesa/main/fbobject.c
> @@ -1414,6 +1414,9 @@ framebuffer_parameteri(struct gl_context *ctx, struct 
> gl_framebuffer *fb,
>_mesa_error(ctx, GL_INVALID_ENUM,
>"%s(pname=0x%x)", func, pname);
> }
> +
> +   invalidate_framebuffer(fb);
> +   ctx->NewState |= _NEW_BUFFERS;
>  }
>
>  void GLAPIENTRY
> --
> 2.4.10
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 3/3] llvmpipe: drop scissor planes early if the tri is fully inside them

2016-02-02 Thread Roland Scheidegger
Am 02.02.2016 um 13:32 schrieb Jose Fonseca:
> On 01/02/16 01:00, srol...@vmware.com wrote:
>> From: Roland Scheidegger 
>>
>> If the tri is fully inside a scissor edge (or rather, we just use the
>> bounding box of the tri for the comparison), then we can drop these
>> additional scissor "planes" early. We do not even need to allocate
>> space for them in the tri.
>> The math actually appears to be slightly iffy due to bounding boxes
>> being rounded, but it doesn't matter in the end.
>> Those scissor rects are costly - the 4 planes from the scissor are
>> already more expensive to calculate than the 3 planes from the tri
>> itself,
>> and it also prevents us from using the specialized raster code for small
>> tris.
>> This helps openarena performance by about 8% or so. Of course, it helps
>> there that while openarena often enables scissoring (and even moves the
>> scissor rect around) I have not seen a single tri actually hit the
>> scissor rect, ever.
>>
>> v2: drop individual scissor edges, and do it earlier, not even allocating
>> space for them.
>> ---
>>   src/gallium/drivers/llvmpipe/lp_rast_tri.c   | 16 +
>>   src/gallium/drivers/llvmpipe/lp_setup_line.c | 81
>> ++-
>>   src/gallium/drivers/llvmpipe/lp_setup_tri.c  | 98
>> +---
>>   3 files changed, 126 insertions(+), 69 deletions(-)
>>
>> diff --git a/src/gallium/drivers/llvmpipe/lp_rast_tri.c
>> b/src/gallium/drivers/llvmpipe/lp_rast_tri.c
>> index f4a2f02..bf27900 100644
>> --- a/src/gallium/drivers/llvmpipe/lp_rast_tri.c
>> +++ b/src/gallium/drivers/llvmpipe/lp_rast_tri.c
>> @@ -380,11 +380,27 @@ lp_rast_triangle_32_3_4(struct
>> lp_rasterizer_task *task,
>>   */
>>  dcdx = _mm_sub_epi32(zero, dcdx);
>>
>> +#if 0
>> +   {
>> +   __m128i lbits, fixup, xy, dcdxdy, dcdx16;
>> +   lbits = _mm_and_si128(c, _mm_set1_epi32(FIXED_ONE - 1));
>> +   fixup = _mm_cmpeq_epi32(lbits, _mm_setzero_si128());
>> +   c = _mm_srai_epi32(c, 8);
>> +   c = _mm_add_epi32(c, fixup);
>> +   xy = _mm_set1_epi32(x | y << 16);
>> +   dcdx = _mm_srai_epi32(dcdx, 8);
>> +   dcdy = _mm_srai_epi32(dcdy, 8);
>> +   dcdx16 = _mm_and_si128(_mm_set_epi16(0,-1,0,-1,0,-1,0,-1), dcdx);
>> +   dcdxdy = _mm_or_si128(dcdx16, _mm_slli_epi32(dcdy, 16));
>> +   c = _mm_add_epi32(c, _mm_madd_epi16(dcdxdy, xy));
>> +   }
>> +#else
>>  c = _mm_add_epi32(c, mm_mullo_epi32(dcdx, _mm_set1_epi32(x)));
>>  c = _mm_add_epi32(c, mm_mullo_epi32(dcdy, _mm_set1_epi32(y)));
>>
>>  /* Adjust so we can just check the sign bit (< 0 comparison),
>> instead of having to do a less efficient <= 0 comparison */
>>  c = _mm_sub_epi32(c, _mm_set1_epi32(1));
>> +#endif
>>
>>  dcdx2 = _mm_add_epi32(dcdx, dcdx);
>>  dcdx3 = _mm_add_epi32(dcdx2, dcdx);
>> diff --git a/src/gallium/drivers/llvmpipe/lp_setup_line.c
>> b/src/gallium/drivers/llvmpipe/lp_setup_line.c
>> index f425825..3ec9ac4 100644
>> --- a/src/gallium/drivers/llvmpipe/lp_setup_line.c
>> +++ b/src/gallium/drivers/llvmpipe/lp_setup_line.c
>> @@ -336,13 +336,6 @@ try_setup_line( struct lp_setup_context *setup,
>> layer = MIN2(layer, scene->fb_max_layer);
>>  }
>>
>> -   if (setup->scissor_test) {
>> -  nr_planes = 8;
>> -   }
>> -   else {
>> -  nr_planes = 4;
>> -   }
>> -
>>  dx = v1[0][0] - v2[0][0];
>>  dy = v1[0][1] - v2[0][1];
>>  area = (dx * dx  + dy * dy);
>> @@ -591,6 +584,20 @@ try_setup_line( struct lp_setup_context *setup,
>>  bbox.x0 = MAX2(bbox.x0, 0);
>>  bbox.y0 = MAX2(bbox.y0, 0);
>>
>> +   nr_planes = 4;
>> +   /*
>> +* Determine how many scissor planes we need, that is drop scissor
>> +* edges if the bounding box of the tri is fully inside that edge.
>> +*/
>> +   if (setup->scissor_test) {
>> +  /* why not just use draw_regions */
>> +  struct u_rect *scissor = >scissors[viewport_index];
> 
> 
> Please use 4 bools:
> 
>   bool scissor_left = bbox.x0 < scissor->x0;
> 
> and reused them below.
> 
> I'm concern we could use >= for some of these -- though it might depend
> on the current rasterization rules.
I think it should be ok. We already have adjusted the bounding box for
the tri depending on rasterization rules so this shouldn't matter
anymore. But yes, the math is a bit non-obvious with the rounded
bounding box of the tri (I'd guess with msaa we'd definitely need
something better, but that would be true elsewhere too).

> 
> Anyway, using bools ensure these conditions stay in sync with the code
> bloew.
I already submitted this yesterday after incorporating Brian's feedback.
Those suggestions were actually incompatible with yours, you can have
either faster or nicer code here ;-).


> Maybe an even better alternative is have a "needed_scissor_planes"
> helper function that gets used every where.
I'm going to push something along these lines, making it nicer ;-)

Roland


> 
> 
> 
>> +  if (bbox.x0 < scissor->x0) nr_planes++;
>> +  if (bbox.x1 > scissor->x1) 

Re: [Mesa-dev] [PATCH 2/5] mesa: implement GL_NVX_gpu_memory_info

2016-02-02 Thread Roland Scheidegger
Am 02.02.2016 um 20:41 schrieb Marek Olšák:
> On Tue, Feb 2, 2016 at 4:02 PM, Roland Scheidegger  wrote:
>> Does anyone use these extensions?
>> I suppose maybe to get the total amount of video memory?
>> From the dynamic counts, I would have thought the eviction one would be
>> the most interesting, but this one isn't implemented. Ah well I guess a
>> sloppily implemented extension is better than none.
> 
> I know from personal experience that Unreal Engine 3 uses one of them
> (or maybe both), because it crashed when I had a bug there. I've heard
> the Source engine uses them too.
> 
> The use case for modern games is to support texture paging, i.e.
> loading texture pages on demand based on on-screen visibility of
> textures and available memory.

But do they really use available memory or just total memory? Anyway, I
guess if it's used that's ok, I'm just not a fan of odd fringe vendor
specific extensions.

Roland

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


Re: [Mesa-dev] [PATCH 7/7] st/mesa: enable GL image extensions when backend supports them

2016-02-02 Thread Marek Olšák
On Tue, Feb 2, 2016 at 8:16 PM, Ilia Mirkin  wrote:
> Thanks! From discussion with Dave re r600 needs, it sounds like we
> need to throw a "writable" property into pipe_image_view, and I need
> to do a proper job of setting the WR flag on the image in patch 6.
> I'll do those as add-on patches.
>
> Did you leave patch 6 unreviewed because you had issues with it, or
> because it was long and touched glsl_to_tgsi?

Mostly a lack of focus today and not remembering the small details of
glsl_to_tgsi.

I don't think r600 needs changes as long as it can analyze TGSI for
store instructions.

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


[Mesa-dev] [PATCH v2 2/5] egl: Add EGL_RECORDABLE_ANDROID attribute

2016-02-02 Thread Rob Herring
This is used by Android to select an eglconfig compatible with screen
recording.

Signed-off-by: Rob Herring 
---
v2:
- Also add reporting the extension string

 src/egl/main/eglapi.c | 1 +
 src/egl/main/eglconfig.c  | 3 +++
 src/egl/main/eglconfig.h  | 2 ++
 src/egl/main/egldisplay.h | 1 +
 4 files changed, 7 insertions(+)

diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 4619855..8eb14e7 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -383,6 +383,7 @@ _eglCreateExtensionsString(_EGLDisplay *dpy)
/* Please keep these sorted alphabetically. */
_EGL_CHECK_EXTENSION(ANDROID_framebuffer_target);
_EGL_CHECK_EXTENSION(ANDROID_image_native_buffer);
+   _EGL_CHECK_EXTENSION(ANDROID_recordable);
 
_EGL_CHECK_EXTENSION(CHROMIUM_sync_control);
 
diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c
index 0e0058f..8ce4fbe 100644
--- a/src/egl/main/eglconfig.c
+++ b/src/egl/main/eglconfig.c
@@ -250,6 +250,9 @@ static const struct {
{ EGL_FRAMEBUFFER_TARGET_ANDROID, ATTRIB_TYPE_BOOLEAN,
 ATTRIB_CRITERION_EXACT,
 EGL_DONT_CARE },
+   { EGL_RECORDABLE_ANDROID,ATTRIB_TYPE_BOOLEAN,
+ATTRIB_CRITERION_EXACT,
+EGL_DONT_CARE },
 };
 
 
diff --git a/src/egl/main/eglconfig.h b/src/egl/main/eglconfig.h
index 7bdb090..22da697 100644
--- a/src/egl/main/eglconfig.h
+++ b/src/egl/main/eglconfig.h
@@ -87,6 +87,7 @@ struct _egl_config
/* extensions */
EGLint YInvertedNOK;
EGLint FramebufferTargetAndroid;
+   EGLint RecordableAndroid;
 };
 
 
@@ -135,6 +136,7 @@ _eglOffsetOfConfig(EGLint attr)
/* extensions */
ATTRIB_MAP(EGL_Y_INVERTED_NOK,YInvertedNOK);
ATTRIB_MAP(EGL_FRAMEBUFFER_TARGET_ANDROID, FramebufferTargetAndroid);
+   ATTRIB_MAP(EGL_RECORDABLE_ANDROID,RecordableAndroid);
 #undef ATTRIB_MAP
default:
   return -1;
diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index e156c79..008c467 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -92,6 +92,7 @@ struct _egl_extensions
/* Please keep these sorted alphabetically. */
EGLBoolean ANDROID_framebuffer_target;
EGLBoolean ANDROID_image_native_buffer;
+   EGLBoolean ANDROID_recordable;
 
EGLBoolean CHROMIUM_sync_control;
 
-- 
2.5.0

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


[Mesa-dev] [PATCH v2 4/5] egl: android: clean-up config attribute setting

2016-02-02 Thread Rob Herring
Pass the additional config attributes to dri2_add_config to set them
instead of open coding them. This is in preparation to add more attributes.

Signed-off-by: Rob Herring 
---
v2:
- No change

 src/egl/drivers/dri2/platform_android.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index b622b00..7d54665 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -534,12 +534,20 @@ droid_add_configs_for_visuals(_EGLDriver *drv, 
_EGLDisplay *dpy)
   { HAL_PIXEL_FORMAT_BGRA_, { 0xff, 0xff00, 0xff, 0xff00 } },
   { 0, { 0, 0, 0, 0 } }
};
+   EGLint config_attrs[] = {
+ EGL_NATIVE_VISUAL_ID,   0,
+ EGL_NATIVE_VISUAL_TYPE, 0,
+ EGL_NONE
+   };
int count, i, j;
 
count = 0;
for (i = 0; visuals[i].format; i++) {
   int format_count = 0;
 
+  config_attrs[1] = visuals[i].format;
+  config_attrs[3] = visuals[i].format;
+
   for (j = 0; dri2_dpy->driver_configs[j]; j++) {
  const EGLint surface_type = EGL_WINDOW_BIT | EGL_PBUFFER_BIT;
  struct dri2_egl_config *dri2_conf;
@@ -553,10 +561,8 @@ droid_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay 
*dpy)
 continue;
 
  dri2_conf = dri2_add_config(dpy, dri2_dpy->driver_configs[j],
-   count + 1, surface_type, NULL, visuals[i].rgba_masks);
+   count + 1, surface_type, config_attrs, visuals[i].rgba_masks);
  if (dri2_conf) {
-dri2_conf->base.NativeVisualID = visuals[i].format;
-dri2_conf->base.NativeVisualType = visuals[i].format;
 count++;
 format_count++;
  }
-- 
2.5.0

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


[Mesa-dev] [PATCH v2 1/5] egl: Add EGL_FRAMEBUFFER_TARGET_ANDROID attribute

2016-02-02 Thread Rob Herring
This is used by Android to select an eglconfig compatible with HWComposer.

Signed-off-by: Rob Herring 
---
v2:
- Also add reporting the extension string

 src/egl/main/eglapi.c | 1 +
 src/egl/main/eglconfig.c  | 5 -
 src/egl/main/eglconfig.h  | 2 ++
 src/egl/main/egldisplay.h | 1 +
 4 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 323634e..4619855 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -381,6 +381,7 @@ _eglCreateExtensionsString(_EGLDisplay *dpy)
char *exts = dpy->ExtensionsString;
 
/* Please keep these sorted alphabetically. */
+   _EGL_CHECK_EXTENSION(ANDROID_framebuffer_target);
_EGL_CHECK_EXTENSION(ANDROID_image_native_buffer);
 
_EGL_CHECK_EXTENSION(CHROMIUM_sync_control);
diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c
index c445d9b..0e0058f 100644
--- a/src/egl/main/eglconfig.c
+++ b/src/egl/main/eglconfig.c
@@ -246,7 +246,10 @@ static const struct {
/* extensions */
{ EGL_Y_INVERTED_NOK,ATTRIB_TYPE_BOOLEAN,
 ATTRIB_CRITERION_EXACT,
-EGL_DONT_CARE }
+EGL_DONT_CARE },
+   { EGL_FRAMEBUFFER_TARGET_ANDROID, ATTRIB_TYPE_BOOLEAN,
+ATTRIB_CRITERION_EXACT,
+EGL_DONT_CARE },
 };
 
 
diff --git a/src/egl/main/eglconfig.h b/src/egl/main/eglconfig.h
index 84cb227..7bdb090 100644
--- a/src/egl/main/eglconfig.h
+++ b/src/egl/main/eglconfig.h
@@ -86,6 +86,7 @@ struct _egl_config
 
/* extensions */
EGLint YInvertedNOK;
+   EGLint FramebufferTargetAndroid;
 };
 
 
@@ -133,6 +134,7 @@ _eglOffsetOfConfig(EGLint attr)
ATTRIB_MAP(EGL_CONFORMANT,Conformant);
/* extensions */
ATTRIB_MAP(EGL_Y_INVERTED_NOK,YInvertedNOK);
+   ATTRIB_MAP(EGL_FRAMEBUFFER_TARGET_ANDROID, FramebufferTargetAndroid);
 #undef ATTRIB_MAP
default:
   return -1;
diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index 6c64980..e156c79 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -90,6 +90,7 @@ struct _egl_resource
 struct _egl_extensions
 {
/* Please keep these sorted alphabetically. */
+   EGLBoolean ANDROID_framebuffer_target;
EGLBoolean ANDROID_image_native_buffer;
 
EGLBoolean CHROMIUM_sync_control;
-- 
2.5.0

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


[Mesa-dev] [PATCH v2 5/5] egl: android: enable EGL_FRAMEBUFFER_TARGET_ANDROID and EGL_RECORDABLE_ANDROID

2016-02-02 Thread Rob Herring
Set EGL_FRAMEBUFFER_TARGET_ANDROID and EGL_RECORDABLE_ANDROID config
attributes to true for Android. These are required in Marshmallow.

The implementation of EGL_RECORDABLE_ANDROID support has 2 options in
the definition of the extension. Android implements the 2nd option
which is the encoder must support RGB input. The requested input format
is RGB888, so setting the attribute on all the native Android visual
formats should be sufficient.

Similarly, setting EGL_FRAMEBUFFER_TARGET_ANDROID for all configs with
a EGL_NATIVE_VISUAL_ID should be sufficient. Most likely, the HWC should
support the same set of formats the underlying DRM driver supports.

Signed-off-by: Rob Herring 
---
v2:
- Enable the extensions so they are reported as supported
- Add explanation in commit msg why the implementation is sufficient

 src/egl/drivers/dri2/platform_android.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index 7d54665..41840aa 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -537,6 +537,8 @@ droid_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay 
*dpy)
EGLint config_attrs[] = {
  EGL_NATIVE_VISUAL_ID,   0,
  EGL_NATIVE_VISUAL_TYPE, 0,
+ EGL_FRAMEBUFFER_TARGET_ANDROID, EGL_TRUE,
+ EGL_RECORDABLE_ANDROID, EGL_TRUE,
  EGL_NONE
};
int count, i, j;
@@ -714,7 +716,9 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *dpy)
   goto cleanup_screen;
}
 
+   dpy->Extensions.ANDROID_framebuffer_target = EGL_TRUE;
dpy->Extensions.ANDROID_image_native_buffer = EGL_TRUE;
+   dpy->Extensions.ANDROID_recordable = EGL_TRUE;
dpy->Extensions.KHR_image_base = EGL_TRUE;
 
/* Fill vtbl last to prevent accidentally calling virtual function during
-- 
2.5.0

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


[Mesa-dev] [PATCH v2 3/5] egl: android: fix visuals declaration

2016-02-02 Thread Rob Herring
From: Varad Gautam 

Signed-off-by: Varad Gautam 
---
v2:
- No change

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

diff --git a/src/egl/drivers/dri2/platform_android.c 
b/src/egl/drivers/dri2/platform_android.c
index 8f3abcb..b622b00 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -532,7 +532,7 @@ droid_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay 
*dpy)
   { HAL_PIXEL_FORMAT_RGB_888,   { 0xff, 0xff00, 0xff, 0x0 } },
   { HAL_PIXEL_FORMAT_RGB_565,   { 0xf800, 0x7e0, 0x1f, 0x0 } },
   { HAL_PIXEL_FORMAT_BGRA_, { 0xff, 0xff00, 0xff, 0xff00 } },
-  { 0, 0, { 0, 0, 0, 0 } }
+  { 0, { 0, 0, 0, 0 } }
};
int count, i, j;
 
-- 
2.5.0

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


Re: [Mesa-dev] [PATCH 2/3] radeonsi: implement PK2H and UP2H opcodes

2016-02-02 Thread Roland Scheidegger
Am 02.02.2016 um 21:15 schrieb Marek Olšák:
> On Sat, Jan 30, 2016 at 12:46 AM, Marek Olšák  wrote:
>> From: Marek Olšák 
>>
>> Based on a gallivm patch by Ilia Mirkin.
>>
>> +8 piglit regressions due to precision issues
>> ---
>>  .../drivers/radeon/radeon_setup_tgsi_llvm.c| 72 
>> ++
>>  src/gallium/drivers/radeonsi/si_pipe.c |  2 +-
>>  2 files changed, 73 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c 
>> b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
>> index 76be376..d8e05ce 100644
>> --- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
>> +++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
>> @@ -1452,6 +1452,74 @@ static void emit_minmax_int(const struct 
>> lp_build_tgsi_action *action,
>> emit_data->args[1], "");
>>  }
>>
>> +static void pk2h_fetch_args(struct lp_build_tgsi_context * bld_base,
>> +   struct lp_build_emit_data * emit_data)
>> +{
>> +   emit_data->args[0] = lp_build_emit_fetch(bld_base, emit_data->inst,
>> +0, TGSI_CHAN_X);
>> +   emit_data->args[1] = lp_build_emit_fetch(bld_base, emit_data->inst,
>> +0, TGSI_CHAN_Y);
>> +}
>> +
>> +static void emit_pk2h(const struct lp_build_tgsi_action *action,
>> + struct lp_build_tgsi_context *bld_base,
>> + struct lp_build_emit_data *emit_data)
>> +{
>> +   LLVMBuilderRef builder = bld_base->base.gallivm->builder;
>> +   LLVMContextRef context = bld_base->base.gallivm->context;
>> +   struct lp_build_context *uint_bld = _base->uint_bld;
>> +   LLVMTypeRef fp16, i16;
>> +   LLVMValueRef const16, comp[2];
>> +   unsigned i;
>> +
>> +   fp16 = LLVMHalfTypeInContext(context);
>> +   i16 = LLVMInt16TypeInContext(context);
>> +   const16 = lp_build_const_int32(uint_bld->gallivm, 16);
>> +
>> +   for (i = 0; i < 2; i++) {
>> +   comp[i] = LLVMBuildFPTrunc(builder, emit_data->args[i], 
>> fp16, "");
>> +   comp[i] = LLVMBuildBitCast(builder, comp[i], i16, "");
>> +   comp[i] = LLVMBuildZExt(builder, comp[i], 
>> uint_bld->elem_type, "");
>> +   }
>> +
>> +   comp[1] = LLVMBuildShl(builder, comp[1], const16, "");
>> +   comp[0] = LLVMBuildOr(builder, comp[0], comp[1], "");
>> +
>> +   emit_data->output[emit_data->chan] = comp[0];
>> +}
>> +
>> +static void up2h_fetch_args(struct lp_build_tgsi_context * bld_base,
>> +   struct lp_build_emit_data * emit_data)
>> +{
>> +   emit_data->args[0] = lp_build_emit_fetch(bld_base, emit_data->inst,
>> +0, TGSI_CHAN_X);
>> +}
>> +
>> +static void emit_up2h(const struct lp_build_tgsi_action *action,
>> + struct lp_build_tgsi_context *bld_base,
>> + struct lp_build_emit_data *emit_data)
>> +{
>> +   LLVMBuilderRef builder = bld_base->base.gallivm->builder;
>> +   LLVMContextRef context = bld_base->base.gallivm->context;
>> +   struct lp_build_context *uint_bld = _base->uint_bld;
>> +   LLVMTypeRef fp16, i16;
>> +   LLVMValueRef const16, input, val;
>> +   unsigned i;
>> +
>> +   fp16 = LLVMHalfTypeInContext(context);
>> +   i16 = LLVMInt16TypeInContext(context);
>> +   const16 = lp_build_const_int32(uint_bld->gallivm, 16);
>> +   input = emit_data->args[0];
>> +
>> +   for (i = 0; i < 2; i++) {
>> +   val = i == 1 ? LLVMBuildLShr(builder, input, const16, "") : 
>> input;
>> +   val = LLVMBuildTrunc(builder, val, i16, "");
>> +   val = LLVMBuildBitCast(builder, val, fp16, "");
>> +   emit_data->output[i] =
>> +   LLVMBuildFPExt(builder, val, 
>> bld_base->base.elem_type, "");
>> +   }
>> +}
>> +
>>  void radeon_llvm_context_init(struct radeon_llvm_context * ctx)
>>  {
>> struct lp_type type;
>> @@ -1581,6 +1649,8 @@ void radeon_llvm_context_init(struct 
>> radeon_llvm_context * ctx)
>> bld_base->op_actions[TGSI_OPCODE_UMSB].emit = emit_umsb;
>> bld_base->op_actions[TGSI_OPCODE_NOT].emit = emit_not;
>> bld_base->op_actions[TGSI_OPCODE_OR].emit = emit_or;
>> +   bld_base->op_actions[TGSI_OPCODE_PK2H].fetch_args = pk2h_fetch_args;
>> +   bld_base->op_actions[TGSI_OPCODE_PK2H].emit = emit_pk2h;
>> bld_base->op_actions[TGSI_OPCODE_POPC].emit = 
>> build_tgsi_intrinsic_nomem;
>> bld_base->op_actions[TGSI_OPCODE_POPC].intr_name = "llvm.ctpop.i32";
>> bld_base->op_actions[TGSI_OPCODE_POW].emit = 
>> build_tgsi_intrinsic_nomem;
>> @@ -1618,6 +1688,8 @@ void radeon_llvm_context_init(struct 
>> radeon_llvm_context * ctx)
>> bld_base->op_actions[TGSI_OPCODE_U2F].emit = emit_u2f;
>> 

Re: [Mesa-dev] [RFCv3 05/11] nir: add lowering pass for y-transform

2016-02-02 Thread Connor Abbott
On Mon, Feb 1, 2016 at 11:48 AM, Rob Clark  wrote:
> On Mon, Feb 1, 2016 at 11:00 AM, Connor Abbott  wrote:
>> On Sun, Jan 31, 2016 at 3:16 PM, Rob Clark  wrote:
>>> From: Rob Clark 
>>>
>>> Signed-off-by: Rob Clark 
>>> ---
>>>  src/compiler/Makefile.sources|   1 +
>>>  src/compiler/nir/nir.h   |  12 +
>>>  src/compiler/nir/nir_lower_wpos_ytransform.c | 317 
>>> +++
>>>  3 files changed, 330 insertions(+)
>>>  create mode 100644 src/compiler/nir/nir_lower_wpos_ytransform.c
>>>
>>> diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources
>>> index c9780d6..26c4c65 100644
>>> --- a/src/compiler/Makefile.sources
>>> +++ b/src/compiler/Makefile.sources
>>> @@ -200,6 +200,7 @@ NIR_FILES = \
>>> nir/nir_lower_vars_to_ssa.c \
>>> nir/nir_lower_var_copies.c \
>>> nir/nir_lower_vec_to_movs.c \
>>> +   nir/nir_lower_wpos_ytransform.c \
>>> nir/nir_metadata.c \
>>> nir/nir_move_vec_src_uses_to_dest.c \
>>> nir/nir_normalize_cubemap_coords.c \
>>> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
>>> index 67fe079..a973a44 100644
>>> --- a/src/compiler/nir/nir.h
>>> +++ b/src/compiler/nir/nir.h
>>> @@ -2119,6 +2119,18 @@ void nir_lower_clip_fs(nir_shader *shader, unsigned 
>>> ucp_enables);
>>>
>>>  void nir_lower_two_sided_color(nir_shader *shader);
>>>
>>> +
>>> +typedef struct nir_lower_wpos_ytransform_options {
>>> +   int state_tokens[5];
>>
>> AFAIK the state slot stuff is only used for old assembly shaders. Why
>> are we using it here?
>
> nope, state-slots are alive and well w/ glsl for builtins, etc.  Quite
> possibly it dates back to old ARB assembly shaders.. but it is still
> the way for compiler / lowering to insert builtin params, afaict.  We
> do the same thing in other places too (like drawpix lowering).

Right, I forgot about that... sorry.

>
>>> +   bool fs_coord_origin_upper_left :1;
>>> +   bool fs_coord_origin_lower_left :1;
>>> +   bool fs_coord_pixel_center_integer :1;
>>> +   bool fs_coord_pixel_center_half_integer :1;
>>> +} nir_lower_wpos_ytransform_options;
>>> +
>>> +bool nir_lower_wpos_ytransform(nir_shader *shader,
>>> +   const nir_lower_wpos_ytransform_options 
>>> *options);
>>> +
>>>  void nir_lower_atomics(nir_shader *shader,
>>> const struct gl_shader_program *shader_program);
>>>  void nir_lower_to_source_mods(nir_shader *shader);
>>> diff --git a/src/compiler/nir/nir_lower_wpos_ytransform.c 
>>> b/src/compiler/nir/nir_lower_wpos_ytransform.c
>>> new file mode 100644
>>> index 000..89d160b
>>> --- /dev/null
>>> +++ b/src/compiler/nir/nir_lower_wpos_ytransform.c
>>> @@ -0,0 +1,317 @@
>>> +/*
>>> + * Copyright © 2015 Red Hat
>>> + *
>>> + * Permission is hereby granted, free of charge, to any person obtaining a
>>> + * copy of this software and associated documentation files (the 
>>> "Software"),
>>> + * to deal in the Software without restriction, including without 
>>> limitation
>>> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
>>> + * and/or sell copies of the Software, and to permit persons to whom the
>>> + * Software is furnished to do so, subject to the following conditions:
>>> + *
>>> + * The above copyright notice and this permission notice (including the 
>>> next
>>> + * paragraph) shall be included in all copies or substantial portions of 
>>> the
>>> + * Software.
>>> + *
>>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
>>> OR
>>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
>>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
>>> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 
>>> OTHER
>>> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
>>> FROM,
>>> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 
>>> IN THE
>>> + * SOFTWARE.
>>> + */
>>> +
>>> +#include "nir.h"
>>> +#include "nir_builder.h"
>>> +
>>> +/* Lower gl_FragCoord (and fddy) to account for driver's requested 
>>> coordinate-
>>> + * origin and pixel-center vs. shader.  If transformation is required, a
>>> + * gl_FbWposYTransform uniform is inserted (with the specified state-slots)
>>> + * and additional instructions are inserted to transform gl_FragCoord (and
>>> + * fddy src arg).
>>> + *
>>> + * This is based on the logic in emit_wpos()/emit_wpos_adjustment() in TGSI
>>> + * compiler.
>>> + *
>>> + * Run before nir_lower_io.
>>> + */
>>> +
>>> +typedef struct {
>>> +   const nir_lower_wpos_ytransform_options *options;
>>> +   nir_shader   *shader;
>>> +   nir_builder   b;
>>> +   nir_variable *transform;
>>> +} lower_wpos_ytransform_state;
>>> +
>>> +static nir_ssa_def *
>>> 

Re: [Mesa-dev] [PATCH 08b/11] nir: passthrough-edgeflags support

2016-02-02 Thread Connor Abbott
On Tue, Feb 2, 2016 at 1:07 PM, Rob Clark  wrote:
> From: Rob Clark 
>
> Handled by tgsi_emulate for glsl->tgsi case.
>
> Signed-off-by: Rob Clark 
> ---
>  src/compiler/Makefile.sources  |  1 +
>  src/compiler/nir/nir.h |  2 +
>  src/compiler/nir/nir_lower_passthrough_edgeflags.c | 86 
> ++
>  3 files changed, 89 insertions(+)
>  create mode 100644 src/compiler/nir/nir_lower_passthrough_edgeflags.c
>
> diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources
> index e85cde5..e493ab0 100644
> --- a/src/compiler/Makefile.sources
> +++ b/src/compiler/Makefile.sources
> @@ -194,6 +194,7 @@ NIR_FILES = \
> nir/nir_lower_idiv.c \
> nir/nir_lower_io.c \
> nir/nir_lower_outputs_to_temporaries.c \
> +   nir/nir_lower_passthrough_edgeflags.c \
> nir/nir_lower_phis_to_scalar.c \
> nir/nir_lower_samplers.c \
> nir/nir_lower_system_values.c \
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> index dc31a67..6601346 100644
> --- a/src/compiler/nir/nir.h
> +++ b/src/compiler/nir/nir.h
> @@ -2121,6 +2121,8 @@ void nir_lower_two_sided_color(nir_shader *shader);
>
>  void nir_lower_clamp_color_outputs(nir_shader *shader);
>
> +void nir_lower_passthrough_edgeflags(nir_shader *shader);
> +
>  typedef struct nir_lower_wpos_ytransform_options {
> int state_tokens[5];
> bool fs_coord_origin_upper_left :1;
> diff --git a/src/compiler/nir/nir_lower_passthrough_edgeflags.c 
> b/src/compiler/nir/nir_lower_passthrough_edgeflags.c
> new file mode 100644
> index 000..6476c80
> --- /dev/null
> +++ b/src/compiler/nir/nir_lower_passthrough_edgeflags.c
> @@ -0,0 +1,86 @@
> +/*
> + * Copyright © 2015 Red Hat
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
> FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
> THE
> + * SOFTWARE.
> + */
> +
> +#include "nir.h"
> +#include "nir_builder.h"
> +
> +typedef struct {
> +   nir_shader *shader;
> +   nir_builder b;
> +   bool emitted;
> +   nir_variable *in, *out;
> +} lower_state;
> +
> +static nir_variable *
> +create_edgeflag_var(nir_shader *shader, bool output)
> +{
> +   nir_variable_mode mode = output ? nir_var_shader_out : nir_var_shader_in;
> +   nir_variable *var = nir_variable_create(shader, mode, glsl_vec4_type(),
> +   output ? "edgeflag_out" : 
> "edgeflag_in");
> +   var->data.location = output ? VARYING_SLOT_EDGE : VERT_ATTRIB_EDGEFLAG;
> +   return var;
> +}
> +
> +static bool
> +lower_block(nir_block *block, void *_state)
> +{
> +   lower_state *state = _state;
> +   nir_builder *b = >b;
> +   nir_ssa_def *def;
> +
> +   if (!state->in)
> +  state->in = create_edgeflag_var(state->shader, false);
> +
> +   if (!state->out)
> +  state->out = create_edgeflag_var(state->shader, true);

You know that this code is going to be run exactly once, so why not do
it in nir_lower_passthrough_edgeflags()? Also, once you do that, you
can probably just inline create_edgeflag_var(), since splitting it
into a separate function probably doesn't help you much.

> +
> +   b->cursor = nir_before_block(block);
> +
> +   def = nir_load_var(b, state->in);
> +   nir_store_var(b, state->out, def, 0xf);
> +
> +   /* only do this for first block: */
> +   return false;
> +}
> +
> +static void
> +lower_impl(lower_state *state, nir_function_impl *impl)
> +{
> +   nir_builder_init(>b, impl);
> +
> +   nir_foreach_block(impl, lower_block, state);
> +   nir_metadata_preserve(impl, nir_metadata_block_index |
> +   nir_metadata_dominance);
> +}
> +
> +void nir_lower_passthrough_edgeflags(nir_shader *shader)
> +{
> +   lower_state state = {
> +  .shader = shader,
> +   };
> +
> +   nir_foreach_function(shader, function) {
> +  if (function->impl)

Just to future proof this 

Re: [Mesa-dev] [PATCH 7/7] st/mesa: enable GL image extensions when backend supports them

2016-02-02 Thread Ilia Mirkin
Thanks! From discussion with Dave re r600 needs, it sounds like we
need to throw a "writable" property into pipe_image_view, and I need
to do a proper job of setting the WR flag on the image in patch 6.
I'll do those as add-on patches.

Did you leave patch 6 unreviewed because you had issues with it, or
because it was long and touched glsl_to_tgsi?

On Tue, Feb 2, 2016 at 2:08 PM, Marek Olšák  wrote:
> Patches 1-5, 7:
>
> Reviewed-by: Marek Olšák 
>
> Marek
>
> On Sun, Jan 31, 2016 at 2:55 AM, Ilia Mirkin  wrote:
>> This enables ARB_shader_image_load_store and ARB_shader_image_size when
>> the backend claims support for these. It will also implicitly enable the
>> image component of ARB_shader_texture_image_samples.
>>
>> Signed-off-by: Ilia Mirkin 
>> ---
>>  src/mesa/state_tracker/st_extensions.c | 16 
>>  1 file changed, 16 insertions(+)
>>
>> diff --git a/src/mesa/state_tracker/st_extensions.c 
>> b/src/mesa/state_tracker/st_extensions.c
>> index d066784..f0fee88 100644
>> --- a/src/mesa/state_tracker/st_extensions.c
>> +++ b/src/mesa/state_tracker/st_extensions.c
>> @@ -223,6 +223,9 @@ void st_init_limits(struct pipe_screen *screen,
>>  screen, sh, PIPE_SHADER_CAP_MAX_SHADER_BUFFERS) / 2;
>>pc->MaxShaderStorageBlocks = pc->MaxAtomicBuffers;
>>
>> +  pc->MaxImageUniforms = screen->get_shader_param(
>> +screen, sh, PIPE_SHADER_CAP_MAX_SHADER_IMAGES);
>> +
>>/* Gallium doesn't really care about local vs. env parameters so use 
>> the
>> * same limits.
>> */
>> @@ -363,6 +366,19 @@ void st_init_limits(struct pipe_screen *screen,
>>c->MaxShaderStorageBlockSize = 1 << 27;
>>extensions->ARB_shader_storage_buffer_object = GL_TRUE;
>> }
>> +
>> +   c->MaxCombinedImageUniforms =
>> + c->Program[MESA_SHADER_VERTEX].MaxImageUniforms +
>> + c->Program[MESA_SHADER_TESS_CTRL].MaxImageUniforms +
>> + c->Program[MESA_SHADER_TESS_EVAL].MaxImageUniforms +
>> + c->Program[MESA_SHADER_GEOMETRY].MaxImageUniforms +
>> + c->Program[MESA_SHADER_FRAGMENT].MaxImageUniforms;
>> +   c->MaxImageUnits = MAX_IMAGE_UNITS;
>> +   c->MaxImageSamples = 0; /* XXX */
>> +   if (c->MaxCombinedImageUniforms) {
>> +  extensions->ARB_shader_image_load_store = GL_TRUE;
>> +  extensions->ARB_shader_image_size = GL_TRUE;
>> +   }
>>  }
>>
>>
>> --
>> 2.4.10
>>
>> ___
>> mesa-dev mailing list
>> mesa-dev@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] glxinfo: test GL_ATI_meminfo and GL_NVX_gpu_memory_info (v2)

2016-02-02 Thread Marek Olšák
From: Marek Olšák 

v2: move the code to glinfo_common.c.
---
 src/xdemos/glinfo_common.c | 56 ++
 src/xdemos/glinfo_common.h |  2 ++
 src/xdemos/glxinfo.c   |  1 +
 3 files changed, 59 insertions(+)

diff --git a/src/xdemos/glinfo_common.c b/src/xdemos/glinfo_common.c
index 5d865f3..a7e1142 100644
--- a/src/xdemos/glinfo_common.c
+++ b/src/xdemos/glinfo_common.c
@@ -798,3 +798,59 @@ parse_args(int argc, char *argv[], struct options *options)
   }
}
 }
+
+static void
+query_ATI_meminfo(void)
+{
+#ifdef GL_ATI_meminfo
+int i[4];
+
+printf("Memory info (GL_ATI_meminfo):\n");
+
+glGetIntegerv(GL_VBO_FREE_MEMORY_ATI, i);
+printf("VBO free memory - total: %u MB, largest block: %u MB\n",
+   i[0] / 1024, i[1] / 1024);
+printf("VBO free aux. memory - total: %u MB, largest block: %u MB\n",
+   i[2] / 1024, i[3] / 1024);
+
+glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, i);
+printf("Texture free memory - total: %u MB, largest block: %u MB\n",
+   i[0] / 1024, i[1] / 1024);
+printf("Texture free aux. memory - total: %u MB, largest block: %u 
MB\n",
+   i[2] / 1024, i[3] / 1024);
+
+glGetIntegerv(GL_RENDERBUFFER_FREE_MEMORY_ATI, i);
+printf("Renderbuffer free memory - total: %u MB, largest block: %u 
MB\n",
+   i[0] / 1024, i[1] / 1024);
+printf("Renderbuffer free aux. memory - total: %u MB, largest block: 
%u MB\n",
+   i[2] / 1024, i[3] / 1024);
+#endif
+}
+
+static void
+query_NVX_gpu_memory_info(void)
+{
+#ifdef GL_NVX_gpu_memory_info
+int i;
+
+printf("Memory info (GL_NVX_gpu_memory_info):\n");
+
+glGetIntegerv(GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, );
+printf("Dedicated video memory: %u MB\n", i / 1024);
+
+glGetIntegerv(GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, );
+printf("Total available memory: %u MB\n", i / 1024);
+
+glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, );
+printf("Currently available dedicated video memory: %u MB\n", i / 
1024);
+#endif
+}
+
+void
+print_gpu_memory_info(const char *glExtensions)
+{
+   if (strstr(glExtensions, "GL_ATI_meminfo"))
+  query_ATI_meminfo();
+   if (strstr(glExtensions, "GL_NVX_gpu_memory_info"))
+  query_NVX_gpu_memory_info();
+}
diff --git a/src/xdemos/glinfo_common.h b/src/xdemos/glinfo_common.h
index ad867ee..0024f85 100644
--- a/src/xdemos/glinfo_common.h
+++ b/src/xdemos/glinfo_common.h
@@ -138,5 +138,7 @@ context_flags_string(int mask);
 void
 parse_args(int argc, char *argv[], struct options *options);
 
+void
+print_gpu_memory_info(const char *glExtensions);
 
 #endif /* GLINFO_COMMON_H */
diff --git a/src/xdemos/glxinfo.c b/src/xdemos/glxinfo.c
index f65451a..1893f7b 100644
--- a/src/xdemos/glxinfo.c
+++ b/src/xdemos/glxinfo.c
@@ -547,6 +547,7 @@ print_screen_info(Display *dpy, int scrnum,
  }
  if (strstr(glxExtensions, "GLX_MESA_query_renderer"))
query_renderer();
+ print_gpu_memory_info(glExtensions);
  printf("OpenGL vendor string: %s\n", glVendor);
  printf("OpenGL renderer string: %s\n", glRenderer);
   } else
-- 
2.1.4

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


Re: [Mesa-dev] [PATCH] glxinfo: test GL_ATI_meminfo and GL_NVX_gpu_memory_info (v2)

2016-02-02 Thread Brian Paul

On 02/02/2016 12:22 PM, Marek Olšák wrote:

From: Marek Olšák 

v2: move the code to glinfo_common.c.
---
  src/xdemos/glinfo_common.c | 56 ++
  src/xdemos/glinfo_common.h |  2 ++
  src/xdemos/glxinfo.c   |  1 +
  3 files changed, 59 insertions(+)

diff --git a/src/xdemos/glinfo_common.c b/src/xdemos/glinfo_common.c
index 5d865f3..a7e1142 100644
--- a/src/xdemos/glinfo_common.c
+++ b/src/xdemos/glinfo_common.c
@@ -798,3 +798,59 @@ parse_args(int argc, char *argv[], struct options *options)
}
 }
  }
+
+static void
+query_ATI_meminfo(void)
+{
+#ifdef GL_ATI_meminfo
+int i[4];
+
+printf("Memory info (GL_ATI_meminfo):\n");
+
+glGetIntegerv(GL_VBO_FREE_MEMORY_ATI, i);
+printf("VBO free memory - total: %u MB, largest block: %u MB\n",
+   i[0] / 1024, i[1] / 1024);
+printf("VBO free aux. memory - total: %u MB, largest block: %u MB\n",
+   i[2] / 1024, i[3] / 1024);
+
+glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, i);
+printf("Texture free memory - total: %u MB, largest block: %u MB\n",
+   i[0] / 1024, i[1] / 1024);
+printf("Texture free aux. memory - total: %u MB, largest block: %u 
MB\n",
+   i[2] / 1024, i[3] / 1024);
+
+glGetIntegerv(GL_RENDERBUFFER_FREE_MEMORY_ATI, i);
+printf("Renderbuffer free memory - total: %u MB, largest block: %u 
MB\n",
+   i[0] / 1024, i[1] / 1024);
+printf("Renderbuffer free aux. memory - total: %u MB, largest block: %u 
MB\n",
+   i[2] / 1024, i[3] / 1024);
+#endif
+}
+
+static void
+query_NVX_gpu_memory_info(void)
+{
+#ifdef GL_NVX_gpu_memory_info
+int i;
+
+printf("Memory info (GL_NVX_gpu_memory_info):\n");
+
+glGetIntegerv(GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, );
+printf("Dedicated video memory: %u MB\n", i / 1024);
+
+glGetIntegerv(GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, );
+printf("Total available memory: %u MB\n", i / 1024);
+
+glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, );
+printf("Currently available dedicated video memory: %u MB\n", i / 
1024);
+#endif
+}
+
+void
+print_gpu_memory_info(const char *glExtensions)
+{
+   if (strstr(glExtensions, "GL_ATI_meminfo"))
+  query_ATI_meminfo();
+   if (strstr(glExtensions, "GL_NVX_gpu_memory_info"))
+  query_NVX_gpu_memory_info();
+}
diff --git a/src/xdemos/glinfo_common.h b/src/xdemos/glinfo_common.h
index ad867ee..0024f85 100644
--- a/src/xdemos/glinfo_common.h
+++ b/src/xdemos/glinfo_common.h
@@ -138,5 +138,7 @@ context_flags_string(int mask);
  void
  parse_args(int argc, char *argv[], struct options *options);

+void
+print_gpu_memory_info(const char *glExtensions);

  #endif /* GLINFO_COMMON_H */
diff --git a/src/xdemos/glxinfo.c b/src/xdemos/glxinfo.c
index f65451a..1893f7b 100644
--- a/src/xdemos/glxinfo.c
+++ b/src/xdemos/glxinfo.c
@@ -547,6 +547,7 @@ print_screen_info(Display *dpy, int scrnum,
   }
   if (strstr(glxExtensions, "GLX_MESA_query_renderer"))
query_renderer();
+ print_gpu_memory_info(glExtensions);
   printf("OpenGL vendor string: %s\n", glVendor);
   printf("OpenGL renderer string: %s\n", glRenderer);
} else



Thanks.

Reviewed-by: Brian Paul 

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


Re: [Mesa-dev] [PATCH] winsys/radeon: Do not deinit the pb cache if it was not initialized

2016-02-02 Thread Marek Olšák
Pushed, thanks.

Marek

On Fri, Jan 29, 2016 at 10:48 PM, Niels Ole Salscheider
 wrote:
> This fixes a crash in pb_cache_release_all_buffers.
>
> Signed-off-by: Niels Ole Salscheider 
> ---
>  src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c 
> b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
> index 8a1ed3a..4823bf3 100644
> --- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
> +++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
> @@ -742,7 +742,7 @@ radeon_drm_winsys_create(int fd, radeon_screen_create_t 
> screen_create)
>  ws->fd = dup(fd);
>
>  if (!do_winsys_init(ws))
> -goto fail;
> +goto fail1;
>
>  pb_cache_init(>bo_cache, 50, 2.0f, 0,
>MIN2(ws->info.vram_size, ws->info.gart_size),
> @@ -812,8 +812,9 @@ radeon_drm_winsys_create(int fd, radeon_screen_create_t 
> screen_create)
>  return >base;
>
>  fail:
> -pipe_mutex_unlock(fd_tab_mutex);
>  pb_cache_deinit(>bo_cache);
> +fail1:
> +pipe_mutex_unlock(fd_tab_mutex);
>  if (ws->surf_man)
>  radeon_surface_manager_free(ws->surf_man);
>  if (ws->fd >= 0)
> --
> 2.7.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 08a/11] nir: clamp-color-output support

2016-02-02 Thread Connor Abbott
On Tue, Feb 2, 2016 at 1:07 PM, Rob Clark  wrote:
> From: Rob Clark 
>
> Handled by tgsi_emulate for glsl->tgsi case.
>
> Signed-off-by: Rob Clark 
> ---
>  src/compiler/Makefile.sources|   1 +
>  src/compiler/nir/nir.h   |   1 +
>  src/compiler/nir/nir_lower_clamp_color_outputs.c | 121 
> +++
>  3 files changed, 123 insertions(+)
>  create mode 100644 src/compiler/nir/nir_lower_clamp_color_outputs.c
>
> diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources
> index d859493..e85cde5 100644
> --- a/src/compiler/Makefile.sources
> +++ b/src/compiler/Makefile.sources
> @@ -184,6 +184,7 @@ NIR_FILES = \
> nir/nir_lower_alu_to_scalar.c \
> nir/nir_lower_atomics.c \
> nir/nir_lower_bitmap.c \
> +   nir/nir_lower_clamp_color_outputs.c \
> nir/nir_lower_clip.c \
> nir/nir_lower_drawpixels.c \
> nir/nir_lower_global_vars_to_local.c \
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> index 29c8631..dc31a67 100644
> --- a/src/compiler/nir/nir.h
> +++ b/src/compiler/nir/nir.h
> @@ -2119,6 +2119,7 @@ void nir_lower_clip_fs(nir_shader *shader, unsigned 
> ucp_enables);
>
>  void nir_lower_two_sided_color(nir_shader *shader);
>
> +void nir_lower_clamp_color_outputs(nir_shader *shader);
>
>  typedef struct nir_lower_wpos_ytransform_options {
> int state_tokens[5];
> diff --git a/src/compiler/nir/nir_lower_clamp_color_outputs.c 
> b/src/compiler/nir/nir_lower_clamp_color_outputs.c
> new file mode 100644
> index 000..0e1add0
> --- /dev/null
> +++ b/src/compiler/nir/nir_lower_clamp_color_outputs.c
> @@ -0,0 +1,121 @@
> +/*
> + * Copyright © 2015 Red Hat
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
> FROM,
> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
> THE
> + * SOFTWARE.
> + */
> +
> +
> +#include "nir.h"
> +#include "nir_builder.h"
> +
> +typedef struct {
> +   nir_shader *shader;
> +   nir_builder b;
> +} lower_state;
> +
> +static bool
> +is_color_output(lower_state *state, nir_variable *out)
> +{
> +   switch (state->shader->stage) {
> +   case MESA_SHADER_VERTEX:
> +   case MESA_SHADER_GEOMETRY:
> +  switch (out->data.location) {
> +  case VARYING_SLOT_COL0:
> +  case VARYING_SLOT_COL1:
> +  case VARYING_SLOT_BFC0:
> +  case VARYING_SLOT_BFC1:
> + return true;
> +  default:
> + return false;
> +  }
> +  break;
> +   case MESA_SHADER_FRAGMENT:
> +  switch (out->data.location) {
> +  case FRAG_RESULT_COLOR:
> + return true;
> +  default:
> + return false;
> +  }
> +  break;
> +   default:
> +  return false;
> +   }
> +}
> +
> +static void
> +lower_intrinsic(lower_state *state, nir_intrinsic_instr *intr)
> +{
> +   nir_variable *out;
> +   nir_builder *b = >b;
> +   nir_ssa_def *s;
> +
> +   if (intr->intrinsic != nir_intrinsic_store_var)
> +  return;
> +
> +   out = intr->variables[0]->var;
> +
> +   if (out->data.mode != nir_var_shader_out)
> +  return;
> +
> +   /* NOTE: 'out' can be null for types larger than vec4,
> +* but these will never be color out's so we can ignore
> +*/

This comment isn't true (store_var intrinsics will always have a
non-NULL variable associated with them) and it doesn't seem relevant,
since even if color out's could be part of a struct/array this would
still work, so I'd just drop it. Other than that this gets my r-b.

> +
> +   if (out && is_color_output(state, out)) {
> +  b->cursor = nir_before_instr(>instr);
> +  s = nir_ssa_for_src(b, intr->src[0], intr->num_components);
> +  s = nir_fsat(b, s);
> +  nir_instr_rewrite_src(>instr, >src[0], nir_src_for_ssa(s));
> +   }
> +}
> +
> +static bool
> +lower_block(nir_block *block, void *_state)
> +{
> +   lower_state *state = _state;
> +
> +   

Re: [Mesa-dev] [PATCH 2/5] mesa: implement GL_NVX_gpu_memory_info

2016-02-02 Thread Marek Olšák
On Tue, Feb 2, 2016 at 3:36 PM, Ilia Mirkin  wrote:
> On Tue, Feb 2, 2016 at 8:45 AM, Marek Olšák  wrote:
>> From: Marek Olšák 
>>
>> ---
>>  src/mapi/glapi/gen/gl_API.xml|  8 
>>  src/mesa/main/dd.h   | 10 ++
>>  src/mesa/main/extensions_table.h |  1 +
>>  src/mesa/main/get.c  | 30 ++
>>  src/mesa/main/get_hash_params.py |  7 +++
>>  src/mesa/main/mtypes.h   |  1 +
>>  6 files changed, 57 insertions(+)
>>
>> diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
>> index d7ab3bf..09dda19 100644
>> --- a/src/mapi/glapi/gen/gl_API.xml
>> +++ b/src/mapi/glapi/gen/gl_API.xml
>> @@ -12714,6 +12714,14 @@
>>  
>>  
>>
>> +
>> +> value="0x9047" />
>> +> value="0x9048" />
>> +> value="0x9049" />
>> +> value="0x904A" />
>> +> value="0x904B" />
>> +
>> +
>>  > xmlns:xi="http://www.w3.org/2001/XInclude"/>
>>
>>  
>> diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
>> index d4378e5..d34e610 100644
>> --- a/src/mesa/main/dd.h
>> +++ b/src/mesa/main/dd.h
>> @@ -939,6 +939,16 @@ struct dd_function_table {
>> void (*DispatchCompute)(struct gl_context *ctx, const GLuint 
>> *num_groups);
>> void (*DispatchComputeIndirect)(struct gl_context *ctx, GLintptr 
>> indirect);
>> /*@}*/
>> +
>> +   /**
>> +* Query information about memory. Device memory is e.g. VRAM. Staging
>> +* memory is e.g. GART. All sizes are in kilobytes.
>> +*/
>> +   void (*QueryMemoryInfo)(struct gl_context *ctx,
>> +   unsigned *total_device_memory,
>> +   unsigned *avail_device_memory,
>> +   unsigned *total_staging_memory,
>> +   unsigned *avail_staging_memory);
>>  };
>>
>>
>> diff --git a/src/mesa/main/extensions_table.h 
>> b/src/mesa/main/extensions_table.h
>> index ad5dc60..dfccb73 100644
>> --- a/src/mesa/main/extensions_table.h
>> +++ b/src/mesa/main/extensions_table.h
>> @@ -291,6 +291,7 @@ EXT(NV_texture_barrier  , 
>> NV_texture_barrier
>>  EXT(NV_texture_env_combine4 , NV_texture_env_combine4   
>>  , GLL,  x ,  x ,  x , 1999)
>>  EXT(NV_texture_rectangle, NV_texture_rectangle  
>>  , GLL,  x ,  x ,  x , 2000)
>>  EXT(NV_vdpau_interop, NV_vdpau_interop  
>>  , GLL, GLC,  x ,  x , 2010)
>> +EXT(NVX_gpu_memory_info , NVX_gpu_memory_info   
>>  , GLL, GLC,  x ,  x , 2013)
>
> More like 2009, or even earlier... 2013 is the last modified date, not
> the creation date. Not sure where to get the creation date though.

If you know the exact date, feel free to tell me. Otherwise, I don't
think it's important.

>
>>
>>  EXT(OES_EGL_image   , OES_EGL_image 
>>  , GLL, GLC, ES1, ES2, 2006) /* FIXME: Mesa expects GL_OES_EGL_image 
>> to be available in OpenGL contexts. */
>>  EXT(OES_EGL_image_external  , OES_EGL_image_external
>>  ,  x ,  x , ES1, ES2, 2010)
>> diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
>> index 0434836..dbc8605 100644
>> --- a/src/mesa/main/get.c
>> +++ b/src/mesa/main/get.c
>> @@ -449,6 +449,7 @@ EXTRA_EXT(ARB_tessellation_shader);
>>  EXTRA_EXT(ARB_shader_subroutine);
>>  EXTRA_EXT(ARB_shader_storage_buffer_object);
>>  EXTRA_EXT(ARB_indirect_parameters);
>> +EXTRA_EXT(NVX_gpu_memory_info);
>>
>>  static const int
>>  extra_ARB_color_buffer_float_or_glcore[] = {
>> @@ -1080,6 +1081,35 @@ find_custom_value(struct gl_context *ctx, const 
>> struct value_desc *d, union valu
>> case GL_DISPATCH_INDIRECT_BUFFER_BINDING:
>>v->value_int = ctx->DispatchIndirectBuffer->Name;
>>break;
>> +   /* GL_NVX_gpu_memory_info */
>> +   case GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX:
>> +   case GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX:
>> +   case GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX:
>> +  {
>> + unsigned total_device_memory;
>> + unsigned avail_device_memory;
>> + unsigned total_staging_memory;
>> + unsigned avail_staging_memory;
>> +
>> + ctx->Driver.QueryMemoryInfo(ctx,
>> + _device_memory,
>> + _device_memory,
>> + _staging_memory,
>> + _staging_memory);
>> +
>> + if (d->pname == GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX)
>> +v->value_int = total_device_memory;
>> + else if (d->pname == GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX)
>> +v->value_int = total_device_memory + total_staging_memory;
>
> Total memory is unlikely to change at runtime. Should these be ctx->Const.foo?
>
>> + else if (d->pname == 
>> 

Re: [Mesa-dev] [PATCH 7/7] st/mesa: enable GL image extensions when backend supports them

2016-02-02 Thread Marek Olšák
On Tue, Feb 2, 2016 at 8:37 PM, Ilia Mirkin  wrote:
> On Tue, Feb 2, 2016 at 2:28 PM, Marek Olšák  wrote:
>> On Tue, Feb 2, 2016 at 8:16 PM, Ilia Mirkin  wrote:
>>> Thanks! From discussion with Dave re r600 needs, it sounds like we
>>> need to throw a "writable" property into pipe_image_view, and I need
>>> to do a proper job of setting the WR flag on the image in patch 6.
>>> I'll do those as add-on patches.
>>>
>>> Did you leave patch 6 unreviewed because you had issues with it, or
>>> because it was long and touched glsl_to_tgsi?
>>
>> Mostly a lack of focus today and not remembering the small details of
>> glsl_to_tgsi.
>
> OK, just making sure there were no explicit issues.
>
>>
>> I don't think r600 needs changes as long as it can analyze TGSI for
>> store instructions.
>
> Well, Dave was saying that he might want to use texturing for
> read-only images, in which case it'd be convenient to know at
> set_shader_images() time as well (or, well when writing that state
> out). And you'd want to generate different shader code depending on
> its read-only-ness.
>
> Anyways, I'm perfectly happy to let you and Dave fight it out :)

Well, the fact is, we don't have to use samplers at all.
GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS assures that we won't
get too many images + fragment outputs, thus we won't have to worry
about such things.

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


[Mesa-dev] [PATCH v2 2/4] Android: Fix building secondary arch in mixed 32/64-bit builds

2016-02-02 Thread Rob Herring
TARGET_CC is not defined for the secondary arch on combined 32/64-bit
builds. The build system uses 2ND_TARGET_CC instead and it is not meant
to be used in module makefiles. LOCAL_CC was used to provide C only
flags as -std=c99 is not valid for C++ files. Since Android 4.4,
LOCAL_CONLYFLAGS was added to set compiler flags on C files only, so it
can be used now instead of LOCAL_CC.

This will break on pre-4.4 versions of Android, but it unlikely anyone
is using current Mesa with such an old version of Android.

Cc: Emil Velikov 
Cc: Chih-Wei Huang 
Signed-off-by: Rob Herring 
---
v2:
- move c99 comment
- Reword the commit msg to better describe the problem and about pre-4.4 
  breakage

 Android.common.mk | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/Android.common.mk b/Android.common.mk
index 948561c..72fa5d9 100644
--- a/Android.common.mk
+++ b/Android.common.mk
@@ -21,13 +21,8 @@
 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 # DEALINGS IN THE SOFTWARE.
 
-# use c99 compiler by default
-ifeq ($(LOCAL_CC),)
 ifeq ($(LOCAL_IS_HOST_MODULE),true)
-LOCAL_CC := $(HOST_CC) -std=c99 -D_GNU_SOURCE
-else
-LOCAL_CC := $(TARGET_CC) -std=c99
-endif
+LOCAL_CFLAGS += -D_GNU_SOURCE
 endif
 
 LOCAL_C_INCLUDES += \
@@ -60,6 +55,10 @@ LOCAL_CFLAGS += \
-fvisibility=hidden \
-Wno-sign-compare
 
+# mesa requires at least c99 compiler
+LOCAL_CONLYFLAGS += \
+   -std=c99
+
 ifeq ($(strip $(MESA_ENABLE_ASM)),true)
 ifeq ($(TARGET_ARCH),x86)
 LOCAL_CFLAGS += \
-- 
2.5.0

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


[Mesa-dev] [PATCH v2 4/4] Android: disable unused-parameter warning

2016-02-02 Thread Rob Herring
Android builds with -Wunused-parameter enabled which results in spewing
lots of warnings. Disable it so more meaningful warnings are more visible.

Signed-off-by: Rob Herring 
Reviewed-by: Emil Velikov 
---
v2:
- No change

 Android.common.mk | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Android.common.mk b/Android.common.mk
index 72fa5d9..c4823f7 100644
--- a/Android.common.mk
+++ b/Android.common.mk
@@ -32,6 +32,7 @@ LOCAL_C_INCLUDES += \
 MESA_VERSION := $(shell cat $(MESA_TOP)/VERSION)
 # define ANDROID_VERSION (e.g., 4.0.x => 0x0400)
 LOCAL_CFLAGS += \
+   -Wno-unused-parameter \
-DPACKAGE_VERSION=\"$(MESA_VERSION)\" \

-DPACKAGE_BUGREPORT=\"https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa\; 
\

-DANDROID_VERSION=0x0$(MESA_ANDROID_MAJOR_VERSION)0$(MESA_ANDROID_MINOR_VERSION)
-- 
2.5.0

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


[Mesa-dev] [PATCH v2 3/4] Android: enable building on arm64

2016-02-02 Thread Rob Herring
Use the LOCAL_CFLAGS_{32/64} instead of arch specific variants to define
the DEFAULT_DRIVER_DIR. This enables building for arm64.

Cc: Emil Velikov 
Cc: Chih-Wei Huang 
Signed-off-by: Rob Herring 
---
v2:
- Use LOCAL_CFLAGS_(32|64) instead of arch flags

 src/egl/Android.mk | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/egl/Android.mk b/src/egl/Android.mk
index ebd67af..cf71251 100644
--- a/src/egl/Android.mk
+++ b/src/egl/Android.mk
@@ -44,9 +44,8 @@ LOCAL_CFLAGS := \
-DHAVE_ANDROID_PLATFORM
 
 ifeq ($(MESA_LOLLIPOP_BUILD),true)
-LOCAL_CFLAGS_arm := -DDEFAULT_DRIVER_DIR=\"/system/lib/dri\"
-LOCAL_CFLAGS_x86 := -DDEFAULT_DRIVER_DIR=\"/system/lib/dri\"
-LOCAL_CFLAGS_x86_64 := -DDEFAULT_DRIVER_DIR=\"/system/lib64/dri\"
+LOCAL_CFLAGS_32 := -DDEFAULT_DRIVER_DIR=\"/system/lib/dri\"
+LOCAL_CFLAGS_64 := -DDEFAULT_DRIVER_DIR=\"/system/lib64/dri\"
 else
 LOCAL_CFLAGS += -DDEFAULT_DRIVER_DIR=\"/system/lib/dri\"
 endif
-- 
2.5.0

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


[Mesa-dev] [PATCH v2 1/4] Android: fix x86 gallium builds

2016-02-02 Thread Rob Herring
Builds with gallium enabled fail on x86 with linker error:

external/mesa3d/src/mesa/vbo/vbo_exec_array.c:127: error: undefined reference 
to '_mesa_uint_array_min_max'

The problem is sse_minmax.c is not included in the libmesa_st_mesa
library. Since the SSE4.1 files are needed for both libmesa_st_mesa
and libmesa_dricore, move SSE4.1 files into a separate static library
that can be used by both.

Signed-off-by: Rob Herring 
---
v2:
- Rework SSE files into static lib

 src/mesa/Android.libmesa_dricore.mk |  7 +++---
 src/mesa/Android.libmesa_sse41.mk   | 44 +
 src/mesa/Android.libmesa_st_mesa.mk |  4 +++-
 src/mesa/Android.mk |  1 +
 src/mesa/Makefile.sources   |  4 
 5 files changed, 55 insertions(+), 5 deletions(-)
 create mode 100644 src/mesa/Android.libmesa_sse41.mk

diff --git a/src/mesa/Android.libmesa_dricore.mk 
b/src/mesa/Android.libmesa_dricore.mk
index ba952da..49f7e9c 100644
--- a/src/mesa/Android.libmesa_dricore.mk
+++ b/src/mesa/Android.libmesa_dricore.mk
@@ -48,9 +48,8 @@ endif # x86
 endif # MESA_ENABLE_ASM
 
 ifeq ($(ARCH_X86_HAVE_SSE4_1),true)
-LOCAL_SRC_FILES += \
-   main/streaming-load-memcpy.c \
-   main/sse_minmax.c
+LOCAL_WHOLE_STATIC_LIBRARIES := \
+   libmesa_sse41
 LOCAL_CFLAGS := \
-msse4.1 \
-DUSE_SSE41
@@ -64,7 +63,7 @@ LOCAL_C_INCLUDES := \
$(MESA_TOP)/src/gallium/include \
$(MESA_TOP)/src/gallium/auxiliary
 
-LOCAL_WHOLE_STATIC_LIBRARIES := \
+LOCAL_WHOLE_STATIC_LIBRARIES += \
libmesa_program
 
 include $(LOCAL_PATH)/Android.gen.mk
diff --git a/src/mesa/Android.libmesa_sse41.mk 
b/src/mesa/Android.libmesa_sse41.mk
new file mode 100644
index 000..8562da6
--- /dev/null
+++ b/src/mesa/Android.libmesa_sse41.mk
@@ -0,0 +1,44 @@
+# Copyright 2012 Intel Corporation
+# Copyright (C) 2010-2011 Chia-I Wu 
+# Copyright (C) 2010-2011 LunarG Inc.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+
+ifeq ($(ARCH_X86_HAVE_SSE4_1),true)
+
+LOCAL_PATH := $(call my-dir)
+
+include $(LOCAL_PATH)/Makefile.sources
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libmesa_sse41
+
+LOCAL_SRC_FILES += \
+   $(X86_SSE41_FILES)
+
+LOCAL_C_INCLUDES := \
+   $(MESA_TOP)/src/mapi \
+   $(MESA_TOP)/src/gallium/include \
+   $(MESA_TOP)/src/gallium/auxiliary
+
+include $(MESA_COMMON_MK)
+include $(BUILD_STATIC_LIBRARY)
+
+endif
diff --git a/src/mesa/Android.libmesa_st_mesa.mk 
b/src/mesa/Android.libmesa_st_mesa.mk
index ee8887b..43e5b21 100644
--- a/src/mesa/Android.libmesa_st_mesa.mk
+++ b/src/mesa/Android.libmesa_st_mesa.mk
@@ -47,6 +47,8 @@ endif # x86
 endif # MESA_ENABLE_ASM
 
 ifeq ($(ARCH_X86_HAVE_SSE4_1),true)
+LOCAL_WHOLE_STATIC_LIBRARIES := \
+   libmesa_sse41
 LOCAL_CFLAGS := \
-DUSE_SSE41
 endif
@@ -59,7 +61,7 @@ LOCAL_C_INCLUDES := \
$(MESA_TOP)/src/gallium/auxiliary \
$(MESA_TOP)/src/gallium/include
 
-LOCAL_WHOLE_STATIC_LIBRARIES := \
+LOCAL_WHOLE_STATIC_LIBRARIES += \
libmesa_program
 
 include $(LOCAL_PATH)/Android.gen.mk
diff --git a/src/mesa/Android.mk b/src/mesa/Android.mk
index 20f7819..9a1aef8 100644
--- a/src/mesa/Android.mk
+++ b/src/mesa/Android.mk
@@ -24,5 +24,6 @@ include $(LOCAL_PATH)/Android.mesa_gen_matypes.mk
 include $(LOCAL_PATH)/Android.libmesa_glsl_utils.mk
 include $(LOCAL_PATH)/Android.libmesa_dricore.mk
 include $(LOCAL_PATH)/Android.libmesa_st_mesa.mk
+include $(LOCAL_PATH)/Android.libmesa_sse41.mk
 
 include $(LOCAL_PATH)/program/Android.mk
diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
index 5d6f2d0..d7d0405 100644
--- a/src/mesa/Makefile.sources
+++ b/src/mesa/Makefile.sources
@@ -582,6 +582,10 @@ X86_64_FILES = \
x86-64/x86-64.h \
x86-64/xform4.S
 
+X86_SSE41_FILES = \
+   main/streaming-load-memcpy.c \
+   main/sse_minmax.c
+
 SPARC_FILES =  \
sparc/sparc.h   \

Re: [Mesa-dev] [PATCH] gallium/radeon: always unmap textures on 32-bit (v2)

2016-02-02 Thread Marek Olšák
Sadly, this patch doesn't fix NS2, so I'm kinda on the fence about pushing it.

Marek

On Tue, Feb 2, 2016 at 9:01 PM, Marek Olšák  wrote:
> From: Marek Olšák 
>
> This might fix mmap errors with Natural Selection 2, which a 32-bit game.
>
> It would be nice if someone tested this patch with the game.
>
> v2: use sizeof(void*)
> ---
>  src/gallium/drivers/radeon/r600_texture.c | 9 +
>  1 file changed, 9 insertions(+)
>
> diff --git a/src/gallium/drivers/radeon/r600_texture.c 
> b/src/gallium/drivers/radeon/r600_texture.c
> index 7c4717d..0bb3c81 100644
> --- a/src/gallium/drivers/radeon/r600_texture.c
> +++ b/src/gallium/drivers/radeon/r600_texture.c
> @@ -1153,10 +1153,19 @@ static void *r600_texture_transfer_map(struct 
> pipe_context *ctx,
>  static void r600_texture_transfer_unmap(struct pipe_context *ctx,
> struct pipe_transfer* transfer)
>  {
> +   struct r600_common_context *rctx = (struct r600_common_context*)ctx;
> struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
> struct pipe_resource *texture = transfer->resource;
> struct r600_texture *rtex = (struct r600_texture*)texture;
>
> +   if (sizeof(void*) == 4) {
> +   /* 32-bit address space can run out of space pretty quickly. 
> */
> +   if (rtransfer->staging)
> +   rctx->ws->buffer_unmap(rtransfer->staging->buf);
> +   else
> +   rctx->ws->buffer_unmap(rtex->resource.buf);
> +   }
> +
> if ((transfer->usage & PIPE_TRANSFER_WRITE) && rtransfer->staging) {
> if (rtex->is_depth && rtex->resource.b.b.nr_samples <= 1) {
> ctx->resource_copy_region(ctx, texture, 
> transfer->level,
> --
> 2.1.4
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] gallium r300 driver for PowerPC

2016-02-02 Thread Herminio Hernandez, Jr.
Mike,

When I trace in gdb and let the program run I get the standard error:

Using host libthread_db library "/lib/powerpc-linux-gnu/libthread_db.so.1".
libGL: OpenDriver: trying /usr/lib/powerpc-linux-gnu/dri/tls/r300_dri.so
libGL: OpenDriver: trying /usr/lib/powerpc-linux-gnu/dri/r300_dri.so
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: r300
libGL: OpenDriver: trying /usr/lib/powerpc-linux-gnu/dri/tls/swrast_dri.so
libGL: OpenDriver: trying /usr/lib/powerpc-linux-gnu/dri/swrast_dri.so
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast

Both r300 and swrast driver fail to load and I do not get a backtrace. When run 
gdb again and force an interrupt at the point the r300 fails to load I see in 
the trace that it is failing at the driOpenDriver function. When I run the 
program again and stop when the swrast driver fails in the trace I see it fail 
at the same spot. Unless I am reading the backtrace wrong I think that is where 
is the issue is. I am attaching the file so you can see.

Herminio



glxgears-gdb2.log
Description: Binary data

> On Jan 26, 2016, at 7:49 PM, Michel Dänzer  wrote:
> 
> On 26.01.2016 19:15, Herminio Hernandez Jr.  wrote:
>> Would the same thing apply swrast driver? I see glxgears trying to
>> fall back to it and relieving the same error.
> 
> Possibly, though that's a bit weird indeed. Anyway, trace the code
> execution (e.g. in gdb) and see.
> 
> 
> --
> Earthling Michel Dänzer   |   http://www.amd.com
> Libre software enthusiast | Mesa and X developer



signature.asc
Description: Message signed with OpenPGP using GPGMail
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] egl: move Null check to eglGetSyncAttribKHR to prevent Segfault

2016-02-02 Thread Dongwon Kim
Null-check on "*value" is currently done in
_eglGetSyncAttrib, which is after eglGetSyncAttribKHR
attempts to copy data at 'value' to 'attrib'. Segfault
is enevitable if value==NULL in this case. Therefore,
null-check should be moved to beginning of
eglGetSyncAttribKHR to avoid any possible segfaults.

Signed-off-by: Dongwon Kim 
---
 src/egl/main/eglapi.c  | 10 --
 src/egl/main/eglsync.c |  3 ---
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index 323634e..32f6823 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -1555,8 +1555,14 @@ eglGetSyncAttrib(EGLDisplay dpy, EGLSync sync, EGLint 
attribute, EGLAttrib *valu
 static EGLBoolean EGLAPIENTRY
 eglGetSyncAttribKHR(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLint 
*value)
 {
-   EGLAttrib attrib = *value;
-   EGLBoolean result = eglGetSyncAttrib(dpy, sync, attribute, );
+   EGLAttrib attrib;
+   EGLBoolean result;
+
+   if (!value)
+  RETURN_EGL_ERROR(NULL, EGL_BAD_PARAMETER, EGL_FALSE);
+
+   attrib = *value;
+   result = eglGetSyncAttrib(dpy, sync, attribute, );
 
/* The EGL_KHR_fence_sync spec says this about eglGetSyncAttribKHR:
 *
diff --git a/src/egl/main/eglsync.c b/src/egl/main/eglsync.c
index 3019e6e..999cb48 100644
--- a/src/egl/main/eglsync.c
+++ b/src/egl/main/eglsync.c
@@ -144,9 +144,6 @@ EGLBoolean
 _eglGetSyncAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
   EGLint attribute, EGLAttrib *value)
 {
-   if (!value)
-  return _eglError(EGL_BAD_PARAMETER, "eglGetSyncAttribKHR");
-
switch (attribute) {
case EGL_SYNC_TYPE_KHR:
   *value = sync->Type;
-- 
1.9.1

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


Re: [Mesa-dev] [PATCH 2/5] mesa: implement GL_NVX_gpu_memory_info

2016-02-02 Thread Erik Faye-Lund
On Tue, Feb 2, 2016 at 4:02 PM, Roland Scheidegger  wrote:
> Does anyone use these extensions?
> I suppose maybe to get the total amount of video memory?

I've used them in a commercial data-visualization application. The
purpose was to get the total amount of video memory, so we'd know
roughly how much data we should try to keep around in memory before
paging to main RAM or disk.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] i965: Define miptree map functions static (trivial)

2016-02-02 Thread Ben Widawsky
They were already declared as such. It was changed here:
commit 31f0967fb50101437d2568e9ab9640ffbcbf7ef9
Author: Ian Romanick 
Date:   Wed Sep 2 14:43:18 2015 -0700

i965: Make intel_miptree_map_raw static

Cc: Ian Romanick 
Signed-off-by: Ben Widawsky 
---
 src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c 
b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index 855eb68..25295b2 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -2161,7 +2161,7 @@ intel_miptree_updownsample(struct brw_context *brw,
}
 }
 
-void *
+static void *
 intel_miptree_map_raw(struct brw_context *brw, struct intel_mipmap_tree *mt)
 {
/* CPU accesses to color buffers don't understand fast color clears, so
@@ -2182,7 +2182,7 @@ intel_miptree_map_raw(struct brw_context *brw, struct 
intel_mipmap_tree *mt)
return bo->virtual;
 }
 
-void
+static void
 intel_miptree_unmap_raw(struct intel_mipmap_tree *mt)
 {
drm_intel_bo_unmap(mt->bo);
-- 
2.7.0

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


Re: [Mesa-dev] [PATCH] i965: Define miptree map functions static (trivial)

2016-02-02 Thread Timothy Arceri
On Tue, 2016-02-02 at 14:51 -0800, Ben Widawsky wrote:
> They were already declared as such. It was changed here:
> commit 31f0967fb50101437d2568e9ab9640ffbcbf7ef9
> Author: Ian Romanick 
> Date:   Wed Sep 2 14:43:18 2015 -0700
> 
> i965: Make intel_miptree_map_raw static
> 
> Cc: Ian Romanick 
> Signed-off-by: Ben Widawsky 

Reviewed-by: Timothy Arceri 

> ---
>  src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> index 855eb68..25295b2 100644
> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> @@ -2161,7 +2161,7 @@ intel_miptree_updownsample(struct brw_context
> *brw,
> }
>  }
>  
> -void *
> +static void *
>  intel_miptree_map_raw(struct brw_context *brw, struct
> intel_mipmap_tree *mt)
>  {
> /* CPU accesses to color buffers don't understand fast color
> clears, so
> @@ -2182,7 +2182,7 @@ intel_miptree_map_raw(struct brw_context *brw,
> struct intel_mipmap_tree *mt)
> return bo->virtual;
>  }
>  
> -void
> +static void
>  intel_miptree_unmap_raw(struct intel_mipmap_tree *mt)
>  {
> drm_intel_bo_unmap(mt->bo);
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/2] glsl: don't generate transform feedback candidate when not required

2016-02-02 Thread Timothy Arceri
If we are not even looking for one don't bother generating a candidate
list.
---
 src/compiler/glsl/link_varyings.cpp | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/compiler/glsl/link_varyings.cpp 
b/src/compiler/glsl/link_varyings.cpp
index 729db78..e5c076a 100644
--- a/src/compiler/glsl/link_varyings.cpp
+++ b/src/compiler/glsl/link_varyings.cpp
@@ -1808,8 +1808,10 @@ assign_varying_locations(struct gl_context *ctx,
 (output_var->data.stream < MAX_VERTEX_STREAMS &&
  producer->Stage == MESA_SHADER_GEOMETRY));
 
- tfeedback_candidate_generator g(mem_ctx, tfeedback_candidates);
- g.process(output_var);
+ if (num_tfeedback_decls > 0) {
+tfeedback_candidate_generator g(mem_ctx, tfeedback_candidates);
+g.process(output_var);
+ }
 
  ir_variable *const input_var =
 linker::get_matching_input(mem_ctx, output_var, consumer_inputs,
-- 
2.5.0

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


Re: [Mesa-dev] [PATCH] i965: Define miptree map functions static (trivial)

2016-02-02 Thread Anuj Phogat
On Tue, Feb 2, 2016 at 2:51 PM, Ben Widawsky
 wrote:
> They were already declared as such. It was changed here:
> commit 31f0967fb50101437d2568e9ab9640ffbcbf7ef9
> Author: Ian Romanick 
> Date:   Wed Sep 2 14:43:18 2015 -0700
>
> i965: Make intel_miptree_map_raw static
>
> Cc: Ian Romanick 
> Signed-off-by: Ben Widawsky 
> ---
>  src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c 
> b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> index 855eb68..25295b2 100644
> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> @@ -2161,7 +2161,7 @@ intel_miptree_updownsample(struct brw_context *brw,
> }
>  }
>
> -void *
> +static void *
>  intel_miptree_map_raw(struct brw_context *brw, struct intel_mipmap_tree *mt)
>  {
> /* CPU accesses to color buffers don't understand fast color clears, so
> @@ -2182,7 +2182,7 @@ intel_miptree_map_raw(struct brw_context *brw, struct 
> intel_mipmap_tree *mt)
> return bo->virtual;
>  }
>
> -void
> +static void
>  intel_miptree_unmap_raw(struct intel_mipmap_tree *mt)
>  {
> drm_intel_bo_unmap(mt->bo);
These functions are declared static at top of the file. In that case 'static'
keyword in front of the functions is optional. But it doesn't hurt and brings
more clarity.

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


[Mesa-dev] [PATCH 1/2] glsl: replace unreachable code with an assert()

2016-02-02 Thread Timothy Arceri
All interface blocks will have been lowered by this point so just
use an assert. Returning false would have caused all sorts of
problems if they were not lowered yet and there is an assert to
catch this later anyway.

We also update the tests to reflect this change.
---
 src/compiler/glsl/link_varyings.cpp   | 25 --
 src/compiler/glsl/tests/varyings_test.cpp | 78 ---
 2 files changed, 38 insertions(+), 65 deletions(-)

diff --git a/src/compiler/glsl/link_varyings.cpp 
b/src/compiler/glsl/link_varyings.cpp
index 8efaa33..729db78 100644
--- a/src/compiler/glsl/link_varyings.cpp
+++ b/src/compiler/glsl/link_varyings.cpp
@@ -1479,7 +1479,7 @@ private:
 
 namespace linker {
 
-bool
+void
 populate_consumer_input_sets(void *mem_ctx, exec_list *ir,
  hash_table *consumer_inputs,
  hash_table *consumer_interface_inputs,
@@ -1493,8 +1493,8 @@ populate_consumer_input_sets(void *mem_ctx, exec_list *ir,
   ir_variable *const input_var = node->as_variable();
 
   if ((input_var != NULL) && (input_var->data.mode == ir_var_shader_in)) {
- if (input_var->type->is_interface())
-return false;
+ /* All interface blocks should have been lowered by this point */
+ assert(!input_var->type->is_interface());
 
  if (input_var->data.explicit_location) {
 /* assign_varying_locations only cares about finding the
@@ -1528,8 +1528,6 @@ populate_consumer_input_sets(void *mem_ctx, exec_list *ir,
  }
   }
}
-
-   return true;
 }
 
 /**
@@ -1791,18 +1789,11 @@ assign_varying_locations(struct gl_context *ctx,
if (producer)
   canonicalize_shader_io(producer->ir, ir_var_shader_out);
 
-   if (consumer
-   && !linker::populate_consumer_input_sets(mem_ctx,
-consumer->ir,
-consumer_inputs,
-consumer_interface_inputs,
-
consumer_inputs_with_locations)) {
-  assert(!"populate_consumer_input_sets failed");
-  hash_table_dtor(tfeedback_candidates);
-  hash_table_dtor(consumer_inputs);
-  hash_table_dtor(consumer_interface_inputs);
-  return false;
-   }
+   if (consumer)
+  linker::populate_consumer_input_sets(mem_ctx, consumer->ir,
+   consumer_inputs,
+   consumer_interface_inputs,
+   consumer_inputs_with_locations);
 
if (producer) {
   foreach_in_list(ir_instruction, node, producer->ir) {
diff --git a/src/compiler/glsl/tests/varyings_test.cpp 
b/src/compiler/glsl/tests/varyings_test.cpp
index 0c4e0a4..9be5e83 100644
--- a/src/compiler/glsl/tests/varyings_test.cpp
+++ b/src/compiler/glsl/tests/varyings_test.cpp
@@ -156,11 +156,11 @@ TEST_F(link_varyings, single_simple_input)
 
ir.push_tail(v);
 
-   ASSERT_TRUE(linker::populate_consumer_input_sets(mem_ctx,
-,
-consumer_inputs,
-consumer_interface_inputs,
-junk));
+   linker::populate_consumer_input_sets(mem_ctx,
+,
+consumer_inputs,
+consumer_interface_inputs,
+junk);
 
EXPECT_EQ((void *) v, hash_table_find(consumer_inputs, "a"));
EXPECT_EQ(1u, num_elements(consumer_inputs));
@@ -183,11 +183,11 @@ TEST_F(link_varyings, gl_ClipDistance)
 
ir.push_tail(clipdistance);
 
-   ASSERT_TRUE(linker::populate_consumer_input_sets(mem_ctx,
-,
-consumer_inputs,
-consumer_interface_inputs,
-junk));
+   linker::populate_consumer_input_sets(mem_ctx,
+,
+consumer_inputs,
+consumer_interface_inputs,
+junk);
 
EXPECT_EQ(clipdistance, junk[VARYING_SLOT_CLIP_DIST0]);
EXPECT_TRUE(is_empty(consumer_inputs));
@@ -205,11 +205,11 @@ TEST_F(link_varyings, single_interface_input)
 
ir.push_tail(v);
 
-   ASSERT_TRUE(linker::populate_consumer_input_sets(mem_ctx,
-,
-consumer_inputs,
-consumer_interface_inputs,
-junk));
+   

[Mesa-dev] [Bug 93970] Second Life - Advanced Lighting Model shader fails to compile on Radeon SI driver

2016-02-02 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=93970

Michel Dänzer  changed:

   What|Removed |Added

   Assignee|dri-devel@lists.freedesktop |mesa-dev@lists.freedesktop.
   |.org|org
  Component|Drivers/Gallium/radeonsi|Mesa core
 QA Contact|dri-devel@lists.freedesktop |mesa-dev@lists.freedesktop.
   |.org|org

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


Re: [Mesa-dev] [android-x86-devel] [PATCH 4/5] android: fix building with new glsl, nir, compiler libraries

2016-02-02 Thread Mauro Rossi
Hi,

> per each target that depended on the old libmesa_glsl static,
> > dependencies were checked and updated according to the new
> > libmesa_glsl, libmesa_nir and libmesa_compiler static libraries
>
> Looks pretty similar to my changes except for a few things.
>


...
>


 >  src/gallium/drivers/vc4/Android.mk   | 4 ++--
> I missed building this one.



I went through all android building errors occurences,
with the following list of drivers BoardConfig.mk:

freedreeno i915 i965 *nouveau* r300g r600g *radeonsi* swrast virgl *vc4*

Compared to you list of changes, only *vc4* had glsl related building error.

I also tried to build vmwgfx drivers, which have dependencies on libLLVM
shared library, but when building vmwgfx linking fails, there are a lot of
building errors all of them are undefined reference to LLVM functions.

With kitkat-x86, vmwgfx of mesa 11.2.0devel is built without a glitch.

Do you have any clue or advice on how to build vmwgfx on
lollipop/marshmallow?

Thanks in advance


> -# We need libmesa_glsl to get NIR's generated include directories.
> > +# We need libmesa_nir to get NIR's generated include directories.
> >  LOCAL_MODULE := libmesa_gallium
> > -LOCAL_STATIC_LIBRARIES += libmesa_glsl
> > +LOCAL_STATIC_LIBRARIES += libmesa_nir
>
> I just added libmesa_nir, but this is probably the correct fix.


I saw no no building error when removing libmesa_glsl


> >  LOCAL_C_INCLUDES := \
> > $(MESA_TOP)/src/mapi \
> > -   $(MESA_TOP)/src/glsl \
> > +   $(MESA_TOP)/src/compiler/glsl \
>
> Are you sure this path is needed? I didn't seem to need it.


I performed the changes based on the assumption that $(MESA_TOP)/src/glsl
is now a non existent path,
but marshamallow is built even without $(MESA_TOP)/src/glsl or
$(MESA_TOP)/src/compiler/glsl

IIRC that line in the includes path was needed in the past to avoid
building errors,
it may be related to kikat-x86 build system, but I need to check next
weekend, when I'll move to where I have the build machine for kitkat-x86.

For the moment, I would recommed to keep it with the new corrected path in
any place it appears.
Thanks a lot

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


[Mesa-dev] [Bug 93820] Change from Mesa 10 to 11 made remote opengl stop working

2016-02-02 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=93820

--- Comment #7 from Michel Dänzer  ---
(In reply to Jason Ekstrand from comment #6)
> [...] you should be able to just query for the AIGLX extension.

There is no AIGLX extension.

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


Re: [Mesa-dev] [PATCH 7/7] st/mesa: enable GL image extensions when backend supports them

2016-02-02 Thread Marek Olšák
Patches 1-5, 7:

Reviewed-by: Marek Olšák 

Marek

On Sun, Jan 31, 2016 at 2:55 AM, Ilia Mirkin  wrote:
> This enables ARB_shader_image_load_store and ARB_shader_image_size when
> the backend claims support for these. It will also implicitly enable the
> image component of ARB_shader_texture_image_samples.
>
> Signed-off-by: Ilia Mirkin 
> ---
>  src/mesa/state_tracker/st_extensions.c | 16 
>  1 file changed, 16 insertions(+)
>
> diff --git a/src/mesa/state_tracker/st_extensions.c 
> b/src/mesa/state_tracker/st_extensions.c
> index d066784..f0fee88 100644
> --- a/src/mesa/state_tracker/st_extensions.c
> +++ b/src/mesa/state_tracker/st_extensions.c
> @@ -223,6 +223,9 @@ void st_init_limits(struct pipe_screen *screen,
>  screen, sh, PIPE_SHADER_CAP_MAX_SHADER_BUFFERS) / 2;
>pc->MaxShaderStorageBlocks = pc->MaxAtomicBuffers;
>
> +  pc->MaxImageUniforms = screen->get_shader_param(
> +screen, sh, PIPE_SHADER_CAP_MAX_SHADER_IMAGES);
> +
>/* Gallium doesn't really care about local vs. env parameters so use 
> the
> * same limits.
> */
> @@ -363,6 +366,19 @@ void st_init_limits(struct pipe_screen *screen,
>c->MaxShaderStorageBlockSize = 1 << 27;
>extensions->ARB_shader_storage_buffer_object = GL_TRUE;
> }
> +
> +   c->MaxCombinedImageUniforms =
> + c->Program[MESA_SHADER_VERTEX].MaxImageUniforms +
> + c->Program[MESA_SHADER_TESS_CTRL].MaxImageUniforms +
> + c->Program[MESA_SHADER_TESS_EVAL].MaxImageUniforms +
> + c->Program[MESA_SHADER_GEOMETRY].MaxImageUniforms +
> + c->Program[MESA_SHADER_FRAGMENT].MaxImageUniforms;
> +   c->MaxImageUnits = MAX_IMAGE_UNITS;
> +   c->MaxImageSamples = 0; /* XXX */
> +   if (c->MaxCombinedImageUniforms) {
> +  extensions->ARB_shader_image_load_store = GL_TRUE;
> +  extensions->ARB_shader_image_size = GL_TRUE;
> +   }
>  }
>
>
> --
> 2.4.10
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] gallium/radeon: always unmap textures on 32-bit (v2)

2016-02-02 Thread Marek Olšák
From: Marek Olšák 

This might fix mmap errors with Natural Selection 2, which a 32-bit game.

It would be nice if someone tested this patch with the game.

v2: use sizeof(void*)
---
 src/gallium/drivers/radeon/r600_texture.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/src/gallium/drivers/radeon/r600_texture.c 
b/src/gallium/drivers/radeon/r600_texture.c
index 7c4717d..0bb3c81 100644
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -1153,10 +1153,19 @@ static void *r600_texture_transfer_map(struct 
pipe_context *ctx,
 static void r600_texture_transfer_unmap(struct pipe_context *ctx,
struct pipe_transfer* transfer)
 {
+   struct r600_common_context *rctx = (struct r600_common_context*)ctx;
struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
struct pipe_resource *texture = transfer->resource;
struct r600_texture *rtex = (struct r600_texture*)texture;
 
+   if (sizeof(void*) == 4) {
+   /* 32-bit address space can run out of space pretty quickly. */
+   if (rtransfer->staging)
+   rctx->ws->buffer_unmap(rtransfer->staging->buf);
+   else
+   rctx->ws->buffer_unmap(rtex->resource.buf);
+   }
+
if ((transfer->usage & PIPE_TRANSFER_WRITE) && rtransfer->staging) {
if (rtex->is_depth && rtex->resource.b.b.nr_samples <= 1) {
ctx->resource_copy_region(ctx, texture, transfer->level,
-- 
2.1.4

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


Re: [Mesa-dev] [PATCH 2/5] mesa: implement GL_NVX_gpu_memory_info

2016-02-02 Thread Marek Olšák
On Tue, Feb 2, 2016 at 9:18 PM, Roland Scheidegger  wrote:
> Am 02.02.2016 um 20:41 schrieb Marek Olšák:
>> On Tue, Feb 2, 2016 at 4:02 PM, Roland Scheidegger  
>> wrote:
>>> Does anyone use these extensions?
>>> I suppose maybe to get the total amount of video memory?
>>> From the dynamic counts, I would have thought the eviction one would be
>>> the most interesting, but this one isn't implemented. Ah well I guess a
>>> sloppily implemented extension is better than none.
>>
>> I know from personal experience that Unreal Engine 3 uses one of them
>> (or maybe both), because it crashed when I had a bug there. I've heard
>> the Source engine uses them too.
>>
>> The use case for modern games is to support texture paging, i.e.
>> loading texture pages on demand based on on-screen visibility of
>> textures and available memory.
>
> But do they really use available memory or just total memory? Anyway, I
> guess if it's used that's ok, I'm just not a fan of odd fringe vendor
> specific extensions.

They use both. The ATI extension only returns the available memory,
not total memory.

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


Re: [Mesa-dev] [PATCH 2/4] i965: Provide sse2 version for rgba8 <-> bgra8 swizzle

2016-02-02 Thread Lofstedt, Marta
Hi Roland and Matt,

I am sorry, but this patch segfaults/asserts Kronos CTS - 
ES2-CTS.gtf.GL2FixedTests.scissor.scissor

I created this bug:
https://bugs.freedesktop.org/show_bug.cgi?id=93962

I also added the bug to the OpenGL ES 3.1 tracker bug, since it blocks CTS 
testing.
https://bugs.freedesktop.org/show_bug.cgi?id=92788


/Marta

> -Original Message-
> From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On
> Behalf Of Roland Scheidegger
> Sent: Friday, January 29, 2016 2:18 AM
> To: Matt Turner
> Cc: mesa-dev@lists.freedesktop.org
> Subject: Re: [Mesa-dev] [PATCH 2/4] i965: Provide sse2 version for rgba8 <->
> bgra8 swizzle
> 
> Am 29.01.2016 um 00:31 schrieb Matt Turner:
> > On Sun, Jan 17, 2016 at 1:49 PM,   wrote:
> >> From: Roland Scheidegger 
> >>
> >> The existing code used ssse3, and because it isn't compiled in a
> >> separate file compiled with that, it is usually not used (that, of
> >> course, could be fixed...), whereas sse2 is always present at least with
> 64bit builds.
> >> It is actually trivial to do with sse2 without pshufb, on some cpus
> >> (I'm looking at you, atom!) it might not even be slower.
> >> This is compile-tested only, it doesn't actually do what I really
> >> want (which is glReadPixels without doing byte access from an
> >> uncached region, which is what you'll get on intel chips not having
> >> llc, if your cpu doesn't support sse41 (in which case the rb would be
> >> copied over with movntdqa instead of mapped, so mesa format_utils
> >> byte swapping conversion will then access the cached region instead
> >> of the uncached one) - really need sse2-optimized convert_ubyte
> >> functions for a proper fix, otherwise google maps in firefox is
> >> reduced to fps below 1 fps), but hey why not. I don't have a gpu which
> could possibly hit this, albeit I succesfully used the exact same code
> elsewhere.
> >
> > Bah, wall of text!
> >
> > I don't think we need all this. The commit title says everything I
> > think it needs to say.
> >
> >> v2: fix andnot argument order, add comments
> >> ---
> >>  src/mesa/drivers/dri/i965/intel_mipmap_tree.c  | 18 +++
> >> src/mesa/drivers/dri/i965/intel_tiled_memcpy.c | 73
> >> +-
> >>  2 files changed, 79 insertions(+), 12 deletions(-)
> >>
> >> diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> >> b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> >> index 108dd87..5fc4212 100644
> >> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> >> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> >> @@ -2773,6 +2773,24 @@ intel_miptree_map(struct brw_context *brw,
> >> } else if (!(mode & GL_MAP_WRITE_BIT) &&
> >>!mt->compressed && cpu_has_sse4_1 &&
> >>(mt->pitch % 16 == 0)) {
> >> +  /*
> >> +   * XXX: without sse4_1, in some situations still really want to copy
> >> +   * regardless. Presumably this is not done for performance reasons -
> >> +   * with movntdqa thanks to the 64byte streaming load buffer the
> >> +   * uncached->cached copy followed by cached->cached later is always
> >> +   * faster than doing "ordinary" uncached->cached copy.
> >> +   * Without movntdqa, of course an additional copy doesn't help,
> albeit
> >> +   * it has to be said the uncached->cached one is an order of
> magnitude
> >> +   * slower than the later cached->cached one in any case.
> >> +   * But mesa may not do a simple memcpy on that memory later -
> some
> >> +   * glReadPixels paths for instance will well hit per-byte access 
> >> which
> >> +   * is a complete performance killer on uncached memory. So in these
> >> +   * cases really want to copy regardless, unless the map below could
> >> +   * play some tricks making the memory cached.
> >> +   * (Or otherwise ensure mesa can't hit these paths often, for 
> >> instance
> >> +   * glReadPixels requiring conversions could be handled by meta, so 
> >> in
> >> +   * end it really would be just memcpy.)
> >> +   */
> >
> > Walls of text are really hard to read...
> >
> > I don't think adding this comment to the code is particularly
> > valuable, but it does make me wonder if we should just add a memcpy
> > fallback after this path? Maybe we don't care once we have this patch.
> 
> Ok I'll remove that. It was rather difficult for me to figure out how mesa 
> ends
> up doing the per-byte access out of uncached memory, which is why I wrote
> it.
> I don't know if the always memcpy is an acceptable solution (hence didn't do
> anything about it). It will only add a quite small extra cost but OTOH that 
> perf
> hit will be on the fast path which you probably expect to hit often (i.e. mesa
> accessing things with a memcpy anyway).
> My guess is the fastest solution would be trying to remap as cacheable
> somehow, but I don't really know much about the driver (but I know tricks
> like that get ugly 

Re: [Mesa-dev] [PATCH 2/5] mesa: implement GL_NVX_gpu_memory_info

2016-02-02 Thread Ilia Mirkin
On Tue, Feb 2, 2016 at 8:45 AM, Marek Olšák  wrote:
> From: Marek Olšák 
>
> ---
>  src/mapi/glapi/gen/gl_API.xml|  8 
>  src/mesa/main/dd.h   | 10 ++
>  src/mesa/main/extensions_table.h |  1 +
>  src/mesa/main/get.c  | 30 ++
>  src/mesa/main/get_hash_params.py |  7 +++
>  src/mesa/main/mtypes.h   |  1 +
>  6 files changed, 57 insertions(+)
>
> diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
> index d7ab3bf..09dda19 100644
> --- a/src/mapi/glapi/gen/gl_API.xml
> +++ b/src/mapi/glapi/gen/gl_API.xml
> @@ -12714,6 +12714,14 @@
>  
>  
>
> +
> + />
> + />
> + />
> + />
> + />
> +
> +
>   xmlns:xi="http://www.w3.org/2001/XInclude"/>
>
>  
> diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
> index d4378e5..d34e610 100644
> --- a/src/mesa/main/dd.h
> +++ b/src/mesa/main/dd.h
> @@ -939,6 +939,16 @@ struct dd_function_table {
> void (*DispatchCompute)(struct gl_context *ctx, const GLuint *num_groups);
> void (*DispatchComputeIndirect)(struct gl_context *ctx, GLintptr 
> indirect);
> /*@}*/
> +
> +   /**
> +* Query information about memory. Device memory is e.g. VRAM. Staging
> +* memory is e.g. GART. All sizes are in kilobytes.
> +*/
> +   void (*QueryMemoryInfo)(struct gl_context *ctx,
> +   unsigned *total_device_memory,
> +   unsigned *avail_device_memory,
> +   unsigned *total_staging_memory,
> +   unsigned *avail_staging_memory);
>  };
>
>
> diff --git a/src/mesa/main/extensions_table.h 
> b/src/mesa/main/extensions_table.h
> index ad5dc60..dfccb73 100644
> --- a/src/mesa/main/extensions_table.h
> +++ b/src/mesa/main/extensions_table.h
> @@ -291,6 +291,7 @@ EXT(NV_texture_barrier  , 
> NV_texture_barrier
>  EXT(NV_texture_env_combine4 , NV_texture_env_combine4
> , GLL,  x ,  x ,  x , 1999)
>  EXT(NV_texture_rectangle, NV_texture_rectangle   
> , GLL,  x ,  x ,  x , 2000)
>  EXT(NV_vdpau_interop, NV_vdpau_interop   
> , GLL, GLC,  x ,  x , 2010)
> +EXT(NVX_gpu_memory_info , NVX_gpu_memory_info
> , GLL, GLC,  x ,  x , 2013)

More like 2009, or even earlier... 2013 is the last modified date, not
the creation date. Not sure where to get the creation date though.

>
>  EXT(OES_EGL_image   , OES_EGL_image  
> , GLL, GLC, ES1, ES2, 2006) /* FIXME: Mesa expects GL_OES_EGL_image 
> to be available in OpenGL contexts. */
>  EXT(OES_EGL_image_external  , OES_EGL_image_external 
> ,  x ,  x , ES1, ES2, 2010)
> diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
> index 0434836..dbc8605 100644
> --- a/src/mesa/main/get.c
> +++ b/src/mesa/main/get.c
> @@ -449,6 +449,7 @@ EXTRA_EXT(ARB_tessellation_shader);
>  EXTRA_EXT(ARB_shader_subroutine);
>  EXTRA_EXT(ARB_shader_storage_buffer_object);
>  EXTRA_EXT(ARB_indirect_parameters);
> +EXTRA_EXT(NVX_gpu_memory_info);
>
>  static const int
>  extra_ARB_color_buffer_float_or_glcore[] = {
> @@ -1080,6 +1081,35 @@ find_custom_value(struct gl_context *ctx, const struct 
> value_desc *d, union valu
> case GL_DISPATCH_INDIRECT_BUFFER_BINDING:
>v->value_int = ctx->DispatchIndirectBuffer->Name;
>break;
> +   /* GL_NVX_gpu_memory_info */
> +   case GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX:
> +   case GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX:
> +   case GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX:
> +  {
> + unsigned total_device_memory;
> + unsigned avail_device_memory;
> + unsigned total_staging_memory;
> + unsigned avail_staging_memory;
> +
> + ctx->Driver.QueryMemoryInfo(ctx,
> + _device_memory,
> + _device_memory,
> + _staging_memory,
> + _staging_memory);
> +
> + if (d->pname == GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX)
> +v->value_int = total_device_memory;
> + else if (d->pname == GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX)
> +v->value_int = total_device_memory + total_staging_memory;

Total memory is unlikely to change at runtime. Should these be ctx->Const.foo?

> + else if (d->pname == 
> GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX)
> +v->value_int = avail_device_memory;

and then this becomes the only thing you need to query?

> +  }
> +  break;
> +   case GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX:
> +   case GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX:
> +  /* not interested in returning anything useful here */
> +  v->value_int = 0;
> +  break;
> 

Re: [Mesa-dev] [PATCH] glxinfo: test GL_ATI_meminfo and GL_NVX_gpu_memory_info

2016-02-02 Thread Brian Paul

On 02/02/2016 06:47 AM, Marek Olšák wrote:

From: Marek Olšák 

---
  src/xdemos/glxinfo.c | 53 
  1 file changed, 53 insertions(+)

diff --git a/src/xdemos/glxinfo.c b/src/xdemos/glxinfo.c
index f65451a..b0377fb 100644
--- a/src/xdemos/glxinfo.c
+++ b/src/xdemos/glxinfo.c
@@ -390,6 +390,55 @@ query_renderer(void)
  }


+static void
+query_ATI_meminfo(void)
+{
+#ifdef GL_ATI_meminfo
+int i[4];
+
+printf("Memory info (GL_ATI_meminfo):\n");
+
+glGetIntegerv(GL_VBO_FREE_MEMORY_ATI, i);
+printf("VBO free memory - total: %u MB, largest block: %u MB\n",
+   i[0] / 1024, i[1] / 1024);
+printf("VBO free aux. memory - total: %u MB, largest block: %u MB\n",
+   i[2] / 1024, i[3] / 1024);
+
+glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, i);
+printf("Texture free memory - total: %u MB, largest block: %u MB\n",
+   i[0] / 1024, i[1] / 1024);
+printf("Texture free aux. memory - total: %u MB, largest block: %u 
MB\n",
+   i[2] / 1024, i[3] / 1024);
+
+glGetIntegerv(GL_RENDERBUFFER_FREE_MEMORY_ATI, i);
+printf("Renderbuffer free memory - total: %u MB, largest block: %u 
MB\n",
+   i[0] / 1024, i[1] / 1024);
+printf("Renderbuffer free aux. memory - total: %u MB, largest block: %u 
MB\n",
+   i[2] / 1024, i[3] / 1024);
+#endif
+}
+
+
+static void
+query_NVX_gpu_memory_info(void)
+{
+#ifdef GL_NVX_gpu_memory_info
+int i;
+
+printf("Memory info (GL_NVX_gpu_memory_info):\n");
+
+glGetIntegerv(GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, );
+printf("Dedicated video memory: %u MB\n", i / 1024);
+
+glGetIntegerv(GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, );
+printf("Total available memory: %u MB\n", i / 1024);
+
+glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, );
+printf("Currently available dedicated video memory: %u MB\n", i / 
1024);
+#endif
+}
+
+
  static Bool
  print_screen_info(Display *dpy, int scrnum,
const struct options *opts,
@@ -547,6 +596,10 @@ print_screen_info(Display *dpy, int scrnum,
   }
   if (strstr(glxExtensions, "GLX_MESA_query_renderer"))
query_renderer();
+ if (strstr(glExtensions, "GL_ATI_meminfo"))
+query_ATI_meminfo();
+ if (strstr(glExtensions, "GL_NVX_gpu_memory_info"))
+query_NVX_gpu_memory_info();
   printf("OpenGL vendor string: %s\n", glVendor);
   printf("OpenGL renderer string: %s\n", glRenderer);
} else



If these extensions are also available on Windows (I bet they are) then 
this code should go into the glinfo_common.c file.


-Brian

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


Re: [Mesa-dev] [PATCH 2/5] mesa: implement GL_NVX_gpu_memory_info

2016-02-02 Thread Roland Scheidegger
Does anyone use these extensions?
I suppose maybe to get the total amount of video memory?
From the dynamic counts, I would have thought the eviction one would be
the most interesting, but this one isn't implemented. Ah well I guess a
sloppily implemented extension is better than none.

Roland

Am 02.02.2016 um 14:45 schrieb Marek Olšák:
> From: Marek Olšák 
> 
> ---
>  src/mapi/glapi/gen/gl_API.xml|  8 
>  src/mesa/main/dd.h   | 10 ++
>  src/mesa/main/extensions_table.h |  1 +
>  src/mesa/main/get.c  | 30 ++
>  src/mesa/main/get_hash_params.py |  7 +++
>  src/mesa/main/mtypes.h   |  1 +
>  6 files changed, 57 insertions(+)
> 
> diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
> index d7ab3bf..09dda19 100644
> --- a/src/mapi/glapi/gen/gl_API.xml
> +++ b/src/mapi/glapi/gen/gl_API.xml
> @@ -12714,6 +12714,14 @@
>  
>  
>  
> +
> + />
> + />
> + />
> + />
> + />
> +
> +
>   xmlns:xi="http://www.w3.org/2001/XInclude"/>
>  
>  
> diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
> index d4378e5..d34e610 100644
> --- a/src/mesa/main/dd.h
> +++ b/src/mesa/main/dd.h
> @@ -939,6 +939,16 @@ struct dd_function_table {
> void (*DispatchCompute)(struct gl_context *ctx, const GLuint *num_groups);
> void (*DispatchComputeIndirect)(struct gl_context *ctx, GLintptr 
> indirect);
> /*@}*/
> +
> +   /**
> +* Query information about memory. Device memory is e.g. VRAM. Staging
> +* memory is e.g. GART. All sizes are in kilobytes.
> +*/
> +   void (*QueryMemoryInfo)(struct gl_context *ctx,
> +   unsigned *total_device_memory,
> +   unsigned *avail_device_memory,
> +   unsigned *total_staging_memory,
> +   unsigned *avail_staging_memory);
>  };
>  
>  
> diff --git a/src/mesa/main/extensions_table.h 
> b/src/mesa/main/extensions_table.h
> index ad5dc60..dfccb73 100644
> --- a/src/mesa/main/extensions_table.h
> +++ b/src/mesa/main/extensions_table.h
> @@ -291,6 +291,7 @@ EXT(NV_texture_barrier  , 
> NV_texture_barrier
>  EXT(NV_texture_env_combine4 , NV_texture_env_combine4
> , GLL,  x ,  x ,  x , 1999)
>  EXT(NV_texture_rectangle, NV_texture_rectangle   
> , GLL,  x ,  x ,  x , 2000)
>  EXT(NV_vdpau_interop, NV_vdpau_interop   
> , GLL, GLC,  x ,  x , 2010)
> +EXT(NVX_gpu_memory_info , NVX_gpu_memory_info
> , GLL, GLC,  x ,  x , 2013)
>  
>  EXT(OES_EGL_image   , OES_EGL_image  
> , GLL, GLC, ES1, ES2, 2006) /* FIXME: Mesa expects GL_OES_EGL_image 
> to be available in OpenGL contexts. */
>  EXT(OES_EGL_image_external  , OES_EGL_image_external 
> ,  x ,  x , ES1, ES2, 2010)
> diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
> index 0434836..dbc8605 100644
> --- a/src/mesa/main/get.c
> +++ b/src/mesa/main/get.c
> @@ -449,6 +449,7 @@ EXTRA_EXT(ARB_tessellation_shader);
>  EXTRA_EXT(ARB_shader_subroutine);
>  EXTRA_EXT(ARB_shader_storage_buffer_object);
>  EXTRA_EXT(ARB_indirect_parameters);
> +EXTRA_EXT(NVX_gpu_memory_info);
>  
>  static const int
>  extra_ARB_color_buffer_float_or_glcore[] = {
> @@ -1080,6 +1081,35 @@ find_custom_value(struct gl_context *ctx, const struct 
> value_desc *d, union valu
> case GL_DISPATCH_INDIRECT_BUFFER_BINDING:
>v->value_int = ctx->DispatchIndirectBuffer->Name;
>break;
> +   /* GL_NVX_gpu_memory_info */
> +   case GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX:
> +   case GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX:
> +   case GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX:
> +  {
> + unsigned total_device_memory;
> + unsigned avail_device_memory;
> + unsigned total_staging_memory;
> + unsigned avail_staging_memory;
> +
> + ctx->Driver.QueryMemoryInfo(ctx,
> + _device_memory,
> + _device_memory,
> + _staging_memory,
> + _staging_memory);
> +
> + if (d->pname == GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX)
> +v->value_int = total_device_memory;
> + else if (d->pname == GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX)
> +v->value_int = total_device_memory + total_staging_memory;
> + else if (d->pname == 
> GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX)
> +v->value_int = avail_device_memory;
> +  }
> +  break;
> +   case GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX:
> +   case GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX:
> +  /* not interested in returning anything useful here */
> +  v->value_int = 0;
> +  

Re: [Mesa-dev] [PATCH 2/4] i965: Provide sse2 version for rgba8 <-> bgra8 swizzle

2016-02-02 Thread Roland Scheidegger
Ok I'm going to revert it.

Note though this hits an assertion which is completely independent of
the added code. This means it works before this patch because you didn't
compile with ssse3 enabled - apparently the existing code is broken and
just relies on compile flags to not get hit...
This should probably be fixed for real regardless...

Roland



Am 02.02.2016 um 09:29 schrieb Lofstedt, Marta:
> Hi Roland and Matt,
> 
> I am sorry, but this patch segfaults/asserts Kronos CTS - 
> ES2-CTS.gtf.GL2FixedTests.scissor.scissor
> 
> I created this bug:
> https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.freedesktop.org_show-5Fbug.cgi-3Fid-3D93962=BQIGaQ=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs=Vjtt0vs_iqoI31UfJxBl7yv9I2FeiaeAYgMTLKRBc_I=nGNQk9Ygig92I2slinye-TToGAmNP8dl5F9AsSX4ehA=SDe7EPcjhDRUb5DigMCXHdn9TJ9l7Y1ealds8cJo-PM=
>  
> 
> I also added the bug to the OpenGL ES 3.1 tracker bug, since it blocks CTS 
> testing.
> https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.freedesktop.org_show-5Fbug.cgi-3Fid-3D92788=BQIGaQ=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs=Vjtt0vs_iqoI31UfJxBl7yv9I2FeiaeAYgMTLKRBc_I=nGNQk9Ygig92I2slinye-TToGAmNP8dl5F9AsSX4ehA=uowtFMWBy9fKM5iN6ZsSGHoOLkYskpAvf4coEYs3ESg=
>  
> 
> 
> /Marta
> 
>> -Original Message-
>> From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On
>> Behalf Of Roland Scheidegger
>> Sent: Friday, January 29, 2016 2:18 AM
>> To: Matt Turner
>> Cc: mesa-dev@lists.freedesktop.org
>> Subject: Re: [Mesa-dev] [PATCH 2/4] i965: Provide sse2 version for rgba8 <->
>> bgra8 swizzle
>>
>> Am 29.01.2016 um 00:31 schrieb Matt Turner:
>>> On Sun, Jan 17, 2016 at 1:49 PM,   wrote:
 From: Roland Scheidegger 

 The existing code used ssse3, and because it isn't compiled in a
 separate file compiled with that, it is usually not used (that, of
 course, could be fixed...), whereas sse2 is always present at least with
>> 64bit builds.
 It is actually trivial to do with sse2 without pshufb, on some cpus
 (I'm looking at you, atom!) it might not even be slower.
 This is compile-tested only, it doesn't actually do what I really
 want (which is glReadPixels without doing byte access from an
 uncached region, which is what you'll get on intel chips not having
 llc, if your cpu doesn't support sse41 (in which case the rb would be
 copied over with movntdqa instead of mapped, so mesa format_utils
 byte swapping conversion will then access the cached region instead
 of the uncached one) - really need sse2-optimized convert_ubyte
 functions for a proper fix, otherwise google maps in firefox is
 reduced to fps below 1 fps), but hey why not. I don't have a gpu which
>> could possibly hit this, albeit I succesfully used the exact same code
>> elsewhere.
>>>
>>> Bah, wall of text!
>>>
>>> I don't think we need all this. The commit title says everything I
>>> think it needs to say.
>>>
 v2: fix andnot argument order, add comments
 ---
  src/mesa/drivers/dri/i965/intel_mipmap_tree.c  | 18 +++
 src/mesa/drivers/dri/i965/intel_tiled_memcpy.c | 73
 +-
  2 files changed, 79 insertions(+), 12 deletions(-)

 diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
 b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
 index 108dd87..5fc4212 100644
 --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
 +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
 @@ -2773,6 +2773,24 @@ intel_miptree_map(struct brw_context *brw,
 } else if (!(mode & GL_MAP_WRITE_BIT) &&
!mt->compressed && cpu_has_sse4_1 &&
(mt->pitch % 16 == 0)) {
 +  /*
 +   * XXX: without sse4_1, in some situations still really want to copy
 +   * regardless. Presumably this is not done for performance reasons -
 +   * with movntdqa thanks to the 64byte streaming load buffer the
 +   * uncached->cached copy followed by cached->cached later is always
 +   * faster than doing "ordinary" uncached->cached copy.
 +   * Without movntdqa, of course an additional copy doesn't help,
>> albeit
 +   * it has to be said the uncached->cached one is an order of
>> magnitude
 +   * slower than the later cached->cached one in any case.
 +   * But mesa may not do a simple memcpy on that memory later -
>> some
 +   * glReadPixels paths for instance will well hit per-byte access 
 which
 +   * is a complete performance killer on uncached memory. So in these
 +   * cases really want to copy regardless, unless the map below could
 +   * play some tricks making the memory cached.
 +   * (Or otherwise ensure mesa can't hit these paths often, for 
 instance
 +   * glReadPixels requiring conversions could be handled by meta, so 
 in
 +   * end it really would be 

Re: [Mesa-dev] [PATCH V2] glsl: disable varying packing when its not safe

2016-02-02 Thread Samuel Iglesias Gonsálvez
Sorry for the delay, I was at FOSDEM and now I am catching up email.

I will take a look at it tomorrow.

Thanks,

Sam

On Tue, 2016-02-02 at 16:50 +1100, Timothy Arceri wrote:
> In GLES 3.1+ and GL 4.4+ there is no guarantee that interpolation
> qualifiers will match between stages so we cannot safely pack
> varyings using the current packing pass in Mesa.
> 
> We also disable packing on outward facing SSO as these too are
> outside
> the rule that guarantees the interpolation qualifiers match.
> 
> We do however enable packing on individual arrays, structs, and
> matrices as these are required by the transform feedback code and it
> is still safe to do so.
> 
> Finally we also enable packing when a varying is only used for
> transform feedback and its not a SSO.
> 
> This fixes all remaining rendering issues with the dEQP SSO tests,
> the only issues remaining with thoses tests are to do with
> validation.
> 
> Note: There is still one remaining SSO bug that this patch doesn't
> fix.
> Their is a chance that VS -> TCS will have mismatching interfaces
> because we pack VS output in case its used by transform feedback but
> don't pack TCS input for performance reasons. This patch will make
> the
> situation better but doesn't fix it.
> 
> V2: Make is_varying_packing_safe() a function in the varying_matches
> class, fix spelling (Matt) and make sure to remove the outer array
> when dealing with Geom and Tess shaders where appropriate.
> Lastly fix piglit regression in new piglit test and document the
> undefined behaviour it depends on:
> arb_separate_shader_objects/execution/vs-gs-linking.shader_test
> 
> Cc: Samuel Iglesias Gonsálvez 
> Cc: Tapani Pälli 
> ---
>  This patch applies on top of my ARB_enhanced_layouts component
> packing
>  series [1].
> 
>  The GLES 3.1 and GL 4.4 changes were tested by changing the code to
>  always disable packing and running the changes in Intel CI system.
>  
>  This patch would also make it possible for a backend to do less
> packing
>  in GLSL IR if it wished to do so now that the transform feedback
> requirements
>  have been isolated. 
> 
>  [1] http://patchwork.freedesktop.org/series/2101/
> 
>  src/compiler/glsl/ir.h  |   7 +
>  src/compiler/glsl/ir_optimization.h |   2 +-
>  src/compiler/glsl/link_varyings.cpp | 214
> +---
>  src/compiler/glsl/lower_packed_varyings.cpp |  37 +++--
>  4 files changed, 202 insertions(+), 58 deletions(-)
> 
> diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h
> index e4513f0..83bb74b 100644
> --- a/src/compiler/glsl/ir.h
> +++ b/src/compiler/glsl/ir.h
> @@ -736,6 +736,13 @@ public:
>    unsigned is_unmatched_generic_inout:1;
>  
>    /**
> +   * Is this varying used only by transform feedback?
> +   *
> +   * This is used by the linker to decide if its safe to pack
> the varying.
> +   */
> +  unsigned is_xfb_only:1;
> +
> +  /**
> * If non-zero, then this variable may be packed along with
> other variables
> * into a single varying slot, so this offset should be
> applied when
> * accessing components.  For example, an offset of 1 means
> that the x
> diff --git a/src/compiler/glsl/ir_optimization.h
> b/src/compiler/glsl/ir_optimization.h
> index a115c46..e201242 100644
> --- a/src/compiler/glsl/ir_optimization.h
> +++ b/src/compiler/glsl/ir_optimization.h
> @@ -126,7 +126,7 @@ void lower_packed_varyings(void *mem_ctx,
> unsigned locations_used, ir_variable_mode
> mode,
> gl_shader *shader, unsigned
> base_location,
> bool disable_varying_packing,
> -   bool has_enhanced_layouts);
> +   bool xfb_enabled, bool
> has_enhanced_layouts);
>  bool lower_vector_insert(exec_list *instructions, bool
> lower_nonconstant_index);
>  bool lower_vector_derefs(gl_shader *shader);
>  void lower_named_interface_blocks(void *mem_ctx, gl_shader *shader);
> diff --git a/src/compiler/glsl/link_varyings.cpp
> b/src/compiler/glsl/link_varyings.cpp
> index 2974e76..8efaa33 100644
> --- a/src/compiler/glsl/link_varyings.cpp
> +++ b/src/compiler/glsl/link_varyings.cpp
> @@ -878,7 +878,7 @@ namespace {
>  class varying_matches
>  {
>  public:
> -   varying_matches(bool disable_varying_packing,
> +   varying_matches(bool disable_varying_packing, bool xfb_enabled,
> gl_shader_stage producer_stage,
> gl_shader_stage consumer_stage);
> ~varying_matches();
> @@ -888,14 +888,30 @@ public:
> void store_locations() const;
>  
>  private:
> +   bool is_varying_packing_safe(const glsl_type *type,
> +const ir_variable *var);
> +
> /**
>  * If true, this driver disables varying packing, so all varyings
> need to
>  * be aligned on slot boundaries, and take up a number of slots
> 

Re: [Mesa-dev] [PATCH 0/5] Memory info extensions

2016-02-02 Thread Alex Deucher
On Tue, Feb 2, 2016 at 8:44 AM, Marek Olšák  wrote:
> Hi,
>
> The motivation behind this is to allow games that use proprietary extensions 
> to query the amount of VRAM to be able to query it with Mesa too. Such games 
> are unlikely to use GLX_MESA_query_renderer in the foreseeable feature.
>
> Unreal Engine 3 does use one of these. Despite that, it doesn't help. UE3 is 
> unable to use advanced graphics and increase its GPU memory pool size even 
> with these extensions.

Some games use the renderer stings to make decisions about these sort of things.

Alex

>
> Anyway, I'd like to merge this.
>
> I don't plan to add a piglit, but I have a patch which adds support for both 
> extensions to glxinfo.
>
> Please review.
>
>  src/gallium/drivers/freedreno/freedreno_screen.c |  1 +
>  src/gallium/drivers/i915/i915_screen.c   |  1 +
>  src/gallium/drivers/ilo/ilo_screen.c |  1 +
>  src/gallium/drivers/llvmpipe/lp_screen.c |  1 +
>  src/gallium/drivers/nouveau/nv30/nv30_screen.c   |  1 +
>  src/gallium/drivers/nouveau/nv50/nv50_screen.c   |  1 +
>  src/gallium/drivers/nouveau/nvc0/nvc0_screen.c   |  1 +
>  src/gallium/drivers/r300/r300_screen.c   |  1 +
>  src/gallium/drivers/r600/r600_pipe.c |  1 +
>  src/gallium/drivers/radeon/r600_pipe_common.c| 35 
> +++
>  src/gallium/drivers/radeonsi/si_pipe.c   |  1 +
>  src/gallium/drivers/softpipe/sp_screen.c |  1 +
>  src/gallium/drivers/svga/svga_screen.c   |  1 +
>  src/gallium/drivers/vc4/vc4_screen.c |  1 +
>  src/gallium/include/pipe/p_defines.h |  1 +
>  src/gallium/include/pipe/p_screen.h  |  6 ++
>  src/gallium/include/pipe/p_state.h   | 11 +++
>  src/mapi/glapi/gen/gl_API.xml| 14 ++
>  src/mesa/main/dd.h   | 10 ++
>  src/mesa/main/extensions_table.h |  2 ++
>  src/mesa/main/get.c  | 54 
> ++
>  src/mesa/main/get_hash_params.py | 12 
>  src/mesa/main/mtypes.h   |  2 ++
>  src/mesa/state_tracker/st_context.c  | 23 +++
>  src/mesa/state_tracker/st_extensions.c   |  2 ++
>  25 files changed, 185 insertions(+)
>
> Marek
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 93820] Change from Mesa 10 to 11 made remote opengl stop working

2016-02-02 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=93820

--- Comment #5 from Christoph Weiss  ---
Thanks for the feedback, +iglx indeed makes everything work again, also with
Mesa 11!

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


[Mesa-dev] [Bug 93820] Change from Mesa 10 to 11 made remote opengl stop working

2016-02-02 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=93820

--- Comment #6 from Jason Ekstrand  ---
(In reply to Ian Romanick from comment #4)
> (In reply to Ilia Mirkin from comment #3)
> > http://cgit.freedesktop.org/xorg/xserver/commit/?id=d0da0e9c3
> > 
> > Apparently Xorg 1.17 disables indirect GLX by default. Try starting the X
> > server with +iglx.
> 
> Ugh.  Is there a way to detect that?  I'd like to change the piglit tests to
> SKIP instead of FAIL in these conditions.

Sure.  If the test is taking to X directly (I would assume it is of it's
explicitly testing indirect rendering), you should be able to just query for
the AIGLX extension.

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


Re: [Mesa-dev] [android-x86-devel] Announcement: 5 patches to fix building errors with android-x86

2016-02-02 Thread Mauro Rossi
> I've submitted similar set to mesa list on Friday. 1, 2, 4, and 5
> appear to be similar.
>
> Rob


Thanks Rob,
I need to watch more carefully the mesa-dev archives next time

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


Re: [Mesa-dev] [RFCv3 05/11] nir: add lowering pass for y-transform

2016-02-02 Thread Marek Olšák
On Mon, Feb 1, 2016 at 5:00 PM, Connor Abbott  wrote:
> On Sun, Jan 31, 2016 at 3:16 PM, Rob Clark  wrote:
>> From: Rob Clark 
>>
>> Signed-off-by: Rob Clark 
>> ---
>>  src/compiler/Makefile.sources|   1 +
>>  src/compiler/nir/nir.h   |  12 +
>>  src/compiler/nir/nir_lower_wpos_ytransform.c | 317 
>> +++
>>  3 files changed, 330 insertions(+)
>>  create mode 100644 src/compiler/nir/nir_lower_wpos_ytransform.c
>>
>> diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources
>> index c9780d6..26c4c65 100644
>> --- a/src/compiler/Makefile.sources
>> +++ b/src/compiler/Makefile.sources
>> @@ -200,6 +200,7 @@ NIR_FILES = \
>> nir/nir_lower_vars_to_ssa.c \
>> nir/nir_lower_var_copies.c \
>> nir/nir_lower_vec_to_movs.c \
>> +   nir/nir_lower_wpos_ytransform.c \
>> nir/nir_metadata.c \
>> nir/nir_move_vec_src_uses_to_dest.c \
>> nir/nir_normalize_cubemap_coords.c \
>> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
>> index 67fe079..a973a44 100644
>> --- a/src/compiler/nir/nir.h
>> +++ b/src/compiler/nir/nir.h
>> @@ -2119,6 +2119,18 @@ void nir_lower_clip_fs(nir_shader *shader, unsigned 
>> ucp_enables);
>>
>>  void nir_lower_two_sided_color(nir_shader *shader);
>>
>> +
>> +typedef struct nir_lower_wpos_ytransform_options {
>> +   int state_tokens[5];
>
> AFAIK the state slot stuff is only used for old assembly shaders. Why
> are we using it here?

The state slot stuff is used everywhere, including GLSL.

>
>> +   bool fs_coord_origin_upper_left :1;
>> +   bool fs_coord_origin_lower_left :1;
>> +   bool fs_coord_pixel_center_integer :1;
>> +   bool fs_coord_pixel_center_half_integer :1;
>> +} nir_lower_wpos_ytransform_options;
>> +
>> +bool nir_lower_wpos_ytransform(nir_shader *shader,
>> +   const nir_lower_wpos_ytransform_options 
>> *options);
>> +
>>  void nir_lower_atomics(nir_shader *shader,
>> const struct gl_shader_program *shader_program);
>>  void nir_lower_to_source_mods(nir_shader *shader);
>> diff --git a/src/compiler/nir/nir_lower_wpos_ytransform.c 
>> b/src/compiler/nir/nir_lower_wpos_ytransform.c
>> new file mode 100644
>> index 000..89d160b
>> --- /dev/null
>> +++ b/src/compiler/nir/nir_lower_wpos_ytransform.c
>> @@ -0,0 +1,317 @@
>> +/*
>> + * Copyright © 2015 Red Hat
>> + *
>> + * Permission is hereby granted, free of charge, to any person obtaining a
>> + * copy of this software and associated documentation files (the 
>> "Software"),
>> + * to deal in the Software without restriction, including without limitation
>> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
>> + * and/or sell copies of the Software, and to permit persons to whom the
>> + * Software is furnished to do so, subject to the following conditions:
>> + *
>> + * The above copyright notice and this permission notice (including the next
>> + * paragraph) shall be included in all copies or substantial portions of the
>> + * Software.
>> + *
>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
>> OR
>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
>> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 
>> OTHER
>> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
>> FROM,
>> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 
>> IN THE
>> + * SOFTWARE.
>> + */
>> +
>> +#include "nir.h"
>> +#include "nir_builder.h"
>> +
>> +/* Lower gl_FragCoord (and fddy) to account for driver's requested 
>> coordinate-
>> + * origin and pixel-center vs. shader.  If transformation is required, a
>> + * gl_FbWposYTransform uniform is inserted (with the specified state-slots)
>> + * and additional instructions are inserted to transform gl_FragCoord (and
>> + * fddy src arg).
>> + *
>> + * This is based on the logic in emit_wpos()/emit_wpos_adjustment() in TGSI
>> + * compiler.
>> + *
>> + * Run before nir_lower_io.
>> + */
>> +
>> +typedef struct {
>> +   const nir_lower_wpos_ytransform_options *options;
>> +   nir_shader   *shader;
>> +   nir_builder   b;
>> +   nir_variable *transform;
>> +} lower_wpos_ytransform_state;
>> +
>> +static nir_ssa_def *
>> +get_transform(lower_wpos_ytransform_state *state)
>> +{
>> +   if (state->transform == NULL) {
>> +  /* NOTE: name must be prefixed w/ "gl_" to trigger slot based
>> +   * special handling in uniform setup:
>> +   */
>> +  nir_variable *var = nir_variable_create(state->shader,
>> +  nir_var_uniform,
>> +  glsl_vec4_type(),
>> +  

[Mesa-dev] [PATCH 0/5] Memory info extensions

2016-02-02 Thread Marek Olšák
Hi,

The motivation behind this is to allow games that use proprietary extensions to 
query the amount of VRAM to be able to query it with Mesa too. Such games are 
unlikely to use GLX_MESA_query_renderer in the foreseeable feature.

Unreal Engine 3 does use one of these. Despite that, it doesn't help. UE3 is 
unable to use advanced graphics and increase its GPU memory pool size even with 
these extensions.

Anyway, I'd like to merge this.

I don't plan to add a piglit, but I have a patch which adds support for both 
extensions to glxinfo.

Please review.

 src/gallium/drivers/freedreno/freedreno_screen.c |  1 +
 src/gallium/drivers/i915/i915_screen.c   |  1 +
 src/gallium/drivers/ilo/ilo_screen.c |  1 +
 src/gallium/drivers/llvmpipe/lp_screen.c |  1 +
 src/gallium/drivers/nouveau/nv30/nv30_screen.c   |  1 +
 src/gallium/drivers/nouveau/nv50/nv50_screen.c   |  1 +
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c   |  1 +
 src/gallium/drivers/r300/r300_screen.c   |  1 +
 src/gallium/drivers/r600/r600_pipe.c |  1 +
 src/gallium/drivers/radeon/r600_pipe_common.c| 35 
+++
 src/gallium/drivers/radeonsi/si_pipe.c   |  1 +
 src/gallium/drivers/softpipe/sp_screen.c |  1 +
 src/gallium/drivers/svga/svga_screen.c   |  1 +
 src/gallium/drivers/vc4/vc4_screen.c |  1 +
 src/gallium/include/pipe/p_defines.h |  1 +
 src/gallium/include/pipe/p_screen.h  |  6 ++
 src/gallium/include/pipe/p_state.h   | 11 +++
 src/mapi/glapi/gen/gl_API.xml| 14 ++
 src/mesa/main/dd.h   | 10 ++
 src/mesa/main/extensions_table.h |  2 ++
 src/mesa/main/get.c  | 54 
++
 src/mesa/main/get_hash_params.py | 12 
 src/mesa/main/mtypes.h   |  2 ++
 src/mesa/state_tracker/st_context.c  | 23 +++
 src/mesa/state_tracker/st_extensions.c   |  2 ++
 25 files changed, 185 insertions(+)

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


[Mesa-dev] [PATCH 4/5] st/mesa: implement and enable memory info extensions

2016-02-02 Thread Marek Olšák
From: Marek Olšák 

---
 src/mesa/state_tracker/st_context.c| 23 +++
 src/mesa/state_tracker/st_extensions.c |  2 ++
 2 files changed, 25 insertions(+)

diff --git a/src/mesa/state_tracker/st_context.c 
b/src/mesa/state_tracker/st_context.c
index ff9135f..0970de2 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -97,6 +97,28 @@ static void st_Enable(struct gl_context * ctx, GLenum cap, 
GLboolean state)
 
 
 /**
+ * Called via ctx->Driver.QueryMemoryInfo()
+ */
+static void
+st_query_memory_info(struct gl_context *ctx,
+ unsigned *total_device_memory,
+ unsigned *avail_device_memory,
+ unsigned *total_staging_memory,
+ unsigned *avail_staging_memory)
+{
+   struct pipe_screen *screen = st_context(ctx)->pipe->screen;
+   struct pipe_memory_info info;
+
+   screen->query_memory_info(screen, );
+
+   *total_device_memory = info.total_device_memory;
+   *avail_device_memory = info.avail_device_memory;
+   *total_staging_memory = info.total_staging_memory;
+   *avail_staging_memory = info.avail_staging_memory;
+}
+
+
+/**
  * Called via ctx->Driver.UpdateState()
  */
 void st_invalidate_state(struct gl_context * ctx, GLbitfield new_state)
@@ -489,4 +511,5 @@ void st_init_driver_functions(struct pipe_screen *screen,
 
functions->Enable = st_Enable;
functions->UpdateState = st_invalidate_state;
+   functions->QueryMemoryInfo = st_query_memory_info;
 }
diff --git a/src/mesa/state_tracker/st_extensions.c 
b/src/mesa/state_tracker/st_extensions.c
index d066784..f4b2e77 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -526,12 +526,14 @@ void st_init_extensions(struct pipe_screen *screen,
   { o(EXT_transform_feedback),   
PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS},
 
   { o(AMD_pinned_memory),
PIPE_CAP_RESOURCE_FROM_USER_MEMORY},
+  { o(ATI_meminfo),  PIPE_CAP_QUERY_MEMORY_INFO
},
   { o(AMD_seamless_cubemap_per_texture), 
PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE},
   { o(ATI_separate_stencil), PIPE_CAP_TWO_SIDED_STENCIL
},
   { o(ATI_texture_mirror_once),  PIPE_CAP_TEXTURE_MIRROR_CLAMP 
},
   { o(NV_conditional_render),PIPE_CAP_CONDITIONAL_RENDER   
},
   { o(NV_primitive_restart), PIPE_CAP_PRIMITIVE_RESTART
},
   { o(NV_texture_barrier),   PIPE_CAP_TEXTURE_BARRIER  
},
+  { o(NVX_gpu_memory_info),  PIPE_CAP_QUERY_MEMORY_INFO
},
   /* GL_NV_point_sprite is not supported by gallium because we don't
* support the GL_POINT_SPRITE_R_MODE_NV option. */
 
-- 
2.1.4

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


[Mesa-dev] [PATCH 2/5] mesa: implement GL_NVX_gpu_memory_info

2016-02-02 Thread Marek Olšák
From: Marek Olšák 

---
 src/mapi/glapi/gen/gl_API.xml|  8 
 src/mesa/main/dd.h   | 10 ++
 src/mesa/main/extensions_table.h |  1 +
 src/mesa/main/get.c  | 30 ++
 src/mesa/main/get_hash_params.py |  7 +++
 src/mesa/main/mtypes.h   |  1 +
 6 files changed, 57 insertions(+)

diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index d7ab3bf..09dda19 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -12714,6 +12714,14 @@
 
 
 
+
+
+
+
+
+
+
+
 http://www.w3.org/2001/XInclude"/>
 
 
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index d4378e5..d34e610 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -939,6 +939,16 @@ struct dd_function_table {
void (*DispatchCompute)(struct gl_context *ctx, const GLuint *num_groups);
void (*DispatchComputeIndirect)(struct gl_context *ctx, GLintptr indirect);
/*@}*/
+
+   /**
+* Query information about memory. Device memory is e.g. VRAM. Staging
+* memory is e.g. GART. All sizes are in kilobytes.
+*/
+   void (*QueryMemoryInfo)(struct gl_context *ctx,
+   unsigned *total_device_memory,
+   unsigned *avail_device_memory,
+   unsigned *total_staging_memory,
+   unsigned *avail_staging_memory);
 };
 
 
diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h
index ad5dc60..dfccb73 100644
--- a/src/mesa/main/extensions_table.h
+++ b/src/mesa/main/extensions_table.h
@@ -291,6 +291,7 @@ EXT(NV_texture_barrier  , 
NV_texture_barrier
 EXT(NV_texture_env_combine4 , NV_texture_env_combine4  
  , GLL,  x ,  x ,  x , 1999)
 EXT(NV_texture_rectangle, NV_texture_rectangle 
  , GLL,  x ,  x ,  x , 2000)
 EXT(NV_vdpau_interop, NV_vdpau_interop 
  , GLL, GLC,  x ,  x , 2010)
+EXT(NVX_gpu_memory_info , NVX_gpu_memory_info  
  , GLL, GLC,  x ,  x , 2013)
 
 EXT(OES_EGL_image   , OES_EGL_image
  , GLL, GLC, ES1, ES2, 2006) /* FIXME: Mesa expects GL_OES_EGL_image to be 
available in OpenGL contexts. */
 EXT(OES_EGL_image_external  , OES_EGL_image_external   
  ,  x ,  x , ES1, ES2, 2010)
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 0434836..dbc8605 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -449,6 +449,7 @@ EXTRA_EXT(ARB_tessellation_shader);
 EXTRA_EXT(ARB_shader_subroutine);
 EXTRA_EXT(ARB_shader_storage_buffer_object);
 EXTRA_EXT(ARB_indirect_parameters);
+EXTRA_EXT(NVX_gpu_memory_info);
 
 static const int
 extra_ARB_color_buffer_float_or_glcore[] = {
@@ -1080,6 +1081,35 @@ find_custom_value(struct gl_context *ctx, const struct 
value_desc *d, union valu
case GL_DISPATCH_INDIRECT_BUFFER_BINDING:
   v->value_int = ctx->DispatchIndirectBuffer->Name;
   break;
+   /* GL_NVX_gpu_memory_info */
+   case GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX:
+   case GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX:
+   case GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX:
+  {
+ unsigned total_device_memory;
+ unsigned avail_device_memory;
+ unsigned total_staging_memory;
+ unsigned avail_staging_memory;
+
+ ctx->Driver.QueryMemoryInfo(ctx,
+ _device_memory,
+ _device_memory,
+ _staging_memory,
+ _staging_memory);
+
+ if (d->pname == GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX)
+v->value_int = total_device_memory;
+ else if (d->pname == GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX)
+v->value_int = total_device_memory + total_staging_memory;
+ else if (d->pname == GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX)
+v->value_int = avail_device_memory;
+  }
+  break;
+   case GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX:
+   case GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX:
+  /* not interested in returning anything useful here */
+  v->value_int = 0;
+  break;
}
 }
 
diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
index 04aec03..be4e030 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -847,6 +847,13 @@ descriptor=[
 # GL_ARB_shader_storage_buffer_object
   [ "MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS", 
"CONTEXT_INT(Const.Program[MESA_SHADER_TESS_CTRL].MaxShaderStorageBlocks), 
extra_ARB_shader_storage_buffer_object" ],
   [ "MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS", 
"CONTEXT_INT(Const.Program[MESA_SHADER_TESS_EVAL].MaxShaderStorageBlocks), 

[Mesa-dev] [PATCH 1/5] gallium: add interface for querying memory usage and sizes

2016-02-02 Thread Marek Olšák
From: Marek Olšák 

If you're worried about the duplication of some CAPs, we can remove them
later.
---
 src/gallium/drivers/freedreno/freedreno_screen.c |  1 +
 src/gallium/drivers/i915/i915_screen.c   |  1 +
 src/gallium/drivers/ilo/ilo_screen.c |  1 +
 src/gallium/drivers/llvmpipe/lp_screen.c |  1 +
 src/gallium/drivers/nouveau/nv30/nv30_screen.c   |  1 +
 src/gallium/drivers/nouveau/nv50/nv50_screen.c   |  1 +
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c   |  1 +
 src/gallium/drivers/r300/r300_screen.c   |  1 +
 src/gallium/drivers/r600/r600_pipe.c |  1 +
 src/gallium/drivers/radeonsi/si_pipe.c   |  1 +
 src/gallium/drivers/softpipe/sp_screen.c |  1 +
 src/gallium/drivers/svga/svga_screen.c   |  1 +
 src/gallium/drivers/vc4/vc4_screen.c |  1 +
 src/gallium/include/pipe/p_defines.h |  1 +
 src/gallium/include/pipe/p_screen.h  |  6 ++
 src/gallium/include/pipe/p_state.h   | 11 +++
 16 files changed, 31 insertions(+)

diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c 
b/src/gallium/drivers/freedreno/freedreno_screen.c
index 640f50f..639a9e6 100644
--- a/src/gallium/drivers/freedreno/freedreno_screen.c
+++ b/src/gallium/drivers/freedreno/freedreno_screen.c
@@ -165,6 +165,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
case PIPE_CAP_TEXTURE_BARRIER:
case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
case PIPE_CAP_COMPUTE:
+   case PIPE_CAP_QUERY_MEMORY_INFO:
return 0;
 
case PIPE_CAP_SM3:
diff --git a/src/gallium/drivers/i915/i915_screen.c 
b/src/gallium/drivers/i915/i915_screen.c
index 6b0ab58..3d5867b 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -262,6 +262,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap 
cap)
case PIPE_CAP_INVALIDATE_BUFFER:
case PIPE_CAP_GENERATE_MIPMAP:
case PIPE_CAP_STRING_MARKER:
+   case PIPE_CAP_QUERY_MEMORY_INFO:
   return 0;
 
case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS:
diff --git a/src/gallium/drivers/ilo/ilo_screen.c 
b/src/gallium/drivers/ilo/ilo_screen.c
index 5171cca..ec91b90 100644
--- a/src/gallium/drivers/ilo/ilo_screen.c
+++ b/src/gallium/drivers/ilo/ilo_screen.c
@@ -486,6 +486,7 @@ ilo_get_param(struct pipe_screen *screen, enum pipe_cap 
param)
case PIPE_CAP_INVALIDATE_BUFFER:
case PIPE_CAP_GENERATE_MIPMAP:
case PIPE_CAP_STRING_MARKER:
+   case PIPE_CAP_QUERY_MEMORY_INFO:
   return 0;
 
case PIPE_CAP_VENDOR_ID:
diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c 
b/src/gallium/drivers/llvmpipe/lp_screen.c
index 879a2e7..5637617 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -311,6 +311,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum 
pipe_cap param)
case PIPE_CAP_INVALIDATE_BUFFER:
case PIPE_CAP_GENERATE_MIPMAP:
case PIPE_CAP_STRING_MARKER:
+   case PIPE_CAP_QUERY_MEMORY_INFO:
   return 0;
}
/* should only get here on unhandled cases */
diff --git a/src/gallium/drivers/nouveau/nv30/nv30_screen.c 
b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
index 61d91fd..5524787 100644
--- a/src/gallium/drivers/nouveau/nv30/nv30_screen.c
+++ b/src/gallium/drivers/nouveau/nv30/nv30_screen.c
@@ -184,6 +184,7 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
case PIPE_CAP_INVALIDATE_BUFFER:
case PIPE_CAP_GENERATE_MIPMAP:
case PIPE_CAP_STRING_MARKER:
+   case PIPE_CAP_QUERY_MEMORY_INFO:
   return 0;
 
case PIPE_CAP_VENDOR_ID:
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c 
b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
index 32da60e..bdf4f02 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
@@ -227,6 +227,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
case PIPE_CAP_INVALIDATE_BUFFER:
case PIPE_CAP_GENERATE_MIPMAP:
case PIPE_CAP_STRING_MARKER:
+   case PIPE_CAP_QUERY_MEMORY_INFO:
   return 0;
 
case PIPE_CAP_VENDOR_ID:
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c 
b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
index 6daa224..79caf17 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
@@ -217,6 +217,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
case PIPE_CAP_INVALIDATE_BUFFER:
case PIPE_CAP_GENERATE_MIPMAP:
case PIPE_CAP_STRING_MARKER:
+   case PIPE_CAP_QUERY_MEMORY_INFO:
   return 0;
 
case PIPE_CAP_VENDOR_ID:
diff --git a/src/gallium/drivers/r300/r300_screen.c 
b/src/gallium/drivers/r300/r300_screen.c
index 90c4f71..2648548 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -210,6 +210,7 @@ static int 

[Mesa-dev] [PATCH 3/5] mesa: implement GL_ATI_meminfo

2016-02-02 Thread Marek Olšák
From: Marek Olšák 

---
 src/mapi/glapi/gen/gl_API.xml|  6 ++
 src/mesa/main/extensions_table.h |  1 +
 src/mesa/main/get.c  | 26 +-
 src/mesa/main/get_hash_params.py |  5 +
 src/mesa/main/mtypes.h   |  1 +
 5 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index 09dda19..ca15b6d 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -12661,6 +12661,12 @@
 
 
 
+
+
+
+
+
+
 http://www.w3.org/2001/XInclude"/>
 
 
diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h
index dfccb73..af7881c 100644
--- a/src/mesa/main/extensions_table.h
+++ b/src/mesa/main/extensions_table.h
@@ -165,6 +165,7 @@ EXT(ARB_window_pos  , dummy_true
 EXT(ATI_blend_equation_separate , EXT_blend_equation_separate  
  , GLL, GLC,  x ,  x , 2003)
 EXT(ATI_draw_buffers, dummy_true   
  , GLL,  x ,  x ,  x , 2002)
 EXT(ATI_fragment_shader , ATI_fragment_shader  
  , GLL,  x ,  x ,  x , 2001)
+EXT(ATI_meminfo , ATI_meminfo  
  , GLL, GLC,  x ,  x , 2009)
 EXT(ATI_separate_stencil, ATI_separate_stencil 
  , GLL,  x ,  x ,  x , 2006)
 EXT(ATI_texture_compression_3dc , ATI_texture_compression_3dc  
  , GLL,  x ,  x ,  x , 2004)
 EXT(ATI_texture_env_combine3, ATI_texture_env_combine3 
  , GLL,  x ,  x ,  x , 2002)
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index dbc8605..50ca1be 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -449,6 +449,7 @@ EXTRA_EXT(ARB_tessellation_shader);
 EXTRA_EXT(ARB_shader_subroutine);
 EXTRA_EXT(ARB_shader_storage_buffer_object);
 EXTRA_EXT(ARB_indirect_parameters);
+EXTRA_EXT(ATI_meminfo);
 EXTRA_EXT(NVX_gpu_memory_info);
 
 static const int
@@ -1081,7 +1082,10 @@ find_custom_value(struct gl_context *ctx, const struct 
value_desc *d, union valu
case GL_DISPATCH_INDIRECT_BUFFER_BINDING:
   v->value_int = ctx->DispatchIndirectBuffer->Name;
   break;
-   /* GL_NVX_gpu_memory_info */
+   /* GL_ATI_meminfo & GL_NVX_gpu_memory_info */
+   case GL_VBO_FREE_MEMORY_ATI:
+   case GL_TEXTURE_FREE_MEMORY_ATI:
+   case GL_RENDERBUFFER_FREE_MEMORY_ATI:
case GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX:
case GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX:
case GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX:
@@ -1103,6 +1107,26 @@ find_custom_value(struct gl_context *ctx, const struct 
value_desc *d, union valu
 v->value_int = total_device_memory + total_staging_memory;
  else if (d->pname == GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX)
 v->value_int = avail_device_memory;
+ else {
+/* ATI free memory enums.
+ *
+ * Since the GPU memory is (usually) page-table based, every two
+ * consecutive elements are equal. From the GL_ATI_meminfo
+ * specification:
+ *
+ *"param[0] - total memory free in the pool
+ * param[1] - largest available free block in the pool
+ * param[2] - total auxiliary memory free
+ * param[3] - largest auxiliary free block"
+ *
+ * All three (VBO, TEXTURE, RENDERBUFFER) queries return
+ * the same numbers here.
+ */
+v->value_int_4[0] = avail_device_memory;
+v->value_int_4[1] = avail_device_memory;
+v->value_int_4[2] = avail_staging_memory;
+v->value_int_4[3] = avail_staging_memory;
+ }
   }
   break;
case GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX:
diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
index be4e030..73610fb 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -848,6 +848,11 @@ descriptor=[
   [ "MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS", 
"CONTEXT_INT(Const.Program[MESA_SHADER_TESS_CTRL].MaxShaderStorageBlocks), 
extra_ARB_shader_storage_buffer_object" ],
   [ "MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS", 
"CONTEXT_INT(Const.Program[MESA_SHADER_TESS_EVAL].MaxShaderStorageBlocks), 
extra_ARB_shader_storage_buffer_object" ],
 
+# GL_ATI_meminfo
+  [ "VBO_FREE_MEMORY_ATI", "LOC_CUSTOM, TYPE_INT_4, NO_OFFSET, 
extra_ATI_meminfo" ],
+  [ "TEXTURE_FREE_MEMORY_ATI", "LOC_CUSTOM, TYPE_INT_4, NO_OFFSET, 
extra_ATI_meminfo" ],
+  [ "RENDERBUFFER_FREE_MEMORY_ATI", "LOC_CUSTOM, TYPE_INT_4, NO_OFFSET, 
extra_ATI_meminfo" ],
+
 # GL_NVX_gpu_memory_info
   [ "GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX", "LOC_CUSTOM, TYPE_INT, NO_OFFSET, 
extra_NVX_gpu_memory_info" ],
   [ "GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX", "LOC_CUSTOM, TYPE_INT, 

[Mesa-dev] [PATCH 5/5] gallium/radeon: implement query_memory_info

2016-02-02 Thread Marek Olšák
From: Marek Olšák 

---
 src/gallium/drivers/r600/r600_pipe.c  |  2 +-
 src/gallium/drivers/radeon/r600_pipe_common.c | 35 +++
 src/gallium/drivers/radeonsi/si_pipe.c|  2 +-
 3 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_pipe.c 
b/src/gallium/drivers/r600/r600_pipe.c
index 15cc9d1..384d59f 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -285,6 +285,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum 
pipe_cap param)
case PIPE_CAP_TGSI_TXQS:
case PIPE_CAP_COPY_BETWEEN_COMPRESSED_AND_PLAIN_FORMATS:
case PIPE_CAP_INVALIDATE_BUFFER:
+   case PIPE_CAP_QUERY_MEMORY_INFO:
return 1;
 
case PIPE_CAP_DEVICE_RESET_STATUS_QUERY:
@@ -364,7 +365,6 @@ static int r600_get_param(struct pipe_screen* pscreen, enum 
pipe_cap param)
case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT:
case PIPE_CAP_GENERATE_MIPMAP:
case PIPE_CAP_STRING_MARKER:
-   case PIPE_CAP_QUERY_MEMORY_INFO:
return 0;
 
case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS:
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c 
b/src/gallium/drivers/radeon/r600_pipe_common.c
index 0620a9a..577dca9 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.c
+++ b/src/gallium/drivers/radeon/r600_pipe_common.c
@@ -799,6 +799,40 @@ static boolean r600_fence_finish(struct pipe_screen 
*screen,
return rws->fence_wait(rws, rfence->gfx, timeout);
 }
 
+static void r600_query_memory_info(struct pipe_screen *screen,
+  struct pipe_memory_info *info)
+{
+   struct r600_common_screen *rscreen = (struct r600_common_screen*)screen;
+   struct radeon_winsys *ws = rscreen->ws;
+   unsigned vram_usage, gtt_usage;
+
+   info->total_device_memory = DIV_ROUND_UP(rscreen->info.vram_size, 1024);
+   info->total_staging_memory = DIV_ROUND_UP(rscreen->info.gart_size, 
1024);
+
+   /* The real TTM memory usage is somewhat random, because:
+*
+* 1) TTM delays freeing memory, because it can only free it after
+*fences expire.
+*
+* 2) The memory usage can be really low if big VRAM evictions are
+*taking place, but the real usage is well above the size of VRAM.
+*
+* Instead, return statistics of this process.
+*/
+   vram_usage = ws->query_value(ws, RADEON_REQUESTED_VRAM_MEMORY);
+   vram_usage = DIV_ROUND_UP(vram_usage, 1024);
+
+   gtt_usage =  ws->query_value(ws, RADEON_REQUESTED_GTT_MEMORY);
+   gtt_usage = DIV_ROUND_UP(gtt_usage, 1024);
+
+   info->avail_device_memory =
+   vram_usage <= info->total_device_memory ?
+   info->total_device_memory - vram_usage : 0;
+   info->avail_staging_memory =
+   gtt_usage <= info->total_staging_memory ?
+   info->total_staging_memory - gtt_usage : 0;
+}
+
 struct pipe_resource *r600_resource_create_common(struct pipe_screen *screen,
  const struct pipe_resource 
*templ)
 {
@@ -838,6 +872,7 @@ bool r600_common_screen_init(struct r600_common_screen 
*rscreen,
rscreen->b.fence_reference = r600_fence_reference;
rscreen->b.resource_destroy = u_resource_destroy_vtbl;
rscreen->b.resource_from_user_memory = r600_buffer_from_user_memory;
+   rscreen->b.query_memory_info = r600_query_memory_info;
 
if (rscreen->info.has_uvd) {
rscreen->b.get_video_param = rvid_get_video_param;
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c 
b/src/gallium/drivers/radeonsi/si_pipe.c
index 45ad2b5..0571a40 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -309,6 +309,7 @@ static int si_get_param(struct pipe_screen* pscreen, enum 
pipe_cap param)
case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL:
case PIPE_CAP_INVALIDATE_BUFFER:
case PIPE_CAP_TGSI_PACK_HALF_FLOAT:
+   case PIPE_CAP_QUERY_MEMORY_INFO:
return 1;
 
case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
@@ -354,7 +355,6 @@ static int si_get_param(struct pipe_screen* pscreen, enum 
pipe_cap param)
case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT:
case PIPE_CAP_GENERATE_MIPMAP:
case PIPE_CAP_STRING_MARKER:
-   case PIPE_CAP_QUERY_MEMORY_INFO:
return 0;
 
case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS:
-- 
2.1.4

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


Re: [Mesa-dev] [PATCH 1/2] virgl: reuse screen when fd is already open

2016-02-02 Thread Emil Velikov
On 31 January 2016 at 19:40, Rob Clark  wrote:
> On Sun, Jan 31, 2016 at 6:18 AM, Emil Velikov  
> wrote:
>> Hi Rob,
>>
>> On 30 January 2016 at 00:36, Rob Herring  wrote:
>>> It is necessary to share the screen between mesa and gralloc to
>>> properly ref count resources. This implements a hash lookup on
>>> the file description to re-use an already created screen. This is
>>> a similar implementation as freedreno and radeon.
>>>
>> I believe you mentioned this before ... can we share this across drivers.
>>
>> Taking that and going the extra step... I'm thinking about exporting
>> the private symbol. This way we can get rid of the
>> "foo_drm_create_screen" symbol that each platform needs to export (and
>> alike 'hack' for Android).
>>
>> About the actual location - I'm leaning towards
>> src/gallium/auxiliary/target-helpers/foo.c although I don't feel too
>> strongly.
>>
>>> --- a/src/gallium/drivers/virgl/virgl_screen.h
>>> +++ b/src/gallium/drivers/virgl/virgl_screen.h
>>> @@ -28,6 +28,12 @@
>>>
>>>  struct virgl_screen {
>>> struct pipe_screen base;
>>> +
>>> +   int refcnt;
>>> +
>>> +   /* place for winsys to stash it's own stuff: */
>>> +   void *winsys_priv;
>>> +
>> In order to avoid this workaround (and similar ones like it) I'm
>> thinking about the following:
>>  - move refcnt to pipe_screen (use struct pipe_reference)
>>  - then within the foo_create_winsys we lock, create the actual
>> winsys, search for existing screen/create new one, refcount. unlock.
>>
>
> would be nice if pipe_screen was refcnt'd across the board.. but that
> was more of a sweeping change than I was motivated to pull off, at
> least until I finish some existing projects..
>
> anyways, beyond that, if someone is motivated to fix this so we don't
> have to duplicate this winsys stuff everywhere, I'm all for it.. otoh
> it is code that probably no one would otherwise touch again, so I'm
> not going to block tactical solutions in other drivers, esp when I did
> the same not too long ago for freedreno ;-)
>
Sure thing. My comment aimed to inspire a discussion and establish if
I got things correct(~ish), rather than "do it or GTFO" ;-)
So I take it that I haven't missed something and the idea sound about right ?

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


Re: [Mesa-dev] [PATCH 2/2] gallivm: add PK2H/UP2H support

2016-02-02 Thread Roland Scheidegger
Am 02.02.2016 um 13:39 schrieb Jose Fonseca:
> On 31/01/16 02:08, srol...@vmware.com wrote:
>> From: Roland Scheidegger 
>>
>> Add support for these opcodes, the conversion functions were already
>> there albeit need some new packing stuff.
>> Just like the tgsi version, piglit won't like it for all the same
>> reasons, so it's disabled (UP2H passes piglit arb_shader_language_packing
>> tests, albeit since PK2H won't due those rounding differences I don't
>> know if that one works or not as the piglit test is rather difficult to
>> deal with).
>> ---
>>   src/gallium/auxiliary/gallivm/lp_bld_conv.c| 16 -
>>   src/gallium/auxiliary/gallivm/lp_bld_pack.c| 26 
>>   src/gallium/auxiliary/gallivm/lp_bld_pack.h|  5 ++
>>   src/gallium/auxiliary/gallivm/lp_bld_tgsi.c|  1 -
>>   src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c | 73
>> ++
>>   5 files changed, 119 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_conv.c
>> b/src/gallium/auxiliary/gallivm/lp_bld_conv.c
>> index 7854142..7cf0dee 100644
>> --- a/src/gallium/auxiliary/gallivm/lp_bld_conv.c
>> +++ b/src/gallium/auxiliary/gallivm/lp_bld_conv.c
>> @@ -130,6 +130,7 @@ lp_build_half_to_float(struct gallivm_state *gallivm,
>>*
>>* Convert float32 to half floats, preserving Infs and NaNs,
>>* with rounding towards zero (trunc).
>> + * XXX: For GL, would prefer rounding towards nearest(-even).
>>*/
>>   LLVMValueRef
>>   lp_build_float_to_half(struct gallivm_state *gallivm,
>> @@ -143,6 +144,15 @@ lp_build_float_to_half(struct gallivm_state
>> *gallivm,
>>  struct lp_type i16_type = lp_type_int_vec(16, 16 * length);
>>  LLVMValueRef result;
>>
>> +   /*
>> +* Note: Newer llvm versions (3.6 or so) support fptrunc to 16 bits
>> +* directly, without any (x86 or generic) intrinsics.
>> +* Albeit the rounding mode cannot be specified (and is undefined,
>> +* though in practice on x86 seems to do nearest-even but it may
>> +* be dependent on instruction set support), so is essentially
>> +* useless.
>> +*/
>> +
>>  if (util_cpu_caps.has_f16c &&
>>  (length == 4 || length == 8)) {
>> struct lp_type i168_type = lp_type_int_vec(16, 16 * 8);
>> @@ -187,7 +197,11 @@ lp_build_float_to_half(struct gallivm_state
>> *gallivm,
>>   LLVMValueRef index = LLVMConstInt(i32t, i, 0);
>>   LLVMValueRef f32 = LLVMBuildExtractElement(builder, src,
>> index, "");
>>   #if 0
>> -/* XXX: not really supported by backends */
>> +/*
>> + * XXX: not really supported by backends.
>> + * Even if they would now, rounding mode cannot be specified and
>> + * is undefined.
>> + */
>>   LLVMValueRef f16 = lp_build_intrinsic_unary(builder,
>> "llvm.convert.to.fp16", i16t, f32);
>>   #else
>>   LLVMValueRef f16 = LLVMBuildCall(builder, func, , 1, "");
>> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_pack.c
>> b/src/gallium/auxiliary/gallivm/lp_bld_pack.c
>> index 0b0f7f0..daa2043 100644
>> --- a/src/gallium/auxiliary/gallivm/lp_bld_pack.c
>> +++ b/src/gallium/auxiliary/gallivm/lp_bld_pack.c
>> @@ -257,6 +257,32 @@ lp_build_concat_n(struct gallivm_state *gallivm,
>>
>>
>>   /**
>> + * Un-interleave vector.
>> + * This will return a vector consisting of every second element
>> + * (depending on lo_hi, beginning at 0 or 1).
>> + * The returned vector size (elems and width) will only be half
>> + * that of the source vector.
>> + */
>> +LLVMValueRef
>> +lp_build_uninterleave1(struct gallivm_state *gallivm,
>> +   unsigned num_elems,
>> +   LLVMValueRef a,
>> +   unsigned lo_hi)
>> +{
>> +   LLVMValueRef shuffle, elems[LP_MAX_VECTOR_LENGTH];
>> +   unsigned i;
>> +   assert(num_elems <= LP_MAX_VECTOR_LENGTH);
>> +
>> +   for(i = 0; i < num_elems / 2; ++i)
>> +  elems[i] = lp_build_const_int32(gallivm, 2*i + lo_hi);
>> +
>> +   shuffle = LLVMConstVector(elems, num_elems / 2);
>> +
>> +   return LLVMBuildShuffleVector(gallivm->builder, a, a, shuffle, "");
> 
> One don't need the second `a` here. One could use
> `LLVMGetUndef(LLVMTypeOf(a))` to make it explicit.
Right. I was lazy, was much less typing :-). LLVM of course will
recognize that too, albeit you're right when you read the code it would
be more obvious the second vector isn't needed.
(There's other instances of such shuffles using just the same source
again, albeit some do use undef indeed.)

> 
>> +}
>> +
>> +
>> +/**
>>* Interleave vector elements.
>>*
>>* Matches the PUNPCKLxx and PUNPCKHxx SSE instructions
>> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_pack.h
>> b/src/gallium/auxiliary/gallivm/lp_bld_pack.h
>> index 7cede35..367fba1 100644
>> --- a/src/gallium/auxiliary/gallivm/lp_bld_pack.h
>> +++ b/src/gallium/auxiliary/gallivm/lp_bld_pack.h
>> @@ -58,6 +58,11 @@ 

Re: [Mesa-dev] [PATCH 1/2] virgl: reuse screen when fd is already open

2016-02-02 Thread Rob Clark
On Tue, Feb 2, 2016 at 12:13 PM, Emil Velikov  wrote:
> On 31 January 2016 at 19:40, Rob Clark  wrote:
>> On Sun, Jan 31, 2016 at 6:18 AM, Emil Velikov  
>> wrote:
>>> Hi Rob,
>>>
>>> On 30 January 2016 at 00:36, Rob Herring  wrote:
 It is necessary to share the screen between mesa and gralloc to
 properly ref count resources. This implements a hash lookup on
 the file description to re-use an already created screen. This is
 a similar implementation as freedreno and radeon.

>>> I believe you mentioned this before ... can we share this across drivers.
>>>
>>> Taking that and going the extra step... I'm thinking about exporting
>>> the private symbol. This way we can get rid of the
>>> "foo_drm_create_screen" symbol that each platform needs to export (and
>>> alike 'hack' for Android).
>>>
>>> About the actual location - I'm leaning towards
>>> src/gallium/auxiliary/target-helpers/foo.c although I don't feel too
>>> strongly.
>>>
 --- a/src/gallium/drivers/virgl/virgl_screen.h
 +++ b/src/gallium/drivers/virgl/virgl_screen.h
 @@ -28,6 +28,12 @@

  struct virgl_screen {
 struct pipe_screen base;
 +
 +   int refcnt;
 +
 +   /* place for winsys to stash it's own stuff: */
 +   void *winsys_priv;
 +
>>> In order to avoid this workaround (and similar ones like it) I'm
>>> thinking about the following:
>>>  - move refcnt to pipe_screen (use struct pipe_reference)
>>>  - then within the foo_create_winsys we lock, create the actual
>>> winsys, search for existing screen/create new one, refcount. unlock.
>>>
>>
>> would be nice if pipe_screen was refcnt'd across the board.. but that
>> was more of a sweeping change than I was motivated to pull off, at
>> least until I finish some existing projects..
>>
>> anyways, beyond that, if someone is motivated to fix this so we don't
>> have to duplicate this winsys stuff everywhere, I'm all for it.. otoh
>> it is code that probably no one would otherwise touch again, so I'm
>> not going to block tactical solutions in other drivers, esp when I did
>> the same not too long ago for freedreno ;-)
>>
> Sure thing. My comment aimed to inspire a discussion and establish if
> I got things correct(~ish), rather than "do it or GTFO" ;-)
> So I take it that I haven't missed something and the idea sound about right ?
>

I can't say that I fully understand your __fancyMesaDriverPrivateSymbol idea..

My rough thinking originally, fwiw, was add pipe_reference to the top
of pipe_screen (iirc, there are some dragons w/ pipe_reference, so you
better not put it anywhere than the first member of the absolute
parent "class" struct), and then have each driver provide it's own fxn
ptr to go from fd to pipe_screen which is guaranteed to only be called
once per fd.  But refcnt'ing screen didn't seem like a trivial change,
and bigger-fires(TM).

Just for the record, the only reason this patch (adding hashtable per
driver's winsys code) is an android hack is because we don't have
vdpau for vc4 (or freedreno)..  the reason it is needed for
radeon/nouveau is gl<->vdpau buffer sharing, the reason it is needed
freedreno/vc4/virgl (or really any drm driver) on android is
gl<->gralloc buffer sharing.  (just fyi)

BR,
-R
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH V2] glsl: disable varying packing when its not safe

2016-02-02 Thread Samuel Iglesias Gonsálvez
On Tue, 2016-02-02 at 16:50 +1100, Timothy Arceri wrote:
> In GLES 3.1+ and GL 4.4+ there is no guarantee that interpolation
> qualifiers will match between stages so we cannot safely pack
> varyings using the current packing pass in Mesa.
> 
> We also disable packing on outward facing SSO as these too are
> outside
> the rule that guarantees the interpolation qualifiers match.
> 
> We do however enable packing on individual arrays, structs, and
> matrices as these are required by the transform feedback code and it
> is still safe to do so.
> 
> Finally we also enable packing when a varying is only used for
> transform feedback and its not a SSO.
> 
> This fixes all remaining rendering issues with the dEQP SSO tests,
> the only issues remaining with thoses tests are to do with
> validation.
> 
> Note: There is still one remaining SSO bug that this patch doesn't
> fix.
> Their is a chance that VS -> TCS will have mismatching interfaces
> because we pack VS output in case its used by transform feedback but
> don't pack TCS input for performance reasons. This patch will make
> the
> situation better but doesn't fix it.
> 
> V2: Make is_varying_packing_safe() a function in the varying_matches
> class, fix spelling (Matt) and make sure to remove the outer array
> when dealing with Geom and Tess shaders where appropriate.
> Lastly fix piglit regression in new piglit test and document the
> undefined behaviour it depends on:
> arb_separate_shader_objects/execution/vs-gs-linking.shader_test
> 
> Cc: Samuel Iglesias Gonsálvez 
> Cc: Tapani Pälli 
> ---
>  This patch applies on top of my ARB_enhanced_layouts component
> packing
>  series [1].
> 
>  The GLES 3.1 and GL 4.4 changes were tested by changing the code to
>  always disable packing and running the changes in Intel CI system.
>  
>  This patch would also make it possible for a backend to do less
> packing
>  in GLSL IR if it wished to do so now that the transform feedback
> requirements
>  have been isolated. 
> 
>  [1] http://patchwork.freedesktop.org/series/2101/
> 
>  src/compiler/glsl/ir.h  |   7 +
>  src/compiler/glsl/ir_optimization.h |   2 +-
>  src/compiler/glsl/link_varyings.cpp | 214
> +---
>  src/compiler/glsl/lower_packed_varyings.cpp |  37 +++--
>  4 files changed, 202 insertions(+), 58 deletions(-)
> 
> diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h
> index e4513f0..83bb74b 100644
> --- a/src/compiler/glsl/ir.h
> +++ b/src/compiler/glsl/ir.h
> @@ -736,6 +736,13 @@ public:
>    unsigned is_unmatched_generic_inout:1;
>  
>    /**
> +   * Is this varying used only by transform feedback?
> +   *
> +   * This is used by the linker to decide if its safe to pack
> the varying.
> +   */
> +  unsigned is_xfb_only:1;
> +
> +  /**
> * If non-zero, then this variable may be packed along with
> other variables
> * into a single varying slot, so this offset should be
> applied when
> * accessing components.  For example, an offset of 1 means
> that the x
> diff --git a/src/compiler/glsl/ir_optimization.h
> b/src/compiler/glsl/ir_optimization.h
> index a115c46..e201242 100644
> --- a/src/compiler/glsl/ir_optimization.h
> +++ b/src/compiler/glsl/ir_optimization.h
> @@ -126,7 +126,7 @@ void lower_packed_varyings(void *mem_ctx,
> unsigned locations_used, ir_variable_mode
> mode,
> gl_shader *shader, unsigned
> base_location,
> bool disable_varying_packing,
> -   bool has_enhanced_layouts);
> +   bool xfb_enabled, bool
> has_enhanced_layouts);
>  bool lower_vector_insert(exec_list *instructions, bool
> lower_nonconstant_index);
>  bool lower_vector_derefs(gl_shader *shader);
>  void lower_named_interface_blocks(void *mem_ctx, gl_shader *shader);
> diff --git a/src/compiler/glsl/link_varyings.cpp
> b/src/compiler/glsl/link_varyings.cpp
> index 2974e76..8efaa33 100644
> --- a/src/compiler/glsl/link_varyings.cpp
> +++ b/src/compiler/glsl/link_varyings.cpp
> @@ -878,7 +878,7 @@ namespace {
>  class varying_matches
>  {
>  public:
> -   varying_matches(bool disable_varying_packing,
> +   varying_matches(bool disable_varying_packing, bool xfb_enabled,
> gl_shader_stage producer_stage,
> gl_shader_stage consumer_stage);
> ~varying_matches();
> @@ -888,14 +888,30 @@ public:
> void store_locations() const;
>  
>  private:
> +   bool is_varying_packing_safe(const glsl_type *type,
> +const ir_variable *var);
> +
> /**
>  * If true, this driver disables varying packing, so all varyings
> need to
>  * be aligned on slot boundaries, and take up a number of slots
> equal to
>  * their number of matrix columns times their array size.
> +*
> +* Packing may also be disabled 

Re: [Mesa-dev] [PATCH 08a/11] nir: clamp-color-output support

2016-02-02 Thread Rob Clark
On Tue, Feb 2, 2016 at 1:29 PM, Connor Abbott  wrote:
> On Tue, Feb 2, 2016 at 1:07 PM, Rob Clark  wrote:
>> From: Rob Clark 
>>
>> Handled by tgsi_emulate for glsl->tgsi case.
>>
>> Signed-off-by: Rob Clark 
>> ---
>>  src/compiler/Makefile.sources|   1 +
>>  src/compiler/nir/nir.h   |   1 +
>>  src/compiler/nir/nir_lower_clamp_color_outputs.c | 121 
>> +++
>>  3 files changed, 123 insertions(+)
>>  create mode 100644 src/compiler/nir/nir_lower_clamp_color_outputs.c
>>
>> diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources
>> index d859493..e85cde5 100644
>> --- a/src/compiler/Makefile.sources
>> +++ b/src/compiler/Makefile.sources
>> @@ -184,6 +184,7 @@ NIR_FILES = \
>> nir/nir_lower_alu_to_scalar.c \
>> nir/nir_lower_atomics.c \
>> nir/nir_lower_bitmap.c \
>> +   nir/nir_lower_clamp_color_outputs.c \
>> nir/nir_lower_clip.c \
>> nir/nir_lower_drawpixels.c \
>> nir/nir_lower_global_vars_to_local.c \
>> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
>> index 29c8631..dc31a67 100644
>> --- a/src/compiler/nir/nir.h
>> +++ b/src/compiler/nir/nir.h
>> @@ -2119,6 +2119,7 @@ void nir_lower_clip_fs(nir_shader *shader, unsigned 
>> ucp_enables);
>>
>>  void nir_lower_two_sided_color(nir_shader *shader);
>>
>> +void nir_lower_clamp_color_outputs(nir_shader *shader);
>>
>>  typedef struct nir_lower_wpos_ytransform_options {
>> int state_tokens[5];
>> diff --git a/src/compiler/nir/nir_lower_clamp_color_outputs.c 
>> b/src/compiler/nir/nir_lower_clamp_color_outputs.c
>> new file mode 100644
>> index 000..0e1add0
>> --- /dev/null
>> +++ b/src/compiler/nir/nir_lower_clamp_color_outputs.c
>> @@ -0,0 +1,121 @@
>> +/*
>> + * Copyright © 2015 Red Hat
>> + *
>> + * Permission is hereby granted, free of charge, to any person obtaining a
>> + * copy of this software and associated documentation files (the 
>> "Software"),
>> + * to deal in the Software without restriction, including without limitation
>> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
>> + * and/or sell copies of the Software, and to permit persons to whom the
>> + * Software is furnished to do so, subject to the following conditions:
>> + *
>> + * The above copyright notice and this permission notice (including the next
>> + * paragraph) shall be included in all copies or substantial portions of the
>> + * Software.
>> + *
>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
>> OR
>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
>> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 
>> OTHER
>> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
>> FROM,
>> + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 
>> IN THE
>> + * SOFTWARE.
>> + */
>> +
>> +
>> +#include "nir.h"
>> +#include "nir_builder.h"
>> +
>> +typedef struct {
>> +   nir_shader *shader;
>> +   nir_builder b;
>> +} lower_state;
>> +
>> +static bool
>> +is_color_output(lower_state *state, nir_variable *out)
>> +{
>> +   switch (state->shader->stage) {
>> +   case MESA_SHADER_VERTEX:
>> +   case MESA_SHADER_GEOMETRY:
>> +  switch (out->data.location) {
>> +  case VARYING_SLOT_COL0:
>> +  case VARYING_SLOT_COL1:
>> +  case VARYING_SLOT_BFC0:
>> +  case VARYING_SLOT_BFC1:
>> + return true;
>> +  default:
>> + return false;
>> +  }
>> +  break;
>> +   case MESA_SHADER_FRAGMENT:
>> +  switch (out->data.location) {
>> +  case FRAG_RESULT_COLOR:
>> + return true;
>> +  default:
>> + return false;
>> +  }
>> +  break;
>> +   default:
>> +  return false;
>> +   }
>> +}
>> +
>> +static void
>> +lower_intrinsic(lower_state *state, nir_intrinsic_instr *intr)
>> +{
>> +   nir_variable *out;
>> +   nir_builder *b = >b;
>> +   nir_ssa_def *s;
>> +
>> +   if (intr->intrinsic != nir_intrinsic_store_var)
>> +  return;
>> +
>> +   out = intr->variables[0]->var;
>> +
>> +   if (out->data.mode != nir_var_shader_out)
>> +  return;
>> +
>> +   /* NOTE: 'out' can be null for types larger than vec4,
>> +* but these will never be color out's so we can ignore
>> +*/
>
> This comment isn't true (store_var intrinsics will always have a
> non-NULL variable associated with them) and it doesn't seem relevant,
> since even if color out's could be part of a struct/array this would
> still work, so I'd just drop it. Other than that this gets my r-b.

right, and the check for null after already deref'ing it is bonkers
too, so I've dropped that as well..

tbh, I don't even remember where that came from, but I can only guess
an earlier 

Re: [Mesa-dev] [PATCH 2/5] android: radeonsi: fix building error in si_shader.c

2016-02-02 Thread Mauro Rossi
Hi Michel,

Patch was updated according to the instructions and log/commit messages
changed.

Thanks for the advice

Mauro


>From 7a9090bffa434b78d8654c4c6d4c8dc0ec00c524 Mon Sep 17 00:00:00 2001
From: Mauro Rossi 
Date: Wed, 3 Feb 2016 03:54:08 +0100
Subject: [PATCH] android: radeonsi: add strchrnul() to fix building error

Android Bionic has no strchrnul, which is used in
si_shader_dump_disassembly(), so we need an implementation.

A new android compatibility header was added to support
the definition of the needed function.
---
 include/android_compat.h | 45

 src/gallium/drivers/radeonsi/si_shader.c |  4 +++
 2 files changed, 49 insertions(+)
 create mode 100644 include/android_compat.h

diff --git a/include/android_compat.h b/include/android_compat.h
new file mode 100644
index 000..224521d
--- /dev/null
+++ b/include/android_compat.h
@@ -0,0 +1,45 @@
+/**
+ *
+ * Copyright (C) 2014 Emil Velikov 
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
"Software"),
+ * to deal in the Software without restriction, including without
limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+
**/
+
+#ifndef _ANDROID_COMPAT_H_
+#define _ANDROID_COMPAT_H_
+
+/*
+ * Android Bionic has no strchrnul, which is used in
si_shader_dump_disassembly(),
+ * so we must fill in an implementation.
+ */
+
+char *
+strchrnul(const char *s, int c)
+{
+ char * result = strchr(s, c);
+
+ if (result == NULL) {
+ result = s + strlen(s);
+ }
+
+ return result;
+}
+
+#endif /* _ANDROID_COMPAT_H_ */
diff --git a/src/gallium/drivers/radeonsi/si_shader.c
b/src/gallium/drivers/radeonsi/si_shader.c
index 2192b21..86a00fb 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -49,6 +49,10 @@

 #include 

+#if defined(__ANDROID__)
+#include "android_compat.h"
+#endif /* __ANDROID__ */
+
 static const char *scratch_rsrc_dword0_symbol =
  "SCRATCH_RSRC_DWORD0";

-- 
2.5.0
From 7a9090bffa434b78d8654c4c6d4c8dc0ec00c524 Mon Sep 17 00:00:00 2001
From: Mauro Rossi 
Date: Wed, 3 Feb 2016 03:54:08 +0100
Subject: [PATCH] android: radeonsi: add strchrnul() to fix building error

Android Bionic has no strchrnul, which is used in
si_shader_dump_disassembly(), so we need an implementation.

A new android compatibility header was added to support
the definition of the needed function.
---
 include/android_compat.h | 45 
 src/gallium/drivers/radeonsi/si_shader.c |  4 +++
 2 files changed, 49 insertions(+)
 create mode 100644 include/android_compat.h

diff --git a/include/android_compat.h b/include/android_compat.h
new file mode 100644
index 000..224521d
--- /dev/null
+++ b/include/android_compat.h
@@ -0,0 +1,45 @@
+/**
+ *
+ * Copyright (C) 2014 Emil Velikov 
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 

Re: [Mesa-dev] [PATCH 3/3] llvmpipe: drop scissor planes early if the tri is fully inside them

2016-02-02 Thread Jose Fonseca

On 01/02/16 01:00, srol...@vmware.com wrote:

From: Roland Scheidegger 

If the tri is fully inside a scissor edge (or rather, we just use the
bounding box of the tri for the comparison), then we can drop these
additional scissor "planes" early. We do not even need to allocate
space for them in the tri.
The math actually appears to be slightly iffy due to bounding boxes
being rounded, but it doesn't matter in the end.
Those scissor rects are costly - the 4 planes from the scissor are
already more expensive to calculate than the 3 planes from the tri itself,
and it also prevents us from using the specialized raster code for small
tris.
This helps openarena performance by about 8% or so. Of course, it helps
there that while openarena often enables scissoring (and even moves the
scissor rect around) I have not seen a single tri actually hit the
scissor rect, ever.

v2: drop individual scissor edges, and do it earlier, not even allocating
space for them.
---
  src/gallium/drivers/llvmpipe/lp_rast_tri.c   | 16 +
  src/gallium/drivers/llvmpipe/lp_setup_line.c | 81 ++-
  src/gallium/drivers/llvmpipe/lp_setup_tri.c  | 98 +---
  3 files changed, 126 insertions(+), 69 deletions(-)

diff --git a/src/gallium/drivers/llvmpipe/lp_rast_tri.c 
b/src/gallium/drivers/llvmpipe/lp_rast_tri.c
index f4a2f02..bf27900 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_tri.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast_tri.c
@@ -380,11 +380,27 @@ lp_rast_triangle_32_3_4(struct lp_rasterizer_task *task,
  */
 dcdx = _mm_sub_epi32(zero, dcdx);

+#if 0
+   {
+   __m128i lbits, fixup, xy, dcdxdy, dcdx16;
+   lbits = _mm_and_si128(c, _mm_set1_epi32(FIXED_ONE - 1));
+   fixup = _mm_cmpeq_epi32(lbits, _mm_setzero_si128());
+   c = _mm_srai_epi32(c, 8);
+   c = _mm_add_epi32(c, fixup);
+   xy = _mm_set1_epi32(x | y << 16);
+   dcdx = _mm_srai_epi32(dcdx, 8);
+   dcdy = _mm_srai_epi32(dcdy, 8);
+   dcdx16 = _mm_and_si128(_mm_set_epi16(0,-1,0,-1,0,-1,0,-1), dcdx);
+   dcdxdy = _mm_or_si128(dcdx16, _mm_slli_epi32(dcdy, 16));
+   c = _mm_add_epi32(c, _mm_madd_epi16(dcdxdy, xy));
+   }
+#else
 c = _mm_add_epi32(c, mm_mullo_epi32(dcdx, _mm_set1_epi32(x)));
 c = _mm_add_epi32(c, mm_mullo_epi32(dcdy, _mm_set1_epi32(y)));

 /* Adjust so we can just check the sign bit (< 0 comparison), instead of 
having to do a less efficient <= 0 comparison */
 c = _mm_sub_epi32(c, _mm_set1_epi32(1));
+#endif

 dcdx2 = _mm_add_epi32(dcdx, dcdx);
 dcdx3 = _mm_add_epi32(dcdx2, dcdx);
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_line.c 
b/src/gallium/drivers/llvmpipe/lp_setup_line.c
index f425825..3ec9ac4 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_line.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup_line.c
@@ -336,13 +336,6 @@ try_setup_line( struct lp_setup_context *setup,
layer = MIN2(layer, scene->fb_max_layer);
 }

-   if (setup->scissor_test) {
-  nr_planes = 8;
-   }
-   else {
-  nr_planes = 4;
-   }
-
 dx = v1[0][0] - v2[0][0];
 dy = v1[0][1] - v2[0][1];
 area = (dx * dx  + dy * dy);
@@ -591,6 +584,20 @@ try_setup_line( struct lp_setup_context *setup,
 bbox.x0 = MAX2(bbox.x0, 0);
 bbox.y0 = MAX2(bbox.y0, 0);

+   nr_planes = 4;
+   /*
+* Determine how many scissor planes we need, that is drop scissor
+* edges if the bounding box of the tri is fully inside that edge.
+*/
+   if (setup->scissor_test) {
+  /* why not just use draw_regions */
+  struct u_rect *scissor = >scissors[viewport_index];



Please use 4 bools:

  bool scissor_left = bbox.x0 < scissor->x0;

and reused them below.

I'm concern we could use >= for some of these -- though it might depend 
on the current rasterization rules.


Anyway, using bools ensure these conditions stay in sync with the code 
bloew.


Maybe an even better alternative is have a "needed_scissor_planes" 
helper function that gets used every where.





+  if (bbox.x0 < scissor->x0) nr_planes++;
+  if (bbox.x1 > scissor->x1) nr_planes++;
+  if (bbox.y0 < scissor->y0) nr_planes++;
+  if (bbox.y1 > scissor->y1) nr_planes++;
+   }
+
 line = lp_setup_alloc_triangle(scene,
key->num_inputs,
nr_planes,
@@ -708,30 +715,44 @@ try_setup_line( struct lp_setup_context *setup,
  * Note that otherwise, the scissor planes only vary in 'C' value,
  * and even then only on state-changes.  Could alternatively store
  * these planes elsewhere.
+* (Or only store the c value together with a bit indicating which
+* scissor edge this is, so rasterization would treat them differently
+* (easier to evaluate) to ordinary planes.)
  */
-   if (nr_planes == 8) {
-  const struct u_rect *scissor =
- >scissors[viewport_index];
-
-  plane[4].dcdx = -1 << 8;
-  plane[4].dcdy = 0;
-  plane[4].c = (1-scissor->x0) << 8;
-  plane[4].eo = 1 << 8;
-

Re: [Mesa-dev] [PATCH 2/2] gallivm: add PK2H/UP2H support

2016-02-02 Thread Jose Fonseca

On 31/01/16 02:08, srol...@vmware.com wrote:

From: Roland Scheidegger 

Add support for these opcodes, the conversion functions were already
there albeit need some new packing stuff.
Just like the tgsi version, piglit won't like it for all the same
reasons, so it's disabled (UP2H passes piglit arb_shader_language_packing
tests, albeit since PK2H won't due those rounding differences I don't
know if that one works or not as the piglit test is rather difficult to
deal with).
---
  src/gallium/auxiliary/gallivm/lp_bld_conv.c| 16 -
  src/gallium/auxiliary/gallivm/lp_bld_pack.c| 26 
  src/gallium/auxiliary/gallivm/lp_bld_pack.h|  5 ++
  src/gallium/auxiliary/gallivm/lp_bld_tgsi.c|  1 -
  src/gallium/auxiliary/gallivm/lp_bld_tgsi_action.c | 73 ++
  5 files changed, 119 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_conv.c 
b/src/gallium/auxiliary/gallivm/lp_bld_conv.c
index 7854142..7cf0dee 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_conv.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_conv.c
@@ -130,6 +130,7 @@ lp_build_half_to_float(struct gallivm_state *gallivm,
   *
   * Convert float32 to half floats, preserving Infs and NaNs,
   * with rounding towards zero (trunc).
+ * XXX: For GL, would prefer rounding towards nearest(-even).
   */
  LLVMValueRef
  lp_build_float_to_half(struct gallivm_state *gallivm,
@@ -143,6 +144,15 @@ lp_build_float_to_half(struct gallivm_state *gallivm,
 struct lp_type i16_type = lp_type_int_vec(16, 16 * length);
 LLVMValueRef result;

+   /*
+* Note: Newer llvm versions (3.6 or so) support fptrunc to 16 bits
+* directly, without any (x86 or generic) intrinsics.
+* Albeit the rounding mode cannot be specified (and is undefined,
+* though in practice on x86 seems to do nearest-even but it may
+* be dependent on instruction set support), so is essentially
+* useless.
+*/
+
 if (util_cpu_caps.has_f16c &&
 (length == 4 || length == 8)) {
struct lp_type i168_type = lp_type_int_vec(16, 16 * 8);
@@ -187,7 +197,11 @@ lp_build_float_to_half(struct gallivm_state *gallivm,
  LLVMValueRef index = LLVMConstInt(i32t, i, 0);
  LLVMValueRef f32 = LLVMBuildExtractElement(builder, src, index, "");
  #if 0
-/* XXX: not really supported by backends */
+/*
+ * XXX: not really supported by backends.
+ * Even if they would now, rounding mode cannot be specified and
+ * is undefined.
+ */
  LLVMValueRef f16 = lp_build_intrinsic_unary(builder, 
"llvm.convert.to.fp16", i16t, f32);
  #else
  LLVMValueRef f16 = LLVMBuildCall(builder, func, , 1, "");
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_pack.c 
b/src/gallium/auxiliary/gallivm/lp_bld_pack.c
index 0b0f7f0..daa2043 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_pack.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_pack.c
@@ -257,6 +257,32 @@ lp_build_concat_n(struct gallivm_state *gallivm,


  /**
+ * Un-interleave vector.
+ * This will return a vector consisting of every second element
+ * (depending on lo_hi, beginning at 0 or 1).
+ * The returned vector size (elems and width) will only be half
+ * that of the source vector.
+ */
+LLVMValueRef
+lp_build_uninterleave1(struct gallivm_state *gallivm,
+   unsigned num_elems,
+   LLVMValueRef a,
+   unsigned lo_hi)
+{
+   LLVMValueRef shuffle, elems[LP_MAX_VECTOR_LENGTH];
+   unsigned i;
+   assert(num_elems <= LP_MAX_VECTOR_LENGTH);
+
+   for(i = 0; i < num_elems / 2; ++i)
+  elems[i] = lp_build_const_int32(gallivm, 2*i + lo_hi);
+
+   shuffle = LLVMConstVector(elems, num_elems / 2);
+
+   return LLVMBuildShuffleVector(gallivm->builder, a, a, shuffle, "");


One don't need the second `a` here. One could use 
`LLVMGetUndef(LLVMTypeOf(a))` to make it explicit.



+}
+
+
+/**
   * Interleave vector elements.
   *
   * Matches the PUNPCKLxx and PUNPCKHxx SSE instructions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_pack.h 
b/src/gallium/auxiliary/gallivm/lp_bld_pack.h
index 7cede35..367fba1 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_pack.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_pack.h
@@ -58,6 +58,11 @@ lp_build_interleave2(struct gallivm_state *gallivm,
   LLVMValueRef b,
   unsigned lo_hi);

+LLVMValueRef
+lp_build_uninterleave1(struct gallivm_state *gallivm,
+   unsigned num_elems,
+   LLVMValueRef a,
+   unsigned lo_hi);

  void
  lp_build_unpack2(struct gallivm_state *gallivm,
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.c 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.c
index c88dfbf..1cbe47c 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.c
@@ -248,7 +248,6 @@ lp_build_tgsi_inst_llvm(
 /* Ignore 

[Mesa-dev] [PATCH] glxinfo: test GL_ATI_meminfo and GL_NVX_gpu_memory_info

2016-02-02 Thread Marek Olšák
From: Marek Olšák 

---
 src/xdemos/glxinfo.c | 53 
 1 file changed, 53 insertions(+)

diff --git a/src/xdemos/glxinfo.c b/src/xdemos/glxinfo.c
index f65451a..b0377fb 100644
--- a/src/xdemos/glxinfo.c
+++ b/src/xdemos/glxinfo.c
@@ -390,6 +390,55 @@ query_renderer(void)
 }
 
 
+static void
+query_ATI_meminfo(void)
+{
+#ifdef GL_ATI_meminfo
+int i[4];
+
+printf("Memory info (GL_ATI_meminfo):\n");
+
+glGetIntegerv(GL_VBO_FREE_MEMORY_ATI, i);
+printf("VBO free memory - total: %u MB, largest block: %u MB\n",
+   i[0] / 1024, i[1] / 1024);
+printf("VBO free aux. memory - total: %u MB, largest block: %u MB\n",
+   i[2] / 1024, i[3] / 1024);
+
+glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, i);
+printf("Texture free memory - total: %u MB, largest block: %u MB\n",
+   i[0] / 1024, i[1] / 1024);
+printf("Texture free aux. memory - total: %u MB, largest block: %u 
MB\n",
+   i[2] / 1024, i[3] / 1024);
+
+glGetIntegerv(GL_RENDERBUFFER_FREE_MEMORY_ATI, i);
+printf("Renderbuffer free memory - total: %u MB, largest block: %u 
MB\n",
+   i[0] / 1024, i[1] / 1024);
+printf("Renderbuffer free aux. memory - total: %u MB, largest block: 
%u MB\n",
+   i[2] / 1024, i[3] / 1024);
+#endif
+}
+
+
+static void
+query_NVX_gpu_memory_info(void)
+{
+#ifdef GL_NVX_gpu_memory_info
+int i;
+
+printf("Memory info (GL_NVX_gpu_memory_info):\n");
+
+glGetIntegerv(GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, );
+printf("Dedicated video memory: %u MB\n", i / 1024);
+
+glGetIntegerv(GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, );
+printf("Total available memory: %u MB\n", i / 1024);
+
+glGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, );
+printf("Currently available dedicated video memory: %u MB\n", i / 
1024);
+#endif
+}
+
+
 static Bool
 print_screen_info(Display *dpy, int scrnum,
   const struct options *opts,
@@ -547,6 +596,10 @@ print_screen_info(Display *dpy, int scrnum,
  }
  if (strstr(glxExtensions, "GLX_MESA_query_renderer"))
query_renderer();
+ if (strstr(glExtensions, "GL_ATI_meminfo"))
+query_ATI_meminfo();
+ if (strstr(glExtensions, "GL_NVX_gpu_memory_info"))
+query_NVX_gpu_memory_info();
  printf("OpenGL vendor string: %s\n", glVendor);
  printf("OpenGL renderer string: %s\n", glRenderer);
   } else
-- 
2.1.4

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


[Mesa-dev] [Bug 93965] Please backport OSMesaCreateContextAttribs to 11.1

2016-02-02 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=93965

Bug ID: 93965
   Summary: Please backport OSMesaCreateContextAttribs to 11.1
   Product: Mesa
   Version: unspecified
  Hardware: All
OS: All
Status: NEW
  Severity: normal
  Priority: medium
 Component: Other
  Assignee: mesa-dev@lists.freedesktop.org
  Reporter: dennis.schri...@uni-heidelberg.de
QA Contact: mesa-dev@lists.freedesktop.org

OSMesa in 11.2 got a new function OSMesaCreateContextAttribs() in
a34e7612dcde891121e355e78c058f138a34c31c, which is needed [1] [2] for ParaView
5.0 to be able to acquire an OpenGL 3.2 rendering context. It would be great if
this could be backported to 11.1.

Please correct me if I am wrong, but the function appears [3] to not have been
backported (and released in 11.1.1) as mentioned in an earlier mailinglist post
[2].

[1]: http://www.kitware.com/blog/home/post/999
[2]: http://permalink.gmane.org/gmane.comp.science.paraview.user/26508
[3]: http://cgit.freedesktop.org/mesa/mesa/tree/include/GL/osmesa.h?h=11.1

P.S: 11.1 does not appear in the list selectable for the "version" field of
this Bugzilla instance.

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


[Mesa-dev] [Bug 93965] Please backport OSMesaCreateContextAttribs to 11.1

2016-02-02 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=93965

--- Comment #1 from Dennis Schridde  ---
(In reply to Dennis Schridde from comment #0)
> Please correct me if I am wrong, but the function appears [3] to not have
> been backported (and released in 11.1.1) as mentioned in an earlier
> mailinglist post [2].

Actually this was mentioned as "potentially planned" in the blog post, not the
mailinglist post.

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