summaryrefslogtreecommitdiffstats
path: root/Graphics/ShaderTools
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-09-15 01:03:02 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-09-15 01:03:02 +0000
commitdc4ae2ec62dae41490c34a78d4ecc1941d92a836 (patch)
tree715cc15af29a698cee721d4caf5a7d3e0585989b /Graphics/ShaderTools
parentCompleted shader compilation refactoring (fixed https://github.com/DiligentGr... (diff)
downloadDiligentCore-dc4ae2ec62dae41490c34a78d4ecc1941d92a836.tar.gz
DiligentCore-dc4ae2ec62dae41490c34a78d4ecc1941d92a836.zip
Fixed linux/mac build errors; few minor updates.
Diffstat (limited to 'Graphics/ShaderTools')
-rw-r--r--Graphics/ShaderTools/include/DXCompiler.hpp5
-rw-r--r--Graphics/ShaderTools/include/GLSLangUtils.hpp2
-rw-r--r--Graphics/ShaderTools/include/HLSLUtils.hpp2
-rw-r--r--Graphics/ShaderTools/src/DXCompiler.cpp25
4 files changed, 18 insertions, 16 deletions
diff --git a/Graphics/ShaderTools/include/DXCompiler.hpp b/Graphics/ShaderTools/include/DXCompiler.hpp
index d361361c..32655a78 100644
--- a/Graphics/ShaderTools/include/DXCompiler.hpp
+++ b/Graphics/ShaderTools/include/DXCompiler.hpp
@@ -84,8 +84,9 @@ public:
ID3D12ShaderReflection** ppShaderReflection) = 0;
};
-// Use this function to load specific library,
-// otherwise default library will be implicitly loaded.
+// Use this function to load the DX Compiler library.
+// pLibraryName is an optional path to the library. If not provided, default
+// path is used.
IDXCompiler* CreateDXCompiler(DXCompilerTarget Target, const char* pLibraryName);
diff --git a/Graphics/ShaderTools/include/GLSLangUtils.hpp b/Graphics/ShaderTools/include/GLSLangUtils.hpp
index 61d7141d..67a0ef18 100644
--- a/Graphics/ShaderTools/include/GLSLangUtils.hpp
+++ b/Graphics/ShaderTools/include/GLSLangUtils.hpp
@@ -51,4 +51,4 @@ std::vector<unsigned int> HLSLtoSPIRV(const ShaderCreateInfo& Attribs,
} // namespace GLSLangUtils
-} // namespace Diligent \ No newline at end of file
+} // namespace Diligent
diff --git a/Graphics/ShaderTools/include/HLSLUtils.hpp b/Graphics/ShaderTools/include/HLSLUtils.hpp
index 0e36c7b4..db3e8aee 100644
--- a/Graphics/ShaderTools/include/HLSLUtils.hpp
+++ b/Graphics/ShaderTools/include/HLSLUtils.hpp
@@ -32,6 +32,8 @@
#include "BasicTypes.h"
#include "GraphicsTypes.h"
#include "Shader.h"
+#include "RefCountedObjectImpl.hpp"
+#include "Errors.hpp"
namespace Diligent
{
diff --git a/Graphics/ShaderTools/src/DXCompiler.cpp b/Graphics/ShaderTools/src/DXCompiler.cpp
index ad7a0023..7496aae7 100644
--- a/Graphics/ShaderTools/src/DXCompiler.cpp
+++ b/Graphics/ShaderTools/src/DXCompiler.cpp
@@ -26,7 +26,6 @@
*/
#include <memory>
-#include <array>
#include <mutex>
// Platforms that support DXCompiler.
@@ -163,7 +162,7 @@ public:
fileName.resize(wcslen(pFilename));
for (size_t i = 0; i < fileName.size(); ++i)
{
- fileName[i] = char(pFilename[i]);
+ fileName[i] = static_cast<char>(pFilename[i]);
}
if (fileName.empty())
@@ -188,7 +187,8 @@ public:
pSourceStream->ReadBlob(pFileData);
CComPtr<IDxcBlobEncoding> sourceBlob;
- HRESULT hr = m_pLibrary->CreateBlobWithEncodingFromPinned(pFileData->GetDataPtr(), UINT32(pFileData->GetSize()), CP_UTF8, &sourceBlob);
+
+ HRESULT hr = m_pLibrary->CreateBlobWithEncodingFromPinned(pFileData->GetDataPtr(), UINT32(pFileData->GetSize()), CP_UTF8, &sourceBlob);
if (FAILED(hr))
{
LOG_ERROR("Failed to allocate space for shader include file ", fileName, ".");
@@ -409,7 +409,6 @@ void DXCompilerImpl::GetD3D12ShaderReflection(IDxcBlob* pShaderBy
}
-
void DXCompilerImpl::Compile(const ShaderCreateInfo& ShaderCI,
const char* ExtraDefinitions,
IDxcBlob** ppByteCodeBlob,
@@ -445,7 +444,7 @@ void DXCompilerImpl::Compile(const ShaderCreateInfo& ShaderCI,
L"-O3", // Optimization level 3
};
- const wchar_t* pDxbcArgs[] =
+ const wchar_t* pDxilArgs[] =
{
L"-Zpc", // Matrices in column-major order
//L"-WX", // Warnings as errors
@@ -459,7 +458,7 @@ void DXCompilerImpl::Compile(const ShaderCreateInfo& ShaderCI,
#endif
};
- CComPtr<IDxcBlob> pCompiledShader;
+ CComPtr<IDxcBlob> pDXIL;
CComPtr<IDxcBlob> pDxcLog;
IDXCompiler::CompileAttribs CA;
@@ -472,23 +471,23 @@ void DXCompilerImpl::Compile(const ShaderCreateInfo& ShaderCI,
CA.Profile = wstrProfile.c_str();
CA.pDefines = nullptr;
CA.DefinesCount = 0;
- CA.pArgs = m_Target == DXCompilerTarget::Direct3D12 ? pDxbcArgs : pSpirvArgs;
- CA.ArgsCount = m_Target == DXCompilerTarget::Direct3D12 ? _countof(pDxbcArgs) : _countof(pSpirvArgs);
+ CA.pArgs = m_Target == DXCompilerTarget::Direct3D12 ? pDxilArgs : pSpirvArgs;
+ CA.ArgsCount = m_Target == DXCompilerTarget::Direct3D12 ? _countof(pDxilArgs) : _countof(pSpirvArgs);
CA.pShaderSourceStreamFactory = ShaderCI.pShaderSourceStreamFactory;
- CA.ppBlobOut = &pCompiledShader;
+ CA.ppBlobOut = &pDXIL;
CA.ppCompilerOutput = &pDxcLog;
auto result = Compile(CA);
HandleHLSLCompilerResult(result, pDxcLog.p, Source, ShaderCI.Desc.Name, ppCompilerOutput);
- if (result && pCompiledShader && pCompiledShader->GetBufferSize() > 0)
+ if (result && pDXIL && pDXIL->GetBufferSize() > 0)
{
if (pByteCode != nullptr)
- pByteCode->assign(static_cast<uint32_t*>(pCompiledShader->GetBufferPointer()),
- static_cast<uint32_t*>(pCompiledShader->GetBufferPointer()) + pCompiledShader->GetBufferSize() / sizeof(uint32_t));
+ pByteCode->assign(static_cast<uint32_t*>(pDXIL->GetBufferPointer()),
+ static_cast<uint32_t*>(pDXIL->GetBufferPointer()) + pDXIL->GetBufferSize() / sizeof(uint32_t));
if (ppByteCodeBlob != nullptr)
- *ppByteCodeBlob = pCompiledShader.Detach();
+ *ppByteCodeBlob = pDXIL.Detach();
}
}