From: Chad Versace Date: Tue, 9 Feb 2016 02:48:41 +0000 (-0800) Subject: isl: Add func isl_surf_get_depth_format() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0a9306799380ff13dc21c0b7626a0e1a4d338d7d;p=mesa.git isl: Add func isl_surf_get_depth_format() For depth surfaces, it gets the value for 3DSTATE_DEPTH_BUFFER.SurfaceFormat. --- diff --git a/src/isl/isl.c b/src/isl/isl.c index ec6323741e8..f5b2cd5b250 100644 --- a/src/isl/isl.c +++ b/src/isl/isl.c @@ -1382,3 +1382,43 @@ isl_surf_get_image_intratile_offset_el(const struct isl_device *dev, *x_offset_el = small_x_offset_el; *y_offset_el = small_y_offset_el; } + +uint32_t +isl_surf_get_depth_format(const struct isl_device *dev, + const struct isl_surf *surf) +{ + /* Support for separate stencil buffers began in gen5. Support for + * interleaved depthstencil buffers ceased in gen7. The intermediate gens, + * those that supported separate and interleaved stencil, were gen5 and + * gen6. + * + * For a list of all available formats, see the Sandybridge PRM >> Volume + * 2 Part 1: 3D/Media - 3D Pipeline >> 3DSTATE_DEPTH_BUFFER >> Surface + * Format (p321). + */ + + assert(surf->usage & ISL_SURF_USAGE_DEPTH_BIT); + + if (surf->usage & ISL_SURF_USAGE_STENCIL_BIT) + assert(ISL_DEV_GEN(dev) < 7); + + switch (surf->format) { + default: + unreachable("bad isl depth format"); + case ISL_FORMAT_R32_FLOAT_X8X24_TYPELESS: + assert(ISL_DEV_GEN(dev) < 7); + return 0; /* D32_FLOAT_S8X24_UINT */ + case ISL_FORMAT_R32_FLOAT: + return 1; /* D32_FLOAT */ + case ISL_FORMAT_R24_UNORM_X8_TYPELESS: + if (surf->usage & ISL_SURF_USAGE_STENCIL_BIT) { + assert(ISL_DEV_GEN(dev) < 7); + return 2; /* D24_UNORM_S8_UINT */ + } else { + assert(ISL_DEV_GEN(dev) >= 5); + return 3; /* D24_UNORM_X8_UINT */ + } + case ISL_FORMAT_R16_UNORM: + return 5; /* D16_UNORM */ + } +} diff --git a/src/isl/isl.h b/src/isl/isl.h index bc7a315e8ae..3e0ff935948 100644 --- a/src/isl/isl.h +++ b/src/isl/isl.h @@ -1010,6 +1010,16 @@ isl_surf_get_image_intratile_offset_el(const struct isl_device *dev, uint32_t *x_offset_el, uint32_t *y_offset_el); +/** + * @brief Get value of 3DSTATE_DEPTH_BUFFER.SurfaceFormat + * + * @pre surf->usage has ISL_SURF_USAGE_DEPTH_BIT + * @pre surf->format must be a valid format for depth surfaces + */ +uint32_t +isl_surf_get_depth_format(const struct isl_device *dev, + const struct isl_surf *surf); + #ifdef __cplusplus } #endif