ReactOS 0.4.17-dev-966-gf06eace
swapchain.c File Reference
#include "d3d8_private.h"
Include dependency graph for swapchain.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3d8)
 
static struct d3d8_swapchain * impl_from_IDirect3DSwapChain8 (IDirect3DSwapChain8 *iface)
 
static HRESULT WINAPI d3d8_swapchain_QueryInterface (IDirect3DSwapChain8 *iface, REFIID riid, void **out)
 
static ULONG WINAPI d3d8_swapchain_AddRef (IDirect3DSwapChain8 *iface)
 
static ULONG WINAPI d3d8_swapchain_Release (IDirect3DSwapChain8 *iface)
 
static HRESULT WINAPI DECLSPEC_HOTPATCH d3d8_swapchain_Present (IDirect3DSwapChain8 *iface, const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, const RGNDATA *dirty_region)
 
static HRESULT WINAPI d3d8_swapchain_GetBackBuffer (IDirect3DSwapChain8 *iface, UINT backbuffer_idx, D3DBACKBUFFER_TYPE backbuffer_type, IDirect3DSurface8 **backbuffer)
 
static void STDMETHODCALLTYPE d3d8_swapchain_wined3d_object_released (void *parent)
 
static void CDECL d3d8_swapchain_windowed_state_changed (struct wined3d_swapchain_state_parent *parent, BOOL windowed)
 
static HRESULT swapchain_init (struct d3d8_swapchain *swapchain, struct d3d8_device *device, struct wined3d_swapchain_desc *desc, unsigned int swap_interval)
 
HRESULT d3d8_swapchain_create (struct d3d8_device *device, struct wined3d_swapchain_desc *desc, unsigned int swap_interval, struct d3d8_swapchain **swapchain)
 

Variables

static const IDirect3DSwapChain8Vtbl d3d8_swapchain_vtbl
 
static const struct wined3d_parent_ops d3d8_swapchain_wined3d_parent_ops
 
static const struct wined3d_swapchain_state_parent_ops d3d8_swapchain_state_parent_ops
 

Function Documentation

◆ d3d8_swapchain_AddRef()

static ULONG WINAPI d3d8_swapchain_AddRef ( IDirect3DSwapChain8 *  iface)
static

Definition at line 48 of file swapchain.c.

