diff options
| author | azhirnov <zh1dron@gmail.com> | 2020-09-08 14:38:56 +0000 |
|---|---|---|
| committer | azhirnov <zh1dron@gmail.com> | 2020-09-08 19:18:54 +0000 |
| commit | ead1635c3c142f7af259dc0af83d244b24c7dfb9 (patch) | |
| tree | e1e59012ba02d685ce1c2dd99151b2255bb76fca /Graphics | |
| parent | fixed message text and docs (diff) | |
| download | DiligentCore-ead1635c3c142f7af259dc0af83d244b24c7dfb9.tar.gz DiligentCore-ead1635c3c142f7af259dc0af83d244b24c7dfb9.zip | |
removed DILIGENT_HAS_SPIRV_DXCOMPILER, it not needed because used dynamic loading and user can specify path to library
Diffstat (limited to 'Graphics')
| -rw-r--r-- | Graphics/GraphicsEngineD3DBase/src/ShaderD3DBase.cpp | 9 | ||||
| -rw-r--r-- | Graphics/GraphicsEngineVulkan/CMakeLists.txt | 75 | ||||
| -rw-r--r-- | Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp | 6 | ||||
| -rw-r--r-- | Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp | 6 | ||||
| -rw-r--r-- | Graphics/HLSLTools/src/DXILUtils.cpp | 56 |
5 files changed, 73 insertions, 79 deletions
diff --git a/Graphics/GraphicsEngineD3DBase/src/ShaderD3DBase.cpp b/Graphics/GraphicsEngineD3DBase/src/ShaderD3DBase.cpp index fb51062b..a93bb5ec 100644 --- a/Graphics/GraphicsEngineD3DBase/src/ShaderD3DBase.cpp +++ b/Graphics/GraphicsEngineD3DBase/src/ShaderD3DBase.cpp @@ -311,7 +311,7 @@ static HRESULT CompileShader(const char* Source, } // namespace -ShaderD3DBase::ShaderD3DBase(const ShaderCreateInfo& ShaderCI, const ShaderVersion RequiredVersion, bool IsD3D12) : +ShaderD3DBase::ShaderD3DBase(const ShaderCreateInfo& ShaderCI, ShaderVersion ShaderModel, bool IsD3D12) : m_isDXIL{false} { if (ShaderCI.Source || ShaderCI.FilePath) @@ -331,7 +331,6 @@ ShaderD3DBase::ShaderD3DBase(const ShaderCreateInfo& ShaderCI, const ShaderVersi } // validate shader model - ShaderVersion ShaderModel = RequiredVersion; if (m_isDXIL) { ShaderModel = (ShaderModel.Major >= 6 ? ShaderModel : ShaderVersion{6, 0}); @@ -355,12 +354,6 @@ ShaderD3DBase::ShaderD3DBase(const ShaderCreateInfo& ShaderCI, const ShaderVersi ShaderModel = (ShaderModel.Major < 6 ? ShaderModel : (IsD3D12 ? ShaderVersion{5, 1} : ShaderVersion{5, 0})); } - if (RequiredVersion.Major != 0 && (ShaderModel.Major != RequiredVersion.Major || ShaderModel.Minor != RequiredVersion.Minor)) - { - LOG_INFO_MESSAGE("Shader '", (ShaderCI.Desc.Name != nullptr ? ShaderCI.Desc.Name : ""), "': version changed from ", - Uint32(RequiredVersion.Major), ".", Uint32(RequiredVersion.Minor), " to ", Uint32(ShaderModel.Major), ".", Uint32(ShaderModel.Minor)); - } - std::string strShaderProfile; switch (ShaderCI.Desc.ShaderType) { diff --git a/Graphics/GraphicsEngineVulkan/CMakeLists.txt b/Graphics/GraphicsEngineVulkan/CMakeLists.txt index 90aa7991..40a0f219 100644 --- a/Graphics/GraphicsEngineVulkan/CMakeLists.txt +++ b/Graphics/GraphicsEngineVulkan/CMakeLists.txt @@ -179,12 +179,9 @@ set(PRIVATE_DEPENDENCIES Diligent-TargetPlatform Diligent-GraphicsEngineNextGenBase Diligent-GLSLTools + Diligent-HLSLTools ) -if(NOT ${DILIGENT_NO_DXC_SPIRV}) - list(APPEND PRIVATE_DEPENDENCIES Diligent-HLSLTools) -endif() - if (${DILIGENT_NO_HLSL}) message("HLSL support is disabled. Vulkan backend may not be able to consume SPIRV bytecode generated from HLSL.") else() @@ -194,51 +191,43 @@ endif() # Use DirectX shader compiler for SPIRV. # This is another implementation of DXC that can compile only to SPIRV. # DXC for D3D12 can compile only to DXIL. -if(NOT ${DILIGENT_NO_DXC_SPIRV}) - if(PLATFORM_WIN32) - # find Vulkan SDK - if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.7") - find_package(Vulkan) - if(Vulkan_FOUND) - get_filename_component(VulkanSDKPath ${Vulkan_LIBRARY} DIRECTORY) - set(VulkanSDKPath "${VulkanSDKPath}/..") - if(NOT EXISTS "${VulkanSDKPath}") - message(STATUS "can't get Vulkan SDK path") - endif() - if (${CMAKE_SIZEOF_VOID_P} EQUAL 8) - set(DXC_SPIRV_PATH "${VulkanSDKPath}/Bin/dxcompiler.dll") - else() - set(DXC_SPIRV_PATH "${VulkanSDKPath}/Bin32/dxcompiler.dll") - endif() +if(PLATFORM_WIN32) + # find Vulkan SDK + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.7") + find_package(Vulkan) + if(Vulkan_FOUND) + get_filename_component(VulkanSDKPath ${Vulkan_LIBRARY} DIRECTORY) + set(VulkanSDKPath "${VulkanSDKPath}/..") + if(NOT EXISTS "${VulkanSDKPath}") + message(STATUS "can't get Vulkan SDK path") + endif() + if (${CMAKE_SIZEOF_VOID_P} EQUAL 8) + set(DXC_SPIRV_PATH "${VulkanSDKPath}/Bin/dxcompiler.dll") + else() + set(DXC_SPIRV_PATH "${VulkanSDKPath}/Bin32/dxcompiler.dll") endif() endif() - # Try to find Vulkan SDK from environment variable - if(NOT Vulkan_FOUND) - if(EXISTS "$ENV{VULKAN_SDK}") - if (${CMAKE_SIZEOF_VOID_P} EQUAL 8) - set(DXC_SPIRV_PATH "$ENV{VULKAN_SDK}/Bin/dxcompiler.dll") - else() - set(DXC_SPIRV_PATH "$ENV{VULKAN_SDK}/Bin32/dxcompiler.dll") - endif() + endif() + # Try to find Vulkan SDK from environment variable + if(NOT Vulkan_FOUND) + if(EXISTS "$ENV{VULKAN_SDK}") + if (${CMAKE_SIZEOF_VOID_P} EQUAL 8) + set(DXC_SPIRV_PATH "$ENV{VULKAN_SDK}/Bin/dxcompiler.dll") + else() + set(DXC_SPIRV_PATH "$ENV{VULKAN_SDK}/Bin32/dxcompiler.dll") endif() endif() - endif(PLATFORM_WIN32) - - if(PLATFORM_LINUX) - # VulkanSDK installs dxc to this path - set(DXC_SPIRV_PATH "/usr/lib/dxc/libdxcompiler.so") endif() +endif(PLATFORM_WIN32) - if(EXISTS ${DXC_SPIRV_PATH}) - set(DILIGENT_HAS_SPIRV_DXCOMPILER TRUE CACHE INTERNAL "" FORCE) - set(DILIGENT_DXCOMPILER_FOR_SPIRV_PATH "${DXC_SPIRV_PATH}" CACHE INTERNAL "" FORCE) - target_compile_definitions(Diligent-GraphicsEngineVk-static PRIVATE DILIGENT_HAS_SPIRV_DXCOMPILER) - message(STATUS "Found DXCompiler for Vulkan") - else() - set(DILIGENT_HAS_SPIRV_DXCOMPILER FALSE CACHE INTERNAL "" FORCE) - endif() -else() - set(DILIGENT_HAS_SPIRV_DXCOMPILER FALSE CACHE INTERNAL "" FORCE) +if(PLATFORM_LINUX) + # VulkanSDK installs dxc to this path + set(DXC_SPIRV_PATH "/usr/lib/dxc/libdxcompiler.so") +endif() + +if(EXISTS ${DXC_SPIRV_PATH}) + set(DILIGENT_DXCOMPILER_FOR_SPIRV_PATH "${DXC_SPIRV_PATH}" CACHE INTERNAL "" FORCE) + message(STATUS "Found DXCompiler for Vulkan") endif() if(PLATFORM_WIN32) diff --git a/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp b/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp index b03a5c0e..9a17c9e2 100644 --- a/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp +++ b/Graphics/GraphicsEngineVulkan/src/EngineFactoryVk.cpp @@ -39,13 +39,11 @@ #include "VulkanUtilities/VulkanInstance.hpp" #include "VulkanUtilities/VulkanPhysicalDevice.hpp" #include "EngineFactoryBase.hpp" +#include "DXILUtils.hpp" #if PLATFORM_ANDROID # include "FileSystem.hpp" #endif -#ifdef DILIGENT_HAS_SPIRV_DXCOMPILER -# include "DXILUtils.hpp" -#endif namespace Diligent { @@ -251,9 +249,7 @@ void EngineFactoryVkImpl::CreateDeviceAndContextsVk(const EngineVkCreateInfo& _E std::array<ICommandQueueVk*, 1> CommandQueues = {{pCmdQueueVk}}; AttachToVulkanDevice(Instance, std::move(PhysicalDevice), LogicalDevice, CommandQueues.size(), CommandQueues.data(), EngineCI, ppDevice, ppContexts); -#ifdef DILIGENT_HAS_SPIRV_DXCOMPILER DxcLoadLibrary(DXCompilerTarget::Vulkan, EngineCI.pDxCompilerPath); -#endif } catch (std::runtime_error&) { diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp index 708458da..cafa7303 100644 --- a/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp @@ -33,13 +33,11 @@ #include "RenderDeviceVkImpl.hpp" #include "DataBlobImpl.hpp" #include "GLSLSourceBuilder.hpp" +#include "DXILUtils.hpp" #if !DILIGENT_NO_GLSLANG # include "SPIRVUtils.hpp" #endif -#ifdef DILIGENT_HAS_SPIRV_DXCOMPILER -# include "DXILUtils.hpp" -#endif namespace Diligent { @@ -68,11 +66,9 @@ ShaderVkImpl::ShaderVkImpl(IReferenceCounters* pRefCounters, switch (CreationAttribs.ShaderCompiler) { -#ifdef DILIGENT_HAS_SPIRV_DXCOMPILER case SHADER_COMPILER_DXC: m_SPIRV = DXILtoSPIRV(CreationAttribs, VulkanDefine, CreationAttribs.ppCompilerOutput); break; -#endif case SHADER_COMPILER_DEFAULT: case SHADER_COMPILER_GLSLANG: diff --git a/Graphics/HLSLTools/src/DXILUtils.cpp b/Graphics/HLSLTools/src/DXILUtils.cpp index ccf419d3..45fec173 100644 --- a/Graphics/HLSLTools/src/DXILUtils.cpp +++ b/Graphics/HLSLTools/src/DXILUtils.cpp @@ -37,18 +37,19 @@ # include <atlcom.h> #endif -#include "dxc/dxcapi.h" -#ifdef PLATFORM_LINUX -# undef _countof -#endif - #include "DXILUtils.hpp" -#include "DataBlobImpl.hpp" -#include "RefCntAutoPtr.hpp" // Platforms that has DXCompiler. #if defined(PLATFORM_WIN32) || defined(PLATFORM_UNIVERSAL_WINDOWS) || defined(PLATFORM_LINUX) +# include "dxc/dxcapi.h" +# ifdef PLATFORM_LINUX +# undef _countof +# endif + +# include "DataBlobImpl.hpp" +# include "RefCntAutoPtr.hpp" + namespace Diligent { namespace @@ -637,20 +638,39 @@ std::vector<uint32_t> DXILtoSPIRV(const ShaderCreateInfo& Attribs, namespace Diligent { -bool DXILCompile(DXCompilerTarget Target, - const char* Source, - const wchar_t* EntryPoint, - const wchar_t* Profile, - const DxcDefine* pDefines, - size_t DefinesCount, - const wchar_t** pArgs, - size_t ArgsCount, - IShaderSourceInputStreamFactory* pShaderSourceStreamFactory, - IDxcBlob** ppBlobOut, - IDxcBlob** ppCompilerOutput) +bool DxcLoadLibrary(DXCompilerTarget Target, const char* name) +{ + return false; +} + +bool DxcGetMaxShaderModel(DXCompilerTarget Target, + ShaderVersion& Version) { return false; } +bool DxcCompile(DXCompilerTarget Target, + const char* Source, + size_t SourceLength, + const wchar_t* EntryPoint, + const wchar_t* Profile, + const DxcDefine* pDefines, + size_t DefinesCount, + const wchar_t** pArgs, + size_t ArgsCount, + IShaderSourceInputStreamFactory* pShaderSourceStreamFactory, + IDxcBlob** ppBlobOut, + IDxcBlob** ppCompilerOutput) +{ + return false; +} + +std::vector<uint32_t> DXILtoSPIRV(const ShaderCreateInfo& Attribs, + const char* ExtraDefinitions, + IDataBlob** ppCompilerOutput) +{ + return {}; +} + } // namespace Diligent #endif |
