diff options
-rw-r--r-- | src/gallium/state_trackers/wgl/SConscript | 1 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/icd/stw_icd.c | 64 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/shared/stw_device.c | 16 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/shared/stw_device.h | 16 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/shared/stw_framebuffer.c | 31 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/shared/stw_pixelformat.h | 1 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/stw.c | 57 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/stw.h | 53 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/wgl/stw_wgl.c | 13 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/wgl/stw_wgl_arbpixelformat.c | 2 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/wgl/stw_wgl_pixelformat.c | 2 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/wgl/stw_wgl_swapbuffers.c | 29 |
12 files changed, 217 insertions, 68 deletions
diff --git a/src/gallium/state_trackers/wgl/SConscript b/src/gallium/state_trackers/wgl/SConscript index 37eb650c87..1accc26d39 100644 --- a/src/gallium/state_trackers/wgl/SConscript +++ b/src/gallium/state_trackers/wgl/SConscript @@ -19,6 +19,7 @@ if env['platform'] in ['windows']: ]) sources = [ + 'stw.c', 'icd/stw_icd.c', 'shared/stw_context.c', 'shared/stw_device.c', diff --git a/src/gallium/state_trackers/wgl/icd/stw_icd.c b/src/gallium/state_trackers/wgl/icd/stw_icd.c index 9c28442c1f..8cc0932de9 100644 --- a/src/gallium/state_trackers/wgl/icd/stw_icd.c +++ b/src/gallium/state_trackers/wgl/icd/stw_icd.c @@ -32,11 +32,55 @@ #include "pipe/p_debug.h" -#include "shared/stw_device.h" -#include "shared/stw_context.h" -#include "shared/stw_pixelformat.h" +#include "shared/stw_public.h" #include "icd/stw_icd.h" #include "wgl/stw_wgl.h" +#include "stw.h" + + +#define DRV_CONTEXT_MAX 32 + +struct stw_icd +{ + struct { + HGLRC hglrc; + } 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) +{ + DHGLRC dhglrc; + + if(!stw_icd) + return; + + /* Ensure all contexts are destroyed */ + for (dhglrc = 1; dhglrc <= DRV_CONTEXT_MAX; dhglrc++) + if (stw_icd->ctx_array[dhglrc - 1].hglrc) + DrvDeleteContext( dhglrc ); + + stw_icd = NULL; +} static HGLRC @@ -46,7 +90,7 @@ lookup_hglrc( DHGLRC dhglrc ) dhglrc >= DRV_CONTEXT_MAX) return NULL; - return stw_dev->ctx_array[dhglrc - 1].hglrc; + return stw_icd->ctx_array[dhglrc - 1].hglrc; } BOOL APIENTRY @@ -73,7 +117,7 @@ DrvCreateLayerContext( DWORD i; for (i = 0; i < DRV_CONTEXT_MAX; i++) { - if (stw_dev->ctx_array[i].hglrc == NULL) + if (stw_icd->ctx_array[i].hglrc == NULL) goto found_slot; } @@ -82,8 +126,8 @@ DrvCreateLayerContext( return 0; found_slot: - stw_dev->ctx_array[i].hglrc = stw_create_context( hdc, iLayerPlane ); - if (stw_dev->ctx_array[i].hglrc == NULL) + stw_icd->ctx_array[i].hglrc = stw_create_context( hdc, iLayerPlane ); + if (stw_icd->ctx_array[i].hglrc == NULL) return 0; return (DHGLRC) i + 1; @@ -106,7 +150,7 @@ DrvDeleteContext( if (hglrc != NULL) { success = stw_delete_context( hglrc ); if (success) - stw_dev->ctx_array[dhglrc - 1].hglrc = NULL; + stw_icd->ctx_array[dhglrc - 1].hglrc = NULL; } debug_printf( "%s( %u ) = %s\n", __FUNCTION__, dhglrc, success ? "TRUE" : "FALSE" ); @@ -187,13 +231,13 @@ DrvReleaseContext( { BOOL success = FALSE; - if (dhglrc == stw_dev->ctx_current) { + if (dhglrc == stw_icd->ctx_current) { HGLRC hglrc = lookup_hglrc( dhglrc ); if (hglrc != NULL) { success = wglMakeCurrent( NULL, NULL ); if (success) - stw_dev->ctx_current = 0; + stw_icd->ctx_current = 0; } } diff --git a/src/gallium/state_trackers/wgl/shared/stw_device.c b/src/gallium/state_trackers/wgl/shared/stw_device.c index 63ee066824..88eeae7de7 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_device.c +++ b/src/gallium/state_trackers/wgl/shared/stw_device.c @@ -34,6 +34,8 @@ #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; @@ -57,7 +59,7 @@ st_flush_frontbuffer(struct pipe_winsys *ws, 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; @@ -86,17 +88,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/gallium/state_trackers/wgl/shared/stw_device.h b/src/gallium/state_trackers/wgl/shared/stw_device.h index 2babc654da..bc0bce37c6 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_device.h +++ b/src/gallium/state_trackers/wgl/shared/stw_device.h @@ -29,28 +29,12 @@ #define ST_DEVICE_H_ -#include "icd/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/gallium/state_trackers/wgl/shared/stw_framebuffer.c b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c index 1ecafa451e..50edf7306d 100644 --- a/src/gallium/state_trackers/wgl/shared/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( @@ -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->winsys, + surf, + hdc ); + + return TRUE; +} diff --git a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.h b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.h index 982de22666..ab5dcfc672 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_pixelformat.h +++ b/src/gallium/state_trackers/wgl/shared/stw_pixelformat.h @@ -29,6 +29,7 @@ #define PIXELFORMAT_H #include <windows.h> +#include "pipe/p_compiler.h" #define PF_FLAG_DOUBLEBUFFER 0x00000001 #define PF_FLAG_MULTISAMPLED 0x00000002 diff --git a/src/gallium/state_trackers/wgl/stw.c b/src/gallium/state_trackers/wgl/stw.c new file mode 100644 index 0000000000..8bccdad221 --- /dev/null +++ b/src/gallium/state_trackers/wgl/stw.c @@ -0,0 +1,57 @@ +/************************************************************************** + * + * 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 + * 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 "stw.h" +#include "shared/stw_winsys.h" + +boolean +st_init(const struct stw_winsys *stw_winsys) +{ + 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; +} + + +void +st_cleanup(void) +{ + stw_icd_cleanup(); + stw_shared_cleanup(); + stw_wgl_cleanup(); +} diff --git a/src/gallium/state_trackers/wgl/stw.h b/src/gallium/state_trackers/wgl/stw.h new file mode 100644 index 0000000000..450af4ccb6 --- /dev/null +++ b/src/gallium/state_trackers/wgl/stw.h @@ -0,0 +1,53 @@ +/************************************************************************** + * + * 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. + * + **************************************************************************/ + +#ifndef STW_H +#define STW_H + +#include "pipe/p_compiler.h" + +struct stw_winsys; + +/* Public interface: + */ +boolean stw_init( const struct stw_winsys *stw_winsys ); +void stw_cleanup( void ); + + + +/* 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/gallium/state_trackers/wgl/wgl/stw_wgl.c b/src/gallium/state_trackers/wgl/wgl/stw_wgl.c index f6a4f66dd7..8f7ec8ddd4 100644 --- a/src/gallium/state_trackers/wgl/wgl/stw_wgl.c +++ b/src/gallium/state_trackers/wgl/wgl/stw_wgl.c @@ -28,8 +28,19 @@ #include <windows.h> #include "pipe/p_debug.h" -#include "shared/stw_context.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 ) +{ +} WINGDIAPI BOOL APIENTRY diff --git a/src/gallium/state_trackers/wgl/wgl/stw_wgl_arbpixelformat.c b/src/gallium/state_trackers/wgl/wgl/stw_wgl_arbpixelformat.c index a1e6fc2ca4..6adb05ea1f 100644 --- a/src/gallium/state_trackers/wgl/wgl/stw_wgl_arbpixelformat.c +++ b/src/gallium/state_trackers/wgl/wgl/stw_wgl_arbpixelformat.c @@ -29,7 +29,7 @@ #include "pipe/p_compiler.h" #include "util/u_memory.h" -#include "shared/stw_pixelformat.h" +#include "shared/stw_public.h" #include "stw_wgl_arbmultisample.h" #include "stw_wgl_arbpixelformat.h" diff --git a/src/gallium/state_trackers/wgl/wgl/stw_wgl_pixelformat.c b/src/gallium/state_trackers/wgl/wgl/stw_wgl_pixelformat.c index 40c6eaf594..11438172e6 100644 --- a/src/gallium/state_trackers/wgl/wgl/stw_wgl_pixelformat.c +++ b/src/gallium/state_trackers/wgl/wgl/stw_wgl_pixelformat.c @@ -29,7 +29,7 @@ #include "pipe/p_compiler.h" #include "pipe/p_debug.h" -#include "shared/stw_pixelformat.h" +#include "shared/stw_public.h" #include "stw_wgl.h" WINGDIAPI int APIENTRY diff --git a/src/gallium/state_trackers/wgl/wgl/stw_wgl_swapbuffers.c b/src/gallium/state_trackers/wgl/wgl/stw_wgl_swapbuffers.c index c0af8bc4f6..9984f9860c 100644 --- a/src/gallium/state_trackers/wgl/wgl/stw_wgl_swapbuffers.c +++ b/src/gallium/state_trackers/wgl/wgl/stw_wgl_swapbuffers.c @@ -27,39 +27,14 @@ #include <windows.h> -#include "pipe/p_winsys.h" -#include "pipe/p_screen.h" -#include "pipe/p_context.h" -#include "state_tracker/st_context.h" -#include "state_tracker/st_public.h" -#include "shared/stw_winsys.h" -#include "shared/stw_device.h" -#include "shared/stw_framebuffer.h" +#include "shared/stw_public.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->winsys, - surf, - hdc ); - - return TRUE; + return stw_swap_buffers( hdc ); } WINGDIAPI BOOL APIENTRY |