[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

mesa: Changes to 'upstream-experimental'



Rebased ref, commits from common ancestor:
commit 866ce39ca091991cc896424ea0e2d3c60b50c143
Author: Ian Romanick <ian.d.romanick@intel.com>
Date:   Sat Nov 23 17:23:00 2013 -0800

    mesa: Bump version to 10.0.0-rc2
    
    Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>

diff --git a/VERSION b/VERSION
index 9db9c78..85e917b 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-10.0.0-rc1
+10.0.0-rc2

commit 48e4daf977a31dc62a1b46ea01d215f78c7585da
Author: Ian Romanick <ian.d.romanick@intel.com>
Date:   Sat Nov 23 17:20:36 2013 -0800

    Remove 068a073 from the pick list
    
    Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>

diff --git a/bin/.cherry-ignore b/bin/.cherry-ignore
index 29c1be2..e4aaba7 100644
--- a/bin/.cherry-ignore
+++ b/bin/.cherry-ignore
@@ -1,3 +1,8 @@
 # Since we've disabled DRI3 completely in 10.0, this commit is no longer
 # necessary.
 f0f202e6b764be803470e27cba9102f14361ae22 glx: conditionaly build dri3 and present loader (v3)
+
+# This patch makes bug #71870 worse, so it won't be cherry picked until that
+# issue can be resolved.  See
+# http://lists.freedesktop.org/archives/mesa-dev/2013-November/048899.html
+068a073c1d4853b5c8f33efdeb481026f42e23a5 meta: fix meta clear of layered framebuffers

commit 1efe2ef620ba592d25d127d64d435fbf2db0bbda
Author: Eric Anholt <eric@anholt.net>
Date:   Tue Nov 19 16:00:28 2013 -0800

    i965: Fix streamed state dumping/annotation after the blorp-flush change.
    
    I think I was thinking of the batch command packet cache when I pasted
    this in, but this counter is only used for dumping out streamed state for
    INTEL_DEBUG=batch and for putting annotations in our aub files.
    
    Cc: "10.0" <mesa-stable@lists.freedesktop.org>
    Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
    (cherry picked from commit 5891f981452c1c5ed45b5a7e5fe54a9884ced2b6)

diff --git a/src/mesa/drivers/dri/i965/brw_blorp.cpp b/src/mesa/drivers/dri/i965/brw_blorp.cpp
index 4cbcebe..fda86f8 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp.cpp
@@ -266,7 +266,6 @@ retry:
     */
    brw->state.dirty.brw = ~0;
    brw->state.dirty.cache = ~0;
-   brw->state_batch_count = 0;
    brw->batch.need_workaround_flush = true;
    brw->ib.type = -1;
    intel_batchbuffer_clear_cache(brw);

commit 47ff55fa86f9bf74cf05944f4420bb6f2208790a
Author: Paul Berry <stereotype441@gmail.com>
Date:   Tue Nov 19 21:17:19 2013 -0800

    mesa: Implement GL_FRAMEBUFFER_ATTACHMENT_LAYERED query.
    
    From section 6.1.18 (Renderbuffer Object Queries) of the GL 3.2 spec,
    under the heading "If the value of FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
    is TEXTURE, then":
    
        If pname is FRAMEBUFFER_ATTACHMENT_LAYERED, then params will
        contain TRUE if an entire level of a three-dimesional texture,
        cube map texture, or one-or two-dimensional array texture is
        attached. Otherwise, params will contain FALSE.
    
    Fixes piglit tests:
    - spec/!OpenGL 3.2/layered-rendering/framebuffer-layered-attachments
    - spec/!OpenGL 3.2/layered-rendering/framebuffertexture-defaults
    
    Cc: "10.0" <mesa-stable@lists.freedesktop.org>
    
    Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
    
    v2: Don't include "EXT" in the error message, since this query only
    makes sensen in context versions that have adopted
    glGetFramebufferAttachmentParameteriv().
    
    Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
    (cherry picked from commit ec79c05cbfb7c68fbef7447e1744423c00f26654)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index dd13107..3650627 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2964,6 +2964,18 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
                        " invalid FBO attachment structure");
       }
       return;
+   case GL_FRAMEBUFFER_ATTACHMENT_LAYERED:
+      if (!_mesa_has_geometry_shaders(ctx)) {
+         goto invalid_pname_enum;
+      } else if (att->Type == GL_TEXTURE) {
+         *params = att->Layered;
+      } else if (att->Type == GL_NONE) {
+         _mesa_error(ctx, err,
+                     "glGetFramebufferAttachmentParameteriv(pname)");
+      } else {
+         goto invalid_pname_enum;
+      }
+      return;
    default:
       goto invalid_pname_enum;
    }

