summaryrefslogtreecommitdiffstats
path: root/src/gallium/targets
diff options
context:
space:
mode:
authorAlexander von Gluck IV <[email protected]>2013-11-04 18:51:41 +0000
committerAlexander von Gluck IV <[email protected]>2013-11-05 01:17:55 +0000
commite759f1c111018949db114e76ebf1a723525fb802 (patch)
treefb0e28e14fe8da5391d009a724752abd4d80b15f /src/gallium/targets
parentfaaf568cfb0548d6162d6fefd68f6ad62eb6406c (diff)
target/haiku-softpipe: Fix viewport issues
* Call mesa viewport call on winndow resize * Add initial postprocessing code * Pass hgl_context to private statetracker as it is more useful than GalliumContext * Use Lock and Unlock functions to standardize GalliumContext locking * Create texture resources in texture validation Acked-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/gallium/targets')
-rw-r--r--src/gallium/targets/haiku-softpipe/GalliumContext.cpp83
-rw-r--r--src/gallium/targets/haiku-softpipe/GalliumContext.h8
-rw-r--r--src/gallium/targets/haiku-softpipe/GalliumFramebuffer.cpp68
-rw-r--r--src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp8
4 files changed, 138 insertions, 29 deletions
diff --git a/src/gallium/targets/haiku-softpipe/GalliumContext.cpp b/src/gallium/targets/haiku-softpipe/GalliumContext.cpp
index ff420b9af26..b750f6578f4 100644
--- a/src/gallium/targets/haiku-softpipe/GalliumContext.cpp
+++ b/src/gallium/targets/haiku-softpipe/GalliumContext.cpp
@@ -18,6 +18,7 @@ extern "C" {
#include "main/context.h"
#include "main/framebuffer.h"
#include "main/renderbuffer.h"
+#include "main/viewport.h"
#include "pipe/p_format.h"
#include "state_tracker/st_cb_fbo.h"
#include "state_tracker/st_cb_flush.h"
@@ -49,11 +50,11 @@ hgl_viewport(struct gl_context* glContext, GLint x, GLint y,
TRACE("%s(glContext: %p, x: %d, y: %d, w: %d, h: %d\n", __func__,
glContext, x, y, width, height);
+ _mesa_check_init_viewport(glContext, width, height);
+
struct gl_framebuffer *draw = glContext->WinSysDrawBuffer;
struct gl_framebuffer *read = glContext->WinSysReadBuffer;
- // TODO: SLOW! We need to check for changes in bitmap vs gl_framebuffer
- // size before doing a _mesa_resize_framebuffer.
if (draw)
_mesa_resize_framebuffer(glContext, draw, width, height);
if (read)
@@ -145,8 +146,8 @@ hook_stm_get_param(struct st_manager *smapi, enum st_manager_param param)
GalliumContext::GalliumContext(ulong options)
:
fOptions(options),
- fCurrentContext(0),
- fScreen(NULL)
+ fScreen(NULL),
+ fCurrentContext(0)
{
CALLED();
@@ -165,10 +166,10 @@ GalliumContext::~GalliumContext()
CALLED();
// Destroy our contexts
- pipe_mutex_lock(fMutex);
+ Lock();
for (context_id i = 0; i < CONTEXT_MAX; i++)
DestroyContext(i);
- pipe_mutex_unlock(fMutex);
+ Unlock();
pipe_mutex_destroy(fMutex);
@@ -337,20 +338,20 @@ GalliumContext::CreateContext(Bitmap *bitmap)
return -1;
}
- // Init Gallium3D Post Processing
- //context->postProcess = pp_init(fScreen, context->postProcessEnable);
-
assert(!context->st->st_manager_private);
- context->st->st_manager_private = (void*)this;
+ context->st->st_manager_private = (void*)context;
struct st_context *stContext = (struct st_context*)context->st;
stContext->ctx->Driver.Viewport = hgl_viewport;
- // TODO: Closely review this next context logic...
- context_id contextNext = -1;
+ // Init Gallium3D Post Processing
+ // TODO: no pp filters are enabled yet through postProcessEnable
+ context->postProcess = pp_init(stContext->pipe, context->postProcessEnable,
+ stContext->cso_context);
- pipe_mutex_lock(fMutex);
+ context_id contextNext = -1;
+ Lock();
for (context_id i = 0; i < CONTEXT_MAX; i++) {
if (fContext[i] == NULL) {
fContext[i] = context;
@@ -358,7 +359,7 @@ GalliumContext::CreateContext(Bitmap *bitmap)
break;
}
}
- pipe_mutex_unlock(fMutex);
+ Unlock();
if (contextNext < 0) {
ERROR("%s: The next context is invalid... something went wrong!\n",
@@ -419,10 +420,10 @@ GalliumContext::SetCurrentContext(Bitmap *bitmap, context_id contextID)
return B_ERROR;
}
- pipe_mutex_lock(fMutex);
+ Lock();
context_id oldContextID = fCurrentContext;
struct hgl_context* context = fContext[contextID];
- pipe_mutex_unlock(fMutex);
+ Unlock();
if (!context) {
ERROR("%s: Invalid context provided (#%" B_PRIu64 ")!\n",
@@ -453,12 +454,14 @@ GalliumContext::SetCurrentContext(Bitmap *bitmap, context_id contextID)
context->draw->Unlock();
context->read->Unlock();
- // TODO: Init textures before post-processing them
- #if 0
- pp_init_fbos(context->postProcess,
- context->textures[ST_ATTACHMENT_BACK_LEFT]->width0,
- context->textures[ST_ATTACHMENT_BACK_LEFT]->height0);
- #endif
+ 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;
@@ -472,9 +475,9 @@ GalliumContext::SwapBuffers(context_id contextID)
{
CALLED();
- pipe_mutex_lock(fMutex);
+ Lock();
struct hgl_context *context = fContext[contextID];
- pipe_mutex_unlock(fMutex);
+ Unlock();
if (!context) {
ERROR("%s: context not found\n", __func__);
@@ -507,10 +510,40 @@ GalliumContext::SwapBuffers(context_id contextID)
#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,
+ fScreen->flush_frontbuffer(fScreen, zSurface->texture, 0, 0,
context->bitmap);
#endif
return B_OK;
}
+
+
+void
+GalliumContext::ResizeViewport(int32 width, int32 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;
+ _mesa_set_viewport(stContext->ctx, 0, 0, width, height);
+ st_manager_validate_framebuffers(stContext);
+ }
+ }
+}
+
+
+void
+GalliumContext::Lock()
+{
+ CALLED();
+ pipe_mutex_lock(fMutex);
+}
+
+
+void
+GalliumContext::Unlock()
+{
+ CALLED();
+ pipe_mutex_unlock(fMutex);
+}
/* vim: set tabstop=4: */
diff --git a/src/gallium/targets/haiku-softpipe/GalliumContext.h b/src/gallium/targets/haiku-softpipe/GalliumContext.h
index 88e9f81238e..e156ef895b4 100644
--- a/src/gallium/targets/haiku-softpipe/GalliumContext.h
+++ b/src/gallium/targets/haiku-softpipe/GalliumContext.h
@@ -58,6 +58,9 @@ public:
GalliumContext(ulong options);
~GalliumContext();
+ void Lock();
+ void Unlock();
+
context_id CreateContext(Bitmap* bitmap);
void DestroyContext(context_id contextID);
context_id GetCurrentContext() { return fCurrentContext; };
@@ -65,17 +68,18 @@ public:
context_id contextID);
status_t SwapBuffers(context_id contextID);
+ void ResizeViewport(int32 width, int32 height);
private:
status_t CreateScreen();
void Flush();
ulong fOptions;
+ struct pipe_screen* fScreen;
+ // Context Management
struct hgl_context* fContext[CONTEXT_MAX];
context_id fCurrentContext;
-
- struct pipe_screen* fScreen;
pipe_mutex fMutex;
};
diff --git a/src/gallium/targets/haiku-softpipe/GalliumFramebuffer.cpp b/src/gallium/targets/haiku-softpipe/GalliumFramebuffer.cpp
index 7a33cc06cda..dd726efb900 100644
--- a/src/gallium/targets/haiku-softpipe/GalliumFramebuffer.cpp
+++ b/src/gallium/targets/haiku-softpipe/GalliumFramebuffer.cpp
@@ -15,8 +15,11 @@ extern "C" {
#include "main/framebuffer.h"
#include "main/renderbuffer.h"
#include "pipe/p_format.h"
+#include "state_tracker/st_manager.h"
}
+#include "GalliumContext.h"
+
#ifdef DEBUG
# define TRACE(x...) printf("GalliumFramebuffer: " x)
@@ -33,7 +36,13 @@ hgl_framebuffer_flush_front(struct st_context_iface *stctx,
struct st_framebuffer_iface* stfb, enum st_attachment_type statt)
{
CALLED();
- // TODO: I have *NO* idea how we are going to access this data...
+
+ hgl_context* context = (hgl_context*)stfb->st_manager_private;
+
+ if (!context) {
+ ERROR("%s: Couldn't obtain valid hgl_context!\n", __func__);
+ return FALSE;
+ }
#if 0
struct stw_st_framebuffer *stwfb = stw_st_framebuffer(stfb);
@@ -56,6 +65,63 @@ hgl_framebuffer_validate(struct st_context_iface* stctx,
{
CALLED();
+ if (!stfb) {
+ ERROR("%s: Invalid st framebuffer interface!\n", __func__);
+ return FALSE;
+ }
+
+ hgl_context* context = (hgl_context*)stfb->st_manager_private;
+
+ if (!context) {
+ ERROR("%s: Couldn't obtain valid hgl_context!\n", __func__);
+ return FALSE;
+ }
+
+ int32 width = 0;
+ int32 height = 0;
+ get_bitmap_size(context->bitmap, &width, &height);
+
+ 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__);
+ int i;
+ for (i = 0; i < count; i++) {
+ enum pipe_format format = PIPE_FORMAT_NONE;
+ unsigned bind = 0;
+
+ switch(statts[i]) {
+ case ST_ATTACHMENT_FRONT_LEFT:
+ format = context->stVisual->color_format;
+ bind = 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:
+ ERROR("%s: Unexpected attachment type!\n", __func__);
+ }
+ 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];
+ }
+ }
+
return TRUE;
}
diff --git a/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp b/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp
index fa71dd764e0..9d85b8d03e2 100644
--- a/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp
+++ b/src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp
@@ -326,7 +326,8 @@ SoftwareRenderer::DirectConnected(direct_buffer_info *info)
void
SoftwareRenderer::FrameResized(float width, float height)
{
-// CALLED();
+ TRACE("%s: %f x %f\n", __func__, width, height);
+
BAutolock lock(fInfoLocker);
fNewWidth = (GLuint)width;
fNewHeight = (GLuint)height;
@@ -354,6 +355,11 @@ SoftwareRenderer::_AllocateBitmap()
return;
}
+ TRACE("%s: New bitmap size: %d x %d\n", __func__,
+ fBitmap->Bounds().IntegerWidth(), fBitmap->Bounds().IntegerHeight());
+
+ fContextObj->ResizeViewport(fWidth, fHeight);
+
#if 0
// debug..
void *data = fBitmap->Bits();