|
@@ -8,6 +8,7 @@
|
|
|
#include <AnKi/Util/Filesystem.h>
|
|
#include <AnKi/Util/Filesystem.h>
|
|
|
#include <AnKi/Util/File.h>
|
|
#include <AnKi/Util/File.h>
|
|
|
#include <AnKi/Util/HighRezTimer.h>
|
|
#include <AnKi/Util/HighRezTimer.h>
|
|
|
|
|
+#include <AnKi/Util/StringList.h>
|
|
|
|
|
|
|
|
namespace anki {
|
|
namespace anki {
|
|
|
|
|
|
|
@@ -18,28 +19,28 @@ static CString profile(ShaderType shaderType)
|
|
|
switch(shaderType)
|
|
switch(shaderType)
|
|
|
{
|
|
{
|
|
|
case ShaderType::kVertex:
|
|
case ShaderType::kVertex:
|
|
|
- return "vs_6_7";
|
|
|
|
|
|
|
+ return "vs_6_8";
|
|
|
break;
|
|
break;
|
|
|
case ShaderType::kFragment:
|
|
case ShaderType::kFragment:
|
|
|
- return "ps_6_7";
|
|
|
|
|
|
|
+ return "ps_6_8";
|
|
|
break;
|
|
break;
|
|
|
case ShaderType::kTessellationEvaluation:
|
|
case ShaderType::kTessellationEvaluation:
|
|
|
- return "ds_6_7";
|
|
|
|
|
|
|
+ return "ds_6_8";
|
|
|
break;
|
|
break;
|
|
|
case ShaderType::kTessellationControl:
|
|
case ShaderType::kTessellationControl:
|
|
|
- return "ds_6_7";
|
|
|
|
|
|
|
+ return "ds_6_8";
|
|
|
break;
|
|
break;
|
|
|
case ShaderType::kGeometry:
|
|
case ShaderType::kGeometry:
|
|
|
- return "gs_6_7";
|
|
|
|
|
|
|
+ return "gs_6_8";
|
|
|
break;
|
|
break;
|
|
|
case ShaderType::kTask:
|
|
case ShaderType::kTask:
|
|
|
- return "as_6_7";
|
|
|
|
|
|
|
+ return "as_6_8";
|
|
|
break;
|
|
break;
|
|
|
case ShaderType::kMesh:
|
|
case ShaderType::kMesh:
|
|
|
- return "ms_6_7";
|
|
|
|
|
|
|
+ return "ms_6_8";
|
|
|
break;
|
|
break;
|
|
|
case ShaderType::kCompute:
|
|
case ShaderType::kCompute:
|
|
|
- return "cs_6_7";
|
|
|
|
|
|
|
+ return "cs_6_8";
|
|
|
break;
|
|
break;
|
|
|
case ShaderType::kRayGen:
|
|
case ShaderType::kRayGen:
|
|
|
case ShaderType::kAnyHit:
|
|
case ShaderType::kAnyHit:
|
|
@@ -47,7 +48,8 @@ static CString profile(ShaderType shaderType)
|
|
|
case ShaderType::kMiss:
|
|
case ShaderType::kMiss:
|
|
|
case ShaderType::kIntersection:
|
|
case ShaderType::kIntersection:
|
|
|
case ShaderType::kCallable:
|
|
case ShaderType::kCallable:
|
|
|
- return "lib_6_7";
|
|
|
|
|
|
|
+ case ShaderType::kWorkgraph:
|
|
|
|
|
+ return "lib_6_8";
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
|
ANKI_ASSERT(0);
|
|
ANKI_ASSERT(0);
|
|
@@ -56,8 +58,8 @@ static CString profile(ShaderType shaderType)
|
|
|
return "";
|
|
return "";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static Error compileHlsl(CString src, ShaderType shaderType, Bool compileWith16bitTypes, Bool spirv, ShaderCompilerDynamicArray<U8>& bin,
|
|
|
|
|
- ShaderCompilerString& errorMessage)
|
|
|
|
|
|
|
+static Error compileHlsl(CString src, ShaderType shaderType, Bool compileWith16bitTypes, Bool debugInfo, Bool spirv,
|
|
|
|
|
+ ShaderCompilerDynamicArray<U8>& bin, ShaderCompilerString& errorMessage)
|
|
|
{
|
|
{
|
|
|
Array<U64, 3> toHash = {g_nextFileId.fetchAdd(1), getCurrentProcessId(), getRandom() & kMaxU32};
|
|
Array<U64, 3> toHash = {g_nextFileId.fetchAdd(1), getCurrentProcessId(), getRandom() & kMaxU32};
|
|
|
const U64 rand = computeHash(&toHash[0], sizeof(toHash));
|
|
const U64 rand = computeHash(&toHash[0], sizeof(toHash));
|
|
@@ -79,7 +81,7 @@ static Error compileHlsl(CString src, ShaderType shaderType, Bool compileWith16b
|
|
|
ShaderCompilerString binFilename;
|
|
ShaderCompilerString binFilename;
|
|
|
binFilename.sprintf("%s/%" PRIu64 ".spvdxil", tmpDir.cstr(), rand);
|
|
binFilename.sprintf("%s/%" PRIu64 ".spvdxil", tmpDir.cstr(), rand);
|
|
|
|
|
|
|
|
- ShaderCompilerDynamicArray<ShaderCompilerString> dxcArgs;
|
|
|
|
|
|
|
+ ShaderCompilerStringList dxcArgs;
|
|
|
dxcArgs.emplaceBack("-Fo");
|
|
dxcArgs.emplaceBack("-Fo");
|
|
|
dxcArgs.emplaceBack(binFilename);
|
|
dxcArgs.emplaceBack(binFilename);
|
|
|
dxcArgs.emplaceBack("-Wall");
|
|
dxcArgs.emplaceBack("-Wall");
|
|
@@ -97,10 +99,12 @@ static Error compileHlsl(CString src, ShaderType shaderType, Bool compileWith16b
|
|
|
dxcArgs.emplaceBack("main");
|
|
dxcArgs.emplaceBack("main");
|
|
|
dxcArgs.emplaceBack("-T");
|
|
dxcArgs.emplaceBack("-T");
|
|
|
dxcArgs.emplaceBack(profile(shaderType));
|
|
dxcArgs.emplaceBack(profile(shaderType));
|
|
|
|
|
+
|
|
|
if(ANKI_COMPILER_MSVC)
|
|
if(ANKI_COMPILER_MSVC)
|
|
|
{
|
|
{
|
|
|
dxcArgs.emplaceBack("-fdiagnostics-format=msvc"); // Make errors clickable in visual studio
|
|
dxcArgs.emplaceBack("-fdiagnostics-format=msvc"); // Make errors clickable in visual studio
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
if(spirv)
|
|
if(spirv)
|
|
|
{
|
|
{
|
|
|
dxcArgs.emplaceBack("-spirv");
|
|
dxcArgs.emplaceBack("-spirv");
|
|
@@ -129,10 +133,15 @@ static Error compileHlsl(CString src, ShaderType shaderType, Bool compileWith16b
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- dxcArgs.emplaceBack("-Wno-ignored-attributes"); // TODO rm that eventually
|
|
|
|
|
- dxcArgs.emplaceBack("-Wno-inline-asm"); // TODO rm that eventually
|
|
|
|
|
|
|
+ dxcArgs.emplaceBack("-Wno-ignored-attributes"); // TODO remove that at some point
|
|
|
|
|
+ dxcArgs.emplaceBack("-Wno-inline-asm"); // Workaround a DXC bug
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(debugInfo)
|
|
|
|
|
+ {
|
|
|
|
|
+ dxcArgs.emplaceBack("-Zi");
|
|
|
}
|
|
}
|
|
|
- // dxcArgs.emplaceBack("-Zi"); // Debug info
|
|
|
|
|
|
|
+
|
|
|
dxcArgs.emplaceBack(hlslFilename);
|
|
dxcArgs.emplaceBack(hlslFilename);
|
|
|
|
|
|
|
|
if(compileWith16bitTypes)
|
|
if(compileWith16bitTypes)
|
|
@@ -141,10 +150,11 @@ static Error compileHlsl(CString src, ShaderType shaderType, Bool compileWith16b
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
ShaderCompilerDynamicArray<CString> dxcArgs2;
|
|
ShaderCompilerDynamicArray<CString> dxcArgs2;
|
|
|
- dxcArgs2.resize(dxcArgs.getSize());
|
|
|
|
|
- for(U32 i = 0; i < dxcArgs.getSize(); ++i)
|
|
|
|
|
|
|
+ dxcArgs2.resize(U32(dxcArgs.getSize()));
|
|
|
|
|
+ U32 count = 0;
|
|
|
|
|
+ for(auto& it : dxcArgs)
|
|
|
{
|
|
{
|
|
|
- dxcArgs2[i] = dxcArgs[i];
|
|
|
|
|
|
|
+ dxcArgs2[count++] = it.cstr();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
while(true)
|
|
while(true)
|
|
@@ -171,6 +181,12 @@ static Error compileHlsl(CString src, ShaderType shaderType, Bool compileWith16b
|
|
|
(void)err; // Shoudn't throw an error
|
|
(void)err; // Shoudn't throw an error
|
|
|
errorMessage = errorMessageTmp;
|
|
errorMessage = errorMessageTmp;
|
|
|
|
|
|
|
|
|
|
+ ShaderCompilerString args;
|
|
|
|
|
+ dxcArgs.join(" ", args);
|
|
|
|
|
+ errorMessage += " (";
|
|
|
|
|
+ errorMessage += args;
|
|
|
|
|
+ errorMessage += ")";
|
|
|
|
|
+
|
|
|
if(!errorMessage.isEmpty() && errorMessage.find("The process cannot access the file because") != CString::kNpos)
|
|
if(!errorMessage.isEmpty() && errorMessage.find("The process cannot access the file because") != CString::kNpos)
|
|
|
{
|
|
{
|
|
|
// DXC might fail to read the HLSL because the antivirus might be having a lock on it. Try again
|
|
// DXC might fail to read the HLSL because the antivirus might be having a lock on it. Try again
|
|
@@ -206,16 +222,16 @@ static Error compileHlsl(CString src, ShaderType shaderType, Bool compileWith16b
|
|
|
return Error::kNone;
|
|
return Error::kNone;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-Error compileHlslToSpirv(CString src, ShaderType shaderType, Bool compileWith16bitTypes, ShaderCompilerDynamicArray<U8>& spirv,
|
|
|
|
|
|
|
+Error compileHlslToSpirv(CString src, ShaderType shaderType, Bool compileWith16bitTypes, Bool debugInfo, ShaderCompilerDynamicArray<U8>& spirv,
|
|
|
ShaderCompilerString& errorMessage)
|
|
ShaderCompilerString& errorMessage)
|
|
|
{
|
|
{
|
|
|
- return compileHlsl(src, shaderType, compileWith16bitTypes, true, spirv, errorMessage);
|
|
|
|
|
|
|
+ return compileHlsl(src, shaderType, compileWith16bitTypes, debugInfo, true, spirv, errorMessage);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-Error compileHlslToDxil(CString src, ShaderType shaderType, Bool compileWith16bitTypes, ShaderCompilerDynamicArray<U8>& dxil,
|
|
|
|
|
|
|
+Error compileHlslToDxil(CString src, ShaderType shaderType, Bool compileWith16bitTypes, Bool debugInfo, ShaderCompilerDynamicArray<U8>& dxil,
|
|
|
ShaderCompilerString& errorMessage)
|
|
ShaderCompilerString& errorMessage)
|
|
|
{
|
|
{
|
|
|
- return compileHlsl(src, shaderType, compileWith16bitTypes, false, dxil, errorMessage);
|
|
|
|
|
|
|
+ return compileHlsl(src, shaderType, compileWith16bitTypes, debugInfo, false, dxil, errorMessage);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} // end namespace anki
|
|
} // end namespace anki
|