Commit 51d02ca0 by Lubosz Sarnecki Committed by Commit Bot

FrameCapture: Use gl*Separate functions only when required.

Use non-separate stencil and blend functions that do not distinguish between front and back buffers or color and alpha, if they apply. This prevents capturing GLES2 functions on GLES1 contexts. Bug: angleproject:5893 Change-Id: I8303ee5b279268ea9c21e2c6465e1b155d1cc54d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2877238Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com> Commit-Queue: Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
parent 57bc7ce1
...@@ -3300,50 +3300,97 @@ void CaptureMidExecutionSetup(const gl::Context *context, ...@@ -3300,50 +3300,97 @@ void CaptureMidExecutionSetup(const gl::Context *context,
capCap(GL_STENCIL_TEST, currentDSState.stencilTest); capCap(GL_STENCIL_TEST, currentDSState.stencilTest);
} }
if (defaultDSState.stencilFunc != currentDSState.stencilFunc || if (currentDSState.stencilFunc == currentDSState.stencilBackFunc &&
defaultDSState.stencilMask != currentDSState.stencilMask || apiState.getStencilRef() != 0) currentDSState.stencilMask == currentDSState.stencilBackMask)
{ {
cap(CaptureStencilFuncSeparate(replayState, true, GL_FRONT, currentDSState.stencilFunc, // Front and back are equal
apiState.getStencilRef(), currentDSState.stencilMask)); if (defaultDSState.stencilFunc != currentDSState.stencilFunc ||
defaultDSState.stencilMask != currentDSState.stencilMask ||
apiState.getStencilRef() != 0)
{
cap(CaptureStencilFunc(replayState, true, currentDSState.stencilFunc,
apiState.getStencilRef(), currentDSState.stencilMask));
}
} }
else
if (defaultDSState.stencilBackFunc != currentDSState.stencilBackFunc ||
defaultDSState.stencilBackMask != currentDSState.stencilBackMask ||
apiState.getStencilBackRef() != 0)
{ {
cap(CaptureStencilFuncSeparate(replayState, true, GL_BACK, currentDSState.stencilBackFunc, // Front and back are separate
apiState.getStencilBackRef(), if (defaultDSState.stencilFunc != currentDSState.stencilFunc ||
currentDSState.stencilBackMask)); defaultDSState.stencilMask != currentDSState.stencilMask ||
apiState.getStencilRef() != 0)
{
cap(CaptureStencilFuncSeparate(replayState, true, GL_FRONT, currentDSState.stencilFunc,
apiState.getStencilRef(), currentDSState.stencilMask));
}
if (defaultDSState.stencilBackFunc != currentDSState.stencilBackFunc ||
defaultDSState.stencilBackMask != currentDSState.stencilBackMask ||
apiState.getStencilBackRef() != 0)
{
cap(CaptureStencilFuncSeparate(
replayState, true, GL_BACK, currentDSState.stencilBackFunc,
apiState.getStencilBackRef(), currentDSState.stencilBackMask));
}
} }
if (defaultDSState.stencilFail != currentDSState.stencilFail || if (currentDSState.stencilFail == currentDSState.stencilBackFail &&
defaultDSState.stencilPassDepthFail != currentDSState.stencilPassDepthFail || currentDSState.stencilPassDepthFail == currentDSState.stencilBackPassDepthFail &&
defaultDSState.stencilPassDepthPass != currentDSState.stencilPassDepthPass) currentDSState.stencilPassDepthPass == currentDSState.stencilBackPassDepthPass)
{ {
cap(CaptureStencilOpSeparate(replayState, true, GL_FRONT, currentDSState.stencilFail, // Front and back are equal
currentDSState.stencilPassDepthFail, if (defaultDSState.stencilFail != currentDSState.stencilFail ||
currentDSState.stencilPassDepthPass)); defaultDSState.stencilPassDepthFail != currentDSState.stencilPassDepthFail ||
defaultDSState.stencilPassDepthPass != currentDSState.stencilPassDepthPass)
{
cap(CaptureStencilOp(replayState, true, currentDSState.stencilFail,
currentDSState.stencilPassDepthFail,
currentDSState.stencilPassDepthPass));
}
} }
else
if (defaultDSState.stencilBackFail != currentDSState.stencilBackFail ||
defaultDSState.stencilBackPassDepthFail != currentDSState.stencilBackPassDepthFail ||
defaultDSState.stencilBackPassDepthPass != currentDSState.stencilBackPassDepthPass)
{ {
cap(CaptureStencilOpSeparate(replayState, true, GL_BACK, currentDSState.stencilBackFail, // Front and back are separate
currentDSState.stencilBackPassDepthFail, if (defaultDSState.stencilFail != currentDSState.stencilFail ||
currentDSState.stencilBackPassDepthPass)); defaultDSState.stencilPassDepthFail != currentDSState.stencilPassDepthFail ||
defaultDSState.stencilPassDepthPass != currentDSState.stencilPassDepthPass)
{
cap(CaptureStencilOpSeparate(replayState, true, GL_FRONT, currentDSState.stencilFail,
currentDSState.stencilPassDepthFail,
currentDSState.stencilPassDepthPass));
}
if (defaultDSState.stencilBackFail != currentDSState.stencilBackFail ||
defaultDSState.stencilBackPassDepthFail != currentDSState.stencilBackPassDepthFail ||
defaultDSState.stencilBackPassDepthPass != currentDSState.stencilBackPassDepthPass)
{
cap(CaptureStencilOpSeparate(replayState, true, GL_BACK, currentDSState.stencilBackFail,
currentDSState.stencilBackPassDepthFail,
currentDSState.stencilBackPassDepthPass));
}
} }
if (defaultDSState.stencilWritemask != currentDSState.stencilWritemask) if (currentDSState.stencilWritemask == currentDSState.stencilBackWritemask)
{ {
cap(CaptureStencilMaskSeparate(replayState, true, GL_FRONT, // Front and back are equal
currentDSState.stencilWritemask)); if (defaultDSState.stencilWritemask != currentDSState.stencilWritemask)
{
cap(CaptureStencilMask(replayState, true, currentDSState.stencilWritemask));
}
} }
else
if (defaultDSState.stencilBackWritemask != currentDSState.stencilBackWritemask)
{ {
cap(CaptureStencilMaskSeparate(replayState, true, GL_BACK, // Front and back are separate
currentDSState.stencilBackWritemask)); if (defaultDSState.stencilWritemask != currentDSState.stencilWritemask)
{
cap(CaptureStencilMaskSeparate(replayState, true, GL_FRONT,
currentDSState.stencilWritemask));
}
if (defaultDSState.stencilBackWritemask != currentDSState.stencilBackWritemask)
{
cap(CaptureStencilMaskSeparate(replayState, true, GL_BACK,
currentDSState.stencilBackWritemask));
}
} }
// Blend state. // Blend state.
...@@ -3360,9 +3407,20 @@ void CaptureMidExecutionSetup(const gl::Context *context, ...@@ -3360,9 +3407,20 @@ void CaptureMidExecutionSetup(const gl::Context *context,
currentBlendState.sourceBlendAlpha != defaultBlendState.sourceBlendAlpha || currentBlendState.sourceBlendAlpha != defaultBlendState.sourceBlendAlpha ||
currentBlendState.destBlendAlpha != defaultBlendState.destBlendAlpha) currentBlendState.destBlendAlpha != defaultBlendState.destBlendAlpha)
{ {
cap(CaptureBlendFuncSeparate( if (currentBlendState.sourceBlendRGB == currentBlendState.sourceBlendAlpha &&
replayState, true, currentBlendState.sourceBlendRGB, currentBlendState.destBlendRGB, currentBlendState.destBlendRGB == currentBlendState.destBlendAlpha)
currentBlendState.sourceBlendAlpha, currentBlendState.destBlendAlpha)); {
// Color and alpha are equal
cap(CaptureBlendFunc(replayState, true, currentBlendState.sourceBlendRGB,
currentBlendState.destBlendRGB));
}
else
{
// Color and alpha are separate
cap(CaptureBlendFuncSeparate(
replayState, true, currentBlendState.sourceBlendRGB, currentBlendState.destBlendRGB,
currentBlendState.sourceBlendAlpha, currentBlendState.destBlendAlpha));
}
} }
if (currentBlendState.blendEquationRGB != defaultBlendState.blendEquationRGB || if (currentBlendState.blendEquationRGB != defaultBlendState.blendEquationRGB ||
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment