diff options
Diffstat (limited to 'src/gallium/state_trackers/wgl')
-rw-r--r-- | src/gallium/state_trackers/wgl/SConscript | 2 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/stw_context.c | 124 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/stw_device.c | 10 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/stw_device.h | 4 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/stw_ext_extensionsstring.c | 1 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/stw_ext_pbuffer.c | 212 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/stw_ext_pixelformat.c | 18 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/stw_framebuffer.c | 14 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/stw_framebuffer.h | 4 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/stw_getprocaddress.c | 7 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/stw_pixelformat.c | 2 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/stw_st.c | 66 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/stw_winsys.h | 7 |
13 files changed, 329 insertions, 142 deletions
diff --git a/src/gallium/state_trackers/wgl/SConscript b/src/gallium/state_trackers/wgl/SConscript index ec55f042f90..1b7597de440 100644 --- a/src/gallium/state_trackers/wgl/SConscript +++ b/src/gallium/state_trackers/wgl/SConscript @@ -13,7 +13,6 @@ env.Append(CPPPATH = [ env.AppendUnique(CPPDEFINES = [ '_GDI32_', # prevent wgl* being declared __declspec(dllimport) 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers - 'WIN32_THREADS', # use Win32 thread API 'WIN32_LEAN_AND_MEAN', # http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx ]) @@ -22,6 +21,7 @@ sources = [ 'stw_device.c', 'stw_ext_extensionsstring.c', 'stw_ext_gallium.c', + 'stw_ext_pbuffer.c', 'stw_ext_pixelformat.c', 'stw_ext_swapinterval.c', 'stw_framebuffer.c', diff --git a/src/gallium/state_trackers/wgl/stw_context.c b/src/gallium/state_trackers/wgl/stw_context.c index 85878b46730..cd4f3c8b3e2 100644 --- a/src/gallium/state_trackers/wgl/stw_context.c +++ b/src/gallium/state_trackers/wgl/stw_context.c @@ -29,12 +29,10 @@ #include "pipe/p_compiler.h" #include "pipe/p_context.h" +#include "pipe/p_state.h" +#include "util/u_memory.h" #include "state_tracker/st_api.h" -/* for _mesa_share_state */ -#include "state_tracker/st_context.h" -#include "main/core.h" - #include "stw_icd.h" #include "stw_device.h" #include "stw_winsys.h" @@ -102,13 +100,8 @@ DrvShareLists( ctx1 = stw_lookup_context_locked( dhglrc1 ); ctx2 = stw_lookup_context_locked( dhglrc2 ); - if (ctx1 && ctx2) { - struct st_context *st1, *st2; - - st1 = (struct st_context *) ctx1->st; - st2 = (struct st_context *) ctx2->st; - ret = _mesa_share_state(st2->ctx, st1->ctx); - } + if (ctx1 && ctx2 && ctx2->st->share) + ret = ctx2->st->share(ctx2->st, ctx1->st); pipe_mutex_unlock( stw_dev->ctx_mutex ); @@ -271,75 +264,82 @@ stw_make_current( struct stw_context *curctx = NULL; struct stw_context *ctx = NULL; struct stw_framebuffer *fb = NULL; + BOOL ret = FALSE; if (!stw_dev) - goto fail; + return FALSE; curctx = stw_current_context(); if (curctx != NULL) { - if (curctx->dhglrc != dhglrc) + if (curctx->dhglrc == dhglrc) { + if (curctx->hdc == hdc) { + /* Return if already current. */ + return TRUE; + } + } else { curctx->st->flush(curctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); - - /* Return if already current. */ - if (curctx->dhglrc == dhglrc && curctx->hdc == hdc) { - ctx = curctx; - fb = stw_framebuffer_from_hdc( hdc ); - goto success; } - - stw_framebuffer_reference(&curctx->current_framebuffer, NULL); - } - - if (hdc == NULL || dhglrc == 0) { - return stw_dev->stapi->make_current(stw_dev->stapi, NULL, NULL, NULL); } - pipe_mutex_lock( stw_dev->ctx_mutex ); - ctx = stw_lookup_context_locked( dhglrc ); - pipe_mutex_unlock( stw_dev->ctx_mutex ); - if(!ctx) - goto fail; - - fb = stw_framebuffer_from_hdc( hdc ); - if (fb) { - stw_framebuffer_update(fb); - } - else { - /* Applications should call SetPixelFormat before creating a context, - * but not all do, and the opengl32 runtime seems to use a default pixel - * format in some cases, so we must create a framebuffer for those here - */ - int iPixelFormat = GetPixelFormat(hdc); - if(iPixelFormat) - fb = stw_framebuffer_create( hdc, iPixelFormat ); - if(!fb) + if (dhglrc) { + pipe_mutex_lock( stw_dev->ctx_mutex ); + ctx = stw_lookup_context_locked( dhglrc ); + pipe_mutex_unlock( stw_dev->ctx_mutex ); + if (!ctx) { goto fail; - } - - if(fb->iPixelFormat != ctx->iPixelFormat) - goto fail; + } - /* Bind the new framebuffer */ - ctx->hdc = hdc; + fb = stw_framebuffer_from_hdc( hdc ); + if (fb) { + stw_framebuffer_update(fb); + } + else { + /* Applications should call SetPixelFormat before creating a context, + * but not all do, and the opengl32 runtime seems to use a default pixel + * format in some cases, so we must create a framebuffer for those here + */ + int iPixelFormat = GetPixelFormat(hdc); + if (iPixelFormat) + fb = stw_framebuffer_create( hdc, iPixelFormat ); + if (!fb) + goto fail; + } - if (!stw_dev->stapi->make_current(stw_dev->stapi, ctx->st, fb->stfb, fb->stfb)) - goto fail; + if (fb->iPixelFormat != ctx->iPixelFormat) { + SetLastError(ERROR_INVALID_PIXEL_FORMAT); + goto fail; + } - stw_framebuffer_reference(&ctx->current_framebuffer, fb); + /* Bind the new framebuffer */ + ctx->hdc = hdc; -success: - assert(fb); - if(fb) { - stw_framebuffer_release(fb); + ret = stw_dev->stapi->make_current(stw_dev->stapi, ctx->st, fb->stfb, fb->stfb); + stw_framebuffer_reference(&ctx->current_framebuffer, fb); + } else { + ret = stw_dev->stapi->make_current(stw_dev->stapi, NULL, NULL, NULL); } - return TRUE; - fail: - if(fb) + + if (fb) { stw_framebuffer_release(fb); - stw_dev->stapi->make_current(stw_dev->stapi, NULL, NULL, NULL); - return FALSE; + } + + /* On failure, make the thread's current rendering context not current + * before returning */ + if (!ret) { + stw_dev->stapi->make_current(stw_dev->stapi, NULL, NULL, NULL); + ctx = NULL; + } + + /* Unreference the previous framebuffer if any. It must be done after + * make_current, as it can be referenced inside. + */ + if (curctx && curctx != ctx) { + stw_framebuffer_reference(&curctx->current_framebuffer, NULL); + } + + return ret; } /** diff --git a/src/gallium/state_trackers/wgl/stw_device.c b/src/gallium/state_trackers/wgl/stw_device.c index 37809d084ce..c4822d4d8aa 100644 --- a/src/gallium/state_trackers/wgl/stw_device.c +++ b/src/gallium/state_trackers/wgl/stw_device.c @@ -41,9 +41,7 @@ #include "stw_framebuffer.h" #include "stw_st.h" -#ifdef WIN32_THREADS extern _glthread_Mutex OneTimeLock; -#endif struct stw_device *stw_dev = NULL; @@ -76,9 +74,7 @@ stw_init(const struct stw_winsys *stw_winsys) stw_dev->stw_winsys = stw_winsys; -#ifdef WIN32_THREADS _glthread_INIT_MUTEX(OneTimeLock); -#endif stw_dev->stapi = stw_st_create_api(); stw_dev->smapi = CALLOC_STRUCT(st_manager); @@ -96,6 +92,10 @@ stw_init(const struct stw_winsys *stw_winsys) stw_dev->smapi->get_param = stw_get_param; stw_dev->screen = screen; + stw_dev->max_2d_levels = + screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS); + stw_dev->max_2d_length = 1 << (stw_dev->max_2d_levels - 1); + pipe_mutex_init( stw_dev->ctx_mutex ); pipe_mutex_init( stw_dev->fb_mutex ); @@ -168,11 +168,9 @@ stw_cleanup(void) stw_dev->screen->destroy(stw_dev->screen); -#ifdef WIN32_THREADS _glthread_DESTROY_MUTEX(OneTimeLock); _glapi_destroy_multithread(); -#endif #ifdef DEBUG debug_memory_end(stw_dev->memdbg_no); diff --git a/src/gallium/state_trackers/wgl/stw_device.h b/src/gallium/state_trackers/wgl/stw_device.h index 1b836960d0d..3c2b6d9c076 100644 --- a/src/gallium/state_trackers/wgl/stw_device.h +++ b/src/gallium/state_trackers/wgl/stw_device.h @@ -50,6 +50,10 @@ struct stw_device struct pipe_screen *screen; + /* Cache some PIPE_CAP_* */ + unsigned max_2d_levels; + unsigned max_2d_length; + struct st_api *stapi; struct st_manager *smapi; diff --git a/src/gallium/state_trackers/wgl/stw_ext_extensionsstring.c b/src/gallium/state_trackers/wgl/stw_ext_extensionsstring.c index 62c859e1f92..ecb326f1cf6 100644 --- a/src/gallium/state_trackers/wgl/stw_ext_extensionsstring.c +++ b/src/gallium/state_trackers/wgl/stw_ext_extensionsstring.c @@ -37,6 +37,7 @@ static const char *stw_extension_string = "WGL_ARB_extensions_string " "WGL_ARB_multisample " + "WGL_ARB_pbuffer " "WGL_ARB_pixel_format " /* "WGL_EXT_swap_interval " */ "WGL_EXT_extensions_string"; diff --git a/src/gallium/state_trackers/wgl/stw_ext_pbuffer.c b/src/gallium/state_trackers/wgl/stw_ext_pbuffer.c new file mode 100644 index 00000000000..32636c603dc --- /dev/null +++ b/src/gallium/state_trackers/wgl/stw_ext_pbuffer.c @@ -0,0 +1,212 @@ +/************************************************************************** + * + * Copyright 2010 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 VMWARE 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 <windows.h> + +#define WGL_WGLEXT_PROTOTYPES + +#include <GL/gl.h> +#include <GL/wglext.h> + +#include "pipe/p_defines.h" +#include "pipe/p_screen.h" + +#include "stw_device.h" +#include "stw_pixelformat.h" +#include "stw_framebuffer.h" + + +HPBUFFERARB WINAPI +wglCreatePbufferARB(HDC _hDC, + int iPixelFormat, + int iWidth, + int iHeight, + const int *piAttribList) +{ + static boolean first = TRUE; + const int *piAttrib; + int useLargest = 0; + const struct stw_pixelformat_info *info; + struct stw_framebuffer *fb; + HWND hWnd; + HDC hDC; + + info = stw_pixelformat_get_info(iPixelFormat); + if (!info) { + SetLastError(ERROR_INVALID_PIXEL_FORMAT); + return 0; + } + + if (iWidth <= 0 || iHeight <= 0) { + SetLastError(ERROR_INVALID_DATA); + return 0; + } + + for (piAttrib = piAttribList; *piAttrib; piAttrib++) { + switch (*piAttrib) { + case WGL_PBUFFER_LARGEST_ARB: + piAttrib++; + useLargest = *piAttrib; + break; + default: + SetLastError(ERROR_INVALID_DATA); + return 0; + } + } + + if (iWidth > stw_dev->max_2d_length) { + if (useLargest) { + iWidth = stw_dev->max_2d_length; + } else { + SetLastError(ERROR_NO_SYSTEM_RESOURCES); + return 0; + } + } + + if (iHeight > stw_dev->max_2d_length) { + if (useLargest) { + iHeight = stw_dev->max_2d_length; + } else { + SetLastError(ERROR_NO_SYSTEM_RESOURCES); + return 0; + } + } + + /* + * Implement pbuffers through invisible windows + */ + + if (first) { + WNDCLASS wc; + memset(&wc, 0, sizeof wc); + wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); + wc.lpfnWndProc = DefWindowProc; + wc.lpszClassName = "wglpbuffer"; + wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; + RegisterClass(&wc); + first = FALSE; + } + + hWnd = CreateWindowEx(0, + "wglpbuffer", /* wc.lpszClassName */ + "wglpbuffer", +#if 0 /* Useful for debugging what the application is drawing */ + WS_VISIBLE | +#endif + WS_CLIPSIBLINGS | WS_CLIPCHILDREN, + CW_USEDEFAULT, CW_USEDEFAULT, /* x, y */ + iWidth, iHeight, + NULL, + NULL, + NULL, + NULL); + if (!hWnd) { + return 0; + } + + hDC = GetDC(hWnd); + if (!hDC) { + return 0; + } + + SetPixelFormat(hDC, iPixelFormat, &info->pfd); + + fb = stw_framebuffer_create(hDC, iPixelFormat); + if (!fb) { + SetLastError(ERROR_NO_SYSTEM_RESOURCES); + } + + return (HPBUFFERARB)fb; +} + + +HDC WINAPI +wglGetPbufferDCARB(HPBUFFERARB hPbuffer) +{ + struct stw_framebuffer *fb; + HDC hDC; + + fb = (struct stw_framebuffer *)hPbuffer; + + hDC = GetDC(fb->hWnd); + SetPixelFormat(hDC, fb->iPixelFormat, &fb->pfi->pfd); + + return hDC; +} + + +int WINAPI +wglReleasePbufferDCARB(HPBUFFERARB hPbuffer, + HDC hDC) +{ + struct stw_framebuffer *fb; + + fb = (struct stw_framebuffer *)hPbuffer; + + return ReleaseDC(fb->hWnd, hDC); +} + + +BOOL WINAPI +wglDestroyPbufferARB(HPBUFFERARB hPbuffer) +{ + struct stw_framebuffer *fb; + + fb = (struct stw_framebuffer *)hPbuffer; + + /* This will destroy all our data */ + return DestroyWindow(fb->hWnd); +} + + +BOOL WINAPI +wglQueryPbufferARB(HPBUFFERARB hPbuffer, + int iAttribute, + int *piValue) +{ + struct stw_framebuffer *fb; + + fb = (struct stw_framebuffer *)hPbuffer; + + switch (iAttribute) { + case WGL_PBUFFER_WIDTH_ARB: + *piValue = fb->width; + return TRUE; + case WGL_PBUFFER_HEIGHT_ARB: + *piValue = fb->width; + return TRUE; + case WGL_PBUFFER_LOST_ARB: + /* We assume that no content is ever lost due to display mode change */ + *piValue = FALSE; + return TRUE; + default: + SetLastError(ERROR_INVALID_DATA); + return FALSE; + } +} diff --git a/src/gallium/state_trackers/wgl/stw_ext_pixelformat.c b/src/gallium/state_trackers/wgl/stw_ext_pixelformat.c index ab56800e28d..d0a95863bb4 100644 --- a/src/gallium/state_trackers/wgl/stw_ext_pixelformat.c +++ b/src/gallium/state_trackers/wgl/stw_ext_pixelformat.c @@ -43,6 +43,7 @@ #include "pipe/p_compiler.h" #include "util/u_memory.h" +#include "stw_device.h" #include "stw_pixelformat.h" @@ -234,6 +235,23 @@ stw_query_attrib( *pvalue = pfi->stvis.samples; break; + + /* WGL_ARB_pbuffer */ + + case WGL_MAX_PBUFFER_WIDTH_ARB: + case WGL_MAX_PBUFFER_HEIGHT_ARB: + *pvalue = stw_dev->max_2d_length; + break; + + case WGL_MAX_PBUFFER_PIXELS_ARB: + *pvalue = stw_dev->max_2d_length * stw_dev->max_2d_length; + break; + + case WGL_DRAW_TO_PBUFFER_ARB: + *pvalue = 1; + break; + + default: return FALSE; } diff --git a/src/gallium/state_trackers/wgl/stw_framebuffer.c b/src/gallium/state_trackers/wgl/stw_framebuffer.c index 259b22f22c7..733222aa21c 100644 --- a/src/gallium/state_trackers/wgl/stw_framebuffer.c +++ b/src/gallium/state_trackers/wgl/stw_framebuffer.c @@ -469,7 +469,7 @@ DrvPresentBuffers(HDC hdc, PGLPRESENTBUFFERSDATA data) { struct stw_framebuffer *fb; struct pipe_screen *screen; - struct pipe_surface *surface; + struct pipe_resource *res; if (!stw_dev) return FALSE; @@ -480,7 +480,7 @@ DrvPresentBuffers(HDC hdc, PGLPRESENTBUFFERSDATA data) screen = stw_dev->screen; - surface = (struct pipe_surface *)data->pPrivateData; + res = (struct pipe_resource *)data->pPrivateData; if(data->hSharedSurface != fb->hSharedSurface) { if(fb->shared_surface) { @@ -498,13 +498,13 @@ DrvPresentBuffers(HDC hdc, PGLPRESENTBUFFERSDATA data) if(fb->shared_surface) { stw_dev->stw_winsys->compose(screen, - surface, + res, fb->shared_surface, &fb->client_rect, data->PresentHistoryToken); } else { - stw_dev->stw_winsys->present( screen, surface, hdc ); + stw_dev->stw_winsys->present( screen, res, hdc ); } stw_framebuffer_update(fb); @@ -524,7 +524,7 @@ DrvPresentBuffers(HDC hdc, PGLPRESENTBUFFERSDATA data) BOOL stw_framebuffer_present_locked(HDC hdc, struct stw_framebuffer *fb, - struct pipe_surface *surface) + struct pipe_resource *res) { if(stw_dev->callbacks.wglCbPresentBuffers && stw_dev->stw_winsys->compose) { @@ -535,7 +535,7 @@ stw_framebuffer_present_locked(HDC hdc, data.magic2 = 0; data.AdapterLuid = stw_dev->AdapterLuid; data.rect = fb->client_rect; - data.pPrivateData = (void *)surface; + data.pPrivateData = (void *)res; stw_notify_current_locked(fb); stw_framebuffer_release(fb); @@ -545,7 +545,7 @@ stw_framebuffer_present_locked(HDC hdc, else { struct pipe_screen *screen = stw_dev->screen; - stw_dev->stw_winsys->present( screen, surface, hdc ); + stw_dev->stw_winsys->present( screen, res, hdc ); stw_framebuffer_update(fb); stw_notify_current_locked(fb); diff --git a/src/gallium/state_trackers/wgl/stw_framebuffer.h b/src/gallium/state_trackers/wgl/stw_framebuffer.h index 89d12300e67..6604e545cbc 100644 --- a/src/gallium/state_trackers/wgl/stw_framebuffer.h +++ b/src/gallium/state_trackers/wgl/stw_framebuffer.h @@ -32,7 +32,7 @@ #include "os/os_thread.h" -struct pipe_surface; +struct pipe_resource; struct st_framebuffer_iface; struct stw_pixelformat_info; @@ -143,7 +143,7 @@ stw_framebuffer_from_hdc( BOOL stw_framebuffer_present_locked(HDC hdc, struct stw_framebuffer *fb, - struct pipe_surface *surface); + struct pipe_resource *res); void stw_framebuffer_update( diff --git a/src/gallium/state_trackers/wgl/stw_getprocaddress.c b/src/gallium/state_trackers/wgl/stw_getprocaddress.c index d43a55fa9e6..b0aef943d30 100644 --- a/src/gallium/state_trackers/wgl/stw_getprocaddress.c +++ b/src/gallium/state_trackers/wgl/stw_getprocaddress.c @@ -50,6 +50,13 @@ static const struct stw_extension_entry stw_extension_entries[] = { /* WGL_ARB_extensions_string */ STW_EXTENSION_ENTRY( wglGetExtensionsStringARB ), + /* WGL_ARB_pbuffer */ + STW_EXTENSION_ENTRY( wglCreatePbufferARB ), + STW_EXTENSION_ENTRY( wglGetPbufferDCARB ), + STW_EXTENSION_ENTRY( wglReleasePbufferDCARB ), + STW_EXTENSION_ENTRY( wglDestroyPbufferARB ), + STW_EXTENSION_ENTRY( wglQueryPbufferARB ), + /* WGL_ARB_pixel_format */ STW_EXTENSION_ENTRY( wglChoosePixelFormatARB ), STW_EXTENSION_ENTRY( wglGetPixelFormatAttribfvARB ), diff --git a/src/gallium/state_trackers/wgl/stw_pixelformat.c b/src/gallium/state_trackers/wgl/stw_pixelformat.c index 18ac4823696..5ede1d43220 100644 --- a/src/gallium/state_trackers/wgl/stw_pixelformat.c +++ b/src/gallium/state_trackers/wgl/stw_pixelformat.c @@ -185,7 +185,7 @@ stw_pixelformat_add( */ pfi->stvis.buffer_mask = ST_ATTACHMENT_FRONT_LEFT_MASK; if (doublebuffer) - pfi->stvis.buffer_mask = ST_ATTACHMENT_BACK_LEFT_MASK; + pfi->stvis.buffer_mask |= ST_ATTACHMENT_BACK_LEFT_MASK; pfi->stvis.color_format = color->format; pfi->stvis.depth_stencil_format = depth->format; diff --git a/src/gallium/state_trackers/wgl/stw_st.c b/src/gallium/state_trackers/wgl/stw_st.c index bcdd82e4f66..b58d91673b7 100644 --- a/src/gallium/state_trackers/wgl/stw_st.c +++ b/src/gallium/state_trackers/wgl/stw_st.c @@ -43,8 +43,6 @@ struct stw_st_framebuffer { struct pipe_resource *textures[ST_ATTACHMENT_COUNT]; unsigned texture_width, texture_height; unsigned texture_mask; - - struct pipe_surface *front_surface, *back_surface; }; static INLINE struct stw_st_framebuffer * @@ -65,10 +63,6 @@ stw_st_framebuffer_validate_locked(struct st_framebuffer_iface *stfb, struct pipe_resource templ; unsigned i; - /* remove outdated surface */ - pipe_surface_reference(&stwfb->front_surface, NULL); - pipe_surface_reference(&stwfb->back_surface, NULL); - /* remove outdated textures */ if (stwfb->texture_width != width || stwfb->texture_height != height) { for (i = 0; i < ST_ATTACHMENT_COUNT; i++) @@ -80,6 +74,7 @@ stw_st_framebuffer_validate_locked(struct st_framebuffer_iface *stfb, templ.width0 = width; templ.height0 = height; templ.depth0 = 1; + templ.array_size = 1; templ.last_level = 0; for (i = 0; i < ST_ATTACHMENT_COUNT; i++) { @@ -155,45 +150,6 @@ stw_st_framebuffer_validate(struct st_framebuffer_iface *stfb, return TRUE; } -static struct pipe_surface * -get_present_surface_locked(struct st_framebuffer_iface *stfb, - enum st_attachment_type statt) -{ - struct stw_st_framebuffer *stwfb = stw_st_framebuffer(stfb); - struct pipe_resource *ptex; - struct pipe_surface *psurf, **cache; - - ptex = stwfb->textures[statt]; - if (!ptex) - return NULL; - - psurf = NULL; - - switch (statt) { - case ST_ATTACHMENT_FRONT_LEFT: - cache = &stwfb->front_surface; - break; - case ST_ATTACHMENT_BACK_LEFT: - cache = &stwfb->back_surface; - break; - default: - cache = &psurf; - break; - } - - if (!*cache) { - *cache = stw_dev->screen->get_tex_surface(stw_dev->screen, - ptex, 0, 0, 0, - PIPE_BIND_DISPLAY_TARGET | - PIPE_BIND_RENDER_TARGET); - } - - if (psurf != *cache) - pipe_surface_reference(&psurf, *cache); - - return psurf; -} - /** * Present an attachment of the framebuffer. */ @@ -202,12 +158,11 @@ stw_st_framebuffer_present_locked(struct st_framebuffer_iface *stfb, enum st_attachment_type statt) { struct stw_st_framebuffer *stwfb = stw_st_framebuffer(stfb); - struct pipe_surface *psurf; - - psurf = get_present_surface_locked(&stwfb->base, statt); - if (psurf) { - stw_framebuffer_present_locked(stwfb->fb->hDC, stwfb->fb, psurf); - pipe_surface_reference(&psurf, NULL); + struct pipe_resource *resource; + + resource = stwfb->textures[statt]; + if (resource) { + stw_framebuffer_present_locked(stwfb->fb->hDC, stwfb->fb, resource); } return TRUE; @@ -255,9 +210,6 @@ stw_st_destroy_framebuffer_locked(struct st_framebuffer_iface *stfb) struct stw_st_framebuffer *stwfb = stw_st_framebuffer(stfb); int i; - pipe_surface_reference(&stwfb->front_surface, NULL); - pipe_surface_reference(&stwfb->back_surface, NULL); - for (i = 0; i < ST_ATTACHMENT_COUNT; i++) pipe_resource_reference(&stwfb->textures[i], NULL); @@ -273,7 +225,6 @@ stw_st_swap_framebuffer_locked(struct st_framebuffer_iface *stfb) struct stw_st_framebuffer *stwfb = stw_st_framebuffer(stfb); unsigned front = ST_ATTACHMENT_FRONT_LEFT, back = ST_ATTACHMENT_BACK_LEFT; struct pipe_resource *ptex; - struct pipe_surface *psurf; unsigned mask; /* swap the textures */ @@ -281,11 +232,6 @@ stw_st_swap_framebuffer_locked(struct st_framebuffer_iface *stfb) stwfb->textures[front] = stwfb->textures[back]; stwfb->textures[back] = ptex; - /* swap the surfaces */ - psurf = stwfb->front_surface; - stwfb->front_surface = stwfb->back_surface; - stwfb->back_surface = psurf; - /* convert to mask */ front = 1 << front; back = 1 << back; diff --git a/src/gallium/state_trackers/wgl/stw_winsys.h b/src/gallium/state_trackers/wgl/stw_winsys.h index 270fad56a19..397065fc159 100644 --- a/src/gallium/state_trackers/wgl/stw_winsys.h +++ b/src/gallium/state_trackers/wgl/stw_winsys.h @@ -34,7 +34,7 @@ struct pipe_screen; struct pipe_context; -struct pipe_surface; +struct pipe_resource; struct stw_shared_surface; @@ -43,12 +43,13 @@ struct stw_winsys struct pipe_screen * (*create_screen)( void ); + /* XXX is it actually possible to have non-zero level/layer ??? */ /** * Present the color buffer to the window associated with the device context. */ void (*present)( struct pipe_screen *screen, - struct pipe_surface *surf, + struct pipe_resource *res, HDC hDC ); /** @@ -85,7 +86,7 @@ struct stw_winsys */ void (*compose)( struct pipe_screen *screen, - struct pipe_surface *src, + struct pipe_resource *res, struct stw_shared_surface *dest, LPCRECT pRect, ULONGLONG PresentHistoryToken ); |