Re: [Mesa-dev] [PATCH 0/9] Early fp64 fixes

2015-11-20 Thread Iago Toral
On Thu, 2015-11-19 at 11:05 +0100, Iago Toral Quiroga wrote:
> These patches are fixes extracted from Connor's fp64 branch that
> I would like to review and land ahead of the rest. They are
> independent of the rest of the series, some of them are even
> general fixes unrelated to fp64 that could fix issues in master,
> others are fairly trivial and we can easily land them now.
> 
> It will help reduce the size of a rather big series (115 patches
> and counting) that is still in development and ease future
> rebases a little, specially since there is a patch that renames
> one of the nir types, so we probably want to land that soon.
> 
> Apparently, Connor sent most of these for review back in August but
> they did not get reviewed back then. I went ahead and added my Rb to
> all but one:
> 
> i965/fs: add stride restrictions for copy propagation
> 
> I could not verify all the conditions (particularly, the cases where we allow
> 0 strides), so it would be nice if someone else could review that or point me
> to the place in the docs where it says that 0 strides are safe for these
> situations. Comments/Reviews to the other patches are also welcome :)
> 
> No piglit regressions on IVB.
> 
> Connor Abbott (8):
>   i965/fs: print non-1 strides when dumping instructions
>   i965/fs: print writemask_all when it's enabled
>   i965: fix 64-bit immediates in brw_inst(_set)_bits
>   i965/fs: respect force_sechalf/force_writemask_all in CSE
>   i965/fs: don't propagate cmod when the exec sizes differ
>   i965/fs: add stride restrictions for copy propagation
>   i965/vec4: avoid dependency control around Align1 instructions
>   nir/builder: only read meaningful channels in nir_swizzle()
> 
> Jason Ekstrand (1):
>   nir: s/nir_type_unsigned/nir_type_uint

I think all the patches are reviewed except for the one about dependency
control around align1 instructions. I'll drop that one for now until
Matt has a chance to check what is going on there and also drop "print
writemask_all when it's enabled" following Connor's input (if Ken won't
push that in the end just let me know and I'll put this back)

I'll push the rest on Monday if there are not other objections.

Thanks for the quick reviews!

Iago

>  src/gallium/auxiliary/nir/tgsi_to_nir.c|  2 +-
>  src/glsl/nir/glsl_to_nir.cpp   |  2 +-
>  src/glsl/nir/nir.h |  2 +-
>  src/glsl/nir/nir_builder.h |  2 +-
>  src/glsl/nir/nir_constant_expressions.py   |  2 +-
>  src/glsl/nir/nir_opcodes.py| 78 
> +++---
>  src/glsl/nir/nir_search.c  |  4 +-
>  src/mesa/drivers/dri/i965/brw_fs.cpp   | 15 +
>  .../drivers/dri/i965/brw_fs_cmod_propagation.cpp   |  3 +
>  .../drivers/dri/i965/brw_fs_copy_propagation.cpp   | 58 +++-
>  src/mesa/drivers/dri/i965/brw_fs_cse.cpp   |  2 +
>  src/mesa/drivers/dri/i965/brw_inst.h   |  6 +-
>  src/mesa/drivers/dri/i965/brw_nir.c|  4 +-
>  src/mesa/drivers/dri/i965/brw_vec4.cpp | 17 +++--
>  src/mesa/drivers/dri/i965/brw_vec4_nir.cpp |  2 +-
>  15 files changed, 142 insertions(+), 57 deletions(-)
> 


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


Re: [Mesa-dev] [PATCH 1/2] i965: Use ldexpf() in VF float test set up.

2015-11-20 Thread Iago Toral
Reviewed-by: Iago Toral Quiroga 

On Thu, 2015-11-19 at 22:43 -0800, Matt Turner wrote:
> ---
>  src/mesa/drivers/dri/i965/test_vf_float_conversions.cpp | 11 +++
>  1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/test_vf_float_conversions.cpp 
> b/src/mesa/drivers/dri/i965/test_vf_float_conversions.cpp
> index 6a8bcea..7f03425 100644
> --- a/src/mesa/drivers/dri/i965/test_vf_float_conversions.cpp
> +++ b/src/mesa/drivers/dri/i965/test_vf_float_conversions.cpp
> @@ -40,15 +40,10 @@ void vf_float_conversion_test::SetUp() {
>int ebits = (vf >> 4) & 0x7;
>int mbits = vf & 0xf;
>  
> -  int e = ebits - 3;
> +  float x = 1.0f + mbits / 16.0f;
> +  int exp = ebits - 3;
>  
> -  float value = 1.0f;
> -
> -  value += mbits / 16.0f;
> -
> -  value *= exp2f(e);
> -
> -  vf_to_float[vf] = value;
> +  vf_to_float[vf] = ldexpf(x, exp);
> }
>  }
>  


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


Re: [Mesa-dev] [PATCH 2/2] i965: Test that nonrepresentable floats cannot be converted to VF.

2015-11-20 Thread Iago Toral
Reviewed-by: Iago Toral Quiroga 

On Thu, 2015-11-19 at 22:43 -0800, Matt Turner wrote:
> ---
>  src/mesa/drivers/dri/i965/test_vf_float_conversions.cpp | 15 +++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/src/mesa/drivers/dri/i965/test_vf_float_conversions.cpp 
> b/src/mesa/drivers/dri/i965/test_vf_float_conversions.cpp
> index 7f03425..7af97d0 100644
> --- a/src/mesa/drivers/dri/i965/test_vf_float_conversions.cpp
> +++ b/src/mesa/drivers/dri/i965/test_vf_float_conversions.cpp
> @@ -93,3 +93,18 @@ TEST_F(vf_float_conversion_test, test_special_case_0)
> EXPECT_EQ(f2u(brw_vf_to_float(brw_float_to_vf(+0.0f))), f2u(+0.0f));
> EXPECT_EQ(f2u(brw_vf_to_float(brw_float_to_vf(-0.0f))), f2u(-0.0f));
>  }
> +
> +TEST_F(vf_float_conversion_test, test_nonrepresentable_float_input)
> +{
> +   EXPECT_EQ(brw_float_to_vf(+32.0f), -1);
> +   EXPECT_EQ(brw_float_to_vf(-32.0f), -1);
> +
> +   EXPECT_EQ(brw_float_to_vf(+16.5f), -1);
> +   EXPECT_EQ(brw_float_to_vf(-16.5f), -1);
> +
> +   EXPECT_EQ(brw_float_to_vf(+8.25f), -1);
> +   EXPECT_EQ(brw_float_to_vf(-8.25f), -1);
> +
> +   EXPECT_EQ(brw_float_to_vf(+4.125f), -1);
> +   EXPECT_EQ(brw_float_to_vf(-4.125f), -1);
> +}


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


Re: [Mesa-dev] [PATCH v3 13/14] glsl: add subroutine index qualifier support

2015-11-20 Thread Tapani Pälli

Reviewed-by: Tapani Pälli 

On 11/14/2015 03:42 PM, Timothy Arceri wrote:

From: Timothy Arceri 

ARB_explicit_uniform_location allows the index for subroutine functions
to be explicitly set in the shader.

This patch reduces the restriction on the index qualifier in
validate_layout_qualifiers() to allow it to be applied to subroutines
and adds the new subroutine qualifier validation to ast_function::hir().

ast_fully_specified_type::has_qualifiers() is updated to allow the
index qualifier on subroutine functions when explicit uniform locations
is available.

A new check is added to ast_type_qualifier::merge_qualifier() to stop
multiple function qualifiers from being defied, before this patch this
would cause a segfault.

Finally a new variable is added to ir_function_signature to store the
index. This value is validated and the non explicit values assigned in
link_assign_subroutine_types().
---
  src/glsl/ast.h |  2 +-
  src/glsl/ast_to_hir.cpp| 34 --
  src/glsl/ast_type.cpp  | 14 +-
  src/glsl/ir.cpp|  1 +
  src/glsl/ir.h  |  2 ++
  src/glsl/ir_clone.cpp  |  1 +
  src/glsl/linker.cpp| 33 +
  src/mesa/main/mtypes.h |  1 +
  src/mesa/main/shader_query.cpp |  7 +++
  9 files changed, 91 insertions(+), 4 deletions(-)

