summaryrefslogtreecommitdiffstats
path: root/tools/gfx/d3d/d3d-util.cpp
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2023-04-20 20:06:37 +0800
committerGitHub <noreply@github.com>2023-04-20 20:06:37 +0800
commit4d24f55226870055c8dcbb3409efc5355da134d7 (patch)
tree479c4341e38dcea2f1b9a831cf6ce0dea20234ac /tools/gfx/d3d/d3d-util.cpp
parent588991f6df3d6813378721166a7260990835817e (diff)
Changes for vkd3d proton (#2813)
* Add some caches to .gitignore * Remove appendWideChars Use String::toWString instead * s/Sleep/sleepCurrentThread * formatting * Expand set of shared libraries which have buggy dlclose Work around https://github.com/microsoft/DirectXShaderCompiler/issues/5119 and https://github.com/doitsujin/dxvk/issues/3330 libdxcompiler.so invokes UB on dlclose, the dxvk libs break GDB when closed * Add assert for specialization failure on DX11 As a band aid for https://github.com/shader-slang/slang/issues/2805 * More fine grained selection of directx features
Diffstat (limited to 'tools/gfx/d3d/d3d-util.cpp')
-rw-r--r--tools/gfx/d3d/d3d-util.cpp37
1 files changed, 12 insertions, 25 deletions
diff --git a/tools/gfx/d3d/d3d-util.cpp b/tools/gfx/d3d/d3d-util.cpp
index eece71c16..c5092ddbd 100644
--- a/tools/gfx/d3d/d3d-util.cpp
+++ b/tools/gfx/d3d/d3d-util.cpp
@@ -2,9 +2,11 @@
#include "d3d-util.h"
#include <d3d12.h>
-#include <d3dcompiler.h>
#include <dxgi1_4.h>
#include <dxgidebug.h>
+#if SLANG_ENABLE_FXC
+#include <d3dcompiler.h>
+#endif
// We will use the C standard library just for printing error messages.
#include <stdio.h>
@@ -423,6 +425,9 @@ bool D3DUtil::isTypeless(DXGI_FORMAT format)
// shader bytecode as part of an offline process, rather than doing it
// on-the-fly like this
//
+#if !SLANG_ENABLE_FXC
+ return SLANG_E_NOT_IMPLEMENTED;
+#else
static pD3DCompile compileFunc = nullptr;
if (!compileFunc)
{
@@ -476,35 +481,15 @@ bool D3DUtil::isTypeless(DXGI_FORMAT format)
SLANG_RETURN_ON_FAIL(hr);
shaderBlobOut.swap(shaderBlob);
return SLANG_OK;
-}
-
-/* static */void D3DUtil::appendWideChars(const char* in, List<wchar_t>& out)
-{
- size_t len = ::strlen(in);
-
- const DWORD dwFlags = 0;
- int outSize = ::MultiByteToWideChar(CP_UTF8, dwFlags, in, int(len), nullptr, 0);
-
- if (outSize > 0)
- {
- const Index prevSize = out.getCount();
- out.setCount(prevSize + len + 1);
-
- WCHAR* dst = out.getBuffer() + prevSize;
- ::MultiByteToWideChar(CP_UTF8, dwFlags, in, int(len), dst, outSize);
- // Make null terminated
- dst[outSize] = 0;
- // Remove terminating 0 from array
- out.unsafeShrinkToCount(prevSize + outSize);
- }
+#endif // SLANG_ENABLE_FXC
}
/* static */SharedLibrary::Handle D3DUtil::getDxgiModule()
{
-#if SLANG_WINDOWS_FAMILY
- const char* const libPath = "dxgi";
-#else
+#if SLANG_ENABLE_DXVK
const char* const libPath = "dxvk_dxgi";
+#else
+ const char* const libPath = "dxgi";
#endif
static SharedLibrary::Handle s_dxgiModule = [&](){
SharedLibrary::Handle h = nullptr;
@@ -849,6 +834,7 @@ D3D12_RESOURCE_STATES D3DUtil::getResourceState(ResourceState state)
{
static IDXGIDebug* dxgiDebug = nullptr;
+#if SLANG_ENABLE_DXGI_DEBUG
if (!dxgiDebug)
{
HMODULE debugModule = LoadLibraryA("dxgidebug.dll");
@@ -861,6 +847,7 @@ D3D12_RESOURCE_STATES D3DUtil::getResourceState(ResourceState state)
}
}
}
+#endif
if (dxgiDebug)
{