| 314 | } |
| 315 | |
| 316 | ShaderToolOutput ShaderProcessingTool::CompileShader(QWidget *window, rdcstr source, |
| 317 | rdcstr entryPoint, ShaderStage stage, |
| 318 | rdcstr spirvVer, rdcstr arguments) const |
| 319 | { |
| 320 | QStringList argList = ParseArgsList(arguments.isEmpty() ? DefaultArguments() : arguments); |
| 321 | // always append IO arguments for known tools, so we read/write to our own files and override any |
| 322 | // dangling output specified file in the embedded command line |
| 323 | argList.append(ParseArgsList(IOArguments())); |
| 324 | |
| 325 | QString input_file, output_file; |
| 326 | |
| 327 | input_file = tmpPath(lit("shader_input")); |
| 328 | |
| 329 | if(spirvVer.isEmpty()) |
| 330 | spirvVer = "spirv1.0"; |
| 331 | |
| 332 | // replace arguments after expansion to avoid problems with quoting paths etc |
| 333 | for(QString &arg : argList) |
| 334 | { |
| 335 | if(arg == lit("{input_file}")) |
| 336 | arg = input_file; |
| 337 | if(arg == lit("{output_file}")) |
| 338 | arg = output_file = tmpPath(lit("shader_output")); |
| 339 | if(arg == lit("{entry_point}")) |
| 340 | arg = entryPoint; |
| 341 | |
| 342 | // substring replacements to enable e.g. {hlsl_stage2}_6_0 and ={vulkan_ver} |
| 343 | arg.replace(lit("{glsl_stage4}"), glsl_stage4[int(stage)]); |
| 344 | arg.replace(lit("{hlsl_stage2}"), hlsl_stage2[int(stage)]); |
| 345 | arg.replace(lit("{full_stage}"), full_stage[int(stage)]); |
| 346 | arg.replace(lit("{spirv_ver}"), spirvVer); |
| 347 | arg.replace(lit("{vulkan_ver}"), vulkanVerForSpirVer(spirvVer)); |
| 348 | } |
| 349 | |
| 350 | QFile binHandle(input_file); |
| 351 | if(binHandle.open(QFile::WriteOnly | QIODevice::Truncate)) |
| 352 | { |
| 353 | binHandle.write(QByteArray((const char *)source.c_str(), source.count())); |
| 354 | binHandle.close(); |
| 355 | } |
| 356 | else |
| 357 | { |
| 358 | ShaderToolOutput ret; |
| 359 | |
| 360 | ret.log = QApplication::translate("ShaderProcessingTool", |
| 361 | "ERROR: Couldn't write input to temporary file '%1'") |
| 362 | .arg(input_file); |
| 363 | |
| 364 | return ret; |
| 365 | } |
| 366 | |
| 367 | return RunTool(*this, window, input_file, output_file, argList); |
| 368 | } |
nothing calls this directly
no test coverage detected