From: Alan Hourihane Date: Fri, 23 Jan 2009 16:04:57 +0000 (+0000) Subject: gallium: change the st_get_framebuffer_surface/texture functions X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b0d0e53a54ce79f57334942bf0b3762db8a3a7b8;p=mesa.git gallium: change the st_get_framebuffer_surface/texture functions to return TRUE/FALSE if the st_framebuffer is valid, and if it is return the surface/texture in the passed pointer. --- diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index e0b666ffc8d..33dc044ad55 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -1117,7 +1117,7 @@ void XMesaSwapBuffers( XMesaBuffer b ) */ st_notify_swapbuffers(b->stfb); - surf = st_get_framebuffer_surface(b->stfb, ST_SURFACE_BACK_LEFT); + st_get_framebuffer_surface(b->stfb, ST_SURFACE_BACK_LEFT, &surf); if (surf) { driver.display_surface(b, surf); } @@ -1132,12 +1132,13 @@ void XMesaSwapBuffers( XMesaBuffer b ) */ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height ) { - struct pipe_surface *surf_front - = st_get_framebuffer_surface(b->stfb, ST_SURFACE_FRONT_LEFT); - struct pipe_surface *surf_back - = st_get_framebuffer_surface(b->stfb, ST_SURFACE_BACK_LEFT); + struct pipe_surface *surf_front; + struct pipe_surface *surf_back; struct pipe_context *pipe = NULL; /* XXX fix */ + st_get_framebuffer_surface(b->stfb, ST_SURFACE_FRONT_LEFT, &surf_front); + st_get_framebuffer_surface(b->stfb, ST_SURFACE_BACK_LEFT, &surf_back); + if (!surf_front || !surf_back) return; diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index 092cdab2bd6..902bdf94f28 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -149,10 +149,9 @@ update_framebuffer_state( struct st_context *st ) if (st->frontbuffer_status == FRONT_STATUS_COPY_OF_BACK) { /* copy back color buffer to front color buffer */ struct st_framebuffer *stfb = (struct st_framebuffer *) fb; - struct pipe_surface *surf_front - = st_get_framebuffer_surface(stfb, ST_SURFACE_FRONT_LEFT); - struct pipe_surface *surf_back - = st_get_framebuffer_surface(stfb, ST_SURFACE_BACK_LEFT); + struct pipe_surface *surf_front, *surf_back; + (void) st_get_framebuffer_surface(stfb, ST_SURFACE_FRONT_LEFT, &surf_front); + (void) st_get_framebuffer_surface(stfb, ST_SURFACE_BACK_LEFT, &surf_back); st->pipe->surface_copy(st->pipe, FALSE, diff --git a/src/mesa/state_tracker/st_framebuffer.c b/src/mesa/state_tracker/st_framebuffer.c index ea22a943039..0d9c7b97e3d 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" @@ -230,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; @@ -242,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; @@ -259,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; } /** diff --git a/src/mesa/state_tracker/st_public.h b/src/mesa/state_tracker/st_public.h index 88995aa8747..2c578f38cc5 100644 --- a/src/mesa/state_tracker/st_public.h +++ b/src/mesa/state_tracker/st_public.h @@ -80,11 +80,11 @@ void st_set_framebuffer_surface(struct st_framebuffer *stfb, void st_get_framebuffer_dimensions( struct st_framebuffer *stfb, uint *width, uint *height); -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 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); void *st_framebuffer_private( struct st_framebuffer *stfb );