diff options
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | slang-gfx.h | 4 | ||||
| -rw-r--r-- | slang.h | 6 | ||||
| -rw-r--r-- | source/compiler-core/slang-fxc-compiler.cpp | 28 | ||||
| -rw-r--r-- | tests/compute/simple.slang | 1 | ||||
| -rw-r--r-- | tools/gfx-unit-test/compute-smoke.cpp | 5 | ||||
| -rw-r--r-- | tools/gfx-unit-test/gfx-test-util.h | 6 | ||||
| -rw-r--r-- | tools/gfx/d3d/d3d-util.cpp | 14 | ||||
| -rw-r--r-- | tools/gfx/d3d12/d3d12-command-encoder.h | 4 | ||||
| -rw-r--r-- | tools/gfx/d3d12/d3d12-device.h | 2 | ||||
| -rw-r--r-- | tools/gfx/d3d12/d3d12-submitter.h | 8 | ||||
| -rw-r--r-- | tools/render-test/render-test-main.cpp | 5 |
12 files changed, 50 insertions, 35 deletions
diff --git a/.gitignore b/.gitignore index 549da7aa0..871471a12 100644 --- a/.gitignore +++ b/.gitignore @@ -80,3 +80,5 @@ build/**/*.log .cache vkd3d-proton.cache +*_d3d11.log +*_dxgi.log diff --git a/slang-gfx.h b/slang-gfx.h index 86ad7d5bc..d110b0f09 100644 --- a/slang-gfx.h +++ b/slang-gfx.h @@ -674,7 +674,7 @@ struct SubresourceRange class ITextureResource: public IResource { public: - static const Size kRemainingTextureSize = 0xFFFFFFFF; + static const GfxCount kRemainingTextureSize = 0xffffffff; struct Offset3D { GfxIndex x = 0; @@ -2058,7 +2058,7 @@ struct AdapterLUID bool operator==(const AdapterLUID& other) const { - for (int i = 0; i < sizeof(AdapterLUID::luid); ++i) + for (size_t i = 0; i < sizeof(AdapterLUID::luid); ++i) if (luid[i] != other.luid[i]) return false; return true; @@ -170,21 +170,21 @@ Any platforms not detected by the above logic are now now explicitly zeroed out. #if SLANG_WINDOWS_FAMILY # define SLANG_ENABLE_DIRECTX 1 # define SLANG_ENABLE_DXGI_DEBUG 1 -# define SLANG_ENABLE_FXC 1 +# define SLANG_ENABLE_DXBC_SUPPORT 1 # define SLANG_ENABLE_PIX 1 # define SLANG_ENABLE_DXVK 0 # define SLANG_ENABLE_VKD3D_PROTON 0 #elif SLANG_LINUX_FAMILY # define SLANG_ENABLE_DIRECTX 0 # define SLANG_ENABLE_DXGI_DEBUG 0 -# define SLANG_ENABLE_FXC 0 +# define SLANG_ENABLE_DXBC_SUPPORT 0 # define SLANG_ENABLE_PIX 0 # define SLANG_ENABLE_DXVK 1 # define SLANG_ENABLE_VKD3D_PROTON 1 #else # define SLANG_ENABLE_DIRECTX 0 # define SLANG_ENABLE_DXGI_DEBUG 0 -# define SLANG_ENABLE_FXC 0 +# define SLANG_ENABLE_DXBC_SUPPORT 0 # define SLANG_ENABLE_PIX 0 # define SLANG_ENABLE_DXVK 0 # define SLANG_ENABLE_VKD3D_PROTON 0 diff --git a/source/compiler-core/slang-fxc-compiler.cpp b/source/compiler-core/slang-fxc-compiler.cpp index 9d547e673..4153585d3 100644 --- a/source/compiler-core/slang-fxc-compiler.cpp +++ b/source/compiler-core/slang-fxc-compiler.cpp @@ -1,6 +1,8 @@ // slang-fxc-compiler.cpp #include "slang-fxc-compiler.h" +#if SLANG_ENABLE_DXBC_SUPPORT + #include "../core/slang-common.h" #include "../../slang-com-helper.h" @@ -28,28 +30,20 @@ #ifdef _WIN32 # include <windows.h> # include <d3dcompiler.h> - -# ifndef SLANG_ENABLE_DXBC_SUPPORT -# define SLANG_ENABLE_DXBC_SUPPORT 1 -# endif #endif -#ifndef SLANG_ENABLE_DXBC_SUPPORT -# define SLANG_ENABLE_DXBC_SUPPORT 0 +// Some of the `D3DCOMPILE_*` constants aren't available in all +// versions of `d3dcompiler.h`, so we define them here just in case +#ifndef D3DCOMPILE_ENABLE_UNBOUNDED_DESCRIPTOR_TABLES +# define D3DCOMPILE_ENABLE_UNBOUNDED_DESCRIPTOR_TABLES (1 << 20) #endif -#if SLANG_ENABLE_DXBC_SUPPORT - // Some of the `D3DCOMPILE_*` constants aren't available in all - // versions of `d3dcompiler.h`, so we define them here just in case -# ifndef D3DCOMPILE_ENABLE_UNBOUNDED_DESCRIPTOR_TABLES -# define D3DCOMPILE_ENABLE_UNBOUNDED_DESCRIPTOR_TABLES (1 << 20) -# endif - -# ifndef D3DCOMPILE_ALL_RESOURCES_BOUND -# define D3DCOMPILE_ALL_RESOURCES_BOUND (1 << 21) -# endif +#ifndef D3DCOMPILE_ALL_RESOURCES_BOUND +# define D3DCOMPILE_ALL_RESOURCES_BOUND (1 << 21) #endif +#endif // SLANG_ENABLE_DXBC_SUPPORT + namespace Slang { @@ -396,6 +390,6 @@ SlangResult FXCDownstreamCompiler::convert(IArtifact* from, const ArtifactDesc& return SLANG_E_NOT_AVAILABLE; } -#endif // SLANG_ENABLE_DXBC_SUPPORT +#endif // else SLANG_ENABLE_DXBC_SUPPORT } diff --git a/tests/compute/simple.slang b/tests/compute/simple.slang index d5f8512bd..0d4efc2e2 100644 --- a/tests/compute/simple.slang +++ b/tests/compute/simple.slang @@ -1,3 +1,4 @@ +//TEST(smoke,compute):COMPARE_COMPUTE:-shaderobj //TEST(smoke,compute):COMPARE_COMPUTE:-dx12 -use-dxil -shaderobj //TEST(smoke,compute):COMPARE_COMPUTE:-cpu -shaderobj //TEST(smoke,compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -shaderobj diff --git a/tools/gfx-unit-test/compute-smoke.cpp b/tools/gfx-unit-test/compute-smoke.cpp index 68925f1e0..5e14a2e00 100644 --- a/tools/gfx-unit-test/compute-smoke.cpp +++ b/tools/gfx-unit-test/compute-smoke.cpp @@ -97,6 +97,11 @@ namespace gfx_test Slang::makeArray<float>(11.0f, 12.0f, 13.0f, 14.0f)); } + SLANG_UNIT_TEST(computeSmokeD3D12) + { + runTestImpl(computeSmokeTestImpl, unitTestContext, Slang::RenderApiFlag::D3D12); + } + SLANG_UNIT_TEST(computeSmokeD3D11) { runTestImpl(computeSmokeTestImpl, unitTestContext, Slang::RenderApiFlag::D3D11); diff --git a/tools/gfx-unit-test/gfx-test-util.h b/tools/gfx-unit-test/gfx-test-util.h index f829d6d12..22b9b2fd3 100644 --- a/tools/gfx-unit-test/gfx-test-util.h +++ b/tools/gfx-unit-test/gfx-test-util.h @@ -108,6 +108,12 @@ namespace gfx_test SLANG_IGNORE_TEST } #endif + // Skip d3d11 tests when we don't have DXBC support as they're bound to + // fail without a backend compiler + if (api == Slang::RenderApiFlag::D3D11 && !SLANG_ENABLE_DXBC_SUPPORT) + { + SLANG_IGNORE_TEST + } try { renderDocBeginFrame(); diff --git a/tools/gfx/d3d/d3d-util.cpp b/tools/gfx/d3d/d3d-util.cpp index c5092ddbd..aff610796 100644 --- a/tools/gfx/d3d/d3d-util.cpp +++ b/tools/gfx/d3d/d3d-util.cpp @@ -4,7 +4,7 @@ #include <d3d12.h> #include <dxgi1_4.h> #include <dxgidebug.h> -#if SLANG_ENABLE_FXC +#if SLANG_ENABLE_DXBC_SUPPORT #include <d3dcompiler.h> #endif @@ -418,6 +418,9 @@ bool D3DUtil::isTypeless(DXGI_FORMAT format) // /* static */Result D3DUtil::compileHLSLShader(char const* sourcePath, char const* source, char const* entryPointName, char const* dxProfileName, ComPtr<ID3DBlob>& shaderBlobOut) { +#if !SLANG_ENABLE_DXBC_SUPPORT + return SLANG_E_NOT_IMPLEMENTED; +#else // Rather than statically link against the `d3dcompile` library, we // dynamically load it. // @@ -425,9 +428,6 @@ 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) { @@ -475,13 +475,15 @@ bool D3DUtil::isTypeless(DXGI_FORMAT format) { ::fputs((const char*)errorBlob->GetBufferPointer(), stderr); ::fflush(stderr); +#if SLANG_WINDOWS_FAMILY ::OutputDebugStringA((const char*)errorBlob->GetBufferPointer()); +#endif } SLANG_RETURN_ON_FAIL(hr); shaderBlobOut.swap(shaderBlob); return SLANG_OK; -#endif // SLANG_ENABLE_FXC +#endif // SLANG_ENABLE_DXBC_SUPPORT } /* static */SharedLibrary::Handle D3DUtil::getDxgiModule() @@ -512,7 +514,7 @@ bool D3DUtil::isTypeless(DXGI_FORMAT format) } typedef HRESULT(WINAPI *PFN_DXGI_CREATE_FACTORY)(REFIID riid, void **ppFactory); - typedef HRESULT(WINAPI *PFN_DXGI_CREATE_FACTORY_2)(UINT Flags, REFIID riid, _COM_Outptr_ void **ppFactory); + typedef HRESULT(WINAPI *PFN_DXGI_CREATE_FACTORY_2)(UINT Flags, REFIID riid, void **ppFactory); { auto createFactory2 = (PFN_DXGI_CREATE_FACTORY_2)SharedLibrary::findSymbolAddressByName(dxgiModule, "CreateDXGIFactory2"); diff --git a/tools/gfx/d3d12/d3d12-command-encoder.h b/tools/gfx/d3d12/d3d12-command-encoder.h index 9e9a8c879..4190e985c 100644 --- a/tools/gfx/d3d12/d3d12-command-encoder.h +++ b/tools/gfx/d3d12/d3d12-command-encoder.h @@ -89,7 +89,7 @@ public: IBufferResource* const* buffers, ResourceState src, ResourceState dst) override; - virtual SLANG_NO_THROW void SLANG_MCALL endEncoding() {} + virtual SLANG_NO_THROW void SLANG_MCALL endEncoding() override {} virtual SLANG_NO_THROW void SLANG_MCALL writeTimestamp(IQueryPool* pool, GfxIndex index) override; virtual SLANG_NO_THROW void SLANG_MCALL copyTexture( @@ -337,7 +337,7 @@ public: GfxCount width, GfxCount height, GfxCount depth) override; - virtual SLANG_NO_THROW void SLANG_MCALL endEncoding() {} + virtual SLANG_NO_THROW void SLANG_MCALL endEncoding() override {} }; #endif diff --git a/tools/gfx/d3d12/d3d12-device.h b/tools/gfx/d3d12/d3d12-device.h index e77693ebe..975ba419b 100644 --- a/tools/gfx/d3d12/d3d12-device.h +++ b/tools/gfx/d3d12/d3d12-device.h @@ -17,7 +17,7 @@ using namespace Slang; // Define function pointer types for PIX library. typedef HRESULT(WINAPI* PFN_BeginEventOnCommandList)( - ID3D12GraphicsCommandList* commandList, UINT64 color, _In_ PCSTR formatString); + ID3D12GraphicsCommandList* commandList, UINT64 color, PCSTR formatString); typedef HRESULT(WINAPI* PFN_EndEventOnCommandList)(ID3D12GraphicsCommandList* commandList); struct D3D12DeviceInfo diff --git a/tools/gfx/d3d12/d3d12-submitter.h b/tools/gfx/d3d12/d3d12-submitter.h index 0b9f885a2..77c3f8c0d 100644 --- a/tools/gfx/d3d12/d3d12-submitter.h +++ b/tools/gfx/d3d12/d3d12-submitter.h @@ -34,8 +34,8 @@ struct GraphicsSubmitter : public Submitter virtual void setRootSRV(int index, D3D12_GPU_VIRTUAL_ADDRESS gpuBufferLocation) override; virtual void setRootDescriptorTable( int index, D3D12_GPU_DESCRIPTOR_HANDLE baseDescriptor) override; - void setRootSignature(ID3D12RootSignature* rootSignature); - void setRootConstants( + virtual void setRootSignature(ID3D12RootSignature* rootSignature) override; + virtual void setRootConstants( Index rootParamIndex, Index dstOffsetIn32BitValues, Index countOf32BitValues, @@ -57,8 +57,8 @@ struct ComputeSubmitter : public Submitter virtual void setRootSRV(int index, D3D12_GPU_VIRTUAL_ADDRESS gpuBufferLocation) override; virtual void setRootDescriptorTable( int index, D3D12_GPU_DESCRIPTOR_HANDLE baseDescriptor) override; - void setRootSignature(ID3D12RootSignature* rootSignature); - void setRootConstants( + virtual void setRootSignature(ID3D12RootSignature* rootSignature) override; + virtual void setRootConstants( Index rootParamIndex, Index dstOffsetIn32BitValues, Index countOf32BitValues, diff --git a/tools/render-test/render-test-main.cpp b/tools/render-test/render-test-main.cpp index f21a5ff07..89f7db3aa 100644 --- a/tools/render-test/render-test-main.cpp +++ b/tools/render-test/render-test-main.cpp @@ -1082,6 +1082,10 @@ static SlangResult _setSessionPrelude(const Options& options, const char* exePat // Let's see if we need to set up special prelude for HLSL if (options.nvapiExtnSlot.getLength()) { +#if !SLANG_WINDOWS_FAMILY + // NVAPI is currently only available on Windows + return SLANG_E_NOT_AVAILABLE; +#else // We want to set the path to NVAPI String rootPath; SLANG_RETURN_ON_FAIL(TestToolUtil::getRootPath(exePath, rootPath)); @@ -1098,6 +1102,7 @@ static SlangResult _setSessionPrelude(const Options& options, const char* exePat buf << "\n\n"; session->setLanguagePrelude(SLANG_SOURCE_LANGUAGE_HLSL, buf.getBuffer()); +#endif } else { |
