Re: [Mesa-dev] [PATCH v1 0/7] Implement commont gralloc_handle_t in libdrm

2018-03-25 Thread Tapani Pälli



On 03/23/2018 03:20 PM, Tomasz Figa wrote:

On Fri, Mar 23, 2018 at 10:15 PM, Stefan Schake  wrote:

On Fri, Mar 23, 2018 at 1:02 PM, Tomasz Figa  wrote:

On Fri, Mar 23, 2018 at 8:52 PM, Robert Foss  wrote:

Hey Chih-Wei,


On 03/23/2018 03:43 AM, Chih-Wei Huang wrote:


2018-03-22 16:23 GMT+08:00 Tomasz Figa :


Hi Chih-Wei,

On Thu, Feb 22, 2018 at 2:53 PM, Chih-Wei Huang 
wrote:


2018-02-21 3:03 GMT+08:00 Rob Herring :



Perhaps worth revisiting. Given we've failed to progress at all since
then may change opinions some. We already have to handle multiple
opens share the same pipe_screen, so I don't think reusing the fd buys
us anything.

Maybe we're close to the point of removing the flink name support too.
The android-x86 folks have been working to get dma-bufs working.
Chih-Wei, any comments on this?



Ah! Sorry. I didn't catch or understand the details.
Did you mean the attempts to use drm_hwcomposer
in android-x86?
My understanding so far is most x86 GPUs won't work
except some very limited models.
It's due to kernel driver issues which may never be solved.
So we can't drop the flink name support.
Please correct me if I am wrong.



Could you elaborate a bit more on those GPUs that won't work and
corresponding driver issues? We're running cros_gralloc on Intel and
AMD GPUs, with DMA-buf and render-node only setup and we haven't seen
any problems.



Hi Tomasz,
I remember (in our previous discussion) you said
CrOS uses your own hwcomposer (proprietary?) so
the story may be different.

What we have tried is gbm_gralloc + drm_hwcomposer
and I reported the issues here:

https://lists.freedesktop.org/archives/dri-devel/2017-September/153580.html



I took the liberty of moving you nouveau issue into the drm_hwc gitlab
bugtracker.

https://gitlab.freedesktop.org/drm-hwcomposer/drm-hwcomposer/issues/1


Hmm, reading further in that thread, that seemed to be related to
missing nouveau.atomic=1 in kernel command line:
https://lists.freedesktop.org/archives/dri-devel/2017-September/153681.html

It went further, but didn't work very well. I suspect that could have
been related to DRM_GRALLOC_GET_FD being used, which makes the mess
from the system due to gralloc and Mesa stepping on each other's GEM
handles (which aren't reference counted by design and importing a
buffer several time will always return the same handle).


I think mixing in drm_hwcomposer here would be trying to do too much at once.
It has a lot of requirements (atomic driver, fence fds, alpha/rotation props)
and no fallback path to speak of. Coming from drm_gralloc where I think in
practice all composition is punted to the hwui GL compositor and DRM is
only around for putting the final framebuffer on a display, it's asking a lot
of some of the (legacy) hardware used for Android-x86.


Do we have any feasible alternative?

Chih-Wei pointed me to the drm_gralloc used on android-x86 and it
seems to seriously pre-date any DMA-buf support. Everything there is
done with the assumption that GEM names are used and adding DMA-buf
would require a significant rework of all the code.


One possibility for android-x86 project would be to have a separate 
lunch target (and libraries) for the old machines. Those ones unlikely 
support OpenGL ES 3.1?), hardware planes, Vulkan or other modern Android 
requirements anyway. These machines could run with old (and stable) 
Mesa, drm_gralloc and maybe the old hwcomposer from Intel that does hwc 
1.0/1.1, there were even patches to use planes there via drmModeSetPlane 
in video usecases IIRC.



That leaves us with gbm_gralloc (or possibly Chromium minigbm, used by
Android-IA too), which doesn't implement the legacy FB management, so
some hwcomposer would be needed.

Best regards,
Tomasz


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


Re: [Mesa-dev] [PATCH] i965/vec4: Fix null destination register in 3-source instructions

2018-03-25 Thread Tapani Pälli

Yes, this fixes the app where I saw this issue, thanks!

Tested-by: Tapani Pälli 

On 03/23/2018 10:54 PM, Ian Romanick wrote:

From: Ian Romanick 

A recent commit (see below) triggered some cases where conditional
modifier propagation and dead code elimination would cause a MAD
instruction like the following to be generated:

 mad.l.f0  null, ...

Matt pointed out that fs_visitor::fixup_3src_null_dest() fixes cases
like this in the scalar backend.  This commit basically ports that code
to the vec4 backend.

NOTE: I have sent a couple tests to the piglit list that reproduce this
bug *without* the commit mentioned below.  This commit fixes those
tests.

Signed-off-by: Ian Romanick 
Cc: Tapani Pälli 
Cc: Matt Turner 
Cc: mesa-sta...@lists.freedesktop.org
Fixes: ee63933a7 ("nir: Distribute binary operations with constants into bcsel")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105704
---
  src/intel/compiler/brw_vec4.cpp | 26 ++
  src/intel/compiler/brw_vec4.h   |  1 +
  2 files changed, 27 insertions(+)

diff --git a/src/intel/compiler/brw_vec4.cpp b/src/intel/compiler/brw_vec4.cpp
index e483814..fb8ffee 100644
--- a/src/intel/compiler/brw_vec4.cpp
+++ b/src/intel/compiler/brw_vec4.cpp
@@ -1945,6 +1945,30 @@ is_align1_df(vec4_instruction *inst)
 }
  }
  
+/**

+ * Three source instruction must have a GRF/MRF destination register.
+ * ARF NULL is not allowed.  Fix that up by allocating a temporary GRF.
+ */
+void
+vec4_visitor::fixup_3src_null_dest()
+{
+   bool progress = false;
+
+   foreach_block_and_inst_safe (block, vec4_instruction, inst, cfg) {
+  if (inst->is_3src(devinfo) && inst->dst.is_null()) {
+ const unsigned size_written = type_sz(inst->dst.type);
+ const unsigned num_regs = DIV_ROUND_UP(size_written, REG_SIZE);
+
+ inst->dst = retype(dst_reg(VGRF, alloc.allocate(num_regs)),
+inst->dst.type);
+ progress = true;
+  }
+   }
+
+   if (progress)
+  invalidate_live_intervals();
+}
+
  void
  vec4_visitor::convert_to_hw_regs()
  {
@@ -2696,6 +2720,8 @@ vec4_visitor::run()
OPT(scalarize_df);
 }
  
+   fixup_3src_null_dest();

