[Mesa-dev] [RFC PATCH 02/12] gen7 depth surface: calculate more specific surface type

Paul Berry stereotype441 at gmail.com
Wed Jul 17 12:07:13 PDT 2013


On 15 July 2013 17:14, Jordan Justen <jordan.l.justen at intel.com> wrote:

> 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 at intel.com>
> ---
>  src/mesa/drivers/dri/i965/gen7_blorp.cpp    |   11 +++++++++++
>  src/mesa/drivers/dri/i965/gen7_misc_state.c |   26
> ++++++++++++++++++++++++++
>  2 files changed, 37 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/gen7_blorp.cpp
> b/src/mesa/drivers/dri/i965/gen7_blorp.cpp
> index acd6237..32dadf7 100644
> --- a/src/mesa/drivers/dri/i965/gen7_blorp.cpp
> +++ b/src/mesa/drivers/dri/i965/gen7_blorp.cpp
> @@ -657,12 +657,23 @@ gen7_blorp_emit_depth_stencil_config(struct
> brw_context *brw,
>     uint32_t draw_x = params->depth.x_offset;
>     uint32_t draw_y = params->depth.y_offset;
>     uint32_t tile_mask_x, tile_mask_y;
> +   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:
> +      surftype = BRW_SURFACE_2D;
>

The PRM claims that this shouldn't be necessary (it should be possible to
set the surface type to BRW_SURFACE_CUBE, which is what
translate_tex_target does).  However, as you and I have discussed
previously, this doesn't work--there appears to be a bug in either the
hardware or the documentation.

Since we're deliberately doing something that the docs claim is
unnecessary, I'd recommend adding a comment here (and
gen7_emit_depth_stencil_hiz) just to make sure no one tries to come along
in the future and delete the code you're adding.  Maybe something like this?


      /* 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;

With that change, this patch is:

Reviewed-by: Paul Berry <stereotype441 at gmail.com>


> +      break;
> +   default:
> +      surftype = translate_tex_target(gl_target);
> +      break;
> +   }
>
>     /* 3DSTATE_DEPTH_BUFFER */
>     {
> diff --git a/src/mesa/drivers/dri/i965/gen7_misc_state.c
> b/src/mesa/drivers/dri/i965/gen7_misc_state.c
> index fe63fef..b3734e0 100644
> --- a/src/mesa/drivers/dri/i965/gen7_misc_state.c
> +++ b/src/mesa/drivers/dri/i965/gen7_misc_state.c
> @@ -21,6 +21,7 @@
>   * IN THE SOFTWARE.
>   */
>
> +#include "main/mtypes.h"
>  #include "intel_batchbuffer.h"
>  #include "intel_mipmap_tree.h"
>  #include "intel_regions.h"
> @@ -40,9 +41,34 @@ gen7_emit_depth_stencil_hiz(struct brw_context *brw,
>                              uint32_t tile_x, uint32_t tile_y)
>  {
>     struct gl_context *ctx = &brw->ctx;
> +   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:
> +      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));
> --
> 1.7.10.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20130717/8fb2e674/attachment.html>


More information about the mesa-dev mailing list