summaryrefslogtreecommitdiff
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/wgl/SConscript4
-rw-r--r--src/gallium/state_trackers/wgl/icd/stw_icd.c60
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_context.c (renamed from src/gallium/state_trackers/wgl/wgl/stw_wgl_context.c)48
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_context.h (renamed from src/gallium/state_trackers/wgl/wgl/stw_wgl_context.h)27
-rw-r--r--src/gallium/state_trackers/wgl/wgl/stw_wgl.c57
5 files changed, 139 insertions, 57 deletions
diff --git a/src/gallium/state_trackers/wgl/SConscript b/src/gallium/state_trackers/wgl/SConscript
index 9516dc5a3c..37eb650c87 100644
--- a/src/gallium/state_trackers/wgl/SConscript
+++ b/src/gallium/state_trackers/wgl/SConscript
@@ -20,6 +20,7 @@ if env['platform'] in ['windows']:
sources = [
'icd/stw_icd.c',
+ 'shared/stw_context.c',
'shared/stw_device.c',
'shared/stw_framebuffer.c',
'shared/stw_pixelformat.c',
@@ -27,8 +28,7 @@ if env['platform'] in ['windows']:
'wgl/stw_wgl_arbextensionsstring.c',
'wgl/stw_wgl_arbmultisample.c',
'wgl/stw_wgl_arbpixelformat.c',
- #'wgl/stw_wgl.c',
- 'wgl/stw_wgl_context.c',
+ 'wgl/stw_wgl.c',
'wgl/stw_wgl_getprocaddress.c',
'wgl/stw_wgl_pixelformat.c',
'wgl/stw_wgl_swapbuffers.c',
diff --git a/src/gallium/state_trackers/wgl/icd/stw_icd.c b/src/gallium/state_trackers/wgl/icd/stw_icd.c
index bf057eb83b..94c6dfe108 100644
--- a/src/gallium/state_trackers/wgl/icd/stw_icd.c
+++ b/src/gallium/state_trackers/wgl/icd/stw_icd.c
@@ -33,15 +33,18 @@
#include "pipe/p_debug.h"
#include "shared/stw_device.h"
+#include "shared/stw_context.h"
#include "icd/stw_icd.h"
#include "wgl/stw_wgl.h"
static HGLRC
-_drv_lookup_hglrc( DHGLRC dhglrc )
+lookup_hglrc( DHGLRC dhglrc )
{
- if (dhglrc == 0 || dhglrc >= DRV_CONTEXT_MAX)
+ if (dhglrc == 0 ||
+ dhglrc >= DRV_CONTEXT_MAX)
return NULL;
+
return stw_dev->ctx_array[dhglrc - 1].hglrc;
}
@@ -51,9 +54,14 @@ DrvCopyContext(
DHGLRC dhrcDest,
UINT fuMask )
{
- debug_printf( "%s\n", __FUNCTION__ );
-
- return FALSE;
+ HGLRC src = lookup_hglrc( dhrcSource );
+ HGLRC dst = lookup_hglrc( dhrcDest );
+
+ if (src == NULL ||
+ dst == NULL)
+ return FALSE;
+
+ return stw_wgl_copy_context( src, dst, fuMask );
}
DHGLRC APIENTRY
@@ -61,26 +69,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_dev->ctx_array[i].hglrc == 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_dev->ctx_array[i].hglrc = stw_wgl_create_context( hdc, iLayerPlane );
+ if (stw_dev->ctx_array[i].hglrc == NULL)
+ return 0;
- return dhglrc;
+ return (DHGLRC) i + 1;
}
DHGLRC APIENTRY
@@ -94,11 +99,11 @@ BOOL APIENTRY
DrvDeleteContext(
DHGLRC dhglrc )
{
- HGLRC hglrc = _drv_lookup_hglrc( dhglrc );
+ HGLRC hglrc = lookup_hglrc( dhglrc );
BOOL success = FALSE;
if (hglrc != NULL) {
- success = wglDeleteContext( hglrc );
+ success = stw_wgl_delete_context( hglrc );
if (success)
stw_dev->ctx_array[dhglrc - 1].hglrc = NULL;
}
@@ -132,7 +137,8 @@ DrvDescribePixelFormat(
r = wglDescribePixelFormat( 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;
}
@@ -181,7 +187,7 @@ DrvReleaseContext(
BOOL success = FALSE;
if (dhglrc == stw_dev->ctx_current) {
- HGLRC hglrc = _drv_lookup_hglrc( dhglrc );
+ HGLRC hglrc = lookup_hglrc( dhglrc );
if (hglrc != NULL) {
success = wglMakeCurrent( NULL, NULL );
@@ -215,7 +221,7 @@ DrvSetContext(
DHGLRC dhglrc,
PFN_SETPROCTABLE pfnSetProcTable )
{
- HGLRC hglrc = _drv_lookup_hglrc( dhglrc );
+ HGLRC hglrc = lookup_hglrc( dhglrc );
GLDISPATCHTABLE *disp = &cpt.glDispatchTable;
debug_printf( "%s( 0x%p, %u, 0x%p )\n", __FUNCTION__, hdc, dhglrc, pfnSetProcTable );
diff --git a/src/gallium/state_trackers/wgl/wgl/stw_wgl_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c
index da4688bcb1..b54e084230 100644
--- a/src/gallium/state_trackers/wgl/wgl/stw_wgl_context.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_context.c
@@ -37,17 +37,17 @@
#include "shared/stw_winsys.h"
#include "shared/stw_framebuffer.h"
#include "shared/stw_pixelformat.h"
-#include "stw_wgl_arbmultisample.h"
-#include "stw_wgl_context.h"
-#include "stw_wgl.h"
+#include "wgl/stw_wgl_arbmultisample.h"
+#include "stw_context.h"
+//#include "stw_wgl.h"
static struct wgl_context *ctx_head = NULL;
static HDC current_hdc = NULL;
static HGLRC current_hrc = NULL;
-WINGDIAPI BOOL APIENTRY
-wglCopyContext(
+BOOL
+stw_wgl_copy_context(
HGLRC hglrcSrc,
HGLRC hglrcDst,
UINT mask )
@@ -59,9 +59,10 @@ wglCopyContext(
return FALSE;
}
-WINGDIAPI HGLRC APIENTRY
-wglCreateContext(
- HDC hdc )
+HGLRC
+stw_wgl_create_context(
+ HDC hdc,
+ int iLayerPlane )
{
uint pfi;
const struct pixelformat_info *pf;
@@ -69,6 +70,9 @@ wglCreateContext(
GLvisual *visual;
struct pipe_context *pipe;
+ if (iLayerPlane != 0)
+ return NULL;
+
pfi = wglGetPixelFormat( hdc );
if (pfi == 0)
return NULL;
@@ -130,19 +134,9 @@ wglCreateContext(
return (HGLRC) ctx;
}
-WINGDIAPI HGLRC APIENTRY
-wglCreateLayerContext(
- HDC hdc,
- int iLayerPlane )
-{
- (void) hdc;
- (void) iLayerPlane;
-
- return NULL;
-}
-WINGDIAPI BOOL APIENTRY
-wglDeleteContext(
+BOOL
+stw_wgl_delete_context(
HGLRC hglrc )
{
struct wgl_context **link = &ctx_head;
@@ -198,20 +192,20 @@ get_window_size( HDC hdc, GLuint *width, GLuint *height )
}
}
-WINGDIAPI HGLRC APIENTRY
-wglGetCurrentContext( VOID )
+HGLRC
+stw_wgl_get_current_context( void )
{
return current_hrc;
}
-WINGDIAPI HDC APIENTRY
-wglGetCurrentDC( VOID )
+HDC
+stw_wgl_get_current_dc( void )
{
return current_hdc;
}
-WINGDIAPI BOOL APIENTRY
-wglMakeCurrent(
+BOOL
+stw_wgl_make_current(
HDC hdc,
HGLRC hglrc )
{
@@ -292,5 +286,3 @@ wgl_context_from_hdc(
}
return NULL;
}
-
-#include "stw_wgl.c"
diff --git a/src/gallium/state_trackers/wgl/wgl/stw_wgl_context.h b/src/gallium/state_trackers/wgl/shared/stw_context.h
index d87b3bdce2..b418e4e02a 100644
--- a/src/gallium/state_trackers/wgl/wgl/stw_wgl_context.h
+++ b/src/gallium/state_trackers/wgl/shared/stw_context.h
@@ -43,4 +43,31 @@ struct wgl_context
struct wgl_context *
wgl_context_from_hdc(HDC hdc );
+//////////////////
+
+
+BOOL stw_wgl_copy_context( HGLRC hglrcSrc,
+ HGLRC hglrcDst,
+ UINT mask );
+
+HGLRC stw_wgl_create_context( HDC hdc, int iLayerPlane );
+
+BOOL stw_wgl_delete_context( HGLRC hglrc );
+
+HGLRC stw_wgl_get_current_context( void );
+
+HDC stw_wgl_get_current_dc( void );
+
+BOOL stw_wgl_make_current( HDC hdc, HGLRC hglrc );
+
+
+
+
+
+
+
+
+
+
+
#endif /* WGL_CONTEXT_H */
diff --git a/src/gallium/state_trackers/wgl/wgl/stw_wgl.c b/src/gallium/state_trackers/wgl/wgl/stw_wgl.c
index 0528c369fc..92fd340658 100644
--- a/src/gallium/state_trackers/wgl/wgl/stw_wgl.c
+++ b/src/gallium/state_trackers/wgl/wgl/stw_wgl.c
@@ -28,6 +28,63 @@
#include <windows.h>
#include "pipe/p_debug.h"
+#include "shared/stw_context.h"
+#include "stw_wgl.h"
+
+
+WINGDIAPI BOOL APIENTRY
+wglCopyContext(
+ HGLRC hglrcSrc,
+ HGLRC hglrcDst,
+ UINT mask )
+{
+ return stw_wgl_copy_context( hglrcSrc, hglrcDst, mask );
+}
+
+WINGDIAPI HGLRC APIENTRY
+wglCreateContext(
+ HDC hdc )
+{
+ return (HGLRC) stw_wgl_create_context( hdc, 0 );
+}
+
+WINGDIAPI HGLRC APIENTRY
+wglCreateLayerContext(
+ HDC hdc,
+ int iLayerPlane )
+{
+ return (HGLRC) stw_wgl_create_context( hdc, iLayerPlane );
+}
+
+WINGDIAPI BOOL APIENTRY
+wglDeleteContext(
+ HGLRC hglrc )
+{
+ return stw_wgl_delete_context( hglrc );
+}
+
+
+WINGDIAPI HGLRC APIENTRY
+wglGetCurrentContext( VOID )
+{
+ return stw_wgl_get_current_context();
+}
+
+WINGDIAPI HDC APIENTRY
+wglGetCurrentDC( VOID )
+{
+ return stw_wgl_get_current_dc();
+}
+
+WINGDIAPI BOOL APIENTRY
+wglMakeCurrent(
+ HDC hdc,
+ HGLRC hglrc )
+{
+ return stw_wgl_make_current( hdc, hglrc );
+}
+
+
WINGDIAPI BOOL APIENTRY
wglUseFontBitmapsA(