ReactOS  0.4.13-dev-242-g611e6d7
swapchain.c File Reference
#include "config.h"
#include "wine/port.h"
#include "wined3d_private.h"
Include dependency graph for swapchain.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3d)
 
 WINE_DECLARE_DEBUG_CHANNEL (fps)
 
static void wined3d_swapchain_destroy_object (void *object)
 
static void swapchain_cleanup (struct wined3d_swapchain *swapchain)
 
ULONG CDECL wined3d_swapchain_incref (struct wined3d_swapchain *swapchain)
 
ULONG CDECL wined3d_swapchain_decref (struct wined3d_swapchain *swapchain)
 
void *CDECL wined3d_swapchain_get_parent (const struct wined3d_swapchain *swapchain)
 
void CDECL wined3d_swapchain_set_window (struct wined3d_swapchain *swapchain, HWND window)
 
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, DWORD flags)
 
HRESULT CDECL wined3d_swapchain_get_front_buffer_data (const struct wined3d_swapchain *swapchain, struct wined3d_texture *dst_texture, unsigned int sub_resource_idx)
 
struct wined3d_texture *CDECL wined3d_swapchain_get_back_buffer (const struct wined3d_swapchain *swapchain, UINT back_buffer_idx)
 
HRESULT CDECL wined3d_swapchain_get_raster_status (const struct wined3d_swapchain *swapchain, struct wined3d_raster_status *raster_status)
 
HRESULT CDECL wined3d_swapchain_get_display_mode (const struct wined3d_swapchain *swapchain, struct wined3d_display_mode *mode, enum wined3d_display_rotation *rotation)
 
struct wined3d_device *CDECL wined3d_swapchain_get_device (const struct wined3d_swapchain *swapchain)
 
void CDECL wined3d_swapchain_get_desc (const struct wined3d_swapchain *swapchain, struct wined3d_swapchain_desc *desc)
 
HRESULT CDECL wined3d_swapchain_set_gamma_ramp (const struct wined3d_swapchain *swapchain, DWORD flags, const struct wined3d_gamma_ramp *ramp)
 
void CDECL wined3d_swapchain_set_palette (struct wined3d_swapchain *swapchain, struct wined3d_palette *palette)
 
HRESULT CDECL wined3d_swapchain_get_gamma_ramp (const struct wined3d_swapchain *swapchain, struct wined3d_gamma_ramp *ramp)
 
static void swapchain_blit (const struct wined3d_swapchain *swapchain, struct wined3d_context *context, const RECT *src_rect, const RECT *dst_rect)
 
static void wined3d_swapchain_rotate (struct wined3d_swapchain *swapchain, struct wined3d_context *context)
 
static void swapchain_gl_present (struct wined3d_swapchain *swapchain, const RECT *src_rect, const RECT *dst_rect, DWORD flags)
 
static void swapchain_gl_frontbuffer_updated (struct wined3d_swapchain *swapchain)
 
static void swapchain_gdi_frontbuffer_updated (struct wined3d_swapchain *swapchain)
 
static void swapchain_gdi_present (struct wined3d_swapchain *swapchain, const RECT *src_rect, const RECT *dst_rect, DWORD flags)
 
static void swapchain_update_render_to_fbo (struct wined3d_swapchain *swapchain)
 
static void wined3d_swapchain_apply_sample_count_override (const struct wined3d_swapchain *swapchain, enum wined3d_format_id format_id, enum wined3d_multisample_type *type, DWORD *quality)
 
void wined3d_swapchain_set_swap_interval (struct wined3d_swapchain *swapchain, unsigned int swap_interval)
 
static void wined3d_swapchain_cs_init (void *object)
 
void swapchain_set_max_frame_latency (struct wined3d_swapchain *swapchain, const struct wined3d_device *device)
 
static HRESULT swapchain_init (struct wined3d_swapchain *swapchain, struct wined3d_device *device, struct wined3d_swapchain_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops)
 
HRESULT CDECL wined3d_swapchain_create (struct wined3d_device *device, struct wined3d_swapchain_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_swapchain **swapchain)
 
static struct wined3d_contextswapchain_create_context (struct wined3d_swapchain *swapchain)
 
void swapchain_destroy_contexts (struct wined3d_swapchain *swapchain)
 
struct wined3d_contextswapchain_get_context (struct wined3d_swapchain *swapchain)
 
HDC swapchain_get_backup_dc (struct wined3d_swapchain *swapchain)
 
void swapchain_update_draw_bindings (struct wined3d_swapchain *swapchain)
 
void wined3d_swapchain_activate (struct wined3d_swapchain *swapchain, BOOL activate)
 
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)
 
static HRESULT wined3d_swapchain_set_display_mode (struct wined3d_swapchain *swapchain, struct wined3d_display_mode *mode)
 
HRESULT CDECL wined3d_swapchain_resize_target (struct wined3d_swapchain *swapchain, const struct wined3d_display_mode *mode)
 
HRESULT CDECL wined3d_swapchain_set_fullscreen (struct wined3d_swapchain *swapchain, const struct wined3d_swapchain_desc *swapchain_desc, const struct wined3d_display_mode *mode)
 

Variables

static const struct wined3d_swapchain_ops swapchain_gl_ops
 
static const struct wined3d_swapchain_ops swapchain_gdi_ops
 

Function Documentation

◆ swapchain_blit()

static void swapchain_blit ( const struct wined3d_swapchain swapchain,
struct wined3d_context context,
const RECT src_rect,
const RECT dst_rect 
)
static

Definition at line 313 of file swapchain.c.

315 {
316  struct wined3d_texture *texture = swapchain->back_buffers[0];
317  struct wined3d_device *device = swapchain->device;
319  DWORD location;
320 
321  TRACE("swapchain %p, context %p, src_rect %s, dst_rect %s.\n",
322  swapchain, context, wine_dbgstr_rect(src_rect), wine_dbgstr_rect(dst_rect));
323 
324  if ((src_rect->right - src_rect->left == dst_rect->right - dst_rect->left
325  && src_rect->bottom - src_rect->top == dst_rect->bottom - dst_rect->top)
326  || is_complex_fixup(texture->resource.format->color_fixup))
328  else
330 
332  if (texture->resource.multisample_type)
334 
336  device->blitter->ops->blitter_blit(device->blitter, WINED3D_BLIT_OP_COLOR_BLIT, context, texture, 0,
337  location, src_rect, texture, 0, WINED3D_LOCATION_DRAWABLE, dst_rect, NULL, filter);
339 }
Definition: http.c:6587
struct wined3d_swapchain * swapchain
static BOOL is_complex_fixup(struct color_fixup_desc fixup)
LONG top
Definition: windef.h:292
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
wined3d_texture_filter_type
Definition: wined3d.h:692
Definition: devices.h:37
#define WINED3D_LOCATION_RB_RESOLVED
smooth NULL
Definition: ftsmooth.c:416
#define WINED3D_LOCATION_DRAWABLE
#define TRACE(s)
Definition: solgame.cpp:4
void wined3d_texture_validate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location)
Definition: texture.c:286
GLenum GLuint texture
Definition: glext.h:6295
const char * wine_dbgstr_rect(const RECT *rect)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define location(file, line)
Definition: kmtest.h:18
void wined3d_texture_invalidate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location)
Definition: texture.c:310
#define WINED3D_LOCATION_TEXTURE_RGB
LONG bottom
Definition: windef.h:294
struct wined3d_device * device
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glext.h:7005

Referenced by swapchain_gl_present().

◆ swapchain_cleanup()

static void swapchain_cleanup ( struct wined3d_swapchain swapchain)
static

Definition at line 39 of file swapchain.c.

40 {
41  HRESULT hr;
42  UINT i;
43 
44  TRACE("Destroying swapchain %p.\n", swapchain);
45 
46  wined3d_swapchain_set_gamma_ramp(swapchain, 0, &swapchain->orig_gamma);
47 
48  /* Release the swapchain's draw buffers. Make sure swapchain->back_buffers[0]
49  * is the last buffer to be destroyed, FindContext() depends on that. */
50  if (swapchain->front_buffer)
51  {
53  if (wined3d_texture_decref(swapchain->front_buffer))
54  WARN("Something's still holding the front buffer (%p).\n", swapchain->front_buffer);
55  swapchain->front_buffer = NULL;
56  }
57 
58  if (swapchain->back_buffers)
59  {
60  i = swapchain->desc.backbuffer_count;
61 
62  while (i--)
63  {
65  if (wined3d_texture_decref(swapchain->back_buffers[i]))
66  WARN("Something's still holding back buffer %u (%p).\n", i, swapchain->back_buffers[i]);
67  }
68  heap_free(swapchain->back_buffers);
69  swapchain->back_buffers = NULL;
70  }
71 
73  swapchain->device->cs->ops->finish(swapchain->device->cs, WINED3D_CS_QUEUE_DEFAULT);
74 
75  /* Restore the screen resolution if we rendered in fullscreen.
76  * This will restore the screen resolution to what it was before creating
77  * the swapchain. In case of d3d8 and d3d9 this will be the original
78  * desktop resolution. In case of d3d7 this will be a NOP because ddraw
79  * sets the resolution before starting up Direct3D, thus orig_width and
80  * orig_height will be equal to the modes in the presentation params. */
81  if (!swapchain->desc.windowed && swapchain->desc.auto_restore_display_mode)
82  {
83  if (FAILED(hr = wined3d_set_adapter_display_mode(swapchain->device->wined3d,
84  swapchain->device->adapter->ordinal, &swapchain->original_mode)))
85  ERR("Failed to restore display mode, hr %#x.\n", hr);
86 
87  if (swapchain->desc.flags & WINED3D_SWAPCHAIN_RESTORE_WINDOW_RECT)
88  {
90  &swapchain->original_window_rect);
92  }
93  }
94 
95  if (swapchain->backup_dc)
96  {
97  TRACE("Destroying backup wined3d window %p, dc %p.\n", swapchain->backup_wnd, swapchain->backup_dc);
98 
99  wined3d_release_dc(swapchain->backup_wnd, swapchain->backup_dc);
100  DestroyWindow(swapchain->backup_wnd);
101  }
102 }
struct wined3d_texture * front_buffer
HRESULT CDECL wined3d_set_adapter_display_mode(struct wined3d *wined3d, UINT adapter_idx, const struct wined3d_display_mode *mode)
Definition: directx.c:4837
HRESULT hr
Definition: shlfolder.c:183
#define WINED3D_SWAPCHAIN_RESTORE_WINDOW_RECT
Definition: wined3d.h:894
#define WARN(fmt,...)
Definition: debug.h:111
void wined3d_cs_destroy_object(struct wined3d_cs *cs, void(*callback)(void *object), void *object)
Definition: cs.c:1907
void CDECL wined3d_device_restore_fullscreen_window(struct wined3d_device *device, HWND window, const RECT *window_rect)
Definition: device.c:889
struct wined3d_texture ** back_buffers
BOOL WINAPI DestroyWindow(_In_ HWND)
void wined3d_texture_set_swapchain(struct wined3d_texture *texture, struct wined3d_swapchain *swapchain)
Definition: texture.c:918
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
struct wined3d_swapchain_desc desc
smooth NULL
Definition: ftsmooth.c:416
struct wined3d_gamma_ramp orig_gamma
void CDECL wined3d_device_release_focus_window(struct wined3d_device *device)
Definition: device.c:958
void wined3d_release_dc(HWND window, HDC dc)
Definition: utils.c:6354
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
HRESULT CDECL wined3d_swapchain_set_gamma_ramp(const struct wined3d_swapchain *swapchain, DWORD flags, const struct wined3d_gamma_ramp *ramp)
Definition: swapchain.c:275
#define ERR(fmt,...)
Definition: debug.h:109
unsigned int UINT
Definition: ndis.h:50
static void wined3d_swapchain_destroy_object(void *object)
Definition: swapchain.c:34
ULONG CDECL wined3d_texture_decref(struct wined3d_texture *texture)
Definition: texture.c:1219
struct wined3d_device * device
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by wined3d_swapchain_decref().

