GLenum Framebuffer::completeness() { int width; int height; int samples; return completeness(width, height, samples); }
int Framebuffer::getSamples() { if (completeness() == GL_FRAMEBUFFER_COMPLETE) { return getColorbuffer()->getSamples(); } else { return 0; } }
bool Framebuffer::isMultisample() { // If the framebuffer is not complete, attachment samples may be mismatched, and it // cannot be used as a multisample framebuffer. If it is complete, it is required to // have a color attachment, and all its attachments must have the same number of samples, // so the number of samples for the colorbuffer will indicate whether the framebuffer is // multisampled. if (completeness() == GL_FRAMEBUFFER_COMPLETE && getColorbuffer()->getSamples() > 0) { return true; } else { return false; } }
int Framebuffer::getSamples(const gl::Data &data) const { if (completeness(data) == GL_FRAMEBUFFER_COMPLETE) { // for a complete framebuffer, all attachments must have the same sample count // in this case return the first nonzero sample size for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++) { if (mColorbuffers[colorAttachment]) { return mColorbuffers[colorAttachment]->getSamples(); } } } return 0; }
void Framebuffer::invalidateSub(const Caps &caps, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height) { ASSERT(completeness() == GL_FRAMEBUFFER_COMPLETE); for (GLsizei attachIndex = 0; attachIndex < numAttachments; ++attachIndex) { GLenum attachmentTarget = attachments[attachIndex]; gl::FramebufferAttachment *attachment = (attachmentTarget == GL_DEPTH_STENCIL_ATTACHMENT) ? getDepthOrStencilbuffer() : getAttachment(attachmentTarget); if (attachment) { rx::RenderTarget *renderTarget = rx::GetAttachmentRenderTarget(attachment); if (renderTarget) { renderTarget->invalidate(x, y, width, height); } } } }