summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2011-12-10 11:44:43 -0700
committerBrian Paul <[email protected]>2011-12-13 06:45:37 -0700
commitc0a55cf68aa80cacbc709b25205705eee2e3bbdb (patch)
tree71a54112c58ea1aa7ebd5155a3c1c907d51b72da /src/mesa/main
parent2750809b2e9a7d24d83d01f0a1d5bb5dce027b4c (diff)
mesa: move update_depth/stencil_buffer() functions
These functions update the gl_framebuffer::_DepthBuffer and _StencilBuffer fields, possibly creating renderbuffer wrappers that make a shared depth+stencil accessible as depth-only or stencil only. This stuff is only used by swrast now and will be moved there next. Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/depthstencil.c90
-rw-r--r--src/mesa/main/depthstencil.h17
-rw-r--r--src/mesa/main/framebuffer.c78
3 files changed, 89 insertions, 96 deletions
diff --git a/src/mesa/main/depthstencil.c b/src/mesa/main/depthstencil.c
index af5c12f67fc..18f2705a479 100644
--- a/src/mesa/main/depthstencil.c
+++ b/src/mesa/main/depthstencil.c
@@ -349,9 +349,9 @@ put_mono_values_z24(struct gl_context *ctx, struct gl_renderbuffer *z24rb,
* a depth renderbuffer.
* \return new depth renderbuffer
*/
-struct gl_renderbuffer *
-_mesa_new_z24_renderbuffer_wrapper(struct gl_context *ctx,
- struct gl_renderbuffer *dsrb)
+static struct gl_renderbuffer *
+new_z24_renderbuffer_wrapper(struct gl_context *ctx,
+ struct gl_renderbuffer *dsrb)
{
struct gl_renderbuffer *z24rb;
@@ -563,9 +563,9 @@ put_mono_values_z32f(struct gl_context *ctx, struct gl_renderbuffer *z32frb,
* a depth renderbuffer.
* \return new depth renderbuffer
*/
-struct gl_renderbuffer *
-_mesa_new_z32f_renderbuffer_wrapper(struct gl_context *ctx,
- struct gl_renderbuffer *dsrb)
+static struct gl_renderbuffer *
+new_z32f_renderbuffer_wrapper(struct gl_context *ctx,
+ struct gl_renderbuffer *dsrb)
{
struct gl_renderbuffer *z32frb;
@@ -915,8 +915,8 @@ put_mono_values_s8(struct gl_context *ctx, struct gl_renderbuffer *s8rb, GLuint
* a stencil renderbuffer.
* \return new stencil renderbuffer
*/
-struct gl_renderbuffer *
-_mesa_new_s8_renderbuffer_wrapper(struct gl_context *ctx, struct gl_renderbuffer *dsrb)
+static struct gl_renderbuffer *
+new_s8_renderbuffer_wrapper(struct gl_context *ctx, struct gl_renderbuffer *dsrb)
{
struct gl_renderbuffer *s8rb;
@@ -957,3 +957,77 @@ _mesa_new_s8_renderbuffer_wrapper(struct gl_context *ctx, struct gl_renderbuffer
return s8rb;
}
+
+
+/**
+ * Update the framebuffer's _DepthBuffer field using the renderbuffer
+ * found at the given attachment index.
+ *
+ * If that attachment points to a combined GL_DEPTH_STENCIL renderbuffer,
+ * create and install a depth wrapper/adaptor.
+ *
+ * \param fb the framebuffer whose _DepthBuffer field to update
+ */
+void
+_mesa_update_depth_buffer(struct gl_context *ctx, struct gl_framebuffer *fb)
+{
+ struct gl_renderbuffer *depthRb =
+ fb->Attachment[BUFFER_DEPTH].Renderbuffer;
+
+ if (depthRb && _mesa_is_format_packed_depth_stencil(depthRb->Format)) {
+ /* The attached depth buffer is a GL_DEPTH_STENCIL renderbuffer */
+ if (!fb->_DepthBuffer
+ || fb->_DepthBuffer->Wrapped != depthRb
+ || _mesa_get_format_base_format(fb->_DepthBuffer->Format) != GL_DEPTH_COMPONENT) {
+ /* need to update wrapper */
+ struct gl_renderbuffer *wrapper;
+
+ if (depthRb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
+ wrapper = new_z32f_renderbuffer_wrapper(ctx, depthRb);
+ }
+ else {
+ wrapper = new_z24_renderbuffer_wrapper(ctx, depthRb);
+ }
+ _mesa_reference_renderbuffer(&fb->_DepthBuffer, wrapper);
+ ASSERT(fb->_DepthBuffer->Wrapped == depthRb);
+ }
+ }
+ else {
+ /* depthRb may be null */
+ _mesa_reference_renderbuffer(&fb->_DepthBuffer, depthRb);
+ }
+}
+
+
+/**
+ * Update the framebuffer's _StencilBuffer field using the renderbuffer
+ * found at the given attachment index.
+ *
+ * If that attachment points to a combined GL_DEPTH_STENCIL renderbuffer,
+ * create and install a stencil wrapper/adaptor.
+ *
+ * \param fb the framebuffer whose _StencilBuffer field to update
+ */
+void
+_mesa_update_stencil_buffer(struct gl_context *ctx, struct gl_framebuffer *fb)
+{
+ struct gl_renderbuffer *stencilRb =
+ fb->Attachment[BUFFER_STENCIL].Renderbuffer;
+
+ if (stencilRb && _mesa_is_format_packed_depth_stencil(stencilRb->Format)) {
+ /* The attached stencil buffer is a GL_DEPTH_STENCIL renderbuffer */
+ if (!fb->_StencilBuffer
+ || fb->_StencilBuffer->Wrapped != stencilRb
+ || _mesa_get_format_base_format(fb->_StencilBuffer->Format) != GL_STENCIL_INDEX) {
+ /* need to update wrapper */
+ struct gl_renderbuffer *wrapper
+ = new_s8_renderbuffer_wrapper(ctx, stencilRb);
+ _mesa_reference_renderbuffer(&fb->_StencilBuffer, wrapper);
+ ASSERT(fb->_StencilBuffer->Wrapped == stencilRb);
+ }
+ }
+ else {
+ /* stencilRb may be null */
+ _mesa_reference_renderbuffer(&fb->_StencilBuffer, stencilRb);
+ }
+}
diff --git a/src/mesa/main/depthstencil.h b/src/mesa/main/depthstencil.h
index c3871d805c7..1cfdd50ae80 100644
--- a/src/mesa/main/depthstencil.h
+++ b/src/mesa/main/depthstencil.h
@@ -27,20 +27,13 @@
#define DEPTHSTENCIL_H
struct gl_context;
+struct gl_framebuffer;
-extern struct gl_renderbuffer *
-_mesa_new_z24_renderbuffer_wrapper(struct gl_context *ctx,
- struct gl_renderbuffer *dsrb);
+void
+_mesa_update_depth_buffer(struct gl_context *ctx, struct gl_framebuffer *fb);
-
-extern struct gl_renderbuffer *
-_mesa_new_z32f_renderbuffer_wrapper(struct gl_context *ctx,
- struct gl_renderbuffer *dsrb);
-
-
-extern struct gl_renderbuffer *
-_mesa_new_s8_renderbuffer_wrapper(struct gl_context *ctx,
- struct gl_renderbuffer *dsrb);
+void
+_mesa_update_stencil_buffer(struct gl_context *ctx, struct gl_framebuffer *fb);
#endif /* DEPTHSTENCIL_H */
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index e30f31a3972..0185622009a 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -600,80 +600,6 @@ _mesa_update_framebuffer_visual(struct gl_context *ctx,
}
-/**
- * Update the framebuffer's _DepthBuffer field using the renderbuffer
- * found at the given attachment index.
- *
- * If that attachment points to a combined GL_DEPTH_STENCIL renderbuffer,
- * create and install a depth wrapper/adaptor.
- *
- * \param fb the framebuffer whose _DepthBuffer field to update
- */
-static void
-update_depth_buffer(struct gl_context *ctx, struct gl_framebuffer *fb)
-{
- struct gl_renderbuffer *depthRb =
- fb->Attachment[BUFFER_DEPTH].Renderbuffer;
-
- if (depthRb && _mesa_is_format_packed_depth_stencil(depthRb->Format)) {
- /* The attached depth buffer is a GL_DEPTH_STENCIL renderbuffer */
- if (!fb->_DepthBuffer
- || fb->_DepthBuffer->Wrapped != depthRb
- || _mesa_get_format_base_format(fb->_DepthBuffer->Format) != GL_DEPTH_COMPONENT) {
- /* need to update wrapper */
- struct gl_renderbuffer *wrapper;
-
- if (depthRb->Format == MESA_FORMAT_Z32_FLOAT_X24S8) {
- wrapper = _mesa_new_z32f_renderbuffer_wrapper(ctx, depthRb);
- }
- else {
- wrapper = _mesa_new_z24_renderbuffer_wrapper(ctx, depthRb);
- }
- _mesa_reference_renderbuffer(&fb->_DepthBuffer, wrapper);
- ASSERT(fb->_DepthBuffer->Wrapped == depthRb);
- }
- }
- else {
- /* depthRb may be null */
- _mesa_reference_renderbuffer(&fb->_DepthBuffer, depthRb);
- }
-}
-
-
-/**
- * Update the framebuffer's _StencilBuffer field using the renderbuffer
- * found at the given attachment index.
- *
- * If that attachment points to a combined GL_DEPTH_STENCIL renderbuffer,
- * create and install a stencil wrapper/adaptor.
- *
- * \param fb the framebuffer whose _StencilBuffer field to update
- */
-static void
-update_stencil_buffer(struct gl_context *ctx, struct gl_framebuffer *fb)
-{
- struct gl_renderbuffer *stencilRb =
- fb->Attachment[BUFFER_STENCIL].Renderbuffer;
-
- if (stencilRb && _mesa_is_format_packed_depth_stencil(stencilRb->Format)) {
- /* The attached stencil buffer is a GL_DEPTH_STENCIL renderbuffer */
- if (!fb->_StencilBuffer
- || fb->_StencilBuffer->Wrapped != stencilRb
- || _mesa_get_format_base_format(fb->_StencilBuffer->Format) != GL_STENCIL_INDEX) {
- /* need to update wrapper */
- struct gl_renderbuffer *wrapper
- = _mesa_new_s8_renderbuffer_wrapper(ctx, stencilRb);
- _mesa_reference_renderbuffer(&fb->_StencilBuffer, wrapper);
- ASSERT(fb->_StencilBuffer->Wrapped == stencilRb);
- }
- }
- else {
- /* stencilRb may be null */
- _mesa_reference_renderbuffer(&fb->_StencilBuffer, stencilRb);
- }
-}
-
-
/*
* Example DrawBuffers scenarios:
*
@@ -812,8 +738,8 @@ update_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)
*/
update_color_draw_buffers(ctx, fb);
update_color_read_buffer(ctx, fb);
- update_depth_buffer(ctx, fb);
- update_stencil_buffer(ctx, fb);
+ _mesa_update_depth_buffer(ctx, fb);
+ _mesa_update_stencil_buffer(ctx, fb);
compute_depth_max(fb);
}