commit 8f4d95d41c0e84766279d7220adec959f86ed081
Author: Paul Berry <stereotype441@gmail.com>
Date:   Tue Nov 19 21:47:04 2013 -0800

    mesa: Fix texture target validation for glFramebufferTexture()
    
    Previously we were using the code path for validating
    glFramebufferTextureLayer().  But glFramebufferTexture() allows
    additional texture types.
    
    Fixes piglit tests:
    - spec/!OpenGL 3.2/layered-rendering/gl-layer-cube-map
    - spec/!OpenGL 3.2/layered-rendering/framebuffertexture
    
    Cc: "10.0" <mesa-stable@lists.freedesktop.org>
    
    Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
    Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
    
    v2: Clarify comment above framebuffer_texture().
    
    Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
    (cherry picked from commit af1471dc04cc89822bab2c253c808880dd47c25a)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index e8cf274..dd13107 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2307,8 +2307,13 @@ reuse_framebuffer_texture_attachment(struct gl_framebuffer *fb,
 /**
  * Common code called by glFramebufferTexture1D/2D/3DEXT() and
  * glFramebufferTextureLayerEXT().
- * Note: glFramebufferTextureLayerEXT() has no textarget parameter so we'll
- * get textarget=0 in that case.
+ *
+ * \param textarget is the textarget that was passed to the
+ * glFramebufferTexture...() function, or 0 if the corresponding function
+ * doesn't have a textarget parameter.
+ *
+ * \param layered is true if this function was called from
+ * glFramebufferTexture(), false otherwise.
  */
 static void
 framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target, 
@@ -2343,16 +2348,46 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target,
       texObj = _mesa_lookup_texture(ctx, texture);
       if (texObj != NULL) {
          if (textarget == 0) {
-            /* If textarget == 0 it means we're being called by
-             * glFramebufferTextureLayer() and textarget is not used.
-             * The only legal texture types for that function are 3D and
-             * 1D/2D arrays textures.
-             */
-            err = (texObj->Target != GL_TEXTURE_3D) &&
-                (texObj->Target != GL_TEXTURE_1D_ARRAY_EXT) &&
-                (texObj->Target != GL_TEXTURE_2D_ARRAY_EXT) &&
-                (texObj->Target != GL_TEXTURE_CUBE_MAP_ARRAY) &&
-                (texObj->Target != GL_TEXTURE_2D_MULTISAMPLE_ARRAY);
+            if (layered) {
+               /* We're being called by glFramebufferTexture() and textarget
+                * is not used.
+                */
+               switch (texObj->Target) {
+               case GL_TEXTURE_3D:
+               case GL_TEXTURE_1D_ARRAY_EXT:
+               case GL_TEXTURE_2D_ARRAY_EXT:
+               case GL_TEXTURE_CUBE_MAP:
+               case GL_TEXTURE_CUBE_MAP_ARRAY:
+               case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+                  err = false;
+                  break;
+               case GL_TEXTURE_1D:
+               case GL_TEXTURE_2D:
+               case GL_TEXTURE_RECTANGLE:
+               case GL_TEXTURE_2D_MULTISAMPLE:
+                  /* These texture types are valid to pass to
+                   * glFramebufferTexture(), but since they aren't layered, it
+                   * is equivalent to calling glFramebufferTexture{1D,2D}().
+                   */
+                  err = false;
+                  layered = false;
+                  textarget = texObj->Target;
+                  break;
+               default:
+                  err = true;
+                  break;
+               }
+            } else {
+               /* We're being called by glFramebufferTextureLayer() and
+                * textarget is not used.  The only legal texture types for
+                * that function are 3D and 1D/2D arrays textures.
+                */
+               err = (texObj->Target != GL_TEXTURE_3D) &&
+                  (texObj->Target != GL_TEXTURE_1D_ARRAY_EXT) &&
+                  (texObj->Target != GL_TEXTURE_2D_ARRAY_EXT) &&
+                  (texObj->Target != GL_TEXTURE_CUBE_MAP_ARRAY) &&
+                  (texObj->Target != GL_TEXTURE_2D_MULTISAMPLE_ARRAY);
+            }
          }
          else {
             /* Make sure textarget is consistent with the texture's type */

commit 79d727e06302e500c5dcb0e766f959a77510eb08
Author: Paul Berry <stereotype441@gmail.com>
Date:   Tue Nov 19 18:51:48 2013 -0800

    i965: Fix fast clear of depth buffers.
    
    From section 4.4.7 (Layered Framebuffers) of the GLSL 3.2 spec:
    
        When the Clear or ClearBuffer* commands are used to clear a
        layered framebuffer attachment, all layers of the attachment are
        cleared.
    
    This patch fixes the fast depth clear path.
    
    Fixes piglit test "spec/!OpenGL 3.2/layered-rendering/clear-depth".
    
    Cc: "10.0" <mesa-stable@lists.freedesktop.org>
    
    Reviewed-by: Eric Anholt <eric@anholt.net>
    Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
    (cherry picked from commit 08315233509f1fa7dc1e877aed2a8517296cf86e)

diff --git a/src/mesa/drivers/dri/i965/brw_clear.c b/src/mesa/drivers/dri/i965/brw_clear.c
index a727e6e..95a6490 100644
--- a/src/mesa/drivers/dri/i965/brw_clear.c
+++ b/src/mesa/drivers/dri/i965/brw_clear.c
@@ -181,8 +181,16 @@ brw_fast_clear_depth(struct gl_context *ctx)
     */
    intel_batchbuffer_emit_mi_flush(brw);
 
-   intel_hiz_exec(brw, mt, depth_irb->mt_level, depth_irb->mt_layer,
-		  GEN6_HIZ_OP_DEPTH_CLEAR);
+   if (fb->NumLayers > 0) {
+      assert(fb->NumLayers == depth_irb->mt->level[depth_irb->mt_level].depth);
+      for (unsigned layer = 0; layer < fb->NumLayers; layer++) {
+         intel_hiz_exec(brw, mt, depth_irb->mt_level, layer,
+                        GEN6_HIZ_OP_DEPTH_CLEAR);
+      }
+   } else {
+      intel_hiz_exec(brw, mt, depth_irb->mt_level, depth_irb->mt_layer,
+                     GEN6_HIZ_OP_DEPTH_CLEAR);
+   }
 
    if (brw->gen == 6) {
       /* From the Sandy Bridge PRM, volume 2 part 1, page 314:

commit 7f99ae72c402869b76f297f87e8ef5b236f5c113
Author: Paul Berry <stereotype441@gmail.com>
Date:   Tue Nov 19 12:58:02 2013 -0800

    i965: Fix blorp clear of layered framebuffers.
    
    From section 4.4.7 (Layered Framebuffers) of the GLSL 3.2 spec:
    
        When the Clear or ClearBuffer* commands are used to clear a
        layered framebuffer attachment, all layers of the attachment are
        cleared.
    
    This patch fixes the blorp clear path for color buffers.
    
    Fixes piglit test "spec/!OpenGL 3.2/layered-rendering/clear-color".
    
    Cc: "10.0" <mesa-stable@lists.freedesktop.org>
    
    Reviewed-by: Eric Anholt <eric@anholt.net>
    Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
    (cherry picked from commit c1019670ea89505ea7411629c052d662c8eb6be6)

diff --git a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
index c7f485e..02ec273 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
@@ -67,7 +67,8 @@ public:
                           struct gl_framebuffer *fb,
                           struct gl_renderbuffer *rb,
                           GLubyte *color_mask,
-                          bool partial_clear);
+                          bool partial_clear,
+                          unsigned layer);
 };
 
 
@@ -183,12 +184,13 @@ brw_blorp_clear_params::brw_blorp_clear_params(struct brw_context *brw,
                                                struct gl_framebuffer *fb,
                                                struct gl_renderbuffer *rb,
                                                GLubyte *color_mask,
-                                               bool partial_clear)
+                                               bool partial_clear,
+                                               unsigned layer)
 {
    struct gl_context *ctx = &brw->ctx;
    struct intel_renderbuffer *irb = intel_renderbuffer(rb);
 
-   dst.set(brw, irb->mt, irb->mt_level, irb->mt_layer, true);
+   dst.set(brw, irb->mt, irb->mt_level, layer, true);
 
    /* Override the surface format according to the context's sRGB rules. */
    gl_format format = _mesa_get_render_format(ctx, irb->mt->format);
@@ -443,13 +445,13 @@ brw_blorp_const_color_program::compile(struct brw_context *brw,
 bool
 do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb,
                       struct gl_renderbuffer *rb, unsigned buf,
-                      bool partial_clear)
+                      bool partial_clear, unsigned layer)
 {
    struct gl_context *ctx = &brw->ctx;
    struct intel_renderbuffer *irb = intel_renderbuffer(rb);
 
    brw_blorp_clear_params params(brw, fb, rb, ctx->Color.ColorMask[buf],
-                                 partial_clear);
+                                 partial_clear, layer);
 
    bool is_fast_clear =
       (params.fast_clear_op == GEN7_FAST_CLEAR_OP_FAST_CLEAR);
@@ -525,6 +527,7 @@ brw_blorp_clear_color(struct brw_context *brw, struct gl_framebuffer *fb,
 
    for (unsigned buf = 0; buf < fb->_NumColorDrawBuffers; buf++) {
       struct gl_renderbuffer *rb = fb->_ColorDrawBuffers[buf];
+      struct intel_renderbuffer *irb = intel_renderbuffer(rb);
 
       /* If this is an ES2 context or GL_ARB_ES2_compatibility is supported,
        * the framebuffer can be complete with some attachments missing.  In
@@ -533,8 +536,17 @@ brw_blorp_clear_color(struct brw_context *brw, struct gl_framebuffer *fb,
       if (rb == NULL)
          continue;
 
-      if (!do_single_blorp_clear(brw, fb, rb, buf, partial_clear))
-         return false;
+      if (fb->NumLayers > 0) {
+         assert(fb->NumLayers == irb->mt->level[irb->mt_level].depth);
+         for (unsigned layer = 0; layer < fb->NumLayers; layer++) {
+            if (!do_single_blorp_clear(brw, fb, rb, buf, partial_clear, layer))
+               return false;
+         }
+      } else {
+         unsigned layer = irb->mt_layer;
+         if (!do_single_blorp_clear(brw, fb, rb, buf, partial_clear, layer))
+            return false;
+      }
    }
 
    return true;

commit e934782b2a87cab79fde9e9c45bd796863dcaf7f
Author: Paul Berry <stereotype441@gmail.com>
Date:   Tue Nov 19 10:42:59 2013 -0800

    i965: refactor blorp clear code in preparation for layered clears.
    
    Cc: "10.0" <mesa-stable@lists.freedesktop.org>
    
    Reviewed-by: Eric Anholt <eric@anholt.net>
    Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
    (cherry picked from commit 1ec5365429b46a39a06186092502c8e66fb4140e)

diff --git a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
index d1933ce..c7f485e 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
@@ -439,13 +439,75 @@ brw_blorp_const_color_program::compile(struct brw_context *brw,
    return brw_get_program(&func, program_size);
 }
 
-extern "C" {
+
 bool
-brw_blorp_clear_color(struct brw_context *brw, struct gl_framebuffer *fb,
+do_single_blorp_clear(struct brw_context *brw, struct gl_framebuffer *fb,
+                      struct gl_renderbuffer *rb, unsigned buf,
                       bool partial_clear)
 {
    struct gl_context *ctx = &brw->ctx;
+   struct intel_renderbuffer *irb = intel_renderbuffer(rb);
+
+   brw_blorp_clear_params params(brw, fb, rb, ctx->Color.ColorMask[buf],
+                                 partial_clear);
+
+   bool is_fast_clear =
+      (params.fast_clear_op == GEN7_FAST_CLEAR_OP_FAST_CLEAR);
+   if (is_fast_clear) {
+      /* Record the clear color in the miptree so that it will be
+       * programmed in SURFACE_STATE by later rendering and resolve
+       * operations.
+       */
+      uint32_t new_color_value =
+         compute_fast_clear_color_bits(&ctx->Color.ClearColor);
+      if (irb->mt->fast_clear_color_value != new_color_value) {
+         irb->mt->fast_clear_color_value = new_color_value;
+         brw->state.dirty.brw |= BRW_NEW_SURFACES;
+      }
+
+      /* If the buffer is already in INTEL_MCS_STATE_CLEAR, the clear is
+       * redundant and can be skipped.
+       */
+      if (irb->mt->mcs_state == INTEL_MCS_STATE_CLEAR)
+         return true;
+
+      /* If the MCS buffer hasn't been allocated yet, we need to allocate
+       * it now.
+       */
+      if (!irb->mt->mcs_mt) {
+         if (!intel_miptree_alloc_non_msrt_mcs(brw, irb->mt)) {
+            /* MCS allocation failed--probably this will only happen in
+             * out-of-memory conditions.  But in any case, try to recover
+             * by falling back to a non-blorp clear technique.
+             */
+            return false;
+         }
+         brw->state.dirty.brw |= BRW_NEW_SURFACES;
+      }
+   }
+
+   DBG("%s to mt %p level %d layer %d\n", __FUNCTION__,
+       irb->mt, irb->mt_level, irb->mt_layer);
+
+   brw_blorp_exec(brw, &params);
+
+   if (is_fast_clear) {
+      /* Now that the fast clear has occurred, put the buffer in
+       * INTEL_MCS_STATE_CLEAR so that we won't waste time doing redundant
+       * clears.
+       */
+      irb->mt->mcs_state = INTEL_MCS_STATE_CLEAR;
+   }
+
+   return true;
+}
+
 
+extern "C" {
+bool
+brw_blorp_clear_color(struct brw_context *brw, struct gl_framebuffer *fb,
+                      bool partial_clear)
+{
    /* The constant color clear code doesn't work for multisampled surfaces, so
     * we need to support falling back to other clear mechanisms.
     * Unfortunately, our clear code is based on a bitmask that doesn't
@@ -463,7 +525,6 @@ brw_blorp_clear_color(struct brw_context *brw, struct gl_framebuffer *fb,
 
    for (unsigned buf = 0; buf < fb->_NumColorDrawBuffers; buf++) {
       struct gl_renderbuffer *rb = fb->_ColorDrawBuffers[buf];
-      struct intel_renderbuffer *irb = intel_renderbuffer(rb);
 
       /* If this is an ES2 context or GL_ARB_ES2_compatibility is supported,
        * the framebuffer can be complete with some attachments missing.  In
@@ -472,56 +533,8 @@ brw_blorp_clear_color(struct brw_context *brw, struct gl_framebuffer *fb,
       if (rb == NULL)
          continue;
 
-      brw_blorp_clear_params params(brw, fb, rb, ctx->Color.ColorMask[buf],
-                                    partial_clear);
-
-      bool is_fast_clear =
-         (params.fast_clear_op == GEN7_FAST_CLEAR_OP_FAST_CLEAR);
-      if (is_fast_clear) {
-         /* Record the clear color in the miptree so that it will be
-          * programmed in SURFACE_STATE by later rendering and resolve
-          * operations.
-          */
-         uint32_t new_color_value =
-            compute_fast_clear_color_bits(&ctx->Color.ClearColor);
-         if (irb->mt->fast_clear_color_value != new_color_value) {
-            irb->mt->fast_clear_color_value = new_color_value;
-            brw->state.dirty.brw |= BRW_NEW_SURFACES;
-         }
-
-         /* If the buffer is already in INTEL_MCS_STATE_CLEAR, the clear is
-          * redundant and can be skipped.
-          */
-         if (irb->mt->mcs_state == INTEL_MCS_STATE_CLEAR)
-            continue;
-
-         /* If the MCS buffer hasn't been allocated yet, we need to allocate
-          * it now.
-          */
-         if (!irb->mt->mcs_mt) {
-            if (!intel_miptree_alloc_non_msrt_mcs(brw, irb->mt)) {
-               /* MCS allocation failed--probably this will only happen in
-                * out-of-memory conditions.  But in any case, try to recover
-                * by falling back to a non-blorp clear technique.
-                */
-               return false;
-            }
-            brw->state.dirty.brw |= BRW_NEW_SURFACES;
-         }
-      }
-
-      DBG("%s to mt %p level %d layer %d\n", __FUNCTION__,
-          irb->mt, irb->mt_level, irb->mt_layer);
-
-      brw_blorp_exec(brw, &params);
-
-      if (is_fast_clear) {
-         /* Now that the fast clear has occurred, put the buffer in
-          * INTEL_MCS_STATE_CLEAR so that we won't waste time doing redundant
-          * clears.
-          */
-         irb->mt->mcs_state = INTEL_MCS_STATE_CLEAR;
-      }
+      if (!do_single_blorp_clear(brw, fb, rb, buf, partial_clear))
+         return false;
    }
 
    return true;

commit ffa073ec72fe33f2155871fc511edbdb43152220
Author: Paul Berry <stereotype441@gmail.com>
Date:   Tue Nov 19 15:55:51 2013 -0800

    mesa: Track number of layers in layered framebuffers.
    
    In order to properly clear layered framebuffers, we need to know how
    many layers they have.  The easiest way to do this is to record it in
    the gl_framebuffer struct when we check framebuffer completeness.
    
    This patch replaces the gl_framebuffer::Layered boolean with a
    gl_framebuffer::NumLayers integer, which is 0 if the framebuffer is
    not layered, and equal to the number of layers otherwise.
    
    v2: Remove gl_framebuffer::Layered and make gl_framebuffer::NumLayers
    always have a defined value.  Fix factor of 6 error in the number of
    layers in a cube map array.
    
    Cc: "10.0" <mesa-stable@lists.freedesktop.org>
    
    Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
    Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
    Reviewed-by: Eric Anholt <eric@anholt.net>
    (cherry picked from commit 95140740ad1c6cd8a34002c307556f5c49a34589)

diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 662c975..fd6954b 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -701,7 +701,7 @@ brw_update_renderbuffer_surfaces(struct brw_context *brw)
       for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
 	 if (intel_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[i])) {
 	    brw->vtbl.update_renderbuffer_surface(brw, ctx->DrawBuffer->_ColorDrawBuffers[i],
-                                                  ctx->DrawBuffer->Layered, i);
+                                                  ctx->DrawBuffer->NumLayers > 0, i);
 	 } else {
 	    brw->vtbl.update_null_renderbuffer_surface(brw, i);
 	 }
diff --git a/src/mesa/drivers/dri/i965/gen6_clip_state.c b/src/mesa/drivers/dri/i965/gen6_clip_state.c
index 03d0f90..37a39b8 100644
--- a/src/mesa/drivers/dri/i965/gen6_clip_state.c
+++ b/src/mesa/drivers/dri/i965/gen6_clip_state.c
@@ -121,7 +121,7 @@ upload_clip_state(struct brw_context *brw)
 	     dw2);
    OUT_BATCH(U_FIXED(0.125, 3) << GEN6_CLIP_MIN_POINT_WIDTH_SHIFT |
              U_FIXED(255.875, 3) << GEN6_CLIP_MAX_POINT_WIDTH_SHIFT |
-             (fb->Layered ? 0 : GEN6_CLIP_FORCE_ZERO_RTAINDEX));
+             (fb->NumLayers > 0 ? 0 : GEN6_CLIP_FORCE_ZERO_RTAINDEX));
    ADVANCE_BATCH();
 }
 