◆ swapchain_create_context()

static struct wined3d_context* swapchain_create_context ( struct wined3d_swapchain swapchain)
static

Definition at line 1029 of file swapchain.c.

1030 {
1031  struct wined3d_context **ctx_array;
1032  struct wined3d_context *ctx;
1033 
1034  TRACE("Creating a new context for swapchain %p, thread %u.\n", swapchain, GetCurrentThreadId());
1035 
1036  if (!(ctx = context_create(swapchain, swapchain->front_buffer, swapchain->ds_format)))
1037  {
1038  ERR("Failed to create a new context for the swapchain\n");
1039  return NULL;
1040  }
1041  context_release(ctx);
1042 
1043  if (!(ctx_array = heap_calloc(swapchain->num_contexts + 1, sizeof(*ctx_array))))
1044  {
1045  ERR("Out of memory when trying to allocate a new context array\n");
1046  context_destroy(swapchain->device, ctx);
1047  return NULL;
1048  }
1049  memcpy(ctx_array, swapchain->context, sizeof(*ctx_array) * swapchain->num_contexts);
1050  heap_free(swapchain->context);
1051  ctx_array[swapchain->num_contexts] = ctx;
1052  swapchain->context = ctx_array;
1053  swapchain->num_contexts++;
1054 
1055  TRACE("Returning context %p\n", ctx);
1056  return ctx;
1057 }
struct wined3d_context * context_create(struct wined3d_swapchain *swapchain, struct wined3d_texture *target, const struct wined3d_format *ds_format)
Definition: context.c:1887
static void * heap_calloc(SIZE_T count, SIZE_T size)
Definition: heap.h:49
smooth NULL
Definition: ftsmooth.c:416
void context_release(struct wined3d_context *context)
Definition: context.c:1559
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:420
#define TRACE(s)
Definition: solgame.cpp:4
void context_destroy(struct wined3d_device *device, struct wined3d_context *context)
Definition: context.c:2281
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
struct wined3d_swapchain * swapchain
#define ERR(fmt,...)
Definition: debug.h:109
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by swapchain_get_context().

◆ swapchain_destroy_contexts()

void swapchain_destroy_contexts ( struct wined3d_swapchain swapchain)

Definition at line 1059 of file swapchain.c.

1060 {
1061  unsigned int i;
1062 
1063  for (i = 0; i < swapchain->num_contexts; ++i)
1064  {
1065  context_destroy(swapchain->device, swapchain->context[i]);
1066  }
1067  heap_free(swapchain->context);
1068  swapchain->num_contexts = 0;
1069  swapchain->context = NULL;
1070 }
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
smooth NULL
Definition: ftsmooth.c:416
void context_destroy(struct wined3d_device *device, struct wined3d_context *context)
Definition: context.c:2281
struct wined3d_swapchain * swapchain
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by wined3d_device_delete_opengl_contexts_cs(), and wined3d_swapchain_destroy_object().

◆ swapchain_gdi_frontbuffer_updated()

static void swapchain_gdi_frontbuffer_updated ( struct wined3d_swapchain swapchain)
static

Definition at line 547 of file swapchain.c.

548 {
549  struct wined3d_dc_info *front;
550  POINT offset = {0, 0};
551  HDC src_dc, dst_dc;
552  RECT draw_rect;
553  HWND window;
554 
555  TRACE("swapchain %p.\n", swapchain);
556 
557  front = &swapchain->front_buffer->dc_info[0];
558  if (swapchain->palette)
559  wined3d_palette_apply_to_dc(swapchain->palette, front->dc);
560 
561  if (swapchain->front_buffer->resource.map_count)
562  ERR("Trying to blit a mapped surface.\n");
563 
564  TRACE("Copying surface %p to screen.\n", front);
565 
566  src_dc = front->dc;
567  window = swapchain->win_handle;
568  dst_dc = GetDCEx(window, 0, DCX_CLIPSIBLINGS | DCX_CACHE);
569 
570  /* Front buffer coordinates are screen coordinates. Map them to the
571  * destination window if not fullscreened. */
572  if (swapchain->desc.windowed)
574 
575  TRACE("offset %s.\n", wine_dbgstr_point(&offset));
576 
577  SetRect(&draw_rect, 0, 0, swapchain->front_buffer->resource.width,
578  swapchain->front_buffer->resource.height);
579  IntersectRect(&draw_rect, &draw_rect, &swapchain->front_buffer_update);
580 
581  BitBlt(dst_dc, draw_rect.left - offset.x, draw_rect.top - offset.y,
582  draw_rect.right - draw_rect.left, draw_rect.bottom - draw_rect.top,
583  src_dc, draw_rect.left, draw_rect.top, SRCCOPY);
584  ReleaseDC(window, dst_dc);
585 
586  SetRectEmpty(&swapchain->front_buffer_update);
587 }
struct wined3d_texture * front_buffer
HDC WINAPI GetDCEx(_In_opt_ HWND, _In_opt_ HRGN, _In_ DWORD)
#define DCX_CLIPSIBLINGS
Definition: winuser.h:2077
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
static HDC
Definition: imagelist.c:92
GLintptr offset
Definition: glext.h:5920
LONG top
Definition: windef.h:292
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
static VOID NTAPI BitBlt(IN ULONG Left, IN ULONG Top, IN ULONG Width, IN ULONG Height, IN PUCHAR Buffer, IN ULONG BitsPerPixel, IN ULONG Delta)
Definition: vga.c:416
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
struct wined3d_swapchain_desc desc
const char * wine_dbgstr_point(const POINT *guid)
#define TRACE(s)
Definition: solgame.cpp:4
static struct address_cache * front
Definition: rpcb_clnt.c:83
void CDECL wined3d_palette_apply_to_dc(const struct wined3d_palette *palette, HDC dc)
Definition: palette.c:86
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
static IHTMLWindow2 * window
Definition: events.c:77
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
#define ERR(fmt,...)
Definition: debug.h:109
#define DCX_CACHE
Definition: winuser.h:2075
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
struct wined3d_palette * palette
LONG bottom
Definition: windef.h:294
#define SRCCOPY
Definition: wingdi.h:332

Referenced by swapchain_gdi_present().

◆ swapchain_gdi_present()

static void swapchain_gdi_present ( struct wined3d_swapchain swapchain,
const RECT src_rect,
const RECT dst_rect,
DWORD  flags 
)
static

Definition at line 589 of file swapchain.c.

