diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2020-09-14 05:27:46 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2020-09-14 05:27:46 +0000 |
| commit | d748358793c89dd77a2c5dbbf3ca64050b1d3bb4 (patch) | |
| tree | 25008f90079aee9988a9e27851a31709df4777fa /Graphics/GraphicsEngineD3DBase | |
| parent | Minor fix for timer query support detection in OpenGLES (diff) | |
| download | DiligentCore-d748358793c89dd77a2c5dbbf3ca64050b1d3bb4.tar.gz DiligentCore-d748358793c89dd77a2c5dbbf3ca64050b1d3bb4.zip | |
Refactoring shader compilation tools - part I (https://github.com/DiligentGraphics/DiligentCore/issues/160)
Diffstat (limited to 'Graphics/GraphicsEngineD3DBase')
| -rw-r--r-- | Graphics/GraphicsEngineD3DBase/CMakeLists.txt | 6 | ||||
| -rw-r--r-- | Graphics/GraphicsEngineD3DBase/include/ShaderD3DBase.hpp | 2 | ||||
| -rw-r--r-- | Graphics/GraphicsEngineD3DBase/src/ShaderD3DBase.cpp | 29 |
3 files changed, 21 insertions, 16 deletions
diff --git a/Graphics/GraphicsEngineD3DBase/CMakeLists.txt b/Graphics/GraphicsEngineD3DBase/CMakeLists.txt index 2708f071..81a48c3d 100644 --- a/Graphics/GraphicsEngineD3DBase/CMakeLists.txt +++ b/Graphics/GraphicsEngineD3DBase/CMakeLists.txt @@ -61,10 +61,10 @@ PUBLIC target_link_libraries(Diligent-GraphicsEngineD3DBase PRIVATE - Diligent-BuildSettings - Diligent-HLSLTools + Diligent-BuildSettings + Diligent-ShaderTools PUBLIC - Diligent-GraphicsEngine + Diligent-GraphicsEngine Diligent-GraphicsEngineD3DBaseInterface ) diff --git a/Graphics/GraphicsEngineD3DBase/include/ShaderD3DBase.hpp b/Graphics/GraphicsEngineD3DBase/include/ShaderD3DBase.hpp index 7d2fe1f6..90d43b6d 100644 --- a/Graphics/GraphicsEngineD3DBase/include/ShaderD3DBase.hpp +++ b/Graphics/GraphicsEngineD3DBase/include/ShaderD3DBase.hpp @@ -40,7 +40,7 @@ namespace Diligent class ShaderD3DBase { public: - ShaderD3DBase(const ShaderCreateInfo& ShaderCI, ShaderVersion ShaderModel, class IDxCompilerLibrary* DxCompiler); + ShaderD3DBase(const ShaderCreateInfo& ShaderCI, ShaderVersion ShaderModel, class IDXCompiler* DxCompiler); protected: CComPtr<ID3DBlob> m_pShaderByteCode; diff --git a/Graphics/GraphicsEngineD3DBase/src/ShaderD3DBase.cpp b/Graphics/GraphicsEngineD3DBase/src/ShaderD3DBase.cpp index 053e3378..e02dadad 100644 --- a/Graphics/GraphicsEngineD3DBase/src/ShaderD3DBase.cpp +++ b/Graphics/GraphicsEngineD3DBase/src/ShaderD3DBase.cpp @@ -32,13 +32,13 @@ #include <D3Dcompiler.h> #include <atlcomcli.h> -#include "dxc/dxcapi.h" +#include "../../../ThirdParty/DirectXShaderCompiler/dxc/dxcapi.h" #include "D3DErrors.hpp" #include "DataBlobImpl.hpp" #include "RefCntAutoPtr.hpp" #include "ShaderD3DBase.hpp" -#include "DXILUtils.hpp" +#include "DXCompiler.hpp" namespace Diligent { @@ -108,7 +108,7 @@ static std::vector<D3D_SHADER_MACRO> GetD3DShaderMacros(const ShaderCreateInfo& } -static HRESULT CompileDxilShader(IDxCompilerLibrary* DxCompiler, +static HRESULT CompileDxilShader(IDXCompiler* DxCompiler, const char* Source, size_t SourceLength, const ShaderCreateInfo& ShaderCI, @@ -158,14 +158,19 @@ static HRESULT CompileDxilShader(IDxCompilerLibrary* DxCompiler, VERIFY_EXPR(__uuidof(ID3DBlob) == __uuidof(IDxcBlob)); - if (!DxCompiler->Compile(Source, SourceLength, - UTF8ToUTF16(ShaderCI.EntryPoint), - UTF8ToUTF16(profile), - DxcMacros.data(), DxcMacros.size(), - pArgs, _countof(pArgs), - ShaderCI.pShaderSourceStreamFactory, - reinterpret_cast<IDxcBlob**>(ppBlobOut), - reinterpret_cast<IDxcBlob**>(ppCompilerOutput))) + IDXCompiler::CompileAttribs CA; + CA.Source = Source; + CA.SourceLength = static_cast<Uint32>(SourceLength); + CA.EntryPoint = UTF8ToUTF16(ShaderCI.EntryPoint); + CA.Profile = UTF8ToUTF16(profile); + CA.pDefines = DxcMacros.data(); + CA.DefinesCount = static_cast<Uint32>(DxcMacros.size()); + CA.pArgs = pArgs; + CA.ArgsCount = _countof(pArgs); + CA.pShaderSourceStreamFactory = ShaderCI.pShaderSourceStreamFactory; + CA.ppBlobOut = reinterpret_cast<IDxcBlob**>(ppBlobOut); + CA.ppCompilerOutput = reinterpret_cast<IDxcBlob**>(ppCompilerOutput); + if (!DxCompiler->Compile(CA)) { return E_FAIL; } @@ -242,7 +247,7 @@ static HRESULT CompileShader(const char* Source, } // namespace -ShaderD3DBase::ShaderD3DBase(const ShaderCreateInfo& ShaderCI, const ShaderVersion ShaderModel, IDxCompilerLibrary* DxCompiler) +ShaderD3DBase::ShaderD3DBase(const ShaderCreateInfo& ShaderCI, const ShaderVersion ShaderModel, IDXCompiler* DxCompiler) { if (ShaderCI.Source || ShaderCI.FilePath) { |
