Commit 38fe6840 by Jamie Madill Committed by Commit Bot

Remove secondary Texture rendering loop check.

This check was not used. It applied only to rendering Feedback Loops. The behaviour is undefined in non-WebGL and for WebGL we have a separate validation check. Also update the feedback loop tests to ignore the current GL states. This change is based on feedback from the OpenGL ES working group. Bug: angleproject:2763 Bug: chromium:763695 Change-Id: I9882b4f9af2d43fc7b5604ff36dadcc79dfd378f Reviewed-on: https://chromium-review.googlesource.com/1228373 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org>
parent 0131ff40
......@@ -1783,8 +1783,6 @@ void Framebuffer::setAttachmentImpl(const Context *context,
}
break;
}
mAttachedTextures.reset();
}
void Framebuffer::updateAttachment(const Context *context,
......@@ -1886,12 +1884,9 @@ bool Framebuffer::formsRenderingFeedbackLoopWith(const State &state) const
}
}
// Validate depth-stencil feedback loop.
const auto &dsState = state.getDepthStencilState();
// We can skip the feedback loop checks if depth/stencil is masked out or disabled.
// Validate depth-stencil feedback loop. This is independent of Depth/Stencil state.
const FramebufferAttachment *depth = getDepthbuffer();
if (depth && depth->type() == GL_TEXTURE && dsState.depthTest && dsState.depthMask)
if (depth && depth->type() == GL_TEXTURE)
{
if (program->samplesFromTexture(state, depth->id()))
{
......@@ -1900,23 +1895,14 @@ bool Framebuffer::formsRenderingFeedbackLoopWith(const State &state) const
}
const FramebufferAttachment *stencil = getStencilbuffer();
if (dsState.stencilTest && stencil)
{
GLuint stencilSize = stencil->getStencilSize();
ASSERT(stencilSize <= 8);
GLuint maxStencilValue = (1 << stencilSize) - 1;
// We assume the front and back masks are the same for WebGL.
ASSERT((dsState.stencilBackWritemask & maxStencilValue) ==
(dsState.stencilWritemask & maxStencilValue));
if (stencil->type() == GL_TEXTURE && dsState.stencilWritemask != 0)
{
// Skip the feedback loop check if depth/stencil point to the same resource.
if (!depth || *stencil != *depth)
if (stencil && stencil->type() == GL_TEXTURE)
{
// Skip the feedback loop check if depth/stencil point to the same resource.
if (!depth || *stencil != *depth)
{
if (program->samplesFromTexture(state, stencil->id()))
{
if (program->samplesFromTexture(state, stencil->id()))
{
return true;
}
return true;
}
}
}
......@@ -2328,37 +2314,4 @@ bool Framebuffer::partialBufferClearNeedsInit(const Context *context, GLenum buf
return false;
}
}
bool Framebuffer::hasTextureAttachment(const Texture *texture) const
{
if (!mAttachedTextures.valid())
{
FramebufferTextureAttachmentVector attachedTextures;
for (const auto &colorAttachment : mState.mColorAttachments)
{
if (colorAttachment.isAttached() && colorAttachment.type() == GL_TEXTURE)
{
attachedTextures.push_back(colorAttachment.getResource());
}
}
if (mState.mDepthAttachment.isAttached() && mState.mDepthAttachment.type() == GL_TEXTURE)
{
attachedTextures.push_back(mState.mDepthAttachment.getResource());
}
if (mState.mStencilAttachment.isAttached() &&
mState.mStencilAttachment.type() == GL_TEXTURE)
{
attachedTextures.push_back(mState.mStencilAttachment.getResource());
}
mAttachedTextures = std::move(attachedTextures);
}
return std::find(mAttachedTextures.value().begin(), mAttachedTextures.value().end(), texture) !=
mAttachedTextures.value().end();
}
} // namespace gl
......@@ -348,8 +348,6 @@ class Framebuffer final : public angle::ObserverInterface,
Error ensureReadAttachmentInitialized(const Context *context, GLbitfield blitMask);
Box getDimensions() const;
bool hasTextureAttachment(const Texture *texture) const;
private:
bool detachResourceById(const Context *context, GLenum resourceType, GLuint resourceId);
bool detachMatchingAttachment(const Context *context,
......@@ -421,12 +419,6 @@ class Framebuffer final : public angle::ObserverInterface,
// The dirty bits guard is checked when we get a dependent state change message. We verify that
// we don't set a dirty bit that isn't already set, when inside the dirty bits syncState.
Optional<DirtyBits> mDirtyBitsGuard;
// A cache of attached textures for quick validation of feedback loops.
using FramebufferTextureAttachmentVector =
angle::FixedVector<const FramebufferAttachmentObject *,
IMPLEMENTATION_MAX_FRAMEBUFFER_ATTACHMENTS>;
mutable Optional<FramebufferTextureAttachmentVector> mAttachedTextures;
};
} // namespace gl
......
......@@ -2754,9 +2754,7 @@ Error State::syncProgramTextures(const Context *context)
// Mark the texture binding bit as dirty if the texture completeness changes.
// TODO(jmadill): Use specific dirty bit for completeness change.
if (texture->isSamplerComplete(context, sampler) &&
(mProgram->hasLinkedShaderStage(ShaderType::Compute) ||
!mDrawFramebuffer->hasTextureAttachment(texture)))
if (texture->isSamplerComplete(context, sampler))
{
ANGLE_TRY(texture->syncState(context));
mActiveTexturesCache[textureUnitIndex] = texture;
......@@ -2794,10 +2792,7 @@ Error State::syncProgramTextures(const Context *context)
{
continue;
}
if (!mDrawFramebuffer->hasTextureAttachment(texture))
{
ANGLE_TRY(texture->syncState(context));
}
ANGLE_TRY(texture->syncState(context));
if (texture->initState() == InitState::MayNeedInit)
{
mCachedImageTexturesInitState = InitState::MayNeedInit;
......
......@@ -10,11 +10,6 @@
#include "libANGLE/renderer/d3d/ImageD3D.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/renderer/d3d/FramebufferD3D.h"
#include "libANGLE/renderer/d3d/RenderTargetD3D.h"
namespace rx
{
......
......@@ -1902,8 +1902,7 @@ angle::Result StateManager11::syncFramebuffer(const gl::Context *context)
depthStencilRenderTarget->getTexture().get());
}
// TODO(jmadill): Use context caps?
ASSERT(maxExistingRT <= static_cast<UINT>(mRenderer->getNativeCaps().maxDrawBuffers));
ASSERT(maxExistingRT <= static_cast<UINT>(context->getCaps().maxDrawBuffers));
// Apply the render target and depth stencil
mRenderer->getDeviceContext()->OMSetRenderTargets(maxExistingRT, framebufferRTVs.data(),
......
......@@ -13,10 +13,8 @@
#include "common/debug.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/renderer/d3d/d3d9/formatutils9.h"
#include "libANGLE/renderer/d3d/d3d9/RenderTarget9.h"
#include "libANGLE/renderer/d3d/FramebufferD3D.h"
#include "libANGLE/renderer/driver_utils.h"
#include "platform/Platform.h"
#include "platform/WorkaroundsD3D.h"
......
......@@ -3255,15 +3255,17 @@ TEST_P(WebGL2CompatibilityTest, RenderingFeedbackLoopWithDepthStencil)
EXPECT_GL_ERROR(GL_INVALID_OPERATION) << "Same image as depth buffer should fail";
// The same image is used as depth buffer. But depth mask is false.
// This is now considered a feedback loop and should generate an error. http://crbug.com/763695
glDepthMask(GL_FALSE);
drawQuad(program.get(), "aPosition", 0.5f, 1.0f, true);
EXPECT_GL_NO_ERROR();
EXPECT_GL_ERROR(GL_INVALID_OPERATION) << "Depth writes disabled should still fail";
// The same image is used as depth buffer. But depth test is not enabled during rendering.
// This is now considered a feedback loop and should generate an error. http://crbug.com/763695
glDepthMask(GL_TRUE);
glDisable(GL_DEPTH_TEST);
drawQuad(program.get(), "aPosition", 0.5f, 1.0f, true);
EXPECT_GL_NO_ERROR();
EXPECT_GL_ERROR(GL_INVALID_OPERATION) << "Depth read disabled should still fail";
// Test rendering and sampling feedback loop for stencil buffer
glBindTexture(GL_TEXTURE_2D, tex2.get());
......@@ -3279,15 +3281,17 @@ TEST_P(WebGL2CompatibilityTest, RenderingFeedbackLoopWithDepthStencil)
EXPECT_GL_ERROR(GL_INVALID_OPERATION) << "Same image as stencil buffer should fail";
// The same image is used as stencil buffer. But stencil mask is zero.
// This is now considered a feedback loop and should generate an error. http://crbug.com/763695
glStencilMask(0x0);
drawQuad(program.get(), "aPosition", 0.5f, 1.0f, true);
EXPECT_GL_NO_ERROR();
EXPECT_GL_ERROR(GL_INVALID_OPERATION) << "Stencil mask zero should still fail";
// The same image is used as stencil buffer. But stencil test is not enabled during rendering.
// This is now considered a feedback loop and should generate an error. http://crbug.com/763695
glStencilMask(0xffff);
glDisable(GL_STENCIL_TEST);
drawQuad(program.get(), "aPosition", 0.5f, 1.0f, true);
EXPECT_GL_NO_ERROR();
EXPECT_GL_ERROR(GL_INVALID_OPERATION) << "Stencil test disabled should still fail";
}
// The source and the target for CopyTexSubImage3D are the same 3D texture.
......
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