[Mesa-dev] [PATCH] i965: Detect ability to pass kernel contexts to any rings

2016-08-27 Thread Chris Wilson
When originally conceived the kernel context was just a plain wrapper
around the logical HW context. Since then it has evolved into a much
grander partitioning of driver state between different clients, it is
the basis for resource tracking and accountability and has an identical
role to the GL context in providing robustness between clients.
Currently mesa is forced to use a shared context (shared address space,
shared resources) for all non-RCS batches, undermining context
segregation. With the ever increasing importance of the segregation of
driver state, the restriction has been relaxed and now we do a quick
probe from mesa and use the GL context everywhere, see kernel commit
f7978a0c581a ("drm/i915: Allow the user to pass a context to any ring")

Signed-off-by: Chris Wilson 
Cc: Kenneth Graunke 
Cc: Daniel Vetter 
---
 src/mesa/drivers/dri/i965/brw_context.c   |  2 ++
 src/mesa/drivers/dri/i965/brw_context.h   |  1 +
 src/mesa/drivers/dri/i965/intel_batchbuffer.c | 13 ++---
 src/mesa/drivers/dri/i965/intel_screen.c  | 23 +++
 src/mesa/drivers/dri/i965/intel_screen.h  |  1 +
 5 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index 888097d..2145ab8 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -1034,6 +1034,8 @@ brwCreateContext(gl_api api,
  intelDestroyContext(driContextPriv);
  return false;
   }
+  if (brw->intelScreen->has_xcs_contexts)
+ brw->hw_ctx_xcs = brw->hw_ctx;
}
 
if (brw_init_pipe_control(brw, devinfo)) {
diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
b/src/mesa/drivers/dri/i965/brw_context.h
index 1a4efa3..4e6044c 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -773,6 +773,7 @@ struct brw_context
dri_bufmgr *bufmgr;
 
drm_intel_context *hw_ctx;
+   drm_intel_context *hw_ctx_xcs;
 
/** BO for post-sync nonzero writes for gen6 workaround. */
drm_intel_bo *workaround_bo;
diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c 
b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
index caa33f8..96bc680 100644
--- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
@@ -337,14 +337,18 @@ do_flush_locked(struct brw_context *brw)
}
 
if (!brw->intelScreen->no_hw) {
+  drm_intel_context *ctx;
   int flags;
 
   if (brw->gen >= 6 && batch->ring == BLT_RING) {
+ ctx = brw->hw_ctx_xcs;
  flags = I915_EXEC_BLT;
   } else {
+ ctx = brw->hw_ctx;
  flags = I915_EXEC_RENDER |
 (brw->use_resource_streamer ? I915_EXEC_RESOURCE_STREAMER : 0);
   }
+
   if (batch->needs_sol_reset)
 flags |= I915_EXEC_GEN7_SOL_RESET;
 
@@ -352,13 +356,8 @@ do_flush_locked(struct brw_context *brw)
  if (unlikely(INTEL_DEBUG & DEBUG_AUB))
 brw_annotate_aub(brw);
 
-if (brw->hw_ctx == NULL || batch->ring != RENDER_RING) {
-ret = drm_intel_bo_mrb_exec(batch->bo, 4 * USED_BATCH(*batch),
-NULL, 0, 0, flags);
-} else {
-   ret = drm_intel_gem_bo_context_exec(batch->bo, brw->hw_ctx,
-4 * USED_BATCH(*batch), flags);
-}
+ ret = drm_intel_gem_bo_context_exec(batch->bo, ctx,
+ 4 * USED_BATCH(*batch), flags);
   }
 
   throttle(brw);
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c 
b/src/mesa/drivers/dri/i965/intel_screen.c
index 84977a7..a2ae83d 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -1129,6 +1129,28 @@ intelDestroyBuffer(__DRIdrawable * driDrawPriv)
 _mesa_reference_framebuffer(&fb, NULL);
 }
 
+static bool
+intel_detect_contexts_blt(struct intel_screen *intelScreen)
+{
+   struct drm_i915_gem_execbuffer2 execbuf;
+   struct drm_i915_gem_exec_object2 exec;
+   int fd = intelScreen->driScrnPriv->fd;
+   int err;
+
+   memset(&exec, 0, sizeof(exec));
+   memset(&execbuf, 0, sizeof(execbuf));
+   execbuf.buffers_ptr = (uintptr_t)&exec;
+   execbuf.buffer_count = 1;
+   execbuf.flags = I915_EXEC_BLT;
+   execbuf.rsvd1 = 0xu;
+
+   err = 0;
+   if (drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf))
+  err = errno;
+
+   return err == ENOENT;
+}
+
 static void
 intel_detect_sseu(struct intel_screen *intelScreen)
 {
@@ -1618,6 +1640,7 @@ __DRIconfig **intelInitScreen2(__DRIscreen *psp)
   intelScreen->max_gtt_map_object_size = gtt_size / 4;
}
 
+   intelScreen->has_xcs_contexts = intel_detect_contexts_blt(intelScreen);
intelScreen->hw_has_swizzling = intel_detect_swizzling(intelScreen);
intelScreen->hw_has_timestamp = intel_detect_timestamp(intelScreen);
 
diff --git a/src/mesa/drivers/dri/i965

[Mesa-dev] [PATCH 4/4] gallium: Use enum pipe_shader_type in set_shader_images()

2016-08-27 Thread Kai Wasserbäch
Signed-off-by: Kai Wasserbäch 
---
 src/gallium/auxiliary/cso_cache/cso_context.c | 3 ++-
 src/gallium/auxiliary/cso_cache/cso_context.h | 3 ++-
 src/gallium/drivers/ddebug/dd_context.c   | 3 ++-
 src/gallium/drivers/ilo/ilo_state.c   | 2 +-
 src/gallium/drivers/nouveau/nvc0/nvc0_state.c | 3 ++-
 src/gallium/drivers/radeonsi/si_descriptors.c | 3 ++-
 src/gallium/drivers/softpipe/sp_state_image.c | 2 +-
 src/gallium/drivers/trace/tr_context.c| 2 +-
 src/gallium/include/pipe/p_context.h  | 3 ++-
 src/mesa/state_tracker/st_atom_image.c| 2 +-
 10 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c 
b/src/gallium/auxiliary/cso_cache/cso_context.c
index 5e6b36e..127e071 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -1360,7 +1360,8 @@ cso_restore_fragment_sampler_views(struct cso_context 
*ctx)
 
 
 void
