summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2008-06-18 10:20:13 -0600
committerBrian Paul <[email protected]>2008-06-18 10:20:13 -0600
commit9a2c70f0754b275e7ec370bbbff3d81b48bfd476 (patch)
tree412de9b3f30e2b1c3bae247e7d3fa1bc7ae0c96d /src/mesa/state_tracker
parent19f872f2ecb45d5e95ccd2b434a88781c9b4f451 (diff)
gallium: added new st_set_framebuffer_surface()
This allows the winsys to explicitly specify gallium surfaces for a framebuffer object.
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_framebuffer.c56
-rw-r--r--src/mesa/state_tracker/st_public.h3
2 files changed, 59 insertions, 0 deletions
diff --git a/src/mesa/state_tracker/st_framebuffer.c b/src/mesa/state_tracker/st_framebuffer.c
index 7099d78eb8c..7e6db467576 100644
--- a/src/mesa/state_tracker/st_framebuffer.c
+++ b/src/mesa/state_tracker/st_framebuffer.c
@@ -38,6 +38,7 @@
#include "st_cb_fbo.h"
#include "pipe/p_defines.h"
#include "pipe/p_context.h"
+#include "pipe/p_inlines.h"
struct st_framebuffer *
@@ -155,6 +156,61 @@ void st_unreference_framebuffer( struct st_framebuffer **stfb )
/**
+ * Set/replace a framebuffer surface.
+ * The user of the state tracker can use this instead of
+ * st_resize_framebuffer() to provide new surfaces when a window is resized.
+ */
+void
+st_set_framebuffer_surface(struct st_framebuffer *stfb,
+ uint surfIndex, struct pipe_surface *surf)
+{
+ static const GLuint invalid_size = 9999999;
+ struct st_renderbuffer *strb;
+ GLuint width, height, i;
+
+ assert(surfIndex < BUFFER_COUNT);
+
+ strb = st_renderbuffer(stfb->Base.Attachment[surfIndex].Renderbuffer);
+ assert(strb);
+
+ /* replace the renderbuffer's surface/texture pointers */
+ pipe_surface_reference( &strb->surface, surf );
+ pipe_texture_reference( &strb->texture, surf->texture );
+
+ /* update renderbuffer's width/height */
+ strb->Base.Width = surf->width;
+ strb->Base.Height = surf->height;
+
+ /* Try to update the framebuffer's width/height from the renderbuffer
+ * sizes. Before we start drawing, all the rbs _should_ be the same size.
+ */
+ width = height = invalid_size;
+ for (i = 0; i < BUFFER_COUNT; i++) {
+ if (stfb->Base.Attachment[i].Renderbuffer) {
+ if (width == invalid_size) {
+ width = stfb->Base.Attachment[i].Renderbuffer->Width;
+ height = stfb->Base.Attachment[i].Renderbuffer->Height;
+ }
+ else if (width != stfb->Base.Attachment[i].Renderbuffer->Width ||
+ height != stfb->Base.Attachment[i].Renderbuffer->Height) {
+ /* inconsistant renderbuffer sizes, bail out */
+ return;
+ }
+ }
+ }
+
+ if (width != invalid_size) {
+ /* OK, the renderbuffers are of a consistant size, so update the
+ * parent framebuffer's size.
+ */
+ stfb->Base.Width = width;
+ stfb->Base.Height = height;
+ }
+}
+
+
+
+/**
* Return the pipe_surface for the given renderbuffer.
*/
struct pipe_surface *
diff --git a/src/mesa/state_tracker/st_public.h b/src/mesa/state_tracker/st_public.h
index a0dab33257f..b99984215f7 100644
--- a/src/mesa/state_tracker/st_public.h
+++ b/src/mesa/state_tracker/st_public.h
@@ -68,6 +68,9 @@ struct st_framebuffer *st_create_framebuffer( const __GLcontextModes *visual,
void st_resize_framebuffer( struct st_framebuffer *stfb,
uint width, uint height );
+void st_set_framebuffer_surface(struct st_framebuffer *stfb,
+ uint surfIndex, struct pipe_surface *surf);
+
struct pipe_surface *st_get_framebuffer_surface(struct st_framebuffer *stfb,
uint surfIndex);