mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-24 22:55:41 +00:00
Set up display of blend equations (and logic, overriding)
This commit is contained in:
@@ -126,8 +126,36 @@ struct GLPipelineState
|
||||
|
||||
ResourceId FBO;
|
||||
|
||||
bool32 FramebufferSRGB;
|
||||
|
||||
rdctype::array<ResourceId> Color;
|
||||
ResourceId Depth;
|
||||
ResourceId Stencil;
|
||||
|
||||
struct BlendState
|
||||
{
|
||||
BlendState()
|
||||
{ BlendFactor[0] = BlendFactor[1] = BlendFactor[2] = BlendFactor[3] = 0.0f; }
|
||||
|
||||
struct RTBlend
|
||||
{
|
||||
RTBlend() : Enabled(false), WriteMask(0) {}
|
||||
struct BlendOp
|
||||
{
|
||||
rdctype::str Source;
|
||||
rdctype::str Destination;
|
||||
rdctype::str Operation;
|
||||
} m_Blend, m_AlphaBlend;
|
||||
|
||||
rdctype::str LogicOp;
|
||||
|
||||
bool32 Enabled;
|
||||
byte WriteMask;
|
||||
};
|
||||
rdctype::array<RTBlend> Blends;
|
||||
|
||||
float BlendFactor[4];
|
||||
} m_Blending;
|
||||
|
||||
} m_FB;
|
||||
};
|
||||
@@ -448,6 +448,45 @@ GLuint GetBoundVertexBuffer(const GLHookSet &gl, GLuint i)
|
||||
return buffer;
|
||||
}
|
||||
|
||||
const char *BlendString(GLenum blendenum)
|
||||
{
|
||||
switch(blendenum)
|
||||
{
|
||||
case GL_FUNC_ADD: return "ADD";
|
||||
case GL_FUNC_SUBTRACT: return "SUBTRACT";
|
||||
case GL_FUNC_REVERSE_SUBTRACT: return "INV_SUBTRACT";
|
||||
case GL_MIN: return "MIN";
|
||||
case GL_MAX: return "MAX";
|
||||
case GL_ZERO: return "ZERO";
|
||||
case GL_ONE: return "ONE";
|
||||
case GL_SRC_COLOR: return "SRC_COLOR";
|
||||
case GL_ONE_MINUS_SRC_COLOR: return "INV_SRC_COLOR";
|
||||
case GL_DST_COLOR: return "DST_COLOR";
|
||||
case GL_ONE_MINUS_DST_COLOR: return "INV_DST_COLOR";
|
||||
case GL_SRC_ALPHA: return "SRC_ALPHA";
|
||||
case GL_ONE_MINUS_SRC_ALPHA: return "INV_SRC_ALPHA";
|
||||
case GL_DST_ALPHA: return "DST_ALPHA";
|
||||
case GL_ONE_MINUS_DST_ALPHA: return "INV_DST_ALPHA";
|
||||
case GL_CONSTANT_COLOR: return "CONST_COLOR";
|
||||
case GL_ONE_MINUS_CONSTANT_COLOR: return "INV_CONST_COLOR";
|
||||
case GL_CONSTANT_ALPHA: return "CONST_ALPHA";
|
||||
case GL_ONE_MINUS_CONSTANT_ALPHA: return "INV_CONST_ALPHA";
|
||||
case GL_SRC_ALPHA_SATURATE: return "SRC_ALPHA_SAT";
|
||||
case GL_SRC1_COLOR: return "SRC1_COL";
|
||||
case GL_ONE_MINUS_SRC1_COLOR: return "INV_SRC1_COL";
|
||||
case GL_SRC1_ALPHA: return "SRC1_ALPHA";
|
||||
case GL_ONE_MINUS_SRC1_ALPHA: return "INV_SRC1_ALPHA";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
static string unknown = ToStr::Get(blendenum).substr(3); // 3 = strlen("GL_");
|
||||
|
||||
RDCERR("Unknown blend enum: %s", unknown.c_str());
|
||||
|
||||
return unknown.c_str();
|
||||
}
|
||||
|
||||
ResourceFormat MakeResourceFormat(WrappedOpenGL &gl, GLenum target, GLenum fmt)
|
||||
{
|
||||
ResourceFormat ret;
|
||||
|
||||
@@ -87,6 +87,7 @@ GLenum ShaderEnum(size_t idx);
|
||||
ResourceFormat MakeResourceFormat(WrappedOpenGL &gl, GLenum target, GLenum fmt);
|
||||
GLenum MakeGLFormat(WrappedOpenGL &gl, GLenum target, ResourceFormat fmt);
|
||||
PrimitiveTopology MakePrimitiveTopology(const GLHookSet &gl, GLenum Topo);
|
||||
const char *BlendString(GLenum blendenum);
|
||||
|
||||
GLuint GetBoundVertexBuffer(const GLHookSet &gl, GLuint idx);
|
||||
|
||||
|
||||
@@ -1359,6 +1359,34 @@ void GLReplay::SavePipelineState()
|
||||
|
||||
pipe.m_FB.Depth = rm->GetOriginalID(rm->GetID(rbDepth ? RenderbufferRes(ctx, curDepth) : TextureRes(ctx, curDepth)));
|
||||
pipe.m_FB.Stencil = rm->GetOriginalID(rm->GetID(rbStencil ? RenderbufferRes(ctx, curStencil) : TextureRes(ctx, curStencil)));
|
||||
|
||||
memcpy(pipe.m_FB.m_Blending.BlendFactor, rs.BlendColor, sizeof(rs.BlendColor));
|
||||
|
||||
pipe.m_FB.FramebufferSRGB = rs.Enabled[GLRenderState::eEnabled_FramebufferSRGB];
|
||||
|
||||
RDCCOMPILE_ASSERT(ARRAY_COUNT(rs.Blends) == ARRAY_COUNT(rs.ColorMasks), "Color masks and blends mismatched");
|
||||
create_array_uninit(pipe.m_FB.m_Blending.Blends, ARRAY_COUNT(rs.Blends));
|
||||
for(size_t i=0; i < ARRAY_COUNT(rs.Blends); i++)
|
||||
{
|
||||
pipe.m_FB.m_Blending.Blends[i].Enabled = rs.Blends[i].Enabled;
|
||||
pipe.m_FB.m_Blending.Blends[i].LogicOp = "";
|
||||
if(rs.LogicOp != eGL_NONE && rs.LogicOp != eGL_COPY && rs.Enabled[GLRenderState::eEnabled_ColorLogicOp])
|
||||
pipe.m_FB.m_Blending.Blends[i].LogicOp = ToStr::Get(rs.LogicOp).substr(3); // 3 == strlen("GL_")
|
||||
|
||||
pipe.m_FB.m_Blending.Blends[i].m_Blend.Source = BlendString(rs.Blends[i].SourceRGB);
|
||||
pipe.m_FB.m_Blending.Blends[i].m_Blend.Destination = BlendString(rs.Blends[i].DestinationRGB);
|
||||
pipe.m_FB.m_Blending.Blends[i].m_Blend.Operation = BlendString(rs.Blends[i].EquationRGB);
|
||||
|
||||
pipe.m_FB.m_Blending.Blends[i].m_AlphaBlend.Source = BlendString(rs.Blends[i].SourceAlpha);
|
||||
pipe.m_FB.m_Blending.Blends[i].m_AlphaBlend.Destination = BlendString(rs.Blends[i].DestinationAlpha);
|
||||
pipe.m_FB.m_Blending.Blends[i].m_AlphaBlend.Operation = BlendString(rs.Blends[i].EquationAlpha);
|
||||
|
||||
pipe.m_FB.m_Blending.Blends[i].WriteMask = 0;
|
||||
if(rs.ColorMasks[i].red) pipe.m_FB.m_Blending.Blends[i].WriteMask |= 1;
|
||||
if(rs.ColorMasks[i].green) pipe.m_FB.m_Blending.Blends[i].WriteMask |= 2;
|
||||
if(rs.ColorMasks[i].blue) pipe.m_FB.m_Blending.Blends[i].WriteMask |= 4;
|
||||
if(rs.ColorMasks[i].alpha) pipe.m_FB.m_Blending.Blends[i].WriteMask |= 8;
|
||||
}
|
||||
}
|
||||
|
||||
void GLReplay::FillCBufferValue(WrappedOpenGL &gl, GLuint prog, bool bufferBacked, bool rowMajor,
|
||||
|
||||
Reference in New Issue
Block a user