+
 bool allocated_without_spills = reg_allocate();
  
 if (!allocated_without_spills) {

diff --git a/src/intel/compiler/brw_vec4.h b/src/intel/compiler/brw_vec4.h
index 39ce51c..71880db 100644
--- a/src/intel/compiler/brw_vec4.h
+++ b/src/intel/compiler/brw_vec4.h
@@ -158,6 +158,7 @@ public:
 void opt_set_dependency_control();
 void opt_schedule_instructions();
 void convert_to_hw_regs();
+   void fixup_3src_null_dest();
  
 bool is_supported_64bit_region(vec4_instruction *inst, unsigned arg);

 bool lower_simd_width();


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


[Mesa-dev] [Bug 105738] commit f7ffa504a065dc2631fd38cc5fe885b277f4e7e7 causes artifacting in radv

2018-03-25 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105738

gloriouseggr...@gmail.com changed:

   What|Removed |Added

 OS|All |Linux (All)
  Component|Other   |Drivers/Vulkan/radeon
   Hardware|Other   |x86-64 (AMD64)

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


[Mesa-dev] [Bug 105670] [regression][hang] Trine1EE hangs GPU after loading screen on Mesa3D-17.3 and later

2018-03-25 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105670

--- Comment #17 from Timothy Arceri  ---
We still need to create a piglit test for this but here is the fix for NIR
also:

https://patchwork.freedesktop.org/patch/212882/

It seems once the loop in unrolled NIR then optimises this whole shader down
to:

vec4 32 ssa_0 = load_const (0x /* 0.00 */, 0x /*
0.00 */, 0x /* 0.00 */, 0x /* 0.00 */)
intrinsic store_var (ssa_0) (ps_out) (15) /* wrmask=xyzw */
/* succs: block_0 */
block block_0:

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


[Mesa-dev] [PATCH] nir: fix crash in loop unroll corner case

2018-03-25 Thread Timothy Arceri
When an if nesting inside anouther if is optimised away we can
end up with a loop terminator and following block that looks like
this:

if ssa_596 {
block block_5:
/* preds: block_4 */
vec1 32 ssa_601 = load_const (0x /* -nan */)
break
/* succs: block_8 */
} else {
block block_6:
/* preds: block_4 */
/* succs: block_7 */
}
block block_7:
/* preds: block_6 */
vec1 32 ssa_602 = phi block_6: ssa_552
vec1 32 ssa_603 = phi block_6: ssa_553
vec1 32 ssa_604 = iadd ssa_551, ssa_66

The problem is the phis. Loop unrolling expects the last block in
the loop to be empty once we splice the instructions in the last
block into the continue branch. The problem is we cant move phis
so here we lower the phis to regs when preparing the loop for
unrolling. As it could be possible to have multiple additional
blocks/ifs following the terminator we just convert all phis at
the top level of the loop body for simplicity.

We also add some comments to loop_prepare_for_unroll() while we
are here.

Fixes: 51daccb289eb "nir: add a loop unrolling pass"

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105670
---
 src/compiler/nir/nir_opt_loop_unroll.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/compiler/nir/nir_opt_loop_unroll.c 
b/src/compiler/nir/nir_opt_loop_unroll.c
index 79d04f978bc..85df3097264 100644
--- a/src/compiler/nir/nir_opt_loop_unroll.c
+++ b/src/compiler/nir/nir_opt_loop_unroll.c
@@ -37,10 +37,10 @@
 #define LOOP_UNROLL_LIMIT 26
 
 /* Prepare this loop for unrolling by first converting to lcssa and then
- * converting the phis from the loops first block and the block that follows
- * the loop into regs.  Partially converting out of SSA allows us to unroll
- * the loop without having to keep track of and update phis along the way
- * which gets tricky and doesn't add much value over conveting to regs.
+ * converting the phis from the top level of the loop body to regs.
+ * Partially converting out of SSA allows us to unroll the loop without having
+ * to keep track of and update phis along the way which gets tricky and
+ * doesn't add much value over conveting to regs.
  *
  * The loop may have a continue instruction at the end of the loop which does
  * nothing.  Once we're out of SSA, we can safely delete it so we don't have
@@ -51,13 +51,20 @@ loop_prepare_for_unroll(nir_loop *loop)
 {
nir_convert_loop_to_lcssa(loop);
 
-   nir_lower_phis_to_regs_block(nir_loop_first_block(loop));
+   /* Lower phis at the top level of the loop body */
+   foreach_list_typed_safe(nir_cf_node, node, node, &loop->body) {
+  if (nir_cf_node_block == node->type) {
+ nir_lower_phis_to_regs_block(nir_cf_node_as_block(node));
+  }
+   }
 
+   /* Lower phis after the loop */
nir_block *block_after_loop =
   nir_cf_node_as_block(nir_cf_node_next(&loop->cf_node));
 
nir_lower_phis_to_regs_block(block_after_loop);
 
+   /* Remove continue if its the last instruction in the loop */
nir_instr *last_instr = nir_block_last_instr(nir_loop_last_block(loop));
if (last_instr && last_instr->type == nir_instr_type_jump) {
   assert(nir_instr_as_jump(last_instr)->type == nir_jump_continue);
-- 
2.14.3

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


[Mesa-dev] [Bug 105738] commit f7ffa504a065dc2631fd38cc5fe885b277f4e7e7 causes artifacting in radv

2018-03-25 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105738

--- Comment #2 from gloriouseggr...@gmail.com ---
for clarification I am currently on an RX Vega 64, llvm 6.0.0, 4.16rc3 kernel
(tested 4.15 and had the same problem)

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


[Mesa-dev] [Bug 105670] [regression][hang] Trine1EE hangs GPU after loading screen on Mesa3D-17.3 and later

2018-03-25 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105670

--- Comment #16 from i...@yahoo.com ---
(In reply to Timothy Arceri from comment #15)
> Here is a fix for drivers that use GLSL IR loop unrolling. I'm still looking
> into NIR unrolling it seems there is a different bug in that pass.
> 
> https://patchwork.freedesktop.org/patch/212881/

I can confirm that this patch fixes the bug for me.

Thank you for reacting so quickly to it.


Is NIR unrolling bug triggered by the same shader/trace?
If so, I should not close this bug until it is fixed too.

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


[Mesa-dev] [Bug 105738] commit f7ffa504a065dc2631fd38cc5fe885b277f4e7e7 causes artifacting in radv

2018-03-25 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105738

--- Comment #1 from gloriouseggr...@gmail.com ---
Created attachment 138351
  --> https://bugs.freedesktop.org/attachment.cgi?id=138351&action=edit
warframe weird bar

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


[Mesa-dev] [Bug 105738] commit f7ffa504a065dc2631fd38cc5fe885b277f4e7e7 causes artifacting in radv

2018-03-25 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105738

Bug ID: 105738
   Summary: commit f7ffa504a065dc2631fd38cc5fe885b277f4e7e7 causes
artifacting in radv
   Product: Mesa
   Version: git
  Hardware: Other
OS: All
Status: NEW
  Severity: normal
  Priority: medium
 Component: Other
  Assignee: mesa-dev@lists.freedesktop.org
  Reporter: gloriouseggr...@gmail.com
QA Contact: mesa-dev@lists.freedesktop.org

Created attachment 138350
  --> https://bugs.freedesktop.org/attachment.cgi?id=138350&action=edit
eso weird bar

I noticed I was getting the same graphical error on RADV recently (within the
last week or so) when playing both Warframe and Elder Scrolls online via DXVK.
It's this weird bar that shows up on the left side. (see pictures).

At first I figured maybe it was a DXVK bug, so we checked logs with no errors
or anything odd. Then I checked different LLVM versions (tried
5.0.0,5.0.1,6.0.0, master) and still the bug persisted. Finally I had two
friends, one on mesa 17.3.7 and another on mesa 18 rc5 who didnt have the
issue. So I tried mesa 18 rc5 and sure enough I didn't have the problem. So I
went back about a week in commits on mesa-git, and sure enough, the problem was
gone. 

So I then did a bisect, and after a few more hours, I found commit
f7ffa504a065dc2631fd38cc5fe885b277f4e7e7 to be the cause.

Once I reverted this commit and the two following commits related to it, the
error was resolved:

  git revert --no-commit a8d55374dc4be7eaeac4684d259c1ef56a4dc30a
  git revert --no-commit cf0a95afacc24f79a22c9b00b29a27061fe195a0
  git revert --no-commit f7ffa504a065dc2631fd38cc5fe885b277f4e7e7

See attached pictures for the "weird bar" issue

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


Re: [Mesa-dev] [PATCH v5 07/21] clover/api: Rework the validation of devices for building

2018-03-25 Thread Francisco Jerez
Pierre Moreau  writes:

> Signed-off-by: Pierre Moreau 
> ---
>  src/gallium/state_trackers/clover/api/program.cpp  | 23 
> +-
>  src/gallium/state_trackers/clover/core/program.cpp |  3 ++-
>  2 files changed, 16 insertions(+), 10 deletions(-)
>
> diff --git a/src/gallium/state_trackers/clover/api/program.cpp 
> b/src/gallium/state_trackers/clover/api/program.cpp
> index 9d59668f8f..e97b6400fe 100644
> --- a/src/gallium/state_trackers/clover/api/program.cpp
> +++ b/src/gallium/state_trackers/clover/api/program.cpp
> @@ -32,6 +32,7 @@ namespace {
> void
> validate_build_common(const program &prog, cl_uint num_devs,
>   const cl_device_id *d_devs,
> + ref_vector &valid_devs,

I asked you to drop the valid_devs argument of this function the last
time around, because it should be equal to prog.devices() in all cases.
If it's not in some case (clLinkProgram?) we should fix the
corresponding program constructor to make sure that's the case.

Otherwise LGTM.

>   void (*pfn_notify)(cl_program, void *),
>   void *user_data) {
>if (!pfn_notify && user_data)
> @@ -41,7 +42,7 @@ namespace {
>   throw error(CL_INVALID_OPERATION);
>  
>if (any_of([&](const device &dev) {
> -   return !count(dev, prog.context().devices());
> +   return !count(dev, valid_devs);
>  }, objs(d_devs, num_devs)))
>   throw error(CL_INVALID_DEVICE);
> }
> @@ -176,12 +177,13 @@ clBuildProgram(cl_program d_prog, cl_uint num_devs,
> void (*pfn_notify)(cl_program, void *),
> void *user_data) try {
> auto &prog = obj(d_prog);
> -   auto devs = (d_devs ? objs(d_devs, num_devs) :
> -ref_vector(prog.context().devices()));
> +   auto valid_devs = ref_vector(prog.devices());
> +   auto devs = (d_devs ? objs(d_devs, num_devs) : valid_devs);
> const auto opts = std::string(p_opts ? p_opts : "") + " " +
>   debug_get_option("CLOVER_EXTRA_BUILD_OPTIONS", "");
>  
> -   validate_build_common(prog, num_devs, d_devs, pfn_notify, user_data);
> +   validate_build_common(prog, num_devs, d_devs, valid_devs, pfn_notify,
> + user_data);
>  
> if (prog.has_source) {
>prog.compile(devs, opts);
> @@ -202,13 +204,14 @@ clCompileProgram(cl_program d_prog, cl_uint num_devs,
>   void (*pfn_notify)(cl_program, void *),
>   void *user_data) try {
> auto &prog = obj(d_prog);
> -   auto devs = (d_devs ? objs(d_devs, num_devs) :
> -ref_vector(prog.context().devices()));
> +   auto valid_devs = ref_vector(prog.devices());
> +   auto devs = (d_devs ? objs(d_devs, num_devs) : valid_devs);
> const auto opts = std::string(p_opts ? p_opts : "") + " " +
>   debug_get_option("CLOVER_EXTRA_COMPILE_OPTIONS", "");
> header_map headers;
>  
> -   validate_build_common(prog, num_devs, d_devs, pfn_notify, user_data);
> +   validate_build_common(prog, num_devs, d_devs, valid_devs, pfn_notify,
> + user_data);
>  
> if (bool(num_headers) != bool(header_names))
>throw error(CL_INVALID_VALUE);
> @@ -280,11 +283,13 @@ clLinkProgram(cl_context d_ctx, cl_uint num_devs, const 
> cl_device_id *d_devs,
>   debug_get_option("CLOVER_EXTRA_LINK_OPTIONS", "");
> auto progs = objs(d_progs, num_progs);
> auto prog = create(ctx);
> +   auto valid_devs = ref_vector(ctx.devices());
> auto devs = validate_link_devices(progs,
>   (d_devs ? objs(d_devs, num_devs) :
> -  ref_vector(ctx.devices(;
> +  valid_devs));
>  
> -   validate_build_common(prog, num_devs, d_devs, pfn_notify, user_data);
> +   validate_build_common(prog, num_dwevs, d_devs, valid_devs, pfn_notify,
> + user_data);
>  
> try {
>prog().link(devs, opts, progs);
> diff --git a/src/gallium/state_trackers/clover/core/program.cpp 
> b/src/gallium/state_trackers/clover/core/program.cpp
> index ec71d99b01..62fa13efbf 100644
> --- a/src/gallium/state_trackers/clover/core/program.cpp
> +++ b/src/gallium/state_trackers/clover/core/program.cpp
> @@ -26,7 +26,8 @@
>  using namespace clover;
>  
>  program::program(clover::context &ctx, const std::string &source) :
> -   has_source(true), context(ctx), _source(source), _kernel_ref_counter(0) {
> +   has_source(true), context(ctx), _devices(ctx.devices()), _source(source),
> +   _kernel_ref_counter(0) {
>  }
>  
>  program::program(clover::context &ctx,
> -- 
> 2.16.3


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


[Mesa-dev] [Bug 105737] st_tests_common.cpp:140:42: error: no matching function for call to 'tgsi_get_opcode_info'

2018-03-25 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105737

Bug ID: 105737
   Summary: st_tests_common.cpp:140:42: error: no matching
function for call to 'tgsi_get_opcode_info'
   Product: Mesa
   Version: git
  Hardware: x86-64 (AMD64)
OS: All
Status: NEW
  Keywords: regression
  Severity: normal
  Priority: medium
 Component: Mesa core
  Assignee: mesa-dev@lists.freedesktop.org
  Reporter: v...@freedesktop.org
QA Contact: mesa-dev@lists.freedesktop.org

CXX  st_tests_common.o
st_tests_common.cpp:140:42: error: no matching function for call to
'tgsi_get_opcode_info'
   const struct tgsi_opcode_info *info = tgsi_get_opcode_info(op);
 ^~~~
../../../../src/gallium/auxiliary/tgsi/tgsi_info.h:86:1: note: candidate
function not viable: no known
  conversion from 'const unsigned int' to 'enum tgsi_opcode' for 1st
argument
tgsi_get_opcode_info(enum tgsi_opcode opcode);
^

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


[Mesa-dev] [Bug 105670] [regression][hang] Trine1EE hangs GPU after loading screen on Mesa3D-17.3 and later

2018-03-25 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105670

--- Comment #15 from Timothy Arceri  ---
Here is a fix for drivers that use GLSL IR loop unrolling. I'm still looking
into NIR unrolling it seems there is a different bug in that pass.

https://patchwork.freedesktop.org/patch/212881/

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


[Mesa-dev] [PATCH] glsl: fix infinite loop caused by bug in loop unrolling pass

2018-03-25 Thread Timothy Arceri
Just checking for 2 jumps is not enough to be sure we can do a
complex loop unroll. We need to make sure we also have also found
2 loop terminators.

Without this we were attempting to unroll a loop where the second
jump was nesed inside multiple ifs which loop analysis is unable
to detect as a terminator. We ended up splicing out the first
terminator but failed to actually unroll the loop, this resulted
in the creation of a possible infinite loop.

Fixes: 646621c66da9 "glsl: make loop unrolling more like the nir unrolling path"

https://bugs.freedesktop.org/show_bug.cgi?id=105670
---
 src/compiler/glsl/loop_unroll.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compiler/glsl/loop_unroll.cpp 
b/src/compiler/glsl/loop_unroll.cpp
index 6e06a30fb91..f6efe6475a0 100644
--- a/src/compiler/glsl/loop_unroll.cpp
+++ b/src/compiler/glsl/loop_unroll.cpp
@@ -519,7 +519,7 @@ loop_unroll_visitor::visit_leave(ir_loop *ir)
 * isn't any additional unknown terminators, or any other jumps nested
 * inside futher ifs.
 */
-   if (ls->num_loop_jumps != 2)
+   if (ls->num_loop_jumps != 2 || ls->terminators.length() != 2)
   return visit_continue;
 
ir_instruction *first_ir =
-- 
2.14.3

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


Re: [Mesa-dev] [PATCH 1/2 v2] nir: fix per_vertex_output intrinsic

2018-03-25 Thread Jason Ekstrand

Rb

On March 25, 2018 11:11:10 Rob Clark  wrote:

This is supposed to have both BASE and COMPONENT but num_indices was
inadvertantly set to 1.

Cc: 
Signed-off-by: Rob Clark 
---
src/compiler/nir/nir_intrinsics.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_intrinsics.h 
b/src/compiler/nir/nir_intrinsics.h

index 8f3d3bcfa23..df2790869ba 100644
--- a/src/compiler/nir/nir_intrinsics.h
+++ b/src/compiler/nir/nir_intrinsics.h
@@ -505,7 +505,7 @@ LOAD(ssbo, 2, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
/* src[] = { offset }. const_index[] = { base, component } */
LOAD(output, 1, 2, BASE, COMPONENT, xx, NIR_INTRINSIC_CAN_ELIMINATE)
/* src[] = { vertex, offset }. const_index[] = { base, component } */
-LOAD(per_vertex_output, 2, 1, BASE, COMPONENT, xx, 
NIR_INTRINSIC_CAN_ELIMINATE)
+LOAD(per_vertex_output, 2, 2, BASE, COMPONENT, xx, 
NIR_INTRINSIC_CAN_ELIMINATE)

/* src[] = { offset }. const_index[] = { base } */
LOAD(shared, 1, 1, BASE, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
/* src[] = { offset }. const_index[] = { base, range } */
--
2.14.3



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


[Mesa-dev] [PATCH] radv: set SAMPLE_RATE to the number of samples of the current fb

2018-03-25 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/amd/vulkan/radv_cmd_buffer.c |  7 +--
 src/amd/vulkan/radv_pass.c   | 12 ++--
 src/amd/vulkan/radv_private.h|  1 +
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c
index cadb06f0af..347aea89ae 100644
--- a/src/amd/vulkan/radv_cmd_buffer.c
+++ b/src/amd/vulkan/radv_cmd_buffer.c
@@ -1180,15 +1180,18 @@ void radv_set_db_count_control(struct radv_cmd_buffer 
*cmd_buffer)
db_count_control = S_028004_ZPASS_INCREMENT_DISABLE(1);
}
} else {
+   const struct radv_subpass *subpass = cmd_buffer->state.subpass;
+   uint32_t sample_rate = util_logbase2(subpass->max_sample_count);
+
if (cmd_buffer->device->physical_device->rad_info.chip_class >= 
CIK) {
db_count_control = S_028004_PERFECT_ZPASS_COUNTS(1) |
-   S_028004_SAMPLE_RATE(0) | /* TODO: set this to 
the number of samples of the current framebuffer */
+   S_028004_SAMPLE_RATE(sample_rate) |
S_028004_ZPASS_ENABLE(1) |
S_028004_SLICE_EVEN_ENABLE(1) |
S_028004_SLICE_ODD_ENABLE(1);
} else {
db_count_control = S_028004_PERFECT_ZPASS_COUNTS(1) |
-   S_028004_SAMPLE_RATE(0); /* TODO: set this to 
the number of samples of the current framebuffer */
+   S_028004_SAMPLE_RATE(sample_rate);
}
}
 
diff --git a/src/amd/vulkan/radv_pass.c b/src/amd/vulkan/radv_pass.c
index 3028955716..d059af54f9 100644
--- a/src/amd/vulkan/radv_pass.c
+++ b/src/amd/vulkan/radv_pass.c
@@ -106,6 +106,7 @@ VkResult radv_CreateRenderPass(
p = pass->subpass_attachments;
for (uint32_t i = 0; i < pCreateInfo->subpassCount; i++) {
const VkSubpassDescription *desc = &pCreateInfo->pSubpasses[i];
+   uint32_t color_sample_count = 1, depth_sample_count = 1;
struct radv_subpass *subpass = &pass->subpasses[i];
 
subpass->input_count = desc->inputAttachmentCount;
@@ -132,8 +133,10 @@ VkResult radv_CreateRenderPass(
for (uint32_t j = 0; j < desc->colorAttachmentCount; 
j++) {
subpass->color_attachments[j]
= desc->pColorAttachments[j];
-   if (desc->pColorAttachments[j].attachment != 
VK_ATTACHMENT_UNUSED)
+   if (desc->pColorAttachments[j].attachment != 
VK_ATTACHMENT_UNUSED) {

pass->attachments[desc->pColorAttachments[j].attachment].view_mask |= 
subpass->view_mask;
+   color_sample_count = 
pCreateInfo->pAttachments[desc->pColorAttachments[j].attachment].samples;
+   }
}
}
 
@@ -156,11 +159,16 @@ VkResult radv_CreateRenderPass(
if (desc->pDepthStencilAttachment) {
subpass->depth_stencil_attachment =
*desc->pDepthStencilAttachment;
-   if (desc->pDepthStencilAttachment->attachment != 
VK_ATTACHMENT_UNUSED)
+   if (desc->pDepthStencilAttachment->attachment != 
VK_ATTACHMENT_UNUSED) {

pass->attachments[desc->pDepthStencilAttachment->attachment].view_mask |= 
subpass->view_mask;
+   depth_sample_count = 
pCreateInfo->pAttachments[desc->pDepthStencilAttachment->attachment].samples;
+   }
} else {
subpass->depth_stencil_attachment.attachment = 
VK_ATTACHMENT_UNUSED;
}
+
+   subpass->max_sample_count = MAX2(color_sample_count,
+depth_sample_count);
}
 
for (unsigned i = 0; i < pCreateInfo->dependencyCount; ++i) {
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index ce2e487bdb..a5cbad6cfe 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -1586,6 +1586,7 @@ struct radv_subpass {
struct radv_subpass_barrier  start_barrier;
 
uint32_t view_mask;
+   VkSampleCountFlagBitsmax_sample_count;
 };
 
 struct radv_render_pass_attachment {
-- 
2.16.2

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


[Mesa-dev] [PATCH 12/12] etnaviv: expose perfmon query groups

2018-03-25 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/etnaviv/etnaviv_query.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query.c 
b/src/gallium/drivers/etnaviv/etnaviv_query.c
index 00f87d22cb..b076e87e78 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query.c
@@ -122,11 +122,15 @@ etna_get_driver_query_group_info(struct pipe_screen 
*pscreen, unsigned index,
  struct pipe_driver_query_group_info *info)
 {
int nr_sw_groups = etna_sw_get_driver_query_group_info(pscreen, 0, NULL);
+   int nr_pm_groups = etna_pm_get_driver_query_group_info(pscreen, 0, NULL);
 
if (!info)
-  return nr_sw_groups;
+  return nr_sw_groups + nr_pm_groups;
 
-   return etna_sw_get_driver_query_group_info(pscreen, index, info);
+   if (index < nr_sw_groups)
+  return etna_sw_get_driver_query_group_info(pscreen, index, info);
+
+   return etna_pm_get_driver_query_group_info(pscreen, index, info);
 }
 
 static void
-- 
2.14.3

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


[Mesa-dev] [PATCH 10/12] etnaviv: assign group_ids to perfmon queries

2018-03-25 Thread Christian Gmeiner
Prep work for AMD_performance_monitor support.

Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/etnaviv/etnaviv_query_pm.c | 48 +-
 src/gallium/drivers/etnaviv/etnaviv_query_pm.h |  9 +
 2 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
index 8a636476d5..d5871f8f86 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
@@ -42,6 +42,7 @@ struct etna_perfmon_config
 {
const char *name;
unsigned type;
+   unsigned group_id;
const struct etna_perfmon_source *source;
 };
 
@@ -49,6 +50,7 @@ static const struct etna_perfmon_config query_config[] = {
{
   .name = "hi-total-cyles",
   .type = ETNA_QUERY_HI_TOTAL_CYCLES,
+  .group_id = ETNA_QUERY_HI_GROUP_ID,
   .source = (const struct etna_perfmon_source[]) {
  { "HI", "TOTAL_CYCLES" }
   }
@@ -56,6 +58,7 @@ static const struct etna_perfmon_config query_config[] = {
{
   .name = "hi-idle-cyles",
   .type = ETNA_QUERY_HI_IDLE_CYCLES,
+  .group_id = ETNA_QUERY_HI_GROUP_ID,
   .source = (const struct etna_perfmon_source[]) {
  { "HI", "IDLE_CYCLES" }
   }
@@ -63,6 +66,7 @@ static const struct etna_perfmon_config query_config[] = {
{
   .name = "hi-axi-cycles-read-request-stalled",
   .type = ETNA_QUERY_HI_AXI_CYCLES_READ_REQUEST_STALLED,
+  .group_id = ETNA_QUERY_HI_GROUP_ID,
   .source = (const struct etna_perfmon_source[]) {
  { "HI", "AXI_CYCLES_READ_REQUEST_STALLED" }
   }
@@ -70,6 +74,7 @@ static const struct etna_perfmon_config query_config[] = {
{
   .name = "hi-axi-cycles-write-request-stalled",
   .type = ETNA_QUERY_HI_AXI_CYCLES_WRITE_REQUEST_STALLED,
+  .group_id = ETNA_QUERY_HI_GROUP_ID,
   .source = (const struct etna_perfmon_source[]) {
  { "HI", "AXI_CYCLES_WRITE_REQUEST_STALLED" }
   }
@@ -77,6 +82,7 @@ static const struct etna_perfmon_config query_config[] = {
{
   .name = "hi-axi-cycles-write-data-stalled",
   .type = ETNA_QUERY_HI_AXI_CYCLES_WRITE_DATA_STALLED,
+  .group_id = ETNA_QUERY_HI_GROUP_ID,
   .source = (const struct etna_perfmon_source[]) {
  { "HI", "AXI_CYCLES_WRITE_DATA_STALLED" }
   }
@@ -84,6 +90,7 @@ static const struct etna_perfmon_config query_config[] = {
{
   .name = "pe-pixel-count-killed-by-color-pipe",
   .type = ETNA_QUERY_PE_PIXEL_COUNT_KILLED_BY_COLOR_PIPE,
+  .group_id = ETNA_QUERY_PE_GROUP_ID,
   .source = (const struct etna_perfmon_source[]) {
  { "PE", "PIXEL_COUNT_KILLED_BY_COLOR_PIPE" }
   }
@@ -91,6 +98,7 @@ static const struct etna_perfmon_config query_config[] = {
{
   .name = "pe-pixel-count-killed-by-depth-pipe",
   .type = ETNA_QUERY_PE_PIXEL_COUNT_KILLED_BY_DEPTH_PIPE,
+  .group_id = ETNA_QUERY_PE_GROUP_ID,
   .source = (const struct etna_perfmon_source[]) {
  { "PE", "PIXEL_COUNT_KILLED_BY_DEPTH_PIPE" }
   }
@@ -98,6 +106,7 @@ static const struct etna_perfmon_config query_config[] = {
{
   .name = "pe-pixel-count-drawn-by-color-pipe",
   .type = ETNA_QUERY_PE_PIXEL_COUNT_DRAWN_BY_COLOR_PIPE,
+  .group_id = ETNA_QUERY_PE_GROUP_ID,
   .source = (const struct etna_perfmon_source[]) {
  { "PE", "PIXEL_COUNT_DRAWN_BY_COLOR_PIPE" }
   }
@@ -105,6 +114,7 @@ static const struct etna_perfmon_config query_config[] = {
{
   .name = "pe-pixel-count-drawn-by-depth-pipe",
   .type = ETNA_QUERY_PE_PIXEL_COUNT_DRAWN_BY_DEPTH_PIPE,
+  .group_id = ETNA_QUERY_PE_GROUP_ID,
   .source = (const struct etna_perfmon_source[]) {
  { "PE", "PIXEL_COUNT_DRAWN_BY_DEPTH_PIPE" }
   }
@@ -112,6 +122,7 @@ static const struct etna_perfmon_config query_config[] = {
{
   .name = "sh-shader-cycles",
   .type = ETNA_QUERY_SH_SHADER_CYCLES,
+  .group_id = ETNA_QUERY_SH_GROUP_ID,
   .source = (const struct etna_perfmon_source[]) {
  { "SH", "SHADER_CYCLES" }
   }
@@ -119,6 +130,7 @@ static const struct etna_perfmon_config query_config[] = {
{
   .name = "sh-ps-inst-counter",
   .type = ETNA_QUERY_SH_PS_INST_COUNTER,
+  .group_id = ETNA_QUERY_SH_GROUP_ID,
   .source = (const struct etna_perfmon_source[]) {
  { "SH", "PS_INST_COUNTER" }
   }
@@ -126,6 +138,7 @@ static const struct etna_perfmon_config query_config[] = {
{
   .name = "sh-rendered-pixel-counter",
   .type = ETNA_QUERY_SH_RENDERED_PIXEL_COUNTER,
+  .group_id = ETNA_QUERY_SH_GROUP_ID,
   .source = (const struct etna_perfmon_source[]) {
  { "SH", "RENDERED_PIXEL_COUNTER" }
   }
@@ -133,6 +146,7 @@ static const struct etna_perfmon_config query_config[] = {
{
   .name = "sh-vs-inst-counter",
   .type = ETNA_QUERY_SH_VS_INST_COUNTER,
+  .group_id = ETNA_QUERY_SH_GROUP_ID,
   .sour

[Mesa-dev] [PATCH 05/12] etnaviv: support PA performance counters

2018-03-25 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/etnaviv/etnaviv_query_pm.c | 42 ++
 src/gallium/drivers/etnaviv/etnaviv_query_pm.h |  7 +
 2 files changed, 49 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
index eaad925e60..8e83eb185c 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
@@ -171,6 +171,48 @@ static const struct etna_perfmon_config query_config[] = {
   .source = (const struct etna_perfmon_source[]) {
  { "SH", "PXL_TEXLD_INST_COUNTER" }
   }
+   },
+   {
+  .name = "pa-input-vtx-counter",
+  .type = ETNA_QUERY_PA_INPUT_VTX_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "PA", "INPUT_VTX_COUNTER" }
+  }
+   },
+   {
+  .name = "pa-input-prim-counter",
+  .type = ETNA_QUERY_PA_INPUT_PRIM_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "PA", "INPUT_PRIM_COUNTER" }
+  }
+   },
+   {
+  .name = "pa-output-prim-counter",
+  .type = ETNA_QUERY_PA_OUTPUT_PRIM_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "PA", "OUTPUT_PRIM_COUNTER" }
+  }
+   },
+   {
+  .name = "pa-depth-clipped-counter",
+  .type = ETNA_QUERY_PA_DEPTH_CLIPPED_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "PA", "DEPTH_CLIPPED_COUNTER" }
+  }
+   },
+   {
+  .name = "pa-trivial-rejected-counter",
+  .type = ETNA_QUERY_PA_TRIVIAL_REJECTED_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "PA", "TRIVIAL_REJECTED_COUNTER" }
+  }
+   },
+   {
+  .name = "pa-culled-counter",
+  .type = ETNA_QUERY_PA_CULLED_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "PA", "CULLED_COUNTER" }
+  }
}
 };
 
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
index b5e7fe5ad3..00fea71f23 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
@@ -55,6 +55,13 @@ struct etna_screen;
 #define ETNA_QUERY_SH_PXL_BRANCH_INST_COUNTER(ETNA_PM_QUERY_BASE + 
17)
 #define ETNA_QUERY_SH_PXL_TEXLD_INST_COUNTER (ETNA_PM_QUERY_BASE + 
18)
 
+#define ETNA_QUERY_PA_INPUT_VTX_COUNTER  (ETNA_PM_QUERY_BASE + 
19)
+#define ETNA_QUERY_PA_INPUT_PRIM_COUNTER (ETNA_PM_QUERY_BASE + 
20)
+#define ETNA_QUERY_PA_OUTPUT_PRIM_COUNTER(ETNA_PM_QUERY_BASE + 
21)
+#define ETNA_QUERY_PA_DEPTH_CLIPPED_COUNTER  (ETNA_PM_QUERY_BASE + 
22)
+#define ETNA_QUERY_PA_TRIVIAL_REJECTED_COUNTER   (ETNA_PM_QUERY_BASE + 
23)
+#define ETNA_QUERY_PA_CULLED_COUNTER (ETNA_PM_QUERY_BASE + 
24)
+
 struct etna_pm_query {
struct etna_query base;
struct etna_perfmon_signal *signal;
-- 
2.14.3

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


[Mesa-dev] [PATCH 08/12] etnaviv: support TX performance counters

2018-03-25 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/etnaviv/etnaviv_query_pm.c | 63 ++
 src/gallium/drivers/etnaviv/etnaviv_query_pm.h | 10 
 2 files changed, 73 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
index 3601d4086c..4c2a2ac7de 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
@@ -276,6 +276,69 @@ static const struct etna_perfmon_config query_config[] = {
   .source = (const struct etna_perfmon_source[]) {
  { "RA", "CULLED_QUAD_COUNT" }
   }
+   },
+   {
+  .name = "tx-total-bilinear-requests",
+  .type = ETNA_QUERY_TX_TOTAL_BILINEAR_REQUESTS,
+  .source = (const struct etna_perfmon_source[]) {
+ { "TX", "TOTAL_BILINEAR_REQUESTS" }
+  }
+   },
+   {
+  .name = "tx-total-trilinear-requests",
+  .type = ETNA_QUERY_TX_TOTAL_TRILINEAR_REQUESTS,
+  .source = (const struct etna_perfmon_source[]) {
+ { "TX", "TOTAL_TRILINEAR_REQUESTS" }
+  }
+   },
+   {
+  .name = "tx-total-discarded-texutre-requests",
+  .type = ETNA_QUERY_TX_TOTAL_DISCARDED_TEXTURE_REQUESTS,
+  .source = (const struct etna_perfmon_source[]) {
+ { "TX", "TOTAL_DISCARDED_TEXTURE_REQUESTS" }
+  }
+   },
+   {
+  .name = "tx-total-texutre-requests",
+  .type = ETNA_QUERY_TX_TOTAL_TEXTURE_REQUESTS,
+  .source = (const struct etna_perfmon_source[]) {
+ { "TX", "TOTAL_TEXTURE_REQUESTS" }
+  }
+   },
+   {
+  .name = "tx-mem-read-count",
+  .type = ETNA_QUERY_TX_MEM_READ_COUNT,
+  .source = (const struct etna_perfmon_source[]) {
+ { "TX", "MEM_READ_COUNT" }
+  }
+   },
+   {
+  .name = "tx-mem-read-in-8b-count",
+  .type = ETNA_QUERY_TX_MEM_READ_IN_8B_COUNT,
+  .source = (const struct etna_perfmon_source[]) {
+ { "TX", "MEM_READ_IN_8B_COUNT" }
+  }
+   },
+   {
+  .name = "tx-cache-miss-count",
+  .type = ETNA_QUERY_TX_CACHE_MISS_COUNT,
+  .source = (const struct etna_perfmon_source[]) {
+ { "TX", "CACHE_MISS_COUNT" }
+  }
+   },
+   {
+  .name = "tx-cache-hit-texel-count",
+  .type = ETNA_QUERY_TX_CACHE_HIT_TEXEL_COUNT,
+  .source = (const struct etna_perfmon_source[]) {
+ { "TX", "CACHE_HIT_TEXEL_COUNT" }
+  }
+   },
+   {
+  .name = "tx-cache-miss-texel-count",
+  .type = ETNA_QUERY_TX_CACHE_MISS_TEXEL_COUNT,
+  .source = (const struct etna_perfmon_source[]) {
+ { "TX", "CACHE_MISS_TEXEL_COUNT" }
+  }
}
 };
 
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
index 01dd135392..9cfd06e0ec 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
@@ -73,6 +73,16 @@ struct etna_screen;
 #define ETNA_QUERY_RA_PREFETCH_CACHE_MISS_COUNTER(ETNA_PM_QUERY_BASE + 
32)
 #define ETNA_QUERY_RA_CULLED_QUAD_COUNT  (ETNA_PM_QUERY_BASE + 
33)
 
+#define ETNA_QUERY_TX_TOTAL_BILINEAR_REQUESTS(ETNA_PM_QUERY_BASE + 
34)
+#define ETNA_QUERY_TX_TOTAL_TRILINEAR_REQUESTS   (ETNA_PM_QUERY_BASE + 
35)
+#define ETNA_QUERY_TX_TOTAL_DISCARDED_TEXTURE_REQUESTS   (ETNA_PM_QUERY_BASE + 
36)
+#define ETNA_QUERY_TX_TOTAL_TEXTURE_REQUESTS (ETNA_PM_QUERY_BASE + 
37)
+#define ETNA_QUERY_TX_MEM_READ_COUNT (ETNA_PM_QUERY_BASE + 
38)
+#define ETNA_QUERY_TX_MEM_READ_IN_8B_COUNT   (ETNA_PM_QUERY_BASE + 
39)
+#define ETNA_QUERY_TX_CACHE_MISS_COUNT   (ETNA_PM_QUERY_BASE + 
40)
+#define ETNA_QUERY_TX_CACHE_HIT_TEXEL_COUNT  (ETNA_PM_QUERY_BASE + 
41)
+#define ETNA_QUERY_TX_CACHE_MISS_TEXEL_COUNT (ETNA_PM_QUERY_BASE + 
42)
+
 struct etna_pm_query {
struct etna_query base;
struct etna_perfmon_signal *signal;
-- 
2.14.3

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


[Mesa-dev] [PATCH 11/12] etnaviv: add query_group_info for perfmon counters

2018-03-25 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/etnaviv/etnaviv_query_pm.c | 45 ++
 src/gallium/drivers/etnaviv/etnaviv_query_pm.h |  5 +++
 2 files changed, 50 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
index d5871f8f86..644b8fe6ca 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
@@ -46,6 +46,17 @@ struct etna_perfmon_config
const struct etna_perfmon_source *source;
 };
 
+static const char *group_names[] = {
+   [ETNA_QUERY_HI_GROUP_ID] = "HI",
+   [ETNA_QUERY_PE_GROUP_ID] = "PE",
+   [ETNA_QUERY_SH_GROUP_ID] = "SH",
+   [ETNA_QUERY_PA_GROUP_ID] = "PA",
+   [ETNA_QUERY_SE_GROUP_ID] = "SE",
+   [ETNA_QUERY_RA_GROUP_ID] = "RA",
+   [ETNA_QUERY_TX_GROUP_ID] = "TX",
+   [ETNA_QUERY_MC_GROUP_ID] = "MC",
+};
+
 static const struct etna_perfmon_config query_config[] = {
{
   .name = "hi-total-cyles",
@@ -631,3 +642,37 @@ etna_pm_get_driver_query_info(struct pipe_screen *pscreen, 
unsigned index,
 
return 1;
 }
+
+static
+unsigned query_count(unsigned group)
+{
+   unsigned count = 0;
+
+   for (unsigned i = 0; i < ARRAY_SIZE(query_config); i++)
+  if (query_config[i].group_id == group)
+ count++;
+
+   assert(count);
+
+   return count;
+}
+
+int
+etna_pm_get_driver_query_group_info(struct pipe_screen *pscreen,
+unsigned index,
+struct pipe_driver_query_group_info *info)
+{
+   if (!info)
+  return ARRAY_SIZE(group_names);
+
+   if (index >= ARRAY_SIZE(group_names))
+  return 0;
+
+   unsigned count = query_count(index);
+
+   info->name = group_names[index];
+   info->max_active_queries = count;
+   info->num_queries = count;
+
+   return 1;
+}
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
index 23d125f2f7..e80310cabf 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
@@ -121,4 +121,9 @@ int
 etna_pm_get_driver_query_info(struct pipe_screen *pscreen, unsigned index,
   struct pipe_driver_query_info *info);
 
+int
+etna_pm_get_driver_query_group_info(struct pipe_screen *pscreen,
+unsigned index,
+struct pipe_driver_query_group_info *info);
+
 #endif
-- 
2.14.3

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


[Mesa-dev] [PATCH 09/12] etnaviv: support MC performance counters

2018-03-25 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/etnaviv/etnaviv_query_pm.c | 21 +
 src/gallium/drivers/etnaviv/etnaviv_query_pm.h |  4 
 2 files changed, 25 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
index 4c2a2ac7de..8a636476d5 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
@@ -339,6 +339,27 @@ static const struct etna_perfmon_config query_config[] = {
   .source = (const struct etna_perfmon_source[]) {
  { "TX", "CACHE_MISS_TEXEL_COUNT" }
   }
+   },
+   {
+  .name = "mc-total-read-req-8b-from-pipeline",
+  .type = ETNA_QUERY_MC_TOTAL_READ_REQ_8B_FROM_PIPELINE,
+  .source = (const struct etna_perfmon_source[]) {
+ { "MC", "TOTAL_READ_REQ_8B_FROM_PIPELINE" }
+  }
+   },
+   {
+  .name = "mc-total-read-req-8b-from-ip",
+  .type = ETNA_QUERY_MC_TOTAL_READ_REQ_8B_FROM_IP,
+  .source = (const struct etna_perfmon_source[]) {
+ { "MC", "TOTAL_READ_REQ_8B_FROM_IP" }
+  }
+   },
+   {
+  .name = "mc-total-write-req-8b-from-pipeline",
+  .type = ETNA_QUERY_MC_TOTAL_WRITE_REQ_8B_FROM_PIPELINE,
+  .source = (const struct etna_perfmon_source[]) {
+ { "MC", "TOTAL_WRITE_REQ_8B_FROM_PIPELINE" }
+  }
}
 };
 
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
index 9cfd06e0ec..f6d27ee406 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
@@ -83,6 +83,10 @@ struct etna_screen;
 #define ETNA_QUERY_TX_CACHE_HIT_TEXEL_COUNT  (ETNA_PM_QUERY_BASE + 
41)
 #define ETNA_QUERY_TX_CACHE_MISS_TEXEL_COUNT (ETNA_PM_QUERY_BASE + 
42)
 
+#define ETNA_QUERY_MC_TOTAL_READ_REQ_8B_FROM_PIPELINE(ETNA_PM_QUERY_BASE + 
43)
+#define ETNA_QUERY_MC_TOTAL_READ_REQ_8B_FROM_IP  (ETNA_PM_QUERY_BASE + 
44)
+#define ETNA_QUERY_MC_TOTAL_WRITE_REQ_8B_FROM_PIPELINE   (ETNA_PM_QUERY_BASE + 
45)
+
 struct etna_pm_query {
struct etna_query base;
struct etna_perfmon_signal *signal;
-- 
2.14.3

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


[Mesa-dev] [PATCH 07/12] etnaviv: support RA performance counters

2018-03-25 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/etnaviv/etnaviv_query_pm.c | 49 ++
 src/gallium/drivers/etnaviv/etnaviv_query_pm.h |  8 +
 2 files changed, 57 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
index 759e3a5d09..3601d4086c 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
@@ -227,6 +227,55 @@ static const struct etna_perfmon_config query_config[] = {
   .source = (const struct etna_perfmon_source[]) {
  { "SE", "CULLED_LINES_COUNT" }
   }
+   },
+   {
+  .name = "ra-valid-pixel-count",
+  .type = ETNA_QUERY_RA_VALID_PIXEL_COUNT,
+  .source = (const struct etna_perfmon_source[]) {
+ { "RA", "VALID_PIXEL_COUNT" }
+  }
+   },
+   {
+  .name = "ra-total-quad-count",
+  .type = ETNA_QUERY_RA_TOTAL_QUAD_COUNT,
+  .source = (const struct etna_perfmon_source[]) {
+ { "RA", "TOTAL_QUAD_COUNT" }
+  }
+   },
+   {
+  .name = "ra-valid-quad-count-after-early-z",
+  .type = ETNA_QUERY_RA_VALID_QUAD_COUNT_AFTER_EARLY_Z,
+  .source = (const struct etna_perfmon_source[]) {
+ { "RA", "VALID_QUAD_COUNT_AFTER_EARLY_Z" }
+  }
+   },
+   {
+  .name = "ra-total-primitive-count",
+  .type = ETNA_QUERY_RA_TOTAL_PRIMITIVE_COUNT,
+  .source = (const struct etna_perfmon_source[]) {
+ { "RA", "TOTAL_PRIMITIVE_COUNT" }
+  }
+   },
+   {
+  .name = "ra-pipe-cache-miss-counter",
+  .type = ETNA_QUERY_RA_PIPE_CACHE_MISS_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "RA", "PIPE_CACHE_MISS_COUNTER" }
+  }
+   },
+   {
+  .name = "ra-prefetch-cache-miss-counter",
+  .type = ETNA_QUERY_RA_PREFETCH_CACHE_MISS_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "RA", "PREFETCH_CACHE_MISS_COUNTER" }
+  }
+   },
+   {
+  .name = "ra-pculled-quad-count",
+  .type = ETNA_QUERY_RA_CULLED_QUAD_COUNT,
+  .source = (const struct etna_perfmon_source[]) {
+ { "RA", "CULLED_QUAD_COUNT" }
+  }
}
 };
 
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
index d93d12c718..01dd135392 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
@@ -65,6 +65,14 @@ struct etna_screen;
 #define ETNA_QUERY_SE_CULLED_TRIANGLE_COUNT  (ETNA_PM_QUERY_BASE + 
25)
 #define ETNA_QUERY_SE_CULLED_LINES_COUNT (ETNA_PM_QUERY_BASE + 
26)
 
+#define ETNA_QUERY_RA_VALID_PIXEL_COUNT  (ETNA_PM_QUERY_BASE + 
27)
+#define ETNA_QUERY_RA_TOTAL_QUAD_COUNT   (ETNA_PM_QUERY_BASE + 
28)
+#define ETNA_QUERY_RA_VALID_QUAD_COUNT_AFTER_EARLY_Z (ETNA_PM_QUERY_BASE + 
29)
+#define ETNA_QUERY_RA_TOTAL_PRIMITIVE_COUNT  (ETNA_PM_QUERY_BASE + 
30)
+#define ETNA_QUERY_RA_PIPE_CACHE_MISS_COUNTER(ETNA_PM_QUERY_BASE + 
31)
+#define ETNA_QUERY_RA_PREFETCH_CACHE_MISS_COUNTER(ETNA_PM_QUERY_BASE + 
32)
+#define ETNA_QUERY_RA_CULLED_QUAD_COUNT  (ETNA_PM_QUERY_BASE + 
33)
+
 struct etna_pm_query {
struct etna_query base;
struct etna_perfmon_signal *signal;
-- 
2.14.3

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


[Mesa-dev] [PATCH 03/12] etnaviv: support PE performance counters

2018-03-25 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/etnaviv/etnaviv_query_pm.c | 28 ++
 src/gallium/drivers/etnaviv/etnaviv_query_pm.h |  6 ++
 2 files changed, 34 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
index 2feca9d1dd..9be65cc6c5 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
@@ -80,6 +80,34 @@ static const struct etna_perfmon_config query_config[] = {
   .source = (const struct etna_perfmon_source[]) {
  { "HI", "AXI_CYCLES_WRITE_DATA_STALLED" }
   }
+   },
+   {
+  .name = "pe-pixel-count-killed-by-color-pipe",
+  .type = ETNA_QUERY_PE_PIXEL_COUNT_KILLED_BY_COLOR_PIPE,
+  .source = (const struct etna_perfmon_source[]) {
+ { "PE", "PIXEL_COUNT_KILLED_BY_COLOR_PIPE" }
+  }
+   },
+   {
+  .name = "pe-pixel-count-killed-by-depth-pipe",
+  .type = ETNA_QUERY_PE_PIXEL_COUNT_KILLED_BY_DEPTH_PIPE,
+  .source = (const struct etna_perfmon_source[]) {
+ { "PE", "PIXEL_COUNT_KILLED_BY_DEPTH_PIPE" }
+  }
+   },
+   {
+  .name = "pe-pixel-count-drawn-by-color-pipe",
+  .type = ETNA_QUERY_PE_PIXEL_COUNT_DRAWN_BY_COLOR_PIPE,
+  .source = (const struct etna_perfmon_source[]) {
+ { "PE", "PIXEL_COUNT_DRAWN_BY_COLOR_PIPE" }
+  }
+   },
+   {
+  .name = "pe-pixel-count-drawn-by-depth-pipe",
+  .type = ETNA_QUERY_PE_PIXEL_COUNT_DRAWN_BY_DEPTH_PIPE,
+  .source = (const struct etna_perfmon_source[]) {
+ { "PE", "PIXEL_COUNT_DRAWN_BY_DEPTH_PIPE" }
+  }
}
 };
 
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
index ce823cf3bf..77fb37b333 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
@@ -39,6 +39,12 @@ struct etna_screen;
 #define ETNA_QUERY_HI_AXI_CYCLES_WRITE_REQUEST_STALLED   (ETNA_PM_QUERY_BASE + 
