diff --git a/renderdoc/api/replay/gl_pipestate.h b/renderdoc/api/replay/gl_pipestate.h index 8f3074437..14b5da9b8 100644 --- a/renderdoc/api/replay/gl_pipestate.h +++ b/renderdoc/api/replay/gl_pipestate.h @@ -343,10 +343,17 @@ struct GLPipelineState struct Attachment { - Attachment() : Obj(), Layer(0), Mip(0) {} + Attachment() : Obj(), Layer(0), Mip(0) + { + Swizzle[0] = eSwizzle_Red; + Swizzle[1] = eSwizzle_Green; + Swizzle[2] = eSwizzle_Blue; + Swizzle[3] = eSwizzle_Alpha; + } ResourceId Obj; uint32_t Layer; uint32_t Mip; + TextureSwizzle Swizzle[4]; }; struct FBO diff --git a/renderdoc/core/replay_proxy.cpp b/renderdoc/core/replay_proxy.cpp index 87563152e..2dee34c82 100644 --- a/renderdoc/core/replay_proxy.cpp +++ b/renderdoc/core/replay_proxy.cpp @@ -903,8 +903,9 @@ void Serialiser::Serialise(const char *name, GLPipelineState::FrameBuffer::Attac Serialise("", el.Obj); Serialise("", el.Layer); Serialise("", el.Mip); + SerialisePODArray<4>("", el.Swizzle); - SIZE_CHECK(16); + SIZE_CHECK(32); } template <> @@ -929,7 +930,7 @@ void Serialiser::Serialise(const char *name, GLPipelineState::FrameBuffer &el) Serialise("", el.m_Blending); - SIZE_CHECK(200); + SIZE_CHECK(264); } template <> @@ -963,7 +964,7 @@ void Serialiser::Serialise(const char *name, GLPipelineState &el) Serialise("", el.m_Hints); - SIZE_CHECK(1952); + SIZE_CHECK(2016); } #pragma endregion OpenGL pipeline state diff --git a/renderdoc/driver/gl/gl_replay.cpp b/renderdoc/driver/gl/gl_replay.cpp index 8fd85f8d2..9606a4bb8 100644 --- a/renderdoc/driver/gl/gl_replay.cpp +++ b/renderdoc/driver/gl/gl_replay.cpp @@ -1759,14 +1759,38 @@ void GLReplay::SavePipelineState() create_array_uninit(pipe.m_FB.m_DrawFBO.Color, numCols); for(GLint i = 0; i < numCols; i++) { - pipe.m_FB.m_DrawFBO.Color[i].Obj = rm->GetOriginalID( - rm->GetID(rbCol[i] ? RenderbufferRes(ctx, curCol[i]) : TextureRes(ctx, curCol[i]))); + ResourceId id = + rm->GetID(rbCol[i] ? RenderbufferRes(ctx, curCol[i]) : TextureRes(ctx, curCol[i])); + + pipe.m_FB.m_DrawFBO.Color[i].Obj = rm->GetOriginalID(id); if(pipe.m_FB.m_DrawFBO.Color[i].Obj != ResourceId() && !rbCol[i]) GetFramebufferMipAndLayer(gl.GetHookset(), eGL_DRAW_FRAMEBUFFER, GLenum(eGL_COLOR_ATTACHMENT0 + i), (GLint *)&pipe.m_FB.m_DrawFBO.Color[i].Mip, (GLint *)&pipe.m_FB.m_DrawFBO.Color[i].Layer); + + GLint swizzles[4] = {eGL_RED, eGL_GREEN, eGL_BLUE, eGL_ALPHA}; + if(!rbCol[i] && id != ResourceId() && (ExtensionSupported[GLExt_ARB_texture_swizzle] || + ExtensionSupported[GLExt_EXT_texture_swizzle])) + { + GLenum target = m_pDriver->m_Textures[id].curType; + gl.glGetTextureParameterivEXT(curCol[i], target, eGL_TEXTURE_SWIZZLE_RGBA, swizzles); + } + + for(int s = 0; s < 4; s++) + { + switch(swizzles[s]) + { + default: + case GL_ZERO: pipe.m_FB.m_DrawFBO.Color[i].Swizzle[s] = eSwizzle_Zero; break; + case GL_ONE: pipe.m_FB.m_DrawFBO.Color[i].Swizzle[s] = eSwizzle_One; break; + case eGL_RED: pipe.m_FB.m_DrawFBO.Color[i].Swizzle[s] = eSwizzle_Red; break; + case eGL_GREEN: pipe.m_FB.m_DrawFBO.Color[i].Swizzle[s] = eSwizzle_Green; break; + case eGL_BLUE: pipe.m_FB.m_DrawFBO.Color[i].Swizzle[s] = eSwizzle_Blue; break; + case eGL_ALPHA: pipe.m_FB.m_DrawFBO.Color[i].Swizzle[s] = eSwizzle_Alpha; break; + } + } } pipe.m_FB.m_DrawFBO.Depth.Obj = rm->GetOriginalID( diff --git a/renderdocui/Interop/GLPipelineState.cs b/renderdocui/Interop/GLPipelineState.cs index 211dc8fee..9d5e8689b 100644 --- a/renderdocui/Interop/GLPipelineState.cs +++ b/renderdocui/Interop/GLPipelineState.cs @@ -336,6 +336,8 @@ namespace renderdoc public ResourceId Obj; public UInt32 Layer; public UInt32 Mip; + [CustomMarshalAs(CustomUnmanagedType.FixedArray, FixedLength = 4)] + public TextureSwizzle[] Swizzle; }; [StructLayout(LayoutKind.Sequential)] @@ -345,7 +347,9 @@ namespace renderdoc [CustomMarshalAs(CustomUnmanagedType.TemplatedArray)] public Attachment[] Color; + [CustomMarshalAs(CustomUnmanagedType.CustomClass)] public Attachment Depth; + [CustomMarshalAs(CustomUnmanagedType.CustomClass)] public Attachment Stencil; [CustomMarshalAs(CustomUnmanagedType.TemplatedArray)] diff --git a/renderdocui/Windows/PipelineState/GLPipelineStateViewer.cs b/renderdocui/Windows/PipelineState/GLPipelineStateViewer.cs index 8a56dc759..fbb31d69c 100644 --- a/renderdocui/Windows/PipelineState/GLPipelineStateViewer.cs +++ b/renderdocui/Windows/PipelineState/GLPipelineStateViewer.cs @@ -1391,8 +1391,13 @@ namespace renderdocui.Windows.PipelineState foreach (var db in state.m_FB.m_DrawFBO.DrawBuffers) { ResourceId p = ResourceId.Null; + GLPipelineState.FrameBuffer.Attachment r = null; - if (db >= 0) p = state.m_FB.m_DrawFBO.Color[db].Obj; + if (db >= 0) + { + p = state.m_FB.m_DrawFBO.Color[db].Obj; + r = state.m_FB.m_DrawFBO.Color[db]; + } if (p != ResourceId.Null || showEmpty.Checked) { @@ -1427,6 +1432,21 @@ namespace renderdocui.Windows.PipelineState if (texs[t].format.srgbCorrected && !state.m_FB.FramebufferSRGB) name += " (GL_FRAMEBUFFER_SRGB = 0)"; + + if (r != null) + { + if (r.Swizzle[0] != TextureSwizzle.Red || + r.Swizzle[1] != TextureSwizzle.Green || + r.Swizzle[2] != TextureSwizzle.Blue || + r.Swizzle[3] != TextureSwizzle.Alpha) + { + format += String.Format(" swizzle[{0}{1}{2}{3}]", + r.Swizzle[0].Str(), + r.Swizzle[1].Str(), + r.Swizzle[2].Str(), + r.Swizzle[3].Str()); + } + } } }