591 {
592  struct wined3d_dc_info *front, *back;
593  HBITMAP bitmap;
594  void *data;
595  HDC dc;
596 
597  front = &swapchain->front_buffer->dc_info[0];
598  back = &swapchain->back_buffers[0]->dc_info[0];
599 
600  /* Flip the surface data. */
601  dc = front->dc;
602  bitmap = front->bitmap;
603  data = swapchain->front_buffer->resource.heap_memory;
604 
605  front->dc = back->dc;
606  front->bitmap = back->bitmap;
607  swapchain->front_buffer->resource.heap_memory = swapchain->back_buffers[0]->resource.heap_memory;
608 
609  back->dc = dc;
610  back->bitmap = bitmap;
611  swapchain->back_buffers[0]->resource.heap_memory = data;
612 
613  /* FPS support */
614  if (TRACE_ON(fps))
615  {
616  static LONG prev_time, frames;
617  DWORD time = GetTickCount();
618 
619  ++frames;
620 
621  /* every 1.5 seconds */
622  if (time - prev_time > 1500)
623  {
624  TRACE_(fps)("@ approx %.2ffps\n", 1000.0 * frames / (time - prev_time));
625  prev_time = time;
626  frames = 0;
627  }
628  }
629 
630  SetRect(&swapchain->front_buffer_update, 0, 0,
631  swapchain->front_buffer->resource.width,
632  swapchain->front_buffer->resource.height);
634 }
struct wined3d_texture * front_buffer
static HDC
Definition: imagelist.c:92
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:445
HDC dc
Definition: cylfrac.c:34
__u16 time
Definition: mkdosfs.c:366
struct wined3d_texture ** back_buffers
long LONG
Definition: pedump.c:60
#define TRACE_(x)
Definition: compat.h:66
Definition: uimain.c:88
static struct address_cache * front
Definition: rpcb_clnt.c:83
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static void swapchain_gdi_frontbuffer_updated(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:547
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
static HBITMAP bitmap
Definition: clipboard.c:1344
static HBITMAP
Definition: button.c:44
#define TRACE_ON(x)
Definition: compat.h:65

◆ swapchain_get_backup_dc()

HDC swapchain_get_backup_dc ( struct wined3d_swapchain swapchain)

Definition at line 1087 of file swapchain.c.

1088 {
1089  if (!swapchain->backup_dc)
1090  {
1091  TRACE("Creating the backup window for swapchain %p.\n", swapchain);
1092 
1093  if (!(swapchain->backup_wnd = CreateWindowA(WINED3D_OPENGL_WINDOW_CLASS_NAME, "WineD3D fake window",
1094  WS_OVERLAPPEDWINDOW, 10, 10, 10, 10, NULL, NULL, NULL, NULL)))
1095  {
1096  ERR("Failed to create a window.\n");
1097  return NULL;
1098  }
1099 
1100  if (!(swapchain->backup_dc = GetDC(swapchain->backup_wnd)))
1101  {
1102  ERR("Failed to get a DC.\n");
1103  DestroyWindow(swapchain->backup_wnd);
1104  swapchain->backup_wnd = NULL;
1105  return NULL;
1106  }
1107  }
1108 
1109  return swapchain->backup_dc;
1110 }
HDC WINAPI GetDC(_In_opt_ HWND)
BOOL WINAPI DestroyWindow(_In_ HWND)
#define WINED3D_OPENGL_WINDOW_CLASS_NAME
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4184
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define ERR(fmt,...)
Definition: debug.h:109
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637

Referenced by context_create(), and context_set_gl_context().

◆ swapchain_get_context()

struct wined3d_context* swapchain_get_context ( struct wined3d_swapchain swapchain)

Definition at line 1072 of file swapchain.c.

1073 {
1075  unsigned int i;
1076 
1077  for (i = 0; i < swapchain->num_contexts; ++i)
1078  {
1079  if (swapchain->context[i]->tid == tid)
1080  return swapchain->context[i];
1081  }
1082 
1083  /* Create a new context for the thread */
1084  return swapchain_create_context(swapchain);
1085 }
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
unsigned int num_contexts
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:420
struct wined3d_context ** context
unsigned long DWORD
Definition: ntddk_ex.h:95
static struct wined3d_context * swapchain_create_context(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:1029
static TfClientId tid

Referenced by context_acquire().

◆ swapchain_gl_frontbuffer_updated()

static void swapchain_gl_frontbuffer_updated ( struct wined3d_swapchain swapchain)
static

Definition at line 530 of file swapchain.c.

531 {
532  struct wined3d_texture *front_buffer = swapchain->front_buffer;
533  struct wined3d_context *context;
534 
535  context = context_acquire(swapchain->device, front_buffer, 0);
536  wined3d_texture_load_location(front_buffer, 0, context, front_buffer->resource.draw_binding);
538  SetRectEmpty(&swapchain->front_buffer_update);
539 }
Definition: http.c:6587
struct wined3d_swapchain * swapchain
struct wined3d_resource resource
void context_release(struct wined3d_context *context)
Definition: context.c:1559
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
struct wined3d_swapchain * swapchain
struct wined3d_context * context_acquire(const struct wined3d_device *device, struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: context.c:4218
BOOL wined3d_texture_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
Definition: texture.c:380

◆ swapchain_gl_present()

static void swapchain_gl_present ( struct wined3d_swapchain swapchain,
const RECT src_rect,
const RECT dst_rect,
DWORD  flags 
)
static

Definition at line 388 of file swapchain.c.

390 {
391  struct wined3d_texture *back_buffer = swapchain->back_buffers[0];
392  const struct wined3d_fb_state *fb = &swapchain->device->cs->fb;
393  struct wined3d_rendertarget_view *dsv = fb->depth_stencil;
394  const struct wined3d_gl_info *gl_info;
395  struct wined3d_texture *logo_texture;
396  struct wined3d_context *context;
397  BOOL render_to_fbo;
398 
399  context = context_acquire(swapchain->device, back_buffer, 0);
400  if (!context->valid)
401  {
403  WARN("Invalid context, skipping present.\n");
404  return;
405  }
406 
407  gl_info = context->gl_info;
408 
409  if ((logo_texture = swapchain->device->logo_texture))
410  {
411  RECT rect = {0, 0, logo_texture->resource.width, logo_texture->resource.height};
412 
413  /* Blit the logo into the upper left corner of the drawable. */
414  wined3d_texture_blt(back_buffer, 0, &rect, logo_texture, 0, &rect,
416  }
417 
418  if (swapchain->device->bCursorVisible && swapchain->device->cursor_texture
419  && !swapchain->device->hardwareCursor)
420  {
421  RECT dst_rect =
422  {
423  swapchain->device->xScreenSpace - swapchain->device->xHotSpot,
424  swapchain->device->yScreenSpace - swapchain->device->yHotSpot,
425  swapchain->device->xScreenSpace + swapchain->device->cursorWidth - swapchain->device->xHotSpot,
426  swapchain->device->yScreenSpace + swapchain->device->cursorHeight - swapchain->device->yHotSpot,
427  };
428  RECT src_rect =
429  {
430  0, 0,
431  swapchain->device->cursor_texture->resource.width,
432  swapchain->device->cursor_texture->resource.height
433  };
434  const RECT clip_rect = {0, 0, back_buffer->resource.width, back_buffer->resource.height};
435 
436  TRACE("Rendering the software cursor.\n");
437 
438  if (swapchain->desc.windowed)
439  MapWindowPoints(NULL, swapchain->win_handle, (POINT *)&dst_rect, 2);
440  if (wined3d_clip_blit(&clip_rect, &dst_rect, &src_rect))
441  wined3d_texture_blt(back_buffer, 0, &dst_rect,
442  swapchain->device->cursor_texture, 0, &src_rect,
444  }
445 
446  TRACE("Presenting HDC %p.\n", context->hdc);
447 
448  if (!(render_to_fbo = swapchain->render_to_fbo)
449  && (src_rect->left || src_rect->top
450  || src_rect->right != swapchain->desc.backbuffer_width
451  || src_rect->bottom != swapchain->desc.backbuffer_height
452  || dst_rect->left || dst_rect->top
453  || dst_rect->right != swapchain->desc.backbuffer_width
454  || dst_rect->bottom != swapchain->desc.backbuffer_height))
455  render_to_fbo = TRUE;
456 
457  /* Rendering to a window of different size, presenting partial rectangles,
458  * or rendering to a different window needs help from FBO_blit or a textured
459  * draw. Render the swapchain to a FBO in the future.
460  *
461  * Note that FBO_blit from the backbuffer to the frontbuffer cannot solve
462  * all these issues - this fails if the window is smaller than the backbuffer.
463  */
464  if (!swapchain->render_to_fbo && render_to_fbo && wined3d_settings.offscreen_rendering_mode == ORM_FBO)
465  {
468  swapchain->render_to_fbo = TRUE;
470  }
471  else
472  {
473  wined3d_texture_load_location(back_buffer, 0, context, back_buffer->resource.draw_binding);
474  }
475 
476  if (swapchain->render_to_fbo)
477  swapchain_blit(swapchain, context, src_rect, dst_rect);
478 
479  if (swapchain->num_contexts > 1)
480  gl_info->gl_ops.gl.p_glFinish();
481 
482  /* call wglSwapBuffers through the gl table to avoid confusing the Steam overlay */
483  gl_info->gl_ops.wgl.p_wglSwapBuffers(context->hdc);
484 
486 
487  TRACE("SwapBuffers called, Starting new frame\n");
488  /* FPS support */
489  if (TRACE_ON(fps))
490  {
491  DWORD time = GetTickCount();
492  ++swapchain->frames;
493 
494  /* every 1.5 seconds */
495  if (time - swapchain->prev_time > 1500)
496  {
497  TRACE_(fps)("%p @ approx %.2ffps\n",
498  swapchain, 1000.0 * swapchain->frames / (time - swapchain->prev_time));
499  swapchain->prev_time = time;
500  swapchain->frames = 0;
501  }
502  }
503 
506  /* If the swapeffect is DISCARD, the back buffer is undefined. That means the SYSMEM
507  * and INTEXTURE copies can keep their old content if they have any defined content.
508  * If the swapeffect is COPY, the content remains the same.
509  *
510  * The FLIP swap effect is not implemented yet. We could mark WINED3D_LOCATION_DRAWABLE
511  * up to date and hope WGL flipped front and back buffers and read this data into
512  * the FBO. Don't bother about this for now. */
513  if (swapchain->desc.swap_effect == WINED3D_SWAP_EFFECT_DISCARD
514  || swapchain->desc.swap_effect == WINED3D_SWAP_EFFECT_FLIP_DISCARD)
515  wined3d_texture_validate_location(swapchain->back_buffers[swapchain->desc.backbuffer_count - 1],
517 
518  if (dsv && dsv->resource->type != WINED3D_RTYPE_BUFFER)
519  {
521 
523  || ds->flags & WINED3D_TEXTURE_DISCARD))
525  }
526 
528 }
#define ORM_FBO
#define WINED3D_BLT_SRC_CKEY
Definition: wined3d.h:1362
#define TRUE
Definition: types.h:120
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
Definition: http.c:6587
struct wined3d_swapchain * swapchain
#define WARN(fmt,...)
Definition: debug.h:111
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:445
LONG top
Definition: windef.h:292
#define ds
Definition: i386-dis.c:434
struct wined3d_resource resource
__u16 time
Definition: mkdosfs.c:366
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
static void swapchain_blit(const struct wined3d_swapchain *swapchain, struct wined3d_context *context, const RECT *src_rect, const RECT *dst_rect)
Definition: swapchain.c:313
& rect
Definition: startmenu.cpp:1413
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define WINED3D_LOCATION_DRAWABLE
void context_release(struct wined3d_context *context)
Definition: context.c:1559
#define TRACE_(x)
Definition: compat.h:66
#define TRACE(s)
Definition: solgame.cpp:4
void wined3d_texture_validate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location)
Definition: texture.c:286
HRESULT CDECL wined3d_texture_blt(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, DWORD flags, const struct wined3d_blt_fx *fx, enum wined3d_texture_filter_type filter)
Definition: texture.c:3087
unsigned long DWORD
Definition: ntddk_ex.h:95
static struct wined3d_texture * texture_from_resource(struct wined3d_resource *resource)
#define WINED3D_BLT_ALPHA_TEST
Definition: wined3d.h:1368
#define WINED3D_TEXTURE_DISCARD
struct wined3d_rendertarget_view * depth_stencil
struct wined3d_swapchain * swapchain
struct wined3d_context * context_acquire(const struct wined3d_device *device, struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: context.c:4218
void wined3d_texture_invalidate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location)
Definition: texture.c:310
#define WINED3D_LOCATION_TEXTURE_RGB
BOOL wined3d_texture_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
Definition: texture.c:380
LONG bottom
Definition: windef.h:294
const struct wined3d_gl_info * gl_info
#define WINED3D_LOCATION_DISCARDED
void swapchain_update_draw_bindings(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:1112
#define WINED3D_SWAPCHAIN_DISCARD_DEPTHSTENCIL
Definition: wined3d.h:887
#define TRACE_ON(x)
Definition: compat.h:65
struct wined3d_device * device
BOOL wined3d_clip_blit(const RECT *clip_rect, RECT *clipped, RECT *other)
Definition: utils.c:6368
static void wined3d_swapchain_rotate(struct wined3d_swapchain *swapchain, struct wined3d_context *context)
Definition: swapchain.c:342
struct wined3d_resource * resource

◆ swapchain_init()

static HRESULT swapchain_init ( struct wined3d_swapchain swapchain,
struct wined3d_device device,
struct wined3d_swapchain_desc desc,
void parent,
const struct wined3d_parent_ops parent_ops 
)
static

Definition at line 753 of file swapchain.c.

755 {
756  const struct wined3d_adapter *adapter = device->adapter;
757  struct wined3d_resource_desc texture_desc;
758  BOOL displaymode_set = FALSE;
759  DWORD texture_flags = 0;
760  RECT client_rect;
761  unsigned int i;
762  HWND window;
763  HRESULT hr;
764 
765  if (desc->backbuffer_count > 1)
766  {
767  FIXME("The application requested more than one back buffer, this is not properly supported.\n"
768  "Please configure the application to use double buffering (1 back buffer) if possible.\n");
769  }
770 
771  if (desc->swap_effect != WINED3D_SWAP_EFFECT_DISCARD
772  && desc->swap_effect != WINED3D_SWAP_EFFECT_SEQUENTIAL
773  && desc->swap_effect != WINED3D_SWAP_EFFECT_COPY)
774  FIXME("Unimplemented swap effect %#x.\n", desc->swap_effect);
775 
776  if (device->wined3d->flags & WINED3D_NO3D)
777  swapchain->swapchain_ops = &swapchain_gdi_ops;
778  else
779  swapchain->swapchain_ops = &swapchain_gl_ops;
780 
781  window = desc->device_window ? desc->device_window : device->create_parms.focus_window;
782 
783  swapchain->device = device;
784  swapchain->parent = parent;
785  swapchain->parent_ops = parent_ops;
786  swapchain->ref = 1;
787  swapchain->win_handle = window;
788  swapchain->device_window = window;
791 
793  adapter->ordinal, &swapchain->original_mode, NULL)))
794  {
795  ERR("Failed to get current display mode, hr %#x.\n", hr);
796  goto err;
797  }
799 
800  GetClientRect(window, &client_rect);
801  if (desc->windowed)
802  {
803  TRACE("Client rect %s.\n", wine_dbgstr_rect(&client_rect));
804 
805  if (!desc->backbuffer_width)
806  {
807  desc->backbuffer_width = client_rect.right ? client_rect.right : 8;
808  TRACE("Updating width to %u.\n", desc->backbuffer_width);
809  }
810  if (!desc->backbuffer_height)
811  {
812  desc->backbuffer_height = client_rect.bottom ? client_rect.bottom : 8;
813  TRACE("Updating height to %u.\n", desc->backbuffer_height);
814  }
815 
816  if (desc->backbuffer_format == WINED3DFMT_UNKNOWN)
817  {
818  desc->backbuffer_format = swapchain->original_mode.format_id;
819  TRACE("Updating format to %s.\n", debug_d3dformat(swapchain->original_mode.format_id));
820  }
821  }
822  swapchain->desc = *desc;
823  wined3d_swapchain_apply_sample_count_override(swapchain, swapchain->desc.backbuffer_format,
824  &swapchain->desc.multisample_type, &swapchain->desc.multisample_quality);
826 
827  TRACE("Creating front buffer.\n");
828 
829  texture_desc.resource_type = WINED3D_RTYPE_TEXTURE_2D;
830  texture_desc.format = swapchain->desc.backbuffer_format;
831  texture_desc.multisample_type = swapchain->desc.multisample_type;
832  texture_desc.multisample_quality = swapchain->desc.multisample_quality;
833  texture_desc.usage = 0;
834  texture_desc.access = WINED3D_RESOURCE_ACCESS_GPU;
835  texture_desc.width = swapchain->desc.backbuffer_width;
836  texture_desc.height = swapchain->desc.backbuffer_height;
837  texture_desc.depth = 1;
838  texture_desc.size = 0;
839 
840  if (swapchain->desc.flags & WINED3D_SWAPCHAIN_GDI_COMPATIBLE)
841  texture_flags |= WINED3D_TEXTURE_CREATE_GET_DC;
842 
843  if (FAILED(hr = device->device_parent->ops->create_swapchain_texture(device->device_parent,
844  parent, &texture_desc, texture_flags, &swapchain->front_buffer)))
845  {
846  WARN("Failed to create front buffer, hr %#x.\n", hr);
847  goto err;
848  }
849 
850  wined3d_texture_set_swapchain(swapchain->front_buffer, swapchain);
851  if (!(device->wined3d->flags & WINED3D_NO3D))
852  {
855  }
856 
857  /* MSDN says we're only allowed a single fullscreen swapchain per device,
858  * so we should really check to see if there is a fullscreen swapchain
859  * already. Does a single head count as full screen? */
860  if (!desc->windowed)
861  {
863  {
864  /* Change the display settings */
865  swapchain->d3d_mode.width = desc->backbuffer_width;
866  swapchain->d3d_mode.height = desc->backbuffer_height;
867  swapchain->d3d_mode.format_id = desc->backbuffer_format;
868  swapchain->d3d_mode.refresh_rate = desc->refresh_rate;
869  swapchain->d3d_mode.scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN;
870 
872  adapter->ordinal, &swapchain->d3d_mode)))
873  {
874  WARN("Failed to set display mode, hr %#x.\n", hr);
875  goto err;
876  }
877  displaymode_set = TRUE;
878  }
879  else
880  {
881  swapchain->d3d_mode = swapchain->original_mode;
882  }
883  }
884 
885  if (!(device->wined3d->flags & WINED3D_NO3D))
886  {
887  if (!(swapchain->context = heap_alloc(sizeof(*swapchain->context))))
888  {
889  ERR("Failed to create the context array.\n");
890  hr = E_OUTOFMEMORY;
891  goto err;
892  }
893 
895  device->cs->ops->finish(device->cs, WINED3D_CS_QUEUE_DEFAULT);
896 
897  if (!swapchain->context[0])
898  {
900  goto err;
901  }
902  }
903 
904  if (swapchain->desc.backbuffer_count > 0)
905  {
906  if (!(swapchain->back_buffers = heap_calloc(swapchain->desc.backbuffer_count,
907  sizeof(*swapchain->back_buffers))))
908  {
909  ERR("Failed to allocate backbuffer array memory.\n");
910  hr = E_OUTOFMEMORY;
911  goto err;
912  }
913 
914  texture_desc.usage = swapchain->desc.backbuffer_usage;
915  for (i = 0; i < swapchain->desc.backbuffer_count; ++i)
916  {
917  TRACE("Creating back buffer %u.\n", i);
918  if (FAILED(hr = device->device_parent->ops->create_swapchain_texture(device->device_parent,
919  parent, &texture_desc, texture_flags, &swapchain->back_buffers[i])))
920  {
921  WARN("Failed to create back buffer %u, hr %#x.\n", i, hr);
922  swapchain->desc.backbuffer_count = i;
923  goto err;
924  }
925  wined3d_texture_set_swapchain(swapchain->back_buffers[i], swapchain);
926  }
927  }
928 
929  /* Swapchains share the depth/stencil buffer, so only create a single depthstencil surface. */
930  if (desc->enable_auto_depth_stencil && !(device->wined3d->flags & WINED3D_NO3D))
931  {
932  TRACE("Creating depth/stencil buffer.\n");
933  if (!device->auto_depth_stencil_view)
934  {
935  struct wined3d_view_desc desc;
936  struct wined3d_texture *ds;
937 
938  texture_desc.format = swapchain->desc.auto_depth_stencil_format;
939  texture_desc.usage = WINED3DUSAGE_DEPTHSTENCIL;
940 
941  if (FAILED(hr = device->device_parent->ops->create_swapchain_texture(device->device_parent,
942  device->device_parent, &texture_desc, texture_flags, &ds)))
943  {
944  WARN("Failed to create the auto depth/stencil surface, hr %#x.\n", hr);
945  goto err;
946  }
947 
948  desc.format_id = ds->resource.format->id;
949  desc.flags = 0;
950  desc.u.texture.level_idx = 0;
951  desc.u.texture.level_count = 1;
952  desc.u.texture.layer_idx = 0;
953  desc.u.texture.layer_count = 1;
955  &device->auto_depth_stencil_view);
957  if (FAILED(hr))
958  {
959  ERR("Failed to create rendertarget view, hr %#x.\n", hr);
960  goto err;
961  }
962  }
963  }
964 
966 
967  return WINED3D_OK;
968 
969 err:
970  if (displaymode_set)
971  {
973  adapter->ordinal, &swapchain->original_mode)))
974  ERR("Failed to restore display mode.\n");
975  ClipCursor(NULL);
976  }
977 
978  if (swapchain->back_buffers)
979  {
980  for (i = 0; i < swapchain->desc.backbuffer_count; ++i)
981  {
982  if (swapchain->back_buffers[i])
983  {
985  wined3d_texture_decref(swapchain->back_buffers[i]);
986  }
987  }
988  heap_free(swapchain->back_buffers);
989  }
990 
992  swapchain->device->cs->ops->finish(device->cs, WINED3D_CS_QUEUE_DEFAULT);
993 
994  if (swapchain->front_buffer)
995  {
997  wined3d_texture_decref(swapchain->front_buffer);
998  }
999 
1000  return hr;
1001 }
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:598
struct wined3d_texture * front_buffer
#define TRUE
Definition: types.h:120
HRESULT CDECL wined3d_get_adapter_display_mode(const struct wined3d *wined3d, UINT adapter_idx, struct wined3d_display_mode *mode, enum wined3d_display_rotation *rotation)
Definition: directx.c:4764
HRESULT CDECL wined3d_set_adapter_display_mode(struct wined3d *wined3d, UINT adapter_idx, const struct wined3d_display_mode *mode)
Definition: directx.c:4837
HRESULT hr
Definition: shlfolder.c:183
BOOL WINAPI ClipCursor(_In_opt_ LPCRECT)
struct wined3d_swapchain * swapchain
void swapchain_set_max_frame_latency(struct wined3d_swapchain *swapchain, const struct wined3d_device *device)
Definition: swapchain.c:747
#define WARN(fmt,...)
Definition: debug.h:111
#define ds
Definition: i386-dis.c:434
static void wined3d_swapchain_apply_sample_count_override(const struct wined3d_swapchain *swapchain, enum wined3d_format_id format_id, enum wined3d_multisample_type *type, DWORD *quality)
Definition: swapchain.c:658
void wined3d_cs_init_object(struct wined3d_cs *cs, void(*callback)(void *object), void *object)
Definition: cs.c:1912
#define WINED3DUSAGE_DEPTHSTENCIL
Definition: wined3d.h:909
void wined3d_cs_destroy_object(struct wined3d_cs *cs, void(*callback)(void *object), void *object)
Definition: cs.c:1907
#define WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH
Definition: wined3d.h:892
static const struct wined3d_swapchain_ops swapchain_gl_ops
Definition: swapchain.c:541
static void * heap_calloc(SIZE_T count, SIZE_T size)
Definition: heap.h:49
struct wined3d_texture ** back_buffers
LONG right
Definition: windef.h:293
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define WINED3D_TEXTURE_CREATE_GET_DC
Definition: wined3d.h:1561
void wined3d_texture_set_swapchain(struct wined3d_texture *texture, struct wined3d_swapchain *swapchain)
Definition: texture.c:918
const struct wined3d_parent_ops * parent_ops
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
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define WINED3D_SWAPCHAIN_GDI_COMPATIBLE
Definition: wined3d.h:895
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: devices.h:37
#define FIXME(fmt,...)
Definition: debug.h:110
struct wined3d_swapchain_desc desc
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
smooth NULL
Definition: ftsmooth.c:416
#define WINED3D_LOCATION_DRAWABLE
#define TRACE(s)
Definition: solgame.cpp:4
void wined3d_texture_validate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location)
Definition: texture.c:286
r parent
Definition: btrfs.c:2677
struct wined3d_context ** context
LONG HRESULT
Definition: typedefs.h:77
const char * wine_dbgstr_rect(const RECT *rect)
#define WINED3D_OK
Definition: wined3d.h:37
unsigned long DWORD
Definition: ntddk_ex.h:95
#define err(...)
static IHTMLWindow2 * window
Definition: events.c:77
#define WINED3D_RESOURCE_ACCESS_GPU
Definition: wined3d.h:55
#define ERR(fmt,...)
Definition: debug.h:109
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
struct wined3d_display_mode original_mode d3d_mode
static const struct wined3d_swapchain_ops swapchain_gdi_ops
Definition: swapchain.c:636
const struct wined3d_parent_ops wined3d_null_parent_ops
Definition: directx.c:6781
void wined3d_texture_invalidate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location)
Definition: texture.c:310
#define WINED3DERR_NOTAVAILABLE
Definition: wined3d.h:46
static void wined3d_swapchain_destroy_object(void *object)
Definition: swapchain.c:34
LONG bottom
Definition: windef.h:294
ULONG CDECL wined3d_texture_decref(struct wined3d_texture *texture)
Definition: texture.c:1219
static void wined3d_swapchain_cs_init(void *object)
Definition: swapchain.c:705
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
unsigned int swap_interval
#define WINED3D_NO3D
Definition: wined3d.h:1318
const struct wined3d_swapchain_ops * swapchain_ops
const char * debug_d3dformat(enum wined3d_format_id format_id)
Definition: utils.c:3922
static void swapchain_update_render_to_fbo(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:642
struct wined3d_device * device
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
HRESULT CDECL wined3d_swapchain_get_gamma_ramp(const struct wined3d_swapchain *swapchain, struct wined3d_gamma_ramp *ramp)
Definition: swapchain.c:298

Referenced by wined3d_swapchain_create().

◆ swapchain_set_max_frame_latency()

void swapchain_set_max_frame_latency ( struct wined3d_swapchain swapchain,
const struct wined3d_device device 
)

Definition at line 747 of file swapchain.c.

748 {
749  /* Subtract 1 for the implicit OpenGL latency. */
750  swapchain->max_frame_latency = device->max_frame_latency >= 2 ? device->max_frame_latency - 1 : 1;
751 }
struct wined3d_swapchain * swapchain
Definition: devices.h:37

Referenced by swapchain_init(), and wined3d_device_set_max_frame_latency().

◆ swapchain_update_draw_bindings()

void swapchain_update_draw_bindings ( struct wined3d_swapchain swapchain)

Definition at line 1112 of file swapchain.c.

1113 {
1114  UINT i;
1115 
1116  wined3d_resource_update_draw_binding(&swapchain->front_buffer->resource);
1117 
1118  for (i = 0; i < swapchain->desc.backbuffer_count; ++i)
1119  {
1120  wined3d_resource_update_draw_binding(&swapchain->back_buffers[i]->resource);
1121  }
1122 }
struct wined3d_swapchain * swapchain
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
void wined3d_resource_update_draw_binding(struct wined3d_resource *resource)
Definition: resource.c:561
unsigned int UINT
Definition: ndis.h:50

Referenced by context_validate_onscreen_formats(), swapchain_gl_present(), and wined3d_swapchain_resize_buffers().

◆ swapchain_update_render_to_fbo()

static void swapchain_update_render_to_fbo ( struct wined3d_swapchain swapchain)
static

Definition at line 642 of file swapchain.c.

643 {
645  return;
646 
647  if (!swapchain->desc.backbuffer_count)
648  {
649  TRACE("Single buffered rendering.\n");
650  swapchain->render_to_fbo = FALSE;
651  return;
652  }
653 
654  TRACE("Rendering to FBO.\n");
655  swapchain->render_to_fbo = TRUE;
656 }
#define ORM_FBO
#define TRUE
Definition: types.h:120
struct wined3d_swapchain * swapchain
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by swapchain_init(), and wined3d_swapchain_resize_buffers().

◆ WINE_DECLARE_DEBUG_CHANNEL()

WINE_DECLARE_DEBUG_CHANNEL ( fps  )

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3d  )

