Skip to content

Commit e2afdd3

Browse files
lexaknyazevAngle LUCI CQ
authored andcommitted
Metal: Fix depth/stencil FBO attachments validation
Simplified and fixed depth/stencil attachments validation to match Metal behavior; added a new error message. Updated allowSeparateDepthStencilBuffers feature condition to enable it on Apple silicon Macs. Fixed: angleproject:362901599 Change-Id: Ib60020f157976240ebfd652254d63380341cddbd Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5823534 Reviewed-by: Geoff Lang <[email protected]> Reviewed-by: Kimmo Kinnunen <[email protected]> Commit-Queue: Alexey Knyazev <[email protected]>
1 parent b43f888 commit e2afdd3

File tree

4 files changed

+20
-52
lines changed

4 files changed

+20
-52
lines changed

src/libANGLE/ErrorStrings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ MSG kFramebufferIncompleteSurfaceless = "Framebuffer is incomplete: Framebuffer
199199
MSG kFramebufferIncompleteUnsupportedMissmatchedDimensions = "Framebuffer is incomplete: Mismatched attachment sizes are unsupported.";
200200
MSG kFramebufferIncompleteUnsupportedNonUniqueAttachments = "Framebuffer is incomplete: Non-unique attachments are unsupported.";
201201
MSG kFramebufferIncompleteUnsupportedSeparateDepthStencilBuffers = "Framebuffer is incomplete: Separate depth and stencil buffers are unsupported.";
202+
MSG kFramebufferIncompleteUnsupportedSeparateDepthStencilBuffersCombinedFormat = "Framebuffer is incomplete: Combined depth/stencil formats cannot be used with separate depth and stencil buffers.";
202203
MSG kFramebufferIncompleteWebGLDepthStencilInconsistant = "Framebuffer is incomplete: WebGL depth stencil state is inconsistent.";
203204
MSG kFramebufferTextureInvalidLayer = "Layer invalid for framebuffer texture attachment.";
204205
MSG kFramebufferTextureInvalidMipLevel = "Mip level invalid for framebuffer texture attachment.";

src/libANGLE/renderer/metal/DisplayMtl.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ bool IsMetalDisplayAvailable()
12451245
isOSX || isCatalyst || supportsAppleGPUFamily(4));
12461246

12471247
ANGLE_FEATURE_CONDITION((&mFeatures), allowSeparateDepthStencilBuffers,
1248-
!isOSX && !isCatalyst && !isSimulator);
1248+
supportsAppleGPUFamily(1) && !isSimulator);
12491249
ANGLE_FEATURE_CONDITION((&mFeatures), emulateTransformFeedback, true);
12501250