diff --git a/src/mesa/drivers/dri/i965/gen7_misc_state.c b/src/mesa/drivers/dri/i965/gen7_misc_state.c
index 3f3833e..4251949 100644
--- a/src/mesa/drivers/dri/i965/gen7_misc_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_misc_state.c
@@ -81,7 +81,7 @@ gen7_emit_depth_stencil_hiz(struct brw_context *brw,
       break;
    }
 
-   if (fb->Layered || !irb) {
+   if (fb->NumLayers > 0 || !irb) {
       min_array_element = 0;
    } else if (irb->mt->num_samples > 1) {
       /* Convert physical layer to logical layer. */
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 9dd7161..e8cf274 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -905,6 +905,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
       struct gl_renderbuffer_attachment *att;
       GLenum f;
       gl_format attFormat;
+      GLenum att_tex_target = GL_NONE;
 
       /*
        * XXX for ARB_fbo, only check color buffers that are named by
@@ -945,6 +946,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
        */
       if (att->Type == GL_TEXTURE) {
          const struct gl_texture_image *texImg = att->Renderbuffer->TexImage;
+         att_tex_target = att->Texture->Target;
          minWidth = MIN2(minWidth, texImg->Width);
          maxWidth = MAX2(maxWidth, texImg->Width);
          minHeight = MIN2(minHeight, texImg->Height);
@@ -1057,7 +1059,14 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
       }
 
       /* Check that layered rendering is consistent. */
-      att_layer_count = att->Layered ? att->Renderbuffer->Depth : 0;
+      if (att->Layered) {
+         if (att_tex_target == GL_TEXTURE_CUBE_MAP)
+            att_layer_count = 6;
+         else
+            att_layer_count = att->Renderbuffer->Depth;
+      } else {
+         att_layer_count = 0;
+      }
       if (!layer_count_valid) {
          layer_count = att_layer_count;
          layer_count_valid = true;
@@ -1073,7 +1082,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
       }
    }
 
-   fb->Layered = layer_count > 0;
+   fb->NumLayers = layer_count;
 
    if (_mesa_is_desktop_gl(ctx) && !ctx->Extensions.ARB_ES2_compatibility) {
       /* Check that all DrawBuffers are present */
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index ae96e23..5a80ea5 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2974,7 +2974,13 @@ struct gl_framebuffer
    struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS];
    struct gl_renderbuffer *_ColorReadBuffer;
 
-   GLboolean Layered;
+   /**
+    * The number of layers in the framebuffer, or 0 if the framebuffer is not
+    * layered.  For cube maps, this value is 6.  For cube map arrays, this
+    * value is the "depth" value passed to TexImage3D (always a multiple of
+    * 6).
+    */
+   GLuint NumLayers;
 
    /** Delete this framebuffer */
    void (*Delete)(struct gl_framebuffer *fb);

commit 620d11aed40088a33011eb62dee911ac5b5a6985
Author: Tom Stellard <thomas.stellard@amd.com>
Date:   Thu Aug 22 11:22:58 2013 -0400

    radeonsi/compute: Fix LDS size calculation
    
    We need to include the number of LDS bytes allocated by the state tracker.
    
    CC: "10.0" <mesa-stable@lists.freedesktop.org>
    (cherry picked from commit 1bdb99330ac68003a9ee6c963f46bddb03b9073d)

diff --git a/src/gallium/drivers/radeonsi/radeonsi_compute.c b/src/gallium/drivers/radeonsi/radeonsi_compute.c
index 5df972f..2d53f2d 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_compute.c
+++ b/src/gallium/drivers/radeonsi/radeonsi_compute.c
@@ -103,6 +103,7 @@ static void radeonsi_launch_grid(
 	unsigned arg_user_sgpr_count = 2;
 	unsigned i;
 	struct si_pipe_shader *shader = &program->kernels[pc];
+	unsigned lds_blocks;
 
 	pm4->compute_pkt = true;
 	si_cmd_context_control(pm4);
@@ -194,6 +195,20 @@ static void radeonsi_launch_grid(
 		                        shader->num_sgprs)) - 1) / 8))
 		;
 
