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,8 +3300,24 @@ void CaptureMidExecutionSetup(const gl::Context *context,
capCap(GL_STENCIL_TEST, currentDSState.stencilTest);
}
if (currentDSState.stencilFunc == currentDSState.stencilBackFunc &&
currentDSState.stencilMask == currentDSState.stencilBackMask)
{
// Front and back are equal
if (defaultDSState.stencilFunc != currentDSState.stencilFunc ||
defaultDSState.stencilMask != currentDSState.stencilMask || apiState.getStencilRef() != 0)
defaultDSState.stencilMask != currentDSState.stencilMask ||
apiState.getStencilRef() != 0)
{
cap(CaptureStencilFunc(replayState, true, currentDSState.stencilFunc,
apiState.getStencilRef(), currentDSState.stencilMask));
}
}
else
{
// Front and back are separate
if (defaultDSState.stencilFunc != currentDSState.stencilFunc ||
defaultDSState.stencilMask != currentDSState.stencilMask ||
apiState.getStencilRef() != 0)
{
cap(CaptureStencilFuncSeparate(replayState, true, GL_FRONT, currentDSState.stencilFunc,
apiState.getStencilRef(), currentDSState.stencilMask));
......@@ -3311,11 +3327,29 @@ void CaptureMidExecutionSetup(const gl::Context *context,
defaultDSState.stencilBackMask != currentDSState.stencilBackMask ||
apiState.getStencilBackRef() != 0)
{
cap(CaptureStencilFuncSeparate(replayState, true, GL_BACK, currentDSState.stencilBackFunc,
apiState.getStencilBackRef(),
currentDSState.stencilBackMask));
cap(CaptureStencilFuncSeparate(
replayState, true, GL_BACK, currentDSState.stencilBackFunc,
apiState.getStencilBackRef(), currentDSState.stencilBackMask));
}
}
if (currentDSState.stencilFail == currentDSState.stencilBackFail &&
currentDSState.stencilPassDepthFail == currentDSState.stencilBackPassDepthFail &&
currentDSState.stencilPassDepthPass == currentDSState.stencilBackPassDepthPass)
{
// Front and back are equal
if (defaultDSState.stencilFail != currentDSState.stencilFail ||
defaultDSState.stencilPassDepthFail != currentDSState.stencilPassDepthFail ||
defaultDSState.stencilPassDepthPass != currentDSState.stencilPassDepthPass)
{
cap(CaptureStencilOp(replayState, true, currentDSState.stencilFail,
currentDSState.stencilPassDepthFail,
currentDSState.stencilPassDepthPass));
}
}
else
{
// Front and back are separate
if (defaultDSState.stencilFail != currentDSState.stencilFail ||
defaultDSState.stencilPassDepthFail != currentDSState.stencilPassDepthFail ||
defaultDSState.stencilPassDepthPass != currentDSState.stencilPassDepthPass)
......@@ -3333,7 +3367,19 @@ void CaptureMidExecutionSetup(const gl::Context *context,
currentDSState.stencilBackPassDepthFail,
currentDSState.stencilBackPassDepthPass));
}
}
if (currentDSState.stencilWritemask == currentDSState.stencilBackWritemask)
{
// Front and back are equal
if (defaultDSState.stencilWritemask != currentDSState.stencilWritemask)
{
cap(CaptureStencilMask(replayState, true, currentDSState.stencilWritemask));
}
}
else
{
// Front and back are separate
if (defaultDSState.stencilWritemask != currentDSState.stencilWritemask)
{
cap(CaptureStencilMaskSeparate(replayState, true, GL_FRONT,
......@@ -3345,6 +3391,7 @@ void CaptureMidExecutionSetup(const gl::Context *context,
cap(CaptureStencilMaskSeparate(replayState, true, GL_BACK,
currentDSState.stencilBackWritemask));
}
}
// Blend state.
const gl::BlendState &defaultBlendState = replayState.getBlendState();
......@@ -3360,10 +3407,21 @@ void CaptureMidExecutionSetup(const gl::Context *context,
currentBlendState.sourceBlendAlpha != defaultBlendState.sourceBlendAlpha ||
currentBlendState.destBlendAlpha != defaultBlendState.destBlendAlpha)
{
if (currentBlendState.sourceBlendRGB == currentBlendState.sourceBlendAlpha &&
currentBlendState.destBlendRGB == 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 ||
currentBlendState.blendEquationAlpha != defaultBlendState.blendEquationAlpha)
......
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