From 4d24f55226870055c8dcbb3409efc5355da134d7 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Thu, 20 Apr 2023 20:06:37 +0800 Subject: 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 --- tools/gfx/d3d/d3d-util.cpp | 37 ++++++++++++------------------------- tools/gfx/d3d/d3d-util.h | 4 ---- 2 files changed, 12 insertions(+), 29 deletions(-) (limited to 'tools/gfx/d3d') 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 -#include #include #include +#if SLANG_ENABLE_FXC +#include +#endif // We will use the C standard library just for printing error messages. #include @@ -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& 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) { diff --git a/tools/gfx/d3d/d3d-util.h b/tools/gfx/d3d/d3d-util.h index 1869d7de6..a35928f47 100644 --- a/tools/gfx/d3d/d3d-util.h +++ b/tools/gfx/d3d/d3d-util.h @@ -76,10 +76,6 @@ class D3DUtil /// 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& out); - - static SlangResult createFactory(DeviceCheckFlags flags, Slang::ComPtr& outFactory); /// Get the dxgiModule -- cgit v1.2.3