void WebGLRenderbuffer::RenderbufferStorage(const char* funcName, uint32_t samples, GLenum internalFormat, uint32_t width, uint32_t height) { const auto usage = mContext->mFormatUsage->GetRBUsage(internalFormat); if (!usage) { mContext->ErrorInvalidEnum("%s: Invalid `internalFormat`: 0x%04x.", funcName, internalFormat); return; } if (width > mContext->mImplMaxRenderbufferSize || height > mContext->mImplMaxRenderbufferSize) { mContext->ErrorInvalidValue("%s: Width or height exceeds maximum renderbuffer" " size.", funcName); return; } mContext->MakeContextCurrent(); if (!usage->maxSamplesKnown) { const_cast<webgl::FormatUsageInfo*>(usage)->ResolveMaxSamples(mContext->gl); } MOZ_ASSERT(usage->maxSamplesKnown); if (samples > usage->maxSamples) { mContext->ErrorInvalidValue("%s: `samples` is out of the valid range.", funcName); return; } // Validation complete. const GLenum error = DoRenderbufferStorage(samples, usage, width, height); if (error) { const char* errorName = mContext->ErrorName(error); mContext->GenerateWarning("%s generated error %s", funcName, errorName); return; } mSamples = samples; mFormat = usage; mWidth = width; mHeight = height; mImageDataStatus = WebGLImageDataStatus::UninitializedImageData; InvalidateStatusOfAttachedFBs(); }
void WebGLRenderbuffer::RenderbufferStorage(GLsizei samples, const webgl::FormatUsageInfo* format, GLsizei width, GLsizei height) { MOZ_ASSERT(mContext->mBoundRenderbuffer == this); gl::GLContext* gl = mContext->gl; MOZ_ASSERT(samples >= 0 && samples <= 256); // Sanity check. GLenum primaryFormat = format->format->sizedFormat; GLenum secondaryFormat = 0; if (NeedsDepthStencilEmu(mContext->gl, primaryFormat)) { primaryFormat = DepthStencilDepthFormat(gl); secondaryFormat = LOCAL_GL_STENCIL_INDEX8; } RenderbufferStorageMaybeMultisample(gl, samples, primaryFormat, width, height); if (mSecondaryRB) { // We can't leave the secondary RB unspecified either, since we should // handle the case where we attach a non-depth-stencil RB to a // depth-stencil attachment point, or attach this depth-stencil RB to a // non-depth-stencil attachment point. gl::ScopedBindRenderbuffer autoRB(gl, mSecondaryRB); if (secondaryFormat) { RenderbufferStorageMaybeMultisample(gl, samples, secondaryFormat, width, height); } else { RenderbufferStorageMaybeMultisample(gl, samples, LOCAL_GL_RGBA4, 1, 1); } } mSamples = samples; mFormat = format; mWidth = width; mHeight = height; mImageDataStatus = WebGLImageDataStatus::UninitializedImageData; mIsUsingSecondary = bool(secondaryFormat); InvalidateStatusOfAttachedFBs(); }
void WebGLTexture::SetImageInfo(TexImageTarget texImageTarget, GLint level, GLsizei width, GLsizei height, GLsizei depth, TexInternalFormat effectiveInternalFormat, WebGLImageDataStatus status) { MOZ_ASSERT(depth == 1 || texImageTarget == LOCAL_GL_TEXTURE_3D); MOZ_ASSERT(TexImageTargetToTexTarget(texImageTarget) == mTarget); InvalidateStatusOfAttachedFBs(); EnsureMaxLevelWithCustomImagesAtLeast(level); ImageInfoAt(texImageTarget, level) = ImageInfo(width, height, depth, effectiveInternalFormat, status); if (level > 0) SetCustomMipmap(); SetFakeBlackStatus(WebGLTextureFakeBlackStatus::Unknown); }