summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2010-08-26 00:51:28 +0800
committerChia-I Wu <[email protected]>2010-08-26 16:40:01 +0800
commit41c095bf31cedf4f463e315e8dbad8a007985464 (patch)
tree5a54175c79f937dd38699b958d50cb89f86b944f /src
parentc5279fd795eb4a0445285d5a9815de68b0c77626 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/state_tracker/st_manager.c31
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 2afc682e0b1..ccce574c364 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);
}