Mesa (master): st/mesa: Add support for surfaceless current contexts.

Chia-I Wu olv at kemper.freedesktop.org
Thu Aug 26 08:40:14 UTC 2010


Module: Mesa
Branch: master
Commit: 41c095bf31cedf4f463e315e8dbad8a007985464
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=41c095bf31cedf4f463e315e8dbad8a007985464

Author: Chia-I Wu <olv at lunarg.com>
Date:   Thu Aug 26 00:51:28 2010 +0800

st/mesa: Add support for surfaceless current contexts.

A surfaceless current context is a context that is made current without
draw and read framebuffers.  Such contexts can only render to FBOs.

---

 src/mesa/state_tracker/st_manager.c |   31 +++++++++++++++++++++++++++----
 1 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
index 2afc682..ccce574 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -42,6 +42,7 @@
 #include "main/texstate.h"
 #include "main/texfetch.h"
 #include "main/framebuffer.h"
+#include "main/fbobject.h"
 #include "main/renderbuffer.h"
 #include "st_texture.h"
 
@@ -247,6 +248,9 @@ st_framebuffer_add_renderbuffer(struct st_framebuffer *stfb,
    int samples;
    boolean sw;
 
+   if (!stfb->iface)
+      return FALSE;
+
    /* do not distinguish depth/stencil buffers */
    if (idx == BUFFER_STENCIL)
       idx = BUFFER_DEPTH;
@@ -299,6 +303,10 @@ st_visual_to_context_mode(const struct st_visual *visual,
 {
    memset(mode, 0, sizeof(*mode));
 
+   /* FBO-only context */
+   if (!visual)
+      return;
+
    if (st_visual_have_buffers(visual, ST_ATTACHMENT_BACK_LEFT_MASK))
       mode->doubleBufferMode = GL_TRUE;
    if (st_visual_have_buffers(visual,
@@ -422,6 +430,15 @@ st_framebuffer_create(struct st_framebuffer_iface *stfbi)
    if (!stfb)
       return NULL;
 
+   /* for FBO-only context */
+   if (!stfbi) {
+      GLframebuffer *base = _mesa_get_incomplete_framebuffer();
+
+      stfb->Base = *base;
+
+      return stfb;
+   }
+
    st_visual_to_context_mode(stfbi->visual, &mode);
    _mesa_initialize_window_framebuffer(&stfb->Base, &mode);
 
@@ -693,10 +710,14 @@ st_api_make_current(struct st_api *stapi, struct st_context_iface *stctxi,
             st_framebuffer_validate(stread, st);
 
          /* modify the draw/read buffers of the context */
-         st_visual_to_default_buffer(stdraw->iface->visual,
-               &st->ctx->Color.DrawBuffer[0], NULL);
-         st_visual_to_default_buffer(stread->iface->visual,
-               &st->ctx->Pixel.ReadBuffer, NULL);
+         if (stdraw->iface) {
+            st_visual_to_default_buffer(stdraw->iface->visual,
+                  &st->ctx->Color.DrawBuffer[0], NULL);
+         }
+         if (stread->iface) {
+            st_visual_to_default_buffer(stread->iface->visual,
+                  &st->ctx->Pixel.ReadBuffer, NULL);
+         }
 
          ret = _mesa_make_current(st->ctx, &stdraw->Base, &stread->Base);
       }
@@ -748,6 +769,8 @@ st_manager_flush_frontbuffer(struct st_context *st)
    if (!strb)
       return;
 
+   /* never a dummy fb */
+   assert(stfb->iface);
    stfb->iface->flush_front(stfb->iface, ST_ATTACHMENT_FRONT_LEFT);
 }
 




More information about the mesa-commit mailing list