ReactOS 0.4.17-dev-966-gf06eace
swapchain.c
Go to the documentation of this file.
1/*
2 * Copyright 2002-2003 Jason Edmeades
3 * Copyright 2002-2003 Raphael Junqueira
4 * Copyright 2005 Oliver Stieber
5 * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
6 * Copyright 2011 Henri Verbeet for CodeWeavers
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 */
22
23#include "wined3d_private.h"
24#include "wined3d_gl.h"
25#include "wined3d_vk.h"
26
29
31{
32 HRESULT hr;
33 UINT i;
34
35 TRACE("Destroying swapchain %p.\n", swapchain);
36
38 wined3d_swapchain_set_gamma_ramp(swapchain, 0, &swapchain->orig_gamma);
39
40 /* Release the swapchain's draw buffers. Make sure swapchain->back_buffers[0]
41 * is the last buffer to be destroyed, FindContext() depends on that. */
42 if (swapchain->front_buffer)
43 {
46 WARN("Something's still holding the front buffer (%p).\n", swapchain->front_buffer);
47 swapchain->front_buffer = NULL;
48 }
49
50 if (swapchain->back_buffers)
51 {
52 i = swapchain->state.desc.backbuffer_count;
53
54 while (i--)
55 {
57 if (wined3d_texture_decref(swapchain->back_buffers[i]))
58 WARN("Something's still holding back buffer %u (%p).\n", i, swapchain->back_buffers[i]);
59 }
60 free(swapchain->back_buffers);
61 swapchain->back_buffers = NULL;
62 }
63
64 /* Restore the screen resolution if we rendered in fullscreen.
65 * This will restore the screen resolution to what it was before creating
66 * the swapchain. In case of d3d8 and d3d9 this will be the original
67 * desktop resolution. In case of d3d7 this will be a NOP because ddraw
68 * sets the resolution before starting up Direct3D, thus orig_width and
69 * orig_height will be equal to the modes in the presentation params. */
70 if (!swapchain->state.desc.windowed)
71 {
72 if (swapchain->state.desc.auto_restore_display_mode)
73 {
74 if (FAILED(hr = wined3d_restore_display_modes(swapchain->device->wined3d)))
75 ERR("Failed to restore display mode, hr %#lx.\n", hr);
76
77 if (swapchain->state.desc.flags & WINED3D_SWAPCHAIN_RESTORE_WINDOW_RECT)
78 {
80 swapchain->state.device_window, &swapchain->state.original_window_rect);
82 }
83 }
84 else
85 {
86 wined3d_swapchain_state_restore_from_fullscreen(&swapchain->state, swapchain->state.device_window, NULL);
87 }
88 }
89}
90
92{
93 wined3d_swapchain_cleanup(&swapchain_gl->s);
94}
95
97{
98 struct wined3d_device_vk *device_vk = wined3d_device_vk(swapchain_vk->s.device);
99 const struct wined3d_vk_info *vk_info;
100 unsigned int i;
101 VkResult vr;
102
103 TRACE("swapchain_vk %p.\n", swapchain_vk);
104
105 vk_info = &wined3d_adapter_vk(device_vk->d.adapter)->vk_info;
106
107 if ((vr = VK_CALL(vkQueueWaitIdle(device_vk->vk_queue))) < 0)
108 ERR("Failed to wait on queue, vr %s.\n", wined3d_debug_vkresult(vr));
109 free(swapchain_vk->vk_images);
110 for (i = 0; i < swapchain_vk->image_count; ++i)
111 {
112 VK_CALL(vkDestroySemaphore(device_vk->vk_device, swapchain_vk->vk_semaphores[i].available, NULL));
113 VK_CALL(vkDestroySemaphore(device_vk->vk_device, swapchain_vk->vk_semaphores[i].presentable, NULL));
114 }
115 free(swapchain_vk->vk_semaphores);
116 VK_CALL(vkDestroySwapchainKHR(device_vk->vk_device, swapchain_vk->vk_swapchain, NULL));
117 VK_CALL(vkDestroySurfaceKHR(vk_info->instance, swapchain_vk->vk_surface, NULL));
118}
119
120static void wined3d_swapchain_vk_destroy_object(void *object)
121{
123}
124
126{
127 struct wined3d_cs *cs = swapchain_vk->s.device->cs;
128
131
132 wined3d_swapchain_cleanup(&swapchain_vk->s);
133}
134
136{
137 unsigned int refcount = InterlockedIncrement(&swapchain->ref);
138
139 TRACE("%p increasing refcount to %u.\n", swapchain, refcount);
140
141 return refcount;
142}
143
145{
146 unsigned int refcount = InterlockedDecrement(&swapchain->ref);
147
148 TRACE("%p decreasing refcount to %u.\n", swapchain, refcount);
149
150 if (!refcount)
151 {
152 struct wined3d_device *device;
153
155
156 device = swapchain->device;
157 if (device->swapchain_count && device->swapchains[0] == swapchain)
160
161 swapchain->parent_ops->wined3d_object_destroyed(swapchain->parent);
162 swapchain->device->adapter->adapter_ops->adapter_destroy_swapchain(swapchain);
163
165 }
166
167 return refcount;
168}
169
171{
172 TRACE("swapchain %p.\n", swapchain);
173
174 return swapchain->parent;
175}
176
178{
179 if (!window)
180 window = swapchain->state.device_window;
181 if (window == swapchain->win_handle)
182 return;
183
184 TRACE("Setting swapchain %p window from %p to %p.\n",
185 swapchain, swapchain->win_handle, window);
186
188
189 swapchain->win_handle = window;
190}
191
193 const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override,
194 unsigned int swap_interval, uint32_t flags)
195{
196 RECT s, d;
197
198 TRACE("swapchain %p, src_rect %s, dst_rect %s, dst_window_override %p, swap_interval %u, flags %#x.\n",
199 swapchain, wine_dbgstr_rect(src_rect), wine_dbgstr_rect(dst_rect),
200 dst_window_override, swap_interval, flags);
201
202 if (flags)
203 FIXME("Ignoring flags %#x.\n", flags);
204
206
207 if (!swapchain->back_buffers)
208 {
209 WARN("Swapchain doesn't have a backbuffer, returning WINED3DERR_INVALIDCALL.\n");
212 }
213
214 if (!src_rect)
215 {
216 SetRect(&s, 0, 0, swapchain->state.desc.backbuffer_width,
217 swapchain->state.desc.backbuffer_height);
218 src_rect = &s;
219 }
220
221 if (!dst_rect)
222 {
223 GetClientRect(swapchain->win_handle, &d);
224 dst_rect = &d;
225 }
226
227 wined3d_cs_emit_present(swapchain->device->cs, swapchain, src_rect,
228 dst_rect, dst_window_override, swap_interval, flags);
229
231
232 return WINED3D_OK;
233}
234
236 struct wined3d_texture *dst_texture, unsigned int sub_resource_idx)
237{
238 RECT src_rect, dst_rect;
239
240 TRACE("swapchain %p, dst_texture %p, sub_resource_idx %u.\n", swapchain, dst_texture, sub_resource_idx);
241
242 SetRect(&src_rect, 0, 0, swapchain->front_buffer->resource.width, swapchain->front_buffer->resource.height);
243 dst_rect = src_rect;
244
245 if (swapchain->state.desc.windowed)
246 {
247 MapWindowPoints(swapchain->win_handle, NULL, (POINT *)&dst_rect, 2);
248 FIXME("Using destination rect %s in windowed mode, this is likely wrong.\n",
249 wine_dbgstr_rect(&dst_rect));
250 }
251
252 return wined3d_device_context_blt(&swapchain->device->cs->c, dst_texture, sub_resource_idx, &dst_rect,
253 swapchain->front_buffer, 0, &src_rect, 0, NULL, WINED3D_TEXF_POINT);
254}
255
257 UINT back_buffer_idx)
258{
259 TRACE("swapchain %p, back_buffer_idx %u.\n",
260 swapchain, back_buffer_idx);
261
262 /* Return invalid if there is no backbuffer array, otherwise it will
263 * crash when ddraw is used (there swapchain->back_buffers is always
264 * NULL). We need this because this function is called from
265 * stateblock_init_default_state() to get the default scissorrect
266 * dimensions. */
267 if (!swapchain->back_buffers || back_buffer_idx >= swapchain->state.desc.backbuffer_count)
268 {
269 WARN("Invalid back buffer index.\n");
270 /* Native d3d9 doesn't set NULL here, just as wine's d3d9. But set it
271 * here in wined3d to avoid problems in other libs. */
272 return NULL;
273 }
274
275 TRACE("Returning back buffer %p.\n", swapchain->back_buffers[back_buffer_idx]);
276
277 return swapchain->back_buffers[back_buffer_idx];
278}
279
281{
282 TRACE("swapchain %p.\n", swapchain);
283
284 return swapchain->front_buffer;
285}
286
288{
289 TRACE("swapchain %p.\n", swapchain);
290
291 return swapchain->state.desc.output;
292}
293
295 struct wined3d_raster_status *raster_status)
296{
297 struct wined3d_output *output;
298
299 TRACE("swapchain %p, raster_status %p.\n", swapchain, raster_status);
300
301 output = wined3d_swapchain_get_output(swapchain);
302 if (!output)
303 {
304 ERR("Failed to get output from swapchain %p.\n", swapchain);
305 return E_FAIL;
306 }
307
308 return wined3d_output_get_raster_status(output, raster_status);
309}
310
312{
313 return &swapchain->state;
314}
315
317 struct wined3d_display_mode *mode, enum wined3d_display_rotation *rotation)
318{
319 struct wined3d_output *output;
320 HRESULT hr;
321
322 TRACE("swapchain %p, mode %p, rotation %p.\n", swapchain, mode, rotation);
323
324 if (!(output = wined3d_swapchain_get_output(swapchain)))
325 {
326 ERR("Failed to get output from swapchain %p.\n", swapchain);
327 return E_FAIL;
328 }
329
330 hr = wined3d_output_get_display_mode(output, mode, rotation);
331
332 TRACE("Returning w %u, h %u, refresh rate %u, format %s.\n",
333 mode->width, mode->height, mode->refresh_rate, debug_d3dformat(mode->format_id));
334
335 return hr;
336}
337
339{
340 TRACE("swapchain %p.\n", swapchain);
341
342 return swapchain->device;
343}
344
347{
348 TRACE("swapchain %p, desc %p.\n", swapchain, desc);
349
350 *desc = swapchain->state.desc;
351}
352
354 uint32_t flags, const struct wined3d_gamma_ramp *ramp)
355{
356 struct wined3d_output *output;
357
358 TRACE("swapchain %p, flags %#x, ramp %p.\n", swapchain, flags, ramp);
359
360 if (flags)
361 FIXME("Ignoring flags %#x.\n", flags);
362
363 if (!(output = wined3d_swapchain_get_output(swapchain)))
364 {
365 ERR("Failed to get output from swapchain %p.\n", swapchain);
366 return E_FAIL;
367 }
368
369 return wined3d_output_set_gamma_ramp(output, ramp);
370}
371
373{
374 TRACE("swapchain %p, palette %p.\n", swapchain, palette);
375
377
378 swapchain->palette = palette;
379}
380
382 struct wined3d_gamma_ramp *ramp)
383{
384 struct wined3d_output *output;
385
386 TRACE("swapchain %p, ramp %p.\n", swapchain, ramp);
387
388 if (!(output = wined3d_swapchain_get_output(swapchain)))
389 {
390 ERR("Failed to get output from swapchain %p.\n", swapchain);
391 return E_FAIL;
392 }
393
394 return wined3d_output_get_gamma_ramp(output, ramp);
395}
396
397/* The is a fallback for cases where we e.g. can't create a GL context or
398 * Vulkan swapchain for the swapchain window. */
399static void swapchain_blit_gdi(struct wined3d_swapchain *swapchain,
400 struct wined3d_context *context, const RECT *src_rect, const RECT *dst_rect)
401{
402 struct wined3d_texture *back_buffer = swapchain->back_buffers[0];
403 D3DKMT_DESTROYDCFROMMEMORY destroy_desc;
404 D3DKMT_CREATEDCFROMMEMORY create_desc;
405 const struct wined3d_format *format;
406 unsigned int row_pitch, slice_pitch;
407 HDC src_dc, dst_dc;
410
411 static unsigned int once;
412
413 TRACE("swapchain %p, context %p, src_rect %s, dst_rect %s.\n",
414 swapchain, context, wine_dbgstr_rect(src_rect), wine_dbgstr_rect(dst_rect));
415
416 if (!once++)
417 FIXME("Using GDI present.\n");
418
419 format = back_buffer->resource.format;
420 if (!format->ddi_format)
421 {
422 WARN("Cannot create a DC for format %s.\n", debug_d3dformat(format->id));
423 return;
424 }
425
427 wined3d_texture_get_pitch(back_buffer, 0, &row_pitch, &slice_pitch);
428
429 create_desc.pMemory = back_buffer->resource.heap_memory;
430 create_desc.Format = format->ddi_format;
431 create_desc.Width = wined3d_texture_get_level_width(back_buffer, 0);
432 create_desc.Height = wined3d_texture_get_level_height(back_buffer, 0);
433 create_desc.Pitch = row_pitch;
434 create_desc.hDeviceDc = CreateCompatibleDC(NULL);
435 create_desc.pColorTable = NULL;
436
437 status = D3DKMTCreateDCFromMemory(&create_desc);
438 DeleteDC(create_desc.hDeviceDc);
439 if (status)
440 {
441 WARN("Failed to create DC, status %#lx.\n", status);
442 return;
443 }
444
445 src_dc = create_desc.hDc;
446 bitmap = create_desc.hBitmap;
447
448 TRACE("Created source DC %p, bitmap %p for backbuffer %p.\n", src_dc, bitmap, back_buffer);
449
450 if (!(dst_dc = GetDCEx(swapchain->win_handle, 0, DCX_USESTYLE | DCX_CACHE)))
451 ERR("Failed to get destination DC.\n");
452
453 if (!StretchBlt(dst_dc, dst_rect->left, dst_rect->top, dst_rect->right - dst_rect->left,
454 dst_rect->bottom - dst_rect->top, src_dc, src_rect->left, src_rect->top,
455 src_rect->right - src_rect->left, src_rect->bottom - src_rect->top, SRCCOPY))
456 ERR("Failed to blit.\n");
457
458 ReleaseDC(swapchain->win_handle, dst_dc);
459 destroy_desc.hDc = src_dc;
460 destroy_desc.hBitmap = bitmap;
461 if ((status = D3DKMTDestroyDCFromMemory(&destroy_desc)))
462 ERR("Failed to destroy src dc, status %#lx.\n", status);
463}
464
465/* A GL context is provided by the caller */
466static void swapchain_blit(const struct wined3d_swapchain *swapchain,
467 struct wined3d_context *context, const RECT *src_rect, const RECT *dst_rect)
468{
469 struct wined3d_texture *texture = swapchain->back_buffers[0];
470 struct wined3d_device *device = swapchain->device;
473
474 TRACE("swapchain %p, context %p, src_rect %s, dst_rect %s.\n",
475 swapchain, context, wine_dbgstr_rect(src_rect), wine_dbgstr_rect(dst_rect));
476
477 if ((src_rect->right - src_rect->left == dst_rect->right - dst_rect->left
478 && src_rect->bottom - src_rect->top == dst_rect->bottom - dst_rect->top)
479 || is_complex_fixup(texture->resource.format->color_fixup))
481 else
483
485 if (texture->resource.multisample_type)
487
489 device->blitter->ops->blitter_blit(device->blitter, WINED3D_BLIT_OP_COLOR_BLIT, context, texture, 0,
490 location, src_rect, texture, 0, WINED3D_LOCATION_DRAWABLE, dst_rect, NULL, filter, NULL);
492}
493
495 struct wined3d_context_gl *context_gl, unsigned int swap_interval)
496{
497 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
498
499 swap_interval = swap_interval <= 4 ? swap_interval : 1;
500 if (swapchain->swap_interval == swap_interval)
501 return;
502
503 swapchain->swap_interval = swap_interval;
504
505 if (!gl_info->supported[WGL_EXT_SWAP_CONTROL])
506 return;
507
508 if (!GL_EXTCALL(wglSwapIntervalEXT(swap_interval)))
509 {
510 ERR("Failed to set swap interval %u for context %p, last error %#lx.\n",
511 swap_interval, context_gl, GetLastError());
512 }
513}
514
515/* Context activation is done by the caller. */
517{
518 struct wined3d_texture_sub_resource *sub_resource;
519 struct wined3d_texture_gl *texture, *texture_prev;
520 struct gl_texture tex0;
521 GLuint rb0;
522 DWORD locations0;
523 unsigned int i;
524 static const DWORD supported_locations = WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_RB_MULTISAMPLE;
525
526 if (swapchain->state.desc.backbuffer_count < 2)
527 return;
528
529 texture_prev = wined3d_texture_gl(swapchain->back_buffers[0]);
530
531 /* Back buffer 0 is already in the draw binding. */
532 tex0 = texture_prev->texture_rgb;
533 rb0 = texture_prev->rb_multisample;
534 locations0 = texture_prev->t.sub_resources[0].locations;
535
536 for (i = 1; i < swapchain->state.desc.backbuffer_count; ++i)
537 {
539 sub_resource = &texture->t.sub_resources[0];
540
541 if (!(sub_resource->locations & supported_locations))
542 wined3d_texture_load_location(&texture->t, 0, context, texture->t.resource.draw_binding);
543
544 texture_prev->texture_rgb = texture->texture_rgb;
545 texture_prev->rb_multisample = texture->rb_multisample;
546
547 wined3d_texture_validate_location(&texture_prev->t, 0, sub_resource->locations & supported_locations);
548 wined3d_texture_invalidate_location(&texture_prev->t, 0, ~(sub_resource->locations & supported_locations));
549
550 texture_prev = texture;
551 }
552
553 texture_prev->texture_rgb = tex0;
554 texture_prev->rb_multisample = rb0;
555
556 wined3d_texture_validate_location(&texture_prev->t, 0, locations0 & supported_locations);
557 wined3d_texture_invalidate_location(&texture_prev->t, 0, ~(locations0 & supported_locations));
558
560}
561
562static bool swapchain_present_is_partial_copy(struct wined3d_swapchain *swapchain, const RECT *dst_rect)
563{
564 enum wined3d_swap_effect swap_effect = swapchain->state.desc.swap_effect;
565 RECT client_rect;
566 unsigned int t;
567
568 if (swap_effect != WINED3D_SWAP_EFFECT_COPY && swap_effect != WINED3D_SWAP_EFFECT_COPY_VSYNC)
569 return false;
570
571 GetClientRect(swapchain->win_handle, &client_rect);
572
573 t = client_rect.right - client_rect.left;
574 if ((dst_rect->left && dst_rect->right) || abs(dst_rect->right - dst_rect->left) != t)
575 return true;
576 t = client_rect.bottom - client_rect.top;
577 if ((dst_rect->top && dst_rect->bottom) || abs(dst_rect->bottom - dst_rect->top) != t)
578 return true;
579
580 return false;
581}
582
583static void swapchain_gl_present(struct wined3d_swapchain *swapchain,
584 const RECT *src_rect, const RECT *dst_rect, unsigned int swap_interval, uint32_t flags)
585{
586 struct wined3d_texture *back_buffer = swapchain->back_buffers[0];
588 const struct wined3d_gl_info *gl_info;
589 struct wined3d_context_gl *context_gl;
590 struct wined3d_context *context;
591
592 context = context_acquire(swapchain->device, swapchain->front_buffer, 0);
593 context_gl = wined3d_context_gl(context);
594 if (!context_gl->valid)
595 {
597 WARN("Invalid context, skipping present.\n");
598 return;
599 }
600
601 TRACE("Presenting DC %p.\n", context_gl->dc);
602
603 pixel_format = &wined3d_adapter_gl(swapchain->device->adapter)->pixel_formats[context_gl->pixel_format];
604 if (context_gl->dc == wined3d_device_gl(swapchain->device)->backup_dc
605 || (pixel_format->swap_method != WGL_SWAP_COPY_ARB
607 {
608 swapchain_blit_gdi(swapchain, context, src_rect, dst_rect);
609 }
610 else
611 {
612 gl_info = context_gl->gl_info;
613
614 swapchain_gl_set_swap_interval(swapchain, context_gl, swap_interval);
615
616 wined3d_texture_load_location(back_buffer, 0, context, back_buffer->resource.draw_binding);
617
618 swapchain_blit(swapchain, context, src_rect, dst_rect);
619
620 if (swapchain->device->context_count > 1)
621 {
622 WARN_(d3d_perf)("Multiple contexts, calling glFinish() to enforce ordering.\n");
623 gl_info->gl_ops.gl.p_glFinish();
624 }
625
626 /* call wglSwapBuffers through the gl table to avoid confusing the Steam overlay */
627 gl_info->gl_ops.wgl.p_wglSwapBuffers(context_gl->dc);
628 }
629
630 if (context->d3d_info->fences)
632
634
635 TRACE("SwapBuffers called, Starting new frame\n");
636
639
641}
642
644{
645 struct wined3d_texture *front_buffer = swapchain->front_buffer;
646 struct wined3d_context *context;
647
648 context = context_acquire(swapchain->device, front_buffer, 0);
649 wined3d_texture_load_location(front_buffer, 0, context, front_buffer->resource.draw_binding);
651 SetRectEmpty(&swapchain->front_buffer_update);
652}
653
655{
658};
659
661 VkPresentModeKHR vk_present_mode)
662{
663 struct wined3d_device_vk *device_vk = wined3d_device_vk(swapchain_vk->s.device);
664 const struct wined3d_vk_info *vk_info;
665 struct wined3d_adapter_vk *adapter_vk;
666 VkPhysicalDevice vk_physical_device;
667 VkPresentModeKHR *vk_modes;
668 bool supported = false;
670 VkResult vr;
671
672 adapter_vk = wined3d_adapter_vk(device_vk->d.adapter);
673 vk_physical_device = adapter_vk->physical_device;
674 vk_info = &adapter_vk->vk_info;
675
676 if ((vr = VK_CALL(vkGetPhysicalDeviceSurfacePresentModesKHR(vk_physical_device,
677 swapchain_vk->vk_surface, &count, NULL))) < 0)
678 {
679 ERR("Failed to get supported present mode count, vr %s.\n", wined3d_debug_vkresult(vr));
680 return false;
681 }
682
683 if (!(vk_modes = calloc(count, sizeof(*vk_modes))))
684 return false;
685
686 if ((vr = VK_CALL(vkGetPhysicalDeviceSurfacePresentModesKHR(vk_physical_device,
687 swapchain_vk->vk_surface, &count, vk_modes))) < 0)
688 {
689 ERR("Failed to get supported present modes, vr %s.\n", wined3d_debug_vkresult(vr));
690 goto done;
691 }
692
693 for (i = 0; i < count; ++i)
694 {
695 if (vk_modes[i] == vk_present_mode)
696 {
697 supported = true;
698 goto done;
699 }
700 }
701
702done:
703 free(vk_modes);
704 return supported;
705}
706
708{
709 switch (vk_format)
710 {
717 default:
718 WARN("Unhandled format %#x.\n", vk_format);
719 return VK_FORMAT_UNDEFINED;
720 }
721}
722
724 VkSurfaceKHR vk_surface)
725{
726 struct wined3d_device_vk *device_vk = wined3d_device_vk(swapchain_vk->s.device);
727 const struct wined3d_swapchain_desc *desc = &swapchain_vk->s.state.desc;
728 const struct wined3d_vk_info *vk_info;
729 struct wined3d_adapter_vk *adapter_vk;
730 const struct wined3d_format *format;
731 VkPhysicalDevice vk_physical_device;
732 VkSurfaceFormatKHR *vk_formats;
733 uint32_t format_count, i;
734 VkFormat vk_format;
735 VkResult vr;
736
737 adapter_vk = wined3d_adapter_vk(device_vk->d.adapter);
738 vk_physical_device = adapter_vk->physical_device;
739 vk_info = &adapter_vk->vk_info;
740
741 if ((format = wined3d_get_format(&adapter_vk->a, desc->backbuffer_format, WINED3D_BIND_RENDER_TARGET)))
742 vk_format = wined3d_format_vk(format)->vk_format;
743 else
744 vk_format = VK_FORMAT_B8G8R8A8_UNORM;
745
746 vr = VK_CALL(vkGetPhysicalDeviceSurfaceFormatsKHR(vk_physical_device, vk_surface, &format_count, NULL));
747 if (vr < 0 || !format_count)
748 {
749 WARN("Failed to get supported surface format count, vr %s.\n", wined3d_debug_vkresult(vr));
750 return VK_FORMAT_UNDEFINED;
751 }
752
753 if (!(vk_formats = calloc(format_count, sizeof(*vk_formats))))
754 return VK_FORMAT_UNDEFINED;
755
756 if ((vr = VK_CALL(vkGetPhysicalDeviceSurfaceFormatsKHR(vk_physical_device,
757 vk_surface, &format_count, vk_formats))) < 0)
758 {
759 WARN("Failed to get supported surface formats, vr %s.\n", wined3d_debug_vkresult(vr));
760 free(vk_formats);
761 return VK_FORMAT_UNDEFINED;
762 }
763
764 for (i = 0; i < format_count; ++i)
765 {
766 if (vk_formats[i].format == vk_format && vk_formats[i].colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR)
767 break;
768 }
769 if (i == format_count)
770 {
771 /* Try to create a swapchain with format conversion. */
772 vk_format = get_swapchain_fallback_format(vk_format);
773 WARN("Failed to find Vulkan swapchain format for %s.\n", debug_d3dformat(desc->backbuffer_format));
774 for (i = 0; i < format_count; ++i)
775 {
776 if (vk_formats[i].format == vk_format && vk_formats[i].colorSpace == VK_COLOR_SPACE_SRGB_NONLINEAR_KHR)
777 break;
778 }
779 }
780 free(vk_formats);
781 if (i == format_count)
782 {
783 FIXME("Failed to find Vulkan swapchain format for %s.\n", debug_d3dformat(desc->backbuffer_format));
784 return VK_FORMAT_UNDEFINED;
785 }
786
787 TRACE("Using Vulkan swapchain format %#x.\n", vk_format);
788
789 return vk_format;
790}
791
793 VkSwapchainKHR vk_swapchain)
794{
795 struct wined3d_device_vk *device_vk = wined3d_device_vk(swapchain_vk->s.device);
796 const struct wined3d_vk_info *vk_info;
797 VkSemaphoreCreateInfo semaphore_info;
798 uint32_t image_count, i;
799 VkResult vr;
800
801 vk_info = &wined3d_adapter_vk(device_vk->d.adapter)->vk_info;
802
803 if ((vr = VK_CALL(vkGetSwapchainImagesKHR(device_vk->vk_device, vk_swapchain, &image_count, NULL))) < 0)
804 {
805 ERR("Failed to get image count, vr %s\n", wined3d_debug_vkresult(vr));
806 return false;
807 }
808
809 if (!(swapchain_vk->vk_images = calloc(image_count, sizeof(*swapchain_vk->vk_images))))
810 {
811 ERR("Failed to allocate images array.\n");
812 return false;
813 }
814
815 if ((vr = VK_CALL(vkGetSwapchainImagesKHR(device_vk->vk_device,
816 vk_swapchain, &image_count, swapchain_vk->vk_images))) < 0)
817 {
818 ERR("Failed to get swapchain images, vr %s.\n", wined3d_debug_vkresult(vr));
819 free(swapchain_vk->vk_images);
820 return false;
821 }
822
823 if (!(swapchain_vk->vk_semaphores = calloc(image_count, sizeof(*swapchain_vk->vk_semaphores))))
824 {
825 ERR("Failed to allocate semaphores array.\n");
826 free(swapchain_vk->vk_images);
827 return false;
828 }
829
831 semaphore_info.pNext = NULL;
832 semaphore_info.flags = 0;
833 for (i = 0; i < image_count; ++i)
834 {
835 if ((vr = VK_CALL(vkCreateSemaphore(device_vk->vk_device,
836 &semaphore_info, NULL, &swapchain_vk->vk_semaphores[i].available))) < 0)
837 {
838 ERR("Failed to create semaphore, vr %s.\n", wined3d_debug_vkresult(vr));
839 goto fail;
840 }
841
842 if ((vr = VK_CALL(vkCreateSemaphore(device_vk->vk_device,
843 &semaphore_info, NULL, &swapchain_vk->vk_semaphores[i].presentable))) < 0)
844 {
845 ERR("Failed to create semaphore, vr %s.\n", wined3d_debug_vkresult(vr));
846 goto fail;
847 }
848 }
849 swapchain_vk->image_count = image_count;
850
851 return true;
852
853fail:
854 for (i = 0; i < image_count; ++i)
855 {
856 if (swapchain_vk->vk_semaphores[i].available)
857 VK_CALL(vkDestroySemaphore(device_vk->vk_device, swapchain_vk->vk_semaphores[i].available, NULL));
858 if (swapchain_vk->vk_semaphores[i].presentable)
859 VK_CALL(vkDestroySemaphore(device_vk->vk_device, swapchain_vk->vk_semaphores[i].presentable, NULL));
860 }
861 free(swapchain_vk->vk_semaphores);
862 free(swapchain_vk->vk_images);
863 return false;
864}
865
867{
868 struct wined3d_device_vk *device_vk = wined3d_device_vk(swapchain_vk->s.device);
869 const struct wined3d_swapchain_desc *desc = &swapchain_vk->s.state.desc;
870 VkSwapchainCreateInfoKHR vk_swapchain_desc;
871 VkWin32SurfaceCreateInfoKHR surface_desc;
872 unsigned int width, height, image_count;
873 const struct wined3d_vk_info *vk_info;
874 VkSurfaceCapabilitiesKHR surface_caps;
875 struct wined3d_adapter_vk *adapter_vk;
876 VkPresentModeKHR vk_present_mode;
877 VkSwapchainKHR vk_swapchain;
879 VkSurfaceKHR vk_surface;
880 VkBool32 supported;
881 VkFormat vk_format;
882 RECT client_rect;
883 VkResult vr;
884
885 adapter_vk = wined3d_adapter_vk(device_vk->d.adapter);
886 vk_info = &adapter_vk->vk_info;
887
889 surface_desc.pNext = NULL;
890 surface_desc.flags = 0;
891 surface_desc.hinstance = (HINSTANCE)GetWindowLongPtrW(swapchain_vk->s.win_handle, GWLP_HINSTANCE);
892 surface_desc.hwnd = swapchain_vk->s.win_handle;
893 if ((vr = VK_CALL(vkCreateWin32SurfaceKHR(vk_info->instance, &surface_desc, NULL, &vk_surface))) < 0)
894 {
895 ERR("Failed to create Vulkan surface, vr %s.\n", wined3d_debug_vkresult(vr));
896 return E_FAIL;
897 }
898 swapchain_vk->vk_surface = vk_surface;
899
901 device_vk->vk_queue_family_index, vk_surface, &supported))) < 0 || !supported)
902 {
903 ERR("Queue family does not support presentation on this surface, vr %s.\n", wined3d_debug_vkresult(vr));
904 goto fail;
905 }
906
907 if ((vk_format = wined3d_swapchain_vk_select_vk_format(swapchain_vk, vk_surface)) == VK_FORMAT_UNDEFINED)
908 {
909 ERR("Failed to select swapchain format.\n");
910 goto fail;
911 }
912
914 swapchain_vk->vk_surface, &surface_caps))) < 0)
915 {
916 ERR("Failed to get surface capabilities, vr %s.\n", wined3d_debug_vkresult(vr));
917 goto fail;
918 }
919
920 image_count = desc->backbuffer_count;
921 if (image_count < surface_caps.minImageCount)
922 image_count = surface_caps.minImageCount;
923 else if (surface_caps.maxImageCount && image_count > surface_caps.maxImageCount)
924 image_count = surface_caps.maxImageCount;
925
926 if (image_count != desc->backbuffer_count)
927 WARN("Image count %u is not supported (%u-%u).\n", desc->backbuffer_count,
928 surface_caps.minImageCount, surface_caps.maxImageCount);
929
930 GetClientRect(swapchain_vk->s.win_handle, &client_rect);
931
932 width = client_rect.right - client_rect.left;
933 if (width < surface_caps.minImageExtent.width)
934 width = surface_caps.minImageExtent.width;
935 else if (width > surface_caps.maxImageExtent.width)
936 width = surface_caps.maxImageExtent.width;
937
938 height = client_rect.bottom - client_rect.top;
939 if (height < surface_caps.minImageExtent.height)
940 height = surface_caps.minImageExtent.height;
941 else if (height > surface_caps.maxImageExtent.height)
942 height = surface_caps.maxImageExtent.height;
943
944 if (width != client_rect.right - client_rect.left || height != client_rect.bottom - client_rect.top)
945 WARN("Swapchain dimensions %lux%lu are not supported (%u-%u x %u-%u).\n",
946 client_rect.right - client_rect.left, client_rect.bottom - client_rect.top,
947 surface_caps.minImageExtent.width, surface_caps.maxImageExtent.width,
948 surface_caps.minImageExtent.height, surface_caps.maxImageExtent.height);
949
954 WARN("Transfer not supported for swapchain images.\n");
955
957 {
958 FIXME("Unsupported alpha mode, %#x.\n", surface_caps.supportedCompositeAlpha);
959 goto fail;
960 }
961
962 vk_present_mode = VK_PRESENT_MODE_FIFO_KHR;
963 if (!swapchain_vk->s.swap_interval)
964 {
966 vk_present_mode = VK_PRESENT_MODE_IMMEDIATE_KHR;
967 else
968 FIXME("Unsupported swap interval %u.\n", swapchain_vk->s.swap_interval);
969 }
970
972 vk_swapchain_desc.pNext = NULL;
973 vk_swapchain_desc.flags = 0;
974 vk_swapchain_desc.surface = vk_surface;
975 vk_swapchain_desc.minImageCount = image_count;
976 vk_swapchain_desc.imageFormat = vk_format;
978 vk_swapchain_desc.imageExtent.width = width;
979 vk_swapchain_desc.imageExtent.height = height;
980 vk_swapchain_desc.imageArrayLayers = 1;
981 vk_swapchain_desc.imageUsage = usage;
983 vk_swapchain_desc.queueFamilyIndexCount = 0;
984 vk_swapchain_desc.pQueueFamilyIndices = NULL;
985 vk_swapchain_desc.preTransform = surface_caps.currentTransform;
987 vk_swapchain_desc.presentMode = vk_present_mode;
988 vk_swapchain_desc.clipped = VK_TRUE;
989 vk_swapchain_desc.oldSwapchain = VK_NULL_HANDLE;
990 if ((vr = VK_CALL(vkCreateSwapchainKHR(device_vk->vk_device, &vk_swapchain_desc, NULL, &vk_swapchain))) < 0)
991 {
992 ERR("Failed to create Vulkan swapchain, vr %s.\n", wined3d_debug_vkresult(vr));
993 goto fail;
994 }
995 swapchain_vk->vk_swapchain = vk_swapchain;
996
997 if (!wined3d_swapchain_vk_create_vulkan_swapchain_images(swapchain_vk, vk_swapchain))
998 {
999 VK_CALL(vkDestroySwapchainKHR(device_vk->vk_device, vk_swapchain, NULL));
1000 goto fail;
1001 }
1002
1003 swapchain_vk->width = width;
1004 swapchain_vk->height = height;
1005
1006 return WINED3D_OK;
1007
1008fail:
1009 VK_CALL(vkDestroySurfaceKHR(vk_info->instance, vk_surface, NULL));
1010 return E_FAIL;
1011}
1012
1014{
1015 TRACE("swapchain_vk %p.\n", swapchain_vk);
1016
1018
1020}
1021
1023 unsigned int swap_interval)
1024{
1025 if (swap_interval > 1)
1026 {
1027 if (swap_interval <= 4)
1028 FIXME("Unsupported swap interval %u.\n", swap_interval);
1029 swap_interval = 1;
1030 }
1031
1032 if (swapchain_vk->s.swap_interval == swap_interval)
1033 return;
1034
1035 swapchain_vk->s.swap_interval = swap_interval;
1036 wined3d_swapchain_vk_recreate(swapchain_vk);
1037}
1038
1040 struct wined3d_context_vk *context_vk, const RECT *src_rect, const RECT *dst_rect, unsigned int swap_interval)
1041{
1042 struct wined3d_texture_vk *back_buffer_vk = wined3d_texture_vk(swapchain_vk->s.back_buffers[0]);
1043 struct wined3d_device_vk *device_vk = wined3d_device_vk(swapchain_vk->s.device);
1044 const struct wined3d_swapchain_desc *desc = &swapchain_vk->s.state.desc;
1045 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
1046 VkCommandBuffer vk_command_buffer;
1047 VkImageSubresourceRange vk_range;
1048 VkPresentInfoKHR present_desc;
1049 unsigned int present_idx;
1050 VkImageLayout vk_layout;
1051 uint32_t image_idx;
1052 RECT dst_rect_tmp;
1053 VkImageBlit blit;
1055 VkResult vr;
1056
1058
1059 TRACE("swapchain_vk %p, context_vk %p, src_rect %s, dst_rect %s, swap_interval %u.\n",
1060 swapchain_vk, context_vk, wine_dbgstr_rect(src_rect), wine_dbgstr_rect(dst_rect), swap_interval);
1061
1062 wined3d_swapchain_vk_set_swap_interval(swapchain_vk, swap_interval);
1063
1064 present_idx = swapchain_vk->current++ % swapchain_vk->image_count;
1065 wined3d_context_vk_wait_command_buffer(context_vk, swapchain_vk->vk_semaphores[present_idx].command_buffer_id);
1066 if ((vr = VK_CALL(vkAcquireNextImageKHR(device_vk->vk_device, swapchain_vk->vk_swapchain, UINT64_MAX,
1067 swapchain_vk->vk_semaphores[present_idx].available, VK_NULL_HANDLE, &image_idx))) < 0)
1068 {
1069 WARN("Failed to acquire image, vr %s.\n", wined3d_debug_vkresult(vr));
1070 return vr;
1071 }
1072
1073 if (dst_rect->right > swapchain_vk->width || dst_rect->bottom > swapchain_vk->height)
1074 {
1075 dst_rect_tmp = *dst_rect;
1076 if (dst_rect->right > swapchain_vk->width)
1077 dst_rect_tmp.right = swapchain_vk->width;
1078 if (dst_rect->bottom > swapchain_vk->height)
1079 dst_rect_tmp.bottom = swapchain_vk->height;
1080 dst_rect = &dst_rect_tmp;
1081 }
1082 filter = src_rect->right - src_rect->left != dst_rect->right - dst_rect->left
1083 || src_rect->bottom - src_rect->top != dst_rect->bottom - dst_rect->top
1085 vk_command_buffer = wined3d_context_vk_get_command_buffer(context_vk);
1086
1088
1090 vk_range.baseMipLevel = 0;
1091 vk_range.levelCount = 1;
1092 vk_range.baseArrayLayer = 0;
1093 vk_range.layerCount = 1;
1094
1095 wined3d_context_vk_image_barrier(context_vk, vk_command_buffer,
1097 vk_access_mask_from_bind_flags(back_buffer_vk->t.resource.bind_flags),
1100 back_buffer_vk->image.vk_image, &vk_range);
1101
1102 wined3d_context_vk_image_barrier(context_vk, vk_command_buffer,
1106 swapchain_vk->vk_images[image_idx], &vk_range);
1107
1108 blit.srcSubresource.aspectMask = vk_range.aspectMask;
1109 blit.srcSubresource.mipLevel = vk_range.baseMipLevel;
1111 blit.srcSubresource.layerCount = vk_range.layerCount;
1112 blit.srcOffsets[0].x = src_rect->left;
1113 blit.srcOffsets[0].y = src_rect->top;
1114 blit.srcOffsets[0].z = 0;
1115 blit.srcOffsets[1].x = src_rect->right;
1116 blit.srcOffsets[1].y = src_rect->bottom;
1117 blit.srcOffsets[1].z = 1;
1118 blit.dstSubresource = blit.srcSubresource;
1119 blit.dstOffsets[0].x = dst_rect->left;
1120 blit.dstOffsets[0].y = dst_rect->top;
1121 blit.dstOffsets[0].z = 0;
1122 blit.dstOffsets[1].x = dst_rect->right;
1123 blit.dstOffsets[1].y = dst_rect->bottom;
1124 blit.dstOffsets[1].z = 1;
1125 VK_CALL(vkCmdBlitImage(vk_command_buffer,
1126 back_buffer_vk->image.vk_image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
1127 swapchain_vk->vk_images[image_idx], VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
1128 1, &blit, filter));
1129
1130 wined3d_context_vk_reference_texture(context_vk, back_buffer_vk);
1131 wined3d_context_vk_image_barrier(context_vk, vk_command_buffer,
1135 swapchain_vk->vk_images[image_idx], &vk_range);
1136
1137 if (desc->swap_effect == WINED3D_SWAP_EFFECT_DISCARD || desc->swap_effect == WINED3D_SWAP_EFFECT_FLIP_DISCARD)
1138 vk_layout = VK_IMAGE_LAYOUT_UNDEFINED;
1139 else
1141 wined3d_context_vk_image_barrier(context_vk, vk_command_buffer,
1144 vk_access_mask_from_bind_flags(back_buffer_vk->t.resource.bind_flags),
1145 vk_layout, back_buffer_vk->layout,
1146 back_buffer_vk->image.vk_image, &vk_range);
1147 back_buffer_vk->bind_mask = 0;
1148
1149 swapchain_vk->vk_semaphores[present_idx].command_buffer_id = context_vk->current_command_buffer.id;
1151 1, &swapchain_vk->vk_semaphores[present_idx].available, &wait_stage,
1152 1, &swapchain_vk->vk_semaphores[present_idx].presentable);
1153
1155 present_desc.pNext = NULL;
1156 present_desc.waitSemaphoreCount = 1;
1157 present_desc.pWaitSemaphores = &swapchain_vk->vk_semaphores[present_idx].presentable;
1158 present_desc.swapchainCount = 1;
1159 present_desc.pSwapchains = &swapchain_vk->vk_swapchain;
1160 present_desc.pImageIndices = &image_idx;
1161 present_desc.pResults = NULL;
1162 if ((vr = VK_CALL(vkQueuePresentKHR(device_vk->vk_queue, &present_desc))))
1163 WARN("Present returned vr %s.\n", wined3d_debug_vkresult(vr));
1164 return vr;
1165}
1166
1167static void wined3d_swapchain_vk_rotate(struct wined3d_swapchain *swapchain, struct wined3d_context_vk *context_vk)
1168{
1169 struct wined3d_texture_sub_resource *sub_resource;
1170 struct wined3d_texture_vk *texture, *texture_prev;
1171 struct wined3d_image_vk image0;
1172 VkDescriptorImageInfo vk_info0;
1173 VkImageLayout vk_layout0;
1174 uint32_t bind_mask0;
1175 DWORD locations0;
1176 unsigned int i;
1177
1178 static const DWORD supported_locations = WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_RB_MULTISAMPLE;
1179
1180 if (swapchain->state.desc.backbuffer_count < 2)
1181 return;
1182
1183 texture_prev = wined3d_texture_vk(swapchain->back_buffers[0]);
1184
1185 /* Back buffer 0 is already in the draw binding. */
1186 image0 = texture_prev->image;
1187 vk_layout0 = texture_prev->layout;
1188 bind_mask0 = texture_prev->bind_mask;
1189 vk_info0 = texture_prev->default_image_info;
1190 locations0 = texture_prev->t.sub_resources[0].locations;
1191
1192 for (i = 1; i < swapchain->state.desc.backbuffer_count; ++i)
1193 {
1195 sub_resource = &texture->t.sub_resources[0];
1196
1197 if (!(sub_resource->locations & supported_locations))
1198 wined3d_texture_load_location(&texture->t, 0, &context_vk->c, texture->t.resource.draw_binding);
1199
1200 texture_prev->image = texture->image;
1201 texture_prev->layout = texture->layout;
1202 texture_prev->bind_mask = texture->bind_mask;
1203 texture_prev->default_image_info = texture->default_image_info;
1204
1205 wined3d_texture_validate_location(&texture_prev->t, 0, sub_resource->locations & supported_locations);
1206 wined3d_texture_invalidate_location(&texture_prev->t, 0, ~(sub_resource->locations & supported_locations));
1207
1208 texture_prev = texture;
1209 }
1210
1211 texture_prev->image = image0;
1212 texture_prev->layout = vk_layout0;
1213 texture_prev->bind_mask = bind_mask0;
1214 texture_prev->default_image_info = vk_info0;
1215
1216 wined3d_texture_validate_location(&texture_prev->t, 0, locations0 & supported_locations);
1217 wined3d_texture_invalidate_location(&texture_prev->t, 0, ~(locations0 & supported_locations));
1218
1220}
1221
1222static void swapchain_vk_present(struct wined3d_swapchain *swapchain, const RECT *src_rect,
1223 const RECT *dst_rect, unsigned int swap_interval, uint32_t flags)
1224{
1225 struct wined3d_swapchain_vk *swapchain_vk = wined3d_swapchain_vk(swapchain);
1226 struct wined3d_texture *back_buffer = swapchain->back_buffers[0];
1227 struct wined3d_context_vk *context_vk;
1228 VkResult vr;
1229 HRESULT hr;
1230
1231 context_vk = wined3d_context_vk(context_acquire(swapchain->device, back_buffer, 0));
1232
1233 if (!swapchain_vk->vk_swapchain || swapchain_present_is_partial_copy(swapchain, dst_rect))
1234 {
1235 swapchain_blit_gdi(swapchain, &context_vk->c, src_rect, dst_rect);
1236 }
1237 else
1238 {
1239 wined3d_texture_load_location(back_buffer, 0, &context_vk->c, back_buffer->resource.draw_binding);
1240
1241 if ((vr = wined3d_swapchain_vk_blit(swapchain_vk, context_vk, src_rect, dst_rect, swap_interval)))
1242 {
1244 {
1245 if (FAILED(hr = wined3d_swapchain_vk_recreate(swapchain_vk)))
1246 ERR("Failed to recreate swapchain, hr %#lx.\n", hr);
1248 swapchain_vk, context_vk, src_rect, dst_rect, swap_interval)))
1249 ERR("Failed to blit image, vr %s.\n", wined3d_debug_vkresult(vr));
1250 }
1251 else
1252 {
1253 ERR("Failed to blit image, vr %s.\n", wined3d_debug_vkresult(vr));
1254 }
1255 }
1256 }
1257
1258 wined3d_swapchain_vk_rotate(swapchain, context_vk);
1259
1262
1263 TRACE("Starting new frame.\n");
1264
1265 context_release(&context_vk->c);
1266}
1267
1269{
1272};
1273
1275{
1276 struct wined3d_dc_info *front;
1277 POINT offset = {0, 0};
1278 HDC src_dc, dst_dc;
1279 RECT draw_rect;
1280 HWND window;
1281
1282 TRACE("swapchain %p.\n", swapchain);
1283
1284 front = &swapchain->front_buffer->dc_info[0];
1285 if (swapchain->palette)
1286 wined3d_palette_apply_to_dc(swapchain->palette, front->dc);
1287
1288 if (swapchain->front_buffer->resource.map_count)
1289 ERR("Trying to blit a mapped surface.\n");
1290
1291 TRACE("Copying surface %p to screen.\n", front);
1292
1293 src_dc = front->dc;
1294 window = swapchain->win_handle;
1295 dst_dc = GetDCEx(window, 0, DCX_CLIPSIBLINGS | DCX_CACHE);
1296
1297 /* Front buffer coordinates are screen coordinates. Map them to the
1298 * destination window if not fullscreened. */
1299 if (swapchain->state.desc.windowed)
1301
1302 TRACE("offset %s.\n", wine_dbgstr_point(&offset));
1303
1304 SetRect(&draw_rect, 0, 0, swapchain->front_buffer->resource.width,
1305 swapchain->front_buffer->resource.height);
1306 IntersectRect(&draw_rect, &draw_rect, &swapchain->front_buffer_update);
1307
1308 BitBlt(dst_dc, draw_rect.left - offset.x, draw_rect.top - offset.y,
1309 draw_rect.right - draw_rect.left, draw_rect.bottom - draw_rect.top,
1310 src_dc, draw_rect.left, draw_rect.top, SRCCOPY);
1311 ReleaseDC(window, dst_dc);
1312
1313 SetRectEmpty(&swapchain->front_buffer_update);
1314}
1315
1316static void swapchain_gdi_present(struct wined3d_swapchain *swapchain,
1317 const RECT *src_rect, const RECT *dst_rect, unsigned int swap_interval, uint32_t flags)
1318{
1319 struct wined3d_dc_info *front, *back;
1321 void *data;
1322 HDC dc;
1323
1324 front = &swapchain->front_buffer->dc_info[0];
1325 back = &swapchain->back_buffers[0]->dc_info[0];
1326
1327 /* Flip the surface data. */
1328 dc = front->dc;
1329 bitmap = front->bitmap;
1330 data = swapchain->front_buffer->resource.heap_memory;
1331
1332 front->dc = back->dc;
1333 front->bitmap = back->bitmap;
1334 swapchain->front_buffer->resource.heap_memory = swapchain->back_buffers[0]->resource.heap_memory;
1335
1336 back->dc = dc;
1337 back->bitmap = bitmap;
1338 swapchain->back_buffers[0]->resource.heap_memory = data;
1339
1340 SetRect(&swapchain->front_buffer_update, 0, 0,
1341 swapchain->front_buffer->resource.width,
1342 swapchain->front_buffer->resource.height);
1344}
1345
1347{
1350};
1351
1354{
1355 const struct wined3d_adapter *adapter;
1356 const struct wined3d_format *format;
1358
1360 return;
1361
1362 adapter = swapchain->device->adapter;
1364 return;
1365
1366 if ((t = min(wined3d_settings.sample_count, adapter->d3d_info.limits.sample_count)))
1367 while (!(format->multisample_types & 1u << (t - 1)))
1368 ++t;
1369 TRACE("Using sample count %u.\n", t);
1370 *type = t;
1371 *quality = 0;
1372}
1373
1375{
1376 /* Subtract 1 for the implicit OpenGL latency. */
1377 swapchain->max_frame_latency = device->max_frame_latency >= 2 ? device->max_frame_latency - 1 : 1;
1378}
1379
1382{
1383 const struct wined3d_format *backbuffer_format;
1384
1386 return pixelformat_for_depth(backbuffer_format->byte_count * CHAR_BIT);
1387}
1388
1390 const struct wined3d_swapchain_desc *desc, HWND window, struct wined3d *wined3d,
1392{
1393 HRESULT hr;
1394
1395 state->desc = *desc;
1396
1397 if (FAILED(hr = wined3d_output_get_display_mode(desc->output, &state->original_mode, NULL)))
1398 {
1399 ERR("Failed to get current display mode, hr %#lx.\n", hr);
1400 return hr;
1401 }
1402
1403 if (state->desc.windowed)
1404 {
1405 RECT client_rect;
1406
1407 GetClientRect(window, &client_rect);
1408 TRACE("Client rect %s.\n", wine_dbgstr_rect(&client_rect));
1409
1410 if (!state->desc.backbuffer_width)
1411 {
1412 state->desc.backbuffer_width = client_rect.right ? client_rect.right : 8;
1413 TRACE("Updating width to %u.\n", state->desc.backbuffer_width);
1414 }
1415 if (!state->desc.backbuffer_height)
1416 {
1417 state->desc.backbuffer_height = client_rect.bottom ? client_rect.bottom : 8;
1418 TRACE("Updating height to %u.\n", state->desc.backbuffer_height);
1419 }
1420
1421 if (state->desc.backbuffer_format == WINED3DFMT_UNKNOWN)
1422 {
1423 state->desc.backbuffer_format = state->original_mode.format_id;
1424 TRACE("Updating format to %s.\n", debug_d3dformat(state->original_mode.format_id));
1425 }
1426 }
1427 else
1428 {
1430 {
1431 state->d3d_mode.width = desc->backbuffer_width;
1432 state->d3d_mode.height = desc->backbuffer_height;
1433 state->d3d_mode.format_id = adapter_format_from_backbuffer_format(desc->output->adapter,
1434 desc->backbuffer_format);
1435 state->d3d_mode.refresh_rate = desc->refresh_rate;
1436 state->d3d_mode.scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN;
1437 }
1438 else
1439 {
1440 state->d3d_mode = state->original_mode;
1441 }
1442 }
1443
1444 GetWindowRect(window, &state->original_window_rect);
1445 state->wined3d = wined3d;
1446 state->device_window = window;
1447 state->desc.device_window = window;
1448 state->parent = parent;
1449
1452
1453 return hr;
1454}
1455
1457 bool front, bool depth, struct wined3d_texture **texture)
1458{
1459 const struct wined3d_swapchain_desc *swapchain_desc = &swapchain->state.desc;
1460 struct wined3d_device *device = swapchain->device;
1461 struct wined3d_resource_desc texture_desc;
1462 uint32_t texture_flags = 0;
1463 HRESULT hr;
1464
1466 texture_desc.format = depth ? swapchain_desc->auto_depth_stencil_format : swapchain_desc->backbuffer_format;
1467 texture_desc.multisample_type = swapchain_desc->multisample_type;
1468 texture_desc.multisample_quality = swapchain_desc->multisample_quality;
1469 texture_desc.usage = 0;
1470 if (!depth && (device->wined3d->flags & WINED3D_NO3D))
1471 texture_desc.usage |= WINED3DUSAGE_OWNDC;
1472 if (device->wined3d->flags & WINED3D_NO3D)
1473 texture_desc.access = WINED3D_RESOURCE_ACCESS_CPU;
1474 else
1475 texture_desc.access = WINED3D_RESOURCE_ACCESS_GPU;
1476 if (!depth && (swapchain_desc->flags & WINED3D_SWAPCHAIN_LOCKABLE_BACKBUFFER))
1478 texture_desc.width = swapchain_desc->backbuffer_width;
1479 texture_desc.height = swapchain_desc->backbuffer_height;
1480 texture_desc.depth = 1;
1481 texture_desc.size = 0;
1482
1483 if (front)
1484 texture_desc.bind_flags = 0;
1485 else if (depth)
1487 else
1488 texture_desc.bind_flags = swapchain_desc->backbuffer_bind_flags;
1489
1490 if (swapchain_desc->flags & WINED3D_SWAPCHAIN_GDI_COMPATIBLE)
1491 texture_flags |= WINED3D_TEXTURE_CREATE_GET_DC;
1492
1493 if (FAILED(hr = wined3d_texture_create(device, &texture_desc, 1, 1,
1494 texture_flags, NULL, NULL, &wined3d_null_parent_ops, texture)))
1495 {
1496 WARN("Failed to create texture, hr %#lx.\n", hr);
1497 return hr;
1498 }
1499
1500 if (!depth)
1502
1503 return S_OK;
1504}
1505
1507 const struct wined3d_swapchain_desc *desc, struct wined3d_swapchain_state_parent *state_parent,
1508 void *parent, const struct wined3d_parent_ops *parent_ops,
1509 const struct wined3d_swapchain_ops *swapchain_ops)
1510{
1511 struct wined3d_output_desc output_desc;
1512 BOOL displaymode_set = FALSE;
1513 HRESULT hr = E_FAIL;
1514 unsigned int i;
1515 HWND window;
1516
1518
1519 if (desc->backbuffer_count > 1)
1520 {
1521 FIXME("The application requested more than one back buffer, this is not properly supported.\n"
1522 "Please configure the application to use double buffering (1 back buffer) if possible.\n");
1523 }
1524
1525 if (desc->swap_effect != WINED3D_SWAP_EFFECT_DISCARD
1526 && desc->swap_effect != WINED3D_SWAP_EFFECT_SEQUENTIAL
1527 && desc->swap_effect != WINED3D_SWAP_EFFECT_COPY)
1528 FIXME("Unimplemented swap effect %#x.\n", desc->swap_effect);
1529
1530 window = desc->device_window ? desc->device_window : device->create_parms.focus_window;
1531 TRACE("Using target window %p.\n", window);
1532
1533 if (FAILED(hr = wined3d_swapchain_state_init(&swapchain->state, desc, window, device->wined3d, state_parent)))
1534 {
1535 ERR("Failed to initialise swapchain state, hr %#lx.\n", hr);
1537 return hr;
1538 }
1539
1540 swapchain->swapchain_ops = swapchain_ops;
1541 swapchain->device = device;
1542 swapchain->parent = parent;
1543 swapchain->parent_ops = parent_ops;
1544 swapchain->ref = 1;
1545 swapchain->win_handle = window;
1548
1549 if (!swapchain->state.desc.windowed)
1550 {
1551 if (FAILED(hr = wined3d_output_get_desc(desc->output, &output_desc)))
1552 {
1553 ERR("Failed to get output description, hr %#lx.\n", hr);
1554 goto err;
1555 }
1556
1558 output_desc.desktop_rect.left, output_desc.desktop_rect.top, desc->backbuffer_width,
1559 desc->backbuffer_height);
1560 }
1561 wined3d_swapchain_apply_sample_count_override(swapchain, swapchain->state.desc.backbuffer_format,
1562 &swapchain->state.desc.multisample_type, &swapchain->state.desc.multisample_quality);
1563
1564 TRACE("Creating front buffer.\n");
1565
1566 if (FAILED(hr = swapchain_create_texture(swapchain, true, false, &swapchain->front_buffer)))
1567 {
1568 WARN("Failed to create front buffer, hr %#lx.\n", hr);
1569 goto err;
1570 }
1571
1572 if (!(device->wined3d->flags & WINED3D_NO3D))
1573 {
1576 }
1577
1578 /* MSDN says we're only allowed a single fullscreen swapchain per device,
1579 * so we should really check to see if there is a fullscreen swapchain
1580 * already. Does a single head count as full screen? */
1581 if (!desc->windowed && desc->flags & WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH)
1582 {
1583 /* Change the display settings */
1585 &swapchain->state.d3d_mode)))
1586 {
1587 WARN("Failed to set display mode, hr %#lx.\n", hr);
1588 goto err;
1589 }
1590 displaymode_set = TRUE;
1591 }
1592
1593 if (swapchain->state.desc.backbuffer_count > 0)
1594 {
1595 if (!(swapchain->back_buffers = calloc(swapchain->state.desc.backbuffer_count,
1596 sizeof(*swapchain->back_buffers))))
1597 {
1598 ERR("Failed to allocate backbuffer array memory.\n");
1599 hr = E_OUTOFMEMORY;
1600 goto err;
1601 }
1602
1603 for (i = 0; i < swapchain->state.desc.backbuffer_count; ++i)
1604 {
1605 TRACE("Creating back buffer %u.\n", i);
1606 if (FAILED(hr = swapchain_create_texture(swapchain, false, false, &swapchain->back_buffers[i])))
1607 {
1608 WARN("Failed to create back buffer %u, hr %#lx.\n", i, hr);
1609 swapchain->state.desc.backbuffer_count = i;
1610 goto err;
1611 }
1612 }
1613 }
1614
1615 /* Swapchains share the depth/stencil buffer, so only create a single depthstencil surface. */
1616 if (desc->enable_auto_depth_stencil)
1617 {
1618 TRACE("Creating depth/stencil buffer.\n");
1619 if (!device->auto_depth_stencil_view)
1620 {
1621 struct wined3d_view_desc desc;
1622 struct wined3d_texture *ds;
1623
1624 if (FAILED(hr = swapchain_create_texture(swapchain, false, true, &ds)))
1625 {
1626 WARN("Failed to create the auto depth/stencil surface, hr %#lx.\n", hr);
1627 goto err;
1628 }
1629
1630 desc.format_id = ds->resource.format->id;
1631 desc.flags = 0;
1632 desc.u.texture.level_idx = 0;
1633 desc.u.texture.level_count = 1;
1634 desc.u.texture.layer_idx = 0;
1635 desc.u.texture.layer_count = 1;
1637 &device->auto_depth_stencil_view);
1639 if (FAILED(hr))
1640 {
1641 ERR("Failed to create rendertarget view, hr %#lx.\n", hr);
1642 goto err;
1643 }
1644 }
1645 }
1646
1648
1650
1651 return WINED3D_OK;
1652
1653err:
1654 if (displaymode_set)
1655 {
1657 ERR("Failed to restore display mode.\n");
1658 }
1659
1660 if (swapchain->back_buffers)
1661 {
1662 for (i = 0; i < swapchain->state.desc.backbuffer_count; ++i)
1663 {
1664 if (swapchain->back_buffers[i])
1665 {
1667 wined3d_texture_decref(swapchain->back_buffers[i]);
1668 }
1669 }
1670 free(swapchain->back_buffers);
1671 }
1672
1673 if (swapchain->front_buffer)
1674 {
1676 wined3d_texture_decref(swapchain->front_buffer);
1677 }
1678
1681
1682 return hr;
1683}
1684
1686 const struct wined3d_swapchain_desc *desc, struct wined3d_swapchain_state_parent *state_parent,
1687 void *parent, const struct wined3d_parent_ops *parent_ops)
1688{
1689 TRACE("swapchain_no3d %p, device %p, desc %p, state_parent %p, parent %p, parent_ops %p.\n",
1690 swapchain_no3d, device, desc, state_parent, parent, parent_ops);
1691
1692 return wined3d_swapchain_init(swapchain_no3d, device, desc, state_parent, parent, parent_ops,
1694}
1695
1697 const struct wined3d_swapchain_desc *desc, struct wined3d_swapchain_state_parent *state_parent,
1698 void *parent, const struct wined3d_parent_ops *parent_ops)
1699{
1700 TRACE("swapchain_gl %p, device %p, desc %p, state_parent %p, parent %p, parent_ops %p.\n",
1701 swapchain_gl, device, desc, state_parent, parent, parent_ops);
1702
1703 return wined3d_swapchain_init(&swapchain_gl->s, device, desc, state_parent, parent,
1704 parent_ops, &swapchain_gl_ops);
1705}
1706
1708 const struct wined3d_swapchain_desc *desc, struct wined3d_swapchain_state_parent *state_parent,
1709 void *parent, const struct wined3d_parent_ops *parent_ops)
1710{
1711 HRESULT hr;
1712
1713 TRACE("swapchain_vk %p, device %p, desc %p, parent %p, parent_ops %p.\n",
1714 swapchain_vk, device, desc, parent, parent_ops);
1715
1716 if (FAILED(hr = wined3d_swapchain_init(&swapchain_vk->s, device, desc, state_parent, parent,
1717 parent_ops, &swapchain_vk_ops)))
1718 return hr;
1719
1720 if (swapchain_vk->s.win_handle == GetDesktopWindow())
1721 {
1722 WARN("Creating a desktop window swapchain.\n");
1723 return hr;
1724 }
1725
1727 WARN("Failed to create a Vulkan swapchain, hr %#lx.\n", hr);
1728
1729 return WINED3D_OK;
1730}
1731
1733 const struct wined3d_swapchain_desc *desc, struct wined3d_swapchain_state_parent *state_parent,
1734 void *parent, const struct wined3d_parent_ops *parent_ops,
1736{
1737 struct wined3d_swapchain *object;
1738 HRESULT hr;
1739
1740 if (FAILED(hr = device->adapter->adapter_ops->adapter_create_swapchain(device,
1741 desc, state_parent, parent, parent_ops, &object)))
1742 return hr;
1743
1744 if (desc->flags & WINED3D_SWAPCHAIN_IMPLICIT)
1745 {
1748 {
1750 device->adapter->adapter_ops->adapter_destroy_swapchain(object);
1752 return hr;
1753 }
1755 }
1756
1757 *swapchain = object;
1758
1759 return hr;
1760}
1761
1763{
1764 struct wined3d_device *device = swapchain_gl->s.device;
1765 struct wined3d_context_gl *context_gl;
1766
1767 TRACE("Creating a new context for swapchain %p, thread %lu.\n", swapchain_gl, GetCurrentThreadId());
1768
1770
1771 if (!(context_gl = calloc(1, sizeof(*context_gl))))
1772 {
1773 ERR("Failed to allocate context memory.\n");
1774 return NULL;
1775 }
1776
1777 if (FAILED(wined3d_context_gl_init(context_gl, swapchain_gl)))
1778 {
1779 WARN("Failed to initialise context.\n");
1780 free(context_gl);
1781 return NULL;
1782 }
1783
1784 if (!device_context_add(device, &context_gl->c))
1785 {
1786 ERR("Failed to add the newly created context to the context list.\n");
1787 wined3d_context_gl_destroy(context_gl);
1788 return NULL;
1789 }
1790
1791 TRACE("Created context %p.\n", context_gl);
1792
1793 context_release(&context_gl->c);
1794
1795 return context_gl;
1796}
1797
1799{
1800 struct wined3d_device *device = swapchain_gl->s.device;
1802 unsigned int i;
1803
1804 for (i = 0; i < device->context_count; ++i)
1805 {
1806 if (wined3d_context_gl(device->contexts[i])->tid == tid)
1807 return wined3d_context_gl(device->contexts[i]);
1808 }
1809
1810 /* Create a new context for the thread. */
1811 return wined3d_swapchain_gl_create_context(swapchain_gl);
1812}
1813
1815{
1816 UINT i;
1817
1819
1820 for (i = 0; i < swapchain->state.desc.backbuffer_count; ++i)
1821 {
1822 wined3d_resource_update_draw_binding(&swapchain->back_buffers[i]->resource);
1823 }
1824}
1825
1826void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activate)
1827{
1828 struct wined3d_device *device = swapchain->device;
1829 HWND window = swapchain->state.device_window;
1830 struct wined3d_output_desc output_desc;
1831 unsigned int screensaver_active;
1832 struct wined3d_output *output;
1833 BOOL focus_messages, filter;
1834 HRESULT hr;
1835
1836 /* This code is not protected by the wined3d mutex, so it may run while
1837 * wined3d_device_reset is active. Testing on Windows shows that changing
1838 * focus during resets and resetting during focus change events causes
1839 * the application to crash with an invalid memory access. */
1840
1841 if (!(focus_messages = device->wined3d->flags & WINED3D_FOCUS_MESSAGES))
1843
1844 if (activate)
1845 {
1846 SystemParametersInfoW(SPI_GETSCREENSAVEACTIVE, 0, &screensaver_active, 0);
1847 if ((device->restore_screensaver = !!screensaver_active))
1849
1850 if (!(device->create_parms.flags & WINED3DCREATE_NOWINDOWCHANGES))
1851 {
1852 /* The d3d versions do not agree on the exact messages here. D3d8 restores
1853 * the window but leaves the size untouched, d3d9 sets the size on an
1854 * invisible window, generates messages but doesn't change the window
1855 * properties. The implementation follows d3d9.
1856 *
1857 * Guild Wars 1 wants a WINDOWPOSCHANGED message on the device window to
1858 * resume drawing after a focus loss. */
1859 output = wined3d_swapchain_get_output(swapchain);
1860 if (!output)
1861 {
1862 ERR("Failed to get output from swapchain %p.\n", swapchain);
1863 return;
1864 }
1865
1866 if (SUCCEEDED(hr = wined3d_output_get_desc(output, &output_desc)))
1868 output_desc.desktop_rect.top, swapchain->state.desc.backbuffer_width,
1869 swapchain->state.desc.backbuffer_height, SWP_NOACTIVATE | SWP_NOZORDER);
1870 else
1871 ERR("Failed to get output description, hr %#lx.\n", hr);
1872 }
1873
1874 if (device->wined3d->flags & WINED3D_RESTORE_MODE_ON_ACTIVATE)
1875 {
1876 output = wined3d_swapchain_get_output(swapchain);
1877 if (!output)
1878 {
1879 ERR("Failed to get output from swapchain %p.\n", swapchain);
1880 return;
1881 }
1882
1884 &swapchain->state.d3d_mode)))
1885 ERR("Failed to set display mode, hr %#lx.\n", hr);
1886 }
1887
1888 if (swapchain == device->swapchains[0])
1889 device->device_parent->ops->activate(device->device_parent, TRUE);
1890 }
1891 else
1892 {
1893 if (device->restore_screensaver)
1894 {
1896 device->restore_screensaver = FALSE;
1897 }
1898
1900 ERR("Failed to restore display modes, hr %#lx.\n", hr);
1901
1902 swapchain->reapply_mode = TRUE;
1903
1904 /* Some DDraw apps (Deus Ex: GOTY, and presumably all UT 1 based games) destroy the device
1905 * during window minimization. Do our housekeeping now, as the device may not exist after
1906 * the ShowWindow call.
1907 *
1908 * In d3d9, the device is marked lost after the window is minimized. If we find an app
1909 * that needs this behavior (e.g. because it calls TestCooperativeLevel in the window proc)
1910 * we'll have to control this via a create flag. Note that the device and swapchain are not
1911 * safe to access after the ShowWindow call. */
1912 if (swapchain == device->swapchains[0])
1913 device->device_parent->ops->activate(device->device_parent, FALSE);
1914
1915 if (!(device->create_parms.flags & WINED3DCREATE_NOWINDOWCHANGES) && IsWindowVisible(window))
1917 }
1918
1919 if (!focus_messages)
1921}
1922
1924 unsigned int width, unsigned int height, enum wined3d_format_id format_id,
1925 enum wined3d_multisample_type multisample_type, unsigned int multisample_quality)
1926{
1927 struct wined3d_swapchain_desc *desc = &swapchain->state.desc;
1928 bool recreate = false;
1929
1930 TRACE("swapchain %p, buffer_count %u, width %u, height %u, format %s, "
1931 "multisample_type %#x, multisample_quality %#x.\n",
1934
1936
1937 if (buffer_count && buffer_count != desc->backbuffer_count)
1938 FIXME("Cannot change the back buffer count yet.\n");
1939
1941
1942 if (!width || !height)
1943 {
1944 RECT client_rect;
1945
1946 /* The application is requesting that either the swapchain width or
1947 * height be set to the corresponding dimension in the window's
1948 * client rect. */
1949
1950 if (!GetClientRect(swapchain->state.device_window, &client_rect))
1951 {
1952 ERR("Failed to get client rect, last error %#lx.\n", GetLastError());
1954 }
1955
1956 if (!width)
1957 width = client_rect.right;
1958
1959 if (!height)
1960 height = client_rect.bottom;
1961 }
1962
1963 if (width != desc->backbuffer_width || height != desc->backbuffer_height)
1964 {
1965 desc->backbuffer_width = width;
1966 desc->backbuffer_height = height;
1967 recreate = true;
1968 }
1969
1971 {
1972 if (!desc->windowed)
1974 format_id = swapchain->state.original_mode.format_id;
1975 }
1976
1977 if (format_id != desc->backbuffer_format)
1978 {
1979 desc->backbuffer_format = format_id;
1980 recreate = true;
1981 }
1982
1983 if (multisample_type != desc->multisample_type
1984 || multisample_quality != desc->multisample_quality)
1985 {
1986 desc->multisample_type = multisample_type;
1987 desc->multisample_quality = multisample_quality;
1988 recreate = true;
1989 }
1990
1991 if (recreate)
1992 {
1993 struct wined3d_texture *new_texture;
1994 HRESULT hr;
1995 UINT i;
1996
1997 TRACE("Recreating swapchain textures.\n");
1998
1999 if (FAILED(hr = swapchain_create_texture(swapchain, true, false, &new_texture)))
2000 return hr;
2002 if (wined3d_texture_decref(swapchain->front_buffer))
2003 ERR("Something's still holding the front buffer (%p).\n", swapchain->front_buffer);
2004 swapchain->front_buffer = new_texture;
2005
2006 if (!(swapchain->device->wined3d->flags & WINED3D_NO3D))
2007 {
2010 }
2011
2012 for (i = 0; i < desc->backbuffer_count; ++i)
2013 {
2014 if (FAILED(hr = swapchain_create_texture(swapchain, false, false, &new_texture)))
2015 return hr;
2017 if (wined3d_texture_decref(swapchain->back_buffers[i]))
2018 ERR("Something's still holding back buffer %u (%p).\n", i, swapchain->back_buffers[i]);
2019 swapchain->back_buffers[i] = new_texture;
2020 }
2021 }
2022
2024
2025 return WINED3D_OK;
2026}
2027
2029 struct wined3d_output *output, struct wined3d_display_mode *mode)
2030{
2031 HRESULT hr;
2032
2034 {
2036 {
2037 WARN("Failed to find closest matching mode, hr %#lx.\n", hr);
2038 }
2039 }
2040
2041 if (output != state->desc.output)
2042 {
2044 {
2045 WARN("Failed to restore display modes, hr %#lx.\n", hr);
2046 return hr;
2047 }
2048
2049 if (FAILED(hr = wined3d_output_get_display_mode(output, &state->original_mode, NULL)))
2050 {
2051 WARN("Failed to get current display mode, hr %#lx.\n", hr);
2052 return hr;
2053 }
2054 }
2055
2057 {
2058 WARN("Failed to set display mode, hr %#lx.\n", hr);
2060 }
2061
2062 return WINED3D_OK;
2063}
2064
2066 const struct wined3d_display_mode *mode)
2067{
2068 struct wined3d_display_mode actual_mode;
2069 struct wined3d_output_desc output_desc;
2070 RECT original_window_rect, window_rect;
2071 int x, y, width, height;
2072 HWND window;
2073 HRESULT hr;
2074
2075 TRACE("state %p, mode %p.\n", state, mode);
2076
2078
2079 window = state->device_window;
2080
2081 if (state->desc.windowed)
2082 {
2083 SetRect(&window_rect, 0, 0, mode->width, mode->height);
2084 AdjustWindowRectEx(&window_rect,
2087 GetWindowRect(window, &original_window_rect);
2088
2089 x = original_window_rect.left;
2090 y = original_window_rect.top;
2091 width = window_rect.right - window_rect.left;
2092 height = window_rect.bottom - window_rect.top;
2093 }
2094 else
2095 {
2097 {
2098 actual_mode = *mode;
2100 &actual_mode)))
2101 {
2102 ERR("Failed to set display mode, hr %#lx.\n", hr);
2104 return hr;
2105 }
2106 }
2107
2108 if (FAILED(hr = wined3d_output_get_desc(state->desc.output, &output_desc)))
2109 {
2110 ERR("Failed to get output description, hr %#lx.\n", hr);
2112 return hr;
2113 }
2114
2115 x = output_desc.desktop_rect.left;
2116 y = output_desc.desktop_rect.top;
2117 width = output_desc.desktop_rect.right - output_desc.desktop_rect.left;
2118 height = output_desc.desktop_rect.bottom - output_desc.desktop_rect.top;
2119 }
2120
2122
2124
2125 return WINED3D_OK;
2126}
2127
2129{
2130 /* Make sure the window is managed, otherwise we won't get keyboard input. */
2133
2134 return style;
2135}
2136
2138{
2139 /* Filter out window decorations. */
2140 exstyle &= ~(WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE);
2141
2142 return exstyle;
2143}
2144
2146{
2150 int x, y, width, height;
2155};
2156
2157#define WINED3D_WINDOW_TOPMOST_TIMER_ID 0x4242
2158
2160{
2163
2165}
2166
2168{
2169 struct wined3d_window_state *s = ctx;
2170 bool filter;
2171
2173
2174 if (s->set_style)
2175 {
2176 SetWindowLongW(s->window, GWL_STYLE, s->style);
2177 SetWindowLongW(s->window, GWL_EXSTYLE, s->exstyle);
2178 }
2179 SetWindowPos(s->window, s->window_pos_after, s->x, s->y, s->width, s->height, s->flags);
2180
2182
2183 free(s);
2184
2185 return 0;
2186}
2187
2189{
2190 static const UINT timeout = 1500;
2191 DWORD window_tid = GetWindowThreadProcessId(s->window, NULL);
2193 HANDLE thread;
2194
2195 TRACE("Window %p belongs to thread %#lx.\n", s->window, window_tid);
2196 /* If the window belongs to a different thread, modifying the style and/or
2197 * position can potentially deadlock if that thread isn't processing
2198 * messages. */
2199 if (window_tid == tid)
2200 {
2201 /* Deus Ex: Game of the Year Edition removes WS_EX_TOPMOST after changing resolutions in
2202 * exclusive fullscreen mode. Tests show that WS_EX_TOPMOST will be restored when a ~1.5s
2203 * timer times out */
2204 if (s->register_topmost_timer)
2205 {
2206 if (s->set_topmost_timer)
2208 else
2210 }
2211
2213 }
2214 else if ((thread = CreateThread(NULL, 0, set_window_state_thread, s, 0, NULL)))
2215 {
2216 SetThreadDescription(thread, L"wined3d_set_window_state");
2218 }
2219 else
2220 {
2221 ERR("Failed to create thread.\n");
2222 }
2223}
2224
2226 HWND window, int x, int y, int width, int height)
2227{
2228 struct wined3d_window_state *s;
2229
2230 TRACE("Setting up window %p for fullscreen mode.\n", window);
2231
2232 if (!IsWindow(window))
2233 {
2234 WARN("%p is not a valid window.\n", window);
2236 }
2237
2238 if (!(s = malloc(sizeof(*s))))
2239 return E_OUTOFMEMORY;
2240 s->window = window;
2241 s->window_pos_after = HWND_TOPMOST;
2242 s->x = x;
2243 s->y = y;
2244 s->width = width;
2245 s->height = height;
2246
2247 if (state->style || state->exstyle)
2248 {
2249 ERR("Changing the window style for window %p, but another style (%08lx, %08lx) is already stored.\n",
2250 window, state->style, state->exstyle);
2251 }
2252
2255 s->flags |= SWP_NOZORDER;
2256 else
2257 s->flags |= SWP_SHOWWINDOW;
2258
2261
2262 s->style = fullscreen_style(state->style);
2263 s->exstyle = fullscreen_exstyle(state->exstyle);
2264 s->set_style = true;
2265 s->register_topmost_timer = !!(state->desc.flags & WINED3D_SWAPCHAIN_REGISTER_TOPMOST_TIMER);
2266 s->set_topmost_timer = true;
2267
2268 TRACE("Old style was %08lx, %08lx, setting to %08lx, %08lx.\n",
2269 state->style, state->exstyle, s->style, s->exstyle);
2270
2272 return WINED3D_OK;
2273}
2274
2276 HWND window, const RECT *window_rect)
2277{
2278 struct wined3d_window_state *s;
2280
2281 if (!state->style && !state->exstyle)
2282 return;
2283
2284 if (!(s = malloc(sizeof(*s))))
2285 return;
2286
2287 s->window = window;
2288 s->window_pos_after = NULL;
2290
2292 && !(state->desc.flags & WINED3D_SWAPCHAIN_NO_WINDOW_CHANGES))
2293 {
2294 s->window_pos_after = (state->exstyle & WS_EX_TOPMOST) ? HWND_TOPMOST : HWND_NOTOPMOST;
2295 s->flags |= (state->style & WS_VISIBLE) ? SWP_SHOWWINDOW : SWP_HIDEWINDOW;
2296 s->flags &= ~SWP_NOZORDER;
2297 }
2298
2301
2302 /* These flags are set by wined3d_device_setup_fullscreen_window, not the
2303 * application, and we want to ignore them in the test below, since it's
2304 * not the application's fault that they changed. Additionally, we want to
2305 * preserve the current status of these flags (i.e. don't restore them) to
2306 * more closely emulate the behavior of Direct3D, which leaves these flags
2307 * alone when returning to windowed mode. */
2308 state->style ^= (state->style ^ style) & WS_VISIBLE;
2309 state->exstyle ^= (state->exstyle ^ exstyle) & WS_EX_TOPMOST;
2310
2311 TRACE("Restoring window style of window %p to %08lx, %08lx.\n",
2312 window, state->style, state->exstyle);
2313
2314 s->style = state->style;
2315 s->exstyle = state->exstyle;
2316 /* Only restore the style if the application didn't modify it during the
2317 * fullscreen phase. Some applications change it before calling Reset()
2318 * when switching between windowed and fullscreen modes (HL2), some
2319 * depend on the original style (Eve Online). */
2320 s->set_style = style == fullscreen_style(state->style) && exstyle == fullscreen_exstyle(state->exstyle);
2321 s->register_topmost_timer = !!(state->desc.flags & WINED3D_SWAPCHAIN_REGISTER_TOPMOST_TIMER);
2322 s->set_topmost_timer = false;
2323
2324 if (window_rect)
2325 {
2326 s->x = window_rect->left;
2327 s->y = window_rect->top;
2328 s->width = window_rect->right - window_rect->left;
2329 s->height = window_rect->bottom - window_rect->top;
2330 }
2331 else
2332 {
2333 s->x = s->y = s->width = s->height = 0;
2334 s->flags |= (SWP_NOMOVE | SWP_NOSIZE);
2335 }
2336
2338
2339 /* Delete the old values. */
2340 state->style = 0;
2341 state->exstyle = 0;
2342}
2343
2345 const struct wined3d_swapchain_desc *swapchain_desc,
2346 const struct wined3d_display_mode *mode)
2347{
2348 struct wined3d_display_mode actual_mode;
2349 struct wined3d_output_desc output_desc;
2350 BOOL windowed = state->desc.windowed;
2351 HRESULT hr;
2352
2353 TRACE("state %p, swapchain_desc %p, mode %p.\n", state, swapchain_desc, mode);
2354
2356 {
2357 if (mode)
2358 {
2359 actual_mode = *mode;
2361 &actual_mode)))
2362 return hr;
2363 }
2364 else
2365 {
2366 if (!swapchain_desc->windowed)
2367 {
2368 actual_mode.width = swapchain_desc->backbuffer_width;
2369 actual_mode.height = swapchain_desc->backbuffer_height;
2370 actual_mode.refresh_rate = swapchain_desc->refresh_rate;
2371 actual_mode.format_id = adapter_format_from_backbuffer_format(swapchain_desc->output->adapter,
2372 swapchain_desc->backbuffer_format);
2375 &actual_mode)))
2376 return hr;
2377 }
2378 else
2379 {
2381 {
2382 WARN("Failed to restore display modes for all outputs, hr %#lx.\n", hr);
2383 return hr;
2384 }
2385 }
2386 }
2387 }
2388 else
2389 {
2390 if (mode)
2391 WARN("WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH is not set, ignoring mode.\n");
2392
2393 if (FAILED(hr = wined3d_output_get_display_mode(swapchain_desc->output, &actual_mode,
2394 NULL)))
2395 {
2396 ERR("Failed to get display mode, hr %#lx.\n", hr);
2398 }
2399 }
2400
2401 if (!swapchain_desc->windowed)
2402 {
2403 unsigned int width = actual_mode.width;
2404 unsigned int height = actual_mode.height;
2405
2406 if (FAILED(hr = wined3d_output_get_desc(swapchain_desc->output, &output_desc)))
2407 {
2408 ERR("Failed to get output description, hr %#lx.\n", hr);
2409 return hr;
2410 }
2411
2412 if (state->desc.windowed)
2413 {
2414 /* Switch from windowed to fullscreen */
2416 output_desc.desktop_rect.left, output_desc.desktop_rect.top, width, height)))
2417 return hr;
2418 }
2419 else
2420 {
2421 HWND window = state->device_window;
2422 BOOL filter;
2423
2424 /* Fullscreen -> fullscreen mode change */
2426 MoveWindow(window, output_desc.desktop_rect.left, output_desc.desktop_rect.top, width,
2427 height, TRUE);
2430 }
2431 state->d3d_mode = actual_mode;
2432 }
2433 else if (!state->desc.windowed)
2434 {
2435 /* Fullscreen -> windowed switch */
2436 RECT *window_rect = NULL;
2438 window_rect = &state->original_window_rect;
2439 wined3d_swapchain_state_restore_from_fullscreen(state, state->device_window, window_rect);
2440 }
2441
2442 state->desc.output = swapchain_desc->output;
2443 state->desc.windowed = swapchain_desc->windowed;
2444
2445 if (windowed != state->desc.windowed)
2446 state->parent->ops->windowed_state_changed(state->parent, state->desc.windowed);
2447
2448 return WINED3D_OK;
2449}
2450
2452{
2453 TRACE("state %p.\n", state);
2454
2455 return state->desc.windowed;
2456}
2457
2459 unsigned int *width, unsigned int *height)
2460{
2461 TRACE("state %p.\n", state);
2462
2463 *width = state->desc.backbuffer_width;
2464 *height = state->desc.backbuffer_height;
2465}
2466
2468{
2470 free(state);
2471}
2472
2474 HWND window, struct wined3d *wined3d, struct wined3d_swapchain_state_parent *state_parent,
2476{
2477 struct wined3d_swapchain_state *s;
2478 HRESULT hr;
2479
2480 TRACE("desc %p, window %p, wined3d %p, state %p.\n", desc, window, wined3d, state);
2481
2482 if (!(s = calloc(1, sizeof(*s))))
2483 return E_OUTOFMEMORY;
2484
2485 if (FAILED(hr = wined3d_swapchain_state_init(s, desc, window, wined3d, state_parent)))
2486 {
2487 free(s);
2488 return hr;
2489 }
2490
2491 *state = s;
2492
2493 return hr;
2494}
#define DCX_USESTYLE
Definition: GetDCEx.c:10
HRESULT WINAPI DECLSPEC_HOTPATCH SetThreadDescription(_In_ HANDLE hThread, _In_ PCWSTR lpThreadDescription)
static int state
Definition: maze.c:121
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
static const char * wine_dbgstr_point(const POINT *ppt)
Definition: atltest.h:138
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
#define msg(x)
Definition: auth_time.c:54
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
LONG NTSTATUS
Definition: precomp.h:26
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
static HANDLE thread
Definition: service.c:33
HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl, struct wined3d_swapchain_gl *swapchain_gl)
Definition: context_gl.c:2032
void wined3d_context_gl_submit_command_fence(struct wined3d_context_gl *context_gl)
Definition: context_gl.c:2653
void wined3d_context_gl_destroy(struct wined3d_context_gl *context_gl)
Definition: context_gl.c:2308
void wined3d_context_vk_end_current_render_pass(struct wined3d_context_vk *context_vk)
Definition: context_vk.c:1564
VkCommandBuffer wined3d_context_vk_get_command_buffer(struct wined3d_context_vk *context_vk)
Definition: context_vk.c:1805
void wined3d_context_vk_image_barrier(struct wined3d_context_vk *context_vk, VkCommandBuffer vk_command_buffer, VkPipelineStageFlags src_stage_mask, VkPipelineStageFlags dst_stage_mask, VkAccessFlags src_access_mask, VkAccessFlags dst_access_mask, VkImageLayout old_layout, VkImageLayout new_layout, VkImage image, const VkImageSubresourceRange *range)
Definition: context_vk.c:2022
void wined3d_context_vk_submit_command_buffer(struct wined3d_context_vk *context_vk, unsigned int wait_semaphore_count, const VkSemaphore *wait_semaphores, const VkPipelineStageFlags *wait_stages, unsigned int signal_semaphore_count, const VkSemaphore *signal_semaphores)
Definition: context_vk.c:1896
void wined3d_context_vk_wait_command_buffer(struct wined3d_context_vk *context_vk, uint64_t id)
Definition: context_vk.c:1990
void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *swapchain, const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, unsigned int swap_interval, uint32_t flags)
Definition: cs.c:748
void wined3d_cs_destroy_object(struct wined3d_cs *cs, void(*callback)(void *object), void *object)
Definition: cs.c:2299
HDC dc
Definition: cylfrac.c:34
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_FAIL
Definition: ddrawi.h:102
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
UINT32 uint32_t
Definition: types.h:75
HRESULT wined3d_device_set_implicit_swapchain(struct wined3d_device *device, struct wined3d_swapchain *swapchain)
Definition: device.c:1537
BOOL device_context_add(struct wined3d_device *device, struct wined3d_context *context)
Definition: device.c:84
void device_invalidate_state(const struct wined3d_device *device, unsigned int state_id)
Definition: device.c:5565
void wined3d_device_uninit_3d(struct wined3d_device *device)
Definition: device.c:1662
void CDECL wined3d_device_release_focus_window(struct wined3d_device *device)
Definition: device.c:1154
void CDECL wined3d_palette_apply_to_dc(const struct wined3d_palette *palette, HDC dc)
Definition: palette.c:91
VkAccessFlags vk_access_mask_from_bind_flags(uint32_t bind_flags)
Definition: resource.c:526
void wined3d_resource_update_draw_binding(struct wined3d_resource *resource)
Definition: resource.c:425
void wined3d_texture_invalidate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, uint32_t location)
Definition: texture.c:702
HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct wined3d_resource_desc *desc, UINT layer_count, UINT level_count, uint32_t flags, const struct wined3d_sub_resource_data *data, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture)
Definition: texture.c:4158
void wined3d_texture_set_swapchain(struct wined3d_texture *texture, struct wined3d_swapchain *swapchain)
Definition: texture.c:1263
ULONG CDECL wined3d_texture_decref(struct wined3d_texture *texture)
Definition: texture.c:1606
void wined3d_texture_validate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, uint32_t location)
Definition: texture.c:678
HRESULT CDECL wined3d_device_context_blt(struct wined3d_device_context *context, struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx, const RECT *dst_rect, struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx, const RECT *src_rect, unsigned int flags, const struct wined3d_blt_fx *fx, enum wined3d_texture_filter_type filter)
Definition: texture.c:3854
BOOL wined3d_texture_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, uint32_t location)
Definition: texture.c:770
void CDECL wined3d_texture_get_pitch(const struct wined3d_texture *texture, unsigned int level, unsigned int *row_pitch, unsigned int *slice_pitch)
Definition: texture.c:1697
const char * debug_d3dformat(enum wined3d_format_id format_id)
Definition: utils.c:4605
const char * wined3d_debug_vkresult(VkResult vr)
Definition: utils.c:5463
const struct wined3d_format * wined3d_get_format(const struct wined3d_adapter *adapter, enum wined3d_format_id format_id, unsigned int bind_flags)
Definition: utils.c:4428
enum wined3d_format_id pixelformat_for_depth(DWORD depth)
Definition: utils.c:6067
HRESULT CDECL wined3d_rendertarget_view_create(const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_rendertarget_view **view)
Definition: view.c:933
#define CHAR_BIT
Definition: cabinet.h:45
#define CDECL
Definition: compat.h:29
#define CloseHandle
Definition: compat.h:739
#define WINE_DECLARE_DEBUG_CHANNEL(x)
Definition: compat.h:45
#define CALLBACK
Definition: compat.h:35
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
#define UINT64_MAX
Definition: stdint.h:86
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Height *Stride) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Stride)
Definition: common.c:42
#define L(x)
Definition: resources.c:13
r parent
Definition: btrfs.c:3010
static VkFormat get_swapchain_fallback_format(VkFormat vk_format)
Definition: swapchain.c:1310
#define abs(i)
Definition: fconv.c:206
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
return adapter
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLdouble s
Definition: gl.h:2039
unsigned int GLuint
Definition: gl.h:159
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLdouble GLdouble t
Definition: gl.h:2047
GLint GLint GLsizei width
Definition: gl.h:1546
GLenum GLuint texture
Definition: glext.h:6295
GLintptr offset
Definition: glext.h:5920
GLenum mode
Definition: glext.h:6217
GLbitfield flags
Definition: glext.h:7161
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
unsigned int UINT
Definition: sysinfo.c:13
#define ds
Definition: i386-dis.c:443
#define cs
Definition: i386-dis.c:442
static TfClientId tid
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
int quality
Definition: jpeglib.h:994
#define d
Definition: ke_i.h:81
#define location(file, line)
Definition: kmtest.h:18
__u16 time
Definition: mkdosfs.c:8
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
static const BYTE ramp[17]
Definition: dib.c:2957
static IHTMLWindow2 * window
Definition: events.c:77
static HPALETTE palette
Definition: clipboard.c:1457
static UINT format_id
Definition: clipboard.c:1455
#define min(a, b)
Definition: monoChain.cc:55
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define WS_CAPTION
Definition: pedump.c:624
#define WS_SYSMENU
Definition: pedump.c:629
#define WS_POPUP
Definition: pedump.c:616
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_EX_TOPMOST
Definition: pedump.c:647
long LONG
Definition: pedump.c:60
#define WS_THICKFRAME
Definition: pedump.c:630
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define SWP_NOACTIVATE
Definition: winuser.h:1253
#define GetWindowLongPtrW
Definition: winuser.h:4983
#define SWP_FRAMECHANGED
Definition: winuser.h:1251
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define DCX_CACHE
Definition: winuser.h:2150
#define HWND_TOPMOST
Definition: winuser.h:1219
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define SW_MINIMIZE
Definition: winuser.h:787
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
LONG WINAPI SetWindowLongW(_In_ HWND, _In_ int, _In_ LONG)
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define SWP_NOMOVE
Definition: winuser.h:1255
#define SPI_SETSCREENSAVEACTIVE
Definition: winuser.h:1377
BOOL WINAPI AdjustWindowRectEx(_Inout_ LPRECT, _In_ DWORD, _In_ BOOL, _In_ DWORD)
#define SWP_NOSIZE
Definition: winuser.h:1256
HDC WINAPI GetDCEx(_In_opt_ HWND, _In_opt_ HRGN, _In_ DWORD)
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define GWLP_HINSTANCE
Definition: winuser.h:867
#define DCX_CLIPSIBLINGS
Definition: winuser.h:2152
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:628
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
#define SWP_SHOWWINDOW
Definition: winuser.h:1259
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
#define SWP_HIDEWINDOW
Definition: winuser.h:1252
#define SW_SHOW
Definition: winuser.h:786
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
#define SWP_NOZORDER
Definition: winuser.h:1258
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define GWL_STYLE
Definition: winuser.h:863
#define HWND_NOTOPMOST
Definition: winuser.h:1217
BOOL WINAPI IsWindowVisible(_In_ HWND)
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
#define SPI_GETSCREENSAVEACTIVE
Definition: winuser.h:1376
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
#define GWL_EXSTYLE
Definition: winuser.h:862
#define err(...)
#define calloc
Definition: rosglue.h:14
static struct address_cache * front
Definition: rpcb_clnt.c:83
#define WARN_(ch,...)
Definition: debug.h:157
#define TRACE(s)
Definition: solgame.cpp:4
Definition: dcommon.idl:28
long bottom
Definition: dcommon.idl:29
long right
Definition: dcommon.idl:29
long left
Definition: dcommon.idl:29
long top
Definition: dcommon.idl:29
uint32_t width
Definition: vulkan.h:8666
uint32_t height
Definition: vulkan.h:8667
VkOffset3D srcOffsets[2]
Definition: vulkan.h:16351
VkImageSubresourceLayers srcSubresource
Definition: vulkan.h:16350
VkOffset3D dstOffsets[2]
Definition: vulkan.h:16353
VkImageSubresourceLayers dstSubresource
Definition: vulkan.h:16352
VkImageAspectFlags aspectMask
Definition: vulkan.h:9065
uint32_t baseArrayLayer
Definition: vulkan.h:9076
VkImageAspectFlags aspectMask
Definition: vulkan.h:9073
int32_t x
Definition: vulkan.h:9579
int32_t y
Definition: vulkan.h:9580
int32_t z
Definition: vulkan.h:9581
const VkSemaphore * pWaitSemaphores
Definition: vulkan.h:13417
VkResult * pResults
Definition: vulkan.h:13421
uint32_t waitSemaphoreCount
Definition: vulkan.h:13416
uint32_t swapchainCount
Definition: vulkan.h:13418
const uint32_t * pImageIndices
Definition: vulkan.h:13420
VkStructureType sType
Definition: vulkan.h:13414
const VkSwapchainKHR * pSwapchains
Definition: vulkan.h:13419
const void * pNext
Definition: vulkan.h:13415
VkStructureType sType
Definition: vulkan.h:13937
VkSemaphoreCreateFlags flags
Definition: vulkan.h:13939
const void * pNext
Definition: vulkan.h:13938
VkSurfaceTransformFlagBitsKHR currentTransform
Definition: vulkan.h:14320
VkCompositeAlphaFlagsKHR supportedCompositeAlpha
Definition: vulkan.h:14321
VkExtent2D maxImageExtent
Definition: vulkan.h:14317
VkExtent2D minImageExtent
Definition: vulkan.h:14316
VkImageUsageFlags supportedUsageFlags
Definition: vulkan.h:14322
const void * pNext
Definition: vulkan.h:14367
VkPresentModeKHR presentMode
Definition: vulkan.h:14381
VkImageUsageFlags imageUsage
Definition: vulkan.h:14375
VkSharingMode imageSharingMode
Definition: vulkan.h:14376
VkStructureType sType
Definition: vulkan.h:14366
VkSwapchainCreateFlagsKHR flags
Definition: vulkan.h:14368
VkColorSpaceKHR imageColorSpace
Definition: vulkan.h:14372
uint32_t queueFamilyIndexCount
Definition: vulkan.h:14377
VkSurfaceTransformFlagBitsKHR preTransform
Definition: vulkan.h:14379
const uint32_t * pQueueFamilyIndices
Definition: vulkan.h:14378
VkCompositeAlphaFlagBitsKHR compositeAlpha
Definition: vulkan.h:14380
VkExtent2D imageExtent
Definition: vulkan.h:14373
VkStructureType sType
Definition: vulkan.h:15245
VkWin32SurfaceCreateFlagsKHR flags
Definition: vulkan.h:15247
PALETTEENTRY * pColorTable
Definition: d3dkmthk.h:167
Definition: uimain.c:89
Definition: http.c:7252
Definition: devices.h:37
Definition: filter.c:165
Definition: ps.c:97
Definition: style.c:91
Definition: dhcpd.h:248
struct wined3d_pixel_format * pixel_formats
Definition: wined3d_gl.h:802
struct wined3d_adapter a
Definition: wined3d_vk.h:726
struct wined3d_vk_info vk_info
Definition: wined3d_vk.h:728
VkPhysicalDevice physical_device
Definition: wined3d_vk.h:731
struct wined3d_context c
Definition: wined3d_gl.h:601
const struct wined3d_gl_info * gl_info
Definition: wined3d_gl.h:603
struct wined3d_command_buffer_vk current_command_buffer
Definition: wined3d_vk.h:617
const struct wined3d_vk_info * vk_info
Definition: wined3d_vk.h:590
struct wined3d_context c
Definition: wined3d_vk.h:588
struct wined3d_swapchain * swapchain
struct wined3d_device d
Definition: wined3d_vk.h:821
VkDevice vk_device
Definition: wined3d_vk.h:825
uint32_t vk_queue_family_index
Definition: wined3d_vk.h:827
enum wined3d_format_id format_id
Definition: wined3d.h:1614
enum wined3d_scanline_ordering scanline_ordering
Definition: wined3d.h:1615
VkFormat vk_format
Definition: wined3d_vk.h:1083
BOOL supported[WINED3D_GL_EXT_COUNT]
Definition: wined3d_gl.h:347
struct opengl_funcs gl_ops
Definition: wined3d_gl.h:353
unsigned int size
Definition: wined3d.h:1801
enum wined3d_resource_type resource_type
Definition: wined3d.h:1791
unsigned int width
Definition: wined3d.h:1798
unsigned int height
Definition: wined3d.h:1799
enum wined3d_multisample_type multisample_type
Definition: wined3d.h:1793
unsigned int multisample_quality
Definition: wined3d.h:1794
unsigned int bind_flags
Definition: wined3d.h:1796
unsigned int usage
Definition: wined3d.h:1795
unsigned int depth
Definition: wined3d.h:1800
enum wined3d_format_id format
Definition: wined3d.h:1792
unsigned int access
Definition: wined3d.h:1797
unsigned int sample_count
unsigned int multisample_quality
Definition: wined3d.h:1778
unsigned int backbuffer_height
Definition: wined3d.h:1773
enum wined3d_multisample_type multisample_type
Definition: wined3d.h:1777
enum wined3d_format_id auto_depth_stencil_format
Definition: wined3d.h:1783
struct wined3d_output * output
Definition: wined3d.h:1771
unsigned int backbuffer_width
Definition: wined3d.h:1772
enum wined3d_format_id backbuffer_format
Definition: wined3d.h:1774
unsigned int refresh_rate
Definition: wined3d.h:1785
unsigned int backbuffer_bind_flags
Definition: wined3d.h:1776
struct wined3d_swapchain s
Definition: wined3d_gl.h:1126
unsigned int width
Definition: wined3d_vk.h:1065
unsigned int image_count
Definition: wined3d_vk.h:1064
VkSwapchainKHR vk_swapchain
Definition: wined3d_vk.h:1055
VkSurfaceKHR vk_surface
Definition: wined3d_vk.h:1056
struct wined3d_swapchain s
Definition: wined3d_vk.h:1053
unsigned int current
Definition: wined3d_vk.h:1064
struct wined3d_swapchain_vk::@366 * vk_semaphores
unsigned int height
Definition: wined3d_vk.h:1065
struct wined3d_texture ** back_buffers
unsigned int swap_interval
const struct wined3d_swapchain_ops * swapchain_ops
struct wined3d_palette * palette
unsigned int max_frame_latency
struct wined3d_texture * front_buffer
struct wined3d_swapchain_state state
struct wined3d_gamma_ramp orig_gamma
const struct wined3d_parent_ops * parent_ops
struct wined3d_device * device
struct wined3d_texture t
Definition: wined3d_gl.h:941
struct wined3d_image_vk image
Definition: wined3d_vk.h:877
uint32_t bind_mask
Definition: wined3d_vk.h:879
VkDescriptorImageInfo default_image_info
Definition: wined3d_vk.h:881
struct wined3d_texture t
Definition: wined3d_vk.h:875
enum VkImageLayout layout
Definition: wined3d_vk.h:878
struct wined3d_swapchain * swapchain
struct wined3d_resource resource
VkInstance instance
Definition: wined3d_vk.h:258
HANDLE HINSTANCE
Definition: typedefs.h:77
uint32_t ULONG
Definition: typedefs.h:59
VkFlags VkPipelineStageFlags
Definition: vulkan.h:1101
VkResult VKAPI_CALL vkCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain)
VkImageLayout
Definition: vulkan.h:3450
@ VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL
Definition: vulkan.h:3457
@ VK_IMAGE_LAYOUT_PRESENT_SRC_KHR
Definition: vulkan.h:3460
@ VK_IMAGE_LAYOUT_UNDEFINED
Definition: vulkan.h:3451
@ VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
Definition: vulkan.h:3458
void VKAPI_CALL vkDestroySemaphore(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks *pAllocator)
@ VK_SHARING_MODE_EXCLUSIVE
Definition: vulkan.h:4921
#define VK_TRUE
Definition: vulkan.h:55
VkResult VKAPI_CALL vkQueueWaitIdle(VkQueue queue)
VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t *pPresentModeCount, VkPresentModeKHR *pPresentModes)
VkFlags VkImageUsageFlags
Definition: vulkan.h:1050
VkResult VKAPI_CALL vkAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, VkSemaphore semaphore, VkFence fence, uint32_t *pImageIndex)
void VKAPI_CALL vkCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit *pRegions, VkFilter filter)
void VKAPI_CALL vkDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks *pAllocator)
VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR *pSurfaceCapabilities)
VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, VkSurfaceKHR surface, VkBool32 *pSupported)
@ VK_IMAGE_ASPECT_COLOR_BIT
Definition: vulkan.h:3365
@ VK_IMAGE_USAGE_TRANSFER_DST_BIT
Definition: vulkan.h:3511
@ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
Definition: vulkan.h:3514
@ VK_IMAGE_USAGE_TRANSFER_SRC_BIT
Definition: vulkan.h:3510
@ VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR
Definition: vulkan.h:2232
VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t *pSurfaceFormatCount, VkSurfaceFormatKHR *pSurfaceFormats)
VkResult VKAPI_CALL vkCreateSemaphore(VkDevice device, const VkSemaphoreCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSemaphore *pSemaphore)
VkResult VKAPI_CALL vkCreateWin32SurfaceKHR(VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface)
VkFilter
Definition: vulkan.h:2806
@ VK_FILTER_NEAREST
Definition: vulkan.h:2807
@ VK_FILTER_LINEAR
Definition: vulkan.h:2808
VkResult VKAPI_CALL vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo)
VkResult
Definition: vulkan.h:4639
@ VK_SUBOPTIMAL_KHR
Definition: vulkan.h:4678
@ VK_ERROR_OUT_OF_DATE_KHR
Definition: vulkan.h:4656
@ VK_ACCESS_TRANSFER_WRITE_BIT
Definition: vulkan.h:1641
@ VK_ACCESS_TRANSFER_READ_BIT
Definition: vulkan.h:1640
VkPresentModeKHR
Definition: vulkan.h:4417
@ VK_PRESENT_MODE_IMMEDIATE_KHR
Definition: vulkan.h:4418
@ VK_PRESENT_MODE_FIFO_KHR
Definition: vulkan.h:4420
#define VK_NULL_HANDLE
Definition: vulkan.h:861
VkResult VKAPI_CALL vkGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchain, uint32_t *pSwapchainImageCount, VkImage *pSwapchainImages)
VkFormat
Definition: vulkan.h:2815
@ VK_FORMAT_R8G8B8A8_SRGB
Definition: vulkan.h:2859
@ VK_FORMAT_B8G8R8A8_UNORM
Definition: vulkan.h:2860
@ VK_FORMAT_A2B10G10R10_UNORM_PACK32
Definition: vulkan.h:2880
@ VK_FORMAT_B8G8R8A8_SRGB
Definition: vulkan.h:2866
@ VK_FORMAT_R8G8B8A8_UNORM
Definition: vulkan.h:2853
@ VK_FORMAT_UNDEFINED
Definition: vulkan.h:2816
@ VK_FORMAT_R16G16B16A16_SFLOAT
Definition: vulkan.h:2913
@ VK_COLOR_SPACE_SRGB_NONLINEAR_KHR
Definition: vulkan.h:2118
uint32_t VkBool32
Definition: vulkan.h:946
@ VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT
Definition: vulkan.h:4272
@ VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
Definition: vulkan.h:4282
@ VK_PIPELINE_STAGE_ALL_COMMANDS_BIT
Definition: vulkan.h:4288
@ VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT
Definition: vulkan.h:4285
@ VK_PIPELINE_STAGE_TRANSFER_BIT
Definition: vulkan.h:4284
void VKAPI_CALL vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks *pAllocator)
@ VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR
Definition: vulkan.h:5023
@ VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO
Definition: vulkan.h:4973
@ VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR
Definition: vulkan.h:5021
@ VK_STRUCTURE_TYPE_PRESENT_INFO_KHR
Definition: vulkan.h:5022
#define WGL_SWAP_COPY_ARB
Definition: wgl.h:5200
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define WINAPI
Definition: msvc.h:6
NTSTATUS WINAPI D3DKMTDestroyDCFromMemory(const D3DKMT_DESTROYDCFROMMEMORY *desc)
NTSTATUS WINAPI D3DKMTCreateDCFromMemory(D3DKMT_CREATEDCFROMMEMORY *desc)
HRESULT wined3d_output_get_gamma_ramp(struct wined3d_output *output, struct wined3d_gamma_ramp *ramp)
Definition: directx.c:1772
HRESULT CDECL wined3d_output_set_display_mode(struct wined3d_output *output, const struct wined3d_display_mode *mode)
Definition: directx.c:1693
HRESULT CDECL wined3d_restore_display_modes(struct wined3d *wined3d)
Definition: directx.c:1618
HRESULT CDECL wined3d_output_get_desc(const struct wined3d_output *output, struct wined3d_output_desc *desc)
Definition: directx.c:1256
HRESULT CDECL wined3d_output_set_gamma_ramp(struct wined3d_output *output, const struct wined3d_gamma_ramp *ramp)
Definition: directx.c:1759
const struct wined3d_parent_ops wined3d_null_parent_ops
Definition: directx.c:3472
HRESULT CDECL wined3d_output_find_closest_matching_mode(struct wined3d_output *output, struct wined3d_display_mode *mode)
Definition: directx.c:1409
HRESULT CDECL wined3d_output_get_display_mode(const struct wined3d_output *output, struct wined3d_display_mode *mode, enum wined3d_display_rotation *rotation)
Definition: directx.c:1515
HRESULT CDECL wined3d_output_get_raster_status(const struct wined3d_output *output, struct wined3d_raster_status *raster_status)
Definition: directx.c:1814
HRESULT CDECL wined3d_swapchain_state_resize_target(struct wined3d_swapchain_state *state, const struct wined3d_display_mode *mode)
Definition: swapchain.c:2065
static VkFormat wined3d_swapchain_vk_select_vk_format(struct wined3d_swapchain_vk *swapchain_vk, VkSurfaceKHR vk_surface)
Definition: swapchain.c:723
static HRESULT wined3d_swapchain_vk_create_vulkan_swapchain(struct wined3d_swapchain_vk *swapchain_vk)
Definition: swapchain.c:866
struct wined3d_texture *CDECL wined3d_swapchain_get_back_buffer(const struct wined3d_swapchain *swapchain, UINT back_buffer_idx)
Definition: swapchain.c:256
void CDECL wined3d_swapchain_get_desc(const struct wined3d_swapchain *swapchain, struct wined3d_swapchain_desc *desc)
Definition: swapchain.c:345
void CDECL wined3d_swapchain_state_destroy(struct wined3d_swapchain_state *state)
Definition: swapchain.c:2467
HRESULT CDECL wined3d_swapchain_get_raster_status(const struct wined3d_swapchain *swapchain, struct wined3d_raster_status *raster_status)
Definition: swapchain.c:294
static void wined3d_swapchain_apply_sample_count_override(const struct wined3d_swapchain *swapchain, enum wined3d_format_id format_id, enum wined3d_multisample_type *type, unsigned int *quality)
Definition: swapchain.c:1352
void *CDECL wined3d_swapchain_get_parent(const struct wined3d_swapchain *swapchain)
Definition: swapchain.c:170
static void wined3d_swapchain_vk_destroy_vulkan_swapchain(struct wined3d_swapchain_vk *swapchain_vk)
Definition: swapchain.c:96
static void swapchain_vk_present(struct wined3d_swapchain *swapchain, const RECT *src_rect, const RECT *dst_rect, unsigned int swap_interval, uint32_t flags)
Definition: swapchain.c:1222
void CDECL wined3d_swapchain_set_window(struct wined3d_swapchain *swapchain, HWND window)
Definition: swapchain.c:177
void swapchain_update_draw_bindings(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:1814
BOOL CDECL wined3d_swapchain_state_is_windowed(const struct wined3d_swapchain_state *state)
Definition: swapchain.c:2451
#define WINED3D_WINDOW_TOPMOST_TIMER_ID
Definition: swapchain.c:2157
static const struct wined3d_swapchain_ops swapchain_vk_ops
Definition: swapchain.c:1268
void wined3d_swapchain_gl_cleanup(struct wined3d_swapchain_gl *swapchain_gl)
Definition: swapchain.c:91
static VkResult wined3d_swapchain_vk_blit(struct wined3d_swapchain_vk *swapchain_vk, struct wined3d_context_vk *context_vk, const RECT *src_rect, const RECT *dst_rect, unsigned int swap_interval)
Definition: swapchain.c:1039
static void set_window_state(struct wined3d_window_state *s)
Definition: swapchain.c:2188
static HRESULT wined3d_swapchain_init(struct wined3d_swapchain *swapchain, struct wined3d_device *device, const struct wined3d_swapchain_desc *desc, struct wined3d_swapchain_state_parent *state_parent, void *parent, const struct wined3d_parent_ops *parent_ops, const struct wined3d_swapchain_ops *swapchain_ops)
Definition: swapchain.c:1506
static void CALLBACK topmost_timer_proc(HWND hwnd, UINT msg, UINT_PTR id, DWORD time)
Definition: swapchain.c:2159
static void swapchain_gdi_present(struct wined3d_swapchain *swapchain, const RECT *src_rect, const RECT *dst_rect, unsigned int swap_interval, uint32_t flags)
Definition: swapchain.c:1316
static struct wined3d_context_gl * wined3d_swapchain_gl_create_context(struct wined3d_swapchain_gl *swapchain_gl)
Definition: swapchain.c:1762
static void swapchain_blit(const struct wined3d_swapchain *swapchain, struct wined3d_context *context, const RECT *src_rect, const RECT *dst_rect)
Definition: swapchain.c:466
static void wined3d_swapchain_vk_rotate(struct wined3d_swapchain *swapchain, struct wined3d_context_vk *context_vk)
Definition: swapchain.c:1167
static void wined3d_swapchain_vk_set_swap_interval(struct wined3d_swapchain_vk *swapchain_vk, unsigned int swap_interval)
Definition: swapchain.c:1022
static void swapchain_blit_gdi(struct wined3d_swapchain *swapchain, struct wined3d_context *context, const RECT *src_rect, const RECT *dst_rect)
Definition: swapchain.c:399
struct wined3d_output * wined3d_swapchain_get_output(const struct wined3d_swapchain *swapchain)
Definition: swapchain.c:287
static HRESULT wined3d_swapchain_vk_recreate(struct wined3d_swapchain_vk *swapchain_vk)
Definition: swapchain.c:1013
HRESULT CDECL wined3d_swapchain_resize_buffers(struct wined3d_swapchain *swapchain, unsigned int buffer_count, unsigned int width, unsigned int height, enum wined3d_format_id format_id, enum wined3d_multisample_type multisample_type, unsigned int multisample_quality)
Definition: swapchain.c:1923
ULONG CDECL wined3d_swapchain_decref(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:144
HRESULT wined3d_swapchain_state_setup_fullscreen(struct wined3d_swapchain_state *state, HWND window, int x, int y, int width, int height)
Definition: swapchain.c:2225
static HRESULT wined3d_swapchain_state_set_display_mode(struct wined3d_swapchain_state *state, struct wined3d_output *output, struct wined3d_display_mode *mode)
Definition: swapchain.c:2028
static HRESULT swapchain_create_texture(struct wined3d_swapchain *swapchain, bool front, bool depth, struct wined3d_texture **texture)
Definition: swapchain.c:1456
HRESULT CDECL wined3d_swapchain_create(struct wined3d_device *device, const struct wined3d_swapchain_desc *desc, struct wined3d_swapchain_state_parent *state_parent, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_swapchain **swapchain)
Definition: swapchain.c:1732
HRESULT wined3d_swapchain_vk_init(struct wined3d_swapchain_vk *swapchain_vk, struct wined3d_device *device, const struct wined3d_swapchain_desc *desc, struct wined3d_swapchain_state_parent *state_parent, void *parent, const struct wined3d_parent_ops *parent_ops)
Definition: swapchain.c:1707
static enum wined3d_format_id adapter_format_from_backbuffer_format(const struct wined3d_adapter *adapter, enum wined3d_format_id format_id)
Definition: swapchain.c:1380
static void wined3d_swapchain_gl_rotate(struct wined3d_swapchain *swapchain, struct wined3d_context *context)
Definition: swapchain.c:516
HRESULT CDECL wined3d_swapchain_get_gamma_ramp(const struct wined3d_swapchain *swapchain, struct wined3d_gamma_ramp *ramp)
Definition: swapchain.c:381
void wined3d_swapchain_vk_cleanup(struct wined3d_swapchain_vk *swapchain_vk)
Definition: swapchain.c:125
HRESULT CDECL wined3d_swapchain_state_set_fullscreen(struct wined3d_swapchain_state *state, const struct wined3d_swapchain_desc *swapchain_desc, const struct wined3d_display_mode *mode)
Definition: swapchain.c:2344
HRESULT wined3d_swapchain_gl_init(struct wined3d_swapchain_gl *swapchain_gl, struct wined3d_device *device, const struct wined3d_swapchain_desc *desc, struct wined3d_swapchain_state_parent *state_parent, void *parent, const struct wined3d_parent_ops *parent_ops)
Definition: swapchain.c:1696
static LONG fullscreen_style(LONG style)
Definition: swapchain.c:2128
static DWORD WINAPI set_window_state_thread(void *ctx)
Definition: swapchain.c:2167
static bool wined3d_swapchain_vk_present_mode_supported(struct wined3d_swapchain_vk *swapchain_vk, VkPresentModeKHR vk_present_mode)
Definition: swapchain.c:660
HRESULT wined3d_swapchain_no3d_init(struct wined3d_swapchain *swapchain_no3d, struct wined3d_device *device, const struct wined3d_swapchain_desc *desc, struct wined3d_swapchain_state_parent *state_parent, void *parent, const struct wined3d_parent_ops *parent_ops)
Definition: swapchain.c:1685
void CDECL wined3d_swapchain_set_palette(struct wined3d_swapchain *swapchain, struct wined3d_palette *palette)
Definition: swapchain.c:372
static const struct wined3d_swapchain_ops swapchain_gl_ops
Definition: swapchain.c:654
ULONG CDECL wined3d_swapchain_incref(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:135
static void swapchain_frontbuffer_updated(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:643
HRESULT CDECL wined3d_swapchain_get_front_buffer_data(const struct wined3d_swapchain *swapchain, struct wined3d_texture *dst_texture, unsigned int sub_resource_idx)
Definition: swapchain.c:235
static void wined3d_swapchain_vk_destroy_object(void *object)
Definition: swapchain.c:120
struct wined3d_device *CDECL wined3d_swapchain_get_device(const struct wined3d_swapchain *swapchain)
Definition: swapchain.c:338
static const struct wined3d_swapchain_ops swapchain_no3d_ops
Definition: swapchain.c:1346
HRESULT CDECL wined3d_swapchain_state_create(const struct wined3d_swapchain_desc *desc, HWND window, struct wined3d *wined3d, struct wined3d_swapchain_state_parent *state_parent, struct wined3d_swapchain_state **state)
Definition: swapchain.c:2473
static void swapchain_gl_set_swap_interval(struct wined3d_swapchain *swapchain, struct wined3d_context_gl *context_gl, unsigned int swap_interval)
Definition: swapchain.c:494
HRESULT CDECL wined3d_swapchain_get_display_mode(const struct wined3d_swapchain *swapchain, struct wined3d_display_mode *mode, enum wined3d_display_rotation *rotation)
Definition: swapchain.c:316
static void swapchain_gl_present(struct wined3d_swapchain *swapchain, const RECT *src_rect, const RECT *dst_rect, unsigned int swap_interval, uint32_t flags)
Definition: swapchain.c:583
void swapchain_set_max_frame_latency(struct wined3d_swapchain *swapchain, const struct wined3d_device *device)
Definition: swapchain.c:1374
HRESULT CDECL wined3d_swapchain_present(struct wined3d_swapchain *swapchain, const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, unsigned int swap_interval, uint32_t flags)
Definition: swapchain.c:192
static void swapchain_gdi_frontbuffer_updated(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:1274
static bool swapchain_present_is_partial_copy(struct wined3d_swapchain *swapchain, const RECT *dst_rect)
Definition: swapchain.c:562
static LONG fullscreen_exstyle(LONG exstyle)
Definition: swapchain.c:2137
static HRESULT wined3d_swapchain_state_init(struct wined3d_swapchain_state *state, const struct wined3d_swapchain_desc *desc, HWND window, struct wined3d *wined3d, struct wined3d_swapchain_state_parent *parent)
Definition: swapchain.c:1389
HRESULT CDECL wined3d_swapchain_set_gamma_ramp(const struct wined3d_swapchain *swapchain, uint32_t flags, const struct wined3d_gamma_ramp *ramp)
Definition: swapchain.c:353
void wined3d_swapchain_cleanup(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:30
void CDECL wined3d_swapchain_state_get_size(const struct wined3d_swapchain_state *state, unsigned int *width, unsigned int *height)
Definition: swapchain.c:2458
struct wined3d_swapchain_state *CDECL wined3d_swapchain_get_state(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:311
struct wined3d_context_gl * wined3d_swapchain_gl_get_context(struct wined3d_swapchain_gl *swapchain_gl)
Definition: swapchain.c:1798
void wined3d_swapchain_state_restore_from_fullscreen(struct wined3d_swapchain_state *state, HWND window, const RECT *window_rect)
Definition: swapchain.c:2275
static bool wined3d_swapchain_vk_create_vulkan_swapchain_images(struct wined3d_swapchain_vk *swapchain_vk, VkSwapchainKHR vk_swapchain)
Definition: swapchain.c:792
struct wined3d_texture *CDECL wined3d_swapchain_get_front_buffer(const struct wined3d_swapchain *swapchain)
Definition: swapchain.c:280
void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activate)
Definition: swapchain.c:1826
#define WINED3D_RESTORE_MODE_ON_ACTIVATE
Definition: wined3d.h:1325
#define WINED3D_NO3D
Definition: wined3d.h:1323
wined3d_multisample_type
Definition: wined3d.h:572
@ WINED3D_SWAP_INTERVAL_DEFAULT
Definition: wined3d.h:550
#define WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH
Definition: wined3d.h:897
#define WINED3D_OK
Definition: wined3d.h:33
#define WINED3D_SWAPCHAIN_IMPLICIT
Definition: wined3d.h:901
#define WINED3DUSAGE_OWNDC
Definition: wined3d.h:935
wined3d_swap_effect
Definition: wined3d.h:533
@ WINED3D_SWAP_EFFECT_FLIP_DISCARD
Definition: wined3d.h:536
@ WINED3D_SWAP_EFFECT_COPY
Definition: wined3d.h:538
@ WINED3D_SWAP_EFFECT_SEQUENTIAL
Definition: wined3d.h:535
@ WINED3D_SWAP_EFFECT_DISCARD
Definition: wined3d.h:534
@ WINED3D_SWAP_EFFECT_COPY_VSYNC
Definition: wined3d.h:539
#define WINED3D_SWAPCHAIN_RESTORE_WINDOW_RECT
Definition: wined3d.h:899
#define WINED3D_RESOURCE_ACCESS_GPU
Definition: wined3d.h:51
#define WINED3D_RESOURCE_ACCESS_CPU
Definition: wined3d.h:52
@ WINED3D_RTYPE_TEXTURE_2D
Definition: wined3d.h:720
#define WINED3D_SWAPCHAIN_REGISTER_TOPMOST_TIMER
Definition: wined3d.h:905
#define WINED3DERR_NOTAVAILABLE
Definition: wined3d.h:42
wined3d_texture_filter_type
Definition: wined3d.h:704
@ WINED3D_TEXF_NONE
Definition: wined3d.h:705
@ WINED3D_TEXF_POINT
Definition: wined3d.h:706
@ WINED3D_TEXF_LINEAR
Definition: wined3d.h:707
#define WINED3D_SWAPCHAIN_GDI_COMPATIBLE
Definition: wined3d.h:900
#define WINED3DCREATE_NOWINDOWCHANGES
Definition: wined3d.h:1029
wined3d_format_id
Definition: wined3d.h:126
@ WINED3DFMT_UNKNOWN
Definition: wined3d.h:127
#define WINED3D_SWAPCHAIN_LOCKABLE_BACKBUFFER
Definition: wined3d.h:891
#define WINED3D_SWAPCHAIN_RESTORE_WINDOW_STATE
Definition: wined3d.h:904
#define WINED3D_BIND_DEPTH_STENCIL
Definition: wined3d.h:915
#define WINED3D_RESOURCE_ACCESS_MAP_R
Definition: wined3d.h:53
#define WINED3D_SWAPCHAIN_REGISTER_STATE
Definition: wined3d.h:902
@ WINED3D_SCANLINE_ORDERING_UNKNOWN
Definition: wined3d.h:825
#define WINED3D_BIND_RENDER_TARGET
Definition: wined3d.h:914
wined3d_display_rotation
Definition: wined3d.h:831
#define WINED3DERR_INVALIDCALL
Definition: wined3d.h:44
#define WINED3D_TEXTURE_CREATE_GET_DC
Definition: wined3d.h:1565
#define WINED3D_FOCUS_MESSAGES
Definition: wined3d.h:1326
#define WINED3D_RESOURCE_ACCESS_MAP_W
Definition: wined3d.h:54
#define WINED3D_SWAPCHAIN_USE_CLOSEST_MATCHING_MODE
Definition: wined3d.h:898
#define WINED3D_SWAPCHAIN_NO_WINDOW_CHANGES
Definition: wined3d.h:903
@ WGL_EXT_SWAP_CONTROL
Definition: wined3d_gl.h:227
#define GL_EXTCALL(f)
Definition: wined3d_gl.h:360
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:544
BOOL wined3d_filter_messages(HWND window, BOOL filter)
Definition: wined3d_main.c:605
void wined3d_swapchain_state_cleanup(struct wined3d_swapchain_state *state)
Definition: wined3d_main.c:942
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:539
void wined3d_swapchain_state_register(struct wined3d_swapchain_state *state)
Definition: wined3d_main.c:868
static unsigned int wined3d_texture_get_level_height(const struct wined3d_texture *texture, unsigned int level)
#define WINED3D_LOCATION_SYSMEM
static void wined3d_cs_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id)
static unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture, unsigned int level)
static BOOL is_complex_fixup(struct color_fixup_desc fixup)
#define WINED3D_LOCATION_RB_RESOLVED
static void context_release(struct wined3d_context *context)
#define WINED3D_LOCATION_TEXTURE_RGB
#define WINED3D_LOCATION_DRAWABLE
static void wined3d_from_cs(const struct wined3d_cs *cs)
#define WINED3D_LOCATION_RB_MULTISAMPLE
static struct wined3d_context * context_acquire(struct wined3d_device *device, struct wined3d_texture *texture, unsigned int sub_resource_idx)
@ WINED3D_CS_QUEUE_DEFAULT
#define STATE_FRAMEBUFFER
@ WINED3D_BLIT_OP_COLOR_BLIT
static void wined3d_context_vk_reference_texture(const struct wined3d_context_vk *context_vk, struct wined3d_texture_vk *texture_vk)
Definition: wined3d_vk.h:1103
#define VK_CALL(f)
Definition: wined3d_vk.h:272
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
#define SRCCOPY
Definition: wingdi.h:333
BOOL WINAPI DeleteDC(_In_ HDC)
size_t const buffer_count
Definition: xtoa.cpp:36