summaryrefslogtreecommitdiff
path: root/tools/render-test/d3d-util.h
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2018-04-02 19:59:33 -0400
committerTim Foley <tfoleyNV@users.noreply.github.com>2018-04-02 16:59:33 -0700
commit38d5ef4764e9271ce2360f42b0759a236cddd9fe (patch)
tree6c8eafb72eb997167dd77e3d1d5abc3582c5789a /tools/render-test/d3d-util.h
parent5a0273848aa4b854bb3c99a81701b044a8929bf8 (diff)
Feature/dx12 (#469)
* Fix signed/unsigned comparison warning. * Split out d3d functions that will work across dx11 and 12. * Improve slang-test/README.md around command line options. * Make Guid comparison honor alignment for comparisons, such that mechanism work on architectures that can only do aligned accesses. * Initial setup of D3D12 Renderer, with presentFrame and clearFrame. * More support for D3D12 * Added FreeList * Added D3D12CircularResourceHeap * First attempt at createBuffer * First pass at map/unmap. * First pass binding vertex/constant buffers, and setting up InputLayout. Note that memory is not kept in scope on binding yet. * First pass of D3DDescriptorHeap * Small tidy up in render-d3d11. Added D3DDescriptorHeap to project. * First pass at D3D12 bind state. * Fix typos in D3D12Resource * Tidy up Dx11 render binding a little to match more with Dx12 style. * First pass at Dx12 BindingState * Handling of the command list d3d12. Support for submitGpuWork and waitForGpu. * First attempt at Dx12 capture of backbuffer to file. * First attempt at D3D12 binding for graphics. * D3D12 setup viewport etc - does now render triangle in render0.hlsl. * First pass at support for compute on D3D12Renderer * Use spaces over tabs in D3DUtil * Tabs to spaces in D3D12DescriptorHeap * Convert tab->spaces on render-d3d12.cpp
Diffstat (limited to 'tools/render-test/d3d-util.h')
-rw-r--r--tools/render-test/d3d-util.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/tools/render-test/d3d-util.h b/tools/render-test/d3d-util.h
new file mode 100644
index 000000000..95ccf4b18
--- /dev/null
+++ b/tools/render-test/d3d-util.h
@@ -0,0 +1,61 @@
+// d3d-util.h
+#pragma once
+
+#include <stdint.h>
+#include "../../source/core/slang-result.h"
+#include "../../source/core/slang-com-ptr.h"
+#include "../../source/core/list.h"
+
+#include "render.h"
+
+#include <D3Dcommon.h>
+#include <DXGIFormat.h>
+
+namespace renderer_test {
+
+class D3DUtil
+{
+ public:
+ 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,
+ };
+
+ /// Get primitive topology as D3D primitive topology
+ static D3D_PRIMITIVE_TOPOLOGY getPrimitiveTopology(PrimitiveTopology prim);
+
+ /// Calculate size taking into account alignment. Alignment must be a power of 2
+ static UInt calcAligned(UInt size, UInt alignment) { return (size + alignment - 1) & ~(alignment - 1); }
+
+ /// The Slang compiler currently generates HLSL source, so we'll need a utility
+ /// routine (defined later) to translate that into D3D11 shader bytecode.
+ /// Definition of the HLSL-to-bytecode compilation logic.
+ static Slang::Result compileHLSLShader(char const* sourcePath, char const* source, char const* entryPointName, char const* dxProfileName, Slang::ComPtr<ID3DBlob>& shaderBlobOut);
+
+ static DXGI_FORMAT getMapFormat(Format format);
+
+
+ /// 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);
+
+ /// Append text in in, into wide char array
+ static void appendWideChars(const char* in, Slang::List<wchar_t>& out);
+};
+
+} // renderer_test