mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-13 19:41:49 +00:00
Bug 970775 - Add more asserts to WebGLFramebuffer. - r=bjacob
This commit is contained in:
parent
ee6f816ed1
commit
20de9c9154
@ -50,6 +50,8 @@ WebGLFramebuffer::Attachment::IsDeleteRequested() const
|
||||
bool
|
||||
WebGLFramebuffer::Attachment::HasAlpha() const
|
||||
{
|
||||
MOZ_ASSERT(HasImage());
|
||||
|
||||
GLenum format = 0;
|
||||
if (Texture() && Texture()->HasImageInfoAt(mTexImageTarget, mTexImageLevel))
|
||||
format = Texture()->ImageInfoAt(mTexImageTarget, mTexImageLevel).InternalFormat();
|
||||
@ -75,7 +77,9 @@ WebGLFramebuffer::Attachment::HasUninitializedImageData() const
|
||||
|
||||
if (Renderbuffer()) {
|
||||
return Renderbuffer()->HasUninitializedImageData();
|
||||
} else if (Texture()) {
|
||||
}
|
||||
|
||||
if (Texture()) {
|
||||
MOZ_ASSERT(Texture()->HasImageInfoAt(mTexImageTarget, mTexImageLevel));
|
||||
return Texture()->ImageInfoAt(mTexImageTarget, mTexImageLevel).HasUninitializedImageData();
|
||||
}
|
||||
@ -90,11 +94,13 @@ WebGLFramebuffer::Attachment::SetImageDataStatus(WebGLImageDataStatus newStatus)
|
||||
if (!HasImage())
|
||||
return;
|
||||
|
||||
if (mRenderbufferPtr) {
|
||||
mRenderbufferPtr->SetImageDataStatus(newStatus);
|
||||
if (Renderbuffer()) {
|
||||
Renderbuffer()->SetImageDataStatus(newStatus);
|
||||
return;
|
||||
} else if (mTexturePtr) {
|
||||
mTexturePtr->SetImageDataStatus(mTexImageTarget, mTexImageLevel, newStatus);
|
||||
}
|
||||
|
||||
if (Texture()) {
|
||||
Texture()->SetImageDataStatus(mTexImageTarget, mTexImageLevel, newStatus);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -106,7 +112,8 @@ WebGLFramebuffer::Attachment::HasImage() const
|
||||
{
|
||||
if (Texture() && Texture()->HasImageInfoAt(mTexImageTarget, mTexImageLevel))
|
||||
return true;
|
||||
else if (Renderbuffer())
|
||||
|
||||
if (Renderbuffer())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@ -120,7 +127,9 @@ WebGLFramebuffer::Attachment::RectangleObject() const
|
||||
if (Texture()) {
|
||||
MOZ_ASSERT(Texture()->HasImageInfoAt(mTexImageTarget, mTexImageLevel));
|
||||
return Texture()->ImageInfoAt(mTexImageTarget, mTexImageLevel);
|
||||
} else if (Renderbuffer()) {
|
||||
}
|
||||
|
||||
if (Renderbuffer()) {
|
||||
return *Renderbuffer();
|
||||
}
|
||||
|
||||
@ -228,10 +237,10 @@ WebGLFramebuffer::Attachment::IsComplete() const
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mTexturePtr) {
|
||||
MOZ_ASSERT(mTexturePtr->HasImageInfoAt(mTexImageTarget, mTexImageLevel));
|
||||
if (Texture()) {
|
||||
MOZ_ASSERT(Texture()->HasImageInfoAt(mTexImageTarget, mTexImageLevel));
|
||||
const WebGLTexture::ImageInfo& imageInfo =
|
||||
mTexturePtr->ImageInfoAt(mTexImageTarget, mTexImageLevel);
|
||||
Texture()->ImageInfoAt(mTexImageTarget, mTexImageLevel);
|
||||
GLenum internalFormat = imageInfo.InternalFormat();
|
||||
|
||||
if (mAttachmentPoint == LOCAL_GL_DEPTH_ATTACHMENT)
|
||||
@ -250,8 +259,8 @@ WebGLFramebuffer::Attachment::IsComplete() const
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mRenderbufferPtr) {
|
||||
GLenum internalFormat = mRenderbufferPtr->InternalFormat();
|
||||
if (Renderbuffer()) {
|
||||
GLenum internalFormat = Renderbuffer()->InternalFormat();
|
||||
|
||||
if (mAttachmentPoint == LOCAL_GL_DEPTH_ATTACHMENT)
|
||||
return IsValidFBORenderbufferDepthFormat(internalFormat);
|
||||
@ -438,7 +447,8 @@ WebGLFramebuffer::GetAttachment(GLenum attachment) const
|
||||
void
|
||||
WebGLFramebuffer::DetachTexture(const WebGLTexture* tex)
|
||||
{
|
||||
for (size_t i = 0; i < mColorAttachments.Length(); i++) {
|
||||
size_t count = mColorAttachments.Length();
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
if (mColorAttachments[i].Texture() == tex) {
|
||||
FramebufferTexture2D(LOCAL_GL_FRAMEBUFFER, LOCAL_GL_COLOR_ATTACHMENT0, LOCAL_GL_TEXTURE_2D, nullptr, 0);
|
||||
// a texture might be attached more that once while editing the framebuffer
|
||||
@ -456,7 +466,8 @@ WebGLFramebuffer::DetachTexture(const WebGLTexture* tex)
|
||||
void
|
||||
WebGLFramebuffer::DetachRenderbuffer(const WebGLRenderbuffer* rb)
|
||||
{
|
||||
for (size_t i = 0; i < mColorAttachments.Length(); i++) {
|
||||
size_t count = mColorAttachments.Length();
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
if (mColorAttachments[0].Renderbuffer() == rb) {
|
||||
FramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER, LOCAL_GL_COLOR_ATTACHMENT0, LOCAL_GL_RENDERBUFFER, nullptr);
|
||||
// a renderbuffer might be attached more that once while editing the framebuffer
|
||||
@ -476,7 +487,8 @@ WebGLFramebuffer::HasDefinedAttachments() const
|
||||
{
|
||||
bool hasAttachments = false;
|
||||
|
||||
for (size_t i = 0; i < mColorAttachments.Length(); i++) {
|
||||
size_t count = mColorAttachments.Length();
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
hasAttachments |= mColorAttachments[i].IsDefined();
|
||||
}
|
||||
|
||||
@ -491,7 +503,7 @@ WebGLFramebuffer::HasDefinedAttachments() const
|
||||
static bool
|
||||
IsIncomplete(const WebGLFramebuffer::Attachment& cur)
|
||||
{
|
||||
return cur.IsDefined() && !cur.IsComplete();
|
||||
return cur.IsDefined() && !cur.IsComplete();
|
||||
}
|
||||
|
||||
bool
|
||||
@ -499,7 +511,8 @@ WebGLFramebuffer::HasIncompleteAttachments() const
|
||||
{
|
||||
bool hasIncomplete = false;
|
||||
|
||||
for (size_t i = 0; i < mColorAttachments.Length(); i++) {
|
||||
size_t count = mColorAttachments.Length();
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
hasIncomplete |= IsIncomplete(mColorAttachments[i]);
|
||||
}
|
||||
|
||||
@ -516,7 +529,8 @@ WebGLFramebuffer::GetAnyRectObject() const
|
||||
{
|
||||
MOZ_ASSERT(HasDefinedAttachments());
|
||||
|
||||
for (size_t i = 0; i < mColorAttachments.Length(); i++) {
|
||||
size_t count = mColorAttachments.Length();
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
if (mColorAttachments[i].HasImage())
|
||||
return mColorAttachments[i].RectangleObject();
|
||||
}
|
||||
@ -552,7 +566,8 @@ WebGLFramebuffer::AllImageRectsMatch() const
|
||||
// Alright, we have *a* rect, let's check all the others.
|
||||
bool imageRectsMatch = true;
|
||||
|
||||
for (size_t i = 0; i < mColorAttachments.Length(); i++) {
|
||||
size_t count = mColorAttachments.Length();
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
if (mColorAttachments[i].HasImage())
|
||||
imageRectsMatch &= RectsMatch(mColorAttachments[i], rect);
|
||||
}
|
||||
@ -591,7 +606,7 @@ WebGLFramebuffer::PrecheckFramebufferStatus() const
|
||||
return LOCAL_GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
|
||||
|
||||
if (!AllImageRectsMatch())
|
||||
return LOCAL_GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS; // No consistent size
|
||||
return LOCAL_GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS; // Inconsistent sizes
|
||||
|
||||
if (HasDepthStencilConflict())
|
||||
return LOCAL_GL_FRAMEBUFFER_UNSUPPORTED;
|
||||
@ -616,7 +631,6 @@ WebGLFramebuffer::CheckFramebufferStatus() const
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
WebGLFramebuffer::CheckAndInitializeAttachments()
|
||||
{
|
||||
@ -626,7 +640,7 @@ WebGLFramebuffer::CheckAndInitializeAttachments()
|
||||
return false;
|
||||
|
||||
// Cool! We've checked out ok. Just need to initialize.
|
||||
size_t colorAttachmentCount = size_t(mColorAttachments.Length());
|
||||
size_t colorAttachmentCount = mColorAttachments.Length();
|
||||
|
||||
// Check if we need to initialize anything
|
||||
{
|
||||
@ -764,7 +778,8 @@ FinalizeDrawAndReadBuffers(GLContext* aGL, bool aColorBufferDefined)
|
||||
void
|
||||
WebGLFramebuffer::FinalizeAttachments() const
|
||||
{
|
||||
for (size_t i = 0; i < ColorAttachmentCount(); i++) {
|
||||
size_t count = ColorAttachmentCount();
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
if (ColorAttachment(i).IsDefined())
|
||||
ColorAttachment(i).FinalizeAttachment(LOCAL_GL_COLOR_ATTACHMENT0 + i);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user