gen7 depth surface: calculate more specific surface type
authorJordan Justen <jordan.l.justen@intel.com>
Tue, 9 Jul 2013 21:56:38 +0000 (14:56 -0700)
committerJordan Justen <jordan.l.justen@intel.com>
Sun, 4 Aug 2013 18:52:37 +0000 (11:52 -0700)
This will be used in 3DSTATE_DEPTH_BUFFER in a later patch.

Note: Cube maps are treated as 2D arrays with 6 times as
many array elements as the cube map array would have.

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
src/mesa/drivers/dri/i965/gen7_blorp.cpp
src/mesa/drivers/dri/i965/gen7_misc_state.c

index 71a5a308e77ad5d7faf72f02a61de4b263e2f786..b94e9d10db9b1a0672651ef29d8879c56db3d5a2 100644 (file)
@@ -663,12 +663,28 @@ gen7_blorp_emit_depth_stencil_config(struct brw_context *brw,
    uint32_t draw_y = params->depth.y_offset;
    uint32_t tile_mask_x, tile_mask_y;
    uint8_t mocs = brw->is_haswell ? GEN7_MOCS_L3 : 0;
+   uint32_t surftype;
+   GLenum gl_target = params->depth.mt->target;
 
    brw_get_depthstencil_tile_masks(params->depth.mt,
                                    params->depth.level,
                                    params->depth.layer,
                                    NULL,
                                    &tile_mask_x, &tile_mask_y);
+   switch (gl_target) {
+   case GL_TEXTURE_CUBE_MAP_ARRAY:
+   case GL_TEXTURE_CUBE_MAP:
+      /* The PRM claims that we should use BRW_SURFACE_CUBE for this
+       * situation, but experiments show that gl_Layer doesn't work when we do
+       * this.  So we use BRW_SURFACE_2D, since for rendering purposes this is
+       * equivalent.
+       */
+      surftype = BRW_SURFACE_2D;
+      break;
+   default:
+      surftype = translate_tex_target(gl_target);
+      break;
+   }
 
    /* 3DSTATE_DEPTH_BUFFER */
    {
index 7d63b2e778bd840382a3508d000130135eda2c83..e460ccca51376b4366da5e7dfed6c566dc29b878 100644 (file)
@@ -21,6 +21,7 @@
  * IN THE SOFTWARE.
  */
 
+#include "main/mtypes.h"
 #include "intel_batchbuffer.h"
 #include "intel_mipmap_tree.h"
 #include "intel_regions.h"
@@ -41,9 +42,39 @@ gen7_emit_depth_stencil_hiz(struct brw_context *brw,
 {
    struct gl_context *ctx = &brw->ctx;
    uint8_t mocs = brw->is_haswell ? GEN7_MOCS_L3 : 0;
+   struct gl_framebuffer *fb = ctx->DrawBuffer;
+   uint32_t surftype;
+   GLenum gl_target = GL_TEXTURE_2D;
+   const struct intel_renderbuffer *irb = NULL;
+   const struct gl_renderbuffer *rb = NULL;
 
    intel_emit_depth_stall_flushes(brw);
 
+   irb = intel_get_renderbuffer(fb, BUFFER_DEPTH);
+   if (!irb)
+      irb = intel_get_renderbuffer(fb, BUFFER_STENCIL);
+   rb = (struct gl_renderbuffer*) irb;
+
+   if (rb) {
+      if (rb->TexImage)
+         gl_target = rb->TexImage->TexObject->Target;
+   }
+
+   switch (gl_target) {
+   case GL_TEXTURE_CUBE_MAP_ARRAY:
+   case GL_TEXTURE_CUBE_MAP:
+      /* The PRM claims that we should use BRW_SURFACE_CUBE for this
+       * situation, but experiments show that gl_Layer doesn't work when we do
+       * this.  So we use BRW_SURFACE_2D, since for rendering purposes this is
+       * equivalent.
+       */
+      surftype = BRW_SURFACE_2D;
+      break;
+   default:
+      surftype = translate_tex_target(gl_target);
+      break;
+   }
+
    /* _NEW_DEPTH, _NEW_STENCIL, _NEW_BUFFERS */
    BEGIN_BATCH(7);
    OUT_BATCH(GEN7_3DSTATE_DEPTH_BUFFER << 16 | (7 - 2));