isl: Add func isl_surf_get_depth_format()

For depth surfaces, it gets the value for
3DSTATE_DEPTH_BUFFER.SurfaceFormat.
This commit is contained in:
Chad Versace 2016-02-08 18:48:41 -08:00
parent 4d037b551e
commit 0a93067993
2 changed files with 50 additions and 0 deletions

View file

@ -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 */
}
}

View file

@ -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