aboutsummaryrefslogtreecommitdiff
path: root/demo/d3d12/NvCoDxFormatUtil.h
diff options
context:
space:
mode:
authorMiles Macklin <[email protected]>2017-06-09 13:41:15 +1200
committerMiles Macklin <[email protected]>2017-06-09 13:41:15 +1200
commit688b5f42e9bfe498d7af7075d4d8f4429867f3a3 (patch)
tree7e0d0e7c95298f0418723abd92f61ac6e16b055e /demo/d3d12/NvCoDxFormatUtil.h
parentUpdate README.md (diff)
downloadflex-688b5f42e9bfe498d7af7075d4d8f4429867f3a3.tar.xz
flex-688b5f42e9bfe498d7af7075d4d8f4429867f3a3.zip
1.2.0.beta.11.2.0.beta.1
Diffstat (limited to 'demo/d3d12/NvCoDxFormatUtil.h')
-rw-r--r--demo/d3d12/NvCoDxFormatUtil.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/demo/d3d12/NvCoDxFormatUtil.h b/demo/d3d12/NvCoDxFormatUtil.h
new file mode 100644
index 0000000..e749ea8
--- /dev/null
+++ b/demo/d3d12/NvCoDxFormatUtil.h
@@ -0,0 +1,41 @@
+#ifndef NV_CO_DX_FORMAT_UTIL_H
+#define NV_CO_DX_FORMAT_UTIL_H
+
+#define NOMINMAX
+#include <dxgi.h>
+
+namespace nvidia {
+namespace Common {
+
+struct DxFormatUtil
+{
+ enum UsageType
+ {
+ USAGE_UNKNOWN, ///< Generally used to mark an error
+ USAGE_TARGET, ///< Format should be used when written as target
+ USAGE_DEPTH_STENCIL, ///< Format should be used when written as depth stencil
+ USAGE_SRV, ///< Format if being read as srv
+ USAGE_COUNT_OF,
+ };
+ enum UsageFlag
+ {
+ USAGE_FLAG_MULTI_SAMPLE = 0x1,
+ USAGE_FLAG_SRV = 0x2,
+ };
+
+ /// Given the usage, flags, and format will return the most suitable format. Will return DXGI_UNKNOWN if combination is not possible
+ static DXGI_FORMAT calcFormat(UsageType usage, DXGI_FORMAT format);
+ /// Calculate appropriate format for creating a buffer for usage and flags
+ static DXGI_FORMAT calcResourceFormat(UsageType usage, int usageFlags, DXGI_FORMAT format);
+ /// True if the type is 'typeless'
+ static bool isTypeless(DXGI_FORMAT format);
+
+ /// Returns number of bits used for color channel for format (for channels with multiple sizes, returns smallest ie RGB565 -> 5)
+ static int getNumColorChannelBits(DXGI_FORMAT fmt);
+
+};
+
+} // namespace Common
+} // namespace nvidia
+
+#endif // NV_CO_DX12_RESOURCE_H