summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2009-02-02 12:17:01 +0000
committerKeith Whitwell <[email protected]>2009-02-02 12:17:01 +0000
commite4d1757f81323636e99abc5fff411d42e19e901a (patch)
tree4fd889e01445ce7c79688fa51dc78e9ad97be8c4
parent59edbc70cd1042a884e7d153ba547c2f7f87318d (diff)
parenta38b8213ff1b99b73aae884e7b90be3d1999e3bf (diff)
Merge branch 'gallium-wgl-rework' into gallium-0.2
Conflicts: src/gallium/state_trackers/wgl/shared/stw_public.h
-rw-r--r--src/gallium/SConscript3
-rw-r--r--src/gallium/state_trackers/wgl/SConscript (renamed from src/mesa/state_tracker/wgl/SConscript)28
-rw-r--r--src/gallium/state_trackers/wgl/icd/stw_icd.c (renamed from src/mesa/state_tracker/wgl/stw_icd.c)167
-rw-r--r--src/gallium/state_trackers/wgl/icd/stw_icd.h (renamed from src/mesa/state_tracker/wgl/stw_icd.h)0
-rw-r--r--src/gallium/state_trackers/wgl/opengl32.def (renamed from src/mesa/state_tracker/wgl/opengl32.def)0
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_arbextensionsstring.c (renamed from src/mesa/state_tracker/wgl/stw_wgl_arbextensionsstring.c)2
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_arbextensionsstring.h (renamed from src/mesa/state_tracker/wgl/stw_wgl_arbextensionsstring.h)0
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_arbpixelformat.c (renamed from src/mesa/state_tracker/wgl/stw_wgl_arbpixelformat.c)14
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_arbpixelformat.h (renamed from src/mesa/state_tracker/wgl/stw_wgl_arbpixelformat.h)3
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_context.c (renamed from src/mesa/state_tracker/wgl/stw_wgl_context.c)138
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_context.h (renamed from src/mesa/state_tracker/wgl/stw_wgl_context.h)21
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_device.c (renamed from src/mesa/state_tracker/wgl/stw_device.c)22
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_device.h (renamed from src/mesa/state_tracker/wgl/stw_device.h)16
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_framebuffer.c (renamed from src/mesa/state_tracker/wgl/stw_framebuffer.c)33
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_framebuffer.h (renamed from src/mesa/state_tracker/wgl/stw_framebuffer.h)0
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_getprocaddress.c (renamed from src/mesa/state_tracker/wgl/stw_wgl_getprocaddress.c)9
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_pixelformat.c (renamed from src/mesa/state_tracker/wgl/stw_wgl_pixelformat.c)241
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_pixelformat.h (renamed from src/mesa/state_tracker/wgl/stw_pixelformat.h)7
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_public.h (renamed from src/mesa/state_tracker/wgl/stw_wgl_swapbuffers.c)92
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_quirks.c (renamed from src/mesa/state_tracker/wgl/stw_quirks.c)0
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_winsys.h (renamed from src/mesa/state_tracker/wgl/stw_winsys.h)0
-rw-r--r--src/gallium/state_trackers/wgl/stw.c (renamed from src/mesa/state_tracker/wgl/stw_wgl_arbmultisample.c)44
-rw-r--r--src/gallium/state_trackers/wgl/stw.h (renamed from src/mesa/state_tracker/wgl/stw_wgl_arbmultisample.h)41
-rw-r--r--src/gallium/state_trackers/wgl/wgl/stw_wgl.c (renamed from src/mesa/state_tracker/wgl/stw_wgl.c)154
-rw-r--r--src/gallium/state_trackers/wgl/wgl/stw_wgl.h (renamed from src/mesa/state_tracker/wgl/stw_wgl.h)0
-rw-r--r--src/mesa/SConscript2
-rw-r--r--src/mesa/state_tracker/wgl/stw_pixelformat.c120
27 files changed, 698 insertions, 459 deletions
diff --git a/src/gallium/SConscript b/src/gallium/SConscript
index 6a3e7e77ed8..9e4596a647f 100644
--- a/src/gallium/SConscript
+++ b/src/gallium/SConscript
@@ -27,3 +27,6 @@ for driver in env['drivers']:
SConscript(os.path.join('drivers', driver, 'SConscript'))
SConscript('state_trackers/python/SConscript')
+
+if platform == 'windows':
+ SConscript('state_trackers/wgl/SConscript')
diff --git a/src/mesa/state_tracker/wgl/SConscript b/src/gallium/state_trackers/wgl/SConscript
index bb579930f52..c72f495735d 100644
--- a/src/mesa/state_tracker/wgl/SConscript
+++ b/src/gallium/state_trackers/wgl/SConscript
@@ -8,6 +8,7 @@ if env['platform'] in ['windows']:
env.Append(CPPPATH = [
'#src/mesa',
+ '.',
])
env.Append(CPPDEFINES = [
@@ -18,19 +19,20 @@ if env['platform'] in ['windows']:
])
sources = [
- 'stw_device.c',
- 'stw_framebuffer.c',
- 'stw_icd.c',
- 'stw_pixelformat.c',
- 'stw_quirks.c',
- 'stw_wgl_arbextensionsstring.c',
- 'stw_wgl_arbmultisample.c',
- 'stw_wgl_arbpixelformat.c',
- #'stw_wgl.c',
- 'stw_wgl_context.c',
- 'stw_wgl_getprocaddress.c',
- 'stw_wgl_pixelformat.c',
- 'stw_wgl_swapbuffers.c',
+ 'stw.c',
+
+ 'icd/stw_icd.c',
+
+ 'wgl/stw_wgl.c',
+
+ 'shared/stw_context.c',
+ 'shared/stw_device.c',
+ 'shared/stw_framebuffer.c',
+ 'shared/stw_pixelformat.c',
+ 'shared/stw_quirks.c',
+ 'shared/stw_arbextensionsstring.c',
+ 'shared/stw_getprocaddress.c',
+ 'shared/stw_arbpixelformat.c',
]
wgl = env.ConvenienceLibrary(
diff --git a/src/mesa/state_tracker/wgl/stw_icd.c b/src/gallium/state_trackers/wgl/icd/stw_icd.c
index 1dddc242097..70e346a5394 100644
--- a/src/mesa/state_tracker/wgl/stw_icd.c
+++ b/src/gallium/state_trackers/wgl/icd/stw_icd.c
@@ -32,17 +32,64 @@
#include "pipe/p_debug.h"
-#include "stw_device.h"
-#include "stw_icd.h"
-#include "stw_wgl.h"
+#include "shared/stw_public.h"
+#include "icd/stw_icd.h"
+#include "stw.h"
-static HGLRC
-_drv_lookup_hglrc( DHGLRC dhglrc )
+#define DRV_CONTEXT_MAX 32
+
+struct stw_icd
{
- if (dhglrc == 0 || dhglrc >= DRV_CONTEXT_MAX)
+ struct {
+ struct stw_context *ctx;
+ } ctx_array[DRV_CONTEXT_MAX];
+
+ DHGLRC ctx_current;
+};
+
+
+static struct stw_icd *stw_icd = NULL;
+
+
+boolean
+stw_icd_init( void )
+{
+ static struct stw_icd stw_icd_storage;
+
+ assert(!stw_icd);
+
+ stw_icd = &stw_icd_storage;
+ memset(stw_icd, 0, sizeof *stw_icd);
+
+ return TRUE;
+}
+
+void
+stw_icd_cleanup(void)
+{
+ int i;
+
+ if(!stw_icd)
+ return;
+
+ /* Ensure all contexts are destroyed */
+ for (i = 0; i < DRV_CONTEXT_MAX; i++)
+ if (stw_icd->ctx_array[i].ctx)
+ stw_delete_context( stw_icd->ctx_array[i].ctx );
+
+ stw_icd = NULL;
+}
+
+
+static struct stw_context *
+lookup_context( DHGLRC dhglrc )
+{
+ if (dhglrc == 0 ||
+ dhglrc >= DRV_CONTEXT_MAX)
return NULL;
- return stw_dev->ctx_array[dhglrc - 1].hglrc;
+
+ return stw_icd->ctx_array[dhglrc - 1].ctx;
}
BOOL APIENTRY
@@ -51,9 +98,14 @@ DrvCopyContext(
DHGLRC dhrcDest,
UINT fuMask )
{
- debug_printf( "%s\n", __FUNCTION__ );
-
- return FALSE;
+ struct stw_context *src = lookup_context( dhrcSource );
+ struct stw_context *dst = lookup_context( dhrcDest );
+
+ if (src == NULL ||
+ dst == NULL)
+ return FALSE;
+
+ return stw_copy_context( src, dst, fuMask );
}
DHGLRC APIENTRY
@@ -61,26 +113,23 @@ DrvCreateLayerContext(
HDC hdc,
INT iLayerPlane )
{
- DHGLRC dhglrc = 0;
-
- if (iLayerPlane == 0) {
- DWORD i;
-
- for (i = 0; i < DRV_CONTEXT_MAX; i++) {
- if (stw_dev->ctx_array[i].hglrc == NULL)
- break;
- }
-
- if (i < DRV_CONTEXT_MAX) {
- stw_dev->ctx_array[i].hglrc = wglCreateContext( hdc );
- if (stw_dev->ctx_array[i].hglrc != NULL)
- dhglrc = i + 1;
- }
+ DWORD i;
+
+ for (i = 0; i < DRV_CONTEXT_MAX; i++) {
+ if (stw_icd->ctx_array[i].ctx == NULL)
+ goto found_slot;
}
+
+ /* No slot available, fail:
+ */
+ return 0;
- debug_printf( "%s( 0x%p, %d ) = %u\n", __FUNCTION__, hdc, iLayerPlane, dhglrc );
+found_slot:
+ stw_icd->ctx_array[i].ctx = stw_create_context( hdc, iLayerPlane );
+ if (stw_icd->ctx_array[i].ctx == NULL)
+ return 0;
- return dhglrc;
+ return (DHGLRC) i + 1;
}
DHGLRC APIENTRY
@@ -94,18 +143,20 @@ BOOL APIENTRY
DrvDeleteContext(
DHGLRC dhglrc )
{
- HGLRC hglrc = _drv_lookup_hglrc( dhglrc );
- BOOL success = FALSE;
+ struct stw_context *ctx;
- if (hglrc != NULL) {
- success = wglDeleteContext( hglrc );
- if (success)
- stw_dev->ctx_array[dhglrc - 1].hglrc = NULL;
- }
+ ctx = lookup_context( dhglrc );
+ if (ctx == NULL)
+ goto fail;
- debug_printf( "%s( %u ) = %s\n", __FUNCTION__, dhglrc, success ? "TRUE" : "FALSE" );
+ if (stw_delete_context( ctx ) == FALSE)
+ goto fail;
- return success;
+ stw_icd->ctx_array[dhglrc - 1].ctx = NULL;
+ return TRUE;
+
+fail:
+ return FALSE;
}
BOOL APIENTRY
@@ -130,9 +181,10 @@ DrvDescribePixelFormat(
{
LONG r;
- r = wglDescribePixelFormat( hdc, iPixelFormat, cjpfd, ppfd );
+ r = stw_pixelformat_describe( hdc, iPixelFormat, cjpfd, ppfd );
- debug_printf( "%s( 0x%p, %d, %u, 0x%p ) = %d\n", __FUNCTION__, hdc, iPixelFormat, cjpfd, ppfd, r );
+ debug_printf( "%s( 0x%p, %d, %u, 0x%p ) = %d\n",
+ __FUNCTION__, hdc, iPixelFormat, cjpfd, ppfd, r );
return r;
}
@@ -156,7 +208,7 @@ DrvGetProcAddress(
{
PROC r;
- r = wglGetProcAddress( lpszProc );
+ r = stw_get_proc_address( lpszProc );
debug_printf( "%s( \", __FUNCTION__%s\" ) = 0x%p\n", lpszProc, r );
@@ -178,21 +230,23 @@ BOOL APIENTRY
DrvReleaseContext(
DHGLRC dhglrc )
{
- BOOL success = FALSE;
+ struct stw_context *ctx;
- if (dhglrc == stw_dev->ctx_current) {
- HGLRC hglrc = _drv_lookup_hglrc( dhglrc );
+ if (dhglrc != stw_icd->ctx_current)
+ goto fail;
- if (hglrc != NULL) {
- success = wglMakeCurrent( NULL, NULL );
- if (success)
- stw_dev->ctx_current = 0;
- }
- }
+ ctx = lookup_context( dhglrc );
+ if (ctx == NULL)
+ goto fail;
- debug_printf( "%s( %u ) = %s\n", __FUNCTION__, dhglrc, success ? "TRUE" : "FALSE" );
+ if (stw_make_current( NULL, NULL ) == FALSE)
+ goto fail;
- return success;
+ stw_icd->ctx_current = 0;
+ return TRUE;
+
+fail:
+ return FALSE;
}
void APIENTRY
@@ -215,15 +269,16 @@ DrvSetContext(
DHGLRC dhglrc,
PFN_SETPROCTABLE pfnSetProcTable )
{
- HGLRC hglrc = _drv_lookup_hglrc( dhglrc );
+ struct stw_context *ctx;
GLDISPATCHTABLE *disp = &cpt.glDispatchTable;
debug_printf( "%s( 0x%p, %u, 0x%p )\n", __FUNCTION__, hdc, dhglrc, pfnSetProcTable );
- if (hglrc == NULL)
+ ctx = lookup_context( dhglrc );
+ if (ctx == NULL)
return NULL;
- if (!wglMakeCurrent( hdc, hglrc ))
+ if (!stw_make_current( hdc, ctx ))
return NULL;
memset( &cpt, 0, sizeof( cpt ) );
@@ -587,11 +642,9 @@ DrvSetPixelFormat(
HDC hdc,
LONG iPixelFormat )
{
- PIXELFORMATDESCRIPTOR pfd;
BOOL r;
- wglDescribePixelFormat( hdc, iPixelFormat, sizeof( pfd ), &pfd );
- r = wglSetPixelFormat( hdc, iPixelFormat, &pfd );
+ r = stw_pixelformat_set( hdc, iPixelFormat );
debug_printf( "%s( 0x%p, %d ) = %s\n", __FUNCTION__, hdc, iPixelFormat, r ? "TRUE" : "FALSE" );
@@ -614,7 +667,7 @@ DrvSwapBuffers(
{
debug_printf( "%s( 0x%p )\n", __FUNCTION__, hdc );
- return wglSwapBuffers( hdc );
+ return stw_swap_buffers( hdc );
}
BOOL APIENTRY
diff --git a/src/mesa/state_tracker/wgl/stw_icd.h b/src/gallium/state_trackers/wgl/icd/stw_icd.h
index 8e676fb5b74..8e676fb5b74 100644
--- a/src/mesa/state_tracker/wgl/stw_icd.h
+++ b/src/gallium/state_trackers/wgl/icd/stw_icd.h
diff --git a/src/mesa/state_tracker/wgl/opengl32.def b/src/gallium/state_trackers/wgl/opengl32.def
index 238b728f1fe..238b728f1fe 100644
--- a/src/mesa/state_tracker/wgl/opengl32.def
+++ b/src/gallium/state_trackers/wgl/opengl32.def
diff --git a/src/mesa/state_tracker/wgl/stw_wgl_arbextensionsstring.c b/src/gallium/state_trackers/wgl/shared/stw_arbextensionsstring.c
index 04865796ec8..b3934cb4643 100644
--- a/src/mesa/state_tracker/wgl/stw_wgl_arbextensionsstring.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_arbextensionsstring.c
@@ -27,7 +27,7 @@
#include <windows.h>
-#include "stw_wgl_arbextensionsstring.h"
+#include "stw_arbextensionsstring.h"
WINGDIAPI const char * APIENTRY
wglGetExtensionsStringARB(
diff --git a/src/mesa/state_tracker/wgl/stw_wgl_arbextensionsstring.h b/src/gallium/state_trackers/wgl/shared/stw_arbextensionsstring.h
index a0e4c5d98e8..a0e4c5d98e8 100644
--- a/src/mesa/state_tracker/wgl/stw_wgl_arbextensionsstring.h
+++ b/src/gallium/state_trackers/wgl/shared/stw_arbextensionsstring.h
diff --git a/src/mesa/state_tracker/wgl/stw_wgl_arbpixelformat.c b/src/gallium/state_trackers/wgl/shared/stw_arbpixelformat.c
index 344bb15d3c1..f5636354202 100644
--- a/src/mesa/state_tracker/wgl/stw_wgl_arbpixelformat.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_arbpixelformat.c
@@ -29,9 +29,9 @@
#include "pipe/p_compiler.h"
#include "util/u_memory.h"
+#include "stw_public.h"
#include "stw_pixelformat.h"
-#include "stw_wgl_arbmultisample.h"
-#include "stw_wgl_arbpixelformat.h"
+#include "stw_arbpixelformat.h"
#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
#define WGL_DRAW_TO_WINDOW_ARB 0x2001
@@ -86,6 +86,12 @@
#define WGL_TYPE_RGBA_ARB 0x202B
#define WGL_TYPE_COLORINDEX_ARB 0x202C
+/* From arb_multisample:
+ */
+#define WGL_SAMPLE_BUFFERS_ARB 0x2041
+#define WGL_SAMPLES_ARB 0x2042
+
+
static boolean
query_attrib(
int iPixelFormat,
@@ -253,14 +259,14 @@ query_attrib(
case WGL_SAMPLE_BUFFERS_ARB:
if (pf->flags & PF_FLAG_MULTISAMPLED)
- *pvalue = wgl_query_sample_buffers();
+ *pvalue = stw_query_sample_buffers();
else
*pvalue = 0;
break;
case WGL_SAMPLES_ARB:
if (pf->flags & PF_FLAG_MULTISAMPLED)
- *pvalue = wgl_query_samples();
+ *pvalue = stw_query_samples();
else
*pvalue = 0;
break;
diff --git a/src/mesa/state_tracker/wgl/stw_wgl_arbpixelformat.h b/src/gallium/state_trackers/wgl/shared/stw_arbpixelformat.h
index 5e480b822b3..a6c42599424 100644
--- a/src/mesa/state_tracker/wgl/stw_wgl_arbpixelformat.h
+++ b/src/gallium/state_trackers/wgl/shared/stw_arbpixelformat.h
@@ -28,6 +28,9 @@
#ifndef WGL_ARBPIXELFORMAT_H
#define WGL_ARBPIXELFORMAT_H
+
+/* Extension functions for get_proc_address:
+ */
WINGDIAPI BOOL APIENTRY
wglChoosePixelFormatARB(
HDC hdc,
diff --git a/src/mesa/state_tracker/wgl/stw_wgl_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c
index 890d97fd72a..2abf97b5adb 100644
--- a/src/mesa/state_tracker/wgl/stw_wgl_context.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_context.c
@@ -33,49 +33,52 @@
#include "pipe/p_context.h"
#include "state_tracker/st_context.h"
#include "state_tracker/st_public.h"
-#include "stw_device.h"
-#include "stw_winsys.h"
-#include "stw_framebuffer.h"
-#include "stw_pixelformat.h"
-#include "stw_wgl_arbmultisample.h"
-#include "stw_wgl_context.h"
-#include "stw_wgl.h"
+#include "shared/stw_device.h"
+#include "shared/stw_winsys.h"
+#include "shared/stw_framebuffer.h"
+#include "shared/stw_pixelformat.h"
+#include "stw_public.h"
+#include "stw_context.h"
-static struct wgl_context *ctx_head = NULL;
+static struct stw_context *ctx_head = NULL;
static HDC current_hdc = NULL;
-static HGLRC current_hrc = NULL;
+static struct stw_context *current_hrc = NULL;
-WINGDIAPI BOOL APIENTRY
-wglCopyContext(
- HGLRC hglrcSrc,
- HGLRC hglrcDst,
+BOOL
+stw_copy_context(
+ struct stw_context *src,
+ struct stw_context *dst,
UINT mask )
{
- (void) hglrcSrc;
- (void) hglrcDst;
+ (void) src;
+ (void) dst;
(void) mask;
return FALSE;
}
-WINGDIAPI HGLRC APIENTRY
-wglCreateContext(
- HDC hdc )
+struct stw_context *
+stw_create_context(
+ HDC hdc,
+ int iLayerPlane )
{
uint pfi;
- const struct pixelformat_info *pf;
- struct wgl_context *ctx;
- GLvisual *visual;
- struct pipe_context *pipe;
+ const struct pixelformat_info *pf = NULL;
+ struct stw_context *ctx = NULL;
+ GLvisual *visual = NULL;
+ struct pipe_context *pipe = NULL;
- pfi = wglGetPixelFormat( hdc );
+ if (iLayerPlane != 0)
+ return NULL;
+
+ pfi = stw_pixelformat_get( hdc );
if (pfi == 0)
return NULL;
pf = pixelformat_get_info( pfi - 1 );
- ctx = CALLOC_STRUCT( wgl_context );
+ ctx = CALLOC_STRUCT( stw_context );
if (ctx == NULL)
return NULL;
@@ -99,57 +102,49 @@ wglCreateContext(
0,
0,
0,
- (pf->flags & PF_FLAG_MULTISAMPLED) ? wgl_query_samples() : 0 );
- if (visual == NULL) {
- FREE( ctx );
- return NULL;
- }
+ (pf->flags & PF_FLAG_MULTISAMPLED) ? stw_query_samples() : 0 );
+ if (visual == NULL)
+ goto fail;
pipe = stw_dev->stw_winsys->create_context( stw_dev->screen );
- if (!pipe) {
- _mesa_destroy_visual( visual );
- FREE( ctx );
- return NULL;
- }
-
+ if (pipe == NULL)
+ goto fail;
+
assert(!pipe->priv);
pipe->priv = hdc;
ctx->st = st_create_context( pipe, visual, NULL );
- if (ctx->st == NULL) {
- pipe->destroy( pipe );
- _mesa_destroy_visual( visual );
- FREE( ctx );
- return NULL;
- }
+ if (ctx->st == NULL)
+ goto fail;
+
ctx->st->ctx->DriverCtx = ctx;
ctx->next = ctx_head;
ctx_head = ctx;
- return (HGLRC) ctx;
-}
-
-WINGDIAPI HGLRC APIENTRY
-wglCreateLayerContext(
- HDC hdc,
- int iLayerPlane )
-{
- (void) hdc;
- (void) iLayerPlane;
+ return ctx;
+fail:
+ if (visual)
+ _mesa_destroy_visual( visual );
+
+ if (pipe)
+ pipe->destroy( pipe );
+
+ FREE( ctx );
return NULL;
}
-WINGDIAPI BOOL APIENTRY
-wglDeleteContext(
- HGLRC hglrc )
+
+BOOL
+stw_delete_context(
+ struct stw_context *hglrc )
{
- struct wgl_context **link = &ctx_head;
- struct wgl_context *ctx = ctx_head;
+ struct stw_context **link = &ctx_head;
+ struct stw_context *ctx = ctx_head;
while (ctx != NULL) {
- if (ctx == (struct wgl_context *) hglrc) {
+ if (ctx == hglrc) {
GLcontext *glctx = ctx->st->ctx;
GET_CURRENT_CONTEXT( glcurctx );
struct stw_framebuffer *fb;
@@ -198,24 +193,24 @@ get_window_size( HDC hdc, GLuint *width, GLuint *height )
}
}
-WINGDIAPI HGLRC APIENTRY
-wglGetCurrentContext( VOID )
+struct stw_context *
+stw_get_current_context( void )
{
return current_hrc;
}
-WINGDIAPI HDC APIENTRY
-wglGetCurrentDC( VOID )
+HDC
+stw_get_current_dc( void )
{
return current_hdc;
}
-WINGDIAPI BOOL APIENTRY
-wglMakeCurrent(
+BOOL
+stw_make_current(
HDC hdc,
- HGLRC hglrc )
+ struct stw_context *hglrc )
{
- struct wgl_context *ctx = ctx_head;
+ struct stw_context *ctx = ctx_head;
GET_CURRENT_CONTEXT( glcurctx );
struct stw_framebuffer *fb;
GLuint width = 0;
@@ -230,7 +225,7 @@ wglMakeCurrent(
}
while (ctx != NULL) {
- if (ctx == (struct wgl_context *) hglrc)
+ if (ctx == hglrc)
break;
ctx = ctx->next;
}
@@ -240,7 +235,7 @@ wglMakeCurrent(
/* Return if already current.
*/
if (glcurctx != NULL) {
- struct wgl_context *curctx = (struct wgl_context *) glcurctx->DriverCtx;
+ struct stw_context *curctx = (struct stw_context *) glcurctx->DriverCtx;
if (curctx != NULL && curctx == ctx && ctx->hdc == hdc)
return TRUE;
@@ -279,11 +274,11 @@ wglMakeCurrent(
return TRUE;
}
-struct wgl_context *
-wgl_context_from_hdc(
+struct stw_context *
+stw_context_from_hdc(
HDC hdc )
{
- struct wgl_context *ctx = ctx_head;
+ struct stw_context *ctx = ctx_head;
while (ctx != NULL) {
if (ctx->hdc == hdc)
@@ -293,4 +288,5 @@ wgl_context_from_hdc(
return NULL;
}
-#include "stw_wgl.c"
+
+
diff --git a/src/mesa/state_tracker/wgl/stw_wgl_context.h b/src/gallium/state_trackers/wgl/shared/stw_context.h
index d87b3bdce23..89a8f900d81 100644
--- a/src/mesa/state_tracker/wgl/stw_wgl_context.h
+++ b/src/gallium/state_trackers/wgl/shared/stw_context.h
@@ -25,22 +25,29 @@
*
**************************************************************************/
-#ifndef WGL_CONTEXT_H
-#define WGL_CONTEXT_H
+#ifndef STW_CONTEXT_H
+#define STW_CONTEXT_H
#include <windows.h>
struct st_context;
-struct wgl_context
+struct stw_context
{
struct st_context *st;
HDC hdc;
DWORD color_bits;
- struct wgl_context *next;
+ struct stw_context *next;
};
-struct wgl_context *
-wgl_context_from_hdc(HDC hdc );
+struct stw_context *
+stw_context_from_hdc(HDC hdc );
-#endif /* WGL_CONTEXT_H */
+
+
+
+
+
+
+
+#endif /* STW_CONTEXT_H */
diff --git a/src/mesa/state_tracker/wgl/stw_device.c b/src/gallium/state_trackers/wgl/shared/stw_device.c
index 4c2fb5c61b6..6873e813ee3 100644
--- a/src/mesa/state_tracker/wgl/stw_device.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_device.c
@@ -30,9 +30,11 @@
#include "pipe/p_debug.h"
#include "pipe/p_screen.h"
-#include "stw_device.h"
-#include "stw_winsys.h"
-#include "stw_pixelformat.h"
+#include "shared/stw_device.h"
+#include "shared/stw_winsys.h"
+#include "shared/stw_pixelformat.h"
+#include "shared/stw_public.h"
+#include "stw.h"
struct stw_device *stw_dev = NULL;
@@ -55,7 +57,7 @@ st_flush_frontbuffer(struct pipe_screen *screen,
boolean
-st_init(const struct stw_winsys *stw_winsys)
+stw_shared_init(const struct stw_winsys *stw_winsys)
{
static struct stw_device stw_dev_storage;
@@ -83,17 +85,7 @@ error1:
void
-st_cleanup(void)
+stw_shared_cleanup(void)
{
- DHGLRC dhglrc;
-
- if(!stw_dev)
- return;
-
- /* Ensure all contexts are destroyed */
- for (dhglrc = 1; dhglrc <= DRV_CONTEXT_MAX; dhglrc++)
- if (stw_dev->ctx_array[dhglrc - 1].hglrc)
- DrvDeleteContext( dhglrc );
-
stw_dev = NULL;
}
diff --git a/src/mesa/state_tracker/wgl/stw_device.h b/src/gallium/state_trackers/wgl/shared/stw_device.h
index e2020bf0554..bc0bce37c6e 100644
--- a/src/mesa/state_tracker/wgl/stw_device.h
+++ b/src/gallium/state_trackers/wgl/shared/stw_device.h
@@ -29,28 +29,12 @@
#define ST_DEVICE_H_
-#include "stw_icd.h"
-
struct pipe_screen;
-
-struct drv_context
-{
- HGLRC hglrc;
-};
-
-#define DRV_CONTEXT_MAX 32
-
-
struct stw_device
{
const struct stw_winsys *stw_winsys;
-
struct pipe_screen *screen;
-
- struct drv_context ctx_array[DRV_CONTEXT_MAX];
-
- DHGLRC ctx_current;
};
diff --git a/src/mesa/state_tracker/wgl/stw_framebuffer.c b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c
index 1ecafa451ee..c70b31a4881 100644
--- a/src/mesa/state_tracker/wgl/stw_framebuffer.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c
@@ -29,9 +29,14 @@
#include "main/context.h"
#include "pipe/p_format.h"
+#include "pipe/p_screen.h"
#include "state_tracker/st_context.h"
#include "state_tracker/st_public.h"
#include "stw_framebuffer.h"
+#include "stw_device.h"
+#include "stw_public.h"
+#include "stw_winsys.h"
+
void
framebuffer_resize(
@@ -166,7 +171,7 @@ framebuffer_destroy(
}
}
-/* Given an hdc, return the corresponding wgl_context.
+/* Given an hdc, return the corresponding stw_framebuffer.
*/
struct stw_framebuffer *
framebuffer_from_hdc(
@@ -179,3 +184,29 @@ framebuffer_from_hdc(
return fb;
return NULL;
}
+
+
+BOOL
+stw_swap_buffers(
+ HDC hdc )
+{
+ struct stw_framebuffer *fb;
+ struct pipe_surface *surf;
+
+ fb = framebuffer_from_hdc( hdc );
+ if (fb == NULL)
+ return FALSE;
+
+ /* If we're swapping the buffer associated with the current context
+ * we have to flush any pending rendering commands first.
+ */
+ st_notify_swapbuffers( fb->stfb );
+
+ st_get_framebuffer_surface( fb->stfb, ST_SURFACE_BACK_LEFT, &surf );
+
+ stw_dev->stw_winsys->flush_frontbuffer(stw_dev->screen,
+ surf,
+ hdc );
+
+ return TRUE;
+}
diff --git a/src/mesa/state_tracker/wgl/stw_framebuffer.h b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.h
index 2e16e421f2c..2e16e421f2c 100644
--- a/src/mesa/state_tracker/wgl/stw_framebuffer.h
+++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.h
diff --git a/src/mesa/state_tracker/wgl/stw_wgl_getprocaddress.c b/src/gallium/state_trackers/wgl/shared/stw_getprocaddress.c
index ec92d2dfce2..ac2d6fc2605 100644
--- a/src/mesa/state_tracker/wgl/stw_wgl_getprocaddress.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_getprocaddress.c
@@ -28,8 +28,9 @@
#include <windows.h>
#include "glapi/glapi.h"
-#include "stw_wgl_arbextensionsstring.h"
-#include "stw_wgl_arbpixelformat.h"
+#include "stw_arbextensionsstring.h"
+#include "stw_arbpixelformat.h"
+#include "stw_public.h"
struct extension_entry
{
@@ -52,8 +53,8 @@ static struct extension_entry extension_entries[] = {
{ NULL, NULL }
};
-WINGDIAPI PROC APIENTRY
-wglGetProcAddress(
+PROC
+stw_get_proc_address(
LPCSTR lpszProc )
{
struct extension_entry *entry;
diff --git a/src/mesa/state_tracker/wgl/stw_wgl_pixelformat.c b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c
index 7a8a2e22e49..12b5ac6d91e 100644
--- a/src/mesa/state_tracker/wgl/stw_wgl_pixelformat.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.c
@@ -1,8 +1,8 @@
/**************************************************************************
- *
+ *
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -10,11 +10,11 @@
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
- *
+ *
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
@@ -22,87 +22,110 @@
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
+ *
**************************************************************************/
-#include <windows.h>
-
-#include "pipe/p_compiler.h"
#include "pipe/p_debug.h"
#include "stw_pixelformat.h"
-#include "stw_wgl.h"
+#include "stw_public.h"
+
+#define MAX_PIXELFORMATS 16
+
+static struct pixelformat_info pixelformats[MAX_PIXELFORMATS];
+static uint pixelformat_count = 0;
+static uint pixelformat_extended_count = 0;
static uint currentpixelformat = 0;
-WINGDIAPI int APIENTRY
-wglChoosePixelFormat(
- HDC hdc,
- CONST PIXELFORMATDESCRIPTOR *ppfd )
+
+static void
+add_standard_pixelformats(
+ struct pixelformat_info **ppf,
+ uint flags )
{
- uint count;
- uint index;
- uint bestindex;
- uint bestdelta;
+ struct pixelformat_info *pf = *ppf;
+ struct pixelformat_color_info color24 = { 8, 0, 8, 8, 8, 16 };
+ struct pixelformat_alpha_info alpha8 = { 8, 24 };
+ struct pixelformat_alpha_info noalpha = { 0, 0 };
+ struct pixelformat_depth_info depth24s8 = { 24, 8 };
+ struct pixelformat_depth_info depth16 = { 16, 0 };
- (void) hdc;
+ pf->flags = PF_FLAG_DOUBLEBUFFER | flags;
+ pf->color = color24;
+ pf->alpha = alpha8;
+ pf->depth = depth16;
+ pf++;
- count = pixelformat_get_count();
- bestindex = count;
- bestdelta = 0xffffffff;
+ pf->flags = PF_FLAG_DOUBLEBUFFER | flags;
+ pf->color = color24;
+ pf->alpha = alpha8;
+ pf->depth = depth24s8;
+ pf++;
- if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ) || ppfd->nVersion != 1)
- return 0;
- if (ppfd->iPixelType != PFD_TYPE_RGBA)
- return 0;
- if (!(ppfd->dwFlags & PFD_DRAW_TO_WINDOW))
- return 0;
- if (!(ppfd->dwFlags & PFD_SUPPORT_OPENGL))
- return 0;
- if (ppfd->dwFlags & PFD_DRAW_TO_BITMAP)
- return 0;
- if (ppfd->dwFlags & PFD_SUPPORT_GDI)
- return 0;
- if (!(ppfd->dwFlags & PFD_STEREO_DONTCARE) && (ppfd->dwFlags & PFD_STEREO))
- return 0;
+ pf->flags = PF_FLAG_DOUBLEBUFFER | flags;
+ pf->color = color24;
+ pf->alpha = noalpha;
+ pf->depth = depth16;
+ pf++;
- for (index = 0; index < count; index++) {
- uint delta = 0;
- const struct pixelformat_info *pf = pixelformat_get_info( index );
+ pf->flags = PF_FLAG_DOUBLEBUFFER | flags;
+ pf->color = color24;
+ pf->alpha = noalpha;
+ pf->depth = depth24s8;
+ pf++;
- if (!(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE)) {
- if ((ppfd->dwFlags & PFD_DOUBLEBUFFER) && !(pf->flags & PF_FLAG_DOUBLEBUFFER))
- continue;
- if (!(ppfd->dwFlags & PFD_DOUBLEBUFFER) && (pf->flags & PF_FLAG_DOUBLEBUFFER))
- continue;
- }
+ pf->flags = flags;
+ pf->color = color24;
+ pf->alpha = noalpha;
+ pf->depth = depth16;
+ pf++;
- if (ppfd->cColorBits != pf->color.redbits + pf->color.greenbits + pf->color.bluebits)
- delta += 8;
+ pf->flags = flags;
+ pf->color = color24;
+ pf->alpha = noalpha;
+ pf->depth = depth24s8;
+ pf++;
- if (ppfd->cDepthBits != pf->depth.depthbits)
- delta += 4;
+ *ppf = pf;
+}
- if (ppfd->cStencilBits != pf->depth.stencilbits)
- delta += 2;
+void
+pixelformat_init( void )
+{
+ struct pixelformat_info *pf = pixelformats;
- if (ppfd->cAlphaBits != pf->alpha.alphabits)
- delta++;
+ add_standard_pixelformats( &pf, 0 );
+ pixelformat_count = pf - pixelformats;
- if (delta < bestdelta) {
- bestindex = index;
- bestdelta = delta;
- if (bestdelta == 0)
- break;
- }
- }
+ add_standard_pixelformats( &pf, PF_FLAG_MULTISAMPLED );
+ pixelformat_extended_count = pf - pixelformats;
- if (bestindex == count)
- return 0;
- return bestindex + 1;
+ assert( pixelformat_extended_count <= MAX_PIXELFORMATS );
+}
+
+uint
+pixelformat_get_count( void )
+{
+ return pixelformat_count;
+}
+
+uint
+pixelformat_get_extended_count( void )
+{
+ return pixelformat_extended_count;
}
-WINGDIAPI int APIENTRY
-wglDescribePixelFormat(
+const struct pixelformat_info *
+pixelformat_get_info( uint index )
+{
+ assert( index < pixelformat_extended_count );
+
+ return &pixelformats[index];
+}
+
+
+int
+stw_pixelformat_describe(
HDC hdc,
int iPixelFormat,
UINT nBytes,
@@ -156,32 +179,100 @@ wglDescribePixelFormat(
return count;
}
-WINGDIAPI int APIENTRY
-wglGetPixelFormat(
- HDC hdc )
+/* Only used by the wgl code, but have it here to avoid exporting the
+ * pixelformat.h functionality.
+ */
+int stw_pixelformat_choose( HDC hdc,
+ CONST PIXELFORMATDESCRIPTOR *ppfd )
{
+ uint count;
+ uint index;
+ uint bestindex;
+ uint bestdelta;
+
(void) hdc;
+ count = pixelformat_get_count();
+ bestindex = count;
+ bestdelta = 0xffffffff;
+
+ for (index = 0; index < count; index++) {
+ uint delta = 0;
+ const struct pixelformat_info *pf = pixelformat_get_info( index );
+
+ if (!(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE) &&
+ !!(ppfd->dwFlags & PFD_DOUBLEBUFFER) !=
+ !!(pf->flags & PF_FLAG_DOUBLEBUFFER))
+ continue;
+
+ if (ppfd->cColorBits != pf->color.redbits + pf->color.greenbits + pf->color.bluebits)
+ delta += 8;
+
+ if (ppfd->cDepthBits != pf->depth.depthbits)
+ delta += 4;
+
+ if (ppfd->cStencilBits != pf->depth.stencilbits)
+ delta += 2;
+
+ if (ppfd->cAlphaBits != pf->alpha.alphabits)
+ delta++;
+
+ if (delta < bestdelta) {
+ bestindex = index;
+ bestdelta = delta;
+ if (bestdelta == 0)
+ break;
+ }
+ }
+
+ if (bestindex == count)
+ return 0;
+
+ return bestindex + 1;
+}
+
+
+int
+stw_pixelformat_get(
+ HDC hdc )
+{
return currentpixelformat;
}
-WINGDIAPI BOOL APIENTRY
-wglSetPixelFormat(
+
+BOOL
+stw_pixelformat_set(
HDC hdc,
- int iPixelFormat,
- const PIXELFORMATDESCRIPTOR *ppfd )
+ int iPixelFormat )
{
uint count;
uint index;
(void) hdc;
- count = pixelformat_get_extended_count();
index = (uint) iPixelFormat - 1;
-
- if (index >= count || ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ))
+ count = pixelformat_get_extended_count();
+ if (index >= count)
return FALSE;
- currentpixelformat = index + 1;
+ currentpixelformat = iPixelFormat;
return TRUE;
}
+
+
+
+/* XXX: this needs to be turned into queries on pipe_screen or
+ * stw_winsys.
+ */
+int
+stw_query_sample_buffers( void )
+{
+ return 1;
+}
+
+int
+stw_query_samples( void )
+{
+ return 4;
+}
+
diff --git a/src/mesa/state_tracker/wgl/stw_pixelformat.h b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.h
index 0b67da8d25c..7ca4194a2ae 100644
--- a/src/mesa/state_tracker/wgl/stw_pixelformat.h
+++ b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.h
@@ -28,6 +28,9 @@
#ifndef PIXELFORMAT_H
#define PIXELFORMAT_H
+#include <windows.h>
+#include "pipe/p_compiler.h"
+
#define PF_FLAG_DOUBLEBUFFER 0x00000001
#define PF_FLAG_MULTISAMPLED 0x00000002
@@ -73,4 +76,8 @@ pixelformat_get_extended_count( void );
const struct pixelformat_info *
pixelformat_get_info( uint index );
+int stw_query_sample_buffers( void );
+int stw_query_samples( void );
+
+
#endif /* PIXELFORMAT_H */
diff --git a/src/mesa/state_tracker/wgl/stw_wgl_swapbuffers.c b/src/gallium/state_trackers/wgl/shared/stw_public.h
index 41bfeadfb1b..75b504a50f6 100644
--- a/src/mesa/state_tracker/wgl/stw_wgl_swapbuffers.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_public.h
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2009 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,49 +25,51 @@
*
**************************************************************************/
+#ifndef STW_PUBLIC_H
+#define STW_PUBLIC_H
+
#include <windows.h>
+#include "pipe/p_compiler.h"
+
+struct stw_winsys;
+struct stw_context;
+
+boolean
+st_shared_init(const struct stw_winsys *stw_winsys);
+
+void
+st_shared_cleanup(void);
+
+
+BOOL stw_copy_context( struct stw_context *src,
+ struct stw_context *dst,
+ UINT mask );
+
+struct stw_context *stw_create_context( HDC hdc, int iLayerPlane );
+
+BOOL stw_delete_context( struct stw_context *ctx );
+
+struct stw_context *stw_get_current_context( void );
+
+HDC stw_get_current_dc( void );
+
+BOOL stw_make_current( HDC hdc, struct stw_context *ctx );
+
+BOOL stw_swap_buffers( HDC hdc );
+
+PROC stw_get_proc_address( LPCSTR lpszProc );
+
+int stw_pixelformat_describe( HDC hdc,
+ int iPixelFormat,
+ UINT nBytes,
+ LPPIXELFORMATDESCRIPTOR ppfd );
+
+int stw_pixelformat_get( HDC hdc );
+
+BOOL stw_pixelformat_set( HDC hdc,
+ int iPixelFormat );
+
+int stw_pixelformat_choose( HDC hdc,
+ CONST PIXELFORMATDESCRIPTOR *ppfd );
-#include "pipe/p_screen.h"
-#include "pipe/p_context.h"
-#include "state_tracker/st_context.h"
-#include "state_tracker/st_public.h"
-#include "stw_winsys.h"
-#include "stw_device.h"
-#include "stw_framebuffer.h"
-#include "stw_wgl.h"
-
-WINGDIAPI BOOL APIENTRY
-wglSwapBuffers(
- HDC hdc )
-{
- struct stw_framebuffer *fb;
- struct pipe_surface *surf;
-
- fb = framebuffer_from_hdc( hdc );
- if (fb == NULL)
- return FALSE;
-
- /* If we're swapping the buffer associated with the current context
- * we have to flush any pending rendering commands first.
- */
- st_notify_swapbuffers( fb->stfb );
-
- st_get_framebuffer_surface( fb->stfb, ST_SURFACE_BACK_LEFT, &surf );
-
- stw_dev->stw_winsys->flush_frontbuffer(stw_dev->screen,
- surf,
- hdc );
-
- return TRUE;
-}
-
-WINGDIAPI BOOL APIENTRY
-wglSwapLayerBuffers(
- HDC hdc,
- UINT fuPlanes )
-{
- (void) hdc;
- (void) fuPlanes;
-
- return FALSE;
-}
+#endif
diff --git a/src/mesa/state_tracker/wgl/stw_quirks.c b/src/gallium/state_trackers/wgl/shared/stw_quirks.c
index bf1ec3fee76..bf1ec3fee76 100644
--- a/src/mesa/state_tracker/wgl/stw_quirks.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_quirks.c
diff --git a/src/mesa/state_tracker/wgl/stw_winsys.h b/src/gallium/state_trackers/wgl/shared/stw_winsys.h
index a85a9a22577..a85a9a22577 100644
--- a/src/mesa/state_tracker/wgl/stw_winsys.h
+++ b/src/gallium/state_trackers/wgl/shared/stw_winsys.h
diff --git a/src/mesa/state_tracker/wgl/stw_wgl_arbmultisample.c b/src/gallium/state_trackers/wgl/stw.c
index aad04e3e8a2..8bccdad2211 100644
--- a/src/mesa/state_tracker/wgl/stw_wgl_arbmultisample.c
+++ b/src/gallium/state_trackers/wgl/stw.c
@@ -1,8 +1,8 @@
/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ *
+ * Copyright 2009, VMware, Inc.
* All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -10,11 +10,11 @@
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
- *
+ *
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
@@ -22,20 +22,36 @@
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
+ *
**************************************************************************/
-#include <windows.h>
-#include "stw_wgl_arbmultisample.h"
+#include "stw.h"
+#include "shared/stw_winsys.h"
-int
-wgl_query_sample_buffers( void )
+boolean
+st_init(const struct stw_winsys *stw_winsys)
{
- return 1;
+ if (!stw_shared_init( stw_winsys ))
+ goto fail;
+
+ if (!stw_icd_init())
+ goto fail;
+
+ if (!stw_wgl_init())
+ goto fail;
+
+ return TRUE;
+
+fail:
+ st_cleanup();
+ return FALSE;
}
-int
-wgl_query_samples( void )
+
+void
+st_cleanup(void)
{
- return 4;
+ stw_icd_cleanup();
+ stw_shared_cleanup();
+ stw_wgl_cleanup();
}
diff --git a/src/mesa/state_tracker/wgl/stw_wgl_arbmultisample.h b/src/gallium/state_trackers/wgl/stw.h
index de3e2cc6a33..450af4ccb6f 100644
--- a/src/mesa/state_tracker/wgl/stw_wgl_arbmultisample.h
+++ b/src/gallium/state_trackers/wgl/stw.h
@@ -1,8 +1,8 @@
/**************************************************************************
- *
+ *
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -10,11 +10,11 @@
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
- *
+ *
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
@@ -22,19 +22,32 @@
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
+ *
**************************************************************************/
-#ifndef WGL_ARBMULTISAMPLE_H
-#define WGL_ARBMULTISAMPLE_H
+#ifndef STW_H
+#define STW_H
-#define WGL_SAMPLE_BUFFERS_ARB 0x2041
-#define WGL_SAMPLES_ARB 0x2042
+#include "pipe/p_compiler.h"
-int
-wgl_query_sample_buffers( void );
+struct stw_winsys;
-int
-wgl_query_samples( void );
+/* Public interface:
+ */
+boolean stw_init( const struct stw_winsys *stw_winsys );
+void stw_cleanup( void );
-#endif /* WGL_ARBMULTISAMPLE_H */
+
+
+/* Internal functions
+ */
+boolean stw_shared_init( const struct stw_winsys *stw_winsys );
+boolean stw_icd_init( void );
+boolean stw_wgl_init( void );
+
+void stw_shared_cleanup( void );
+void stw_icd_cleanup( void );
+void stw_wgl_cleanup( void );
+
+
+#endif /* STW_H */
diff --git a/src/mesa/state_tracker/wgl/stw_wgl.c b/src/gallium/state_trackers/wgl/wgl/stw_wgl.c
index 0528c369fc8..f50b79b4e11 100644
--- a/src/mesa/state_tracker/wgl/stw_wgl.c
+++ b/src/gallium/state_trackers/wgl/wgl/stw_wgl.c
@@ -28,6 +28,160 @@
#include <windows.h>
#include "pipe/p_debug.h"
+#include "shared/stw_public.h"
+#include "stw_wgl.h"
+#include "stw.h"
+
+boolean stw_wgl_init( void )
+{
+ debug_printf("%s\n", __FUNCTION__);
+ return TRUE;
+}
+
+void stw_wgl_cleanup( void )
+{
+}
+
+static INLINE struct stw_context *stw_context( HGLRC hglrc )
+{
+ return (struct stw_context *)hglrc;
+}
+
+
+WINGDIAPI BOOL APIENTRY
+wglCopyContext(
+ HGLRC hglrcSrc,
+ HGLRC hglrcDst,
+ UINT mask )
+{
+ return stw_copy_context( stw_context(hglrcSrc),
+ stw_context(hglrcDst),
+ mask );
+}
+
+WINGDIAPI HGLRC APIENTRY
+wglCreateContext(
+ HDC hdc )
+{
+ return (HGLRC) stw_create_context( hdc, 0 );
+}
+
+WINGDIAPI HGLRC APIENTRY
+wglCreateLayerContext(
+ HDC hdc,
+ int iLayerPlane )
+{
+ return (HGLRC) stw_create_context( hdc, iLayerPlane );
+}
+
+WINGDIAPI BOOL APIENTRY
+wglDeleteContext(
+ HGLRC hglrc )
+{
+ return stw_delete_context( stw_context(hglrc) );
+}
+
+
+WINGDIAPI HGLRC APIENTRY
+wglGetCurrentContext( VOID )
+{
+ return (HGLRC) stw_get_current_context();
+}
+
+WINGDIAPI HDC APIENTRY
+wglGetCurrentDC( VOID )
+{
+ return stw_get_current_dc();
+}
+
+WINGDIAPI BOOL APIENTRY
+wglMakeCurrent(
+ HDC hdc,
+ HGLRC hglrc )
+{
+ return stw_make_current( hdc, stw_context(hglrc) );
+}
+
+
+WINGDIAPI BOOL APIENTRY
+wglSwapBuffers(
+ HDC hdc )
+{
+ return stw_swap_buffers( hdc );
+}
+
+
+WINGDIAPI BOOL APIENTRY
+wglSwapLayerBuffers(
+ HDC hdc,
+ UINT fuPlanes )
+{
+ (void) hdc;
+ (void) fuPlanes;
+
+ return FALSE;
+}
+
+WINGDIAPI PROC APIENTRY
+wglGetProcAddress(
+ LPCSTR lpszProc )
+{
+ return stw_get_proc_address( lpszProc );
+}
+
+
+WINGDIAPI int APIENTRY
+wglChoosePixelFormat(
+ HDC hdc,
+ CONST PIXELFORMATDESCRIPTOR *ppfd )
+{
+ if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ) || ppfd->nVersion != 1)
+ return 0;
+ if (ppfd->iPixelType != PFD_TYPE_RGBA)
+ return 0;
+ if (!(ppfd->dwFlags & PFD_DRAW_TO_WINDOW))
+ return 0;
+ if (!(ppfd->dwFlags & PFD_SUPPORT_OPENGL))
+ return 0;
+ if (ppfd->dwFlags & PFD_DRAW_TO_BITMAP)
+ return 0;
+ if (ppfd->dwFlags & PFD_SUPPORT_GDI)
+ return 0;
+ if (!(ppfd->dwFlags & PFD_STEREO_DONTCARE) && (ppfd->dwFlags & PFD_STEREO))
+ return 0;
+
+ return stw_pixelformat_choose( hdc, ppfd );
+}
+
+WINGDIAPI int APIENTRY
+wglDescribePixelFormat(
+ HDC hdc,
+ int iPixelFormat,
+ UINT nBytes,
+ LPPIXELFORMATDESCRIPTOR ppfd )
+{
+ return stw_pixelformat_describe( hdc, iPixelFormat, nBytes, ppfd );
+}
+
+WINGDIAPI int APIENTRY
+wglGetPixelFormat(
+ HDC hdc )
+{
+ return stw_pixelformat_get( hdc );
+}
+
+WINGDIAPI BOOL APIENTRY
+wglSetPixelFormat(
+ HDC hdc,
+ int iPixelFormat,
+ const PIXELFORMATDESCRIPTOR *ppfd )
+{
+ if (ppfd->nSize != sizeof( PIXELFORMATDESCRIPTOR ))
+ return FALSE;
+
+ return stw_pixelformat_set( hdc, iPixelFormat );
+}
+
WINGDIAPI BOOL APIENTRY
wglUseFontBitmapsA(
diff --git a/src/mesa/state_tracker/wgl/stw_wgl.h b/src/gallium/state_trackers/wgl/wgl/stw_wgl.h
index b86cc240f28..b86cc240f28 100644
--- a/src/mesa/state_tracker/wgl/stw_wgl.h
+++ b/src/gallium/state_trackers/wgl/wgl/stw_wgl.h
diff --git a/src/mesa/SConscript b/src/mesa/SConscript
index 01620ee6147..a878d31dbb5 100644
--- a/src/mesa/SConscript
+++ b/src/mesa/SConscript
@@ -341,5 +341,3 @@ if env['platform'] != 'winddk':
)
Export('glapi')
- if platform == 'windows':
- SConscript('state_tracker/wgl/SConscript')
diff --git a/src/mesa/state_tracker/wgl/stw_pixelformat.c b/src/mesa/state_tracker/wgl/stw_pixelformat.c
deleted file mode 100644
index 7a054af3d3e..00000000000
--- a/src/mesa/state_tracker/wgl/stw_pixelformat.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "pipe/p_debug.h"
-#include "stw_pixelformat.h"
-
-#define MAX_PIXELFORMATS 16
-
-static struct pixelformat_info pixelformats[MAX_PIXELFORMATS];
-static uint pixelformat_count = 0;
-static uint pixelformat_extended_count = 0;
-
-static void
-add_standard_pixelformats(
- struct pixelformat_info **ppf,
- uint flags )
-{
- struct pixelformat_info *pf = *ppf;
- struct pixelformat_color_info color24 = { 8, 0, 8, 8, 8, 16 };
- struct pixelformat_alpha_info alpha8 = { 8, 24 };
- struct pixelformat_alpha_info noalpha = { 0, 0 };
- struct pixelformat_depth_info depth24s8 = { 24, 8 };
- struct pixelformat_depth_info depth16 = { 16, 0 };
-
- pf->flags = PF_FLAG_DOUBLEBUFFER | flags;
- pf->color = color24;
- pf->alpha = alpha8;
- pf->depth = depth16;
- pf++;
-
- pf->flags = PF_FLAG_DOUBLEBUFFER | flags;
- pf->color = color24;
- pf->alpha = alpha8;
- pf->depth = depth24s8;
- pf++;
-
- pf->flags = PF_FLAG_DOUBLEBUFFER | flags;
- pf->color = color24;
- pf->alpha = noalpha;
- pf->depth = depth16;
- pf++;
-
- pf->flags = PF_FLAG_DOUBLEBUFFER | flags;
- pf->color = color24;
- pf->alpha = noalpha;
- pf->depth = depth24s8;
- pf++;
-
- pf->flags = flags;
- pf->color = color24;
- pf->alpha = noalpha;
- pf->depth = depth16;
- pf++;
-
- pf->flags = flags;
- pf->color = color24;
- pf->alpha = noalpha;
- pf->depth = depth24s8;
- pf++;
-
- *ppf = pf;
-}
-
-void
-pixelformat_init( void )
-{
- struct pixelformat_info *pf = pixelformats;
-
- add_standard_pixelformats( &pf, 0 );
- pixelformat_count = pf - pixelformats;
-
- add_standard_pixelformats( &pf, PF_FLAG_MULTISAMPLED );
- pixelformat_extended_count = pf - pixelformats;
-
- assert( pixelformat_extended_count <= MAX_PIXELFORMATS );
-}
-
-uint
-pixelformat_get_count( void )
-{
- return pixelformat_count;
-}
-
-uint
-pixelformat_get_extended_count( void )
-{
- return pixelformat_extended_count;
-}
-
-const struct pixelformat_info *
-pixelformat_get_info( uint index )
-{
- assert( index < pixelformat_extended_count );
-
- return &pixelformats[index];
-}