[Mesa-dev] [PATCH 6/7] isl: Add a helper for getting a depth format from an isl_format
Jason Ekstrand
jason at jlekstrand.net
Sat Aug 6 17:31:21 UTC 2016
---
src/intel/isl/isl.h | 2 ++
src/intel/isl/isl_format.c | 24 ++++++++++++++++++++++++
2 files changed, 26 insertions(+)
diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h
index 19673f8..4caf0e8 100644
--- a/src/intel/isl/isl.h
+++ b/src/intel/isl/isl.h
@@ -1016,6 +1016,8 @@ isl_format_has_int_channel(enum isl_format fmt)
unsigned isl_format_get_num_channels(enum isl_format fmt);
+uint32_t isl_format_get_depth_format(enum isl_format fmt, bool has_stencil);
+
static inline bool
isl_format_is_compressed(enum isl_format fmt)
{
diff --git a/src/intel/isl/isl_format.c b/src/intel/isl/isl_format.c
index 73688a7..41d3050 100644
--- a/src/intel/isl/isl_format.c
+++ b/src/intel/isl/isl_format.c
@@ -494,6 +494,30 @@ isl_format_get_num_channels(enum isl_format fmt)
(fmtl->channels.i.bits > 0);
}
+uint32_t
+isl_format_get_depth_format(enum isl_format fmt, bool has_stencil)
+{
+ switch (fmt) {
+ default:
+ unreachable("bad isl depth format");
+ case ISL_FORMAT_R32_FLOAT_X8X24_TYPELESS:
+ assert(has_stencil);
+ return 0; /* D32_FLOAT_S8X24_UINT */
+ case ISL_FORMAT_R32_FLOAT:
+ assert(!has_stencil);
+ return 1; /* D32_FLOAT */
+ case ISL_FORMAT_R24_UNORM_X8_TYPELESS:
+ if (has_stencil) {
+ return 2; /* D24_UNORM_S8_UINT */
+ } else {
+ return 3; /* D24_UNORM_X8_UINT */
+ }
+ case ISL_FORMAT_R16_UNORM:
+ assert(!has_stencil);
+ return 5; /* D16_UNORM */
+ }
+}
+
enum isl_format
isl_format_rgb_to_rgba(enum isl_format rgb)
{
--
2.5.0.400.gff86faf
More information about the mesa-dev
mailing list