From c8a6d0dbb75f9ce8410ef24703bdd3c135661e9a Mon Sep 17 00:00:00 2001 From: baldurk Date: Sat, 14 Nov 2015 19:44:05 +0100 Subject: [PATCH] If displaying via a custom shader when saving texture, save that output --- renderdoc/api/replay/renderdoc_replay.h | 2 ++ renderdoc/replay/replay_output.cpp | 3 +++ renderdoc/replay/replay_renderer.h | 2 ++ renderdocui/Interop/ReplayRenderer.cs | 12 ++++++++++++ renderdocui/Windows/TextureViewer.cs | 10 ++++++++++ 5 files changed, 29 insertions(+) diff --git a/renderdoc/api/replay/renderdoc_replay.h b/renderdoc/api/replay/renderdoc_replay.h index 88ad1d0e0..40cc7230c 100644 --- a/renderdoc/api/replay/renderdoc_replay.h +++ b/renderdoc/api/replay/renderdoc_replay.h @@ -152,6 +152,8 @@ extern "C" RENDERDOC_API bool32 RENDERDOC_CC ReplayOutput_SetPixelContext(Replay extern "C" RENDERDOC_API bool32 RENDERDOC_CC ReplayOutput_SetPixelContextLocation(ReplayOutput *output, uint32_t x, uint32_t y); extern "C" RENDERDOC_API void RENDERDOC_CC ReplayOutput_DisablePixelContext(ReplayOutput *output); +extern "C" RENDERDOC_API void RENDERDOC_CC ReplayOutput_GetCustomShaderTexID(ReplayOutput *output, ResourceId *id); + extern "C" RENDERDOC_API bool32 RENDERDOC_CC ReplayOutput_PickPixel(ReplayOutput *output, ResourceId texID, bool32 customShader, uint32_t x, uint32_t y, uint32_t sliceFace, uint32_t mip, uint32_t sample, PixelValue *val); extern "C" RENDERDOC_API uint32_t RENDERDOC_CC ReplayOutput_PickVertex(ReplayOutput *output, uint32_t frameID, uint32_t eventID, uint32_t x, uint32_t y); diff --git a/renderdoc/replay/replay_output.cpp b/renderdoc/replay/replay_output.cpp index b0c2e9384..d6a05ebd1 100644 --- a/renderdoc/replay/replay_output.cpp +++ b/renderdoc/replay/replay_output.cpp @@ -669,6 +669,9 @@ extern "C" RENDERDOC_API bool32 RENDERDOC_CC ReplayOutput_SetPixelContextLocatio extern "C" RENDERDOC_API void RENDERDOC_CC ReplayOutput_DisablePixelContext(ReplayOutput *output) { output->DisablePixelContext(); } +extern "C" RENDERDOC_API void RENDERDOC_CC ReplayOutput_GetCustomShaderTexID(ReplayOutput *output, ResourceId *id) +{ if(id) *id = output->GetCustomShaderTexID(); } + extern "C" RENDERDOC_API bool32 RENDERDOC_CC ReplayOutput_PickPixel(ReplayOutput *output, ResourceId texID, bool32 customShader, uint32_t x, uint32_t y, uint32_t sliceFace, uint32_t mip, uint32_t sample, PixelValue *val) { return output->PickPixel(texID, customShader != 0, x, y, sliceFace, mip, sample, val); } diff --git a/renderdoc/replay/replay_renderer.h b/renderdoc/replay/replay_renderer.h index 2a4ae1ef5..388cdba99 100644 --- a/renderdoc/replay/replay_renderer.h +++ b/renderdoc/replay/replay_renderer.h @@ -55,6 +55,8 @@ public: bool SetPixelContextLocation(uint32_t x, uint32_t y); void DisablePixelContext(); + ResourceId GetCustomShaderTexID() { return m_CustomShaderResourceId; } + bool PickPixel(ResourceId texID, bool customShader, uint32_t x, uint32_t y, uint32_t sliceFace, uint32_t mip, uint32_t sample, PixelValue *val); diff --git a/renderdocui/Interop/ReplayRenderer.cs b/renderdocui/Interop/ReplayRenderer.cs index 0b47ddd27..0297e7e6f 100644 --- a/renderdocui/Interop/ReplayRenderer.cs +++ b/renderdocui/Interop/ReplayRenderer.cs @@ -98,6 +98,9 @@ namespace renderdoc private static extern bool ReplayOutput_SetPixelContextLocation(IntPtr real, UInt32 x, UInt32 y); [DllImport("renderdoc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] private static extern void ReplayOutput_DisablePixelContext(IntPtr real); + + [DllImport("renderdoc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] + private static extern void ReplayOutput_GetCustomShaderTexID(IntPtr real, ref ResourceId texid); [DllImport("renderdoc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] private static extern bool ReplayOutput_PickPixel(IntPtr real, ResourceId texID, bool customShader, @@ -149,6 +152,15 @@ namespace renderdoc ReplayOutput_DisablePixelContext(m_Real); } + public ResourceId GetCustomShaderTexID() + { + ResourceId ret = ResourceId.Null; + + ReplayOutput_GetCustomShaderTexID(m_Real, ref ret); + + return ret; + } + public PixelValue PickPixel(ResourceId texID, bool customShader, UInt32 x, UInt32 y, UInt32 sliceFace, UInt32 mip, UInt32 sample) { IntPtr mem = CustomMarshal.Alloc(typeof(PixelValue)); diff --git a/renderdocui/Windows/TextureViewer.cs b/renderdocui/Windows/TextureViewer.cs index c2b03ab94..07436af98 100644 --- a/renderdocui/Windows/TextureViewer.cs +++ b/renderdocui/Windows/TextureViewer.cs @@ -3417,6 +3417,16 @@ namespace renderdocui.Windows if (m_TexDisplay.Alpha && !checkerBack.Checked) m_SaveDialog.saveData.alpha = AlphaMapping.BlendToColour; m_SaveDialog.tex = CurrentTexture; + if (m_TexDisplay.CustomShader != ResourceId.Null) + { + m_Core.Renderer.Invoke((ReplayRenderer r) => + { + ResourceId id = m_Output.GetCustomShaderTexID(); + if(id != ResourceId.Null) + m_SaveDialog.saveData.id = id; + }); + } + if(m_SaveDialog.ShowDialog() == DialogResult.OK) { bool ret = false;