| 6541 | } |
| 6542 | |
| 6543 | void ShaderViewer::on_refresh_clicked() |
| 6544 | { |
| 6545 | if(m_Trace) |
| 6546 | { |
| 6547 | m_Ctx.GetPipelineViewer()->SaveShaderFile(m_ShaderDetails); |
| 6548 | return; |
| 6549 | } |
| 6550 | |
| 6551 | ShaderEncoding encoding = currentEncoding(); |
| 6552 | |
| 6553 | // if we don't have any compile tools - even the 'builtin' one, this compilation is not going to |
| 6554 | // succeed. |
| 6555 | if(ui->compileTool->count() == 0 && !m_CustomShader) |
| 6556 | { |
| 6557 | ShowErrors(tr("No compilation tool found that takes %1 as input and produces compatible output") |
| 6558 | .arg(ToQStr(encoding))); |
| 6559 | } |
| 6560 | else if(m_SaveCallback) |
| 6561 | { |
| 6562 | rdcstrpairs files; |
| 6563 | for(ScintillaEdit *s : m_Scintillas) |
| 6564 | { |
| 6565 | QWidget *w = (QWidget *)s; |
| 6566 | files.push_back( |
| 6567 | {w->property("filename").toString(), QString::fromUtf8(s->getText(s->textLength() + 1))}); |
| 6568 | } |
| 6569 | |
| 6570 | if(files.isEmpty()) |
| 6571 | return; |
| 6572 | |
| 6573 | QString source = files[0].second; |
| 6574 | |
| 6575 | if(encoding == ShaderEncoding::HLSL || encoding == ShaderEncoding::Slang || |
| 6576 | encoding == ShaderEncoding::GLSL) |
| 6577 | { |
| 6578 | rdcarray<rdcstr> allIncluded = {files[0].first}; |
| 6579 | bool success = ProcessIncludeDirectives(source, files, allIncluded, {files[0].first}); |
| 6580 | if(!success) |
| 6581 | return; |
| 6582 | } |
| 6583 | |
| 6584 | m_Saved = true; |
| 6585 | |
| 6586 | bytebuf shaderBytes(source.toUtf8()); |
| 6587 | |
| 6588 | rdcarray<ShaderEncoding> accepted = m_Ctx.TargetShaderEncodings(); |
| 6589 | |
| 6590 | rdcstr spirvVer = "spirv1.0"; |
| 6591 | for(const ShaderCompileFlag &flag : m_Flags.flags) |
| 6592 | if(flag.name == "@spirver") |
| 6593 | spirvVer = flag.value; |
| 6594 | |
| 6595 | if(m_CustomShader || (accepted.indexOf(encoding) >= 0 && |
| 6596 | ui->compileTool->currentIndex() == ui->compileTool->count() - 1)) |
| 6597 | { |
| 6598 | // if using the builtin compiler, just pass through |
| 6599 | } |
| 6600 | else |
nothing calls this directly
no test coverage detected