diff options
Diffstat (limited to 'src/gallium/targets')
4 files changed, 52 insertions, 37 deletions
diff --git a/src/gallium/targets/haiku-softpipe/GalliumContext.cpp b/src/gallium/targets/haiku-softpipe/GalliumContext.cpp index 62db7e2c39d..f9d7dfc8734 100644 --- a/src/gallium/targets/haiku-softpipe/GalliumContext.cpp +++ b/src/gallium/targets/haiku-softpipe/GalliumContext.cpp @@ -15,7 +15,6 @@ #include "bitmap_wrapper.h" extern "C" { #include "glapi/glapi.h" -#include "main/viewport.h" #include "pipe/p_format.h" #include "state_tracker/st_cb_fbo.h" #include "state_tracker/st_cb_flush.h" @@ -24,6 +23,7 @@ extern "C" { #include "state_tracker/st_manager.h" #include "state_tracker/sw_winsys.h" #include "sw/hgl/hgl_sw_winsys.h" +#include "util/u_atomic.h" #include "util/u_memory.h" #include "target-helpers/inline_sw_helper.h" @@ -120,6 +120,7 @@ GalliumContext::CreateContext(Bitmap *bitmap) // Set up the initial things our context needs context->bitmap = bitmap; context->colorSpace = get_bitmap_color_space(bitmap); + context->screen = fScreen; context->draw = NULL; context->read = NULL; context->st = NULL; @@ -131,7 +132,7 @@ GalliumContext::CreateContext(Bitmap *bitmap) } // Create state_tracker manager - context->manager = hgl_create_st_manager(fScreen); + context->manager = hgl_create_st_manager(context); // Create state tracker visual context->stVisual = hgl_create_st_visual(fOptions); @@ -305,14 +306,14 @@ GalliumContext::SetCurrentContext(Bitmap *bitmap, context_id contextID) api->make_current(context->api, context->st, context->draw->stfbi, context->read->stfbi); - if (context->textures[ST_ATTACHMENT_BACK_LEFT] - && context->textures[ST_ATTACHMENT_DEPTH_STENCIL] - && context->postProcess) { - TRACE("Postprocessing textures...\n"); - pp_init_fbos(context->postProcess, - context->textures[ST_ATTACHMENT_BACK_LEFT]->width0, - context->textures[ST_ATTACHMENT_BACK_LEFT]->height0); - } + //if (context->textures[ST_ATTACHMENT_BACK_LEFT] + // && context->textures[ST_ATTACHMENT_DEPTH_STENCIL] + // && context->postProcess) { + // TRACE("Postprocessing textures...\n"); + // pp_init_fbos(context->postProcess, + // context->textures[ST_ATTACHMENT_BACK_LEFT]->width0, + // context->textures[ST_ATTACHMENT_BACK_LEFT]->height0); + //} context->bitmap = bitmap; //context->st->pipe->priv = context; @@ -369,18 +370,38 @@ GalliumContext::SwapBuffers(context_id contextID) } -void -GalliumContext::ResizeViewport(int32 width, int32 height) +bool +GalliumContext::Validate(uint32 width, uint32 height) { CALLED(); - for (context_id i = 0; i < CONTEXT_MAX; i++) { - if (fContext[i] && fContext[i]->st) { - struct st_context *stContext = (struct st_context*)fContext[i]->st; - // TODO: _mesa_set_viewport needs to be removed for something st_api? - _mesa_set_viewport(stContext->ctx, 0, 0, 0, width, height); - st_manager_validate_framebuffers(stContext); - } + + if (!fContext[fCurrentContext]) { + return false; + } + + if (fContext[fCurrentContext]->width != width + || fContext[fCurrentContext]->height != height) { + Invalidate(width, height); + return false; } + return true; +} + + +void +GalliumContext::Invalidate(uint32 width, uint32 height) +{ + CALLED(); + + assert(fContext[fCurrentContext]); + + // Update st_context dimensions + fContext[fCurrentContext]->width = width; + fContext[fCurrentContext]->height = height; + + // Is this the best way to invalidate? + p_atomic_inc(&fContext[fCurrentContext]->read->stfbi->stamp); + p_atomic_inc(&fContext[fCurrentContext]->draw->stfbi->stamp); } diff --git a/src/gallium/targets/haiku-softpipe/GalliumContext.h b/src/gallium/targets/haiku-softpipe/GalliumContext.h index 6f8a4d0bda3..b50d52895fc 100644 --- a/src/gallium/targets/haiku-softpipe/GalliumContext.h +++ b/src/gallium/targets/haiku-softpipe/GalliumContext.h @@ -40,7 +40,9 @@ public: context_id contextID); status_t SwapBuffers(context_id contextID); - void ResizeViewport(int32 width, int32 height); + + bool Validate(uint32 width, uint32 height); + void Invalidate(uint32 width, uint32 height); private: status_t CreateScreen(); diff --git a/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp b/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp index 77cafd4b935..18cb1ac2e19 100644 --- a/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp +++ b/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp @@ -54,7 +54,7 @@ SoftwareRenderer::SoftwareRenderer(BGLView *view, ulong options, CALLED(); // Disable double buffer for the moment. - options &= ~BGL_DOUBLE; + //options &= ~BGL_DOUBLE; // Initialize the "Haiku Software GL Pipe" time_t beg; @@ -72,8 +72,6 @@ SoftwareRenderer::SoftwareRenderer(BGLView *view, ulong options, fWidth = (GLint)b.IntegerWidth(); fHeight = (GLint)b.IntegerHeight(); - fNewWidth = fWidth; - fNewHeight = fHeight; _AllocateBitmap(); @@ -115,19 +113,16 @@ SoftwareRenderer::LockGL() BAutolock lock(fInfoLocker); if (fDirectModeEnabled && fInfo != NULL) { - fNewWidth = fInfo->window_bounds.right - fInfo->window_bounds.left; - fNewHeight = fInfo->window_bounds.bottom - fInfo->window_bounds.top; + fWidth = fInfo->window_bounds.right - fInfo->window_bounds.left; + fHeight = fInfo->window_bounds.bottom - fInfo->window_bounds.top; } - if (fBitmap && cs == fColorSpace && fNewWidth == fWidth - && fNewHeight == fHeight) { + if (fBitmap && cs == fColorSpace && fContextObj->Validate(fWidth, fHeight)) { fContextObj->SetCurrentContext(fBitmap, fContextID); return; } fColorSpace = cs; - fWidth = fNewWidth; - fHeight = fNewHeight; _AllocateBitmap(); fContextObj->SetCurrentContext(fBitmap, fContextID); @@ -329,8 +324,8 @@ SoftwareRenderer::FrameResized(float width, float height) TRACE("%s: %f x %f\n", __func__, width, height); BAutolock lock(fInfoLocker); - fNewWidth = (GLuint)width; - fNewHeight = (GLuint)height; + fWidth = (GLuint)width; + fHeight = (GLuint)height; } @@ -341,8 +336,9 @@ SoftwareRenderer::_AllocateBitmap() // allocate new size of back buffer bitmap BAutolock lock(fInfoLocker); - delete fBitmap; - fBitmap = NULL; + if (fBitmap) + delete fBitmap; + if (fWidth < 1 || fHeight < 1) { TRACE("%s: Can't allocate bitmap of %dx%d\n", __func__, fWidth, fHeight); @@ -358,8 +354,6 @@ SoftwareRenderer::_AllocateBitmap() TRACE("%s: New bitmap size: %" B_PRId32 " x %" B_PRId32 "\n", __func__, fBitmap->Bounds().IntegerWidth(), fBitmap->Bounds().IntegerHeight()); - fContextObj->ResizeViewport(fWidth, fHeight); - #if 0 // debug.. void *data = fBitmap->Bits(); diff --git a/src/gallium/targets/haiku-softpipe/SoftwareRenderer.h b/src/gallium/targets/haiku-softpipe/SoftwareRenderer.h index 8427ce171fe..10eaef870f3 100644 --- a/src/gallium/targets/haiku-softpipe/SoftwareRenderer.h +++ b/src/gallium/targets/haiku-softpipe/SoftwareRenderer.h @@ -51,8 +51,6 @@ private: ulong fOptions; GLuint fWidth; GLuint fHeight; - GLuint fNewWidth; - GLuint fNewHeight; color_space fColorSpace; }; |