MCPcopy Create free account
hub / github.com/baldurk/renderdoc / ApplyShaderEdit

Method ApplyShaderEdit

qrenderdoc/Code/CaptureContext.cpp:2561–2600  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2559}
2560
2561void CaptureContext::ApplyShaderEdit(IShaderViewer *viewer, ResourceId id, ShaderStage stage,
2562 ShaderEncoding shaderEncoding, ShaderCompileFlags flags,
2563 const rdcstr &entryFunc, const bytebuf &shaderBytes)
2564{
2565 if(shaderBytes.isEmpty())
2566 return;
2567
2568 ANALYTIC_SET(UIFeatures.ShaderEditing, true);
2569
2570 QPointer<QObject> ptr(viewer->Widget());
2571
2572 // invoke off to the ReplayController to replace the capture's shader
2573 // with our edited one
2574 Replay().AsyncInvoke([this, entryFunc, shaderBytes, shaderEncoding, flags, stage, id, ptr,
2575 viewer](IReplayController *r) {
2576 rdcstr errs;
2577
2578 ResourceId from = id;
2579 ResourceId to;
2580
2581 rdctie(to, errs) = r->BuildTargetShader(entryFunc, shaderEncoding, shaderBytes, flags, stage);
2582
2583 if(to == ResourceId())
2584 {
2585 r->RemoveReplacement(from);
2586
2587 // this GUIInvoke call always needs to go through even if the viewer has been closed.
2588 GUIInvoke::call(GetMainWindow()->Widget(), [this, from]() { UnregisterReplacement(from); });
2589 }
2590 else
2591 {
2592 r->ReplaceResource(from, to);
2593
2594 GUIInvoke::call(GetMainWindow()->Widget(),
2595 [this, from, to]() { RegisterReplacement(from, to); });
2596 }
2597 if(ptr)
2598 GUIInvoke::call(ptr, [viewer, errs]() { viewer->ShowErrors(errs); });
2599 });
2600}
2601
2602void CaptureContext::RevertShaderEdit(IShaderViewer *viewer, ResourceId id)
2603{

Callers

nothing calls this directly

Calls 9

rdctieFunction · 0.85
ShowErrorsMethod · 0.80
ResourceIdFunction · 0.50
isEmptyMethod · 0.45
WidgetMethod · 0.45
AsyncInvokeMethod · 0.45
BuildTargetShaderMethod · 0.45
RemoveReplacementMethod · 0.45
ReplaceResourceMethod · 0.45

Tested by

no test coverage detected