◆ wined3d_swapchain_activate()

void wined3d_swapchain_activate ( struct wined3d_swapchain swapchain,
BOOL  activate 
)

Definition at line 1124 of file swapchain.c.

1125 {
1126  struct wined3d_device *device = swapchain->device;
1127  BOOL filter_messages = device->filter_messages;
1128 
1129  /* This code is not protected by the wined3d mutex, so it may run while
1130  * wined3d_device_reset is active. Testing on Windows shows that changing
1131  * focus during resets and resetting during focus change events causes
1132  * the application to crash with an invalid memory access. */
1133 
1134  device->filter_messages = !(device->wined3d->flags & WINED3D_FOCUS_MESSAGES);
1135 
1136  if (activate)
1137  {
1138  if (!(device->create_parms.flags & WINED3DCREATE_NOWINDOWCHANGES))
1139  {
1140  /* The d3d versions do not agree on the exact messages here. D3d8 restores
1141  * the window but leaves the size untouched, d3d9 sets the size on an
1142  * invisible window, generates messages but doesn't change the window
1143  * properties. The implementation follows d3d9.
1144  *
1145  * Guild Wars 1 wants a WINDOWPOSCHANGED message on the device window to
1146  * resume drawing after a focus loss. */
1147  SetWindowPos(swapchain->device_window, NULL, 0, 0,
1148  swapchain->desc.backbuffer_width, swapchain->desc.backbuffer_height,
1150  }
1151 
1152  if (device->wined3d->flags & WINED3D_RESTORE_MODE_ON_ACTIVATE)
1153  {
1155  device->adapter->ordinal, &swapchain->d3d_mode)))
1156  ERR("Failed to set display mode.\n");
1157  }
1158  }
1159  else
1160  {
1162  device->adapter->ordinal, NULL)))
1163  ERR("Failed to set display mode.\n");
1164 
1165  swapchain->reapply_mode = TRUE;
1166 
1167  if (!(device->create_parms.flags & WINED3DCREATE_NOWINDOWCHANGES)
1168  && IsWindowVisible(swapchain->device_window))
1169  ShowWindow(swapchain->device_window, SW_MINIMIZE);
1170  }
1171 
1172  device->filter_messages = filter_messages;
1173 }
#define TRUE
Definition: types.h:120
#define WINED3D_RESTORE_MODE_ON_ACTIVATE
Definition: wined3d.h:1321
#define WINED3DCREATE_NOWINDOWCHANGES
Definition: wined3d.h:1019
HRESULT CDECL wined3d_set_adapter_display_mode(struct wined3d *wined3d, UINT adapter_idx, const struct wined3d_display_mode *mode)
Definition: directx.c:4837
#define SWP_NOZORDER
Definition: winuser.h:1232
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: devices.h:37
struct wined3d_swapchain_desc desc
smooth NULL
Definition: ftsmooth.c:416
#define SWP_NOACTIVATE
Definition: winuser.h:1227
#define SW_MINIMIZE
Definition: winuser.h:770
#define WINED3D_FOCUS_MESSAGES
Definition: wined3d.h:1322
#define ERR(fmt,...)
Definition: debug.h:109
struct wined3d_display_mode original_mode d3d_mode
BOOL WINAPI IsWindowVisible(_In_ HWND)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
struct wined3d_device * device

