diff options
author | Jason Ekstrand <[email protected]> | 2016-11-28 15:44:13 -0800 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2016-11-28 20:17:16 -0800 |
commit | d4ef87c1bb4290293148cbd6cb782764df38f8f4 (patch) | |
tree | 490f2088e41d350be63624d0f144d89a841a4e2c | |
parent | e6847f24f032b094b5a40012968ca79a5fdc67b4 (diff) |
anv/cmd_buffer: Set the correct surface type for depth/stencil
Reviewed-by: Nanley Chery <[email protected]>
-rw-r--r-- | src/intel/vulkan/genX_cmd_buffer.c | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c index a965cd633c9..e9a1ef9dfac 100644 --- a/src/intel/vulkan/genX_cmd_buffer.c +++ b/src/intel/vulkan/genX_cmd_buffer.c @@ -2033,6 +2033,51 @@ genX(cmd_buffer_emit_gen7_depth_flush)(struct anv_cmd_buffer *cmd_buffer) } } +static uint32_t +depth_stencil_surface_type(enum isl_surf_dim dim) +{ + switch (dim) { + case ISL_SURF_DIM_1D: + if (GEN_GEN >= 9) { + /* From the Sky Lake PRM, 3DSTATAE_DEPTH_BUFFER::SurfaceType + * + * Programming Notes: + * The Surface Type of the depth buffer must be the same as the + * Surface Type of the render target(s) (defined in + * SURFACE_STATE), unless either the depth buffer or render + * targets are SURFTYPE_NULL (see exception below for SKL). 1D + * surface type not allowed for depth surface and stencil surface. + * + * Workaround: + * If depth/stencil is enabled with 1D render target, + * depth/stencil surface type needs to be set to 2D surface type + * and height set to 1. Depth will use (legacy) TileY and stencil + * will use TileW. For this case only, the Surface Type of the + * depth buffer can be 2D while the Surface Type of the render + * target(s) are 1D, representing an exception to a programming + * note above. + */ + return SURFTYPE_2D; + } else { + return SURFTYPE_1D; + } + case ISL_SURF_DIM_2D: + return SURFTYPE_2D; + case ISL_SURF_DIM_3D: + if (GEN_GEN >= 9) { + /* The Sky Lake docs list the value for 3D as "Reserved". However, + * they have the exact same layout as 2D arrays on gen9+, so we can + * just use 2D here. + */ + return SURFTYPE_2D; + } else { + return SURFTYPE_3D; + } + default: + unreachable("Invalid surface dimension"); + } +} + static void cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer) { @@ -2054,7 +2099,8 @@ cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer) /* Emit 3DSTATE_DEPTH_BUFFER */ if (has_depth) { anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_DEPTH_BUFFER), db) { - db.SurfaceType = SURFTYPE_2D; + db.SurfaceType = + depth_stencil_surface_type(image->depth_surface.isl.dim); db.DepthWriteEnable = true; db.StencilWriteEnable = has_stencil; @@ -2106,7 +2152,12 @@ cmd_buffer_emit_depth_stencil(struct anv_cmd_buffer *cmd_buffer) * be combined with a stencil buffer so we use D32_FLOAT instead. */ anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_DEPTH_BUFFER), db) { - db.SurfaceType = SURFTYPE_2D; + if (has_stencil) { + db.SurfaceType = SURFTYPE_2D; + depth_stencil_surface_type(image->stencil_surface.isl.dim); + } else { + db.SurfaceType = SURFTYPE_2D; + } db.SurfaceFormat = D32_FLOAT; db.Width = fb->width - 1; db.Height = fb->height - 1; |