Esempio n. 1
0
FBStatus
WebGLFramebuffer::PrecheckFramebufferStatus(nsCString* const out_info) const
{
    MOZ_ASSERT(mContext->mBoundDrawFramebuffer == this ||
               mContext->mBoundReadFramebuffer == this);

    if (!HasDefinedAttachments())
        return LOCAL_GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; // No attachments

    if (HasIncompleteAttachments(out_info))
        return LOCAL_GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;

    if (!mContext->IsWebGL2()) {
        // INCOMPLETE_DIMENSIONS doesn't exist in GLES3.
        if (!AllImageRectsMatch())
            return LOCAL_GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS; // Inconsistent sizes

        const auto depthOrStencilCount = int(mDepthAttachment.IsDefined()) +
                                         int(mStencilAttachment.IsDefined()) +
                                         int(mDepthStencilAttachment.IsDefined());
        if (depthOrStencilCount > 1)
            return LOCAL_GL_FRAMEBUFFER_UNSUPPORTED;
    }

    return LOCAL_GL_FRAMEBUFFER_COMPLETE;
}
Esempio n. 2
0
bool
WebGLFramebuffer::AllImageRectsMatch() const
{
    MOZ_ASSERT(HasDefinedAttachments());
    MOZ_ASSERT(!HasIncompleteAttachments());

    const WebGLRectangleObject& rect = GetAnyRectObject();

    // Alright, we have *a* rect, let's check all the others.
    bool imageRectsMatch = true;

    if (mColorAttachment0.HasImage())
        imageRectsMatch &= RectsMatch(mColorAttachment0, rect);

    if (mDepthAttachment.HasImage())
        imageRectsMatch &= RectsMatch(mDepthAttachment, rect);

    if (mStencilAttachment.HasImage())
        imageRectsMatch &= RectsMatch(mStencilAttachment, rect);

    if (mDepthStencilAttachment.HasImage())
        imageRectsMatch &= RectsMatch(mDepthStencilAttachment, rect);

    const size_t moreColorAttachmentCount = mMoreColorAttachments.Length();
    for (size_t i = 0; i < moreColorAttachmentCount; i++) {
        if (mMoreColorAttachments[i].HasImage())
            imageRectsMatch &= RectsMatch(mMoreColorAttachments[i], rect);
    }

    return imageRectsMatch;
}
Esempio n. 3
0
const WebGLRectangleObject&
WebGLFramebuffer::GetAnyRectObject() const
{
    MOZ_ASSERT(HasDefinedAttachments());

    if (mColorAttachment0.HasImage())
        return mColorAttachment0.RectangleObject();

    if (mDepthAttachment.HasImage())
        return mDepthAttachment.RectangleObject();

    if (mStencilAttachment.HasImage())
        return mStencilAttachment.RectangleObject();

    if (mDepthStencilAttachment.HasImage())
        return mDepthStencilAttachment.RectangleObject();

    const size_t moreColorAttachmentCount = mMoreColorAttachments.Length();
    for (size_t i = 0; i < moreColorAttachmentCount; i++) {
        if (mMoreColorAttachments[i].HasImage())
            return mMoreColorAttachments[i].RectangleObject();
    }

    MOZ_CRASH("Should not get here.");
}
Esempio n. 4
0
FBStatus
WebGLFramebuffer::PrecheckFramebufferStatus() const
{
    MOZ_ASSERT(mContext->mBoundDrawFramebuffer == this ||
               mContext->mBoundReadFramebuffer == this);

    if (!HasDefinedAttachments())
        return LOCAL_GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; // No attachments

    if (HasIncompleteAttachments())
        return LOCAL_GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;

    if (!AllImageRectsMatch())
        return LOCAL_GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS; // Inconsistent sizes

    if (HasDepthStencilConflict())
        return LOCAL_GL_FRAMEBUFFER_UNSUPPORTED;

    return LOCAL_GL_FRAMEBUFFER_COMPLETE;
}
bool
WebGLFramebuffer::AllImageRectsMatch() const
{
    MOZ_ASSERT(HasDefinedAttachments());
    MOZ_ASSERT(!HasIncompleteAttachments());

    uint32_t width = 0;
    uint32_t height = 0;
    bool imageRectsMatch = true;

    imageRectsMatch &= MatchOrReplaceSize(mColorAttachment0,       &width, &height);
    imageRectsMatch &= MatchOrReplaceSize(mDepthAttachment,        &width, &height);
    imageRectsMatch &= MatchOrReplaceSize(mStencilAttachment,      &width, &height);
    imageRectsMatch &= MatchOrReplaceSize(mDepthStencilAttachment, &width, &height);

    for (const auto& cur : mMoreColorAttachments) {
        imageRectsMatch &= MatchOrReplaceSize(cur, &width, &height);
    }

    return imageRectsMatch;
}