49{
50 struct d3d8_swapchain *swapchain = impl_from_IDirect3DSwapChain8(iface);
52
53 TRACE("%p increasing refcount to %lu.\n", iface, ref);
54
55 if (ref == 1)
56 {
57 if (swapchain->parent_device)
60 }
61
62 return ref;
63}
#define InterlockedIncrement
Definition: armddk.h:53
static struct d3d8_swapchain * impl_from_IDirect3DSwapChain8(IDirect3DSwapChain8 *iface)
Definition: swapchain.c:25
#define IDirect3DDevice8_AddRef(p)
Definition: d3d8.h:943
#define TRACE(s)
Definition: solgame.cpp:4
struct wined3d_swapchain * wined3d_swapchain
Definition: d3d8_private.h:179
IDirect3DDevice8 * parent_device
Definition: d3d8_private.h:181
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59
ULONG CDECL wined3d_swapchain_incref(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:135

◆ d3d8_swapchain_create()

HRESULT d3d8_swapchain_create ( struct d3d8_device *  device,
struct wined3d_swapchain_desc *  desc,
unsigned int  swap_interval,
struct d3d8_swapchain **  swapchain 
)

Definition at line 193 of file swapchain.c.

195{
196 struct wined3d_rendertarget_view *wined3d_dsv;
197 struct d3d8_swapchain *object;
198 struct d3d8_surface *surface;
199 unsigned int i;
200 HRESULT hr;
201
202 if (!(object = calloc(1, sizeof(*object))))
203 return E_OUTOFMEMORY;
204
205 if (FAILED(hr = swapchain_init(object, device, desc, swap_interval)))
206 {
207 WARN("Failed to initialize swapchain, hr %#lx.\n", hr);
208 free(object);
209 return hr;
210 }
211
212 for (i = 0; i < desc->backbuffer_count; ++i)
213 {
214 if (!(surface = d3d8_surface_create(wined3d_swapchain_get_back_buffer(object->wined3d_swapchain, i), 0,
215 (IUnknown *)&device->IDirect3DDevice8_iface)))
216 {
217 IDirect3DSwapChain8_Release(&object->IDirect3DSwapChain8_iface);
218 return E_OUTOFMEMORY;
219 }
220 surface->parent_device = &device->IDirect3DDevice8_iface;
221 }
222
223 if ((desc->flags & WINED3D_SWAPCHAIN_IMPLICIT)
224 && (wined3d_dsv = wined3d_device_context_get_depth_stencil_view(device->immediate_context)))
225 {
227
229 (IUnknown *)&device->IDirect3DDevice8_iface)))
230 {
231 IDirect3DSwapChain8_Release(&object->IDirect3DSwapChain8_iface);
232 return E_OUTOFMEMORY;
233 }
234 surface->parent_device = &device->IDirect3DDevice8_iface;
235 }
236
237 TRACE("Created swapchain %p.\n", object);
238 *swapchain = object;
239
240 return D3D_OK;
241}
#define WARN(fmt,...)
Definition: precomp.h:61
static HRESULT swapchain_init(struct d3d8_swapchain *swapchain, struct d3d8_device *device, struct wined3d_swapchain_desc *desc, unsigned int swap_interval)
Definition: swapchain.c:170
struct d3d8_surface * d3d8_surface_create(struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, IUnknown *container)
Definition: surface.c:318
#define D3D_OK
Definition: d3d.h:106
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define free
Definition: debug_ros.c:5
HRESULT hr
Definition: delayimp.cpp:582
struct wined3d_rendertarget_view *CDECL wined3d_device_context_get_depth_stencil_view(const struct wined3d_device_context *context)
Definition: device.c:4676
struct wined3d_texture *__cdecl wined3d_texture_from_resource(struct wined3d_resource *resource)
Definition: texture.c:3343
struct wined3d_resource *CDECL wined3d_rendertarget_view_get_resource(const struct wined3d_rendertarget_view *view)
Definition: view.c:430
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 FAILED(hr)
Definition: intsafe.h:51
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
#define calloc
Definition: rosglue.h:14
#define IDirect3DSwapChain8_Release(p)
Definition: d3d8.h:266
IDirect3DDevice8 * parent_device
Definition: d3d8_private.h:196
Definition: devices.h:37
struct wined3d_texture *CDECL wined3d_swapchain_get_back_buffer(const struct wined3d_swapchain *swapchain, UINT back_buffer_idx)
Definition: swapchain.c:256
#define WINED3D_SWAPCHAIN_IMPLICIT
Definition: wined3d.h:901

Referenced by d3d8_device_CreateAdditionalSwapChain(), and device_init().

◆ d3d8_swapchain_GetBackBuffer()

static HRESULT WINAPI d3d8_swapchain_GetBackBuffer ( IDirect3DSwapChain8 *  iface,
UINT  backbuffer_idx,
D3DBACKBUFFER_TYPE  backbuffer_type,
IDirect3DSurface8 **  backbuffer 
)
static

Definition at line 104 of file swapchain.c.

106{
107 struct d3d8_swapchain *swapchain = impl_from_IDirect3DSwapChain8(iface);
109 struct d3d8_surface *surface_impl;
110 HRESULT hr = D3D_OK;
111
112 TRACE("iface %p, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
113 iface, backbuffer_idx, backbuffer_type, backbuffer);
114
115 /* backbuffer_type is ignored by native. */
116
117 if (!backbuffer)
118 {
119 WARN("The output pointer is NULL, returning D3DERR_INVALIDCALL.\n");
120 return D3DERR_INVALIDCALL;
121 }
122
124 if ((wined3d_texture = wined3d_swapchain_get_back_buffer(swapchain->wined3d_swapchain, backbuffer_idx)))
125 {
127 *backbuffer = &surface_impl->IDirect3DSurface8_iface;
128 IDirect3DSurface8_AddRef(*backbuffer);
129 }
130 else
131 {
132 /* Do not set *backbuffer = NULL, see tests/device.c, test_swapchain(). */
134 }
136
137 return hr;
138}
#define D3DERR_INVALIDCALL
Definition: d3d10_private.h:42
void *CDECL wined3d_texture_get_sub_resource_parent(struct wined3d_texture *texture, unsigned int sub_resource_idx)
Definition: texture.c:4033
#define IDirect3DSurface8_AddRef(p)
Definition: d3d8.h:305
IDirect3DSurface8 IDirect3DSurface8_iface
Definition: d3d8_private.h:190
struct wined3d_swapchain * swapchain
Definition: d3d8_private.h:199
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:544
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:539

