diff options
author | Thomas White <taw@bitwiz.org.uk> | 2009-04-21 01:19:17 +0100 |
---|---|---|
committer | Martin Jansa <Martin.Jansa@gmail.com> | 2010-02-18 15:39:22 +0100 |
commit | fac814d6b1b7f541acb1e9e45c01c41cbcef3aae (patch) | |
tree | e4836f00abad69764e2f354e8d24e2c08b58ad81 /src | |
parent | dcfcbf3be0dd2cbcc37e63359427295e938ae006 (diff) |
More framebuffer stuff
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/glamo/glamo_context.c | 112 | ||||
-rw-r--r-- | src/mesa/drivers/dri/glamo/glamo_fbo.c | 16 | ||||
-rw-r--r-- | src/mesa/drivers/dri/glamo/glamo_fbo.h | 2 |
3 files changed, 122 insertions, 8 deletions
diff --git a/src/mesa/drivers/dri/glamo/glamo_context.c b/src/mesa/drivers/dri/glamo/glamo_context.c index f3c1dd32b8..2bc89c2e92 100644 --- a/src/mesa/drivers/dri/glamo/glamo_context.c +++ b/src/mesa/drivers/dri/glamo/glamo_context.c @@ -25,7 +25,9 @@ #include "dri_util.h" +#include "drirenderbuffer.h" #include "utils.h" + #include "swrast/swrast.h" #include "swrast_setup/swrast_setup.h" #include "drivers/common/driverfuncs.h" @@ -40,10 +42,25 @@ #include "glamo_fbo.h" #include "glamo_tris.h" +#include <glamo_bo.h> +#include <glamo_bo_gem.h> +#include <glamo_drm.h> + #define DRIVER_DATE "20090402" +static inline struct glamo_renderbuffer *glamo_get_renderbuffer( + struct gl_framebuffer *fb, + int att_index) +{ + if ( att_index >= 0 ) + return glamo_renderbuffer(fb->Attachment[att_index].Renderbuffer); + else + return NULL; +} + + static const GLubyte *glamoGetString(GLcontext *ctx, GLenum name) { static char buffer[128]; @@ -164,13 +181,14 @@ static void glamo_update_renderbuffers(__DRIcontext *context, unsigned int attachments[10]; __DRIbuffer *buffers; __DRIscreen *screen; - struct glamo_renderbuffer *grb; int i, count; struct glamo_framebuffer *draw; glamoContextPtr glamo; char *regname; + struct glamo_bo *bo; + struct glamo_bo *depth_bo; - fprintf(stderr, "enter %s, drawable %p\n", __func__, drawable); + fprintf(stderr, "Enter %s, drawable %p\n", __func__, drawable); draw = drawable->driverPrivate; screen = context->driScreenPriv; @@ -180,20 +198,100 @@ static void glamo_update_renderbuffers(__DRIcontext *context, attachments[i++] = __DRI_BUFFER_FRONT_LEFT; if ( draw->color_rb[1] ) attachments[i++] = __DRI_BUFFER_BACK_LEFT; -printf("screen = %p\n", screen); fflush(stdout); -printf("screen->dri2.loader = %p\n", screen->dri2.loader); fflush(stdout); -printf("screen->dri2.loader->getBuffers = %p\n", screen->dri2.loader->getBuffers); fflush(stdout); + buffers = (*screen->dri2.loader->getBuffers)(drawable, &drawable->w, &drawable->h, attachments, i, &count, drawable->loaderPrivate); -printf("b\n"); fflush(stdout); + if (buffers == NULL) return; -printf("c\n"); fflush(stdout); printf("%i, %i\n", drawable->w, drawable->h); + + /* Set one cliprect to cover the whole drawable */ + drawable->x = 0; + drawable->y = 0; + drawable->backX = 0; + drawable->backY = 0; + drawable->numClipRects = 1; + drawable->pClipRects[0].x1 = 0; + drawable->pClipRects[0].y1 = 0; + drawable->pClipRects[0].x2 = drawable->w; + drawable->pClipRects[0].y2 = drawable->h; + drawable->numBackClipRects = 1; + drawable->pBackClipRects[0].x1 = 0; + drawable->pBackClipRects[0].y1 = 0; + drawable->pBackClipRects[0].x2 = drawable->w; + drawable->pBackClipRects[0].y2 = drawable->h; + + /* For each attachment */ + for ( i=0; i<count; i++ ) { + + struct glamo_renderbuffer *grb; + + switch ( buffers[i].attachment ) { + case __DRI_BUFFER_FRONT_LEFT: + grb = draw->color_rb[0]; + regname = "dri2 front buffer"; + break; + case __DRI_BUFFER_BACK_LEFT: + grb = draw->color_rb[1]; + regname = "dri2 back buffer"; + break; + case __DRI_BUFFER_DEPTH: + grb = glamo_get_renderbuffer(&draw->base, BUFFER_DEPTH); + regname = "dri2 depth buffer"; + break; + case __DRI_BUFFER_STENCIL: + grb = glamo_get_renderbuffer(&draw->base, BUFFER_STENCIL); + regname = "dri2 stencil buffer"; + break; + case __DRI_BUFFER_ACCUM: + default: + fprintf(stderr, + "unhandled buffer attach event, attachment type %d\n", + buffers[i].attachment); + return; + } + + if ( grb == NULL ) continue; + + if ( grb->bo ) { + uint32_t name = glamo_gem_name_bo(grb->bo); + if ( name == buffers[i].name ) continue; + } + + fprintf(stderr, "attaching buffer %s, %d, at %d, cpp %d, pitch %d\n", + regname, buffers[i].name, buffers[i].attachment, + buffers[i].cpp, buffers[i].pitch); + + grb->cpp = buffers[i].cpp; + grb->pitch = buffers[i].pitch; + grb->width = drawable->w; + grb->height = drawable->h; + + bo = glamo_bo_open(glamo->glamoScreen->bom, + buffers[i].name, + 0, + 0, + GLAMO_GEM_DOMAIN_VRAM, + buffers[i].flags); + if ( bo == NULL ) { + fprintf(stderr, "failed to attach %s %d\n", regname, buffers[i].name); + } + + if ( buffers[i].attachment == __DRI_BUFFER_DEPTH ) { + if ( draw->base.Visual.depthBits == 16 ) grb->cpp = 2; + depth_bo = bo; + } + + glamo_renderbuffer_set_bo(grb, bo); + glamo_bo_unref(bo); + } + + driUpdateFramebufferSize(glamo->glCtx, drawable); } diff --git a/src/mesa/drivers/dri/glamo/glamo_fbo.c b/src/mesa/drivers/dri/glamo/glamo_fbo.c index 13de654577..4da7dc5ad9 100644 --- a/src/mesa/drivers/dri/glamo/glamo_fbo.c +++ b/src/mesa/drivers/dri/glamo/glamo_fbo.c @@ -32,6 +32,9 @@ #include "main/context.h" #include "dri_util.h" +/* This comes from libdrm_glamo */ +#include <glamo_bo.h> + #include "glamo_fbo.h" @@ -42,7 +45,7 @@ static void glamo_delete_renderbuffer(struct gl_renderbuffer *rb) ASSERT(grb); if ( grb && grb->bo ) { -// glamo_bo_unref(grb->bo); + glamo_bo_unref(grb->bo); } _mesa_free(grb); } @@ -117,4 +120,15 @@ struct glamo_renderbuffer *glamo_create_renderbuffer(GLenum format, } +void glamo_renderbuffer_set_bo(struct glamo_renderbuffer *grb, + struct glamo_bo *bo) +{ + struct glamo_bo *old; + old = grb->bo; + grb->bo = bo; + glamo_bo_ref(bo); + if ( old ) glamo_bo_unref(old); +} + + /* kate: space-indent on; indent-width 3; mixedindent off; indent-mode cstyle; */ diff --git a/src/mesa/drivers/dri/glamo/glamo_fbo.h b/src/mesa/drivers/dri/glamo/glamo_fbo.h index 2da6633331..52e1ceab42 100644 --- a/src/mesa/drivers/dri/glamo/glamo_fbo.h +++ b/src/mesa/drivers/dri/glamo/glamo_fbo.h @@ -69,6 +69,8 @@ static inline struct glamo_renderbuffer extern struct glamo_renderbuffer *glamo_create_renderbuffer(GLenum format, __DRIdrawablePrivate *driDrawPriv); +extern void glamo_renderbuffer_set_bo(struct glamo_renderbuffer *grb, + struct glamo_bo *bo); #endif /* __GLAMO_FBO_H */ |