| 2559 | } |
| 2560 | |
| 2561 | void 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 | |
| 2602 | void CaptureContext::RevertShaderEdit(IShaderViewer *viewer, ResourceId id) |
| 2603 | { |
nothing calls this directly
no test coverage detected