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