From d748358793c89dd77a2c5dbbf3ca64050b1d3bb4 Mon Sep 17 00:00:00 2001 From: assiduous Date: Sun, 13 Sep 2020 22:27:46 -0700 Subject: Refactoring shader compilation tools - part I (https://github.com/DiligentGraphics/DiligentCore/issues/160) --- Graphics/GraphicsEngineD3D12/CMakeLists.txt | 2 +- .../include/RenderDeviceD3D12Impl.hpp | 6 +++--- .../GraphicsEngineD3D12/include/ShaderResourcesD3D12.hpp | 8 ++++---- .../GraphicsEngineD3D12/src/ShaderResourcesD3D12.cpp | 16 ++++++++-------- 4 files changed, 16 insertions(+), 16 deletions(-) (limited to 'Graphics/GraphicsEngineD3D12') diff --git a/Graphics/GraphicsEngineD3D12/CMakeLists.txt b/Graphics/GraphicsEngineD3D12/CMakeLists.txt index 24696d7c..9941b62b 100644 --- a/Graphics/GraphicsEngineD3D12/CMakeLists.txt +++ b/Graphics/GraphicsEngineD3D12/CMakeLists.txt @@ -157,7 +157,7 @@ PRIVATE Diligent-GraphicsEngineD3DBase Diligent-GraphicsEngineNextGenBase Diligent-TargetPlatform - Diligent-HLSLTools + Diligent-ShaderTools dxgi.lib d3dcompiler.lib PUBLIC diff --git a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.hpp b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.hpp index 5c077497..0dc4201e 100644 --- a/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.hpp +++ b/Graphics/GraphicsEngineD3D12/include/RenderDeviceD3D12Impl.hpp @@ -40,7 +40,7 @@ #include "CommandQueueD3D12.h" #include "GenerateMips.hpp" #include "QueryManagerD3D12.hpp" -#include "DXILUtils.hpp" +#include "DXCompiler.hpp" namespace Diligent { @@ -152,7 +152,7 @@ public: const GenerateMipsHelper& GetMipsGenerator() const { return m_MipsGenerator; } QueryManagerD3D12& GetQueryManager() { return m_QueryMgr; } - IDxCompilerLibrary* GetDxCompiler() const { return m_pDxCompiler.get(); } + IDXCompiler* GetDxCompiler() const { return m_pDxCompiler.get(); } #ifdef D3D12_H_HAS_MESH_SHADER ID3D12Device2* GetD3D12Device2(); @@ -194,7 +194,7 @@ private: D3D_SHADER_MODEL m_MaxShaderModel = D3D_SHADER_MODEL_5_1; - std::unique_ptr m_pDxCompiler; + std::unique_ptr m_pDxCompiler; }; } // namespace Diligent diff --git a/Graphics/GraphicsEngineD3D12/include/ShaderResourcesD3D12.hpp b/Graphics/GraphicsEngineD3D12/include/ShaderResourcesD3D12.hpp index 228db950..fe867d89 100644 --- a/Graphics/GraphicsEngineD3D12/include/ShaderResourcesD3D12.hpp +++ b/Graphics/GraphicsEngineD3D12/include/ShaderResourcesD3D12.hpp @@ -92,10 +92,10 @@ class ShaderResourcesD3D12 final : public ShaderResources { public: // Loads shader resources from the compiled shader bytecode - ShaderResourcesD3D12(ID3DBlob* pShaderBytecode, - const ShaderDesc& ShdrDesc, - const char* CombinedSamplerSuffix, - class IDxCompilerLibrary* pCompilerLibrary); + ShaderResourcesD3D12(ID3DBlob* pShaderBytecode, + const ShaderDesc& ShdrDesc, + const char* CombinedSamplerSuffix, + class IDXCompiler* pDXCompiler); // clang-format off ShaderResourcesD3D12 (const ShaderResourcesD3D12&) = delete; diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderResourcesD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderResourcesD3D12.cpp index 6cd31660..700a5c47 100644 --- a/Graphics/GraphicsEngineD3D12/src/ShaderResourcesD3D12.cpp +++ b/Graphics/GraphicsEngineD3D12/src/ShaderResourcesD3D12.cpp @@ -31,16 +31,16 @@ #include "ShaderResourcesD3D12.hpp" #include "ShaderD3DBase.hpp" #include "ShaderBase.hpp" -#include "DXILUtils.hpp" +#include "DXCompiler.hpp" namespace Diligent { -ShaderResourcesD3D12::ShaderResourcesD3D12(ID3DBlob* pShaderBytecode, - const ShaderDesc& ShdrDesc, - const char* CombinedSamplerSuffix, - class IDxCompilerLibrary* pCompilerLibrary) : +ShaderResourcesD3D12::ShaderResourcesD3D12(ID3DBlob* pShaderBytecode, + const ShaderDesc& ShdrDesc, + const char* CombinedSamplerSuffix, + IDXCompiler* pDXCompiler) : ShaderResources{ShdrDesc.ShaderType} { class NewResourceHandler @@ -57,15 +57,15 @@ ShaderResourcesD3D12::ShaderResourcesD3D12(ID3DBlob* pShaderByte }; CComPtr pShaderReflection; - if (pCompilerLibrary != nullptr) + if (pDXCompiler != nullptr) { // Try to get shader reflection with DXC. - DxcGetShaderReflection(pCompilerLibrary, reinterpret_cast(pShaderBytecode), &pShaderReflection); + pDXCompiler->GetD3D12ShaderReflection(reinterpret_cast(pShaderBytecode), &pShaderReflection); } if (!pShaderReflection) { - // Use FXC to get reflection. + // Use D3D compiler to get reflection. auto hr = D3DReflect(pShaderBytecode->GetBufferPointer(), pShaderBytecode->GetBufferSize(), __uuidof(pShaderReflection), reinterpret_cast(&pShaderReflection)); CHECK_D3D_RESULT_THROW(hr, "Failed to get the shader reflection"); } -- cgit v1.2.3