Skip to content

Commit 3f625cb

Browse files
committed
Mitigate preprocess & fix some DXC flags
1 parent 3bdb4bc commit 3f625cb

File tree

1 file changed

+42
-6
lines changed

1 file changed

+42
-6
lines changed

src/nbl/asset/utils/CHLSLCompiler.cpp

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,20 +101,56 @@ core::smart_refctd_ptr<ICPUShader> CHLSLCompiler::compileToSPIRV(const char* cod
101101
hlslOptions.preprocessorOptions.logger.log("code is nullptr", system::ILogger::ELL_ERROR);
102102
return nullptr;
103103
}
104-
105-
auto newCode = preprocessShader(code, hlslOptions.stage, hlslOptions.preprocessorOptions);
104+
105+
auto newCode = std::string(code);//preprocessShader(code, hlslOptions.stage, hlslOptions.preprocessorOptions);
106+
107+
// Suffix is the shader model version
108+
std::wstring targetProfile(L"XX_6_2");
109+
110+
// Set profile two letter prefix based on stage
111+
switch (options.stage) {
112+
case asset::IShader::ESS_VERTEX:
113+
targetProfile.replace(0, 2, L"vs");
114+
break;
115+
case asset::IShader::ESS_TESSELLATION_CONTROL:
116+
targetProfile.replace(0, 2, L"ds");
117+
break;
118+
case asset::IShader::ESS_TESSELLATION_EVALUATION:
119+
targetProfile.replace(0, 2, L"hs");
120+
break;
121+
case asset::IShader::ESS_GEOMETRY:
122+
targetProfile.replace(0, 2, L"gs");
123+
break;
124+
case asset::IShader::ESS_FRAGMENT:
125+
targetProfile.replace(0, 2, L"ps");
126+
break;
127+
case asset::IShader::ESS_COMPUTE:
128+
targetProfile.replace(0, 2, L"cs");
129+
break;
130+
case asset::IShader::ESS_TASK:
131+
targetProfile.replace(0, 2, L"as");
132+
break;
133+
case asset::IShader::ESS_MESH:
134+
targetProfile.replace(0, 2, L"ms");
135+
break;
136+
default:
137+
hlslOptions.preprocessorOptions.logger.log("invalid shader stage %i", system::ILogger::ELL_ERROR, options.stage);
138+
return nullptr;
139+
};
106140

107141
LPCWSTR arguments[] = {
108142
// These will always be present
109143
L"-spirv",
110-
L"-HLSL2021",
144+
L"-HV", L"2021",
145+
L"-T", targetProfile.c_str(),
111146

112147
// These are debug only
113-
L"-Qembed_debug"
148+
L"-Zi", // Enables debug information
149+
L"-Qembed_debug" //Embeds debug information
114150
};
115151

116-
const uint32_t nonDebugArgs = 2;
117-
const uint32_t allArgs = nonDebugArgs + 0;
152+
const uint32_t nonDebugArgs = 3;
153+
const uint32_t allArgs = nonDebugArgs + 1;
118154

119155
DxcCompilationResult compileResult = dxcCompile(newCode, &arguments[0], hlslOptions.genDebugInfo ? allArgs : nonDebugArgs, hlslOptions);
120156

0 commit comments

Comments
 (0)