From 32aab0863c32338d7caa5c22b9c595cb76201574 Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Sat, 1 Dec 2012 11:44:24 -0600 Subject: [PATCH] swpipe: Flush color buffers (and z buffer?) * Take bitmap passed via private pointer and copy data into context BBitmap * Not 100% sure if z buffer needs flushed as well. --- src/add-ons/opengl/swpipe/GalliumContext.cpp | 35 ++++++++++++++------ src/add-ons/opengl/swpipe/SoftwareWinsys.cpp | 16 ++++++--- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/src/add-ons/opengl/swpipe/GalliumContext.cpp b/src/add-ons/opengl/swpipe/GalliumContext.cpp index 8bf28b842ee..d5e3de6bea6 100644 --- a/src/add-ons/opengl/swpipe/GalliumContext.cpp +++ b/src/add-ons/opengl/swpipe/GalliumContext.cpp @@ -464,23 +464,36 @@ GalliumContext::SwapBuffers(context_id contextID) return B_ERROR; } - //pipe_mutex_lock(context->draw->mutex); - // TODO: Where did st_notify_swapbuffers go? //st_notify_swapbuffers(context->draw->stfb); - // TODO: Where did st_get_framebuffer_surface go? - //struct pipe_surface *surface; - //st_get_framebuffer_surface(context->draw->stfb, ST_SURFACE_BACK_LEFT, - // &surface); - context->st->flush(context->st, ST_FLUSH_FRONT, NULL); - // TODO: Flush the frontbuffer! - //hsp_dev->hsp_winsys->flush_frontbuffer(hsp_dev->screen, surface, - // context->bitmap); + // I'm not 100% sold on this... but Gallium does it quite often. + struct st_context *stContext = (struct st_context*)context->st; + + unsigned nColorBuffers = stContext->state.framebuffer.nr_cbufs; + for (unsigned i = 0; i < nColorBuffers; i++) { + pipe_surface* surface = stContext->state.framebuffer.cbufs[i]; + if (!surface) { + ERROR("%s: color buffer %d invalid!\n", __func__, i); + continue; + } + + TRACE("%s: Flushing color buffer #%d\n", __func__, i); - //pipe_mutex_unlock(context->draw->mutex); + // We pass our destination bitmap to flush_fronbuffer which passes it + // to the private winsys display call. + fScreen->flush_frontbuffer(fScreen, surface->texture, 0, 0, + context->bitmap); + } + + #if 0 + // TODO... should we flush the z stencil buffer? + pipe_surface* zSurface = stContext->state.framebuffer.zsbuf; + fScreen->flush_frontbuffer(fScreen, surface->texture, 0, 0, + context->bitmap); + #endif return true; } diff --git a/src/add-ons/opengl/swpipe/SoftwareWinsys.cpp b/src/add-ons/opengl/swpipe/SoftwareWinsys.cpp index efcdcbbfc9f..1cdee948245 100644 --- a/src/add-ons/opengl/swpipe/SoftwareWinsys.cpp +++ b/src/add-ons/opengl/swpipe/SoftwareWinsys.cpp @@ -169,12 +169,18 @@ hook_winsys_displaytarget_display(struct sw_winsys* winsys, { CALLED(); - //struct haiku_displaytarget* haikuDisplayTarget - // = cast_haiku_displaytarget(displayTarget); + if (!contextPrivate) { + ERROR("%s: Passed invalid private pointer!\n", __func__); + return; + } + + Bitmap* bitmap = (Bitmap*)contextPrivate; + + struct haiku_displaytarget* haikuDisplayTarget + = cast_haiku_displaytarget(displayTarget); - // GDI copies data from haikuDisplayTarget->data into - // a Bitmap casted from contextPrivate.. need to investigate - // this. + copy_bitmap_bits(bitmap, haikuDisplayTarget->data, + haikuDisplayTarget->size); return; }