© Copyright 3Dlabs 2004 Page 1 Super Buffers Workgroup Status update, December 2004
© Copyright 3Dlabs 2004 Page 2 Highlights since last ARB meeting EXT_framebuffer_object is done! Can be used for ‘render to texture’ and general off-screen rendering Only single context needed Resolved since last ARB meeting Error behavior when framebuffer cannot be rendered to What state is per context or per framebuffer object Error behavior across contexts What, if any, state can change after a call to BindFramebuffer? Still on schedule, as presented at last meeting Sept 2004 – Draft spec with render-to-texture support Dec 2004 – Final spec. Promoted to ARB (?)
© Copyright 3Dlabs 2004 Page 3 OverviewOverview New objects Renderbuffer – a new 2D storage object. Holds destination of pixel data resulting from rendering Framebuffer – Collection of logical buffers (color, depth, stencil) and its state defining where GL output is directed to. Terminology Renderbuffer image – 2D array of pixels part of a renderbuffer. Framebuffer-attachable image – 2D array of pixels that can be attached to a framebuffer. Texture images and renderbuffer images are examples. Attachment point – State that references a framebuffer-attachable image. One each for color, depth and stencil information of a framebuffer. Renderable image completeness Framebuffer attachment completeness Framebuffer completeness Renderbuffer images and texture images can be shared among framebuffers.
© Copyright 3Dlabs 2004 Page 4 Overview - cont When a framebuffer object is bound its attached images are the source and destination for rendering Color and depth textures Multiple color attachments to support MRT Stencil, depth, color renderbuffers
© Copyright 3Dlabs 2004 Page 5 RelationshipRelationship Textures (color, depth) 2D in nature Renderbuffers (stencil, depth, accum etc) Renderbuffer image is 2D in nature Attachment points Framebuffer object
© Copyright 3Dlabs 2004 Page 6 Framebuffer completeness Measures if the framebuffer can be rendered to. Depends on attachements Can be implementation specific If not complete, Begin will generate error INVALID_FRAMEBUFFER_OPERATION CheckFramebufferStatus Optional, but useful development tool Returns enums FRAMEBUFFER_COMPLETE FRAMEBUFFER_INCOMPLETE_ATTACHEMENTS FRAMEBUFFER_INCOMPLETE_IMAGES FRAMEBUFFER_INCOMPLETE_DIMENSIONS FRAMEBUFFER_INCOMPLETE_FORMATS FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER FRAMEBUFFER_INCOMPLETE_READ_BUFFER FRAMEBUFFER_UNSUPPORTED FRAMEBUFFER_STATUS_ERROR Set of state that can change on a framebuffer bind AUX_BUFFERS, MAX_DRAW_BUFFERS, STEREO, SAMPLES, X_BITS, DOUBLE_BUFFER and a few more
© Copyright 3Dlabs 2004 Page 7 Resolved since last ARB meeting At last ARB meeting asked for input on Begin error behavior Error behavior across contexts What state can change after a bind to a framebuffer object Other noteworthy issues resolved Drawbuffer state per framebuffer object Readpixels will throw error when reading from incomplete framebuffer Include separate GenerateMipmap command Framebuffer-attachable images cannot change internal format or dimensions No Accum, No multi-sample support (for now) Reading from, and rendering to, the same texture image is undefined Allow rendering to textures with borders and border pixels No context state influences framebuffer completenes
© Copyright 3Dlabs 2004 Page 8 ExampleExample #define CHECK_FRAMEBUFFER_STATUS() \ { \ GLenum status; \ status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); \ switch(status) { \ case GL_FRAMEBUFFER_COMPLETE_EXT: \ break; \ case GL_FRAMEBUFFER_UNSUPPORTED_EXT: \ // choose different formats \ break; \ default: \ // programming error; will fail on all hardware \ assert(0); \ }
© Copyright 3Dlabs 2004 Page 9 Render to 2D texture with depth buffer No benefit Need 16-bit fp Need 32-bit fp Need 16-bit and/or 32-bit fp // fb, color_tex, depth_rb already allocated // Enable render-to-texture glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb); // Set up color_tex and depth_rb for render-to-texture glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, color_tex, 0); glFramebufferRenderBufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT, GL_RENDER_BUFFER_EXT, depth_rb); CHECK_FRAMEBUFFER_STATUS(); // Re-enable rendering to the window glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glBindTexture(GL_TEXTURE_2D, color_tex);
© Copyright 3Dlabs 2004 Page 10 Wrap up Spec done, start implementing! Next steps Format Restrictions API to layer on top Support Multi-sample, accum as separate extension Start work on “render-to-vertex-array” Questions ?