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