Referenced by device_process_message().

◆ wined3d_swapchain_apply_sample_count_override()

static void wined3d_swapchain_apply_sample_count_override ( const struct wined3d_swapchain swapchain,
enum wined3d_format_id  format_id,
enum wined3d_multisample_type type,
DWORD quality 
)
static

Definition at line 658 of file swapchain.c.

660 {
661  const struct wined3d_gl_info *gl_info;
662  const struct wined3d_format *format;
664 
666  return;
667 
668  gl_info = &swapchain->device->adapter->gl_info;
670  return;
671 
672  if ((t = min(wined3d_settings.sample_count, gl_info->limits.samples)))
673  while (!(format->multisample_types & 1u << (t - 1)))
674  ++t;
675  TRACE("Using sample count %u.\n", t);
676  *type = t;
677  *quality = 0;
678 }
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 sample_count
GLdouble GLdouble t
Definition: gl.h:2047
const struct wined3d_format * wined3d_get_format(const struct wined3d_gl_info *gl_info, enum wined3d_format_id format_id, unsigned int resource_usage)
Definition: utils.c:3773
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define TRACE(s)
Definition: solgame.cpp:4
#define WINED3DUSAGE_RENDERTARGET
Definition: wined3d.h:908
int quality
Definition: jpeglib.h:991
wined3d_multisample_type
Definition: wined3d.h:561
#define min(a, b)
Definition: monoChain.cc:55
static UINT format_id
Definition: clipboard.c:1343
struct wined3d_device * device
struct wined3d_gl_limits limits

Referenced by swapchain_init(), and wined3d_swapchain_resize_buffers().

◆ wined3d_swapchain_create()

HRESULT CDECL wined3d_swapchain_create ( struct wined3d_device device,
struct wined3d_swapchain_desc desc,
void parent,
const struct wined3d_parent_ops parent_ops,
struct wined3d_swapchain **  swapchain 
)

Definition at line 1003 of file swapchain.c.

1005 {
1006  struct wined3d_swapchain *object;
1007  HRESULT hr;
1008 
1009  TRACE("device %p, desc %p, parent %p, parent_ops %p, swapchain %p.\n",
1010  device, desc, parent, parent_ops, swapchain);
1011 
1012  if (!(object = heap_alloc_zero(sizeof(*object))))
1013  return E_OUTOFMEMORY;
1014 
1015  hr = swapchain_init(object, device, desc, parent, parent_ops);
1016  if (FAILED(hr))
1017  {
1018  WARN("Failed to initialize swapchain, hr %#x.\n", hr);
1019  heap_free(object);
1020  return hr;
1021  }
1022 
1023  TRACE("Created swapchain %p.\n", object);
1024  *swapchain = object;
1025 
1026  return WINED3D_OK;
1027 }
HRESULT hr
Definition: shlfolder.c:183
#define WARN(fmt,...)
Definition: debug.h:111
const struct wined3d_parent_ops * parent_ops
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
Definition: devices.h:37
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
#define TRACE(s)
Definition: solgame.cpp:4
r parent
Definition: btrfs.c:2677
LONG HRESULT
Definition: typedefs.h:77
#define WINED3D_OK
Definition: wined3d.h:37
static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3d_device *device, struct wined3d_swapchain_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops)
Definition: swapchain.c:753
void * object
Definition: jmemsys.h:48
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by device_parent_create_swapchain(), and swapchain_init().

◆ wined3d_swapchain_cs_init()

static void wined3d_swapchain_cs_init ( void object)
static

Definition at line 705 of file swapchain.c.

706 {
707  struct wined3d_swapchain *swapchain = object;
708  const struct wined3d_gl_info *gl_info;
709  unsigned int i;
710 
711  static const enum wined3d_format_id formats[] =
712  {
718  };
719 
720  gl_info = &swapchain->device->adapter->gl_info;
721 
722  /* Without ORM_FBO, switching the depth/stencil format is hard. Always
723  * request a depth/stencil buffer in the likely case it's needed later. */
724  for (i = 0; i < ARRAY_SIZE(formats); ++i)
725  {
727  if ((swapchain->context[0] = context_create(swapchain, swapchain->front_buffer, swapchain->ds_format)))
728  break;
729  TRACE("Depth stencil format %s is not supported, trying next format.\n", debug_d3dformat(formats[i]));
730  }
731 
732  if (!swapchain->context[0])
733  {
734  WARN("Failed to create context.\n");
735  return;
736  }
737  swapchain->num_contexts = 1;
738 
740  && (!swapchain->desc.enable_auto_depth_stencil
741  || swapchain->desc.auto_depth_stencil_format != swapchain->ds_format->id))
742  FIXME("Add OpenGL context recreation support.\n");
743 
744  context_release(swapchain->context[0]);
745 }
#define ORM_FBO
struct wined3d_texture * front_buffer
const struct wined3d_format * ds_format
#define WARN(fmt,...)
Definition: debug.h:111
static const struct pixel_format_desc formats[]
Definition: util.c:57
const struct wined3d_format * wined3d_get_format(const struct wined3d_gl_info *gl_info, enum wined3d_format_id format_id, unsigned int resource_usage)
Definition: utils.c:3773
#define WINED3DUSAGE_DEPTHSTENCIL
Definition: wined3d.h:909
struct wined3d_context * context_create(struct wined3d_swapchain *swapchain, struct wined3d_texture *target, const struct wined3d_format *ds_format)
Definition: context.c:1887
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
unsigned int num_contexts
#define FIXME(fmt,...)
Definition: debug.h:110
struct wined3d_swapchain_desc desc
void context_release(struct wined3d_context *context)
Definition: context.c:1559
#define TRACE(s)
Definition: solgame.cpp:4
struct wined3d_context ** context
wined3d_format_id
Definition: wined3d.h:105
#define ARRAY_SIZE(a)
Definition: main.h:24
const char * debug_d3dformat(enum wined3d_format_id format_id)
Definition: utils.c:3922
struct wined3d_device * device
void * object
Definition: jmemsys.h:48

Referenced by swapchain_init().

◆ wined3d_swapchain_decref()

ULONG CDECL wined3d_swapchain_decref ( struct wined3d_swapchain swapchain)

Definition at line 113 of file swapchain.c.

