Commit 7151fe54 by Jonah Ryan-Davis Committed by Commit Bot

Port adjust_src_dst_region_for_blitframebuffer workaround to ANGLE.

BlitFramebuffer has issues on some platforms with large source/dest textures. As per the WebGL2 spec, this was caught with validation for sizes over 2^32, but there is a specific issue on Linux NVIDIA where it fails on sizes over 2^16. A better workaround (from chromium), resizes the blitframebuffer call based on the framebuffer size. Bug: chromium:830046 Change-Id: Ic6196db6228d0d0ac92b12a68bbced76dcbcdf8c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1707115Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com>
parent 9ec3f51d
......@@ -323,6 +323,14 @@ struct FeaturesGL : FeatureSetBase
"Limit max 3d texture size and max array texture layers to 1024 to avoid system hang on "
"older Intel Linux",
&members, "http://crbug.com/927470"};
// BlitFramebuffer has issues on some platforms with large source/dest texture sizes. This
// workaround adjusts the destination rectangle source and dest rectangle to fit within maximum
// twice the size of the framebuffer.
Feature adjustSrcDstRegionBlitFramebuffer = {
"adjust_src_dst_region_for_blitframebuffer", FeatureCategory::OpenGLWorkarounds,
"Many platforms have issues with blitFramebuffer when the parameters are large.", &members,
"http://crbug.com/830046"};
};
inline FeaturesGL::FeaturesGL() = default;
......
......@@ -89,6 +89,14 @@ class CheckedNumeric
// IsValid() is the public API to test if a CheckedNumeric is currently valid.
bool IsValid() const { return validity() == RANGE_VALID; }
// AssignIfValid(Dst) - Assigns the underlying value if it is currently valid and is within the
// range supported by the destination type. Returns true if successful and false otherwise.
template <typename Dst>
constexpr bool AssignIfValid(Dst *result) const
{
return IsValid() ? ((*result = static_cast<Dst>(state_.value())), true) : false;
}
// ValueOrDie() The primary accessor for the underlying value. If the current
// state is not valid it will CHECK and crash.
T ValueOrDie() const
......
......@@ -602,10 +602,15 @@ int FramebufferState::getBaseViewIndex() const
Box FramebufferState::getDimensions() const
{
Extents extents = getExtents();
return Box(0, 0, 0, extents.width, extents.height, extents.depth);
}
Extents FramebufferState::getExtents() const
{
ASSERT(attachmentsHaveSameDimensions());
ASSERT(getFirstNonNullAttachment() != nullptr);
Extents extents = getFirstNonNullAttachment()->getSize();
return Box(0, 0, 0, extents.width, extents.height, extents.depth);
return getFirstNonNullAttachment()->getSize();
}
Framebuffer::Framebuffer(const Caps &caps, rx::GLImplFactory *factory, GLuint id)
......@@ -2285,6 +2290,11 @@ Box Framebuffer::getDimensions() const
return mState.getDimensions();
}
Extents Framebuffer::getExtents() const
{
return mState.getExtents();
}
angle::Result Framebuffer::ensureBufferInitialized(const Context *context,
GLenum bufferType,
GLint bufferIndex)
......
......@@ -82,6 +82,7 @@ class FramebufferState final : angle::NonCopyable
bool hasSeparateDepthAndStencilAttachments() const;
bool colorAttachmentsAreUniqueImages() const;
Box getDimensions() const;
Extents getExtents() const;
const FramebufferAttachment *getDrawBuffer(size_t drawBufferIdx) const;
size_t getDrawBufferCount() const;
......@@ -202,6 +203,7 @@ class Framebuffer final : public angle::ObserverInterface,
bool readDisallowedByMultiview() const;
GLsizei getNumViews() const;
GLint getBaseViewIndex() const;
Extents getExtents() const;
size_t getDrawbufferStateCount() const;
GLenum getDrawBufferState(size_t drawBuffer) const;
......
......@@ -115,6 +115,12 @@ class FramebufferGL : public FramebufferImpl
void maskOutInactiveOutputDrawBuffersImpl(const gl::Context *context,
gl::DrawBufferMask targetAppliedDrawBuffers);
angle::Result adjustSrcDstRegion(const gl::Context *context,
const gl::Rectangle &sourceArea,
const gl::Rectangle &destArea,
gl::Rectangle *newSourceArea,
gl::Rectangle *newDestArea);
GLuint mFramebufferID;
bool mIsDefault;
......
......@@ -1531,6 +1531,9 @@ void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *feature
features->clearToZeroOrOneBroken.enabled =
IsApple() && IsIntel(vendor) && GetMacOSVersion() < OSVersion(10, 12, 6);
features->adjustSrcDstRegionBlitFramebuffer.enabled =
IsApple() || IsLinux() || (IsAndroid() && IsNvidia(vendor));
}
void InitializeFrontendFeatures(const FunctionsGL *functions, angle::FrontendFeatures *features)
......
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