3)
 #define ETNA_QUERY_HI_AXI_CYCLES_WRITE_DATA_STALLED  (ETNA_PM_QUERY_BASE + 
4)
 
+#define ETNA_QUERY_PE_PIXEL_COUNT_KILLED_BY_COLOR_PIPE   (ETNA_PM_QUERY_BASE + 
5)
+#define ETNA_QUERY_PE_PIXEL_COUNT_KILLED_BY_DEPTH_PIPE   (ETNA_PM_QUERY_BASE + 
6)
+#define ETNA_QUERY_PE_PIXEL_COUNT_DRAWN_BY_COLOR_PIPE(ETNA_PM_QUERY_BASE + 
7)
+#define ETNA_QUERY_PE_PIXEL_COUNT_DRAWN_BY_DEPTH_PIPE(ETNA_PM_QUERY_BASE + 
8)
+#define ETNA_QUERY_PE_PIXELS_RENDERED_2D (ETNA_PM_QUERY_BASE + 
9)
+
 struct etna_pm_query {
struct etna_query base;
struct etna_perfmon_signal *signal;
-- 
2.14.3

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


[Mesa-dev] [PATCH 01/12] etnaviv: add perfmon query implementation

2018-03-25 Thread Christian Gmeiner
Add needed infrastructure to use performance monitor
requests for queries.

Signed-off-by: Christian Gmeiner 
---
 configure.ac   |   2 +-
 meson.build|   2 +-
 src/gallium/drivers/etnaviv/Makefile.sources   |   2 +
 src/gallium/drivers/etnaviv/etnaviv_query.c|  11 +-
 src/gallium/drivers/etnaviv/etnaviv_query.h|   1 +
 src/gallium/drivers/etnaviv/etnaviv_query_pm.c | 272 +
 .../{etnaviv_query.h => etnaviv_query_pm.h}|  49 ++--
 src/gallium/drivers/etnaviv/etnaviv_screen.c   |   8 +
 src/gallium/drivers/etnaviv/etnaviv_screen.h   |   4 +
 9 files changed, 321 insertions(+), 30 deletions(-)
 create mode 100644 src/gallium/drivers/etnaviv/etnaviv_query_pm.c
 copy src/gallium/drivers/etnaviv/{etnaviv_query.h => etnaviv_query_pm.h} (57%)

diff --git a/configure.ac b/configure.ac
index 99805e0f2b..d9b14c0850 100644
--- a/configure.ac
+++ b/configure.ac
@@ -79,7 +79,7 @@ LIBDRM_INTEL_REQUIRED=2.4.75
 LIBDRM_NVVIEUX_REQUIRED=2.4.66
 LIBDRM_NOUVEAU_REQUIRED=2.4.66
 LIBDRM_FREEDRENO_REQUIRED=2.4.91
-LIBDRM_ETNAVIV_REQUIRED=2.4.82
+LIBDRM_ETNAVIV_REQUIRED=2.4.89
 
 dnl Versions for external dependencies
 DRI2PROTO_REQUIRED=2.8
diff --git a/meson.build b/meson.build
index 041d2bfc70..2a9ca3b719 100644
--- a/meson.build
+++ b/meson.build
@@ -1051,7 +1051,7 @@ if with_gallium_nouveau or with_dri_nouveau
   dep_libdrm_nouveau = dependency('libdrm_nouveau', version : '>= 2.4.66')
 endif
 if with_gallium_etnaviv
-  dep_libdrm_etnaviv = dependency('libdrm_etnaviv', version : '>= 2.4.82')
+  dep_libdrm_etnaviv = dependency('libdrm_etnaviv', version : '>= 2.4.89')
 endif
 if with_gallium_freedreno
   dep_libdrm_freedreno = dependency('libdrm_freedreno', version : '>= 2.4.91')
diff --git a/src/gallium/drivers/etnaviv/Makefile.sources 
b/src/gallium/drivers/etnaviv/Makefile.sources
index 587d369dfb..05df2d9c5f 100644
--- a/src/gallium/drivers/etnaviv/Makefile.sources
+++ b/src/gallium/drivers/etnaviv/Makefile.sources
@@ -35,6 +35,8 @@ C_SOURCES :=  \
etnaviv_query_hw.h \
etnaviv_query_sw.c \
etnaviv_query_sw.h \
+   etnaviv_query_pm.c \
+   etnaviv_query_pm.h \
etnaviv_rasterizer.c \
etnaviv_rasterizer.h \
etnaviv_resource.c \
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query.c 
b/src/gallium/drivers/etnaviv/etnaviv_query.c
index 2d257a9d34..00f87d22cb 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query.c
@@ -32,6 +32,7 @@
 #include "etnaviv_query.h"
 #include "etnaviv_query_hw.h"
 #include "etnaviv_query_sw.h"
+#include "etnaviv_query_pm.h"
 
 static struct pipe_query *
 etna_create_query(struct pipe_context *pctx, unsigned query_type,
@@ -43,6 +44,8 @@ etna_create_query(struct pipe_context *pctx, unsigned 
query_type,
q = etna_sw_create_query(ctx, query_type);
if (!q)
   q = etna_hw_create_query(ctx, query_type);
+   if (!q)
+  q = etna_pm_create_query(ctx, query_type);
 
return (struct pipe_query *)q;
 }
@@ -103,11 +106,15 @@ etna_get_driver_query_info(struct pipe_screen *pscreen, 
unsigned index,
struct pipe_driver_query_info *info)
 {
int nr_sw_queries = etna_sw_get_driver_query_info(pscreen, 0, NULL);
+   int nr_pm_queries = etna_pm_get_driver_query_info(pscreen, 0, NULL);
 
if (!info)
-  return nr_sw_queries;
+  return nr_sw_queries + nr_pm_queries;
+
+   if (index < nr_sw_queries)
+  return etna_sw_get_driver_query_info(pscreen, index, info);
 
-   return etna_sw_get_driver_query_info(pscreen, index, info);
+   return etna_pm_get_driver_query_info(pscreen, index - nr_sw_queries, info);
 }
 
 static int
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query.h 
b/src/gallium/drivers/etnaviv/etnaviv_query.h
index 8927266057..d738fb9e81 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_query.h
@@ -54,6 +54,7 @@ etna_query(struct pipe_query *pq)
 }
 
 #define ETNA_SW_QUERY_BASE   (PIPE_QUERY_DRIVER_SPECIFIC + 0)
+#define ETNA_PM_QUERY_BASE   (PIPE_QUERY_DRIVER_SPECIFIC + 32)
 
 void
 etna_query_screen_init(struct pipe_screen *pscreen);
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
new file mode 100644
index 00..2b09e5dac1
--- /dev/null
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
@@ -0,0 +1,272 @@
+/*
+ * Copyright (c) 2017 Etnaviv Project
+ * Copyright (C) 2017 Zodiac Inflight Innovations
+ *
+ * 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
+ * So

[Mesa-dev] [PATCH 04/12] etnaviv: support SH performance counters

2018-03-25 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/etnaviv/etnaviv_query_pm.c | 63 ++
 src/gallium/drivers/etnaviv/etnaviv_query_pm.h | 10 
 2 files changed, 73 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
index 9be65cc6c5..eaad925e60 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
@@ -108,6 +108,69 @@ static const struct etna_perfmon_config query_config[] = {
   .source = (const struct etna_perfmon_source[]) {
  { "PE", "PIXEL_COUNT_DRAWN_BY_DEPTH_PIPE" }
   }
+   },
+   {
+  .name = "sh-shader-cycles",
+  .type = ETNA_QUERY_SH_SHADER_CYCLES,
+  .source = (const struct etna_perfmon_source[]) {
+ { "SH", "SHADER_CYCLES" }
+  }
+   },
+   {
+  .name = "sh-ps-inst-counter",
+  .type = ETNA_QUERY_SH_PS_INST_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "SH", "PS_INST_COUNTER" }
+  }
+   },
+   {
+  .name = "sh-rendered-pixel-counter",
+  .type = ETNA_QUERY_SH_RENDERED_PIXEL_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "SH", "RENDERED_PIXEL_COUNTER" }
+  }
+   },
+   {
+  .name = "sh-vs-inst-counter",
+  .type = ETNA_QUERY_SH_VS_INST_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "SH", "VS_INST_COUNTER" }
+  }
+   },
+   {
+  .name = "sh-rendered-vertice-counter",
+  .type = ETNA_QUERY_SH_RENDERED_VERTICE_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "SH", "RENDERED_VERTICE_COUNTER" }
+  }
+   },
+   {
+  .name = "sh-vtx-branch-inst-counter",
+  .type = ETNA_QUERY_SH_RENDERED_VERTICE_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "SH", "VTX_BRANCH_INST_COUNTER" }
+  }
+   },
+   {
+  .name = "sh-vtx-texld-inst-counter",
+  .type = ETNA_QUERY_SH_RENDERED_VERTICE_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "SH", "VTX_TEXLD_INST_COUNTER" }
+  }
+   },
+   {
+  .name = "sh-plx-branch-inst-counter",
+  .type = ETNA_QUERY_SH_RENDERED_VERTICE_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "SH", "PXL_BRANCH_INST_COUNTER" }
+  }
+   },
+   {
+  .name = "sh-plx-texld-inst-counter",
+  .type = ETNA_QUERY_SH_RENDERED_VERTICE_COUNTER,
+  .source = (const struct etna_perfmon_source[]) {
+ { "SH", "PXL_TEXLD_INST_COUNTER" }
+  }
}
 };
 
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
index 77fb37b333..b5e7fe5ad3 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
@@ -45,6 +45,16 @@ struct etna_screen;
 #define ETNA_QUERY_PE_PIXEL_COUNT_DRAWN_BY_DEPTH_PIPE(ETNA_PM_QUERY_BASE + 
8)
 #define ETNA_QUERY_PE_PIXELS_RENDERED_2D (ETNA_PM_QUERY_BASE + 
9)
 
+#define ETNA_QUERY_SH_SHADER_CYCLES  (ETNA_PM_QUERY_BASE + 
10)
+#define ETNA_QUERY_SH_PS_INST_COUNTER(ETNA_PM_QUERY_BASE + 
11)
+#define ETNA_QUERY_SH_RENDERED_PIXEL_COUNTER (ETNA_PM_QUERY_BASE + 
12)
+#define ETNA_QUERY_SH_VS_INST_COUNTER(ETNA_PM_QUERY_BASE + 
13)
+#define ETNA_QUERY_SH_RENDERED_VERTICE_COUNTER   (ETNA_PM_QUERY_BASE + 
14)
+#define ETNA_QUERY_SH_VTX_BRANCH_INST_COUNTER(ETNA_PM_QUERY_BASE + 
15)
+#define ETNA_QUERY_SH_VTX_TEXLD_INST_COUNTER (ETNA_PM_QUERY_BASE + 
16)
+#define ETNA_QUERY_SH_PXL_BRANCH_INST_COUNTER(ETNA_PM_QUERY_BASE + 
17)
+#define ETNA_QUERY_SH_PXL_TEXLD_INST_COUNTER (ETNA_PM_QUERY_BASE + 
18)
+
 struct etna_pm_query {
struct etna_query base;
struct etna_perfmon_signal *signal;
-- 
2.14.3

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


[Mesa-dev] [PATCH 02/12] etnaviv: support HI performance counters

2018-03-25 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/etnaviv/etnaviv_query_pm.c | 35 ++
 src/gallium/drivers/etnaviv/etnaviv_query_pm.h |  6 +
 2 files changed, 41 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
index 2b09e5dac1..2feca9d1dd 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
@@ -46,6 +46,41 @@ struct etna_perfmon_config
 };
 
 static const struct etna_perfmon_config query_config[] = {
+   {
+  .name = "hi-total-cyles",
+  .type = ETNA_QUERY_HI_TOTAL_CYCLES,
+  .source = (const struct etna_perfmon_source[]) {
+ { "HI", "TOTAL_CYCLES" }
+  }
+   },
+   {
+  .name = "hi-idle-cyles",
+  .type = ETNA_QUERY_HI_IDLE_CYCLES,
+  .source = (const struct etna_perfmon_source[]) {
+ { "HI", "IDLE_CYCLES" }
+  }
+   },
+   {
+  .name = "hi-axi-cycles-read-request-stalled",
+  .type = ETNA_QUERY_HI_AXI_CYCLES_READ_REQUEST_STALLED,
+  .source = (const struct etna_perfmon_source[]) {
+ { "HI", "AXI_CYCLES_READ_REQUEST_STALLED" }
+  }
+   },
+   {
+  .name = "hi-axi-cycles-write-request-stalled",
+  .type = ETNA_QUERY_HI_AXI_CYCLES_WRITE_REQUEST_STALLED,
+  .source = (const struct etna_perfmon_source[]) {
+ { "HI", "AXI_CYCLES_WRITE_REQUEST_STALLED" }
+  }
+   },
+   {
+  .name = "hi-axi-cycles-write-data-stalled",
+  .type = ETNA_QUERY_HI_AXI_CYCLES_WRITE_DATA_STALLED,
+  .source = (const struct etna_perfmon_source[]) {
+ { "HI", "AXI_CYCLES_WRITE_DATA_STALLED" }
+  }
+   }
 };
 
 static const struct etna_perfmon_config *
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
index 3d8cf1419b..ce823cf3bf 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
@@ -33,6 +33,12 @@
 
 struct etna_screen;
 
+#define ETNA_QUERY_HI_TOTAL_CYCLES   (ETNA_PM_QUERY_BASE + 
0)
+#define ETNA_QUERY_HI_IDLE_CYCLES(ETNA_PM_QUERY_BASE + 
1)
+#define ETNA_QUERY_HI_AXI_CYCLES_READ_REQUEST_STALLED(ETNA_PM_QUERY_BASE + 
2)
+#define ETNA_QUERY_HI_AXI_CYCLES_WRITE_REQUEST_STALLED   (ETNA_PM_QUERY_BASE + 
3)
+#define ETNA_QUERY_HI_AXI_CYCLES_WRITE_DATA_STALLED  (ETNA_PM_QUERY_BASE + 
4)
+
 struct etna_pm_query {
struct etna_query base;
struct etna_perfmon_signal *signal;
-- 
2.14.3

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


[Mesa-dev] [PATCH 00/12] etnaviv: support performance monitor

2018-03-25 Thread Christian Gmeiner
Starting with kernel 4.16 the etnaviv driver exports perfmon domains
and signals to userspace. This patch series adds support for those
queries to mesa and exposes them via amd_performance_monitor.

Passes all amd_performance_monitor piglits.

Christian Gmeiner (12):
  etnaviv: add perfmon query implementation
  etnaviv: support HI performance counters
  etnaviv: support PE performance counters
  etnaviv: support SH performance counters
  etnaviv: support PA performance counters
  etnaviv: support SE performance counters
  etnaviv: support RA performance counters
  etnaviv: support TX performance counters
  etnaviv: support MC performance counters
  etnaviv: assign group_ids to perfmon queries
  etnaviv: add query_group_info for perfmon counters
  etnaviv: expose perfmon query groups

 configure.ac   |   2 +-
 meson.build|   2 +-
 src/gallium/drivers/etnaviv/Makefile.sources   |   2 +
 src/gallium/drivers/etnaviv/etnaviv_query.c|  19 +-
 src/gallium/drivers/etnaviv/etnaviv_query.h|   1 +
 src/gallium/drivers/etnaviv/etnaviv_query_pm.c | 678 +
 src/gallium/drivers/etnaviv/etnaviv_query_pm.h | 129 +
 src/gallium/drivers/etnaviv/etnaviv_screen.c   |   8 +
 src/gallium/drivers/etnaviv/etnaviv_screen.h   |   4 +
 9 files changed, 839 insertions(+), 6 deletions(-)
 create mode 100644 src/gallium/drivers/etnaviv/etnaviv_query_pm.c
 create mode 100644 src/gallium/drivers/etnaviv/etnaviv_query_pm.h

-- 
2.14.3

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


[Mesa-dev] [PATCH 06/12] etnaviv: support SE performance counters

2018-03-25 Thread Christian Gmeiner
Signed-off-by: Christian Gmeiner 
---
 src/gallium/drivers/etnaviv/etnaviv_query_pm.c | 14 ++
 src/gallium/drivers/etnaviv/etnaviv_query_pm.h |  3 +++
 2 files changed, 17 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
index 8e83eb185c..759e3a5d09 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.c
@@ -213,6 +213,20 @@ static const struct etna_perfmon_config query_config[] = {
   .source = (const struct etna_perfmon_source[]) {
  { "PA", "CULLED_COUNTER" }
   }
+   },
+   {
+  .name = "se-culled-triangle-count",
+  .type = ETNA_QUERY_SE_CULLED_TRIANGLE_COUNT,
+  .source = (const struct etna_perfmon_source[]) {
+ { "SE", "CULLED_TRIANGLE_COUNT" }
+  }
+   },
+   {
+  .name = "se-culled-lines-count",
+  .type = ETNA_QUERY_SE_CULLED_LINES_COUNT,
+  .source = (const struct etna_perfmon_source[]) {
+ { "SE", "CULLED_LINES_COUNT" }
+  }
}
 };
 
diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h 
b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
index 00fea71f23..d93d12c718 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_query_pm.h
@@ -62,6 +62,9 @@ struct etna_screen;
 #define ETNA_QUERY_PA_TRIVIAL_REJECTED_COUNTER   (ETNA_PM_QUERY_BASE + 
23)
 #define ETNA_QUERY_PA_CULLED_COUNTER (ETNA_PM_QUERY_BASE + 
24)
 
+#define ETNA_QUERY_SE_CULLED_TRIANGLE_COUNT  (ETNA_PM_QUERY_BASE + 
25)
+#define ETNA_QUERY_SE_CULLED_LINES_COUNT (ETNA_PM_QUERY_BASE + 
26)
+
 struct etna_pm_query {
struct etna_query base;
struct etna_perfmon_signal *signal;
-- 
2.14.3

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


[Mesa-dev] [Bug 105670] [regression][hang] Trine1EE hangs GPU after loading screen on Mesa3D-17.3 and later

2018-03-25 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105670

--- Comment #14 from almos  ---
(In reply to Roland Scheidegger from comment #5)
> (In reply to almos from comment #4)
> > The problem is not loop unrolling. The problem is that userspace code can
> > hang the GPU unrecoverably, and thus bringing down the entire system.
> > 
> > BTW I can confirm this on Pitcairn with radeon drm in linux 4.15.
> 
> There isn't much you can do about shaders not terminating (loop limiting in
> llvmpipe is quite a hack, you could legitimately have a loop which has more
> iterations).
You can detect the stall and kill the process that sent the drawing command.

> 
> But yes, gpu reset actually working reliably would be nice. I haven't really
> seen it succeed lately neither (but it can happen...).
It wouldn't be nice. It's essential.

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


[Mesa-dev] [PATCH 0/8] Push down gl_vertex_array into drivers.

2018-03-25 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Hi,

This series pushes the inputs array down into the driver backends.
Also the draw code paths get cleaned up to use the higher level
function entry points from the driver functions struct.
And finally vbo_split* can now be moved into the tnl module.

This step is meant ot be an intermediate step for gallium and i965 that
serves as a starting point to get rid of gl_vertex_array in those drivers.

The patch was run through piglit on radeonsi and clasic swrast as well as
on intels CI systems without regressions.

please review!
Thanks in advance and best

Mathias


Mathias Fröhlich (8):
  gallium: Push down the gl_vertex_array inputs into gallium.
  i965: Push down the gl_vertex_array inputs into i965.
  vbo: Remove vbo_indirect_draw_func.
  tnl: Push down the gl_vertex_array inputs into tnl drivers.
  vbo: Remove the now unused vbo draw path.
  vbo: Readd the arrays argument to the legacy draw methods.
  vbo: Move vbo_split into the tnl module.
  vbo: Remove unused includes to vbo_private.h

 src/mesa/Makefile.sources  |  10 +-
 src/mesa/drivers/common/driverfuncs.c  |   2 +-
 src/mesa/drivers/dri/i915/intel_context.c  |   1 +
 src/mesa/drivers/dri/i965/brw_context.c|   1 +
 src/mesa/drivers/dri/i965/brw_context.h|   4 +
 src/mesa/drivers/dri/i965/brw_draw.c   |  27 ++--
 src/mesa/drivers/dri/i965/brw_draw.h   |   1 +
 src/mesa/drivers/dri/nouveau/nouveau_context.c |   1 +
 src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c   |  34 -
 src/mesa/drivers/dri/r200/r200_context.c   |   1 +
 src/mesa/drivers/dri/radeon/radeon_context.c   |   1 +
 src/mesa/drivers/dri/swrast/swrast.c   |   1 +
 src/mesa/drivers/osmesa/osmesa.c   |   1 +
 src/mesa/drivers/x11/xm_api.c  |   1 +
 src/mesa/main/state.c  |  12 +-
 src/mesa/meson.build   |   8 +-
 src/mesa/state_tracker/st_cb_feedback.c|  35 -
 src/mesa/state_tracker/st_context.c|   9 +-
 src/mesa/state_tracker/st_context.h|   4 +
 src/mesa/state_tracker/st_draw.c   |  16 ++-
 src/mesa/state_tracker/st_draw.h   |   2 +-
 src/mesa/tnl/t_context.c   |   6 +-
 src/mesa/tnl/t_context.h   |   3 +
 src/mesa/tnl/t_draw.c  |  53 ++--
 src/mesa/tnl/t_rebase.c|  13 +-
 src/mesa/tnl/t_rebase.h|   4 +-
 src/mesa/{vbo/vbo_split.c => tnl/t_split.c}|  34 ++---
 src/mesa/{vbo/vbo_split.h => tnl/t_split.h}|  46 +++
 .../{vbo/vbo_split_copy.c => tnl/t_split_copy.c}   |  31 ++---
 .../vbo_split_inplace.c => tnl/t_split_inplace.c}  |  59 -
 src/mesa/tnl/tnl.h |  95 ++
 src/mesa/vbo/vbo.h | 131 ---
 src/mesa/vbo/vbo_context.c | 141 +
 src/mesa/vbo/vbo_exec.c|   8 --
 src/mesa/vbo/vbo_exec.h|   4 -
 src/mesa/vbo/vbo_exec_array.c  |   2 -
 src/mesa/vbo/vbo_primitive_restart.c   |   1 -
 src/mesa/vbo/vbo_private.h |  13 --
 38 files changed, 387 insertions(+), 429 deletions(-)
 rename src/mesa/{vbo/vbo_split.c => tnl/t_split.c} (84%)
 rename src/mesa/{vbo/vbo_split.h => tnl/t_split.h} (59%)
 rename src/mesa/{vbo/vbo_split_copy.c => tnl/t_split_copy.c} (96%)
 rename src/mesa/{vbo/vbo_split_inplace.c => tnl/t_split_inplace.c} (85%)

-- 
2.14.3

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


[Mesa-dev] [PATCH 4/8] tnl: Push down the gl_vertex_array inputs into tnl drivers.

2018-03-25 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/drivers/dri/i915/intel_context.c  |  1 +
 src/mesa/drivers/dri/i965/brw_draw.c   |  4 +--
 src/mesa/drivers/dri/nouveau/nouveau_context.c |  1 +
 src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c   | 21 -
 src/mesa/drivers/dri/r200/r200_context.c   |  1 +
 src/mesa/drivers/dri/radeon/radeon_context.c   |  1 +
 src/mesa/drivers/dri/swrast/swrast.c   |  1 +
 src/mesa/drivers/osmesa/osmesa.c   |  1 +
 src/mesa/drivers/x11/xm_api.c  |  1 +
 src/mesa/tnl/t_context.c   |  6 ++--
 src/mesa/tnl/t_context.h   |  3 ++
 src/mesa/tnl/t_draw.c  | 42 --
 src/mesa/tnl/tnl.h | 14 +
 13 files changed, 88 insertions(+), 9 deletions(-)

diff --git a/src/mesa/drivers/dri/i915/intel_context.c 
b/src/mesa/drivers/dri/i915/intel_context.c
index 96d09ca947..f22ebbd7ac 100644
--- a/src/mesa/drivers/dri/i915/intel_context.c
+++ b/src/mesa/drivers/dri/i915/intel_context.c
@@ -380,6 +380,7 @@ void
 intelInitDriverFunctions(struct dd_function_table *functions)
 {
_mesa_init_driver_functions(functions);
+   _tnl_init_driver_draw_function(functions);
 
functions->Flush = intel_glFlush;
functions->Finish = intelFinish;
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c 
b/src/mesa/drivers/dri/i965/brw_draw.c
index 5f52404bd6..4caaadd560 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -969,8 +969,8 @@ brw_draw_prims(struct gl_context *ctx,
  _mesa_enum_to_string(ctx->RenderMode));
   _swsetup_Wakeup(ctx);
   _tnl_wakeup(ctx);
-  _tnl_draw_prims(ctx, prims, nr_prims, ib,
-  index_bounds_valid, min_index, max_index, NULL, 0, NULL);
+  _tnl_draw(ctx, prims, nr_prims, ib,
+index_bounds_valid, min_index, max_index, NULL, 0, NULL);
   return;
}
 
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c 
b/src/mesa/drivers/dri/nouveau/nouveau_context.c
index 5fab81d866..93f6ce473a 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_context.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c
@@ -119,6 +119,7 @@ nouveau_context_init(struct gl_context *ctx, gl_api api,
 
/* Initialize the function pointers. */
_mesa_init_driver_functions(&functions);
+   _tnl_init_driver_draw_function(&functions);
nouveau_driver_functions_init(&functions);
nouveau_bufferobj_functions_init(&functions);
nouveau_texture_functions_init(&functions);
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c 
b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
index a7b911c50e..10b5c15e41 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
@@ -537,6 +537,24 @@ TAG(vbo_check_render_prims)(struct gl_context *ctx,
tfb_vertcount, stream, indirect);
 }
 