114 {
115  ULONG refcount = InterlockedDecrement(&swapchain->ref);
116 
117  TRACE("%p decreasing refcount to %u.\n", swapchain, refcount);
118 
119  if (!refcount)
120  {
121  struct wined3d_device *device = swapchain->device;
122 
123  device->cs->ops->finish(device->cs, WINED3D_CS_QUEUE_DEFAULT);
124 
125  swapchain_cleanup(swapchain);
126  swapchain->parent_ops->wined3d_object_destroyed(swapchain->parent);
127  heap_free(swapchain);
128  }
129 
130  return refcount;
131 }
static void swapchain_cleanup(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:39
const struct wined3d_parent_ops * parent_ops
Definition: devices.h:37
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedDecrement
Definition: armddk.h:52
unsigned int ULONG
Definition: retypes.h:1
struct wined3d_device * device
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by d3d8_swapchain_Release(), d3d9_swapchain_Release(), ddraw_destroy_swapchain(), wined3d_device_init_3d(), wined3d_device_init_gdi(), wined3d_device_uninit_3d(), wined3d_device_uninit_gdi(), and wined3d_texture_decref().

◆ wined3d_swapchain_destroy_object()

static void wined3d_swapchain_destroy_object ( void object)
static

Definition at line 34 of file swapchain.c.

35 {
37 }
void swapchain_destroy_contexts(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:1059

Referenced by swapchain_cleanup(), and swapchain_init().

◆ wined3d_swapchain_get_back_buffer()

struct wined3d_texture* CDECL wined3d_swapchain_get_back_buffer ( const struct wined3d_swapchain swapchain,
UINT  back_buffer_idx 
)

Definition at line 211 of file swapchain.c.

213 {
214  TRACE("swapchain %p, back_buffer_idx %u.\n",
215  swapchain, back_buffer_idx);
216 
217  /* Return invalid if there is no backbuffer array, otherwise it will
218  * crash when ddraw is used (there swapchain->back_buffers is always
219  * NULL). We need this because this function is called from
220  * stateblock_init_default_state() to get the default scissorrect
221  * dimensions. */
222  if (!swapchain->back_buffers || back_buffer_idx >= swapchain->desc.backbuffer_count)
223  {
224  WARN("Invalid back buffer index.\n");
225  /* Native d3d9 doesn't set NULL here, just as wine's d3d9. But set it
226  * here in wined3d to avoid problems in other libs. */
227  return NULL;
228  }
229 
230  TRACE("Returning back buffer %p.\n", swapchain->back_buffers[back_buffer_idx]);
231 
232  return swapchain->back_buffers[back_buffer_idx];
233 }
#define WARN(fmt,...)
Definition: debug.h:111
struct wined3d_texture ** back_buffers
struct wined3d_swapchain_desc desc
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by d3d8_device_GetBackBuffer(), d3d8_swapchain_GetBackBuffer(), d3d9_swapchain_GetBackBuffer(), and ddraw_surface_update_frontbuffer().

◆ wined3d_swapchain_get_desc()

void CDECL wined3d_swapchain_get_desc ( const struct wined3d_swapchain swapchain,
struct wined3d_swapchain_desc desc 
)

Definition at line 267 of file swapchain.c.

269 {
270  TRACE("swapchain %p, desc %p.\n", swapchain, desc);
271 
272  *desc = swapchain->desc;
273 }
struct wined3d_swapchain_desc desc
const struct builtin_class_descr * desc
Definition: regcontrol.c:48
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by d3d8_device_CreateAdditionalSwapChain(), d3d9_device_CheckDeviceState(), d3d9_device_CreateAdditionalSwapChain(), d3d9_device_reset(), d3d9_swapchain_GetPresentParameters(), and ddraw_surface_create().

◆ wined3d_swapchain_get_device()

struct wined3d_device* CDECL wined3d_swapchain_get_device ( const struct wined3d_swapchain swapchain)

Definition at line 260 of file swapchain.c.

261 {
262  TRACE("swapchain %p.\n", swapchain);
263 
264  return swapchain->device;
265 }
#define TRACE(s)
Definition: solgame.cpp:4
struct wined3d_device * device

◆ wined3d_swapchain_get_display_mode()

HRESULT CDECL wined3d_swapchain_get_display_mode ( const struct wined3d_swapchain swapchain,
struct wined3d_display_mode mode,
enum wined3d_display_rotation rotation 
)

Definition at line 244 of file swapchain.c.

246 {
247  HRESULT hr;
248 
249  TRACE("swapchain %p, mode %p, rotation %p.\n", swapchain, mode, rotation);
250 
251  hr = wined3d_get_adapter_display_mode(swapchain->device->wined3d,
252  swapchain->device->adapter->ordinal, mode, rotation);
253 
254  TRACE("Returning w %u, h %u, refresh rate %u, format %s.\n",
255  mode->width, mode->height, mode->refresh_rate, debug_d3dformat(mode->format_id));
256 
257  return hr;
258 }
HRESULT CDECL wined3d_get_adapter_display_mode(const struct wined3d *wined3d, UINT adapter_idx, struct wined3d_display_mode *mode, enum wined3d_display_rotation *rotation)
Definition: directx.c:4764
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
GLenum mode
Definition: glext.h:6217
const char * debug_d3dformat(enum wined3d_format_id format_id)
Definition: utils.c:3922
struct wined3d_device * device

Referenced by d3d9_swapchain_GetDisplayMode(), d3d9_swapchain_GetDisplayModeEx(), ddraw_surface7_Restore(), and wined3d_device_get_display_mode().

◆ wined3d_swapchain_get_front_buffer_data()

HRESULT CDECL wined3d_swapchain_get_front_buffer_data ( const struct wined3d_swapchain swapchain,
struct wined3d_texture dst_texture,
unsigned int  sub_resource_idx 
)

Definition at line 190 of file swapchain.c.

192 {
193  RECT src_rect, dst_rect;
194 
195  TRACE("swapchain %p, dst_texture %p, sub_resource_idx %u.\n", swapchain, dst_texture, sub_resource_idx);
196 
197  SetRect(&src_rect, 0, 0, swapchain->front_buffer->resource.width, swapchain->front_buffer->resource.height);
198  dst_rect = src_rect;
199 
200  if (swapchain->desc.windowed)
201  {
202  MapWindowPoints(swapchain->win_handle, NULL, (POINT *)&dst_rect, 2);
203  FIXME("Using destination rect %s in windowed mode, this is likely wrong.\n",
204  wine_dbgstr_rect(&dst_rect));
205  }
206 
207  return wined3d_texture_blt(dst_texture, sub_resource_idx, &dst_rect,
208  swapchain->front_buffer, 0, &src_rect, 0, NULL, WINED3D_TEXF_POINT);
209 }
struct wined3d_texture * front_buffer
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define FIXME(fmt,...)
Definition: debug.h:110
struct wined3d_swapchain_desc desc
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT CDECL wined3d_texture_blt(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, DWORD flags, const struct wined3d_blt_fx *fx, enum wined3d_texture_filter_type filter)
Definition: texture.c:3087
const char * wine_dbgstr_rect(const RECT *rect)
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)

Referenced by d3d8_device_GetFrontBuffer(), d3d9_device_GetFrontBufferData(), and d3d9_swapchain_GetFrontBufferData().

◆ wined3d_swapchain_get_gamma_ramp()

HRESULT CDECL wined3d_swapchain_get_gamma_ramp ( const struct wined3d_swapchain swapchain,
struct wined3d_gamma_ramp ramp 
)

Definition at line 298 of file swapchain.c.

300 {
301  HDC dc;
302 
303  TRACE("swapchain %p, ramp %p.\n", swapchain, ramp);
304 
305  dc = GetDCEx(swapchain->device_window, 0, DCX_USESTYLE | DCX_CACHE);
307  ReleaseDC(swapchain->device_window, dc);
308 
309  return WINED3D_OK;
310 }
HDC WINAPI GetDCEx(_In_opt_ HWND, _In_opt_ HRGN, _In_ DWORD)
static HDC
Definition: imagelist.c:92
#define DCX_USESTYLE
Definition: GetDCEx.c:10
HDC dc
Definition: cylfrac.c:34
static const BYTE ramp[17]
Definition: dib.c:2709
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define TRACE(s)
Definition: solgame.cpp:4
#define WINED3D_OK
Definition: wined3d.h:37
BOOL WINAPI GetDeviceGammaRamp(_In_ HDC hdc, _Out_writes_bytes_(3 *256 *2) LPVOID lpRamp)
#define DCX_CACHE
Definition: winuser.h:2075

Referenced by swapchain_init(), and wined3d_device_get_gamma_ramp().

◆ wined3d_swapchain_get_parent()

void* CDECL wined3d_swapchain_get_parent ( const struct wined3d_swapchain swapchain)

Definition at line 133 of file swapchain.c.

134 {
135  TRACE("swapchain %p.\n", swapchain);
136 
137  return swapchain->parent;
138 }
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by d3d9_device_get_swapchains(), and device_init().

◆ wined3d_swapchain_get_raster_status()

HRESULT CDECL wined3d_swapchain_get_raster_status ( const struct wined3d_swapchain swapchain,
struct wined3d_raster_status raster_status 
)

Definition at line 235 of file swapchain.c.

237 {
238  TRACE("swapchain %p, raster_status %p.\n", swapchain, raster_status);
239 
240  return wined3d_get_adapter_raster_status(swapchain->device->wined3d,
241  swapchain->device->adapter->ordinal, raster_status);
242 }
#define TRACE(s)
Definition: solgame.cpp:4
HRESULT CDECL wined3d_get_adapter_raster_status(const struct wined3d *wined3d, UINT adapter_idx, struct wined3d_raster_status *raster_status)
Definition: directx.c:4991
struct wined3d_device * device

Referenced by d3d9_swapchain_GetRasterStatus(), and wined3d_device_get_raster_status().

◆ wined3d_swapchain_incref()

ULONG CDECL wined3d_swapchain_incref ( struct wined3d_swapchain swapchain)

Definition at line 104 of file swapchain.c.

105 {
106  ULONG refcount = InterlockedIncrement(&swapchain->ref);
107 
108  TRACE("%p increasing refcount to %u.\n", swapchain, refcount);
109 
110  return refcount;
111 }
#define TRACE(s)
Definition: solgame.cpp:4
#define InterlockedIncrement
Definition: armddk.h:53
unsigned int ULONG
Definition: retypes.h:1

Referenced by d3d8_swapchain_AddRef(), d3d9_swapchain_AddRef(), ddraw_create_swapchain(), device_parent_create_swapchain(), and wined3d_texture_incref().

◆ wined3d_swapchain_present()

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,
DWORD  flags 
)

Definition at line 152 of file swapchain.c.

155 {
156  RECT s, d;
157 
158  TRACE("swapchain %p, src_rect %s, dst_rect %s, dst_window_override %p, flags %#x.\n",
159  swapchain, wine_dbgstr_rect(src_rect), wine_dbgstr_rect(dst_rect),
160  dst_window_override, flags);
161 
162  if (flags)
163  FIXME("Ignoring flags %#x.\n", flags);
164 
165  if (!swapchain->back_buffers)
166  {
167  WARN("Swapchain doesn't have a backbuffer, returning WINED3DERR_INVALIDCALL.\n");
168  return WINED3DERR_INVALIDCALL;
169  }
170 
171  if (!src_rect)
172  {
173  SetRect(&s, 0, 0, swapchain->desc.backbuffer_width,
174  swapchain->desc.backbuffer_height);
175  src_rect = &s;
176  }
177 
178  if (!dst_rect)
179  {
180  GetClientRect(swapchain->win_handle, &d);
181  dst_rect = &d;
182  }
183 
184  wined3d_cs_emit_present(swapchain->device->cs, swapchain, src_rect,
185  dst_rect, dst_window_override, swap_interval, flags);
186 
187  return WINED3D_OK;
188 }
#define WINED3DERR_INVALIDCALL
Definition: wined3d.h:48
#define WARN(fmt,...)
Definition: debug.h:111
struct wined3d_texture ** back_buffers
#define FIXME(fmt,...)
Definition: debug.h:110
struct wined3d_swapchain_desc desc
#define TRACE(s)
Definition: solgame.cpp:4
#define d
Definition: ke_i.h:81
const char * wine_dbgstr_rect(const RECT *rect)
#define WINED3D_OK
Definition: wined3d.h:37
GLbitfield flags
Definition: glext.h:7161
GLdouble s
Definition: gl.h:2039
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
struct wined3d_device * device
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, DWORD flags)
Definition: cs.c:472

Referenced by d3d8_swapchain_Present(), d3d9_device_Present(), d3d9_device_PresentEx(), d3d9_swapchain_Present(), ddraw_surface_update_frontbuffer(), and texture2d_blt().

◆ wined3d_swapchain_resize_buffers()

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 at line 1175 of file swapchain.c.

