aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/wgl/shared/stw_context.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers/wgl/shared/stw_context.c')
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_context.c121
1 files changed, 88 insertions, 33 deletions
diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c
index f3c7af93f50..dd97e48b144 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_context.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_context.c
@@ -64,6 +64,7 @@ stw_copy_context(
if (src && dst) {
/* FIXME */
+ assert(0);
(void) src;
(void) dst;
(void) mask;
@@ -74,6 +75,30 @@ stw_copy_context(
return ret;
}
+BOOL
+stw_share_lists(
+ UINT_PTR hglrc1,
+ UINT_PTR hglrc2 )
+{
+ struct stw_context *ctx1;
+ struct stw_context *ctx2;
+ BOOL ret = FALSE;
+
+ pipe_mutex_lock( stw_dev->mutex );
+
+ ctx1 = stw_lookup_context_locked( hglrc1 );
+ ctx2 = stw_lookup_context_locked( hglrc2 );
+
+ if (ctx1 && ctx2 &&
+ ctx1->pfi == ctx2->pfi) {
+ ret = _mesa_share_state(ctx2->st->ctx, ctx1->st->ctx);
+ }
+
+ pipe_mutex_unlock( stw_dev->mutex );
+
+ return ret;
+}
+
UINT_PTR
stw_create_layer_context(
HDC hdc,
@@ -85,7 +110,6 @@ stw_create_layer_context(
GLvisual *visual = NULL;
struct pipe_screen *screen = NULL;
struct pipe_context *pipe = NULL;
- UINT_PTR hglrc = 0;
if(!stw_dev)
return 0;
@@ -101,7 +125,7 @@ stw_create_layer_context(
ctx = CALLOC_STRUCT( stw_context );
if (ctx == NULL)
- return 0;
+ goto no_ctx;
ctx->hdc = hdc;
ctx->color_bits = GetDeviceCaps( ctx->hdc, BITSPIXEL );
@@ -125,7 +149,7 @@ stw_create_layer_context(
pf->pfd.cAccumAlphaBits,
pf->numSamples );
if (visual == NULL)
- goto fail;
+ goto no_visual;
screen = stw_dev->screen;
@@ -137,7 +161,7 @@ stw_create_layer_context(
pipe = stw_dev->stw_winsys->create_context( screen );
if (pipe == NULL)
- goto fail;
+ goto no_pipe;
#ifdef DEBUG
/* Wrap context */
@@ -150,28 +174,29 @@ stw_create_layer_context(
ctx->st = st_create_context( pipe, visual, NULL );
if (ctx->st == NULL)
- goto fail;
+ goto no_st_ctx;
ctx->st->ctx->DriverCtx = ctx;
ctx->pfi = pf;
pipe_mutex_lock( stw_dev->mutex );
- hglrc = handle_table_add(stw_dev->ctx_table, ctx);
+ ctx->hglrc = handle_table_add(stw_dev->ctx_table, ctx);
pipe_mutex_unlock( stw_dev->mutex );
-
- /* Success?
- */
- if (hglrc != 0)
- return hglrc;
-
-fail:
- if (visual)
- _mesa_destroy_visual( visual );
-
- if (pipe)
- pipe->destroy( pipe );
-
+ if (!ctx->hglrc)
+ goto no_hglrc;
+
+ return ctx->hglrc;
+
+no_hglrc:
+ st_destroy_context(ctx->st);
+ goto no_pipe; /* st_context_destroy already destroys pipe */
+no_st_ctx:
+ pipe->destroy( pipe );
+no_pipe:
+ _mesa_destroy_visual( visual );
+no_visual:
FREE( ctx );
+no_ctx:
return 0;
}
@@ -253,31 +278,64 @@ stw_release_context(
/* Find the width and height of the window named by hdc.
*/
static void
-stw_get_window_size( HDC hdc, GLuint *width, GLuint *height )
+stw_get_window_size( HDC hdc, GLuint *pwidth, GLuint *pheight )
{
- if (WindowFromDC( hdc )) {
- RECT rect;
+ GLuint width, height;
+ HWND hwnd;
- GetClientRect( WindowFromDC( hdc ), &rect );
- *width = rect.right - rect.left;
- *height = rect.bottom - rect.top;
+ hwnd = WindowFromDC( hdc );
+ if (hwnd) {
+ RECT rect;
+ GetClientRect( hwnd, &rect );
+ width = rect.right - rect.left;
+ height = rect.bottom - rect.top;
}
else {
- *width = GetDeviceCaps( hdc, HORZRES );
- *height = GetDeviceCaps( hdc, VERTRES );
+ width = GetDeviceCaps( hdc, HORZRES );
+ height = GetDeviceCaps( hdc, VERTRES );
}
+
+ if(width < 1)
+ width = 1;
+ if(height < 1)
+ height = 1;
+
+ *pwidth = width;
+ *pheight = height;
}
UINT_PTR
stw_get_current_context( void )
{
- return stw_tls_get_data()->currentGLRC;
+ GET_CURRENT_CONTEXT( glcurctx );
+ struct stw_context *ctx;
+
+ if(!glcurctx)
+ return 0;
+
+ ctx = (struct stw_context *)glcurctx->DriverCtx;
+ assert(ctx);
+ if(!ctx)
+ return 0;
+
+ return ctx->hglrc;
}
HDC
stw_get_current_dc( void )
{
- return stw_tls_get_data()->currentDC;
+ GET_CURRENT_CONTEXT( glcurctx );
+ struct stw_context *ctx;
+
+ if(!glcurctx)
+ return NULL;
+
+ ctx = (struct stw_context *)glcurctx->DriverCtx;
+ assert(ctx);
+ if(!ctx)
+ return NULL;
+
+ return ctx->hdc;
}
BOOL
@@ -290,7 +348,7 @@ stw_make_current(
struct stw_framebuffer *fb;
GLuint width = 0;
GLuint height = 0;
- struct stw_context *curctx;
+ struct stw_context *curctx = NULL;
if (!stw_dev)
return FALSE;
@@ -299,9 +357,6 @@ stw_make_current(
ctx = stw_lookup_context_locked( hglrc );
pipe_mutex_unlock( stw_dev->mutex );
- stw_tls_get_data()->currentDC = hdc;
- stw_tls_get_data()->currentGLRC = hglrc;
-
if (glcurctx != NULL) {
curctx = (struct stw_context *) glcurctx->DriverCtx;