◆ d3d8_swapchain_Present()

static HRESULT WINAPI DECLSPEC_HOTPATCH d3d8_swapchain_Present ( IDirect3DSwapChain8 *  iface,
const RECT *  src_rect,
const RECT *  dst_rect,
HWND  dst_window_override,
const RGNDATA *  dirty_region 
)
static

Definition at line 84 of file swapchain.c.

87{
88 struct d3d8_swapchain *swapchain = impl_from_IDirect3DSwapChain8(iface);
90
91 TRACE("iface %p, src_rect %s, dst_rect %s, dst_window_override %p, dirty_region %p.\n",
92 iface, wine_dbgstr_rect(src_rect), wine_dbgstr_rect(dst_rect), dst_window_override, dirty_region);
93
94 if (device->device_state != D3D8_DEVICE_STATE_OK)
95 return D3DERR_DEVICELOST;
96
97 if (dirty_region)
98 FIXME("Ignoring dirty_region %p.\n", dirty_region);
99
101 src_rect, dst_rect, dst_window_override, swapchain->swap_interval, 0);
102}
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
#define FIXME(fmt,...)
Definition: precomp.h:53
@ D3D8_DEVICE_STATE_OK
Definition: d3d8_private.h:102
static struct d3d8_device * impl_from_IDirect3DDevice8(IDirect3DDevice8 *iface)
Definition: d3d8_private.h:144
#define D3DERR_DEVICELOST
Definition: d3d8.h:78
unsigned int swap_interval
Definition: d3d8_private.h:182
HRESULT CDECL wined3d_swapchain_present(struct wined3d_swapchain *swapchain, const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, unsigned int swap_interval, uint32_t flags)
Definition: swapchain.c:192

◆ d3d8_swapchain_QueryInterface()

static HRESULT WINAPI d3d8_swapchain_QueryInterface ( IDirect3DSwapChain8 *  iface,
REFIID  riid,
void **  out 
)
static

Definition at line 30 of file swapchain.c.

