[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Public WebGL] Proposal for depth and stencil FBO attachments
- To: firstname.lastname@example.org
- Subject: [Public WebGL] Proposal for depth and stencil FBO attachments
- From: Kenneth Russell <email@example.com>
- Date: Thu, 25 Feb 2010 11:28:59 -0800
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1267126142; bh=mm6yQnOp9ZL2EMOiAKzdmimj3bE=; h=MIME-Version:Date:Message-ID:Subject:From:To:Content-Type; b=hvCZ/3u9XiMpzy49zn8JH/Ns47NxYWcH9AGdtitRv9Xw4Vy7UiJayOZttOXRGsIqb NK9NCVKsKXfxe/Z062zSQ==
- Domainkey-signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns; h=mime-version:date:message-id:subject:from:to:content-type:x-system-of-record; b=GOpMblod30WxGLq4jAbd1sXdSVV0i11MbM/ooYkn+dJQCj9qV6PvmaqFHWdLaM/90 2RR1w/4lCWOToV35eGVNg==
- Sender: firstname.lastname@example.org
There is a problem implementing the current WebGL (and OpenGL ES) semantics for depth and stencil attachments to framebuffer objects on desktop OpenGL. On the desktop, the best supported functionality for adding a stencil buffer to an FBO is to use EXT_packed_depth_stencil. The renderbuffer is allocated with the GL_DEPTH_STENCIL or GL_DEPTH24_STENCIL8 format and is attached to both the GL_DEPTH_ATTACHMENT and GL_STENCIL_ATTACHMENT points of the framebuffer. Separate depth and stencil renderbuffer attachments to FBOs are not well supported.
On OpenGL ES, the only functionality guaranteed to be supported is separate depth and stencil attachments, though there is a GL_OES_packed_depth_stencil extension.
Because of how renderbuffers are allocated and attached to FBOs, it is very difficult to emulate the behavior of separate depth and stencil attachments when the underlying platform only supports packed depth and stencil. However, it is easy to emulate the behavior of packed depth and stencil attachments when the underlying platform only supports separate attachments. The reason is that at the point glRenderbufferStorage is called with the packed format, a hidden second renderbuffer can be generated and allocated. There is no good place to do this if the separate depth and stencil renderbuffers are exposed in the public API; glFramebufferRenderbuffer is the best interposition point, but it is a poor one.
To make it feasible to implement stencil buffer support for FBOs on all platforms I would like to propose the following specification changes.
1. Add the enum DEPTH_STENCIL (0x84F9), which is accepted as the internalformat parameter of renderbufferStorage.
2. Add the enum DEPTH_STENCIL_ATTACHMENT (0x821A) from OpenGL 3, which is accepted as the attachment parameter of framebufferRenderbuffer.
3. Remove the enums STENCIL_ATTACHMENT, STENCIL_INDEX and STENCIL_INDEX8.
4. State that it is an error to attach the same renderbuffer to both the DEPTH_ATTACHMENT and DEPTH_STENCIL_ATTACHMENT attachment points of a framebuffer object.
5. Add a subsection to the spec describing the difference in behavior compared to OpenGL ES 2.0.
These changes would move the WebGL spec closer to OpenGL 3's behavior and would be implementable on both desktop GL and OpenGL ES 2.0 without OES_packed_depth_stencil. They would also have the benefit of being easily implementable on top of D3D. They are a subset of OES/EXT_packed_depth_texture and OpenGL 3 functionality.
The only downside compared to the current API is the inability to attach a stencil buffer without a depth buffer, which I don't think is important.