-cso_set_shader_images(struct cso_context *ctx, unsigned shader_stage,
+cso_set_shader_images(struct cso_context *ctx,
+  enum pipe_shader_type shader_stage,
   unsigned start, unsigned count,
   struct pipe_image_view *images)
 {
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h 
b/src/gallium/auxiliary/cso_cache/cso_context.h
index 27863f4..29e5e33 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.h
+++ b/src/gallium/auxiliary/cso_cache/cso_context.h
@@ -196,7 +196,8 @@ cso_set_sampler_views(struct cso_context *cso,
 /* shader images */
 
 void
-cso_set_shader_images(struct cso_context *cso, unsigned shader_stage,
+cso_set_shader_images(struct cso_context *cso,
+  enum pipe_shader_type shader_stage,
   unsigned start, unsigned count,
   struct pipe_image_view *views);
 
diff --git a/src/gallium/drivers/ddebug/dd_context.c 
b/src/gallium/drivers/ddebug/dd_context.c
index 50edfd7..4bcbbff 100644
--- a/src/gallium/drivers/ddebug/dd_context.c
+++ b/src/gallium/drivers/ddebug/dd_context.c
@@ -521,7 +521,8 @@ dd_context_set_sampler_views(struct pipe_context *_pipe,
 }
 
 static void
-dd_context_set_shader_images(struct pipe_context *_pipe, unsigned shader,
+dd_context_set_shader_images(struct pipe_context *_pipe,
+ enum pipe_shader_type shader,
  unsigned start, unsigned num,
  const struct pipe_image_view *views)
 {
diff --git a/src/gallium/drivers/ilo/ilo_state.c 
b/src/gallium/drivers/ilo/ilo_state.c
index 0ae32c7..95b292a 100644
--- a/src/gallium/drivers/ilo/ilo_state.c
+++ b/src/gallium/drivers/ilo/ilo_state.c
@@ -1853,7 +1853,7 @@ ilo_set_sampler_views(struct pipe_context *pipe, enum 
pipe_shader_type shader,
 }
 
 static void
-ilo_set_shader_images(struct pipe_context *pipe, unsigned shader,
+ilo_set_shader_images(struct pipe_context *pipe, enum pipe_shader_type shader,
   unsigned start, unsigned count,
   const struct pipe_image_view *views)
 {
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c 
b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c
index ee1e184..6aaada4 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c
@@ -1344,7 +1344,8 @@ nvc0_bind_images_range(struct nvc0_context *nvc0, const 
unsigned s,
 }
 
 static void
-nvc0_set_shader_images(struct pipe_context *pipe, unsigned shader,
+nvc0_set_shader_images(struct pipe_context *pipe,
+   enum pipe_shader_type shader,
unsigned start, unsigned nr,
const struct pipe_image_view *images)
 {
diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index dfd0607..eb0e5fa 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -704,7 +704,8 @@ static void si_set_shader_image(struct si_context *ctx,
 }
 
 static void
-si_set_shader_images(struct pipe_context *pipe, unsigned shader,
+si_set_shader_images(struct pipe_context *pipe,
+enum pipe_shader_type shader,
 unsigned start_slot, unsigned count,
 const struct pipe_image_view *views)
 {
diff --git a/src/gallium/drivers/softpipe/sp_state_image.c 
b/src/gallium/drivers/softpipe/sp_state_image.c
index c5ef466..38e5cd4 100644
--- a/src/gallium/drivers/softpipe/sp_state_image.c
+++ b/src/gallium/drivers/softpipe/sp_state_image.c
@@ -27,7 +27,7 @@
 #include "sp_buffer.h"
 
 static void softpipe_set_shader_images(struct pipe_context *pipe,
-   unsigned shader,
+   enum pipe_shader_type shader,
unsigned start,
unsigned num,
  

[Mesa-dev] [PATCH 2/4] gallium: Use enum pipe_shader_type in set_sampler_views()

2016-08-27 Thread Kai Wasserbäch
Signed-off-by: Kai Wasserbäch 
---
 src/gallium/auxiliary/cso_cache/cso_context.c | 2 +-
 src/gallium/auxiliary/cso_cache/cso_context.h | 2 +-
 src/gallium/auxiliary/draw/draw_context.c | 4 ++--
 src/gallium/auxiliary/draw/draw_context.h | 4 ++--
 src/gallium/auxiliary/draw/draw_pipe_aaline.c | 3 ++-
 src/gallium/auxiliary/draw/draw_pipe_pstipple.c   | 9 +
 src/gallium/drivers/ddebug/dd_context.c   | 3 ++-
 src/gallium/drivers/freedreno/a4xx/fd4_texture.c  | 2 +-
 src/gallium/drivers/freedreno/freedreno_texture.c | 2 +-
 src/gallium/drivers/freedreno/freedreno_texture.h | 3 ++-
 src/gallium/drivers/i915/i915_state.c | 2 +-
 src/gallium/drivers/ilo/ilo_state.c   | 5 -
 src/gallium/drivers/llvmpipe/lp_state_sampler.c   | 2 +-
 src/gallium/drivers/noop/noop_state.c | 3 ++-
 src/gallium/drivers/nouveau/nv30/nv30_fragtex.c   | 2 +-
 src/gallium/drivers/nouveau/nv50/nv50_state.c | 2 +-
 src/gallium/drivers/nouveau/nvc0/nvc0_state.c | 2 +-
 src/gallium/drivers/r300/r300_state.c | 3 ++-
 src/gallium/drivers/r600/r600_state_common.c  | 3 ++-
 src/gallium/drivers/radeonsi/si_descriptors.c | 2 +-
 src/gallium/drivers/rbug/rbug_context.c   | 2 +-
 src/gallium/drivers/softpipe/sp_state.h   | 2 +-
 src/gallium/drivers/softpipe/sp_state_sampler.c   | 2 +-
 src/gallium/drivers/svga/svga_pipe_sampler.c  | 2 +-
 src/gallium/drivers/swr/swr_state.cpp | 2 +-
 src/gallium/drivers/trace/tr_context.c| 2 +-
 src/gallium/drivers/vc4/vc4_state.c   | 5 +++--
 src/gallium/drivers/virgl/virgl_context.c | 2 +-
 src/gallium/include/pipe/p_context.h  | 3 ++-
 src/mesa/state_tracker/st_atom_constbuf.c | 2 +-
 src/mesa/state_tracker/st_atom_texture.c  | 2 +-
 src/mesa/state_tracker/st_context.h   | 2 +-
 src/mesa/state_tracker/st_glsl_to_nir.cpp | 2 +-
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp| 6 +++---
 34 files changed, 54 insertions(+), 42 deletions(-)

diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c 
b/src/gallium/auxiliary/cso_cache/cso_context.c
index 6ffcce4..5e6b36e 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -1284,7 +1284,7 @@ cso_restore_fragment_samplers(struct cso_context *ctx)
 
 void
 cso_set_sampler_views(struct cso_context *ctx,
-  unsigned shader_stage,
+  enum pipe_shader_type shader_stage,
   unsigned count,
   struct pipe_sampler_view **views)
 {
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h 
b/src/gallium/auxiliary/cso_cache/cso_context.h
index 5c9cb5a..27863f4 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.h
+++ b/src/gallium/auxiliary/cso_cache/cso_context.h
@@ -188,7 +188,7 @@ void cso_restore_state(struct cso_context *cso);
 
 void
 cso_set_sampler_views(struct cso_context *cso,
-  unsigned shader_stage,
+  enum pipe_shader_type shader_stage,
   unsigned count,
   struct pipe_sampler_view **views);
 
diff --git a/src/gallium/auxiliary/draw/draw_context.c 
b/src/gallium/auxiliary/draw/draw_context.c
index 6305761..56abcff 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -964,7 +964,7 @@ draw_set_mapped_so_targets(struct draw_context *draw,
 
 void
 draw_set_sampler_views(struct draw_context *draw,
-   unsigned shader_stage,
+   enum pipe_shader_type shader_stage,
struct pipe_sampler_view **views,
unsigned num)
 {
@@ -985,7 +985,7 @@ draw_set_sampler_views(struct draw_context *draw,
 
 void
 draw_set_samplers(struct draw_context *draw,
-  unsigned shader_stage,
+  enum pipe_shader_type shader_stage,
   struct pipe_sampler_state **samplers,
   unsigned num)
 {
diff --git a/src/gallium/auxiliary/draw/draw_context.h 
b/src/gallium/auxiliary/draw/draw_context.h
index 9167ffd..145fc2e 100644
--- a/src/gallium/auxiliary/draw/draw_context.h
+++ b/src/gallium/auxiliary/draw/draw_context.h
@@ -167,12 +167,12 @@ draw_buffer(struct draw_context *draw,
 
 void
 draw_set_sampler_views(struct draw_context *draw,
-   unsigned shader_stage,
+   enum pipe_shader_type shader_stage,
struct pipe_sampler_view **views,
unsigned num);
 void
 draw_set_samplers(struct draw_context *draw,
-  unsigned shader_stage,
+  enum pipe_shader_type shader_stage,
   struct pipe_sampler_state **samplers,
   unsigned num);
 
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c 
b/src/gallium/auxiliary/draw/

[Mesa-dev] [PATCH 3/4] gallium: Use enum pipe_shader_type in set_shader_buffers()

2016-08-27 Thread Kai Wasserbäch
Signed-off-by: Kai Wasserbäch 
---
 src/gallium/drivers/nouveau/nvc0/nvc0_state.c | 2 +-
 src/gallium/drivers/radeonsi/si_descriptors.c | 8 +---
 src/gallium/drivers/softpipe/sp_state_image.c | 2 +-
 src/gallium/drivers/trace/tr_context.c| 2 +-
 src/gallium/include/pipe/p_context.h  | 3 ++-
 src/mesa/state_tracker/st_atom_atomicbuf.c| 2 +-
 src/mesa/state_tracker/st_atom_storagebuf.c   | 2 +-
 7 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c 
b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c
index c9b0e3f..ee1e184 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_state.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_state.c
@@ -1409,7 +1409,7 @@ nvc0_bind_buffers_range(struct nvc0_context *nvc0, const 
unsigned t,
 
 static void
 nvc0_set_shader_buffers(struct pipe_context *pipe,
-unsigned shader,
+enum pipe_shader_type shader,
 unsigned start, unsigned nr,
 const struct pipe_shader_buffer *buffers)
 {
diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c 
b/src/gallium/drivers/radeonsi/si_descriptors.c
index 573c8a8..dfd0607 100644
--- a/src/gallium/drivers/radeonsi/si_descriptors.c
+++ b/src/gallium/drivers/radeonsi/si_descriptors.c
@@ -1060,19 +1060,21 @@ static void si_pipe_set_constant_buffer(struct 
pipe_context *ctx,
 /* SHADER BUFFERS */
 
 static unsigned
-si_shader_buffer_descriptors_idx(unsigned shader)
+si_shader_buffer_descriptors_idx(enum pipe_shader_type shader)
 {
return SI_DESCS_FIRST_SHADER + shader * SI_NUM_SHADER_DESCS +
   SI_SHADER_DESCS_SHADER_BUFFERS;
 }
 
 static struct si_descriptors *
-si_shader_buffer_descriptors(struct si_context *sctx, unsigned shader)
+si_shader_buffer_descriptors(struct si_context *sctx,
+ enum pipe_shader_type shader)
 {
return &sctx->descriptors[si_shader_buffer_descriptors_idx(shader)];
 }
 
-static void si_set_shader_buffers(struct pipe_context *ctx, unsigned shader,
+static void si_set_shader_buffers(struct pipe_context *ctx,
+ enum pipe_shader_type shader,
  unsigned start_slot, unsigned count,
  const struct pipe_shader_buffer *sbuffers)
 {
diff --git a/src/gallium/drivers/softpipe/sp_state_image.c 
b/src/gallium/drivers/softpipe/sp_state_image.c
index 553a76a..c5ef466 100644
--- a/src/gallium/drivers/softpipe/sp_state_image.c
+++ b/src/gallium/drivers/softpipe/sp_state_image.c
@@ -53,7 +53,7 @@ static void softpipe_set_shader_images(struct pipe_context 
*pipe,
 }
 
 static void softpipe_set_shader_buffers(struct pipe_context *pipe,
-unsigned shader,
+enum pipe_shader_type shader,
 unsigned start,
 unsigned num,
 const struct pipe_shader_buffer 
*buffers)
diff --git a/src/gallium/drivers/trace/tr_context.c 
b/src/gallium/drivers/trace/tr_context.c
index a648297..61b69c2 100644
--- a/src/gallium/drivers/trace/tr_context.c
+++ b/src/gallium/drivers/trace/tr_context.c
@@ -1711,7 +1711,7 @@ trace_context_set_tess_state(struct pipe_context 
*_context,
 
 
 static void trace_context_set_shader_buffers(struct pipe_context *_context,
- unsigned shader,
+ enum pipe_shader_type shader,
  unsigned start, unsigned nr,
  const struct pipe_shader_buffer 
*buffers)
 {
diff --git a/src/gallium/include/pipe/p_context.h 
b/src/gallium/include/pipe/p_context.h
index b74679d..bea1924 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -314,7 +314,8 @@ struct pipe_context {
 *   unless it's NULL, in which case no buffers will
 *   be bound.
 */
-   void (*set_shader_buffers)(struct pipe_context *, unsigned shader,
+   void (*set_shader_buffers)(struct pipe_context *,
+  enum pipe_shader_type shader,
   unsigned start_slot, unsigned count,
   const struct pipe_shader_buffer *buffers);
 
diff --git a/src/mesa/state_tracker/st_atom_atomicbuf.c 
b/src/mesa/state_tracker/st_atom_atomicbuf.c
index 7dde76a..f48ae61 100644
--- a/src/mesa/state_tracker/st_atom_atomicbuf.c
+++ b/src/mesa/state_tracker/st_atom_atomicbuf.c
@@ -43,7 +43,7 @@
 static void
 st_bind_atomics(struct st_context *st,
 struct gl_shader_program *prog,
-unsigned shader_type)
+enum pipe_shader_type shader_type)
 {
unsigned i;
 
diff --git a/src/mesa/state_tracker/st_atom_storagebuf.c 
b/src/

[Mesa-dev] [PATCH 0/4] gallium clean-up (unsigned to enum pipe_shader_type)

2016-08-27 Thread Kai Wasserbäch
Hey everybody,
here is the complete series to switch from "unsigned shader" to
"enum pipe_shader_type" in the functions defined in p_context.h.

Please review and – if this series gets accepted – commit it for me, since I
do not have access for that.
Patch 1 already carries the R-b by Samuel.

All patches survived a compile run and 3D is still working on my
radeonsi-powered ASIC. ;-)

Cheers,
Kai

P.S.: By the way: there some other functions like get_shader_param, which also
could use this treatment. Not sure if I get around to this soon.


Kai Wasserbäch (4):
  gallium: Use enum pipe_shader_type in bind_sampler_states() (v2)
  gallium: Use enum pipe_shader_type in set_sampler_views()
  gallium: Use enum pipe_shader_type in set_shader_buffers()
  gallium: Use enum pipe_shader_type in set_shader_images()

 src/gallium/auxiliary/cso_cache/cso_context.c | 12 +++-
 src/gallium/auxiliary/cso_cache/cso_context.h | 10 ++
 src/gallium/auxiliary/draw/draw_context.c |  4 ++--
 src/gallium/auxiliary/draw/draw_context.h |  4 ++--
 src/gallium/auxiliary/draw/draw_pipe_aaline.c | 12 
 src/gallium/auxiliary/draw/draw_pipe_pstipple.c   | 16 +---
 src/gallium/drivers/ddebug/dd_context.c   |  9 ++---
 src/gallium/drivers/freedreno/a2xx/fd2_texture.c  |  2 +-
 src/gallium/drivers/freedreno/a3xx/fd3_texture.c  |  2 +-
 src/gallium/drivers/freedreno/a4xx/fd4_texture.c  |  4 ++--
 src/gallium/drivers/freedreno/freedreno_texture.c |  4 ++--
 src/gallium/drivers/freedreno/freedreno_texture.h |  3 ++-
 src/gallium/drivers/i915/i915_state.c |  5 +++--
 src/gallium/drivers/ilo/ilo_state.c   | 10 +++---
 src/gallium/drivers/llvmpipe/lp_state_sampler.c   |  4 ++--
 src/gallium/drivers/noop/noop_state.c |  6 --
 src/gallium/drivers/nouveau/nv30/nv30_fragtex.c   |  2 +-
 src/gallium/drivers/nouveau/nv30/nv30_texture.c   |  5 -
 src/gallium/drivers/nouveau/nv50/nv50_state.c |  7 +--
 src/gallium/drivers/nouveau/nvc0/nvc0_state.c | 18 --
 src/gallium/drivers/r300/r300_state.c |  5 +++--
 src/gallium/drivers/r600/r600_state_common.c  |  5 +++--
 src/gallium/drivers/radeonsi/si_descriptors.c | 16 ++--
 src/gallium/drivers/rbug/rbug_context.c   |  5 +++--
 src/gallium/drivers/softpipe/sp_state.h   |  2 +-
 src/gallium/drivers/softpipe/sp_state_image.c |  4 ++--
 src/gallium/drivers/softpipe/sp_state_sampler.c   |  4 ++--
 src/gallium/drivers/svga/svga_pipe_sampler.c  |  4 ++--
 src/gallium/drivers/swr/swr_state.cpp |  4 ++--
 src/gallium/drivers/trace/tr_context.c|  8 
 src/gallium/drivers/vc4/vc4_state.c   |  7 ---
 src/gallium/drivers/virgl/virgl_context.c |  5 +++--
 src/gallium/include/pipe/p_context.h  | 14 +-
 src/mesa/state_tracker/st_atom_atomicbuf.c|  2 +-
 src/mesa/state_tracker/st_atom_constbuf.c |  2 +-
 src/mesa/state_tracker/st_atom_image.c|  2 +-
 src/mesa/state_tracker/st_atom_sampler.c  |  2 +-
 src/mesa/state_tracker/st_atom_storagebuf.c   |  2 +-
 src/mesa/state_tracker/st_atom_texture.c  |  2 +-
 src/mesa/state_tracker/st_context.h   |  2 +-
 src/mesa/state_tracker/st_glsl_to_nir.cpp |  2 +-
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp|  6 +++---
 42 files changed, 145 insertions(+), 99 deletions(-)

-- 
2.9.3

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


[Mesa-dev] [PATCH 1/4] gallium: Use enum pipe_shader_type in bind_sampler_states() (v2)

2016-08-27 Thread Kai Wasserbäch
v1 → v2:
 - Fixed indentation (noted by Brian Paul)
 - Removed second assert from nouveau's switch statements (suggested by
   Brian Paul)

Reviewed-by: Samuel Pitoiset 
Signed-off-by: Kai Wasserbäch 
---
 src/gallium/auxiliary/cso_cache/cso_context.c |  7 ---
 src/gallium/auxiliary/cso_cache/cso_context.h |  5 +++--
 src/gallium/auxiliary/draw/draw_pipe_aaline.c |  9 ++---
 src/gallium/auxiliary/draw/draw_pipe_pstipple.c   |  7 ---
 src/gallium/drivers/ddebug/dd_context.c   |  3 ++-
 src/gallium/drivers/freedreno/a2xx/fd2_texture.c  |  2 +-
 src/gallium/drivers/freedreno/a3xx/fd3_texture.c  |  2 +-
 src/gallium/drivers/freedreno/a4xx/fd4_texture.c  |  2 +-
 src/gallium/drivers/freedreno/freedreno_texture.c |  2 +-
 src/gallium/drivers/i915/i915_state.c |  3 ++-
 src/gallium/drivers/ilo/ilo_state.c   |  3 ++-
 src/gallium/drivers/llvmpipe/lp_state_sampler.c   |  2 +-
 src/gallium/drivers/noop/noop_state.c |  3 ++-
 src/gallium/drivers/nouveau/nv30/nv30_texture.c   |  5 -
 src/gallium/drivers/nouveau/nv50/nv50_state.c |  5 -
 src/gallium/drivers/nouveau/nvc0/nvc0_state.c | 11 ---
 src/gallium/drivers/r300/r300_state.c |  2 +-
 src/gallium/drivers/r600/r600_state_common.c  |  2 +-
 src/gallium/drivers/radeonsi/si_descriptors.c |  3 ++-
 src/gallium/drivers/rbug/rbug_context.c   |  3 ++-
 src/gallium/drivers/softpipe/sp_state_sampler.c   |  2 +-
 src/gallium/drivers/svga/svga_pipe_sampler.c  |  2 +-
 src/gallium/drivers/swr/swr_state.cpp |  2 +-
 src/gallium/drivers/trace/tr_context.c|  2 +-
 src/gallium/drivers/vc4/vc4_state.c   |  2 +-
 src/gallium/drivers/virgl/virgl_context.c |  3 ++-
 src/gallium/include/pipe/p_context.h  |  5 +++--
 src/mesa/state_tracker/st_atom_sampler.c  |  2 +-
 28 files changed, 63 insertions(+), 38 deletions(-)

diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c 
b/src/gallium/auxiliary/cso_cache/cso_context.c
index 4a54cff..6ffcce4 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -316,7 +316,7 @@ void cso_destroy_context( struct cso_context *ctx )
  static struct pipe_sampler_view *views[PIPE_MAX_SHADER_SAMPLER_VIEWS] 
= { NULL };
  static void *zeros[PIPE_MAX_SAMPLERS] = { NULL };
  struct pipe_screen *scr = ctx->pipe->screen;
- unsigned sh;
+ enum pipe_shader_type sh;
  for (sh = 0; sh < PIPE_SHADER_TYPES; sh++) {
 int maxsam = scr->get_shader_param(scr, sh,

PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS);
@@ -1207,7 +1207,8 @@ cso_single_sampler(struct cso_context *ctx, unsigned 
shader_stage,
  * Send staged sampler state to the driver.
  */
 void
-cso_single_sampler_done(struct cso_context *ctx, unsigned shader_stage)
+cso_single_sampler_done(struct cso_context *ctx,
+enum pipe_shader_type shader_stage)
 {
struct sampler_info *info = &ctx->samplers[shader_stage];
const unsigned old_nr_samplers = info->nr_samplers;
@@ -1233,7 +1234,7 @@ cso_single_sampler_done(struct cso_context *ctx, unsigned 
shader_stage)
  */
 enum pipe_error
 cso_set_samplers(struct cso_context *ctx,
- unsigned shader_stage,
+ enum pipe_shader_type shader_stage,
  unsigned nr,
  const struct pipe_sampler_state **templates)
 {
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h 
b/src/gallium/auxiliary/cso_cache/cso_context.h
index a4309c7..5c9cb5a 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.h
+++ b/src/gallium/auxiliary/cso_cache/cso_context.h
@@ -60,7 +60,7 @@ enum pipe_error cso_set_rasterizer( struct cso_context *cso,
 
 enum pipe_error
 cso_set_samplers(struct cso_context *cso,
- unsigned shader_stage,
+ enum pipe_shader_type shader_stage,
  unsigned count,
  const struct pipe_sampler_state **states);
 
@@ -73,7 +73,8 @@ cso_single_sampler(struct cso_context *cso, unsigned 
shader_stage,
unsigned idx, const struct pipe_sampler_state *states);
 
 void
-cso_single_sampler_done(struct cso_context *cso, unsigned shader_stage);
+cso_single_sampler_done(struct cso_context *cso,
+enum pipe_shader_type shader_stage);
 
 
 enum pipe_error cso_set_vertex_elements(struct cso_context *ctx,
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c 
b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
index a5f0723..1ea77da 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
@@ -118,10 +118,12 @@ struct aaline_stage
void (*driver_bind_fs_state)(struct pipe_context *, void *);
void (*driver_delete_fs_state)(struct pipe_context *, void *);
 
-   void (*driver_bind_sampler_states)(s

Re: [Mesa-dev] [PATCH] gallium: Use enum pipe_shader_type in bind_sampler_states()

2016-08-27 Thread Kai Wasserbäch
Hey Samuel,
Samuel Pitoiset wrote on 26.08.2016 20:22:
> On 08/26/2016 04:17 PM, Kai Wasserbäch wrote:
>> Hey Samuel,
>> Samuel Pitoiset wrote on 26.08.2016 15:54:
>>> On 08/26/2016 01:58 PM, Kai Wasserbäch wrote:
 [...]
 diff --git a/src/gallium/drivers/nouveau/nv30/nv30_texture.c
 b/src/gallium/drivers/nouveau/nv30/nv30_texture.c
 index 4f4f87e..dc1a476 100644
 --- a/src/gallium/drivers/nouveau/nv30/nv30_texture.c
 +++ b/src/gallium/drivers/nouveau/nv30/nv30_texture.c
 @@ -188,7 +188,7 @@ nv30_sampler_state_delete(struct pipe_context *pipe, 
 void
 *hwcso)

  static void
  nv30_bind_sampler_states(struct pipe_context *pipe,
 - unsigned shader, unsigned start_slot,
 + enum pipe_shader_type shader, unsigned 
 start_slot,
   unsigned num_samplers, void **samplers)
  {
 switch (shader) {
 @@ -198,6 +198,10 @@ nv30_bind_sampler_states(struct pipe_context *pipe,
 case PIPE_SHADER_FRAGMENT:
nv30_fragtex_sampler_states_bind(pipe, num_samplers, samplers);
break;
 +   default:
 +  assert(shader <= PIPE_SHADER_TYPES);
 +  assert(!"invalid/unhandled type");
>>>
>>> assert(!"invalid PIPE_SHADER type"); is enough here.
>>> Please apply the same change for nv50 and nvc0 as well.
>>
>> Is v2 – with a slightly different assert message – ok then?
> 
> Yeah, I wouldn't worry about it, it's fine by me.
> 
> Just make sure it compiles, it should but who knows. :)
> 
> Reviewed-by: Samuel Pitoiset 

thanks for the review! I've sent the complete series and would appreciate
further R-bs (and the subsequent commit). ;-)

Cheers,
Kai



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


Re: [Mesa-dev] [PATCH] gallium: Use enum pipe_shader_type in bind_sampler_states() (v2)

2016-08-27 Thread Kai Wasserbäch
Hey Michael,
Michael Schellenberger wrote on 26.08.2016 20:19:
> Am 26.08.2016 um 15:23 schrieb Kai Wasserbäch:
>> [...]
>> diff --git a/src/gallium/drivers/nouveau/nv30/nv30_texture.c 
>> b/src/gallium/drivers/nouveau/nv30/nv30_texture.c
>> index 4f4f87e..e5d3db3 100644
>> --- a/src/gallium/drivers/nouveau/nv30/nv30_texture.c
>> +++ b/src/gallium/drivers/nouveau/nv30/nv30_texture.c
>> @@ -188,7 +188,7 @@ nv30_sampler_state_delete(struct pipe_context *pipe, 
>> void *hwcso)
>>  
>>  static void
>>  nv30_bind_sampler_states(struct pipe_context *pipe,
>> - unsigned shader, unsigned start_slot,
>> + enum pipe_shader_type shader, unsigned start_slot,
>>   unsigned num_samplers, void **samplers)
>>  {
>> switch (shader) {
>> @@ -198,6 +198,9 @@ nv30_bind_sampler_states(struct pipe_context *pipe,
>> case PIPE_SHADER_FRAGMENT:
>>nv30_fragtex_sampler_states_bind(pipe, num_samplers, samplers);
>>break;
>> +   default:
>> +  assert(!"unexpected shader type");
>> +  break;
> Shouldnt that be unreachable("unexpected shader type")? The break after
> that shouldnt be necessary. Same for other occurrences.

please see my discussion with Eric
().

And since Samuel seemed to be ok (he gave me his R-b) with the assert() I'm
going to leave it as is. If some other change would require a v3 I could change 
it.

Cheers,
Kai



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


[Mesa-dev] [PATCH, 08/23 V2] glsl: Convert ast_to_hir to the util hash table

2016-08-27 Thread Thomas Helland
V2: Rebase onto the adaption of new hashing functions

Signed-off-by: Thomas Helland 
---
 src/compiler/glsl/ast_to_hir.cpp | 25 ++---
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index 581367b..030343a 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -53,7 +53,7 @@
 #include "glsl_parser_extras.h"
 #include "ast.h"
 #include "compiler/glsl_types.h"
-#include "program/hash_table.h"
+#include "util/hash_table.h"
 #include "main/macros.h"
 #include "main/shaderobj.h"
 #include "ir.h"
@@ -5958,8 +5958,9 @@ ast_switch_statement::hir(exec_list *instructions,
 
state->switch_state.is_switch_innermost = true;
state->switch_state.switch_nesting_ast = this;
-   state->switch_state.labels_ht = hash_table_ctor(0, key_contents,
-   compare_case_value);
+   state->switch_state.labels_ht =
+ _mesa_hash_table_create(NULL, key_contents,
+ compare_case_value);
state->switch_state.previous_default = NULL;
 
/* Initalize is_fallthru state to false.
@@ -6033,7 +6034,7 @@ ast_switch_statement::hir(exec_list *instructions,
   instructions->push_tail(irif);
}
 
-   hash_table_dtor(state->switch_state.labels_ht);
+   _mesa_hash_table_destroy(state->switch_state.labels_ht, NULL);
 
state->switch_state = saved;
 
@@ -6215,20 +6216,22 @@ ast_case_label::hir(exec_list *instructions,
  /* Stuff a dummy value in to allow processing to continue. */
  label_const = new(ctx) ir_constant(0);
   } else {
- ast_expression *previous_label = (ast_expression *)
- hash_table_find(state->switch_state.labels_ht,
- (void *)(uintptr_t)&label_const->value.u[0]);
+ ast_expression *previous_label;
+ hash_entry *entry =
+   _mesa_hash_table_search(state->switch_state.labels_ht,
+ (void *)(uintptr_t)&label_const->value.u[0]);
 
- if (previous_label) {
+ if (entry) {
+previous_label = (ast_expression *) entry->data;
 YYLTYPE loc = this->test_value->get_location();
 _mesa_glsl_error(& loc, state, "duplicate case value");
 
 loc = previous_label->get_location();
 _mesa_glsl_error(& loc, state, "this is the previous case label");
  } else {
-hash_table_insert(state->switch_state.labels_ht,
-  this->test_value,
-  (void *)(uintptr_t)&label_const->value.u[0]);
+_mesa_hash_table_insert(state->switch_state.labels_ht,
+(void 
*)(uintptr_t)&label_const->value.u[0],
+this->test_value);
  }
   }
 
-- 
2.9.3

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


Re: [Mesa-dev] [PATCH 0/4] Resolving Android + desktop OpenGL 'hack'

2016-08-27 Thread Tomasz Figa
On Sat, Aug 27, 2016 at 4:12 AM, Ilia Mirkin  wrote:
> On Fri, Aug 26, 2016 at 3:01 PM, Ryan Houdek  wrote:
>> Most of the Tegra devices (K1 and above) provide desktop GL, except for the
>> Nexus devices which cut out that functionality.
>> Not sure how front buffers differ there, never checked.
>> Dolphin relies on a large amount of extensions, both for performance and
>> proper emulation standpoint..
>> For performance, GLES 3.0, base_vertex, blend_func_extended, and
>> buffer_storage are good enough there.
>> For accurate emulation there are a few features that desktop GL provide that
>> just can't be done in ES (Even 3.2, although it adds a bunch) due to the
>> lack of a feature either in extensions or in core.
>> I don't have a list of all the features it needs in front of me at the
>> moment(Requires grepping the codebase to figure out what all it is using
>> again)
>
> The most recent example that comes to mind is depth clamping instead
> of clipping, available in GL 3.2 (or GL_ARB_depth_clamp), but no GL ES
> extension available for the functionality.

Okay, thanks guys for in depth explanation. Looks like it might be
worth figuring out how to implement front buffers and enable desktop
GL.

In fact I had a patch which did that by keeping a reference to last
back buffer and using it as front, but I doubt it's the correct way,
since a depth buffer after being queued back to the winsys might hit
another client.

Still, I think this series does not really make anything worse. We can
revert some of the patches as soon as someone figures out how handle
front buffers and other are actually useful even if desktop GL gets
enabled, like removing the config postprocessing.

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


Re: [Mesa-dev] [PATCH 03/12] nir: Add a loop analysis pass

2016-08-27 Thread Thomas Helland
2016-08-27 8:03 GMT+02:00 Timothy Arceri :
> This pass detects induction variables and calculates the
> trip count of loops to be used for loop unrolling.
>
> I've removed support for float induction values for now, for the
> simple reason that they don't appear in my shader-db collection,
> and so I don't see it as common enough that we want to pollute the
> pass with this in the initial version.
>
> V2: Rebase, adapt to removal of function overloads
>
> V3: (Timothy Arceri)
>  - don't try to find trip count if loop terminator conditional is a phi
>  - fix trip count for do-while loops
>  - replace conditional type != alu assert with return
>  - disable unrolling of loops with continues
>  - multiple fixes to memory allocation, stop leaking and don't destroy
>structs we want to use for unrolling.
>  - find induction var when copy propagation disabled
>  - fix iteration count bugs when induction var not on RHS of condition
>  - add FIXME for && conditions
>  - calculate trip count for unsigned induction/limit vars
> ---
>  src/compiler/Makefile.sources   |   2 +
>  src/compiler/nir/nir.h  |  75 +++
>  src/compiler/nir/nir_loop_analyze.c | 922 
> 
>  3 files changed, 999 insertions(+)
>  create mode 100644 src/compiler/nir/nir_loop_analyze.c
>
> diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources
> index cfb6359..1bf1c52 100644
> --- a/src/compiler/Makefile.sources
> +++ b/src/compiler/Makefile.sources
> @@ -187,6 +187,8 @@ NIR_FILES = \
> nir/nir_intrinsics.c \
> nir/nir_intrinsics.h \
> nir/nir_liveness.c \
> +   nir/nir_loop_analyze.c \
> +   nir/nir_loop_analyze.h \
> nir/nir_lower_alu_to_scalar.c \
> nir/nir_lower_atomics.c \
> nir/nir_lower_bitmap.c \
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> index e3e06b1..f85e829 100644
> --- a/src/compiler/nir/nir.h
> +++ b/src/compiler/nir/nir.h
> @@ -1541,10 +1541,78 @@ nir_if_last_else_node(nir_if *if_stmt)
> return exec_node_data(nir_cf_node, tail, node);
>  }
>
> +typedef enum {
> +   undefined,
> +   invariant,
> +   basic_induction
> +} nir_loop_variable_type;
> +
> +typedef struct {
> +   /* The ssa_def associated with this info */
> +   nir_ssa_def *def;
> +
> +   /* The type of this ssa_def */
> +   nir_loop_variable_type type;
> +
> +   /* Link to the loop_variable list for the loop */
> +   struct list_head loop_vars_link;
> +
> +   /* A link for a list of invariant variables */
> +   struct list_head invariant_link;
> +
> +   /* A link for a list of induction variables */
> +   struct list_head induction_link;
> +
> +   /* If the ssa-def is constant */
> +   bool is_constant;
> +
> +   bool in_conditional_block;
> +
> +   bool in_nested_loop;
> +} nir_loop_variable;
> +
> +typedef struct {
> +   nir_op alu_op;/* The type of 
> alu-operation*/
> +   nir_loop_variable *alu_def;   /* The def of the 
> alu-operation */
> +   nir_loop_variable *invariant; /* The invariant 
> alu-operand*/
> +   nir_loop_variable *phi;   /* The other alu-operand
> */
> +   nir_loop_variable *def_outside_loop;  /* The phi-src outside the 
> loop */
> +} nir_basic_induction_var;
> +
> +typedef struct {
> +   nir_if *nif;
> +
> +   /* Some more suitable fields like maybe indicated trip-count? */
> +   nir_instr *conditional_instr;

This question here should probably be answered, or removed.

> +
> +   struct list_head loop_terminator_link;
> +} nir_loop_terminator;
> +
> +typedef struct {
> +   /* Loop_variable for all ssa_defs in loop */
> +   struct list_head loop_vars_list;
> +
> +   /* How many times the loop is run (if known) */
> +   uint32_t trip_count;
> +   bool is_trip_count_known;
> +
> +   nir_loop_terminator *limiting_terminator;
> +
> +   /* A list of loop_terminators terminating this loop XXX: These (apart 
> from the limiting terminator) can be dead-code-eliminated */
> +   struct list_head loop_terminator_list;
> +

Line wrapping.

> +   /* The ssa_defs that are invariant */
> +   struct list_head invariant_list;
> +
> +   struct hash_table *var_to_basic_ind;
> +} nir_loop_info;
> +
>  typedef struct {
> nir_cf_node cf_node;
>
> struct exec_list body; /** < list of nir_cf_node */
> +
> +   nir_loop_info *info;
>  } nir_loop;
>
>  static inline nir_cf_node *
> @@ -1569,6 +1637,7 @@ typedef enum {
> nir_metadata_dominance = 0x2,
> nir_metadata_live_ssa_defs = 0x4,
> nir_metadata_not_properly_reset = 0x8,
> +   nir_metadata_loop_analysis = 0x16,
>  } nir_metadata;
>
>  typedef struct {
> @@ -1751,6 +1820,8 @@ typedef struct nir_shader_compiler_options {
>  * information must be inferred from the list of input nir_variables.
>  */
> bool use_interpolated_input_intrinsics;
> +
> +   unsigned max_unroll_iterations;
>  } nir_shader_compiler_options;
>
>  typedef struct ni

[Mesa-dev] [Bug 97260] [bisected] R9 290 low performance in Linux 4.7

2016-08-27 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=97260

--- Comment #32 from Clésio Luiz  ---
Padoka updated (mesa 12.1~git1600826212300.cf7be70~x~padoka0), so I made a test
with kernels 4.7.2 and 4.8 RC3. The problem persist.

The package xserver-xorg-video-ati from his PPA is from 08/24 though.

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


Re: [Mesa-dev] [PATCH 04/12] nir: add is_simple_for_loop() helper

2016-08-27 Thread Thomas Helland
This patch is:

Reviewed-by: Thomas Helland 

2016-08-27 8:03 GMT+02:00 Timothy Arceri :
> This will be used by the loop unroll and lcssa passes.
> ---
>  src/compiler/nir/nir.h | 8 
>  1 file changed, 8 insertions(+)
>
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> index f85e829..6b0a73f 100644
> --- a/src/compiler/nir/nir.h
> +++ b/src/compiler/nir/nir.h
> @@ -2614,6 +2614,14 @@ bool nir_normalize_cubemap_coords(nir_shader *shader);
>
>  void nir_live_ssa_defs_impl(nir_function_impl *impl);
>
> +static inline bool
> +is_simple_for_loop(nir_shader *shader, nir_loop_info *li)
> +{
> +   unsigned max_iter = shader->options->max_unroll_iterations;
> +   return li->is_trip_count_known && li->trip_count < max_iter &&
> +  list_is_singular(&li->loop_terminator_list);
> +}
> +
>  void nir_loop_analyze_impl(nir_function_impl *impl);
>  void nir_loop_analyze(nir_shader *shader);
>
> --
> 2.7.4
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 06/12] nir: don't count removal of lcssa_phi as progress

2016-08-27 Thread Thomas Helland
2016-08-27 8:03 GMT+02:00 Timothy Arceri :
> We generate these in each optimisation pass, counting them
> as progress would cause the loop to run forever.

These are just some random thoughts that I thought I'd share.
It might not make sense at all, and it might be answered in the
patch series, but just thought I'd share them.

It's a bit unfortunate that we generate and remove phi's like this,
but I'm not sure how it could be done in a better way.
LCSSA, I think, is only useful if one is doing loop transformations.
Maybe we could do loop transformations only once on the first iteration
of the optimization loop, and then drop LCSSA transformation after that?
Then again, future optimizations might open possibilities for unrolling,
so this might not be ideal. There's also the issue that one might unroll
a loop bit-by-bit on each iteration of the optimization loop, thereby
completely unrolling a loop even if one only wants do to partial
unrolling due to code size. I haven't studied how you hook the loop
unrolling into the optimization loop, so my comments might not
make sense at all.

> ---
>  src/compiler/nir/nir_opt_remove_phis.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/src/compiler/nir/nir_opt_remove_phis.c 
> b/src/compiler/nir/nir_opt_remove_phis.c
> index ee92fbe..13a139d 100644
> --- a/src/compiler/nir/nir_opt_remove_phis.c
> +++ b/src/compiler/nir/nir_opt_remove_phis.c
> @@ -72,6 +72,7 @@ remove_phis_block(nir_block *block)
>   break;
>
>nir_phi_instr *phi = nir_instr_as_phi(instr);
> +  bool is_lcssa_phi = phi->is_lcssa_phi;
>
>nir_ssa_def *def = NULL;
>nir_alu_instr *mov = NULL;
> @@ -118,6 +119,8 @@ remove_phis_block(nir_block *block)
>nir_instr_remove(instr);
>
>progress = true;
> +  if (!is_lcssa_phi)
> + progress = true;

This does not do what you intended, as you do not remove
the progress = true; line above the if you're inserting.

With that fixed, the patch itself looks good. It's kinda funny
though that things presumable work even though this
patch has no effect, indicating that it is not needed.

> }
>
> return progress;
> --
> 2.7.4
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [Bug 95346] Stellaris - Black/super dark planets

2016-08-27 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=95346

Nelson  changed:

   What|Removed |Added

URL||http://www.memonic.com/user
   ||/pharmacy/id/1Fzdh

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


Re: [Mesa-dev] RFC - Simple loop unrolling in NIR

2016-08-27 Thread Jason Ekstrand
Hey Timothy,

Thanks for working on this!  Looks like you're making pretty good
progress.  I'm going to try and give the series a hard look some time next
week.

On Aug 26, 2016 11:03 PM, "Timothy Arceri" 
wrote:

> This series does the equivalent of the simple unroll in GLSL IR. The
> main difference is that currently it unrolls everything with an
> iteration count < 32, the GLSL IR pass also tries to limit unrolling
> based on the number of nodes it contains but this seemed a little
> simplistic
> so I have left this out for now.
>
> I'm still working on the complex unroll equivalent but hacking the cf in
> NIR is not much fun so I thought I'd send the series as is for now to get
> some feedback. I guess it also my be useful for Vulkan as is.
>
> This series works on ssa defs so for now it's only enabled for Gen8+.
>
> Shader-db results for BDW:
>
> total instructions in shared programs: 8527200 -> 8526827 (-0.00%)
> instructions in affected programs: 50339 -> 49966 (-0.74%)
> helped: 103
> HURT: 89
>
> total cycles in shared programs: 70789034 -> 70756662 (-0.05%)
> cycles in affected programs: 3273418 -> 3241046 (-0.99%)
> helped: 1027
> HURT: 864
>
> total loops in shared programs: 2069 -> 1819 (-12.08%)
> loops in affected programs: 568 -> 318 (-44.01%)
> helped: 522
> HURT: 280
>
> total spills in shared programs: 2212 -> 2212 (0.00%)
> spills in affected programs: 0 -> 0
> helped: 0
> HURT: 0
>
> total fills in shared programs: 1894 -> 1894 (0.00%)
> fills in affected programs: 0 -> 0
> helped: 0
> HURT: 0
>
> LOST:   9
> GAINED: 0
>
>
> Almost all of the HURT programs with increased loop counts are from
> planeshift and basically contain an if () break; a equivalent of complex
> unroll should fix this up.
>
> As for the helped loop counts I'm not entirely sure (haven't checked) why
> the GLSL IR pass is not unrolling them as the ones I've looked at do not
> seem like they should be skipped and seem to produce acceptable output in
> NIR.
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] i915g: Fix typo in i915_translate_instruction()

2016-08-27 Thread Echelon9
From: Rhys Kidd 

Noticed this error in a debug message whilst reviewing
https://bugs.freedesktop.org/show_bug.cgi?id=97477

This patch doesn't go towards fixing that bug, but at
least may clarify future debug output.

Signed-off-by: Rhys Kidd 
---
I don't have the hardware to actually test this, but then again this
is an fix for a typo in a debug output comment ...

Because i915g gets less attention these days, copying a slightly longer
list of developers than usual that have touched this file.

Cc: Stéphane Marchesin 
Cc: Stéphane Marchesin 
Cc: Jakob Bornecrantz 
Cc: Daniel Vetter 
Cc: Kenneth Graunke 
Cc: Brian Paul 

I do not have commit rights to fd.o so after R-B would appreciate if
the reviewer could push to master.

 src/gallium/drivers/i915/i915_fpc_translate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/i915/i915_fpc_translate.c 
b/src/gallium/drivers/i915/i915_fpc_translate.c
index 70016ed..72b9092 100644
--- a/src/gallium/drivers/i915/i915_fpc_translate.c
+++ b/src/gallium/drivers/i915/i915_fpc_translate.c
@@ -585,7 +585,7 @@ i915_translate_instruction(struct i915_fp_compile *p,
   case TGSI_OPCODE_DDX:
   case TGSI_OPCODE_DDY:
   /* XXX We just output 0 here */
-  debug_printf("Punting DDX/DDX\n");
+  debug_printf("Punting DDX/DDY\n");
   src0 = get_result_vector(p, &inst->Dst[0]);
   i915_emit_arith(p,
   A0_MOV,
-- 
2.7.4

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


[Mesa-dev] [PATCH 1/2] r600g: Avoid duplicated initialization of TGSI_OPCODE_DFMA

2016-08-27 Thread Rhys Kidd
As reported by Clang, TGSI_OPCODE_DFMA (defined magic number 118) is
currently initialized twice for Cayman and Evergreen.

When Jan Vesely added double precision FMA opcode it did make sense
to locate it immediately after TGSI_OPCODE_DMAD, although this is
out of order.

This change cleans up the prior magic number definition and ensures
any later reordering of this struct will not create problems.

Prior change was:

  commit 015e2e0fce3eea7884f8df275c2fadc35143a324
  Author: Jan Vesely 
  Date:   Sat Jul 2 16:14:54 2016 -0400

  r600g: Add double precision FMA ops

  Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96782
  Fixes: 54c4d525da7c7fc1e103d7a3e6db015abb132d5d ("r600g: Enable FMA on 
chips that support it")

  Signed-off-by: Jan Vesely 
  Tested-by: James Harvey 
  Signed-off-by: Marek Olšák 

Signed-off-by: Rhys Kidd 
---
 src/gallium/drivers/r600/r600_shader.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_shader.c 
b/src/gallium/drivers/r600/r600_shader.c
index 64aacca..a39301f 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -9210,7 +9210,7 @@ static const struct r600_shader_tgsi_instruction 
eg_shader_tgsi_instruction[] =
[TGSI_OPCODE_BREAKC]= { ALU_OP0_NOP, tgsi_unsupported},
[TGSI_OPCODE_KILL_IF]   = { ALU_OP2_KILLGT, tgsi_kill},  /* conditional 
kill */
[TGSI_OPCODE_END]   = { ALU_OP0_NOP, tgsi_end},  /* aka HALT */
-   [118]   = { ALU_OP0_NOP, tgsi_unsupported},
+   /* Refer below for TGSI_OPCODE_DFMA */
[TGSI_OPCODE_F2I]   = { ALU_OP1_FLT_TO_INT, tgsi_f2i},
[TGSI_OPCODE_IDIV]  = { ALU_OP0_NOP, tgsi_idiv},
[TGSI_OPCODE_IMAX]  = { ALU_OP2_MAX_INT, tgsi_op2},
@@ -9433,7 +9433,7 @@ static const struct r600_shader_tgsi_instruction 
cm_shader_tgsi_instruction[] =
[TGSI_OPCODE_BREAKC]= { ALU_OP0_NOP, tgsi_unsupported},
[TGSI_OPCODE_KILL_IF]   = { ALU_OP2_KILLGT, tgsi_kill},  /* conditional 
kill */
[TGSI_OPCODE_END]   = { ALU_OP0_NOP, tgsi_end},  /* aka HALT */
-   [118]   = { ALU_OP0_NOP, tgsi_unsupported},
+   /* Refer below for TGSI_OPCODE_DFMA */
[TGSI_OPCODE_F2I]   = { ALU_OP1_FLT_TO_INT, tgsi_op2},
[TGSI_OPCODE_IDIV]  = { ALU_OP0_NOP, tgsi_idiv},
[TGSI_OPCODE_IMAX]  = { ALU_OP2_MAX_INT, tgsi_op2},
-- 
2.7.4

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


[Mesa-dev] [PATCH 2/2] r600g: Clean up defined magic numbers for TGSI opcodes

2016-08-27 Thread Rhys Kidd
Small code clean up that removes magic numbers where a TGSI
opcode has been defined.

No functional change expected as each opcode is unsupported on
the respective hardware.

Signed-off-by: Rhys Kidd 
---
 src/gallium/drivers/r600/r600_shader.c | 14 +++---
 src/gallium/include/pipe/p_shader_tokens.h |  1 +
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/r600/r600_shader.c 
b/src/gallium/drivers/r600/r600_shader.c
index a39301f..f7b8495 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -8998,20 +8998,20 @@ static const struct r600_shader_tgsi_instruction 
r600_shader_tgsi_instruction[]
[TGSI_OPCODE_ENDSUB]= { ALU_OP0_NOP, tgsi_unsupported},
[TGSI_OPCODE_TXQ_LZ]= { FETCH_OP_GET_TEXTURE_RESINFO, tgsi_tex},
[TGSI_OPCODE_TXQS]  = { FETCH_OP_GET_NUMBER_OF_SAMPLES, tgsi_tex},
-   [105]   = { ALU_OP0_NOP, tgsi_unsupported},
+   [TGSI_OPCODE_RESQ]  = { ALU_OP0_NOP, tgsi_unsupported},
[106]   = { ALU_OP0_NOP, tgsi_unsupported},
[TGSI_OPCODE_NOP]   = { ALU_OP0_NOP, tgsi_unsupported},
[TGSI_OPCODE_FSEQ]  = { ALU_OP2_SETE_DX10, tgsi_op2},
[TGSI_OPCODE_FSGE]  = { ALU_OP2_SETGE_DX10, tgsi_op2},
[TGSI_OPCODE_FSLT]  = { ALU_OP2_SETGT_DX10, tgsi_op2_swap},
[TGSI_OPCODE_FSNE]  = { ALU_OP2_SETNE_DX10, tgsi_op2_swap},
-   [112]   = { ALU_OP0_NOP, tgsi_unsupported},
+   [TGSI_OPCODE_MEMBAR]= { ALU_OP0_NOP, tgsi_unsupported},
[TGSI_OPCODE_CALLNZ]= { ALU_OP0_NOP, tgsi_unsupported},
[114]   = { ALU_OP0_NOP, tgsi_unsupported},
[TGSI_OPCODE_BREAKC]= { ALU_OP0_NOP, tgsi_loop_breakc},
[TGSI_OPCODE_KILL_IF]   = { ALU_OP2_KILLGT, tgsi_kill},  /* conditional 
kill */
[TGSI_OPCODE_END]   = { ALU_OP0_NOP, tgsi_end},  /* aka HALT */
-   [118]   = { ALU_OP0_NOP, tgsi_unsupported},
+   [TGSI_OPCODE_DFMA]  = { ALU_OP0_NOP, tgsi_unsupported},
[TGSI_OPCODE_F2I]   = { ALU_OP1_FLT_TO_INT, tgsi_op2_trans},
[TGSI_OPCODE_IDIV]  = { ALU_OP0_NOP, tgsi_idiv},
[TGSI_OPCODE_IMAX]  = { ALU_OP2_MAX_INT, tgsi_op2},
@@ -9197,14 +9197,14 @@ static const struct r600_shader_tgsi_instruction 
eg_shader_tgsi_instruction[] =
[TGSI_OPCODE_ENDSUB]= { ALU_OP0_NOP, tgsi_unsupported},
[TGSI_OPCODE_TXQ_LZ]= { FETCH_OP_GET_TEXTURE_RESINFO, tgsi_tex},
[TGSI_OPCODE_TXQS]  = { FETCH_OP_GET_NUMBER_OF_SAMPLES, tgsi_tex},
-   [105]   = { ALU_OP0_NOP, tgsi_unsupported},
+   [TGSI_OPCODE_RESQ]  = { ALU_OP0_NOP, tgsi_unsupported},
[106]   = { ALU_OP0_NOP, tgsi_unsupported},
[TGSI_OPCODE_NOP]   = { ALU_OP0_NOP, tgsi_unsupported},
[TGSI_OPCODE_FSEQ]  = { ALU_OP2_SETE_DX10, tgsi_op2},
[TGSI_OPCODE_FSGE]  = { ALU_OP2_SETGE_DX10, tgsi_op2},
[TGSI_OPCODE_FSLT]  = { ALU_OP2_SETGT_DX10, tgsi_op2_swap},
[TGSI_OPCODE_FSNE]  = { ALU_OP2_SETNE_DX10, tgsi_op2_swap},
-   [112]   = { ALU_OP0_NOP, tgsi_unsupported},
+   [TGSI_OPCODE_MEMBAR]= { ALU_OP0_NOP, tgsi_unsupported},
[TGSI_OPCODE_CALLNZ]= { ALU_OP0_NOP, tgsi_unsupported},
[114]   = { ALU_OP0_NOP, tgsi_unsupported},
[TGSI_OPCODE_BREAKC]= { ALU_OP0_NOP, tgsi_unsupported},
@@ -9420,14 +9420,14 @@ static const struct r600_shader_tgsi_instruction 
cm_shader_tgsi_instruction[] =
[TGSI_OPCODE_ENDSUB]= { ALU_OP0_NOP, tgsi_unsupported},
[TGSI_OPCODE_TXQ_LZ]= { FETCH_OP_GET_TEXTURE_RESINFO, tgsi_tex},
[TGSI_OPCODE_TXQS]  = { FETCH_OP_GET_NUMBER_OF_SAMPLES, tgsi_tex},
-   [105]   = { ALU_OP0_NOP, tgsi_unsupported},
+   [TGSI_OPCODE_RESQ]  = { ALU_OP0_NOP, tgsi_unsupported},
[106]   = { ALU_OP0_NOP, tgsi_unsupported},
[TGSI_OPCODE_NOP]   = { ALU_OP0_NOP, tgsi_unsupported},
[TGSI_OPCODE_FSEQ]  = { ALU_OP2_SETE_DX10, tgsi_op2},
[TGSI_OPCODE_FSGE]  = { ALU_OP2_SETGE_DX10, tgsi_op2},
[TGSI_OPCODE_FSLT]  = { ALU_OP2_SETGT_DX10, tgsi_op2_swap},
[TGSI_OPCODE_FSNE]  = { ALU_OP2_SETNE_DX10, tgsi_op2_swap},
-   [112]   = { ALU_OP0_NOP, tgsi_unsupported},
+   [TGSI_OPCODE_MEMBAR]= { ALU_OP0_NOP, tgsi_unsupported},
[TGSI_OPCODE_CALLNZ]= { ALU_OP0_NOP, tgsi_unsupported},
[114]   = { ALU_OP0_NOP, tgsi_unsupported},
[TGSI_OPCODE_BREAKC]= { ALU_OP0_NOP, tgsi_unsupported},
diff --git a/src/gallium/include/pipe/p_shader_tokens.h 
b/src/gallium/include/pipe/p_shader_tokens.h
index 7621ab9..39ce9ea 100644
--- a/src/gallium/include/pipe/p_shader_tokens.h
+++ b/src/gallium/include/pipe/p_shader_tokens.h
@@ -397,6 +397,7 @@ struct tgsi

[Mesa-dev] [PATCH 0/2] r600g: Pair of small code clean ups with TGSI

2016-08-27 Thread Rhys Kidd
Having run Mesa through Clang on Eric Anholt's Travis harness, these small
code clean ups improve readability of TGSI code in r600g and may avoid
future problems.

Series also can be found at:
https://github.com/Echelon9/mesa/tree/fix/r600g-cleanup-tgsi-opcodes

I don't have the hardware to test this so would appreciated Tested-by's.

I do not have commit rights to fd.o so after R-B would appreciate if
the reviewer(s) could push to master.

Rhys Kidd (2):
  r600g: Avoid duplicated initialization of TGSI_OPCODE_DFMA
  r600g: Clean up defined magic numbers for TGSI opcodes

 src/gallium/drivers/r600/r600_shader.c | 18 +-
 src/gallium/include/pipe/p_shader_tokens.h |  1 +
 2 files changed, 10 insertions(+), 9 deletions(-)

-- 
2.7.4

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


Re: [Mesa-dev] [PATCH] gallium: Use enum pipe_shader_type in bind_sampler_states()

2016-08-27 Thread Jan Vesely
On Fri, 2016-08-26 at 17:25 +0100, Eric Engestrom wrote:
> On Fri, Aug 26, 2016 at 04:21:14PM +0200, Kai Wasserbäch wrote:
> > 
> > Hey Eric,
> > Eric Engestrom wrote on 26.08.2016 15:49:
> > > 
> > > On Fri, Aug 26, 2016 at 03:14:57PM +0200, Kai Wasserbäch wrote:
> > > > 
> > > > Brian Paul wrote on 26.08.2016 14:50:
> > > > > 
> > > > > On 08/26/2016 05:58 AM, Kai Wasserbäch wrote:
> > > > > > 
> > > > > > Cc: Brian Paul 
> > > > > > Signed-off-by: Kai Wasserbäch 
> > > > > > ---
> > > > > > 
> > > > > > Hi Brian,
> > > > > > is this what you had in mind? If so, I was wondering
> > > > > > whether virgl_encode.c
> > > > > > would need to be updated as well. Doesn't seem like it,
> > > > > > since the functions
> > > > > > there map everything to uint32_t or some other standard
> > > > > > type.
> > > > > > 
> > > > > > Another point are the switch statements nouveau uses. To
> > > > > > silence the -Wswitch
> > > > > > warning of GCC I stuck a default case with two asserts at
> > > > > > the end of them. But
> > > > > > maybe it would be better to use an if...else for nv30 and
> > > > > > nv50.
> > > > > I think one assertion is enough.  It's up to the nouveau
> > > > > developers whether they
> > > > > want to do more.
> > > > ok, then I'll go for the generic "unhandled type" assert.
> > > I would've gone with `unreachable()`, since nothing outside the
> > > enum range should ever get in.
> > Do you feel strongly about that and require a v3?
> I don't, it's fine as is.
> 
> > 
> > Personally I think the
> > assert() is better since the function could be called with another
> > enum member
> > value, which still is unhandled by the switch().
> unreachable() still has an assert() (see src/util/macros.h:75)
> The difference is that unreachable() tells the compiler that we won't
> be
> interested in what comes next. If we reach it, we abort with a
> message
> in debug builds, and after that the compiler can do whatever it
> wants,
> e.g. optimise out irrelevant code paths, and obviously it wont warn
> about these code paths anymore, which is often more interesting.

moreover, assert leaves untested codepath with silent failure in
ndebug builds.
In this case it would be better to use unreachable + unhandled enum
values instead of default (so the compiler complains when new shader
types get added, however unlikely that is).

just my 2c,
Jan

> 
> > 
> > 
> > > 
> > > > 
> > > > > 
> > > > > > 
> > > > > > Cheers,
> > > > > > Kai
> > > > > > 
> > > > > > P.S.: If this is the right direction, I can do the
> > > > > > remaining stuff as well.
> > > > > I think there was another person interested so feel free to
> > > > > share the task.
> > > > Eric, I'm sorry I didn't see your message before I had prepared
> > > > this patch and
> > > > sent it. If I should leave the rest alone, just give me a
> > > > shout. Would be
> > > > unfortunate if we did the same task twice.
> > > No worries, I also saw your message after having sent my reply on
> > > Brian's comment, so I'm no better xD
> > > 
> > > I also have other ideas of things I could do, so I'll leave this
> > > "int to enum" task to you :)
> > Ok, I'll prepare the other patches as well. (I'll probably sent
> > them out tomorrow.)
> > 
> > Cheers,
> > Kai
> > 
> 
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


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


Re: [Mesa-dev] [PATCH 1/2] r600g: Avoid duplicated initialization of TGSI_OPCODE_DFMA

2016-08-27 Thread Jan Vesely
On Sat, 2016-08-27 at 12:05 -0400, Rhys Kidd wrote:
> As reported by Clang, TGSI_OPCODE_DFMA (defined magic number 118) is
> currently initialized twice for Cayman and Evergreen.
> When Jan Vesely added double precision FMA opcode it did make sense
> to locate it immediately after TGSI_OPCODE_DMAD, although this is
> out of order.
> 
> This change cleans up the prior magic number definition and ensures
> any later reordering of this struct will not create problems.
> 
> Prior change was:
> 
>   commit 015e2e0fce3eea7884f8df275c2fadc35143a324
>   Author: Jan Vesely 
>   Date:   Sat Jul 2 16:14:54 2016 -0400
> 
>   r600g: Add double precision FMA ops
> 
>   Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96782
>   Fixes: 54c4d525da7c7fc1e103d7a3e6db015abb132d5d ("r600g: Enable
> FMA on chips that support it")
> 
>   Signed-off-by: Jan Vesely 
>   Tested-by: James Harvey 
>   Signed-off-by: Marek Olšák 
> 
> Signed-off-by: Rhys Kidd 

So much for using magic numbers.
Reviewed-by: Jan Vesely 

thanks,
Jan

> ---
>  src/gallium/drivers/r600/r600_shader.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/gallium/drivers/r600/r600_shader.c
> b/src/gallium/drivers/r600/r600_shader.c
> index 64aacca..a39301f 100644
> --- a/src/gallium/drivers/r600/r600_shader.c
> +++ b/src/gallium/drivers/r600/r600_shader.c
> @@ -9210,7 +9210,7 @@ static const struct
> r600_shader_tgsi_instruction eg_shader_tgsi_instruction[] =
>   [TGSI_OPCODE_BREAKC]= { ALU_OP0_NOP,
> tgsi_unsupported},
>   [TGSI_OPCODE_KILL_IF]   = { ALU_OP2_KILLGT,
> tgsi_kill},  /* conditional kill */
>   [TGSI_OPCODE_END]   = { ALU_OP0_NOP, tgsi_end},  /* aka
> HALT */
> - [118]   = { ALU_OP0_NOP,
> tgsi_unsupported},
> + /* Refer below for TGSI_OPCODE_DFMA */
>   [TGSI_OPCODE_F2I]   = { ALU_OP1_FLT_TO_INT, tgsi_f2i},
>   [TGSI_OPCODE_IDIV]  = { ALU_OP0_NOP, tgsi_idiv},
>   [TGSI_OPCODE_IMAX]  = { ALU_OP2_MAX_INT, tgsi_op2},
> @@ -9433,7 +9433,7 @@ static const struct
> r600_shader_tgsi_instruction cm_shader_tgsi_instruction[] =
>   [TGSI_OPCODE_BREAKC]= { ALU_OP0_NOP,
> tgsi_unsupported},
>   [TGSI_OPCODE_KILL_IF]   = { ALU_OP2_KILLGT,
> tgsi_kill},  /* conditional kill */
>   [TGSI_OPCODE_END]   = { ALU_OP0_NOP, tgsi_end},  /* aka
> HALT */
> - [118]   = { ALU_OP0_NOP,
> tgsi_unsupported},
> + /* Refer below for TGSI_OPCODE_DFMA */
>   [TGSI_OPCODE_F2I]   = { ALU_OP1_FLT_TO_INT, tgsi_op2},
>   [TGSI_OPCODE_IDIV]  = { ALU_OP0_NOP, tgsi_idiv},
>   [TGSI_OPCODE_IMAX]  = { ALU_OP2_MAX_INT, tgsi_op2},


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


Re: [Mesa-dev] [PATCH] loader/dri3: Overhaul dri3_update_num_back

2016-08-27 Thread Dieter Nützel

Am 25.08.2016 11:09, schrieb Michel Dänzer:

On 24/08/16 06:35 AM, Eric Anholt wrote:

Michel Dänzer  writes:

On 20/08/16 04:42 AM, Eric Anholt wrote:

Michel Dänzer  writes:


From: Michel Dänzer 

Always use 3 buffers when flipping. With only 2 buffers, we have to 
wait
for a flip to complete (which takes non-0 time even with 
asynchronous
flips) before we can start working on the next frame. We were 
previously
only using 2 buffers for flipping if the X server supports 
asynchronous
flips, even when we're not using asynchronous flips. This could 
result
in bad performance (the referenced bug report is an extreme case, 
where
the inter-frame stalls were preventing the GPU from reaching its 
maximum

clocks).

I couldn't measure any performance boost using 4 buffers with 
flipping.
Performance actually seemed to go down slightly, but that might 
have

been just noise.

Without flipping, a single back buffer is enough for swap interval 
0,

but we need to use 2 back buffers when the swap interval is non-0,
otherwise we have to wait for the swap interval to pass before we 
can
start working on the next frame. This condition was previously 
reversed.


Cc: "12.0 11.2" 
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97260
Signed-off-by: Michel Dänzer 


Reviewed-by: Eric Anholt 


Thanks.


Hello Michel,

found this _before_ your commit, but haven't had time, so...

With this patch Blender at least 2.76b flicker horribly with

'User Preferences...' -> 'Window Draw Method: Automatic'
Switching to:
'Window Draw Method: Tripple Buffer'
fix it.

I'll add this to the related bug if you want.

Greetings,

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


[Mesa-dev] [PATCH] i965/hsw: Enable ARB_ES3_1_compatibility extension

2016-08-27 Thread Jordan Justen
Signed-off-by: Jordan Justen 
Acked-by: Kenneth Graunke 
---
 docs/features.txt| 2 +-
 src/mesa/drivers/dri/i965/intel_extensions.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/docs/features.txt b/docs/features.txt
index 26e8ff7..218fa6c 100644
--- a/docs/features.txt
+++ b/docs/features.txt
@@ -208,7 +208,7 @@ GL 4.4, GLSL 4.40 -- all DONE: i965/gen8+
 
 GL 4.5, GLSL 4.50:
 
-  GL_ARB_ES3_1_compatibilityDONE (i965/gen8+, 
nvc0, radeonsi)
+  GL_ARB_ES3_1_compatibilityDONE (i965/hsw+, nvc0, 
radeonsi)
   GL_ARB_clip_control   DONE (i965, nv50, 
nvc0, r600, radeonsi, llvmpipe, softpipe, swr)
   GL_ARB_conditional_render_invertedDONE (i965, nv50, 
nvc0, r600, radeonsi, llvmpipe, softpipe, swr)
   GL_ARB_cull_distance  DONE (i965, nv50, 
nvc0, llvmpipe, softpipe, swr)
diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c 
b/src/mesa/drivers/dri/i965/intel_extensions.c
index 48822b7..00b68eb 100644
--- a/src/mesa/drivers/dri/i965/intel_extensions.c
+++ b/src/mesa/drivers/dri/i965/intel_extensions.c
@@ -365,7 +365,8 @@ intelInitExtensions(struct gl_context *ctx)
  if ((brw->gen >= 8 || brw->intelScreen->cmd_parser_version >= 5) &&
  ctx->Const.MaxComputeWorkGroupSize[0] >= 1024) {
 ctx->Extensions.ARB_compute_shader = true;
-ctx->Extensions.ARB_ES3_1_compatibility = brw->gen >= 8;
+ctx->Extensions.ARB_ES3_1_compatibility =
+   brw->gen >= 8 || brw->is_haswell;
  }
 
  if (brw->intelScreen->cmd_parser_version >= 2)
-- 
2.8.1

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


[Mesa-dev] [PATCH] mesa: remove OES_shader_io_blocks enable

2016-08-27 Thread Ilia Mirkin
This extension should just be available whenever ES 3.1 is available.
With the new extension verification infrastructure, it will only be
enable-able on a #version 310 es shader, rendering the original reason
for having a separate enable moot.

Signed-off-by: Ilia Mirkin 
---
 src/mesa/drivers/dri/i965/intel_extensions.c | 1 -
 src/mesa/main/extensions_table.h | 4 ++--
 src/mesa/main/mtypes.h   | 1 -
 src/mesa/state_tracker/st_extensions.c   | 6 --
 4 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c 
b/src/mesa/drivers/dri/i965/intel_extensions.c
index 48822b7..3ca30d0 100644
--- a/src/mesa/drivers/dri/i965/intel_extensions.c
+++ b/src/mesa/drivers/dri/i965/intel_extensions.c
@@ -399,7 +399,6 @@ intelInitExtensions(struct gl_context *ctx)
   ctx->Extensions.ARB_gpu_shader_fp64 = true;
   ctx->Extensions.ARB_vertex_attrib_64bit = true;
   ctx->Extensions.OES_geometry_shader = true;
-  ctx->Extensions.OES_shader_io_blocks = true;
   ctx->Extensions.OES_texture_cube_map_array = true;
}
 
diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h
index f4d55c3..fd4eccb 100644
--- a/src/mesa/main/extensions_table.h
+++ b/src/mesa/main/extensions_table.h
@@ -232,7 +232,7 @@ EXT(EXT_separate_shader_objects , dummy_true
 EXT(EXT_separate_specular_color , dummy_true   
  , GLL,  x ,  x ,  x , 1997)
 EXT(EXT_shader_framebuffer_fetch, MESA_shader_framebuffer_fetch
  ,  x ,  x ,  x , ES2, 2013)
 EXT(EXT_shader_integer_mix  , EXT_shader_integer_mix   
  , GLL, GLC,  x ,  30, 2013)
-EXT(EXT_shader_io_blocks, OES_shader_io_blocks 
  ,  x ,  x ,  x ,  31, 2014)
+EXT(EXT_shader_io_blocks, dummy_true   
  ,  x ,  x ,  x ,  31, 2014)
 EXT(EXT_shader_samples_identical, EXT_shader_samples_identical 
  , GLL, GLC,  x ,  31, 2015)
 EXT(EXT_shadow_funcs, ARB_shadow   
  , GLL,  x ,  x ,  x , 2002)
 EXT(EXT_stencil_two_side, EXT_stencil_two_side 
  , GLL,  x ,  x ,  x , 2001)
@@ -359,7 +359,7 @@ EXT(OES_rgb8_rgba8  , dummy_true
 EXT(OES_sample_shading  , OES_sample_variables 
  ,  x ,  x ,  x ,  30, 2014)
 EXT(OES_sample_variables, OES_sample_variables 
  ,  x ,  x ,  x ,  30, 2014)
 EXT(OES_shader_image_atomic , ARB_shader_image_load_store  
  ,  x ,  x ,  x ,  31, 2015)
-EXT(OES_shader_io_blocks, OES_shader_io_blocks 
  ,  x ,  x ,  x ,  31, 2014)
+EXT(OES_shader_io_blocks, dummy_true   
  ,  x ,  x ,  x ,  31, 2014)
 EXT(OES_shader_multisample_interpolation, OES_sample_variables 
  ,  x ,  x ,  x ,  30, 2014)
 EXT(OES_single_precision, dummy_true   
  ,  x ,  x , ES1,  x , 2003)
 EXT(OES_standard_derivatives, OES_standard_derivatives 
  ,  x ,  x ,  x , ES2, 2005)
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 3f83f84..8d8488f 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3944,7 +3944,6 @@ struct gl_extensions
GLboolean OES_copy_image;
GLboolean OES_primitive_bounding_box;
GLboolean OES_sample_variables;
-   GLboolean OES_shader_io_blocks;
GLboolean OES_standard_derivatives;
GLboolean OES_texture_buffer;
GLboolean OES_texture_cube_map_array;
diff --git a/src/mesa/state_tracker/st_extensions.c 
b/src/mesa/state_tracker/st_extensions.c
index 1f53bdf..f86a5a3 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -1210,10 +1210,4 @@ void st_init_extensions(struct pipe_screen *screen,
   extensions->ARB_texture_multisample &&
   extensions->ARB_gpu_shader5 &&
   extensions->EXT_shader_integer_mix;
-
-   /* And if we have enough for ES 3.1, we can also expose
-* OES_shader_io_blocks, which is only hidden due to the compiler not being
-* able to version-restrict things.
-*/
-   extensions->OES_shader_io_blocks = extensions->ARB_ES3_1_compatibility;
 }
-- 
2.7.3

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


[Mesa-dev] [Bug 95346] Stellaris - Black/super dark planets

2016-08-27 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=95346

Alexander Tsoy  changed:

   What|Removed |Added

URL|http://www.memonic.com/user |
   |/pharmacy/id/1Fzdh  |

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


[Mesa-dev] [PATCH] st/mesa: expose OES_geometry_shader and OES_texture_cube_map_array

2016-08-27 Thread Ilia Mirkin
Signed-off-by: Ilia Mirkin 
---
 docs/features.txt  |  4 ++--
 docs/relnotes/12.1.0.html  |  4 ++--
 src/mesa/state_tracker/st_extensions.c | 14 ++
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/docs/features.txt b/docs/features.txt
index 26e8ff7..4c755c6 100644
--- a/docs/features.txt
+++ b/docs/features.txt
@@ -260,7 +260,7 @@ GLES3.2, GLSL ES 3.2:
   GL_OES_copy_image DONE (all drivers)
   GL_OES_draw_buffers_indexed   DONE (all drivers that 
support GL_ARB_draw_buffers_blend)
   GL_OES_draw_elements_base_vertex  DONE (all drivers)
-  GL_OES_geometry_shaderDONE (i965/gen8+)
+  GL_OES_geometry_shaderDONE (i965/gen8+, 
nvc0, radeonsi)
   GL_OES_gpu_shader5DONE (all drivers that 
support GL_ARB_gpu_shader5)
   GL_OES_primitive_bounding_box not started
   GL_OES_sample_shading DONE (i965, nvc0, 
r600, radeonsi)
@@ -271,7 +271,7 @@ GLES3.2, GLSL ES 3.2:
   GL_OES_tessellation_shaderstarted (Ken)
   GL_OES_texture_border_clamp   DONE (all drivers)
   GL_OES_texture_buffer DONE (i965, nvc0, 
radeonsi)
-  GL_OES_texture_cube_map_array DONE (i965/gen8+)
+  GL_OES_texture_cube_map_array DONE (i965/gen8+, 
nvc0, radeonsi)
   GL_OES_texture_stencil8   DONE (all drivers that 
support GL_ARB_texture_stencil8)
   GL_OES_texture_storage_multisample_2d_array   DONE (all drivers that 
support GL_ARB_texture_multisample)
 
diff --git a/docs/relnotes/12.1.0.html b/docs/relnotes/12.1.0.html
index d22d14b..f77ef91 100644
--- a/docs/relnotes/12.1.0.html
+++ b/docs/relnotes/12.1.0.html
@@ -57,8 +57,8 @@ Note: some of the new features are only available with 
certain drivers.
 GL_KHR_blend_equation_advanced on i965
 GL_KHR_texture_compression_astc_sliced_3d on i965
 GL_OES_copy_image on nv50, nvc0, r600, radeonsi, softpipe, llvmpipe
-GL_OES_geometry_shader on i965/gen8+
-GL_OES_texture_cube_map_array on i965/gen8+
+GL_OES_geometry_shader on i965/gen8+, nvc0, radeonsi
+GL_OES_texture_cube_map_array on i965/gen8+, nvc0, radeonsi
 
 
 Bug fixes
diff --git a/src/mesa/state_tracker/st_extensions.c 
b/src/mesa/state_tracker/st_extensions.c
index f86a5a3..c7ec10c 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -946,6 +946,15 @@ void st_init_extensions(struct pipe_screen *screen,
   extensions->ARB_tessellation_shader = GL_TRUE;
}
 
+   /* Ideally this should also check that invocations are supported. In
+* practice, all of the hw that supports ES 3.1 also supports multiple
+* invocations.
+*/
+   if (screen->get_shader_param(screen, PIPE_SHADER_GEOMETRY,
+PIPE_SHADER_CAP_MAX_INSTRUCTIONS) > 0) {
+  extensions->OES_geometry_shader = GL_TRUE;
+   }
+
if (screen->fence_finish) {
   extensions->ARB_sync = GL_TRUE;
}
@@ -1210,4 +1219,9 @@ void st_init_extensions(struct pipe_screen *screen,
   extensions->ARB_texture_multisample &&
   extensions->ARB_gpu_shader5 &&
   extensions->EXT_shader_integer_mix;
+
+   extensions->OES_texture_cube_map_array =
+  extensions->ARB_ES3_1_compatibility &&
+  extensions->OES_geometry_shader &&
+  extensions->ARB_texture_cube_map_array;
 }
-- 
2.7.3

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


[Mesa-dev] [PATCH] mesa: add EXT_texture_cube_map_array support

2016-08-27 Thread Ilia Mirkin
This is identical to OES_texture_cube_map_array support. dEQP has tests
which use this extension. Also it is part of AEP.

Signed-off-by: Ilia Mirkin 
---
 src/compiler/glsl/builtin_functions.cpp  |  2 ++
 src/compiler/glsl/builtin_types.cpp  |  2 ++
 src/compiler/glsl/glsl_lexer.ll  | 14 +++---
 src/compiler/glsl/glsl_parser_extras.cpp |  1 +
 src/compiler/glsl/glsl_parser_extras.h   |  3 +++
 src/mesa/main/extensions_table.h |  1 +
 6 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/src/compiler/glsl/builtin_functions.cpp 
b/src/compiler/glsl/builtin_functions.cpp
index 64bf8d8..19ef99e 100644
--- a/src/compiler/glsl/builtin_functions.cpp
+++ b/src/compiler/glsl/builtin_functions.cpp
@@ -249,6 +249,7 @@ gpu_shader5_or_OES_texture_cube_map_array(const 
_mesa_glsl_parse_state *state)
 {
return state->is_version(400, 320) ||
   state->ARB_gpu_shader5_enable ||
+  state->EXT_texture_cube_map_array_enable ||
   state->OES_texture_cube_map_array_enable;
 }
 
@@ -371,6 +372,7 @@ texture_gather_cube_map_array(const _mesa_glsl_parse_state 
*state)
return state->is_version(400, 320) ||
   state->ARB_texture_gather_enable ||
   state->ARB_gpu_shader5_enable ||
+  state->EXT_texture_cube_map_array_enable ||
   state->OES_texture_cube_map_array_enable;
 }
 
diff --git a/src/compiler/glsl/builtin_types.cpp 
b/src/compiler/glsl/builtin_types.cpp
index d40f785..000f811 100644
--- a/src/compiler/glsl/builtin_types.cpp
+++ b/src/compiler/glsl/builtin_types.cpp
@@ -299,6 +299,7 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state 
*state)
 * is harmless.
 */
if (state->ARB_texture_cube_map_array_enable ||
+   state->EXT_texture_cube_map_array_enable ||
state->OES_texture_cube_map_array_enable) {
   add_type(symbols, glsl_type::samplerCubeArray_type);
   add_type(symbols, glsl_type::samplerCubeArrayShadow_type);
@@ -339,6 +340,7 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state 
*state)
}
 
if (state->ARB_shader_image_load_store_enable ||
+   state->EXT_texture_cube_map_array_enable ||
state->OES_texture_cube_map_array_enable) {
   add_type(symbols, glsl_type::imageCubeArray_type);
   add_type(symbols, glsl_type::iimageCubeArray_type);
diff --git a/src/compiler/glsl/glsl_lexer.ll b/src/compiler/glsl/glsl_lexer.ll
index 2ed11ef..d5e5d4c 100644
--- a/src/compiler/glsl/glsl_lexer.ll
+++ b/src/compiler/glsl/glsl_lexer.ll
@@ -348,10 +348,10 @@ isampler2DMSArray  KEYWORD_WITH_ALT(150, 300, 150, 320, 
yyextra->ARB_texture_mul
 usampler2DMSArray  KEYWORD_WITH_ALT(150, 300, 150, 320, 
yyextra->ARB_texture_multisample_enable || 
yyextra->OES_texture_storage_multisample_2d_array_enable, USAMPLER2DMSARRAY);
 
/* keywords available with ARB_texture_cube_map_array_enable extension on 
desktop GLSL */
-samplerCubeArray   KEYWORD_WITH_ALT(400, 310, 400, 320, 
yyextra->ARB_texture_cube_map_array_enable || 
yyextra->OES_texture_cube_map_array_enable, SAMPLERCUBEARRAY);
-isamplerCubeArray KEYWORD_WITH_ALT(400, 310, 400, 320, 
yyextra->ARB_texture_cube_map_array_enable || 
yyextra->OES_texture_cube_map_array_enable, ISAMPLERCUBEARRAY);
-usamplerCubeArray KEYWORD_WITH_ALT(400, 310, 400, 320, 
yyextra->ARB_texture_cube_map_array_enable || 
yyextra->OES_texture_cube_map_array_enable, USAMPLERCUBEARRAY);
-samplerCubeArrayShadow   KEYWORD_WITH_ALT(400, 310, 400, 320, 
yyextra->ARB_texture_cube_map_array_enable || 
yyextra->OES_texture_cube_map_array_enable, SAMPLERCUBEARRAYSHADOW);
+samplerCubeArray   KEYWORD_WITH_ALT(400, 310, 400, 320, 
yyextra->ARB_texture_cube_map_array_enable || 
yyextra->OES_texture_cube_map_array_enable || 
yyextra->EXT_texture_cube_map_array_enable, SAMPLERCUBEARRAY);
+isamplerCubeArray KEYWORD_WITH_ALT(400, 310, 400, 320, 
yyextra->ARB_texture_cube_map_array_enable || 
yyextra->OES_texture_cube_map_array_enable || 
yyextra->EXT_texture_cube_map_array_enable, ISAMPLERCUBEARRAY);
+usamplerCubeArray KEYWORD_WITH_ALT(400, 310, 400, 320, 
yyextra->ARB_texture_cube_map_array_enable || 
yyextra->OES_texture_cube_map_array_enable || 
yyextra->EXT_texture_cube_map_array_enable, USAMPLERCUBEARRAY);
+samplerCubeArrayShadow   KEYWORD_WITH_ALT(400, 310, 400, 320, 
yyextra->ARB_texture_cube_map_array_enable || 
yyextra->OES_texture_cube_map_array_enable || 
yyextra->EXT_texture_cube_map_array_enable, SAMPLERCUBEARRAYSHADOW);
 
 samplerExternalOES {
  if (yyextra->OES_EGL_image_external_enable)
@@ -372,7 +372,7 @@ imageCube   KEYWORD_WITH_ALT(130, 300, 420, 310, 
yyextra->ARB_shader_image_l
 imageBuffer KEYWORD_WITH_ALT(130, 300, 420, 320, 
yyextra->ARB_shader_image_load_store_enable || 
yyextra->EXT_texture_buffer_enable || yyextra->OES_texture_buffer_enable, 
IMAGEBUFFER);
 image1DArrayKEYWORD_WITH_ALT(130, 300, 420, 0, 
yyextra->ARB_shader_image_load_store_enable, IMAGE1DARRAY);
 image2DArrayKEYWORD

[Mesa-dev] [PATCH 2/2] nouveau: always enable at least one RC

2016-08-27 Thread Ilia Mirkin
Experimentally, this is required for glxgears and others to display the
proper colors.

Signed-off-by: Ilia Mirkin 
---
 src/mesa/drivers/dri/nouveau/nv20_state_frag.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/nouveau/nv20_state_frag.c 
b/src/mesa/drivers/dri/nouveau/nv20_state_frag.c
index 492ecdc..2c5c2db 100644
--- a/src/mesa/drivers/dri/nouveau/nv20_state_frag.c
+++ b/src/mesa/drivers/dri/nouveau/nv20_state_frag.c
@@ -67,5 +67,5 @@ nv20_emit_frag(struct gl_context *ctx, int emit)
PUSH_DATA (push, in >> 32);
 
BEGIN_NV04(push, NV20_3D(RC_ENABLE), 1);
-   PUSH_DATA (push, n);
+   PUSH_DATA (push, MAX2(1, n));
 }
-- 
2.7.3

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


[Mesa-dev] [PATCH 1/2] nouveau: allow NV3x's to be used with nouveau_vieux

2016-08-27 Thread Ilia Mirkin
NV34 and possibly other NV3x hardware has the capability of exposing the
NV25 graph class. This allows forcing nouveau_vieux to be used instead
of the gallium driver, primarily for testing purposes. (Among other
things, NV2x only ever came as AGP or inside an Xbox, never PCI/PCIe).

Signed-off-by: Ilia Mirkin 
---
 src/loader/pci_id_driver_map.c| 4 +++-
 src/mesa/drivers/dri/nouveau/nouveau_screen.c | 1 +
 src/mesa/drivers/dri/nouveau/nv04_surface.c   | 4 +++-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/loader/pci_id_driver_map.c b/src/loader/pci_id_driver_map.c
index 3c4657f..8b2079e 100644
--- a/src/loader/pci_id_driver_map.c
+++ b/src/loader/pci_id_driver_map.c
@@ -25,6 +25,7 @@ int is_nouveau_vieux(int fd);
 
 #ifdef HAVE_LIBDRM
 
+#include 
 #include 
 #include 
 
@@ -45,7 +46,8 @@ int
 is_nouveau_vieux(int fd)
 {
int chipset = nouveau_chipset(fd);
-   return chipset > 0 && chipset < 0x30;
+   return (chipset > 0 && chipset < 0x30) ||
+  (chipset < 0x40 && getenv("NOUVEAU_VIEUX") != NULL);
 }
 
 #else
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_screen.c 
b/src/mesa/drivers/dri/nouveau/nouveau_screen.c
index 0545e68..de578a5 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_screen.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_screen.c
@@ -130,6 +130,7 @@ nouveau_init_screen2(__DRIscreen *dri_screen)
dri_screen->max_gl_es1_version = 10;
break;
case 0x20:
+   case 0x30:
screen->driver = &nv20_driver;
dri_screen->max_gl_compat_version = 13;
dri_screen->max_gl_es1_version = 10;
diff --git a/src/mesa/drivers/dri/nouveau/nv04_surface.c 
b/src/mesa/drivers/dri/nouveau/nv04_surface.c
index 968c05f..b1f0ea0 100644
--- a/src/mesa/drivers/dri/nouveau/nv04_surface.c
+++ b/src/mesa/drivers/dri/nouveau/nv04_surface.c
@@ -577,8 +577,10 @@ nv04_surface_init(struct gl_context *ctx)
/* Swizzled surface. */
if (context_chipset(ctx) < 0x20)
class = NV04_SURFACE_SWZ_CLASS;
-   else
+   else if (context_chipset (ctx) < 0x30)
class = NV20_SURFACE_SWZ_CLASS;
+   else
+   class = NV30_SURFACE_SWZ_CLASS;
 
ret = nouveau_object_new(chan, handle++, class, NULL, 0, &hw->swzsurf);
if (ret)
-- 
2.7.3

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


Re: [Mesa-dev] [PATCH 2/2] nouveau: always enable at least one RC

2016-08-27 Thread Ilia Mirkin
On Sat, Aug 27, 2016 at 8:01 PM, Ilia Mirkin  wrote:
> Experimentally, this is required for glxgears and others to display the
> proper colors.
>
> Signed-off-by: Ilia Mirkin 
> ---
>  src/mesa/drivers/dri/nouveau/nv20_state_frag.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/mesa/drivers/dri/nouveau/nv20_state_frag.c 
> b/src/mesa/drivers/dri/nouveau/nv20_state_frag.c
> index 492ecdc..2c5c2db 100644
> --- a/src/mesa/drivers/dri/nouveau/nv20_state_frag.c
> +++ b/src/mesa/drivers/dri/nouveau/nv20_state_frag.c
> @@ -67,5 +67,5 @@ nv20_emit_frag(struct gl_context *ctx, int emit)
> PUSH_DATA (push, in >> 32);
>
> BEGIN_NV04(push, NV20_3D(RC_ENABLE), 1);
> -   PUSH_DATA (push, n);
> +   PUSH_DATA (push, MAX2(1, n));

As an add-on analysis, it looks like that's what this driver did back
in antiquity:

https://cgit.freedesktop.org/mesa/mesa/tree/src/mesa/drivers/dri/nouveau/nv10_state_frag.c?h=7.10#n365
*n = log2i(ctx->Texture._EnabledUnits) + 1;

Whereas now it does

https://cgit.freedesktop.org/mesa/mesa/tree/src/mesa/drivers/dri/nouveau/nv10_state_frag.c?h=12.0#n365
*n = ctx->Texture._MaxEnabledTexImageUnit + 1;

The old code would always return at least 1, while the new code will
return 0 when there are no enabled tex image units.

  -ilia

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


Re: [Mesa-dev] [PATCH] android: fix build issues with genxml, isl

2016-08-27 Thread Mauro Rossi
Hi Emil, Jason, Tapani,

this weekend I had planned to check mesa-dev with marshmallow-x86 and
nougat-x86,builds,
so here you can find the port to android of commit
bebc1a1d995e33f173ea207848bcddd81f6dd19a

Built successfully and tested on Sandybridge.
Added also the same formatted patch as attachment in case gmail causes problems.

Mauro

>From 4769f3e4b51fc804676d2b7b2ea320cfa5fffdde Mon Sep 17 00:00:00 2001
From: Mauro Rossi 
Date: Sat, 27 Aug 2016 17:19:34 +0200
Subject: [PATCH] android: intel: Flatten the makefile structure

Android porting of commit bebc1a1 "intel: Flatten the makefile structure"

Automake approach was followed, by moving makefiles a level up,
naming them Android.genxml.mk and Android.isl.mk,
performing the necessary adjustments to the paths,
adding src/intel/Android.mk and fixing mesa top level makefile.
---
 Android.mk  |   3 +-
 src/intel/Android.genxml.mk |  97 
 src/intel/Android.isl.mk| 216 +++
 src/intel/Android.mk|  29 ++
 src/intel/genxml/Android.mk |  97 
 src/intel/isl/Android.mk| 217 
 6 files changed, 343 insertions(+), 316 deletions(-)
 create mode 100644 src/intel/Android.genxml.mk
 create mode 100644 src/intel/Android.isl.mk
 create mode 100644 src/intel/Android.mk
 delete mode 100644 src/intel/genxml/Android.mk
 delete mode 100644 src/intel/isl/Android.mk

diff --git a/Android.mk b/Android.mk
index f673029..4a63384 100644
--- a/Android.mk
+++ b/Android.mk
@@ -90,8 +90,7 @@ SUBDIRS := \
  src/mesa \
  src/util \
  src/egl \
- src/intel/genxml \
- src/intel/isl \
+ src/intel \
  src/mesa/drivers/dri

 INC_DIRS := $(call all-named-subdir-makefiles,$(SUBDIRS))
diff --git a/src/intel/Android.genxml.mk b/src/intel/Android.genxml.mk
new file mode 100644
index 000..79de784
--- /dev/null
+++ b/src/intel/Android.genxml.mk
@@ -0,0 +1,97 @@
+# Copyright © 2016 Intel Corporation
+# Copyright © 2016 Mauro Rossi 
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+#
+
+# ---
+# Build libmesa_genxml
+# ---
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libmesa_genxml
+
+LOCAL_MODULE_CLASS := STATIC_LIBRARIES
+
+intermediates := $(call local-generated-sources-dir)
+
+# dummy.c source file is generated to meet the build system's rules.
+LOCAL_GENERATED_SOURCES += $(intermediates)/dummy.c
+
+$(intermediates)/dummy.c:
+ @mkdir -p $(dir $@)
+ @echo "Gen Dummy: $(PRIVATE_MODULE) <= $(notdir $(@))"
+ $(hide) touch $@
+
+# This is the list of auto-generated files headers
+LOCAL_GENERATED_SOURCES += $(addprefix $(intermediates)/,
$(GENXML_GENERATED_FILES))
+
+define header-gen
+ @mkdir -p $(dir $@)
+ @echo "Gen Header: $(PRIVATE_MODULE) <= $(notdir $(@))"
+ $(hide) $(PRIVATE_SCRIPT) $(PRIVATE_XML) > $@
+endef
+
+$(intermediates)/genxml/gen4_pack.h: PRIVATE_SCRIPT :=
$(MESA_PYTHON2) $(LOCAL_PATH)/genxml/gen_pack_header.py
+$(intermediates)/genxml/gen4_pack.h: PRIVATE_XML :=
$(LOCAL_PATH)/genxml/gen4.xml
+$(intermediates)/genxml/gen4_pack.h: $(LOCAL_PATH)/genxml/gen4.xml
$(LOCAL_PATH)/genxml/gen_pack_header.py
+ $(call header-gen)
+
+$(intermediates)/genxml/gen45_pack.h: PRIVATE_SCRIPT :=
$(MESA_PYTHON2) $(LOCAL_PATH)/genxml/gen_pack_header.py
+$(intermediates)/genxml/gen45_pack.h: PRIVATE_XML :=
$(LOCAL_PATH)/genxml/gen45.xml
+$(intermediates)/genxml/gen45_pack.h: $(LOCAL_PATH)/genxml/gen45.xml
$(LOCAL_PATH)/genxml/gen_pack_header.py
+ $(call header-gen)
+
+$(intermediates)/genxml/gen5_pack.h: PRIVATE_SCRIPT :=
$(MESA_PYTHON2) $(LOCAL_PATH)/genxml/gen_pack_header.py
+$(intermediates)/genxml/gen5_pack.h: PRIVATE_XML :=
$(LOCAL_PATH)/genxml/gen5.xml
+$(intermediates)/genxml/gen5_pack.h: $(LOCAL_PATH)/genxml/gen5.xml
$(LOCAL_PATH)/genxml/gen_pack_header.py
+ $(call header-gen)
+
+$(intermediates)/genxml/gen6_pack.h: PRIVATE_SCRIPT :=
$(MESA_PYTHON2) $(LOCAL_PATH

Re: [Mesa-dev] [PATCH] android: fix build issues with genxml, isl

2016-08-27 Thread Jason Ekstrand
On Aug 27, 2016 5:51 PM, "Mauro Rossi"  wrote:
>
> Hi Emil, Jason, Tapani,
>
> this weekend I had planned to check mesa-dev with marshmallow-x86 and
> nougat-x86,builds,
> so here you can find the port to android of commit
> bebc1a1d995e33f173ea207848bcddd81f6dd19a
>
> Built successfully and tested on Sandybridge.
> Added also the same formatted patch as attachment in case gmail causes
problems.

While you're at it, I've got another build-breaking branch here:

https://cgit.freedesktop.org/~jekstrand/mesa/log/?h=wip/blorp-vulkan

It's almost reviewed so I'll be pushing soon. If you could provide a
squash-in, that would be great.

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


Re: [Mesa-dev] [PATCH 06/12] nir: don't count removal of lcssa_phi as progress

2016-08-27 Thread Timothy Arceri
On Sat, 2016-08-27 at 16:06 +0200, Thomas Helland wrote:
> 2016-08-27 8:03 GMT+02:00 Timothy Arceri  m>:
> > 
> > We generate these in each optimisation pass, counting them
> > as progress would cause the loop to run forever.
> 
> These are just some random thoughts that I thought I'd share.
> It might not make sense at all, and it might be answered in the
> patch series, but just thought I'd share them.
> 
> It's a bit unfortunate that we generate and remove phi's like this,
> but I'm not sure how it could be done in a better way.
> LCSSA, I think, is only useful if one is doing loop transformations.
> Maybe we could do loop transformations only once on the first
> iteration
> of the optimization loop, and then drop LCSSA transformation after
> that?
> Then again, future optimizations might open possibilities for
> unrolling,
> so this might not be ideal. There's also the issue that one might
> unroll
> a loop bit-by-bit on each iteration of the optimization loop, thereby
> completely unrolling a loop even if one only wants do to partial
> unrolling due to code size. I haven't studied how you hook the loop
> unrolling into the optimization loop, so my comments might not
> make sense at all.
> 
> > 
> > ---
> >  src/compiler/nir/nir_opt_remove_phis.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/src/compiler/nir/nir_opt_remove_phis.c
> > b/src/compiler/nir/nir_opt_remove_phis.c
> > index ee92fbe..13a139d 100644
> > --- a/src/compiler/nir/nir_opt_remove_phis.c
> > +++ b/src/compiler/nir/nir_opt_remove_phis.c
> > @@ -72,6 +72,7 @@ remove_phis_block(nir_block *block)
> >   break;
> > 
> >    nir_phi_instr *phi = nir_instr_as_phi(instr);
> > +  bool is_lcssa_phi = phi->is_lcssa_phi;
> > 
> >    nir_ssa_def *def = NULL;
> >    nir_alu_instr *mov = NULL;
> > @@ -118,6 +119,8 @@ remove_phis_block(nir_block *block)
> >    nir_instr_remove(instr);
> > 
> >    progress = true;
> > +  if (!is_lcssa_phi)
> > + progress = true;
> 
> This does not do what you intended, as you do not remove
> the progress = true; line above the if you're inserting.
> 
> With that fixed, the patch itself looks good. It's kinda funny
> though that things presumable work even though this
> patch has no effect, indicating that it is not needed.

This looks like an error from rebasing. I believe it still works
because I added an is_simple_for_loop() check to the LCSSA pass so we
only do LCSSA if we are going to do unrolling which resolves the issues
you are talking about above. I should also be able add an
is_complex_for_loop() check once I add the support.

So in other words I think I can just drop this patch.


> 
> > 
> > }
> > 
> > return progress;
> > --
> > 2.7.4
> > 
> > ___
> > mesa-dev mailing list
> > mesa-dev@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 03/12] nir: Add a loop analysis pass

2016-08-27 Thread Timothy Arceri
On Sat, 2016-08-27 at 14:08 +0200, Thomas Helland wrote:
> 2016-08-27 8:03 GMT+02:00 Timothy Arceri  m>:
> > 
> > This pass detects induction variables and calculates the
> > trip count of loops to be used for loop unrolling.
> > 
> > I've removed support for float induction values for now, for the
> > simple reason that they don't appear in my shader-db collection,
> > and so I don't see it as common enough that we want to pollute the
> > pass with this in the initial version.
> > 
> > V2: Rebase, adapt to removal of function overloads
> > 
> > V3: (Timothy Arceri)
> >  - don't try to find trip count if loop terminator conditional is a
> > phi
> >  - fix trip count for do-while loops
> >  - replace conditional type != alu assert with return
> >  - disable unrolling of loops with continues
> >  - multiple fixes to memory allocation, stop leaking and don't
> > destroy
> >    structs we want to use for unrolling.
> >  - find induction var when copy propagation disabled
> >  - fix iteration count bugs when induction var not on RHS of
> > condition
> >  - add FIXME for && conditions
> >  - calculate trip count for unsigned induction/limit vars
> > ---
> >  src/compiler/Makefile.sources   |   2 +
> >  src/compiler/nir/nir.h  |  75 +++
> >  src/compiler/nir/nir_loop_analyze.c | 922
> > 
> >  3 files changed, 999 insertions(+)
> >  create mode 100644 src/compiler/nir/nir_loop_analyze.c
> > 
> > diff --git a/src/compiler/Makefile.sources
> > b/src/compiler/Makefile.sources
> > index cfb6359..1bf1c52 100644
> > --- a/src/compiler/Makefile.sources
> > +++ b/src/compiler/Makefile.sources
> > @@ -187,6 +187,8 @@ NIR_FILES = \
> > nir/nir_intrinsics.c \
> > nir/nir_intrinsics.h \
> > nir/nir_liveness.c \
> > +   nir/nir_loop_analyze.c \
> > +   nir/nir_loop_analyze.h \
> > nir/nir_lower_alu_to_scalar.c \
> > nir/nir_lower_atomics.c \
> > nir/nir_lower_bitmap.c \
> > diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> > index e3e06b1..f85e829 100644
> > --- a/src/compiler/nir/nir.h
> > +++ b/src/compiler/nir/nir.h
> > @@ -1541,10 +1541,78 @@ nir_if_last_else_node(nir_if *if_stmt)
> > return exec_node_data(nir_cf_node, tail, node);
> >  }
> > 
> > +typedef enum {
> > +   undefined,
> > +   invariant,
> > +   basic_induction
> > +} nir_loop_variable_type;
> > +
> > +typedef struct {
> > +   /* The ssa_def associated with this info */
> > +   nir_ssa_def *def;
> > +
> > +   /* The type of this ssa_def */
> > +   nir_loop_variable_type type;
> > +
> > +   /* Link to the loop_variable list for the loop */
> > +   struct list_head loop_vars_link;
> > +
> > +   /* A link for a list of invariant variables */
> > +   struct list_head invariant_link;
> > +
> > +   /* A link for a list of induction variables */
> > +   struct list_head induction_link;
> > +
> > +   /* If the ssa-def is constant */
> > +   bool is_constant;
> > +
> > +   bool in_conditional_block;
> > +
> > +   bool in_nested_loop;
> > +} nir_loop_variable;
> > +
> > +typedef struct {
> > +   nir_op alu_op;/* The type of
> > alu-operation*/
> > +   nir_loop_variable *alu_def;   /* The def of the
> > alu-operation */
> > +   nir_loop_variable *invariant; /* The invariant
> > alu-operand*/
> > +   nir_loop_variable *phi;   /* The other alu-
> > operand*/
> > +   nir_loop_variable *def_outside_loop;  /* The phi-src
> > outside the loop */
> > +} nir_basic_induction_var;
> > +
> > +typedef struct {
> > +   nir_if *nif;
> > +
> > +   /* Some more suitable fields like maybe indicated trip-count?
> > */
> > +   nir_instr *conditional_instr;
> 
> This question here should probably be answered, or removed.
> 
> > 
> > +
> > +   struct list_head loop_terminator_link;
> > +} nir_loop_terminator;
> > +
> > +typedef struct {
> > +   /* Loop_variable for all ssa_defs in loop */
> > +   struct list_head loop_vars_list;
> > +
> > +   /* How many times the loop is run (if known) */
> > +   uint32_t trip_count;
> > +   bool is_trip_count_known;
> > +
> > +   nir_loop_terminator *limiting_terminator;
> > +
> > +   /* A list of loop_terminators terminating this loop XXX: These
> > (apart from the limiting terminator) can be dead-code-eliminated */
> > +   struct list_head loop_terminator_list;
> > +
> 
> Line wrapping.
> 
> > 
> > +   /* The ssa_defs that are invariant */
> > +   struct list_head invariant_list;
> > +
> > +   struct hash_table *var_to_basic_ind;
> > +} nir_loop_info;
> > +
> >  typedef struct {
> > nir_cf_node cf_node;
> > 
> > struct exec_list body; /** < list of nir_cf_node */
> > +
> > +   nir_loop_info *info;
> >  } nir_loop;
> > 
> >  static inline nir_cf_node *
> > @@ -1569,6 +1637,7 @@ typedef enum {
> > nir_metadata_dominance = 0x2,
> > nir_metadata_live_ssa_defs = 0x4,
> > nir_metadata_not_properly_reset = 0x8,
>

Re: [Mesa-dev] RFC - Simple loop unrolling in NIR

2016-08-27 Thread Timothy Arceri
On Sat, 2016-08-27 at 07:52 -0700, Jason Ekstrand wrote:
> Hey Timothy,
> > > Thanks for working on this!  Looks like you're making pretty good
progress.  I'm going to try and give the series a hard look some time
next week.

Thanks that would be great. I'll try to get an new series out tomorrow
with a few clean-ups Thomas has pointed out and a couple of others I've
spotted.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 05/12] nir: Add a LCSAA-pass

2016-08-27 Thread Matt Turner
On Fri, Aug 26, 2016 at 11:03 PM, Timothy Arceri
 wrote:
> V2: Do a "depth first search" to convert to LCSSA
>
> V3: Small comment fixup
>
> V4: Rebase, adapt to removal of function overloads
>
> V5: Rebase, adapt to relocation of nir to compiler/nir
> Still need to adapt to potential if-uses
> Work around nir_validate issue
>
> V6 (Timothy):
>  - tidy lcssa and stop leaking memory
>  - dont rewrite the src for the lcssa phi node
>  - validate lcssa phi srcs to avoid postvalidate assert
>  - don't add new phi if one already exists
>  - more lcssa phi validation fixes
>  - Rather than marking ssa defs inside a loop just mark blocks inside
>a loop. This is simpler and fixes lcssa for intrinsics which do
>not have a destination.
>  - don't create LCSSA phis for loops we won't unroll
>  - require loop metadata for lcssa pass
> ---
>  src/compiler/Makefile.sources |   1 +
>  src/compiler/nir/nir.h|   5 +
>  src/compiler/nir/nir_form_lcssa.c | 225 
> ++
>  src/compiler/nir/nir_validate.c   |  11 +-
>  4 files changed, 239 insertions(+), 3 deletions(-)
>  create mode 100644 src/compiler/nir/nir_form_lcssa.c
>
> diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources
> index 1bf1c52..55eb399 100644
> --- a/src/compiler/Makefile.sources
> +++ b/src/compiler/Makefile.sources
> @@ -178,6 +178,7 @@ NIR_FILES = \
> nir/nir_control_flow.h \
> nir/nir_control_flow_private.h \
> nir/nir_dominance.c \
> +   nir/nir_form_lcssa.c \

This name is confusing. I initially thought it was a typo of "from". I
think it'd be better to call it nir_to_lcssa.c (like nir_to_ssa.c).

> nir/nir_from_ssa.c \
> nir/nir_gather_info.c \
> nir/nir_gs_count_vertices.c \
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> index 6b0a73f..d8c5e8e 100644
> --- a/src/compiler/nir/nir.h
> +++ b/src/compiler/nir/nir.h
> @@ -1377,6 +1377,8 @@ typedef struct {
> struct exec_list srcs; /** < list of nir_phi_src */
>
> nir_dest dest;
> +
> +   bool is_lcssa_phi;
>  } nir_phi_instr;
>
>  typedef struct {
> @@ -2633,6 +2635,9 @@ void nir_convert_to_ssa(nir_shader *shader);
>  bool nir_repair_ssa_impl(nir_function_impl *impl);
>  bool nir_repair_ssa(nir_shader *shader);
>
> +void nir_form_LCSSA_impl(nir_function_impl *impl);
> +void nir_form_LCSSA(nir_shader *shader);
> +
>  /* If phi_webs_only is true, only convert SSA values involved in phi nodes to
>   * registers.  If false, convert all values (even those not involved in a phi
>   * node) to registers.
> diff --git a/src/compiler/nir/nir_form_lcssa.c 
> b/src/compiler/nir/nir_form_lcssa.c
> new file mode 100644
> index 000..86e78cd
> --- /dev/null
> +++ b/src/compiler/nir/nir_form_lcssa.c
> @@ -0,0 +1,225 @@
> +/*
> + * Copyright © 2015 Thomas Helland (for Google's Summer of Code)

I don't think it's appropriate to put "(for Google's Summer of Code)"
as part of a copyright statement.

> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
> DEALINGS
> + * IN THE SOFTWARE.
> + */
> +
> +/*
> + * This pass converts the ssa-graph into "Loop Closed SSA form". This is
> + * done by placing phi nodes at the exits of the loop for all values
> + * that are used outside the loop. The result is it transforms:
> + *
> + * loop {->  loop {
> + *ssa2 = ->  ssa2 = ...
> + *if (cond)  ->  if (cond) {
> + *   break;  -> break;
> + *ssa3 = ssa2 * ssa4 ->  }
> + * } ->  ssa3 = ssa2 * ssa4
> + * ssa6 = ssa2 + 4   ->   }
> + *ssa5 = lcssa_phi(ssa2)
> + *ssa6 = ssa5 + 4
> + *
> + * This will make a lot of other passes like loop unrolling and LICM simpler.
> + * It is also b