+	lds_blocks = shader->lds_size;
+	/* XXX: We are over allocating LDS.  For SI, the shader reports LDS in
+	 * blocks of 256 bytes, so if there are 4 bytes lds allocated in
+	 * the shader and 4 bytes allocated by the state tracker, then
+	 * we will set LDS_SIZE to 512 bytes rather than 256.
+	 */
+	if (rctx->b.chip_class <= SI) {
+		lds_blocks += align(program->local_size, 256) >> 8;
+	} else {
+		lds_blocks += align(program->local_size, 512) >> 9;
+	}
+
+	assert(lds_blocks <= 0xFF);
+
 	si_pm4_set_reg(pm4, R_00B84C_COMPUTE_PGM_RSRC2,
 		S_00B84C_SCRATCH_EN(0)
 		| S_00B84C_USER_SGPR(arg_user_sgpr_count)
@@ -202,7 +217,7 @@ static void radeonsi_launch_grid(
 		| S_00B84C_TGID_Z_EN(1)
 		| S_00B84C_TG_SIZE_EN(1)
 		| S_00B84C_TIDIG_COMP_CNT(2)
-		| S_00B84C_LDS_SIZE(shader->lds_size)
+		| S_00B84C_LDS_SIZE(lds_blocks)
 		| S_00B84C_EXCP_EN(0))
 		;
 	si_pm4_set_reg(pm4, R_00B854_COMPUTE_RESOURCE_LIMITS, 0);

commit c8cf5dc401a964cacf88d6bd347f07f31221fc85
Author: Tom Stellard <thomas.stellard@amd.com>
Date:   Tue Nov 19 22:05:52 2013 -0500

    r600g/compute: Add a work-around for flushing issues on Cayman
    
    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    Reviewed-by: Marek Olšák <marek.olsak@amd.com>
    
    https://bugs.freedesktop.org/show_bug.cgi?id=69321
    
    CC: "10.0" <mesa-stable@lists.freedesktop.org>
    (cherry picked from commit 7a30cd7085b6879d3858f5c1a6945fbe30c818a6)

diff --git a/src/gallium/drivers/r600/evergreen_compute.c b/src/gallium/drivers/r600/evergreen_compute.c
index ffdc5c3..d668c8e 100644
--- a/src/gallium/drivers/r600/evergreen_compute.c
+++ b/src/gallium/drivers/r600/evergreen_compute.c
@@ -474,6 +474,10 @@ static void compute_emit_cs(struct r600_context *ctx, const uint *block_layout,
 	r600_flush_emit(ctx);
 	ctx->b.flags = 0;
 
+	if (ctx->b.chip_class >= CAYMAN) {
+		ctx->skip_surface_sync_on_next_cs_flush = true;
+	}
+
 #if 0
 	COMPUTE_DBG(ctx->screen, "cdw: %i\n", cs->cdw);
 	for (i = 0; i < cs->cdw; i++) {
diff --git a/src/gallium/drivers/r600/r600_hw_context.c b/src/gallium/drivers/r600/r600_hw_context.c
index 5f3a9bd..191a81d 100644
--- a/src/gallium/drivers/r600/r600_hw_context.c
+++ b/src/gallium/drivers/r600/r600_hw_context.c
@@ -293,7 +293,7 @@ void r600_flush_emit(struct r600_context *rctx)
 				S_0085F0_SMX_ACTION_ENA(1);
 	}
 
-	if (cp_coher_cntl) {
+	if (cp_coher_cntl && !rctx->skip_surface_sync_on_next_cs_flush) {
 		cs->buf[cs->cdw++] = PKT3(PKT3_SURFACE_SYNC, 3, 0);
 		cs->buf[cs->cdw++] = cp_coher_cntl;   /* CP_COHER_CNTL */
 		cs->buf[cs->cdw++] = 0xffffffff;      /* CP_COHER_SIZE */
@@ -354,6 +354,8 @@ void r600_context_flush(struct r600_context *ctx, unsigned flags)
 
 	/* Flush the CS. */
 	ctx->b.ws->cs_flush(ctx->b.rings.gfx.cs, flags, ctx->screen->cs_count++);
+
+	ctx->skip_surface_sync_on_next_cs_flush = false;
 }
 
 void r600_begin_new_cs(struct r600_context *ctx)
diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h
index d7af618..f0d4be4 100644
--- a/src/gallium/drivers/r600/r600_pipe.h
+++ b/src/gallium/drivers/r600/r600_pipe.h
@@ -507,6 +507,16 @@ struct r600_context {
 
 	void				*sb_context;
 	struct r600_isa		*isa;
+
+	/* Work-around for flushing problems with compute shaders on Cayman:
+	 * Emitting a SURFACE_SYNC packet with any of the CB*_DEST_BASE_ENA
+	 * or DB_DEST_BASE_ENA bits set after dispatching a compute shader
+	 * hangs the GPU.
+	 *
+	 * Setting this to true will prevent r600_flush_emit() from emitting
+	 * a SURFACE_SYNC packet.  This field will be cleared by
+	 * by r600_context_flush() after flushing the command stream. */
+	boolean				skip_surface_sync_on_next_cs_flush;
 };
 
 static INLINE void r600_emit_command_buffer(struct radeon_winsys_cs *cs,

commit a645df01340d758b79905696a7ae41e196ba57f5
Author: Paul Berry <stereotype441@gmail.com>
Date:   Fri Nov 15 14:23:45 2013 -0800

    glsl: Fix interstage uniform interface block link error detection.
    
    Previously, we checked for interstage uniform interface block link
    errors in validate_interstage_interface_blocks(), which is only called
    on pairs of adjacent shader stages.  Therefore, we failed to detect
    uniform interface block mismatches between non-adjacent shader stages.
    
    Before the introduction of geometry shaders, this wasn't a problem,
    because the only supported shader stages were vertex and fragment
    shaders, therefore they were always adjacent.  However, now that we
    allow a program to contain vertex, geometry, and fragment shaders,
    that is no longer the case.
    
    Fixes piglit test "skip-stage-uniform-block-array-size-mismatch".
    
    Cc: "10.0" <mesa-stable@lists.freedesktop.org>
    
    v2: Rename validate_interstage_interface_blocks() to
    validate_interstage_inout_blocks() to reflect the fact that it no
    longer validates uniform blocks.
    
    Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
    
    v3: Make validate_interstage_inout_blocks() skip uniform blocks.
    
    Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
    (cherry picked from commit 544e3129c5addeb6c9539339782dd54616ef0499)

diff --git a/src/glsl/link_interface_blocks.cpp b/src/glsl/link_interface_blocks.cpp
index 528d4a1..6900fa9 100644
--- a/src/glsl/link_interface_blocks.cpp
+++ b/src/glsl/link_interface_blocks.cpp
@@ -308,57 +308,78 @@ validate_intrastage_interface_blocks(struct gl_shader_program *prog,
 }
 
 void
-validate_interstage_interface_blocks(struct gl_shader_program *prog,
-                                     const gl_shader *producer,
-                                     const gl_shader *consumer)
+validate_interstage_inout_blocks(struct gl_shader_program *prog,
+                                 const gl_shader *producer,
+                                 const gl_shader *consumer)
 {
-   interface_block_definitions inout_interfaces;
-   interface_block_definitions uniform_interfaces;
+   interface_block_definitions definitions;
    const bool extra_array_level = consumer->Type == GL_GEOMETRY_SHADER;
 
-   /* Add non-output interfaces from the consumer to the symbol table. */
+   /* Add input interfaces from the consumer to the symbol table. */
    foreach_list(node, consumer->ir) {
       ir_variable *var = ((ir_instruction *) node)->as_variable();
-      if (!var || !var->get_interface_type() || var->mode == ir_var_shader_out)
+      if (!var || !var->get_interface_type() || var->mode != ir_var_shader_in)
          continue;
 
-      interface_block_definitions *definitions = var->mode == ir_var_uniform ?
-         &uniform_interfaces : &inout_interfaces;
-      definitions->store(interface_block_definition(var));
+      definitions.store(interface_block_definition(var));
    }
 
-   /* Verify that the producer's interfaces match. */
+   /* Verify that the producer's output interfaces match. */
    foreach_list(node, producer->ir) {
       ir_variable *var = ((ir_instruction *) node)->as_variable();
-      if (!var || !var->get_interface_type() || var->mode == ir_var_shader_in)
+      if (!var || !var->get_interface_type() || var->mode != ir_var_shader_out)
          continue;
 
-      interface_block_definitions *definitions = var->mode == ir_var_uniform ?
-         &uniform_interfaces : &inout_interfaces;
       interface_block_definition *consumer_def =
-         definitions->lookup(var->get_interface_type()->name);
+         definitions.lookup(var->get_interface_type()->name);
 
       /* The consumer doesn't use this output block.  Ignore it. */
       if (consumer_def == NULL)
          continue;
 
       const interface_block_definition producer_def(var);
-      bool match;
-      if (var->mode == ir_var_uniform) {
-         /* Uniform matching rules are the same for interstage and intrastage
-          * linking.
-          */
-         match = intrastage_match(consumer_def, &producer_def,
-                                  (ir_variable_mode) var->mode);
-      } else {
-         match = interstage_match(&producer_def, consumer_def,
-                                  extra_array_level);
-      }
 
-      if (!match) {
+      if (!interstage_match(&producer_def, consumer_def, extra_array_level)) {
          linker_error(prog, "definitions of interface block `%s' do not "
                       "match\n", var->get_interface_type()->name);
          return;
       }
    }
 }
+
+
+void
+validate_interstage_uniform_blocks(struct gl_shader_program *prog,
+                                   gl_shader **stages, int num_stages)
+{
+   interface_block_definitions definitions;
+
+   for (int i = 0; i < num_stages; i++) {
+      if (stages[i] == NULL)
+         continue;
+
+      const gl_shader *stage = stages[i];
+      foreach_list(node, stage->ir) {
+         ir_variable *var = ((ir_instruction *) node)->as_variable();
+         if (!var || !var->get_interface_type() || var->mode != ir_var_uniform)
+            continue;
+
+         interface_block_definition *old_def =
+            definitions.lookup(var->get_interface_type()->name);
+         const interface_block_definition new_def(var);
+         if (old_def == NULL) {
+            definitions.store(new_def);
+         } else {
+            /* Interstage uniform matching rules are the same as intrastage
+             * uniform matchin rules (for uniforms, it is as though all
+             * shaders are in the same shader stage).
+             */
+            if (!intrastage_match(old_def, &new_def, ir_var_uniform)) {
+               linker_error(prog, "definitions of interface block `%s' do not "
+                            "match\n", var->get_interface_type()->name);
+               return;
+            }
+         }
+      }
+   }
+}
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 1d53b65..fac186a 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -2154,8 +2154,8 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
       if (prog->_LinkedShaders[i] == NULL)
          continue;
 
-      validate_interstage_interface_blocks(prog, prog->_LinkedShaders[prev],
-                                           prog->_LinkedShaders[i]);
+      validate_interstage_inout_blocks(prog, prog->_LinkedShaders[prev],
+                                       prog->_LinkedShaders[i]);
       if (!prog->LinkStatus)
          goto done;
 
@@ -2168,6 +2168,11 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
       prev = i;
    }
 
+   /* Cross-validate uniform blocks between shader stages */
+   validate_interstage_uniform_blocks(prog, prog->_LinkedShaders,
+                                      MESA_SHADER_TYPES);
+   if (!prog->LinkStatus)
+      goto done;
 
    for (unsigned int i = 0; i < MESA_SHADER_TYPES; i++) {
       if (prog->_LinkedShaders[i] != NULL)
diff --git a/src/glsl/linker.h b/src/glsl/linker.h
index 7b1f6f9..130915d 100644
--- a/src/glsl/linker.h
+++ b/src/glsl/linker.h
@@ -65,9 +65,13 @@ validate_intrastage_interface_blocks(struct gl_shader_program *prog,
                                      unsigned num_shaders);
 
 void
-validate_interstage_interface_blocks(struct gl_shader_program *prog,
-                                     const gl_shader *producer,
-                                     const gl_shader *consumer);
+validate_interstage_inout_blocks(struct gl_shader_program *prog,
+                                 const gl_shader *producer,
+                                 const gl_shader *consumer);
+
+void
+validate_interstage_uniform_blocks(struct gl_shader_program *prog,
+                                   gl_shader **stages, int num_stages);
 
 extern void
 link_assign_atomic_counter_resources(struct gl_context *ctx,

commit 3470916d6af016254fe938324d67d58307384920
Author: Paul Berry <stereotype441@gmail.com>
Date:   Tue Nov 19 17:48:02 2013 -0800

    glsl: Fix cross-version linking between VS and GS.
    
    Previously, when attempting to link a vertex shader and a geometry
    shader that use different GLSL versions, we would sometimes generate a
    link error due to the implicit declaration of gl_PerVertex being
    different between the two GLSL versions.
    
    This patch fixes that problem by only requiring interface block
    definitions to match when they are explicitly declared.
    
    Fixes piglit test "shaders/version-mixing vs-gs".
    
    Cc: "10.0" <mesa-stable@lists.freedesktop.org>
    
    v2: In the interface_block_definition constructor, move the assignment
    to explicitly_declared after the existing if block.
    
    Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
    (cherry picked from commit 0f4cacbb53c23e4fa027375c492edd17b40ae748)

diff --git a/src/glsl/link_interface_blocks.cpp b/src/glsl/link_interface_blocks.cpp
index a7fceb9..528d4a1 100644


Reply to: