summaryrefslogtreecommitdiffstats
path: root/Graphics
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-09-10 05:10:11 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-09-10 05:10:11 +0000
commitd528bfb214a09ddb37d123470cc29d8b5880f3dd (patch)
tree1cd16a63352e4c2ed88031b5f386b7fc6efd9b00 /Graphics
parentAnother set of minor updates to mesh shader implementation (diff)
downloadDiligentCore-d528bfb214a09ddb37d123470cc29d8b5880f3dd.tar.gz
DiligentCore-d528bfb214a09ddb37d123470cc29d8b5880f3dd.zip
Few updates to DXILUtils
Diffstat (limited to 'Graphics')
-rw-r--r--Graphics/HLSLTools/CMakeLists.txt7
-rw-r--r--Graphics/HLSLTools/src/DXCompilerBaseLiunx.hpp11
-rw-r--r--Graphics/HLSLTools/src/DXCompilerBaseUWP.hpp25
-rw-r--r--Graphics/HLSLTools/src/DXCompilerBaseWin32.hpp26
-rw-r--r--Graphics/HLSLTools/src/DXILUtils.cpp54
-rw-r--r--Graphics/HLSLTools/src/DXILUtilsStub.cpp46
6 files changed, 97 insertions, 72 deletions
diff --git a/Graphics/HLSLTools/CMakeLists.txt b/Graphics/HLSLTools/CMakeLists.txt
index b4e33258..15e137aa 100644
--- a/Graphics/HLSLTools/CMakeLists.txt
+++ b/Graphics/HLSLTools/CMakeLists.txt
@@ -7,12 +7,17 @@ set(INCLUDE
)
set(SOURCE
- src/DXILUtils.cpp
src/DXCompilerBaseLiunx.hpp
src/DXCompilerBaseUWP.hpp
src/DXCompilerBaseWin32.hpp
)
+if(PLATFORM_WIN32 OR PLATFORM_UNIVERSAL_WINDOWS OR PLATFORM_LINUX)
+ list(APPEND SOURCE src/DXILUtils.cpp)
+else()
+ list(APPEND SOURCE src/DXILUtilsStub.cpp)
+endif()
+
if(PLATFORM_LINUX)
list(APPEND INCLUDE
../../ThirdParty/DirectXShaderCompiler/dxc/dxcapi.h
diff --git a/Graphics/HLSLTools/src/DXCompilerBaseLiunx.hpp b/Graphics/HLSLTools/src/DXCompilerBaseLiunx.hpp
index ff8ad75a..4a93eb2c 100644
--- a/Graphics/HLSLTools/src/DXCompilerBaseLiunx.hpp
+++ b/Graphics/HLSLTools/src/DXCompilerBaseLiunx.hpp
@@ -25,14 +25,14 @@
* of the possibility of such damages.
*/
-#ifdef PLATFORM_LINUX
-# include "DXILUtils.hpp"
+#include "DXILUtils.hpp"
-# include "dxc/dxcapi.h"
+#include "dxc/dxcapi.h"
namespace Diligent
{
+
namespace
{
@@ -48,7 +48,7 @@ public:
protected:
DxcCreateInstanceProc Load(DXCompilerTarget, const String& LibName)
{
- if (LibName.size())
+ if (!LibName.empty())
Module = dlopen(LibName.c_str(), RTLD_LOCAL | RTLD_LAZY);
if (Module == nullptr)
@@ -66,6 +66,5 @@ private:
};
} // namespace
-} // namespace Diligent
-#endif // PLATFORM_LINUX \ No newline at end of file
+} // namespace Diligent
diff --git a/Graphics/HLSLTools/src/DXCompilerBaseUWP.hpp b/Graphics/HLSLTools/src/DXCompilerBaseUWP.hpp
index f8b9771e..8db8557d 100644
--- a/Graphics/HLSLTools/src/DXCompilerBaseUWP.hpp
+++ b/Graphics/HLSLTools/src/DXCompilerBaseUWP.hpp
@@ -25,25 +25,23 @@
* of the possibility of such damages.
*/
-#ifdef PLATFORM_UNIVERSAL_WINDOWS
-# ifdef WIN32
-# include <Unknwn.h>
-# include <guiddef.h>
-# include <atlbase.h>
-# include <atlcom.h>
-# endif
+#include <Unknwn.h>
+#include <guiddef.h>
+#include <atlbase.h>
+#include <atlcom.h>
-# include "dxc/dxcapi.h"
+#include "dxc/dxcapi.h"
-# include "DXILUtils.hpp"
+#include "DXILUtils.hpp"
-# if D3D12_SUPPORTED
-# include <d3d12shader.h>
-# endif
+#if D3D12_SUPPORTED
+# include <d3d12shader.h>
+#endif
namespace Diligent
{
+
namespace
{
@@ -78,6 +76,5 @@ private:
};
} // namespace
-} // namespace Diligent
-#endif // PLATFORM_UNIVERSAL_WINDOWS \ No newline at end of file
+} // namespace Diligent
diff --git a/Graphics/HLSLTools/src/DXCompilerBaseWin32.hpp b/Graphics/HLSLTools/src/DXCompilerBaseWin32.hpp
index b186bcf1..7b5ea2a5 100644
--- a/Graphics/HLSLTools/src/DXCompilerBaseWin32.hpp
+++ b/Graphics/HLSLTools/src/DXCompilerBaseWin32.hpp
@@ -25,25 +25,22 @@
* of the possibility of such damages.
*/
-#ifdef PLATFORM_WIN32
+#include <Unknwn.h>
+#include <guiddef.h>
+#include <atlbase.h>
+#include <atlcom.h>
-# ifdef WIN32
-# include <Unknwn.h>
-# include <guiddef.h>
-# include <atlbase.h>
-# include <atlcom.h>
-# endif
+#include "dxc/dxcapi.h"
-# include "dxc/dxcapi.h"
+#include "DXILUtils.hpp"
-# include "DXILUtils.hpp"
-
-# if D3D12_SUPPORTED
-# include <d3d12shader.h>
-# endif
+#if D3D12_SUPPORTED
+# include <d3d12shader.h>
+#endif
namespace Diligent
{
+
namespace
{
@@ -79,6 +76,5 @@ private:
};
} // namespace
-} // namespace Diligent
-#endif // PLATFORM_WIN32 \ No newline at end of file
+} // namespace Diligent
diff --git a/Graphics/HLSLTools/src/DXILUtils.cpp b/Graphics/HLSLTools/src/DXILUtils.cpp
index 58211993..b183a65c 100644
--- a/Graphics/HLSLTools/src/DXILUtils.cpp
+++ b/Graphics/HLSLTools/src/DXILUtils.cpp
@@ -31,18 +31,23 @@
#include <array>
#include <mutex>
-// Platforms that has DXCompiler.
-#if defined(PLATFORM_WIN32) || defined(PLATFORM_UNIVERSAL_WINDOWS) || defined(PLATFORM_LINUX)
-
-# include "DXCompilerBaseLiunx.hpp"
-# include "DXCompilerBaseUWP.hpp"
+// Platforms that support DXCompiler.
+#if PLATFORM_WIN32
# include "DXCompilerBaseWin32.hpp"
+#elif PLATFORM_UNIVERSAL_WINDOWS
+# include "DXCompilerBaseUWP.hpp"
+#elif PLATFORM_LINUX
+# include "DXCompilerBaseLiunx.hpp"
+#else
+# error DXC is not supported on this platform
+#endif
-# include "DataBlobImpl.hpp"
-# include "RefCntAutoPtr.hpp"
+#include "DataBlobImpl.hpp"
+#include "RefCntAutoPtr.hpp"
namespace Diligent
{
+
namespace
{
@@ -51,7 +56,7 @@ class DXCompilerImpl final : public DXCompilerBase
public:
DXCompilerImpl(DXCompilerTarget Target, const char* pLibName) :
m_Target{Target},
- m_LibName{pLibName ? pLibName : ""}
+ m_LibName{pLibName ? pLibName : "dxcompiler.dll"}
{}
ShaderVersion GetMaxShaderModel() override
@@ -353,8 +358,8 @@ bool DXCompilerImpl::Compile(const char* Source,
return true;
}
-# if D3D12_SUPPORTED
-# define FOURCC(a, b, c, d) (uint32_t{((d) << 24) | ((c) << 16) | ((b) << 8) | (a)})
+#if D3D12_SUPPORTED
+# define FOURCC(a, b, c, d) (uint32_t{((d) << 24) | ((c) << 16) | ((b) << 8) | (a)})
bool DxcGetShaderReflection(IDxCompilerLibrary* pLibrary,
IDxcBlob* pShaderBytecode,
@@ -389,10 +394,10 @@ bool DxcGetShaderReflection(IDxCompilerLibrary* pLibrary,
}
return IsDXIL;
}
-# endif
+#endif
-# if VULKAN_SUPPORTED
+#if VULKAN_SUPPORTED
// Implemented in GLSLSourceBuilder.cpp
const char* GetShaderTypeDefines(SHADER_TYPE Type);
@@ -547,29 +552,6 @@ std::vector<uint32_t> DXILtoSPIRV(IDxCompilerLibrary* pLibrary,
return SPIRV;
}
-# endif // VULKAN_SUPPORTED
+#endif // VULKAN_SUPPORTED
} // namespace Diligent
-
-#else
-
-# include "DXILUtils.hpp"
-
-namespace Diligent
-{
-
-IDxCompilerLibrary* CreateDXCompiler(DXCompilerTarget Target, const char* pLibraryName)
-{
- return nullptr;
-}
-
-std::vector<uint32_t> DXILtoSPIRV(IDxCompilerLibrary* pLibrary,
- const ShaderCreateInfo& Attribs,
- const char* ExtraDefinitions,
- IDataBlob** ppCompilerOutput) noexcept(false)
-{
- return {};
-}
-
-} // namespace Diligent
-#endif
diff --git a/Graphics/HLSLTools/src/DXILUtilsStub.cpp b/Graphics/HLSLTools/src/DXILUtilsStub.cpp
new file mode 100644
index 00000000..b0db5df0
--- /dev/null
+++ b/Graphics/HLSLTools/src/DXILUtilsStub.cpp
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2019-2020 Diligent Graphics LLC
+ * Copyright 2015-2019 Egor Yusov
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * In no event and under no legal theory, whether in tort (including negligence),
+ * contract, or otherwise, unless required by applicable law (such as deliberate
+ * and grossly negligent acts) or agreed to in writing, shall any Contributor be
+ * liable for any damages, including any direct, indirect, special, incidental,
+ * or consequential damages of any character arising as a result of this License or
+ * out of the use or inability to use the software (including but not limited to damages
+ * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
+ * all other commercial damages or losses), even if such Contributor has been advised
+ * of the possibility of such damages.
+ */
+
+#include "DXILUtils.hpp"
+
+namespace Diligent
+{
+
+IDxCompilerLibrary* CreateDXCompiler(DXCompilerTarget Target, const char* pLibraryName)
+{
+ return nullptr;
+}
+
+std::vector<uint32_t> DXILtoSPIRV(IDxCompilerLibrary* pLibrary,
+ const ShaderCreateInfo& Attribs,
+ const char* ExtraDefinitions,
+ IDataBlob** ppCompilerOutput) noexcept(false)
+{
+ return {};
+}
+
+} // namespace Diligent