summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/wgl
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2009-04-27 20:24:55 +0100
committerKeith Whitwell <[email protected]>2009-04-28 18:15:16 +0100
commit43e24a5928aaf6a00f7d9e55e92abfb1b3e20166 (patch)
treea2db3e7ffc3a13fc285f5b4a36025fcbc7a9fd23 /src/gallium/state_trackers/wgl
parent09c91a1565fc99f20379a0f552651303ae8067c2 (diff)
wgl: Store current HDC/HGLRC in stw_context.
Less TLS lookups.
Diffstat (limited to 'src/gallium/state_trackers/wgl')
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_context.c66
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_context.h1
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_tls.h2
3 files changed, 44 insertions, 25 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..0b5dd78ec63 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_context.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_context.c
@@ -101,7 +101,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 +125,7 @@ stw_create_layer_context(
pf->pfd.cAccumAlphaBits,
pf->numSamples );
if (visual == NULL)
- goto fail;
+ goto no_visual;
screen = stw_dev->screen;
@@ -137,7 +137,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 +150,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;
}
@@ -271,13 +272,35 @@ stw_get_window_size( HDC hdc, GLuint *width, GLuint *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 NULL;
+
+ ctx = (struct stw_context *)glcurctx->DriverCtx;
+ assert(ctx);
+ if(!ctx)
+ return NULL;
+
+ 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
@@ -299,9 +322,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;
diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.h b/src/gallium/state_trackers/wgl/shared/stw_context.h
index bc3b1dc880d..e276737e85a 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_context.h
+++ b/src/gallium/state_trackers/wgl/shared/stw_context.h
@@ -36,6 +36,7 @@ struct stw_pixelformat_info;
struct stw_context
{
struct st_context *st;
+ UINT_PTR hglrc;
HDC hdc;
DWORD color_bits;
const struct stw_pixelformat_info *pfi;
diff --git a/src/gallium/state_trackers/wgl/shared/stw_tls.h b/src/gallium/state_trackers/wgl/shared/stw_tls.h
index f5a6bdf4b1a..6cfb0899f2d 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_tls.h
+++ b/src/gallium/state_trackers/wgl/shared/stw_tls.h
@@ -33,8 +33,6 @@
struct stw_tls_data
{
uint currentPixelFormat;
- HDC currentDC;
- UINT_PTR currentGLRC;
HHOOK hCallWndProcHook;
};