12511251
ANGLE_FEATURE_CONDITION((&mFeatures), intelExplicitBoolCastWorkaround,

src/libANGLE/renderer/metal/FrameBufferMtl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ class FramebufferMtl : public FramebufferImpl
129129

130130
private:
131131
void reset();
132-
gl::FramebufferStatus checkPackedDepthStencilAttachment() const;
133132
angle::Result invalidateImpl(const gl::Context *context,
134133
size_t count,
135134
const GLenum *attachments);

src/libANGLE/renderer/metal/FrameBufferMtl.mm

Lines changed: 18 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -654,67 +654,35 @@ void RoundValueAndAdjustCorrespondingValue(float a,
654654

655655
gl::FramebufferStatus FramebufferMtl::checkStatus(const gl::Context *context) const
656656
{
657-
ContextMtl *contextMtl = mtl::GetImpl(context);
658-
if (!contextMtl->getDisplay()->getFeatures().allowSeparateDepthStencilBuffers.enabled &&
659-
mState.hasSeparateDepthAndStencilAttachments())
660-
{
661-
return gl::FramebufferStatus::Incomplete(
662-
GL_FRAMEBUFFER_UNSUPPORTED,
663-
gl::err::kFramebufferIncompleteUnsupportedSeparateDepthStencilBuffers);
664-
}
665-
666-
if (mState.getDepthAttachment() && mState.getDepthAttachment()->getFormat().info->depthBits &&
667-
mState.getDepthAttachment()->getFormat().info->stencilBits)
657+
if (mState.hasSeparateDepthAndStencilAttachments())
668658
{
669-
return checkPackedDepthStencilAttachment();
670-
}
671-
672-
if (mState.getStencilAttachment() &&
673-
mState.getStencilAttachment()->getFormat().info->depthBits &&
674-
mState.getStencilAttachment()->getFormat().info->stencilBits)
675-
{
676-
return checkPackedDepthStencilAttachment();
677-
}
678-
679-
if (!totalBitsUsedIsLessThanOrEqualToMaxBitsSupported(context))
680-
{
681-
return gl::FramebufferStatus::Incomplete(
682-
GL_FRAMEBUFFER_UNSUPPORTED,
683-
gl::err::kFramebufferIncompleteColorBitsUsedExceedsMaxColorBitsSupported);
684-
}
685-
686-
return gl::FramebufferStatus::Complete();
687-
}
688-
689-
gl::FramebufferStatus FramebufferMtl::checkPackedDepthStencilAttachment() const
690-
{
691-
if (ANGLE_APPLE_AVAILABLE_XCI(10.14, 13.1, 12.0))
692-
{
693-
// If depth/stencil attachment has depth & stencil bits, then depth & stencil must not have
694-
// separate attachment. i.e. They must be the same texture or one of them has no
695-
// attachment.
696-
if (mState.hasSeparateDepthAndStencilAttachments())
659+
ContextMtl *contextMtl = mtl::GetImpl(context);
660+
if (!contextMtl->getDisplay()->getFeatures().allowSeparateDepthStencilBuffers.enabled)
697661
{
698-
WARN() << "Packed depth stencil texture/buffer must not be mixed with other "
699-
"texture/buffer.";
700662
return gl::FramebufferStatus::Incomplete(
701663
GL_FRAMEBUFFER_UNSUPPORTED,
702664
gl::err::kFramebufferIncompleteUnsupportedSeparateDepthStencilBuffers);
703665
}
704-
}
705-
else
706-
{
707-
// Metal 2.0 and below doesn't allow packed depth stencil texture to be attached only as
708-
// depth or stencil buffer. i.e. None of the depth & stencil attachment can be null.
709-
if (!mState.getDepthStencilAttachment())
666+
667+
ASSERT(mState.getDepthAttachment()->getFormat().info->depthBits > 0);
668+
ASSERT(mState.getStencilAttachment()->getFormat().info->stencilBits > 0);
669+
if (mState.getDepthAttachment()->getFormat().info->stencilBits != 0 ||
670+
mState.getStencilAttachment()->getFormat().info->depthBits != 0)
710671
{
711-
WARN() << "Packed depth stencil texture/buffer must be bound to both depth & stencil "
712-
"attachment point.";
713672
return gl::FramebufferStatus::Incomplete(
714673
GL_FRAMEBUFFER_UNSUPPORTED,
715-
gl::err::kFramebufferIncompleteUnsupportedSeparateDepthStencilBuffers);
674+
gl::err::
675+
kFramebufferIncompleteUnsupportedSeparateDepthStencilBuffersCombinedFormat);
716676
}
717677
}
678+
679+
if (!totalBitsUsedIsLessThanOrEqualToMaxBitsSupported(context))
680+
{
681+
return gl::FramebufferStatus::Incomplete(
682+
GL_FRAMEBUFFER_UNSUPPORTED,
683+
gl::err::kFramebufferIncompleteColorBitsUsedExceedsMaxColorBitsSupported);
684+
}
685+
718686
return gl::FramebufferStatus::Complete();
719687
}
720688

0 commit comments

Comments
 (0)