summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexander von Gluck IV <[email protected]>2014-12-29 21:51:46 +0000
committerAlexander von Gluck IV <[email protected]>2015-01-01 21:33:36 -0500
commit290553b6d637779cb733549a582230437545d335 (patch)
treeef0d08cccb015fd247279815afb3c08b0ade74c7 /src
parentb77eaafcdc1b9f050d44d46608e542a9e593da3e (diff)
gallium/state_tracker: Rewrite Haiku's state tracker
* More gallium-like * Leverage stamps properly and don't call mesa functions
Diffstat (limited to 'src')
-rw-r--r--src/gallium/state_trackers/hgl/hgl.c338
-rw-r--r--src/gallium/state_trackers/hgl/hgl_context.h13
-rw-r--r--src/gallium/targets/haiku-softpipe/GalliumContext.cpp59
-rw-r--r--src/gallium/targets/haiku-softpipe/GalliumContext.h4
-rw-r--r--src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp24
-rw-r--r--src/gallium/targets/haiku-softpipe/SoftwareRenderer.h2
-rw-r--r--src/gallium/winsys/sw/hgl/hgl_sw_winsys.c24
7 files changed, 274 insertions, 190 deletions
diff --git a/src/gallium/state_trackers/hgl/hgl.c b/src/gallium/state_trackers/hgl/hgl.c
index 0b302903c04..b75dc26bc39 100644
--- a/src/gallium/state_trackers/hgl/hgl.c
+++ b/src/gallium/state_trackers/hgl/hgl.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2012-2013, Haiku, Inc. All Rights Reserved.
+ * Copyright 2012-2014, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -10,12 +10,11 @@
#include "GLView.h"
-#include "main/context.h"
-#include "main/framebuffer.h"
-#include "main/renderbuffer.h"
#include "pipe/p_format.h"
#include "util/u_atomic.h"
+#include "util/u_format.h"
#include "util/u_memory.h"
+#include "util/u_inlines.h"
#include "hgl_context.h"
@@ -30,18 +29,38 @@
#define ERROR(x...) printf("hgl:state_tracker: " x)
+// Perform a safe void to hgl_context cast
+static INLINE struct hgl_context*
+hgl_st_context(struct st_context_iface *stctxi)
+{
+ struct hgl_context* context;
+ assert(stctxi);
+ context = (struct hgl_context*)stctxi->st_manager_private;
+ assert(context);
+ return context;
+}
+
+
+// Perform a safe void to hgl_buffer cast
+static INLINE struct hgl_buffer*
+hgl_st_framebuffer(struct st_framebuffer_iface *stfbi)
+{
+ struct hgl_buffer* buffer;
+ assert(stfbi);
+ buffer = (struct hgl_buffer*)stfbi->st_manager_private;
+ assert(buffer);
+ return buffer;
+}
+
+
static boolean
-hgl_st_framebuffer_flush_front(struct st_context_iface *stctx,
- struct st_framebuffer_iface* stfb, enum st_attachment_type statt)
+hgl_st_framebuffer_flush_front(struct st_context_iface *stctxi,
+ struct st_framebuffer_iface* stfbi, enum st_attachment_type statt)
{
CALLED();
- struct hgl_context* context = (struct hgl_context*)stfb->st_manager_private;
-
- if (!context) {
- ERROR("%s: Couldn't obtain valid hgl_context!\n", __func__);
- return FALSE;
- }
+ //struct hgl_context* context = hgl_st_context(stctxi);
+ //struct hgl_buffer* buffer = hgl_st_context(stfbi);
#if 0
struct stw_st_framebuffer *stwfb = stw_st_framebuffer(stfb);
@@ -56,77 +75,125 @@ hgl_st_framebuffer_flush_front(struct st_context_iface *stctx,
}
+static boolean
+hgl_st_framebuffer_validate_textures(struct st_framebuffer_iface *stfbi,
+ unsigned width, unsigned height, unsigned mask)
+{
+ struct hgl_buffer* buffer;
+ enum st_attachment_type i;
+ struct pipe_resource templat;
+
+ CALLED();
+
+ buffer = hgl_st_framebuffer(stfbi);
+
+ if (buffer->width != width || buffer->height != height) {
+ for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
+ pipe_resource_reference(&buffer->textures[i], NULL);
+ }
+
+ memset(&templat, 0, sizeof(templat));
+ templat.target = buffer->target;
+ templat.width0 = width;
+ templat.height0 = height;
+ templat.depth0 = 1;
+ templat.array_size = 1;
+ templat.last_level = 0;
+
+ for (i = 0; i < ST_ATTACHMENT_COUNT; i++) {
+ enum pipe_format format;
+ unsigned bind;
+
+ switch (i) {
+ case ST_ATTACHMENT_FRONT_LEFT:
+ case ST_ATTACHMENT_BACK_LEFT:
+ case ST_ATTACHMENT_FRONT_RIGHT:
+ case ST_ATTACHMENT_BACK_RIGHT:
+ format = buffer->visual->color_format;
+ bind = PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_RENDER_TARGET;
+ break;
+ case ST_ATTACHMENT_DEPTH_STENCIL:
+ format = buffer->visual->depth_stencil_format;
+ bind = PIPE_BIND_DEPTH_STENCIL;
+ break;
+ default:
+ format = PIPE_FORMAT_NONE;
+ bind = 0;
+ break;
+ }
+
+ if (format != PIPE_FORMAT_NONE) {
+ templat.format = format;
+ templat.bind = bind;
+ buffer->textures[i] = buffer->screen->resource_create(buffer->screen,
+ &templat);
+ if (!buffer->textures[i])
+ return FALSE;
+ }
+ }
+
+ buffer->width = width;
+ buffer->height = height;
+ buffer->mask = mask;
+
+ return TRUE;
+}
+
+
/**
* Called by the st manager to validate the framebuffer (allocate
* its resources).
*/
static boolean
-hgl_st_framebuffer_validate(struct st_context_iface *stctx,
+hgl_st_framebuffer_validate(struct st_context_iface *stctxi,
struct st_framebuffer_iface *stfbi, const enum st_attachment_type *statts,
unsigned count, struct pipe_resource **out)
{
+ struct hgl_context* context;
+ struct hgl_buffer* buffer;
+ unsigned stAttachmentMask, newMask;
+ unsigned i;
+ boolean resized;
+
CALLED();
- if (!stfbi) {
- ERROR("%s: Invalid st framebuffer interface!\n", __func__);
- return FALSE;
- }
+ context = hgl_st_context(stctxi);
+ buffer = hgl_st_framebuffer(stfbi);
- struct hgl_context* context = (struct hgl_context*)stfbi->st_manager_private;
+ //int32 width = 0;
+ //int32 height = 0;
+ //get_bitmap_size(context->bitmap, &width, &height);
- if (!context) {
- ERROR("%s: Couldn't obtain valid hgl_context!\n", __func__);
- return FALSE;
- }
+ // Build mask of current attachments
+ stAttachmentMask = 0;
+ for (i = 0; i < count; i++)
+ stAttachmentMask |= 1 << statts[i];
- int32 width = 0;
- int32 height = 0;
- get_bitmap_size(context->bitmap, &width, &height);
+ newMask = stAttachmentMask & ~buffer->mask;
- struct pipe_resource templat;
- memset(&templat, 0, sizeof(templat));
- templat.target = PIPE_TEXTURE_RECT;
- templat.width0 = width;
- templat.height0 = height;
- templat.depth0 = 1;
- templat.array_size = 1;
- templat.usage = PIPE_USAGE_DEFAULT;
-
- if (context->stVisual && context->manager && context->manager->screen) {
- TRACE("%s: Updating resources\n", __func__);
- for (unsigned i = 0; i < count; i++) {
- enum pipe_format format = PIPE_FORMAT_NONE;
- unsigned bind = 0;
-
- switch(statts[i]) {
- case ST_ATTACHMENT_FRONT_LEFT:
- case ST_ATTACHMENT_BACK_LEFT:
- format = context->stVisual->color_format;
- bind = PIPE_BIND_DISPLAY_TARGET
- | PIPE_BIND_RENDER_TARGET;
- break;
- case ST_ATTACHMENT_DEPTH_STENCIL:
- format = context->stVisual->depth_stencil_format;
- bind = PIPE_BIND_DEPTH_STENCIL;
- break;
- case ST_ATTACHMENT_ACCUM:
- format = context->stVisual->accum_format;
- bind = PIPE_BIND_RENDER_TARGET;
- break;
- default:
- format = PIPE_FORMAT_NONE;
- break;
- }
-
- if (format != PIPE_FORMAT_NONE) {
- templat.format = format;
- templat.bind = bind;
-
- struct pipe_screen* screen = context->manager->screen;
- context->textures[i] = screen->resource_create(screen, &templat);
- out[i] = context->textures[i];
- }
- }
+ resized = (buffer->width != context->width)
+ || (buffer->height != context->height);
+
+ if (resized || newMask) {
+ boolean ret;
+ TRACE("%s: resize event. old: %d x %d; new: %d x %d\n", __func__,
+ buffer->width, buffer->height, context->width, context->height);
+
+ ret = hgl_st_framebuffer_validate_textures(stfbi,
+ context->width, context->height, stAttachmentMask);
+
+ if (!ret)
+ return ret;
+
+ // TODO: Simply update attachments
+ //if (!resized) {
+
+ //}
+ }
+
+ for (i = 0; i < count; i++) {
+ out[i] = NULL;
+ pipe_resource_reference(&out[i], buffer->textures[statts[i]]);
}
return TRUE;
@@ -140,9 +207,6 @@ hgl_st_manager_get_param(struct st_manager *smapi, enum st_manager_param param)
switch (param) {
case ST_MANAGER_BROKEN_INVALIDATE:
- TRACE("%s: TODO: How should we handle BROKEN_INVALIDATE calls?\n",
- __func__);
- // For now we force validation of the framebuffer.
return 1;
}
@@ -156,53 +220,58 @@ hgl_st_manager_get_param(struct st_manager *smapi, enum st_manager_param param)
struct hgl_buffer *
hgl_create_st_framebuffer(struct hgl_context* context)
{
+ struct hgl_buffer *buffer;
CALLED();
- struct hgl_buffer *buffer = CALLOC_STRUCT(hgl_buffer);
-
+ // Our requires before creating a framebuffer
assert(context);
+ assert(context->screen);
assert(context->stVisual);
- if (buffer) {
- // Copy context visual into framebuffer
- memcpy(&buffer->visual, context->stVisual, sizeof(struct st_visual));
+ buffer = CALLOC_STRUCT(hgl_buffer);
+ assert(buffer);
- // calloc and configure our st_framebuffer interface
- buffer->stfbi = CALLOC_STRUCT(st_framebuffer_iface);
- if (!buffer->stfbi) {
- ERROR("%s: Couldn't calloc framebuffer!\n", __func__);
- return NULL;
- }
+ // calloc and configure our st_framebuffer interface
+ buffer->stfbi = CALLOC_STRUCT(st_framebuffer_iface);
+ assert(buffer->stfbi);
- struct st_framebuffer_iface* stfbi = buffer->stfbi;
- p_atomic_set(&stfbi->stamp, 1);
- stfbi->flush_front = hgl_st_framebuffer_flush_front;
- stfbi->validate = hgl_st_framebuffer_validate;
- stfbi->st_manager_private = (void*)context;
- stfbi->visual = &buffer->visual;
+ // Prepare our buffer
+ buffer->visual = context->stVisual;
+ buffer->screen = context->screen;
- // TODO: Do we need linked list?
- }
+ if (context->screen->get_param(buffer->screen, PIPE_CAP_NPOT_TEXTURES))
+ buffer->target = PIPE_TEXTURE_2D;
+ else
+ buffer->target = PIPE_TEXTURE_RECT;
+
+ // Prepare our state_tracker interface
+ buffer->stfbi->flush_front = hgl_st_framebuffer_flush_front;
+ buffer->stfbi->validate = hgl_st_framebuffer_validate;
+ buffer->stfbi->visual = context->stVisual;
+
+ p_atomic_set(&buffer->stfbi->stamp, 1);
+ buffer->stfbi->st_manager_private = (void*)buffer;
- return buffer;
+ return buffer;
}
struct st_manager *
-hgl_create_st_manager(struct pipe_screen* screen)
+hgl_create_st_manager(struct hgl_context* context)
{
+ struct st_manager* manager;
+
CALLED();
- assert(screen);
- struct st_manager* manager = CALLOC_STRUCT(st_manager);
+ // Required things
+ assert(context);
+ assert(context->screen);
- if (!manager) {
- ERROR("%s: Couldn't allocate state tracker manager!\n", __func__);
- return NULL;
- }
+ manager = CALLOC_STRUCT(st_manager);
+ assert(manager);
//manager->display = dpy;
- manager->screen = screen;
+ manager->screen = context->screen;
manager->get_param = hgl_st_manager_get_param;
return manager;
@@ -221,56 +290,26 @@ hgl_destroy_st_manager(struct st_manager *manager)
struct st_visual*
hgl_create_st_visual(ulong options)
{
- struct st_visual* visual = CALLOC_STRUCT(st_visual);
- if (!visual) {
- ERROR("%s: Couldn't allocate st_visual\n", __func__);
- return NULL;
- }
+ struct st_visual* visual;
- // Calculate visual configuration
- const GLboolean rgbFlag = ((options & BGL_INDEX) == 0);
- const GLboolean alphaFlag = ((options & BGL_ALPHA) == BGL_ALPHA);
- const GLboolean dblFlag = ((options & BGL_DOUBLE) == BGL_DOUBLE);
- const GLboolean stereoFlag = false;
- const GLboolean depthFlag = ((options & BGL_DEPTH) == BGL_DEPTH);
- const GLboolean stencilFlag = ((options & BGL_STENCIL) == BGL_STENCIL);
- const GLboolean accumFlag = ((options & BGL_ACCUM) == BGL_ACCUM);
-
- const GLint red = rgbFlag ? 8 : 5;
- const GLint green = rgbFlag ? 8 : 5;
- const GLint blue = rgbFlag ? 8 : 5;
- const GLint alpha = alphaFlag ? 8 : 0;
-
- TRACE("rgb :\t%d\n", (bool)rgbFlag);
- TRACE("alpha :\t%d\n", (bool)alphaFlag);
- TRACE("dbl :\t%d\n", (bool)dblFlag);
- TRACE("stereo :\t%d\n", (bool)stereoFlag);
- TRACE("depth :\t%d\n", (bool)depthFlag);
- TRACE("stencil :\t%d\n", (bool)stencilFlag);
- TRACE("accum :\t%d\n", (bool)accumFlag);
- TRACE("red :\t%d\n", red);
- TRACE("green :\t%d\n", green);
- TRACE("blue :\t%d\n", blue);
- TRACE("alpha :\t%d\n", alpha);
+ CALLED();
+
+ visual = CALLOC_STRUCT(st_visual);
+ assert(visual);
// Determine color format
- if (red == 8) {
- // Color format
- if (alpha == 8)
- visual->color_format = PIPE_FORMAT_B8G8R8A8_UNORM;
- else
- visual->color_format = PIPE_FORMAT_B8G8R8X8_UNORM;
-
- // Depth buffer
- if (depthFlag)
- visual->depth_stencil_format = PIPE_FORMAT_Z32_UNORM;
- else
- visual->depth_stencil_format = PIPE_FORMAT_NONE;
- } else {
+ if ((options & BGL_INDEX) != 0) {
+ // Index color
visual->color_format = PIPE_FORMAT_B5G6R5_UNORM;
-
// TODO: Indexed color depth buffer?
visual->depth_stencil_format = PIPE_FORMAT_NONE;
+ } else {
+ // RGB color
+ visual->color_format = (options & BGL_ALPHA)
+ ? PIPE_FORMAT_BGRA8888_UNORM : PIPE_FORMAT_BGRX8888_UNORM;
+ // TODO: Determine additional stencil formats
+ visual->depth_stencil_format = (options & BGL_DEPTH)
+ ? PIPE_FORMAT_Z24_UNORM_S8_UINT : PIPE_FORMAT_NONE;
}
visual->accum_format = (options & BGL_ACCUM)
@@ -279,20 +318,25 @@ hgl_create_st_visual(ulong options)
visual->buffer_mask |= ST_ATTACHMENT_FRONT_LEFT_MASK;
visual->render_buffer = ST_ATTACHMENT_FRONT_LEFT;
- if (dblFlag) {
+ if ((options & BGL_DOUBLE) != 0) {
visual->buffer_mask |= ST_ATTACHMENT_BACK_LEFT_MASK;
visual->render_buffer = ST_ATTACHMENT_BACK_LEFT;
}
- if (stereoFlag) {
+ #if 0
+ if ((options & BGL_STEREO) != 0) {
visual->buffer_mask |= ST_ATTACHMENT_FRONT_RIGHT_MASK;
- if (dblFlag)
+ if ((options & BGL_DOUBLE) != 0)
visual->buffer_mask |= ST_ATTACHMENT_BACK_RIGHT_MASK;
}
+ #endif
if ((options & BGL_DEPTH) || (options & BGL_STENCIL))
visual->buffer_mask |= ST_ATTACHMENT_DEPTH_STENCIL_MASK;
+ TRACE("%s: Visual color format: %s\n", __func__,
+ util_format_name(visual->color_format));
+
return visual;
}
diff --git a/src/gallium/state_trackers/hgl/hgl_context.h b/src/gallium/state_trackers/hgl/hgl_context.h
index 1d9841468ae..4840d9e2ee4 100644
--- a/src/gallium/state_trackers/hgl/hgl_context.h
+++ b/src/gallium/state_trackers/hgl/hgl_context.h
@@ -37,7 +37,10 @@ struct hgl_buffer
unsigned width;
unsigned height;
+ unsigned mask;
+ struct pipe_screen* screen;
+ enum pipe_texture_target target;
struct pipe_resource* textures[ST_ATTACHMENT_COUNT];
void *map;
@@ -57,12 +60,18 @@ struct hgl_context
struct st_visual* stVisual;
// State Tracker Visual
- struct pipe_resource* textures[ST_ATTACHMENT_COUNT];
+ struct pipe_screen* screen;
+
+ //struct pipe_resource* textures[ST_ATTACHMENT_COUNT];
// Post processing
struct pp_queue_t* postProcess;
unsigned int postProcessEnable[PP_FILTERS];
+ // Desired viewport size
+ unsigned width;
+ unsigned height;
+
Bitmap* bitmap;
color_space colorSpace;
@@ -77,7 +86,7 @@ struct hgl_context
struct hgl_buffer* hgl_create_st_framebuffer(struct hgl_context* context);
// hgl state_tracker manager
-struct st_manager* hgl_create_st_manager(struct pipe_screen* screen);
+struct st_manager* hgl_create_st_manager(struct hgl_context* screen);
void hgl_destroy_st_manager(struct st_manager *manager);
// hgl state_tracker visual
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;
};
diff --git a/src/gallium/winsys/sw/hgl/hgl_sw_winsys.c b/src/gallium/winsys/sw/hgl/hgl_sw_winsys.c
index 8e8413bbb97..a71d2a76791 100644
--- a/src/gallium/winsys/sw/hgl/hgl_sw_winsys.c
+++ b/src/gallium/winsys/sw/hgl/hgl_sw_winsys.c
@@ -1,7 +1,7 @@
/**************************************************************************
*
* Copyright 2009 Artur Wyszynski <[email protected]>
- * Copyright 2013 Alexander von Gluck IV <[email protected]>
+ * Copyright 2013-2014 Alexander von Gluck IV <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
@@ -25,6 +25,7 @@
*
**************************************************************************/
+#include <stdio.h>
#include "pipe/p_compiler.h"
#include "pipe/p_defines.h"
@@ -40,6 +41,16 @@
#include "hgl_sw_winsys.h"
+#ifdef DEBUG
+# define TRACE(x...) printf("hgl:winsys: " x)
+# define CALLED() TRACE("CALLED: %s\n", __PRETTY_FUNCTION__)
+#else
+# define TRACE(x...)
+# define CALLED()
+#endif
+#define ERROR(x...) printf("hgl:winsys: " x)
+
+
struct haiku_displaytarget
{
enum pipe_format format;
@@ -75,7 +86,7 @@ hgl_winsys_is_displaytarget_format_supported(struct sw_winsys* winsys,
unsigned textureUsage, enum pipe_format format)
{
// TODO STUB
- return true;
+ return TRUE;
}
static color_space
@@ -85,8 +96,8 @@ hgl_winsys_convert_cs(enum pipe_format format)
switch(format) {
case PIPE_FORMAT_B5G6R5_UNORM:
return B_CMAP8;
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case PIPE_FORMAT_X8R8G8B8_UNORM:
+ case PIPE_FORMAT_A8B8G8R8_UNORM:
+ case PIPE_FORMAT_X8B8G8R8_UNORM:
default:
return B_RGB32;
}
@@ -101,6 +112,8 @@ hgl_winsys_displaytarget_create(struct sw_winsys* winsys,
= CALLOC_STRUCT(haiku_displaytarget);
assert(haikuDisplayTarget);
+ TRACE("%s: %d x %d\n", __func__, width, height);
+
haikuDisplayTarget->colorSpace = hgl_winsys_convert_cs(format);
haikuDisplayTarget->format = format;
haikuDisplayTarget->width = width;
@@ -193,6 +206,9 @@ hgl_winsys_displaytarget_display(struct sw_winsys* winsys,
haikuDisplayTarget->size, haikuDisplayTarget->stride,
haikuDisplayTarget->colorSpace);
+ // Dump the rendered bitmap to disk for debugging
+ //dump_bitmap(bitmap);
+
return;
}