mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-05 14:21:10 +00:00
Pass through texture swizzles on FBO attachments and display
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user