+static void
+TAG(vbo_draw)(struct gl_context *ctx,
+ const struct _mesa_prim *prims, GLuint nr_prims,
+ const struct _mesa_index_buffer *ib,
+ GLboolean index_bounds_valid,
+ GLuint min_index, GLuint max_index,
+ struct gl_transform_feedback_object *tfb_vertcount,
+ unsigned stream,
+ struct gl_buffer_object *indirect)
+{
+   /* Borrow and update the inputs list from the tnl context */
+   _tnl_bind_inputs(ctx);
+
+   TAG(vbo_check_render_prims)(ctx, prims, nr_prims, ib,
+   index_bounds_valid, min_index, max_index,
+   tfb_vertcount, stream, indirect);
+}
+
 void
 TAG(vbo_init)(struct gl_context *ctx)
 {
@@ -546,7 +564,8 @@ TAG(vbo_init)(struct gl_context *ctx)
for (i = 0; i < VERT_ATTRIB_MAX; i++)
render->map[i] = -1;
 
-   vbo_set_draw_func(ctx, TAG(vbo_check_render_prims));
+   /* Overwrite our draw function */
+   ctx->Driver.Draw = TAG(vbo_draw);
vbo_use_buffer_objects(ctx);
 }
 
diff --git a/src/mesa/drivers/dri/r200/r200_context.c 
b/src/mesa/drivers/dri/r200/r200_context.c
index eb7d92f3c6..4524f06d10 100644
--- a/src/mesa/drivers/dri/r200/r200_context.c
+++ b/src/mesa/drivers/dri/r200/r200_context.c
@@ -227,6 +227,7 @@ GLboolean r200CreateContext( gl_api api,
 * (the texture functions are especially important)
 */
_mesa_init_driver_functions(&functions);
+   _tnl_init_driver_draw_function(&functions);
r200InitDriverFuncs(&functions);
r200InitIoctlFuncs(&functions);
r200InitStateFuncs(&rmesa->radeon, &functions);
diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c 
b/src/mesa/drivers/dri/radeon/radeon_context.c
index 8c5c167199..28ced814e5 100644
--- a/src/mesa/drivers/dri/radeon/radeon_context.c
+++ b/src/mesa/drivers/dri/radeon/radeon_context.c
@@ -194,6 +194,7 @@ r100Creat

[Mesa-dev] [PATCH 2/8] i965: Push down the gl_vertex_array inputs into i965.

2018-03-25 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Let the i965 backend have its own gl_vertex_array array and basically
reimplement the way _vbo_draw works.
Note that brw_draw_indirect_prims calls brw_draw_prims internally
and gets its update to Array._DrawArray by this way.

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/drivers/dri/i965/brw_context.c |  1 +
 src/mesa/drivers/dri/i965/brw_context.h |  4 
 src/mesa/drivers/dri/i965/brw_draw.c| 23 +--
 src/mesa/drivers/dri/i965/brw_draw.h|  1 +
 4 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index fca5c8e307..78bae33607 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -283,6 +283,7 @@ brw_init_driver_functions(struct brw_context *brw,
functions->GetString = intel_get_string;
functions->UpdateState = intel_update_state;
 
+   brw_init_draw_functions(functions);
intelInitTextureFuncs(functions);
intelInitTextureImageFuncs(functions);
intelInitTextureCopyImageFuncs(functions);
diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
b/src/mesa/drivers/dri/i965/brw_context.h
index 177273c364..f049d08649 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -36,6 +36,7 @@
 #include 
 #include "main/macros.h"
 #include "main/mtypes.h"
+#include "vbo/vbo.h"
 #include "brw_structs.h"
 #include "brw_pipe_control.h"
 #include "compiler/brw_compiler.h"
@@ -954,6 +955,9 @@ struct brw_context
* These bitfields indicate which workarounds are needed.
*/
   uint8_t attrib_wa_flags[VERT_ATTRIB_MAX];
+
+  /* For the initial pushdown, keep the list of vbo inputs. */
+  struct vbo_inputs draw_arrays;
} vb;
 
struct {
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c 
b/src/mesa/drivers/dri/i965/brw_draw.c
index 0d1ae8982c..5f52404bd6 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -34,6 +34,7 @@
 #include "main/macros.h"
 #include "main/transformfeedback.h"
 #include "main/framebuffer.h"
+#include "main/varray.h"
 #include "tnl/tnl.h"
 #include "vbo/vbo.h"
 #include "swrast/swrast.h"
@@ -941,11 +942,16 @@ brw_draw_prims(struct gl_context *ctx,
 {
unsigned i;
struct brw_context *brw = brw_context(ctx);
-   const struct gl_vertex_array *arrays = ctx->Array._DrawArrays;
+   const struct gl_vertex_array *arrays;
int predicate_state = brw->predicate.state;
struct brw_transform_feedback_object *xfb_obj =
   (struct brw_transform_feedback_object *) gl_xfb_obj;
 
+   /* The initial pushdown of the inputs array into the drivers */
+   _mesa_set_drawing_arrays(ctx, brw->vb.draw_arrays.inputs);
+   arrays = ctx->Array._DrawArrays;
+   _vbo_update_inputs(ctx, &brw->vb.draw_arrays);
+
if (!brw_check_conditional_render(brw))
   return;
 
@@ -1075,14 +1081,19 @@ brw_draw_indirect_prims(struct gl_context *ctx,
 }
 
 void
-brw_draw_init(struct brw_context *brw)
+brw_init_draw_functions(struct dd_function_table *functions)
 {
-   struct gl_context *ctx = &brw->ctx;
-
/* Register our drawing function:
 */
-   vbo_set_draw_func(ctx, brw_draw_prims);
-   vbo_set_indirect_draw_func(ctx, brw_draw_indirect_prims);
+   functions->Draw = brw_draw_prims;
+   functions->DrawIndirect = brw_draw_indirect_prims;
+}
+
+void
+brw_draw_init(struct brw_context *brw)
+{
+   /* Keep our list of gl_vertex_array inputs */
+   _vbo_init_inputs(&brw->vb.draw_arrays);
 
for (int i = 0; i < VERT_ATTRIB_MAX; i++)
   brw->vb.inputs[i].buffer = -1;
diff --git a/src/mesa/drivers/dri/i965/brw_draw.h 
b/src/mesa/drivers/dri/i965/brw_draw.h
index c3a972c276..c74a2536aa 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.h
+++ b/src/mesa/drivers/dri/i965/brw_draw.h
@@ -55,6 +55,7 @@ void brw_draw_prims(struct gl_context *ctx,
  unsigned stream,
 struct gl_buffer_object *indirect );
 
+void brw_init_draw_functions(struct dd_function_table *functions);
 void brw_draw_init( struct brw_context *brw );
 void brw_draw_destroy( struct brw_context *brw );
 
-- 
2.14.3

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


[Mesa-dev] [PATCH 1/8] gallium: Push down the gl_vertex_array inputs into gallium.

2018-03-25 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Let the gallium backend have its own gl_vertex_array array and basically
reimplement the way _vbo_draw works.

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/state_tracker/st_cb_feedback.c | 35 ++---
 src/mesa/state_tracker/st_context.c |  9 -
 src/mesa/state_tracker/st_context.h |  4 
 src/mesa/state_tracker/st_draw.c| 16 ++-
 src/mesa/state_tracker/st_draw.h|  2 +-
 5 files changed, 52 insertions(+), 14 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_feedback.c 
b/src/mesa/state_tracker/st_cb_feedback.c
index 436062b1f8..b7a082fca3 100644
--- a/src/mesa/state_tracker/st_cb_feedback.c
+++ b/src/mesa/state_tracker/st_cb_feedback.c
@@ -40,6 +40,7 @@
 #include "main/imports.h"
 #include "main/context.h"
 #include "main/feedback.h"
+#include "main/varray.h"
 
 #include "vbo/vbo.h"
 
@@ -271,6 +272,34 @@ draw_glselect_stage(struct gl_context *ctx, struct 
draw_context *draw)
 }
 
 
+static void
+feedback_draw_vbo(struct gl_context *ctx,
+  const struct _mesa_prim *prims,
+  GLuint nr_prims,
+  const struct _mesa_index_buffer *ib,
+  GLboolean index_bounds_valid,
+  GLuint min_index,
+  GLuint max_index,
+  struct gl_transform_feedback_object *tfb_vertcount,
+  unsigned stream,
+  struct gl_buffer_object *indirect)
+{
+   struct st_context *st = st_context(ctx);
+
+   /* The initial pushdown of the inputs array into the drivers */
+   _mesa_set_drawing_arrays(ctx, st->draw_arrays.inputs);
+   _vbo_update_inputs(ctx, &st->draw_arrays);
+
+   /* The above needs to happen outside of st_feedback_draw_vbo,
+* since st_RasterPossets _DrawArrays and does not want that to be
+* overwritten by _mesa_set_drawing_arrays.
+*/
+   st_feedback_draw_vbo(ctx, prims, nr_prims, ib, index_bounds_valid,
+min_index, max_index, tfb_vertcount,
+stream, indirect);
+}
+
+
 static void
 st_RenderMode(struct gl_context *ctx, GLenum newMode )
 {
@@ -282,14 +311,14 @@ st_RenderMode(struct gl_context *ctx, GLenum newMode )
 
if (newMode == GL_RENDER) {
   /* restore normal VBO draw function */
-  st_init_draw(st);
+  st_init_draw_functions(&ctx->Driver);
}
else if (newMode == GL_SELECT) {
   if (!st->selection_stage)
  st->selection_stage = draw_glselect_stage(ctx, draw);
   draw_set_rasterize_stage(draw, st->selection_stage);
   /* Plug in new vbo draw function */
-  vbo_set_draw_func(ctx, st_feedback_draw_vbo);
+  ctx->Driver.Draw = feedback_draw_vbo;
}
else {
   struct gl_program *vp = st->ctx->VertexProgram._Current;
@@ -298,7 +327,7 @@ st_RenderMode(struct gl_context *ctx, GLenum newMode )
  st->feedback_stage = draw_glfeedback_stage(ctx, draw);
   draw_set_rasterize_stage(draw, st->feedback_stage);
   /* Plug in new vbo draw function */
-  vbo_set_draw_func(ctx, st_feedback_draw_vbo);
+  ctx->Driver.Draw = feedback_draw_vbo;
   /* need to generate/use a vertex program that emits pos/color/tex */
   if (vp)
  st->dirty |= ST_NEW_VERTEX_PROGRAM(st, st_vertex_program(vp));
diff --git a/src/mesa/state_tracker/st_context.c 
b/src/mesa/state_tracker/st_context.c
index 90b7f9359a..a3da0f8f1f 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -382,7 +382,6 @@ st_create_context_priv(struct gl_context *ctx, struct 
pipe_context *pipe,
 
st_init_atoms(st);
st_init_clear(st);
-   st_init_draw(st);
st_init_pbo_helpers(st);
 
/* Choose texture target for glDrawPixels, glBitmap, renderbuffers */
@@ -551,6 +550,9 @@ st_create_context_priv(struct gl_context *ctx, struct 
pipe_context *pipe,
/* Initialize context's winsys buffers list */
LIST_INITHEAD(&st->winsys_buffers);
 
+   /* Keep our list of gl_vertex_array inputs */
+   _vbo_init_inputs(&st->draw_arrays);
+
return st;
 }
 
@@ -715,6 +717,7 @@ st_init_driver_functions(struct pipe_screen *screen,
_mesa_init_shader_object_functions(functions);
_mesa_init_sampler_object_functions(functions);
 
+   st_init_draw_functions(functions);
st_init_blit_functions(functions);
st_init_bufferobject_functions(screen, functions);
st_init_clear_functions(functions);
@@ -752,10 +755,6 @@ st_init_driver_functions(struct pipe_screen *screen,
if (screen->get_param(screen, PIPE_CAP_STRING_MARKER))
   functions->EmitStringMarker = st_emit_string_marker;
 
-   /* For now call through these into the vbo_set_draw_func... */
-   functions->Draw = _vbo_draw;
-   functions->DrawIndirect = _vbo_draw_indirect;
-
functions->Enable = st_Enable;
functions->UpdateState = st_invalidate_state;
functions->QueryMemoryInfo = st_query_memory_info;
diff --git a/src/mesa/state_tracker/st_context.h 
b/src/mesa/state_track

[Mesa-dev] [PATCH 8/8] vbo: Remove unused includes to vbo_private.h

2018-03-25 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/vbo/vbo_exec_array.c| 2 --
 src/mesa/vbo/vbo_primitive_restart.c | 1 -
 2 files changed, 3 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 51fd434dc4..b3ce138a09 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -39,8 +39,6 @@
 #include "main/macros.h"
 #include "main/transformfeedback.h"
 
-#include "vbo_private.h"
-
 
 /**
  * Check that element 'j' of the array has reasonable data.
diff --git a/src/mesa/vbo/vbo_primitive_restart.c 
b/src/mesa/vbo/vbo_primitive_restart.c
index 699b566dca..f170347fbe 100644
--- a/src/mesa/vbo/vbo_primitive_restart.c
+++ b/src/mesa/vbo/vbo_primitive_restart.c
@@ -33,7 +33,6 @@
 #include "main/varray.h"
 
 #include "vbo.h"
-#include "vbo_private.h"
 
 
 #define UPDATE_MIN2(a, b) (a) = MIN2((a), (b))
-- 
2.14.3

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


[Mesa-dev] [PATCH 3/8] vbo: Remove vbo_indirect_draw_func.

2018-03-25 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Remove the vbo_indirect_draw_func vbo callback and make the default
implementation use the drivers main draw callback function directly.
This will be needed with the next changes when drivers without own main
drivers DrawIndirect implementation get moved to the main drivers
Draw method.

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/vbo/vbo.h | 32 
 src/mesa/vbo/vbo_context.c | 94 +++---
 src/mesa/vbo/vbo_private.h |  6 ---
 3 files changed, 30 insertions(+), 102 deletions(-)

diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h
index ef2bf9221a..db136f9445 100644
--- a/src/mesa/vbo/vbo.h
+++ b/src/mesa/vbo/vbo.h
@@ -169,34 +169,6 @@ typedef void (*vbo_draw_func)(struct gl_context *ctx,
   struct gl_buffer_object *indirect);
 
 
-/**
- * Draw a primitive, getting the vertex count, instance count, start
- * vertex, etc. from a buffer object.
- * \param mode  GL_POINTS, GL_LINES, GL_TRIANGLE_STRIP, etc.
- * \param indirect_data  buffer to get "DrawArrays/ElementsIndirectCommand" 
data
- * \param indirect_offset  offset of first primitive in indrect_data buffer
- * \param draw_count  number of primitives to draw
- * \param stride  stride, in bytes, between 
"DrawArrays/ElementsIndirectCommand"
- *objects
- * \param indirect_draw_count_buffer  if non-NULL specifies a buffer to get the
- *real draw_count value.  Used for
- *GL_ARB_indirect_parameters.
- * \param indirect_draw_count_offset  offset to the draw_count value in
- *indirect_draw_count_buffer
- * \param ib  index buffer for indexed drawing, NULL otherwise.
- */
-typedef void (*vbo_indirect_draw_func)(
-   struct gl_context *ctx,
-   GLuint mode,
-   struct gl_buffer_object *indirect_data,
-   GLsizeiptr indirect_offset,
-   unsigned draw_count,
-   unsigned stride,
-   struct gl_buffer_object *indirect_draw_count_buffer,
-   GLsizeiptr indirect_draw_count_offset,
-   const struct _mesa_index_buffer *ib);
-
-
 
 
 /* Utility function to cope with various constraints on tnl modules or
@@ -261,10 +233,6 @@ vbo_always_unmap_buffers(struct gl_context *ctx);
 void
 vbo_set_draw_func(struct gl_context *ctx, vbo_draw_func func);
 
-void
-vbo_set_indirect_draw_func(struct gl_context *ctx,
-   vbo_indirect_draw_func func);
-
 void
 vbo_sw_primitive_restart(struct gl_context *ctx,
  const struct _mesa_prim *prim,
diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index 025d6d8de8..54cbab0c14 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -141,55 +141,6 @@ init_mat_currval(struct gl_context *ctx)
 }
 
 
-/**
- * Fallback for when a driver does not call vbo_set_indirect_draw_func().
- */
-static void
-vbo_draw_indirect_prims(struct gl_context *ctx,
-GLuint mode,
-struct gl_buffer_object *indirect_buffer,
-GLsizeiptr indirect_offset,
-unsigned draw_count,
-unsigned stride,
-struct gl_buffer_object *indirect_draw_count_buffer,
-GLsizeiptr indirect_draw_count_offset,
-const struct _mesa_index_buffer *ib)
-{
-   struct vbo_context *vbo = vbo_context(ctx);
-   struct _mesa_prim *prim;
-   GLsizei i;
-
-   prim = calloc(draw_count, sizeof(*prim));
-   if (prim == NULL) {
-  _mesa_error(ctx, GL_OUT_OF_MEMORY, "gl%sDraw%sIndirect%s",
-  (draw_count > 1) ? "Multi" : "",
-  ib ? "Elements" : "Arrays",
-  indirect_buffer ? "CountARB" : "");
-  return;
-   }
-
-   prim[0].begin = 1;
-   prim[draw_count - 1].end = 1;
-   for (i = 0; i < draw_count; ++i, indirect_offset += stride) {
-  prim[i].mode = mode;
-  prim[i].indexed = !!ib;
-  prim[i].indirect_offset = indirect_offset;
-  prim[i].is_indirect = 1;
-  prim[i].draw_id = i;
-   }
-
-   /* This should always be true at this time */
-   assert(indirect_buffer == ctx->DrawIndirectBuffer);
-
-   vbo->draw_prims(ctx, prim, draw_count,
-   ib, false, 0, ~0,
-   NULL, 0,
-   indirect_buffer);
-
-   free(prim);
-}
-
-
 void
 _vbo_install_exec_vtxfmt(struct gl_context *ctx)
 {
@@ -236,7 +187,6 @@ _vbo_CreateContext(struct gl_context *ctx)
init_generic_currval(ctx);
init_mat_currval(ctx);
_vbo_init_inputs(&vbo->draw_arrays);
-   vbo_set_indirect_draw_func(ctx, vbo_draw_indirect_prims);
 
/* make sure all VBO_ATTRIB_ values can fit in an unsigned byte */
STATIC_ASSERT(VBO_ATTRIB_MAX <= 255);
@@ -292,15 +242,6 @@ vbo_set_draw_func(struct gl_context *ctx, vbo_draw_func 
func)
 }
 
 
-void
-vbo_set_indirect_draw_func(struct gl_context *ctx,
-   vbo_indi

[Mesa-dev] [PATCH 6/8] vbo: Readd the arrays argument to the legacy draw methods.

2018-03-25 Thread Mathias . Froehlich
From: Mathias Fröhlich 

The legacy draw paths from back before 2012 contained a gl_vertex_array
array for the inputs to be used for draw. So all draw methods from legacy
drivers and evereything that goes through tnl are originally written
for this calling convention. The same goes for tools like t_rebase or
vbo_split*, that even partly still have the original calling convention
with a currently unused such pointer.
Back in 2012 patch 50f7e75

mesa: move gl_client_array*[] from vbo_draw_func into gl_context

introduced Array._DrawArrays, which was something that was IMO aiming for
a similar direction than Array._DrawVAO introduced recently.
Now several tools like t_rebase and vbo_split*, which are mostly used by
tnl based drivers, would need to be converted to use the internal
Array._DrawVAO instead of Array._DrawArrays. The same goes for the driver
backends that use any of these tools.
Alternatively we can reintroduce the gl_vertex_array array in its call
argument list and put these tools finally into the tnl directory.
So this change reintroduces this gl_vertex_array array for the legacy
draw paths that are still required for the tools t_rebase and vbo_split*.
A followup will move vbo_split also into tnl.

Note that none of the affected drivers use the DriverFlags.NewArray
driver bit. So it should be safe to remove this also for the legacy
draw path.

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c | 11 +++
 src/mesa/tnl/t_draw.c|  7 ---
 src/mesa/tnl/t_rebase.c  | 10 ++
 src/mesa/tnl/tnl.h   |  1 +
 src/mesa/vbo/vbo.h   |  2 ++
 src/mesa/vbo/vbo_split_copy.c|  8 +---
 src/mesa/vbo/vbo_split_inplace.c |  8 +---
 7 files changed, 18 insertions(+), 29 deletions(-)

diff --git a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c 
b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
index 10b5c15e41..4533069692 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
@@ -239,6 +239,7 @@ get_max_client_stride(struct gl_context *ctx, const struct 
gl_vertex_array *arra
 
 static void
 TAG(vbo_render_prims)(struct gl_context *ctx,
+ const struct gl_vertex_array *arrays,
  const struct _mesa_prim *prims, GLuint nr_prims,
  const struct _mesa_index_buffer *ib,
  GLboolean index_bounds_valid,
@@ -476,6 +477,7 @@ vbo_draw_imm(struct gl_context *ctx, const struct 
gl_vertex_array *arrays,
 
 static void
 TAG(vbo_render_prims)(struct gl_context *ctx,
+ const struct gl_vertex_array *arrays,
  const struct _mesa_prim *prims, GLuint nr_prims,
  const struct _mesa_index_buffer *ib,
  GLboolean index_bounds_valid,
@@ -485,7 +487,6 @@ TAG(vbo_render_prims)(struct gl_context *ctx,
  struct gl_buffer_object *indirect)
 {
struct nouveau_render_state *render = to_render_state(ctx);
-   const struct gl_vertex_array *arrays = ctx->Array._DrawArrays;
 
if (!index_bounds_valid)
vbo_get_minmax_indices(ctx, prims, ib, &min_index, &max_index,
@@ -514,6 +515,7 @@ TAG(vbo_render_prims)(struct gl_context *ctx,
 
 static void
 TAG(vbo_check_render_prims)(struct gl_context *ctx,
+   const struct gl_vertex_array *arrays,
const struct _mesa_prim *prims, GLuint nr_prims,
const struct _mesa_index_buffer *ib,
GLboolean index_bounds_valid,
@@ -527,12 +529,12 @@ TAG(vbo_check_render_prims)(struct gl_context *ctx,
nouveau_validate_framebuffer(ctx);
 
if (nctx->fallback == HWTNL)
-   TAG(vbo_render_prims)(ctx, prims, nr_prims, ib,
+   TAG(vbo_render_prims)(ctx, arrays, prims, nr_prims, ib,
  index_bounds_valid, min_index, max_index,
  tfb_vertcount, stream, indirect);
 
if (nctx->fallback == SWTNL)
-   _tnl_draw_prims(ctx, prims, nr_prims, ib,
+   _tnl_draw_prims(ctx, arrays, prims, nr_prims, ib,
index_bounds_valid, min_index, max_index,
tfb_vertcount, stream, indirect);
 }
@@ -550,7 +552,8 @@ TAG(vbo_draw)(struct gl_context *ctx,
/* Borrow and update the inputs list from the tnl context */
_tnl_bind_inputs(ctx);
 
-   TAG(vbo_check_render_prims)(ctx, prims, nr_prims, ib,
+   TAG(vbo_check_render_prims)(ctx, ctx->Array._DrawArrays,
+   prims, nr_prims, ib,
index_bounds_valid, min_index, max_index,
tfb_vertcount, stream, indirect);
 }
diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tn

[Mesa-dev] [PATCH 7/8] vbo: Move vbo_split into the tnl module.

2018-03-25 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Move the files, adapt to the naming scheme in tnl, update callers
and build system.

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/Makefile.sources  | 10 +--
 src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c   |  4 +-
 src/mesa/meson.build   |  8 +--
 src/mesa/tnl/t_draw.c  |  8 +--
 src/mesa/tnl/t_rebase.c|  3 +-
 src/mesa/tnl/t_rebase.h|  4 +-
 src/mesa/{vbo/vbo_split.c => tnl/t_split.c}| 34 -
 src/mesa/{vbo/vbo_split.h => tnl/t_split.h}| 46 ++--
 .../{vbo/vbo_split_copy.c => tnl/t_split_copy.c}   | 23 +++---
 .../vbo_split_inplace.c => tnl/t_split_inplace.c}  | 51 +++---
 src/mesa/tnl/tnl.h | 80 +
 src/mesa/vbo/vbo.h | 81 --
 12 files changed, 178 insertions(+), 174 deletions(-)
 rename src/mesa/{vbo/vbo_split.c => tnl/t_split.c} (84%)
 rename src/mesa/{vbo/vbo_split.h => tnl/t_split.h} (59%)
 rename src/mesa/{vbo/vbo_split_copy.c => tnl/t_split_copy.c} (97%)
 rename src/mesa/{vbo/vbo_split_inplace.c => tnl/t_split_inplace.c} (87%)

diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
index 0446078136..92565ef8f5 100644
--- a/src/mesa/Makefile.sources
+++ b/src/mesa/Makefile.sources
@@ -372,6 +372,10 @@ TNL_FILES = \
tnl/t_pipeline.h \
tnl/t_rebase.c \
tnl/t_rebase.h \
+   tnl/t_split.c \
+   tnl/t_split_copy.c \
+   tnl/t_split.h \
+   tnl/t_split_inplace.c \
tnl/t_vb_cliptmp.h \
tnl/t_vb_fog.c \
tnl/t_vb_light.c \
@@ -411,11 +415,7 @@ VBO_FILES = \
vbo/vbo_save.c \
vbo/vbo_save_draw.c \
vbo/vbo_save.h \
-   vbo/vbo_save_loopback.c \
-   vbo/vbo_split.c \
-   vbo/vbo_split_copy.c \
-   vbo/vbo_split.h \
-   vbo/vbo_split_inplace.c
+   vbo/vbo_save_loopback.c
 
 STATETRACKER_FILES = \
state_tracker/st_atifs_to_tgsi.c \
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c 
b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
index 4533069692..79b444cf55 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
@@ -277,8 +277,8 @@ vbo_maybe_split(struct gl_context *ctx, const struct 
gl_vertex_array *arrays,
.max_vb_size = ~0,
};
 
-   vbo_split_prims(ctx, arrays, prims, nr_prims, ib, min_index,
-   max_index, TAG(vbo_render_prims), &limits);
+   _tnl_split_prims(ctx, arrays, prims, nr_prims, ib, min_index,
+max_index, TAG(vbo_render_prims), &limits);
return GL_TRUE;
}
 
diff --git a/src/mesa/meson.build b/src/mesa/meson.build
index b74d169377..d2d058bfa3 100644
--- a/src/mesa/meson.build
+++ b/src/mesa/meson.build
@@ -343,10 +343,6 @@ files_libmesa_common = files(
   'vbo/vbo_save_draw.c',
   'vbo/vbo_save.h',
   'vbo/vbo_save_loopback.c',
-  'vbo/vbo_split.c',
-  'vbo/vbo_split_copy.c',
-  'vbo/vbo_split.h',
-  'vbo/vbo_split_inplace.c',
   'x86/common_x86.c',
 )
 
@@ -366,6 +362,10 @@ files_libmesa_classic = files(
   'tnl/t_pipeline.c',
   'tnl/t_pipeline.h',
   'tnl/t_rebase.c',
+  'tnl/t_split.c',
+  'tnl/t_split_copy.c',
+  'tnl/t_split.h',
+  'tnl/t_split_inplace.c',
   'tnl/t_vb_cliptmp.h',
   'tnl/t_vb_fog.c',
   'tnl/t_vb_light.c',
diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c
index a0fd58432a..a83b98eede 100644
--- a/src/mesa/tnl/t_draw.c
+++ b/src/mesa/tnl/t_draw.c
@@ -486,10 +486,10 @@ void _tnl_draw_prims(struct gl_context *ctx,
   /* This will split the buffers one way or another and
* recursively call back into this function.
*/
-  vbo_split_prims( ctx, arrays, prim, nr_prims, ib, 
-  0, max_index + prim->basevertex,
-  _tnl_draw_prims,
-  &limits );
+  _tnl_split_prims( ctx, arrays, prim, nr_prims, ib,
+0, max_index + prim->basevertex,
+_tnl_draw_prims,
+&limits );
}
else {
   /* May need to map a vertex buffer object for every attribute plus
diff --git a/src/mesa/tnl/t_rebase.c b/src/mesa/tnl/t_rebase.c
index 19e759f44b..d28512423c 100644
--- a/src/mesa/tnl/t_rebase.c
+++ b/src/mesa/tnl/t_rebase.c
@@ -51,6 +51,7 @@
 #include "main/glheader.h"
 #include "main/imports.h"
 #include "main/mtypes.h"
+#include "vbo/vbo.h"
 
 #include "t_rebase.h"
 
@@ -108,7 +109,7 @@ void t_rebase_prims( struct gl_context *ctx,
  const struct _mesa_index_buffer *ib,
  GLuint min_index,
  GLuint max_index,
- vbo_draw_func draw )
+ tnl_draw_func draw )
 {
struct gl_array_attributes tmp_attribs[VERT_AT

[Mesa-dev] [PATCH 5/8] vbo: Remove the now unused vbo draw path.

2018-03-25 Thread Mathias . Froehlich
From: Mathias Fröhlich 

Signed-off-by: Mathias Fröhlich 
---
 src/mesa/drivers/common/driverfuncs.c |  2 +-
 src/mesa/main/state.c | 12 ++---
 src/mesa/vbo/vbo.h| 20 ---
 src/mesa/vbo/vbo_context.c| 47 ---
 src/mesa/vbo/vbo_exec.c   |  8 --
 src/mesa/vbo/vbo_exec.h   |  4 ---
 src/mesa/vbo/vbo_private.h|  7 --
 7 files changed, 3 insertions(+), 97 deletions(-)

diff --git a/src/mesa/drivers/common/driverfuncs.c 
b/src/mesa/drivers/common/driverfuncs.c
index 2ddfdb5efa..11134b69e9 100644
--- a/src/mesa/drivers/common/driverfuncs.c
+++ b/src/mesa/drivers/common/driverfuncs.c
@@ -121,7 +121,7 @@ _mesa_init_driver_functions(struct dd_function_table 
*driver)
driver->NewATIfs = NULL;
 
/* Draw functions */
-   driver->Draw = _vbo_draw;
+   driver->Draw = NULL;
driver->DrawIndirect = _vbo_draw_indirect;
 
/* simple state commands */
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index fb97165db9..be8f3f302c 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -458,14 +458,6 @@ _mesa_set_vp_override(struct gl_context *ctx, GLboolean 
flag)
 }
 
 
-static void
-set_new_array(struct gl_context *ctx)
-{
-   _vbo_set_recalculate_inputs(ctx);
-   ctx->NewDriverState |= ctx->DriverFlags.NewArray;
-}
-
-
 static void
 set_vertex_processing_mode(struct gl_context *ctx, gl_vertex_processing_mode m)
 {
@@ -473,7 +465,7 @@ set_vertex_processing_mode(struct gl_context *ctx, 
gl_vertex_processing_mode m)
   return;
 
/* On change we may get new maps into the current values */
-   set_new_array(ctx);
+   ctx->NewDriverState |= ctx->DriverFlags.NewArray;
 
/* Finally memorize the value */
ctx->VertexProgram._VPMode = m;
@@ -532,7 +524,7 @@ _mesa_set_draw_vao(struct gl_context *ctx, struct 
gl_vertex_array_object *vao,
   new_array = true;
 
if (new_array)
-  set_new_array(ctx);
+  ctx->NewDriverState |= ctx->DriverFlags.NewArray;
 
ctx->Array._DrawVAOEnabledAttribs = enabled;
_mesa_set_varying_vp_inputs(ctx, enabled);
diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h
index db136f9445..13f77d9db3 100644
--- a/src/mesa/vbo/vbo.h
+++ b/src/mesa/vbo/vbo.h
@@ -186,14 +186,6 @@ struct split_limits
 };
 
 
-void
-_vbo_draw(struct gl_context *ctx, const struct _mesa_prim *prims,
-   GLuint nr_prims, const struct _mesa_index_buffer *ib,
-   GLboolean index_bounds_valid, GLuint min_index, GLuint 
max_index,
-   struct gl_transform_feedback_object *tfb_vertcount,
-   unsigned tfb_stream, struct gl_buffer_object *indirect);
-
-
 void
 _vbo_draw_indirect(struct gl_context *ctx, GLuint mode,
 struct gl_buffer_object *indirect_data,
@@ -230,9 +222,6 @@ vbo_use_buffer_objects(struct gl_context *ctx);
 void
 vbo_always_unmap_buffers(struct gl_context *ctx);
 
-void
-vbo_set_draw_func(struct gl_context *ctx, vbo_draw_func func);
-
 void
 vbo_sw_primitive_restart(struct gl_context *ctx,
  const struct _mesa_prim *prim,
@@ -260,15 +249,6 @@ struct vbo_inputs
 };
 
 
-/**
- * Set the recalculate_inputs flag.
- * The method should in the longer run be replaced with listening for the
- * DriverFlags.NewArray flag in NewDriverState. But for now ...
- */
-void
-_vbo_set_recalculate_inputs(struct gl_context *ctx);
-
-
 /**
  * Initialize inputs.
  */
diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index 54cbab0c14..b8c28ceffb 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -186,7 +186,6 @@ _vbo_CreateContext(struct gl_context *ctx)
init_legacy_currval(ctx);
init_generic_currval(ctx);
init_mat_currval(ctx);
-   _vbo_init_inputs(&vbo->draw_arrays);
 
/* make sure all VBO_ATTRIB_ values can fit in an unsigned byte */
STATIC_ASSERT(VBO_ATTRIB_MAX <= 255);
@@ -234,52 +233,6 @@ _vbo_DestroyContext(struct gl_context *ctx)
 }
 
 
-void
-vbo_set_draw_func(struct gl_context *ctx, vbo_draw_func func)
-{
-   struct vbo_context *vbo = vbo_context(ctx);
-   vbo->draw_prims = func;
-}
-
-
-/**
- * Examine the enabled vertex arrays to set the exec->array.inputs[] values.
- * These will point to the arrays to actually use for drawing.  Some will
- * be user-provided arrays, other will be zero-stride const-valued arrays.
- */
-static void
-vbo_bind_arrays(struct gl_context *ctx)
-{
-   struct vbo_context *vbo = vbo_context(ctx);
-   struct vbo_exec_context *exec = &vbo->exec;
-
-   _mesa_set_drawing_arrays(ctx, vbo->draw_arrays.inputs);
-
-   if (exec->array.recalculate_inputs) {
-  /* Finally update the inputs array */
-  _vbo_update_inputs(ctx, &vbo->draw_arrays);
-  exec->array.recalculate_inputs = GL_FALSE;
-   }
-
-   assert(ctx->NewState == 0);
-   assert(ctx->Array._DrawVAO->NewArrays == 0);
-}
-
-
-void
-_vbo_draw(struct gl_context *ctx, const struct _mesa_prim *prims,

[Mesa-dev] [PATCH 1/2] radv: add support for VK_EXT_sampler_filter_minmax

2018-03-25 Thread Samuel Pitoiset
The driver only supports the required formats for now.

Signed-off-by: Samuel Pitoiset 
---
 src/amd/vulkan/radv_device.c  | 35 ++-
 src/amd/vulkan/radv_formats.c | 36 
 2 files changed, 70 insertions(+), 1 deletion(-)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 9c82fd059f..5eeff1da22 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -44,6 +44,7 @@
 #include "vk_format.h"
 #include "sid.h"
 #include "gfx9d.h"
+#include "addrlib/gfx9/chip/gfx9_enum.h"
 #include "util/debug.h"
 
 static int
@@ -943,6 +944,14 @@ void radv_GetPhysicalDeviceProperties2(
properties->maxMemoryAllocationSize = 0xull;
break;
}
+   case 
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES_EXT: {
+   VkPhysicalDeviceSamplerFilterMinmaxPropertiesEXT 
*properties =
+   
(VkPhysicalDeviceSamplerFilterMinmaxPropertiesEXT *)ext;
+   /* GFX6-8 only support single channel min/max filter. */
+   properties->filterMinmaxImageComponentMapping = 
pdevice->rad_info.chip_class >= GFX9;
+   properties->filterMinmaxSingleComponentFormats = true;
+   break;
+   }
default:
break;
}
@@ -3962,6 +3971,22 @@ radv_tex_aniso_filter(unsigned filter)
return 4;
 }
 
+static unsigned
+radv_tex_filter_mode(VkSamplerReductionModeEXT mode)
+{
+   switch (mode) {
+   case VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE_EXT:
+   return SQ_IMG_FILTER_MODE_BLEND;
+   case VK_SAMPLER_REDUCTION_MODE_MIN_EXT:
+   return SQ_IMG_FILTER_MODE_MIN;
+   case VK_SAMPLER_REDUCTION_MODE_MAX_EXT:
+   return SQ_IMG_FILTER_MODE_MAX;
+   default:
+   break;
+   }
+   return 0;
+}
+
 static void
 radv_init_sampler(struct radv_device *device,
  struct radv_sampler *sampler,
@@ -3971,6 +3996,13 @@ radv_init_sampler(struct radv_device *device,
(uint32_t) pCreateInfo->maxAnisotropy : 
0;
uint32_t max_aniso_ratio = radv_tex_aniso_filter(max_aniso);
bool is_vi = (device->physical_device->rad_info.chip_class >= VI);
+   unsigned filter_mode = SQ_IMG_FILTER_MODE_BLEND;
+
+   const struct VkSamplerReductionModeCreateInfoEXT *sampler_reduction =
+   vk_find_struct_const(pCreateInfo->pNext,
+SAMPLER_REDUCTION_MODE_CREATE_INFO_EXT);
+   if (sampler_reduction)
+   filter_mode = 
radv_tex_filter_mode(sampler_reduction->reductionMode);
 
sampler->state[0] = 
(S_008F30_CLAMP_X(radv_tex_wrap(pCreateInfo->addressModeU)) |
 
S_008F30_CLAMP_Y(radv_tex_wrap(pCreateInfo->addressModeV)) |
@@ -3981,7 +4013,8 @@ radv_init_sampler(struct radv_device *device,
 S_008F30_ANISO_THRESHOLD(max_aniso_ratio >> 1) |
 S_008F30_ANISO_BIAS(max_aniso_ratio) |
 S_008F30_DISABLE_CUBE_WRAP(0) |
-S_008F30_COMPAT_MODE(is_vi));
+S_008F30_COMPAT_MODE(is_vi) |
+S_008F30_FILTER_MODE(filter_mode));
sampler->state[1] = 
(S_008F34_MIN_LOD(S_FIXED(CLAMP(pCreateInfo->minLod, 0, 15), 8)) |
 
S_008F34_MAX_LOD(S_FIXED(CLAMP(pCreateInfo->maxLod, 0, 15), 8)) |
 S_008F34_PERF_MIP(max_aniso_ratio ? 
max_aniso_ratio + 6 : 0));
diff --git a/src/amd/vulkan/radv_formats.c b/src/amd/vulkan/radv_formats.c
index da341a3a84..efb1d78790 100644
--- a/src/amd/vulkan/radv_formats.c
+++ b/src/amd/vulkan/radv_formats.c
@@ -541,6 +541,35 @@ static bool radv_is_zs_format_supported(VkFormat format)
return radv_translate_dbformat(format) != V_028040_Z_INVALID || format 
== VK_FORMAT_S8_UINT;
 }
 
+static bool radv_is_filter_minmax_format_supported(VkFormat format)
+{
+   /* From the Vulkan spec 1.1.71:
+*
+* "The following formats must support the
+*  VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT_EXT feature with
+*  VK_IMAGE_TILING_OPTIMAL, if they support
+*  VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT."
+*/
+   /* TODO: enable more formats. */
+   switch (format) {
+   case VK_FORMAT_R8_UNORM:
+   case VK_FORMAT_R8_SNORM:
+   case VK_FORMAT_R16_UNORM:
+   case VK_FORMAT_R16_SNORM:
+   case VK_FORMAT_R16_SFLOAT:
+   case VK_FORMAT_R32_SFLOAT:
+   case VK_FORMAT_D16_UNORM:
+   case VK_FORMAT_X8_D24_UNORM_PACK32:
+   case VK_FORMAT_D32_SFLOAT:
+   case VK_FORMAT_D16_UNORM_S8_UINT:
+   case VK_FORMAT_D24_UNORM_S8_UINT:
+   case VK_FORMAT_D32_SFLOAT_

[Mesa-dev] [PATCH 2/2] radv: enable VK_EXT_sampler_filter_minmax

2018-03-25 Thread Samuel Pitoiset
Signed-off-by: Samuel Pitoiset 
---
 src/amd/vulkan/radv_extensions.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/amd/vulkan/radv_extensions.py 
b/src/amd/vulkan/radv_extensions.py
index 896cc62459..36f2d61d59 100644
--- a/src/amd/vulkan/radv_extensions.py
+++ b/src/amd/vulkan/radv_extensions.py
@@ -91,6 +91,7 @@ EXTENSIONS = [
 Extension('VK_EXT_external_memory_dma_buf',   1, True),
 Extension('VK_EXT_external_memory_host',  1, 
'device->rad_info.has_userptr'),
 Extension('VK_EXT_global_priority',   1, 
'device->rad_info.has_ctx_priority'),
+Extension('VK_EXT_sampler_filter_minmax', 1, True),
 Extension('VK_AMD_draw_indirect_count',   1, True),
 Extension('VK_AMD_gcn_shader',1, True),
 Extension('VK_AMD_rasterization_order',   1, 
'device->rad_info.chip_class >= VI && device->rad_info.max_se >= 2'),
-- 
2.16.2

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


[Mesa-dev] [PATCH 1/2 v2] nir: fix per_vertex_output intrinsic

2018-03-25 Thread Rob Clark
This is supposed to have both BASE and COMPONENT but num_indices was
inadvertantly set to 1.

Cc: 
Signed-off-by: Rob Clark 
---
 src/compiler/nir/nir_intrinsics.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/compiler/nir/nir_intrinsics.h 
b/src/compiler/nir/nir_intrinsics.h
index 8f3d3bcfa23..df2790869ba 100644
--- a/src/compiler/nir/nir_intrinsics.h
+++ b/src/compiler/nir/nir_intrinsics.h
@@ -505,7 +505,7 @@ LOAD(ssbo, 2, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
 /* src[] = { offset }. const_index[] = { base, component } */
 LOAD(output, 1, 2, BASE, COMPONENT, xx, NIR_INTRINSIC_CAN_ELIMINATE)
 /* src[] = { vertex, offset }. const_index[] = { base, component } */
-LOAD(per_vertex_output, 2, 1, BASE, COMPONENT, xx, NIR_INTRINSIC_CAN_ELIMINATE)
+LOAD(per_vertex_output, 2, 2, BASE, COMPONENT, xx, NIR_INTRINSIC_CAN_ELIMINATE)
 /* src[] = { offset }. const_index[] = { base } */
 LOAD(shared, 1, 1, BASE, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
 /* src[] = { offset }. const_index[] = { base, range } */
-- 
2.14.3

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


[Mesa-dev] [PATCH 2/2 v2] nir: mako all the intrinsics

2018-03-25 Thread Rob Clark
I threatened to do this a long time ago.. I probably *should* have done
it a long time ago when there where many fewer intrinsics.  But the
system of macro/#include magic for dealing with intrinsics is a bit
annoying, and python has the nice property of optional fxn params,
making it possible to define new intrinsics while ignoring parameters
that are not applicable (and naming optional params).  And not having to
specify various array lengths explicitly is nice too.

I think the end result makes it easier to add new intrinsics.

v2: couple small fixes found with a test program to compare the old and
new tables
v3: misc comments, don't rely on capture=true for meson.build, get rid
of system_values table to avoid return value of intrinsic() and
*mostly* remove side-effects, add autotools build support

Signed-off-by: Rob Clark 
---
So, new scheme is, I think, a reasonable compromise between keeping the
python "clean" and keeping the intrinsic declarations easy to follow.
It still has the side-effect that intrinsic() adds to the table, but
drops the separate system_values table so that intrinsic() doesn't
return a value.  The alternative would require the helper for various
specialized intrinsic categories to be declared far from where they are
used, which is, I think, suboptimal.  And it keeps intrinsic() and
various wrappers pretty straightforward, so I don't think this should
ever pose a problem for refactoring (and certainly less of a problem
than the previous solution using cpp macros, so regardless of what your
opinion about the py code, I guess anyone could agree that this is an
improvement over the current state ;-))

Also added autotools build support.  Sorry scons and android.  (Are we
ready to drop either of these in favor of nir?)

 src/compiler/Makefile.nir.am   |  13 +-
 src/compiler/Makefile.sources  |   4 +-
 src/compiler/nir/meson.build   |  24 +-
 src/compiler/nir/nir.h |   9 -
 src/compiler/nir/nir_builder.h |  27 +-
 src/compiler/nir/nir_builder_opcodes_h.py  |  24 +-
 src/compiler/nir/nir_intrinsics.h  | 540 
 src/compiler/nir/nir_intrinsics.py | 546 +
 src/compiler/nir/nir_intrinsics_c.py   |  68 +++
 .../nir/{nir_intrinsics.c => nir_intrinsics_h.py}  |  75 +--
 10 files changed, 711 insertions(+), 619 deletions(-)
 delete mode 100644 src/compiler/nir/nir_intrinsics.h
 create mode 100644 src/compiler/nir/nir_intrinsics.py
 create mode 100644 src/compiler/nir/nir_intrinsics_c.py
 rename src/compiler/nir/{nir_intrinsics.c => nir_intrinsics_h.py} (55%)

diff --git a/src/compiler/Makefile.nir.am b/src/compiler/Makefile.nir.am
index 28033256762..d805f573d51 100644
--- a/src/compiler/Makefile.nir.am
+++ b/src/compiler/Makefile.nir.am
@@ -32,7 +32,7 @@ nir_libnir_la_SOURCES =   
\
$(SPIRV_GENERATED_FILES)\
$(NIR_GENERATED_FILES)
 
-nir/nir_builder_opcodes.h: nir/nir_opcodes.py nir/nir_builder_opcodes_h.py
+nir/nir_builder_opcodes.h: nir/nir_opcodes.py nir/nir_builder_opcodes_h.py 
nir/nir_intrinsics.py
$(MKDIR_GEN)
$(PYTHON_GEN) $(srcdir)/nir/nir_builder_opcodes_h.py > $@ || ($(RM) $@; 
false)
 
@@ -40,6 +40,14 @@ nir/nir_constant_expressions.c: nir/nir_opcodes.py 
nir/nir_constant_expressions.
$(MKDIR_GEN)
$(PYTHON_GEN) $(srcdir)/nir/nir_constant_expressions.py > $@ || ($(RM) 
$@; false)
 
+nir/nir_intrinsics.h: nir/nir_intrinsics.py nir/nir_intrinsics_h.py
+   $(MKDIR_GEN)
+   $(PYTHON_GEN) $(srcdir)/nir/nir_intrinsics_h.py --outdir nir || ($(RM) 
$@; false)
+
+nir/nir_intrinsics.c: nir/nir_intrinsics.py nir/nir_intrinsics_c.py
+   $(MKDIR_GEN)
+   $(PYTHON_GEN) $(srcdir)/nir/nir_intrinsics_c.py --outdir nir || ($(RM) 
$@; false)
+
 nir/nir_opcodes.h: nir/nir_opcodes.py nir/nir_opcodes_h.py
$(MKDIR_GEN)
$(PYTHON_GEN) $(srcdir)/nir/nir_opcodes_h.py > $@ || ($(RM) $@; false)
@@ -112,6 +120,9 @@ EXTRA_DIST += \
nir/nir_algebraic.py\
nir/nir_builder_opcodes_h.py\
nir/nir_constant_expressions.py \
+   nir/nir_intrinsics.py   \
+   nir/nir_intrinsics_c.py \
+   nir/nir_intrinsics_h.py \
nir/nir_opcodes.py  \
nir/nir_opcodes_c.py\
nir/nir_opcodes_h.py\
diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources
index 2dc48365507..273ce4cde49 100644
--- a/src/compiler/Makefile.sources
+++ b/src/compiler/Makefile.sources
@@ -182,6 +182,8 @@ LIBGLCPP_GENERATED_FILES = \
 NIR_GENERATED_FILES = \
nir/nir_builder_opcodes.h \
nir/nir_constant_expressions.

[Mesa-dev] [PATCH v5 20/21] clover: Advertise cl_khr_il_program

2018-03-25 Thread Pierre Moreau
Reviewed-by: Karol Herbst 
Signed-off-by: Pierre Moreau 
---
 src/gallium/state_trackers/clover/api/platform.cpp | 2 ++
 src/gallium/state_trackers/clover/core/device.cpp  | 8 +++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/clover/api/platform.cpp 
b/src/gallium/state_trackers/clover/api/platform.cpp
index 94d883c1f0..54a35c5dc5 100644
--- a/src/gallium/state_trackers/clover/api/platform.cpp
+++ b/src/gallium/state_trackers/clover/api/platform.cpp
@@ -111,6 +111,8 @@ clover::GetExtensionFunctionAddress(const char *p_name) {
 
if (name == "clIcdGetPlatformIDsKHR")
   return reinterpret_cast(IcdGetPlatformIDsKHR);
+   else if (name == "clCreateProgramWithILKHR")
+  return reinterpret_cast(CreateProgramWithILKHR);
else
   return NULL;
 }
diff --git a/src/gallium/state_trackers/clover/core/device.cpp 
b/src/gallium/state_trackers/clover/core/device.cpp
index 21de0e3d61..b9a26e4eec 100644
--- a/src/gallium/state_trackers/clover/core/device.cpp
+++ b/src/gallium/state_trackers/clover/core/device.cpp
@@ -285,6 +285,11 @@ device::supports_ir(enum pipe_shader_ir ir) const {
 
 std::string
 device::supported_extensions() const {
+#ifdef CLOVER_ALLOW_SPIRV
+   const bool supports_il_program = supports_ir(PIPE_SHADER_IR_NATIVE);
+#else
+   const bool supports_il_program = false;
+#endif
return
   "cl_khr_byte_addressable_store"
   " cl_khr_global_int32_base_atomics"
@@ -294,5 +299,6 @@ device::supported_extensions() const {
   + std::string(has_int64_atomics() ? " cl_khr_int64_base_atomics" : "")
   + std::string(has_int64_atomics() ? " cl_khr_int64_extended_atomics" : 
"")
   + std::string(has_doubles() ? " cl_khr_fp64" : "")
-  + std::string(has_halves() ? " cl_khr_fp16" : "");
+  + std::string(has_halves() ? " cl_khr_fp16" : "")
+  + std::string(supports_il_program ? " cl_khr_il_program" : "");
 }
-- 
2.16.3

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


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

2018-03-25 Thread Pierre Moreau
Signed-off-by: Pierre Moreau 
---
New in v5

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

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

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

2018-03-25 Thread Pierre Moreau
Reviewed-by: Karol Herbst 
Signed-off-by: Pierre Moreau 
---
Changes in v5:
* Add a comment saying where to find llvm-spirv (Karol Herbst).

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

diff --git a/configure.ac b/configure.ac
index 99805e0f2b..f6b99cab9a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2425,6 +2425,24 @@ AM_CONDITIONAL(HAVE_CLOVER_ICD, test 
"x$enable_opencl_icd" = xyes)
 AC_SUBST([OPENCL_LIBNAME])
 AC_SUBST([CLANG_RESOURCE_DIR])
 
+AS_IF([test "x$enable_opencl" = xyes], [
+PKG_CHECK_MODULES([SPIRV_TOOLS], [SPIRV-Tools >= 2018.0],
+  [have_spirv_tools=yes], [have_spirv_tools=no])])
+AC_SUBST([SPIRV_TOOLS_CFLAGS])
+AC_SUBST([SPIRV_TOOLS_LIBS])
+
+# llvm-spirv is available at https://github.com/pierremoreau/llvm-spirv
+AS_IF([test "x$enable_opencl" = xyes], [
+PKG_CHECK_MODULES([LLVM_SPIRV], [llvm-spirv >= 0.2],
+  [have_llvm_spirv=yes], [have_llvm_spirv=no])])
+AC_SUBST([LLVM_SPIRV_CFLAGS])
+AC_SUBST([LLVM_SPIRV_LIBS])
+
+if test "x$have_spirv_tools" = xyes -o \
+"x$have_llvm_spirv" = xyes; then
+DEFINES="$DEFINES -DCLOVER_ALLOW_SPIRV"
+fi
+
 dnl
 dnl Gallium configuration
 dnl
diff --git a/meson.build b/meson.build
index 041d2bfc70..cc2dbe1fb4 100644
--- a/meson.build
+++ b/meson.build
@@ -640,10 +640,18 @@ if _opencl != 'disabled'
 
   # TODO: alitvec?
   dep_clc = dependency('libclc')
+  dep_spirv_tools = dependency('SPIRV-Tools', required : false, version : '>= 
2018.0')
+# llvm-spirv is available at https://github.com/pierremoreau/llvm-spirv
+  dep_llvm_spirv = dependency('llvm-spirv', required : false, version : '>= 
0.2')
+  if dep_spirv_tools.found() and dep_llvm_spirv.found()
+pre_args += '-DCLOVER_ALLOW_SPIRV'
+  endif
   with_gallium_opencl = true
   with_opencl_icd = _opencl == 'icd'
 else
   dep_clc = []
+  dep_spirv_tools = []
+  dep_llvm_spirv = []
   with_gallium_opencl = false
   with_gallium_icd = false
 endif
-- 
2.16.3

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


[Mesa-dev] [PATCH v5 19/21] clover/api: Implement CL_DEVICE_IL_VERSION

2018-03-25 Thread Pierre Moreau
Reviewed-by: Karol Herbst 
Signed-off-by: Pierre Moreau 
---
 src/gallium/state_trackers/clover/api/device.cpp | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/src/gallium/state_trackers/clover/api/device.cpp 
b/src/gallium/state_trackers/clover/api/device.cpp
index 4e274c5005..ac6e4e0185 100644
--- a/src/gallium/state_trackers/clover/api/device.cpp
+++ b/src/gallium/state_trackers/clover/api/device.cpp
@@ -333,6 +333,13 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
   buf.as_string() = dev.supported_extensions();
   break;
 
+   case CL_DEVICE_IL_VERSION:
+  if (dev.supported_extensions().find("cl_khr_il_program") == 
std::string::npos)
+ throw error(CL_INVALID_VALUE);
+  buf.as_string() = std::string("SPIR-V_1.0");
+
+  break;
+
case CL_DEVICE_PLATFORM:
   buf.as_scalar() = desc(dev.platform);
   break;
-- 
2.16.3

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


[Mesa-dev] [PATCH v5 17/21] clover: Implement clCreateProgramWithILKHR

2018-03-25 Thread Pierre Moreau
Signed-off-by: Pierre Moreau 
---
Changes in v5:
* Use is_binary_spirv and is_valid_spirv from the SPIR-V backend;
* Drop the SPIRV-Tools and llvm-spirv dependencies on clover.

 src/gallium/state_trackers/clover/api/dispatch.hpp |  4 ++
 src/gallium/state_trackers/clover/api/program.cpp  | 60 +-
 src/gallium/state_trackers/clover/core/program.cpp | 47 ++---
 src/gallium/state_trackers/clover/core/program.hpp | 12 +
 4 files changed, 113 insertions(+), 10 deletions(-)

diff --git a/src/gallium/state_trackers/clover/api/dispatch.hpp 
b/src/gallium/state_trackers/clover/api/dispatch.hpp
index 84b992af9b..dc9c94a540 100644
--- a/src/gallium/state_trackers/clover/api/dispatch.hpp
+++ b/src/gallium/state_trackers/clover/api/dispatch.hpp
@@ -974,6 +974,10 @@ namespace clover {
cl_int
IcdGetPlatformIDsKHR(cl_uint num_entries, cl_platform_id *rd_platforms,
 cl_uint *rnum_platforms);
+
+   cl_program
+   CreateProgramWithILKHR(cl_context d_ctx, const void *il,
+  size_t length, cl_int *r_errcode);
 }
 
 #endif
diff --git a/src/gallium/state_trackers/clover/api/program.cpp 
b/src/gallium/state_trackers/clover/api/program.cpp
index 7d57d3f0e9..3c7e56efb9 100644
--- a/src/gallium/state_trackers/clover/api/program.cpp
+++ b/src/gallium/state_trackers/clover/api/program.cpp
@@ -22,6 +22,7 @@
 
 #include "api/util.hpp"
 #include "core/program.hpp"
+#include "spirv/invocation.hpp"
 #include "util/u_debug.h"
 
 #include 
@@ -46,6 +47,26 @@ namespace {
 }, objs(d_devs, num_devs)))
  throw error(CL_INVALID_DEVICE);
}
+
+   enum program::il_type
+   identify_and_validate_il(const void *il, size_t length,
+const std::string &opencl_version,
+const context::notify_action ¬ify) {
+
+  enum program::il_type il_type = program::il_type::none;
+
+#ifdef CLOVER_ALLOW_SPIRV
+  const uint32_t *stream = reinterpret_cast(il);
+  if (spirv::is_binary_spirv(reinterpret_cast(il), length)) {
+ if (!spirv::is_valid_spirv(stream, length / 4u, opencl_version,
+notify))
+throw error(CL_INVALID_VALUE);
+ il_type = program::il_type::spirv;
+  }
+#endif
+
+  return il_type;
+   }
 }
 
 CLOVER_API cl_program
@@ -129,6 +150,41 @@ clCreateProgramWithBinary(cl_context d_ctx, cl_uint n,
return NULL;
 }
 
+cl_program
+clover::CreateProgramWithILKHR(cl_context d_ctx, const void *il,
+   size_t length, cl_int *r_errcode) try {
+   auto &ctx = obj(d_ctx);
+
+   if (!il || !length)
+  throw error(CL_INVALID_VALUE);
+
+   // Compute the highest OpenCL version supported by all devices associated to
+   // the context. That is the version used for validating the SPIR-V binary.
+   std::string min_opencl_version;
+   for (const device &dev : ctx.devices()) {
+  const std::string opencl_version = dev.device_version();
+  if (min_opencl_version.empty())
+ min_opencl_version = opencl_version;
+  else if (opencl_version < min_opencl_version)
+ min_opencl_version = opencl_version;
+   }
+
+   const enum program::il_type il_type = identify_and_validate_il(il, length,
+  
min_opencl_version,
+  ctx.notify);
+
+   if (il_type == program::il_type::none)
+  throw error(CL_INVALID_VALUE);
+
+   // Initialize a program object with it.
+   ret_error(r_errcode, CL_SUCCESS);
+   return new program(ctx, reinterpret_cast(il), length, il_type);
+
+} catch (error &e) {
+   ret_error(r_errcode, e);
+   return NULL;
+}
+
 CLOVER_API cl_program
 clCreateProgramWithBuiltInKernels(cl_context d_ctx, cl_uint n,
   const cl_device_id *d_devs,
@@ -185,7 +241,7 @@ clBuildProgram(cl_program d_prog, cl_uint num_devs,
validate_build_common(prog, num_devs, d_devs, valid_devs, pfn_notify,
  user_data);
 
-   if (prog.has_source) {
+   if (prog.has_source || prog.has_il) {
   prog.compile(devs, opts);
   prog.link(devs, opts, { prog });
} else if (any_of([&](const device &dev){
@@ -223,7 +279,7 @@ clCompileProgram(cl_program d_prog, cl_uint num_devs,
if (bool(num_headers) != bool(header_names))
   throw error(CL_INVALID_VALUE);
 
-   if (!prog.has_source)
+   if (!prog.has_source && !prog.has_il)
   throw error(CL_INVALID_OPERATION);
 
for_each([&](const char *name, const program &header) {
diff --git a/src/gallium/state_trackers/clover/core/program.cpp 
b/src/gallium/state_trackers/clover/core/program.cpp
index 62fa13efbf..9480cfb0b4 100644
--- a/src/gallium/state_trackers/clover/core/program.cpp
+++ b/src/gallium/state_trackers/clover/core/program.cpp
@@ -25,26 +25,48 @@
 
 using namespace clover;
 
+namespace {
+   module
+   compile_program(const program &prog, c

[Mesa-dev] [PATCH v5 21/21] clover: Implement clCreateProgramWithIL from OpenCL 2.1

2018-03-25 Thread Pierre Moreau
Reviewed-by: Karol Herbst 
Signed-off-by: Pierre Moreau 
---
 src/gallium/state_trackers/clover/api/dispatch.cpp | 2 +-
 src/gallium/state_trackers/clover/api/program.cpp  | 8 
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/clover/api/dispatch.cpp 
b/src/gallium/state_trackers/clover/api/dispatch.cpp
index 8be4d3cb26..f5f3248f26 100644
--- a/src/gallium/state_trackers/clover/api/dispatch.cpp
+++ b/src/gallium/state_trackers/clover/api/dispatch.cpp
@@ -162,7 +162,7 @@ namespace clover {
   NULL, // clSetKernelExecInfo
   NULL, // clGetKernelSubGroupInfoKHR
   NULL, // clCloneKernel
-  NULL, // clCreateProgramWithIL
+  clCreateProgramWithIL,
   NULL, // clEnqueueSVMMigrateMem
   NULL, // clGetDeviceAndHostTimer
   NULL, // clGetHostTimer
diff --git a/src/gallium/state_trackers/clover/api/program.cpp 
b/src/gallium/state_trackers/clover/api/program.cpp
index 851a212b99..a5d1fd0567 100644
--- a/src/gallium/state_trackers/clover/api/program.cpp
+++ b/src/gallium/state_trackers/clover/api/program.cpp
@@ -185,6 +185,14 @@ clover::CreateProgramWithILKHR(cl_context d_ctx, const 
void *il,
return NULL;
 }
 
+CLOVER_API cl_program
+clCreateProgramWithIL(cl_context d_ctx,
+  const void *il,
+  size_t length,
+  cl_int *r_errcode) {
+   return CreateProgramWithILKHR(d_ctx, il, length, r_errcode);
+}
+
 CLOVER_API cl_program
 clCreateProgramWithBuiltInKernels(cl_context d_ctx, cl_uint n,
   const cl_device_id *d_devs,
-- 
2.16.3

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


[Mesa-dev] [PATCH v5 18/21] clover: Handle CL_PROGRAM_IL in clGetProgramInfo

2018-03-25 Thread Pierre Moreau
Signed-off-by: Pierre Moreau 
---
 src/gallium/state_trackers/clover/api/program.cpp | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/src/gallium/state_trackers/clover/api/program.cpp 
b/src/gallium/state_trackers/clover/api/program.cpp
index 3c7e56efb9..851a212b99 100644
--- a/src/gallium/state_trackers/clover/api/program.cpp
+++ b/src/gallium/state_trackers/clover/api/program.cpp
@@ -429,6 +429,13 @@ clGetProgramInfo(cl_program d_prog, cl_program_info param,
   buf.as_string() = prog.source();
   break;
 
+   case CL_PROGRAM_IL:
+  if (prog.has_il)
+ buf.as_vector() = prog.il();
+  else if (r_size)
+ *r_size = 0u;
+  break;
+
case CL_PROGRAM_BINARY_SIZES:
   buf.as_vector() = map([&](const device &dev) {
 return prog.build(dev).binary.size();
-- 
2.16.3

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


[Mesa-dev] [PATCH v5 14/21] clover/llvm: Allow translating from SPIR-V to LLVM IR

2018-03-25 Thread Pierre Moreau
Signed-off-by: Pierre Moreau 
---
 .../state_trackers/clover/llvm/invocation.cpp  | 29 ++
 .../state_trackers/clover/llvm/invocation.hpp  |  6 +
 src/gallium/state_trackers/clover/meson.build  |  2 +-
 3 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp 
b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index b2c64bc48f..4933d018ae 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -24,12 +24,17 @@
 // OTHER DEALINGS IN THE SOFTWARE.
 //
 
+#include 
+
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#ifdef CLOVER_ALLOW_SPIRV
+#include 
+#endif
 
 #include 
 #include 
@@ -392,3 +397,27 @@ clover::llvm::link_program(const std::vector 
&modules,
   unreachable("Unsupported IR.");
}
 }
+
+#ifdef CLOVER_ALLOW_SPIRV
+module
+clover::llvm::compile_from_spirv(const std::vector &binary,
+ const device &dev,
+ std::string &r_log) {
+   auto ctx = create_context(r_log);
+
+   ::llvm::Module *unsafe_mod;
+   std::string error_msg;
+   std::istringstream input({ binary.begin(), binary.end() }, 
std::ios_base::binary);
+   if (!::llvm::readSPIRV(*ctx, input, unsafe_mod, error_msg)) {
+  r_log += "Failed to convert SPIR-V to LLVM IR: " + error_msg + ".\n";
+  throw error(CL_INVALID_VALUE);
+   }
+
+   std::unique_ptr<::llvm::Module> mod(unsafe_mod);
+
+   if (has_flag(debug::llvm))
+  debug::log(".ll", print_module_bitcode(*mod));
+
+   return build_module_library(*mod, module::section::text_intermediate);
+}
+#endif
diff --git a/src/gallium/state_trackers/clover/llvm/invocation.hpp 
b/src/gallium/state_trackers/clover/llvm/invocation.hpp
index ff9caa457c..85b16f6c90 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.hpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.hpp
@@ -40,6 +40,12 @@ namespace clover {
   const device &device,
   const std::string &opts,
   std::string &r_log);
+
+#ifdef CLOVER_ALLOW_SPIRV
+  module compile_from_spirv(const std::vector &binary,
+const device &dev,
+std::string &r_log);
+#endif
}
 }
 
diff --git a/src/gallium/state_trackers/clover/meson.build 
b/src/gallium/state_trackers/clover/meson.build
index c52f0faa40..bffd0df11d 100644
--- a/src/gallium/state_trackers/clover/meson.build
+++ b/src/gallium/state_trackers/clover/meson.build
@@ -48,7 +48,7 @@ libclllvm = static_library(
   dep_llvm.get_configtool_variable('version'), 'include',
 )),
   ],
-  dependencies : [dep_llvm, dep_elf],
+  dependencies : [dep_llvm, dep_elf, dep_llvm_spirv],
 )
 
 clover_files = files(
-- 
2.16.3

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


[Mesa-dev] [PATCH v5 12/21] clover: Move platform extensions definitions to clover/platform.cpp

2018-03-25 Thread Pierre Moreau
Reviewed-by: Francisco Jerez 
Reviewed-by: Aaron Watry 
Signed-off-by: Pierre Moreau 
---
 src/gallium/state_trackers/clover/api/platform.cpp  | 4 ++--
 src/gallium/state_trackers/clover/core/platform.cpp | 5 +
 src/gallium/state_trackers/clover/core/platform.hpp | 2 ++
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/gallium/state_trackers/clover/api/platform.cpp 
b/src/gallium/state_trackers/clover/api/platform.cpp
index 3b96b03fde..94d883c1f0 100644
--- a/src/gallium/state_trackers/clover/api/platform.cpp
+++ b/src/gallium/state_trackers/clover/api/platform.cpp
@@ -51,7 +51,7 @@ clover::GetPlatformInfo(cl_platform_id d_platform, 
cl_platform_info param,
 size_t size, void *r_buf, size_t *r_size) try {
property_buffer buf { r_buf, size, r_size };
 
-   obj(d_platform);
+   auto &platform = obj(d_platform);
 
switch (param) {
case CL_PLATFORM_PROFILE:
@@ -78,7 +78,7 @@ clover::GetPlatformInfo(cl_platform_id d_platform, 
cl_platform_info param,
   break;
 
case CL_PLATFORM_EXTENSIONS:
-  buf.as_string() = "cl_khr_icd";
+  buf.as_string() = platform.supported_extensions();
   break;
 
case CL_PLATFORM_ICD_SUFFIX_KHR:
diff --git a/src/gallium/state_trackers/clover/core/platform.cpp 
b/src/gallium/state_trackers/clover/core/platform.cpp
index 489e8dc5a8..ddd63fc5a0 100644
--- a/src/gallium/state_trackers/clover/core/platform.cpp
+++ b/src/gallium/state_trackers/clover/core/platform.cpp
@@ -39,3 +39,8 @@ platform::platform() : adaptor_range(evals(), devs) {
   }
}
 }
+
+std::string
+platform::supported_extensions() const {
+   return "cl_khr_icd";
+}
diff --git a/src/gallium/state_trackers/clover/core/platform.hpp 
b/src/gallium/state_trackers/clover/core/platform.hpp
index e849645bbe..b94434c983 100644
--- a/src/gallium/state_trackers/clover/core/platform.hpp
+++ b/src/gallium/state_trackers/clover/core/platform.hpp
@@ -40,6 +40,8 @@ namespace clover {
   platform &
   operator=(const platform &platform) = delete;
 
+  std::string supported_extensions() const;
+
protected:
   std::vector> devs;
};
-- 
2.16.3

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


[Mesa-dev] [PATCH v5 15/21] include/CL: Add cl_khr_il_program

2018-03-25 Thread Pierre Moreau
Reviewed-by: Karol Herbst 
Signed-off-by: Pierre Moreau 
---
 include/CL/cl_ext.h | 37 +
 1 file changed, 37 insertions(+)

diff --git a/include/CL/cl_ext.h b/include/CL/cl_ext.h
index 5078e8f45f..5ea4968042 100644
--- a/include/CL/cl_ext.h
+++ b/include/CL/cl_ext.h
@@ -599,6 +599,43 @@ clSetKernelExecInfoARM(cl_kernel/* kernel */,
 
 #endif /* CL_VERSION_1_2 */
 
+/***
+ * cl_khr_il_program extension *
+ ***/
+
+#if defined(CL_VERSION_1_2) || defined(CL_VERSION_2_0)
+
+#ifndef cl_khr_il_program
+#define cl_khr_il_program 1
+
+/* New property to clGetDeviceInfo for retrieving supported intermediate
+ * languages
+ */
+#define CL_DEVICE_IL_VERSION_KHR0x105B
+
+/* New property to clGetProgramInfo for retrieving for retrieving the IL of a
+ * program
+ */
+#define CL_PROGRAM_IL_KHR   0x1169
+
+extern CL_API_ENTRY cl_program
+  CL_API_CALL clCreateProgramWithILKHR(
+  cl_context /* context */,
+  const void * /* il */,
+  size_t /* length */,
+  cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_2;
+
+typedef CL_API_ENTRY cl_program
+  (CL_API_CALL *clCreateProgramWithILKHR_fn)(
+  cl_context /* context */,
+  const void * /* il */,
+  size_t /* length */,
+  cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_2;
+
+#endif /* CL_VERSION_1_2 || CL_VERSION_2_0 */
+
+#endif /* cl_khr_il_program */
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.16.3

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


[Mesa-dev] [PATCH v5 11/21] clover: Move device extensions definitions to core/device.cpp

2018-03-25 Thread Pierre Moreau
Reviewed-by: Francisco Jerez 
Reviewed-by: Aaron Watry 
Signed-off-by: Pierre Moreau 
---
 src/gallium/state_trackers/clover/api/device.cpp  | 11 +--
 src/gallium/state_trackers/clover/core/device.cpp | 14 ++
 src/gallium/state_trackers/clover/core/device.hpp |  1 +
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/src/gallium/state_trackers/clover/api/device.cpp 
b/src/gallium/state_trackers/clover/api/device.cpp
index 576555a9af..4e274c5005 100644
--- a/src/gallium/state_trackers/clover/api/device.cpp
+++ b/src/gallium/state_trackers/clover/api/device.cpp
@@ -330,16 +330,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
   break;
 
case CL_DEVICE_EXTENSIONS:
-  buf.as_string() =
- "cl_khr_byte_addressable_store"
- " cl_khr_global_int32_base_atomics"
- " cl_khr_global_int32_extended_atomics"
- " cl_khr_local_int32_base_atomics"
- " cl_khr_local_int32_extended_atomics"
- + std::string(dev.has_int64_atomics() ? " cl_khr_int64_base_atomics" 
: "")
- + std::string(dev.has_int64_atomics() ? " 
cl_khr_int64_extended_atomics" : "")
- + std::string(dev.has_doubles() ? " cl_khr_fp64" : "")
- + std::string(dev.has_halves() ? " cl_khr_fp16" : "");
+  buf.as_string() = dev.supported_extensions();
   break;
 
case CL_DEVICE_PLATFORM:
diff --git a/src/gallium/state_trackers/clover/core/device.cpp 
b/src/gallium/state_trackers/clover/core/device.cpp
index bd67bab5bc..21de0e3d61 100644
--- a/src/gallium/state_trackers/clover/core/device.cpp
+++ b/src/gallium/state_trackers/clover/core/device.cpp
@@ -282,3 +282,17 @@ device::supports_ir(enum pipe_shader_ir ir) const {
return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE,
  PIPE_SHADER_CAP_SUPPORTED_IRS) & (1 << ir);
 }
+
+std::string
+device::supported_extensions() const {
+   return
+  "cl_khr_byte_addressable_store"
+  " cl_khr_global_int32_base_atomics"
+  " cl_khr_global_int32_extended_atomics"
+  " cl_khr_local_int32_base_atomics"
+  " cl_khr_local_int32_extended_atomics"
+  + std::string(has_int64_atomics() ? " cl_khr_int64_base_atomics" : "")
+  + std::string(has_int64_atomics() ? " cl_khr_int64_extended_atomics" : 
"")
+  + std::string(has_doubles() ? " cl_khr_fp64" : "")
+  + std::string(has_halves() ? " cl_khr_fp16" : "");
+}
diff --git a/src/gallium/state_trackers/clover/core/device.hpp 
b/src/gallium/state_trackers/clover/core/device.hpp
index ebe15f28e9..a7084e863f 100644
--- a/src/gallium/state_trackers/clover/core/device.hpp
+++ b/src/gallium/state_trackers/clover/core/device.hpp
@@ -83,6 +83,7 @@ namespace clover {
   std::string ir_target() const;
   enum pipe_endian endianness() const;
   bool supports_ir(enum pipe_shader_ir ir) const;
+  std::string supported_extensions() const;
 
   friend class command_queue;
   friend class root_resource;
-- 
2.16.3

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


[Mesa-dev] [PATCH v5 10/21] clover: Track flags per module section

2018-03-25 Thread Pierre Moreau
One flag that needs to be tracked is whether a library is allowed to
received mathematics optimisations or not, as the authorisation is given
when creating the library while the optimisations are specified when
creating the executable.

Reviewed-by: Aaron Watry 
Signed-off-by: Pierre Moreau 
---
 src/gallium/state_trackers/clover/core/module.cpp  |  1 +
 src/gallium/state_trackers/clover/core/module.hpp  | 13 +
 src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp |  3 ++-
 src/gallium/state_trackers/clover/llvm/codegen/common.cpp  |  2 +-
 4 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/gallium/state_trackers/clover/core/module.cpp 
b/src/gallium/state_trackers/clover/core/module.cpp
index a6c5b98d8e..0e11506d0d 100644
--- a/src/gallium/state_trackers/clover/core/module.cpp
+++ b/src/gallium/state_trackers/clover/core/module.cpp
@@ -163,6 +163,7 @@ namespace {
   proc(S &s, QT &x) {
  _proc(s, x.id);
  _proc(s, x.type);
+ _proc(s, x.flags);
  _proc(s, x.size);
  _proc(s, x.data);
   }
diff --git a/src/gallium/state_trackers/clover/core/module.hpp 
b/src/gallium/state_trackers/clover/core/module.hpp
index 2ddd26426f..ff7e9b6234 100644
--- a/src/gallium/state_trackers/clover/core/module.hpp
+++ b/src/gallium/state_trackers/clover/core/module.hpp
@@ -41,14 +41,19 @@ namespace clover {
 data_local,
 data_private
  };
+ enum class flags_t {
+none,
+allow_link_options
+ };
 
- section(resource_id id, enum type type, size_t size,
- const std::vector &data) :
- id(id), type(type), size(size), data(data) { }
- section() : id(0), type(text_intermediate), size(0), data() { }
+ section(resource_id id, enum type type, flags_t flags,
+ size_t size, const std::vector &data) :
+ id(id), type(type), flags(flags), size(size), data(data) { }
+ section() : id(0), type(text_intermediate), flags(flags_t::none), 
size(0), data() { }
 
  resource_id id;
  type type;
+ flags_t flags;
  size_t size;
  std::vector data;
   };
diff --git a/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp 
b/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp
index 40bb426218..8e9d4c7e85 100644
--- a/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp
+++ b/src/gallium/state_trackers/clover/llvm/codegen/bitcode.cpp
@@ -84,7 +84,8 @@ clover::llvm::build_module_library(const ::llvm::Module &mod,
enum module::section::type section_type) {
module m;
const auto code = emit_code(mod);
-   m.secs.emplace_back(0, section_type, code.size(), code);
+   m.secs.emplace_back(0, section_type, module::section::flags_t::none,
+   code.size(), code);
return m;
 }
 
diff --git a/src/gallium/state_trackers/clover/llvm/codegen/common.cpp 
b/src/gallium/state_trackers/clover/llvm/codegen/common.cpp
index ddf2083f37..3a08f11fcc 100644
--- a/src/gallium/state_trackers/clover/llvm/codegen/common.cpp
+++ b/src/gallium/state_trackers/clover/llvm/codegen/common.cpp
@@ -179,7 +179,7 @@ namespace {
make_text_section(const std::vector &code) {
   const pipe_llvm_program_header header { uint32_t(code.size()) };
   module::section text { 0, module::section::text_executable,
- header.num_bytes, {} };
+ module::section::flags_t::none, header.num_bytes, 
{} };
 
   text.data.insert(text.data.end(), reinterpret_cast(&header),
reinterpret_cast(&header) + 
sizeof(header));
-- 
2.16.3

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


[Mesa-dev] [PATCH v5 09/21] clover: Disallow creating libraries from other libraries

2018-03-25 Thread Pierre Moreau
If creating a library, do not allow non-compiled object in it, as
executables are not allowed, and libraries would make it really hard to
enforce the "-enable-link-options" flag.

Reviewed-by: Francisco Jerez 
Reviewed-by: Aaron Watry 
Signed-off-by: Pierre Moreau 
---
 src/gallium/state_trackers/clover/api/program.cpp | 21 ++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/gallium/state_trackers/clover/api/program.cpp 
b/src/gallium/state_trackers/clover/api/program.cpp
index 134cebfdf7..7d57d3f0e9 100644
--- a/src/gallium/state_trackers/clover/api/program.cpp
+++ b/src/gallium/state_trackers/clover/api/program.cpp
@@ -253,8 +253,11 @@ clCompileProgram(cl_program d_prog, cl_uint num_devs,
 namespace {
ref_vector
validate_link_devices(const ref_vector &progs,
- const ref_vector &all_devs) {
+ const ref_vector &all_devs,
+ const std::string &opts) {
   std::vector devs;
+  const bool create_library =
+ opts.find("-create-library") != std::string::npos;
 
   for (auto &dev : all_devs) {
  const auto has_binary = [&](const program &prog) {
@@ -263,10 +266,22 @@ namespace {
t == CL_PROGRAM_BINARY_TYPE_LIBRARY;
  };
 
+ // According to the OpenCL 1.2 specification, a library is made of
+ // “compiled binaries specified in input_programs argument to
+ // clLinkProgram“; compiled binaries does not refer to libraries:
+ // “input_programs is an array of program objects that are compiled
+ // binaries or libraries that are to be linked to create the program
+ // executable”.
+ if (create_library && any_of([&](const program &prog) {
+  const auto t = prog.build(dev).binary_type();
+  return t != CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT;
+   }, progs))
+throw error(CL_INVALID_OPERATION);
+
  // According to the CL 1.2 spec, when "all programs specified [..]
  // contain a compiled binary or library for the device [..] a link is
  // performed",
- if (all_of(has_binary, progs))
+ else if (all_of(has_binary, progs))
 devs.push_back(&dev);
 
  // otherwise if "none of the programs contain a compiled binary or
@@ -293,7 +308,7 @@ clLinkProgram(cl_context d_ctx, cl_uint num_devs, const 
cl_device_id *d_devs,
auto valid_devs = ref_vector(ctx.devices());
auto devs = validate_link_devices(progs,
  (d_devs ? objs(d_devs, num_devs) :
-  valid_devs));
+  valid_devs), opts);
 
validate_build_common(prog, num_devs, d_devs, valid_devs, pfn_notify,
  user_data);
-- 
2.16.3

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


[Mesa-dev] [PATCH v5 07/21] clover/api: Rework the validation of devices for building

2018-03-25 Thread Pierre Moreau
Signed-off-by: Pierre Moreau 
---
 src/gallium/state_trackers/clover/api/program.cpp  | 23 +-
 src/gallium/state_trackers/clover/core/program.cpp |  3 ++-
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/src/gallium/state_trackers/clover/api/program.cpp 
b/src/gallium/state_trackers/clover/api/program.cpp
index 9d59668f8f..e97b6400fe 100644
--- a/src/gallium/state_trackers/clover/api/program.cpp
+++ b/src/gallium/state_trackers/clover/api/program.cpp
@@ -32,6 +32,7 @@ namespace {
void
validate_build_common(const program &prog, cl_uint num_devs,
  const cl_device_id *d_devs,
+ ref_vector &valid_devs,
  void (*pfn_notify)(cl_program, void *),
  void *user_data) {
   if (!pfn_notify && user_data)
@@ -41,7 +42,7 @@ namespace {
  throw error(CL_INVALID_OPERATION);
 
   if (any_of([&](const device &dev) {
-   return !count(dev, prog.context().devices());
+   return !count(dev, valid_devs);
 }, objs(d_devs, num_devs)))
  throw error(CL_INVALID_DEVICE);
}
@@ -176,12 +177,13 @@ clBuildProgram(cl_program d_prog, cl_uint num_devs,
void (*pfn_notify)(cl_program, void *),
void *user_data) try {
auto &prog = obj(d_prog);
-   auto devs = (d_devs ? objs(d_devs, num_devs) :
-ref_vector(prog.context().devices()));
+   auto valid_devs = ref_vector(prog.devices());
+   auto devs = (d_devs ? objs(d_devs, num_devs) : valid_devs);
const auto opts = std::string(p_opts ? p_opts : "") + " " +
  debug_get_option("CLOVER_EXTRA_BUILD_OPTIONS", "");
 
-   validate_build_common(prog, num_devs, d_devs, pfn_notify, user_data);
+   validate_build_common(prog, num_devs, d_devs, valid_devs, pfn_notify,
+ user_data);
 
if (prog.has_source) {
   prog.compile(devs, opts);
@@ -202,13 +204,14 @@ clCompileProgram(cl_program d_prog, cl_uint num_devs,
  void (*pfn_notify)(cl_program, void *),
  void *user_data) try {
auto &prog = obj(d_prog);
-   auto devs = (d_devs ? objs(d_devs, num_devs) :
-ref_vector(prog.context().devices()));
+   auto valid_devs = ref_vector(prog.devices());
+   auto devs = (d_devs ? objs(d_devs, num_devs) : valid_devs);
const auto opts = std::string(p_opts ? p_opts : "") + " " +
  debug_get_option("CLOVER_EXTRA_COMPILE_OPTIONS", "");
header_map headers;
 
-   validate_build_common(prog, num_devs, d_devs, pfn_notify, user_data);
+   validate_build_common(prog, num_devs, d_devs, valid_devs, pfn_notify,
+ user_data);
 
if (bool(num_headers) != bool(header_names))
   throw error(CL_INVALID_VALUE);
@@ -280,11 +283,13 @@ clLinkProgram(cl_context d_ctx, cl_uint num_devs, const 
cl_device_id *d_devs,
  debug_get_option("CLOVER_EXTRA_LINK_OPTIONS", "");
auto progs = objs(d_progs, num_progs);
auto prog = create(ctx);
+   auto valid_devs = ref_vector(ctx.devices());
auto devs = validate_link_devices(progs,
  (d_devs ? objs(d_devs, num_devs) :
-  ref_vector(ctx.devices(;
+  valid_devs));
 
-   validate_build_common(prog, num_devs, d_devs, pfn_notify, user_data);
+   validate_build_common(prog, num_devs, d_devs, valid_devs, pfn_notify,
+ user_data);
 
try {
   prog().link(devs, opts, progs);
diff --git a/src/gallium/state_trackers/clover/core/program.cpp 
b/src/gallium/state_trackers/clover/core/program.cpp
index ec71d99b01..62fa13efbf 100644
--- a/src/gallium/state_trackers/clover/core/program.cpp
+++ b/src/gallium/state_trackers/clover/core/program.cpp
@@ -26,7 +26,8 @@
 using namespace clover;
 
 program::program(clover::context &ctx, const std::string &source) :
-   has_source(true), context(ctx), _source(source), _kernel_ref_counter(0) {
+   has_source(true), context(ctx), _devices(ctx.devices()), _source(source),
+   _kernel_ref_counter(0) {
 }
 
 program::program(clover::context &ctx,
-- 
2.16.3

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


[Mesa-dev] [PATCH v5 02/21] clover: update ICD table to support everything up to 2.2

2018-03-25 Thread Pierre Moreau
From: Karol Herbst 

Reviewed-by: Pierre Moreau 
Signed-off-by: Karol Herbst 
---
v5: Fix return type of clCreateCommandQueueWithProperties
v2: add more prototypes

 src/gallium/state_trackers/clover/api/dispatch.cpp |  29 +++-
 src/gallium/state_trackers/clover/api/dispatch.hpp | 190 +
 2 files changed, 218 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/clover/api/dispatch.cpp 
b/src/gallium/state_trackers/clover/api/dispatch.cpp
index 8f4cfdc7fb..8be4d3cb26 100644
--- a/src/gallium/state_trackers/clover/api/dispatch.cpp
+++ b/src/gallium/state_trackers/clover/api/dispatch.cpp
@@ -142,6 +142,33 @@ namespace clover {
   NULL, // clEnqueueReleaseD3D11ObjectsKHR
   NULL, // clGetDeviceIDsFromDX9MediaAdapterKHR
   NULL, // clEnqueueAcquireDX9MediaSurfacesKHR
-  NULL // clEnqueueReleaseDX9MediaSurfacesKHR
+  NULL, // clEnqueueReleaseDX9MediaSurfacesKHR
+  NULL, // clCreateFromEGLImageKHR
+  NULL, // clEnqueueAcquireEGLObjectsKHR
+  NULL, // clEnqueueReleaseEGLObjectsKHR
+  NULL, // clCreateEventFromEGLSyncKHR
+  NULL, // clCreateCommandQueueWithProperties
+  NULL, // clCreatePipe
+  NULL, // clGetPipeInfo
+  NULL, // clSVMAlloc
+  NULL, // clSVMFree
+  NULL, // clEnqueueSVMFree
+  NULL, // clEnqueueSVMMemcpy
+  NULL, // clEnqueueSVMMemFill
+  NULL, // clEnqueueSVMMap
+  NULL, // clEnqueueSVMUnmap
+  NULL, // clCreateSamplerWithProperties
+  NULL, // clSetKernelArgSVMPointer
+  NULL, // clSetKernelExecInfo
+  NULL, // clGetKernelSubGroupInfoKHR
+  NULL, // clCloneKernel
+  NULL, // clCreateProgramWithIL
+  NULL, // clEnqueueSVMMigrateMem
+  NULL, // clGetDeviceAndHostTimer
+  NULL, // clGetHostTimer
+  NULL, // clGetKernelSubGroupInfo
+  NULL, // clSetDefaultDeviceCommandQueue
+  NULL, // clSetProgramReleaseCallback
+  NULL, // clSetProgramSpecializationConstant
};
 }
diff --git a/src/gallium/state_trackers/clover/api/dispatch.hpp 
b/src/gallium/state_trackers/clover/api/dispatch.hpp
index 0ec1b51fa6..84b992af9b 100644
--- a/src/gallium/state_trackers/clover/api/dispatch.hpp
+++ b/src/gallium/state_trackers/clover/api/dispatch.hpp
@@ -27,6 +27,7 @@
 
 #include "CL/cl.h"
 #include "CL/cl_ext.h"
+#include "CL/cl_egl.h"
 #include "CL/cl_gl.h"
 
 ///
@@ -765,6 +766,195 @@ struct _cl_icd_dispatch {
void *clGetDeviceIDsFromDX9MediaAdapterKHR;
void *clEnqueueAcquireDX9MediaSurfacesKHR;
void *clEnqueueReleaseDX9MediaSurfacesKHR;
+
+   CL_API_ENTRY void (CL_API_CALL *clCreateFromEGLImageKHR)(
+  cl_context context,
+  CLeglDisplayKHR display,
+  CLeglImageKHR image,
+  cl_mem_flags flags,
+  const cl_egl_image_properties_khr *properties,
+  cl_int *errcode_ret);
+
+   CL_API_ENTRY void (CL_API_CALL *clEnqueueAcquireEGLObjectsKHR)(
+  cl_command_queue command_queue,
+  cl_uint num_objects,
+  const cl_mem *mem_objects,
+  cl_uint num_events_in_wait_list,
+  const cl_event *event_wait_list,
+  cl_event *event);
+
+   CL_API_ENTRY void (CL_API_CALL *clEnqueueReleaseEGLObjectsKHR)(
+  cl_command_queue command_queue,
+  cl_uint num_objects,
+  const cl_mem *mem_objects,
+  cl_uint num_events_in_wait_list,
+  const cl_event *event_wait_list,
+  cl_event *event);
+
+   CL_API_ENTRY void (CL_API_CALL *clCreateEventFromEGLSyncKHR)(
+  cl_context context,
+  CLeglSyncKHR sync,
+  CLeglDisplayKHR display,
+  cl_int *errcode_ret);
+
+   CL_API_ENTRY cl_command_queue (CL_API_CALL 
*clCreateCommandQueueWithProperties)(
+  cl_context context,
+  cl_device_id device,
+  const cl_queue_properties *properties,
+  cl_int *errcode_ret);
+
+   CL_API_ENTRY void (CL_API_CALL *clCreatePipe)(
+  cl_context context,
+  cl_mem_flags flags,
+  cl_uint pipe_packet_size,
+  cl_uint pipe_max_packets,
+  const cl_pipe_properties *properties,
+  cl_int *errcode_ret);
+
+   CL_API_ENTRY void (CL_API_CALL *clGetPipeInfo)(
+  cl_mem pipe,
+  cl_pipe_info param_name,
+  size_t param_value_size,
+  void *param_value,
+  size_t *param_value_size_ret);
+
+   CL_API_ENTRY void (CL_API_CALL *clSVMAlloc)(
+  cl_context context,
+  cl_svm_mem_flags flags,
+  size_t size,
+  unsigned int alignment);
+
+   CL_API_ENTRY void (CL_API_CALL *clSVMFree)(
+  cl_context context,
+  void *svm_pointer);
+
+   CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueSVMFree)(
+  cl_command_queue command_queue,
+  cl_uint num_svm_pointers,
+  void **svm_pointers,
+  void (CL_CALLBACK *pfn_free_func)(cl_command_queue, cl_uint, void **, 
void *),
+  void *user_data,
+  cl_uint num_events_in_wait_list,
+  const cl_event *event_wait_list,
+  cl_event *event);
+
+   CL_API_ENTRY cl_int (CL_API_CALL *clEnqueueSVMMemcpy)(
+  cl_command_queue command_queue,
+  cl_bool blocking_copy,
+  void *dst_ptr,

[Mesa-dev] [PATCH v5 06/21] clover/device: Replace usage of "1 << PIPE_SHADER_IR_*" with supports_ir

2018-03-25 Thread Pierre Moreau
Reviewed-by: Aaron Watry 
Reviewed-by: Karol Herbst 
Signed-off-by: Pierre Moreau 
---
 src/gallium/state_trackers/clover/core/device.cpp | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/gallium/state_trackers/clover/core/device.cpp 
b/src/gallium/state_trackers/clover/core/device.cpp
index 62d5221bf8..bd67bab5bc 100644
--- a/src/gallium/state_trackers/clover/core/device.cpp
+++ b/src/gallium/state_trackers/clover/core/device.cpp
@@ -244,11 +244,7 @@ device::vendor_name() const {
 
 enum pipe_shader_ir
 device::ir_format() const {
-   int supported_irs =
-  pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE,
- PIPE_SHADER_CAP_SUPPORTED_IRS);
-
-   if (supported_irs & (1 << PIPE_SHADER_IR_NATIVE)) {
+   if (supports_ir(PIPE_SHADER_IR_NATIVE)) {
   return PIPE_SHADER_IR_NATIVE;
}
 
-- 
2.16.3

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


[Mesa-dev] [PATCH v5 03/21] clover/api: Fix tab indentation to spaces

2018-03-25 Thread Pierre Moreau
Acked-by: Francisco Jerez 
Reviewed-by: Karol Herbst 
Reviewed-by: Aaron Watry 
Signed-off-by: Pierre Moreau 
---
 src/gallium/state_trackers/clover/api/device.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/clover/api/device.cpp 
b/src/gallium/state_trackers/clover/api/device.cpp
index 3572bb0c92..576555a9af 100644
--- a/src/gallium/state_trackers/clover/api/device.cpp
+++ b/src/gallium/state_trackers/clover/api/device.cpp
@@ -326,7 +326,7 @@ clGetDeviceInfo(cl_device_id d_dev, cl_device_info param,
 #ifdef MESA_GIT_SHA1
 " (" MESA_GIT_SHA1 ")"
 #endif
-   ;
+;
   break;
 
case CL_DEVICE_EXTENSIONS:
-- 
2.16.3

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


[Mesa-dev] [PATCH v5 04/21] clover: Remove the TGSI backend as unused

2018-03-25 Thread Pierre Moreau
Reviewed-by: Karol Herbst 
Signed-off-by: Pierre Moreau 
---
 src/gallium/state_trackers/clover/Makefile.am  |  11 +-
 src/gallium/state_trackers/clover/Makefile.sources |   4 -
 src/gallium/state_trackers/clover/core/program.cpp |  13 +--
 src/gallium/state_trackers/clover/meson.build  |   9 +-
 .../state_trackers/clover/tgsi/compiler.cpp| 120 -
 .../state_trackers/clover/tgsi/invocation.hpp  |  37 ---
 6 files changed, 8 insertions(+), 186 deletions(-)
 delete mode 100644 src/gallium/state_trackers/clover/tgsi/compiler.cpp
 delete mode 100644 src/gallium/state_trackers/clover/tgsi/invocation.hpp

diff --git a/src/gallium/state_trackers/clover/Makefile.am 
b/src/gallium/state_trackers/clover/Makefile.am
index a7befb4605..35ee092f3f 100644
--- a/src/gallium/state_trackers/clover/Makefile.am
+++ b/src/gallium/state_trackers/clover/Makefile.am
@@ -28,14 +28,7 @@ cl_HEADERS = \
$(top_srcdir)/include/CL/opencl.h
 endif
 
-noinst_LTLIBRARIES = libclover.la libcltgsi.la libclllvm.la
-
-libcltgsi_la_CXXFLAGS = \
-   $(CXX11_CXXFLAGS) \
-   $(CLOVER_STD_OVERRIDE) \
-   $(VISIBILITY_CXXFLAGS)
-
-libcltgsi_la_SOURCES = $(TGSI_SOURCES)
+noinst_LTLIBRARIES = libclover.la libclllvm.la
 
 libclllvm_la_CXXFLAGS = \
$(CXX11_CXXFLAGS) \
@@ -56,7 +49,7 @@ libclover_la_CXXFLAGS = \
$(VISIBILITY_CXXFLAGS)
 
 libclover_la_LIBADD = \
-   libcltgsi.la libclllvm.la
+   libclllvm.la
 
 libclover_la_SOURCES = $(CPP_SOURCES)
 
diff --git a/src/gallium/state_trackers/clover/Makefile.sources 
b/src/gallium/state_trackers/clover/Makefile.sources
index e9828b107b..5167ca75af 100644
--- a/src/gallium/state_trackers/clover/Makefile.sources
+++ b/src/gallium/state_trackers/clover/Makefile.sources
@@ -62,7 +62,3 @@ LLVM_SOURCES := \
llvm/invocation.hpp \
llvm/metadata.hpp \
llvm/util.hpp
-
-TGSI_SOURCES := \
-   tgsi/compiler.cpp \
-   tgsi/invocation.hpp
diff --git a/src/gallium/state_trackers/clover/core/program.cpp 
b/src/gallium/state_trackers/clover/core/program.cpp
index 4e74fccd97..ec71d99b01 100644
--- a/src/gallium/state_trackers/clover/core/program.cpp
+++ b/src/gallium/state_trackers/clover/core/program.cpp
@@ -22,7 +22,6 @@
 
 #include "core/program.hpp"
 #include "llvm/invocation.hpp"
-#include "tgsi/invocation.hpp"
 
 using namespace clover;
 
@@ -51,10 +50,9 @@ program::compile(const ref_vector &devs, const 
std::string &opts,
  std::string log;
 
  try {
-const module m = (dev.ir_format() == PIPE_SHADER_IR_TGSI ?
-  tgsi::compile_program(_source, log) :
-  llvm::compile_program(_source, headers, dev,
-opts, log));
+assert(dev.ir_format() == PIPE_SHADER_IR_NATIVE);
+const module m = llvm::compile_program(_source, headers, dev, opts,
+   log);
 _builds[&dev] = { m, opts, log };
  } catch (...) {
 _builds[&dev] = { module(), opts, log };
@@ -76,9 +74,8 @@ program::link(const ref_vector &devs, const 
std::string &opts,
   std::string log = _builds[&dev].log;
 
   try {
- const module m = (dev.ir_format() == PIPE_SHADER_IR_TGSI ?
-   tgsi::link_program(ms) :
-   llvm::link_program(ms, dev, opts, log));
+ assert(dev.ir_format() == PIPE_SHADER_IR_NATIVE);
+ const module m = llvm::link_program(ms, dev, opts, log);
  _builds[&dev] = { m, opts, log };
   } catch (...) {
  _builds[&dev] = { module(), opts, log };
diff --git a/src/gallium/state_trackers/clover/meson.build 
b/src/gallium/state_trackers/clover/meson.build
index d1497e657e..c52f0faa40 100644
--- a/src/gallium/state_trackers/clover/meson.build
+++ b/src/gallium/state_trackers/clover/meson.build
@@ -25,13 +25,6 @@ if with_opencl_icd
   clover_cpp_args += '-DHAVE_CLOVER_ICD'
 endif
 
-libcltgsi = static_library(
-  'cltgsi',
-  files('tgsi/compiler.cpp', 'tgsi/invocation.hpp'),
-  include_directories : clover_incs,
-  cpp_args : [cpp_vis_args],
-)
-
 libclllvm = static_library(
   'clllvm',
   files(
@@ -118,5 +111,5 @@ libclover = static_library(
   clover_files,
   include_directories : clover_incs,
   cpp_args : [clover_cpp_args, cpp_vis_args],
-  link_with : [libcltgsi, libclllvm],
+  link_with : [libclllvm],
 )
diff --git a/src/gallium/state_trackers/clover/tgsi/compiler.cpp 
b/src/gallium/state_trackers/clover/tgsi/compiler.cpp
deleted file mode 100644
index e165311fa4..00
--- a/src/gallium/state_trackers/clover/tgsi/compiler.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-//
-// Copyright 2012 Francisco Jerez
-//
-// 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, includi

[Mesa-dev] [PATCH v5 08/21] clover/api: Fail if trying to build a non-executable binary

2018-03-25 Thread Pierre Moreau
From the OpenCL 1.2 Specification, Section 5.6.2 (about clBuildProgram):

> If program is created with clCreateProgramWithBinary, then the
> program binary must be an executable binary (not a compiled binary or
> library).

Reviewed-by: Aaron Watry 
Signed-off-by: Pierre Moreau 
---
 src/gallium/state_trackers/clover/api/program.cpp | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/src/gallium/state_trackers/clover/api/program.cpp 
b/src/gallium/state_trackers/clover/api/program.cpp
index e97b6400fe..134cebfdf7 100644
--- a/src/gallium/state_trackers/clover/api/program.cpp
+++ b/src/gallium/state_trackers/clover/api/program.cpp
@@ -188,6 +188,13 @@ clBuildProgram(cl_program d_prog, cl_uint num_devs,
if (prog.has_source) {
   prog.compile(devs, opts);
   prog.link(devs, opts, { prog });
+   } else if (any_of([&](const device &dev){
+ return prog.build(dev).binary_type() != 
CL_PROGRAM_BINARY_TYPE_EXECUTABLE;
+ }, devs)) {
+  // According to the OpenCL 1.2 specification, “if program is created
+  // with clCreateProgramWithBinary, then the program binary must be an
+  // executable binary (not a compiled binary or library).”
+  throw error(CL_INVALID_BINARY);
}
 
return CL_SUCCESS;
-- 
2.16.3

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


[Mesa-dev] [PATCH v5 05/21] clover: Add an helper for checking if an IR is supported

2018-03-25 Thread Pierre Moreau
Reviewed-by: Aaron Watry 
Reviewed-by: Karol Herbst 
Signed-off-by: Pierre Moreau 
---
 src/gallium/state_trackers/clover/core/device.cpp | 6 ++
 src/gallium/state_trackers/clover/core/device.hpp | 1 +
 2 files changed, 7 insertions(+)

diff --git a/src/gallium/state_trackers/clover/core/device.cpp 
b/src/gallium/state_trackers/clover/core/device.cpp
index 0d911e3751..62d5221bf8 100644
--- a/src/gallium/state_trackers/clover/core/device.cpp
+++ b/src/gallium/state_trackers/clover/core/device.cpp
@@ -280,3 +280,9 @@ device::device_clc_version() const {
  debug_get_option("CLOVER_DEVICE_CLC_VERSION_OVERRIDE", "1.1");
return device_clc_version;
 }
+
+bool
+device::supports_ir(enum pipe_shader_ir ir) const {
+   return pipe->get_shader_param(pipe, PIPE_SHADER_COMPUTE,
+ PIPE_SHADER_CAP_SUPPORTED_IRS) & (1 << ir);
+}
diff --git a/src/gallium/state_trackers/clover/core/device.hpp 
b/src/gallium/state_trackers/clover/core/device.hpp
index 85cd031676..ebe15f28e9 100644
--- a/src/gallium/state_trackers/clover/core/device.hpp
+++ b/src/gallium/state_trackers/clover/core/device.hpp
@@ -82,6 +82,7 @@ namespace clover {
   enum pipe_shader_ir ir_format() const;
   std::string ir_target() const;
   enum pipe_endian endianness() const;
+  bool supports_ir(enum pipe_shader_ir ir) const;
 
   friend class command_queue;
   friend class root_resource;
-- 
2.16.3

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


[Mesa-dev] [PATCH v5 00/21] Introducing SPIR-V support to clover

2018-03-25 Thread Pierre Moreau
Hello,

This has only minor changes compared to the previous version, but as it
introduces a new patch, I preferred to resend the whole series, as patch
numbering would be messed up otherwise.

As is_valid_spirv will be also used by the SPIR-V backend, I moved that
function away from api/program.cpp and into spirv/invocation.cpp, to avoid
introducing it in one place in this series, and moving it around in the next
series.

The current repository for llvm-spirv is temporary, and should be replaced by
an official one during next week. I’ll send an update to patch 13 when that
happens.

The series is accessible at
https://github.com/pierremoreau/mesa/tree/clover_spirv_series_v5.

Thanks in advance for the reviews and comments.
Pierre


v5:
* Update patch 02 to return the proper type for
  clCreateCommandQueueWithProperties;
* Add a comment in patch 13 to indicate where to find llvm-spirv;
* Move the is_spirv_valid function to spirv/invocation.cpp and improve it to
  take an OpenCL version as argument, which is used to configure the SPIR-V
  validator, instead of hardcoding OpenCL 1.2: new patch 16;
* Edit patch 17 to use SPIR-V functions from the backend.

Missing reviews/acks for:
* Patch 07: “clover/api: Rework the validation of devices for building”;
* Patch 14: “clover/llvm: Allow translating from SPIR-V to LLVM IR”;
* Patch 18: “clover: Handle CL_PROGRAM_IL in clGetProgramInfo”


Karol Herbst (1):
  clover: update ICD table to support everything up to 2.2

Pierre Moreau (20):
  include/CL: Update to the latest OpenCL 2.2 headers
  clover/api: Fix tab indentation to spaces
  clover: Remove the TGSI backend as unused
  clover: Add an helper for checking if an IR is supported
  clover/device: Replace usage of "1 << PIPE_SHADER_IR_*" with
supports_ir
  clover/api: Rework the validation of devices for building
  clover/api: Fail if trying to build a non-executable binary
  clover: Disallow creating libraries from other libraries
  clover: Track flags per module section
  clover: Move device extensions definitions to core/device.cpp
  clover: Move platform extensions definitions to clover/platform.cpp
  configure.ac,meson: Check for SPIRV-Tools and llvm-spirv
  clover/llvm: Allow translating from SPIR-V to LLVM IR
  include/CL: Add cl_khr_il_program
  clover/spirv: Add functions for validating SPIR-V binaries
  clover: Implement clCreateProgramWithILKHR
  clover: Handle CL_PROGRAM_IL in clGetProgramInfo
  clover/api: Implement CL_DEVICE_IL_VERSION
  clover: Advertise cl_khr_il_program
  clover: Implement clCreateProgramWithIL from OpenCL 2.1

 configure.ac   |   18 +
 include/CL/cl.h|  472 +++--
 include/CL/cl_d3d10.h  |7 +-
 include/CL/cl_d3d11.h  |7 +-
 include/CL/cl_dx9_media_sharing.h  |9 +-
 include/CL/cl_dx9_media_sharing_intel.h|  182 
 include/CL/cl_egl.h|9 +-
 include/CL/cl_ext.h|  338 +-
 include/CL/cl_ext_intel.h  |  429 
 include/CL/cl_gl.h |7 +-
 include/CL/cl_gl_ext.h |7 +-
 include/CL/cl_platform.h   |  328 --
 include/CL/cl_va_api_media_sharing_intel.h |  172 
 include/CL/opencl.h|7 +-
 meson.build|8 +
 src/gallium/state_trackers/clover/Makefile.am  |   22 +-
 src/gallium/state_trackers/clover/Makefile.sources |6 +-
 src/gallium/state_trackers/clover/api/device.cpp   |   20 +-
 src/gallium/state_trackers/clover/api/dispatch.cpp |   29 +-
 src/gallium/state_trackers/clover/api/dispatch.hpp |  194 
 src/gallium/state_trackers/clover/api/platform.cpp |6 +-
 src/gallium/state_trackers/clover/api/program.cpp  |  124 ++-
 src/gallium/state_trackers/clover/core/device.cpp  |   32 +-
 src/gallium/state_trackers/clover/core/device.hpp  |2 +
 src/gallium/state_trackers/clover/core/module.cpp  |1 +
 src/gallium/state_trackers/clover/core/module.hpp  |   13 +-
 .../state_trackers/clover/core/platform.cpp|5 +
 .../state_trackers/clover/core/platform.hpp|2 +
 src/gallium/state_trackers/clover/core/program.cpp |   55 +-
 src/gallium/state_trackers/clover/core/program.hpp |   12 +
 .../state_trackers/clover/llvm/codegen/bitcode.cpp |3 +-
 .../state_trackers/clover/llvm/codegen/common.cpp  |2 +-
 .../state_trackers/clover/llvm/invocation.cpp  |   29 +
 .../state_trackers/clover/llvm/invocation.hpp  |6 +
 src/gallium/state_trackers/clover/meson.build  |   19 +-
 .../state_trackers/clover/spirv/invocation.cpp |  138 +++
 .../clover/{tgsi => spirv}/invocation.hpp  |   26 +-
 src/gallium/state_trackers/clover/spirv/spirv.hpp  | 1081 
 .../state_track

[Mesa-dev] [AppVeyor] mesa master #7289 failed

2018-03-25 Thread AppVeyor



Build mesa 7289 failed


Commit 2f181c8c18 by Rob Clark on 3/12/2018 7:00 PM:

glsl_types: vec8/vec16 support\n\nNot used in GL but 8 and 16 component vectors exist in OpenCL.\n\nSigned-off-by: Rob Clark \nReviewed-by: Timothy Arceri 


Configure your notification preferences

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


Re: [Mesa-dev] [PATCH] mesa: readpixels add support for GL_HALF_FLOAT

2018-03-25 Thread Lin, Johnson
Cool. Thanks. Will update the patch.

-Original Message-
From: Palli, Tapani 
Sent: Friday, March 23, 2018 4:59 PM
To: Lin, Johnson ; Alejandro Piñeiro 
; mesa-dev@lists.freedesktop.org
Subject: Re: [Mesa-dev] [PATCH] mesa: readpixels add support for GL_HALF_FLOAT


On 03/23/2018 07:54 AM, Lin, Johnson wrote:
> So the solution will be query if EXT_color_buffer_half_float is supported?

I think I found a proof that we don't actually need anything. Spec for 
EXT_color_buffer_float adds following text:

--- 8< ---
An INVALID_OPERATION error is generated ... if the color buffer is a 
floating-point format and type is not FLOAT, HALF FLOAT, or 
UNSIGNED_INT_10F_11F_11F_REV.
--- 8< ---

This means that type can be HALF FLOAT when color buffer has floating-point 
format.

(even though for some weird reason spec does not add it to earlier sentence 
that says " "For floating-point rendering surfaces, the combination format RGBA 
and type FLOAT is accepted.")

Since EXT_color_buffer_float is enabled, we can just use this patch. 
Please remove the comment about EXT_color_buffer_half_float extension though, 
that extension is not enabled and would need more work elsewhere.


> -Original Message-
> From: Palli, Tapani
> Sent: Friday, March 23, 2018 1:53 PM
> To: Lin, Johnson ; Alejandro Piñeiro 
> ; mesa-dev@lists.freedesktop.org
> Subject: Re: [Mesa-dev] [PATCH] mesa: readpixels add support for GL_HALF_FLOAT
> 
> 
> On 03/22/2018 07:53 AM, Tapani Pälli wrote:
>>
>>
>> On 03/22/2018 04:43 AM, Lin, Johnson wrote:
>>> Hi,  Thanks for the comments.
>>>
>>> I just noticed it does not check the extension support for
>>> EXT_color_buffer_float neither?
>>
>> That is probably because it is enabled as 'dummy_true' (see
>> extensions_table.h) so it's always enabled on any driver. I wonder if
>> we can just go and do the same for EXT_color_buffer_half_float? Is
>> there any driver that would not support this?
> 
> Took a brief look and no, we can't simply toggle it on. There is also some 
> API interaction defined by the spec that would need to be enabled, querying 
> component type via glGetFramebufferAttachmentParameteriv and so on.
> 
>>
>>> -Original Message-
>>> From: Palli, Tapani
>>> Sent: Wednesday, March 21, 2018 6:57 PM
>>> To: Alejandro Piñeiro ; Lin, Johnson
>>> ; mesa-dev@lists.freedesktop.org
>>> Subject: Re: [Mesa-dev] [PATCH] mesa: readpixels add support for
>>> GL_HALF_FLOAT
>>>
>>>
>>>
>>> On 21.03.2018 12:45, Tapani Pälli wrote:


 On 21.03.2018 08:52, Alejandro Piñeiro wrote:
> On 21/03/18 06:57, Lin Johnson wrote:
>> Ext_color_buffer_half_float is using type GL_HALF_FLOAT and
>> data_type GL_FLOAT. This fix Android CTS test
>> android.view.cts.PixelCopyTest #TestWindowProducerCopyToRGBA16F
>>
>> Signed-off-by: Lin Johnson 
>> ---
>>     src/mesa/main/readpix.c | 2 ++
>>     1 file changed, 2 insertions(+)
>>
>> diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c
>> index 6ce340ddf9bb..51331dd095ab 100644
>> --- a/src/mesa/main/readpix.c
>> +++ b/src/mesa/main/readpix.c
>> @@ -920,6 +920,8 @@ read_pixels_es3_error_check(GLenum format,
>> GLenum type,
>>    case GL_RGBA:
>>   if (type == GL_FLOAT && data_type == GL_FLOAT)
>>      return GL_NO_ERROR; /* EXT_color_buffer_float */
>> +  if (type == GL_HALF_FLOAT && data_type == GL_FLOAT)
>> + return GL_NO_ERROR; /* EXT_color_buffer_half_float */
>
> If this combination is allowed thanks to that extension, what would
> happen if that extension is not supported? shouldn't include a
> extension check? Or that is checked in a different place?

 I was thinking the same. Having seen the test it does not seem to
 make any kind of checks what is supported (like asking for
 extension, or maybe asking for GL_IMPLEMENTATION_COLOR_READ_TYPE)
 but attempts glReadPixels using GL_HALF_FLOAT type, I think it
 should verify first that such reads are supported. Currently we
 don't seem to support this extension.
>>>
>>> ... but probably support the functionality (OpenGL ES 3.2), so maybe
>>> some checks needed for ES version (?)
>>>
>>>


>>   if (type == GL_UNSIGNED_BYTE && data_type ==
>> GL_UNSIGNED_NORMALIZED)
>>      return GL_NO_ERROR;
>>   if (internalFormat == GL_RGB10_A2 &&
>
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>> ___
>> mesa-dev mailing list
>> mesa-dev@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
_

[Mesa-dev] [Bug 105670] [regression][hang] Trine1EE hangs GPU after loading screen on Mesa3D-17.3 and later

2018-03-25 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105670

--- Comment #13 from Gert Wollny  ---
The GLSL spec says that "negative zeros are generated as dictated by IEEE" and
that "==" returns the correct result, which I'd assume means (0.0 == -0.0) is
true. 

In any case, I don't see how this is relevant for this bug.

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


Re: [Mesa-dev] [PATCH v3 06/19] RFC: nir/vtn: "raw" pointer support

2018-03-25 Thread Karol Herbst
On Sun, Mar 25, 2018 at 2:18 PM, Rob Clark  wrote:
> On Sun, Mar 25, 2018 at 6:35 AM, Karol Herbst  wrote:
>> On Sun, Mar 25, 2018 at 12:18 AM, Rob Clark  wrote:
>>> On Fri, Mar 23, 2018 at 5:18 PM, Jason Ekstrand  
>>> wrote:
 On Fri, Mar 23, 2018 at 2:15 PM, Karol Herbst  wrote:
>
> On Fri, Mar 23, 2018 at 10:07 PM, Jason Ekstrand 
> wrote:
> > +list
> >
> > On Fri, Mar 23, 2018 at 1:45 PM, Karol Herbst 
> > wrote:
> >>
> >> On Fri, Mar 23, 2018 at 9:30 PM, Jason Ekstrand 
> >> wrote:
> >> > As I've been rewriting core NIR deref handling, I've been thinking
> >> > about
> >> > this problem quite a bit.  One objective I have is to actually make
> >> > UBO
> >> > and
> >> > SSBO access go through derefs instead of just being an offset and
> >> > index
> >> > so
> >> > that the compiler can better reason about them.  In particular, I
> >> > want
> >> > to be
> >> > able to start doing load/store elimination on SSBOs, SLM, and
> >> > whatever
> >> > CL
> >> > has which would be great for everyone's compute performance (GL,
> >> > Vulkan,
> >> > CL,
> >> > etc.).
> >> >
> >> > I would be lying if I said I had a full plan but I do have part of a
> >> > plan.
> >> > In my patch which adds the deref instructions, I add a new "cast"
> >> > deref
> >> > type
> >> > which takes an arbitrary value as it's source and kicks out a deref
> >> > with
> >> > a
> >> > type.  Whenever we discover that the source of the cast is actually
> >> > another
> >> > deref which is compatible (same type etc.), copy propagation gets rid
> >> > of
> >> > the
> >> > cast for you.  The idea is that, instead of doing a
> >> > load_raw(raw_ptr),
> >> > you
> >> > would do a load((type *)raw_ptr).
> >> >
> >> > Right now, most of the core NIR optimizations will throw a fit if
> >> > they
> >> > ever
> >> > see a cast.  This is intentional because it requires us to manually
> >> > go
> >> > through and handle casts.  This would mean that, at the moment, you
> >> > would
> >> > have to lower to load_raw intrinsics almost immediately after coming
> >> > out
> >> > of
> >> > SPIR-V.
> >> >
> >>
> >> Well it gets more fun with OpenCL 2.0 where you can have generic
> >> pointer where you only know the type at creation type. You can also
> >> declare generic pointers as function inputs in a way, that you never
> >> actually know from where you have to load if you only have that one
> >> function. So the actual load operation depends on when you create the
> >> initial pointer variable (you can cast from X to generic, but not the
> >> other way around).
> >>
> >> Which in the end means you can end up with load(generic_ptr) and only
> >> following the chain up to it's creation (with function inlining in
> >> mind) you know the actual memory target.
> >
> >
> > Yup.  And there will always be crazy cases where you can't actually
> > follow
> > it and you have to emit a pile of code to load different ways depending
> > on
> > some bits somewhere that tell you how to load it.  I'm well aware of the
> > insanity. :-)  This is part of the reason why I'm glad I'm not trying to
> > write an OpenCL 2.0 driver.
> >
> > This insanity is exactly why I'm suggesting the pointer casting.  Sure,
> > you
> > may not know the data type until the actual load.  In that case, you end
> > up
> > with the cast being right before the load.  If you don't know the
> > storage
> > class, maybe you have to switch and do multiple casts based on some
> > bits.
> > Alternatively, if you don't know the storage class, we can just let the
> > deref mode be 0 for "I don't know". or maybe multiple bits for "these
> > are
> > the things it might be".  In any case, I think we can handle it.
> >
>
> there shouldn't be a situation where we don't know, except when you
> don't inline all functions. I think Rob had the idea of fat pointers
> where a pointer is a vec2 and the 2nd component contains the actual
> pointer type and you end up with a switch over the type to get the
> correct storage class. And if the compiler inlines all functions, it
> should be able to optimize that switch away.


 Right.  Today, we live in a world where all functions are inlined.  Sadly, 
 I
 fear that world may come to and end one of these days. :(

>>>
>>> fwiw, so far I'm mostly caring about the inline-all-the-fxns case..
>>>
>>> for the cases where we don't know what sort of pointer we have, Karol
>>> (iirc?) suggested name-mangling functions, which seems semi-sane.. but
>>> I've mostly tried to ignore that for now until we have more basic
>>> things working.
>>>
>>> Possibly we need

Re: [Mesa-dev] [PATCH v3 06/19] RFC: nir/vtn: "raw" pointer support

2018-03-25 Thread Rob Clark
On Sun, Mar 25, 2018 at 6:35 AM, Karol Herbst  wrote:
> On Sun, Mar 25, 2018 at 12:18 AM, Rob Clark  wrote:
>> On Fri, Mar 23, 2018 at 5:18 PM, Jason Ekstrand  wrote:
>>> On Fri, Mar 23, 2018 at 2:15 PM, Karol Herbst  wrote:

 On Fri, Mar 23, 2018 at 10:07 PM, Jason Ekstrand 
 wrote:
 > +list
 >
 > On Fri, Mar 23, 2018 at 1:45 PM, Karol Herbst 
 > wrote:
 >>
 >> On Fri, Mar 23, 2018 at 9:30 PM, Jason Ekstrand 
 >> wrote:
 >> > As I've been rewriting core NIR deref handling, I've been thinking
 >> > about
 >> > this problem quite a bit.  One objective I have is to actually make
 >> > UBO
 >> > and
 >> > SSBO access go through derefs instead of just being an offset and
 >> > index
 >> > so
 >> > that the compiler can better reason about them.  In particular, I
 >> > want
 >> > to be
 >> > able to start doing load/store elimination on SSBOs, SLM, and
 >> > whatever
 >> > CL
 >> > has which would be great for everyone's compute performance (GL,
 >> > Vulkan,
 >> > CL,
 >> > etc.).
 >> >
 >> > I would be lying if I said I had a full plan but I do have part of a
 >> > plan.
 >> > In my patch which adds the deref instructions, I add a new "cast"
 >> > deref
 >> > type
 >> > which takes an arbitrary value as it's source and kicks out a deref
 >> > with
 >> > a
 >> > type.  Whenever we discover that the source of the cast is actually
 >> > another
 >> > deref which is compatible (same type etc.), copy propagation gets rid
 >> > of
 >> > the
 >> > cast for you.  The idea is that, instead of doing a
 >> > load_raw(raw_ptr),
 >> > you
 >> > would do a load((type *)raw_ptr).
 >> >
 >> > Right now, most of the core NIR optimizations will throw a fit if
 >> > they
 >> > ever
 >> > see a cast.  This is intentional because it requires us to manually
 >> > go
 >> > through and handle casts.  This would mean that, at the moment, you
 >> > would
 >> > have to lower to load_raw intrinsics almost immediately after coming
 >> > out
 >> > of
 >> > SPIR-V.
 >> >
 >>
 >> Well it gets more fun with OpenCL 2.0 where you can have generic
 >> pointer where you only know the type at creation type. You can also
 >> declare generic pointers as function inputs in a way, that you never
 >> actually know from where you have to load if you only have that one
 >> function. So the actual load operation depends on when you create the
 >> initial pointer variable (you can cast from X to generic, but not the
 >> other way around).
 >>
 >> Which in the end means you can end up with load(generic_ptr) and only
 >> following the chain up to it's creation (with function inlining in
 >> mind) you know the actual memory target.
 >
 >
 > Yup.  And there will always be crazy cases where you can't actually
 > follow
 > it and you have to emit a pile of code to load different ways depending
 > on
 > some bits somewhere that tell you how to load it.  I'm well aware of the
 > insanity. :-)  This is part of the reason why I'm glad I'm not trying to
 > write an OpenCL 2.0 driver.
 >
 > This insanity is exactly why I'm suggesting the pointer casting.  Sure,
 > you
 > may not know the data type until the actual load.  In that case, you end
 > up
 > with the cast being right before the load.  If you don't know the
 > storage
 > class, maybe you have to switch and do multiple casts based on some
 > bits.
 > Alternatively, if you don't know the storage class, we can just let the
 > deref mode be 0 for "I don't know". or maybe multiple bits for "these
 > are
 > the things it might be".  In any case, I think we can handle it.
 >

 there shouldn't be a situation where we don't know, except when you
 don't inline all functions. I think Rob had the idea of fat pointers
 where a pointer is a vec2 and the 2nd component contains the actual
 pointer type and you end up with a switch over the type to get the
 correct storage class. And if the compiler inlines all functions, it
 should be able to optimize that switch away.
>>>
>>>
>>> Right.  Today, we live in a world where all functions are inlined.  Sadly, I
>>> fear that world may come to and end one of these days. :(
>>>
>>
>> fwiw, so far I'm mostly caring about the inline-all-the-fxns case..
>>
>> for the cases where we don't know what sort of pointer we have, Karol
>> (iirc?) suggested name-mangling functions, which seems semi-sane.. but
>> I've mostly tried to ignore that for now until we have more basic
>> things working.
>>
>> Possibly we need a compiler option to lower everything to
>> load/store_global (or maybe "raw" is a better name?) for hw that can
>> remap local memory into a single address space and use the same
>

Re: [Mesa-dev] [PATCH v3 06/19] RFC: nir/vtn: "raw" pointer support

2018-03-25 Thread Karol Herbst
On Sun, Mar 25, 2018 at 12:18 AM, Rob Clark  wrote:
> On Fri, Mar 23, 2018 at 5:18 PM, Jason Ekstrand  wrote:
>> On Fri, Mar 23, 2018 at 2:15 PM, Karol Herbst  wrote:
>>>
>>> On Fri, Mar 23, 2018 at 10:07 PM, Jason Ekstrand 
>>> wrote:
>>> > +list
>>> >
>>> > On Fri, Mar 23, 2018 at 1:45 PM, Karol Herbst 
>>> > wrote:
>>> >>
>>> >> On Fri, Mar 23, 2018 at 9:30 PM, Jason Ekstrand 
>>> >> wrote:
>>> >> > As I've been rewriting core NIR deref handling, I've been thinking
>>> >> > about
>>> >> > this problem quite a bit.  One objective I have is to actually make
>>> >> > UBO
>>> >> > and
>>> >> > SSBO access go through derefs instead of just being an offset and
>>> >> > index
>>> >> > so
>>> >> > that the compiler can better reason about them.  In particular, I
>>> >> > want
>>> >> > to be
>>> >> > able to start doing load/store elimination on SSBOs, SLM, and
>>> >> > whatever
>>> >> > CL
>>> >> > has which would be great for everyone's compute performance (GL,
>>> >> > Vulkan,
>>> >> > CL,
>>> >> > etc.).
>>> >> >
>>> >> > I would be lying if I said I had a full plan but I do have part of a
>>> >> > plan.
>>> >> > In my patch which adds the deref instructions, I add a new "cast"
>>> >> > deref
>>> >> > type
>>> >> > which takes an arbitrary value as it's source and kicks out a deref
>>> >> > with
>>> >> > a
>>> >> > type.  Whenever we discover that the source of the cast is actually
>>> >> > another
>>> >> > deref which is compatible (same type etc.), copy propagation gets rid
>>> >> > of
>>> >> > the
>>> >> > cast for you.  The idea is that, instead of doing a
>>> >> > load_raw(raw_ptr),
>>> >> > you
>>> >> > would do a load((type *)raw_ptr).
>>> >> >
>>> >> > Right now, most of the core NIR optimizations will throw a fit if
>>> >> > they
>>> >> > ever
>>> >> > see a cast.  This is intentional because it requires us to manually
>>> >> > go
>>> >> > through and handle casts.  This would mean that, at the moment, you
>>> >> > would
>>> >> > have to lower to load_raw intrinsics almost immediately after coming
>>> >> > out
>>> >> > of
>>> >> > SPIR-V.
>>> >> >
>>> >>
>>> >> Well it gets more fun with OpenCL 2.0 where you can have generic
>>> >> pointer where you only know the type at creation type. You can also
>>> >> declare generic pointers as function inputs in a way, that you never
>>> >> actually know from where you have to load if you only have that one
>>> >> function. So the actual load operation depends on when you create the
>>> >> initial pointer variable (you can cast from X to generic, but not the
>>> >> other way around).
>>> >>
>>> >> Which in the end means you can end up with load(generic_ptr) and only
>>> >> following the chain up to it's creation (with function inlining in
>>> >> mind) you know the actual memory target.
>>> >
>>> >
>>> > Yup.  And there will always be crazy cases where you can't actually
>>> > follow
>>> > it and you have to emit a pile of code to load different ways depending
>>> > on
>>> > some bits somewhere that tell you how to load it.  I'm well aware of the
>>> > insanity. :-)  This is part of the reason why I'm glad I'm not trying to
>>> > write an OpenCL 2.0 driver.
>>> >
>>> > This insanity is exactly why I'm suggesting the pointer casting.  Sure,
>>> > you
>>> > may not know the data type until the actual load.  In that case, you end
>>> > up
>>> > with the cast being right before the load.  If you don't know the
>>> > storage
>>> > class, maybe you have to switch and do multiple casts based on some
>>> > bits.
>>> > Alternatively, if you don't know the storage class, we can just let the
>>> > deref mode be 0 for "I don't know". or maybe multiple bits for "these
>>> > are
>>> > the things it might be".  In any case, I think we can handle it.
>>> >
>>>
>>> there shouldn't be a situation where we don't know, except when you
>>> don't inline all functions. I think Rob had the idea of fat pointers
>>> where a pointer is a vec2 and the 2nd component contains the actual
>>> pointer type and you end up with a switch over the type to get the
>>> correct storage class. And if the compiler inlines all functions, it
>>> should be able to optimize that switch away.
>>
>>
>> Right.  Today, we live in a world where all functions are inlined.  Sadly, I
>> fear that world may come to and end one of these days. :(
>>
>
> fwiw, so far I'm mostly caring about the inline-all-the-fxns case..
>
> for the cases where we don't know what sort of pointer we have, Karol
> (iirc?) suggested name-mangling functions, which seems semi-sane.. but
> I've mostly tried to ignore that for now until we have more basic
> things working.
>
> Possibly we need a compiler option to lower everything to
> load/store_global (or maybe "raw" is a better name?) for hw that can
> remap local memory into a single address space and use the same
> load/store instructions.  I think that should be at least enough to
> move forward with nv hw + fxn calls.  Less so for intel/adreno but
> from my PoV I'm willing to solve th

[Mesa-dev] [Bug 105670] [regression][hang] Trine1EE hangs GPU after loading screen on Mesa3D-17.3 and later

2018-03-25 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=105670

--- Comment #12 from i...@yahoo.com ---
(In reply to Gert Wollny from comment #11)
> The if statement can be be true because  
> which means at this point R3.w can be zero.

But that's the point in my initial question.
When R3.w=0.0, will "if(+0.0 != -0.0)" be true of false, because float points
do have 2 different zeroes - positive and negative one, and both zero floats do
have different binary representation aka +0.0 = 0x; -0.0 = 0x8000.

My question is more of the lines: are shader float point operations always IEEE
complaint, and is it guaranteed that (+0.0 == -0.0) is true for all their
implementations.
(For example, SSE float operations sometimes deviate from IEEE for speed
reasons.)

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


Re: [Mesa-dev] [PATCH mesa] meson/configure: detect endian.h instead of trying to guess when it's available

2018-03-25 Thread Jonathan Gray
On Wed, Mar 21, 2018 at 05:09:17PM +, Eric Engestrom wrote:
> Cc: Maxin B. John 
> Cc: Khem Raj 
> Suggested-by: Jon Turney 
> Signed-off-by: Eric Engestrom 
> ---
>  configure.ac| 1 +
>  meson.build | 2 +-
>  src/util/u_endian.h | 2 +-
>  3 files changed, 3 insertions(+), 2 deletions(-)

OpenBSD and I suspect other systems have an endian.h that does not have
the __ defines like glibc.

So this change will break things unless a block along the lines of

#if _BYTE_ORDER == _LITTLE_ENDIAN
# define PIPE_ARCH_LITTLE_ENDIAN
#elif _BYTE_ORDER == _BIG_ENDIAN
# define PIPE_ARCH_BIG_ENDIAN
#endif

or

#if BYTE_ORDER == LITTLE_ENDIAN
# define PIPE_ARCH_LITTLE_ENDIAN
#elif BYTE_ORDER == BIG_ENDIAN
# define PIPE_ARCH_BIG_ENDIAN
#endif

is added.

 defines the public non underscored names
 will only pull in the underscored defines.

> 
> diff --git a/configure.ac b/configure.ac
> index 29d3c3457a7cdaefc36a..36c56da787e4fab5a355 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -865,6 +865,7 @@ fi
>  AC_HEADER_MAJOR
>  AC_CHECK_HEADER([xlocale.h], [DEFINES="$DEFINES -DHAVE_XLOCALE_H"])
>  AC_CHECK_HEADER([sys/sysctl.h], [DEFINES="$DEFINES -DHAVE_SYS_SYSCTL_H"])
> +AC_CHECK_HEADER([endian.h], [DEFINES="$DEFINES -DHAVE_ENDIAN_H"])
>  AC_CHECK_FUNC([strtof], [DEFINES="$DEFINES -DHAVE_STRTOF"])
>  AC_CHECK_FUNC([mkostemp], [DEFINES="$DEFINES -DHAVE_MKOSTEMP"])
>  AC_CHECK_FUNC([timespec_get], [DEFINES="$DEFINES -DHAVE_TIMESPEC_GET"])
> diff --git a/meson.build b/meson.build
> index 88518ec0f0e9b81759a7..1132b4bd37075d8c9d21 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -904,7 +904,7 @@ elif cc.has_header_symbol('sys/mkdev.h', 'major')
>pre_args += '-DMAJOR_IN_MKDEV'
>  endif
>  
> -foreach h : ['xlocale.h', 'sys/sysctl.h', 'linux/futex.h']
> +foreach h : ['xlocale.h', 'sys/sysctl.h', 'linux/futex.h', 'endian.h']
>if cc.compiles('#include <@0@>'.format(h), name : '@0@ works'.format(h))
>  pre_args += '-DHAVE_@0@'.format(h.to_upper().underscorify())
>endif
> diff --git a/src/util/u_endian.h b/src/util/u_endian.h
> index 22d011ec0086ee77e11c..e11b381588dbc960e8c3 100644
> --- a/src/util/u_endian.h
> +++ b/src/util/u_endian.h
> @@ -27,7 +27,7 @@
>  #ifndef U_ENDIAN_H
>  #define U_ENDIAN_H
>  
> -#if defined(__GLIBC__) || defined(ANDROID) || defined(__CYGWIN__)
> +#ifdef HAVE_ENDIAN_H
>  #include 
>  
>  #if __BYTE_ORDER == __LITTLE_ENDIAN
> -- 
> Cheers,
>   Eric
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev