summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorazhirnov <zh1dron@gmail.com>2020-11-12 16:21:15 +0000
committerazhirnov <zh1dron@gmail.com>2020-11-12 18:22:27 +0000
commitea9e37f92332358fe85f7802bc301ab509fa2003 (patch)
treedc115cf8174b1c4cce34080ca99557714496f98f
parentadded address alignment checks (diff)
downloadDiligentCore-ea9e37f92332358fe85f7802bc301ab509fa2003.tar.gz
DiligentCore-ea9e37f92332358fe85f7802bc301ab509fa2003.zip
added IntToStr instead of _itoa_s, fixed compilation
-rw-r--r--Graphics/ShaderTools/src/DXCompiler.cpp34
-rw-r--r--ThirdParty/DirectXShaderCompiler/dxc/Support/dxcapi.cpp2
2 files changed, 27 insertions, 9 deletions
diff --git a/Graphics/ShaderTools/src/DXCompiler.cpp b/Graphics/ShaderTools/src/DXCompiler.cpp
index 3d5bedb9..cdad9b55 100644
--- a/Graphics/ShaderTools/src/DXCompiler.cpp
+++ b/Graphics/ShaderTools/src/DXCompiler.cpp
@@ -771,6 +771,7 @@ bool DXCompilerImpl::RemapResourceBinding(const TBindingMapPerStage& BindingMapP
size_t BytecodeSize,
IDxcBlob** ppByteCodeBlob)
{
+#if D3D12_SUPPORTED
auto CreateInstance = GetCreateInstaceProc();
if (CreateInstance == nullptr)
@@ -874,13 +875,28 @@ bool DXCompilerImpl::RemapResourceBinding(const TBindingMapPerStage& BindingMapP
return false;
return ValidateAndSign(CreateInstance, library, compiled, ppByteCodeBlob);
+#else
+
+ return false;
+#endif // D3D12_SUPPORTED
}
bool DXCompilerImpl::PatchDXIL(const TResourceBindingMap& ResourceMap, String& DXIL) const
{
String ResName;
- char BindPointStr[256];
- const char Zero[] = "0";
+ char BindPointStr[32];
+ const char Zero[] = "0";
+ const auto IntToStr = [&BindPointStr](int val) //
+ {
+ char* str = &BindPointStr[_countof(BindPointStr) - 1];
+ *(str--) = 0;
+ do
+ {
+ *(str--) = "0123456789"[val % 10];
+ val /= 10;
+ } while (val);
+ return ++str;
+ };
for (auto& ResPair : ResourceMap)
{
@@ -903,10 +919,9 @@ bool DXCompilerImpl::PatchDXIL(const TResourceBindingMap& ResourceMap, String& D
const char c = DXIL[i];
if (c == ' ')
{
- const char* str = &DXIL[PartStart];
-
if (Part == 0 || Part == 2)
{
+ const char* str = &DXIL[PartStart];
VERIFY_EXPR(std::memcmp(str, "i32", i - PartStart) == 0);
}
else if (Part == 1) // space
@@ -916,9 +931,9 @@ bool DXCompilerImpl::PatchDXIL(const TResourceBindingMap& ResourceMap, String& D
}
else if (Part == 3) // bind point
{
- _itoa_s(BindPoint, BindPointStr, 10);
- DXIL.replace(PartStart, i - PartStart - 1, BindPointStr);
- i = PartStart + strlen(BindPointStr) + 1;
+ const char* str = IntToStr(BindPoint);
+ DXIL.replace(PartStart, i - PartStart - 1, str);
+ i = PartStart + strlen(str) + 1;
}
else
break;
@@ -931,13 +946,16 @@ bool DXCompilerImpl::PatchDXIL(const TResourceBindingMap& ResourceMap, String& D
return true;
}
+namespace
+{
template <Uint32 S>
-bool ReverseCmp(const char* lhsRev, const char (&rhs)[S])
+inline bool ReverseCmp(const char* lhsRev, const char (&rhs)[S])
{
const Uint32 count = S - 1;
const char* lhs = lhsRev - count;
return std::memcmp(lhs, rhs, count) == 0;
}
+} // namespace
SHADER_TYPE DXCompilerImpl::GetEntryShaderType(const String& EntryPoint, const String& DXIL) const
{
diff --git a/ThirdParty/DirectXShaderCompiler/dxc/Support/dxcapi.cpp b/ThirdParty/DirectXShaderCompiler/dxc/Support/dxcapi.cpp
index d5ebbb14..a04a02c9 100644
--- a/ThirdParty/DirectXShaderCompiler/dxc/Support/dxcapi.cpp
+++ b/ThirdParty/DirectXShaderCompiler/dxc/Support/dxcapi.cpp
@@ -5,4 +5,4 @@ DEFINE_CROSS_PLATFORM_UUIDOF(IDxcLibrary)
DEFINE_CROSS_PLATFORM_UUIDOF(IDxcCompiler)
DEFINE_CROSS_PLATFORM_UUIDOF(IDxcValidator)
DEFINE_CROSS_PLATFORM_UUIDOF(IDxcVersionInfo)
-
+DEFINE_CROSS_PLATFORM_UUIDOF(IDxcAssembler)