#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"
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)
GalliumContext::GalliumContext(ulong options)
:
fOptions(options),
- fCurrentContext(0),
- fScreen(NULL)
+ fScreen(NULL),
+ fCurrentContext(0)
{
CALLED();
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);
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;
break;
}
}
- pipe_mutex_unlock(fMutex);
+ Unlock();
if (contextNext < 0) {
ERROR("%s: The next context is invalid... something went wrong!\n",
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",
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;
{
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__);
#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: */
#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)
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);
{
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;
}