Commit c916fe8a by Jamie Madill Committed by Commit Bot

Don't call syncState inside FBO queries.

This prevents a syncState ordering issue that was confusing FBO sync when robust resource init is enabled. Also cleans up some redundant format processing for the half float extensions. Bug: angleproject:4517 Change-Id: Ieb13fc5203cf824a3e8affda96ea5cbbd89d78ee Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2134411Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent a30c6f35
......@@ -1607,19 +1607,16 @@ angle::Result Framebuffer::clearBufferfi(const Context *context,
return angle::Result::Continue;
}
angle::Result Framebuffer::getImplementationColorReadFormat(const Context *context,
GLenum *formatOut)
GLenum Framebuffer::getImplementationColorReadFormat(const Context *context)
{
ANGLE_TRY(syncState(context));
*formatOut = mImpl->getImplementationColorReadFormat(context);
return angle::Result::Continue;
const gl::InternalFormat &format = mImpl->getImplementationColorReadFormat(context);
return format.getReadPixelsFormat(context->getExtensions());
}
angle::Result Framebuffer::getImplementationColorReadType(const Context *context, GLenum *typeOut)
GLenum Framebuffer::getImplementationColorReadType(const Context *context)
{
ANGLE_TRY(syncState(context));
*typeOut = mImpl->getImplementationColorReadType(context);
return angle::Result::Continue;
const gl::InternalFormat &format = mImpl->getImplementationColorReadFormat(context);
return format.getReadPixelsType(context->getClientVersion());
}
angle::Result Framebuffer::readPixels(const Context *context,
......
......@@ -340,9 +340,8 @@ class Framebuffer final : public angle::ObserverInterface,
GLfloat depth,
GLint stencil);
// These two methods call syncState() internally.
angle::Result getImplementationColorReadFormat(const Context *context, GLenum *formatOut);
angle::Result getImplementationColorReadType(const Context *context, GLenum *typeOut);
GLenum getImplementationColorReadFormat(const Context *context);
GLenum getImplementationColorReadType(const Context *context);
angle::Result readPixels(const Context *context,
const Rectangle &area,
......
......@@ -2432,12 +2432,10 @@ angle::Result State::getIntegerv(const Context *context, GLenum pname, GLint *pa
*params = mStencilClearValue;
break;
case GL_IMPLEMENTATION_COLOR_READ_TYPE:
ANGLE_TRY(mReadFramebuffer->getImplementationColorReadType(
context, reinterpret_cast<GLenum *>(params)));
*params = mReadFramebuffer->getImplementationColorReadType(context);
break;
case GL_IMPLEMENTATION_COLOR_READ_FORMAT:
ANGLE_TRY(mReadFramebuffer->getImplementationColorReadFormat(
context, reinterpret_cast<GLenum *>(params)));
*params = mReadFramebuffer->getImplementationColorReadFormat(context);
break;
case GL_SAMPLE_BUFFERS:
case GL_SAMPLES:
......
......@@ -63,13 +63,13 @@ class FramebufferImpl : angle::NonCopyable
GLfloat depth,
GLint stencil) = 0;
virtual GLenum getImplementationColorReadFormat(const gl::Context *context) const = 0;
virtual GLenum getImplementationColorReadType(const gl::Context *context) const = 0;
virtual const gl::InternalFormat &getImplementationColorReadFormat(
const gl::Context *context) const;
virtual angle::Result readPixels(const gl::Context *context,
const gl::Rectangle &area,
GLenum format,
GLenum type,
void *pixels) = 0;
void *pixels) = 0;
virtual angle::Result blit(const gl::Context *context,
const gl::Rectangle &sourceArea,
......@@ -103,6 +103,13 @@ inline bool FramebufferImpl::shouldSyncStateBeforeCheckStatus() const
return false;
}
// Default implementation returns the format specified in the attachment.
inline const gl::InternalFormat &FramebufferImpl::getImplementationColorReadFormat(
const gl::Context *context) const
{
const gl::FramebufferAttachment *readAttachment = mState.getReadAttachment();
return *readAttachment->getFormat().info;
}
} // namespace rx
#endif // LIBANGLE_RENDERER_FRAMEBUFFERIMPL_H_
......@@ -34,8 +34,6 @@ class MockFramebufferImpl : public rx::FramebufferImpl
MOCK_METHOD4(clearBufferiv, angle::Result(const gl::Context *, GLenum, GLint, const GLint *));
MOCK_METHOD5(clearBufferfi, angle::Result(const gl::Context *, GLenum, GLint, GLfloat, GLint));
MOCK_CONST_METHOD1(getImplementationColorReadFormat, GLenum(const gl::Context *));
MOCK_CONST_METHOD1(getImplementationColorReadType, GLenum(const gl::Context *));
MOCK_METHOD5(readPixels,
angle::Result(const gl::Context *, const gl::Rectangle &, GLenum, GLenum, void *));
......
......@@ -184,54 +184,6 @@ angle::Result FramebufferD3D::clearBufferfi(const gl::Context *context,
return clearImpl(context, clearParams);
}
GLenum FramebufferD3D::getImplementationColorReadFormat(const gl::Context *context) const
{
const gl::FramebufferAttachment *readAttachment = mState.getReadAttachment();
if (readAttachment == nullptr)
{
return GL_NONE;
}
RenderTargetD3D *attachmentRenderTarget = nullptr;
angle::Result error = readAttachment->getRenderTarget(
context, readAttachment->getRenderToTextureSamples(), &attachmentRenderTarget);
if (error != angle::Result::Continue)
{
return GL_NONE;
}
GLenum implementationFormat = getRenderTargetImplementationFormat(attachmentRenderTarget);
const gl::InternalFormat &implementationFormatInfo =
gl::GetSizedInternalFormatInfo(implementationFormat);
return implementationFormatInfo.getReadPixelsFormat(context->getExtensions());
}
GLenum FramebufferD3D::getImplementationColorReadType(const gl::Context *context) const
{
const gl::FramebufferAttachment *readAttachment = mState.getReadAttachment();
if (readAttachment == nullptr)
{
return GL_NONE;
}
RenderTargetD3D *attachmentRenderTarget = nullptr;
angle::Result error = readAttachment->getRenderTarget(
context, readAttachment->getRenderToTextureSamples(), &attachmentRenderTarget);
if (error != angle::Result::Continue)
{
return GL_NONE;
}
GLenum implementationFormat = getRenderTargetImplementationFormat(attachmentRenderTarget);
const gl::InternalFormat &implementationFormatInfo =
gl::GetSizedInternalFormatInfo(implementationFormat);
return implementationFormatInfo.getReadPixelsType(context->getClientVersion());
}
angle::Result FramebufferD3D::readPixels(const gl::Context *context,
const gl::Rectangle &area,
GLenum format,
......
......@@ -81,8 +81,6 @@ class FramebufferD3D : public FramebufferImpl
GLfloat depth,
GLint stencil) override;
GLenum getImplementationColorReadFormat(const gl::Context *context) const override;
GLenum getImplementationColorReadType(const gl::Context *context) const override;
angle::Result readPixels(const gl::Context *context,
const gl::Rectangle &area,
GLenum format,
......@@ -131,8 +129,6 @@ class FramebufferD3D : public FramebufferImpl
GLenum filter,
const gl::Framebuffer *sourceFramebuffer) = 0;
virtual GLenum getRenderTargetImplementationFormat(RenderTargetD3D *renderTarget) const = 0;
RendererD3D *mRenderer;
Optional<gl::AttachmentList> mColorAttachmentsForRender;
gl::DrawBufferMask mCurrentActiveProgramOutputs;
......
......@@ -17,6 +17,7 @@
#include "libANGLE/renderer/d3d/TextureD3D.h"
#include "libANGLE/renderer/d3d/d3d11/Buffer11.h"
#include "libANGLE/renderer/d3d/d3d11/Clear11.h"
#include "libANGLE/renderer/d3d/d3d11/Context11.h"
#include "libANGLE/renderer/d3d/d3d11/RenderTarget11.h"
#include "libANGLE/renderer/d3d/d3d11/Renderer11.h"
#include "libANGLE/renderer/d3d/d3d11/TextureStorage11.h"
......@@ -374,10 +375,14 @@ angle::Result Framebuffer11::blitImpl(const gl::Context *context,
return angle::Result::Continue;
}
GLenum Framebuffer11::getRenderTargetImplementationFormat(RenderTargetD3D *renderTarget) const
const gl::InternalFormat &Framebuffer11::getImplementationColorReadFormat(
const gl::Context *context) const
{
RenderTarget11 *renderTarget11 = GetAs<RenderTarget11>(renderTarget);
return renderTarget11->getFormatSet().format().fboImplementationInternalFormat;
Context11 *context11 = GetImplAs<Context11>(context);
const Renderer11DeviceCaps &caps = context11->getRenderer()->getRenderer11DeviceCaps();
GLenum sizedFormat = mState.getReadAttachment()->getFormat().info->sizedInternalFormat;
const angle::Format &angleFormat = d3d11::Format::Get(sizedFormat, caps).format();
return gl::GetSizedInternalFormatInfo(angleFormat.fboImplementationInternalFormat);
}
angle::Result Framebuffer11::syncState(const gl::Context *context,
......
......@@ -56,6 +56,9 @@ class Framebuffer11 : public FramebufferD3D
size_t index,
GLfloat *xy) const override;
const gl::InternalFormat &getImplementationColorReadFormat(
const gl::Context *context) const override;
private:
angle::Result clearImpl(const gl::Context *context,
const ClearParameters &clearParams) override;
......@@ -85,8 +88,6 @@ class Framebuffer11 : public FramebufferD3D
angle::Result invalidateAttachment(const gl::Context *context,
const gl::FramebufferAttachment *attachment) const;
GLenum getRenderTargetImplementationFormat(RenderTargetD3D *renderTarget) const override;
Renderer11 *const mRenderer;
RenderTargetCache<RenderTarget11> mRenderTargetCache;
};
......
......@@ -385,11 +385,14 @@ angle::Result Framebuffer9::blitImpl(const gl::Context *context,
return angle::Result::Continue;
}
GLenum Framebuffer9::getRenderTargetImplementationFormat(RenderTargetD3D *renderTarget) const
const gl::InternalFormat &Framebuffer9::getImplementationColorReadFormat(
const gl::Context *context) const
{
RenderTarget9 *renderTarget9 = GetAs<RenderTarget9>(renderTarget);
const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(renderTarget9->getD3DFormat());
return d3dFormatInfo.info().glInternalFormat;
GLenum sizedFormat = mState.getReadAttachment()->getFormat().info->sizedInternalFormat;
const d3d9::TextureFormat &textureFormat = d3d9::GetTextureFormatInfo(sizedFormat);
const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(textureFormat.renderFormat);
const angle::Format &angleFormat = angle::Format::Get(d3dFormatInfo.formatID);
return gl::GetSizedInternalFormatInfo(angleFormat.fboImplementationInternalFormat);
}
angle::Result Framebuffer9::getSamplePosition(const gl::Context *context,
......
......@@ -51,6 +51,9 @@ class Framebuffer9 : public FramebufferD3D
return mRenderTargetCache.getDepthStencil(true);
}
const gl::InternalFormat &getImplementationColorReadFormat(
const gl::Context *context) const override;
private:
angle::Result clearImpl(const gl::Context *context,
const ClearParameters &clearParams) override;
......@@ -73,8 +76,6 @@ class Framebuffer9 : public FramebufferD3D
GLenum filter,
const gl::Framebuffer *sourceFramebuffer) override;
GLenum getRenderTargetImplementationFormat(RenderTargetD3D *renderTarget) const override;
Renderer9 *const mRenderer;
RenderTargetCache<RenderTarget9> mRenderTargetCache;
......
......@@ -276,10 +276,8 @@ angle::Result BlitGL::copyImageToLUMAWorkaroundTexture(const gl::Context *contex
mStateManager->bindTexture(textureType, texture);
// Allocate the texture memory
GLenum format = gl::GetUnsizedFormat(internalFormat);
GLenum readType = GL_NONE;
ANGLE_TRY(source->getImplementationColorReadType(context, &readType));
GLenum format = gl::GetUnsizedFormat(internalFormat);
GLenum readType = source->getImplementationColorReadType(context);
gl::PixelUnpackState unpack;
mStateManager->setPixelUnpackState(unpack);
......@@ -313,11 +311,8 @@ angle::Result BlitGL::copySubImageToLUMAWorkaroundTexture(const gl::Context *con
const FramebufferGL *sourceFramebufferGL = GetImplAs<FramebufferGL>(source);
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, sourceFramebufferGL->getFramebufferID());
GLenum readFormat = GL_NONE;
ANGLE_TRY(source->getImplementationColorReadFormat(context, &readFormat));
GLenum readType = GL_NONE;
ANGLE_TRY(source->getImplementationColorReadType(context, &readType));
GLenum readFormat = source->getImplementationColorReadFormat(context);
GLenum readType = source->getImplementationColorReadType(context);
nativegl::CopyTexImageImageFormat copyTexImageFormat =
nativegl::GetCopyTexImageImageFormat(mFunctions, mFeatures, readFormat, readType);
......
......@@ -607,20 +607,6 @@ angle::Result FramebufferGL::clearBufferfi(const gl::Context *context,
return angle::Result::Continue;
}
GLenum FramebufferGL::getImplementationColorReadFormat(const gl::Context *context) const
{
const auto *readAttachment = mState.getReadAttachment();
const Format &format = readAttachment->getFormat();
return format.info->getReadPixelsFormat(context->getExtensions());
}
GLenum FramebufferGL::getImplementationColorReadType(const gl::Context *context) const
{
const auto *readAttachment = mState.getReadAttachment();
const Format &format = readAttachment->getFormat();
return format.info->getReadPixelsType(context->getClientVersion());
}
angle::Result FramebufferGL::readPixels(const gl::Context *context,
const gl::Rectangle &area,
GLenum format,
......
......@@ -58,9 +58,6 @@ class FramebufferGL : public FramebufferImpl
GLfloat depth,
GLint stencil) override;
GLenum getImplementationColorReadFormat(const gl::Context *context) const override;
GLenum getImplementationColorReadType(const gl::Context *context) const override;
angle::Result readPixels(const gl::Context *context,
const gl::Rectangle &area,
GLenum format,
......
......@@ -617,8 +617,7 @@ angle::Result TextureGL::copyImage(const gl::Context *context,
gl::TextureTarget target = index.getTarget();
size_t level = static_cast<size_t>(index.getLevelIndex());
GLenum type = GL_NONE;
ANGLE_TRY(source->getImplementationColorReadType(context, &type));
GLenum type = source->getImplementationColorReadType(context);
nativegl::CopyTexImageImageFormat copyTexImageFormat =
nativegl::GetCopyTexImageImageFormat(functions, features, internalFormat, type);
......
......@@ -58,8 +58,8 @@ class FramebufferMtl : public FramebufferImpl
GLfloat depth,
GLint stencil) override;
GLenum getImplementationColorReadFormat(const gl::Context *context) const override;
GLenum getImplementationColorReadType(const gl::Context *context) const override;
const gl::InternalFormat &getImplementationColorReadFormat(
const gl::Context *context) const override;
angle::Result readPixels(const gl::Context *context,
const gl::Rectangle &area,
GLenum format,
......
......@@ -22,28 +22,6 @@
namespace rx
{
namespace
{
const gl::InternalFormat &GetReadAttachmentInfo(const gl::Context *context,
RenderTargetMtl *renderTarget)
{
GLenum implFormat;
if (renderTarget && renderTarget->getFormat())
{
implFormat = renderTarget->getFormat()->actualAngleFormat().fboImplementationInternalFormat;
}
else
{
implFormat = GL_NONE;
}
return gl::GetSizedInternalFormatInfo(implFormat);
}
}
// FramebufferMtl implementation
FramebufferMtl::FramebufferMtl(const gl::FramebufferState &state, bool flipY)
: FramebufferImpl(state), mFlipY(flipY)
......@@ -157,14 +135,15 @@ angle::Result FramebufferMtl::clearBufferfi(const gl::Context *context,
return angle::Result::Stop;
}
GLenum FramebufferMtl::getImplementationColorReadFormat(const gl::Context *context) const
const gl::InternalFormat &FramebufferMtl::getImplementationColorReadFormat(
const gl::Context *context) const
{
return GetReadAttachmentInfo(context, getColorReadRenderTarget()).format;
}
GLenum FramebufferMtl::getImplementationColorReadType(const gl::Context *context) const
{
return GetReadAttachmentInfo(context, getColorReadRenderTarget()).type;
ContextMtl *contextMtl = mtl::GetImpl(context);
GLenum sizedFormat = mState.getReadAttachment()->getFormat().info->sizedInternalFormat;
angle::FormatID formatID = angle::Format::InternalFormatToID(sizedFormat);
const mtl::Format &mtlFormat = contextMtl->getDisplay()->getPixelFormat(formatID);
GLenum implFormat = mtlFormat.actualAngleFormat().fboImplementationInternalFormat;
return gl::GetSizedInternalFormatInfo(implFormat);
}
angle::Result FramebufferMtl::readPixels(const gl::Context *context,
......
......@@ -82,32 +82,6 @@ angle::Result FramebufferNULL::clearBufferfi(const gl::Context *context,
return angle::Result::Continue;
}
GLenum FramebufferNULL::getImplementationColorReadFormat(const gl::Context *context) const
{
const gl::FramebufferAttachment *readAttachment = mState.getReadAttachment();
if (readAttachment == nullptr)
{
return GL_NONE;
}
const gl::Format &format = readAttachment->getFormat();
ASSERT(format.info != nullptr);
return format.info->getReadPixelsFormat(context->getExtensions());
}
GLenum FramebufferNULL::getImplementationColorReadType(const gl::Context *context) const
{
const gl::FramebufferAttachment *readAttachment = mState.getReadAttachment();
if (readAttachment == nullptr)
{
return GL_NONE;
}
const gl::Format &format = readAttachment->getFormat();
ASSERT(format.info != nullptr);
return format.info->getReadPixelsType(context->getClientVersion());
}
angle::Result FramebufferNULL::readPixels(const gl::Context *context,
const gl::Rectangle &origArea,
GLenum format,
......
......@@ -51,8 +51,6 @@ class FramebufferNULL : public FramebufferImpl
GLfloat depth,
GLint stencil) override;
GLenum getImplementationColorReadFormat(const gl::Context *context) const override;
GLenum getImplementationColorReadType(const gl::Context *context) const override;
angle::Result readPixels(const gl::Context *context,
const gl::Rectangle &area,
GLenum format,
......
......@@ -43,14 +43,6 @@ constexpr size_t kReadPixelsBufferAlignment = 32 * 3;
// in case of a bug.
constexpr VkClearValue kUninitializedClearValue = {{{0.95, 0.05, 0.95, 0.95}}};
const gl::InternalFormat &GetReadAttachmentInfo(const gl::Context *context,
RenderTargetVk *renderTarget)
{
GLenum implFormat =
renderTarget->getImageFormat().actualImageFormat().fboImplementationInternalFormat;
return gl::GetSizedInternalFormatInfo(implFormat);
}
bool HasSrcBlitFeature(RendererVk *renderer, RenderTargetVk *srcRenderTarget)
{
const VkFormat srcFormat = srcRenderTarget->getImageFormat().vkImageFormat;
......@@ -420,21 +412,14 @@ angle::Result FramebufferVk::clearBufferfi(const gl::Context *context,
clearValue.depthStencil);
}
GLenum FramebufferVk::getImplementationColorReadFormat(const gl::Context *context) const
{
return GetReadAttachmentInfo(context, mRenderTargetCache.getColorRead(mState)).format;
}
GLenum FramebufferVk::getImplementationColorReadType(const gl::Context *context) const
const gl::InternalFormat &FramebufferVk::getImplementationColorReadFormat(
const gl::Context *context) const
{
GLenum readType = GetReadAttachmentInfo(context, mRenderTargetCache.getColorRead(mState)).type;
if (context->getClientMajorVersion() < 3 && readType == GL_HALF_FLOAT)
{
// GL_HALF_FLOAT was not introduced until GLES 3.0, and has a different value from
// GL_HALF_FLOAT_OES
readType = GL_HALF_FLOAT_OES;
}
return readType;
ContextVk *contextVk = vk::GetImpl(context);
GLenum sizedFormat = mState.getReadAttachment()->getFormat().info->sizedInternalFormat;
const vk::Format &vkFormat = contextVk->getRenderer()->getFormat(sizedFormat);
GLenum implFormat = vkFormat.actualImageFormat().fboImplementationInternalFormat;
return gl::GetSizedInternalFormatInfo(implFormat);
}
angle::Result FramebufferVk::readPixels(const gl::Context *context,
......
......@@ -69,8 +69,8 @@ class FramebufferVk : public FramebufferImpl
GLfloat depth,
GLint stencil) override;
GLenum getImplementationColorReadFormat(const gl::Context *context) const override;
GLenum getImplementationColorReadType(const gl::Context *context) const override;
const gl::InternalFormat &getImplementationColorReadFormat(
const gl::Context *context) const override;
angle::Result readPixels(const gl::Context *context,
const gl::Rectangle &area,
GLenum format,
......
......@@ -117,7 +117,6 @@ class RendererVk : angle::NonCopyable
const vk::MemoryProperties &getMemoryProperties() const { return mMemoryProperties; }
// TODO(jmadill): We could pass angle::FormatID here.
const vk::Format &getFormat(GLenum internalFormat) const
{
return mFormatTable[internalFormat];
......
......@@ -5733,10 +5733,8 @@ bool ValidateReadPixelsBase(const Context *context,
// Only rely on ValidReadPixelsFormatType for depth/stencil formats
break;
default:
ANGLE_VALIDATION_TRY(
readFramebuffer->getImplementationColorReadFormat(context, &currentFormat));
ANGLE_VALIDATION_TRY(
readFramebuffer->getImplementationColorReadType(context, &currentType));
currentFormat = readFramebuffer->getImplementationColorReadFormat(context);
currentType = readFramebuffer->getImplementationColorReadType(context);
break;
}
......
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