31{
32 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
33
34 if (IsEqualGUID(riid, &IID_IDirect3DSwapChain8)
36 {
38 *out = iface;
39 return S_OK;
40 }
41
42 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
43
44 *out = NULL;
45 return E_NOINTERFACE;
46}
const GUID IID_IUnknown
#define NULL
Definition: types.h:112
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define IDirect3DSwapChain8_AddRef(p)
Definition: d3d8.h:265
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
#define E_NOINTERFACE
Definition: winerror.h:3479

◆ d3d8_swapchain_Release()

static ULONG WINAPI d3d8_swapchain_Release ( IDirect3DSwapChain8 *  iface)
static

Definition at line 65 of file swapchain.c.

66{
67 struct d3d8_swapchain *swapchain = impl_from_IDirect3DSwapChain8(iface);
69
70 TRACE("%p decreasing refcount to %lu.\n", iface, ref);
71
72 if (!ref)
73 {
74 IDirect3DDevice8 *parent_device = swapchain->parent_device;
75
77
78 if (parent_device)
80 }
81 return ref;
82}
#define InterlockedDecrement
Definition: armddk.h:52
#define IDirect3DDevice8_Release(p)
Definition: d3d8.h:944
ULONG CDECL wined3d_swapchain_decref(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:144

◆ d3d8_swapchain_windowed_state_changed()

static void CDECL d3d8_swapchain_windowed_state_changed ( struct wined3d_swapchain_state_parent *  parent,
BOOL  windowed 
)
static

Definition at line 159 of file swapchain.c.

161{
162 TRACE("parent %p, windowed %d.\n", parent, windowed);
163}
r parent
Definition: btrfs.c:3010

◆ d3d8_swapchain_wined3d_object_released()

static void STDMETHODCALLTYPE d3d8_swapchain_wined3d_object_released ( void *  parent)
static

Definition at line 149 of file swapchain.c.

150{
151 free(parent);
152}

◆ impl_from_IDirect3DSwapChain8()

static struct d3d8_swapchain * impl_from_IDirect3DSwapChain8 ( IDirect3DSwapChain8 *  iface)
inlinestatic

Definition at line 25 of file swapchain.c.

26{
27 return CONTAINING_RECORD(iface, struct d3d8_swapchain, IDirect3DSwapChain8_iface);
28}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by d3d8_swapchain_AddRef(), d3d8_swapchain_GetBackBuffer(), d3d8_swapchain_Present(), and d3d8_swapchain_Release().

◆ swapchain_init()

static HRESULT swapchain_init ( struct d3d8_swapchain *  swapchain,
struct d3d8_device *  device,
struct wined3d_swapchain_desc *  desc,
unsigned int  swap_interval 
)
static

Definition at line 170 of file swapchain.c.

172{
173 HRESULT hr;
174
175 swapchain->refcount = 1;
178 swapchain->swap_interval = swap_interval;
179
180 if (FAILED(hr = wined3d_swapchain_create(device->wined3d_device, desc, &swapchain->state_parent,
181 swapchain, &d3d8_swapchain_wined3d_parent_ops, &swapchain->wined3d_swapchain)))
182 {
183 WARN("Failed to create wined3d swapchain, hr %#lx.\n", hr);
184 return hr;
185 }
186
187 swapchain->parent_device = &device->IDirect3DDevice8_iface;
189
190 return D3D_OK;
191}
static const struct wined3d_swapchain_state_parent_ops d3d8_swapchain_state_parent_ops
Definition: swapchain.c:165
static const struct wined3d_parent_ops d3d8_swapchain_wined3d_parent_ops
Definition: swapchain.c:154
static const IDirect3DSwapChain8Vtbl d3d8_swapchain_vtbl
Definition: swapchain.c:140
IDirect3DSwapChain8 IDirect3DSwapChain8_iface
Definition: d3d8_private.h:177
struct wined3d_swapchain_state_parent state_parent
Definition: d3d8_private.h:180
HRESULT CDECL wined3d_swapchain_create(struct wined3d_device *device, const struct wined3d_swapchain_desc *desc, struct wined3d_swapchain_state_parent *state_parent, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_swapchain **swapchain)
Definition: swapchain.c:1732

Referenced by d3d8_swapchain_create(), and d3d9_swapchain_create().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3d8  )

Variable Documentation

◆ d3d8_swapchain_state_parent_ops

const struct wined3d_swapchain_state_parent_ops d3d8_swapchain_state_parent_ops
static
Initial value:
=
{
}
static void CDECL d3d8_swapchain_windowed_state_changed(struct wined3d_swapchain_state_parent *parent, BOOL windowed)
Definition: swapchain.c:159

Definition at line 165 of file swapchain.c.

Referenced by swapchain_init().

◆ d3d8_swapchain_vtbl

const IDirect3DSwapChain8Vtbl d3d8_swapchain_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI d3d8_swapchain_QueryInterface(IDirect3DSwapChain8 *iface, REFIID riid, void **out)
Definition: swapchain.c:30
static ULONG WINAPI d3d8_swapchain_AddRef(IDirect3DSwapChain8 *iface)
Definition: swapchain.c:48
static ULONG WINAPI d3d8_swapchain_Release(IDirect3DSwapChain8 *iface)
Definition: swapchain.c:65
static HRESULT WINAPI d3d8_swapchain_GetBackBuffer(IDirect3DSwapChain8 *iface, UINT backbuffer_idx, D3DBACKBUFFER_TYPE backbuffer_type, IDirect3DSurface8 **backbuffer)
Definition: swapchain.c:104
static HRESULT WINAPI DECLSPEC_HOTPATCH d3d8_swapchain_Present(IDirect3DSwapChain8 *iface, const RECT *src_rect, const RECT *dst_rect, HWND dst_window_override, const RGNDATA *dirty_region)
Definition: swapchain.c:84

Definition at line 140 of file swapchain.c.

Referenced by swapchain_init().

◆ d3d8_swapchain_wined3d_parent_ops

const struct wined3d_parent_ops d3d8_swapchain_wined3d_parent_ops
static
Initial value:
=
{
}
static void STDMETHODCALLTYPE d3d8_swapchain_wined3d_object_released(void *parent)
Definition: swapchain.c:149

Definition at line 154 of file swapchain.c.

Referenced by swapchain_init().