- Timestamp:
- Jul 26, 2011 6:56:40 AM (13 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/context.c
r38146 r38172 734 734 } 735 735 736 void context_update_window(struct wined3d_context *context 736 #ifdef VBOX_WITH_WDDM 737 static BOOL swapchain_validate(IWineD3DSwapChainImpl *swapchain) 738 { 739 HWND hWnd = WindowFromDC(swapchain->hDC); 740 if (hWnd != swapchain->win_handle) 741 { 742 ERR("Unexpected swapchain for dc %p window expected %p, but was %p.\n", swapchain->hDC, swapchain->win_handle, hWnd); 743 return FALSE; 744 } 745 return TRUE; 746 } 747 748 static IWineD3DSwapChainImpl * swapchain_find_valid(IWineD3DDeviceImpl *device) 749 { 750 int i; 751 for (i = device->NumberOfSwapChains - 1; i >= 0 ; --i) 752 { 753 if (swapchain_validate((IWineD3DSwapChainImpl*)device->swapchains[i])) 754 { 755 return (IWineD3DSwapChainImpl*)device->swapchains[i]; 756 } 757 } 758 759 return NULL; 760 } 761 #endif 762 763 static void context_update_window(struct wined3d_context *context 737 764 #ifdef VBOX_WITH_WDDM 738 765 , IWineD3DSwapChainImpl *swapchain … … 761 788 762 789 #ifdef VBOX_WITH_WDDM 763 # ifdef DEBUG 764 { 765 HWND wnd = WindowFromDC(swapchain->hDC); 766 if (wnd != swapchain->win_handle) 767 { 768 ERR("Lost swapchain dc %p for window %p.\n", swapchain->hDC, swapchain->win_handle); 769 } 770 } 771 # endif 772 790 if (!swapchain_validate(swapchain)) 791 { 792 ERR("invalid swapchain %p\n", swapchain); 793 goto err; 794 } 773 795 context->win_handle = swapchain->win_handle; 774 796 context->currentSwapchain = swapchain; … … 814 836 { 815 837 DWORD winEr = GetLastError(); 816 ERR("DC %p belongs to window %p instead of %p., winEr(%d)\n",838 WARN("DC %p belongs to window %p instead of %p., winEr(%d)\n", 817 839 context->hdc, wnd, context->win_handle, winEr); 840 #ifdef VBOX_WITH_WDDM 841 if (!swapchain || context->win_handle == swapchain->win_handle) 842 { 843 ERR("!!!unexpected equal HWND!!!: DC %p belongs to window %p instead of %p., winEr(%d)\n", 844 context->hdc, wnd, context->win_handle, winEr); 845 } 846 #endif 818 847 context->valid = 0; 819 848 } … … 834 863 } 835 864 } 865 866 #ifdef VBOX_WITH_WDDM 867 static void context_validate_adjust_wnd(struct wined3d_context *context) 868 { 869 IWineD3DSwapChainImpl *swapchain = NULL; 870 871 context_validate(context, NULL); 872 if (context->valid) 873 return; 874 875 swapchain = swapchain_find_valid(context->device); 876 if (swapchain) 877 { 878 context_validate(context, swapchain); 879 if (!context->valid) 880 { 881 ERR("unexpected\n"); 882 } 883 } 884 else 885 { 886 ERR("novalid swapchain found\n"); 887 } 888 } 889 #endif 836 890 837 891 static void context_destroy_gl_resources(struct wined3d_context *context) … … 848 902 restore_dc = pwglGetCurrentDC(); 849 903 850 context_validate(context 851 #ifdef VBOX_WITH_WDDM/* tmp work-around */ 852 , NULL //(IWineD3DSwapChainImpl*)context->device->swapchains[context->device->NumberOfSwapChains-1] 853 #endif 854 ); 904 #ifdef VBOX_WITH_WDDM 905 context_validate_adjust_wnd(context); 906 #else 907 context_validate(context); 908 #endif 855 909 if (context->valid && restore_ctx != context->glCtx) pwglMakeCurrent(context->hdc, context->glCtx); 856 910 else restore_ctx = NULL; … … 1323 1377 /* When findCompatible is set and no suitable format was found, let ChoosePixelFormat choose a pixel format in order not to crash. */ 1324 1378 if(!iPixelFormat && !findCompatible) { 1379 #ifdef DEBUG_misha 1380 WARN("Can't find a suitable iPixelFormat\n"); 1381 #else 1325 1382 ERR("Can't find a suitable iPixelFormat\n"); 1383 #endif 1326 1384 return FALSE; 1327 1385 } else if(!iPixelFormat) { … … 1718 1776 } 1719 1777 else { 1720 /* tmp work-around */ 1721 context_validate(context, 1722 NULL //(IWineD3DSwapChainImpl*)context->device->swapchains[context->device->NumberOfSwapChains-1] 1723 ); 1778 context_validate_adjust_wnd(context); 1724 1779 } 1725 1780 } … … 2245 2300 struct wined3d_context *context = This->numContexts ? This->contexts[0] : NULL; 2246 2301 2302 2247 2303 if (context && context->destroyed) 2248 2304 { … … 2261 2317 else 2262 2318 { 2263 #ifdef VBOX_WITH_WDDM 2264 /* tmp work-around */ 2265 IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)This->swapchains[This->NumberOfSwapChains-1]; 2266 #else 2267 IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)This->swapchains[0]; 2268 #endif 2319 IWineD3DSwapChainImpl *swapchain = swapchain_find_valid(This); 2320 if (!swapchain) 2321 swapchain = (IWineD3DSwapChainImpl *)This->swapchains[This->NumberOfSwapChains-1]; /* just fallback to anything to avoid NPE */ 2269 2322 if (swapchain->backBuffer) target = swapchain->backBuffer[0]; 2270 2323 else target = swapchain->frontBuffer; … … 2274 2327 if (context && context->current_rt == target) 2275 2328 { 2276 #ifdef VBOX_WITH_WDDM2277 2329 IWineD3DSwapChain *swapchain = NULL; 2278 2330 if (SUCCEEDED(IWineD3DSurface_GetContainer(target, &IID_IWineD3DSwapChain, (void **)&swapchain))) { … … 2281 2333 } 2282 2334 else { 2283 /* tmp work-around */ 2284 context_validate(context, 2285 NULL //(IWineD3DSwapChainImpl*)current_context->device->swapchains[current_context->device->NumberOfSwapChains-1] 2286 ); 2287 } 2288 #else 2289 context_validate(context); 2290 #endif 2335 context_validate_adjust_wnd(context); 2336 } 2291 2337 return context; 2292 2338 } … … 2296 2342 2297 2343 context = findThreadContextForSwapChain(swapchain); 2298 #ifdef VBOX_WITH_WDDM2299 2344 context_validate(context, (IWineD3DSwapChainImpl*)swapchain); 2300 #endif2301 2345 IWineD3DSwapChain_Release(swapchain); 2302 2346 } 2303 2347 else 2304 2348 { 2349 if (context) 2350 { 2351 context_validate_adjust_wnd(context); 2352 } 2353 else 2354 { 2355 IWineD3DSwapChainImpl *swapchain = swapchain_find_valid(This); 2356 if (!swapchain) 2357 swapchain = (IWineD3DSwapChainImpl *)This->swapchains[This->NumberOfSwapChains-1]; /* just fallback to anything to avoid NPE */ 2358 context = findThreadContextForSwapChain(swapchain); 2359 context_validate(context, swapchain); 2360 } 2361 2305 2362 TRACE("Rendering offscreen\n"); 2306 2307 if (!context) 2308 { 2309 /* This may happen if the app jumps straight into offscreen rendering 2310 * Start using the context of the primary swapchain. tid == 0 is no problem 2311 * for findThreadContextForSwapChain. 2312 * 2313 * Can also happen on thread switches - in that case findThreadContextForSwapChain 2314 * is perfect to call. */ 2315 #ifdef VBOX_WITH_WDDM /* tmp work-around */ 2316 context = findThreadContextForSwapChain(This->swapchains[This->NumberOfSwapChains-1]); 2317 #else 2318 context = findThreadContextForSwapChain(This->swapchains[0], tid); 2319 #endif 2320 } 2321 #ifdef VBOX_WITH_WDDM 2322 context_validate(context, 2323 NULL //(IWineD3DSwapChainImpl*)This->swapchains[This->NumberOfSwapChains-1] /* tmp work-around */ 2324 ); 2325 #endif 2326 } 2327 2328 #ifndef VBOX_WITH_WDDM 2329 context_validate(context); 2330 #endif 2363 } 2331 2364 2332 2365 return context; -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/state.c
r36029 r38172 53 53 static void state_undefined(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context) 54 54 { 55 #ifdef DEBUG_misha 56 WARN("Undefined state.\n"); 57 #else 55 58 ERR("Undefined state.\n"); 59 #endif 56 60 } 57 61
Note:
See TracChangeset
for help on using the changeset viewer.