1178 {
1179  struct wined3d_device *device = swapchain->device;
1180  BOOL update_desc = FALSE;
1181 
1182  TRACE("swapchain %p, buffer_count %u, width %u, height %u, format %s, "
1183  "multisample_type %#x, multisample_quality %#x.\n",
1184  swapchain, buffer_count, width, height, debug_d3dformat(format_id),
1185  multisample_type, multisample_quality);
1186 
1187  wined3d_swapchain_apply_sample_count_override(swapchain, format_id, &multisample_type, &multisample_quality);
1188 
1189  if (buffer_count && buffer_count != swapchain->desc.backbuffer_count)
1190  FIXME("Cannot change the back buffer count yet.\n");
1191 
1192  device->cs->ops->finish(device->cs, WINED3D_CS_QUEUE_DEFAULT);
1193 
1194  if (!width || !height)
1195  {
1196  /* The application is requesting that either the swapchain width or
1197  * height be set to the corresponding dimension in the window's
1198  * client rect. */
1199 
1200  RECT client_rect;
1201 
1202  if (!swapchain->desc.windowed)
1203  return WINED3DERR_INVALIDCALL;
1204 
1205  if (!GetClientRect(swapchain->device_window, &client_rect))
1206  {
1207  ERR("Failed to get client rect, last error %#x.\n", GetLastError());
1208  return WINED3DERR_INVALIDCALL;
1209  }
1210 
1211  if (!width)
1212  width = client_rect.right;
1213 
1214  if (!height)
1215  height = client_rect.bottom;
1216  }
1217 
1218  if (width != swapchain->desc.backbuffer_width
1219  || height != swapchain->desc.backbuffer_height)
1220  {
1221  swapchain->desc.backbuffer_width = width;
1222  swapchain->desc.backbuffer_height = height;
1223  update_desc = TRUE;
1224  }
1225 
1227  {
1228  if (!swapchain->desc.windowed)
1229  return WINED3DERR_INVALIDCALL;
1230  format_id = swapchain->original_mode.format_id;
1231  }
1232 
1233  if (format_id != swapchain->desc.backbuffer_format)
1234  {
1235  swapchain->desc.backbuffer_format = format_id;
1236  update_desc = TRUE;
1237  }
1238 
1239  if (multisample_type != swapchain->desc.multisample_type
1240  || multisample_quality != swapchain->desc.multisample_quality)
1241  {
1242  swapchain->desc.multisample_type = multisample_type;
1243  swapchain->desc.multisample_quality = multisample_quality;
1244  update_desc = TRUE;
1245  }
1246 
1247  if (update_desc)
1248  {
1249  HRESULT hr;
1250  UINT i;
1251 
1252  if (FAILED(hr = wined3d_texture_update_desc(swapchain->front_buffer, swapchain->desc.backbuffer_width,
1253  swapchain->desc.backbuffer_height, swapchain->desc.backbuffer_format,
1254  swapchain->desc.multisample_type, swapchain->desc.multisample_quality, NULL, 0)))
1255  return hr;
1256 
1257  for (i = 0; i < swapchain->desc.backbuffer_count; ++i)
1258  {
1259  if (FAILED(hr = wined3d_texture_update_desc(swapchain->back_buffers[i], swapchain->desc.backbuffer_width,
1260  swapchain->desc.backbuffer_height, swapchain->desc.backbuffer_format,
1261  swapchain->desc.multisample_type, swapchain->desc.multisample_quality, NULL, 0)))
1262  return hr;
1263  }
1264  }
1265 
1266  swapchain_update_render_to_fbo(swapchain);
1267  swapchain_update_draw_bindings(swapchain);
1268 
1269  return WINED3D_OK;
1270 }
#define WINED3DERR_INVALIDCALL
Definition: wined3d.h:48
struct wined3d_texture * front_buffer
GLint GLint GLsizei width
Definition: gl.h:1546
#define TRUE
Definition: types.h:120
HRESULT hr
Definition: shlfolder.c:183
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static void wined3d_swapchain_apply_sample_count_override(const struct wined3d_swapchain *swapchain, enum wined3d_format_id format_id, enum wined3d_multisample_type *type, DWORD *quality)
Definition: swapchain.c:658
struct wined3d_texture ** back_buffers
LONG right
Definition: windef.h:293
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
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: devices.h:37
#define FIXME(fmt,...)
Definition: debug.h:110
struct wined3d_swapchain_desc desc
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#define WINED3D_OK
Definition: wined3d.h:37
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define ERR(fmt,...)
Definition: debug.h:109
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
unsigned int UINT
Definition: ndis.h:50
LONG bottom
Definition: windef.h:294
static UINT format_id
Definition: clipboard.c:1343
void swapchain_update_draw_bindings(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:1112
HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT width, UINT height, enum wined3d_format_id format_id, enum wined3d_multisample_type multisample_type, UINT multisample_quality, void *mem, UINT pitch)
Definition: texture.c:1534
const char * debug_d3dformat(enum wined3d_format_id format_id)
Definition: utils.c:3922
static void swapchain_update_render_to_fbo(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:642
struct wined3d_device * device

Referenced by ddraw7_SetDisplayMode(), and wined3d_device_reset().

◆ wined3d_swapchain_resize_target()

HRESULT CDECL wined3d_swapchain_resize_target ( struct wined3d_swapchain swapchain,
const struct wined3d_display_mode mode 
)

Definition at line 1297 of file swapchain.c.

1299 {
1300  struct wined3d_device *device = swapchain->device;
1301  struct wined3d_display_mode actual_mode;
1302  RECT original_window_rect, window_rect;
1303  HRESULT hr;
1304 
1305  TRACE("swapchain %p, mode %p.\n", swapchain, mode);
1306 
1307  if (swapchain->desc.windowed)
1308  {
1309  SetRect(&window_rect, 0, 0, mode->width, mode->height);
1310  AdjustWindowRectEx(&window_rect,
1313  SetRect(&window_rect, 0, 0,
1314  window_rect.right - window_rect.left, window_rect.bottom - window_rect.top);
1315  GetWindowRect(swapchain->device_window, &original_window_rect);
1316  OffsetRect(&window_rect, original_window_rect.left, original_window_rect.top);
1317  }
1318  else if (swapchain->desc.flags & WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH)
1319  {
1320  actual_mode = *mode;
1321  if (FAILED(hr = wined3d_swapchain_set_display_mode(swapchain, &actual_mode)))
1322  return hr;
1323  SetRect(&window_rect, 0, 0, actual_mode.width, actual_mode.height);
1324  }
1325  else
1326  {
1327  if (FAILED(hr = wined3d_get_adapter_display_mode(device->wined3d, device->adapter->ordinal,
1328  &actual_mode, NULL)))
1329  {
1330  ERR("Failed to get display mode, hr %#x.\n", hr);
1331  return WINED3DERR_INVALIDCALL;
1332  }
1333 
1334  SetRect(&window_rect, 0, 0, actual_mode.width, actual_mode.height);
1335  }
1336 
1337  MoveWindow(swapchain->device_window, window_rect.left, window_rect.top,
1338  window_rect.right - window_rect.left,
1339  window_rect.bottom - window_rect.top, TRUE);
1340 
1341  return WINED3D_OK;
1342 }
#define WINED3DERR_INVALIDCALL
Definition: wined3d.h:48
#define TRUE
Definition: types.h:120
HRESULT CDECL wined3d_get_adapter_display_mode(const struct wined3d *wined3d, UINT adapter_idx, struct wined3d_display_mode *mode, enum wined3d_display_rotation *rotation)
Definition: directx.c:4764
HRESULT hr
Definition: shlfolder.c:183
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
BOOL WINAPI AdjustWindowRectEx(_Inout_ LPRECT, _In_ DWORD, _In_ BOOL, _In_ DWORD)
#define GWL_EXSTYLE
Definition: winuser.h:845
#define WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH
Definition: wined3d.h:892
static HRESULT wined3d_swapchain_set_display_mode(struct wined3d_swapchain *swapchain, struct wined3d_display_mode *mode)
Definition: swapchain.c:1272
Definition: devices.h:37
struct wined3d_swapchain_desc desc
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
#define WINED3D_OK
Definition: wined3d.h:37
GLenum mode
Definition: glext.h:6217
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
#define ERR(fmt,...)
Definition: debug.h:109
#define GWL_STYLE
Definition: winuser.h:846
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
struct wined3d_device * device

◆ wined3d_swapchain_rotate()

static void wined3d_swapchain_rotate ( struct wined3d_swapchain swapchain,
struct wined3d_context context 
)
static

Definition at line 342 of file swapchain.c.

343 {
344  struct wined3d_texture_sub_resource *sub_resource;
345  struct wined3d_texture *texture, *texture_prev;
346  struct gl_texture tex0;
347  GLuint rb0;
348  DWORD locations0;
349  unsigned int i;
350  static const DWORD supported_locations = WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_RB_MULTISAMPLE;
351 
352  if (swapchain->desc.backbuffer_count < 2 || !swapchain->render_to_fbo)
353  return;
354 
355  texture_prev = swapchain->back_buffers[0];
356 
357  /* Back buffer 0 is already in the draw binding. */
358  tex0 = texture_prev->texture_rgb;
359  rb0 = texture_prev->rb_multisample;
360  locations0 = texture_prev->sub_resources[0].locations;
361 
362  for (i = 1; i < swapchain->desc.backbuffer_count; ++i)
363  {
364  texture = swapchain->back_buffers[i];
365  sub_resource = &texture->sub_resources[0];
366 
367  if (!(sub_resource->locations & supported_locations))
368  wined3d_texture_load_location(texture, 0, context, texture->resource.draw_binding);
369 
370  texture_prev->texture_rgb = texture->texture_rgb;
371  texture_prev->rb_multisample = texture->rb_multisample;
372 
373  wined3d_texture_validate_location(texture_prev, 0, sub_resource->locations & supported_locations);
374  wined3d_texture_invalidate_location(texture_prev, 0, ~(sub_resource->locations & supported_locations));
375 
376  texture_prev = texture;
377  }
378 
379  texture_prev->texture_rgb = tex0;
380  texture_prev->rb_multisample = rb0;
381 
382  wined3d_texture_validate_location(texture_prev, 0, locations0 & supported_locations);
383  wined3d_texture_invalidate_location(texture_prev, 0, ~(locations0 & supported_locations));
384 
386 }
Definition: http.c:6587
struct wined3d_texture ** back_buffers
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
#define WINED3D_LOCATION_RB_MULTISAMPLE
struct wined3d_swapchain_desc desc
void wined3d_texture_validate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location)
Definition: texture.c:286
GLenum GLuint texture
Definition: glext.h:6295
unsigned long DWORD
Definition: ntddk_ex.h:95
struct wined3d_texture::wined3d_texture_sub_resource sub_resources[1]
unsigned int GLuint
Definition: gl.h:159
void wined3d_texture_invalidate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, DWORD location)
Definition: texture.c:310
#define WINED3D_LOCATION_TEXTURE_RGB
void device_invalidate_state(const struct wined3d_device *device, DWORD state)
Definition: device.c:5293
BOOL wined3d_texture_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location)
Definition: texture.c:380
#define STATE_FRAMEBUFFER
struct wined3d_device * device

Referenced by swapchain_gl_present().

◆ wined3d_swapchain_set_display_mode()

static HRESULT wined3d_swapchain_set_display_mode ( struct wined3d_swapchain swapchain,
struct wined3d_display_mode mode 
)
static

Definition at line 1272 of file swapchain.c.

1274 {
1275  struct wined3d_device *device = swapchain->device;
1276  HRESULT hr;
1277 
1278  if (swapchain->desc.flags & WINED3D_SWAPCHAIN_USE_CLOSEST_MATCHING_MODE)
1279  {
1281  device->adapter->ordinal, mode)))
1282  {
1283  WARN("Failed to find closest matching mode, hr %#x.\n", hr);
1284  }
1285  }
1286 
1288  device->adapter->ordinal, mode)))
1289  {
1290  WARN("Failed to set display mode, hr %#x.\n", hr);
1291  return WINED3DERR_INVALIDCALL;
1292  }
1293 
1294  return WINED3D_OK;
1295 }
#define WINED3DERR_INVALIDCALL
Definition: wined3d.h:48
HRESULT CDECL wined3d_set_adapter_display_mode(struct wined3d *wined3d, UINT adapter_idx, const struct wined3d_display_mode *mode)
Definition: directx.c:4837
HRESULT hr
Definition: shlfolder.c:183
#define WARN(fmt,...)
Definition: debug.h:111
Definition: devices.h:37
struct wined3d_swapchain_desc desc
LONG HRESULT
Definition: typedefs.h:77
#define WINED3D_OK
Definition: wined3d.h:37
#define WINED3D_SWAPCHAIN_USE_CLOSEST_MATCHING_MODE
Definition: wined3d.h:893
GLenum mode
Definition: glext.h:6217
HRESULT CDECL wined3d_find_closest_matching_adapter_mode(const struct wined3d *wined3d, unsigned int adapter_idx, struct wined3d_display_mode *mode)
Definition: directx.c:4664
struct wined3d_device * device