diff --git a/src/glsl/ast.h b/src/glsl/ast.h
index bfeab6b..1e4a998 100644
--- a/src/glsl/ast.h
+++ b/src/glsl/ast.h
@@ -772,7 +772,7 @@ public:
  class ast_fully_specified_type : public ast_node {
  public:
 virtual void print(void) const;
-   bool has_qualifiers() const;
+   bool has_qualifiers(_mesa_glsl_parse_state *state) const;

 ast_fully_specified_type() : qualifier(), specifier(NULL)
 {
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 6a3ec44..6c56829 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -2848,6 +2848,13 @@ apply_explicit_location(const struct ast_type_qualifier 
*qual,
   break;
}

+  /* Check if index was set for the uniform instead of the function */
+  if (qual->flags.q.explicit_index && qual->flags.q.subroutine) {
+ _mesa_glsl_error(loc, state, "an index qualifier can only be "
+  "used with subroutine functions");
+ return;
+  }
+
unsigned qual_index;
if (qual->flags.q.explicit_index &&
process_qualifier_constant(state, loc, "index", qual->index,
@@ -3067,7 +3074,9 @@ apply_layout_qualifier_to_variable(const struct 
ast_type_qualifier *qual,
 if (qual->flags.q.explicit_location) {
apply_explicit_location(qual, var, state, loc);
 } else if (qual->flags.q.explicit_index) {
-  _mesa_glsl_error(loc, state, "explicit index requires explicit 
location");
+  if (!qual->flags.q.subroutine_def)
+ _mesa_glsl_error(loc, state,
+  "explicit index requires explicit location");
 }

 if (qual->flags.q.explicit_binding) {
@@ -5075,7 +5084,7 @@ ast_function::hir(exec_list *instructions,
 /* From page 56 (page 62 of the PDF) of the GLSL 1.30 spec:
  * "No qualifier is allowed on the return type of a function."
  */
-   if (this->return_type->has_qualifiers()) {
+   if (this->return_type->has_qualifiers(state)) {
YYLTYPE loc = this->get_location();
_mesa_glsl_error(& loc, state,
 "function `%s' return type has qualifiers", name);
@@ -5207,6 +5216,27 @@ ast_function::hir(exec_list *instructions,
 if (this->return_type->qualifier.flags.q.subroutine_def) {
int idx;

+  if (this->return_type->qualifier.flags.q.explicit_index) {
+ unsigned qual_index;
+ if (process_qualifier_constant(state, &loc, "index",
+this->return_type->qualifier.index,
+&qual_index)) {
+if (!state->has_explicit_uniform_location()) {
+   _mesa_glsl_error(&loc, state, "subroutine index requires "
+"GL_ARB_explicit_uniform_location or "
+"GLSL 4.30");
+} else if (qual_index >= MAX_SUBROUTINES) {
+   _mesa_glsl_error(&loc, state,
+"invalid subroutine index (%d) index must "
+"be a number between 0 and "
+"GL_MAX_SUBROUTINES - 1 (%d)", qual_index,
+MAX_SUBROUTINES - 1);
+} else {
+   f->subroutine_index = qual_index;
+}
+ }
+  }
+
f->num_subroutine_types = 
this->return_type->qualifier.subroutine_list->declarations.length();
f->subroutine_types = ralloc_array(state, const struct glsl_type *,
   f->num_subroutine_types);
diff --git a/src/glsl/ast_t

[Mesa-dev] [Bug 92985] Mac OS X build error "ar: no archive members specified"

2015-11-20 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=92985

Emil Velikov  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED

--- Comment #4 from Emil Velikov  ---
This bug should be fixed with

commit 7157085140a502a182ff0e23d30bd8e421212c42
Author: Emil Velikov 
Date:   Thu Nov 19 15:36:03 2015 +

automake: loader: don't create an empty dri3 helper


The other issues mentioned in comment 3 have been fixed with patches prior to
the above referenced one.

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


Re: [Mesa-dev] [PATCH 4/4] automake: loader: don't create an empty dri3 helper

2015-11-20 Thread Emil Velikov
On 20 November 2015 at 05:37, Vinson Lee  wrote:
> On Thu, Nov 19, 2015 at 9:36 PM, Vinson Lee  wrote:
>> On Thu, Nov 19, 2015 at 8:32 AM, Emil Velikov  
>> wrote:
>>> On 19 November 2015 at 16:33, Emil Velikov  wrote:
 From: Emil Velikov 

 Seems that creating an empty one does not fair too well with MacOSX's
 ar. Considering that all the users of the helper include it only when
 needed, let's reshuffle the makefile.

>>> Forgot to mention - the cause is guesswork, as I'm not that intimate
>>> familiar with different AR implementations. Yet this seems the most
>>> likely one.
>>>
>>> Vinson, can you test this ?
>>>
>>> -Emil
>>
>> This patch fixed my Mac OS X build error.
>>
>> Tested-by: Vinson Lee 
>
> Fixed a typo in Tested-by line.
>
> Tested-by: Vinson Lee 
So my guesswork was right. Nice :-)

Thanks to all for the reviews and testing !
Emil
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 00/13] auxiliary/vl: winsys' galore

2015-11-20 Thread Emil Velikov
On 10 November 2015 at 22:31, Alex Deucher  wrote:
> On Mon, Nov 9, 2015 at 8:31 AM, Emil Velikov  wrote:
>> Hi all,
>>
>> Inspired by the resent interest in alternative vl winsys, I've decided
>> to rework the winsys into a traditional gallium fashion.
>>
>> Namely: add the destroy() and other functions into struct vl_screen.
>> This will allow users (state-trackers) to call the
>> vl_foo_screen_create() entry point and do the rest in a generic manner.
>>
>> It will also ease the introduction of other winsys (dri3, wayland,
>> android anyone ?) into the module. As a follow up one can even remove
>> the static linking to xcb and friends, with a dlopen/dlsym combo.
>>
>> The lot can be found in branch 'hello-vl' at
>> https://github.com/evelikov/mesa
>>
>> Comments, suggestions and bikeshed wars are welcome.
>
> Not really my area of expertise, but it seems like a nice cleanup.
>
> Acked-by: Alex Deucher 
Thanks Alex.

I've went ahead and pushed the series with you ack. If you guys spot
any regressions or you'd like to nuke the static linking to xcb & co.
let me know.

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


Re: [Mesa-dev] [PATCH] xmlconfig: Add support for DragonFly

2015-11-20 Thread Emil Velikov
Hi Francois,

On 17 November 2015 at 18:17, Francois Tigeot  wrote:
> Hi,
>
> Emil has recently convinced me to send DragonFly support patches present in
> our ports tree, so here's the first one.
>
Glad to hear it :-P

Considering how trivial the patch is (and lack of objections) I've
pushed it to master... only to forget the mesa-stable tag (I'll pick
it up for the next stable release regardless) :-\ If you have _any_
additional patches do send them over, but please use git send-email -
it makes review/commenting a bit easier.

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


Re: [Mesa-dev] [PATCH] android: fix LOCAL_C_INCLUDES to find glsl_types.h

2015-11-20 Thread Emil Velikov
On 14 November 2015 at 14:43, Mauro Rossi  wrote:
> Hi Emil,
>
> I checked with Chih-Wei and LOCAL_EXPORT_C_INCLUDE_DIRS is the preferred
> way.
>
> I took the chance to finally understand why the single line of change you
> proposed will suffice,
> it's because glsl_compiler module invokes libmesa_glsl as static library and
> the same applies to i965_dri module.
>
> My last problem was probably due to uncleaned mesa targets folders in $OUT
> path,
> now I have checked again and building errors are gone.
>
You might want to take a look and update the CleanSpec.mk for that.
I've pushed the one-liner to master - do we want it in stable (11.0.x)
as well ? I'm not sure which branch android-x86 current follows.

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


[Mesa-dev] [Bug 92985] Mac OS X build error "ar: no archive members specified"

2015-11-20 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=92985

Emil Velikov  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #5 from Emil Velikov  ---
Got the wrong status - this issue should be resolved/fixed.

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


Re: [Mesa-dev] [PATCH v3 7/9] gallium: add the concept of batch queries

2015-11-20 Thread Samuel Pitoiset

Reviewed-by: Samuel Pitoiset 


On 11/18/2015 12:49 PM, Nicolai Hähnle wrote:

Some drivers (in particular radeon[si], but also freedreno judging from
a quick grep) may want to expose performance counters that cannot be
individually enabled or disabled.

Allow such drivers to mark driver-specific queries as requiring a new
type of batch query object that is used to start and stop a list of queries
simultaneously.

v3: adjust recently added nv50 queries

v2: documentation for create_batch_query
---
  src/gallium/drivers/nouveau/nv50/nv50_query.c |  1 +
  src/gallium/drivers/nouveau/nvc0/nvc0_query.c |  1 +
  src/gallium/include/pipe/p_context.h  | 19 +++
  src/gallium/include/pipe/p_defines.h  | 27 +--
  4 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nv50/nv50_query.c 
b/src/gallium/drivers/nouveau/nv50/nv50_query.c
index 643d430..6b3e49a 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_query.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_query.c
@@ -174,6 +174,7 @@ nv50_screen_get_driver_query_info(struct pipe_screen 
*pscreen,
 info->max_value.u64 = 0;
 info->type = PIPE_DRIVER_QUERY_TYPE_UINT64;
 info->group_id = -1;
+   info->flags = 0;

 return nv50_hw_get_driver_query_info(screen, id, info);
  }
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c 
b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
index 1f1270e..d992b10 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
@@ -162,6 +162,7 @@ nvc0_screen_get_driver_query_info(struct pipe_screen 
*pscreen,
 info->max_value.u64 = 0;
 info->type = PIPE_DRIVER_QUERY_TYPE_UINT64;
 info->group_id = -1;
+   info->flags = 0;

  #ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS
 if (id < num_sw_queries)
diff --git a/src/gallium/include/pipe/p_context.h 
b/src/gallium/include/pipe/p_context.h
index 27f358f..be7447d 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -116,6 +116,25 @@ struct pipe_context {
 unsigned query_type,
 unsigned index );

+   /**
+* Create a query object that queries all given query types simultaneously.
+*
+* This can only be used for those query types for which
+* get_driver_query_info indicates that it must be used. Only one batch
+* query object may be active at a time.
+*
+* There may be additional constraints on which query types can be used
+* together, in particular those that are implied by
+* get_driver_query_group_info.
+*
+* \param num_queries the number of query types
+* \param query_types array of \p num_queries query types
+* \return a query object, or NULL on error.
+*/
+   struct pipe_query *(*create_batch_query)( struct pipe_context *pipe,
+ unsigned num_queries,
+ unsigned *query_types );
+
 void (*destroy_query)(struct pipe_context *pipe,
   struct pipe_query *q);

diff --git a/src/gallium/include/pipe/p_defines.h 
b/src/gallium/include/pipe/p_defines.h
index 7ed9f6d..b3c8b9f 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -776,6 +776,16 @@ struct pipe_query_data_pipeline_statistics
  };

  /**
+ * For batch queries.
+ */
+union pipe_numeric_type_union
+{
+   uint64_t u64;
+   uint32_t u32;
+   float f;
+};
+
+/**
   * Query result (returned by pipe_context::get_query_result).
   */
  union pipe_query_result
@@ -811,6 +821,9 @@ union pipe_query_result

 /* PIPE_QUERY_PIPELINE_STATISTICS */
 struct pipe_query_data_pipeline_statistics pipeline_statistics;
+
+   /* batch queries */
+   union pipe_numeric_type_union batch[0];
  };

  union pipe_color_union
@@ -840,12 +853,13 @@ enum pipe_driver_query_result_type
 PIPE_DRIVER_QUERY_RESULT_TYPE_CUMULATIVE = 1,
  };

-union pipe_numeric_type_union
-{
-   uint64_t u64;
-   uint32_t u32;
-   float f;
-};
+/**
+ * Some hardware requires some hardware-specific queries to be submitted
+ * as batched queries. The corresponding query objects are created using
+ * create_batch_query, and at most one such query may be active at
+ * any time.
+ */
+#define PIPE_DRIVER_QUERY_FLAG_BATCH (1 << 0)

  struct pipe_driver_query_info
  {
@@ -855,6 +869,7 @@ struct pipe_driver_query_info
 enum pipe_driver_query_type type;
 enum pipe_driver_query_result_type result_type;
 unsigned group_id;
+   unsigned flags;
  };

  struct pipe_driver_query_group_info



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


Re: [Mesa-dev] [PATCH] radeon/llvm: Use llvm.AMDIL.exp intrinsic again for now

2015-11-20 Thread Nicolai Hähnle

On 20.11.2015 03:22, Michel Dänzer wrote:

On 20.11.2015 02:11, Nicolai Hähnle wrote:

On 19.11.2015 17:37, Tom Stellard wrote:

On Thu, Nov 19, 2015 at 11:17:12AM +0100, Nicolai Hähnle wrote:

On 19.11.2015 03:55, Tom Stellard wrote:

On Thu, Nov 19, 2015 at 11:31:55AM +0900, Michel Dänzer wrote:

From: Michel Dänzer 

llvm.exp2.f32 doesn't work in some cases yet.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92709
Signed-off-by: Michel Dänzer 
---

Once the problem is fixed in the LLVM AMDGPU backend, we can re-enable
llvm.exp2.f32 for the fixed LLVM version.

   src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c | 2 +-
   1 file changed, 1 insertion(+), 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 ac99e73..c94f109 100644
--- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
+++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
@@ -1539,7 +1539,7 @@ void radeon_llvm_context_init(struct
radeon_llvm_context * ctx)
   bld_base->op_actions[TGSI_OPCODE_ENDIF].emit = endif_emit;
   bld_base->op_actions[TGSI_OPCODE_ENDLOOP].emit = endloop_emit;
   bld_base->op_actions[TGSI_OPCODE_EX2].emit =
build_tgsi_intrinsic_nomem;
-bld_base->op_actions[TGSI_OPCODE_EX2].intr_name =
"llvm.exp2.f32";
+bld_base->op_actions[TGSI_OPCODE_EX2].intr_name =
"llvm.AMDIL.exp.";


Do we want a native instruction here, or do we want IEEE precise exp2?
If it's the former then we shouldn't be using llvm.exp2.f32 anyway.

I know that we need to use llvm.AMDIL.exp. for older LLVM, but for
newer
LLVM, I would really like to start doing intrinsics the correct
way.  In
this case, it means adding an llvm.amdgcn.exp.f32 intrinsic to
include/llvm/IR/IntrinsicsAMDGPU.td.  In the section with the amdgcn
TargetPrefix.


Doesn't AMDGPU currently emit native instructions for the various
math intrinsics anyway? If your plan is to change that and we add
our own intrinsics, what's the plan to still benefit from existing
LLVM optimization passes?



AMDGPU does emit native instruction for the math intrinsics, but this is
wrong in most cases, because it assumes that a less precise
calculation is
acceptable when this is not always the case.


Okay, that makes sense.


This a good point about optimizations.  I think the main benefits we
get from
using the LLVM intrinsic are constant folding and also speculative
execution.

An alternate solution would be to use the llvm intrinsic, but then
communicate
to the backend via a function attribute that it is OK to use the less
precise
version of exp.


I like that alternate solution.


FWIW, the original bug that Michel addresses here is caused by LLVM
libcall optimizations replacing the exp2 _intrinsic_ by a ldexp
_libcall_, which AMDGPU codegen cannot deal with. I suggested to
address this with http://reviews.llvm.org/D14327. Could you take a
look at that?



Please take a look at the comment I added to this review.


Done :)


Meanwhile, can I get an R-b for this patch to fix the immediate
regression in Mesa Git until LLVM is fixed (and for released versions of
LLVM)?


Right, sorry about that:

Reviewed-by: Nicolai Hähnle 






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


Re: [Mesa-dev] [PATCH v3 8/9] gallium/hud: add support for batch queries

2015-11-20 Thread Samuel Pitoiset

Reviewed-by: Samuel Pitoiset 


On 11/18/2015 12:49 PM, Nicolai Hähnle wrote:

v2 + v3: be more defensive about allocations
---
  src/gallium/auxiliary/hud/hud_context.c  |  24 ++-
  src/gallium/auxiliary/hud/hud_driver_query.c | 270 +++
  src/gallium/auxiliary/hud/hud_private.h  |  13 +-
  3 files changed, 261 insertions(+), 46 deletions(-)

diff --git a/src/gallium/auxiliary/hud/hud_context.c 
b/src/gallium/auxiliary/hud/hud_context.c
index ffe30b8..bcef701 100644
--- a/src/gallium/auxiliary/hud/hud_context.c
+++ b/src/gallium/auxiliary/hud/hud_context.c
@@ -57,6 +57,7 @@ struct hud_context {
 struct cso_context *cso;
 struct u_upload_mgr *uploader;

+   struct hud_batch_query_context *batch_query;
 struct list_head pane_list;

 /* states */
@@ -510,6 +511,8 @@ hud_draw(struct hud_context *hud, struct pipe_resource *tex)
 hud_alloc_vertices(hud, &hud->text, 4 * 512, 4 * sizeof(float));

 /* prepare all graphs */
+   hud_batch_query_update(hud->batch_query);
+
 LIST_FOR_EACH_ENTRY(pane, &hud->pane_list, head) {
LIST_FOR_EACH_ENTRY(gr, &pane->graph_list, head) {
   gr->query_new_value(gr);
@@ -903,17 +906,21 @@ hud_parse_env_var(struct hud_context *hud, const char 
*env)
}
else if (strcmp(name, "samples-passed") == 0 &&
 has_occlusion_query(hud->pipe->screen)) {
- hud_pipe_query_install(pane, hud->pipe, "samples-passed",
+ hud_pipe_query_install(&hud->batch_query, pane, hud->pipe,
+"samples-passed",
  PIPE_QUERY_OCCLUSION_COUNTER, 0, 0,
  PIPE_DRIVER_QUERY_TYPE_UINT64,
-PIPE_DRIVER_QUERY_RESULT_TYPE_AVERAGE);
+PIPE_DRIVER_QUERY_RESULT_TYPE_AVERAGE,
+0);
}
else if (strcmp(name, "primitives-generated") == 0 &&
 has_streamout(hud->pipe->screen)) {
- hud_pipe_query_install(pane, hud->pipe, "primitives-generated",
+ hud_pipe_query_install(&hud->batch_query, pane, hud->pipe,
+"primitives-generated",
  PIPE_QUERY_PRIMITIVES_GENERATED, 0, 0,
  PIPE_DRIVER_QUERY_TYPE_UINT64,
-PIPE_DRIVER_QUERY_RESULT_TYPE_AVERAGE);
+PIPE_DRIVER_QUERY_RESULT_TYPE_AVERAGE,
+0);
}
else {
   boolean processed = FALSE;
@@ -938,17 +945,19 @@ hud_parse_env_var(struct hud_context *hud, const char 
*env)
 if (strcmp(name, pipeline_statistics_names[i]) == 0)
break;
  if (i < Elements(pipeline_statistics_names)) {
-   hud_pipe_query_install(pane, hud->pipe, name,
+   hud_pipe_query_install(&hud->batch_query, pane, hud->pipe, name,
PIPE_QUERY_PIPELINE_STATISTICS, i,
0, PIPE_DRIVER_QUERY_TYPE_UINT64,
-  PIPE_DRIVER_QUERY_RESULT_TYPE_AVERAGE);
+  PIPE_DRIVER_QUERY_RESULT_TYPE_AVERAGE,
+  0);
 processed = TRUE;
  }
   }

   /* driver queries */
   if (!processed) {
-if (!hud_driver_query_install(pane, hud->pipe, name)){
+if (!hud_driver_query_install(&hud->batch_query, pane, hud->pipe,
+  name)) {
 fprintf(stderr, "gallium_hud: unknown driver query '%s'\n", 
name);
  }
   }
@@ -1287,6 +1296,7 @@ hud_destroy(struct hud_context *hud)
FREE(pane);
 }

+   hud_batch_query_cleanup(&hud->batch_query);
 pipe->delete_fs_state(pipe, hud->fs_color);
 pipe->delete_fs_state(pipe, hud->fs_text);
 pipe->delete_vs_state(pipe, hud->vs);
diff --git a/src/gallium/auxiliary/hud/hud_driver_query.c 
b/src/gallium/auxiliary/hud/hud_driver_query.c
index 3198ab3..d7b1f11 100644
--- a/src/gallium/auxiliary/hud/hud_driver_query.c
+++ b/src/gallium/auxiliary/hud/hud_driver_query.c
@@ -34,13 +34,164 @@
  #include "hud/hud_private.h"
  #include "pipe/p_screen.h"
  #include "os/os_time.h"
+#include "util/u_math.h"
  #include "util/u_memory.h"
  #include 

+// Must be a power of two
  #define NUM_QUERIES 8

+struct hud_batch_query_context {
+   struct pipe_context *pipe;
+   unsigned num_query_types;
+   unsigned allocated_query_types;
+   unsigned *query_types;
+
+   boolean failed;
+   struct pipe_query *query[NUM_QUERIES];
+   union pipe_query_result *result[NUM_QUERIES];
+   unsigned head, pending, results;
+};
+
+void
+hud_batch_query_update(struct hud_batch_query_context *bq)
+{
+   struct pipe_context *pipe;
+
+   if (!bq || bq->failed)
+  return;
+
+   pipe = bq->pipe;

[Mesa-dev] Link failure when copying big arrays stored in SSBOs

2015-11-20 Thread Iago Toral
Hi,

Jordan sent a piglit test that produces a link failure with the ssbo
code [1]. Doing something like this is sufficient to reproduce the
problem:

[fragment shader]
#version 330
#extension GL_ARB_shader_storage_buffer_object: require

#define SIZE 6

layout (std430) buffer SSBO {
mat4 m1[SIZE];
mat4 m2[SIZE];
};

void main() {
m2 = m1;
}

the thing here is that the lower_ubo_reference pass will first find that
we read all of m1 and emit ssbo loads for each offset, then it will find
the write to m2 and emit all the writes, one for each offset. That
produces NIR code that looks like this:

vec4 ssa_1 = intrinsic load_ssbo (ssa_0) () (0)
vec4 ssa_2 = intrinsic load_ssbo (ssa_0) () (16)
vec4 ssa_3 = intrinsic load_ssbo (ssa_0) () (32)
(...)
vec4 ssa_24 = intrinsic load_ssbo (ssa_0) () (368)
intrinsic store_ssbo (ssa_24, ssa_0) () (752, 15)
intrinsic store_ssbo (ssa_23, ssa_0) () (736, 15)
intrinsic store_ssbo (ssa_22, ssa_0) () (720, 15)
(...)
intrinsic store_ssbo (ssa_1, ssa_0) () (384, 15)

Down at the i965 level, the registers used to configure the loads are
also used also to configure the writes (since they specify the address),
which means that they are alive for the whole time between the read and
the write to the same offset. For example:

{  7}1: untyped_surface_read(8) (mlen: 1) vgrf95+2.0:UD, vgrf25:UD
...  ...
...  ...
{  6}  140: mov(8) vgrf95+0.0:UD, 0d NoMask
{  6}  141: mov(8) vgrf95+0.28:UD, g1:UD NoMask
{  6}  142: mov(8) vgrf95+1.0:UD, 384u
{  6}  143: untyped_surface_write(8) (mlen: 6) null:UD, vgrf95:UD

In that code, vgrf95 is alive in ip=[1, 143]. The same goes for all the
other offsets, so we just end up with too many live registers. In
general, register pressure increases with each load and won't decrease
until we start with the writes, so the larger the arrays get the worse
the situation becomes.

I don't think we can do much about this other than maybe handling array
copies specially (so that instead of emitting all the loads first and
all the stores second, we emit the load and store for each element at
once, reducing liveness for the registers involved. I am assuming that
nobody would write structs big enough to generate the same problem
there, but hey... :)

Any better ideas?

Iago

[1]http://lists.freedesktop.org/archives/piglit/2015-November/018055.html

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


Re: [Mesa-dev] Link failure when copying big arrays stored in SSBOs

2015-11-20 Thread Iago Toral
On Fri, 2015-11-20 at 13:07 +0100, Iago Toral wrote:
> Hi,
> 
> Jordan sent a piglit test that produces a link failure with the ssbo
> code [1]. Doing something like this is sufficient to reproduce the
> problem:
> 
> [fragment shader]
> #version 330
> #extension GL_ARB_shader_storage_buffer_object: require
> 
> #define SIZE 6
> 
> layout (std430) buffer SSBO {
> mat4 m1[SIZE];
> mat4 m2[SIZE];
> };
> 
> void main() {
> m2 = m1;
> }
> 
> the thing here is that the lower_ubo_reference pass will first find that
> we read all of m1 and emit ssbo loads for each offset, then it will find
> the write to m2 and emit all the writes, one for each offset. That
> produces NIR code that looks like this:
> 
> vec4 ssa_1 = intrinsic load_ssbo (ssa_0) () (0)
> vec4 ssa_2 = intrinsic load_ssbo (ssa_0) () (16)
> vec4 ssa_3 = intrinsic load_ssbo (ssa_0) () (32)
> (...)
> vec4 ssa_24 = intrinsic load_ssbo (ssa_0) () (368)
> intrinsic store_ssbo (ssa_24, ssa_0) () (752, 15)
> intrinsic store_ssbo (ssa_23, ssa_0) () (736, 15)
> intrinsic store_ssbo (ssa_22, ssa_0) () (720, 15)
> (...)
> intrinsic store_ssbo (ssa_1, ssa_0) () (384, 15)
> 
> Down at the i965 level, the registers used to configure the loads are
> also used also to configure the writes (since they specify the address),
> which means that they are alive for the whole time between the read and
> the write to the same offset. For example:
> 
> {  7}1: untyped_surface_read(8) (mlen: 1) vgrf95+2.0:UD, vgrf25:UD
> ...  ...
> ...  ...
> {  6}  140: mov(8) vgrf95+0.0:UD, 0d NoMask
> {  6}  141: mov(8) vgrf95+0.28:UD, g1:UD NoMask
> {  6}  142: mov(8) vgrf95+1.0:UD, 384u
> {  6}  143: untyped_surface_write(8) (mlen: 6) null:UD, vgrf95:UD
> 
> In that code, vgrf95 is alive in ip=[1, 143]. The same goes for all the
> other offsets, so we just end up with too many live registers. In
> general, register pressure increases with each load and won't decrease
> until we start with the writes, so the larger the arrays get the worse
> the situation becomes.
> 
> I don't think we can do much about this other than maybe handling array
> copies specially (so that instead of emitting all the loads first and
> all the stores second, we emit the load and store for each element at
> once, reducing liveness for the registers involved. I am assuming that
> nobody would write structs big enough to generate the same problem
> there, but hey... :)

Actually, we'd need the same for struct copies, since we would run into
the same problem as soon as they include large arrays of course.

> Any better ideas?
> 
> Iago
> 
> [1]http://lists.freedesktop.org/archives/piglit/2015-November/018055.html


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


Re: [Mesa-dev] [PATCH] gallivm: use sampler index 0 for texel fetches

2015-11-20 Thread Jose Fonseca

On 20/11/15 03:50, srol...@vmware.com wrote:

From: Roland Scheidegger 

texel fetches don't use any samplers. Previously we just set the same
number for both texture and sampler unit (as per "ordinary" gl style
sampling where the numbers are always the same) however this would trigger
some assertions checking that the sampler index isn't over PIPE_MAX_SAMPLERS
limit elsewhere with d3d10, so just set to 0.
(Fixing the assertion instead isn't really an option, the sampler isn't
really used but might still pass an out-of-bound pointer around and even
copy some things from it.)
---
  src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 7 ++-
  1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
index 7d2cd9a..28c7a86 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
@@ -2608,7 +2608,12 @@ emit_fetch_texels( struct lp_build_tgsi_soa_context *bld,
 params.type = bld->bld_base.base.type;
 params.sample_key = sample_key;
 params.texture_index = unit;
-   params.sampler_index = unit;
+   /*
+* sampler not actually used, set to 0 so it won't exceed PIPE_MAX_SAMPLERS
+* and trigger some assertions with d3d10 where the sampler view number
+* can exceed this.
+*/
+   params.sampler_index = 0;
 params.context_ptr = bld->context_ptr;
 params.thread_data_ptr = bld->thread_data_ptr;
 params.coords = coords;



Makes sense.

Reviewed-by: Jose Fonseca 

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


Re: [Mesa-dev] [PATCH v3 9/9] st/mesa: add support for batch driver queries to perfmon

2015-11-20 Thread Samuel Pitoiset

Reviewed-by: Samuel Pitoiset 


On 11/18/2015 12:49 PM, Nicolai Hähnle wrote:

v2 + v3: forgot null-pointer checks (spotted by Samuel Pitoiset)
---
  src/mesa/state_tracker/st_cb_perfmon.c | 83 +++---
  src/mesa/state_tracker/st_cb_perfmon.h |  6 +++
  2 files changed, 82 insertions(+), 7 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_perfmon.c 
b/src/mesa/state_tracker/st_cb_perfmon.c
index 8628e23..8fdf0e8 100644
--- a/src/mesa/state_tracker/st_cb_perfmon.c
+++ b/src/mesa/state_tracker/st_cb_perfmon.c
@@ -42,7 +42,10 @@ init_perf_monitor(struct gl_context *ctx, struct 
gl_perf_monitor_object *m)
 struct st_context *st = st_context(ctx);
 struct st_perf_monitor_object *stm = st_perf_monitor_object(m);
 struct pipe_context *pipe = st->pipe;
+   unsigned *batch = NULL;
 unsigned num_active_counters = 0;
+   unsigned max_batch_counters = 0;
+   unsigned num_batch_counters = 0;
 int gid, cid;

 st_flush_bitmap_cache(st);
@@ -50,6 +53,7 @@ init_perf_monitor(struct gl_context *ctx, struct 
gl_perf_monitor_object *m)
 /* Determine the number of active counters. */
 for (gid = 0; gid < ctx->PerfMonitor.NumGroups; gid++) {
const struct gl_perf_monitor_group *g = &ctx->PerfMonitor.Groups[gid];
+  const struct st_perf_monitor_group *stg = &st->perfmon[gid];

if (m->ActiveGroups[gid] > g->MaxActiveCounters) {
   /* Maximum number of counters reached. Cannot start the session. */
@@ -61,6 +65,8 @@ init_perf_monitor(struct gl_context *ctx, struct 
gl_perf_monitor_object *m)
}

num_active_counters += m->ActiveGroups[gid];
+  if (stg->has_batch)
+ max_batch_counters += m->ActiveGroups[gid];
 }

 if (!num_active_counters)
@@ -71,6 +77,12 @@ init_perf_monitor(struct gl_context *ctx, struct 
gl_perf_monitor_object *m)
 if (!stm->active_counters)
return false;

+   if (max_batch_counters) {
+  batch = CALLOC(max_batch_counters, sizeof(*batch));
+  if (!batch)
+ return false;
+   }
+
 /* Create a query for each active counter. */
 for (gid = 0; gid < ctx->PerfMonitor.NumGroups; gid++) {
const struct gl_perf_monitor_group *g = &ctx->PerfMonitor.Groups[gid];
@@ -82,13 +94,35 @@ init_perf_monitor(struct gl_context *ctx, struct 
gl_perf_monitor_object *m)
   struct st_perf_counter_object *cntr =
  &stm->active_counters[stm->num_active_counters];

- cntr->query= pipe->create_query(pipe, stc->query_type, 0);
   cntr->id   = cid;
   cntr->group_id = gid;
+ if (stc->flags & PIPE_DRIVER_QUERY_FLAG_BATCH) {
+cntr->batch_index = num_batch_counters;
+batch[num_batch_counters++] = stc->query_type;
+ } else {
+cntr->query = pipe->create_query(pipe, stc->query_type, 0);
+if (!cntr->query)
+   goto fail;
+ }
   ++stm->num_active_counters;
}
 }
+
+   /* Create the batch query. */
+   if (num_batch_counters) {
+  stm->batch_query = pipe->create_batch_query(pipe, num_batch_counters,
+  batch);
+  stm->batch_result = CALLOC(num_batch_counters, 
sizeof(stm->batch_result->batch[0]));
+  if (!stm->batch_query || !stm->batch_result)
+ goto fail;
+   }
+
+   FREE(batch);
 return true;
+
+fail:
+   FREE(batch);
+   return false;
  }

  static void
@@ -105,6 +139,13 @@ reset_perf_monitor(struct st_perf_monitor_object *stm,
 FREE(stm->active_counters);
 stm->active_counters = NULL;
 stm->num_active_counters = 0;
+
+   if (stm->batch_query) {
+  pipe->destroy_query(pipe, stm->batch_query);
+  stm->batch_query = NULL;
+   }
+   FREE(stm->batch_result);
+   stm->batch_result = NULL;
  }

  static struct gl_perf_monitor_object *
@@ -143,9 +184,13 @@ st_BeginPerfMonitor(struct gl_context *ctx, struct 
gl_perf_monitor_object *m)
 /* Start the query for each active counter. */
 for (i = 0; i < stm->num_active_counters; ++i) {
struct pipe_query *query = stm->active_counters[i].query;
-  if (!pipe->begin_query(pipe, query))
+  if (query && !pipe->begin_query(pipe, query))
goto fail;
 }
+
+   if (stm->batch_query && !pipe->begin_query(pipe, stm->batch_query))
+  goto fail;
+
 return true;

  fail:
@@ -164,8 +209,12 @@ st_EndPerfMonitor(struct gl_context *ctx, struct 
gl_perf_monitor_object *m)
 /* Stop the query for each active counter. */
 for (i = 0; i < stm->num_active_counters; ++i) {
struct pipe_query *query = stm->active_counters[i].query;
-  pipe->end_query(pipe, query);
+  if (query)
+ pipe->end_query(pipe, query);
 }
+
+   if (stm->batch_query)
+  pipe->end_query(pipe, stm->batch_query);
  }

  static void
@@ -199,11 +248,16 @@ st_IsPerfMonitorResultAvailable(struct gl_context *ctx,
 for (i = 0; i < stm->num_active_counters; ++i) {
struct

Re: [Mesa-dev] [PATCH v3 1/9] gallium: remove pipe_driver_query_group_info field type

2015-11-20 Thread Samuel Pitoiset

Reviewed-by: Samuel Pitoiset 


On 11/18/2015 12:49 PM, Nicolai Hähnle wrote:

This was only used to implement an unnecessarily restrictive interpretation
of the spec of AMD_performance_monitor. The spec says

   A performance monitor consists of a number of hardware and software
   counters that can be sampled by the GPU and reported back to the
   application.

I guess one could take this as a requirement that counters _must_ be sampled
by the GPU, but then why are they called _software_ counters? Besides,
there's not much reason _not_ to expose all counters that are available,
and this simplifies the code.

v3: add a missing change in the nouveau driver (thanks Samuel Pitoiset)
---
  src/gallium/drivers/nouveau/nvc0/nvc0_query.c |  4 
  src/gallium/include/pipe/p_defines.h  |  7 ---
  src/mesa/state_tracker/st_cb_perfmon.c| 30 ---
  3 files changed, 41 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c 
b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
index edde57e..1f1270e 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
@@ -200,7 +200,6 @@ nvc0_screen_get_driver_query_group_info(struct pipe_screen 
*pscreen,
 if (id == NVC0_HW_SM_QUERY_GROUP) {
if (screen->compute) {
   info->name = "MP counters";
- info->type = PIPE_DRIVER_QUERY_GROUP_TYPE_GPU;

   /* Because we can't expose the number of hardware counters needed for
* each different query, we don't want to allow more than one active
@@ -224,7 +223,6 @@ nvc0_screen_get_driver_query_group_info(struct pipe_screen 
*pscreen,
if (screen->compute) {
   if (screen->base.class_3d < NVE4_3D_CLASS) {
  info->name = "Performance metrics";
-info->type = PIPE_DRIVER_QUERY_GROUP_TYPE_GPU;
  info->max_active_queries = 1;
  info->num_queries = NVC0_HW_METRIC_QUERY_COUNT;
  return 1;
@@ -234,7 +232,6 @@ nvc0_screen_get_driver_query_group_info(struct pipe_screen 
*pscreen,
  #ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS
 else if (id == NVC0_SW_QUERY_DRV_STAT_GROUP) {
info->name = "Driver statistics";
-  info->type = PIPE_DRIVER_QUERY_GROUP_TYPE_CPU;
info->max_active_queries = NVC0_SW_QUERY_DRV_STAT_COUNT;
info->num_queries = NVC0_SW_QUERY_DRV_STAT_COUNT;
return 1;
@@ -245,7 +242,6 @@ nvc0_screen_get_driver_query_group_info(struct pipe_screen 
*pscreen,
 info->name = "this_is_not_the_query_group_you_are_looking_for";
 info->max_active_queries = 0;
 info->num_queries = 0;
-   info->type = 0;
 return 0;
  }

diff --git a/src/gallium/include/pipe/p_defines.h 
b/src/gallium/include/pipe/p_defines.h
index 7240154..7f241c8 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -829,12 +829,6 @@ enum pipe_driver_query_type
 PIPE_DRIVER_QUERY_TYPE_HZ   = 6,
  };

-enum pipe_driver_query_group_type
-{
-   PIPE_DRIVER_QUERY_GROUP_TYPE_CPU = 0,
-   PIPE_DRIVER_QUERY_GROUP_TYPE_GPU = 1,
-};
-
  /* Whether an average value per frame or a cumulative value should be
   * displayed.
   */
@@ -864,7 +858,6 @@ struct pipe_driver_query_info
  struct pipe_driver_query_group_info
  {
 const char *name;
-   enum pipe_driver_query_group_type type;
 unsigned max_active_queries;
 unsigned num_queries;
  };
diff --git a/src/mesa/state_tracker/st_cb_perfmon.c 
b/src/mesa/state_tracker/st_cb_perfmon.c
index 1bb5be3..4ec6d86 100644
--- a/src/mesa/state_tracker/st_cb_perfmon.c
+++ b/src/mesa/state_tracker/st_cb_perfmon.c
@@ -65,27 +65,6 @@ find_query_type(struct pipe_screen *screen, const char *name)
 return type;
  }

-/**
- * Return TRUE if the underlying driver expose GPU counters.
- */
-static bool
-has_gpu_counters(struct pipe_screen *screen)
-{
-   int num_groups, gid;
-
-   num_groups = screen->get_driver_query_group_info(screen, 0, NULL);
-   for (gid = 0; gid < num_groups; gid++) {
-  struct pipe_driver_query_group_info group_info;
-
-  if (!screen->get_driver_query_group_info(screen, gid, &group_info))
- continue;
-
-  if (group_info.type == PIPE_DRIVER_QUERY_GROUP_TYPE_GPU)
- return true;
-   }
-   return false;
-}
-
  static bool
  init_perf_monitor(struct gl_context *ctx, struct gl_perf_monitor_object *m)
  {
@@ -313,12 +292,6 @@ st_init_perfmon(struct st_context *st)
 if (!screen->get_driver_query_info || !screen->get_driver_query_group_info)
return false;

-   if (!has_gpu_counters(screen)) {
-  /* According to the spec, GL_AMD_performance_monitor must only
-   * expose GPU counters. */
-  return false;
-   }
-
 /* Get the number of available queries. */
 num_counters = screen->get_driver_query_info(screen, 0, NULL);
 if (!num_counters)
@@ -339,9 +312,6 @@ st_init_perfmon(struct st_context *st)
if (!screen->get_driver_query_group_info(screen, g

Re: [Mesa-dev] [PATCH v3 0/9] gallium: batch query objects and related cleanups

2015-11-20 Thread Samuel Pitoiset

Hi Nicolai,

The whole series is:

Reviewed-by: Samuel Pitoiset 
Tested-by: Samuel Pitoiset 

Thanks!

On 11/18/2015 12:49 PM, Nicolai Hähnle wrote:

Hi everybody,

this is the next iteration of the series, rebased on current master and
with the adjustment to nv50 queries. Please take a look! Samuel, let me know
when you've tested this!

Cheers,
Nicolai
---
  gallium/auxiliary/hud/hud_context.c   |   24 +-
  gallium/auxiliary/hud/hud_driver_query.c  |  271 
+-
  gallium/auxiliary/hud/hud_private.h   |   13 +
  gallium/drivers/nouveau/nv50/nv50_query.c |1
  gallium/drivers/nouveau/nvc0/nvc0_query.c |5
  gallium/include/pipe/p_context.h  |   19 ++
  gallium/include/pipe/p_defines.h  |   36 ++-
  mesa/state_tracker/st_cb_perfmon.c|  258 
  mesa/state_tracker/st_cb_perfmon.h|   32 ++-
  mesa/state_tracker/st_context.h   |3
  10 files changed, 486 insertions(+), 176 deletions(-)

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



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


Re: [Mesa-dev] [Mesa-stable] [PATCH] i965: Fix JIP to properly skip over unrelated control flow.

2015-11-20 Thread Francisco Jerez
Kenneth Graunke  writes:

> On Thursday, November 19, 2015 02:05:44 PM Kenneth Graunke wrote:
>> We've apparently always been botching JIP for sequences such as:
>> 
>>do
>>cmp.f0.0 ...
>>(+f0.0) break
>>...
>>if
>>   ...
>>else
>>   ...
>>endif
>>...
>>while
>> 
>> Normally, UIP is supposed to point to the final destination of the jump,
>> while in nested control flow, JIP is supposed to point to the end of the
>> current nesting level.  It essentially bounces out of the current nested
>> control flow, to an instruction that has a JIP which bounces out another
>> level, and so on.
>> 
>> In the above example, when setting JIP for the BREAK, we call
>> brw_find_next_block_end(), which begins a search after the BREAK for the
>> next ENDIF, ELSE, WHILE, or HALT.  It ignores the IF and finds the ELSE,
>> setting JIP there.
>> 
>> This makes no sense at all.  The break is supposed to skip over the
>> whole if/else/endif block entirely.  They have a sibling relationship,
>> not a nesting relationship.
>> 
>> This patch fixes brw_find_next_block_end() to track depth as it does
>> its search, and ignore anything not at depth 0.  So when it sees the
>> IF, it ignores everything until after the ENDIF.  That way, it finds
>> the end of the right block.
>> 
>> Caught while debugging a tessellation shader - no apparent effect on
>> Piglit.  I did look for actual applications that were affected, and
>> found that GLBenchmark Manhattan had a BREAK with a bogus JIP.
>> 
>> Cc: mesa-sta...@lists.freedesktop.org
>> Signed-off-by: Kenneth Graunke 
>
> I tried pretty hard to produce a Piglit test that showed an actual
> problem from doing this wrong - and I wasn't able to.
>
> It seems it just steps through some extra instructions which do
> nothing, and is pretty harmless.
>
From my understanding of how control flow is implemented, jumping to the
ENDIF instruction of an inactive IF-ENDIF construct (or similarly to the
WHILE instruction of an inactive loop) is fully equivalent to jumping to
the same point of an active (i.e. properly nested) but non-diverging
IF-ENDIF construct, and will behave the same: It will have no effect on
the current per-channel enables (because the IP of the ENDIF instruction
won't match the UIP value present at the top of the stack), and for that
reason will go on and jump to the instruction pointed to by the JIP
value of the ENDIF, which will be another ENDIF/WHILE/HALT instruction
closer to the right ENDIF/WHILE instruction that closes the current
block.

> So I don't think this should actually go to stable after all.
>
Yeah, seems pretty harmless -- If it weren't harmeless you'd also need
to apply a similar fix to WHILE loops, but I don't think you do.

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


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


Re: [Mesa-dev] [PATCH v2 10/42] i965: Calculate appropriate L3 partition weights for the current pipeline state.

2015-11-20 Thread Francisco Jerez
Kristian Høgsberg  writes:

> On Thu, Nov 19, 2015 at 4:24 AM, Francisco Jerez  
> wrote:
>> Kristian Høgsberg  writes:
>>
>>> On Tue, Nov 17, 2015 at 9:54 PM, Jordan Justen
>>>  wrote:
 From: Francisco Jerez 

 This calculates a rather conservative partitioning of the L3 cache
 based on the shaders currently bound to the pipeline and whether they
 use SLM, atomics, images or scratch space.  The result is intended to
 be fine-tuned later on based on other pipeline state.
 ---
  src/mesa/drivers/dri/i965/brw_compiler.h  |  1 +
  src/mesa/drivers/dri/i965/gen7_l3_state.c | 53 
 +++
  2 files changed, 54 insertions(+)

 diff --git a/src/mesa/drivers/dri/i965/brw_compiler.h 
 b/src/mesa/drivers/dri/i965/brw_compiler.h
 index 8f147d3..ef8bddb 100644
 --- a/src/mesa/drivers/dri/i965/brw_compiler.h
 +++ b/src/mesa/drivers/dri/i965/brw_compiler.h
 @@ -300,6 +300,7 @@ struct brw_stage_prog_data {

 unsigned curb_read_length;
 unsigned total_scratch;
 +   unsigned total_shared;

 /**
  * Register where the thread expects to find input data from the URB
 diff --git a/src/mesa/drivers/dri/i965/gen7_l3_state.c 
 b/src/mesa/drivers/dri/i965/gen7_l3_state.c
 index 4d0cfcd..1a88261 100644
 --- a/src/mesa/drivers/dri/i965/gen7_l3_state.c
 +++ b/src/mesa/drivers/dri/i965/gen7_l3_state.c
 @@ -258,6 +258,59 @@ get_l3_config(const struct brw_device_info *devinfo, 
 struct brw_l3_weights w0)
  }

  /**
 + * Return a reasonable default L3 configuration for the specified device 
 based
 + * on whether SLM and DC are required.  In the non-SLM non-DC case the 
 result
 + * is intended to approximately resemble the hardware defaults.
 + */
 +static struct brw_l3_weights
 +get_default_l3_weights(const struct brw_device_info *devinfo,
 +   bool needs_dc, bool needs_slm)
 +{
 +   struct brw_l3_weights w = {{ 0 }};
 +
 +   w.w[L3P_SLM] = needs_slm;
 +   w.w[L3P_URB] = 1.0;
 +
 +   if (devinfo->gen >= 8) {
 +  w.w[L3P_ALL] = 1.0;
 +   } else {
 +  w.w[L3P_DC] = needs_dc ? 0.1 : 0;
 +  w.w[L3P_RO] = devinfo->is_baytrail ? 0.5 : 1.0;
 +   }
 +
 +   return norm_l3_weights(w);
 +}
 +
 +/**
 + * Calculate the desired L3 partitioning based on the current state of the
 + * pipeline.  For now this simply returns the conservative defaults 
 calculated
 + * by get_default_l3_weights(), but we could probably do better by 
 gathering
 + * more statistics from the pipeline state (e.g. guess of expected URB 
 usage
 + * and bound surfaces), or by using feed-back from performance counters.
 + */
 +static struct brw_l3_weights
 +get_pipeline_state_l3_weights(const struct brw_context *brw)
 +{
 +   const struct brw_stage_state *stage_states[] = {
 +  &brw->vs.base, &brw->gs.base, &brw->wm.base, &brw->cs.base
 +   };
 +   bool needs_dc = false, needs_slm = false;
>>>
>>> This doesn't seem optimal - we should evaluate the 3D pipe and the
>>> compute pipe separately depending on which  one is active. For
>>> example, if we have a current compute program that uses SLM, but are
>>> using the 3D pipeline, we'll get a partition that includes SLM even
>>> for the 3D pipe.
>>>
>> The intention of this patch is not to provide an optimal heuristic, but
>> to implement a simple heuristic that calculates conservative defaults in
>> order to guarantee functional correctness.  It would be possible to base
>> the result on the currently active pipeline with minimal changes to this
>> function (and making sure that the L3 config atom is invalidated while
>> switching pipelines), but I don't think we want to switch back and forth
>> between SLM and non-SLM configurations if the application interleaves
>> draw and compute operations, because the L3 partitioning is global
>> rather than per-pipeline and transitions are expensive -- Switching
>> between L3 configuration requires a full pipeline stall and flushing and
>> invalidation of all L3-backed caches, doing what you suggest would
>> likely lead to cache-thrashing and might prevent pipelining of compute
>> and render workloads [At least on BDW+ -- On Gen7 it might be impossible
>> to achieve pipelining of render and compute workloads due to hardware
>> issues].  If the result of the heuristic is based on the currently
>> active pipeline some sort of hysteresis will likely be desirable, which
>> in this patch I get for free by basing the calculation on the context
>> state rather than on the currently active pipeline.  I agree with you
>> that we'll probably need a more sophisticated heuristic in the future,
>> but that falls outside the scope of this series -- If anything we need
>> to be able to run benchmarks exercising CS and SLM before

Re: [Mesa-dev] [Mesa-stable] [PATCH 2/2] radeonsi/compute: Use the compiler's COMPUTE_PGM_RSRC* register values

2015-11-20 Thread Emil Velikov
On 20 November 2015 at 02:26, Michel Dänzer  wrote:
> On 20.11.2015 05:53, Emil Velikov wrote:
>> On 19 November 2015 at 20:37, Tom Stellard  wrote:
>>> On Wed, Nov 18, 2015 at 05:43:31PM +, Emil Velikov wrote:
 Hi Tom,

 Please flip the order of the patches and drop the now patch 1/2 from
 the stable queue.

>>>
>>> I'm confused about why I need to flip the order of the patches.
>>>
>> As mentioned on IRC - patch 1 is not a bugfix and despite how trivial
>> I'd rather have only bugfixes in stable.
>> Is flipping things too much to ask ?
>
> It would make the current patch 2 a bit ugly, because it would use the
> ls_rsrc field even for non-LS shaders.
>
There are plenty of ugly corners in mesa, and we have to be loosing
our marbles if patches "beautifying" those are considered bugfixes.

That said, I had enough on this topic (ie. do as you wish), but for
the future please only bugfixes to stable.

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


Re: [Mesa-dev] [PATCH 2/2] i965: Prevent implicit upcasts to brw_reg.

2015-11-20 Thread Francisco Jerez
Matt Turner  writes:

> Now that backend_reg inherits from brw_reg, we have to be careful to
> avoid the object slicing problem.
> ---
>  src/mesa/drivers/dri/i965/brw_fs.cpp   |  6 +++--
>  .../drivers/dri/i965/brw_fs_copy_propagation.cpp   |  4 +--
>  src/mesa/drivers/dri/i965/brw_fs_generator.cpp |  2 +-
>  src/mesa/drivers/dri/i965/brw_shader.h | 31 
> +-
>  src/mesa/drivers/dri/i965/brw_vec4.cpp | 15 ++-
>  .../drivers/dri/i965/brw_vec4_copy_propagation.cpp |  4 +--
>  src/mesa/drivers/dri/i965/brw_vec4_generator.cpp   | 10 +++
>  7 files changed, 53 insertions(+), 19 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
> b/src/mesa/drivers/dri/i965/brw_fs.cpp
> index e9c990d..a5f1d8f 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
> @@ -392,7 +392,8 @@ fs_reg::fs_reg(struct brw_reg reg) :
>  bool
>  fs_reg::equals(const fs_reg &r) const
>  {
> -   return (memcmp((brw_reg *)this, (brw_reg *)&r, sizeof(brw_reg)) == 0 &&
> +   return (memcmp(&this->as_brw_reg(), &r.as_brw_reg(),
> +  sizeof(struct brw_reg)) == 0 &&
> reg_offset == r.reg_offset &&
> subreg_offset == r.subreg_offset &&
> !reladdr && !r.reladdr &&
> @@ -2037,7 +2038,8 @@ fs_visitor::opt_algebraic()
>  if (inst->dst.type != inst->src[0].type)
> assert(!"unimplemented: saturate mixed types");
>  
> -if (brw_saturate_immediate(inst->dst.type, &inst->src[0])) {
> +if (brw_saturate_immediate(inst->dst.type,
> +   &inst->src[0].as_brw_reg())) {
> inst->saturate = false;
> progress = true;
>  }
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp 
> b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
> index 426ea57..b72fe33 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
> @@ -478,14 +478,14 @@ fs_visitor::try_constant_propagate(fs_inst *inst, 
> acp_entry *entry)
>  
>if (inst->src[i].abs) {
>   if ((devinfo->gen >= 8 && is_logic_op(inst->opcode)) ||
> - !brw_abs_immediate(val.type, &val)) {
> + !brw_abs_immediate(val.type, &val.as_brw_reg())) {
>  continue;
>   }
>}
>  
>if (inst->src[i].negate) {
>   if ((devinfo->gen >= 8 && is_logic_op(inst->opcode)) ||
> - !brw_negate_immediate(val.type, &val)) {
> + !brw_negate_immediate(val.type, &val.as_brw_reg())) {
>  continue;
>   }
>}
> diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp 
> b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
> index 77969c4..ea37ea4 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp
> @@ -92,7 +92,7 @@ brw_reg_from_fs_reg(fs_inst *inst, fs_reg *reg, unsigned 
> gen)
> case ARF:
> case FIXED_GRF:
> case IMM:
> -  brw_reg = *static_cast(reg);
> +  brw_reg = reg->as_brw_reg();
>break;
> case BAD_FILE:
>/* Probably unused. */
> diff --git a/src/mesa/drivers/dri/i965/brw_shader.h 
> b/src/mesa/drivers/dri/i965/brw_shader.h
> index a4139cf..52b9aff 100644
> --- a/src/mesa/drivers/dri/i965/brw_shader.h
> +++ b/src/mesa/drivers/dri/i965/brw_shader.h
> @@ -39,11 +39,21 @@
>  #define MAX_VGRF_SIZE 16
>  
>  #ifdef __cplusplus
> -struct backend_reg : public brw_reg
> +struct backend_reg : private brw_reg
>  {
> backend_reg() {}
> backend_reg(struct brw_reg reg) : brw_reg(reg) {}
>  
> +   const brw_reg &as_brw_reg() const
> +   {

It would be nice to have assertions here to make sure that the
additional state of the backend reg is the identity, so we know we
aren't losing information by slicing.  If you don't feel like overriding
this function in each one of the backend_reg subclasses (which would be
necessary to make sure that e.g. fs_reg::subreg_offset and ::reladdr are
zero and ::stride is one), I guess that for the moment we could just
assert that reg_offset is zero and that file is one of the actual
hardware values (ARF/FIXED_GRF/MRF/IMM).

Note that that will mean that you are no longer able to use these
casting functions to implement some constructors and the equals()
methods of the backend_reg subclasses, so you may have to factor out the
common logic of equals() (i.e. the memcmp call and reg_offset
comparison) into a backend_reg::equals() method (which seems like a good
idea on its own).  As for the constructors, is there any reason you
cannot delegate to the implicitly-declared copy constructor of
backend_reg?  (That way you'd also avoid initializing reg_offset
manually)

> +  return static_cast(*this);
> +   }
> +
> +   brw_reg &as_brw_reg()
> +   {
> +  return static_cast(*this);
> +   }
> +

Re: [Mesa-dev] [PATCH 1/2] i965/vec4: Initialize nir_inputs with src_reg().

2015-11-20 Thread Francisco Jerez
Matt Turner  writes:

> nir_locals, nir_ssa_values, and nir_system_values are all dst_reg (not
> that that makes a whole lot of sense to me), and only nir_inputs is a
> src_reg.

Reviewed-by: Francisco Jerez 

> ---
>  src/mesa/drivers/dri/i965/brw_vec4_nir.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp 
> b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
> index 3d186b4..3b7c28d 100644
> --- a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
> @@ -122,7 +122,7 @@ vec4_visitor::nir_setup_inputs()
>  {
> nir_inputs = ralloc_array(mem_ctx, src_reg, nir->num_inputs);
> for (unsigned i = 0; i < nir->num_inputs; i++) {
> -  nir_inputs[i] = dst_reg();
> +  nir_inputs[i] = src_reg();
> }
>  
> nir_foreach_variable(var, &nir->inputs) {
> -- 
> 2.4.9


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


Re: [Mesa-dev] [PATCH 1/7] i965/fs_surface_builder: Explicitly handle FORMAT_NONE in num_image_coordinates

2015-11-20 Thread Francisco Jerez
Chad Versace  writes:

> On Wed 04 Nov 2015, Jason Ekstrand wrote:
>> Previously, we were relying on has_matching_typed_format returning true for
>> MESA_FORMAT_NONE which, in turn, relied on _mesa_get_format_bytes returning
>> 1 for MESA_FORMAT_NONE.  All of this is extremely non-obvious.  Instead,
>> this commit makes us handle it explicitly.
>> ---
>>  src/mesa/drivers/dri/i965/brw_fs_surface_builder.cpp | 1 +
>>  1 file changed, 1 insertion(+)
>> 
>> diff --git a/src/mesa/drivers/dri/i965/brw_fs_surface_builder.cpp 
>> b/src/mesa/drivers/dri/i965/brw_fs_surface_builder.cpp
>> index 534d849..31ecb5b 100644
>> --- a/src/mesa/drivers/dri/i965/brw_fs_surface_builder.cpp
>> +++ b/src/mesa/drivers/dri/i965/brw_fs_surface_builder.cpp
>> @@ -409,6 +409,7 @@ namespace {
>>* reads want the array index to be at the Z component.
>>*/
>>   const bool array_index_at_z =
>> +format != MESA_FORMAT_NONE &&
>>  !image_format_info::has_matching_typed_format(
>> bld.shader->devinfo, format);
>>   const unsigned zero_dims =
>
>
> Knowing nothing about the implicit assumptions you discovered that
> relied on _mesa_get_format_bytes(MESA_FORMAT_NONE) => 1, the patch is
> still looks like an improvement to me.
>
It didn't.  It relied on _mesa_get_format_bytes(MESA_FORMAT_NONE) not
being greater than 4, which seems sensible anyway.

> Acked-by: Chad Versace 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


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


Re: [Mesa-dev] [PATCH 3/7] i965: Add an image format metadata array

2015-11-20 Thread Francisco Jerez
Jason Ekstrand  writes:

> This little data structure and associated array contains all of the image
> format metadata needed for doing image_load_store work-arounds.  This way
> we can pull metadata from within the i965 driver without having to go out
> to core mesa for it.  It is a bit of duplication with what we have in core
> mesa but it's limited enough that it's easily verified and not a big deal.
> ---
>  src/mesa/drivers/dri/i965/brw_image_load_store.c | 45 
> 
>  src/mesa/drivers/dri/i965/brw_image_load_store.h | 20 +++
>  2 files changed, 65 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_image_load_store.c 
> b/src/mesa/drivers/dri/i965/brw_image_load_store.c
> index 4876041..b78d6b2 100644
> --- a/src/mesa/drivers/dri/i965/brw_image_load_store.c
> +++ b/src/mesa/drivers/dri/i965/brw_image_load_store.c
> @@ -26,6 +26,51 @@
>  #include "brw_defines.h"
>  #include "brw_image_load_store.h"
>  
> +#define IF(r, g, b, a, dt, f) \
> +   [BRW_SURFACEFORMAT_##f] = { true, r, g, b, a, BRW_IMAGE_FORMAT_##dt },
> +const struct brw_image_format_info brw_image_format_info[] = {
> +   IF( 8,  0,  0,  0, UNORM, R8_UNORM)
> +   IF( 8,  0,  0,  0, SNORM, R8_SNORM)
> +   IF( 8,  0,  0,  0,  UINT, R8_UINT)
> +   IF( 8,  0,  0,  0,  SINT, R8_SINT)
> +   IF( 8,  8,  0,  0, UNORM, R8G8_UNORM)
> +   IF( 8,  8,  0,  0, SNORM, R8G8_SNORM)
> +   IF( 8,  8,  0,  0,  UINT, R8G8_UINT)
> +   IF( 8,  8,  0,  0,  SINT, R8G8_SINT)
> +   IF( 8,  8,  8,  8, UNORM, R8G8B8A8_UNORM)
> +   IF( 8,  8,  8,  8, SNORM, R8G8B8A8_SNORM)
> +   IF( 8,  8,  8,  8,  UINT, R8G8B8A8_UINT)
> +   IF( 8,  8,  8,  8,  SINT, R8G8B8A8_SINT)
> +   IF(11, 11, 10,  0, FLOAT, R11G11B10_FLOAT)
> +   IF(10, 10, 10,  2, UNORM, R10G10B10A2_UNORM)
> +   IF(10, 10, 10,  2,  UINT, R10G10B10A2_UINT)
> +   IF(16,  0,  0,  0, UNORM, R16_UNORM)
> +   IF(16,  0,  0,  0, SNORM, R16_SNORM)
> +   IF(16,  0,  0,  0, FLOAT, R16_FLOAT)
> +   IF(16,  0,  0,  0,  UINT, R16_UINT)
> +   IF(16,  0,  0,  0,  SINT, R16_SINT)
> +   IF(16, 16,  0,  0, UNORM, R16G16_UNORM)
> +   IF(16, 16,  0,  0, SNORM, R16G16_SNORM)
> +   IF(16, 16,  0,  0, FLOAT, R16G16_FLOAT)
> +   IF(16, 16,  0,  0,  UINT, R16G16_UINT)
> +   IF(16, 16,  0,  0,  SINT, R16G16_SINT)
> +   IF(16, 16, 16, 16, UNORM, R16G16B16A16_UNORM)
> +   IF(16, 16, 16, 16, SNORM, R16G16B16A16_SNORM)
> +   IF(16, 16, 16, 16, FLOAT, R16G16B16A16_FLOAT)
> +   IF(16, 16, 16, 16,  UINT, R16G16B16A16_UINT)
> +   IF(16, 16, 16, 16,  SINT, R16G16B16A16_SINT)
> +   IF(32,  0,  0,  0, FLOAT, R32_FLOAT)
> +   IF(32,  0,  0,  0,  UINT, R32_UINT)
> +   IF(32,  0,  0,  0,  SINT, R32_SINT)
> +   IF(32, 32,  0,  0, FLOAT, R32G32_FLOAT)
> +   IF(32, 32,  0,  0,  UINT, R32G32_UINT)
> +   IF(32, 32,  0,  0,  SINT, R32G32_SINT)
> +   IF(32, 32, 32, 32, FLOAT, R32G32B32A32_FLOAT)
> +   IF(32, 32, 32, 32,  UINT, R32G32B32A32_UINT)
> +   IF(32, 32, 32, 32,  SINT, R32G32B32A32_SINT)
> +};
> +#undef IF
> +

I'm not particularly excited about introducing yet another format
metadata table, used for image_load_store only, even though there's
nothing image_load_store-specific about this abstraction other than the
rather limited set of formats it supports.

What's your long-term plan for this?  Do you have any uses in mind other
than the surface built-in builder, or is it fully ad-hoc infrastructure?

>  uint32_t
>  brw_lower_image_format(const struct brw_device_info *devinfo,
> uint32_t format)
> diff --git a/src/mesa/drivers/dri/i965/brw_image_load_store.h 
> b/src/mesa/drivers/dri/i965/brw_image_load_store.h
> index 883eec4..2ab85cc 100644
> --- a/src/mesa/drivers/dri/i965/brw_image_load_store.h
> +++ b/src/mesa/drivers/dri/i965/brw_image_load_store.h
> @@ -23,6 +23,7 @@
>  
>  #pragma once
>  
> +#include 
>  #include 
>  
>  #include "brw_device_info.h"
> @@ -31,6 +32,25 @@
>  extern "C" {
>  #endif
>  
> +enum brw_image_format_data_type {
> +   BRW_IMAGE_FORMAT_UNORM,
> +   BRW_IMAGE_FORMAT_SNORM,
> +   BRW_IMAGE_FORMAT_UINT,
> +   BRW_IMAGE_FORMAT_SINT,
> +   BRW_IMAGE_FORMAT_FLOAT,
> +};
> +
> +struct brw_image_format_info {
> +   bool is_image_format;
> +   uint8_t red_bits;
> +   uint8_t green_bits;
> +   uint8_t blue_bits;
> +   uint8_t alpha_bits;
> +   enum brw_image_format_data_type data_type;
> +};
> +
> +extern const struct brw_image_format_info brw_image_format_info[];
> +
>  uint32_t brw_lower_image_format(const struct brw_device_info *devinfo,
>  uint32_t format);
>  #ifdef __cplusplus
> -- 
> 2.5.0.400.gff86faf
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


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


Re: [Mesa-dev] [PATCH v2 1/2] mesa: Add KBL PCI IDs and platform information.

2015-11-20 Thread Emil Velikov
On 18 November 2015 at 21:59, Ilia Mirkin  wrote:
> On Wed, Nov 18, 2015 at 4:54 PM, Sarah Sharp
>  wrote:
>>> There's not really a consensus I guess, but most people do leave the version
>>> information in the final commit message.
>>
>> I personally feel like that's leaving boredom doodles on a final
>> architectural drawing. If people want to know the back-and-forth
>> history, the mailing list archive will always be there. So, no, I don't
>> really want to leave version info in the commit message.
>
> FWIW I wholeheartedly agree with this line of reasoning. I never put
> the version info into my commits either, and find it
> confusing/misleading when others do. I want to know the final state of
> things when looking at the commit 1 year from now, not the 20-step
> process and all the wrong turns to get there.
>

The other side of the coin:

 - One might not have access to the discussion - ISP/ML archive is
down. discussion was offline or no longer available (10+ years ago),
etc.
 - Revision history is immediately available, rather than going back
and forth between git/browser/email client.
 - We can easily ignore the revision history hunk
 - Hitting more than v3 is a clear sign something fishy (most likely
lack of experience of said author), which in itself is useful.

Obviously I'm not saying that we must use approach A or B. Whatever
floats your boat really :-)

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


Re: [Mesa-dev] [PATCH 0/8] Implement EXT_shader_samples_identical

2015-11-20 Thread Emil Velikov
On 20 November 2015 at 04:08, Ian Romanick  wrote:
> On 11/19/2015 06:47 AM, Emil Velikov wrote:
>> Hi Ian,
>>
>> Attempting to high-jack the thread :-P
>>
>> On 18 November 2015 at 23:46, Ian Romanick  wrote:
>>
>>> I really wanted to get this in the next Mesa release.  For some reason,
>>> I thought the branch point was after Thanksgiving (which is next
>>> Thursday).  Ken reminded me yesterday that the branch point is actually
>>> this Friday. :( As a result, I'm sending it out today to get review as
>>> soon as possible.
>>>
>> Any suggestions on how we make dates more prominent/obvious ? I was
>> going to say "we even have it in #irc-devel channel topic" but you
>> don't seem to be around these days.
>
> VPN problems have made it basically impossible for me to be on IRC.
> It's a long, annoying story.  It's one of those "too busy to fix it"
> things too.  Ugh.
>
Ack. Let's hope you have a spare moment one of these days to fix it.

>> Alternatively you can set a filter in your email client - the subject
>> is always "Mesa #VERSION release plan"
>
> All my mesa-dev email goes in one folder, and it's really easy for
> single messages to get lost between the 40 patch series.  I like Ilia's
> suggestion of using mesa-announce.  That just dumps in my main inbox,
> and I'm less likely to miss it there.
>
Sure thing, we can mesa-announce for announcements (/me feels like cpt Obvious).

> One other thing... what time are you planning to make the branch
> tomorrow? :)
>
As usual - late night (after you guys have finished) or early Sat morning.

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


[Mesa-dev] [PATCH] glsl: split ssbo array copies into element copies

2015-11-20 Thread Iago Toral Quiroga
Improves register pressure, since otherwise we end up emitting
loads for all the elements in the RHS and them emitting
stores for all elements in the LHS.

Fixes the following piglit test:
tests/spec/arb_shader_storage_buffer_object/execution/large-field-copy.shader_test
---

Jordan, this fixes the link failure for the the test you provided. Needs more
testing and I have to check if I need to do something for structs that contain
arrays too, etc I'll do that on Monday unless someone else comes with a better
idea to fix this.

 src/glsl/lower_ubo_reference.cpp | 61 
 1 file changed, 61 insertions(+)

diff --git a/src/glsl/lower_ubo_reference.cpp b/src/glsl/lower_ubo_reference.cpp
index b74aa3d..7d48960 100644
--- a/src/glsl/lower_ubo_reference.cpp
+++ b/src/glsl/lower_ubo_reference.cpp
@@ -154,6 +154,7 @@ public:
ir_call *ssbo_load(const struct glsl_type *type,
   ir_rvalue *offset);
 
+   bool check_for_ssbo_array_copy(ir_assignment *ir);
void check_for_ssbo_store(ir_assignment *ir);
void write_to_memory(ir_dereference *deref,
 ir_variable *var,
@@ -1133,9 +1134,69 @@ 
lower_ubo_reference_visitor::check_for_ssbo_store(ir_assignment *ir)
 }
 
 
+bool
+lower_ubo_reference_visitor::check_for_ssbo_array_copy(ir_assignment *ir)
+{
+   if (!ir || !ir->lhs || !ir->rhs)
+  return false;
+
+   ir_dereference *rhs_deref = ir->rhs->as_dereference();
+   if (!rhs_deref)
+  return false;
+
+   ir_dereference *lhs_deref = ir->lhs->as_dereference();
+   if (!lhs_deref)
+  return false;
+
+   /* LHS and RHS must be SSBO variables */
+   ir_variable *lhs_var = ir->lhs->variable_referenced();
+   if (!lhs_var || !lhs_var->is_in_shader_storage_block())
+  return false;
+
+   ir_variable *rhs_var = ir->rhs->variable_referenced();
+   if (!rhs_var || !rhs_var->is_in_shader_storage_block())
+  return false;
+
+   /* LHS and RHS must be variable dereferences.
+* FIXME: arrays of arrays?
+*/
+   if (!ir->lhs->as_dereference_variable() ||
+   !ir->rhs->as_dereference_variable())
+  return false;
+
+   /* LHS and RHS must be arrays */
+   if (!rhs_var->type->is_array() || !lhs_var->type->is_array())
+  return false;
+
+   assert(lhs_deref->type->length == rhs_deref->type->length);
+
+   for (unsigned i = 0; i < lhs_deref->type->length; i++) {
+  ir_dereference *lhs_i =
+ new(mem_ctx) ir_dereference_array(lhs_deref->clone(mem_ctx, NULL),
+   new(mem_ctx) ir_constant(i));
+
+  ir_dereference *rhs_i =
+ new(mem_ctx) ir_dereference_array(rhs_deref->clone(mem_ctx, NULL),
+   new(mem_ctx) ir_constant(i));
+  ir->insert_after(assign(lhs_i, rhs_i));
+   }
+
+   ir->remove();
+   return true;
+}
+
 ir_visitor_status
 lower_ubo_reference_visitor::visit_enter(ir_assignment *ir)
 {
+   /* Array copies could involve large amounts of SSBO load/store
+* operations. To improve register pressure we want to special-case
+* this and split the array copy into many individual element copies.
+* This way we avoid emitting all the loads for the RHS first and
+* all the writes for the LHS second.
+*/
+   if (check_for_ssbo_array_copy(ir))
+  return visit_continue_with_parent;
+
check_ssbo_unsized_array_length_assignment(ir);
check_for_ssbo_store(ir);
return rvalue_visit(ir);
-- 
1.9.1

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


[Mesa-dev] [PATCH 2/2] radeon/vce: disable two pipe mode for stoney

2015-11-20 Thread Leo Liu
Only one encoding pipe available for Stoney

Signed-off-by: Leo Liu 
Reviewed-by: Alex Deucher 
---
 src/gallium/drivers/radeon/radeon_vce.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/radeon/radeon_vce.c 
b/src/gallium/drivers/radeon/radeon_vce.c
index b2b084e..8a60441 100644
--- a/src/gallium/drivers/radeon/radeon_vce.c
+++ b/src/gallium/drivers/radeon/radeon_vce.c
@@ -406,7 +406,8 @@ struct pipe_video_codec *rvce_create_encoder(struct 
pipe_context *context,
enc->use_vm = true;
if ((rscreen->info.drm_major > 2) || (rscreen->info.drm_minor >= 42))
enc->use_vui = true;
-   if (rscreen->info.family >= CHIP_TONGA)
+   if (rscreen->info.family >= CHIP_TONGA &&
+ rscreen->info.family != CHIP_STONEY)
enc->dual_pipe = true;
/* TODO enable B frame with dual instance */
if ((rscreen->info.family >= CHIP_TONGA) &&
-- 
2.5.0

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


Re: [Mesa-dev] [Mesa-stable] [PATCH] i965: Fix JIP to properly skip over unrelated control flow.

2015-11-20 Thread Kenneth Graunke
On Friday, November 20, 2015 02:38:10 PM Francisco Jerez wrote:
> Kenneth Graunke  writes:
> 
> > On Thursday, November 19, 2015 02:05:44 PM Kenneth Graunke wrote:
> >> We've apparently always been botching JIP for sequences such as:
> >> 
> >>do
> >>cmp.f0.0 ...
> >>(+f0.0) break
> >>...
> >>if
> >>   ...
> >>else
> >>   ...
> >>endif
> >>...
> >>while
> >> 
> >> Normally, UIP is supposed to point to the final destination of the jump,
> >> while in nested control flow, JIP is supposed to point to the end of the
> >> current nesting level.  It essentially bounces out of the current nested
> >> control flow, to an instruction that has a JIP which bounces out another
> >> level, and so on.
> >> 
> >> In the above example, when setting JIP for the BREAK, we call
> >> brw_find_next_block_end(), which begins a search after the BREAK for the
> >> next ENDIF, ELSE, WHILE, or HALT.  It ignores the IF and finds the ELSE,
> >> setting JIP there.
> >> 
> >> This makes no sense at all.  The break is supposed to skip over the
> >> whole if/else/endif block entirely.  They have a sibling relationship,
> >> not a nesting relationship.
> >> 
> >> This patch fixes brw_find_next_block_end() to track depth as it does
> >> its search, and ignore anything not at depth 0.  So when it sees the
> >> IF, it ignores everything until after the ENDIF.  That way, it finds
> >> the end of the right block.
> >> 
> >> Caught while debugging a tessellation shader - no apparent effect on
> >> Piglit.  I did look for actual applications that were affected, and
> >> found that GLBenchmark Manhattan had a BREAK with a bogus JIP.
> >> 
> >> Cc: mesa-sta...@lists.freedesktop.org
> >> Signed-off-by: Kenneth Graunke 
> >
> > I tried pretty hard to produce a Piglit test that showed an actual
> > problem from doing this wrong - and I wasn't able to.
> >
> > It seems it just steps through some extra instructions which do
> > nothing, and is pretty harmless.
> >
> From my understanding of how control flow is implemented, jumping to the
> ENDIF instruction of an inactive IF-ENDIF construct (or similarly to the
> WHILE instruction of an inactive loop) is fully equivalent to jumping to
> the same point of an active (i.e. properly nested) but non-diverging
> IF-ENDIF construct, and will behave the same: It will have no effect on
> the current per-channel enables (because the IP of the ENDIF instruction
> won't match the UIP value present at the top of the stack), and for that
> reason will go on and jump to the instruction pointed to by the JIP
> value of the ENDIF, which will be another ENDIF/WHILE/HALT instruction
> closer to the right ENDIF/WHILE instruction that closes the current
> block.
> 
> > So I don't think this should actually go to stable after all.
> >
> Yeah, seems pretty harmless -- If it weren't harmeless you'd also need
> to apply a similar fix to WHILE loops, but I don't think you do.

Thanks, Curro!  I appreciate you confirming the theory :)

I haven't pushed the patch yet, so would you like to add a Reviewed-by?

What WHILE fix are you thinking of?  We may as well get it right, even
if it is harmless.  At a cursory glance, I didn't see anything wrong,
as it uses the loop stack.  But I might've missed something...


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


[Mesa-dev] [PATCH 1/2] radeon/vce: add new firmware interface support

2015-11-20 Thread Leo Liu
Add new interface to create and encode
 
Signed-off-by: Leo Liu 
Reviewed-by: Alex Deucher 
---
 src/gallium/drivers/radeon/Makefile.sources |   1 +
 src/gallium/drivers/radeon/radeon_vce.c |  21 ++-
 src/gallium/drivers/radeon/radeon_vce.h |   3 +
 src/gallium/drivers/radeon/radeon_vce_52.c  | 242 
 4 files changed, 262 insertions(+), 5 deletions(-)
 create mode 100644 src/gallium/drivers/radeon/radeon_vce_52.c

diff --git a/src/gallium/drivers/radeon/Makefile.sources 
b/src/gallium/drivers/radeon/Makefile.sources
index d840ff8..1dbad2f 100644
--- a/src/gallium/drivers/radeon/Makefile.sources
+++ b/src/gallium/drivers/radeon/Makefile.sources
@@ -14,6 +14,7 @@ C_SOURCES := \
radeon_uvd.h \
radeon_vce_40_2_2.c \
radeon_vce_50.c \
+   radeon_vce_52.c \
radeon_vce.c \
radeon_vce.h \
radeon_video.c \
diff --git a/src/gallium/drivers/radeon/radeon_vce.c 
b/src/gallium/drivers/radeon/radeon_vce.c
index 0dac6fb..b2b084e 100644
--- a/src/gallium/drivers/radeon/radeon_vce.c
+++ b/src/gallium/drivers/radeon/radeon_vce.c
@@ -49,6 +49,7 @@
 #define FW_50_1_2 ((50 << 24) | (1 << 16) | (2 << 8))
 #define FW_50_10_2 ((50 << 24) | (10 << 16) | (2 << 8))
 #define FW_50_17_3 ((50 << 24) | (17 << 16) | (3 << 8))
+#define FW_52_0_3 ((52 << 24) | (0 << 16) | (3 << 8))
 
 /**
  * flush commands to the hardware
@@ -478,6 +479,10 @@ struct pipe_video_codec *rvce_create_encoder(struct 
pipe_context *context,
radeon_vce_50_init(enc);
break;
 
+   case FW_52_0_3:
+   radeon_vce_52_init(enc);
+   break;
+
default:
goto error;
}
@@ -500,11 +505,17 @@ error:
  */
 bool rvce_is_fw_version_supported(struct r600_common_screen *rscreen)
 {
-   return rscreen->info.vce_fw_version == FW_40_2_2 ||
-   rscreen->info.vce_fw_version == FW_50_0_1 ||
-   rscreen->info.vce_fw_version == FW_50_1_2 ||
-   rscreen->info.vce_fw_version == FW_50_10_2 ||
-   rscreen->info.vce_fw_version == FW_50_17_3;
+   switch (rscreen->info.vce_fw_version) {
+   case FW_40_2_2:
+   case FW_50_0_1:
+   case FW_50_1_2:
+   case FW_50_10_2:
+   case FW_50_17_3:
+   case FW_52_0_3:
+   return true;
+   default:
+   return false;
+   }
 }
 
 /**
diff --git a/src/gallium/drivers/radeon/radeon_vce.h 
b/src/gallium/drivers/radeon/radeon_vce.h
index 624bda4..25e2133 100644
--- a/src/gallium/drivers/radeon/radeon_vce.h
+++ b/src/gallium/drivers/radeon/radeon_vce.h
@@ -140,4 +140,7 @@ void radeon_vce_40_2_2_init(struct rvce_encoder *enc);
 /* init vce fw 50 specific callbacks */
 void radeon_vce_50_init(struct rvce_encoder *enc);
 
+/* init vce fw 52 specific callbacks */
+void radeon_vce_52_init(struct rvce_encoder *enc);
+
 #endif
diff --git a/src/gallium/drivers/radeon/radeon_vce_52.c 
b/src/gallium/drivers/radeon/radeon_vce_52.c
new file mode 100644
index 000..fbae1f9
--- /dev/null
+++ b/src/gallium/drivers/radeon/radeon_vce_52.c
@@ -0,0 +1,242 @@
+/**
+ *
+ * Copyright 2015 Advanced Micro Devices, Inc.
+ * All Rights Reserved.
+ *
+ * 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, sub license, 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 NON-INFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **/
+
+#include 
+
+#include "pipe/p_video_codec.h"
+
+#include "util/u_video.h"
+#include "util/u_memory.h"
+
+#include "vl/vl_video_buffer.h"
+
+#include "r600_pipe_common.h"
+#include "radeon_video.h"
+#include "radeon_vce.h"
+
+static const unsigned profiles[7] = { 66, 77, 88, 100, 110, 122, 244 };
+
+static void create(struct rvce_encoder *enc)
+{
+   enc->task_info(enc, 0x, 0, 0, 0);
+
+   RVCE_BEGIN(0x0101); // create cmd
+   RVCE_CS(0x); // encUseCircularBuff

Re: [Mesa-dev] [PATCH 1/2] radeon/vce: add new firmware interface support

2015-11-20 Thread Christian König

On 20.11.2015 16:12, Leo Liu wrote:

Add new interface to create and encode
  
Signed-off-by: Leo Liu 

Reviewed-by: Alex Deucher 


Didn't had a chance to take a look before releasing them, so I thought I 
better do now.


Both patches are Reviewed-by: Christian König 


---
  src/gallium/drivers/radeon/Makefile.sources |   1 +
  src/gallium/drivers/radeon/radeon_vce.c |  21 ++-
  src/gallium/drivers/radeon/radeon_vce.h |   3 +
  src/gallium/drivers/radeon/radeon_vce_52.c  | 242 
  4 files changed, 262 insertions(+), 5 deletions(-)
  create mode 100644 src/gallium/drivers/radeon/radeon_vce_52.c

diff --git a/src/gallium/drivers/radeon/Makefile.sources 
b/src/gallium/drivers/radeon/Makefile.sources
index d840ff8..1dbad2f 100644
--- a/src/gallium/drivers/radeon/Makefile.sources
+++ b/src/gallium/drivers/radeon/Makefile.sources
@@ -14,6 +14,7 @@ C_SOURCES := \
radeon_uvd.h \
radeon_vce_40_2_2.c \
radeon_vce_50.c \
+   radeon_vce_52.c \
radeon_vce.c \
radeon_vce.h \
radeon_video.c \
diff --git a/src/gallium/drivers/radeon/radeon_vce.c 
b/src/gallium/drivers/radeon/radeon_vce.c
index 0dac6fb..b2b084e 100644
--- a/src/gallium/drivers/radeon/radeon_vce.c
+++ b/src/gallium/drivers/radeon/radeon_vce.c
@@ -49,6 +49,7 @@
  #define FW_50_1_2 ((50 << 24) | (1 << 16) | (2 << 8))
  #define FW_50_10_2 ((50 << 24) | (10 << 16) | (2 << 8))
  #define FW_50_17_3 ((50 << 24) | (17 << 16) | (3 << 8))
+#define FW_52_0_3 ((52 << 24) | (0 << 16) | (3 << 8))
  
  /**

   * flush commands to the hardware
@@ -478,6 +479,10 @@ struct pipe_video_codec *rvce_create_encoder(struct 
pipe_context *context,
radeon_vce_50_init(enc);
break;
  
+	case FW_52_0_3:

+   radeon_vce_52_init(enc);
+   break;
+
default:
goto error;
}
@@ -500,11 +505,17 @@ error:
   */
  bool rvce_is_fw_version_supported(struct r600_common_screen *rscreen)
  {
-   return rscreen->info.vce_fw_version == FW_40_2_2 ||
-   rscreen->info.vce_fw_version == FW_50_0_1 ||
-   rscreen->info.vce_fw_version == FW_50_1_2 ||
-   rscreen->info.vce_fw_version == FW_50_10_2 ||
-   rscreen->info.vce_fw_version == FW_50_17_3;
+   switch (rscreen->info.vce_fw_version) {
+   case FW_40_2_2:
+   case FW_50_0_1:
+   case FW_50_1_2:
+   case FW_50_10_2:
+   case FW_50_17_3:
+   case FW_52_0_3:
+   return true;
+   default:
+   return false;
+   }
  }
  
  /**

diff --git a/src/gallium/drivers/radeon/radeon_vce.h 
b/src/gallium/drivers/radeon/radeon_vce.h
index 624bda4..25e2133 100644
--- a/src/gallium/drivers/radeon/radeon_vce.h
+++ b/src/gallium/drivers/radeon/radeon_vce.h
@@ -140,4 +140,7 @@ void radeon_vce_40_2_2_init(struct rvce_encoder *enc);
  /* init vce fw 50 specific callbacks */
  void radeon_vce_50_init(struct rvce_encoder *enc);
  
+/* init vce fw 52 specific callbacks */

+void radeon_vce_52_init(struct rvce_encoder *enc);
+
  #endif
diff --git a/src/gallium/drivers/radeon/radeon_vce_52.c 
b/src/gallium/drivers/radeon/radeon_vce_52.c
new file mode 100644
index 000..fbae1f9
--- /dev/null
+++ b/src/gallium/drivers/radeon/radeon_vce_52.c
@@ -0,0 +1,242 @@
+/**
+ *
+ * Copyright 2015 Advanced Micro Devices, Inc.
+ * All Rights Reserved.
+ *
+ * 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, sub license, 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 NON-INFRINGEMENT.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **/
+
+#include 
+
+#include "pipe/p_video_codec.h"
+
+#include "util/u_video.h"
+#include "util/u_memory.h"
+
+#include "vl/vl_video_buffer.h"
+
+#include "r600_pipe_common.h"
+#include "radeon_video.h"
+#include "radeon_vce.h"
+
+static const unsigned profiles[7] = { 66, 77, 88, 100, 110, 122, 244

Re: [Mesa-dev] [Mesa-stable] [PATCH] i965: Fix JIP to properly skip over unrelated control flow.

2015-11-20 Thread Francisco Jerez
Kenneth Graunke  writes:

> On Friday, November 20, 2015 02:38:10 PM Francisco Jerez wrote:
>> Kenneth Graunke  writes:
>> 
>> > On Thursday, November 19, 2015 02:05:44 PM Kenneth Graunke wrote:
>> >> We've apparently always been botching JIP for sequences such as:
>> >> 
>> >>do
>> >>cmp.f0.0 ...
>> >>(+f0.0) break
>> >>...
>> >>if
>> >>   ...
>> >>else
>> >>   ...
>> >>endif
>> >>...
>> >>while
>> >> 
>> >> Normally, UIP is supposed to point to the final destination of the jump,
>> >> while in nested control flow, JIP is supposed to point to the end of the
>> >> current nesting level.  It essentially bounces out of the current nested
>> >> control flow, to an instruction that has a JIP which bounces out another
>> >> level, and so on.
>> >> 
>> >> In the above example, when setting JIP for the BREAK, we call
>> >> brw_find_next_block_end(), which begins a search after the BREAK for the
>> >> next ENDIF, ELSE, WHILE, or HALT.  It ignores the IF and finds the ELSE,
>> >> setting JIP there.
>> >> 
>> >> This makes no sense at all.  The break is supposed to skip over the
>> >> whole if/else/endif block entirely.  They have a sibling relationship,
>> >> not a nesting relationship.
>> >> 
>> >> This patch fixes brw_find_next_block_end() to track depth as it does
>> >> its search, and ignore anything not at depth 0.  So when it sees the
>> >> IF, it ignores everything until after the ENDIF.  That way, it finds
>> >> the end of the right block.
>> >> 
>> >> Caught while debugging a tessellation shader - no apparent effect on
>> >> Piglit.  I did look for actual applications that were affected, and
>> >> found that GLBenchmark Manhattan had a BREAK with a bogus JIP.
>> >> 
>> >> Cc: mesa-sta...@lists.freedesktop.org
>> >> Signed-off-by: Kenneth Graunke 
>> >
>> > I tried pretty hard to produce a Piglit test that showed an actual
>> > problem from doing this wrong - and I wasn't able to.
>> >
>> > It seems it just steps through some extra instructions which do
>> > nothing, and is pretty harmless.
>> >
>> From my understanding of how control flow is implemented, jumping to the
>> ENDIF instruction of an inactive IF-ENDIF construct (or similarly to the
>> WHILE instruction of an inactive loop) is fully equivalent to jumping to
>> the same point of an active (i.e. properly nested) but non-diverging
>> IF-ENDIF construct, and will behave the same: It will have no effect on
>> the current per-channel enables (because the IP of the ENDIF instruction
>> won't match the UIP value present at the top of the stack), and for that
>> reason will go on and jump to the instruction pointed to by the JIP
>> value of the ENDIF, which will be another ENDIF/WHILE/HALT instruction
>> closer to the right ENDIF/WHILE instruction that closes the current
>> block.
>> 
>> > So I don't think this should actually go to stable after all.
>> >
>> Yeah, seems pretty harmless -- If it weren't harmeless you'd also need
>> to apply a similar fix to WHILE loops, but I don't think you do.
>
> Thanks, Curro!  I appreciate you confirming the theory :)
>
> I haven't pushed the patch yet, so would you like to add a Reviewed-by?
>
> What WHILE fix are you thinking of?  We may as well get it right, even
> if it is harmless.  At a cursory glance, I didn't see anything wrong,
> as it uses the loop stack.  But I might've missed something...

Hmm, does it?  AFAICT brw_find_next_block_end() will just give you the
first WHILE instruction it finds even if the corresponding loop starts
after the given offset.  Not that it matters much anyway.

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


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


Re: [Mesa-dev] [PATCH 2/9] i965/fs: print writemask_all when it's enabled

2015-11-20 Thread Connor Abbott
On Fri, Nov 20, 2015 at 2:46 AM, Iago Toral  wrote:
> On Thu, 2015-11-19 at 10:14 -0500, Connor Abbott wrote:
>> I think Ken already pushed a similar patch so we can drop this.
>
> I don't see that in master, but sure, we can hold this back if he is
> planning to push the same thing.
>
> Iago

No, he already pushed it, the SHA is e42a29531ae3d5dedb72011da2947357dfa8715b.

>
>> On Thu, Nov 19, 2015 at 5:05 AM, Iago Toral Quiroga  
>> wrote:
>> > From: Connor Abbott 
>> >
>> > Reviewed-by: Iago Toral Quiroga 
>> > ---
>> >  src/mesa/drivers/dri/i965/brw_fs.cpp | 3 +++
>> >  1 file changed, 3 insertions(+)
>> >
>> > diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp 
>> > b/src/mesa/drivers/dri/i965/brw_fs.cpp
>> > index 2d4ed6a..63dcba7 100644
>> > --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
>> > +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
>> > @@ -4787,6 +4787,9 @@ fs_visitor::dump_instruction(backend_instruction 
>> > *be_inst, FILE *file)
>> >   fprintf(file, "1sthalf ");
>> > }
>> >
>> > +   if (inst->force_writemask_all)
>> > +  fprintf(file, "WE_all ");
>> > +
>> > fprintf(file, "\n");
>> >  }
>> >
>> > --
>> > 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/2] radeon/vce: disable two pipe mode for stoney

2015-11-20 Thread Emil Velikov
Hi Leo,

On 20 November 2015 at 15:12, Leo Liu  wrote:
> Only one encoding pipe available for Stoney
>
> Signed-off-by: Leo Liu 
> Reviewed-by: Alex Deucher 
> ---
>  src/gallium/drivers/radeon/radeon_vce.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/radeon/radeon_vce.c 
> b/src/gallium/drivers/radeon/radeon_vce.c
> index b2b084e..8a60441 100644
> --- a/src/gallium/drivers/radeon/radeon_vce.c
> +++ b/src/gallium/drivers/radeon/radeon_vce.c
> @@ -406,7 +406,8 @@ struct pipe_video_codec *rvce_create_encoder(struct 
> pipe_context *context,
> enc->use_vm = true;
> if ((rscreen->info.drm_major > 2) || (rscreen->info.drm_minor >= 42))
> enc->use_vui = true;
> -   if (rscreen->info.family >= CHIP_TONGA)
> +   if (rscreen->info.family >= CHIP_TONGA &&
> + rscreen->info.family != CHIP_STONEY)
Since we have Stoney support in 11.0, can you send a patch to
mesa-stable that disables VCE for Stoney. I'd recommend committing
this and patch 1/2 some time today, as I will be branching 11.1 after
people finish they work day.

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


Re: [Mesa-dev] [PATCH 1/7] i965/fs_surface_builder: Explicitly handle FORMAT_NONE in num_image_coordinates

2015-11-20 Thread Jason Ekstrand
On Fri, Nov 20, 2015 at 5:49 AM, Francisco Jerez  wrote:
> Chad Versace  writes:
>
>> On Wed 04 Nov 2015, Jason Ekstrand wrote:
>>> Previously, we were relying on has_matching_typed_format returning true for
>>> MESA_FORMAT_NONE which, in turn, relied on _mesa_get_format_bytes returning
>>> 1 for MESA_FORMAT_NONE.  All of this is extremely non-obvious.  Instead,
>>> this commit makes us handle it explicitly.
>>> ---
>>>  src/mesa/drivers/dri/i965/brw_fs_surface_builder.cpp | 1 +
>>>  1 file changed, 1 insertion(+)
>>>
>>> diff --git a/src/mesa/drivers/dri/i965/brw_fs_surface_builder.cpp 
>>> b/src/mesa/drivers/dri/i965/brw_fs_surface_builder.cpp
>>> index 534d849..31ecb5b 100644
>>> --- a/src/mesa/drivers/dri/i965/brw_fs_surface_builder.cpp
>>> +++ b/src/mesa/drivers/dri/i965/brw_fs_surface_builder.cpp
>>> @@ -409,6 +409,7 @@ namespace {
>>>* reads want the array index to be at the Z component.
>>>*/
>>>   const bool array_index_at_z =
>>> +format != MESA_FORMAT_NONE &&
>>>  !image_format_info::has_matching_typed_format(
>>> bld.shader->devinfo, format);
>>>   const unsigned zero_dims =
>>
>>
>> Knowing nothing about the implicit assumptions you discovered that
>> relied on _mesa_get_format_bytes(MESA_FORMAT_NONE) => 1, the patch is
>> still looks like an improvement to me.
>>
> It didn't.  It relied on _mesa_get_format_bytes(MESA_FORMAT_NONE) not
> being greater than 4, which seems sensible anyway.

I can change the commit message to say

Previously, we were relying on has_matching_typed_format returning true for
MESA_FORMAT_NONE which, in turn, relied on _mesa_get_format_bytes returning
a value <= 4 for MESA_FORMAT_NONE.  While reliable, this is extremely
non-obvious.  Instead,
this commit makes us handle it explicitly.

>> Acked-by: Chad Versace 
>> ___
>> 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 2/2] radeon: re-prepare query buffers on begin_query for predicate queries

2015-11-20 Thread Nicolai Hähnle
The point of prepare_buffer is to ensure that the query buffer contains valid
initial data for conditional rendering: as long as the buffer is initialized
correctly, the GPU is able to tell whether query results have been written
already (and wait or fall back to unconditional rendering if desired).

This means prepare_buffer needs to be called again when a buffer is reused.

Conversely, for queries that cannot be used for conditional rendering
(notably pipeline statistics), we can re-use buffers immediately, and they
do not need to be initialized.
---
 src/gallium/drivers/radeon/r600_query.c | 32 +---
 src/gallium/drivers/radeon/r600_query.h |  1 +
 2 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/src/gallium/drivers/radeon/r600_query.c 
b/src/gallium/drivers/radeon/r600_query.c
index 4726b78..fb974c7 100644
--- a/src/gallium/drivers/radeon/r600_query.c
+++ b/src/gallium/drivers/radeon/r600_query.c
@@ -242,7 +242,7 @@ static struct r600_resource *r600_new_query_buffer(struct 
r600_common_context *c
pipe_buffer_create(ctx->b.screen, PIPE_BIND_CUSTOM,
   PIPE_USAGE_STAGING, buf_size);
 
-   if (query->ops->prepare_buffer)
+   if (query->flags & R600_QUERY_HW_FLAG_PREDICATE)
query->ops->prepare_buffer(ctx, query, buf);
 
return buf;
@@ -251,15 +251,11 @@ static struct r600_resource *r600_new_query_buffer(struct 
r600_common_context *c
 static void r600_query_hw_prepare_buffer(struct r600_common_context *ctx,
 struct r600_query_hw *query,
 struct r600_resource *buffer)
- {
-   uint32_t *results;
-
-   if (query->b.type == PIPE_QUERY_TIME_ELAPSED ||
-   query->b.type == PIPE_QUERY_TIMESTAMP)
-   return;
-
-   results = r600_buffer_map_sync_with_rings(ctx, buffer,
- PIPE_TRANSFER_WRITE);
+{
+   /* Callers ensure that the buffer is currently unused by the GPU. */
+   uint32_t *results = ctx->ws->buffer_map(buffer->cs_buf, NULL,
+   PIPE_TRANSFER_WRITE |
+   PIPE_TRANSFER_UNSYNCHRONIZED);
 
memset(results, 0, buffer->b.b.width0);
 
@@ -339,6 +335,7 @@ static struct pipe_query *r600_query_hw_create(struct 
r600_common_context *rctx,
query->result_size = 16 * rctx->max_db;
query->num_cs_dw_begin = 6;
query->num_cs_dw_end = 6;
+   query->flags |= R600_QUERY_HW_FLAG_PREDICATE;
break;
case PIPE_QUERY_TIME_ELAPSED:
query->result_size = 16;
@@ -361,6 +358,7 @@ static struct pipe_query *r600_query_hw_create(struct 
r600_common_context *rctx,
query->num_cs_dw_begin = 6;
query->num_cs_dw_end = 6;
query->stream = index;
+   query->flags |= R600_QUERY_HW_FLAG_PREDICATE;
break;
case PIPE_QUERY_PIPELINE_STATISTICS:
/* 11 values on EG, 8 on R600. */
@@ -667,11 +665,15 @@ static void r600_query_hw_reset_buffers(struct 
r600_common_context *rctx,
FREE(qbuf);
}
 
-   /* Obtain a new buffer if the current one can't be mapped without a 
stall. */
-   if (r600_rings_is_buffer_referenced(rctx, query->buffer.buf->cs_buf, 
RADEON_USAGE_READWRITE) ||
-   !rctx->ws->buffer_wait(query->buffer.buf->buf, 0, 
RADEON_USAGE_READWRITE)) {
-   pipe_resource_reference((struct 
pipe_resource**)&query->buffer.buf, NULL);
-   query->buffer.buf = r600_new_query_buffer(rctx, query);
+   if (query->flags & R600_QUERY_HW_FLAG_PREDICATE) {
+   /* Obtain a new buffer if the current one can't be mapped 
without a stall. */
+   if (r600_rings_is_buffer_referenced(rctx, 
query->buffer.buf->cs_buf, RADEON_USAGE_READWRITE) ||
+   !rctx->ws->buffer_wait(query->buffer.buf->buf, 0, 
RADEON_USAGE_READWRITE)) {
+   pipe_resource_reference((struct 
pipe_resource**)&query->buffer.buf, NULL);
+   query->buffer.buf = r600_new_query_buffer(rctx, query);
+   } else {
+   query->ops->prepare_buffer(rctx, query, 
query->buffer.buf);
+   }
}
 
query->buffer.results_end = 0;
diff --git a/src/gallium/drivers/radeon/r600_query.h 
b/src/gallium/drivers/radeon/r600_query.h
index 5d12191..b20beec 100644
--- a/src/gallium/drivers/radeon/r600_query.h
+++ b/src/gallium/drivers/radeon/r600_query.h
@@ -75,6 +75,7 @@ struct r600_query {
 enum {
R600_QUERY_HW_FLAG_NO_START = (1 << 0),
R600_QUERY_HW_FLAG_TIMER = (1 << 1),
+   R600_QUERY_HW_FLAG_PREDICATE = (1 << 2),
 };
 
 struct r600_query_hw_ops {
-- 
2.5.0

___
mesa-dev mailing list
mesa-dev@

[Mesa-dev] [PATCH 1/2] radeon: reset query buffers for PIPE_QUERY_TIMESTAMP

2015-11-20 Thread Nicolai Hähnle
Since begin_query is not called for this query type, we need to reset the
query buffer state in end_query instead.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93015
---
 src/gallium/drivers/radeon/r600_query.c | 26 ++
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/radeon/r600_query.c 
b/src/gallium/drivers/radeon/r600_query.c
index ecf4084..4726b78 100644
--- a/src/gallium/drivers/radeon/r600_query.c
+++ b/src/gallium/drivers/radeon/r600_query.c
@@ -654,17 +654,11 @@ static boolean r600_begin_query(struct pipe_context *ctx,
return rquery->ops->begin(rctx, rquery);
 }
 
-boolean r600_query_hw_begin(struct r600_common_context *rctx,
-   struct r600_query *rquery)
+static void r600_query_hw_reset_buffers(struct r600_common_context *rctx,
+   struct r600_query_hw *query)
 {
-   struct r600_query_hw *query = (struct r600_query_hw *)rquery;
struct r600_query_buffer *prev = query->buffer.previous;
 
-   if (query->flags & R600_QUERY_HW_FLAG_NO_START) {
-   assert(0);
-   return false;
-   }
-
/* Discard the old query buffers. */
while (prev) {
struct r600_query_buffer *qbuf = prev;
@@ -682,6 +676,19 @@ boolean r600_query_hw_begin(struct r600_common_context 
*rctx,
 
query->buffer.results_end = 0;
query->buffer.previous = NULL;
+}
+
+boolean r600_query_hw_begin(struct r600_common_context *rctx,
+   struct r600_query *rquery)
+{
+   struct r600_query_hw *query = (struct r600_query_hw *)rquery;
+
+   if (query->flags & R600_QUERY_HW_FLAG_NO_START) {
+   assert(0);
+   return false;
+   }
+
+   r600_query_hw_reset_buffers(rctx, query);
 
r600_query_hw_emit_start(rctx, query);
 
@@ -705,6 +712,9 @@ void r600_query_hw_end(struct r600_common_context *rctx,
 {
struct r600_query_hw *query = (struct r600_query_hw *)rquery;
 
+   if (query->flags & R600_QUERY_HW_FLAG_NO_START)
+   r600_query_hw_reset_buffers(rctx, query);
+
r600_query_hw_emit_stop(rctx, query);
 
if (!(query->flags & R600_QUERY_HW_FLAG_NO_START))
-- 
2.5.0

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


Re: [Mesa-dev] MESA_EXTENSION_OVERRIDE problem

2015-11-20 Thread Brian Paul
On Thu, Nov 19, 2015 at 7:04 PM, Ian Romanick  wrote:

> On 11/19/2015 05:40 PM, Nanley Chery wrote:
> >
> > On Thu, Nov 19, 2015 at 12:13 PM, Brian Paul  > > wrote:
> >
> > Hi Nanley,
> >
> >
> > Hi Brian,
> >
> >
> > Maybe you can fix an issue I have with the new extension code.
> >
> > Previously, I could do something like export
> > MESA_EXTENSION_OVERRIDE="-ARB_clear_buffer_object" and I would no
> > longer see it in the GL_EXTENSIONS string, even if it was an "always
> > on" extension.
> >
> > Now when I try that I get:
> >
> > Mesa 11.1.0-devel implementation error: Trying to disable
> > permanently enabled extensions: GL_ARB_get_texture_sub_image
> > Please report at
> https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa
> >
> > The whole point of the "-GL_EXT_foobar" syntax was to hide an
> > extension from the application when it queries the driver's
> extensions.
> >
> > Can you please fix this so it works as before?
> >
> >
> > I have two branches that provide the ability to disable permanently
> > enabled extensions:
> > 1. The first only modifies the extension strings and is located here:
> > http://cgit.freedesktop.org/~nchery/mesa/commit/?h=mod_always_on
> > 
> > 2. The second modifies the extension strings and disables the extension
> > within the driver (assuming appropriate the helper function is used). It
> > also provides some performance benefits. :
> > http://cgit.freedesktop.org/~nchery/mesa/commit/?h=init_ext_vals
> > 
> >
> > I'd appreciate any feedback on the two approaches as I work to get the
> > feature upstreamed.
>
> I think #2 might be better, but there's a lot of churn.  I don't know
> that we want that much churn right around the time of the release branch
> point, and I think it would be good to have this resolved in 11.1.  I
> also have a few bits of feedback in #2, so it might take a couple
> iterations before that could land.
>
>
Since 11.1 is coming up, can we go with the simpler #1 for now, then go to
#2 after 11.1 branches?

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


[Mesa-dev] [PATCH] radeon/vce: disable Stoney VCE for 11.0

2015-11-20 Thread Leo Liu
Signed-off-by: Leo Liu 
"11.0" 
---
 src/gallium/drivers/radeon/radeon_vce.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/gallium/drivers/radeon/radeon_vce.c 
b/src/gallium/drivers/radeon/radeon_vce.c
index 0dac6fb..7c5a961 100644
--- a/src/gallium/drivers/radeon/radeon_vce.c
+++ b/src/gallium/drivers/radeon/radeon_vce.c
@@ -388,6 +388,11 @@ struct pipe_video_codec *rvce_create_encoder(struct 
pipe_context *context,
struct radeon_surf *tmp_surf;
unsigned cpb_size;
 
+   if (rscreen->info.family == CHIP_STONEY) {
+   RVID_ERR("Stoney VCE is not supported!\n");
+   return NULL;
+   }
+
if (!rscreen->info.vce_fw_version) {
RVID_ERR("Kernel doesn't supports VCE!\n");
return NULL;
-- 
2.5.0

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


[Mesa-dev] [PATCH] radeon/vce: disable Stoney VCE for 11.0

2015-11-20 Thread Leo Liu
Signed-off-by: Leo Liu 
Cc: "11.0" 
---
 src/gallium/drivers/radeon/radeon_vce.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/src/gallium/drivers/radeon/radeon_vce.c 
b/src/gallium/drivers/radeon/radeon_vce.c
index 0dac6fb..7c5a961 100644
--- a/src/gallium/drivers/radeon/radeon_vce.c
+++ b/src/gallium/drivers/radeon/radeon_vce.c
@@ -388,6 +388,11 @@ struct pipe_video_codec *rvce_create_encoder(struct 
pipe_context *context,
struct radeon_surf *tmp_surf;
unsigned cpb_size;
 
+   if (rscreen->info.family == CHIP_STONEY) {
+   RVID_ERR("Stoney VCE is not supported!\n");
+   return NULL;
+   }
+
if (!rscreen->info.vce_fw_version) {
RVID_ERR("Kernel doesn't supports VCE!\n");
return NULL;
-- 
2.5.0

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


Re: [Mesa-dev] [PATCH] radeon/vce: disable Stoney VCE for 11.0

2015-11-20 Thread Alex Deucher
On Fri, Nov 20, 2015 at 12:07 PM, Leo Liu  wrote:
> Signed-off-by: Leo Liu 
> Cc: "11.0" 

Reviewed-by: Alex Deucher 

> ---
>  src/gallium/drivers/radeon/radeon_vce.c | 5 +
>  1 file changed, 5 insertions(+)
>
> diff --git a/src/gallium/drivers/radeon/radeon_vce.c 
> b/src/gallium/drivers/radeon/radeon_vce.c
> index 0dac6fb..7c5a961 100644
> --- a/src/gallium/drivers/radeon/radeon_vce.c
> +++ b/src/gallium/drivers/radeon/radeon_vce.c
> @@ -388,6 +388,11 @@ struct pipe_video_codec *rvce_create_encoder(struct 
> pipe_context *context,
> struct radeon_surf *tmp_surf;
> unsigned cpb_size;
>
> +   if (rscreen->info.family == CHIP_STONEY) {
> +   RVID_ERR("Stoney VCE is not supported!\n");
> +   return NULL;
> +   }
> +
> if (!rscreen->info.vce_fw_version) {
> RVID_ERR("Kernel doesn't supports VCE!\n");
> return NULL;
> --
> 2.5.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] android: fix LOCAL_C_INCLUDES to find glsl_types.h

2015-11-20 Thread Mauro Rossi
> > My last problem was probably due to uncleaned mesa targets folders in
> $OUT
> > path,
> > now I have checked again and building errors are gone.
> >
> You might want to take a look and update the CleanSpec.mk for that.
> I've pushed the one-liner to master - do we want it in stable (11.0.x)
> as well ? I'm not sure which branch android-x86 current follows.
>
> Cheers,
> Emil
>

Hi Emil,

I'll check CleanSpec.mk

The patch is needed only in master, building errors related to missing
glsl_types.h never happened in mesa 11.0 branch.
lollipop-x86 branch is using mesa 11.0.3

Thanks a lot
Regards

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


[Mesa-dev] [PATCH] freedreno/a4xx: fix dst_alpha blend for RGBX render targets

2015-11-20 Thread Ilia Mirkin
There are not native RGBX render formats, so we must manually force
dst_alpha to be one, same as for a3xx.

Signed-off-by: Ilia Mirkin 
---
 src/gallium/drivers/freedreno/a4xx/fd4_blend.c | 13 +++--
 src/gallium/drivers/freedreno/a4xx/fd4_blend.h |  7 ++-
 src/gallium/drivers/freedreno/a4xx/fd4_emit.c  | 17 +++--
 3 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_blend.c 
b/src/gallium/drivers/freedreno/a4xx/fd4_blend.c
index eb84ba1..03c1a37 100644
--- a/src/gallium/drivers/freedreno/a4xx/fd4_blend.c
+++ b/src/gallium/drivers/freedreno/a4xx/fd4_blend.c
@@ -27,6 +27,7 @@
  */
 
 #include "pipe/p_state.h"
+#include "util/u_blend.h"
 #include "util/u_string.h"
 #include "util/u_memory.h"
 
@@ -98,14 +99,22 @@ fd4_blend_state_create(struct pipe_context *pctx,
else
rt = &cso->rt[0];
 
-   so->rb_mrt[i].blend_control =
+   so->rb_mrt[i].blend_control_rgb =

A4XX_RB_MRT_BLEND_CONTROL_RGB_SRC_FACTOR(fd_blend_factor(rt->rgb_src_factor)) |

A4XX_RB_MRT_BLEND_CONTROL_RGB_BLEND_OPCODE(blend_func(rt->rgb_func)) |
-   
A4XX_RB_MRT_BLEND_CONTROL_RGB_DEST_FACTOR(fd_blend_factor(rt->rgb_dst_factor)) |
+   
A4XX_RB_MRT_BLEND_CONTROL_RGB_DEST_FACTOR(fd_blend_factor(rt->rgb_dst_factor));
+
+   so->rb_mrt[i].blend_control_alpha =

A4XX_RB_MRT_BLEND_CONTROL_ALPHA_SRC_FACTOR(fd_blend_factor(rt->alpha_src_factor))
 |

A4XX_RB_MRT_BLEND_CONTROL_ALPHA_BLEND_OPCODE(blend_func(rt->alpha_func)) |

A4XX_RB_MRT_BLEND_CONTROL_ALPHA_DEST_FACTOR(fd_blend_factor(rt->alpha_dst_factor));
 
+   so->rb_mrt[i].blend_control_no_alpha_rgb =
+   
A4XX_RB_MRT_BLEND_CONTROL_RGB_SRC_FACTOR(fd_blend_factor(util_blend_dst_alpha_to_one(rt->rgb_src_factor)))
 |
+   
A4XX_RB_MRT_BLEND_CONTROL_RGB_BLEND_OPCODE(blend_func(rt->rgb_func)) |
+   
A4XX_RB_MRT_BLEND_CONTROL_RGB_DEST_FACTOR(fd_blend_factor(util_blend_dst_alpha_to_one(rt->rgb_dst_factor)));
+
+
so->rb_mrt[i].control =
A4XX_RB_MRT_CONTROL_ROP_CODE(rop) |
COND(cso->logicop_enable, 
A4XX_RB_MRT_CONTROL_ROP_ENABLE) |
diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_blend.h 
b/src/gallium/drivers/freedreno/a4xx/fd4_blend.h
index 7620d00..6230fa7 100644
--- a/src/gallium/drivers/freedreno/a4xx/fd4_blend.h
+++ b/src/gallium/drivers/freedreno/a4xx/fd4_blend.h
@@ -39,7 +39,12 @@ struct fd4_blend_stateobj {
struct {
uint32_t control;
uint32_t buf_info;
-   uint32_t blend_control;
+   /* Blend control bits for color if there is an alpha channel */
+   uint32_t blend_control_rgb;
+   /* Blend control bits for color if there is no alpha channel */
+   uint32_t blend_control_no_alpha_rgb;
+   /* Blend control bits for alpha channel */
+   uint32_t blend_control_alpha;
} rb_mrt[A4XX_MAX_RENDER_TARGETS];
uint32_t rb_fs_output;
 };
diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_emit.c 
b/src/gallium/drivers/freedreno/a4xx/fd4_emit.c
index 5a7b192..99d1602 100644
--- a/src/gallium/drivers/freedreno/a4xx/fd4_emit.c
+++ b/src/gallium/drivers/freedreno/a4xx/fd4_emit.c
@@ -626,11 +626,24 @@ fd4_emit_state(struct fd_context *ctx, struct 
fd_ringbuffer *ring,
uint32_t i;
 
for (i = 0; i < A4XX_MAX_RENDER_TARGETS; i++) {
+   enum pipe_format format = pipe_surface_format(
+   ctx->framebuffer.cbufs[i]);
+   bool has_alpha = util_format_has_alpha(format);
+   uint32_t control = blend->rb_mrt[i].control;
+   uint32_t blend_control = 
blend->rb_mrt[i].blend_control_alpha;
+
+   if (has_alpha) {
+   blend_control |= 
blend->rb_mrt[i].blend_control_rgb;
+   } else {
+   blend_control |= 
blend->rb_mrt[i].blend_control_no_alpha_rgb;
+   control &= ~A4XX_RB_MRT_CONTROL_BLEND2;
+   }
+
OUT_PKT0(ring, REG_A4XX_RB_MRT_CONTROL(i), 1);
-   OUT_RING(ring, blend->rb_mrt[i].control);
+   OUT_RING(ring, control);
 
OUT_PKT0(ring, REG_A4XX_RB_MRT_BLEND_CONTROL(i), 1);
-   OUT_RING(ring, blend->rb_mrt[i].blend_control);
+   OUT_RING(ring, blend_control);
}
 
OUT_PKT0(ring, REG_A4XX_RB_FS_OUTPUT, 1);
-- 
2.4.10

__

Re: [Mesa-dev] [PATCH] xmlconfig: Add support for DragonFly

2015-11-20 Thread Francois Tigeot

Emil Velikov wrote:


Considering how trivial the patch is (and lack of objections) I've
pushed it to master... only to forget the mesa-stable tag (I'll pick
it up for the next stable release regardless) :-\ If you have _any_
additional patches do send them over, but please use git send-email -
it makes review/commenting a bit easier.


Thanks !

I'll try to remember to use git-send-email for the next ones ;-)

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


Re: [Mesa-dev] [PATCH v2 1/2] mesa: Add KBL PCI IDs and platform information.

2015-11-20 Thread Sarah Sharp
On Fri, Nov 20, 2015 at 02:18:56PM +, Emil Velikov wrote:
> On 18 November 2015 at 21:59, Ilia Mirkin  wrote:
> > On Wed, Nov 18, 2015 at 4:54 PM, Sarah Sharp
> >  wrote:
> >>> There's not really a consensus I guess, but most people do leave the 
> >>> version
> >>> information in the final commit message.
> >>
> >> I personally feel like that's leaving boredom doodles on a final
> >> architectural drawing. If people want to know the back-and-forth
> >> history, the mailing list archive will always be there. So, no, I don't
> >> really want to leave version info in the commit message.
> >
> > FWIW I wholeheartedly agree with this line of reasoning. I never put
> > the version info into my commits either, and find it
> > confusing/misleading when others do. I want to know the final state of
> > things when looking at the commit 1 year from now, not the 20-step
> > process and all the wrong turns to get there.
> >
> 
> The other side of the coin:
> 
>  - One might not have access to the discussion - ISP/ML archive is
> down. discussion was offline or no longer available (10+ years ago),
> etc.
>  - Revision history is immediately available, rather than going back
> and forth between git/browser/email client.
>  - We can easily ignore the revision history hunk
>  - Hitting more than v3 is a clear sign something fishy (most likely
> lack of experience of said author), which in itself is useful.

Or perfectionist maintainers, or a controversial change that touches
many subsystems. It's not uncommon for a kernel patchset to make it up
to v8, even if the idea is sound. Glad to hear that mesa is less picky
than the kernel anyway. :)

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


Re: [Mesa-dev] [PATCH] [v2] i965: Add lossless compression to surface format table

2015-11-20 Thread Chad Versace
On Wed 18 Nov 2015, Ben Widawsky wrote:
> On Wed, Nov 18, 2015 at 10:28:27AM -0800, Chad Versace wrote:
> > On Tue 17 Nov 2015, Ben Widawsky wrote:


> > > The logic in the table works a bit differently than the other columns in 
> > > the
> > > table and therefore deserves a small mention. For most other features, 
> > > the GEN
> > > which began implementing it is set, and it is assumed future gens also 
> > > support
> > > this. For this feature, GEN9 actually eliminates support for certain 
> > > formats. We
> > > could use this column to determine support for the similar feature on 
> > > older
> > > generation hardware. Aside from that being an error prone task which is
> > > unrelated to enabling this on GEN9, it becomes somewhat tricky to 
> > > implement
> > > because of the fact that surface format support diminishes. You'd 
> > > probably want
> > > another column to cleanly implement it.
> > 
> > Does the above paragraph still apply to the table's ccs_e column?
> > I understand your patch series, the ccs_e column behaves identically to
> > all other columns:
> > 
> > feature_is_supported == (10 * gen >= table[format].feature)
> > 
> > The patch's diff looks good to me. My only remaining questions/issues
> > with the patch are the ones stated in this message.
> 
> Yes. As Topi pointed this out too, I agree. With the changes your requested,
> this part of the commit message needs to be removed.

Ok, with that portion of the commit message dropped, this patch is
Reviewed-by: Chad Versace 

I retract my CCS_E feedback for this patch.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 1/2] mesa: Add KBL PCI IDs and platform information.

2015-11-20 Thread Ben Widawsky
On Fri, Nov 20, 2015 at 02:18:56PM +, Emil Velikov wrote:
> On 18 November 2015 at 21:59, Ilia Mirkin  wrote:
> > On Wed, Nov 18, 2015 at 4:54 PM, Sarah Sharp
> >  wrote:
> >>> There's not really a consensus I guess, but most people do leave the 
> >>> version
> >>> information in the final commit message.
> >>
> >> I personally feel like that's leaving boredom doodles on a final
> >> architectural drawing. If people want to know the back-and-forth
> >> history, the mailing list archive will always be there. So, no, I don't
> >> really want to leave version info in the commit message.
> >
> > FWIW I wholeheartedly agree with this line of reasoning. I never put
> > the version info into my commits either, and find it
> > confusing/misleading when others do. I want to know the final state of
> > things when looking at the commit 1 year from now, not the 20-step
> > process and all the wrong turns to get there.

When I'm lazy, the commit message doesn't reflect the final state and you need
to read through the version info to get the end result. That is not great
because I am usually lazy. However aside from that case, I don't see what is
confusing about it - it's at the bottom. Don't read it if you don't want to.

> >
> 
> The other side of the coin:
> 
>  - One might not have access to the discussion - ISP/ML archive is
> down. discussion was offline or no longer available (10+ years ago),
> etc.
>  - Revision history is immediately available, rather than going back
> and forth between git/browser/email client.
>  - We can easily ignore the revision history hunk
>  - Hitting more than v3 is a clear sign something fishy (most likely
> lack of experience of said author), which in itself is useful.

I agree with all but this one - and of course I am partial because I almost
never land something in under v3. It could also mean there was a lot of
contention about something, or a poor review process (for instance if v5-v10 are
all comment changes or commit message changes, that is not an efficient review).
I think you do hit on a reason some people might not want to put version
information in - because there is some amount of shaming and embarrassment.

> 
> Obviously I'm not saying that we must use approach A or B. Whatever
> floats your boat really :-)
> 
> -Emil

I was forced to do the version thing against my will originally for the kernel
driver, but over time it grew on me. (I wanted to do it as git notes, but that
was rejected).

I personally like the version information because a lot of times the changes
that go in there are things which I don't necessarily want or like, but was
requested of me to make in order to get a reviewed-by. As a result, when I look
back and say, WTF did I do that - it's immediately obvious without having to
look at the m-l. Similarly, I tend to do the most amount of testing on v1.
There have been several times where my patch regressed something, and it's
useful to try to figure out how I could have missed such a regression - the
version information often has the answer.

What is definitely clear is there is not consensus, and I even take back my
original assertion that "most" people do this. Going through the history I found
that there are some developers who themselves don't have a reliable approach.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] [v2] i965: Add lossless compression to surface format table

2015-11-20 Thread Chad Versace
On Wed 18 Nov 2015, Ben Widawsky wrote:
> On Wed, Nov 18, 2015 at 10:28:27AM -0800, Chad Versace wrote:
> > On Tue 17 Nov 2015, Ben Widawsky wrote:
> > > Background: Prior to Skylake and since Ivybridge Intel hardware has had 
> > > the
> > > ability to use a MCS (Multisample Control Surface) as auxiliary data in
> > > "compression" operations on the surface. This reduces memory bandwidth.  
> > > This
> > > hardware was either used for MSAA compression, and fast clear operations. 
> > >  On
> > > Gen8, a similar mechanism exists to allow the hiz buffer to be sampled 
> > > from, and
> > > therefore this feature is sometimes referred to more generally as "AUX 
> > > buffers".
> > > 
> > > Skylake adds the ability to have the display engine directly source 
> > > compressed
> > > surfaces on top of the ability to sample from them. Inference dictates 
> > > that
> > > enabling this display features adding a restriction to the formats which 
> > > could
> > > actually be compressed. The current set of surfaces seems to be a subset 
> > > as
> > > compared to previous gens (see the next patch). Also, if I had to guess I 
> > > would
> > > guess that future gens add support for more surface formats. To make 
> > > handling
> > > this a bit easier to read, and more future proof, the support for this is 
> > > moved
> > > into the surface formats table.
> > > 
> > > Along with the modifications to the table, a helper function is also 
> > > provided to
> > > determine if a surface is CCS compatible.  Because fast clears are 
> > > currently
> > ^^^
> > Should say "CCS_E".
> 
> I don't understand why you are insisting on calling everything CCS_E.
> Admittedly, the docs aren't crystal clear here, but here is how I understand 
> it.
> For single sample render compression - the thing we're not using yet, you use
> CCS_E. For single sample fast clears, you use CCS_D (with the restriction that
> such surfaces must be supported for render compression when using the 
> sampler).
> For multisample compression, I don't understand the difference. More
> confusingly, the bit we're actually setting in the surface state is CCS_D, so
> the last change you asked me to make (renaming ccs to ccs_e in the table) 
> didn't
> make sense to me - but for the sake of making progress, I just changed it to
> make you happy. However, since you're now asking for another version without
> leaving an R-B, I really must know what is going on in your head. Can you 
> prove
> to me from the docs why it's not accurate to say CCS, or if you must CCS_*, 
> and
> why it is MORE accurate to say CCS_E? I will happily change it for you if you
> give me a convincing answer.

We both misunderstand eachother frequently on this topic. And the poor
hardware documentation doesn't make matters better :/

Next time we're in the same room, let's try to explain to each other our
own understanding of the aux surface. That my unravel the subtle (but
significant) differences between us. I think our understandings mostly
agree on SKL but diverge for older gens.

I retract my "CCS_E" comment above. See my other reply to this patch for
the r-b.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] glsl: split ssbo array copies into element copies

2015-11-20 Thread Jordan Justen
On 2015-11-20 06:48:27, Iago Toral Quiroga wrote:
> Improves register pressure, since otherwise we end up emitting
> loads for all the elements in the RHS and them emitting
> stores for all elements in the LHS.
> 
> Fixes the following piglit test:
> tests/spec/arb_shader_storage_buffer_object/execution/large-field-copy.shader_test
> ---
> 
> Jordan, this fixes the link failure for the the test you provided. Needs more
> testing and I have to check if I need to do something for structs that contain
> arrays too, etc I'll do that on Monday unless someone else comes with a better
> idea to fix this.
> 
>  src/glsl/lower_ubo_reference.cpp | 61 
> 
>  1 file changed, 61 insertions(+)
> 
> diff --git a/src/glsl/lower_ubo_reference.cpp 
> b/src/glsl/lower_ubo_reference.cpp
> index b74aa3d..7d48960 100644
> --- a/src/glsl/lower_ubo_reference.cpp
> +++ b/src/glsl/lower_ubo_reference.cpp
> @@ -154,6 +154,7 @@ public:
> ir_call *ssbo_load(const struct glsl_type *type,
>ir_rvalue *offset);
>  
> +   bool check_for_ssbo_array_copy(ir_assignment *ir);
> void check_for_ssbo_store(ir_assignment *ir);
> void write_to_memory(ir_dereference *deref,
>  ir_variable *var,
> @@ -1133,9 +1134,69 @@ 
> lower_ubo_reference_visitor::check_for_ssbo_store(ir_assignment *ir)
>  }
>  
>  
> +bool
> +lower_ubo_reference_visitor::check_for_ssbo_array_copy(ir_assignment *ir)
> +{
> +   if (!ir || !ir->lhs || !ir->rhs)
> +  return false;
> +
> +   ir_dereference *rhs_deref = ir->rhs->as_dereference();
> +   if (!rhs_deref)
> +  return false;
> +
> +   ir_dereference *lhs_deref = ir->lhs->as_dereference();
> +   if (!lhs_deref)
> +  return false;
> +
> +   /* LHS and RHS must be SSBO variables */

Must they? In fact, the issue that prompted this was a copy from an
SSBO to a CS shared variable in the ES3.1 CTS. Maybe just the source
or dest being an SSBO is good enough?

Also, I just re-sent a piglit patch. In this case I just focused on
testing that the shader linked. I tried the 'array' version with this
patch, and it hit an assertion in nir_validate.

The copy 'struct' version still fails to register allocate.

-Jordan

> +   ir_variable *lhs_var = ir->lhs->variable_referenced();
> +   if (!lhs_var || !lhs_var->is_in_shader_storage_block())
> +  return false;
> +
> +   ir_variable *rhs_var = ir->rhs->variable_referenced();
> +   if (!rhs_var || !rhs_var->is_in_shader_storage_block())
> +  return false;
> +
> +   /* LHS and RHS must be variable dereferences.
> +* FIXME: arrays of arrays?
> +*/
> +   if (!ir->lhs->as_dereference_variable() ||
> +   !ir->rhs->as_dereference_variable())
> +  return false;
> +
> +   /* LHS and RHS must be arrays */
> +   if (!rhs_var->type->is_array() || !lhs_var->type->is_array())
> +  return false;
> +
> +   assert(lhs_deref->type->length == rhs_deref->type->length);
> +
> +   for (unsigned i = 0; i < lhs_deref->type->length; i++) {
> +  ir_dereference *lhs_i =
> + new(mem_ctx) ir_dereference_array(lhs_deref->clone(mem_ctx, NULL),
> +   new(mem_ctx) ir_constant(i));
> +
> +  ir_dereference *rhs_i =
> + new(mem_ctx) ir_dereference_array(rhs_deref->clone(mem_ctx, NULL),
> +   new(mem_ctx) ir_constant(i));
> +  ir->insert_after(assign(lhs_i, rhs_i));
> +   }
> +
> +   ir->remove();
> +   return true;
> +}
> +
>  ir_visitor_status
>  lower_ubo_reference_visitor::visit_enter(ir_assignment *ir)
>  {
> +   /* Array copies could involve large amounts of SSBO load/store
> +* operations. To improve register pressure we want to special-case
> +* this and split the array copy into many individual element copies.
> +* This way we avoid emitting all the loads for the RHS first and
> +* all the writes for the LHS second.
> +*/
> +   if (check_for_ssbo_array_copy(ir))
> +  return visit_continue_with_parent;
> +
> check_ssbo_unsized_array_length_assignment(ir);
> check_for_ssbo_store(ir);
> return rvalue_visit(ir);
> -- 
> 1.9.1
> 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v2 1/2] mesa: Add KBL PCI IDs and platform information.

2015-11-20 Thread Ilia Mirkin
On Fri, Nov 20, 2015 at 2:01 PM, Ben Widawsky  wrote:
>> > FWIW I wholeheartedly agree with this line of reasoning. I never put
>> > the version info into my commits either, and find it
>> > confusing/misleading when others do. I want to know the final state of
>> > things when looking at the commit 1 year from now, not the 20-step
>> > process and all the wrong turns to get there.
>
> When I'm lazy, the commit message doesn't reflect the final state and you need
> to read through the version info to get the end result. That is not great
> because I am usually lazy. However aside from that case, I don't see what is
> confusing about it - it's at the bottom. Don't read it if you don't want to.

That's the problem -- with the revision history in there, it's really
tempting not to update the original. And then I'm stuck reading
sequences of "do; undo; do; undo" and figuring out what the last
desired state was. If there's no version history, then you're stuck
making sure that the commit description matches reality.

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


[Mesa-dev] [PATCH 1/2] nv50: expose two groups of compute-related MP perf counters

2015-11-20 Thread Samuel Pitoiset
This turns on GL_AMD_performance_monitor.

Signed-off-by: Samuel Pitoiset 
---
 src/gallium/drivers/nouveau/nv50/nv50_query.c  | 52 ++
 src/gallium/drivers/nouveau/nv50/nv50_query.h  |  6 +++
 .../drivers/nouveau/nv50/nv50_query_hw_metric.c|  2 +-
 .../drivers/nouveau/nv50/nv50_query_hw_sm.c|  2 +-
 src/gallium/drivers/nouveau/nv50/nv50_screen.c |  1 +
 src/gallium/drivers/nouveau/nv50/nv50_screen.h |  2 +
 6 files changed, 63 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nv50/nv50_query.c 
b/src/gallium/drivers/nouveau/nv50/nv50_query.c
index 6b3e49a..4cd3b61 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_query.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_query.c
@@ -27,6 +27,8 @@
 #include "nv50/nv50_context.h"
 #include "nv50/nv50_query.h"
 #include "nv50/nv50_query_hw.h"
+#include "nv50/nv50_query_hw_metric.h"
+#include "nv50/nv50_query_hw_sm.h"
 
 static struct pipe_query *
 nv50_create_query(struct pipe_context *pipe, unsigned type, unsigned index)
@@ -178,3 +180,53 @@ nv50_screen_get_driver_query_info(struct pipe_screen 
*pscreen,
 
return nv50_hw_get_driver_query_info(screen, id, info);
 }
+
+int
+nv50_screen_get_driver_query_group_info(struct pipe_screen *pscreen,
+unsigned id,
+struct pipe_driver_query_group_info 
*info)
+{
+   struct nv50_screen *screen = nv50_screen(pscreen);
+   int count = 0;
+
+   if (screen->compute)
+  if (screen->base.class_3d >= NV84_3D_CLASS)
+ count += 2;
+
+   if (!info)
+  return count;
+
+   if (id == NV50_HW_SM_QUERY_GROUP) {
+  if (screen->compute) {
+ if (screen->base.class_3d >= NV84_3D_CLASS) {
+info->name = "MP counters";
+
+/* Because we can't expose the number of hardware counters needed
+ * for each different query, we don't want to allow more than one
+ * active query simultaneously to avoid failure when the maximum
+ * number of counters is reached. Note that these groups of GPU
+ * counters are currently only used by AMD_performance_monitor.
+ */
+info->max_active_queries = 1;
+info->num_queries = NV50_HW_SM_QUERY_COUNT;
+return 1;
+ }
+  }
+   } else
+   if (id == NV50_HW_METRIC_QUERY_GROUP) {
+  if (screen->compute) {
+ if (screen->base.class_3d >= NV84_3D_CLASS) {
+info->name = "Performance metrics";
+info->max_active_queries = 1;
+info->num_queries = NV50_HW_METRIC_QUERY_COUNT;
+return 1;
+ }
+  }
+   }
+
+   /* user asked for info about non-existing query group */
+   info->name = "this_is_not_the_query_group_you_are_looking_for";
+   info->max_active_queries = 0;
+   info->num_queries = 0;
+   return 0;
+}
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_query.h 
b/src/gallium/drivers/nouveau/nv50/nv50_query.h
index d990285..bd4c0a3 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_query.h
+++ b/src/gallium/drivers/nouveau/nv50/nv50_query.h
@@ -28,6 +28,12 @@ nv50_query(struct pipe_query *pipe)
return (struct nv50_query *)pipe;
 }
 
+/*
+ * Driver queries groups:
+ */
+#define NV50_HW_SM_QUERY_GROUP   0
+#define NV50_HW_METRIC_QUERY_GROUP   1
+
 void nv50_init_query_functions(struct nv50_context *);
 
 #endif
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_query_hw_metric.c 
b/src/gallium/drivers/nouveau/nv50/nv50_query_hw_metric.c
index 13dad30..d1bccb9 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_query_hw_metric.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_query_hw_metric.c
@@ -198,7 +198,7 @@ nv50_hw_metric_get_driver_query_info(struct nv50_screen 
*screen, unsigned id,
  if (screen->base.class_3d >= NV84_3D_CLASS) {
 info->name = nv50_hw_metric_names[id];
 info->query_type = NV50_HW_METRIC_QUERY(id);
-info->group_id = -1;
+info->group_id = NV50_HW_METRIC_QUERY_GROUP;
 return 1;
  }
   }
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_query_hw_sm.c 
b/src/gallium/drivers/nouveau/nv50/nv50_query_hw_sm.c
index e75b428..8453ce7 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_query_hw_sm.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_query_hw_sm.c
@@ -408,7 +408,7 @@ nv50_hw_sm_get_driver_query_info(struct nv50_screen 
*screen, unsigned id,
  if (screen->base.class_3d >= NV84_3D_CLASS) {
 info->name = nv50_hw_sm_query_names[id];
 info->query_type = NV50_HW_SM_QUERY(id);
-info->group_id = -1;
+info->group_id = NV50_HW_SM_QUERY_GROUP;
 return 1;
  }
   }
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c 
b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
index cc7984d..1e4b75f 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nouveau/nv50

[Mesa-dev] [PATCH 2/2] docs: mark GL_AMD_performance_monitor for nv50

2015-11-20 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 docs/relnotes/11.1.0.html | 1 +
 1 file changed, 1 insertion(+)

diff --git a/docs/relnotes/11.1.0.html b/docs/relnotes/11.1.0.html
index 2f462f7..204a665 100644
--- a/docs/relnotes/11.1.0.html
+++ b/docs/relnotes/11.1.0.html
@@ -45,6 +45,7 @@ Note: some of the new features are only available with 
certain drivers.
 
 
 OpenGL 3.1 support on freedreno (a3xx, a4xx)
+GL_AMD_performance_monitor on nv50
 GL_ARB_arrays_of_arrays on i965
 GL_ARB_blend_func_extended on freedreno (a3xx)
 GL_ARB_clear_texture on nv50, nvc0
-- 
2.5.3

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


Re: [Mesa-dev] [PATCH 1/2] nv50: expose two groups of compute-related MP perf counters

2015-11-20 Thread Ilia Mirkin
Series is Acked-by: Ilia Mirkin  . TBH I haven't
spent the time to figure out what all this stuff is, but these changes
appear to be internally consistent :)

On Fri, Nov 20, 2015 at 2:28 PM, Samuel Pitoiset
 wrote:
> This turns on GL_AMD_performance_monitor.
>
> Signed-off-by: Samuel Pitoiset 
> ---
>  src/gallium/drivers/nouveau/nv50/nv50_query.c  | 52 
> ++
>  src/gallium/drivers/nouveau/nv50/nv50_query.h  |  6 +++
>  .../drivers/nouveau/nv50/nv50_query_hw_metric.c|  2 +-
>  .../drivers/nouveau/nv50/nv50_query_hw_sm.c|  2 +-
>  src/gallium/drivers/nouveau/nv50/nv50_screen.c |  1 +
>  src/gallium/drivers/nouveau/nv50/nv50_screen.h |  2 +
>  6 files changed, 63 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_query.c 
> b/src/gallium/drivers/nouveau/nv50/nv50_query.c
> index 6b3e49a..4cd3b61 100644
> --- a/src/gallium/drivers/nouveau/nv50/nv50_query.c
> +++ b/src/gallium/drivers/nouveau/nv50/nv50_query.c
> @@ -27,6 +27,8 @@
>  #include "nv50/nv50_context.h"
>  #include "nv50/nv50_query.h"
>  #include "nv50/nv50_query_hw.h"
> +#include "nv50/nv50_query_hw_metric.h"
> +#include "nv50/nv50_query_hw_sm.h"
>
>  static struct pipe_query *
>  nv50_create_query(struct pipe_context *pipe, unsigned type, unsigned index)
> @@ -178,3 +180,53 @@ nv50_screen_get_driver_query_info(struct pipe_screen 
> *pscreen,
>
> return nv50_hw_get_driver_query_info(screen, id, info);
>  }
> +
> +int
> +nv50_screen_get_driver_query_group_info(struct pipe_screen *pscreen,
> +unsigned id,
> +struct pipe_driver_query_group_info 
> *info)
> +{
> +   struct nv50_screen *screen = nv50_screen(pscreen);
> +   int count = 0;
> +
> +   if (screen->compute)
> +  if (screen->base.class_3d >= NV84_3D_CLASS)
> + count += 2;
> +
> +   if (!info)
> +  return count;
> +
> +   if (id == NV50_HW_SM_QUERY_GROUP) {
> +  if (screen->compute) {
> + if (screen->base.class_3d >= NV84_3D_CLASS) {
> +info->name = "MP counters";
> +
> +/* Because we can't expose the number of hardware counters needed
> + * for each different query, we don't want to allow more than one
> + * active query simultaneously to avoid failure when the maximum
> + * number of counters is reached. Note that these groups of GPU
> + * counters are currently only used by AMD_performance_monitor.
> + */
> +info->max_active_queries = 1;
> +info->num_queries = NV50_HW_SM_QUERY_COUNT;
> +return 1;
> + }
> +  }
> +   } else
> +   if (id == NV50_HW_METRIC_QUERY_GROUP) {
> +  if (screen->compute) {
> + if (screen->base.class_3d >= NV84_3D_CLASS) {
> +info->name = "Performance metrics";
> +info->max_active_queries = 1;
> +info->num_queries = NV50_HW_METRIC_QUERY_COUNT;
> +return 1;
> + }
> +  }
> +   }
> +
> +   /* user asked for info about non-existing query group */
> +   info->name = "this_is_not_the_query_group_you_are_looking_for";
> +   info->max_active_queries = 0;
> +   info->num_queries = 0;
> +   return 0;
> +}
> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_query.h 
> b/src/gallium/drivers/nouveau/nv50/nv50_query.h
> index d990285..bd4c0a3 100644
> --- a/src/gallium/drivers/nouveau/nv50/nv50_query.h
> +++ b/src/gallium/drivers/nouveau/nv50/nv50_query.h
> @@ -28,6 +28,12 @@ nv50_query(struct pipe_query *pipe)
> return (struct nv50_query *)pipe;
>  }
>
> +/*
> + * Driver queries groups:
> + */
> +#define NV50_HW_SM_QUERY_GROUP   0
> +#define NV50_HW_METRIC_QUERY_GROUP   1
> +
>  void nv50_init_query_functions(struct nv50_context *);
>
>  #endif
> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_query_hw_metric.c 
> b/src/gallium/drivers/nouveau/nv50/nv50_query_hw_metric.c
> index 13dad30..d1bccb9 100644
> --- a/src/gallium/drivers/nouveau/nv50/nv50_query_hw_metric.c
> +++ b/src/gallium/drivers/nouveau/nv50/nv50_query_hw_metric.c
> @@ -198,7 +198,7 @@ nv50_hw_metric_get_driver_query_info(struct nv50_screen 
> *screen, unsigned id,
>   if (screen->base.class_3d >= NV84_3D_CLASS) {
>  info->name = nv50_hw_metric_names[id];
>  info->query_type = NV50_HW_METRIC_QUERY(id);
> -info->group_id = -1;
> +info->group_id = NV50_HW_METRIC_QUERY_GROUP;
>  return 1;
>   }
>}
> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_query_hw_sm.c 
> b/src/gallium/drivers/nouveau/nv50/nv50_query_hw_sm.c
> index e75b428..8453ce7 100644
> --- a/src/gallium/drivers/nouveau/nv50/nv50_query_hw_sm.c
> +++ b/src/gallium/drivers/nouveau/nv50/nv50_query_hw_sm.c
> @@ -408,7 +408,7 @@ nv50_hw_sm_get_driver_query_info(struct nv50_screen 
> *screen, unsigned id,
>   if (screen->base.class_3d >= NV84_3D_CLASS) {
>  i

Re: [Mesa-dev] [PATCH] [v2] i965: Add lossless compression to surface format table

2015-11-20 Thread Ben Widawsky
On Fri, Nov 20, 2015 at 11:02:43AM -0800, Chad Versace wrote:
> On Wed 18 Nov 2015, Ben Widawsky wrote:
> > On Wed, Nov 18, 2015 at 10:28:27AM -0800, Chad Versace wrote:
> > > On Tue 17 Nov 2015, Ben Widawsky wrote:
> > > > Background: Prior to Skylake and since Ivybridge Intel hardware has had 
> > > > the
> > > > ability to use a MCS (Multisample Control Surface) as auxiliary data in
> > > > "compression" operations on the surface. This reduces memory bandwidth. 
> > > >  This
> > > > hardware was either used for MSAA compression, and fast clear 
> > > > operations.  On
> > > > Gen8, a similar mechanism exists to allow the hiz buffer to be sampled 
> > > > from, and
> > > > therefore this feature is sometimes referred to more generally as "AUX 
> > > > buffers".
> > > > 
> > > > Skylake adds the ability to have the display engine directly source 
> > > > compressed
> > > > surfaces on top of the ability to sample from them. Inference dictates 
> > > > that
> > > > enabling this display features adding a restriction to the formats 
> > > > which could
> > > > actually be compressed. The current set of surfaces seems to be a 
> > > > subset as
> > > > compared to previous gens (see the next patch). Also, if I had to guess 
> > > > I would
> > > > guess that future gens add support for more surface formats. To make 
> > > > handling
> > > > this a bit easier to read, and more future proof, the support for this 
> > > > is moved
> > > > into the surface formats table.
> > > > 
> > > > Along with the modifications to the table, a helper function is also 
> > > > provided to
> > > > determine if a surface is CCS compatible.  Because fast clears are 
> > > > currently
> > > ^^^
> > > Should say "CCS_E".
> > 
> > I don't understand why you are insisting on calling everything CCS_E.
> > Admittedly, the docs aren't crystal clear here, but here is how I 
> > understand it.
> > For single sample render compression - the thing we're not using yet, you 
> > use
> > CCS_E. For single sample fast clears, you use CCS_D (with the restriction 
> > that
> > such surfaces must be supported for render compression when using the 
> > sampler).
> > For multisample compression, I don't understand the difference. More
> > confusingly, the bit we're actually setting in the surface state is CCS_D, 
> > so
> > the last change you asked me to make (renaming ccs to ccs_e in the table) 
> > didn't
> > make sense to me - but for the sake of making progress, I just changed it to
> > make you happy. However, since you're now asking for another version without
> > leaving an R-B, I really must know what is going on in your head. Can you 
> > prove
> > to me from the docs why it's not accurate to say CCS, or if you must CCS_*, 
> > and
> > why it is MORE accurate to say CCS_E? I will happily change it for you if 
> > you
> > give me a convincing answer.
> 
> We both misunderstand eachother frequently on this topic. And the poor
> hardware documentation doesn't make matters better :/
> 
> Next time we're in the same room, let's try to explain to each other our
> own understanding of the aux surface. That my unravel the subtle (but
> significant) differences between us. I think our understandings mostly
> agree on SKL but diverge for older gens.
> 
> I retract my "CCS_E" comment above. See my other reply to this patch for
> the r-b.

Even though it's airing some dirty laundry, I'm keeping the list on the Cc
because I think it clarifies things and it might benefit Topi and Tapani who
will be doing the render compression work...

I was talking to Topi this morning and he helped me see something which you may
or may not be thinking that helped me understand why you made the request to
name is CCS_E. Summing up my conversation with him, the last round of changes
you had me make (prior to this one) seemed extremely trivial and benign
to me at the time. Those changes were mostly renames, but it had a sweeping
impact on how the patches "worked." With the last round of changes, we are
indeed tracking CCS_E support, which was never my intention and therefore the
big source of confusion for me. With that, I do understand your request to name
things CCS_E even though it's not the direction I wanted to go in the first
place - it's too late now and I didn't put up the fight for the thing that
mattered which turns out to be the simple renaming of the column in
surface_formats[] from ccs to ccs_e.

Thank you for the review. Even with my new found understand, since we're at this
stage, I'd really like to just push things as is. I feel like if I dig any more
it will just unearth more issues with wording or other similar things which
really don't matter to the actual quality of the driver we are shipping.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] Patchwork admin rights

2015-11-20 Thread Emil Velikov
On 13 November 2015 at 12:56, Ilia Mirkin  wrote:
> On Fri, Nov 13, 2015 at 7:40 AM, Emil Velikov  
> wrote:
>> On 13 November 2015 at 12:34, Antía Puentes  wrote:
>>> On vie, 2015-11-13 at 13:26 +0100, Samuel Iglesias Gonsálvez wrote:
 Hello,

 I would like to have admin permissions to Mesa and Piglit projects in
 patchwork [0] to change the status of patches that are mine but they
 are not assigned to me.
>>>
>>> As Samuel, I would like to have admin permissions in patchwork for Mesa
>>> and Piglit,
>>> for the same reasons that he commented.
>>>
>> One can change the status of their patches without admin permissions.
>> They (patches) don't have be to assigned to you or anything. As long
>> as you're registered/login with the same email as the one sending the
>> patches, you should be good to go :-)
>
> No bulk tools without admin permissions, makes the thing basically
> useless. Have to go into each patch.

Fwiw this is no longer an issue - non-maintainers can do bulk change
of their patches as pointed by Damien [1]

-Emil

[1] https://github.com/dlespiau/patchwork/issues/82
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [Mesa-stable] [PATCH] i965: Fix JIP to properly skip over unrelated control flow.

2015-11-20 Thread Kenneth Graunke
On Friday, November 20, 2015 05:36:35 PM Francisco Jerez wrote:
> Kenneth Graunke  writes:
> 
> > On Friday, November 20, 2015 02:38:10 PM Francisco Jerez wrote:
> >> Kenneth Graunke  writes:
> >> 
> >> > On Thursday, November 19, 2015 02:05:44 PM Kenneth Graunke wrote:
> >> >> We've apparently always been botching JIP for sequences such as:
> >> >> 
> >> >>do
> >> >>cmp.f0.0 ...
> >> >>(+f0.0) break
> >> >>...
> >> >>if
> >> >>   ...
> >> >>else
> >> >>   ...
> >> >>endif
> >> >>...
> >> >>while
> >> >> 
> >> >> Normally, UIP is supposed to point to the final destination of the jump,
> >> >> while in nested control flow, JIP is supposed to point to the end of the
> >> >> current nesting level.  It essentially bounces out of the current nested
> >> >> control flow, to an instruction that has a JIP which bounces out another
> >> >> level, and so on.
> >> >> 
> >> >> In the above example, when setting JIP for the BREAK, we call
> >> >> brw_find_next_block_end(), which begins a search after the BREAK for the
> >> >> next ENDIF, ELSE, WHILE, or HALT.  It ignores the IF and finds the ELSE,
> >> >> setting JIP there.
> >> >> 
> >> >> This makes no sense at all.  The break is supposed to skip over the
> >> >> whole if/else/endif block entirely.  They have a sibling relationship,
> >> >> not a nesting relationship.
> >> >> 
> >> >> This patch fixes brw_find_next_block_end() to track depth as it does
> >> >> its search, and ignore anything not at depth 0.  So when it sees the
> >> >> IF, it ignores everything until after the ENDIF.  That way, it finds
> >> >> the end of the right block.
> >> >> 
> >> >> Caught while debugging a tessellation shader - no apparent effect on
> >> >> Piglit.  I did look for actual applications that were affected, and
> >> >> found that GLBenchmark Manhattan had a BREAK with a bogus JIP.
> >> >> 
> >> >> Cc: mesa-sta...@lists.freedesktop.org
> >> >> Signed-off-by: Kenneth Graunke 
> >> >
> >> > I tried pretty hard to produce a Piglit test that showed an actual
> >> > problem from doing this wrong - and I wasn't able to.
> >> >
> >> > It seems it just steps through some extra instructions which do
> >> > nothing, and is pretty harmless.
> >> >
> >> From my understanding of how control flow is implemented, jumping to the
> >> ENDIF instruction of an inactive IF-ENDIF construct (or similarly to the
> >> WHILE instruction of an inactive loop) is fully equivalent to jumping to
> >> the same point of an active (i.e. properly nested) but non-diverging
> >> IF-ENDIF construct, and will behave the same: It will have no effect on
> >> the current per-channel enables (because the IP of the ENDIF instruction
> >> won't match the UIP value present at the top of the stack), and for that
> >> reason will go on and jump to the instruction pointed to by the JIP
> >> value of the ENDIF, which will be another ENDIF/WHILE/HALT instruction
> >> closer to the right ENDIF/WHILE instruction that closes the current
> >> block.
> >> 
> >> > So I don't think this should actually go to stable after all.
> >> >
> >> Yeah, seems pretty harmless -- If it weren't harmeless you'd also need
> >> to apply a similar fix to WHILE loops, but I don't think you do.
> >
> > Thanks, Curro!  I appreciate you confirming the theory :)
> >
> > I haven't pushed the patch yet, so would you like to add a Reviewed-by?
> >
> > What WHILE fix are you thinking of?  We may as well get it right, even
> > if it is harmless.  At a cursory glance, I didn't see anything wrong,
> > as it uses the loop stack.  But I might've missed something...
> 
> Hmm, does it?  AFAICT brw_find_next_block_end() will just give you the
> first WHILE instruction it finds even if the corresponding loop starts
> after the given offset.  Not that it matters much anyway.

Ahh.  I thought you meant the code for patching WHILE's JIP was
similarly broken.  But you're right, I think as is,


DO
   CMP.f0.0 ...
   (+f0.0) BREAK

   ...

   DO
  ...
   WHILE

   ...
WHILE

will make the BREAK point to the first WHILE instead of the second.
The obvious fix would be to handle DO just like I handle IF.
Unfortunately, there is no DO instruction...and at this point, the
loop stack is gone.

I suppose one fix would be to make brw_find_next_block_end() only
accept a WHILE as the end of the block if the WHILE's jump target
is before our starting offset.  In other words, if the WHILE's
top-of-the-loop is after our BREAK/CONTINUE, it is obviously the
wrong loop.  (This works because WHILE's jumps are set as soon as
we emit the WHILE, so they're already in place by brw_set_uip_jip.)

I think that would work, but it would at least need a comment.


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


[Mesa-dev] [PATCH v2 08/40] pipe-loader: remove HAVE_DRM_LOADER_GALLIUM and HAVE_PIPE_LOADER_DRM

2015-11-20 Thread Emil Velikov
... in favour of HAVE_LIBDRM. After all we solely want to build the code
when the latter is available.

In the not too distant future we will remove the libudev/sysfs
dependency and simplify configure.ac even further.

Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 configure.ac| 9 -
 src/gallium/auxiliary/pipe-loader/Makefile.am   | 2 +-
 src/gallium/auxiliary/pipe-loader/pipe_loader.c | 2 +-
 3 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/configure.ac b/configure.ac
index 322f7b6..55c0501 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2077,10 +2077,6 @@ gallium_require_drm_loader() {
 if test "x$need_pci_id$have_pci_id" = xyesno; then
 AC_MSG_ERROR([Gallium drm loader requires libudev >= 
$LIBUDEV_REQUIRED or sysfs])
 fi
-enable_gallium_drm_loader=yes
-fi
-if test "x$enable_va" = xyes && test "x$7" != x; then
- GALLIUM_TARGET_DIRS="$GALLIUM_TARGET_DIRS $7"
 fi
 }
 
@@ -2287,10 +2283,6 @@ if test "x$enable_gallium_loader" = xyes; then
 GALLIUM_PIPE_LOADER_DEFINES="$GALLIUM_PIPE_LOADER_DEFINES 
-DHAVE_PIPE_LOADER_KMS"
 fi
 
-if test "x$enable_gallium_drm_loader" = xyes; then
-GALLIUM_PIPE_LOADER_DEFINES="$GALLIUM_PIPE_LOADER_DEFINES 
-DHAVE_PIPE_LOADER_DRM"
-fi
-
 AC_SUBST([GALLIUM_PIPE_LOADER_DEFINES])
 fi
 
@@ -2308,7 +2300,6 @@ AM_CONDITIONAL(NEED_WINSYS_XLIB, test 
"x$NEED_WINSYS_XLIB" = xyes)
 AM_CONDITIONAL(NEED_RADEON_LLVM, test x$NEED_RADEON_LLVM = xyes)
 AM_CONDITIONAL(USE_R600_LLVM_COMPILER, test x$USE_R600_LLVM_COMPILER = xyes)
 AM_CONDITIONAL(HAVE_LOADER_GALLIUM, test x$enable_gallium_loader = xyes)
-AM_CONDITIONAL(HAVE_DRM_LOADER_GALLIUM, test x$enable_gallium_drm_loader = 
xyes)
 AM_CONDITIONAL(HAVE_GALLIUM_COMPUTE, test x$enable_opencl = xyes)
 AM_CONDITIONAL(HAVE_MESA_LLVM, test x$MESA_LLVM = x1)
 AM_CONDITIONAL(USE_VC4_SIMULATOR, test x$USE_VC4_SIMULATOR = xyes)
diff --git a/src/gallium/auxiliary/pipe-loader/Makefile.am 
b/src/gallium/auxiliary/pipe-loader/Makefile.am
index 8c83799..e12620c 100644
--- a/src/gallium/auxiliary/pipe-loader/Makefile.am
+++ b/src/gallium/auxiliary/pipe-loader/Makefile.am
@@ -14,7 +14,7 @@ noinst_LTLIBRARIES = libpipe_loader.la
 libpipe_loader_la_SOURCES = \
$(COMMON_SOURCES)
 
-if HAVE_DRM_LOADER_GALLIUM
+if HAVE_LIBDRM
 AM_CFLAGS += \
$(LIBDRM_CFLAGS)
 
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.c 
b/src/gallium/auxiliary/pipe-loader/pipe_loader.c
index 8e79f85..0ca2e8c 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.c
@@ -35,7 +35,7 @@
 #define MODULE_PREFIX "pipe_"
 
 static int (*backends[])(struct pipe_loader_device **, int) = {
-#ifdef HAVE_PIPE_LOADER_DRM
+#ifdef HAVE_LIBDRM
&pipe_loader_drm_probe,
 #endif
&pipe_loader_sw_probe
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 28/40] pipe-loader: add preliminary Android support

2015-11-20 Thread Emil Velikov
Add a 'static' pipe-loader build, which will be used with follow-up
commits.

Signed-off-by: Emil Velikov 
Reviewed-by: Chih-Wei Huang 
Acked-by: Rob Clark 
---
 src/gallium/Android.mk   |  1 +
 src/gallium/auxiliary/pipe-loader/Android.mk | 49 
 2 files changed, 50 insertions(+)
 create mode 100644 src/gallium/auxiliary/pipe-loader/Android.mk

diff --git a/src/gallium/Android.mk b/src/gallium/Android.mk
index 39e064e..b406d4a 100644
--- a/src/gallium/Android.mk
+++ b/src/gallium/Android.mk
@@ -27,6 +27,7 @@ GALLIUM_TOP := $(call my-dir)
 GALLIUM_COMMON_MK := $(GALLIUM_TOP)/Android.common.mk
 
 SUBDIRS := auxiliary
+SUBDIRS += auxiliary/pipe-loader
 
 #
 # Gallium drivers and their respective winsys
diff --git a/src/gallium/auxiliary/pipe-loader/Android.mk 
b/src/gallium/auxiliary/pipe-loader/Android.mk
new file mode 100644
index 000..2789313
--- /dev/null
+++ b/src/gallium/auxiliary/pipe-loader/Android.mk
@@ -0,0 +1,49 @@
+# Mesa 3-D graphics library
+#
+# Copyright (C) 2015 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.
+
+# NOTE: Currently we build only a 'static' pipe-loader
+LOCAL_PATH := $(call my-dir)
+
+# get COMMON_SOURCES and DRM_SOURCES
+include $(LOCAL_PATH)/Makefile.sources
+
+include $(CLEAR_VARS)
+
+LOCAL_CFLAGS := \
+   -DHAVE_PIPE_LOADER_DRI \
+   -DDROP_PIPE_LOADER_MISC \
+   -DGALLIUM_STATIC_TARGETS
+
+LOCAL_SRC_FILES := $(COMMON_SOURCES)
+
+LOCAL_MODULE := libmesa_pipe_loader
+
+ifneq ($(filter-out swrast,$(MESA_GPU_DRIVERS)),)
+LOCAL_CFLAGS += -DHAVE_LIBDRM
+LOCAL_SRC_FILES += $(DRM_SOURCES)
+
+LOCAL_SHARED_LIBRARIES := libdrm
+LOCAL_STATIC_LIBRARIES := libmesa_loader
+endif
+
+include $(GALLIUM_COMMON_MK)
+include $(BUILD_STATIC_LIBRARY)
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 29/40] {st, targets}/dri: use static/dynamic pipe-loader

2015-11-20 Thread Emil Velikov
Covert DRI to use only the pipe-loader interface.

With drisw_create_screen and kms_swrast_create_screen replaced by their
pipe-loader equivalent, we can now drop them.

Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 .../auxiliary/target-helpers/inline_drm_helper.h   | 24 ---
 .../auxiliary/target-helpers/inline_sw_helper.h| 28 --
 src/gallium/drivers/softpipe/Automake.inc  |  3 ---
 src/gallium/state_trackers/dri/Android.mk  |  3 ---
 src/gallium/state_trackers/dri/Makefile.am |  5 
 src/gallium/state_trackers/dri/SConscript  |  4 
 src/gallium/state_trackers/dri/dri2.c  | 20 
 src/gallium/state_trackers/dri/dri_screen.c|  2 --
 src/gallium/state_trackers/dri/drisw.c | 12 ++
 src/gallium/targets/dri/Android.mk |  1 +
 src/gallium/targets/dri/Makefile.am|  7 --
 src/gallium/targets/dri/SConscript |  1 +
 src/gallium/targets/dri/target.c   |  3 +--
 13 files changed, 19 insertions(+), 94 deletions(-)

diff --git a/src/gallium/auxiliary/target-helpers/inline_drm_helper.h 
b/src/gallium/auxiliary/target-helpers/inline_drm_helper.h
index 55f6363..c57fbac 100644
--- a/src/gallium/auxiliary/target-helpers/inline_drm_helper.h
+++ b/src/gallium/auxiliary/target-helpers/inline_drm_helper.h
@@ -4,9 +4,6 @@
 #include "state_tracker/drm_driver.h"
 #include "target-helpers/inline_debug_helper.h"
 #include "loader.h"
-#if defined(DRI_TARGET)
-#include "dri_screen.h"
-#endif
 
 #if GALLIUM_SOFTPIPE
 #include "target-helpers/inline_sw_helper.h"
@@ -68,27 +65,6 @@ static char* driver_name = NULL;
 
 /* XXX: We need to teardown the winsys if *screen_create() fails. */
 
-#if defined(GALLIUM_SOFTPIPE)
-#if defined(DRI_TARGET)
-#if defined(HAVE_LIBDRM)
-
-struct pipe_screen *
-kms_swrast_create_screen(int fd)
-{
-   struct sw_winsys *sws;
-   struct pipe_screen *screen;
-
-   sws = kms_dri_create_winsys(fd);
-   if (!sws)
-  return NULL;
-
-   screen = sw_screen_create(sws);
-   return screen ? debug_screen_wrap(screen) : NULL;
-}
-#endif
-#endif
-#endif
-
 #if defined(GALLIUM_I915)
 
 static struct pipe_screen *
diff --git a/src/gallium/auxiliary/target-helpers/inline_sw_helper.h 
b/src/gallium/auxiliary/target-helpers/inline_sw_helper.h
index 16937bc..a9ab16f 100644
--- a/src/gallium/auxiliary/target-helpers/inline_sw_helper.h
+++ b/src/gallium/auxiliary/target-helpers/inline_sw_helper.h
@@ -69,32 +69,4 @@ sw_screen_create(struct sw_winsys *winsys)
return sw_screen_create_named(winsys, driver);
 }
 
-#if defined(GALLIUM_SOFTPIPE)
-#if defined(DRI_TARGET)
-#include "target-helpers/inline_debug_helper.h"
-#include "sw/dri/dri_sw_winsys.h"
-
-inline struct pipe_screen *
-drisw_create_screen(struct drisw_loader_funcs *lf)
-{
-   struct sw_winsys *winsys = NULL;
-   struct pipe_screen *screen = NULL;
-
-   winsys = dri_create_sw_winsys(lf);
-   if (winsys == NULL)
-  return NULL;
-
-   screen = sw_screen_create(winsys);
-   if (screen == NULL) {
-  winsys->destroy(winsys);
-  return NULL;
-   }
-
-   screen = debug_screen_wrap(screen);
-   return screen;
-}
-#endif // DRI_TARGET
-#endif // GALLIUM_SOFTPIPE
-
-
 #endif
diff --git a/src/gallium/drivers/softpipe/Automake.inc 
b/src/gallium/drivers/softpipe/Automake.inc
index 5cedcef..bd3c2ee 100644
--- a/src/gallium/drivers/softpipe/Automake.inc
+++ b/src/gallium/drivers/softpipe/Automake.inc
@@ -3,13 +3,10 @@ if HAVE_GALLIUM_SOFTPIPE
 TARGET_DRIVERS += swrast
 TARGET_CPPFLAGS += -DGALLIUM_SOFTPIPE
 TARGET_LIB_DEPS += \
-   $(top_builddir)/src/gallium/winsys/sw/dri/libswdri.la \
$(top_builddir)/src/gallium/drivers/softpipe/libsoftpipe.la
 
 if HAVE_DRISW_KMS
 TARGET_DRIVERS += kms_swrast
-TARGET_LIB_DEPS += \
-   $(top_builddir)/src/gallium/winsys/sw/kms-dri/libswkmsdri.la
 
 endif
 endif
diff --git a/src/gallium/state_trackers/dri/Android.mk 
b/src/gallium/state_trackers/dri/Android.mk
index 43f0de9..f0eb18d 100644
--- a/src/gallium/state_trackers/dri/Android.mk
+++ b/src/gallium/state_trackers/dri/Android.mk
@@ -29,9 +29,6 @@ include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := $(common_SOURCES)
 
-LOCAL_CFLAGS := \
-   -DGALLIUM_STATIC_TARGETS=1 \
-
 LOCAL_C_INCLUDES := \
$(MESA_TOP)/src/mapi \
$(MESA_TOP)/src/mesa \
diff --git a/src/gallium/state_trackers/dri/Makefile.am 
b/src/gallium/state_trackers/dri/Makefile.am
index 102b843..74bccaa 100644
--- a/src/gallium/state_trackers/dri/Makefile.am
+++ b/src/gallium/state_trackers/dri/Makefile.am
@@ -34,15 +34,10 @@ AM_CPPFLAGS = \
$(LIBDRM_CFLAGS) \
$(VISIBILITY_CFLAGS)
 
-if HAVE_GALLIUM_STATIC_TARGETS
-AM_CPPFLAGS += \
-   -DGALLIUM_STATIC_TARGETS=1
-
 if HAVE_GALLIUM_SOFTPIPE
 AM_CPPFLAGS += \
-DGALLIUM_SOFTPIPE
 endif # HAVE_GALLIUM_SOFTPIPE
-endif # HAVE_GALLIUM_STATIC_TARGETS
 
 noinst_LTLIBRARIES = libdri.la
 libdri_la_SOURCES = $(common_SOURC

[Mesa-dev] [PATCH v2 31/40] {st, targets}/xa: use static/dynamic pipe-loader

2015-11-20 Thread Emil Velikov
Analogous to previous commits.

Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/state_trackers/xa/Makefile.am  |  5 -
 src/gallium/state_trackers/xa/xa_tracker.c | 16 ++--
 src/gallium/targets/xa/Makefile.am |  7 +--
 src/gallium/targets/xa/target.c|  2 +-
 4 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/src/gallium/state_trackers/xa/Makefile.am 
b/src/gallium/state_trackers/xa/Makefile.am
index 0d50c27..968778f 100644
--- a/src/gallium/state_trackers/xa/Makefile.am
+++ b/src/gallium/state_trackers/xa/Makefile.am
@@ -28,11 +28,6 @@ AM_CFLAGS = \
$(GALLIUM_CFLAGS) \
$(VISIBILITY_CFLAGS)
 
-if HAVE_GALLIUM_STATIC_TARGETS
-AM_CPPFLAGS = \
-   -DGALLIUM_STATIC_TARGETS=1
-endif
-
 xa_includedir = $(includedir)
 xa_include_HEADERS = \
xa_composite.h \
diff --git a/src/gallium/state_trackers/xa/xa_tracker.c 
b/src/gallium/state_trackers/xa/xa_tracker.c
index 3011598..faa630c 100644
--- a/src/gallium/state_trackers/xa/xa_tracker.c
+++ b/src/gallium/state_trackers/xa/xa_tracker.c
@@ -152,21 +152,13 @@ xa_tracker_create(int drm_fd)
 struct xa_tracker *xa = calloc(1, sizeof(struct xa_tracker));
 enum xa_surface_type stype;
 unsigned int num_formats;
-int loader_fd;
 
 if (!xa)
return NULL;
 
-#if GALLIUM_STATIC_TARGETS
-xa->screen = dd_create_screen(drm_fd);
-(void) loader_fd; /* silence unused var warning */
-#else
-loader_fd = dup(drm_fd);
-if (loader_fd == -1)
-return NULL;
-if (pipe_loader_drm_probe_fd(&xa->dev, loader_fd))
+if (pipe_loader_drm_probe_fd(&xa->dev, dup(drm_fd)))
xa->screen = pipe_loader_create_screen(xa->dev);
-#endif
+
 if (!xa->screen)
goto out_no_screen;
 
@@ -214,10 +206,8 @@ xa_tracker_create(int drm_fd)
  out_no_pipe:
 xa->screen->destroy(xa->screen);
  out_no_screen:
-#if !GALLIUM_STATIC_TARGETS
 if (xa->dev)
pipe_loader_release(&xa->dev, 1);
-#endif
 free(xa);
 return NULL;
 }
@@ -228,9 +218,7 @@ xa_tracker_destroy(struct xa_tracker *xa)
 free(xa->supported_formats);
 xa_context_destroy(xa->default_ctx);
 xa->screen->destroy(xa->screen);
-#if !GALLIUM_STATIC_TARGETS
 pipe_loader_release(&xa->dev, 1);
-#endif
 free(xa);
 }
 
diff --git a/src/gallium/targets/xa/Makefile.am 
b/src/gallium/targets/xa/Makefile.am
index 545d17e..a63fd69 100644
--- a/src/gallium/targets/xa/Makefile.am
+++ b/src/gallium/targets/xa/Makefile.am
@@ -60,7 +60,7 @@ if HAVE_GALLIUM_STATIC_TARGETS
 
 TARGET_DRIVERS =
 TARGET_CPPFLAGS =
-TARGET_LIB_DEPS = $(top_builddir)/src/loader/libloader.la
+TARGET_LIB_DEPS =
 
 include $(top_srcdir)/src/gallium/drivers/i915/Automake.inc
 
@@ -74,7 +74,10 @@ include 
$(top_srcdir)/src/gallium/drivers/freedreno/Automake.inc
 
 libxatracker_la_SOURCES += target.c
 libxatracker_la_CPPFLAGS = $(TARGET_CPPFLAGS)
-libxatracker_la_LIBADD += $(TARGET_LIB_DEPS)
+libxatracker_la_LIBADD += \
+   
$(top_builddir)/src/gallium/auxiliary/pipe-loader/libpipe_loader_static.la \
+   $(GALLIUM_PIPE_LOADER_WINSYS_LIBS) \
+   $(TARGET_LIB_DEPS)
 
 else # HAVE_GALLIUM_STATIC_TARGETS
 
diff --git a/src/gallium/targets/xa/target.c b/src/gallium/targets/xa/target.c
index fde4a4a..42b1346 100644
--- a/src/gallium/targets/xa/target.c
+++ b/src/gallium/targets/xa/target.c
@@ -1 +1 @@
-#include "target-helpers/inline_drm_helper.h"
+#include "target-helpers/drm_helper.h"
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 09/40] targets/nine: remove the custom pipe-driver path management

2015-11-20 Thread Emil Velikov
Since the up-streaming of nine, the static target was used by default.
The dynamic pipe-drivers being available only via manual tweak of
configure.ac.

As we'll be removing the library_path argument from the pipe-loader with
follow-up commits, we can remove D3D9_DRIVERS_PATH/D3D9_DRIVERS_DIR.
Everyone doing local hacking on nine, or wishing to have a env override
can bring them back within the pipe-loader.

Cc: Axel Davy 
Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/targets/d3dadapter9/drm.c | 20 ++--
 1 file changed, 2 insertions(+), 18 deletions(-)

diff --git a/src/gallium/targets/d3dadapter9/drm.c 
b/src/gallium/targets/d3dadapter9/drm.c
index 89789fa..92567ac 100644
--- a/src/gallium/targets/d3dadapter9/drm.c
+++ b/src/gallium/targets/d3dadapter9/drm.c
@@ -215,14 +215,6 @@ drm_create_adapter( int fd,
 driOptionCache userInitOptions;
 int throttling_value_user = -2;
 
-#if !GALLIUM_STATIC_TARGETS
-const char *paths[] = {
-getenv("D3D9_DRIVERS_PATH"),
-getenv("D3D9_DRIVERS_DIR"),
-PIPE_SEARCH_DIR
-};
-#endif
-
 if (!ctx) { return E_OUTOFMEMORY; }
 
 ctx->base.destroy = drm_destroy;
@@ -243,11 +235,7 @@ drm_create_adapter( int fd,
 }
 
 /* use pipe-loader to create a drm screen (hal) */
-ctx->base.hal = NULL;
-for (i = 0; !ctx->base.hal && i < Elements(paths); ++i) {
-if (!paths[i]) { continue; }
-ctx->base.hal = pipe_loader_create_screen(ctx->dev, paths[i]);
-}
+ctx->base.hal = pipe_loader_create_screen(ctx->dev, PIPE_SEARCH_DIR);
 #endif
 if (!ctx->base.hal) {
 ERR("Unable to load requested driver.\n");
@@ -313,11 +301,7 @@ drm_create_adapter( int fd,
 #else
 /* wrap it to create a software screen that can share resources */
 if (pipe_loader_sw_probe_wrapped(&ctx->swdev, ctx->base.hal)) {
-ctx->base.ref = NULL;
-for (i = 0; !ctx->base.ref && i < Elements(paths); ++i) {
-if (!paths[i]) { continue; }
-ctx->base.ref = pipe_loader_create_screen(ctx->swdev, paths[i]);
-}
+ctx->base.ref = pipe_loader_create_screen(ctx->swdev, PIPE_SEARCH_DIR);
 }
 #endif
 if (!ctx->base.ref) {
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 05/40] targets/nine: use the existing sw_screen_wrap() over our custom version

2015-11-20 Thread Emil Velikov
Cc: Axel Davy 
Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 .../auxiliary/target-helpers/inline_sw_helper.h| 27 --
 src/gallium/targets/d3dadapter9/Makefile.am|  1 -
 src/gallium/targets/d3dadapter9/drm.c  |  4 ++--
 3 files changed, 2 insertions(+), 30 deletions(-)

diff --git a/src/gallium/auxiliary/target-helpers/inline_sw_helper.h 
b/src/gallium/auxiliary/target-helpers/inline_sw_helper.h
index f3693fb..7e10c28 100644
--- a/src/gallium/auxiliary/target-helpers/inline_sw_helper.h
+++ b/src/gallium/auxiliary/target-helpers/inline_sw_helper.h
@@ -104,33 +104,6 @@ drisw_create_screen(struct drisw_loader_funcs *lf)
 }
 #endif // DRI_TARGET
 
-#if defined(NINE_TARGET)
-#include "sw/wrapper/wrapper_sw_winsys.h"
-#include "target-helpers/inline_debug_helper.h"
-
-extern struct pipe_screen *ninesw_create_screen(struct pipe_screen *screen);
-
-inline struct pipe_screen *
-ninesw_create_screen(struct pipe_screen *pscreen)
-{
-   struct sw_winsys *winsys = NULL;
-   struct pipe_screen *screen = NULL;
-
-   winsys = wrapper_sw_winsys_wrap_pipe_screen(pscreen);
-   if (winsys == NULL)
-  return NULL;
-
-   screen = sw_screen_create(winsys);
-   if (screen == NULL) {
-  winsys->destroy(winsys);
-  return NULL;
-   }
-
-   screen = debug_screen_wrap(screen);
-   return screen;
-}
-#endif // NINE_TARGET
-
 #endif // GALLIUM_SOFTPIPE
 
 
diff --git a/src/gallium/targets/d3dadapter9/Makefile.am 
b/src/gallium/targets/d3dadapter9/Makefile.am
index d36a8b8..7ec5c83 100644
--- a/src/gallium/targets/d3dadapter9/Makefile.am
+++ b/src/gallium/targets/d3dadapter9/Makefile.am
@@ -36,7 +36,6 @@ AM_CFLAGS = \
 
 if HAVE_GALLIUM_STATIC_TARGETS
 AM_CPPFLAGS = \
-   -DNINE_TARGET \
-DGALLIUM_STATIC_TARGETS=1
 
 else
diff --git a/src/gallium/targets/d3dadapter9/drm.c 
b/src/gallium/targets/d3dadapter9/drm.c
index fabc820..89789fa 100644
--- a/src/gallium/targets/d3dadapter9/drm.c
+++ b/src/gallium/targets/d3dadapter9/drm.c
@@ -30,7 +30,7 @@
 #include "pipe/p_state.h"
 
 #include "target-helpers/inline_drm_helper.h"
-#include "target-helpers/inline_sw_helper.h"
+#include "target-helpers/inline_wrapper_sw_helper.h"
 #include "state_tracker/drm_driver.h"
 
 #include "d3dadapter/d3dadapter9.h"
@@ -309,7 +309,7 @@ drm_create_adapter( int fd,
 driDestroyOptionInfo(&defaultInitOptions);
 
 #if GALLIUM_STATIC_TARGETS
-ctx->base.ref = ninesw_create_screen(ctx->base.hal);
+ctx->base.ref = sw_screen_wrap(ctx->base.hal);
 #else
 /* wrap it to create a software screen that can share resources */
 if (pipe_loader_sw_probe_wrapped(&ctx->swdev, ctx->base.hal)) {
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 07/40] pipe-loader: add pipe_loader_sw_probe_kms() implementation

2015-11-20 Thread Emil Velikov
Will be used as a counterpart for target-helpers'
kms_swrast_create_screen().

Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 configure.ac   |  4 
 src/gallium/Automake.inc   |  5 +
 src/gallium/auxiliary/pipe-loader/pipe_loader.h| 10 +
 src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c | 24 ++
 4 files changed, 43 insertions(+)

diff --git a/configure.ac b/configure.ac
index 98acfdd..322f7b6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2283,6 +2283,10 @@ if test "x$enable_gallium_loader" = xyes; then
 GALLIUM_PIPE_LOADER_DEFINES="$GALLIUM_PIPE_LOADER_DEFINES 
-DHAVE_PIPE_LOADER_DRI"
 fi
 
+if test "x$have_drisw_kms" = xyes; then
+GALLIUM_PIPE_LOADER_DEFINES="$GALLIUM_PIPE_LOADER_DEFINES 
-DHAVE_PIPE_LOADER_KMS"
+fi
+
 if test "x$enable_gallium_drm_loader" = xyes; then
 GALLIUM_PIPE_LOADER_DEFINES="$GALLIUM_PIPE_LOADER_DEFINES 
-DHAVE_PIPE_LOADER_DRM"
 fi
diff --git a/src/gallium/Automake.inc b/src/gallium/Automake.inc
index ee07ab6..095e6ec 100644
--- a/src/gallium/Automake.inc
+++ b/src/gallium/Automake.inc
@@ -67,3 +67,8 @@ if HAVE_DRISW
 GALLIUM_PIPE_LOADER_WINSYS_LIBS += \
$(top_builddir)/src/gallium/winsys/sw/dri/libswdri.la
 endif
+
+if HAVE_DRISW_KMS
+GALLIUM_PIPE_LOADER_WINSYS_LIBS += \
+   $(top_builddir)/src/gallium/winsys/sw/kms-dri/libswkmsdri.la
+endif
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.h 
b/src/gallium/auxiliary/pipe-loader/pipe_loader.h
index 7aa9c67..8eba8a6 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader.h
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.h
@@ -124,6 +124,16 @@ pipe_loader_sw_probe_dri(struct pipe_loader_device **devs,
  struct drisw_loader_funcs *drisw_lf);
 
 /**
+ * Initialize a kms backed sw device given an fd.
+ *
+ * This function is platform-specific.
+ *
+ * \sa pipe_loader_probe
+ */
+bool
+pipe_loader_sw_probe_kms(struct pipe_loader_device **devs, int fd);
+
+/**
  * Initialize a null sw device.
  *
  * This function is platform-specific.
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c 
b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
index 6794930..86039a3 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
@@ -30,6 +30,7 @@
 #include "util/u_memory.h"
 #include "util/u_dl.h"
 #include "sw/dri/dri_sw_winsys.h"
+#include "sw/kms-dri/kms_dri_sw_winsys.h"
 #include "sw/null/null_sw_winsys.h"
 #include "sw/wrapper/wrapper_sw_winsys.h"
 #include "target-helpers/inline_sw_helper.h"
@@ -72,6 +73,29 @@ pipe_loader_sw_probe_dri(struct pipe_loader_device **devs, 
struct drisw_loader_f
 }
 #endif
 
+#ifdef HAVE_PIPE_LOADER_KMS
+bool
+pipe_loader_sw_probe_kms(struct pipe_loader_device **devs, int fd)
+{
+   struct pipe_loader_sw_device *sdev = CALLOC_STRUCT(pipe_loader_sw_device);
+
+   if (!sdev)
+  return false;
+
+   sdev->base.type = PIPE_LOADER_DEVICE_SOFTWARE;
+   sdev->base.driver_name = "swrast";
+   sdev->base.ops = &pipe_loader_sw_ops;
+   sdev->ws = kms_dri_create_winsys(fd);
+   if (!sdev->ws) {
+  FREE(sdev);
+  return false;
+   }
+   *devs = &sdev->base;
+
+   return true;
+}
+#endif
+
 bool
 pipe_loader_sw_probe_null(struct pipe_loader_device **devs)
 {
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 12/40] pipe-loader: add pipe_loader_sw_probe_init_common() helper

2015-11-20 Thread Emil Velikov
Allows us to fold the duplication in pipe_loader_sw_probe_*().

Cc: Tom Stellard 
Cc: Francisco Jerez 
Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c | 38 ++
 1 file changed, 18 insertions(+), 20 deletions(-)

diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c 
b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
index c79f7c9..4b6e884 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
@@ -50,6 +50,19 @@ static struct sw_winsys *(*backends[])() = {
null_sw_create
 };
 
+static bool
+pipe_loader_sw_probe_init_common(struct pipe_loader_sw_device *sdev)
+{
+   if (!sdev->ws)
+  return false;
+
+   sdev->base.type = PIPE_LOADER_DEVICE_SOFTWARE;
+   sdev->base.driver_name = "swrast";
+   sdev->base.ops = &pipe_loader_sw_ops;
+
+   return true;
+}
+
 #ifdef HAVE_PIPE_LOADER_DRI
 bool
 pipe_loader_sw_probe_dri(struct pipe_loader_device **devs, struct 
drisw_loader_funcs *drisw_lf)
@@ -59,11 +72,8 @@ pipe_loader_sw_probe_dri(struct pipe_loader_device **devs, 
struct drisw_loader_f
if (!sdev)
   return false;
 
-   sdev->base.type = PIPE_LOADER_DEVICE_SOFTWARE;
-   sdev->base.driver_name = "swrast";
-   sdev->base.ops = &pipe_loader_sw_ops;
sdev->ws = dri_create_sw_winsys(drisw_lf);
-   if (!sdev->ws) {
+   if (!pipe_loader_sw_probe_init_common(sdev)) {
   FREE(sdev);
   return false;
}
@@ -82,11 +92,8 @@ pipe_loader_sw_probe_kms(struct pipe_loader_device **devs, 
int fd)
if (!sdev)
   return false;
 
-   sdev->base.type = PIPE_LOADER_DEVICE_SOFTWARE;
-   sdev->base.driver_name = "swrast";
-   sdev->base.ops = &pipe_loader_sw_ops;
sdev->ws = kms_dri_create_winsys(fd);
-   if (!sdev->ws) {
+   if (!pipe_loader_sw_probe_init_common(sdev)) {
   FREE(sdev);
   return false;
}
@@ -104,11 +111,8 @@ pipe_loader_sw_probe_null(struct pipe_loader_device **devs)
if (!sdev)
   return false;
 
-   sdev->base.type = PIPE_LOADER_DEVICE_SOFTWARE;
-   sdev->base.driver_name = "swrast";
-   sdev->base.ops = &pipe_loader_sw_ops;
sdev->ws = null_sw_create();
-   if (!sdev->ws) {
+   if (!pipe_loader_sw_probe_init_common(sdev)) {
   FREE(sdev);
   return false;
}
@@ -127,10 +131,8 @@ pipe_loader_sw_probe(struct pipe_loader_device **devs, int 
ndev)
  struct pipe_loader_sw_device *sdev = 
CALLOC_STRUCT(pipe_loader_sw_device);
 /* TODO: handle CALLOC_STRUCT failure */
 
- sdev->base.type = PIPE_LOADER_DEVICE_SOFTWARE;
- sdev->base.driver_name = "swrast";
- sdev->base.ops = &pipe_loader_sw_ops;
  sdev->ws = backends[i]();
+ pipe_loader_sw_probe_init_common(sdev);
  devs[i] = &sdev->base;
   }
}
@@ -147,12 +149,8 @@ pipe_loader_sw_probe_wrapped(struct pipe_loader_device 
**dev,
if (!sdev)
   return false;
 
-   sdev->base.type = PIPE_LOADER_DEVICE_SOFTWARE;
-   sdev->base.driver_name = "swrast";
-   sdev->base.ops = &pipe_loader_sw_ops;
sdev->ws = wrapper_sw_winsys_wrap_pipe_screen(screen);
-
-   if (!sdev->ws) {
+   if (!pipe_loader_sw_probe_init_common(sdev)) {
   FREE(sdev);
   return false;
}
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 18/40] pipe-loader: dlopen/dlsym the pipe-driver at probe time

2015-11-20 Thread Emil Velikov
Rather than giving false hopes that things might work, just check at
probe time. This allows us to remove the duplication and consolidate
the code wrt the upcomming static pipe-loader.

Cc: Tom Stellard 
Cc: Francisco Jerez 
Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 .../auxiliary/pipe-loader/pipe_loader_drm.c| 44 +-
 1 file changed, 17 insertions(+), 27 deletions(-)

diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c 
b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
index d4cb317..33274de 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
@@ -50,6 +50,7 @@
 
 struct pipe_loader_drm_device {
struct pipe_loader_device base;
+   const struct drm_driver_descriptor *dd;
struct util_dl_library *lib;
int fd;
 };
@@ -81,10 +82,23 @@ pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, 
int fd)
if (!ddev->base.driver_name)
   goto fail;
 
+   ddev->lib = pipe_loader_find_module(dev, PIPE_SEARCH_DIR);
+   if (!ddev->lib)
+  return fail;
+
+   ddev->dd = (const struct drm_driver_descriptor *)
+  util_dl_get_proc_address(ddev->lib, "driver_descriptor");
+
+   /* sanity check on the name */
+   if (!ddev->dd || strcmp(ddev->dd->name, ddev->base.driver_name) != 0)
+   goto fail;
+
*dev = &ddev->base;
return true;
 
   fail:
+   if (ddev->lib)
+  util_dl_close(ddev->lib);
FREE(ddev);
return false;
 }
@@ -146,43 +160,19 @@ pipe_loader_drm_configuration(struct pipe_loader_device 
*dev,
   enum drm_conf conf)
 {
struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(dev);
-   const struct drm_driver_descriptor *dd;
-
-   if (!ddev->lib)
-  return NULL;
-
-   dd = (const struct drm_driver_descriptor *)
-  util_dl_get_proc_address(ddev->lib, "driver_descriptor");
-
-   /* sanity check on the name */
-   if (!dd || strcmp(dd->name, ddev->base.driver_name) != 0)
-  return NULL;
 
-   if (!dd->configuration)
+   if (!ddev->dd->configuration)
   return NULL;
 
-   return dd->configuration(conf);
+   return ddev->dd->configuration(conf);
 }
 
 static struct pipe_screen *
 pipe_loader_drm_create_screen(struct pipe_loader_device *dev)
 {
struct pipe_loader_drm_device *ddev = pipe_loader_drm_device(dev);
-   const struct drm_driver_descriptor *dd;
-
-   if (!ddev->lib)
-  ddev->lib = pipe_loader_find_module(&ddev->base, PIPE_SEARCH_DIR);
-   if (!ddev->lib)
-  return NULL;
-
-   dd = (const struct drm_driver_descriptor *)
-  util_dl_get_proc_address(ddev->lib, "driver_descriptor");
-
-   /* sanity check on the name */
-   if (!dd || strcmp(dd->name, ddev->base.driver_name) != 0)
-  return NULL;
 
-   return dd->create_screen(ddev->fd);
+   return ddev->dd->create_screen(ddev->fd);
 }
 
 static const struct pipe_loader_ops pipe_loader_drm_ops = {
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 24/40] target-helpers: move the DRI specifics to the target

2015-11-20 Thread Emil Velikov
Rather than having all targets include the file, with only some defining
the relevant guard macro, just move things where they are used.

v2: rebase on top of virgl support.

Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 .../auxiliary/target-helpers/inline_drm_helper.h   | 136 -
 .../auxiliary/target-helpers/inline_sw_helper.h|  10 --
 src/gallium/state_trackers/dri/drisw.c |   3 +
 src/gallium/targets/dri/Android.mk |   2 +-
 src/gallium/targets/dri/Makefile.am|   1 -
 src/gallium/targets/dri/SConscript |   1 -
 src/gallium/targets/dri/target.c   | 162 +
 7 files changed, 166 insertions(+), 149 deletions(-)

diff --git a/src/gallium/auxiliary/target-helpers/inline_drm_helper.h 
b/src/gallium/auxiliary/target-helpers/inline_drm_helper.h
index 6ca4dc8..55f6363 100644
--- a/src/gallium/auxiliary/target-helpers/inline_drm_helper.h
+++ b/src/gallium/auxiliary/target-helpers/inline_drm_helper.h
@@ -72,14 +72,6 @@ static char* driver_name = NULL;
 #if defined(DRI_TARGET)
 #if defined(HAVE_LIBDRM)
 
-const __DRIextension **__driDriverGetExtensions_kms_swrast(void);
-
-PUBLIC const __DRIextension **__driDriverGetExtensions_kms_swrast(void)
-{
-   globalDriverAPI = &dri_kms_driver_api;
-   return galliumdrm_driver_extensions;
-}
-
 struct pipe_screen *
 kms_swrast_create_screen(int fd)
 {
@@ -98,16 +90,6 @@ kms_swrast_create_screen(int fd)
 #endif
 
 #if defined(GALLIUM_I915)
-#if defined(DRI_TARGET)
-
-const __DRIextension **__driDriverGetExtensions_i915(void);
-
-PUBLIC const __DRIextension **__driDriverGetExtensions_i915(void)
-{
-   globalDriverAPI = &galliumdrm_driver_api;
-   return galliumdrm_driver_extensions;
-}
-#endif
 
 static struct pipe_screen *
 pipe_i915_create_screen(int fd)
@@ -125,16 +107,6 @@ pipe_i915_create_screen(int fd)
 #endif
 
 #if defined(GALLIUM_ILO)
-#if defined(DRI_TARGET)
-
-const __DRIextension **__driDriverGetExtensions_i965(void);
-
-PUBLIC const __DRIextension **__driDriverGetExtensions_i965(void)
-{
-   globalDriverAPI = &galliumdrm_driver_api;
-   return galliumdrm_driver_extensions;
-}
-#endif
 
 static struct pipe_screen *
 pipe_ilo_create_screen(int fd)
@@ -152,16 +124,6 @@ pipe_ilo_create_screen(int fd)
 #endif
 
 #if defined(GALLIUM_NOUVEAU)
-#if defined(DRI_TARGET)
-
-const __DRIextension **__driDriverGetExtensions_nouveau(void);
-
-PUBLIC const __DRIextension **__driDriverGetExtensions_nouveau(void)
-{
-   globalDriverAPI = &galliumdrm_driver_api;
-   return galliumdrm_driver_extensions;
-}
-#endif
 
 static struct pipe_screen *
 pipe_nouveau_create_screen(int fd)
@@ -174,16 +136,6 @@ pipe_nouveau_create_screen(int fd)
 #endif
 
 #if defined(GALLIUM_R300)
-#if defined(DRI_TARGET)
-
-const __DRIextension **__driDriverGetExtensions_r300(void);
-
-PUBLIC const __DRIextension **__driDriverGetExtensions_r300(void)
-{
-   globalDriverAPI = &galliumdrm_driver_api;
-   return galliumdrm_driver_extensions;
-}
-#endif
 
 static struct pipe_screen *
 pipe_r300_create_screen(int fd)
@@ -196,16 +148,6 @@ pipe_r300_create_screen(int fd)
 #endif
 
 #if defined(GALLIUM_R600)
-#if defined(DRI_TARGET)
-
-const __DRIextension **__driDriverGetExtensions_r600(void);
-
-PUBLIC const __DRIextension **__driDriverGetExtensions_r600(void)
-{
-   globalDriverAPI = &galliumdrm_driver_api;
-   return galliumdrm_driver_extensions;
-}
-#endif
 
 static struct pipe_screen *
 pipe_r600_create_screen(int fd)
@@ -218,16 +160,6 @@ pipe_r600_create_screen(int fd)
 #endif
 
 #if defined(GALLIUM_RADEONSI)
-#if defined(DRI_TARGET)
-
-const __DRIextension **__driDriverGetExtensions_radeonsi(void);
-
-PUBLIC const __DRIextension **__driDriverGetExtensions_radeonsi(void)
-{
-   globalDriverAPI = &galliumdrm_driver_api;
-   return galliumdrm_driver_extensions;
-}
-#endif
 
 static struct pipe_screen *
 pipe_radeonsi_create_screen(int fd)
@@ -245,16 +177,6 @@ pipe_radeonsi_create_screen(int fd)
 #endif
 
 #if defined(GALLIUM_VMWGFX)
-#if defined(DRI_TARGET)
-
-const __DRIextension **__driDriverGetExtensions_vmwgfx(void);
-
-PUBLIC const __DRIextension **__driDriverGetExtensions_vmwgfx(void)
-{
-   globalDriverAPI = &galliumdrm_driver_api;
-   return galliumdrm_driver_extensions;
-}
-#endif
 
 static struct pipe_screen *
 pipe_vmwgfx_create_screen(int fd)
@@ -272,24 +194,6 @@ pipe_vmwgfx_create_screen(int fd)
 #endif
 
 #if defined(GALLIUM_FREEDRENO)
-#if defined(DRI_TARGET)
-
-const __DRIextension **__driDriverGetExtensions_msm(void);
-
-PUBLIC const __DRIextension **__driDriverGetExtensions_msm(void)
-{
-   globalDriverAPI = &galliumdrm_driver_api;
-   return galliumdrm_driver_extensions;
-}
-
-const __DRIextension **__driDriverGetExtensions_kgsl(void);
-
-PUBLIC const __DRIextension **__driDriverGetExtensions_kgsl(void)
-{
-   globalDriverAPI = &galliumdrm_driver_api;
-   return galliumdrm_driver_extensions;
-}
-#endif
 
 static struct pipe_screen *
 pipe_freedreno_create_screen(int fd)
@@ 

[Mesa-dev] [PATCH v2 00/40] Rework/consolidate the pipe-loader business

2015-11-20 Thread Emil Velikov
Hi all,

An update/rebase from the previous series.
 - updated to handle vl_winsys_drm
 - included virgl handling
 - targets should print "foo: driver missing" when built without foo

I might be abusing my luck here, but considering the amount of interest 
the previous round brought (not suprisingly), I will be giving this a 
few spins locally and barring any issues I will be pushing it just 
before the branchpoint (in 4-12 hours).

So if you have objections shout loudly.

The lot can be found at
https://github.com/evelikov/Mesa pipe-loader-redux-v2

Regards,
Emil

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


[Mesa-dev] [PATCH v2 14/40] gallium: keep the libdrm link alongside libkmsdri.la

2015-11-20 Thread Emil Velikov
Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/Automake.inc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gallium/Automake.inc b/src/gallium/Automake.inc
index 095e6ec..6fe2e22 100644
--- a/src/gallium/Automake.inc
+++ b/src/gallium/Automake.inc
@@ -70,5 +70,6 @@ endif
 
 if HAVE_DRISW_KMS
 GALLIUM_PIPE_LOADER_WINSYS_LIBS += \
-   $(top_builddir)/src/gallium/winsys/sw/kms-dri/libswkmsdri.la
+   $(top_builddir)/src/gallium/winsys/sw/kms-dri/libswkmsdri.la \
+   $(LIBDRM_LIBS)
 endif
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 03/40] pipe-loader: remove HAVE_PIPE_LOADER_foo function prototype guards

2015-11-20 Thread Emil Velikov
They serve little to no purpose, as we don't need any additional
dependencies (headers and/or symbols). On the other hand dropping them
will allow us to use GALLIUM_PIPE_LOADER_DEFINES in only one single
place - the pipe-loader.

Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/auxiliary/pipe-loader/pipe_loader.h | 8 
 1 file changed, 8 deletions(-)

diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.h 
b/src/gallium/auxiliary/pipe-loader/pipe_loader.h
index 9b87126..7aa9c67 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader.h
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.h
@@ -112,8 +112,6 @@ pipe_loader_configuration(struct pipe_loader_device *dev,
 void
 pipe_loader_release(struct pipe_loader_device **devs, int ndev);
 
-#ifdef HAVE_PIPE_LOADER_DRI
-
 /**
  * Initialize sw dri device give the drisw_loader_funcs.
  *
@@ -125,8 +123,6 @@ bool
 pipe_loader_sw_probe_dri(struct pipe_loader_device **devs,
  struct drisw_loader_funcs *drisw_lf);
 
-#endif
-
 /**
  * Initialize a null sw device.
  *
@@ -158,8 +154,6 @@ boolean
 pipe_loader_sw_probe_wrapped(struct pipe_loader_device **dev,
  struct pipe_screen *screen);
 
-#ifdef HAVE_PIPE_LOADER_DRM
-
 /**
  * Get a list of known DRM devices.
  *
@@ -180,8 +174,6 @@ pipe_loader_drm_probe(struct pipe_loader_device **devs, int 
ndev);
 bool
 pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, int fd);
 
-#endif
-
 #ifdef __cplusplus
 }
 #endif
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 16/40] pipe-loader: teardown the winsys, if create_screen fails

2015-11-20 Thread Emil Velikov
i.e. plug some (hard to hit) memory leaks.

v2: fix rebase fallout - really teardown the winsys (Brian)
Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c 
b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
index 816ff1c..85e06d3 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
@@ -240,8 +240,13 @@ static struct pipe_screen *
 pipe_loader_sw_create_screen(struct pipe_loader_device *dev)
 {
struct pipe_loader_sw_device *sdev = pipe_loader_sw_device(dev);
+   struct pipe_screen *screen;
 
-   return sdev->dd->create_screen(sdev->ws);
+   screen = sdev->dd->create_screen(sdev->ws);
+   if (!screen)
+  sdev->ws->destroy(sdev->ws);
+
+   return screen;
 }
 
 static struct pipe_loader_ops pipe_loader_sw_ops = {
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 01/40] configure: remove obsolete _CLIENT comment

2015-11-20 Thread Emil Velikov
The referenced variable(s) have been removed with commit abc20120e4a
(automake: pipe-loader: remove the 'client' pipe-loader)

Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 configure.ac | 5 -
 1 file changed, 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index 32fb989..027cfb1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2273,11 +2273,6 @@ AM_CONDITIONAL(HAVE_GALLIUM_VIRGL, test 
"x$HAVE_GALLIUM_VIRGL" = xyes)
 
 AM_CONDITIONAL(HAVE_GALLIUM_STATIC_TARGETS, test 
"x$enable_shared_pipe_drivers" = xno)
 
-# NOTE: anything using xcb or other client side libs ends up in separate
-#   _CLIENT variables.  The pipe loader is built in two variants,
-#   one that is standalone and does not link any x client libs (for
-#   use by XA tracker in particular, but could be used in any case
-#   where communication with xserver is not desired).
 if test "x$enable_gallium_loader" = xyes; then
 if test "x$enable_dri" = xyes; then
 GALLIUM_PIPE_LOADER_DEFINES="$GALLIUM_PIPE_LOADER_DEFINES 
-DHAVE_PIPE_LOADER_DRI"
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 06/40] configure: use HAVE_DRISW_KMS when handling kms swrast

2015-11-20 Thread Emil Velikov
Using HAVE_DRI2 to manage it seems counter-intuitive.

Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 configure.ac  | 5 +
 src/gallium/Makefile.am   | 2 +-
 src/gallium/drivers/softpipe/Automake.inc | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 027cfb1..98acfdd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -956,8 +956,13 @@ gnu*|cygwin*)
 dri_platform='drm' ;;
 esac
 
+if test "x$enable_dri" = xyes -a "x$dri_platform" = xdrm -a "x$have_libdrm" = 
xyes; then
+have_drisw_kms='yes'
+fi
+
 AM_CONDITIONAL(HAVE_DRICOMMON, test "x$enable_dri" = xyes )
 AM_CONDITIONAL(HAVE_DRISW, test "x$enable_dri" = xyes )
+AM_CONDITIONAL(HAVE_DRISW_KMS, test "x$have_drisw_kms" = xyes )
 AM_CONDITIONAL(HAVE_DRI2, test "x$enable_dri" = xyes -a "x$dri_platform" = 
xdrm -a "x$have_libdrm" = xyes )
 AM_CONDITIONAL(HAVE_DRI3, test "x$enable_dri3" = xyes -a "x$dri_platform" = 
xdrm -a "x$have_libdrm" = xyes )
 AM_CONDITIONAL(HAVE_APPLEDRI, test "x$enable_dri" = xyes -a "x$dri_platform" = 
xapple )
diff --git a/src/gallium/Makefile.am b/src/gallium/Makefile.am
index 611d55f..2c75083 100644
--- a/src/gallium/Makefile.am
+++ b/src/gallium/Makefile.am
@@ -98,7 +98,7 @@ if HAVE_DRISW
 SUBDIRS += winsys/sw/dri
 endif
 
-if HAVE_DRI2
+if HAVE_DRISW_KMS
 SUBDIRS += winsys/sw/kms-dri
 endif
 
diff --git a/src/gallium/drivers/softpipe/Automake.inc 
b/src/gallium/drivers/softpipe/Automake.inc
index 6455f3c..5cedcef 100644
--- a/src/gallium/drivers/softpipe/Automake.inc
+++ b/src/gallium/drivers/softpipe/Automake.inc
@@ -6,7 +6,7 @@ TARGET_LIB_DEPS += \
$(top_builddir)/src/gallium/winsys/sw/dri/libswdri.la \
$(top_builddir)/src/gallium/drivers/softpipe/libsoftpipe.la
 
-if HAVE_DRI2
+if HAVE_DRISW_KMS
 TARGET_DRIVERS += kms_swrast
 TARGET_LIB_DEPS += \
$(top_builddir)/src/gallium/winsys/sw/kms-dri/libswkmsdri.la
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 15/40] pipe-loader: rework the sw backend

2015-11-20 Thread Emil Velikov
Move the winsys into the pipe-target, similar to the hardware
pipe-driver.

v2:
 - move int declaration outside of loop (Brian)
 - fold the teardown into a goto + separate function.

Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c | 127 +++--
 src/gallium/include/state_tracker/sw_driver.h  |  21 
 src/gallium/targets/d3dadapter9/Makefile.am|   3 +-
 src/gallium/targets/dri/Makefile.am|   3 +-
 src/gallium/targets/omx/Makefile.am|   3 +-
 src/gallium/targets/opencl/Makefile.am |   1 -
 src/gallium/targets/pipe-loader/Makefile.am|   5 +
 src/gallium/targets/pipe-loader/pipe.sym   |   2 +-
 src/gallium/targets/pipe-loader/pipe_swrast.c  |  34 +-
 src/gallium/targets/va/Makefile.am |   3 +-
 src/gallium/targets/vdpau/Makefile.am  |   3 +-
 src/gallium/targets/xa/Makefile.am |   3 +-
 src/gallium/targets/xvmc/Makefile.am   |   3 +-
 src/gallium/tests/trivial/Makefile.am  |   1 -
 14 files changed, 158 insertions(+), 54 deletions(-)
 create mode 100644 src/gallium/include/state_tracker/sw_driver.h

diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c 
b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
index c61f2b8..816ff1c 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
@@ -35,9 +35,11 @@
 #include "sw/wrapper/wrapper_sw_winsys.h"
 #include "target-helpers/inline_sw_helper.h"
 #include "state_tracker/drisw_api.h"
+#include "state_tracker/sw_driver.h"
 
 struct pipe_loader_sw_device {
struct pipe_loader_device base;
+   const struct sw_driver_descriptor *dd;
struct util_dl_library *lib;
struct sw_winsys *ws;
 };
@@ -49,33 +51,62 @@ static struct pipe_loader_ops pipe_loader_sw_ops;
 static bool
 pipe_loader_sw_probe_init_common(struct pipe_loader_sw_device *sdev)
 {
-   if (!sdev->ws)
-  return false;
-
sdev->base.type = PIPE_LOADER_DEVICE_SOFTWARE;
sdev->base.driver_name = "swrast";
sdev->base.ops = &pipe_loader_sw_ops;
 
+   sdev->lib = pipe_loader_find_module(&sdev->base, PIPE_SEARCH_DIR);
+   if (!sdev->lib)
+  return false;
+
+   sdev->dd = (const struct sw_driver_descriptor *)
+  util_dl_get_proc_address(sdev->lib, "swrast_driver_descriptor");
+
+   if (!sdev->dd){
+  util_dl_close(sdev->lib);
+  sdev->lib = NULL;
+  return false;
+   }
+
return true;
 }
 
+static void
+pipe_loader_sw_probe_teardown_common(struct pipe_loader_sw_device *sdev)
+{
+   if (sdev->lib)
+  util_dl_close(sdev->lib);
+}
+
 #ifdef HAVE_PIPE_LOADER_DRI
 bool
 pipe_loader_sw_probe_dri(struct pipe_loader_device **devs, struct 
drisw_loader_funcs *drisw_lf)
 {
struct pipe_loader_sw_device *sdev = CALLOC_STRUCT(pipe_loader_sw_device);
+   int i;
 
if (!sdev)
   return false;
 
-   sdev->ws = dri_create_sw_winsys(drisw_lf);
-   if (!pipe_loader_sw_probe_init_common(sdev)) {
-  FREE(sdev);
-  return false;
+   if (!pipe_loader_sw_probe_init_common(sdev))
+  goto fail;
+
+   for (i = 0; sdev->dd->winsys; i++) {
+  if (strcmp(sdev->dd->winsys[i].name, "dri") == 0) {
+ sdev->ws = sdev->dd->winsys[i].create_winsys(drisw_lf);
+ break;
+  }
}
-   *devs = &sdev->base;
+   if (!sdev->ws)
+  goto fail;
 
+   *devs = &sdev->base;
return true;
+
+fail:
+   pipe_loader_sw_probe_teardown_common(sdev);
+   FREE(sdev);
+   return false;
 }
 #endif
 
@@ -84,18 +115,30 @@ bool
 pipe_loader_sw_probe_kms(struct pipe_loader_device **devs, int fd)
 {
struct pipe_loader_sw_device *sdev = CALLOC_STRUCT(pipe_loader_sw_device);
+   int i;
 
if (!sdev)
   return false;
 
-   sdev->ws = kms_dri_create_winsys(fd);
-   if (!pipe_loader_sw_probe_init_common(sdev)) {
-  FREE(sdev);
-  return false;
+   if (!pipe_loader_sw_probe_init_common(sdev))
+  goto fail;
+
+   for (i = 0; sdev->dd->winsys; i++) {
+  if (strcmp(sdev->dd->winsys[i].name, "kms_dri") == 0) {
+ sdev->ws = sdev->dd->winsys[i].create_winsys(fd);
+ break;
+  }
}
-   *devs = &sdev->base;
+   if (!sdev->ws)
+  goto fail;
 
+   *devs = &sdev->base;
return true;
+
+fail:
+   pipe_loader_sw_probe_teardown_common(sdev);
+   FREE(sdev);
+   return false;
 }
 #endif
 
@@ -103,18 +146,30 @@ bool
 pipe_loader_sw_probe_null(struct pipe_loader_device **devs)
 {
struct pipe_loader_sw_device *sdev = CALLOC_STRUCT(pipe_loader_sw_device);
+   int i;
 
if (!sdev)
   return false;
 
-   sdev->ws = null_sw_create();
-   if (!pipe_loader_sw_probe_init_common(sdev)) {
-  FREE(sdev);
-  return false;
+   if (!pipe_loader_sw_probe_init_common(sdev))
+  goto fail;
+
+   for (i = 0; sdev->dd->winsys; i++) {
+  if (strcmp(sdev->dd->winsys[i].name, "null") == 0) {
+ sdev->ws = sdev->dd->winsys[i].create_winsys();
+

[Mesa-dev] [PATCH v2 13/40] pipe-loader: directly use pipe_loader_sw_probe_null() at probe time

2015-11-20 Thread Emil Velikov
Due to the nature of the other sw winsys' we cannot use them during the
generic probe stage. As such there is little point in keeping the
abstraction layer.

Cc: Tom Stellard 
Cc: Francisco Jerez 
Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c | 17 -
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c 
b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
index 4b6e884..c61f2b8 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
@@ -46,10 +46,6 @@ struct pipe_loader_sw_device {
 
 static struct pipe_loader_ops pipe_loader_sw_ops;
 
-static struct sw_winsys *(*backends[])() = {
-   null_sw_create
-};
-
 static bool
 pipe_loader_sw_probe_init_common(struct pipe_loader_sw_device *sdev)
 {
@@ -124,16 +120,11 @@ pipe_loader_sw_probe_null(struct pipe_loader_device 
**devs)
 int
 pipe_loader_sw_probe(struct pipe_loader_device **devs, int ndev)
 {
-   int i;
-
-   for (i = 0; i < Elements(backends); i++) {
-  if (i < ndev) {
- struct pipe_loader_sw_device *sdev = 
CALLOC_STRUCT(pipe_loader_sw_device);
-/* TODO: handle CALLOC_STRUCT failure */
+   int i = 1;
 
- sdev->ws = backends[i]();
- pipe_loader_sw_probe_init_common(sdev);
- devs[i] = &sdev->base;
+   if (i < ndev) {
+  if (!pipe_loader_sw_probe_null(devs)) {
+ i--;
   }
}
 
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 25/40] target-helpers: add a non-inline drm_helper.h

2015-11-20 Thread Emil Velikov
Unlike the inline ones, here we'd want to have an extern definition of
the functions. This is required as with follow-up commits, we'll
gradually start using the static pipe-loader, with the latter needing
the symbols.

These are direct copy from the inline version.

v2:
 - rebase on top of virgl support
 - add "driver missing" printfs (Nicolai)

Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/auxiliary/target-helpers/drm_helper.h | 275 ++
 1 file changed, 275 insertions(+)
 create mode 100644 src/gallium/auxiliary/target-helpers/drm_helper.h

diff --git a/src/gallium/auxiliary/target-helpers/drm_helper.h 
b/src/gallium/auxiliary/target-helpers/drm_helper.h
new file mode 100644
index 000..73a80b6
--- /dev/null
+++ b/src/gallium/auxiliary/target-helpers/drm_helper.h
@@ -0,0 +1,275 @@
+#ifndef DRM_HELPER_H
+#define DRM_HELPER_H
+
+#include 
+#include "target-helpers/inline_debug_helper.h"
+#include "target-helpers/drm_helper_public.h"
+
+#ifdef GALLIUM_I915
+#include "i915/drm/i915_drm_public.h"
+#include "i915/i915_public.h"
+
+struct pipe_screen *
+pipe_i915_create_screen(int fd)
+{
+   struct i915_winsys *iws;
+   struct pipe_screen *screen;
+
+   iws = i915_drm_winsys_create(fd);
+   if (!iws)
+  return NULL;
+
+   screen = i915_screen_create(iws);
+   return screen ? debug_screen_wrap(screen) : NULL;
+}
+
+#else
+
+struct pipe_screen *
+pipe_i915_create_screen(int fd)
+{
+   fprintf(stderr, "i915g: driver missing\n");
+   return NULL;
+}
+
+#endif
+
+#ifdef GALLIUM_ILO
+#include "intel/drm/intel_drm_public.h"
+#include "ilo/ilo_public.h"
+
+struct pipe_screen *
+pipe_ilo_create_screen(int fd)
+{
+   struct intel_winsys *iws;
+   struct pipe_screen *screen;
+
+   iws = intel_winsys_create_for_fd(fd);
+   if (!iws)
+  return NULL;
+
+   screen = ilo_screen_create(iws);
+   return screen ? debug_screen_wrap(screen) : NULL;
+}
+
+#else
+
+struct pipe_screen *
+pipe_ilo_create_screen(int fd)
+{
+   fprintf(stderr, "ilo: driver missing\n");
+   return NULL;
+}
+
+#endif
+
+#ifdef GALLIUM_NOUVEAU
+#include "nouveau/drm/nouveau_drm_public.h"
+
+struct pipe_screen *
+pipe_nouveau_create_screen(int fd)
+{
+   struct pipe_screen *screen;
+
+   screen = nouveau_drm_screen_create(fd);
+   return screen ? debug_screen_wrap(screen) : NULL;
+}
+
+#else
+
+struct pipe_screen *
+pipe_nouveau_create_screen(int fd)
+{
+   fprintf(stderr, "nouveau: driver missing\n");
+   return NULL;
+}
+
+#endif
+
+#ifdef GALLIUM_R300
+#include "radeon/radeon_winsys.h"
+#include "radeon/drm/radeon_drm_public.h"
+#include "r300/r300_public.h"
+
+struct pipe_screen *
+pipe_r300_create_screen(int fd)
+{
+   struct radeon_winsys *rw;
+
+   rw = radeon_drm_winsys_create(fd, r300_screen_create);
+   return rw ? debug_screen_wrap(rw->screen) : NULL;
+}
+
+#else
+
+struct pipe_screen *
+pipe_r300_create_screen(int fd)
+{
+   fprintf(stderr, "r300: driver missing\n");
+   return NULL;
+}
+
+#endif
+
+#ifdef GALLIUM_R600
+#include "radeon/radeon_winsys.h"
+#include "radeon/drm/radeon_drm_public.h"
+#include "r600/r600_public.h"
+
+struct pipe_screen *
+pipe_r600_create_screen(int fd)
+{
+   struct radeon_winsys *rw;
+
+   rw = radeon_drm_winsys_create(fd, r600_screen_create);
+   return rw ? debug_screen_wrap(rw->screen) : NULL;
+}
+
+#else
+
+struct pipe_screen *
+pipe_r600_create_screen(int fd)
+{
+   fprintf(stderr, "r600: driver missing\n");
+   return NULL;
+}
+
+#endif
+
+#ifdef GALLIUM_RADEONSI
+#include "radeon/radeon_winsys.h"
+#include "radeon/drm/radeon_drm_public.h"
+#include "amdgpu/drm/amdgpu_public.h"
+#include "radeonsi/si_public.h"
+
+struct pipe_screen *
+pipe_radeonsi_create_screen(int fd)
+{
+   struct radeon_winsys *rw;
+
+   /* First, try amdgpu. */
+   rw = amdgpu_winsys_create(fd, radeonsi_screen_create);
+
+   if (!rw)
+  rw = radeon_drm_winsys_create(fd, radeonsi_screen_create);
+
+   return rw ? debug_screen_wrap(rw->screen) : NULL;
+}
+
+#else
+
+struct pipe_screen *
+pipe_radeonsi_create_screen(int fd)
+{
+   fprintf(stderr, "radeonsi: driver missing\n");
+   return NULL;
+}
+
+#endif
+
+#ifdef GALLIUM_VMWGFX
+#include "svga/drm/svga_drm_public.h"
+#include "svga/svga_public.h"
+
+struct pipe_screen *
+pipe_vmwgfx_create_screen(int fd)
+{
+   struct svga_winsys_screen *sws;
+   struct pipe_screen *screen;
+
+   sws = svga_drm_winsys_screen_create(fd);
+   if (!sws)
+  return NULL;
+
+   screen = svga_screen_create(sws);
+   return screen ? debug_screen_wrap(screen) : NULL;
+}
+
+#else
+
+struct pipe_screen *
+pipe_vmwgfx_create_screen(int fd)
+{
+   fprintf(stderr, "svga: driver missing\n");
+   return NULL;
+}
+
+#endif
+
+#ifdef GALLIUM_FREEDRENO
+#include "freedreno/drm/freedreno_drm_public.h"
+
+struct pipe_screen *
+pipe_freedreno_create_screen(int fd)
+{
+   struct pipe_screen *screen;
+
+   screen = fd_drm_screen_create(fd);
+   return screen ? debug_screen_wrap(screen) : NULL;
+}
+
+#else
+
+struct pipe_screen *
+pipe_freedreno_create_screen(int fd)
+{
+

[Mesa-dev] [PATCH v2 04/40] automake: use GALLIUM_PIPE_LOADER_DEFINES only where applicable

2015-11-20 Thread Emil Velikov
As of last commit we no longer need the defines in order to have the
function prototypes.

Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/auxiliary/Makefile.am | 1 -
 src/gallium/state_trackers/clover/Makefile.am | 1 -
 src/gallium/state_trackers/dri/Makefile.am| 1 -
 src/gallium/state_trackers/xa/Makefile.am | 1 -
 src/gallium/targets/d3dadapter9/Makefile.am   | 3 +--
 src/gallium/tests/trivial/Makefile.am | 3 +--
 6 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/src/gallium/auxiliary/Makefile.am 
b/src/gallium/auxiliary/Makefile.am
index a728162..c33def7 100644
--- a/src/gallium/auxiliary/Makefile.am
+++ b/src/gallium/auxiliary/Makefile.am
@@ -67,7 +67,6 @@ COMMON_VL_CFLAGS = \
$(VL_CFLAGS) \
$(DRI2PROTO_CFLAGS) \
$(LIBDRM_CFLAGS) \
-   $(GALLIUM_PIPE_LOADER_DEFINES) \
-DPIPE_SEARCH_DIR=\"$(libdir)/gallium-pipe\"
 
 if HAVE_GALLIUM_STATIC_TARGETS
diff --git a/src/gallium/state_trackers/clover/Makefile.am 
b/src/gallium/state_trackers/clover/Makefile.am
index fd0ccf8..c6528ff 100644
--- a/src/gallium/state_trackers/clover/Makefile.am
+++ b/src/gallium/state_trackers/clover/Makefile.am
@@ -1,7 +1,6 @@
 include Makefile.sources
 
 AM_CPPFLAGS = \
-   $(GALLIUM_PIPE_LOADER_DEFINES) \
-DPIPE_SEARCH_DIR=\"$(libdir)/gallium-pipe\" \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src \
diff --git a/src/gallium/state_trackers/dri/Makefile.am 
b/src/gallium/state_trackers/dri/Makefile.am
index 9f4deba..e407304 100644
--- a/src/gallium/state_trackers/dri/Makefile.am
+++ b/src/gallium/state_trackers/dri/Makefile.am
@@ -25,7 +25,6 @@ include Makefile.sources
 include $(top_srcdir)/src/gallium/Automake.inc
 
 AM_CPPFLAGS = \
-   $(GALLIUM_PIPE_LOADER_DEFINES) \
-DPIPE_SEARCH_DIR=\"$(libdir)/gallium-pipe\" \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src/mapi \
diff --git a/src/gallium/state_trackers/xa/Makefile.am 
b/src/gallium/state_trackers/xa/Makefile.am
index 5051e82..400a70b 100644
--- a/src/gallium/state_trackers/xa/Makefile.am
+++ b/src/gallium/state_trackers/xa/Makefile.am
@@ -29,7 +29,6 @@ AM_CFLAGS = \
$(VISIBILITY_CFLAGS)
 
 AM_CPPFLAGS = \
-   $(GALLIUM_PIPE_LOADER_DEFINES) \
-DPIPE_SEARCH_DIR=\"$(libdir)/gallium-pipe\"
 
 if HAVE_GALLIUM_STATIC_TARGETS
diff --git a/src/gallium/targets/d3dadapter9/Makefile.am 
b/src/gallium/targets/d3dadapter9/Makefile.am
index b522147..d36a8b8 100644
--- a/src/gallium/targets/d3dadapter9/Makefile.am
+++ b/src/gallium/targets/d3dadapter9/Makefile.am
@@ -42,8 +42,7 @@ AM_CPPFLAGS = \
 else
 
 AM_CPPFLAGS = \
-   -DPIPE_SEARCH_DIR=\"$(libdir)/gallium-pipe\" \
-   $(GALLIUM_PIPE_LOADER_DEFINES)
+   -DPIPE_SEARCH_DIR=\"$(libdir)/gallium-pipe\"
 
 endif
 
diff --git a/src/gallium/tests/trivial/Makefile.am 
b/src/gallium/tests/trivial/Makefile.am
index 56b7f3f..26783ab 100644
--- a/src/gallium/tests/trivial/Makefile.am
+++ b/src/gallium/tests/trivial/Makefile.am
@@ -8,8 +8,7 @@ AM_CFLAGS = \
 AM_CPPFLAGS = \
-I$(top_srcdir)/src/gallium/drivers \
-I$(top_srcdir)/src/gallium/winsys \
-   -DPIPE_SEARCH_DIR=\"$(PIPE_SRC_DIR)/.libs\" \
-   $(GALLIUM_PIPE_LOADER_DEFINES)
+   -DPIPE_SEARCH_DIR=\"$(PIPE_SRC_DIR)/.libs\"
 
 LDADD = \
$(top_builddir)/src/gallium/auxiliary/pipe-loader/libpipe_loader.la \
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 02/40] gallium/trace: remove useless NULL check from trace_screen_create()

2015-11-20 Thread Emil Velikov
Currently every target makes sure that the screen is non-null prior to
using the debug (trace including) wrappers. If that no longer holds true
we want to know and fix this ASAP rather than silently bailing out.

Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/drivers/trace/tr_screen.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/gallium/drivers/trace/tr_screen.c 
b/src/gallium/drivers/trace/tr_screen.c
index 8b02680..62a51e9 100644
--- a/src/gallium/drivers/trace/tr_screen.c
+++ b/src/gallium/drivers/trace/tr_screen.c
@@ -456,9 +456,6 @@ trace_screen_create(struct pipe_screen *screen)
 {
struct trace_screen *tr_scr;
 
-   if(!screen)
-  goto error1;
-
if (!trace_enabled())
   goto error1;
 
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 11/40] gallium/tests: remove unneeded include paths

2015-11-20 Thread Emil Velikov
The tests don't (and shouldn't) need to have anything driver and/or
winsys specific.

Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/tests/trivial/Makefile.am | 4 
 1 file changed, 4 deletions(-)

diff --git a/src/gallium/tests/trivial/Makefile.am 
b/src/gallium/tests/trivial/Makefile.am
index 4a86dc8..b30cb13 100644
--- a/src/gallium/tests/trivial/Makefile.am
+++ b/src/gallium/tests/trivial/Makefile.am
@@ -5,10 +5,6 @@ PIPE_SRC_DIR = $(top_builddir)/src/gallium/targets/pipe-loader
 AM_CFLAGS = \
$(GALLIUM_CFLAGS)
 
-AM_CPPFLAGS = \
-   -I$(top_srcdir)/src/gallium/drivers \
-   -I$(top_srcdir)/src/gallium/winsys
-
 LDADD = \
$(top_builddir)/src/gallium/auxiliary/pipe-loader/libpipe_loader.la \
$(top_builddir)/src/gallium/auxiliary/libgallium.la \
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 23/40] automake: remove no longer needed HAVE_LOADER_GALLIUM conditional

2015-11-20 Thread Emil Velikov
As of last few commits we have a static and dynamic pipe-loader. Either
of which will be used with (almost) all targets..

We can look into allowing the user to select which way the targets are
built, be that 'static for all' or 'per target' in follow up commits.
After which we can look into building only the static or dynamic
version, although building both shouldn't cause any issues.

Hack/workaround alert:
Control the standalone pipe-drivers via HAVE_CLOVER. Will need to be
fixed as the targets are converted/configure knobs are in.

Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 configure.ac  | 38 --
 src/gallium/Makefile.am   |  4 +++-
 src/gallium/auxiliary/Makefile.am |  4 
 3 files changed, 11 insertions(+), 35 deletions(-)

diff --git a/configure.ac b/configure.ac
index 55c0501..91fdfe5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -997,10 +997,6 @@ if test -n "$with_gallium_drivers" -a 
"x$enable_glx$enable_xlib_glx" = xyesyes;
 NEED_WINSYS_XLIB="yes"
 fi
 
-if test "x$enable_dri" = xyes; then
-enable_gallium_loader="$enable_shared_pipe_drivers"
-fi
-
 if test "x$enable_gallium_osmesa" = xyes; then
 if ! echo "$with_gallium_drivers" | grep -q 'swrast'; then
 AC_MSG_ERROR([gallium_osmesa requires the gallium swrast driver])
@@ -1604,7 +1600,6 @@ if test "x$enable_xa" = xyes; then
   enabling XA.
   Example: ./configure --enable-xa --with-gallium-drivers=svga...])
 fi
-enable_gallium_loader=$enable_shared_pipe_drivers
 gallium_st="$gallium_st xa"
 fi
 AM_CONDITIONAL(HAVE_ST_XA, test "x$enable_xa" = xyes)
@@ -1650,28 +1645,24 @@ AM_CONDITIONAL(NEED_GALLIUM_VL_WINSYS, test 
"x$need_gallium_vl_winsys" = xyes)
 
 if test "x$enable_xvmc" = xyes; then
 PKG_CHECK_MODULES([XVMC], [xvmc >= $XVMC_REQUIRED])
-enable_gallium_loader=$enable_shared_pipe_drivers
 gallium_st="$gallium_st xvmc"
 fi
 AM_CONDITIONAL(HAVE_ST_XVMC, test "x$enable_xvmc" = xyes)
 
 if test "x$enable_vdpau" = xyes; then
 PKG_CHECK_MODULES([VDPAU], [vdpau >= $VDPAU_REQUIRED])
-enable_gallium_loader=$enable_shared_pipe_drivers
 gallium_st="$gallium_st vdpau"
 fi
 AM_CONDITIONAL(HAVE_ST_VDPAU, test "x$enable_vdpau" = xyes)
 
 if test "x$enable_omx" = xyes; then
 PKG_CHECK_MODULES([OMX], [libomxil-bellagio >= 
$LIBOMXIL_BELLAGIO_REQUIRED])
-enable_gallium_loader=$enable_shared_pipe_drivers
 gallium_st="$gallium_st omx"
 fi
 AM_CONDITIONAL(HAVE_ST_OMX, test "x$enable_omx" = xyes)
 
 if test "x$enable_va" = xyes; then
 PKG_CHECK_MODULES([VA], [libva >= $LIBVA_REQUIRED])
-enable_gallium_loader=$enable_shared_pipe_drivers
 gallium_st="$gallium_st va"
 fi
 AM_CONDITIONAL(HAVE_ST_VA, test "x$enable_va" = xyes)
@@ -1694,7 +1685,6 @@ if test "x$enable_nine" = xyes; then
 AC_MSG_WARN([using nine together with wine requires DRI3 enabled 
system])
 fi
 
-enable_gallium_loader=$enable_shared_pipe_drivers
 gallium_st="$gallium_st nine"
 fi
 AM_CONDITIONAL(HAVE_ST_NINE, test "x$enable_nine" = xyes)
@@ -1733,8 +1723,6 @@ if test "x$enable_opencl" = xyes; then
 AC_SUBST([LIBCLC_LIBEXECDIR])
 fi
 
-# XXX: Use $enable_shared_pipe_drivers once converted to use static/shared 
pipe-drivers
-enable_gallium_loader=yes
 gallium_st="$gallium_st clover"
 
 if test "x$enable_opencl_icd" = xyes; then
@@ -2015,10 +2003,6 @@ AC_SUBST([XVMC_LIB_INSTALL_DIR])
 dnl
 dnl Gallium Tests
 dnl
-if test "x$enable_gallium_tests" = xyes; then
-# XXX: Use $enable_shared_pipe_drivers once converted to use static/shared 
pipe-drivers
-enable_gallium_loader=yes
-fi
 AM_CONDITIONAL(HAVE_GALLIUM_TESTS, test "x$enable_gallium_tests" = xyes)
 
 dnl Directory for VDPAU libs
@@ -2073,10 +2057,8 @@ gallium_require_llvm() {
 }
 
 gallium_require_drm_loader() {
-if test "x$enable_gallium_loader" = xyes; then
-if test "x$need_pci_id$have_pci_id" = xyesno; then
-AC_MSG_ERROR([Gallium drm loader requires libudev >= 
$LIBUDEV_REQUIRED or sysfs])
-fi
+if test "x$need_pci_id$have_pci_id" = xyesno; then
+AC_MSG_ERROR([Gallium drm loader requires libudev >= $LIBUDEV_REQUIRED 
or sysfs])
 fi
 }
 
@@ -2274,17 +2256,14 @@ AM_CONDITIONAL(HAVE_GALLIUM_VIRGL, test 
"x$HAVE_GALLIUM_VIRGL" = xyes)
 
 AM_CONDITIONAL(HAVE_GALLIUM_STATIC_TARGETS, test 
"x$enable_shared_pipe_drivers" = xno)
 
-if test "x$enable_gallium_loader" = xyes; then
-if test "x$enable_dri" = xyes; then
-GALLIUM_PIPE_LOADER_DEFINES="$GALLIUM_PIPE_LOADER_DEFINES 
-DHAVE_PIPE_LOADER_DRI"
-fi
-
-if test "x$have_drisw_kms" = xyes; then
-GALLIUM_PIPE_LOADER_DEFINES="$GALLIUM_PIPE_LOADER_DEFINES 
-DHAVE_PIPE_LOADER_KMS"
-fi
+if test "x$enable_dri" = xyes; then
+GALLIUM_PIPE_LOADER_DEFINES="$GALLIUM_PIPE_LOADER_DEFINES 
-DHAVE_PIPE_LOADER_DRI"
+fi
 
-AC_SUBST([GALLIUM_PIPE_LOADER_DEFINES])
+if test "x$have_drisw_kms" = xyes; then
+GAL

[Mesa-dev] [PATCH v2 10/40] gallium: remove library_path argument from pipe_loader_create_screen()

2015-11-20 Thread Emil Velikov
Currently the location is determined at configure/build time and
consistently copied across gallium. Just remove the extra argument, and
use PIPE_SEARCH_DIR where appropriate.

This will allow us to remove the duplication in the *configuration and
*screen_create APIs by moving util_dl_get_proc_address() and friends to
probe time.

v2: rebase on top of vl_winsys_drm.c addition

Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/auxiliary/Makefile.am| 3 +--
 src/gallium/auxiliary/pipe-loader/Makefile.am| 1 +
 src/gallium/auxiliary/pipe-loader/pipe_loader.c  | 5 ++---
 src/gallium/auxiliary/pipe-loader/pipe_loader.h  | 6 +-
 src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c  | 5 ++---
 src/gallium/auxiliary/pipe-loader/pipe_loader_priv.h | 3 +--
 src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c   | 5 ++---
 src/gallium/auxiliary/vl/vl_winsys_dri.c | 2 +-
 src/gallium/auxiliary/vl/vl_winsys_drm.c | 6 ++
 src/gallium/state_trackers/clover/Makefile.am| 1 -
 src/gallium/state_trackers/clover/core/device.cpp| 2 +-
 src/gallium/state_trackers/dri/Makefile.am   | 1 -
 src/gallium/state_trackers/dri/dri2.c| 2 +-
 src/gallium/state_trackers/xa/Makefile.am| 5 +
 src/gallium/state_trackers/xa/xa_tracker.c   | 2 +-
 src/gallium/targets/d3dadapter9/Makefile.am  | 5 -
 src/gallium/targets/d3dadapter9/drm.c| 4 ++--
 src/gallium/tests/trivial/Makefile.am| 3 +--
 src/gallium/tests/trivial/compute.c  | 2 +-
 src/gallium/tests/trivial/quad-tex.c | 2 +-
 src/gallium/tests/trivial/tri.c  | 2 +-
 21 files changed, 23 insertions(+), 44 deletions(-)

diff --git a/src/gallium/auxiliary/Makefile.am 
b/src/gallium/auxiliary/Makefile.am
index c33def7..0908608 100644
--- a/src/gallium/auxiliary/Makefile.am
+++ b/src/gallium/auxiliary/Makefile.am
@@ -66,8 +66,7 @@ COMMON_VL_CFLAGS = \
$(AM_CFLAGS) \
$(VL_CFLAGS) \
$(DRI2PROTO_CFLAGS) \
-   $(LIBDRM_CFLAGS) \
-   -DPIPE_SEARCH_DIR=\"$(libdir)/gallium-pipe\"
+   $(LIBDRM_CFLAGS)
 
 if HAVE_GALLIUM_STATIC_TARGETS
 COMMON_VL_CFLAGS += \
diff --git a/src/gallium/auxiliary/pipe-loader/Makefile.am 
b/src/gallium/auxiliary/pipe-loader/Makefile.am
index e12620c..1597b79 100644
--- a/src/gallium/auxiliary/pipe-loader/Makefile.am
+++ b/src/gallium/auxiliary/pipe-loader/Makefile.am
@@ -5,6 +5,7 @@ include $(top_srcdir)/src/gallium/Automake.inc
 AM_CFLAGS = \
-I$(top_srcdir)/src/loader \
-I$(top_srcdir)/src/gallium/winsys \
+   -DPIPE_SEARCH_DIR=\"$(libdir)/gallium-pipe\" \
$(GALLIUM_PIPE_LOADER_DEFINES) \
$(GALLIUM_CFLAGS) \
$(VISIBILITY_CFLAGS)
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.c 
b/src/gallium/auxiliary/pipe-loader/pipe_loader.c
index 0ca2e8c..40df216 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.c
@@ -69,10 +69,9 @@ pipe_loader_configuration(struct pipe_loader_device *dev,
 }
 
 struct pipe_screen *
-pipe_loader_create_screen(struct pipe_loader_device *dev,
-  const char *library_paths)
+pipe_loader_create_screen(struct pipe_loader_device *dev)
 {
-   return dev->ops->create_screen(dev, library_paths);
+   return dev->ops->create_screen(dev);
 }
 
 struct util_dl_library *
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.h 
b/src/gallium/auxiliary/pipe-loader/pipe_loader.h
index 8eba8a6..690d088 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader.h
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.h
@@ -82,13 +82,9 @@ pipe_loader_probe(struct pipe_loader_device **devs, int 
ndev);
  * Create a pipe_screen for the specified device.
  *
  * \param dev Device the screen will be created for.
- * \param library_paths Colon-separated list of filesystem paths that
- *  will be used to look for the pipe driver
- *  module that handles this device.
  */
 struct pipe_screen *
-pipe_loader_create_screen(struct pipe_loader_device *dev,
-  const char *library_paths);
+pipe_loader_create_screen(struct pipe_loader_device *dev);
 
 /**
  * Query the configuration parameters for the specified device.
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c 
b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
index 1799df7..3b858e7 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
@@ -165,14 +165,13 @@ pipe_loader_drm_configuration(struct pipe_loader_device 
*dev,
 }
 
 static struct pipe_screen *
-pipe_loader_drm_create_screen(struct pipe_loader_device *dev,
-  const char *library_paths)
+pipe_loader_drm_create_screen(struct pipe_loader_device *dev)
 {
struct pipe_loader_drm_device *ddev 

[Mesa-dev] [PATCH v2 34/40] st/dri: Don't close the drm fd on failure

2015-11-20 Thread Emil Velikov
Ported from an identically named commit in st/xa

commit 35cf3831d71770211f29da6608313dc1f6213d7b
Author: Thomas Hellstrom 
Date:   Thu Jul 3 02:07:36 2014 -0700

st/xa: Don't close the drm fd on failure v2

Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/state_trackers/dri/dri2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/dri/dri2.c 
b/src/gallium/state_trackers/dri/dri2.c
index 6217375..5b7be64b 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -1457,7 +1457,7 @@ dri2_init_screen(__DRIscreen * sPriv)
 
sPriv->driverPrivate = (void *)screen;
 
-   if (pipe_loader_drm_probe_fd(&screen->dev, screen->fd)) {
+   if (pipe_loader_drm_probe_fd(&screen->dev, dup(screen->fd))) {
   pscreen = pipe_loader_create_screen(screen->dev);
 
   throttle_ret = pipe_loader_configuration(screen->dev, DRM_CONF_THROTTLE);
@@ -1529,7 +1529,7 @@ dri_kms_init_screen(__DRIscreen * sPriv)
 
sPriv->driverPrivate = (void *)screen;
 
-   if (pipe_loader_sw_probe_kms(&screen->dev, screen->fd))
+   if (pipe_loader_sw_probe_kms(&screen->dev, dup(screen->fd)))
   pscreen = pipe_loader_create_screen(screen->dev);
 
if (drmGetCap(sPriv->fd, DRM_CAP_PRIME, &cap) == 0 &&
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 30/40] {auxiliary, targets}/vl: use static/dynamic pipe-loader

2015-11-20 Thread Emil Velikov
Analogous to previous commit.

v2: rebase on top of vl_winsys_drm.c addition

Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/auxiliary/Makefile.am|  6 --
 src/gallium/auxiliary/vl/vl_winsys_dri.c |  8 
 src/gallium/auxiliary/vl/vl_winsys_drm.c | 11 +--
 src/gallium/targets/omx/Makefile.am  |  7 +--
 src/gallium/targets/omx/target.c |  2 +-
 src/gallium/targets/va/Makefile.am   |  7 +--
 src/gallium/targets/va/target.c  |  2 +-
 src/gallium/targets/vdpau/Makefile.am|  7 +--
 src/gallium/targets/vdpau/target.c   |  2 +-
 src/gallium/targets/xvmc/Makefile.am |  7 +--
 src/gallium/targets/xvmc/target.c|  2 +-
 11 files changed, 25 insertions(+), 36 deletions(-)

diff --git a/src/gallium/auxiliary/Makefile.am 
b/src/gallium/auxiliary/Makefile.am
index 7ff8972..ee296ce 100644
--- a/src/gallium/auxiliary/Makefile.am
+++ b/src/gallium/auxiliary/Makefile.am
@@ -64,12 +64,6 @@ COMMON_VL_CFLAGS = \
$(DRI2PROTO_CFLAGS) \
$(LIBDRM_CFLAGS)
 
-if HAVE_GALLIUM_STATIC_TARGETS
-COMMON_VL_CFLAGS += \
-   -DGALLIUM_STATIC_TARGETS=1
-
-endif # HAVE_GALLIUM_STATIC_TARGETS
-
 noinst_LTLIBRARIES += libgalliumvl.la
 
 libgalliumvl_la_CFLAGS = \
diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri.c 
b/src/gallium/auxiliary/vl/vl_winsys_dri.c
index fb16adc..c4f9295 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri.c
@@ -402,12 +402,8 @@ vl_dri2_screen_create(Display *display, int screen)
if (authenticate == NULL || !authenticate->authenticated)
   goto free_authenticate;
 
-#if GALLIUM_STATIC_TARGETS
-   scrn->base.pscreen = dd_create_screen(fd);
-#else
if (pipe_loader_drm_probe_fd(&scrn->base.dev, fd))
   scrn->base.pscreen = pipe_loader_create_screen(scrn->base.dev);
-#endif // GALLIUM_STATIC_TARGETS
 
if (!scrn->base.pscreen)
   goto release_pipe;
@@ -430,10 +426,8 @@ vl_dri2_screen_create(Display *display, int screen)
return &scrn->base;
 
 release_pipe:
-#if !GALLIUM_STATIC_TARGETS
if (scrn->base.dev)
   pipe_loader_release(&scrn->base.dev, 1);
-#endif // !GALLIUM_STATIC_TARGETS
 free_authenticate:
free(authenticate);
 free_connect:
@@ -462,8 +456,6 @@ vl_dri2_screen_destroy(struct vl_screen *vscreen)
 
vl_dri2_destroy_drawable(scrn);
scrn->base.pscreen->destroy(scrn->base.pscreen);
-#if !GALLIUM_STATIC_TARGETS
pipe_loader_release(&scrn->base.dev, 1);
-#endif // !GALLIUM_STATIC_TARGETS
FREE(scrn);
 }
diff --git a/src/gallium/auxiliary/vl/vl_winsys_drm.c 
b/src/gallium/auxiliary/vl/vl_winsys_drm.c
index f4e8306..f993e2c 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_drm.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_drm.c
@@ -46,12 +46,8 @@ vl_drm_screen_create(int fd)
if (!vscreen)
   return NULL;
 
-#if GALLIUM_STATIC_TARGETS
-   vscreen->pscreen = dd_create_screen(fd);
-#else
if (pipe_loader_drm_probe_fd(&vscreen->dev, dup(fd)))
   vscreen->pscreen = pipe_loader_create_screen(vscreen->dev);
-#endif
 
if (!vscreen->pscreen)
   goto error;
@@ -65,10 +61,9 @@ vl_drm_screen_create(int fd)
return vscreen;
 
 error:
-#if !GALLIUM_STATIC_TARGETS
if (vscreen->dev)
   pipe_loader_release(&vscreen->dev, 1);
-#endif // !GALLIUM_STATIC_TARGETS
+
FREE(vscreen);
return NULL;
 }
@@ -79,10 +74,6 @@ vl_drm_screen_destroy(struct vl_screen *vscreen)
assert(vscreen);
 
vscreen->pscreen->destroy(vscreen->pscreen);
-
-#if !GALLIUM_STATIC_TARGETS
pipe_loader_release(&vscreen->dev, 1);
-#endif
-
FREE(vscreen);
 }
diff --git a/src/gallium/targets/omx/Makefile.am 
b/src/gallium/targets/omx/Makefile.am
index f9c0842..3bdb9eb 100644
--- a/src/gallium/targets/omx/Makefile.am
+++ b/src/gallium/targets/omx/Makefile.am
@@ -40,7 +40,7 @@ if HAVE_GALLIUM_STATIC_TARGETS
 
 TARGET_DRIVERS =
 TARGET_CPPFLAGS =
-TARGET_LIB_DEPS = $(top_builddir)/src/loader/libloader.la
+TARGET_LIB_DEPS =
 
 
 include $(top_srcdir)/src/gallium/drivers/nouveau/Automake.inc
@@ -50,7 +50,10 @@ include 
$(top_srcdir)/src/gallium/drivers/radeonsi/Automake.inc
 
 libomx_mesa_la_SOURCES += target.c
 libomx_mesa_la_CPPFLAGS = $(TARGET_CPPFLAGS)
-libomx_mesa_la_LIBADD += $(TARGET_LIB_DEPS) \
+libomx_mesa_la_LIBADD += \
+   
$(top_builddir)/src/gallium/auxiliary/pipe-loader/libpipe_loader_static.la \
+   $(GALLIUM_PIPE_LOADER_WINSYS_LIBS) \
+   $(TARGET_LIB_DEPS) \
$(TARGET_RADEON_WINSYS) $(TARGET_RADEON_COMMON)
 
 else # HAVE_GALLIUM_STATIC_TARGETS
diff --git a/src/gallium/targets/omx/target.c b/src/gallium/targets/omx/target.c
index fde4a4a..42b1346 100644
--- a/src/gallium/targets/omx/target.c
+++ b/src/gallium/targets/omx/target.c
@@ -1 +1 @@
-#include "target-helpers/inline_drm_helper.h"
+#include "target-helpers/drm_helper.h"
diff --git a/src/gallium/targets/va/Makefile.am 
b/src/gallium/targets/va/Makefile.am
index 17b9ae3..733e7ac 100644
--- a/src/gallium/targets/va/Makefile.am

[Mesa-dev] [PATCH v2 35/40] st/dri: NULL check the pscreen earlier

2015-11-20 Thread Emil Velikov
We delay the null check only to jump through hoops to work around that.
Check early to make our lives easier.

Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/state_trackers/dri/dri2.c   | 22 --
 src/gallium/state_trackers/dri/dri_screen.c |  5 -
 src/gallium/state_trackers/dri/drisw.c  |  3 ++-
 3 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/src/gallium/state_trackers/dri/dri2.c 
b/src/gallium/state_trackers/dri/dri2.c
index 5b7be64b..beb0866 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -1444,8 +1444,8 @@ dri2_init_screen(__DRIscreen * sPriv)
const __DRIconfig **configs;
struct dri_screen *screen;
struct pipe_screen *pscreen = NULL;
-   const struct drm_conf_ret *throttle_ret = NULL;
-   const struct drm_conf_ret *dmabuf_ret = NULL;
+   const struct drm_conf_ret *throttle_ret;
+   const struct drm_conf_ret *dmabuf_ret;
 
screen = CALLOC_STRUCT(dri_screen);
if (!screen)
@@ -1457,12 +1457,14 @@ dri2_init_screen(__DRIscreen * sPriv)
 
sPriv->driverPrivate = (void *)screen;
 
-   if (pipe_loader_drm_probe_fd(&screen->dev, dup(screen->fd))) {
+   if (pipe_loader_drm_probe_fd(&screen->dev, dup(screen->fd)))
   pscreen = pipe_loader_create_screen(screen->dev);
 
-  throttle_ret = pipe_loader_configuration(screen->dev, DRM_CONF_THROTTLE);
-  dmabuf_ret = pipe_loader_configuration(screen->dev, DRM_CONF_SHARE_FD);
-   }
+   if (!pscreen)
+   goto fail;
+
+   throttle_ret = pipe_loader_configuration(screen->dev, DRM_CONF_THROTTLE);
+   dmabuf_ret = pipe_loader_configuration(screen->dev, DRM_CONF_SHARE_FD);
 
if (throttle_ret && throttle_ret->val.val_int != -1) {
   screen->throttling_enabled = TRUE;
@@ -1479,15 +1481,13 @@ dri2_init_screen(__DRIscreen * sPriv)
   }
}
 
-   if (pscreen && pscreen->get_param(pscreen, 
PIPE_CAP_DEVICE_RESET_STATUS_QUERY)) {
+   if (pscreen->get_param(pscreen, PIPE_CAP_DEVICE_RESET_STATUS_QUERY)) {
   sPriv->extensions = dri_robust_screen_extensions;
   screen->has_reset_status_query = true;
}
else
   sPriv->extensions = dri_screen_extensions;
 
-   /* dri_init_screen_helper checks pscreen for us */
-
configs = dri_init_screen_helper(screen, pscreen, screen->dev->driver_name);
if (!configs)
   goto fail;
@@ -1532,6 +1532,9 @@ dri_kms_init_screen(__DRIscreen * sPriv)
if (pipe_loader_sw_probe_kms(&screen->dev, dup(screen->fd)))
   pscreen = pipe_loader_create_screen(screen->dev);
 
+   if (!pscreen)
+   goto fail;
+
if (drmGetCap(sPriv->fd, DRM_CAP_PRIME, &cap) == 0 &&
   (cap & DRM_PRIME_CAP_IMPORT)) {
   dri2ImageExtension.createImageFromFds = dri2_from_fds;
@@ -1540,7 +1543,6 @@ dri_kms_init_screen(__DRIscreen * sPriv)
 
sPriv->extensions = dri_screen_extensions;
 
-   /* dri_init_screen_helper checks pscreen for us */
configs = dri_init_screen_helper(screen, pscreen, "swrast");
if (!configs)
   goto fail;
diff --git a/src/gallium/state_trackers/dri/dri_screen.c 
b/src/gallium/state_trackers/dri/dri_screen.c
index cf0f265..2ac55c8 100644
--- a/src/gallium/state_trackers/dri/dri_screen.c
+++ b/src/gallium/state_trackers/dri/dri_screen.c
@@ -414,11 +414,6 @@ dri_init_screen_helper(struct dri_screen *screen,
const char* driver_name)
 {
screen->base.screen = pscreen;
-   if (!screen->base.screen) {
-  debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__);
-  return NULL;
-   }
-
screen->base.get_egl_image = dri_get_egl_image;
screen->base.get_param = dri_get_param;
 
diff --git a/src/gallium/state_trackers/dri/drisw.c 
b/src/gallium/state_trackers/dri/drisw.c
index 06fa942..b85a73c 100644
--- a/src/gallium/state_trackers/dri/drisw.c
+++ b/src/gallium/state_trackers/dri/drisw.c
@@ -400,7 +400,8 @@ drisw_init_screen(__DRIscreen * sPriv)
if (pipe_loader_sw_probe_dri(&screen->dev, &drisw_lf))
   pscreen = pipe_loader_create_screen(screen->dev);
 
-   /* dri_init_screen_helper checks pscreen for us */
+   if (!pscreen)
+  goto fail;
 
configs = dri_init_screen_helper(screen, pscreen, "swrast");
if (!configs)
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 26/40] pipe-loader: don't mix code and variable declarations

2015-11-20 Thread Emil Velikov
We cannot use this C99 feature here quite yet, as the code needs to be
build with MSVC prior to 2013.

Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c 
b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
index e7804d3..b5dfc56 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
@@ -238,8 +238,9 @@ pipe_loader_drm_probe(struct pipe_loader_device **devs, int 
ndev)
 
for (i = DRM_RENDER_NODE_MIN_MINOR, j = 0;
 i <= DRM_RENDER_NODE_MAX_MINOR; i++) {
-  fd = open_drm_render_node_minor(i);
   struct pipe_loader_device *dev;
+
+  fd = open_drm_render_node_minor(i);
   if (fd < 0)
  continue;
 
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 19/40] gallium: rename libpipe_loader to libpipe_loader_dynamic

2015-11-20 Thread Emil Velikov
With the next commits we'll introduce a 'static' version, which will
essentially load the statically linked-in pipe-drivers, rather than the
standalone pipe-$foo.so ones.

Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/auxiliary/pipe-loader/Makefile.am | 8 
 src/gallium/targets/d3dadapter9/Makefile.am   | 2 +-
 src/gallium/targets/dri/Makefile.am   | 2 +-
 src/gallium/targets/omx/Makefile.am   | 2 +-
 src/gallium/targets/opencl/Makefile.am| 2 +-
 src/gallium/targets/va/Makefile.am| 2 +-
 src/gallium/targets/vdpau/Makefile.am | 2 +-
 src/gallium/targets/xa/Makefile.am| 2 +-
 src/gallium/targets/xvmc/Makefile.am  | 2 +-
 src/gallium/tests/trivial/Makefile.am | 2 +-
 10 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/gallium/auxiliary/pipe-loader/Makefile.am 
b/src/gallium/auxiliary/pipe-loader/Makefile.am
index 1597b79..974cf08 100644
--- a/src/gallium/auxiliary/pipe-loader/Makefile.am
+++ b/src/gallium/auxiliary/pipe-loader/Makefile.am
@@ -10,19 +10,19 @@ AM_CFLAGS = \
$(GALLIUM_CFLAGS) \
$(VISIBILITY_CFLAGS)
 
-noinst_LTLIBRARIES = libpipe_loader.la
+noinst_LTLIBRARIES = libpipe_loader_dynamic.la
 
-libpipe_loader_la_SOURCES = \
+libpipe_loader_dynamic_la_SOURCES = \
$(COMMON_SOURCES)
 
 if HAVE_LIBDRM
 AM_CFLAGS += \
$(LIBDRM_CFLAGS)
 
-libpipe_loader_la_SOURCES += \
+libpipe_loader_dynamic_la_SOURCES += \
$(DRM_SOURCES)
 
-libpipe_loader_la_LIBADD = \
+libpipe_loader_dynamic_la_LIBADD = \
$(top_builddir)/src/loader/libloader.la
 
 endif
diff --git a/src/gallium/targets/d3dadapter9/Makefile.am 
b/src/gallium/targets/d3dadapter9/Makefile.am
index d125ba8..776f86b 100644
--- a/src/gallium/targets/d3dadapter9/Makefile.am
+++ b/src/gallium/targets/d3dadapter9/Makefile.am
@@ -110,7 +110,7 @@ d3dadapter9_la_LIBADD += $(TARGET_LIB_DEPS) \
 else # HAVE_GALLIUM_STATIC_TARGETS
 
 d3dadapter9_la_LIBADD += \
-   $(top_builddir)/src/gallium/auxiliary/pipe-loader/libpipe_loader.la
+   
$(top_builddir)/src/gallium/auxiliary/pipe-loader/libpipe_loader_dynamic.la
 
 endif # HAVE_GALLIUM_STATIC_TARGETS
 
diff --git a/src/gallium/targets/dri/Makefile.am 
b/src/gallium/targets/dri/Makefile.am
index 038a12b..e3a145f 100644
--- a/src/gallium/targets/dri/Makefile.am
+++ b/src/gallium/targets/dri/Makefile.am
@@ -98,7 +98,7 @@ gallium_dri_la_LIBADD += $(TARGET_LIB_DEPS) \
 else # HAVE_GALLIUM_STATIC_TARGETS
 
 gallium_dri_la_LIBADD += \
-   $(top_builddir)/src/gallium/auxiliary/pipe-loader/libpipe_loader.la
+   
$(top_builddir)/src/gallium/auxiliary/pipe-loader/libpipe_loader_dynamic.la
 
 endif # HAVE_GALLIUM_STATIC_TARGETS
 
diff --git a/src/gallium/targets/omx/Makefile.am 
b/src/gallium/targets/omx/Makefile.am
index 2454cbe..f9c0842 100644
--- a/src/gallium/targets/omx/Makefile.am
+++ b/src/gallium/targets/omx/Makefile.am
@@ -56,7 +56,7 @@ libomx_mesa_la_LIBADD += $(TARGET_LIB_DEPS) \
 else # HAVE_GALLIUM_STATIC_TARGETS
 
 libomx_mesa_la_LIBADD += \
-   $(top_builddir)/src/gallium/auxiliary/pipe-loader/libpipe_loader.la
+   
$(top_builddir)/src/gallium/auxiliary/pipe-loader/libpipe_loader_dynamic.la
 
 endif # HAVE_GALLIUM_STATIC_TARGETS
 
diff --git a/src/gallium/targets/opencl/Makefile.am 
b/src/gallium/targets/opencl/Makefile.am
index 004d6d7..3cb2976 100644
--- a/src/gallium/targets/opencl/Makefile.am
+++ b/src/gallium/targets/opencl/Makefile.am
@@ -15,7 +15,7 @@ lib@OPENCL_LIBNAME@_la_LDFLAGS += \
 endif
 
 lib@OPENCL_LIBNAME@_la_LIBADD = \
-   $(top_builddir)/src/gallium/auxiliary/pipe-loader/libpipe_loader.la \
+   
$(top_builddir)/src/gallium/auxiliary/pipe-loader/libpipe_loader_dynamic.la \
$(top_builddir)/src/gallium/state_trackers/clover/libclover.la \
$(top_builddir)/src/gallium/auxiliary/libgallium.la \
$(top_builddir)/src/util/libmesautil.la \
diff --git a/src/gallium/targets/va/Makefile.am 
b/src/gallium/targets/va/Makefile.am
index 2fd24a8..17b9ae3 100644
--- a/src/gallium/targets/va/Makefile.am
+++ b/src/gallium/targets/va/Makefile.am
@@ -53,7 +53,7 @@ gallium_drv_video_la_LIBADD += $(TARGET_LIB_DEPS) \
 else # HAVE_GALLIUM_STATIC_TARGETS
 
 gallium_drv_video_la_LIBADD += \
-   $(top_builddir)/src/gallium/auxiliary/pipe-loader/libpipe_loader.la
+   
$(top_builddir)/src/gallium/auxiliary/pipe-loader/libpipe_loader_dynamic.la
 
 endif # HAVE_GALLIUM_STATIC_TARGETS
 
diff --git a/src/gallium/targets/vdpau/Makefile.am 
b/src/gallium/targets/vdpau/Makefile.am
index 34b7ef4..f9fb560 100644
--- a/src/gallium/targets/vdpau/Makefile.am
+++ b/src/gallium/targets/vdpau/Makefile.am
@@ -65,7 +65,7 @@ libvdpau_gallium_la_LIBADD += $(TARGET_LIB_DEPS) \
 else # HAVE_GALLIUM_STATIC_TARGETS
 
 libvdpau_gallium_la_LIBADD += \
-   $(top_builddir)/src/gallium/auxiliary/pipe-loader/libpipe_loader.la
+   
$(top_builddir)/src/gallium/auxiliary/pipe-loader/libpipe_loader_dynamic.la
 
 endif # HAVE_GA

[Mesa-dev] [PATCH v2 27/40] pipe-loader: add preliminary scons support

2015-11-20 Thread Emil Velikov
Add a 'static' pipe-loader build, which will be used with follow-up
commits.

Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/SConscript|  1 +
 src/gallium/auxiliary/pipe-loader/Makefile.am |  2 ++
 src/gallium/auxiliary/pipe-loader/SConscript  | 34 +++
 3 files changed, 37 insertions(+)
 create mode 100644 src/gallium/auxiliary/pipe-loader/SConscript

diff --git a/src/gallium/SConscript b/src/gallium/SConscript
index fa5fa6e..0c3a374 100644
--- a/src/gallium/SConscript
+++ b/src/gallium/SConscript
@@ -5,6 +5,7 @@ Import('env')
 #
 
 SConscript('auxiliary/SConscript')
+SConscript('auxiliary/pipe-loader/SConscript')
 
 #
 # Drivers
diff --git a/src/gallium/auxiliary/pipe-loader/Makefile.am 
b/src/gallium/auxiliary/pipe-loader/Makefile.am
index 6a4a667..f661897 100644
--- a/src/gallium/auxiliary/pipe-loader/Makefile.am
+++ b/src/gallium/auxiliary/pipe-loader/Makefile.am
@@ -44,3 +44,5 @@ libpipe_loader_dynamic_la_LIBADD = \
$(top_builddir)/src/loader/libloader.la
 
 endif
+
+EXTRA_DIST = SConscript
diff --git a/src/gallium/auxiliary/pipe-loader/SConscript 
b/src/gallium/auxiliary/pipe-loader/SConscript
new file mode 100644
index 000..393b602
--- /dev/null
+++ b/src/gallium/auxiliary/pipe-loader/SConscript
@@ -0,0 +1,34 @@
+Import('*')
+
+env = env.Clone()
+
+env.MSVC2008Compat()
+
+env.Append(CPPPATH = [
+'#/src/loader',
+'#/src/gallium/winsys',
+])
+
+env.Append(CPPDEFINES = [
+('HAVE_PIPE_LOADER_DRI', '1'),
+('DROP_PIPE_LOADER_MISC', '1'),
+('GALLIUM_STATIC_TARGETS', '1'),
+])
+
+source = env.ParseSourceList('Makefile.sources', 'COMMON_SOURCES')
+
+#if HAVE_LIBDRM
+source += env.ParseSourceList('Makefile.sources', 'DRM_SOURCES')
+
+env.PkgUseModules('DRM')
+env.Append(LIBS = [libloader])
+#endif
+
+pipe_loader = env.ConvenienceLibrary(
+target = 'pipe_loader',
+source = source,
+)
+
+env.Alias('pipe_loader', pipe_loader)
+
+Export('pipe_loader')
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 21/40] pipe-loader: wire up the 'static' drm pipe-loader

2015-11-20 Thread Emil Velikov
Add a list of driver descriptors and select one from the list, during
probe time.

As we'll need to have all the driver pipe_foo_screen_create() functions
provided externally (i.e. from another static lib) we need a separate
(non-inline) drm_helper, which contains the function declarations.

v2: rebase on top of virgl support.

Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 .../auxiliary/pipe-loader/pipe_loader_drm.c| 127 -
 .../auxiliary/target-helpers/drm_helper_public.h   |  37 ++
 2 files changed, 161 insertions(+), 3 deletions(-)
 create mode 100644 src/gallium/auxiliary/target-helpers/drm_helper_public.h

diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c 
b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
index 33274de..e7804d3 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
@@ -36,6 +36,7 @@
 #include 
 
 #include "loader.h"
+#include "target-helpers/drm_helper_public.h"
 #include "state_tracker/drm_driver.h"
 #include "pipe_loader_priv.h"
 
@@ -51,7 +52,9 @@
 struct pipe_loader_drm_device {
struct pipe_loader_device base;
const struct drm_driver_descriptor *dd;
+#ifndef GALLIUM_STATIC_TARGETS
struct util_dl_library *lib;
+#endif
int fd;
 };
 
@@ -59,6 +62,109 @@ struct pipe_loader_drm_device {
 
 static const struct pipe_loader_ops pipe_loader_drm_ops;
 
+#ifdef GALLIUM_STATIC_TARGETS
+static const struct drm_conf_ret throttle_ret = {
+   DRM_CONF_INT,
+   {2},
+};
+
+static const struct drm_conf_ret share_fd_ret = {
+   DRM_CONF_BOOL,
+   {true},
+};
+
+static inline const struct drm_conf_ret *
+configuration_query(enum drm_conf conf)
+{
+   switch (conf) {
+   case DRM_CONF_THROTTLE:
+  return &throttle_ret;
+   case DRM_CONF_SHARE_FD:
+  return &share_fd_ret;
+   default:
+  break;
+   }
+   return NULL;
+}
+
+static const struct drm_driver_descriptor driver_descriptors[] = {
+{
+.name = "i915",
+.driver_name = "i915",
+.create_screen = pipe_i915_create_screen,
+.configuration = configuration_query,
+},
+{
+.name = "i965",
+.driver_name = "i915",
+.create_screen = pipe_ilo_create_screen,
+.configuration = configuration_query,
+},
+{
+.name = "nouveau",
+.driver_name = "nouveau",
+.create_screen = pipe_nouveau_create_screen,
+.configuration = configuration_query,
+},
+{
+.name = "r300",
+.driver_name = "radeon",
+.create_screen = pipe_r300_create_screen,
+.configuration = configuration_query,
+},
+{
+.name = "r600",
+.driver_name = "radeon",
+.create_screen = pipe_r600_create_screen,
+.configuration = configuration_query,
+},
+{
+.name = "radeonsi",
+.driver_name = "radeon",
+.create_screen = pipe_radeonsi_create_screen,
+.configuration = configuration_query,
+},
+{
+.name = "vmwgfx",
+.driver_name = "vmwgfx",
+.create_screen = pipe_vmwgfx_create_screen,
+.configuration = configuration_query,
+},
+{
+.name = "kgsl",
+.driver_name = "freedreno",
+.create_screen = pipe_freedreno_create_screen,
+.configuration = configuration_query,
+},
+{
+.name = "msm",
+.driver_name = "freedreno",
+.create_screen = pipe_freedreno_create_screen,
+.configuration = configuration_query,
+},
+{
+.name = "virtio_gpu",
+.driver_name = "virtio-gpu",
+.create_screen = pipe_virgl_create_screen,
+.configuration = configuration_query,
+},
+{
+.name = "vc4",
+.driver_name = "vc4",
+.create_screen = pipe_vc4_create_screen,
+.configuration = configuration_query,
+},
+#ifdef USE_VC4_SIMULATOR
+{
+.name = "i965",
+.driver_name = "vc4",
+.create_screen = pipe_vc4_create_screen,
+.configuration = configuration_query,
+},
+#endif
+};
+#endif
+
 bool
 pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, int fd)
 {
@@ -82,23 +188,36 @@ pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, 
int fd)
if (!ddev->base.driver_name)
   goto fail;
 
-   ddev->lib = pipe_loader_find_module(dev, PIPE_SEARCH_DIR);
+#ifdef GALLIUM_STATIC_TARGETS
+   for (int i = 0; i < ARRAY_SIZE(driver_descriptors); i++) {
+  if (strcmp(driver_descriptors[i].name, ddev->base.driver_name) == 0) {
+ ddev->dd = &driver_descriptors[i];
+ break;
+  }
+   }
+   if (!ddev->dd)
+  goto fail;
+#else
+   ddev->lib = pipe_loader_find_module(&ddev->base, PIPE_SEARCH_DIR);
if (!ddev->lib)
-  return fail;
+  goto fail;
 
ddev->dd = (const struct drm_driver_descriptor *)
   util_dl_get_proc_address(ddev->lib, "driver_descriptor");
 
/* sanity check on the name */
if (!ddev->dd

[Mesa-dev] [PATCH v2 37/40] targets/nine: add note about fd owndership

2015-11-20 Thread Emil Velikov
v2:
 - move autotools hunk into correct patch
 - correct the note based on Axel's feedback

Cc: Axel Davy 
Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/targets/d3dadapter9/drm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/gallium/targets/d3dadapter9/drm.c 
b/src/gallium/targets/d3dadapter9/drm.c
index c890191..84cfb94 100644
--- a/src/gallium/targets/d3dadapter9/drm.c
+++ b/src/gallium/targets/d3dadapter9/drm.c
@@ -216,6 +216,8 @@ drm_create_adapter( int fd,
 
 ctx->base.destroy = drm_destroy;
 
+/* Although the fd is provided from external source, mesa/nine
+ * takes ownership of it. */
 fd = loader_get_user_preferred_fd(fd, &different_device);
 ctx->fd = fd;
 ctx->base.linear_framebuffer = !!different_device;
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 39/40] targets/nine: remove unused static functions

2015-11-20 Thread Emil Velikov
Dead code since commit 8f50614910c40366d94964fe2c5da5772aff2f96

Cc: Axel Davy 
Cc: Tiziano Bacocco 
Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/targets/d3dadapter9/drm.c | 36 ---
 1 file changed, 36 deletions(-)

diff --git a/src/gallium/targets/d3dadapter9/drm.c 
b/src/gallium/targets/d3dadapter9/drm.c
index 00e58e0..ad712db 100644
--- a/src/gallium/targets/d3dadapter9/drm.c
+++ b/src/gallium/targets/d3dadapter9/drm.c
@@ -100,42 +100,6 @@ drm_destroy( struct d3dadapter9_context *ctx )
 FREE(ctx);
 }
 
-/* read a DWORD in the form 0x, which is how sysfs pci id stuff is
- * formatted. */
-static inline DWORD
-read_file_dword( const char *name )
-{
-char buf[32];
-int fd, r;
-
-fd = open(name, O_RDONLY);
-if (fd < 0) {
-DBG("Unable to get PCI information from `%s'\n", name);
-return 0;
-}
-
-r = read(fd, buf, 32);
-close(fd);
-
-return (r > 0) ? (DWORD)strtol(buf, NULL, 0) : 0;
-}
-
-/* sysfs doesn't expose the revision as its own file, so this function grabs a
- * dword at an offset in the raw PCI header. The reason this isn't used for all
- * data is that the kernel will make corrections but not expose them in the raw
- * header bytes. */
-static inline DWORD
-read_config_dword( int fd,
-   unsigned offset )
-{
-DWORD r = 0;
-
-if (lseek(fd, offset, SEEK_SET) != offset) { return 0; }
-if (read(fd, &r, 4) != 4) { return 0; }
-
-return r;
-}
-
 static inline void
 get_bus_info( int fd,
   DWORD *vendorid,
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 40/40] util: use RTLD_LOCAL with util_dl_open()

2015-11-20 Thread Emil Velikov
Otherwise we risk things blowing up due to conflicting symbols.

Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/auxiliary/util/u_dl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/util/u_dl.c 
b/src/gallium/auxiliary/util/u_dl.c
index aca435d..9b97d8d 100644
--- a/src/gallium/auxiliary/util/u_dl.c
+++ b/src/gallium/auxiliary/util/u_dl.c
@@ -45,7 +45,7 @@ struct util_dl_library *
 util_dl_open(const char *filename)
 {
 #if defined(PIPE_OS_UNIX)
-   return (struct util_dl_library *)dlopen(filename, RTLD_LAZY | RTLD_GLOBAL);
+   return (struct util_dl_library *)dlopen(filename, RTLD_LAZY | RTLD_LOCAL);
 #elif defined(PIPE_OS_WINDOWS)
return (struct util_dl_library *)LoadLibraryA(filename);
 #else
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 17/40] pipe-loader: annotate the ops as const data

2015-11-20 Thread Emil Velikov
Already defined as such in struct pipe_loader_device::ops.

Cc: Tom Stellard 
Cc: Francisco Jerez 
Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c | 4 ++--
 src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c 
b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
index 3b858e7..d4cb317 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
@@ -56,7 +56,7 @@ struct pipe_loader_drm_device {
 
 #define pipe_loader_drm_device(dev) ((struct pipe_loader_drm_device *)dev)
 
-static struct pipe_loader_ops pipe_loader_drm_ops;
+static const struct pipe_loader_ops pipe_loader_drm_ops;
 
 bool
 pipe_loader_drm_probe_fd(struct pipe_loader_device **dev, int fd)
@@ -185,7 +185,7 @@ pipe_loader_drm_create_screen(struct pipe_loader_device 
*dev)
return dd->create_screen(ddev->fd);
 }
 
-static struct pipe_loader_ops pipe_loader_drm_ops = {
+static const struct pipe_loader_ops pipe_loader_drm_ops = {
.create_screen = pipe_loader_drm_create_screen,
.configuration = pipe_loader_drm_configuration,
.release = pipe_loader_drm_release
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c 
b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
index 85e06d3..3db53e1 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
@@ -46,7 +46,7 @@ struct pipe_loader_sw_device {
 
 #define pipe_loader_sw_device(dev) ((struct pipe_loader_sw_device *)dev)
 
-static struct pipe_loader_ops pipe_loader_sw_ops;
+static const struct pipe_loader_ops pipe_loader_sw_ops;
 
 static bool
 pipe_loader_sw_probe_init_common(struct pipe_loader_sw_device *sdev)
@@ -249,7 +249,7 @@ pipe_loader_sw_create_screen(struct pipe_loader_device *dev)
return screen;
 }
 
-static struct pipe_loader_ops pipe_loader_sw_ops = {
+static const struct pipe_loader_ops pipe_loader_sw_ops = {
.create_screen = pipe_loader_sw_create_screen,
.configuration = pipe_loader_sw_configuration,
.release = pipe_loader_sw_release
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 33/40] target-helpers: remove inline_drm_helper.h

2015-11-20 Thread Emil Velikov
As of earlier all the targets use the non inline version. Don't forget
to remove the function prototypes/declarations.

v2: rebase on top of virgl support.

Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 .../auxiliary/target-helpers/inline_drm_helper.h   | 371 -
 src/gallium/include/state_tracker/drm_driver.h |   6 -
 2 files changed, 377 deletions(-)
 delete mode 100644 src/gallium/auxiliary/target-helpers/inline_drm_helper.h

diff --git a/src/gallium/auxiliary/target-helpers/inline_drm_helper.h 
b/src/gallium/auxiliary/target-helpers/inline_drm_helper.h
deleted file mode 100644
index c57fbac..000
--- a/src/gallium/auxiliary/target-helpers/inline_drm_helper.h
+++ /dev/null
@@ -1,371 +0,0 @@
-#ifndef INLINE_DRM_HELPER_H
-#define INLINE_DRM_HELPER_H
-
-#include "state_tracker/drm_driver.h"
-#include "target-helpers/inline_debug_helper.h"
-#include "loader.h"
-
-#if GALLIUM_SOFTPIPE
-#include "target-helpers/inline_sw_helper.h"
-#include "sw/kms-dri/kms_dri_sw_winsys.h"
-#endif
-
-#if GALLIUM_I915
-#include "i915/drm/i915_drm_public.h"
-#include "i915/i915_public.h"
-#endif
-
-#if GALLIUM_ILO
-#include "intel/drm/intel_drm_public.h"
-#include "ilo/ilo_public.h"
-#endif
-
-#if GALLIUM_NOUVEAU
-#include "nouveau/drm/nouveau_drm_public.h"
-#endif
-
-#if GALLIUM_R300
-#include "radeon/radeon_winsys.h"
-#include "radeon/drm/radeon_drm_public.h"
-#include "r300/r300_public.h"
-#endif
-
-#if GALLIUM_R600
-#include "radeon/radeon_winsys.h"
-#include "radeon/drm/radeon_drm_public.h"
-#include "r600/r600_public.h"
-#endif
-
-#if GALLIUM_RADEONSI
-#include "radeon/radeon_winsys.h"
-#include "radeon/drm/radeon_drm_public.h"
-#include "amdgpu/drm/amdgpu_public.h"
-#include "radeonsi/si_public.h"
-#endif
-
-#if GALLIUM_VMWGFX
-#include "svga/drm/svga_drm_public.h"
-#include "svga/svga_public.h"
-#endif
-
-#if GALLIUM_FREEDRENO
-#include "freedreno/drm/freedreno_drm_public.h"
-#endif
-
-#if GALLIUM_VC4
-#include "vc4/drm/vc4_drm_public.h"
-#endif
-
-#if GALLIUM_VIRGL
-#include "virgl/drm/virgl_drm_public.h"
-#include "virgl/virgl_public.h"
-#endif
-
-static char* driver_name = NULL;
-
-/* XXX: We need to teardown the winsys if *screen_create() fails. */
-
-#if defined(GALLIUM_I915)
-
-static struct pipe_screen *
-pipe_i915_create_screen(int fd)
-{
-   struct i915_winsys *iws;
-   struct pipe_screen *screen;
-
-   iws = i915_drm_winsys_create(fd);
-   if (!iws)
-  return NULL;
-
-   screen = i915_screen_create(iws);
-   return screen ? debug_screen_wrap(screen) : NULL;
-}
-#endif
-
-#if defined(GALLIUM_ILO)
-
-static struct pipe_screen *
-pipe_ilo_create_screen(int fd)
-{
-   struct intel_winsys *iws;
-   struct pipe_screen *screen;
-
-   iws = intel_winsys_create_for_fd(fd);
-   if (!iws)
-  return NULL;
-
-   screen = ilo_screen_create(iws);
-   return screen ? debug_screen_wrap(screen) : NULL;
-}
-#endif
-
-#if defined(GALLIUM_NOUVEAU)
-
-static struct pipe_screen *
-pipe_nouveau_create_screen(int fd)
-{
-   struct pipe_screen *screen;
-
-   screen = nouveau_drm_screen_create(fd);
-   return screen ? debug_screen_wrap(screen) : NULL;
-}
-#endif
-
-#if defined(GALLIUM_R300)
-
-static struct pipe_screen *
-pipe_r300_create_screen(int fd)
-{
-   struct radeon_winsys *rw;
-
-   rw = radeon_drm_winsys_create(fd, r300_screen_create);
-   return rw ? debug_screen_wrap(rw->screen) : NULL;
-}
-#endif
-
-#if defined(GALLIUM_R600)
-
-static struct pipe_screen *
-pipe_r600_create_screen(int fd)
-{
-   struct radeon_winsys *rw;
-
-   rw = radeon_drm_winsys_create(fd, r600_screen_create);
-   return rw ? debug_screen_wrap(rw->screen) : NULL;
-}
-#endif
-
-#if defined(GALLIUM_RADEONSI)
-
-static struct pipe_screen *
-pipe_radeonsi_create_screen(int fd)
-{
-   struct radeon_winsys *rw;
-
-   /* First, try amdgpu. */
-   rw = amdgpu_winsys_create(fd, radeonsi_screen_create);
-
-   if (!rw)
-  rw = radeon_drm_winsys_create(fd, radeonsi_screen_create);
-
-   return rw ? debug_screen_wrap(rw->screen) : NULL;
-}
-#endif
-
-#if defined(GALLIUM_VMWGFX)
-
-static struct pipe_screen *
-pipe_vmwgfx_create_screen(int fd)
-{
-   struct svga_winsys_screen *sws;
-   struct pipe_screen *screen;
-
-   sws = svga_drm_winsys_screen_create(fd);
-   if (!sws)
-  return NULL;
-
-   screen = svga_screen_create(sws);
-   return screen ? debug_screen_wrap(screen) : NULL;
-}
-#endif
-
-#if defined(GALLIUM_FREEDRENO)
-
-static struct pipe_screen *
-pipe_freedreno_create_screen(int fd)
-{
-   struct pipe_screen *screen;
-
-   screen = fd_drm_screen_create(fd);
-   return screen ? debug_screen_wrap(screen) : NULL;
-}
-#endif
-
-#if defined(GALLIUM_VIRGL)
-
-static struct pipe_screen *
-pipe_virgl_create_screen(int fd)
-{
-   struct virgl_winsys *vws;
-   struct pipe_screen *screen;
-
-   vws = virgl_drm_winsys_create(fd);
-   if (!vws)
-  return NULL;
-
-   screen = virgl_create_screen(vws);
-   return screen ? debug_screen_wrap(screen) : NULL;
-}
-#endif
-
-#if defined(GALLIUM_VC4)
-
-static struct pipe_scre

[Mesa-dev] [PATCH v2 32/40] {st, targets}/nine: use static/dynamic pipe-loader

2015-11-20 Thread Emil Velikov
Analogous to previous commits.

v2: add the missing winsys libs linkage

Cc: Axel Davy 
Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/targets/d3dadapter9/Makefile.am | 14 +-
 src/gallium/targets/d3dadapter9/drm.c   | 24 +++-
 2 files changed, 8 insertions(+), 30 deletions(-)

diff --git a/src/gallium/targets/d3dadapter9/Makefile.am 
b/src/gallium/targets/d3dadapter9/Makefile.am
index 776f86b..d1d9829 100644
--- a/src/gallium/targets/d3dadapter9/Makefile.am
+++ b/src/gallium/targets/d3dadapter9/Makefile.am
@@ -34,12 +34,6 @@ AM_CFLAGS = \
$(GALLIUM_TARGET_CFLAGS) \
$(VISIBILITY_CFLAGS)
 
-if HAVE_GALLIUM_STATIC_TARGETS
-AM_CPPFLAGS = \
-   -DGALLIUM_STATIC_TARGETS=1
-
-endif
-
 ninedir = $(D3D_DRIVER_INSTALL_DIR)
 nine_LTLIBRARIES = d3dadapter9.la
 
@@ -71,7 +65,6 @@ d3dadapter9_la_LIBADD = \
$(top_builddir)/src/glsl/libnir.la \
$(top_builddir)/src/gallium/state_trackers/nine/libninetracker.la \
$(top_builddir)/src/util/libmesautil.la \
-   $(top_builddir)/src/gallium/winsys/sw/wrapper/libwsw.la \
$(EXPAT_LIBS) \
$(GALLIUM_COMMON_LIB_DEPS)
 
@@ -80,7 +73,7 @@ EXTRA_DIST = d3dadapter9.sym
 
 TARGET_DRIVERS =
 TARGET_CPPFLAGS =
-TARGET_LIB_DEPS = $(top_builddir)/src/loader/libloader.la
+TARGET_LIB_DEPS =
 
 include $(top_srcdir)/src/gallium/drivers/i915/Automake.inc
 
@@ -104,7 +97,10 @@ include 
$(top_srcdir)/src/gallium/drivers/llvmpipe/Automake.inc
 if HAVE_GALLIUM_STATIC_TARGETS
 
 d3dadapter9_la_CPPFLAGS = $(AM_CPPFLAGS) $(TARGET_CPPFLAGS)
-d3dadapter9_la_LIBADD += $(TARGET_LIB_DEPS) \
+d3dadapter9_la_LIBADD += \
+   
$(top_builddir)/src/gallium/auxiliary/pipe-loader/libpipe_loader_static.la \
+   $(GALLIUM_PIPE_LOADER_WINSYS_LIBS) \
+   $(TARGET_LIB_DEPS) \
$(TARGET_RADEON_WINSYS) $(TARGET_RADEON_COMMON)
 
 else # HAVE_GALLIUM_STATIC_TARGETS
diff --git a/src/gallium/targets/d3dadapter9/drm.c 
b/src/gallium/targets/d3dadapter9/drm.c
index 78896cb..c890191 100644
--- a/src/gallium/targets/d3dadapter9/drm.c
+++ b/src/gallium/targets/d3dadapter9/drm.c
@@ -29,8 +29,7 @@
 #include "pipe/p_screen.h"
 #include "pipe/p_state.h"
 
-#include "target-helpers/inline_drm_helper.h"
-#include "target-helpers/inline_wrapper_sw_helper.h"
+#include "target-helpers/drm_helper.h"
 #include "state_tracker/drm_driver.h"
 
 #include "d3dadapter/d3dadapter9.h"
@@ -91,12 +90,10 @@ drm_destroy( struct d3dadapter9_context *ctx )
 else if (ctx->hal)
 ctx->hal->destroy(ctx->hal);
 
-#if !GALLIUM_STATIC_TARGETS
 if (drm->swdev)
 pipe_loader_release(&drm->swdev, 1);
 if (drm->dev)
 pipe_loader_release(&drm->dev, 1);
-#endif
 
 close(drm->fd);
 FREE(ctx);
@@ -223,10 +220,6 @@ drm_create_adapter( int fd,
 ctx->fd = fd;
 ctx->base.linear_framebuffer = !!different_device;
 
-#if GALLIUM_STATIC_TARGETS
-ctx->base.hal = dd_create_screen(fd);
-#else
-/* use pipe-loader to dlopen appropriate drm driver */
 if (!pipe_loader_drm_probe_fd(&ctx->dev, fd)) {
 ERR("Failed to probe drm fd %d.\n", fd);
 FREE(ctx);
@@ -234,22 +227,15 @@ drm_create_adapter( int fd,
 return D3DERR_DRIVERINTERNALERROR;
 }
 
-/* use pipe-loader to create a drm screen (hal) */
 ctx->base.hal = pipe_loader_create_screen(ctx->dev);
-#endif
 if (!ctx->base.hal) {
 ERR("Unable to load requested driver.\n");
 drm_destroy(&ctx->base);
 return D3DERR_DRIVERINTERNALERROR;
 }
 
-#if GALLIUM_STATIC_TARGETS
-dmabuf_ret = dd_configuration(DRM_CONF_SHARE_FD);
-throttle_ret = dd_configuration(DRM_CONF_THROTTLE);
-#else
 dmabuf_ret = pipe_loader_configuration(ctx->dev, DRM_CONF_SHARE_FD);
 throttle_ret = pipe_loader_configuration(ctx->dev, DRM_CONF_THROTTLE);
-#endif // GALLIUM_STATIC_TARGETS
 if (!dmabuf_ret || !dmabuf_ret->val.val_bool) {
 ERR("The driver is not capable of dma-buf sharing."
 "Abandon to load nine state tracker\n");
@@ -296,14 +282,10 @@ drm_create_adapter( int fd,
 driDestroyOptionCache(&userInitOptions);
 driDestroyOptionInfo(&defaultInitOptions);
 
-#if GALLIUM_STATIC_TARGETS
-ctx->base.ref = sw_screen_wrap(ctx->base.hal);
-#else
 /* wrap it to create a software screen that can share resources */
-if (pipe_loader_sw_probe_wrapped(&ctx->swdev, ctx->base.hal)) {
+if (pipe_loader_sw_probe_wrapped(&ctx->swdev, ctx->base.hal))
 ctx->base.ref = pipe_loader_create_screen(ctx->swdev);
-}
-#endif
+
 if (!ctx->base.ref) {
 ERR("Couldn't wrap drm screen to swrast screen. Software devices "
 "will be unavailable.\n");
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 36/40] auxiliary/vl: Don't close the drm fd on failure

2015-11-20 Thread Emil Velikov
Ported from an identically named commit in st/xa

commit 35cf3831d71770211f29da6608313dc1f6213d7b
Author: Thomas Hellstrom 
Date:   Thu Jul 3 02:07:36 2014 -0700

st/xa: Don't close the drm fd on failure v2

Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/auxiliary/vl/vl_winsys_dri.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri.c 
b/src/gallium/auxiliary/vl/vl_winsys_dri.c
index c4f9295..ae0d4cd 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri.c
@@ -402,7 +402,7 @@ vl_dri2_screen_create(Display *display, int screen)
if (authenticate == NULL || !authenticate->authenticated)
   goto free_authenticate;
 
-   if (pipe_loader_drm_probe_fd(&scrn->base.dev, fd))
+   if (pipe_loader_drm_probe_fd(&scrn->base.dev, dup(fd)))
   scrn->base.pscreen = pipe_loader_create_screen(scrn->base.dev);
 
if (!scrn->base.pscreen)
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 38/40] targets/nine: add note about messy header inclusion order

2015-11-20 Thread Emil Velikov
Cc: Axel Davy 
Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/targets/d3dadapter9/drm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gallium/targets/d3dadapter9/drm.c 
b/src/gallium/targets/d3dadapter9/drm.c
index 84cfb94..00e58e0 100644
--- a/src/gallium/targets/d3dadapter9/drm.c
+++ b/src/gallium/targets/d3dadapter9/drm.c
@@ -20,6 +20,7 @@
  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  * USE OR OTHER DEALINGS IN THE SOFTWARE. */
 
+/* XXX: header order is slightly screwy here */
 #include "loader.h"
 
 #include "adapter9.h"
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 22/40] pipe-loader: wire up the 'static' sw pipe-loader

2015-11-20 Thread Emil Velikov
Analogous to previous commit with a small catch.

As the sw inline helpers are mere wrappers, and the screen <> winsys
split is more prominent (with the latter not being part of the final
pipe-driver), things will just work.

v2: rebase on top of earlier 'consolitate teardown' changes

Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c | 47 ++
 1 file changed, 47 insertions(+)

diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c 
b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
index 3db53e1..5539a73 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
@@ -40,7 +40,9 @@
 struct pipe_loader_sw_device {
struct pipe_loader_device base;
const struct sw_driver_descriptor *dd;
+#ifndef GALLIUM_STATIC_TARGETS
struct util_dl_library *lib;
+#endif
struct sw_winsys *ws;
 };
 
@@ -48,6 +50,41 @@ struct pipe_loader_sw_device {
 
 static const struct pipe_loader_ops pipe_loader_sw_ops;
 
+#ifdef GALLIUM_STATIC_TARGETS
+static const struct sw_driver_descriptor driver_descriptors = {
+   .create_screen = sw_screen_create,
+   .winsys = {
+#ifdef HAVE_PIPE_LOADER_DRI
+  {
+ .name = "dri",
+ .create_winsys = dri_create_sw_winsys,
+  },
+#endif
+#ifdef HAVE_PIPE_LOADER_KMS
+  {
+ .name = "kms_dri",
+ .create_winsys = kms_dri_create_winsys,
+  },
+#endif
+/**
+ * XXX: Do not include these two for non autotools builds.
+ * They don't have neither opencl nor nine, where these are used.
+ */
+#ifndef DROP_PIPE_LOADER_MISC
+  {
+ .name = "null",
+ .create_winsys = null_sw_create,
+  },
+  {
+ .name = "wrapped",
+ .create_winsys = wrapper_sw_winsys_wrap_pipe_screen,
+  },
+#endif
+  { 0 },
+   }
+};
+#endif
+
 static bool
 pipe_loader_sw_probe_init_common(struct pipe_loader_sw_device *sdev)
 {
@@ -55,6 +92,11 @@ pipe_loader_sw_probe_init_common(struct 
pipe_loader_sw_device *sdev)
sdev->base.driver_name = "swrast";
sdev->base.ops = &pipe_loader_sw_ops;
 
+#ifdef GALLIUM_STATIC_TARGETS
+   sdev->dd = &driver_descriptors;
+   if (!sdev->dd)
+  return false;
+#else
sdev->lib = pipe_loader_find_module(&sdev->base, PIPE_SEARCH_DIR);
if (!sdev->lib)
   return false;
@@ -67,6 +109,7 @@ pipe_loader_sw_probe_init_common(struct 
pipe_loader_sw_device *sdev)
   sdev->lib = NULL;
   return false;
}
+#endif
 
return true;
 }
@@ -74,8 +117,10 @@ pipe_loader_sw_probe_init_common(struct 
pipe_loader_sw_device *sdev)
 static void
 pipe_loader_sw_probe_teardown_common(struct pipe_loader_sw_device *sdev)
 {
+#ifndef GALLIUM_STATIC_TARGETS
if (sdev->lib)
   util_dl_close(sdev->lib);
+#endif
 }
 
 #ifdef HAVE_PIPE_LOADER_DRI
@@ -222,8 +267,10 @@ pipe_loader_sw_release(struct pipe_loader_device **dev)
 {
struct pipe_loader_sw_device *sdev = pipe_loader_sw_device(*dev);
 
+#ifndef GALLIUM_STATIC_TARGETS
if (sdev->lib)
   util_dl_close(sdev->lib);
+#endif
 
FREE(sdev);
*dev = NULL;
-- 
2.6.2

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


[Mesa-dev] [PATCH v2 20/40] pipe-loader: add a dummy 'static' pipe-loader

2015-11-20 Thread Emil Velikov
It is to be used in contrast of the dynamic one. The state-tracker does
not need to know if the pipe-driver is built into the final blob or
a separate object. This will allow us to move the logic to the final
step (in target) where the appropriate pipe-loader will be chosen.

Cc: Tom Stellard 
Cc: Francisco Jerez 
Signed-off-by: Emil Velikov 
Acked-by: Rob Clark 
---
 src/gallium/auxiliary/pipe-loader/Makefile.am | 23 ---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/pipe-loader/Makefile.am 
b/src/gallium/auxiliary/pipe-loader/Makefile.am
index 974cf08..6a4a667 100644
--- a/src/gallium/auxiliary/pipe-loader/Makefile.am
+++ b/src/gallium/auxiliary/pipe-loader/Makefile.am
@@ -5,12 +5,24 @@ include $(top_srcdir)/src/gallium/Automake.inc
 AM_CFLAGS = \
-I$(top_srcdir)/src/loader \
-I$(top_srcdir)/src/gallium/winsys \
-   -DPIPE_SEARCH_DIR=\"$(libdir)/gallium-pipe\" \
$(GALLIUM_PIPE_LOADER_DEFINES) \
$(GALLIUM_CFLAGS) \
$(VISIBILITY_CFLAGS)
 
-noinst_LTLIBRARIES = libpipe_loader_dynamic.la
+noinst_LTLIBRARIES = \
+   libpipe_loader_static.la \
+   libpipe_loader_dynamic.la
+
+libpipe_loader_static_la_CFLAGS = \
+   $(AM_CFLAGS) \
+   -DGALLIUM_STATIC_TARGETS=1
+
+libpipe_loader_dynamic_la_CFLAGS = \
+   $(AM_CFLAGS) \
+   -DPIPE_SEARCH_DIR=\"$(libdir)/gallium-pipe\"
+
+libpipe_loader_static_la_SOURCES = \
+   $(COMMON_SOURCES)
 
 libpipe_loader_dynamic_la_SOURCES = \
$(COMMON_SOURCES)
@@ -19,11 +31,16 @@ if HAVE_LIBDRM
 AM_CFLAGS += \
$(LIBDRM_CFLAGS)
 
+libpipe_loader_static_la_SOURCES += \
+   $(DRM_SOURCES)
+
 libpipe_loader_dynamic_la_SOURCES += \
$(DRM_SOURCES)
 
+libpipe_loader_static_la_LIBADD = \
+   $(top_builddir)/src/loader/libloader.la
+
 libpipe_loader_dynamic_la_LIBADD = \
$(top_builddir)/src/loader/libloader.la
 
 endif
-
-- 
2.6.2

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


Re: [Mesa-dev] [PATCH 2/2] radeon: re-prepare query buffers on begin_query for predicate queries

2015-11-20 Thread Marek Olšák
For the series:

Reviewed-by: Marek Olšák 

Marek

On Fri, Nov 20, 2015 at 5:38 PM, Nicolai Hähnle  wrote:
> The point of prepare_buffer is to ensure that the query buffer contains valid
> initial data for conditional rendering: as long as the buffer is initialized
> correctly, the GPU is able to tell whether query results have been written
> already (and wait or fall back to unconditional rendering if desired).
>
> This means prepare_buffer needs to be called again when a buffer is reused.
>
> Conversely, for queries that cannot be used for conditional rendering
> (notably pipeline statistics), we can re-use buffers immediately, and they
> do not need to be initialized.
> ---
>  src/gallium/drivers/radeon/r600_query.c | 32 +---
>  src/gallium/drivers/radeon/r600_query.h |  1 +
>  2 files changed, 18 insertions(+), 15 deletions(-)
>
> diff --git a/src/gallium/drivers/radeon/r600_query.c 
> b/src/gallium/drivers/radeon/r600_query.c
> index 4726b78..fb974c7 100644
> --- a/src/gallium/drivers/radeon/r600_query.c
> +++ b/src/gallium/drivers/radeon/r600_query.c
> @@ -242,7 +242,7 @@ static struct r600_resource *r600_new_query_buffer(struct 
> r600_common_context *c
> pipe_buffer_create(ctx->b.screen, PIPE_BIND_CUSTOM,
>PIPE_USAGE_STAGING, buf_size);
>
> -   if (query->ops->prepare_buffer)
> +   if (query->flags & R600_QUERY_HW_FLAG_PREDICATE)
> query->ops->prepare_buffer(ctx, query, buf);
>
> return buf;
> @@ -251,15 +251,11 @@ static struct r600_resource 
> *r600_new_query_buffer(struct r600_common_context *c
>  static void r600_query_hw_prepare_buffer(struct r600_common_context *ctx,
>  struct r600_query_hw *query,
>  struct r600_resource *buffer)
> - {
> -   uint32_t *results;
> -
> -   if (query->b.type == PIPE_QUERY_TIME_ELAPSED ||
> -   query->b.type == PIPE_QUERY_TIMESTAMP)
> -   return;
> -
> -   results = r600_buffer_map_sync_with_rings(ctx, buffer,
> - PIPE_TRANSFER_WRITE);
> +{
> +   /* Callers ensure that the buffer is currently unused by the GPU. */
> +   uint32_t *results = ctx->ws->buffer_map(buffer->cs_buf, NULL,
> +   PIPE_TRANSFER_WRITE |
> +   PIPE_TRANSFER_UNSYNCHRONIZED);
>
> memset(results, 0, buffer->b.b.width0);
>
> @@ -339,6 +335,7 @@ static struct pipe_query *r600_query_hw_create(struct 
> r600_common_context *rctx,
> query->result_size = 16 * rctx->max_db;
> query->num_cs_dw_begin = 6;
> query->num_cs_dw_end = 6;
> +   query->flags |= R600_QUERY_HW_FLAG_PREDICATE;
> break;
> case PIPE_QUERY_TIME_ELAPSED:
> query->result_size = 16;
> @@ -361,6 +358,7 @@ static struct pipe_query *r600_query_hw_create(struct 
> r600_common_context *rctx,
> query->num_cs_dw_begin = 6;
> query->num_cs_dw_end = 6;
> query->stream = index;
> +   query->flags |= R600_QUERY_HW_FLAG_PREDICATE;
> break;
> case PIPE_QUERY_PIPELINE_STATISTICS:
> /* 11 values on EG, 8 on R600. */
> @@ -667,11 +665,15 @@ static void r600_query_hw_reset_buffers(struct 
> r600_common_context *rctx,
> FREE(qbuf);
> }
>
> -   /* Obtain a new buffer if the current one can't be mapped without a 
> stall. */
> -   if (r600_rings_is_buffer_referenced(rctx, query->buffer.buf->cs_buf, 
> RADEON_USAGE_READWRITE) ||
> -   !rctx->ws->buffer_wait(query->buffer.buf->buf, 0, 
> RADEON_USAGE_READWRITE)) {
> -   pipe_resource_reference((struct 
> pipe_resource**)&query->buffer.buf, NULL);
> -   query->buffer.buf = r600_new_query_buffer(rctx, query);
> +   if (query->flags & R600_QUERY_HW_FLAG_PREDICATE) {
> +   /* Obtain a new buffer if the current one can't be mapped 
> without a stall. */
> +   if (r600_rings_is_buffer_referenced(rctx, 
> query->buffer.buf->cs_buf, RADEON_USAGE_READWRITE) ||
> +   !rctx->ws->buffer_wait(query->buffer.buf->buf, 0, 
> RADEON_USAGE_READWRITE)) {
> +   pipe_resource_reference((struct 
> pipe_resource**)&query->buffer.buf, NULL);
> +   query->buffer.buf = r600_new_query_buffer(rctx, 
> query);
> +   } else {
> +   query->ops->prepare_buffer(rctx, query, 
> query->buffer.buf);
> +   }
> }
>
> query->buffer.results_end = 0;
> diff --git a/src/gallium/drivers/radeon/r600_query.h 
> b/src/gallium/drivers/radeon/r600_query.h
> index 5d12191..b20beec 100644
> --- a/src/gallium/drivers/radeon/r600_query.h
> +++ b/src/gallium/drivers/radeon/r600_query.h
> @@ 

  1   2   >