Browse Source

wgl: Store current HDC/HGLRC in stw_context.

Less TLS lookups.
tags/mesa_7_5_rc1
José Fonseca 16 years ago
parent
commit
43e24a5928

+ 43
- 23
src/gallium/state_trackers/wgl/shared/stw_context.c View File

@@ -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;


+ 1
- 0
src/gallium/state_trackers/wgl/shared/stw_context.h View File

@@ -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;

+ 0
- 2
src/gallium/state_trackers/wgl/shared/stw_tls.h View File

@@ -33,8 +33,6 @@
struct stw_tls_data
{
uint currentPixelFormat;
HDC currentDC;
UINT_PTR currentGLRC;
HHOOK hCallWndProcHook;
};


Loading…
Cancel
Save