summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker/st_framebuffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/state_tracker/st_framebuffer.c')
-rw-r--r--src/mesa/state_tracker/st_framebuffer.c57
1 files changed, 42 insertions, 15 deletions
diff --git a/src/mesa/state_tracker/st_framebuffer.c b/src/mesa/state_tracker/st_framebuffer.c
index 7d270a3272..0d4474a8b3 100644
--- a/src/mesa/state_tracker/st_framebuffer.c
+++ b/src/mesa/state_tracker/st_framebuffer.c
@@ -33,9 +33,9 @@
#include "main/matrix.h"
#include "main/renderbuffer.h"
#include "main/scissor.h"
-#include "st_public.h"
#include "st_context.h"
#include "st_cb_fbo.h"
+#include "st_public.h"
#include "pipe/p_defines.h"
#include "pipe/p_context.h"
#include "pipe/p_inlines.h"
@@ -49,7 +49,7 @@ st_create_framebuffer( const __GLcontextModes *visual,
uint width, uint height,
void *private)
{
- struct st_framebuffer *stfb = CALLOC_STRUCT(st_framebuffer);
+ struct st_framebuffer *stfb = ST_CALLOC_STRUCT(st_framebuffer);
if (stfb) {
int samples = st_get_msaa();
@@ -153,9 +153,9 @@ void st_resize_framebuffer( struct st_framebuffer *stfb,
}
-void st_unreference_framebuffer( struct st_framebuffer **stfb )
+void st_unreference_framebuffer( struct st_framebuffer *stfb )
{
- _mesa_unreference_framebuffer((struct gl_framebuffer **) stfb);
+ _mesa_unreference_framebuffer((struct gl_framebuffer **) &stfb);
}
@@ -169,6 +169,7 @@ void
st_set_framebuffer_surface(struct st_framebuffer *stfb,
uint surfIndex, struct pipe_surface *surf)
{
+ GET_CURRENT_CONTEXT(ctx);
static const GLuint invalid_size = 9999999;
struct st_renderbuffer *strb;
GLuint width, height, i;
@@ -176,12 +177,23 @@ st_set_framebuffer_surface(struct st_framebuffer *stfb,
assert(surfIndex < BUFFER_COUNT);
strb = st_renderbuffer(stfb->Base.Attachment[surfIndex].Renderbuffer);
- assert(strb);
+
+ /* fail */
+ if (!strb) return;
/* replace the renderbuffer's surface/texture pointers */
pipe_surface_reference( &strb->surface, surf );
pipe_texture_reference( &strb->texture, surf->texture );
+ if (ctx) {
+ /* If ctx isn't set, we've likely not made current yet.
+ * But when we do, we need to start setting this dirty bit
+ * to ensure the renderbuffer attachements are up-to-date
+ * via update_framebuffer.
+ */
+ ctx->st->dirty.st |= ST_NEW_FRAMEBUFFER;
+ }
+
/* update renderbuffer's width/height */
strb->Base.Width = surf->width;
strb->Base.Height = surf->height;
@@ -218,8 +230,8 @@ st_set_framebuffer_surface(struct st_framebuffer *stfb,
/**
* Return the pipe_surface for the given renderbuffer.
*/
-struct pipe_surface *
-st_get_framebuffer_surface(struct st_framebuffer *stfb, uint surfIndex)
+int
+st_get_framebuffer_surface(struct st_framebuffer *stfb, uint surfIndex, struct pipe_surface **surface)
{
struct st_renderbuffer *strb;
@@ -230,13 +242,17 @@ st_get_framebuffer_surface(struct st_framebuffer *stfb, uint surfIndex)
assert(ST_SURFACE_BACK_RIGHT == BUFFER_BACK_RIGHT);
strb = st_renderbuffer(stfb->Base.Attachment[surfIndex].Renderbuffer);
- if (strb)
- return strb->surface;
- return NULL;
+ if (strb) {
+ *surface = strb->surface;
+ return GL_TRUE;
+ }
+
+ *surface = NULL;
+ return GL_FALSE;
}
-struct pipe_texture *
-st_get_framebuffer_texture(struct st_framebuffer *stfb, uint surfIndex)
+int
+st_get_framebuffer_texture(struct st_framebuffer *stfb, uint surfIndex, struct pipe_texture **texture)
{
struct st_renderbuffer *strb;
@@ -247,9 +263,13 @@ st_get_framebuffer_texture(struct st_framebuffer *stfb, uint surfIndex)
assert(ST_SURFACE_BACK_RIGHT == BUFFER_BACK_RIGHT);
strb = st_renderbuffer(stfb->Base.Attachment[surfIndex].Renderbuffer);
- if (strb)
- return strb->texture;
- return NULL;
+ if (strb) {
+ *texture = strb->texture;
+ return GL_TRUE;
+ }
+
+ *texture = NULL;
+ return GL_FALSE;
}
/**
@@ -304,3 +324,10 @@ void *st_framebuffer_private( struct st_framebuffer *stfb )
return stfb->Private;
}
+void st_get_framebuffer_dimensions( struct st_framebuffer *stfb,
+ uint *width,
+ uint *height)
+{
+ *width = stfb->Base.Width;
+ *height = stfb->Base.Height;
+}