Referenced by wined3d_swapchain_resize_target(), and wined3d_swapchain_set_fullscreen().

◆ wined3d_swapchain_set_fullscreen()

HRESULT CDECL wined3d_swapchain_set_fullscreen ( struct wined3d_swapchain swapchain,
const struct wined3d_swapchain_desc swapchain_desc,
const struct wined3d_display_mode mode 
)

Definition at line 1344 of file swapchain.c.

1346 {
1347  struct wined3d_device *device = swapchain->device;
1348  struct wined3d_display_mode actual_mode;
1349  HRESULT hr;
1350 
1351  TRACE("swapchain %p, desc %p, mode %p.\n", swapchain, swapchain_desc, mode);
1352 
1353  if (swapchain->desc.flags & WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH)
1354  {
1355  if (mode)
1356  {
1357  actual_mode = *mode;
1358  }
1359  else
1360  {
1361  if (!swapchain_desc->windowed)
1362  {
1363  actual_mode.width = swapchain_desc->backbuffer_width;
1364  actual_mode.height = swapchain_desc->backbuffer_height;
1365  actual_mode.refresh_rate = swapchain_desc->refresh_rate;
1366  actual_mode.format_id = swapchain_desc->backbuffer_format;
1367  actual_mode.scanline_ordering = WINED3D_SCANLINE_ORDERING_UNKNOWN;
1368  }
1369  else
1370  {
1371  actual_mode = swapchain->original_mode;
1372  }
1373  }
1374 
1375  if (FAILED(hr = wined3d_swapchain_set_display_mode(swapchain, &actual_mode)))
1376  return hr;
1377  }
1378  else
1379  {
1380  if (mode)
1381  WARN("WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH is not set, ignoring mode.\n");
1382 
1383  if (FAILED(hr = wined3d_get_adapter_display_mode(device->wined3d, device->adapter->ordinal,
1384  &actual_mode, NULL)))
1385  {
1386  ERR("Failed to get display mode, hr %#x.\n", hr);
1387  return WINED3DERR_INVALIDCALL;
1388  }
1389  }
1390 
1391  if (!swapchain_desc->windowed)
1392  {
1393  unsigned int width = actual_mode.width;
1394  unsigned int height = actual_mode.height;
1395 
1396  if (swapchain->desc.windowed)
1397  {
1398  /* Switch from windowed to fullscreen */
1399  HWND focus_window = device->create_parms.focus_window;
1400  if (!focus_window)
1401  focus_window = swapchain->device_window;
1402  if (FAILED(hr = wined3d_device_acquire_focus_window(device, focus_window)))
1403  {
1404  ERR("Failed to acquire focus window, hr %#x.\n", hr);
1405  return hr;
1406  }
1407 
1409  }
1410  else
1411  {
1412  /* Fullscreen -> fullscreen mode change */
1413  BOOL filter_messages = device->filter_messages;
1414  device->filter_messages = TRUE;
1415 
1416  MoveWindow(swapchain->device_window, 0, 0, width, height, TRUE);
1417  ShowWindow(swapchain->device_window, SW_SHOW);
1418 
1419  device->filter_messages = filter_messages;
1420  }
1421  swapchain->d3d_mode = actual_mode;
1422  }
1423  else if (!swapchain->desc.windowed)
1424  {
1425  /* Fullscreen -> windowed switch */
1426  RECT *window_rect = NULL;
1427  if (swapchain->desc.flags & WINED3D_SWAPCHAIN_RESTORE_WINDOW_RECT)
1428  window_rect = &swapchain->original_window_rect;
1431  }
1432 
1433  swapchain->desc.windowed = swapchain_desc->windowed;
1434 
1435  return WINED3D_OK;
1436 }
#define WINED3DERR_INVALIDCALL
Definition: wined3d.h:48
GLint GLint GLsizei width
Definition: gl.h:1546
#define TRUE
Definition: types.h:120
unsigned int backbuffer_height
Definition: wined3d.h:1735
HRESULT CDECL wined3d_get_adapter_display_mode(const struct wined3d *wined3d, UINT adapter_idx, struct wined3d_display_mode *mode, enum wined3d_display_rotation *rotation)
Definition: directx.c:4764
HRESULT hr
Definition: shlfolder.c:183
HRESULT CDECL wined3d_device_acquire_focus_window(struct wined3d_device *device, HWND window)
Definition: device.c:942
unsigned int backbuffer_width
Definition: wined3d.h:1734
#define WINED3D_SWAPCHAIN_RESTORE_WINDOW_RECT
Definition: wined3d.h:894
#define WARN(fmt,...)
Definition: debug.h:111
void CDECL wined3d_device_restore_fullscreen_window(struct wined3d_device *device, HWND window, const RECT *window_rect)
Definition: device.c:889
#define WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH
Definition: wined3d.h:892
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
static HRESULT wined3d_swapchain_set_display_mode(struct wined3d_swapchain *swapchain, struct wined3d_display_mode *mode)
Definition: swapchain.c:1272
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: devices.h:37
struct wined3d_swapchain_desc desc
smooth NULL
Definition: ftsmooth.c:416
void CDECL wined3d_device_release_focus_window(struct wined3d_device *device)
Definition: device.c:958
#define SW_SHOW
Definition: winuser.h:769
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
void CDECL wined3d_device_setup_fullscreen_window(struct wined3d_device *device, HWND window, UINT w, UINT h)
Definition: device.c:857
#define WINED3D_OK
Definition: wined3d.h:37
GLenum mode
Definition: glext.h:6217
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define ERR(fmt,...)
Definition: debug.h:109
struct wined3d_display_mode original_mode d3d_mode
unsigned int refresh_rate
Definition: wined3d.h:1747
struct wined3d_device * device
enum wined3d_format_id backbuffer_format
Definition: wined3d.h:1736

Referenced by wined3d_device_reset().

◆ wined3d_swapchain_set_gamma_ramp()

HRESULT CDECL wined3d_swapchain_set_gamma_ramp ( const struct wined3d_swapchain swapchain,
DWORD  flags,
const struct wined3d_gamma_ramp ramp 
)

Definition at line 275 of file swapchain.c.

277 {
278  HDC dc;
279 
280  TRACE("swapchain %p, flags %#x, ramp %p.\n", swapchain, flags, ramp);
281 
282  if (flags)
283  FIXME("Ignoring flags %#x.\n", flags);
284 
285  dc = GetDCEx(swapchain->device_window, 0, DCX_USESTYLE | DCX_CACHE);
286  SetDeviceGammaRamp(dc, (void *)ramp);
287  ReleaseDC(swapchain->device_window, dc);
288 
289  return WINED3D_OK;
290 }
HDC WINAPI GetDCEx(_In_opt_ HWND, _In_opt_ HRGN, _In_ DWORD)
static HDC
Definition: imagelist.c:92
#define DCX_USESTYLE
Definition: GetDCEx.c:10
HDC dc
Definition: cylfrac.c:34
static const BYTE ramp[17]
Definition: dib.c:2709
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define FIXME(fmt,...)
Definition: debug.h:110
#define TRACE(s)
Definition: solgame.cpp:4
#define WINED3D_OK
Definition: wined3d.h:37
GLbitfield flags
Definition: glext.h:7161
#define DCX_CACHE
Definition: winuser.h:2075
BOOL WINAPI SetDeviceGammaRamp(_In_ HDC hdc, _In_reads_bytes_(3 *256 *2) LPVOID lpRamp)

Referenced by swapchain_cleanup(), and wined3d_device_set_gamma_ramp().

◆ wined3d_swapchain_set_palette()

void CDECL wined3d_swapchain_set_palette ( struct wined3d_swapchain swapchain,
struct wined3d_palette palette 
)

Definition at line 292 of file swapchain.c.

293 {
294  TRACE("swapchain %p, palette %p.\n", swapchain, palette);
295  swapchain->palette = palette;
296 }
#define TRACE(s)
Definition: solgame.cpp:4
static HPALETTE palette
Definition: clipboard.c:1345
struct wined3d_palette * palette

Referenced by ddraw_create_swapchain(), and ddraw_surface_set_palette().

◆ wined3d_swapchain_set_swap_interval()

void wined3d_swapchain_set_swap_interval ( struct wined3d_swapchain swapchain,
unsigned int  swap_interval 
)

Definition at line 680 of file swapchain.c.

682 {
683  const struct wined3d_gl_info *gl_info;
684  struct wined3d_context *context;
685 
686  swap_interval = swap_interval <= 4 ? swap_interval : 1;
687  if (swapchain->swap_interval == swap_interval)
688  return;
689 
690  swapchain->swap_interval = swap_interval;
691 
692  context = context_acquire(swapchain->device, swapchain->front_buffer, 0);
693  gl_info = context->gl_info;
694 
695  if (gl_info->supported[WGL_EXT_SWAP_CONTROL])
696  {
697  if (!GL_EXTCALL(wglSwapIntervalEXT(swap_interval)))
698  ERR("wglSwapIntervalEXT failed to set swap interval %d for context %p, last error %#x.\n",
699  swap_interval, context, GetLastError());
700  }
701 
703 }
Definition: http.c:6587
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
void context_release(struct wined3d_context *context)
Definition: context.c:1559
#define GL_EXTCALL(f)
struct wined3d_swapchain * swapchain
#define ERR(fmt,...)
Definition: debug.h:109
struct wined3d_context * context_acquire(const struct wined3d_device *device, struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: context.c:4218
const struct wined3d_gl_info * gl_info

Referenced by wined3d_cs_exec_present().

◆ wined3d_swapchain_set_window()

void CDECL wined3d_swapchain_set_window ( struct wined3d_swapchain swapchain,
HWND  window 
)

Definition at line 140 of file swapchain.c.

141 {
142  if (!window)
143  window = swapchain->device_window;
144  if (window == swapchain->win_handle)
145  return;
146 
147  TRACE("Setting swapchain %p window from %p to %p.\n",
148  swapchain, swapchain->win_handle, window);
149  swapchain->win_handle = window;
150 }
#define TRACE(s)
Definition: solgame.cpp:4
static IHTMLWindow2 * window
Definition: events.c:77
struct wined3d_swapchain * swapchain

Referenced by ddraw_surface7_SetClipper(), wined3d_cs_exec_present(), and wined3d_device_reset().

Variable Documentation

◆ swapchain_gdi_ops

const struct wined3d_swapchain_ops swapchain_gdi_ops
static
Initial value:
=
{
}
static void swapchain_gdi_present(struct wined3d_swapchain *swapchain, const RECT *src_rect, const RECT *dst_rect, DWORD flags)
Definition: swapchain.c:589
static void swapchain_gdi_frontbuffer_updated(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:547

Definition at line 636 of file swapchain.c.

Referenced by swapchain_init().

◆ swapchain_gl_ops

const struct wined3d_swapchain_ops swapchain_gl_ops
static
Initial value:
=
{
}
static void swapchain_gl_present(struct wined3d_swapchain *swapchain, const RECT *src_rect, const RECT *dst_rect, DWORD flags)
Definition: swapchain.c:388
static void swapchain_gl_frontbuffer_updated(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:530

Definition at line 541 of file swapchain.c.

Referenced by swapchain_init().