[Mesa-dev] [Bug 91254] (regresion) video using VA-API on Intel slow and freeze system with mesa 10.6 or 10.6.1

2015-08-23 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=91254

Chris Wilson ch...@chris-wilson.co.uk changed:

   What|Removed |Added

 CC||frds...@genodeftest.de

--- Comment #17 from Chris Wilson ch...@chris-wilson.co.uk ---
*** Bug 91382 has been marked as a duplicate of this bug. ***

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


[Mesa-dev] [Bug 91254] (regresion) video using VA-API on Intel slow and freeze system with mesa 10.6 or 10.6.1

2015-08-23 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=91254

Ting-Wei Lan lant...@gmail.com changed:

   What|Removed |Added

 CC||lant...@gmail.com

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


Re: [Mesa-dev] [PATCH 1/5] mesa: Add GL API support for ARB_copy_image

2015-08-23 Thread Marek Olšák
On Fri, Aug 8, 2014 at 8:55 PM, Jason Ekstrand ja...@jlekstrand.net wrote:
 This adds the API entrypoint, error checking logic, and a driver hook for
 the ARB_copy_image extension.

 v2: Fix a typo in ARB_copy_image.xml and add it to the makefile
 v3: Put ARB_copy_image.xml in the right place alphebetically in the
 makefile and properly prefix the commit message
 v4: Fixed some line wrapping and added a check for null
 v5: Check for incomplete renderbuffers

 Signed-off-by: Jason Ekstrand jason.ekstr...@intel.com
 Reviewed-by: Juha-Pekka Heikkila juhapekka.heikk...@gmail.com
 Reviewed-by: Neil Roberts n...@linux.intel.com

 v6: Update dispatch_sanity for the addition of CopyImageSubData
 ---
  src/mapi/glapi/gen/ARB_copy_image.xml   |  28 +++
  src/mapi/glapi/gen/Makefile.am  |   1 +
  src/mapi/glapi/gen/gl_API.xml   |   2 +-
  src/mapi/glapi/gen/gl_genexec.py|   1 +
  src/mesa/Makefile.sources   |   1 +
  src/mesa/main/copyimage.c   | 356 
 
  src/mesa/main/copyimage.h   |  49 +
  src/mesa/main/dd.h  |  16 ++
  src/mesa/main/extensions.c  |   1 +
  src/mesa/main/mtypes.h  |   1 +
  src/mesa/main/tests/dispatch_sanity.cpp |   2 +-
  src/mesa/main/textureview.c |  36 ++--
  src/mesa/main/textureview.h |   4 +
  13 files changed, 477 insertions(+), 21 deletions(-)
  create mode 100644 src/mapi/glapi/gen/ARB_copy_image.xml
  create mode 100644 src/mesa/main/copyimage.c
  create mode 100644 src/mesa/main/copyimage.h

 diff --git a/src/mapi/glapi/gen/ARB_copy_image.xml 
 b/src/mapi/glapi/gen/ARB_copy_image.xml
 new file mode 100644
 index 000..2fbd845
 --- /dev/null
 +++ b/src/mapi/glapi/gen/ARB_copy_image.xml
 @@ -0,0 +1,28 @@
 +?xml version=1.0?
 +!DOCTYPE OpenGLAPI SYSTEM gl_API.dtd
 +
 +OpenGLAPI
 +
 +category name=GL_ARB_copy_image number=123
 +
 +function name=CopyImageSubData offset=assign
 +param name=srcName type=GLuint/
 +param name=srcTarget type=GLenum/
 +param name=srcLevel type=GLint/
 +param name=srcX type=GLint/
 +param name=srcY type=GLint/
 +param name=srcZ type=GLint/
 +param name=dstName type=GLuint/
 +param name=dstTarget type=GLenum/
 +param name=dstLevel type=GLint/
 +param name=dstX type=GLint/
 +param name=dstY type=GLint/
 +param name=dstZ type=GLint/
 +param name=srcWidth type=GLsizei/
 +param name=srcHeight type=GLsizei/
 +param name=srcDepth type=GLsizei/
 +/function
 +
 +/category
 +
 +/OpenGLAPI
 diff --git a/src/mapi/glapi/gen/Makefile.am b/src/mapi/glapi/gen/Makefile.am
 index 212731f..645def4 100644
 --- a/src/mapi/glapi/gen/Makefile.am
 +++ b/src/mapi/glapi/gen/Makefile.am
 @@ -117,6 +117,7 @@ API_XML = \
 ARB_compressed_texture_pixel_storage.xml \
 ARB_compute_shader.xml \
 ARB_copy_buffer.xml \
 +   ARB_copy_image.xml \
 ARB_debug_output.xml \
 ARB_depth_buffer_float.xml \
 ARB_depth_clamp.xml \
 diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
 index e011509..619717d 100644
 --- a/src/mapi/glapi/gen/gl_API.xml
 +++ b/src/mapi/glapi/gen/gl_API.xml
 @@ -8302,7 +8302,7 @@

  xi:include href=ARB_compute_shader.xml 
 xmlns:xi=http://www.w3.org/2001/XInclude/

 -!-- ARB extension #123 --
 +xi:include href=ARB_copy_image.xml 
 xmlns:xi=http://www.w3.org/2001/XInclude/

  xi:include href=ARB_texture_view.xml 
 xmlns:xi=http://www.w3.org/2001/XInclude/

 diff --git a/src/mapi/glapi/gen/gl_genexec.py 
 b/src/mapi/glapi/gen/gl_genexec.py
 index 4609193..d479e66 100644
 --- a/src/mapi/glapi/gen/gl_genexec.py
 +++ b/src/mapi/glapi/gen/gl_genexec.py
 @@ -62,6 +62,7 @@ header = /**
  #include main/condrender.h
  #include main/context.h
  #include main/convolve.h
 +#include main/copyimage.h
  #include main/depth.h
  #include main/dlist.h
  #include main/drawpix.h
 diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
 index 45c53ca..d02c174 100644
 --- a/src/mesa/Makefile.sources
 +++ b/src/mesa/Makefile.sources
 @@ -31,6 +31,7 @@ MAIN_FILES = \
 $(SRCDIR)main/condrender.c \
 $(SRCDIR)main/context.c \
 $(SRCDIR)main/convolve.c \
 +   $(SRCDIR)main/copyimage.c \
 $(SRCDIR)main/cpuinfo.c \
 $(SRCDIR)main/debug.c \
 $(SRCDIR)main/depth.c \
 diff --git a/src/mesa/main/copyimage.c b/src/mesa/main/copyimage.c
 new file mode 100644
 index 000..e1110dd
 --- /dev/null
 +++ b/src/mesa/main/copyimage.c
 @@ -0,0 +1,356 @@
 +/*
 + * Mesa 3-D graphics library
 + *
 + * Copyright (C) 2014 Intel Corporation.  All Rights Reserved.
 + *
 + * Permission is hereby granted, free of charge, to any person obtaining a
 + * copy of this software and associated documentation files (the Software),
 + * to deal in the Software without restriction, including without 

[Mesa-dev] [Bug 91646] dlopen'ing libudev.so.1 from static library initializer corrupts TLS state

2015-08-23 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=91646

Matthias Schuster shaloksha...@riseup.net changed:

   What|Removed |Added

   Priority|medium  |high
   Severity|normal  |major

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


Re: [Mesa-dev] [PATCH] i965: Always re-emit the pipeline select during invariant state emission

2015-08-23 Thread Jordan Justen
On 2015-08-23 01:31:16, Chris Wilson wrote:
 On the older platforms where we don't have logical contexts preserving
 state across batches, we need to emit the invariant state setup on every
 batch.

How about?: 'we emit the invariant state setup on every batch using
the brw_invariant_state atom.'

Reviewed-by: Jordan Justen jordan.l.jus...@intel.com

 This includes the pipeline selection which is cached with the
 introduction of
 
 commit 0e0e23ef537c9add672ff322f34e129a07edc55e
 Author: Jordan Justen jordan.l.jus...@intel.com
 Date:   Wed Apr 22 11:43:50 2015 -0700
 
 i965/state: Emit pipeline select when changing pipelines
 
 However, we do not reset the cache between batches on context-less
 platforms. A simple solution is to just forcibly re-emit the pipeline
 select along with the invariant state and reset the cache at that point.
 
 Reported-by: Tomasz C. toma...@o2.pl
 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91254
 Signed-off-by: Chris Wilson ch...@chris-wilson.co.uk
 Cc: Jordan Justen jordan.l.jus...@intel.com
 Cc: Kenneth Graunke kenn...@whitecape.org
 ---
  src/mesa/drivers/dri/i965/brw_misc_state.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
 
 diff --git a/src/mesa/drivers/dri/i965/brw_misc_state.c 
 b/src/mesa/drivers/dri/i965/brw_misc_state.c
 index e9d9467..2751152 100644
 --- a/src/mesa/drivers/dri/i965/brw_misc_state.c
 +++ b/src/mesa/drivers/dri/i965/brw_misc_state.c
 @@ -878,7 +878,8 @@ brw_upload_invariant_state(struct brw_context *brw)
  {
 const bool is_965 = brw-gen == 4  !brw-is_g4x;
  
 -   brw_select_pipeline(brw, BRW_RENDER_PIPELINE);
 +   brw_emit_select_pipeline(brw, BRW_RENDER_PIPELINE);
 +   brw-last_pipeline = BRW_RENDER_PIPELINE;
  
 if (brw-gen  6) {
/* Disable depth offset clamping. */
 -- 
 2.5.0
 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] i965: Always re-emit the pipeline select during invariant state emission

2015-08-23 Thread Jordan Justen
Can you also cc mesa-stable in the commit message?

Cc: 10.6 11.0 mesa-sta...@lists.freedesktop.org

-Jordan

On 2015-08-23 12:20:23, Jordan Justen wrote:
 On 2015-08-23 01:31:16, Chris Wilson wrote:
  On the older platforms where we don't have logical contexts preserving
  state across batches, we need to emit the invariant state setup on every
  batch.
 
 How about?: 'we emit the invariant state setup on every batch using
 the brw_invariant_state atom.'
 
 Reviewed-by: Jordan Justen jordan.l.jus...@intel.com
 
  This includes the pipeline selection which is cached with the
  introduction of
  
  commit 0e0e23ef537c9add672ff322f34e129a07edc55e
  Author: Jordan Justen jordan.l.jus...@intel.com
  Date:   Wed Apr 22 11:43:50 2015 -0700
  
  i965/state: Emit pipeline select when changing pipelines
  
  However, we do not reset the cache between batches on context-less
  platforms. A simple solution is to just forcibly re-emit the pipeline
  select along with the invariant state and reset the cache at that point.
  
  Reported-by: Tomasz C. toma...@o2.pl
  Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91254
  Signed-off-by: Chris Wilson ch...@chris-wilson.co.uk
  Cc: Jordan Justen jordan.l.jus...@intel.com
  Cc: Kenneth Graunke kenn...@whitecape.org
  ---
   src/mesa/drivers/dri/i965/brw_misc_state.c | 3 ++-
   1 file changed, 2 insertions(+), 1 deletion(-)
  
  diff --git a/src/mesa/drivers/dri/i965/brw_misc_state.c 
  b/src/mesa/drivers/dri/i965/brw_misc_state.c
  index e9d9467..2751152 100644
  --- a/src/mesa/drivers/dri/i965/brw_misc_state.c
  +++ b/src/mesa/drivers/dri/i965/brw_misc_state.c
  @@ -878,7 +878,8 @@ brw_upload_invariant_state(struct brw_context *brw)
   {
  const bool is_965 = brw-gen == 4  !brw-is_g4x;
   
  -   brw_select_pipeline(brw, BRW_RENDER_PIPELINE);
  +   brw_emit_select_pipeline(brw, BRW_RENDER_PIPELINE);
  +   brw-last_pipeline = BRW_RENDER_PIPELINE;
   
  if (brw-gen  6) {
 /* Disable depth offset clamping. */
  -- 
  2.5.0
  
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] i965: Always re-emit the pipeline select during invariant state emission

2015-08-23 Thread Chris Wilson
On the older platforms where we don't have logical contexts preserving
state across batches, we need to emit the invariant state setup on every
batch. This includes the pipeline selection which is cached with the
introduction of

commit 0e0e23ef537c9add672ff322f34e129a07edc55e
Author: Jordan Justen jordan.l.jus...@intel.com
Date:   Wed Apr 22 11:43:50 2015 -0700

i965/state: Emit pipeline select when changing pipelines

However, we do not reset the cache between batches on context-less
platforms. A simple solution is to just forcibly re-emit the pipeline
select along with the invariant state and reset the cache at that point.

Reported-by: Tomasz C. toma...@o2.pl
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91254
Signed-off-by: Chris Wilson ch...@chris-wilson.co.uk
Cc: Jordan Justen jordan.l.jus...@intel.com
Cc: Kenneth Graunke kenn...@whitecape.org
---
 src/mesa/drivers/dri/i965/brw_misc_state.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_misc_state.c 
b/src/mesa/drivers/dri/i965/brw_misc_state.c
index e9d9467..2751152 100644
--- a/src/mesa/drivers/dri/i965/brw_misc_state.c
+++ b/src/mesa/drivers/dri/i965/brw_misc_state.c
@@ -878,7 +878,8 @@ brw_upload_invariant_state(struct brw_context *brw)
 {
const bool is_965 = brw-gen == 4  !brw-is_g4x;
 
-   brw_select_pipeline(brw, BRW_RENDER_PIPELINE);
+   brw_emit_select_pipeline(brw, BRW_RENDER_PIPELINE);
+   brw-last_pipeline = BRW_RENDER_PIPELINE;
 
if (brw-gen  6) {
   /* Disable depth offset clamping. */
-- 
2.5.0

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


[Mesa-dev] [Bug 91079] New account request

2015-08-23 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=91079

--- Comment #3 from Martin Peres martin.pe...@free.fr ---
Marta has been successfully contributing to mesa for a few months now, I vouch
for her.

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


[Mesa-dev] [Bug 91079] New account request

2015-08-23 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=91079

Martin Peres martin.pe...@free.fr changed:

   What|Removed |Added

  Component|Other   |New Accounts
   Assignee|mesa-dev@lists.freedesktop. |sitewranglers@lists.freedes
   |org |ktop.org
Product|Mesa|freedesktop.org
 QA Contact|mesa-dev@lists.freedesktop. |
   |org |

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


[Mesa-dev] [Bug 91254] (regresion) video using VA-API on Intel slow and freeze system with mesa 10.6 or 10.6.1

2015-08-23 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=91254

--- Comment #14 from Chris Wilson ch...@chris-wilson.co.uk ---
diff --git a/src/mesa/drivers/dri/i965/brw_misc_state.c
b/src/mesa/drivers/dri/i965/brw_misc_state.c
index e9d9467..2751152 100644
--- a/src/mesa/drivers/dri/i965/brw_misc_state.c
+++ b/src/mesa/drivers/dri/i965/brw_misc_state.c
@@ -878,7 +878,8 @@ brw_upload_invariant_state(struct brw_context *brw)
 {
const bool is_965 = brw-gen == 4  !brw-is_g4x;

-   brw_select_pipeline(brw, BRW_RENDER_PIPELINE);
+   brw_emit_select_pipeline(brw, BRW_RENDER_PIPELINE);
+   brw-last_pipeline = BRW_RENDER_PIPELINE;

if (brw-gen  6) {
   /* Disable depth offset clamping. */
diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c
b/src/mesa/drivers/dri/i965/brw_state_upload.c
index 9de42ce..7577cfc 100644
--- a/src/mesa/drivers/dri/i965/brw_state_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_state_upload.c
@@ -423,9 +423,6 @@ void brw_init_state( struct brw_context *brw )
 {
struct gl_context *ctx = brw-ctx;

-   /* Force the first brw_select_pipeline to emit pipeline select */
-   brw-last_pipeline = BRW_NUM_PIPELINES;
-
STATIC_ASSERT(ARRAY_SIZE(gen4_atoms) = ARRAY_SIZE(brw-render_atoms));
STATIC_ASSERT(ARRAY_SIZE(gen6_atoms) = ARRAY_SIZE(brw-render_atoms));
STATIC_ASSERT(ARRAY_SIZE(gen7_render_atoms) =

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


[Mesa-dev] [PATCH 15/15] gallium/radeon: read_registers should return bool meaning success or failure

2015-08-23 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

---
 src/gallium/drivers/radeon/radeon_winsys.h| 2 +-
 src/gallium/drivers/radeonsi/si_debug.c   | 4 ++--
 src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c | 6 +++---
 src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 6 --
 4 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/radeon/radeon_winsys.h 
b/src/gallium/drivers/radeon/radeon_winsys.h
index 7ab6e56..a4a2ae1 100644
--- a/src/gallium/drivers/radeon/radeon_winsys.h
+++ b/src/gallium/drivers/radeon/radeon_winsys.h
@@ -680,7 +680,7 @@ struct radeon_winsys {
 uint64_t (*query_value)(struct radeon_winsys *ws,
 enum radeon_value_id value);
 
-void (*read_registers)(struct radeon_winsys *ws, unsigned reg_offset,
+bool (*read_registers)(struct radeon_winsys *ws, unsigned reg_offset,
unsigned num_registers, uint32_t *out);
 };
 
diff --git a/src/gallium/drivers/radeonsi/si_debug.c 
b/src/gallium/drivers/radeonsi/si_debug.c
index 22d6f25..d3fd201 100644
--- a/src/gallium/drivers/radeonsi/si_debug.c
+++ b/src/gallium/drivers/radeonsi/si_debug.c
@@ -349,8 +349,8 @@ static void si_dump_mmapped_reg(struct si_context *sctx, 
FILE *f,
struct radeon_winsys *ws = sctx-b.ws;
uint32_t value;
 
-   ws-read_registers(ws, offset, 1, value);
-   si_dump_reg(f, offset, value, ~0);
+   if (ws-read_registers(ws, offset, 1, value))
+   si_dump_reg(f, offset, value, ~0);
 }
 
 static void si_dump_debug_registers(struct si_context *sctx, FILE *f)
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c 
b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
index 012c900..875dcd0 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
@@ -350,14 +350,14 @@ static uint64_t amdgpu_query_value(struct radeon_winsys 
*rws,
return 0;
 }
 
-static void amdgpu_read_registers(struct radeon_winsys *rws,
+static bool amdgpu_read_registers(struct radeon_winsys *rws,
   unsigned reg_offset,
   unsigned num_registers, uint32_t *out)
 {
struct amdgpu_winsys *ws = (struct amdgpu_winsys*)rws;
 
-   amdgpu_read_mm_registers(ws-dev, reg_offset / 4, num_registers,
-0x, 0, out);
+   return amdgpu_read_mm_registers(ws-dev, reg_offset / 4, num_registers,
+   0x, 0, out) == 0;
 }
 
 static unsigned hash_dev(void *key)
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
index b70bbaa..102792a 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c
@@ -587,7 +587,7 @@ static uint64_t radeon_query_value(struct radeon_winsys 
*rws,
 return 0;
 }
 
-static void radeon_read_registers(struct radeon_winsys *rws,
+static bool radeon_read_registers(struct radeon_winsys *rws,
   unsigned reg_offset,
   unsigned num_registers, uint32_t *out)
 {
@@ -597,9 +597,11 @@ static void radeon_read_registers(struct radeon_winsys 
*rws,
 for (i = 0; i  num_registers; i++) {
 uint32_t reg = reg_offset + i*4;
 
-radeon_get_drm_value(ws-fd, RADEON_INFO_READ_REG, read-reg, reg);
+if (!radeon_get_drm_value(ws-fd, RADEON_INFO_READ_REG, NULL, reg))
+return false;
 out[i] = reg;
 }
+return true;
 }
 
 static unsigned hash_fd(void *key)
-- 
2.1.4

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


[Mesa-dev] [PATCH 0/3] A few fixes of building errors with Android-x86

2015-08-23 Thread Mauro Rossi
Here follow three trivial patches for android.
Kind regards

Mauro


[PATCH 1/3] android: fix nv50_ir_print.cpp buiding error with operator PRIx64

The PRINT function will not complain anymore with the additional space.


[PATCH 2/3] android: rename LLVM_VERSION_PATCH to MESA_LLVM_VERSION_PATCH

Due to renaming of variable.


[PATCH 3/3] android: Always define __STDC_LIMIT_MACROS.

This is equivalent to what happened to scons build.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] r600: don't parse properties ourselves.

2015-08-23 Thread Marek Olšák
Reviewed-by: Marek Olšák marek.ol...@amd.com

Marek

On Sun, Aug 23, 2015 at 2:21 AM, Dave Airlie airl...@gmail.com wrote:
 shader scan has already happened so just the results,
 also nobody uses gs_input_prim so drop it.

 Signed-off-by: Dave Airlie airl...@redhat.com
 ---
  src/gallium/drivers/r600/r600_shader.c | 38 
 +-
  src/gallium/drivers/r600/r600_shader.h |  1 -
  2 files changed, 10 insertions(+), 29 deletions(-)

 diff --git a/src/gallium/drivers/r600/r600_shader.c 
 b/src/gallium/drivers/r600/r600_shader.c
 index 8d1f95a..74141bb 100644
 --- a/src/gallium/drivers/r600/r600_shader.c
 +++ b/src/gallium/drivers/r600/r600_shader.c
 @@ -1809,7 +1809,6 @@ static int r600_shader_from_tgsi(struct r600_context 
 *rctx,
 struct tgsi_token *tokens = pipeshader-selector-tokens;
 struct pipe_stream_output_info so = pipeshader-selector-so;
 struct tgsi_full_immediate *immediate;
 -   struct tgsi_full_property *property;
 struct r600_shader_ctx ctx;
 struct r600_bytecode_output output[32];
 unsigned output_done, noutput;
 @@ -1968,6 +1967,16 @@ static int r600_shader_from_tgsi(struct r600_context 
 *rctx,
 ctx.nliterals = 0;
 ctx.literals = NULL;
 shader-fs_write_all = FALSE;
 +   if (ctx.info.properties[TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS])
 +   shader-fs_write_all = TRUE;
 +
 +   shader-vs_position_window_space = FALSE;
 +   if (ctx.info.properties[TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION])
 +   shader-vs_position_window_space = TRUE;
 +
 +   shader-gs_output_prim = 
 ctx.info.properties[TGSI_PROPERTY_GS_OUTPUT_PRIM];
 +   shader-gs_max_out_vertices = 
 ctx.info.properties[TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES];
 +   shader-gs_num_invocations = 
 ctx.info.properties[TGSI_PROPERTY_GS_INVOCATIONS];

 if (shader-vs_as_gs_a)
 vs_add_primid_output(ctx, key.vs_prim_id_out);
 @@ -1994,34 +2003,7 @@ static int r600_shader_from_tgsi(struct r600_context 
 *rctx,
 goto out_err;
 break;
 case TGSI_TOKEN_TYPE_INSTRUCTION:
 -   break;
 case TGSI_TOKEN_TYPE_PROPERTY:
 -   property = ctx.parse.FullToken.FullProperty;
 -   switch (property-Property.PropertyName) {
 -   case TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS:
 -   if (property-u[0].Data == 1)
 -   shader-fs_write_all = TRUE;
 -   break;
 -   case TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION:
 -   if (property-u[0].Data == 1)
 -   shader-vs_position_window_space = 
 TRUE;
 -   break;
 -   case TGSI_PROPERTY_VS_PROHIBIT_UCPS:
 -   /* we don't need this one */
 -   break;
 -   case TGSI_PROPERTY_GS_INPUT_PRIM:
 -   shader-gs_input_prim = property-u[0].Data;
 -   break;
 -   case TGSI_PROPERTY_GS_OUTPUT_PRIM:
 -   shader-gs_output_prim = property-u[0].Data;
 -   break;
 -   case TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES:
 -   shader-gs_max_out_vertices = 
 property-u[0].Data;
 -   break;
 -   case TGSI_PROPERTY_GS_INVOCATIONS:
 -   shader-gs_num_invocations = 
 property-u[0].Data;
 -   break;
 -   }
 break;
 default:
 R600_ERR(unsupported token type %d\n, 
 ctx.parse.FullToken.Token.Type);
 diff --git a/src/gallium/drivers/r600/r600_shader.h 
 b/src/gallium/drivers/r600/r600_shader.h
 index 5d05c81..e0cfafd 100644
 --- a/src/gallium/drivers/r600/r600_shader.h
 +++ b/src/gallium/drivers/r600/r600_shader.h
 @@ -79,7 +79,6 @@ struct r600_shader {
 boolean uses_index_registers;

 /* geometry shader properties */
 -   unsignedgs_input_prim;
 unsignedgs_output_prim;
 unsignedgs_max_out_vertices;
 unsignedgs_num_invocations;
 --
 2.4.3

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


[Mesa-dev] [PATCH 10/15] radeonsi: add an IB parser

2015-08-23 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

---
 src/gallium/drivers/radeonsi/si_debug.c | 245 
 1 file changed, 245 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_debug.c 
b/src/gallium/drivers/radeonsi/si_debug.c
index fa2ec03..d692547 100644
--- a/src/gallium/drivers/radeonsi/si_debug.c
+++ b/src/gallium/drivers/radeonsi/si_debug.c
@@ -27,6 +27,7 @@
 #include si_pipe.h
 #include si_shader.h
 #include sid.h
+#include sid_tables.h
 
 
 static void si_dump_shader(struct si_shader_selector *sel, const char *name,
@@ -40,6 +41,243 @@ static void si_dump_shader(struct si_shader_selector *sel, 
const char *name,
fprintf(f, %s\n\n, sel-current-binary.disasm_string);
 }
 
+/* Parsed IBs are difficult to read without colors. Use less -R file to
+ * read them, or use aha -b -f file to convert them to html.
+ */
+#define COLOR_RESET\033[0m
+#define COLOR_RED  \033[31m
+#define COLOR_GREEN\033[1;32m
+#define COLOR_YELLOW   \033[1;33m
+#define COLOR_CYAN \033[1;36m
+
+#define INDENT_PKT 8
+
+static void print_spaces(FILE *f, unsigned num)
+{
+   fprintf(f, %*s, num, );
+}
+
+static void print_value(FILE *file, uint32_t value, int bits)
+{
+   /* Guess if it's int or float */
+   if (value = (1  15))
+   fprintf(file, %u\n, value);
+   else {
+   float f = uif(value);
+
+   if (fabs(f)  10  f*10 == floor(f*10))
+   fprintf(file, %.1ff\n, f);
+   else
+   /* Don't print more leading zeros than there are bits. 
*/
+   fprintf(file, 0x%0*x\n, bits / 4, value);
+   }
+}
+
+static void print_named_value(FILE *file, const char *name, uint32_t value,
+ int bits)
+{
+   print_spaces(file, INDENT_PKT);
+   fprintf(file, COLOR_YELLOW %s COLOR_RESET  - , name);
+   print_value(file, value, bits);
+}
+
+static void si_dump_reg(FILE *file, unsigned offset, uint32_t value,
+   uint32_t field_mask)
+{
+   int r, f;
+
+   for (r = 0; r  ARRAY_SIZE(reg_table); r++) {
+   const struct si_reg *reg = reg_table[r];
+
+   if (reg-offset == offset) {
+   bool first_field = true;
+
+   print_spaces(file, INDENT_PKT);
+   fprintf(file, COLOR_YELLOW %s COLOR_RESET  - ,
+   reg-name);
+
+   if (!reg-num_fields) {
+   print_value(file, value, 32);
+   return;
+   }
+
+   for (f = 0; f  reg-num_fields; f++) {
+   const struct si_field *field = reg-fields[f];
+   uint32_t val = (value  field-mask) 
+  (ffs(field-mask) - 1);
+
+   if (!(field-mask  field_mask))
+   continue;
+
+   /* Indent the field. */
+   if (!first_field)
+   print_spaces(file,
+INDENT_PKT + 
strlen(reg-name) + 4);
+
+   /* Print the field. */
+   fprintf(file, %s = , field-name);
+
+   if (val  field-num_values  
field-values[val])
+   fprintf(file, %s\n, 
field-values[val]);
+   else
+   print_value(file, val,
+   util_bitcount(field-mask));
+
+   first_field = false;
+   }
+   return;
+   }
+   }
+
+   fprintf(file, COLOR_YELLOW 0x%05x COLOR_RESET  = 0x%08x, offset, 
value);
+}
+
+static void si_parse_set_reg_packet(FILE *f, uint32_t *ib, unsigned count,
+   unsigned reg_offset)
+{
+   unsigned reg = (ib[1]  2) + reg_offset;
+   int i;
+
+   for (i = 0; i  count; i++)
+   si_dump_reg(f, reg + i*4, ib[2+i], ~0);
+}
+
+static uint32_t *si_parse_packet3(FILE *f, uint32_t *ib, int *num_dw)
+{
+   unsigned count = PKT_COUNT_G(ib[0]);
+   unsigned op = PKT3_IT_OPCODE_G(ib[0]);
+   const char *predicate = PKT3_PREDICATE(ib[0]) ? (predicate) : ;
+   int i;
+
+   /* Print the name first. */
+   for (i = 0; i  ARRAY_SIZE(packet3_table); i++)
+   if (packet3_table[i].op == op)
+   break;
+
+   if (i  ARRAY_SIZE(packet3_table))
+   if (op == PKT3_SET_CONTEXT_REG ||
+   op == PKT3_SET_CONFIG_REG ||
+   op == PKT3_SET_UCONFIG_REG ||
+   op == PKT3_SET_SH_REG)
+   fprintf(f, COLOR_CYAN %s%s 

[Mesa-dev] [PATCH 03/15] gallium/ddebug: new pipe for hang detection and driver state dumping (v2)

2015-08-23 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

v2: lots of improvements

This is like identity or trace, but simpler. It doesn't wrap most states.

Run with:
  GALLIUM_DDEBUG=1000 [executable]
where executable is the app and 1000 is in miliseconds, meaning that
the context will be considered hung if a fence fails to signal in 1000 ms.

If that happens, all shaders, context states, bound resources, draw
parameters, and driver debug information (if any) will be dumped into:
  /home/$username/dd_dumps/$processname_$pid_$index.

Note that the context is flushed after every draw/clear/copy/blit operation
and then waited for to find the exact call that hangs.

You can also do:
  GALLIUM_DDEBUG=always
to do the dumping after every draw/clear/copy/blit operation without
flushing and waiting.

Examples of driver states that can be dumped are:
- Hardware status registers saying which hw block is busy (hung).
- Disassembled shaders in a human-readable form.
- The last submitted command buffer in a human-readable form.
---
 configure.ac   |   1 +
 src/gallium/Makefile.am|   1 +
 .../auxiliary/target-helpers/inline_debug_helper.h |   8 +
 src/gallium/drivers/ddebug/Makefile.am |  11 +
 src/gallium/drivers/ddebug/Makefile.sources|   6 +
 src/gallium/drivers/ddebug/SConscript  |  12 +
 src/gallium/drivers/ddebug/dd.h| 141 
 src/gallium/drivers/ddebug/dd_context.c| 771 
 src/gallium/drivers/ddebug/dd_draw.c   | 807 +
 src/gallium/drivers/ddebug/dd_public.h |  36 +
 src/gallium/drivers/ddebug/dd_screen.c | 353 +
 src/gallium/targets/dri/Makefile.am|   2 +
 src/gallium/targets/pipe-loader/Makefile.am|   2 +
 13 files changed, 2151 insertions(+)
 create mode 100644 src/gallium/drivers/ddebug/Makefile.am
 create mode 100644 src/gallium/drivers/ddebug/Makefile.sources
 create mode 100644 src/gallium/drivers/ddebug/SConscript
 create mode 100644 src/gallium/drivers/ddebug/dd.h
 create mode 100644 src/gallium/drivers/ddebug/dd_context.c
 create mode 100644 src/gallium/drivers/ddebug/dd_draw.c
 create mode 100644 src/gallium/drivers/ddebug/dd_public.h
 create mode 100644 src/gallium/drivers/ddebug/dd_screen.c

diff --git a/configure.ac b/configure.ac
index e3b5f2e..90ba4fe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2317,6 +2317,7 @@ AC_CONFIG_FILES([Makefile
src/gallium/auxiliary/Makefile
src/gallium/auxiliary/pipe-loader/Makefile
src/gallium/drivers/freedreno/Makefile
+   src/gallium/drivers/ddebug/Makefile
src/gallium/drivers/i915/Makefile
src/gallium/drivers/ilo/Makefile
src/gallium/drivers/llvmpipe/Makefile
diff --git a/src/gallium/Makefile.am b/src/gallium/Makefile.am
index e2c1090..a7c3606 100644
--- a/src/gallium/Makefile.am
+++ b/src/gallium/Makefile.am
@@ -11,6 +11,7 @@ SUBDIRS += auxiliary
 ##
 
 SUBDIRS += \
+   drivers/ddebug \
drivers/noop \
drivers/trace \
drivers/rbug
diff --git a/src/gallium/auxiliary/target-helpers/inline_debug_helper.h 
b/src/gallium/auxiliary/target-helpers/inline_debug_helper.h
index d353ab8..2443bf2 100644
--- a/src/gallium/auxiliary/target-helpers/inline_debug_helper.h
+++ b/src/gallium/auxiliary/target-helpers/inline_debug_helper.h
@@ -11,6 +11,10 @@
  * one or more debug driver: rbug, trace.
  */
 
+#ifdef GALLIUM_DDEBUG
+#include ddebug/dd_public.h
+#endif
+
 #ifdef GALLIUM_TRACE
 #include trace/tr_public.h
 #endif
@@ -30,6 +34,10 @@
 static inline struct pipe_screen *
 debug_screen_wrap(struct pipe_screen *screen)
 {
+#if defined(GALLIUM_DDEBUG)
+   screen = ddebug_screen_create(screen);
+#endif
+
 #if defined(GALLIUM_RBUG)
screen = rbug_screen_create(screen);
 #endif
diff --git a/src/gallium/drivers/ddebug/Makefile.am 
b/src/gallium/drivers/ddebug/Makefile.am
new file mode 100644
index 000..e8a187d
--- /dev/null
+++ b/src/gallium/drivers/ddebug/Makefile.am
@@ -0,0 +1,11 @@
+include Makefile.sources
+include $(top_srcdir)/src/gallium/Automake.inc
+
+AM_CFLAGS = \
+   $(GALLIUM_DRIVER_CFLAGS)
+
+noinst_LTLIBRARIES = libddebug.la
+
+libddebug_la_SOURCES = $(C_SOURCES)
+
+EXTRA_DIST = SConscript
diff --git a/src/gallium/drivers/ddebug/Makefile.sources 
b/src/gallium/drivers/ddebug/Makefile.sources
new file mode 100644
index 000..60d012d
--- /dev/null
+++ b/src/gallium/drivers/ddebug/Makefile.sources
@@ -0,0 +1,6 @@
+C_SOURCES := \
+   dd.h \
+   dd_public.h \
+   dd_context.c \
+   dd_draw.c \
+   dd_screen.c
diff --git a/src/gallium/drivers/ddebug/SConscript 
b/src/gallium/drivers/ddebug/SConscript
new file mode 100644
index 000..75792a2
--- /dev/null
+++ b/src/gallium/drivers/ddebug/SConscript
@@ -0,0 +1,12 @@
+Import('*')
+
+env = env.Clone()
+
+ddebug = env.ConvenienceLibrary(
+  

[Mesa-dev] [PATCH 09/15] radeonsi: save the contents of indirect buffers for debug contexts

2015-08-23 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

This will be used by the IB parser.
---
 src/gallium/drivers/radeonsi/si_hw_context.c | 8 
 src/gallium/drivers/radeonsi/si_pipe.c   | 2 ++
 src/gallium/drivers/radeonsi/si_pipe.h   | 5 +
 3 files changed, 15 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_hw_context.c 
b/src/gallium/drivers/radeonsi/si_hw_context.c
index 307dc39..f848c64 100644
--- a/src/gallium/drivers/radeonsi/si_hw_context.c
+++ b/src/gallium/drivers/radeonsi/si_hw_context.c
@@ -130,6 +130,14 @@ void si_context_gfx_flush(void *context, unsigned flags,
/* force to keep tiling flags */
flags |= RADEON_FLUSH_KEEP_TILING_FLAGS;
 
+   /* Save the IB for debug contexts. */
+   if (ctx-is_debug) {
+   free(ctx-last_ib);
+   ctx-last_ib_dw_size = cs-cdw;
+   ctx-last_ib = malloc(cs-cdw * 4);
+   memcpy(ctx-last_ib, cs-buf, cs-cdw * 4);
+   }
+
/* Flush the CS. */
ws-cs_flush(cs, flags, ctx-last_gfx_fence,
 ctx-screen-b.cs_count++);
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c 
b/src/gallium/drivers/radeonsi/si_pipe.c
index f6d4a5a..e5900b7 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -81,6 +81,7 @@ static void si_destroy_context(struct pipe_context *context)
LLVMDisposeTargetMachine(sctx-tm);
 #endif
 
+   free(sctx-last_ib);
FREE(sctx);
 }
 
@@ -112,6 +113,7 @@ static struct pipe_context *si_create_context(struct 
pipe_screen *screen,
sctx-b.b.destroy = si_destroy_context;
sctx-b.set_atom_dirty = (void *)si_set_atom_dirty;
sctx-screen = sscreen; /* Easy accessing of screen/winsys. */
+   sctx-is_debug = (flags  PIPE_CONTEXT_DEBUG) != 0;
 
if (!r600_common_context_init(sctx-b, sscreen-b))
goto fail;
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h 
b/src/gallium/drivers/radeonsi/si_pipe.h
index 3ab9538..3672fec 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -243,6 +243,11 @@ struct si_context {
struct si_shader_selector *last_tcs;
int last_num_tcs_input_cp;
int last_tes_sh_base;
+
+   /* Debug state. */
+   boolis_debug;
+   uint32_t*last_ib;
+   unsignedlast_ib_dw_size;
 };
 
 /* cik_sdma.c */
-- 
2.1.4

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


[Mesa-dev] [PATCH 02/15] gallium: add flags parameter to pipe_screen::context_create

2015-08-23 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

This allows creating compute-only and debug contexts.
---
 src/gallium/auxiliary/util/u_tests.c  |  2 +-
 src/gallium/auxiliary/vl/vl_mpeg12_decoder.c  |  2 +-
 src/gallium/drivers/freedreno/a2xx/fd2_context.c  |  2 +-
 src/gallium/drivers/freedreno/a2xx/fd2_context.h  |  2 +-
 src/gallium/drivers/freedreno/a3xx/fd3_context.c  |  2 +-
 src/gallium/drivers/freedreno/a3xx/fd3_context.h  |  2 +-
 src/gallium/drivers/freedreno/a4xx/fd4_context.c  |  2 +-
 src/gallium/drivers/freedreno/a4xx/fd4_context.h  |  2 +-
 src/gallium/drivers/i915/i915_context.c   |  2 +-
 src/gallium/drivers/i915/i915_context.h   |  2 +-
 src/gallium/drivers/ilo/ilo_context.c |  2 +-
 src/gallium/drivers/llvmpipe/lp_context.c |  3 ++-
 src/gallium/drivers/llvmpipe/lp_context.h |  3 ++-
 src/gallium/drivers/noop/noop_pipe.c  |  3 ++-
 src/gallium/drivers/nouveau/nv30/nv30_context.c   |  2 +-
 src/gallium/drivers/nouveau/nv30/nv30_context.h   |  2 +-
 src/gallium/drivers/nouveau/nv50/nv50_context.c   |  2 +-
 src/gallium/drivers/nouveau/nv50/nv50_context.h   |  2 +-
 src/gallium/drivers/nouveau/nvc0/nvc0_context.c   |  2 +-
 src/gallium/drivers/nouveau/nvc0/nvc0_context.h   |  2 +-
 src/gallium/drivers/r300/r300_context.c   |  2 +-
 src/gallium/drivers/r300/r300_context.h   |  2 +-
 src/gallium/drivers/r600/r600_pipe.c  |  5 +++--
 src/gallium/drivers/radeonsi/si_pipe.c|  5 +++--
 src/gallium/drivers/rbug/rbug_screen.c|  6 +++---
 src/gallium/drivers/softpipe/sp_context.c |  4 ++--
 src/gallium/drivers/softpipe/sp_context.h |  2 +-
 src/gallium/drivers/svga/svga_context.c   |  4 ++--
 src/gallium/drivers/svga/svga_context.h   |  2 +-
 src/gallium/drivers/trace/tr_screen.c |  7 +--
 src/gallium/drivers/vc4/vc4_context.c |  2 +-
 src/gallium/drivers/vc4/vc4_context.h |  2 +-
 src/gallium/include/pipe/p_defines.h  | 15 +++
 src/gallium/include/pipe/p_screen.h   | 11 +--
 src/gallium/state_trackers/clover/core/queue.cpp  |  2 +-
 src/gallium/state_trackers/glx/xlib/xm_st.c   |  2 +-
 src/gallium/state_trackers/nine/device9.c |  2 +-
 src/gallium/state_trackers/omx/vid_dec.c  |  2 +-
 src/gallium/state_trackers/omx/vid_enc.c  |  4 ++--
 src/gallium/state_trackers/va/context.c   |  3 ++-
 src/gallium/state_trackers/vdpau/device.c |  2 +-
 src/gallium/state_trackers/xa/xa_context.c|  2 +-
 src/gallium/state_trackers/xvmc/context.c |  2 +-
 src/gallium/tests/graw/clear.c|  2 +-
 src/gallium/tests/graw/fs-test.c  |  2 +-
 src/gallium/tests/graw/graw_util.h|  2 +-
 src/gallium/tests/graw/gs-test.c  |  2 +-
 src/gallium/tests/graw/quad-sample.c  |  2 +-
 src/gallium/tests/graw/shader-leak.c  |  2 +-
 src/gallium/tests/graw/tri-gs.c   |  2 +-
 src/gallium/tests/graw/tri-instanced.c|  2 +-
 src/gallium/tests/graw/vs-test.c  |  2 +-
 src/gallium/tests/trivial/compute.c   |  2 +-
 src/gallium/tests/trivial/quad-tex.c  |  2 +-
 src/gallium/tests/trivial/tri.c   |  2 +-
 src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c |  2 +-
 src/mesa/state_tracker/st_manager.c   |  2 +-
 57 files changed, 96 insertions(+), 65 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_tests.c 
b/src/gallium/auxiliary/util/u_tests.c
index 6a489d6..a94e5cc 100644
--- a/src/gallium/auxiliary/util/u_tests.c
+++ b/src/gallium/auxiliary/util/u_tests.c
@@ -457,7 +457,7 @@ null_constant_buffer(struct pipe_context *ctx)
 void
 util_run_tests(struct pipe_screen *screen)
 {
-   struct pipe_context *ctx = screen-context_create(screen, NULL);
+   struct pipe_context *ctx = screen-context_create(screen, NULL, 0);
 
tgsi_vs_window_space_position(ctx);
null_sampler_view(ctx, TGSI_TEXTURE_2D);
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c 
b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
index b700983..9d0e4a1 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
@@ -1120,7 +1120,7 @@ vl_create_mpeg12_decoder(struct pipe_context *context,
 
dec-base = *templat;
dec-base.context = context;
-   dec-context = context-screen-context_create(context-screen, NULL);
+   dec-context = context-screen-context_create(context-screen, NULL, 0);
 
dec-base.destroy = vl_mpeg12_destroy;
dec-base.begin_frame = vl_mpeg12_begin_frame;
diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_context.c 
b/src/gallium/drivers/freedreno/a2xx/fd2_context.c
index 6089ebc..3bed735 100644
--- a/src/gallium/drivers/freedreno/a2xx/fd2_context.c
+++ b/src/gallium/drivers/freedreno/a2xx/fd2_context.c
@@ -86,7 +86,7 @@ 

[Mesa-dev] [PATCH 08/15] radeonsi: generate register and packet tables for an IB parser from sid.h

2015-08-23 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

This makes writing a good IB parser a lot easier.

It generates 2 tables:
- packet3 table
- register table with all registers, fields, and named values
---
 src/gallium/drivers/radeonsi/.gitignore   |   1 +
 src/gallium/drivers/radeonsi/Makefile.am  |   9 ++
 src/gallium/drivers/radeonsi/Makefile.sources |   1 +
 src/gallium/drivers/radeonsi/sid_tables.py| 179 ++
 4 files changed, 190 insertions(+)
 create mode 100644 src/gallium/drivers/radeonsi/.gitignore
 create mode 100755 src/gallium/drivers/radeonsi/sid_tables.py

diff --git a/src/gallium/drivers/radeonsi/.gitignore 
b/src/gallium/drivers/radeonsi/.gitignore
new file mode 100644
index 000..e0ee798
--- /dev/null
+++ b/src/gallium/drivers/radeonsi/.gitignore
@@ -0,0 +1 @@
+sid_tables.h
diff --git a/src/gallium/drivers/radeonsi/Makefile.am 
b/src/gallium/drivers/radeonsi/Makefile.am
index aa79c5e..ae5035a 100644
--- a/src/gallium/drivers/radeonsi/Makefile.am
+++ b/src/gallium/drivers/radeonsi/Makefile.am
@@ -31,3 +31,12 @@ AM_CFLAGS = \
 noinst_LTLIBRARIES = libradeonsi.la
 
 libradeonsi_la_SOURCES = $(C_SOURCES)
+
+sid_tables.h: $(srcdir)/sid_tables.py $(srcdir)/sid.h
+   $(AM_V_GEN) $(PYTHON2) $(srcdir)/sid_tables.py $(srcdir)/sid.h  $@
+
+EXTRA_DIST = \
+   sid_tables.py
+
+BUILT_SOURCES =\
+   sid_tables.h
diff --git a/src/gallium/drivers/radeonsi/Makefile.sources 
b/src/gallium/drivers/radeonsi/Makefile.sources
index ae8fe59..fd44807 100644
--- a/src/gallium/drivers/radeonsi/Makefile.sources
+++ b/src/gallium/drivers/radeonsi/Makefile.sources
@@ -7,6 +7,7 @@ C_SOURCES := \
si_debug.c \
si_descriptors.c \
sid.h \
+   sid_tables.h \
si_dma.c \
si_hw_context.c \
si_pipe.c \
diff --git a/src/gallium/drivers/radeonsi/sid_tables.py 
b/src/gallium/drivers/radeonsi/sid_tables.py
new file mode 100755
index 000..1fe5d3c
--- /dev/null
+++ b/src/gallium/drivers/radeonsi/sid_tables.py
@@ -0,0 +1,179 @@
+#!/usr/bin/env python
+
+CopyRight = '''
+/*
+ * Copyright 2015 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the Software),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS 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.
+ *
+ */
+'''
+
+import sys
+import re
+
+
+class Field:
+def __init__(self, reg, s_name):
+self.s_name = s_name
+self.name = strip_prefix(s_name)
+self.values = []
+self.varname_values = '%s__%s__values' % (reg.r_name.lower(), 
self.name.lower())
+
+class Reg:
+def __init__(self, r_name):
+self.r_name = r_name
+self.name = strip_prefix(r_name)
+self.fields = []
+self.varname_fields = '%s__fields' % self.r_name.lower()
+self.own_fields = True
+
+
+def strip_prefix(s):
+'''Strip prefix in the form ._.*_, e.g. R_001234_'''
+return s[s[2:].find('_')+3:]
+
+
+def parse(filename):
+stream = open(filename)
+regs = []
+packets = []
+
+for line in stream:
+if not line.startswith('#define '):
+continue
+
+line = line[8:].strip()
+
+if line.startswith('R_'):
+reg = Reg(line.split()[0])
+regs.append(reg)
+
+elif line.startswith('S_'):
+field = Field(reg, line[:line.find('(')])
+reg.fields.append(field)
+
+elif line.startswith('V_'):
+field.values.append(line.split()[0])
+
+elif line.startswith('PKT3_') and line.find('0x') != -1 and 
line.find('(') == -1:
+packets.append(line.split()[0])
+
+# Copy fields to indexed registers which have their fields only defined
+# at register index 0.
+# For example, copy fields from CB_COLOR0_INFO to CB_COLORn_INFO, n  0.
+match_number = re.compile('[0-9]+')
+reg_dict = dict()
+
+# Create a dict of registers with fields and '0' in their name
+for reg in regs:
+if len(reg.fields) and reg.name.find('0') != -1:
+

[Mesa-dev] [PATCH 11/15] radeonsi: parse and dump status registers on GPU hang

2015-08-23 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

GPU hang detection must be enabled by setting: GALLIUM_DDEBUG=[timeout in ms]

This may print too much information that we might not understand yet,
but some of the bits are very useful.
---
 src/gallium/drivers/radeonsi/si_debug.c | 52 +
 1 file changed, 52 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_debug.c 
b/src/gallium/drivers/radeonsi/si_debug.c
index d692547..72b7989 100644
--- a/src/gallium/drivers/radeonsi/si_debug.c
+++ b/src/gallium/drivers/radeonsi/si_debug.c
@@ -278,11 +278,63 @@ static void si_parse_ib(FILE *f, uint32_t *ib, int num_dw)
}
 }
 
+static void si_dump_mmapped_reg(struct si_context *sctx, FILE *f,
+   unsigned offset)
+{
+   struct radeon_winsys *ws = sctx-b.ws;
+   uint32_t value;
+
+   ws-read_registers(ws, offset, 1, value);
+   si_dump_reg(f, offset, value, ~0);
+}
+
+static void si_dump_debug_registers(struct si_context *sctx, FILE *f)
+{
+   if (sctx-screen-b.info.drm_major == 2 
+   sctx-screen-b.info.drm_minor  42)
+   return; /* no radeon support */
+
+   fprintf(f, Memory-mapped registers:\n);
+   si_dump_mmapped_reg(sctx, f, R_008010_GRBM_STATUS);
+
+   /* No other registers can be read on DRM  3.1.0. */
+   if (sctx-screen-b.info.drm_major  3 ||
+   sctx-screen-b.info.drm_minor  1) {
+   fprintf(f, \n);
+   return;
+   }
+
+   si_dump_mmapped_reg(sctx, f, R_008008_GRBM_STATUS2);
+   si_dump_mmapped_reg(sctx, f, R_008014_GRBM_STATUS_SE0);
+   si_dump_mmapped_reg(sctx, f, R_008018_GRBM_STATUS_SE1);
+   si_dump_mmapped_reg(sctx, f, R_008038_GRBM_STATUS_SE2);
+   si_dump_mmapped_reg(sctx, f, R_00803C_GRBM_STATUS_SE3);
+   si_dump_mmapped_reg(sctx, f, R_00D034_SDMA0_STATUS_REG);
+   si_dump_mmapped_reg(sctx, f, R_00D834_SDMA1_STATUS_REG);
+   si_dump_mmapped_reg(sctx, f, R_000E50_SRBM_STATUS);
+   si_dump_mmapped_reg(sctx, f, R_000E4C_SRBM_STATUS2);
+   si_dump_mmapped_reg(sctx, f, R_000E54_SRBM_STATUS3);
+   si_dump_mmapped_reg(sctx, f, R_008680_CP_STAT);
+   si_dump_mmapped_reg(sctx, f, R_008674_CP_STALLED_STAT1);
+   si_dump_mmapped_reg(sctx, f, R_008678_CP_STALLED_STAT2);
+   si_dump_mmapped_reg(sctx, f, R_008670_CP_STALLED_STAT3);
+   si_dump_mmapped_reg(sctx, f, R_008210_CP_CPC_STATUS);
+   si_dump_mmapped_reg(sctx, f, R_008214_CP_CPC_BUSY_STAT);
+   si_dump_mmapped_reg(sctx, f, R_008218_CP_CPC_STALLED_STAT1);
+   si_dump_mmapped_reg(sctx, f, R_00821C_CP_CPF_STATUS);
+   si_dump_mmapped_reg(sctx, f, R_008220_CP_CPF_BUSY_STAT);
+   si_dump_mmapped_reg(sctx, f, R_008224_CP_CPF_STALLED_STAT1);
+   fprintf(f, \n);
+}
+
 static void si_dump_debug_state(struct pipe_context *ctx, FILE *f,
unsigned flags)
 {
struct si_context *sctx = (struct si_context*)ctx;
 
+   if (flags  PIPE_DEBUG_DEVICE_IS_HUNG)
+   si_dump_debug_registers(sctx, f);
+
si_dump_shader(sctx-vs_shader, Vertex, f);
si_dump_shader(sctx-tcs_shader, Tessellation control, f);
si_dump_shader(sctx-tes_shader, Tessellation evaluation, f);
-- 
2.1.4

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


[Mesa-dev] [PATCH 13/15] radeonsi: add IB tracing support for debug contexts

2015-08-23 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

This adds trace points to all IBs and the parser prints them and also
prints which trace points were reached (executed) by the CP.
This can help pinpoint a problematic packet, draw call, etc.
---
 src/gallium/drivers/radeonsi/si_debug.c  | 67 ++--
 src/gallium/drivers/radeonsi/si_hw_context.c | 24 +-
 src/gallium/drivers/radeonsi/si_pipe.c   |  2 +
 src/gallium/drivers/radeonsi/si_pipe.h   |  9 +++-
 src/gallium/drivers/radeonsi/si_state_draw.c | 19 
 5 files changed, 105 insertions(+), 16 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_debug.c 
b/src/gallium/drivers/radeonsi/si_debug.c
index 72b7989..cf09686 100644
--- a/src/gallium/drivers/radeonsi/si_debug.c
+++ b/src/gallium/drivers/radeonsi/si_debug.c
@@ -142,7 +142,8 @@ static void si_parse_set_reg_packet(FILE *f, uint32_t *ib, 
unsigned count,
si_dump_reg(f, reg + i*4, ib[2+i], ~0);
 }
 
-static uint32_t *si_parse_packet3(FILE *f, uint32_t *ib, int *num_dw)
+static uint32_t *si_parse_packet3(FILE *f, uint32_t *ib, int *num_dw,
+ int trace_id)
 {
unsigned count = PKT_COUNT_G(ib[0]);
unsigned op = PKT3_IT_OPCODE_G(ib[0]);
@@ -232,6 +233,36 @@ static uint32_t *si_parse_packet3(FILE *f, uint32_t *ib, 
int *num_dw)
if (ib[0] == 0x1000) {
count = -1; /* One dword NOP. */
break;
+   } else if (count == 0  SI_IS_TRACE_POINT(ib[1])) {
+   unsigned packet_id = SI_GET_TRACE_POINT_ID(ib[1]);
+
+   print_spaces(f, INDENT_PKT);
+   fprintf(f, COLOR_RED Trace point ID: %u\n, packet_id);
+
+   if (trace_id == -1)
+   break; /* tracing was disabled */
+
+   print_spaces(f, INDENT_PKT);
+   if (packet_id  trace_id)
+   fprintf(f, COLOR_RED
+   This trace point was reached by the 
CP.
+   COLOR_RESET \n);
+   else if (packet_id == trace_id)
+   fprintf(f, COLOR_RED
+   ! This is the last trace point 
that 
+   was reached by the CP !
+   COLOR_RESET \n);
+   else if (packet_id+1 == trace_id)
+   fprintf(f, COLOR_RED
+   ! This is the first trace point 
that 
+   was NOT been reached by the CP !
+   COLOR_RESET \n);
+   else
+   fprintf(f, COLOR_RED
+   ! This trace point was NOT reached 

+   by the CP !
+   COLOR_RESET \n);
+   break;
}
/* fall through, print all dwords */
default:
@@ -246,7 +277,17 @@ static uint32_t *si_parse_packet3(FILE *f, uint32_t *ib, 
int *num_dw)
return ib;
 }
 
-static void si_parse_ib(FILE *f, uint32_t *ib, int num_dw)
+/**
+ * Parse and print an IB into a file.
+ *
+ * \param ffile
+ * \param ib   IB
+ * \param num_dw   size of the IB
+ * \param chip_class   chip class
+ * \param trace_id the last trace ID that is known to have been reached
+ * and executed by the CP, typically read from a buffer
+ */
+static void si_parse_ib(FILE *f, uint32_t *ib, int num_dw, int trace_id)
 {
fprintf(f, -- IB begin --\n);
 
@@ -255,7 +296,7 @@ static void si_parse_ib(FILE *f, uint32_t *ib, int num_dw)
 
switch (type) {
case 3:
-   ib = si_parse_packet3(f, ib, num_dw);
+   ib = si_parse_packet3(f, ib, num_dw, trace_id);
break;
case 2:
/* type-2 nop */
@@ -342,9 +383,27 @@ static void si_dump_debug_state(struct pipe_context *ctx, 
FILE *f,
si_dump_shader(sctx-ps_shader, Fragment, f);
 
if (sctx-last_ib) {
-   si_parse_ib(f, sctx-last_ib, sctx-last_ib_dw_size);
+   int last_trace_id = -1;
+
+   if (sctx-last_trace_buf) {
+   /* We are expecting that the ddebug pipe has already
+* waited for the context, so this buffer should be 
idle.
+* If the GPU is hung, there is no point in waiting for 
it.
+*/
+   uint32_t *map =
+   
sctx-b.ws-buffer_map(sctx-last_trace_buf-cs_buf,
+

[Mesa-dev] [PATCH 12/15] radeonsi: remove old CS tracing code

2015-08-23 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

Some of it is left there and it will be re-used in the next commit.
---
 src/gallium/drivers/radeonsi/si_hw_context.c | 25 +
 src/gallium/drivers/radeonsi/si_pipe.h   |  5 -
 src/gallium/drivers/radeonsi/si_pm4.c| 12 
 src/gallium/drivers/radeonsi/si_state.h  |  1 +
 src/gallium/drivers/radeonsi/si_state_draw.c |  7 +--
 5 files changed, 3 insertions(+), 47 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_hw_context.c 
b/src/gallium/drivers/radeonsi/si_hw_context.c
index f848c64..b726eb3 100644
--- a/src/gallium/drivers/radeonsi/si_hw_context.c
+++ b/src/gallium/drivers/radeonsi/si_hw_context.c
@@ -88,11 +88,8 @@ void si_need_cs_space(struct si_context *ctx, unsigned 
num_dw,
/* Count in framebuffer cache flushes at the end of CS. */
num_dw += ctx-atoms.s.cache_flush-num_dw;
 
-#if SI_TRACE_CS
-   if (ctx-screen-b.trace_bo) {
+   if (ctx-screen-b.trace_bo)
num_dw += SI_TRACE_CS_DWORDS;
-   }
-#endif
 
/* Flush if there's not enough space. */
if (num_dw  cs-max_dw) {
@@ -146,26 +143,6 @@ void si_context_gfx_flush(void *context, unsigned flags,
if (fence)
ws-fence_reference(fence, ctx-last_gfx_fence);
 
-#if SI_TRACE_CS
-   if (ctx-screen-b.trace_bo) {
-   struct si_screen *sscreen = ctx-screen;
-   unsigned i;
-
-   for (i = 0; i  10; i++) {
-   usleep(5);
-   if (!ws-buffer_is_busy(sscreen-b.trace_bo-buf, 
RADEON_USAGE_READWRITE)) {
-   break;
-   }
-   }
-   if (i == 10) {
-   fprintf(stderr, timeout on cs lockup likely happen at 
cs %d dw %d\n,
-   sscreen-b.trace_ptr[1], 
sscreen-b.trace_ptr[0]);
-   } else {
-   fprintf(stderr, cs %d executed in %dms\n, 
sscreen-b.trace_ptr[1], i * 5);
-   }
-   }
-#endif
-
si_begin_new_cs(ctx);
 }
 
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h 
b/src/gallium/drivers/radeonsi/si_pipe.h
index 3672fec..09a21ce 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -43,7 +43,6 @@
 #define SI_RESTART_INDEX_UNKNOWN INT_MIN
 #define SI_NUM_SMOOTH_AA_SAMPLES 8
 
-#define SI_TRACE_CS 0
 #define SI_TRACE_CS_DWORDS 6
 
 #define SI_MAX_DRAW_CS_DWORDS \
@@ -298,10 +297,6 @@ void si_context_gfx_flush(void *context, unsigned flags,
 void si_begin_new_cs(struct si_context *ctx);
 void si_need_cs_space(struct si_context *ctx, unsigned num_dw, boolean 
count_draw_in);
 
-#if SI_TRACE_CS
-void si_trace_emit(struct si_context *sctx);
-#endif
-
 /* si_compute.c */
 void si_init_compute_functions(struct si_context *sctx);
 
diff --git a/src/gallium/drivers/radeonsi/si_pm4.c 
b/src/gallium/drivers/radeonsi/si_pm4.c
index e9b9a5f..036d90c 100644
--- a/src/gallium/drivers/radeonsi/si_pm4.c
+++ b/src/gallium/drivers/radeonsi/si_pm4.c
@@ -135,12 +135,6 @@ unsigned si_pm4_dirty_dw(struct si_context *sctx)
continue;
 
count += state-ndw;
-#if SI_TRACE_CS
-   /* for tracing each states */
-   if (sctx-screen-b.trace_bo) {
-   count += SI_TRACE_CS_DWORDS;
-   }
-#endif
}
 
return count;
@@ -161,12 +155,6 @@ void si_pm4_emit(struct si_context *sctx, struct 
si_pm4_state *state)
}
 
cs-cdw += state-ndw;
-
-#if SI_TRACE_CS
-   if (sctx-screen-b.trace_bo) {
-   si_trace_emit(sctx);
-   }
-#endif
 }
 
 void si_pm4_emit_dirty(struct si_context *sctx)
diff --git a/src/gallium/drivers/radeonsi/si_state.h 
b/src/gallium/drivers/radeonsi/si_state.h
index b8f63c5..118c562 100644
--- a/src/gallium/drivers/radeonsi/si_state.h
+++ b/src/gallium/drivers/radeonsi/si_state.h
@@ -281,6 +281,7 @@ extern const struct r600_atom si_atom_msaa_sample_locs;
 extern const struct r600_atom si_atom_msaa_config;
 void si_emit_cache_flush(struct r600_common_context *sctx, struct r600_atom 
*atom);
 void si_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *dinfo);
+void si_trace_emit(struct si_context *sctx);
 
 /* si_commands.c */
 void si_cmd_context_control(struct si_pm4_state *pm4);
diff --git a/src/gallium/drivers/radeonsi/si_state_draw.c 
b/src/gallium/drivers/radeonsi/si_state_draw.c
index 4c21655..e56c9e7 100644
--- a/src/gallium/drivers/radeonsi/si_state_draw.c
+++ b/src/gallium/drivers/radeonsi/si_state_draw.c
@@ -835,11 +835,8 @@ void si_draw_vbo(struct pipe_context *ctx, const struct 
pipe_draw_info *info)
si_emit_draw_registers(sctx, info);
si_emit_draw_packets(sctx, info, ib);
 
-#if SI_TRACE_CS
-   if (sctx-screen-b.trace_bo) {
+   if (sctx-screen-b.trace_bo)
si_trace_emit(sctx);
-   }
-#endif
 
/* 

[Mesa-dev] [PATCH 14/15] radeonsi: add IB parser support for CP DMA packets

2015-08-23 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

If the packet encoding is defined in the same format as register definitions,
the python script can process them automatically and the parser support
becomes trivial.
---
 src/gallium/drivers/radeonsi/si_cp_dma.c |  17 ++--
 src/gallium/drivers/radeonsi/si_debug.c  |  24 +
 src/gallium/drivers/radeonsi/si_state_draw.c |   6 +-
 src/gallium/drivers/radeonsi/sid.h   | 136 +--
 4 files changed, 122 insertions(+), 61 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_cp_dma.c 
b/src/gallium/drivers/radeonsi/si_cp_dma.c
index f8a9da4..7bdac97 100644
--- a/src/gallium/drivers/radeonsi/si_cp_dma.c
+++ b/src/gallium/drivers/radeonsi/si_cp_dma.c
@@ -47,10 +47,11 @@ static void si_emit_cp_dma_copy_buffer(struct si_context 
*sctx,
   unsigned size, unsigned flags)
 {
struct radeon_winsys_cs *cs = sctx-b.rings.gfx.cs;
-   uint32_t sync_flag = flags  R600_CP_DMA_SYNC ? PKT3_CP_DMA_CP_SYNC : 0;
-   uint32_t raw_wait = flags  SI_CP_DMA_RAW_WAIT ? 
PKT3_CP_DMA_CMD_RAW_WAIT : 0;
+   uint32_t sync_flag = flags  R600_CP_DMA_SYNC ? S_411_CP_SYNC(1) : 0;
+   uint32_t raw_wait = flags  SI_CP_DMA_RAW_WAIT ? S_414_RAW_WAIT(1) : 0;
uint32_t sel = flags  CIK_CP_DMA_USE_L2 ?
-  PKT3_CP_DMA_SRC_SEL(3) | PKT3_CP_DMA_DST_SEL(3) : 0;
+  S_411_SRC_SEL(V_411_SRC_ADDR_TC_L2) |
+  S_411_DSL_SEL(V_411_DST_ADDR_TC_L2) : 0;
 
assert(size);
assert((size  ((121)-1)) == size);
@@ -79,16 +80,16 @@ static void si_emit_cp_dma_clear_buffer(struct si_context 
*sctx,
uint32_t clear_value, unsigned flags)
 {
struct radeon_winsys_cs *cs = sctx-b.rings.gfx.cs;
-   uint32_t sync_flag = flags  R600_CP_DMA_SYNC ? PKT3_CP_DMA_CP_SYNC : 0;
-   uint32_t raw_wait = flags  SI_CP_DMA_RAW_WAIT ? 
PKT3_CP_DMA_CMD_RAW_WAIT : 0;
-   uint32_t dst_sel = flags  CIK_CP_DMA_USE_L2 ? PKT3_CP_DMA_DST_SEL(3) : 
0;
+   uint32_t sync_flag = flags  R600_CP_DMA_SYNC ? S_411_CP_SYNC(1) : 0;
+   uint32_t raw_wait = flags  SI_CP_DMA_RAW_WAIT ? S_414_RAW_WAIT(1) : 0;
+   uint32_t dst_sel = flags  CIK_CP_DMA_USE_L2 ? 
S_411_DSL_SEL(V_411_DST_ADDR_TC_L2) : 0;
 
assert(size);
assert((size  ((121)-1)) == size);
 
if (sctx-b.chip_class = CIK) {
radeon_emit(cs, PKT3(PKT3_DMA_DATA, 5, 0));
-   radeon_emit(cs, sync_flag | dst_sel | PKT3_CP_DMA_SRC_SEL(2)); 
/* CP_SYNC [31] | SRC_SEL[30:29] */
+   radeon_emit(cs, sync_flag | dst_sel | 
S_411_SRC_SEL(V_411_DATA)); /* CP_SYNC [31] | SRC_SEL[30:29] */
radeon_emit(cs, clear_value);   /* DATA [31:0] */
radeon_emit(cs, 0);
radeon_emit(cs, dst_va);/* DST_ADDR_LO [31:0] */
@@ -97,7 +98,7 @@ static void si_emit_cp_dma_clear_buffer(struct si_context 
*sctx,
} else {
radeon_emit(cs, PKT3(PKT3_CP_DMA, 4, 0));
radeon_emit(cs, clear_value);   /* DATA [31:0] */
-   radeon_emit(cs, sync_flag | PKT3_CP_DMA_SRC_SEL(2)); /* CP_SYNC 
[31] | SRC_SEL[30:29] */
+   radeon_emit(cs, sync_flag | S_411_SRC_SEL(V_411_DATA)); /* 
CP_SYNC [31] | SRC_SEL[30:29] */
radeon_emit(cs, dst_va);/* DST_ADDR_LO 
[31:0] */
radeon_emit(cs, (dst_va  32)  0x);   /* DST_ADDR_HI 
[15:0] */
radeon_emit(cs, size | raw_wait);   /* COMMAND 
[29:22] | BYTE_COUNT [20:0] */
diff --git a/src/gallium/drivers/radeonsi/si_debug.c 
b/src/gallium/drivers/radeonsi/si_debug.c
index cf09686..22d6f25 100644
--- a/src/gallium/drivers/radeonsi/si_debug.c
+++ b/src/gallium/drivers/radeonsi/si_debug.c
@@ -229,6 +229,30 @@ static uint32_t *si_parse_packet3(FILE *f, uint32_t *ib, 
int *num_dw,
case PKT3_NUM_INSTANCES:
si_dump_reg(f, R_030934_VGT_NUM_INSTANCES, ib[1], ~0);
break;
+   case PKT3_WRITE_DATA:
+   si_dump_reg(f, R_370_CONTROL, ib[1], ~0);
+   si_dump_reg(f, R_371_DST_ADDR_LO, ib[2], ~0);
+   si_dump_reg(f, R_372_DST_ADDR_HI, ib[3], ~0);
+   for (i = 2; i  count; i++) {
+   print_spaces(f, INDENT_PKT);
+   fprintf(f, 0x%08x\n, ib[2+i]);
+   }
+   break;
+   case PKT3_CP_DMA:
+   si_dump_reg(f, R_410_CP_DMA_WORD0, ib[1], ~0);
+   si_dump_reg(f, R_411_CP_DMA_WORD1, ib[2], ~0);
+   si_dump_reg(f, R_412_CP_DMA_WORD2, ib[3], ~0);
+   si_dump_reg(f, R_413_CP_DMA_WORD3, ib[4], ~0);
+   si_dump_reg(f, R_414_COMMAND, ib[5], ~0);
+   break;
+   case PKT3_DMA_DATA:
+   si_dump_reg(f, R_500_DMA_DATA_WORD0, ib[1], ~0);
+   si_dump_reg(f, 

[Mesa-dev] [PATCH 00/15] gallium/radeonsi hang debugging and IB parser

2015-08-23 Thread Marek Olšák
Hi,

Setting GALLIUM_DDEBUG=800 (timeout=800ms) enables the new ddebug module, which 
records all gallium states. The module tries to detect a hang and if it occurs, 
it prints all gallium states to a file, and calls 
pipe_context-dump_debug_state, which prints driver-specific state to the same 
file. The module exactly pinpoints the problematic draw call, because it waits 
for every draw call to finish within the given timeout.

The result on the radeonsi driver is a report that contains the following:
- the problematic draw call with all gallium states
- memory mapped status registers for hang debugging (GRBM_STATUS, etc.)
- disassembled shaders
- the indirect buffer (IB, AKA command buffer or CS) in a human-readable form

The driver also adds trace points to indirect buffers, and it prints where the 
CP stopped executing the IB. You can either read it with less -R or convert 
to html with aha.

This is the html report from one GPU hang. You can see the trace points in the 
IB there. The CP is probably stuck at PS_PARTIAL_FLUSH, waiting for the 3D 
engine to go idle:
http://people.freedesktop.org/~mareko/ddebug_heaven_hung.html

Most of the IB parser is automatically generated from sid.h using a python 
script invoked during a Mesa build, so it understands all packets and all 
registers which are defined there. It's regenerated when sid.h is changed.

One more html report just showing how many status registers are printed on VI:
http://people.freedesktop.org/~mareko/ddebug_dump.html

Please review.

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


[Mesa-dev] [PATCH 01/15] gallium: add an interface for dumping debug driver state

2015-08-23 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

---
 src/gallium/include/pipe/p_context.h | 12 
 src/gallium/include/pipe/p_defines.h |  5 +
 2 files changed, 17 insertions(+)

diff --git a/src/gallium/include/pipe/p_context.h 
b/src/gallium/include/pipe/p_context.h
index f89dae9..9d8f5bd 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -32,6 +32,7 @@
 #include p_format.h
 #include p_video_enums.h
 #include p_defines.h
+#include stdio.h
 
 #ifdef __cplusplus
 extern C {
@@ -617,6 +618,17 @@ struct pipe_context {
 * Return information about unexpected device resets.
 */
enum pipe_reset_status (*get_device_reset_status)(struct pipe_context *ctx);
+
+   /**
+* Dump driver-specific debug information into a stream. This is
+* used by debugging tools.
+*
+* \param ctxpipe context
+* \param stream where the output should be written to
+* \param flags  a mask of PIPE_DEBUG_* flags
+*/
+   void (*dump_debug_state)(struct pipe_context *ctx, FILE *stream,
+unsigned flags);
 };
 
 
diff --git a/src/gallium/include/pipe/p_defines.h 
b/src/gallium/include/pipe/p_defines.h
index 2ba56ea..4f2aa14 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -329,6 +329,11 @@ enum pipe_flush_flags
 };
 
 /**
+ * Flags for pipe_context::dump_debug_state.
+ */
+#define PIPE_DEBUG_DEVICE_IS_HUNG  (1  0)
+
+/**
  * Flags for pipe_context::memory_barrier.
  */
 #define PIPE_BARRIER_MAPPED_BUFFER (1  0)
-- 
2.1.4

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


[Mesa-dev] [PATCH 06/15] r600g, radeonsi: remove unused ill-formed register field definitions

2015-08-23 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

---
 src/gallium/drivers/r600/r600d.h   | 1 -
 src/gallium/drivers/radeonsi/sid.h | 1 -
 2 files changed, 2 deletions(-)

diff --git a/src/gallium/drivers/r600/r600d.h b/src/gallium/drivers/r600/r600d.h
index bce8b4e..3c08ba5 100644
--- a/src/gallium/drivers/r600/r600d.h
+++ b/src/gallium/drivers/r600/r600d.h
@@ -3428,7 +3428,6 @@
 #define   S_0085F0_SO3_DEST_BASE_ENA(x)(((x)  0x1)  5)
 #define   G_0085F0_SO3_DEST_BASE_ENA(x)(((x)  5)  0x1)
 #define   C_0085F0_SO3_DEST_BASE_ENA   0xFFDF
-#define   S_0085F0_CB0_DEST_BASE_ENA_SHIFT 6
 #define   S_0085F0_CB0_DEST_BASE_ENA(x)(((x)  0x1)  6)
 #define   G_0085F0_CB0_DEST_BASE_ENA(x)(((x)  6)  0x1)
 #define   C_0085F0_CB0_DEST_BASE_ENA   0xFFBF
diff --git a/src/gallium/drivers/radeonsi/sid.h 
b/src/gallium/drivers/radeonsi/sid.h
index 66fdf35..05d20db 100644
--- a/src/gallium/drivers/radeonsi/sid.h
+++ b/src/gallium/drivers/radeonsi/sid.h
@@ -614,7 +614,6 @@
 #define   S_0085F0_DEST_BASE_1_ENA(x) (((x)  
0x1)  1)
 #define   G_0085F0_DEST_BASE_1_ENA(x) (((x)  
1)  0x1)
 #define   C_0085F0_DEST_BASE_1_ENA
0xFFFD
-#define   S_0085F0_CB0_DEST_BASE_ENA_SHIFT   6
 #define   S_0085F0_CB0_DEST_BASE_ENA(x)   (((x)  
0x1)  6)
 #define   G_0085F0_CB0_DEST_BASE_ENA(x)   (((x)  
6)  0x1)
 #define   C_0085F0_CB0_DEST_BASE_ENA  
0xFFBF
-- 
2.1.4

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


[Mesa-dev] [PATCH 05/15] radeonsi: add an initial dump_debug_state implementation dumping shaders

2015-08-23 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

This is usually called after a draw call.
---
 src/gallium/drivers/radeonsi/Makefile.sources |  1 +
 src/gallium/drivers/radeonsi/si_debug.c   | 59 +++
 src/gallium/drivers/radeonsi/si_pipe.c|  1 +
 src/gallium/drivers/radeonsi/si_pipe.h|  3 ++
 4 files changed, 64 insertions(+)
 create mode 100644 src/gallium/drivers/radeonsi/si_debug.c

diff --git a/src/gallium/drivers/radeonsi/Makefile.sources 
b/src/gallium/drivers/radeonsi/Makefile.sources
index a0b1414..ae8fe59 100644
--- a/src/gallium/drivers/radeonsi/Makefile.sources
+++ b/src/gallium/drivers/radeonsi/Makefile.sources
@@ -4,6 +4,7 @@ C_SOURCES := \
si_commands.c \
si_compute.c \
si_cp_dma.c \
+   si_debug.c \
si_descriptors.c \
sid.h \
si_dma.c \
diff --git a/src/gallium/drivers/radeonsi/si_debug.c 
b/src/gallium/drivers/radeonsi/si_debug.c
new file mode 100644
index 000..fa2ec03
--- /dev/null
+++ b/src/gallium/drivers/radeonsi/si_debug.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2015 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the Software),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS 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.
+ *
+ * Authors:
+ *  Marek Olšák mar...@gmail.com
+ */
+
+#include si_pipe.h
+#include si_shader.h
+#include sid.h
+
+
+static void si_dump_shader(struct si_shader_selector *sel, const char *name,
+  FILE *f)
+{
+   if (!sel || !sel-current)
+   return;
+
+   fprintf(f, %s shader disassembly:\n, name);
+   si_dump_shader_key(sel-type, sel-current-key, f);
+   fprintf(f, %s\n\n, sel-current-binary.disasm_string);
+}
+
+static void si_dump_debug_state(struct pipe_context *ctx, FILE *f,
+   unsigned flags)
+{
+   struct si_context *sctx = (struct si_context*)ctx;
+
+   si_dump_shader(sctx-vs_shader, Vertex, f);
+   si_dump_shader(sctx-tcs_shader, Tessellation control, f);
+   si_dump_shader(sctx-tes_shader, Tessellation evaluation, f);
+   si_dump_shader(sctx-gs_shader, Geometry, f);
+   si_dump_shader(sctx-ps_shader, Fragment, f);
+   fprintf(f, Done.\n);
+}
+
+void si_init_debug_functions(struct si_context *sctx)
+{
+   sctx-b.b.dump_debug_state = si_dump_debug_state;
+}
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c 
b/src/gallium/drivers/radeonsi/si_pipe.c
index 029b3cc..f6d4a5a 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -122,6 +122,7 @@ static struct pipe_context *si_create_context(struct 
pipe_screen *screen,
si_init_blit_functions(sctx);
si_init_compute_functions(sctx);
si_init_cp_dma_functions(sctx);
+   si_init_debug_functions(sctx);
 
if (sscreen-b.info.has_uvd) {
sctx-b.b.create_video_codec = si_uvd_create_decoder;
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h 
b/src/gallium/drivers/radeonsi/si_pipe.h
index 553e1f3..3ab9538 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -275,6 +275,9 @@ void si_copy_buffer(struct si_context *sctx,
bool is_framebuffer);
 void si_init_cp_dma_functions(struct si_context *sctx);
 
+/* si_debug.c */
+void si_init_debug_functions(struct si_context *sctx);
+
 /* si_dma.c */
 void si_dma_copy(struct pipe_context *ctx,
 struct pipe_resource *dst,
-- 
2.1.4

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


[Mesa-dev] [PATCH 04/15] radeonsi: allow si_dump_key to write to a file

2015-08-23 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

---
 src/gallium/drivers/radeonsi/si_shader.c | 36 
 src/gallium/drivers/radeonsi/si_shader.h |  1 +
 2 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index fa6c15a..2532d3c 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -3964,48 +3964,48 @@ static int si_generate_gs_copy_shader(struct si_screen 
*sscreen,
return r;
 }
 
-static void si_dump_key(unsigned shader, union si_shader_key *key)
+void si_dump_shader_key(unsigned shader, union si_shader_key *key, FILE *f)
 {
int i;
 
-   fprintf(stderr, SHADER KEY\n);
+   fprintf(f, SHADER KEY\n);
 
switch (shader) {
case PIPE_SHADER_VERTEX:
-   fprintf(stderr,   instance_divisors = {);
+   fprintf(f,   instance_divisors = {);
for (i = 0; i  Elements(key-vs.instance_divisors); i++)
-   fprintf(stderr, !i ? %u : , %u,
+   fprintf(f, !i ? %u : , %u,
key-vs.instance_divisors[i]);
-   fprintf(stderr, }\n);
+   fprintf(f, }\n);
 
if (key-vs.as_es)
-   fprintf(stderr,   es_enabled_outputs = 0x%PRIx64\n,
+   fprintf(f,   es_enabled_outputs = 0x%PRIx64\n,
key-vs.es_enabled_outputs);
-   fprintf(stderr,   as_es = %u\n, key-vs.as_es);
-   fprintf(stderr,   as_ls = %u\n, key-vs.as_ls);
+   fprintf(f,   as_es = %u\n, key-vs.as_es);
+   fprintf(f,   as_ls = %u\n, key-vs.as_ls);
break;
 
case PIPE_SHADER_TESS_CTRL:
-   fprintf(stderr,   prim_mode = %u\n, key-tcs.prim_mode);
+   fprintf(f,   prim_mode = %u\n, key-tcs.prim_mode);
break;
 
case PIPE_SHADER_TESS_EVAL:
if (key-tes.as_es)
-   fprintf(stderr,   es_enabled_outputs = 0x%PRIx64\n,
+   fprintf(f,   es_enabled_outputs = 0x%PRIx64\n,
key-tes.es_enabled_outputs);
-   fprintf(stderr,   as_es = %u\n, key-tes.as_es);
+   fprintf(f,   as_es = %u\n, key-tes.as_es);
break;
 
case PIPE_SHADER_GEOMETRY:
break;
 
case PIPE_SHADER_FRAGMENT:
-   fprintf(stderr,   export_16bpc = 0x%X\n, 
key-ps.export_16bpc);
-   fprintf(stderr,   last_cbuf = %u\n, key-ps.last_cbuf);
-   fprintf(stderr,   color_two_side = %u\n, 
key-ps.color_two_side);
-   fprintf(stderr,   alpha_func = %u\n, key-ps.alpha_func);
-   fprintf(stderr,   alpha_to_one = %u\n, key-ps.alpha_to_one);
-   fprintf(stderr,   poly_stipple = %u\n, key-ps.poly_stipple);
+   fprintf(f,   export_16bpc = 0x%X\n, key-ps.export_16bpc);
+   fprintf(f,   last_cbuf = %u\n, key-ps.last_cbuf);
+   fprintf(f,   color_two_side = %u\n, key-ps.color_two_side);
+   fprintf(f,   alpha_func = %u\n, key-ps.alpha_func);
+   fprintf(f,   alpha_to_one = %u\n, key-ps.alpha_to_one);
+   fprintf(f,   poly_stipple = %u\n, key-ps.poly_stipple);
break;
 
default:
@@ -4036,7 +4036,7 @@ int si_shader_create(struct si_screen *sscreen, 
LLVMTargetMachineRef tm,
/* Dump TGSI code before doing TGSI-LLVM conversion in case the
 * conversion fails. */
if (dump  !(sscreen-b.debug_flags  DBG_NO_TGSI)) {
-   si_dump_key(sel-type, shader-key);
+   si_dump_shader_key(sel-type, shader-key, stderr);
tgsi_dump(tokens, 0);
si_dump_streamout(sel-so);
}
diff --git a/src/gallium/drivers/radeonsi/si_shader.h 
b/src/gallium/drivers/radeonsi/si_shader.h
index cd845c1..423b849 100644
--- a/src/gallium/drivers/radeonsi/si_shader.h
+++ b/src/gallium/drivers/radeonsi/si_shader.h
@@ -304,6 +304,7 @@ static inline bool si_vs_exports_prim_id(struct si_shader 
*shader)
 /* radeonsi_shader.c */
 int si_shader_create(struct si_screen *sscreen, LLVMTargetMachineRef tm,
 struct si_shader *shader);
+void si_dump_shader_key(unsigned shader, union si_shader_key *key, FILE *f);
 int si_compile_llvm(struct si_screen *sscreen, struct si_shader *shader,
LLVMTargetMachineRef tm, LLVMModuleRef mod);
 void si_shader_destroy(struct pipe_context *ctx, struct si_shader *shader);
-- 
2.1.4

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


[Mesa-dev] [PATCH 2/2] glsl/cs: Initialize gl_LocalInvocationIndex in main()

2015-08-23 Thread Jordan Justen
We initialize gl_LocalInvocationIndex based on the extension spec
formula:

gl_LocalInvocationIndex =
gl_LocalInvocationID.z * gl_WorkGroupSize.x * gl_WorkGroupSize.y +
gl_LocalInvocationID.y * gl_WorkGroupSize.x +
gl_LocalInvocationID.x;

https://www.opengl.org/registry/specs/ARB/compute_shader.txt

Signed-off-by: Jordan Justen jordan.l.jus...@intel.com
---
 src/glsl/builtin_variables.cpp | 28 
 1 file changed, 28 insertions(+)

diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp
index 8f8be90..082c73a 100644
--- a/src/glsl/builtin_variables.cpp
+++ b/src/glsl/builtin_variables.cpp
@@ -1059,6 +1059,7 @@ builtin_variable_generator::generate_cs_special_vars()
add_system_value(SYSTEM_VALUE_WORK_GROUP_ID, glsl_type::uvec3_type,
 gl_WorkGroupID);
add_variable(gl_GlobalInvocationID, glsl_type::uvec3_type, ir_var_auto, 
0);
+   add_variable(gl_LocalInvocationIndex, glsl_type::uint_type, ir_var_auto, 
0);
/* TODO: finish this. */
 }
 
@@ -1217,6 +1218,11 @@ _mesa_glsl_initialize_variables(exec_list *instructions,
 }
 
 
+using ir_builder::swizzle_x;
+using ir_builder::swizzle_y;
+using ir_builder::swizzle_z;
+
+
 /**
  * Initialize compute shader variables with values that are derived from other
  * compute shader variable.
@@ -1249,6 +1255,28 @@ initialize_cs_derived_variables(gl_shader *shader,
  gl_WorkGroupSize),
  gl_LocalInvocationID));
main_sig-body.push_head(inst);
+
+   /* gl_LocalInvocationIndex =
+*gl_LocalInvocationID.z * gl_WorkGroupSize.x * gl_WorkGroupSize.y +
+*gl_LocalInvocationID.y * gl_WorkGroupSize.x +
+*gl_LocalInvocationID.x;
+*/
+   ir_expression *index_z =
+  ir_builder::mul(ir_builder::mul(swizzle_z(gl_LocalInvocationID),
+  swizzle_x(gl_WorkGroupSize)),
+  swizzle_y(gl_WorkGroupSize));
+   ir_expression *index_y =
+  ir_builder::mul(swizzle_y(gl_LocalInvocationID),
+  swizzle_x(gl_WorkGroupSize));
+   ir_expression *index_y_plus_z = ir_builder::add(index_y, index_z);
+   ir_builder::operand index_x(swizzle_x(gl_LocalInvocationID));
+   ir_expression *index_x_plus_y_plus_z =
+  ir_builder::add(index_y_plus_z, index_x);
+   ir_variable *gl_LocalInvocationIndex =
+  shader-symbols-get_variable(gl_LocalInvocationIndex);
+   assert(gl_LocalInvocationIndex);
+   inst = ir_builder::assign(gl_LocalInvocationIndex, index_x_plus_y_plus_z);
+   main_sig-body.push_head(inst);
 }
 
 
-- 
2.1.4

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


[Mesa-dev] [PATCH 1/2] glsl/cs: Exclude gl_LocalInvocationIndex from builtin variable stripping

2015-08-23 Thread Jordan Justen
We lower gl_LocalInvocationIndex based on the extension spec formula:

gl_LocalInvocationIndex =
gl_LocalInvocationID.z * gl_WorkGroupSize.x * gl_WorkGroupSize.y +
gl_LocalInvocationID.y * gl_WorkGroupSize.x +
gl_LocalInvocationID.x;

https://www.opengl.org/registry/specs/ARB/compute_shader.txt

We need to set this variable in main(), even if gl_LocalInvocationIndex
is not referenced by the shader. (It may be used by a linked shader.)
Therefore, we can't eliminate it as a dead variable.

Signed-off-by: Jordan Justen jordan.l.jus...@intel.com
---
 git://people.freedesktop.org/~jljusten/mesa cs-local-index-v1
 http://patchwork.freedesktop.org/bundle/jljusten/cs-local-index-v1

 src/glsl/opt_dead_builtin_variables.cpp | 8 
 1 file changed, 8 insertions(+)

diff --git a/src/glsl/opt_dead_builtin_variables.cpp 
b/src/glsl/opt_dead_builtin_variables.cpp
index 90b753e..03e5789 100644
--- a/src/glsl/opt_dead_builtin_variables.cpp
+++ b/src/glsl/opt_dead_builtin_variables.cpp
@@ -72,6 +72,13 @@ optimize_dead_builtin_variables(exec_list *instructions,
*gl_GlobalInvocationID =
*   gl_WorkGroupID * gl_WorkGroupSize + gl_LocalInvocationID
*
+   * Similarly, we initialize gl_LocalInvocationIndex in the main function:
+   *
+   *gl_LocalInvocationIndex =
+   *   gl_LocalInvocationID.z * gl_WorkGroupSize.x * 
gl_WorkGroupSize.y +
+   *   gl_LocalInvocationID.y * gl_WorkGroupSize.x +
+   *   gl_LocalInvocationID.x;
+   *
* Matrix uniforms with Transpose are not eliminated because there's
* an optimization pass that can turn references to the regular matrix
* into references to the transpose matrix.  Eliminating the transpose
@@ -87,6 +94,7 @@ optimize_dead_builtin_variables(exec_list *instructions,
   || strcmp(var-name, gl_WorkGroupSize) == 0
   || strcmp(var-name, gl_LocalInvocationID) == 0
   || strcmp(var-name, gl_GlobalInvocationID) == 0
+  || strcmp(var-name, gl_LocalInvocationIndex) == 0
   || strstr(var-name, Transpose) != NULL)
  continue;
 
-- 
2.1.4

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


Re: [Mesa-dev] [PATCH 00/15] gallium/radeonsi hang debugging and IB parser

2015-08-23 Thread Marek Olšák
Patch 7 didn't make to the list, because it's too big:
http://cgit.freedesktop.org/~mareko/mesa/commit/?h=ddebugid=f282ecc33e8b7ca5a058dda4e48c1d0f795e90df

Marek

On Sun, Aug 23, 2015 at 2:04 PM, Marek Olšák mar...@gmail.com wrote:
 Hi,

 Setting GALLIUM_DDEBUG=800 (timeout=800ms) enables the new ddebug module, 
 which records all gallium states. The module tries to detect a hang and if it 
 occurs, it prints all gallium states to a file, and calls 
 pipe_context-dump_debug_state, which prints driver-specific state to the 
 same file. The module exactly pinpoints the problematic draw call, because it 
 waits for every draw call to finish within the given timeout.

 The result on the radeonsi driver is a report that contains the following:
 - the problematic draw call with all gallium states
 - memory mapped status registers for hang debugging (GRBM_STATUS, etc.)
 - disassembled shaders
 - the indirect buffer (IB, AKA command buffer or CS) in a human-readable form

 The driver also adds trace points to indirect buffers, and it prints where 
 the CP stopped executing the IB. You can either read it with less -R or 
 convert to html with aha.

 This is the html report from one GPU hang. You can see the trace points in 
 the IB there. The CP is probably stuck at PS_PARTIAL_FLUSH, waiting for the 
 3D engine to go idle:
 http://people.freedesktop.org/~mareko/ddebug_heaven_hung.html

 Most of the IB parser is automatically generated from sid.h using a python 
 script invoked during a Mesa build, so it understands all packets and all 
 registers which are defined there. It's regenerated when sid.h is changed.

 One more html report just showing how many status registers are printed on VI:
 http://people.freedesktop.org/~mareko/ddebug_dump.html

 Please review.

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


[Mesa-dev] [PATCH 2/3] android: rename LLVM_VERSION_PATCH to MESA_LLVM_VERSION_PATCH

2015-08-23 Thread Mauro Rossi
---
 Android.common.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Android.common.mk b/Android.common.mk
index d662d60..f7556d7 100644
--- a/Android.common.mk
+++ b/Android.common.mk
@@ -70,7 +70,7 @@ endif
 
 ifeq ($(MESA_ENABLE_LLVM),true)
 LOCAL_CFLAGS += \
-   -DHAVE_LLVM=0x0305 -DLLVM_VERSION_PATCH=2 \
+   -DHAVE_LLVM=0x0305 -DMESA_LLVM_VERSION_PATCH=2 \
-D__STDC_CONSTANT_MACROS \
-D__STDC_FORMAT_MACROS \
-D__STDC_LIMIT_MACROS
-- 
2.1.4

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


[Mesa-dev] [PATCH 1/3] android: fix nv50_ir_print.cpp buiding error with operator PRIx64

2015-08-23 Thread Mauro Rossi
---
 src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp 
b/src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp
index 9ebdc65..5f30f3d 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp
@@ -411,7 +411,7 @@ int ImmediateValue::print(char *buf, size_t size, DataType 
ty) const
case TYPE_U64:
case TYPE_S64:
default:
-  PRINT(0x%016PRIx64, reg.data.u64);
+  PRINT(0x%016 PRIx64, reg.data.u64);
   break;
}
return pos;
-- 
2.1.4

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


[Mesa-dev] [PATCH 3/3] android: Always define __STDC_LIMIT_MACROS.

2015-08-23 Thread Mauro Rossi
---
 Android.common.mk | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Android.common.mk b/Android.common.mk
index f7556d7..466e306 100644
--- a/Android.common.mk
+++ b/Android.common.mk
@@ -42,6 +42,7 @@ LOCAL_CFLAGS += \

-DANDROID_VERSION=0x0$(MESA_ANDROID_MAJOR_VERSION)0$(MESA_ANDROID_MINOR_VERSION)
 
 LOCAL_CFLAGS += \
+   -D__STDC_LIMIT_MACROS \
-DHAVE___BUILTIN_EXPECT \
-DHAVE___BUILTIN_FFS \
-DHAVE___BUILTIN_FFSLL \
@@ -72,8 +73,7 @@ ifeq ($(MESA_ENABLE_LLVM),true)
 LOCAL_CFLAGS += \
-DHAVE_LLVM=0x0305 -DMESA_LLVM_VERSION_PATCH=2 \
-D__STDC_CONSTANT_MACROS \
-   -D__STDC_FORMAT_MACROS \
-   -D__STDC_LIMIT_MACROS
+   -D__STDC_FORMAT_MACROS
 endif
 
 LOCAL_CPPFLAGS += \
-- 
2.1.4

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


[Mesa-dev] [PATCH] mesa-demos: xeglthreads needs to add -lX11 -lpthread itself

2015-08-23 Thread Stefan Dirsch
Hi

This is just a simple buildfix for current mesa-demos git master branch.

Thanks,
Stefan

Author: Stefan Dirsch sndir...@suse.de
Subject: xeglthreads needs to add -lX11 -lpthread itself
Signed-off-by: Stefan Dirsch sndir...@suse.de

xeglthreads no longer can rely on the toolchain to add the required libs,
it uses directly.

--- src/egl/opengl/Makefile.am.orig 2011-08-29 14:34:02.0 +
+++ src/egl/opengl/Makefile.am  2011-08-29 14:34:31.0 +
@@ -32,7 +32,7 @@ AM_CFLAGS = \
-I$(top_srcdir)/src/util
 AM_LDFLAGS = \
$(DEMO_LIBS) \
-   $(EGL_LIBS)
+   $(EGL_LIBS) -lX11 -lpthread
 
 if HAVE_X11
 EGL_X11_DEMOS = \

Public Key available
--
Stefan Dirsch (Res.  Dev.)   SUSE LINUX GmbH
Tel: 0911-740 53 0Maxfeldstraße 5
FAX: 0911-740 53 479  D-90409 Nürnberg
http://www.suse.deGermany 
---
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham
Norton, HRB 21284 (AG Nürnberg)
---
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH v2 1/3] glsl/cs: Don't strip gl_GlobalInvocationID and dependencies

2015-08-23 Thread Jordan Justen
We lower gl_GlobalInvocationID based on the extension spec formula:

gl_GlobalInvocationID =
gl_WorkGroupID * gl_WorkGroupSize + gl_LocalInvocationID

https://www.opengl.org/registry/specs/ARB/compute_shader.txt

We need to set this variable in main(), even if gl_GlobalInvocationID
is not referenced by the shader. (It may be used by a linked shader.)
Therefore, we can't eliminate these as dead variables.

Signed-off-by: Jordan Justen jordan.l.jus...@intel.com
---
 src/glsl/opt_dead_builtin_variables.cpp | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/src/glsl/opt_dead_builtin_variables.cpp 
b/src/glsl/opt_dead_builtin_variables.cpp
index 0d4e3a8..90b753e 100644
--- a/src/glsl/opt_dead_builtin_variables.cpp
+++ b/src/glsl/opt_dead_builtin_variables.cpp
@@ -62,6 +62,16 @@ optimize_dead_builtin_variables(exec_list *instructions,
* information, so removing these variables from the user shader will
* cause problems later.
*
+   * For compute shaders, gl_GlobalInvocationID has some dependencies, so
+   * we avoid removing these dependencies.
+   *
+   * We also avoid removing gl_GlobalInvocationID at this stage because it
+   * might be used by a linked shader. In this case it still needs to be
+   * initialized by the main function.
+   *
+   *gl_GlobalInvocationID =
+   *   gl_WorkGroupID * gl_WorkGroupSize + gl_LocalInvocationID
+   *
* Matrix uniforms with Transpose are not eliminated because there's
* an optimization pass that can turn references to the regular matrix
* into references to the transpose matrix.  Eliminating the transpose
@@ -73,6 +83,10 @@ optimize_dead_builtin_variables(exec_list *instructions,
*/
   if (strcmp(var-name, gl_ModelViewProjectionMatrix) == 0
   || strcmp(var-name, gl_Vertex) == 0
+  || strcmp(var-name, gl_WorkGroupID) == 0
+  || strcmp(var-name, gl_WorkGroupSize) == 0
+  || strcmp(var-name, gl_LocalInvocationID) == 0
+  || strcmp(var-name, gl_GlobalInvocationID) == 0
   || strstr(var-name, Transpose) != NULL)
  continue;
 
-- 
2.1.4

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


[Mesa-dev] [PATCH v2 0/3] cs: Add gl_GlobalInvocationID

2015-08-23 Thread Jordan Justen
git://people.freedesktop.org/~jljusten/mesa cs-global-id-v2
http://patchwork.freedesktop.org/bundle/jljusten/cs-global-id-v2

For i965, these also depend on the texture sampling series:
http://patchwork.freedesktop.org/bundle/jljusten/cs%20texture%20sampling/

And the gl_LocalInvocationID series:
http://patchwork.freedesktop.org/bundle/jljusten/i965-local-inv-id-v1/

These patches allow piglit's
tests/spec/arb_compute_shader/execution/basic-global-id-atomic.shader_test
to pass.

To test, I set MESA_GL_VERSION_OVERRIDE=4.3,
MESA_GLSL_VERSION_OVERRIDE=430 and
MESA_EXTENSION_OVERRIDE=GL_ARB_compute_shader.

Jordan Justen (3):
  glsl/cs: Don't strip gl_GlobalInvocationID and dependencies
  glsl: Move link_get_main_function_signature to a common location
  glsl/cs: Initialize gl_GlobalInvocationID in main()

 src/glsl/builtin_functions.cpp  | 28 
 src/glsl/builtin_variables.cpp  | 58 +
 src/glsl/glsl_parser_extras.cpp |  2 ++
 src/glsl/ir.h   |  6 
 src/glsl/linker.cpp | 31 ++
 src/glsl/linker.h   |  3 --
 src/glsl/lower_vertex_id.cpp|  2 +-
 src/glsl/opt_dead_builtin_variables.cpp | 14 
 8 files changed, 111 insertions(+), 33 deletions(-)

-- 
2.1.4

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


[Mesa-dev] [PATCH v2 3/3] glsl/cs: Initialize gl_GlobalInvocationID in main()

2015-08-23 Thread Jordan Justen
We initialize gl_GlobalInvocationID based on the extension spec
formula:

gl_GlobalInvocationID =
gl_WorkGroupID * gl_WorkGroupSize + gl_LocalInvocationID

https://www.opengl.org/registry/specs/ARB/compute_shader.txt

Signed-off-by: Jordan Justen jordan.l.jus...@intel.com
Cc: Ilia Mirkin imir...@alum.mit.edu
---
 src/glsl/builtin_variables.cpp  | 58 +
 src/glsl/glsl_parser_extras.cpp |  2 ++
 src/glsl/ir.h   |  3 +++
 3 files changed, 63 insertions(+)

diff --git a/src/glsl/builtin_variables.cpp b/src/glsl/builtin_variables.cpp
index 5d9e446..8f8be90 100644
--- a/src/glsl/builtin_variables.cpp
+++ b/src/glsl/builtin_variables.cpp
@@ -22,6 +22,8 @@
  */
 
 #include ir.h
+#include ir_builder.h
+#include linker.h
 #include glsl_parser_extras.h
 #include glsl_symbol_table.h
 #include main/core.h
@@ -1056,6 +1058,7 @@ builtin_variable_generator::generate_cs_special_vars()
 gl_LocalInvocationID);
add_system_value(SYSTEM_VALUE_WORK_GROUP_ID, glsl_type::uvec3_type,
 gl_WorkGroupID);
+   add_variable(gl_GlobalInvocationID, glsl_type::uvec3_type, ir_var_auto, 
0);
/* TODO: finish this. */
 }
 
@@ -1212,3 +1215,58 @@ _mesa_glsl_initialize_variables(exec_list *instructions,
   break;
}
 }
+
+
+/**
+ * Initialize compute shader variables with values that are derived from other
+ * compute shader variable.
+ */
+static void
+initialize_cs_derived_variables(gl_shader *shader,
+ir_function_signature *const main_sig)
+{
+   assert(shader-Stage == MESA_SHADER_COMPUTE);
+
+   ir_variable *gl_GlobalInvocationID =
+  shader-symbols-get_variable(gl_GlobalInvocationID);
+   assert(gl_GlobalInvocationID);
+   ir_variable *gl_WorkGroupID =
+  shader-symbols-get_variable(gl_WorkGroupID);
+   assert(gl_WorkGroupID);
+   ir_variable *gl_WorkGroupSize =
+  shader-symbols-get_variable(gl_WorkGroupSize);
+   assert(gl_WorkGroupSize);
+   ir_variable *gl_LocalInvocationID =
+  shader-symbols-get_variable(gl_LocalInvocationID);
+   assert(gl_LocalInvocationID);
+
+   /* gl_GlobalInvocationID =
+*gl_WorkGroupID * gl_WorkGroupSize + gl_LocalInvocationID
+*/
+   ir_instruction *inst =
+  ir_builder::assign(gl_GlobalInvocationID,
+ ir_builder::add(ir_builder::mul(gl_WorkGroupID,
+ gl_WorkGroupSize),
+ gl_LocalInvocationID));
+   main_sig-body.push_head(inst);
+}
+
+
+/**
+ * Initialize builtin variables with values based on other builtin variables.
+ * These are initialized in the main function.
+ */
+void
+_mesa_glsl_initialize_derived_variables(gl_shader *shader)
+{
+   /* We only need to set CS variables currently. */
+   if (shader-Stage != MESA_SHADER_COMPUTE)
+  return;
+
+   ir_function_signature *const main_sig =
+  _mesa_get_main_function_signature(shader);
+   if (main_sig == NULL)
+  return;
+
+   initialize_cs_derived_variables(shader, main_sig);
+}
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 6440a96..eefa12a 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -1692,6 +1692,8 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct 
gl_shader *shader,
   }
}
 
+   _mesa_glsl_initialize_derived_variables(shader);
+
delete state-symbols;
ralloc_free(state);
 }
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index 750321e..4c88144 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -2513,6 +2513,9 @@ _mesa_glsl_initialize_variables(exec_list *instructions,
struct _mesa_glsl_parse_state *state);
 
 extern void
+_mesa_glsl_initialize_derived_variables(gl_shader *shader);
+
+extern void
 _mesa_glsl_initialize_functions(_mesa_glsl_parse_state *state);
 
 extern void
-- 
2.1.4

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


[Mesa-dev] [PATCH v2 2/3] glsl: Move link_get_main_function_signature to a common location

2015-08-23 Thread Jordan Justen
Also rename to _mesa_get_main_function_signature.

We will call it near the end of compilation to insert some code into
main for initializing some compute shader global variables.

Signed-off-by: Jordan Justen jordan.l.jus...@intel.com
---
 src/glsl/builtin_functions.cpp | 28 
 src/glsl/ir.h  |  3 +++
 src/glsl/linker.cpp| 31 ++-
 src/glsl/linker.h  |  3 ---
 src/glsl/lower_vertex_id.cpp   |  2 +-
 5 files changed, 34 insertions(+), 33 deletions(-)

diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp
index 1bc3de4..bb8bc50 100644
--- a/src/glsl/builtin_functions.cpp
+++ b/src/glsl/builtin_functions.cpp
@@ -5061,4 +5061,32 @@ _mesa_glsl_get_builtin_function_shader()
return builtins.shader;
 }
 
+
+/**
+ * Get the function signature for main from a shader
+ */
+ir_function_signature *
+_mesa_get_main_function_signature(gl_shader *sh)
+{
+   ir_function *const f = sh-symbols-get_function(main);
+   if (f != NULL) {
+  exec_list void_parameters;
+
+  /* Look for the 'void main()' signature and ensure that it's defined.
+   * This keeps the linker from accidentally pick a shader that just
+   * contains a prototype for main.
+   *
+   * We don't have to check for multiple definitions of main (in multiple
+   * shaders) because that would have already been caught above.
+   */
+  ir_function_signature *sig =
+ f-matching_signature(NULL, void_parameters, false);
+  if ((sig != NULL)  sig-is_defined) {
+return sig;
+  }
+   }
+
+   return NULL;
+}
+
 /** @} */
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index ede8caa..750321e 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -2529,6 +2529,9 @@ 
_mesa_glsl_find_builtin_function_by_name(_mesa_glsl_parse_state *state,
 extern gl_shader *
 _mesa_glsl_get_builtin_function_shader(void);
 
+extern ir_function_signature *
+_mesa_get_main_function_signature(gl_shader *sh);
+
 extern void
 _mesa_glsl_release_functions(void);
 
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 47f7d25..cf0f646 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1341,33 +1341,6 @@ move_non_declarations(exec_list *instructions, exec_node 
*last,
return last;
 }
 
-/**
- * Get the function signature for main from a shader
- */
-ir_function_signature *
-link_get_main_function_signature(gl_shader *sh)
-{
-   ir_function *const f = sh-symbols-get_function(main);
-   if (f != NULL) {
-  exec_list void_parameters;
-
-  /* Look for the 'void main()' signature and ensure that it's defined.
-   * This keeps the linker from accidentally pick a shader that just
-   * contains a prototype for main.
-   *
-   * We don't have to check for multiple definitions of main (in multiple
-   * shaders) because that would have already been caught above.
-   */
-  ir_function_signature *sig =
- f-matching_signature(NULL, void_parameters, false);
-  if ((sig != NULL)  sig-is_defined) {
-return sig;
-  }
-   }
-
-   return NULL;
-}
-
 
 /**
  * This class is only used in link_intrastage_shaders() below but declaring
@@ -2040,7 +2013,7 @@ link_intrastage_shaders(void *mem_ctx,
 */
gl_shader *main = NULL;
for (unsigned i = 0; i  num_shaders; i++) {
-  if (link_get_main_function_signature(shader_list[i]) != NULL) {
+  if (_mesa_get_main_function_signature(shader_list[i]) != NULL) {
 main = shader_list[i];
 break;
   }
@@ -2072,7 +2045,7 @@ link_intrastage_shaders(void *mem_ctx,
 * copy of the original shader that contained the main function).
 */
ir_function_signature *const main_sig =
-  link_get_main_function_signature(linked);
+  _mesa_get_main_function_signature(linked);
 
/* Move any instructions other than variable declarations or function
 * declarations into main.
diff --git a/src/glsl/linker.h b/src/glsl/linker.h
index ce3dc32..0999878 100644
--- a/src/glsl/linker.h
+++ b/src/glsl/linker.h
@@ -26,9 +26,6 @@
 #ifndef GLSL_LINKER_H
 #define GLSL_LINKER_H
 
-ir_function_signature *
-link_get_main_function_signature(gl_shader *sh);
-
 extern bool
 link_function_calls(gl_shader_program *prog, gl_shader *main,
gl_shader **shader_list, unsigned num_shaders);
diff --git a/src/glsl/lower_vertex_id.cpp b/src/glsl/lower_vertex_id.cpp
index fc90bc8..3da7a2f 100644
--- a/src/glsl/lower_vertex_id.cpp
+++ b/src/glsl/lower_vertex_id.cpp
@@ -130,7 +130,7 @@ lower_vertex_id(gl_shader *shader)
   return false;
 
ir_function_signature *const main_sig =
-  link_get_main_function_signature(shader);
+  _mesa_get_main_function_signature(shader);
if (main_sig == NULL) {
   assert(main_sig != NULL);
   return false;
-- 
2.1.4

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

[Mesa-dev] [Bug 91254] (regresion) video using VA-API on Intel slow and freeze system with mesa 10.6 or 10.6.1

2015-08-23 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=91254

--- Comment #15 from Jordan Justen jljus...@gmail.com ---
(In reply to Chris Wilson from comment #14)
 diff --git a/src/mesa/drivers/dri/i965/brw_misc_state.c
 b/src/mesa/drivers/dri/i965/brw_misc_state.c
 index e9d9467..2751152 100644
 --- a/src/mesa/drivers/dri/i965/brw_misc_state.c
 +++ b/src/mesa/drivers/dri/i965/brw_misc_state.c
 @@ -878,7 +878,8 @@ brw_upload_invariant_state(struct brw_context *brw)
  {
 const bool is_965 = brw-gen == 4  !brw-is_g4x;
  
 -   brw_select_pipeline(brw, BRW_RENDER_PIPELINE);
 +   brw_emit_select_pipeline(brw, BRW_RENDER_PIPELINE);
 +   brw-last_pipeline = BRW_RENDER_PIPELINE;
  
 if (brw-gen  6) {
/* Disable depth offset clamping. */
 diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c
 b/src/mesa/drivers/dri/i965/brw_state_upload.c
 index 9de42ce..7577cfc 100644
 --- a/src/mesa/drivers/dri/i965/brw_state_upload.c
 +++ b/src/mesa/drivers/dri/i965/brw_state_upload.c
 @@ -423,9 +423,6 @@ void brw_init_state( struct brw_context *brw )
  {
 struct gl_context *ctx = brw-ctx;
  
 -   /* Force the first brw_select_pipeline to emit pipeline select */
 -   brw-last_pipeline = BRW_NUM_PIPELINES;
 -
 STATIC_ASSERT(ARRAY_SIZE(gen4_atoms) = ARRAY_SIZE(brw-render_atoms));
 STATIC_ASSERT(ARRAY_SIZE(gen6_atoms) = ARRAY_SIZE(brw-render_atoms));
 STATIC_ASSERT(ARRAY_SIZE(gen7_render_atoms) =

brw_init_state calls brw_upload_initial_gpu_state
which calls brw_upload_invariant_state, which calls
brw_select_pipeline(brw, BRW_RENDER_PIPELINE), so
this should be the same, right?

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


[Mesa-dev] [PATCH 2/3] gallium/radeon: fix the ADDRESS_HI mask for EVENT_WRITE CIK packets

2015-08-23 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

Cc: mesa-sta...@lists.freedesktop.org
---
 src/gallium/drivers/radeon/r600_query.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/gallium/drivers/radeon/r600_query.c 
b/src/gallium/drivers/radeon/r600_query.c
index 7057aa1..65339bb 100644
--- a/src/gallium/drivers/radeon/r600_query.c
+++ b/src/gallium/drivers/radeon/r600_query.c
@@ -197,7 +197,7 @@ static void r600_emit_query_begin(struct 
r600_common_context *ctx, struct r600_q
radeon_emit(cs, PKT3(PKT3_EVENT_WRITE, 2, 0));
radeon_emit(cs, EVENT_TYPE(EVENT_TYPE_ZPASS_DONE) | 
EVENT_INDEX(1));
radeon_emit(cs, va);
-   radeon_emit(cs, (va  32UL)  0xFF);
+   radeon_emit(cs, (va  32)  0x);
break;
case PIPE_QUERY_PRIMITIVES_EMITTED:
case PIPE_QUERY_PRIMITIVES_GENERATED:
@@ -206,13 +206,13 @@ static void r600_emit_query_begin(struct 
r600_common_context *ctx, struct r600_q
radeon_emit(cs, PKT3(PKT3_EVENT_WRITE, 2, 0));
radeon_emit(cs, EVENT_TYPE(event_type_for_stream(query)) | 
EVENT_INDEX(3));
radeon_emit(cs, va);
-   radeon_emit(cs, (va  32UL)  0xFF);
+   radeon_emit(cs, (va  32)  0x);
break;
case PIPE_QUERY_TIME_ELAPSED:
radeon_emit(cs, PKT3(PKT3_EVENT_WRITE_EOP, 4, 0));
radeon_emit(cs, 
EVENT_TYPE(EVENT_TYPE_CACHE_FLUSH_AND_INV_TS_EVENT) | EVENT_INDEX(5));
radeon_emit(cs, va);
-   radeon_emit(cs, (3  29) | ((va  32UL)  0xFF));
+   radeon_emit(cs, (3  29) | ((va  32)  0x));
radeon_emit(cs, 0);
radeon_emit(cs, 0);
break;
@@ -220,7 +220,7 @@ static void r600_emit_query_begin(struct 
r600_common_context *ctx, struct r600_q
radeon_emit(cs, PKT3(PKT3_EVENT_WRITE, 2, 0));
radeon_emit(cs, EVENT_TYPE(EVENT_TYPE_SAMPLE_PIPELINESTAT) | 
EVENT_INDEX(2));
radeon_emit(cs, va);
-   radeon_emit(cs, (va  32UL)  0xFF);
+   radeon_emit(cs, (va  32)  0x);
break;
default:
assert(0);
@@ -254,7 +254,7 @@ static void r600_emit_query_end(struct r600_common_context 
*ctx, struct r600_que
radeon_emit(cs, PKT3(PKT3_EVENT_WRITE, 2, 0));
radeon_emit(cs, EVENT_TYPE(EVENT_TYPE_ZPASS_DONE) | 
EVENT_INDEX(1));
radeon_emit(cs, va);
-   radeon_emit(cs, (va  32UL)  0xFF);
+   radeon_emit(cs, (va  32)  0x);
break;
case PIPE_QUERY_PRIMITIVES_EMITTED:
case PIPE_QUERY_PRIMITIVES_GENERATED:
@@ -264,7 +264,7 @@ static void r600_emit_query_end(struct r600_common_context 
*ctx, struct r600_que
radeon_emit(cs, PKT3(PKT3_EVENT_WRITE, 2, 0));
radeon_emit(cs, EVENT_TYPE(event_type_for_stream(query)) | 
EVENT_INDEX(3));
radeon_emit(cs, va);
-   radeon_emit(cs, (va  32UL)  0xFF);
+   radeon_emit(cs, (va  32)  0x);
break;
case PIPE_QUERY_TIME_ELAPSED:
va += query-buffer.results_end + query-result_size/2;
@@ -273,7 +273,7 @@ static void r600_emit_query_end(struct r600_common_context 
*ctx, struct r600_que
radeon_emit(cs, PKT3(PKT3_EVENT_WRITE_EOP, 4, 0));
radeon_emit(cs, 
EVENT_TYPE(EVENT_TYPE_CACHE_FLUSH_AND_INV_TS_EVENT) | EVENT_INDEX(5));
radeon_emit(cs, va);
-   radeon_emit(cs, (3  29) | ((va  32UL)  0xFF));
+   radeon_emit(cs, (3  29) | ((va  32)  0x));
radeon_emit(cs, 0);
radeon_emit(cs, 0);
break;
@@ -282,7 +282,7 @@ static void r600_emit_query_end(struct r600_common_context 
*ctx, struct r600_que
radeon_emit(cs, PKT3(PKT3_EVENT_WRITE, 2, 0));
radeon_emit(cs, EVENT_TYPE(EVENT_TYPE_SAMPLE_PIPELINESTAT) | 
EVENT_INDEX(2));
radeon_emit(cs, va);
-   radeon_emit(cs, (va  32UL)  0xFF);
+   radeon_emit(cs, (va  32)  0x);
break;
default:
assert(0);
-- 
2.1.4

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


[Mesa-dev] [PATCH 1/3] winsys/radeon: handle non-zero finite timeout when waiting for buffers

2015-08-23 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

---
 src/gallium/winsys/radeon/drm/radeon_drm_bo.c | 54 +++
 src/gallium/winsys/radeon/drm/radeon_drm_cs.c | 25 +
 2 files changed, 41 insertions(+), 38 deletions(-)

diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index 3a9ac44..600ced9 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -101,30 +101,54 @@ static struct radeon_bo *get_radeon_bo(struct pb_buffer 
*_buf)
 return bo;
 }
 
+static bool radeon_bo_is_busy(struct radeon_bo *bo)
+{
+struct drm_radeon_gem_busy args = {0};
+
+args.handle = bo-handle;
+return drmCommandWriteRead(bo-rws-fd, DRM_RADEON_GEM_BUSY,
+   args, sizeof(args)) != 0;
+}
+
+static void radeon_bo_wait_idle(struct radeon_bo *bo)
+{
+struct drm_radeon_gem_wait_idle args = {0};
+
+args.handle = bo-handle;
+while (drmCommandWrite(bo-rws-fd, DRM_RADEON_GEM_WAIT_IDLE,
+   args, sizeof(args)) == -EBUSY);
+}
+
 static bool radeon_bo_wait(struct pb_buffer *_buf, uint64_t timeout,
enum radeon_bo_usage usage)
 {
-   struct radeon_bo *bo = get_radeon_bo(_buf);
+struct radeon_bo *bo = get_radeon_bo(_buf);
+int64_t abs_timeout;
 
-   /* Wait if any ioctl is being submitted with this buffer. */
-   if (!os_wait_until_zero(bo-num_active_ioctls, timeout))
-  return false;
+/* No timeout. Just query. */
+if (timeout == 0)
+return !bo-num_active_ioctls  !radeon_bo_is_busy(bo);
 
-   /* TODO: handle arbitrary timeout */
-if (!timeout) {
-struct drm_radeon_gem_busy args = {0};
+abs_timeout = os_time_get_absolute_timeout(timeout);
 
-args.handle = bo-handle;
-return drmCommandWriteRead(bo-rws-fd, DRM_RADEON_GEM_BUSY,
-   args, sizeof(args)) == 0;
-} else {
-struct drm_radeon_gem_wait_idle args = {0};
+/* Wait if any ioctl is being submitted with this buffer. */
+if (!os_wait_until_zero_abs_timeout(bo-num_active_ioctls, abs_timeout))
+return false;
 
-args.handle = bo-handle;
-while (drmCommandWrite(bo-rws-fd, DRM_RADEON_GEM_WAIT_IDLE,
-   args, sizeof(args)) == -EBUSY);
+/* Infinite timeout. */
+if (abs_timeout == PIPE_TIMEOUT_INFINITE) {
+radeon_bo_wait_idle(bo);
 return true;
 }
+
+/* Other timeouts need to be emulated with a loop. */
+while (radeon_bo_is_busy(bo)) {
+   if (os_time_get_nano() = abs_timeout)
+  return false;
+   os_time_sleep(10);
+}
+
+return true;
 }
 
 static enum radeon_bo_domain get_valid_domain(enum radeon_bo_domain domain)
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c 
b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
index 7a267f9..c60d91d 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c
@@ -651,29 +651,8 @@ static bool radeon_fence_wait(struct radeon_winsys *ws,
   struct pipe_fence_handle *fence,
   uint64_t timeout)
 {
-struct pb_buffer *rfence = (struct pb_buffer*)fence;
-
-if (timeout == 0)
-return ws-buffer_wait(rfence, 0, RADEON_USAGE_READWRITE);
-
-if (timeout != PIPE_TIMEOUT_INFINITE) {
-int64_t start_time = os_time_get();
-
-/* Convert to microseconds. */
-timeout /= 1000;
-
-/* Wait in a loop. */
-while (!ws-buffer_wait(rfence, 0, RADEON_USAGE_READWRITE)) {
-if (os_time_get() - start_time = timeout) {
-return FALSE;
-}
-os_time_sleep(10);
-}
-return TRUE;
-}
-
-ws-buffer_wait(rfence, PIPE_TIMEOUT_INFINITE, RADEON_USAGE_READWRITE);
-return TRUE;
+return ws-buffer_wait((struct pb_buffer*)fence, timeout,
+   RADEON_USAGE_READWRITE);
 }
 
 static void radeon_fence_reference(struct pipe_fence_handle **dst,
-- 
2.1.4

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


[Mesa-dev] [PATCH 3/3] radeonsi: remove no-op 32-bit masking

2015-08-23 Thread Marek Olšák
From: Marek Olšák marek.ol...@amd.com

---
 src/gallium/drivers/radeon/r600_query.c   | 4 ++--
 src/gallium/drivers/radeonsi/si_compute.c | 2 +-
 src/gallium/drivers/radeonsi/si_descriptors.c | 2 +-
 src/gallium/drivers/radeonsi/si_dma.c | 4 ++--
 src/gallium/drivers/radeonsi/si_shader.c  | 2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/radeon/r600_query.c 
b/src/gallium/drivers/radeon/r600_query.c
index 65339bb..deeae0a 100644
--- a/src/gallium/drivers/radeon/r600_query.c
+++ b/src/gallium/drivers/radeon/r600_query.c
@@ -341,8 +341,8 @@ static void r600_emit_query_predication(struct 
r600_common_context *ctx, struct

while (results_base  qbuf-results_end) {
radeon_emit(cs, PKT3(PKT3_SET_PREDICATION, 1, 
0));
-   radeon_emit(cs, (va + results_base)  
0xUL);
-   radeon_emit(cs, op | (((va + results_base)  
32UL)  0xFF));
+   radeon_emit(cs, va + results_base);
+   radeon_emit(cs, op | (((va + results_base)  
32)  0xFF));
r600_emit_reloc(ctx, ctx-rings.gfx, 
qbuf-buf, RADEON_USAGE_READ,
RADEON_PRIO_MIN);
results_base += query-result_size;
diff --git a/src/gallium/drivers/radeonsi/si_compute.c 
b/src/gallium/drivers/radeonsi/si_compute.c
index d4fe565..0cdecd6 100644
--- a/src/gallium/drivers/radeonsi/si_compute.c
+++ b/src/gallium/drivers/radeonsi/si_compute.c
@@ -362,7 +362,7 @@ static void si_launch_grid(
shader_va += pc;
 #endif
si_pm4_add_bo(pm4, shader-bo, RADEON_USAGE_READ, 
RADEON_PRIO_SHADER_DATA);
-   si_pm4_set_reg(pm4, R_00B830_COMPUTE_PGM_LO, (shader_va  8)  
0x);
+   si_pm4_set_reg(pm4, R_00B830_COMPUTE_PGM_LO, shader_va  8);
si_pm4_set_reg(pm4, R_00B834_COMPUTE_PGM_HI, shader_va  40);
 
si_pm4_set_reg(pm4, R_00B848_COMPUTE_PGM_RSRC1,
diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index 890be07..b74c893 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -426,7 +426,7 @@ static bool si_upload_vertex_buffer_descriptors(struct 
si_context *sctx)
va = rbuffer-gpu_address + offset;
 
/* Fill in T# buffer resource description */
-   desc[0] = va  0x;
+   desc[0] = va;
desc[1] = S_008F04_BASE_ADDRESS_HI(va  32) |
  S_008F04_STRIDE(vb-stride);
 
diff --git a/src/gallium/drivers/radeonsi/si_dma.c 
b/src/gallium/drivers/radeonsi/si_dma.c
index 7a0076e..1a7eeae 100644
--- a/src/gallium/drivers/radeonsi/si_dma.c
+++ b/src/gallium/drivers/radeonsi/si_dma.c
@@ -86,8 +86,8 @@ static void si_dma_copy_buffer(struct si_context *ctx,
for (i = 0; i  ncopy; i++) {
csize = size  max_csize ? size : max_csize;
cs-buf[cs-cdw++] = SI_DMA_PACKET(SI_DMA_PACKET_COPY, sub_cmd, 
csize);
-   cs-buf[cs-cdw++] = dst_offset  0x;
-   cs-buf[cs-cdw++] = src_offset  0x;
+   cs-buf[cs-cdw++] = dst_offset;
+   cs-buf[cs-cdw++] = src_offset;
cs-buf[cs-cdw++] = (dst_offset  32UL)  0xff;
cs-buf[cs-cdw++] = (src_offset  32UL)  0xff;
dst_offset += csize  shift;
diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index 2532d3c..98cb3aa 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -3781,7 +3781,7 @@ void si_shader_apply_scratch_relocs(struct si_context 
*sctx,
uint64_t scratch_va)
 {
unsigned i;
-   uint32_t scratch_rsrc_dword0 = scratch_va  0x;
+   uint32_t scratch_rsrc_dword0 = scratch_va;
uint32_t scratch_rsrc_dword1 =
S_008F04_BASE_ADDRESS_HI(scratch_va  32)
|  S_008F04_STRIDE(shader-scratch_bytes_per_wave / 64);
-- 
2.1.4

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


[Mesa-dev] [Bug 91254] (regresion) video using VA-API on Intel slow and freeze system with mesa 10.6 or 10.6.1

2015-08-23 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=91254

--- Comment #16 from di...@gmx.net ---
I'm happy to see something happening here.
This might be helpful for reproducing this bug.

I don't use a compositing window manager. So for me 'mpv --vo=opengl
--hwdec=vaapi' doesn't hang.
But if I first start any gl-program e.g. glxgears and then start mpv
--vo=opengl --hwdec=vaapi my system freezes for a few seconds and glxgears
crashes with this error intel_do_flush_locked failed: Input/output error

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


[Mesa-dev] [PATCH] nvc0: make use of conservative depth info for forcing early z tests

2015-08-23 Thread Ilia Mirkin
Signed-off-by: Ilia Mirkin imir...@alum.mit.edu
---

Entirely untested as there are no piglit tests for this
functionality. Won't push until some appear, but wanted to get it out
there.

 .../drivers/nouveau/codegen/nv50_ir_driver.h   |  2 +-
 .../drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp  |  3 +++
 src/gallium/drivers/nouveau/nvc0/nvc0_program.c|  2 +-
 src/gallium/drivers/nouveau/nvc0/nvc0_program.h|  2 +-
 .../drivers/nouveau/nvc0/nvc0_shader_state.c   |  5 
 .../drivers/nouveau/nvc0/nvc0_state_validate.c | 30 --
 6 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h 
b/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h
index 2b9edcf..14acb60 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h
@@ -140,7 +140,7 @@ struct nv50_ir_prog_info
   struct {
  unsigned numColourResults;
  bool writesDepth;
- bool earlyFragTests;
+ bool depthLayout;
  bool separateFragData;
  bool usesDiscard;
   } fp;
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp 
b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
index f153674..dcfa4c4 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp
@@ -947,6 +947,9 @@ void Source::scanProperty(const struct tgsi_full_property 
*prop)
case TGSI_PROPERTY_FS_COORD_PIXEL_CENTER:
   // we don't care
   break;
+   case TGSI_PROPERTY_FS_DEPTH_LAYOUT:
+  info-prop.fp.depthLayout = prop-u[0].Data;
+  break;
case TGSI_PROPERTY_VS_PROHIBIT_UCPS:
   info-io.genUserClip = -1;
   break;
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_program.c 
b/src/gallium/drivers/nouveau/nvc0/nvc0_program.c
index 12f1bb7..44d951b 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_program.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_program.c
@@ -452,7 +452,7 @@ nvc0_fp_gen_header(struct nvc0_program *fp, struct 
nv50_ir_prog_info *info)
  fp-hdr[18] |= info-out[i].mask  info-out[i].slot[0];
}
 
-   fp-fp.early_z = info-prop.fp.earlyFragTests;
+   fp-fp.depth_layout = info-prop.fp.depthLayout;
 
return 0;
 }
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_program.h 
b/src/gallium/drivers/nouveau/nvc0/nvc0_program.h
index 390e0c7..fa14d68 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_program.h
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_program.h
@@ -44,7 +44,7 @@ struct nvc0_program {
   bool need_vertex_id;
} vp;
struct {
-  uint8_t early_z;
+  uint8_t depth_layout;
   uint8_t in_pos[PIPE_MAX_SHADER_INPUTS];
   uint8_t sample_interp;
} fp;
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c 
b/src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c
index 8f8ac2d..1c87714 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c
@@ -113,11 +113,6 @@ nvc0_fragprog_validate(struct nvc0_context *nvc0)
  return;
nvc0_program_update_context_state(nvc0, fp, 4);
 
-   if (fp-fp.early_z != nvc0-state.early_z_forced) {
-  nvc0-state.early_z_forced = fp-fp.early_z;
-  IMMED_NVC0(push, NVC0_3D(FORCE_EARLY_FRAGMENT_TESTS), fp-fp.early_z);
-   }
-
BEGIN_NVC0(push, NVC0_3D(SP_SELECT(5)), 2);
PUSH_DATA (push, 0x51);
PUSH_DATA (push, fp-code_base);
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c 
b/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c
index 47bd66d..609b3b8 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c
@@ -517,25 +517,51 @@ nvc0_validate_global_residents(struct nvc0_context *nvc0,
}
 }
 
+static bool
+nvc0_depth_layout_test_compatible(unsigned depth_layout, unsigned test)
+{
+   if (depth_layout  (test == PIPE_FUNC_ALWAYS || test == PIPE_FUNC_NEVER))
+  return true;
+   switch (depth_layout) {
+   case TGSI_FS_DEPTH_LAYOUT_UNCHANGED:
+  return true;
+   case TGSI_FS_DEPTH_LAYOUT_GREATER:
+  return test == PIPE_FUNC_GREATER || test == PIPE_FUNC_GEQUAL;
+   case TGSI_FS_DEPTH_LAYOUT_LESS:
+  return test == PIPE_FUNC_LESS || test == PIPE_FUNC_LEQUAL;
+   default:
+  return false;
+   }
+}
+
 static void
 nvc0_validate_derived_1(struct nvc0_context *nvc0)
 {
struct nouveau_pushbuf *push = nvc0-base.pushbuf;
+   struct nvc0_program *fp = nvc0-fragprog;
bool rasterizer_discard;
+   bool early_z = false;
 
if (nvc0-rast  nvc0-rast-pipe.rasterizer_discard) {
   rasterizer_discard = true;
} else {
   bool zs = nvc0-zsa 
  (nvc0-zsa-pipe.depth.enabled || nvc0-zsa-pipe.stencil[0].enabled);
-  rasterizer_discard = !zs 
- (!nvc0-fragprog || !nvc0-fragprog-hdr[18]);
+  rasterizer_discard = !zs  (!fp || 

Re: [Mesa-dev] [PATCH 1/5] mesa: Add GL API support for ARB_copy_image

2015-08-23 Thread Jason Ekstrand
On Sun, Aug 23, 2015 at 10:42 AM, Marek Olšák mar...@gmail.com wrote:
 On Fri, Aug 8, 2014 at 8:55 PM, Jason Ekstrand ja...@jlekstrand.net wrote:
 This adds the API entrypoint, error checking logic, and a driver hook for
 the ARB_copy_image extension.

 v2: Fix a typo in ARB_copy_image.xml and add it to the makefile
 v3: Put ARB_copy_image.xml in the right place alphebetically in the
 makefile and properly prefix the commit message
 v4: Fixed some line wrapping and added a check for null
 v5: Check for incomplete renderbuffers

 Signed-off-by: Jason Ekstrand jason.ekstr...@intel.com
 Reviewed-by: Juha-Pekka Heikkila juhapekka.heikk...@gmail.com
 Reviewed-by: Neil Roberts n...@linux.intel.com

 v6: Update dispatch_sanity for the addition of CopyImageSubData
 ---
  src/mapi/glapi/gen/ARB_copy_image.xml   |  28 +++
  src/mapi/glapi/gen/Makefile.am  |   1 +
  src/mapi/glapi/gen/gl_API.xml   |   2 +-
  src/mapi/glapi/gen/gl_genexec.py|   1 +
  src/mesa/Makefile.sources   |   1 +
  src/mesa/main/copyimage.c   | 356 
 
  src/mesa/main/copyimage.h   |  49 +
  src/mesa/main/dd.h  |  16 ++
  src/mesa/main/extensions.c  |   1 +
  src/mesa/main/mtypes.h  |   1 +
  src/mesa/main/tests/dispatch_sanity.cpp |   2 +-
  src/mesa/main/textureview.c |  36 ++--
  src/mesa/main/textureview.h |   4 +
  13 files changed, 477 insertions(+), 21 deletions(-)
  create mode 100644 src/mapi/glapi/gen/ARB_copy_image.xml
  create mode 100644 src/mesa/main/copyimage.c
  create mode 100644 src/mesa/main/copyimage.h

 diff --git a/src/mapi/glapi/gen/ARB_copy_image.xml 
 b/src/mapi/glapi/gen/ARB_copy_image.xml
 new file mode 100644
 index 000..2fbd845
 --- /dev/null
 +++ b/src/mapi/glapi/gen/ARB_copy_image.xml
 @@ -0,0 +1,28 @@
 +?xml version=1.0?
 +!DOCTYPE OpenGLAPI SYSTEM gl_API.dtd
 +
 +OpenGLAPI
 +
 +category name=GL_ARB_copy_image number=123
 +
 +function name=CopyImageSubData offset=assign
 +param name=srcName type=GLuint/
 +param name=srcTarget type=GLenum/
 +param name=srcLevel type=GLint/
 +param name=srcX type=GLint/
 +param name=srcY type=GLint/
 +param name=srcZ type=GLint/
 +param name=dstName type=GLuint/
 +param name=dstTarget type=GLenum/
 +param name=dstLevel type=GLint/
 +param name=dstX type=GLint/
 +param name=dstY type=GLint/
 +param name=dstZ type=GLint/
 +param name=srcWidth type=GLsizei/
 +param name=srcHeight type=GLsizei/
 +param name=srcDepth type=GLsizei/
 +/function
 +
 +/category
 +
 +/OpenGLAPI
 diff --git a/src/mapi/glapi/gen/Makefile.am b/src/mapi/glapi/gen/Makefile.am
 index 212731f..645def4 100644
 --- a/src/mapi/glapi/gen/Makefile.am
 +++ b/src/mapi/glapi/gen/Makefile.am
 @@ -117,6 +117,7 @@ API_XML = \
 ARB_compressed_texture_pixel_storage.xml \
 ARB_compute_shader.xml \
 ARB_copy_buffer.xml \
 +   ARB_copy_image.xml \
 ARB_debug_output.xml \
 ARB_depth_buffer_float.xml \
 ARB_depth_clamp.xml \
 diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
 index e011509..619717d 100644
 --- a/src/mapi/glapi/gen/gl_API.xml
 +++ b/src/mapi/glapi/gen/gl_API.xml
 @@ -8302,7 +8302,7 @@

  xi:include href=ARB_compute_shader.xml 
 xmlns:xi=http://www.w3.org/2001/XInclude/

 -!-- ARB extension #123 --
 +xi:include href=ARB_copy_image.xml 
 xmlns:xi=http://www.w3.org/2001/XInclude/

  xi:include href=ARB_texture_view.xml 
 xmlns:xi=http://www.w3.org/2001/XInclude/

 diff --git a/src/mapi/glapi/gen/gl_genexec.py 
 b/src/mapi/glapi/gen/gl_genexec.py
 index 4609193..d479e66 100644
 --- a/src/mapi/glapi/gen/gl_genexec.py
 +++ b/src/mapi/glapi/gen/gl_genexec.py
 @@ -62,6 +62,7 @@ header = /**
  #include main/condrender.h
  #include main/context.h
  #include main/convolve.h
 +#include main/copyimage.h
  #include main/depth.h
  #include main/dlist.h
  #include main/drawpix.h
 diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
 index 45c53ca..d02c174 100644
 --- a/src/mesa/Makefile.sources
 +++ b/src/mesa/Makefile.sources
 @@ -31,6 +31,7 @@ MAIN_FILES = \
 $(SRCDIR)main/condrender.c \
 $(SRCDIR)main/context.c \
 $(SRCDIR)main/convolve.c \
 +   $(SRCDIR)main/copyimage.c \
 $(SRCDIR)main/cpuinfo.c \
 $(SRCDIR)main/debug.c \
 $(SRCDIR)main/depth.c \
 diff --git a/src/mesa/main/copyimage.c b/src/mesa/main/copyimage.c
 new file mode 100644
 index 000..e1110dd
 --- /dev/null
 +++ b/src/mesa/main/copyimage.c
 @@ -0,0 +1,356 @@
 +/*
 + * Mesa 3-D graphics library
 + *
 + * Copyright (C) 2014 Intel Corporation.  All Rights Reserved.
 + *
 + * Permission is hereby granted, free of charge, to any person obtaining a
 + * copy of this software and associated documentation files (the 
 Software),
 + 

Re: [Mesa-dev] [PATCH 1/5] mesa: Add GL API support for ARB_copy_image

2015-08-23 Thread Jason Ekstrand
On Aug 23, 2015 3:48 PM, Marek Olšák mar...@gmail.com wrote:

 On Mon, Aug 24, 2015 at 12:32 AM, Jason Ekstrand ja...@jlekstrand.net
wrote:
  On Sun, Aug 23, 2015 at 10:42 AM, Marek Olšák mar...@gmail.com wrote:
  On Fri, Aug 8, 2014 at 8:55 PM, Jason Ekstrand ja...@jlekstrand.net
wrote:
  This adds the API entrypoint, error checking logic, and a driver hook
for
  the ARB_copy_image extension.
 
  v2: Fix a typo in ARB_copy_image.xml and add it to the makefile
  v3: Put ARB_copy_image.xml in the right place alphebetically in the
  makefile and properly prefix the commit message
  v4: Fixed some line wrapping and added a check for null
  v5: Check for incomplete renderbuffers
 
  Signed-off-by: Jason Ekstrand jason.ekstr...@intel.com
  Reviewed-by: Juha-Pekka Heikkila juhapekka.heikk...@gmail.com
  Reviewed-by: Neil Roberts n...@linux.intel.com
 
  v6: Update dispatch_sanity for the addition of CopyImageSubData
  ---
   src/mapi/glapi/gen/ARB_copy_image.xml   |  28 +++
   src/mapi/glapi/gen/Makefile.am  |   1 +
   src/mapi/glapi/gen/gl_API.xml   |   2 +-
   src/mapi/glapi/gen/gl_genexec.py|   1 +
   src/mesa/Makefile.sources   |   1 +
   src/mesa/main/copyimage.c   | 356

   src/mesa/main/copyimage.h   |  49 +
   src/mesa/main/dd.h  |  16 ++
   src/mesa/main/extensions.c  |   1 +
   src/mesa/main/mtypes.h  |   1 +
   src/mesa/main/tests/dispatch_sanity.cpp |   2 +-
   src/mesa/main/textureview.c |  36 ++--
   src/mesa/main/textureview.h |   4 +
   13 files changed, 477 insertions(+), 21 deletions(-)
   create mode 100644 src/mapi/glapi/gen/ARB_copy_image.xml
   create mode 100644 src/mesa/main/copyimage.c
   create mode 100644 src/mesa/main/copyimage.h
 
  diff --git a/src/mapi/glapi/gen/ARB_copy_image.xml
b/src/mapi/glapi/gen/ARB_copy_image.xml
  new file mode 100644
  index 000..2fbd845
  --- /dev/null
  +++ b/src/mapi/glapi/gen/ARB_copy_image.xml
  @@ -0,0 +1,28 @@
  +?xml version=1.0?
  +!DOCTYPE OpenGLAPI SYSTEM gl_API.dtd
  +
  +OpenGLAPI
  +
  +category name=GL_ARB_copy_image number=123
  +
  +function name=CopyImageSubData offset=assign
  +param name=srcName type=GLuint/
  +param name=srcTarget type=GLenum/
  +param name=srcLevel type=GLint/
  +param name=srcX type=GLint/
  +param name=srcY type=GLint/
  +param name=srcZ type=GLint/
  +param name=dstName type=GLuint/
  +param name=dstTarget type=GLenum/
  +param name=dstLevel type=GLint/
  +param name=dstX type=GLint/
  +param name=dstY type=GLint/
  +param name=dstZ type=GLint/
  +param name=srcWidth type=GLsizei/
  +param name=srcHeight type=GLsizei/
  +param name=srcDepth type=GLsizei/
  +/function
  +
  +/category
  +
  +/OpenGLAPI
  diff --git a/src/mapi/glapi/gen/Makefile.am
b/src/mapi/glapi/gen/Makefile.am
  index 212731f..645def4 100644
  --- a/src/mapi/glapi/gen/Makefile.am
  +++ b/src/mapi/glapi/gen/Makefile.am
  @@ -117,6 +117,7 @@ API_XML = \
  ARB_compressed_texture_pixel_storage.xml \
  ARB_compute_shader.xml \
  ARB_copy_buffer.xml \
  +   ARB_copy_image.xml \
  ARB_debug_output.xml \
  ARB_depth_buffer_float.xml \
  ARB_depth_clamp.xml \
  diff --git a/src/mapi/glapi/gen/gl_API.xml
b/src/mapi/glapi/gen/gl_API.xml
  index e011509..619717d 100644
  --- a/src/mapi/glapi/gen/gl_API.xml
  +++ b/src/mapi/glapi/gen/gl_API.xml
  @@ -8302,7 +8302,7 @@
 
   xi:include href=ARB_compute_shader.xml xmlns:xi=
http://www.w3.org/2001/XInclude/
 
  -!-- ARB extension #123 --
  +xi:include href=ARB_copy_image.xml xmlns:xi=
http://www.w3.org/2001/XInclude/
 
   xi:include href=ARB_texture_view.xml xmlns:xi=
http://www.w3.org/2001/XInclude/
 
  diff --git a/src/mapi/glapi/gen/gl_genexec.py
b/src/mapi/glapi/gen/gl_genexec.py
  index 4609193..d479e66 100644
  --- a/src/mapi/glapi/gen/gl_genexec.py
  +++ b/src/mapi/glapi/gen/gl_genexec.py
  @@ -62,6 +62,7 @@ header = /**
   #include main/condrender.h
   #include main/context.h
   #include main/convolve.h
  +#include main/copyimage.h
   #include main/depth.h
   #include main/dlist.h
   #include main/drawpix.h
  diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
  index 45c53ca..d02c174 100644
  --- a/src/mesa/Makefile.sources
  +++ b/src/mesa/Makefile.sources
  @@ -31,6 +31,7 @@ MAIN_FILES = \
  $(SRCDIR)main/condrender.c \
  $(SRCDIR)main/context.c \
  $(SRCDIR)main/convolve.c \
  +   $(SRCDIR)main/copyimage.c \
  $(SRCDIR)main/cpuinfo.c \
  $(SRCDIR)main/debug.c \
  $(SRCDIR)main/depth.c \
  diff --git a/src/mesa/main/copyimage.c b/src/mesa/main/copyimage.c
  new file mode 100644
  index 000..e1110dd
  --- /dev/null
  +++ b/src/mesa/main/copyimage.c
  @@ -0,0 +1,356 @@
  +/*
  + * 

Re: [Mesa-dev] [PATCH 1/5] mesa: Add GL API support for ARB_copy_image

2015-08-23 Thread Marek Olšák
On Mon, Aug 24, 2015 at 12:32 AM, Jason Ekstrand ja...@jlekstrand.net wrote:
 On Sun, Aug 23, 2015 at 10:42 AM, Marek Olšák mar...@gmail.com wrote:
 On Fri, Aug 8, 2014 at 8:55 PM, Jason Ekstrand ja...@jlekstrand.net wrote:
 This adds the API entrypoint, error checking logic, and a driver hook for
 the ARB_copy_image extension.

 v2: Fix a typo in ARB_copy_image.xml and add it to the makefile
 v3: Put ARB_copy_image.xml in the right place alphebetically in the
 makefile and properly prefix the commit message
 v4: Fixed some line wrapping and added a check for null
 v5: Check for incomplete renderbuffers

 Signed-off-by: Jason Ekstrand jason.ekstr...@intel.com
 Reviewed-by: Juha-Pekka Heikkila juhapekka.heikk...@gmail.com
 Reviewed-by: Neil Roberts n...@linux.intel.com

 v6: Update dispatch_sanity for the addition of CopyImageSubData
 ---
  src/mapi/glapi/gen/ARB_copy_image.xml   |  28 +++
  src/mapi/glapi/gen/Makefile.am  |   1 +
  src/mapi/glapi/gen/gl_API.xml   |   2 +-
  src/mapi/glapi/gen/gl_genexec.py|   1 +
  src/mesa/Makefile.sources   |   1 +
  src/mesa/main/copyimage.c   | 356 
 
  src/mesa/main/copyimage.h   |  49 +
  src/mesa/main/dd.h  |  16 ++
  src/mesa/main/extensions.c  |   1 +
  src/mesa/main/mtypes.h  |   1 +
  src/mesa/main/tests/dispatch_sanity.cpp |   2 +-
  src/mesa/main/textureview.c |  36 ++--
  src/mesa/main/textureview.h |   4 +
  13 files changed, 477 insertions(+), 21 deletions(-)
  create mode 100644 src/mapi/glapi/gen/ARB_copy_image.xml
  create mode 100644 src/mesa/main/copyimage.c
  create mode 100644 src/mesa/main/copyimage.h

 diff --git a/src/mapi/glapi/gen/ARB_copy_image.xml 
 b/src/mapi/glapi/gen/ARB_copy_image.xml
 new file mode 100644
 index 000..2fbd845
 --- /dev/null
 +++ b/src/mapi/glapi/gen/ARB_copy_image.xml
 @@ -0,0 +1,28 @@
 +?xml version=1.0?
 +!DOCTYPE OpenGLAPI SYSTEM gl_API.dtd
 +
 +OpenGLAPI
 +
 +category name=GL_ARB_copy_image number=123
 +
 +function name=CopyImageSubData offset=assign
 +param name=srcName type=GLuint/
 +param name=srcTarget type=GLenum/
 +param name=srcLevel type=GLint/
 +param name=srcX type=GLint/
 +param name=srcY type=GLint/
 +param name=srcZ type=GLint/
 +param name=dstName type=GLuint/
 +param name=dstTarget type=GLenum/
 +param name=dstLevel type=GLint/
 +param name=dstX type=GLint/
 +param name=dstY type=GLint/
 +param name=dstZ type=GLint/
 +param name=srcWidth type=GLsizei/
 +param name=srcHeight type=GLsizei/
 +param name=srcDepth type=GLsizei/
 +/function
 +
 +/category
 +
 +/OpenGLAPI
 diff --git a/src/mapi/glapi/gen/Makefile.am b/src/mapi/glapi/gen/Makefile.am
 index 212731f..645def4 100644
 --- a/src/mapi/glapi/gen/Makefile.am
 +++ b/src/mapi/glapi/gen/Makefile.am
 @@ -117,6 +117,7 @@ API_XML = \
 ARB_compressed_texture_pixel_storage.xml \
 ARB_compute_shader.xml \
 ARB_copy_buffer.xml \
 +   ARB_copy_image.xml \
 ARB_debug_output.xml \
 ARB_depth_buffer_float.xml \
 ARB_depth_clamp.xml \
 diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
 index e011509..619717d 100644
 --- a/src/mapi/glapi/gen/gl_API.xml
 +++ b/src/mapi/glapi/gen/gl_API.xml
 @@ -8302,7 +8302,7 @@

  xi:include href=ARB_compute_shader.xml 
 xmlns:xi=http://www.w3.org/2001/XInclude/

 -!-- ARB extension #123 --
 +xi:include href=ARB_copy_image.xml 
 xmlns:xi=http://www.w3.org/2001/XInclude/

  xi:include href=ARB_texture_view.xml 
 xmlns:xi=http://www.w3.org/2001/XInclude/

 diff --git a/src/mapi/glapi/gen/gl_genexec.py 
 b/src/mapi/glapi/gen/gl_genexec.py
 index 4609193..d479e66 100644
 --- a/src/mapi/glapi/gen/gl_genexec.py
 +++ b/src/mapi/glapi/gen/gl_genexec.py
 @@ -62,6 +62,7 @@ header = /**
  #include main/condrender.h
  #include main/context.h
  #include main/convolve.h
 +#include main/copyimage.h
  #include main/depth.h
  #include main/dlist.h
  #include main/drawpix.h
 diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
 index 45c53ca..d02c174 100644
 --- a/src/mesa/Makefile.sources
 +++ b/src/mesa/Makefile.sources
 @@ -31,6 +31,7 @@ MAIN_FILES = \
 $(SRCDIR)main/condrender.c \
 $(SRCDIR)main/context.c \
 $(SRCDIR)main/convolve.c \
 +   $(SRCDIR)main/copyimage.c \
 $(SRCDIR)main/cpuinfo.c \
 $(SRCDIR)main/debug.c \
 $(SRCDIR)main/depth.c \
 diff --git a/src/mesa/main/copyimage.c b/src/mesa/main/copyimage.c
 new file mode 100644
 index 000..e1110dd
 --- /dev/null
 +++ b/src/mesa/main/copyimage.c
 @@ -0,0 +1,356 @@
 +/*
 + * Mesa 3-D graphics library
 + *
 + * Copyright (C) 2014 Intel Corporation.  All Rights Reserved.
 + *
 + * Permission is hereby granted, free of charge, to any person obtaining a
 + * 

[Mesa-dev] [PATCH 2/4] r600g: make all viewport states use single atom

2015-08-23 Thread Grazvydas Ignotas
Similarly to scissor states, we can use single atom to track all viewport
states. This will allow to simplify dirty atom handling later.
---
 src/gallium/drivers/r600/evergreen_state.c   |  7 ++---
 src/gallium/drivers/r600/r600_blit.c |  2 +-
 src/gallium/drivers/r600/r600_hw_context.c   |  8 +++---
 src/gallium/drivers/r600/r600_pipe.h |  8 +++---
 src/gallium/drivers/r600/r600_state.c|  6 +
 src/gallium/drivers/r600/r600_state_common.c | 38 ++--
 6 files changed, 37 insertions(+), 32 deletions(-)

diff --git a/src/gallium/drivers/r600/evergreen_state.c 
b/src/gallium/drivers/r600/evergreen_state.c
index fbdcc9c..af71ad4 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -3444,7 +3444,7 @@ fallback:
 void evergreen_init_state_functions(struct r600_context *rctx)
 {
unsigned id = 4;
-   int i;
+
/* !!!
 *  To avoid GPU lockup registers must be emited in a specific order
 * (no kidding ...). The order below is important and have been
@@ -3497,10 +3497,7 @@ void evergreen_init_state_functions(struct r600_context 
*rctx)
r600_init_atom(rctx, rctx-poly_offset_state.atom, id++, 
evergreen_emit_polygon_offset, 6);
r600_init_atom(rctx, rctx-rasterizer_state.atom, id++, 
r600_emit_cso_state, 0);
r600_init_atom(rctx, rctx-scissor.atom, id++, 
evergreen_emit_scissor_state, 0);
-   for (i = 0; i  R600_MAX_VIEWPORTS; i++) {
-   r600_init_atom(rctx, rctx-viewport[i].atom, id++, 
r600_emit_viewport_state, 8);
-   rctx-viewport[i].idx = i;
-   }
+   r600_init_atom(rctx, rctx-viewport.atom, id++, 
r600_emit_viewport_state, 0);
r600_init_atom(rctx, rctx-stencil_ref.atom, id++, 
r600_emit_stencil_ref, 4);
r600_init_atom(rctx, rctx-vertex_fetch_shader.atom, id++, 
evergreen_emit_vertex_fetch_shader, 5);
r600_add_atom(rctx, rctx-b.streamout.begin_atom, id++);
diff --git a/src/gallium/drivers/r600/r600_blit.c 
b/src/gallium/drivers/r600/r600_blit.c
index 6ecb8ee..dd3b0e6 100644
--- a/src/gallium/drivers/r600/r600_blit.c
+++ b/src/gallium/drivers/r600/r600_blit.c
@@ -65,7 +65,7 @@ static void r600_blitter_begin(struct pipe_context *ctx, enum 
r600_blitter_op op
util_blitter_save_rasterizer(rctx-blitter, rctx-rasterizer_state.cso);
 
if (op  R600_SAVE_FRAGMENT_STATE) {
-   util_blitter_save_viewport(rctx-blitter, 
rctx-viewport[0].state);
+   util_blitter_save_viewport(rctx-blitter, 
rctx-viewport.state[0]);
util_blitter_save_scissor(rctx-blitter, 
rctx-scissor.scissor[0]);
util_blitter_save_fragment_shader(rctx-blitter, 
rctx-ps_shader);
util_blitter_save_blend(rctx-blitter, rctx-blend_state.cso);
diff --git a/src/gallium/drivers/r600/r600_hw_context.c 
b/src/gallium/drivers/r600/r600_hw_context.c
index 6710cd3..a0ba0cf 100644
--- a/src/gallium/drivers/r600/r600_hw_context.c
+++ b/src/gallium/drivers/r600/r600_hw_context.c
@@ -287,7 +287,7 @@ void r600_context_gfx_flush(void *context, unsigned flags,
 void r600_begin_new_cs(struct r600_context *ctx)
 {
unsigned shader;
-   int i;
+
ctx-b.flags = 0;
ctx-b.gtt = 0;
ctx-b.vram = 0;
@@ -311,9 +311,9 @@ void r600_begin_new_cs(struct r600_context *ctx)
ctx-scissor.dirty_mask = (1  R600_MAX_VIEWPORTS) - 1;
ctx-scissor.atom.num_dw = R600_MAX_VIEWPORTS * 4;
r600_mark_atom_dirty(ctx, ctx-scissor.atom);
-   for (i = 0; i  R600_MAX_VIEWPORTS; i++) {
-   r600_mark_atom_dirty(ctx, ctx-viewport[i].atom);
-   }
+   ctx-viewport.dirty_mask = (1  R600_MAX_VIEWPORTS) - 1;
+   ctx-viewport.atom.num_dw = R600_MAX_VIEWPORTS * 8;
+   r600_mark_atom_dirty(ctx, ctx-viewport.atom);
if (ctx-b.chip_class  EVERGREEN) {
r600_mark_atom_dirty(ctx, ctx-config_state.atom);
}
diff --git a/src/gallium/drivers/r600/r600_pipe.h 
b/src/gallium/drivers/r600/r600_pipe.h
index 549a7f6..5f56204 100644
--- a/src/gallium/drivers/r600/r600_pipe.h
+++ b/src/gallium/drivers/r600/r600_pipe.h
@@ -36,7 +36,7 @@
 #include util/list.h
 #include util/u_transfer.h
 
-#define R600_NUM_ATOMS 60
+#define R600_NUM_ATOMS 45
 
 #define R600_MAX_VIEWPORTS 16
 
@@ -206,8 +206,8 @@ struct r600_stencil_ref_state {
 
 struct r600_viewport_state {
struct r600_atom atom;
-   struct pipe_viewport_state state;
-   int idx;
+   struct pipe_viewport_state state[R600_MAX_VIEWPORTS];
+   uint32_t dirty_mask;
 };
 
 struct r600_shader_stages_state {
@@ -455,7 +455,7 @@ struct r600_context {
struct r600_config_stateconfig_state;
struct r600_stencil_ref_state   stencil_ref;
struct r600_vgt_state   vgt_state;
-   struct r600_viewport_state  viewport[R600_MAX_VIEWPORTS];
+   struct r600_viewport_state  viewport;
/* Shaders and shader 

[Mesa-dev] [PATCH 3/4] r600g: start numbering atoms from 1

2015-08-23 Thread Grazvydas Ignotas
There doesn't seem any reason to start from 4.
Start from 1 instead (0 is left reserved to catch uninitialized atoms).
---
 src/gallium/drivers/r600/evergreen_state.c | 2 +-
 src/gallium/drivers/r600/r600_pipe.h   | 2 +-
 src/gallium/drivers/r600/r600_state.c  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/r600/evergreen_state.c 
b/src/gallium/drivers/r600/evergreen_state.c
index af71ad4..eef3e49 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -3443,7 +3443,7 @@ fallback:
 
 void evergreen_init_state_functions(struct r600_context *rctx)
 {
-   unsigned id = 4;
+   unsigned id = 1;
 
/* !!!
 *  To avoid GPU lockup registers must be emited in a specific order
diff --git a/src/gallium/drivers/r600/r600_pipe.h 
b/src/gallium/drivers/r600/r600_pipe.h
index 5f56204..1962bc5 100644
--- a/src/gallium/drivers/r600/r600_pipe.h
+++ b/src/gallium/drivers/r600/r600_pipe.h
@@ -36,7 +36,7 @@
 #include util/list.h
 #include util/u_transfer.h
 
-#define R600_NUM_ATOMS 45
+#define R600_NUM_ATOMS 42
 
 #define R600_MAX_VIEWPORTS 16
 
diff --git a/src/gallium/drivers/r600/r600_state.c 
b/src/gallium/drivers/r600/r600_state.c
index 3d0615c..f485f8d 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -3028,7 +3028,7 @@ fallback:
 
 void r600_init_state_functions(struct r600_context *rctx)
 {
-   unsigned id = 4;
+   unsigned id = 1;
 
/* !!!
 *  To avoid GPU lockup registers must be emited in a specific order
-- 
1.9.1

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


[Mesa-dev] [PATCH 1/4] r600g: make all scissor states use single atom

2015-08-23 Thread Grazvydas Ignotas
As suggested by Marek Olšák, we can use single atom to track all scissor
states. This will allow to simplify dirty atom handling later.
---
 src/gallium/drivers/r600/evergreen_state.c   | 33 ++---
 src/gallium/drivers/r600/r600_blit.c |  2 +-
 src/gallium/drivers/r600/r600_hw_context.c   |  4 ++-
 src/gallium/drivers/r600/r600_pipe.h |  8 +++---
 src/gallium/drivers/r600/r600_state.c| 43 +---
 src/gallium/drivers/r600/r600_state_common.c |  6 ++--
 6 files changed, 60 insertions(+), 36 deletions(-)

diff --git a/src/gallium/drivers/r600/evergreen_state.c 
b/src/gallium/drivers/r600/evergreen_state.c
index 6a91d47..fbdcc9c 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -892,27 +892,39 @@ static void evergreen_set_scissor_states(struct 
pipe_context *ctx,
const struct pipe_scissor_state *state)
 {
struct r600_context *rctx = (struct r600_context *)ctx;
+   struct r600_scissor_state *rstate = rctx-scissor;
int i;
 
for (i = start_slot; i  start_slot + num_scissors; i++) {
-   rctx-scissor[i].scissor = state[i - start_slot];
-   r600_mark_atom_dirty(rctx, rctx-scissor[i].atom);
+   rstate-scissor[i] = state[i - start_slot];
+   rstate-dirty_mask |= 1  i;
}
+   rstate-atom.num_dw = util_bitcount(rstate-dirty_mask) * 4;
+   r600_mark_atom_dirty(rctx, rstate-atom);
 }
 
 static void evergreen_emit_scissor_state(struct r600_context *rctx, struct 
r600_atom *atom)
 {
struct radeon_winsys_cs *cs = rctx-b.rings.gfx.cs;
-   struct r600_scissor_state *rstate = (struct r600_scissor_state *)atom;
-   struct pipe_scissor_state *state = rstate-scissor;
-   unsigned offset = rstate-idx * 4 * 2;
+   struct r600_scissor_state *rstate = rctx-scissor;
+   struct pipe_scissor_state *state;
+   uint32_t dirty_mask;
+   unsigned i, offset;
uint32_t tl, br;
 
-   evergreen_get_scissor_rect(rctx, state-minx, state-miny, state-maxx, 
state-maxy, tl, br);
+   dirty_mask = rstate-dirty_mask;
+   while (dirty_mask != 0) {
+   i = u_bit_scan(dirty_mask);
+   state = rstate-scissor[i];
+   evergreen_get_scissor_rect(rctx, state-minx, state-miny, 
state-maxx, state-maxy, tl, br);
 
-   r600_write_context_reg_seq(cs, R_028250_PA_SC_VPORT_SCISSOR_0_TL + 
offset, 2);
-   radeon_emit(cs, tl);
-   radeon_emit(cs, br);
+   offset = i * 4 * 2;
+   r600_write_context_reg_seq(cs, 
R_028250_PA_SC_VPORT_SCISSOR_0_TL + offset, 2);
+   radeon_emit(cs, tl);
+   radeon_emit(cs, br);
+   }
+   rstate-dirty_mask = 0;
+   rstate-atom.num_dw = 0;
 }
 
 /**
@@ -3484,11 +3496,10 @@ void evergreen_init_state_functions(struct r600_context 
*rctx)
r600_init_atom(rctx, rctx-dsa_state.atom, id++, r600_emit_cso_state, 
0);
r600_init_atom(rctx, rctx-poly_offset_state.atom, id++, 
evergreen_emit_polygon_offset, 6);
r600_init_atom(rctx, rctx-rasterizer_state.atom, id++, 
r600_emit_cso_state, 0);
+   r600_init_atom(rctx, rctx-scissor.atom, id++, 
evergreen_emit_scissor_state, 0);
for (i = 0; i  R600_MAX_VIEWPORTS; i++) {
r600_init_atom(rctx, rctx-viewport[i].atom, id++, 
r600_emit_viewport_state, 8);
-   r600_init_atom(rctx, rctx-scissor[i].atom, id++, 
evergreen_emit_scissor_state, 4);
rctx-viewport[i].idx = i;
-   rctx-scissor[i].idx = i;
}
r600_init_atom(rctx, rctx-stencil_ref.atom, id++, 
r600_emit_stencil_ref, 4);
r600_init_atom(rctx, rctx-vertex_fetch_shader.atom, id++, 
evergreen_emit_vertex_fetch_shader, 5);
diff --git a/src/gallium/drivers/r600/r600_blit.c 
b/src/gallium/drivers/r600/r600_blit.c
index 22a0950..6ecb8ee 100644
--- a/src/gallium/drivers/r600/r600_blit.c
+++ b/src/gallium/drivers/r600/r600_blit.c
@@ -66,7 +66,7 @@ static void r600_blitter_begin(struct pipe_context *ctx, enum 
r600_blitter_op op
 
if (op  R600_SAVE_FRAGMENT_STATE) {
util_blitter_save_viewport(rctx-blitter, 
rctx-viewport[0].state);
-   util_blitter_save_scissor(rctx-blitter, 
rctx-scissor[0].scissor);
+   util_blitter_save_scissor(rctx-blitter, 
rctx-scissor.scissor[0]);
util_blitter_save_fragment_shader(rctx-blitter, 
rctx-ps_shader);
util_blitter_save_blend(rctx-blitter, rctx-blend_state.cso);
util_blitter_save_depth_stencil_alpha(rctx-blitter, 
rctx-dsa_state.cso);
diff --git a/src/gallium/drivers/r600/r600_hw_context.c 
b/src/gallium/drivers/r600/r600_hw_context.c
index 6445151..6710cd3 100644
--- a/src/gallium/drivers/r600/r600_hw_context.c
+++ b/src/gallium/drivers/r600/r600_hw_context.c
@@ -308,8 +308,10 @@ void r600_begin_new_cs(struct r600_context 

[Mesa-dev] [PATCH 4/4] r600g: simplify dirty atom tracking

2015-08-23 Thread Grazvydas Ignotas
Now that R600_NUM_ATOMS is below 64, dirty atom tracking can be
simplified.
---
 src/gallium/drivers/r600/r600_pipe.h | 41 ++--
 1 file changed, 11 insertions(+), 30 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_pipe.h 
b/src/gallium/drivers/r600/r600_pipe.h
index 1962bc5..c6fb86b 100644
--- a/src/gallium/drivers/r600/r600_pipe.h
+++ b/src/gallium/drivers/r600/r600_pipe.h
@@ -85,9 +85,6 @@
 #define R600_BIG_ENDIAN 0
 #endif
 
-#define R600_DIRTY_ATOM_WORD_BITS (sizeof(unsigned long) * 8)
-#define R600_DIRTY_ATOM_ARRAY_LEN DIV_ROUND_UP(R600_NUM_ATOMS, 
R600_DIRTY_ATOM_WORD_BITS)
-
 struct r600_context;
 struct r600_bytecode;
 union  r600_shader_key;
@@ -430,7 +427,7 @@ struct r600_context {
/* State binding slots are here. */
struct r600_atom*atoms[R600_NUM_ATOMS];
/* Dirty atom bitmask for fast tests */
-   unsigned long   dirty_atoms[R600_DIRTY_ATOM_ARRAY_LEN];
+   uint64_tdirty_atoms;
/* States for CS initialization. */
struct r600_command_buffer  start_cs_cmd; /* invariant state mostly 
*/
/** Compute specific registers initializations.  The start_cs_cmd atom
@@ -507,18 +504,17 @@ static inline void r600_set_atom_dirty(struct 
r600_context *rctx,
   struct r600_atom *atom,
   bool dirty)
 {
-   unsigned long mask;
-   unsigned int w;
+   uint64_t mask;
 
atom-dirty = dirty;
 
assert(atom-id != 0);
-   w = atom-id / R600_DIRTY_ATOM_WORD_BITS;
-   mask = 1ul  (atom-id % R600_DIRTY_ATOM_WORD_BITS);
+   assert(atom-id  sizeof(mask) * 8);
+   mask = 1ull  atom-id;
if (dirty)
-   rctx-dirty_atoms[w] |= mask;
+   rctx-dirty_atoms |= mask;
else
-   rctx-dirty_atoms[w] = ~mask;
+   rctx-dirty_atoms = ~mask;
 }
 
 static inline void r600_mark_atom_dirty(struct r600_context *rctx,
@@ -530,30 +526,15 @@ static inline void r600_mark_atom_dirty(struct 
r600_context *rctx,
 static inline unsigned int r600_next_dirty_atom(struct r600_context *rctx,
unsigned int id)
 {
-#if !defined(DEBUG)  defined(HAVE___BUILTIN_CTZ)
-   unsigned int w = id / R600_DIRTY_ATOM_WORD_BITS;
-   unsigned int bit = id % R600_DIRTY_ATOM_WORD_BITS;
-   unsigned long bits, mask = (1ul  bit) - 1;
+   uint64_t mask = rctx-dirty_atoms  ~((1ull  id) - 1);
 
-   for (; w  R600_DIRTY_ATOM_ARRAY_LEN; w++, mask = 0ul) {
-   bits = rctx-dirty_atoms[w]  ~mask;
-   if (bits == 0)
-   continue;
-   return w * R600_DIRTY_ATOM_WORD_BITS + __builtin_ctzl(bits);
+   if (mask != 0) {
+   id = u_bit_scan64(mask);
+   assert(rctx-atoms[id]  rctx-atoms[id]-dirty);
+   return id;
}
 
return R600_NUM_ATOMS;
-#else
-   for (; id  R600_NUM_ATOMS; id++) {
-   bool dirty = !!(rctx-dirty_atoms[id / 
R600_DIRTY_ATOM_WORD_BITS] 
-   (1ul  (id % R600_DIRTY_ATOM_WORD_BITS)));
-   assert(dirty == (rctx-atoms[id]  rctx-atoms[id]-dirty));
-   if (dirty)
-   break;
-   }
-
-   return id;
-#endif
 }
 
 void r600_trace_emit(struct r600_context *rctx);
-- 
1.9.1

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


Re: [Mesa-dev] [PATCH 1/5] mesa: Add GL API support for ARB_copy_image

2015-08-23 Thread Brian Paul
On Sun, Aug 23, 2015 at 4:51 PM, Jason Ekstrand ja...@jlekstrand.net
wrote:


 On Aug 23, 2015 3:48 PM, Marek Olšák mar...@gmail.com wrote:
 
  On Mon, Aug 24, 2015 at 12:32 AM, Jason Ekstrand ja...@jlekstrand.net
 wrote:
   On Sun, Aug 23, 2015 at 10:42 AM, Marek Olšák mar...@gmail.com
 wrote:
   On Fri, Aug 8, 2014 at 8:55 PM, Jason Ekstrand ja...@jlekstrand.net
 wrote:
   This adds the API entrypoint, error checking logic, and a driver
 hook for
   the ARB_copy_image extension.
  
   v2: Fix a typo in ARB_copy_image.xml and add it to the makefile
   v3: Put ARB_copy_image.xml in the right place alphebetically in the
   makefile and properly prefix the commit message
   v4: Fixed some line wrapping and added a check for null
   v5: Check for incomplete renderbuffers
  
   Signed-off-by: Jason Ekstrand jason.ekstr...@intel.com
   Reviewed-by: Juha-Pekka Heikkila juhapekka.heikk...@gmail.com
   Reviewed-by: Neil Roberts n...@linux.intel.com
  
   v6: Update dispatch_sanity for the addition of CopyImageSubData
   ---
src/mapi/glapi/gen/ARB_copy_image.xml   |  28 +++
src/mapi/glapi/gen/Makefile.am  |   1 +
src/mapi/glapi/gen/gl_API.xml   |   2 +-
src/mapi/glapi/gen/gl_genexec.py|   1 +
src/mesa/Makefile.sources   |   1 +
src/mesa/main/copyimage.c   | 356
 
src/mesa/main/copyimage.h   |  49 +
src/mesa/main/dd.h  |  16 ++
src/mesa/main/extensions.c  |   1 +
src/mesa/main/mtypes.h  |   1 +
src/mesa/main/tests/dispatch_sanity.cpp |   2 +-
src/mesa/main/textureview.c |  36 ++--
src/mesa/main/textureview.h |   4 +
13 files changed, 477 insertions(+), 21 deletions(-)
create mode 100644 src/mapi/glapi/gen/ARB_copy_image.xml
create mode 100644 src/mesa/main/copyimage.c
create mode 100644 src/mesa/main/copyimage.h
  
   diff --git a/src/mapi/glapi/gen/ARB_copy_image.xml
 b/src/mapi/glapi/gen/ARB_copy_image.xml
   new file mode 100644
   index 000..2fbd845
   --- /dev/null
   +++ b/src/mapi/glapi/gen/ARB_copy_image.xml
   @@ -0,0 +1,28 @@
   +?xml version=1.0?
   +!DOCTYPE OpenGLAPI SYSTEM gl_API.dtd
   +
   +OpenGLAPI
   +
   +category name=GL_ARB_copy_image number=123
   +
   +function name=CopyImageSubData offset=assign
   +param name=srcName type=GLuint/
   +param name=srcTarget type=GLenum/
   +param name=srcLevel type=GLint/
   +param name=srcX type=GLint/
   +param name=srcY type=GLint/
   +param name=srcZ type=GLint/
   +param name=dstName type=GLuint/
   +param name=dstTarget type=GLenum/
   +param name=dstLevel type=GLint/
   +param name=dstX type=GLint/
   +param name=dstY type=GLint/
   +param name=dstZ type=GLint/
   +param name=srcWidth type=GLsizei/
   +param name=srcHeight type=GLsizei/
   +param name=srcDepth type=GLsizei/
   +/function
   +
   +/category
   +
   +/OpenGLAPI
   diff --git a/src/mapi/glapi/gen/Makefile.am
 b/src/mapi/glapi/gen/Makefile.am
   index 212731f..645def4 100644
   --- a/src/mapi/glapi/gen/Makefile.am
   +++ b/src/mapi/glapi/gen/Makefile.am
   @@ -117,6 +117,7 @@ API_XML = \
   ARB_compressed_texture_pixel_storage.xml \
   ARB_compute_shader.xml \
   ARB_copy_buffer.xml \
   +   ARB_copy_image.xml \
   ARB_debug_output.xml \
   ARB_depth_buffer_float.xml \
   ARB_depth_clamp.xml \
   diff --git a/src/mapi/glapi/gen/gl_API.xml
 b/src/mapi/glapi/gen/gl_API.xml
   index e011509..619717d 100644
   --- a/src/mapi/glapi/gen/gl_API.xml
   +++ b/src/mapi/glapi/gen/gl_API.xml
   @@ -8302,7 +8302,7 @@
  
xi:include href=ARB_compute_shader.xml xmlns:xi=
 http://www.w3.org/2001/XInclude/
  
   -!-- ARB extension #123 --
   +xi:include href=ARB_copy_image.xml xmlns:xi=
 http://www.w3.org/2001/XInclude/
  
xi:include href=ARB_texture_view.xml xmlns:xi=
 http://www.w3.org/2001/XInclude/
  
   diff --git a/src/mapi/glapi/gen/gl_genexec.py
 b/src/mapi/glapi/gen/gl_genexec.py
   index 4609193..d479e66 100644
   --- a/src/mapi/glapi/gen/gl_genexec.py
   +++ b/src/mapi/glapi/gen/gl_genexec.py
   @@ -62,6 +62,7 @@ header = /**
#include main/condrender.h
#include main/context.h
#include main/convolve.h
   +#include main/copyimage.h
#include main/depth.h
#include main/dlist.h
#include main/drawpix.h
   diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
   index 45c53ca..d02c174 100644
   --- a/src/mesa/Makefile.sources
   +++ b/src/mesa/Makefile.sources
   @@ -31,6 +31,7 @@ MAIN_FILES = \
   $(SRCDIR)main/condrender.c \
   $(SRCDIR)main/context.c \
   $(SRCDIR)main/convolve.c \
   +   $(SRCDIR)main/copyimage.c \
   $(SRCDIR)main/cpuinfo.c \
   $(SRCDIR)main/debug.c \
   

Re: [Mesa-dev] [PATCH 1/6] mesa: GetTexLevelParameter{if}v changes for OpenGL ES 3.1

2015-08-23 Thread Tapani Pälli



On 08/21/2015 05:14 PM, Ilia Mirkin wrote:

On Fri, Aug 21, 2015 at 3:22 AM, Tapani Pälli tapani.pa...@intel.com wrote:

Patch refactors existing parameters check to first check common enums
between desktop GL and GLES 3.1 and modifies get_tex_level_parameter_image
to be compatible with enums specified in 3.1.

Signed-off-by: Tapani Pälli tapani.pa...@intel.com
---
  src/mesa/main/texparam.c | 34 +++---
  1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index 16739f1..947a2a1 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -1208,20 +1208,34 @@ static GLboolean
  legal_get_tex_level_parameter_target(struct gl_context *ctx, GLenum target,
   bool dsa)
  {
+   /* Common targets for desktop GL and GLES 3.1. */
 switch (target) {
-   case GL_TEXTURE_1D:
-   case GL_PROXY_TEXTURE_1D:
 case GL_TEXTURE_2D:
-   case GL_PROXY_TEXTURE_2D:
 case GL_TEXTURE_3D:
-   case GL_PROXY_TEXTURE_3D:
return GL_TRUE;
+   case GL_TEXTURE_2D_ARRAY_EXT:
+  return (_mesa_is_gles31(ctx) || ctx-Extensions.EXT_texture_array);
 case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
+  return (_mesa_is_gles31(ctx) || ctx-Extensions.ARB_texture_cube_map);
+   case GL_TEXTURE_2D_MULTISAMPLE:
+  return (_mesa_is_gles31(ctx) || ctx-Extensions.ARB_texture_multisample);
+   }
+
+   if (!_mesa_is_desktop_gl(ctx))
+  return GL_FALSE;
+
+   /* Rest of the desktop GL targets. */
+   switch (target) {
+   case GL_TEXTURE_1D:
+   case GL_PROXY_TEXTURE_1D:
+   case GL_PROXY_TEXTURE_2D:
+   case GL_PROXY_TEXTURE_3D:
+  return GL_TRUE;
 case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
return ctx-Extensions.ARB_texture_cube_map;
 case GL_TEXTURE_CUBE_MAP_ARRAY_ARB:
@@ -1232,7 +1246,6 @@ legal_get_tex_level_parameter_target(struct gl_context 
*ctx, GLenum target,
return ctx-Extensions.NV_texture_rectangle;
 case GL_TEXTURE_1D_ARRAY_EXT:
 case GL_PROXY_TEXTURE_1D_ARRAY_EXT:
-   case GL_TEXTURE_2D_ARRAY_EXT:
 case GL_PROXY_TEXTURE_2D_ARRAY_EXT:
return ctx-Extensions.EXT_texture_array;
 case GL_TEXTURE_BUFFER:
@@ -1254,7 +1267,6 @@ legal_get_tex_level_parameter_target(struct gl_context 
*ctx, GLenum target,
 * target may also be TEXTURE_BUFFER, indicating the texture buffer.
 */
return ctx-API == API_OPENGL_CORE  ctx-Version = 31;
-   case GL_TEXTURE_2D_MULTISAMPLE:
 case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
 case GL_PROXY_TEXTURE_2D_MULTISAMPLE:
 case GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY:
@@ -1381,8 +1393,8 @@ get_tex_level_parameter_image(struct gl_context *ctx,
   *params = _mesa_get_format_bits(texFormat, pname);
   break;
case GL_TEXTURE_SHARED_SIZE:
- if (ctx-Version  30 
- !ctx-Extensions.EXT_texture_shared_exponent)
+ if (!_mesa_is_gles31(ctx)  (ctx-Version  30 
+ !ctx-Extensions.EXT_texture_shared_exponent))
  goto invalid_pname;
   *params = texFormat == MESA_FORMAT_R9G9B9E5_FLOAT ? 5 : 0;
   break;
@@ -1415,7 +1427,7 @@ get_tex_level_parameter_image(struct gl_context *ctx,
case GL_TEXTURE_BLUE_TYPE_ARB:
case GL_TEXTURE_ALPHA_TYPE_ARB:
case GL_TEXTURE_DEPTH_TYPE_ARB:
- if (!ctx-Extensions.ARB_texture_float)
+ if (!_mesa_is_gles31(ctx)  !ctx-Extensions.ARB_texture_float)
  goto invalid_pname;
  if (_mesa_base_format_has_channel(img-_BaseFormat, pname))
 *params = _mesa_get_format_datatype(texFormat);
@@ -1425,13 +1437,13 @@ get_tex_level_parameter_image(struct gl_context *ctx,

/* GL_ARB_texture_multisample */
case GL_TEXTURE_SAMPLES:
- if (!ctx-Extensions.ARB_texture_multisample)
+ if (!_mesa_is_gles31(ctx)  !ctx-Extensions.ARB_texture_multisample)
  goto invalid_pname;
   *params = img-NumSamples;
   break;

case GL_TEXTURE_FIXED_SAMPLE_LOCATIONS:
- if (!ctx-Extensions.ARB_texture_multisample)
+ if (!_mesa_is_gles31(ctx)  !ctx-Extensions.ARB_texture_multisample)


I think you guys have gone a little nuts with sticking _mesa_is_gles31
all over the place... This is accounting for drivers which want to
expose gles3.1 but don't have ARB_texture_multisample supported. Are
there any such drivers? Are all these changes really worthwhile?


This particular patch was to address

glGetTexLevelParameter[fi]v - needs updates to restrict to GLES enums

in docs/GL3.txt GLES3.1 section.

I do understand your worry about sticking is_gles31() here and there but 
remember that most (if not all) these changes will apply also for 
gles32. In Mesa 

Re: [Mesa-dev] [PATCH 1/6] mesa: GetTexLevelParameter{if}v changes for OpenGL ES 3.1

2015-08-23 Thread Tapani Pälli



On 08/24/2015 08:17 AM, Ilia Mirkin wrote:


On Aug 24, 2015 1:07 AM, Tapani Pälli tapani.pa...@intel.com
mailto:tapani.pa...@intel.com wrote:
 
 
 
  On 08/21/2015 05:14 PM, Ilia Mirkin wrote:
 
  On Fri, Aug 21, 2015 at 3:22 AM, Tapani Pälli
tapani.pa...@intel.com mailto:tapani.pa...@intel.com wrote:
 
  Patch refactors existing parameters check to first check common enums
  between desktop GL and GLES 3.1 and modifies
get_tex_level_parameter_image
  to be compatible with enums specified in 3.1.
 
  Signed-off-by: Tapani Pälli tapani.pa...@intel.com
mailto:tapani.pa...@intel.com
  ---
src/mesa/main/texparam.c | 34 +++---
1 file changed, 23 insertions(+), 11 deletions(-)
 
  diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
  index 16739f1..947a2a1 100644
  --- a/src/mesa/main/texparam.c
  +++ b/src/mesa/main/texparam.c
  @@ -1208,20 +1208,34 @@ static GLboolean
legal_get_tex_level_parameter_target(struct gl_context *ctx,
GLenum target,
 bool dsa)
{
  +   /* Common targets for desktop GL and GLES 3.1. */
   switch (target) {
  -   case GL_TEXTURE_1D:
  -   case GL_PROXY_TEXTURE_1D:
   case GL_TEXTURE_2D:
  -   case GL_PROXY_TEXTURE_2D:
   case GL_TEXTURE_3D:
  -   case GL_PROXY_TEXTURE_3D:
  return GL_TRUE;
  +   case GL_TEXTURE_2D_ARRAY_EXT:
  +  return (_mesa_is_gles31(ctx) ||
ctx-Extensions.EXT_texture_array);
   case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
   case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
   case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
   case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
   case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
  +  return (_mesa_is_gles31(ctx) ||
ctx-Extensions.ARB_texture_cube_map);
  +   case GL_TEXTURE_2D_MULTISAMPLE:
  +  return (_mesa_is_gles31(ctx) ||
ctx-Extensions.ARB_texture_multisample);
  +   }
  +
  +   if (!_mesa_is_desktop_gl(ctx))
  +  return GL_FALSE;
  +
  +   /* Rest of the desktop GL targets. */
  +   switch (target) {
  +   case GL_TEXTURE_1D:
  +   case GL_PROXY_TEXTURE_1D:
  +   case GL_PROXY_TEXTURE_2D:
  +   case GL_PROXY_TEXTURE_3D:
  +  return GL_TRUE;
   case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
  return ctx-Extensions.ARB_texture_cube_map;
   case GL_TEXTURE_CUBE_MAP_ARRAY_ARB:
  @@ -1232,7 +1246,6 @@ legal_get_tex_level_parameter_target(struct
gl_context *ctx, GLenum target,
  return ctx-Extensions.NV_texture_rectangle;
   case GL_TEXTURE_1D_ARRAY_EXT:
   case GL_PROXY_TEXTURE_1D_ARRAY_EXT:
  -   case GL_TEXTURE_2D_ARRAY_EXT:
   case GL_PROXY_TEXTURE_2D_ARRAY_EXT:
  return ctx-Extensions.EXT_texture_array;
   case GL_TEXTURE_BUFFER:
  @@ -1254,7 +1267,6 @@ legal_get_tex_level_parameter_target(struct
gl_context *ctx, GLenum target,
   * target may also be TEXTURE_BUFFER, indicating the
texture buffer.
   */
  return ctx-API == API_OPENGL_CORE  ctx-Version = 31;
  -   case GL_TEXTURE_2D_MULTISAMPLE:
   case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
   case GL_PROXY_TEXTURE_2D_MULTISAMPLE:
   case GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY:
  @@ -1381,8 +1393,8 @@ get_tex_level_parameter_image(struct
gl_context *ctx,
 *params = _mesa_get_format_bits(texFormat, pname);
 break;
  case GL_TEXTURE_SHARED_SIZE:
  - if (ctx-Version  30 
  - !ctx-Extensions.EXT_texture_shared_exponent)
  + if (!_mesa_is_gles31(ctx)  (ctx-Version  30 
  + !ctx-Extensions.EXT_texture_shared_exponent))
goto invalid_pname;
 *params = texFormat == MESA_FORMAT_R9G9B9E5_FLOAT ? 5 : 0;
 break;
  @@ -1415,7 +1427,7 @@ get_tex_level_parameter_image(struct
gl_context *ctx,
  case GL_TEXTURE_BLUE_TYPE_ARB:
  case GL_TEXTURE_ALPHA_TYPE_ARB:
  case GL_TEXTURE_DEPTH_TYPE_ARB:
  - if (!ctx-Extensions.ARB_texture_float)
  + if (!_mesa_is_gles31(ctx) 
!ctx-Extensions.ARB_texture_float)
goto invalid_pname;
if (_mesa_base_format_has_channel(img-_BaseFormat, pname))
   *params = _mesa_get_format_datatype(texFormat);
  @@ -1425,13 +1437,13 @@ get_tex_level_parameter_image(struct
gl_context *ctx,
 
  /* GL_ARB_texture_multisample */
  case GL_TEXTURE_SAMPLES:
  - if (!ctx-Extensions.ARB_texture_multisample)
  + if (!_mesa_is_gles31(ctx) 
!ctx-Extensions.ARB_texture_multisample)
goto invalid_pname;
 *params = img-NumSamples;
 break;
 
  case GL_TEXTURE_FIXED_SAMPLE_LOCATIONS:
  - if (!ctx-Extensions.ARB_texture_multisample)
  + if (!_mesa_is_gles31(ctx) 
!ctx-Extensions.ARB_texture_multisample)
 
 
  I think you guys have gone a little nuts with sticking _mesa_is_gles31
  all over the place... This is accounting for drivers which want to
  expose gles3.1 

Re: [Mesa-dev] [PATCH 4/6] glsl: add support for OES_texture_storage_multisample_2d_array

2015-08-23 Thread Tapani Pälli



On 08/21/2015 01:29 PM, Lofstedt, Marta wrote:

-Original Message-
From: mesa-dev [mailto:mesa-dev-boun...@lists.freedesktop.org] On
Behalf Of Tapani Pälli
Sent: Friday, August 21, 2015 9:22 AM
To: mesa-dev@lists.freedesktop.org
Subject: [Mesa-dev] [PATCH 4/6] glsl: add support for
OES_texture_storage_multisample_2d_array

Patch adds extension enable bit and enables required keywords and builtin
functions for the extension.

Signed-off-by: Tapani Pälli tapani.pa...@intel.com
---
  src/glsl/builtin_functions.cpp  | 5 +++--
  src/glsl/builtin_types.cpp  | 3 ++-
  src/glsl/glcpp/glcpp-parse.y| 2 ++
  src/glsl/glsl_lexer.ll  | 6 +++---
  src/glsl/glsl_parser_extras.cpp | 1 +
  src/glsl/glsl_parser_extras.h   | 2 ++
  6 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp
index 57bed86..a4e9baf 100644
--- a/src/glsl/builtin_functions.cpp
+++ b/src/glsl/builtin_functions.cpp
@@ -284,8 +284,9 @@ texture_multisample(const _mesa_glsl_parse_state
*state)  static bool  texture_multisample_array(const
_mesa_glsl_parse_state *state)  {
-   return state-is_version(150, 0) ||
-  state-ARB_texture_multisample_enable;
+   return state-is_version(150, 320) ||


Could you explain 320?
The rest of the patchset appear to go for exposure under GLES 3.1


This is not necessary change, it's a 'when changing that line make sure 
that it does not need to be touched again' requested by Timothy here:


http://lists.freedesktop.org/archives/mesa-dev/2015-August/091922.html

I think this kind of 'future-proofing' in general is potentially 
dangerous but in the case of keywords and builtins it should not cause 
trouble.




/Marta


+  state-ARB_texture_multisample_enable ||
+  state-OES_texture_storage_multisample_2d_array_enable;
  }


  static bool
diff --git a/src/glsl/builtin_types.cpp b/src/glsl/builtin_types.cpp index
9cf198f..0d0d71d 100644
--- a/src/glsl/builtin_types.cpp
+++ b/src/glsl/builtin_types.cpp
@@ -307,7 +307,8 @@ _mesa_glsl_initialize_types(struct
_mesa_glsl_parse_state *state)
add_type(symbols, glsl_type::usamplerCubeArray_type);
 }

-   if (state-ARB_texture_multisample_enable) {
+   if (state-ARB_texture_multisample_enable ||
+   state-OES_texture_storage_multisample_2d_array_enable) {
add_type(symbols, glsl_type::sampler2DMS_type);
add_type(symbols, glsl_type::isampler2DMS_type);
add_type(symbols, glsl_type::usampler2DMS_type); diff --git
a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index
18e50af..6396817 100644
--- a/src/glsl/glcpp/glcpp-parse.y
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -2382,6 +2382,8 @@
_glcpp_parser_handle_version_declaration(glcpp_parser_t *parser,
intmax_t versio
 add_builtin_define(parser,
GL_OES_EGL_image_external, 1);
if (extensions-OES_standard_derivatives)
   add_builtin_define(parser, GL_OES_standard_derivatives, 1);
+  if (extensions-OES_texture_storage_multisample_2d_array)
+ add_builtin_define(parser,
+ GL_OES_texture_storage_multisample_2d_array, 1);
   }
} else {
   add_builtin_define(parser, GL_ARB_draw_buffers, 1); diff
--git a/src/glsl/glsl_lexer.ll b/src/glsl/glsl_lexer.ll index 24998c1..9d7ad74
100644
--- a/src/glsl/glsl_lexer.ll
+++ b/src/glsl/glsl_lexer.ll
@@ -347,9 +347,9 @@ usampler2DArray KEYWORD(130, 300,
130, 300, USAMPLER2DARRAY);
  sampler2DMSKEYWORD_WITH_ALT(150, 300, 150, 310, yyextra-

ARB_texture_multisample_enable, SAMPLER2DMS);

  isampler2DMS   KEYWORD_WITH_ALT(150, 300, 150, 310, yyextra-

ARB_texture_multisample_enable, ISAMPLER2DMS);

  usampler2DMS   KEYWORD_WITH_ALT(150, 300, 150, 310, yyextra-

ARB_texture_multisample_enable, USAMPLER2DMS);

-sampler2DMSArray   KEYWORD_WITH_ALT(150, 300, 150, 0, yyextra-

ARB_texture_multisample_enable, SAMPLER2DMSARRAY);

-isampler2DMSArray  KEYWORD_WITH_ALT(150, 300, 150, 0, yyextra-

ARB_texture_multisample_enable, ISAMPLER2DMSARRAY); -

usampler2DMSArray  KEYWORD_WITH_ALT(150, 300, 150, 0, yyextra-

ARB_texture_multisample_enable, USAMPLER2DMSARRAY);

+sampler2DMSArray   KEYWORD_WITH_ALT(150, 300, 150, 320, yyextra-

ARB_texture_multisample_enable||yyextra-
OES_texture_storage_multisample_2d_array_enable,

SAMPLER2DMSARRAY);
+isampler2DMSArray  KEYWORD_WITH_ALT(150, 300, 150, 320,
+yyextra-ARB_texture_multisample_enable||yyextra-

OES_texture_storage_m

+ultisample_2d_array_enable, ISAMPLER2DMSARRAY); usampler2DMSArray
+KEYWORD_WITH_ALT(150, 300, 150, 320,
+yyextra-ARB_texture_multisample_enable||yyextra-

OES_texture_storage_m

+ultisample_2d_array_enable, USAMPLER2DMSARRAY);

 /* keywords available with ARB_texture_cube_map_array_enable
extension on desktop GLSL */
  samplerCubeArray   KEYWORD_WITH_ALT(400, 0, 400, 0, yyextra-

ARB_texture_cube_map_array_enable, SAMPLERCUBEARRAY);

diff --git 

Re: [Mesa-dev] [PATCH 1/6] mesa: GetTexLevelParameter{if}v changes for OpenGL ES 3.1

2015-08-23 Thread Ilia Mirkin
On Aug 24, 2015 1:25 AM, Tapani Pälli tapani.pa...@intel.com wrote:



 On 08/24/2015 08:17 AM, Ilia Mirkin wrote:


 On Aug 24, 2015 1:07 AM, Tapani Pälli tapani.pa...@intel.com
 mailto:tapani.pa...@intel.com wrote:
  
  
  
   On 08/21/2015 05:14 PM, Ilia Mirkin wrote:
  
   On Fri, Aug 21, 2015 at 3:22 AM, Tapani Pälli
 tapani.pa...@intel.com mailto:tapani.pa...@intel.com wrote:
  
   Patch refactors existing parameters check to first check common
enums
   between desktop GL and GLES 3.1 and modifies
 get_tex_level_parameter_image
   to be compatible with enums specified in 3.1.
  
   Signed-off-by: Tapani Pälli tapani.pa...@intel.com
 mailto:tapani.pa...@intel.com

   ---
 src/mesa/main/texparam.c | 34 +++---
 1 file changed, 23 insertions(+), 11 deletions(-)
  
   diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
   index 16739f1..947a2a1 100644
   --- a/src/mesa/main/texparam.c
   +++ b/src/mesa/main/texparam.c
   @@ -1208,20 +1208,34 @@ static GLboolean
 legal_get_tex_level_parameter_target(struct gl_context *ctx,
 GLenum target,
  bool dsa)
 {
   +   /* Common targets for desktop GL and GLES 3.1. */
switch (target) {
   -   case GL_TEXTURE_1D:
   -   case GL_PROXY_TEXTURE_1D:
case GL_TEXTURE_2D:
   -   case GL_PROXY_TEXTURE_2D:
case GL_TEXTURE_3D:
   -   case GL_PROXY_TEXTURE_3D:
   return GL_TRUE;
   +   case GL_TEXTURE_2D_ARRAY_EXT:
   +  return (_mesa_is_gles31(ctx) ||
 ctx-Extensions.EXT_texture_array);
case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
   +  return (_mesa_is_gles31(ctx) ||
 ctx-Extensions.ARB_texture_cube_map);
   +   case GL_TEXTURE_2D_MULTISAMPLE:
   +  return (_mesa_is_gles31(ctx) ||
 ctx-Extensions.ARB_texture_multisample);
   +   }
   +
   +   if (!_mesa_is_desktop_gl(ctx))
   +  return GL_FALSE;
   +
   +   /* Rest of the desktop GL targets. */
   +   switch (target) {
   +   case GL_TEXTURE_1D:
   +   case GL_PROXY_TEXTURE_1D:
   +   case GL_PROXY_TEXTURE_2D:
   +   case GL_PROXY_TEXTURE_3D:
   +  return GL_TRUE;
case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
   return ctx-Extensions.ARB_texture_cube_map;
case GL_TEXTURE_CUBE_MAP_ARRAY_ARB:
   @@ -1232,7 +1246,6 @@ legal_get_tex_level_parameter_target(struct
 gl_context *ctx, GLenum target,
   return ctx-Extensions.NV_texture_rectangle;
case GL_TEXTURE_1D_ARRAY_EXT:
case GL_PROXY_TEXTURE_1D_ARRAY_EXT:
   -   case GL_TEXTURE_2D_ARRAY_EXT:
case GL_PROXY_TEXTURE_2D_ARRAY_EXT:
   return ctx-Extensions.EXT_texture_array;
case GL_TEXTURE_BUFFER:
   @@ -1254,7 +1267,6 @@ legal_get_tex_level_parameter_target(struct
 gl_context *ctx, GLenum target,
* target may also be TEXTURE_BUFFER, indicating the
 texture buffer.
*/
   return ctx-API == API_OPENGL_CORE  ctx-Version = 31;
   -   case GL_TEXTURE_2D_MULTISAMPLE:
case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
case GL_PROXY_TEXTURE_2D_MULTISAMPLE:
case GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY:
   @@ -1381,8 +1393,8 @@ get_tex_level_parameter_image(struct
 gl_context *ctx,
  *params = _mesa_get_format_bits(texFormat, pname);
  break;
   case GL_TEXTURE_SHARED_SIZE:
   - if (ctx-Version  30 
   - !ctx-Extensions.EXT_texture_shared_exponent)
   + if (!_mesa_is_gles31(ctx)  (ctx-Version  30 
   + !ctx-Extensions.EXT_texture_shared_exponent))
 goto invalid_pname;
  *params = texFormat == MESA_FORMAT_R9G9B9E5_FLOAT ? 5 :
0;
  break;
   @@ -1415,7 +1427,7 @@ get_tex_level_parameter_image(struct
 gl_context *ctx,
   case GL_TEXTURE_BLUE_TYPE_ARB:
   case GL_TEXTURE_ALPHA_TYPE_ARB:
   case GL_TEXTURE_DEPTH_TYPE_ARB:
   - if (!ctx-Extensions.ARB_texture_float)
   + if (!_mesa_is_gles31(ctx) 
 !ctx-Extensions.ARB_texture_float)
 goto invalid_pname;
 if (_mesa_base_format_has_channel(img-_BaseFormat,
pname))
*params = _mesa_get_format_datatype(texFormat);
   @@ -1425,13 +1437,13 @@ get_tex_level_parameter_image(struct
 gl_context *ctx,
  
   /* GL_ARB_texture_multisample */
   case GL_TEXTURE_SAMPLES:
   - if (!ctx-Extensions.ARB_texture_multisample)
   + if (!_mesa_is_gles31(ctx) 
 !ctx-Extensions.ARB_texture_multisample)
 goto invalid_pname;
  *params = img-NumSamples;
  break;
  
   case GL_TEXTURE_FIXED_SAMPLE_LOCATIONS:
   - if (!ctx-Extensions.ARB_texture_multisample)
   + if (!_mesa_is_gles31(ctx) 
 

[Mesa-dev] [Bug 91254] (regresion) video using VA-API on Intel slow and freeze system with mesa 10.6 or 10.6.1

2015-08-23 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=91254

--- Comment #18 from Tomasz C. toma...@o2.pl ---
Chris patch of comment # 14 is working properly.
I hope that it will enter into the next release.

I am happy that this has been resolved.
Thanks to Chris for helping to fix this bug.

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


Re: [Mesa-dev] [PATCH] mesa: debug facility to replace shaders when running apps

2015-08-23 Thread Tapani Pälli



On 08/21/2015 04:30 PM, Brian Paul wrote:

On Fri, Aug 21, 2015 at 2:17 AM, Tapani Pälli tapani.pa...@intel.com
mailto:tapani.pa...@intel.com wrote:

Patch adds shader source and replace functionality in to the compiler.


I had some very primitive support for this sort of thing already.  See
SHADER_SUBST in shaderapi.c  However, feel free to replace it with
something better/nicer.

Also, please document this feature in docs/shading.html



Wow, I've managed to miss this :) I could modify your SHADER_SUBST code 
by adding environment variable support and use SHA1 to avoid collisions.




This can be used to debug individual (failing) shaders and measure
performance impact of each shader.

Functionality is controlled via 2 environment variables:

MESA_SHADER_DUMP - path where shader sources are dumped
MESA_SHADER_READ - path where replacement shaders are read


Let's put _PATH on the end of both of those to better describe the vars.


ok




Signed-off-by: Tapani Pälli tapani.pa...@intel.com
mailto:tapani.pa...@intel.com
Suggested-by: Eero Tamminen eero.t.tammi...@intel.com
mailto:eero.t.tammi...@intel.com
---
  src/glsl/glsl_parser_extras.cpp | 76
+
  src/mesa/main/mtypes.h  |  2 +-
  2 files changed, 77 insertions(+), 1 deletion(-)

diff --git a/src/glsl/glsl_parser_extras.cpp
b/src/glsl/glsl_parser_extras.cpp
index 46896d7..17b79b0 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp


Are you sure this is the right file for this new code?  Maybe it should
go into a new source file.  glsl_parser_extras.cpp already seems to have
become a dumping ground for a lot of unrelated things.


agreed, I think I'll just modify your existing code




@@ -1570,10 +1570,86 @@ set_shader_inout_layout(struct gl_shader
*shader,

  extern C {

+#include sys/stat.h
+#include util/mesa-sha1.h
+
+static void
+generate_sha1(struct gl_shader *shader, char sha_str[64])


const-qualify shader?


ok


+{
+   unsigned char sha[20];
+   _mesa_sha1_compute(shader-Source, strlen(shader-Source), sha);
+   _mesa_sha1_format(sha_str, sha);
+}
+
+static void
+construct_name(struct gl_shader *shader, const char *path,


const qualify shader?

Please add a comment to the function explaining what it does.


ok


+   char *name, unsigned length)
+{
+   char sha[64];
+   static const char *types[] = {
+  VS, TC, TE, GS, FS, CS,
+   };
+
+   generate_sha1(shader, sha);
+   _mesa_snprintf(name, length, %s/%s_%s.glsl, path,
types[shader-Stage],
+  sha);
+}
+
+static void
+read_shader(struct gl_shader *shader)


Please put a comment on the function explaining what it does.


+{
+   char name[PATH_MAX];
+   static char *read_path = getenv(MESA_SHADER_READ);
+
+   if (!read_path)
+  return;
+
+   construct_name(shader, read_path, name, PATH_MAX);
+
+   FILE *in = fopen(name, r);
+   if (in) {
+  fseek(in, 0, SEEK_END);
+  long size = ftell(in);
+  rewind(in);
+  char *source = (char *) malloc(size + 1);


Should probably check for source==NULL here.  Otherwise, tools like
coverity will probably complain.


will use your code with the checks!



+  fread(source, size, 1, in);
+  source[size] = '\0';
+  free(shader-Source);
+  shader-Source = source;
+  fclose(in);
+   }
+}
+
+static void
+dump_shader(struct gl_shader *shader)


const-qualify shader?


+{
+   char name[PATH_MAX];
+   static char *dump_path = getenv(MESA_SHADER_DUMP);
+
+   if (!dump_path)
+  return;
+
+   construct_name(shader, dump_path, name, PATH_MAX);
+
+   FILE *out = fopen(name, w);
+   if (out) {
+  fprintf(out, %s, shader-Source);


fputs() instead?

+  fclose(out);
+   } else {
+  fprintf(stderr, could not open %s for dumping shader\n, name);


Or, _mesa_warning()?


Yep, I was lazy with this because _mesa_warning would need additional 
changes to Makefiles and linking.




+   }
+}
+
  void
  _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader
*shader,
bool dump_ast, bool dump_hir)
  {
+   /* Dump original shader source to MESA_SHADER_DUMP and replace
+* if corresponding entry found from MESA_SHADER_READ path.
+*/
+   dump_shader(shader);
+   read_shader(shader);
+
 struct _mesa_glsl_parse_state *state =
new(shader) _mesa_glsl_parse_state(ctx, shader-Stage, shader);
 const char *source = shader-Source;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index f61a245..fb47a22 100644
--- 

Re: [Mesa-dev] [PATCH 1/6] mesa: GetTexLevelParameter{if}v changes for OpenGL ES 3.1

2015-08-23 Thread Ilia Mirkin
On Aug 24, 2015 1:07 AM, Tapani Pälli tapani.pa...@intel.com wrote:



 On 08/21/2015 05:14 PM, Ilia Mirkin wrote:

 On Fri, Aug 21, 2015 at 3:22 AM, Tapani Pälli tapani.pa...@intel.com
wrote:

 Patch refactors existing parameters check to first check common enums
 between desktop GL and GLES 3.1 and modifies
get_tex_level_parameter_image
 to be compatible with enums specified in 3.1.

 Signed-off-by: Tapani Pälli tapani.pa...@intel.com
 ---
   src/mesa/main/texparam.c | 34 +++---
   1 file changed, 23 insertions(+), 11 deletions(-)

 diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
 index 16739f1..947a2a1 100644
 --- a/src/mesa/main/texparam.c
 +++ b/src/mesa/main/texparam.c
 @@ -1208,20 +1208,34 @@ static GLboolean
   legal_get_tex_level_parameter_target(struct gl_context *ctx, GLenum
target,
bool dsa)
   {
 +   /* Common targets for desktop GL and GLES 3.1. */
  switch (target) {
 -   case GL_TEXTURE_1D:
 -   case GL_PROXY_TEXTURE_1D:
  case GL_TEXTURE_2D:
 -   case GL_PROXY_TEXTURE_2D:
  case GL_TEXTURE_3D:
 -   case GL_PROXY_TEXTURE_3D:
 return GL_TRUE;
 +   case GL_TEXTURE_2D_ARRAY_EXT:
 +  return (_mesa_is_gles31(ctx) ||
ctx-Extensions.EXT_texture_array);
  case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
  case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
  case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
  case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
  case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
  case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
 +  return (_mesa_is_gles31(ctx) ||
ctx-Extensions.ARB_texture_cube_map);
 +   case GL_TEXTURE_2D_MULTISAMPLE:
 +  return (_mesa_is_gles31(ctx) ||
ctx-Extensions.ARB_texture_multisample);
 +   }
 +
 +   if (!_mesa_is_desktop_gl(ctx))
 +  return GL_FALSE;
 +
 +   /* Rest of the desktop GL targets. */
 +   switch (target) {
 +   case GL_TEXTURE_1D:
 +   case GL_PROXY_TEXTURE_1D:
 +   case GL_PROXY_TEXTURE_2D:
 +   case GL_PROXY_TEXTURE_3D:
 +  return GL_TRUE;
  case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
 return ctx-Extensions.ARB_texture_cube_map;
  case GL_TEXTURE_CUBE_MAP_ARRAY_ARB:
 @@ -1232,7 +1246,6 @@ legal_get_tex_level_parameter_target(struct
gl_context *ctx, GLenum target,
 return ctx-Extensions.NV_texture_rectangle;
  case GL_TEXTURE_1D_ARRAY_EXT:
  case GL_PROXY_TEXTURE_1D_ARRAY_EXT:
 -   case GL_TEXTURE_2D_ARRAY_EXT:
  case GL_PROXY_TEXTURE_2D_ARRAY_EXT:
 return ctx-Extensions.EXT_texture_array;
  case GL_TEXTURE_BUFFER:
 @@ -1254,7 +1267,6 @@ legal_get_tex_level_parameter_target(struct
gl_context *ctx, GLenum target,
  * target may also be TEXTURE_BUFFER, indicating the texture
buffer.
  */
 return ctx-API == API_OPENGL_CORE  ctx-Version = 31;
 -   case GL_TEXTURE_2D_MULTISAMPLE:
  case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
  case GL_PROXY_TEXTURE_2D_MULTISAMPLE:
  case GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY:
 @@ -1381,8 +1393,8 @@ get_tex_level_parameter_image(struct gl_context
*ctx,
*params = _mesa_get_format_bits(texFormat, pname);
break;
 case GL_TEXTURE_SHARED_SIZE:
 - if (ctx-Version  30 
 - !ctx-Extensions.EXT_texture_shared_exponent)
 + if (!_mesa_is_gles31(ctx)  (ctx-Version  30 
 + !ctx-Extensions.EXT_texture_shared_exponent))
   goto invalid_pname;
*params = texFormat == MESA_FORMAT_R9G9B9E5_FLOAT ? 5 : 0;
break;
 @@ -1415,7 +1427,7 @@ get_tex_level_parameter_image(struct gl_context
*ctx,
 case GL_TEXTURE_BLUE_TYPE_ARB:
 case GL_TEXTURE_ALPHA_TYPE_ARB:
 case GL_TEXTURE_DEPTH_TYPE_ARB:
 - if (!ctx-Extensions.ARB_texture_float)
 + if (!_mesa_is_gles31(ctx) 
!ctx-Extensions.ARB_texture_float)
   goto invalid_pname;
   if (_mesa_base_format_has_channel(img-_BaseFormat, pname))
  *params = _mesa_get_format_datatype(texFormat);
 @@ -1425,13 +1437,13 @@ get_tex_level_parameter_image(struct gl_context
*ctx,

 /* GL_ARB_texture_multisample */
 case GL_TEXTURE_SAMPLES:
 - if (!ctx-Extensions.ARB_texture_multisample)
 + if (!_mesa_is_gles31(ctx) 
!ctx-Extensions.ARB_texture_multisample)
   goto invalid_pname;
*params = img-NumSamples;
break;

 case GL_TEXTURE_FIXED_SAMPLE_LOCATIONS:
 - if (!ctx-Extensions.ARB_texture_multisample)
 + if (!_mesa_is_gles31(ctx) 
!ctx-Extensions.ARB_texture_multisample)


 I think you guys have gone a little nuts with sticking _mesa_is_gles31
 all over the place... This is accounting for drivers which want to
 expose gles3.1 but don't have ARB_texture_multisample supported. Are
 there any such drivers? Are all these changes really worthwhile?


 This particular patch was to address

 glGetTexLevelParameter[fi]v - needs updates to restrict to GLES enums

 in docs/GL3.txt