We will have more than one implementation of IDXGISwapChain.
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/dxgi/device.c | 8 +- dlls/dxgi/dxgi_private.h | 4 +- dlls/dxgi/swapchain.c | 186 +++++++++++++++++++++++------------------------ 3 files changed, 99 insertions(+), 99 deletions(-)
diff --git a/dlls/dxgi/device.c b/dlls/dxgi/device.c index 0341bb0e995b..5607c380f1ff 100644 --- a/dlls/dxgi/device.c +++ b/dlls/dxgi/device.c @@ -327,7 +327,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_create_surface(IWineDXGIDevice *ifa
if (!(object = heap_alloc_zero(sizeof(*object)))) { - ERR("Failed to allocate DXGI surface object memory\n"); + ERR("Failed to allocate DXGI surface object memory.\n"); return E_OUTOFMEMORY; }
@@ -338,7 +338,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_create_surface(IWineDXGIDevice *ifa return hr; }
- TRACE("Created IDXGISurface %p\n", object); + TRACE("Created IDXGISurface %p.\n", object); *surface = outer ? &object->IUnknown_iface : (IUnknown *)&object->IDXGISurface1_iface;
return S_OK; @@ -348,7 +348,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_create_swapchain(IWineDXGIDevice *i struct wined3d_swapchain_desc *desc, BOOL implicit, struct wined3d_swapchain **wined3d_swapchain) { struct dxgi_device *device = impl_from_IWineDXGIDevice(iface); - struct dxgi_swapchain *object; + struct d3d11_swapchain *object; HRESULT hr;
TRACE("iface %p, desc %p, wined3d_swapchain %p.\n", @@ -360,7 +360,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_create_swapchain(IWineDXGIDevice *i return E_OUTOFMEMORY; }
- if (FAILED(hr = dxgi_swapchain_init(object, device, desc, implicit))) + if (FAILED(hr = d3d11_swapchain_init(object, device, desc, implicit))) { WARN("Failed to initialize swapchain, hr %#x.\n", hr); heap_free(object); diff --git a/dlls/dxgi/dxgi_private.h b/dlls/dxgi/dxgi_private.h index 24487c3aa0b1..559a834204b0 100644 --- a/dlls/dxgi/dxgi_private.h +++ b/dlls/dxgi/dxgi_private.h @@ -160,7 +160,7 @@ HRESULT dxgi_adapter_create(struct dxgi_factory *factory, UINT ordinal, struct dxgi_adapter *unsafe_impl_from_IDXGIAdapter(IDXGIAdapter *iface) DECLSPEC_HIDDEN;
/* IDXGISwapChain */ -struct dxgi_swapchain +struct d3d11_swapchain { IDXGISwapChain1 IDXGISwapChain1_iface; LONG refcount; @@ -173,7 +173,7 @@ struct dxgi_swapchain IDXGIOutput *target; };
-HRESULT dxgi_swapchain_init(struct dxgi_swapchain *swapchain, struct dxgi_device *device, +HRESULT d3d11_swapchain_init(struct d3d11_swapchain *swapchain, struct dxgi_device *device, struct wined3d_swapchain_desc *desc, BOOL implicit) DECLSPEC_HIDDEN;
/* IDXGISurface */ diff --git a/dlls/dxgi/swapchain.c b/dlls/dxgi/swapchain.c index 6f9d0338aeef..c85b742e4f80 100644 --- a/dlls/dxgi/swapchain.c +++ b/dlls/dxgi/swapchain.c @@ -24,14 +24,14 @@
WINE_DEFAULT_DEBUG_CHANNEL(dxgi);
-static inline struct dxgi_swapchain *impl_from_IDXGISwapChain1(IDXGISwapChain1 *iface) +static inline struct d3d11_swapchain *d3d11_swapchain_from_IDXGISwapChain1(IDXGISwapChain1 *iface) { - return CONTAINING_RECORD(iface, struct dxgi_swapchain, IDXGISwapChain1_iface); + return CONTAINING_RECORD(iface, struct d3d11_swapchain, IDXGISwapChain1_iface); }
/* IUnknown methods */
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_QueryInterface(IDXGISwapChain1 *iface, REFIID riid, void **object) +static HRESULT STDMETHODCALLTYPE d3d11_swapchain_QueryInterface(IDXGISwapChain1 *iface, REFIID riid, void **object) { TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
@@ -52,26 +52,26 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_QueryInterface(IDXGISwapChain1 * return E_NOINTERFACE; }
-static ULONG STDMETHODCALLTYPE dxgi_swapchain_AddRef(IDXGISwapChain1 *iface) +static ULONG STDMETHODCALLTYPE d3d11_swapchain_AddRef(IDXGISwapChain1 *iface) { - struct dxgi_swapchain *This = impl_from_IDXGISwapChain1(iface); - ULONG refcount = InterlockedIncrement(&This->refcount); + struct d3d11_swapchain *swapchain = d3d11_swapchain_from_IDXGISwapChain1(iface); + ULONG refcount = InterlockedIncrement(&swapchain->refcount);
- TRACE("%p increasing refcount to %u\n", This, refcount); + TRACE("%p increasing refcount to %u\n", swapchain, refcount);
if (refcount == 1) { wined3d_mutex_lock(); - wined3d_swapchain_incref(This->wined3d_swapchain); + wined3d_swapchain_incref(swapchain->wined3d_swapchain); wined3d_mutex_unlock(); }
return refcount; }
-static ULONG STDMETHODCALLTYPE dxgi_swapchain_Release(IDXGISwapChain1 *iface) +static ULONG STDMETHODCALLTYPE d3d11_swapchain_Release(IDXGISwapChain1 *iface) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface); + struct d3d11_swapchain *swapchain = d3d11_swapchain_from_IDXGISwapChain1(iface); ULONG refcount = InterlockedDecrement(&swapchain->refcount);
TRACE("%p decreasing refcount to %u.\n", swapchain, refcount); @@ -98,39 +98,39 @@ static ULONG STDMETHODCALLTYPE dxgi_swapchain_Release(IDXGISwapChain1 *iface)
/* IDXGIObject methods */
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_SetPrivateData(IDXGISwapChain1 *iface, +static HRESULT STDMETHODCALLTYPE d3d11_swapchain_SetPrivateData(IDXGISwapChain1 *iface, REFGUID guid, UINT data_size, const void *data) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface); + struct d3d11_swapchain *swapchain = d3d11_swapchain_from_IDXGISwapChain1(iface);
TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
return dxgi_set_private_data(&swapchain->private_store, guid, data_size, data); }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_SetPrivateDataInterface(IDXGISwapChain1 *iface, +static HRESULT STDMETHODCALLTYPE d3d11_swapchain_SetPrivateDataInterface(IDXGISwapChain1 *iface, REFGUID guid, const IUnknown *object) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface); + struct d3d11_swapchain *swapchain = d3d11_swapchain_from_IDXGISwapChain1(iface);
TRACE("iface %p, guid %s, object %p.\n", iface, debugstr_guid(guid), object);
return dxgi_set_private_data_interface(&swapchain->private_store, guid, object); }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetPrivateData(IDXGISwapChain1 *iface, +static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetPrivateData(IDXGISwapChain1 *iface, REFGUID guid, UINT *data_size, void *data) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface); + struct d3d11_swapchain *swapchain = d3d11_swapchain_from_IDXGISwapChain1(iface);
TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data);
return dxgi_get_private_data(&swapchain->private_store, guid, data_size, data); }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetParent(IDXGISwapChain1 *iface, REFIID riid, void **parent) +static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetParent(IDXGISwapChain1 *iface, REFIID riid, void **parent) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface); + struct d3d11_swapchain *swapchain = d3d11_swapchain_from_IDXGISwapChain1(iface);
TRACE("iface %p, riid %s, parent %p.\n", iface, debugstr_guid(riid), parent);
@@ -146,9 +146,9 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetParent(IDXGISwapChain1 *iface
/* IDXGIDeviceSubObject methods */
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetDevice(IDXGISwapChain1 *iface, REFIID riid, void **device) +static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetDevice(IDXGISwapChain1 *iface, REFIID riid, void **device) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface); + struct d3d11_swapchain *swapchain = d3d11_swapchain_from_IDXGISwapChain1(iface);
TRACE("iface %p, riid %s, device %p.\n", iface, debugstr_guid(riid), device);
@@ -164,19 +164,19 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetDevice(IDXGISwapChain1 *iface
/* IDXGISwapChain1 methods */
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_Present(IDXGISwapChain1 *iface, UINT sync_interval, UINT flags) +static HRESULT STDMETHODCALLTYPE d3d11_swapchain_Present(IDXGISwapChain1 *iface, UINT sync_interval, UINT flags) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface); + struct d3d11_swapchain *swapchain = d3d11_swapchain_from_IDXGISwapChain1(iface);
TRACE("iface %p, sync_interval %u, flags %#x.\n", iface, sync_interval, flags);
return IDXGISwapChain1_Present1(&swapchain->IDXGISwapChain1_iface, sync_interval, flags, NULL); }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetBuffer(IDXGISwapChain1 *iface, +static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetBuffer(IDXGISwapChain1 *iface, UINT buffer_idx, REFIID riid, void **surface) { - struct dxgi_swapchain *This = impl_from_IDXGISwapChain1(iface); + struct d3d11_swapchain *swapchain = d3d11_swapchain_from_IDXGISwapChain1(iface); struct wined3d_texture *texture; IUnknown *parent; HRESULT hr; @@ -186,7 +186,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetBuffer(IDXGISwapChain1 *iface
wined3d_mutex_lock();
- if (!(texture = wined3d_swapchain_get_back_buffer(This->wined3d_swapchain, buffer_idx))) + if (!(texture = wined3d_swapchain_get_back_buffer(swapchain->wined3d_swapchain, buffer_idx))) { wined3d_mutex_unlock(); return DXGI_ERROR_INVALID_CALL; @@ -199,10 +199,10 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetBuffer(IDXGISwapChain1 *iface return hr; }
-static HRESULT STDMETHODCALLTYPE DECLSPEC_HOTPATCH dxgi_swapchain_SetFullscreenState(IDXGISwapChain1 *iface, +static HRESULT STDMETHODCALLTYPE DECLSPEC_HOTPATCH d3d11_swapchain_SetFullscreenState(IDXGISwapChain1 *iface, BOOL fullscreen, IDXGIOutput *target) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface); + struct d3d11_swapchain *swapchain = d3d11_swapchain_from_IDXGISwapChain1(iface); struct wined3d_swapchain_desc swapchain_desc; HRESULT hr;
@@ -248,10 +248,10 @@ static HRESULT STDMETHODCALLTYPE DECLSPEC_HOTPATCH dxgi_swapchain_SetFullscreenS return hr; }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetFullscreenState(IDXGISwapChain1 *iface, +static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetFullscreenState(IDXGISwapChain1 *iface, BOOL *fullscreen, IDXGIOutput **target) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface); + struct d3d11_swapchain *swapchain = d3d11_swapchain_from_IDXGISwapChain1(iface);
TRACE("iface %p, fullscreen %p, target %p.\n", iface, fullscreen, target);
@@ -268,9 +268,9 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetFullscreenState(IDXGISwapChai return S_OK; }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetDesc(IDXGISwapChain1 *iface, DXGI_SWAP_CHAIN_DESC *desc) +static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetDesc(IDXGISwapChain1 *iface, DXGI_SWAP_CHAIN_DESC *desc) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface); + struct d3d11_swapchain *swapchain = d3d11_swapchain_from_IDXGISwapChain1(iface); struct wined3d_swapchain_desc wined3d_desc;
TRACE("iface %p, desc %p.\n", iface, desc); @@ -306,10 +306,10 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetDesc(IDXGISwapChain1 *iface, return S_OK; }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_ResizeBuffers(IDXGISwapChain1 *iface, +static HRESULT STDMETHODCALLTYPE d3d11_swapchain_ResizeBuffers(IDXGISwapChain1 *iface, UINT buffer_count, UINT width, UINT height, DXGI_FORMAT format, UINT flags) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface); + struct d3d11_swapchain *swapchain = d3d11_swapchain_from_IDXGISwapChain1(iface); struct wined3d_swapchain_desc wined3d_desc; struct wined3d_texture *texture; IUnknown *parent; @@ -344,10 +344,10 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_ResizeBuffers(IDXGISwapChain1 *i return hr; }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_ResizeTarget(IDXGISwapChain1 *iface, +static HRESULT STDMETHODCALLTYPE d3d11_swapchain_ResizeTarget(IDXGISwapChain1 *iface, const DXGI_MODE_DESC *target_mode_desc) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface); + struct d3d11_swapchain *swapchain = d3d11_swapchain_from_IDXGISwapChain1(iface); struct wined3d_display_mode mode; HRESULT hr;
@@ -373,9 +373,9 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_ResizeTarget(IDXGISwapChain1 *if return hr; }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetContainingOutput(IDXGISwapChain1 *iface, IDXGIOutput **output) +static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetContainingOutput(IDXGISwapChain1 *iface, IDXGIOutput **output) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface); + struct d3d11_swapchain *swapchain = d3d11_swapchain_from_IDXGISwapChain1(iface); IDXGIAdapter *adapter; IDXGIDevice *device; HRESULT hr; @@ -388,7 +388,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetContainingOutput(IDXGISwapCha return S_OK; }
- if (FAILED(hr = dxgi_swapchain_GetDevice(iface, &IID_IDXGIDevice, (void **)&device))) + if (FAILED(hr = d3d11_swapchain_GetDevice(iface, &IID_IDXGIDevice, (void **)&device))) return hr;
hr = IDXGIDevice_GetAdapter(device, &adapter); @@ -410,7 +410,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetContainingOutput(IDXGISwapCha return hr; }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetFrameStatistics(IDXGISwapChain1 *iface, +static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetFrameStatistics(IDXGISwapChain1 *iface, DXGI_FRAME_STATISTICS *stats) { FIXME("iface %p, stats %p stub!\n", iface, stats); @@ -418,7 +418,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetFrameStatistics(IDXGISwapChai return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetLastPresentCount(IDXGISwapChain1 *iface, +static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetLastPresentCount(IDXGISwapChain1 *iface, UINT *last_present_count) { FIXME("iface %p, last_present_count %p stub!\n", iface, last_present_count); @@ -428,9 +428,9 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetLastPresentCount(IDXGISwapCha
/* IDXGISwapChain1 methods */
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetDesc1(IDXGISwapChain1 *iface, DXGI_SWAP_CHAIN_DESC1 *desc) +static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetDesc1(IDXGISwapChain1 *iface, DXGI_SWAP_CHAIN_DESC1 *desc) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface); + struct d3d11_swapchain *swapchain = d3d11_swapchain_from_IDXGISwapChain1(iface); struct wined3d_swapchain_desc wined3d_desc;
TRACE("iface %p, desc %p.\n", iface, desc); @@ -463,10 +463,10 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetDesc1(IDXGISwapChain1 *iface, return S_OK; }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetFullscreenDesc(IDXGISwapChain1 *iface, +static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetFullscreenDesc(IDXGISwapChain1 *iface, DXGI_SWAP_CHAIN_FULLSCREEN_DESC *desc) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface); + struct d3d11_swapchain *swapchain = d3d11_swapchain_from_IDXGISwapChain1(iface); struct wined3d_swapchain_desc wined3d_desc;
TRACE("iface %p, desc %p.\n", iface, desc); @@ -492,9 +492,9 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetFullscreenDesc(IDXGISwapChain return S_OK; }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetHwnd(IDXGISwapChain1 *iface, HWND *hwnd) +static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetHwnd(IDXGISwapChain1 *iface, HWND *hwnd) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface); + struct d3d11_swapchain *swapchain = d3d11_swapchain_from_IDXGISwapChain1(iface); struct wined3d_swapchain_desc wined3d_desc;
TRACE("iface %p, hwnd %p.\n", iface, hwnd); @@ -513,7 +513,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetHwnd(IDXGISwapChain1 *iface, return S_OK; }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetCoreWindow(IDXGISwapChain1 *iface, +static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetCoreWindow(IDXGISwapChain1 *iface, REFIID iid, void **core_window) { FIXME("iface %p, iid %s, core_window %p stub!\n", iface, debugstr_guid(iid), core_window); @@ -524,10 +524,10 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetCoreWindow(IDXGISwapChain1 *i return DXGI_ERROR_INVALID_CALL; }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_Present1(IDXGISwapChain1 *iface, +static HRESULT STDMETHODCALLTYPE d3d11_swapchain_Present1(IDXGISwapChain1 *iface, UINT sync_interval, UINT flags, const DXGI_PRESENT_PARAMETERS *present_parameters) { - struct dxgi_swapchain *swapchain = impl_from_IDXGISwapChain1(iface); + struct d3d11_swapchain *swapchain = d3d11_swapchain_from_IDXGISwapChain1(iface); HRESULT hr;
TRACE("iface %p, sync_interval %u, flags %#x, present_parameters %p.\n", @@ -557,14 +557,14 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_Present1(IDXGISwapChain1 *iface, return hr; }
-static BOOL STDMETHODCALLTYPE dxgi_swapchain_IsTemporaryMonoSupported(IDXGISwapChain1 *iface) +static BOOL STDMETHODCALLTYPE d3d11_swapchain_IsTemporaryMonoSupported(IDXGISwapChain1 *iface) { FIXME("iface %p stub!\n", iface);
return FALSE; }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetRestrictToOutput(IDXGISwapChain1 *iface, IDXGIOutput **output) +static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetRestrictToOutput(IDXGISwapChain1 *iface, IDXGIOutput **output) { FIXME("iface %p, output %p stub!\n", iface, output);
@@ -578,91 +578,91 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetRestrictToOutput(IDXGISwapCha return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_SetBackgroundColor(IDXGISwapChain1 *iface, const DXGI_RGBA *color) +static HRESULT STDMETHODCALLTYPE d3d11_swapchain_SetBackgroundColor(IDXGISwapChain1 *iface, const DXGI_RGBA *color) { FIXME("iface %p, color %p stub!\n", iface, color);
return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetBackgroundColor(IDXGISwapChain1 *iface, DXGI_RGBA *color) +static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetBackgroundColor(IDXGISwapChain1 *iface, DXGI_RGBA *color) { FIXME("iface %p, color %p stub!\n", iface, color);
return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_SetRotation(IDXGISwapChain1 *iface, DXGI_MODE_ROTATION rotation) +static HRESULT STDMETHODCALLTYPE d3d11_swapchain_SetRotation(IDXGISwapChain1 *iface, DXGI_MODE_ROTATION rotation) { FIXME("iface %p, rotation %#x stub!\n", iface, rotation);
return E_NOTIMPL; }
-static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetRotation(IDXGISwapChain1 *iface, DXGI_MODE_ROTATION *rotation) +static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetRotation(IDXGISwapChain1 *iface, DXGI_MODE_ROTATION *rotation) { FIXME("iface %p, rotation %p stub!\n", iface, rotation);
return E_NOTIMPL; }
-static const struct IDXGISwapChain1Vtbl dxgi_swapchain_vtbl = +static const struct IDXGISwapChain1Vtbl d3d11_swapchain_vtbl = { /* IUnknown methods */ - dxgi_swapchain_QueryInterface, - dxgi_swapchain_AddRef, - dxgi_swapchain_Release, + d3d11_swapchain_QueryInterface, + d3d11_swapchain_AddRef, + d3d11_swapchain_Release, /* IDXGIObject methods */ - dxgi_swapchain_SetPrivateData, - dxgi_swapchain_SetPrivateDataInterface, - dxgi_swapchain_GetPrivateData, - dxgi_swapchain_GetParent, + d3d11_swapchain_SetPrivateData, + d3d11_swapchain_SetPrivateDataInterface, + d3d11_swapchain_GetPrivateData, + d3d11_swapchain_GetParent, /* IDXGIDeviceSubObject methods */ - dxgi_swapchain_GetDevice, + d3d11_swapchain_GetDevice, /* IDXGISwapChain methods */ - dxgi_swapchain_Present, - dxgi_swapchain_GetBuffer, - dxgi_swapchain_SetFullscreenState, - dxgi_swapchain_GetFullscreenState, - dxgi_swapchain_GetDesc, - dxgi_swapchain_ResizeBuffers, - dxgi_swapchain_ResizeTarget, - dxgi_swapchain_GetContainingOutput, - dxgi_swapchain_GetFrameStatistics, - dxgi_swapchain_GetLastPresentCount, + d3d11_swapchain_Present, + d3d11_swapchain_GetBuffer, + d3d11_swapchain_SetFullscreenState, + d3d11_swapchain_GetFullscreenState, + d3d11_swapchain_GetDesc, + d3d11_swapchain_ResizeBuffers, + d3d11_swapchain_ResizeTarget, + d3d11_swapchain_GetContainingOutput, + d3d11_swapchain_GetFrameStatistics, + d3d11_swapchain_GetLastPresentCount, /* IDXGISwapChain1 methods */ - dxgi_swapchain_GetDesc1, - dxgi_swapchain_GetFullscreenDesc, - dxgi_swapchain_GetHwnd, - dxgi_swapchain_GetCoreWindow, - dxgi_swapchain_Present1, - dxgi_swapchain_IsTemporaryMonoSupported, - dxgi_swapchain_GetRestrictToOutput, - dxgi_swapchain_SetBackgroundColor, - dxgi_swapchain_GetBackgroundColor, - dxgi_swapchain_SetRotation, - dxgi_swapchain_GetRotation, + d3d11_swapchain_GetDesc1, + d3d11_swapchain_GetFullscreenDesc, + d3d11_swapchain_GetHwnd, + d3d11_swapchain_GetCoreWindow, + d3d11_swapchain_Present1, + d3d11_swapchain_IsTemporaryMonoSupported, + d3d11_swapchain_GetRestrictToOutput, + d3d11_swapchain_SetBackgroundColor, + d3d11_swapchain_GetBackgroundColor, + d3d11_swapchain_SetRotation, + d3d11_swapchain_GetRotation, };
-static void STDMETHODCALLTYPE dxgi_swapchain_wined3d_object_released(void *parent) +static void STDMETHODCALLTYPE d3d11_swapchain_wined3d_object_released(void *parent) { - struct dxgi_swapchain *swapchain = parent; + struct d3d11_swapchain *swapchain = parent;
wined3d_private_store_cleanup(&swapchain->private_store); heap_free(parent); }
-static const struct wined3d_parent_ops dxgi_swapchain_wined3d_parent_ops = +static const struct wined3d_parent_ops d3d11_swapchain_wined3d_parent_ops = { - dxgi_swapchain_wined3d_object_released, + d3d11_swapchain_wined3d_object_released, };
-HRESULT dxgi_swapchain_init(struct dxgi_swapchain *swapchain, struct dxgi_device *device, +HRESULT d3d11_swapchain_init(struct d3d11_swapchain *swapchain, struct dxgi_device *device, struct wined3d_swapchain_desc *desc, BOOL implicit) { HRESULT hr;
- /** + /* * A reference to the implicit swapchain is held by the wined3d device. * In order to avoid circular references we do not keep a reference * to the device in the implicit swapchain. @@ -683,7 +683,7 @@ HRESULT dxgi_swapchain_init(struct dxgi_swapchain *swapchain, struct dxgi_device swapchain->factory = NULL; }
- swapchain->IDXGISwapChain1_iface.lpVtbl = &dxgi_swapchain_vtbl; + swapchain->IDXGISwapChain1_iface.lpVtbl = &d3d11_swapchain_vtbl; swapchain->refcount = 1; wined3d_mutex_lock(); wined3d_private_store_init(&swapchain->private_store); @@ -694,7 +694,7 @@ HRESULT dxgi_swapchain_init(struct dxgi_swapchain *swapchain, struct dxgi_device swapchain->fullscreen = !desc->windowed; desc->windowed = TRUE; if (FAILED(hr = wined3d_swapchain_create(device->wined3d_device, desc, swapchain, - &dxgi_swapchain_wined3d_parent_ops, &swapchain->wined3d_swapchain))) + &d3d11_swapchain_wined3d_parent_ops, &swapchain->wined3d_swapchain))) { WARN("Failed to create wined3d swapchain, hr %#x.\n", hr); goto cleanup;
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/dxgi/dxgi_private.h | 2 ++ dlls/dxgi/factory.c | 56 ++++-------------------------------------- dlls/dxgi/swapchain.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 51 deletions(-)
diff --git a/dlls/dxgi/dxgi_private.h b/dlls/dxgi/dxgi_private.h index 559a834204b0..900906cfa425 100644 --- a/dlls/dxgi/dxgi_private.h +++ b/dlls/dxgi/dxgi_private.h @@ -173,6 +173,8 @@ struct d3d11_swapchain IDXGIOutput *target; };
+HRESULT d3d11_swapchain_create(IWineDXGIDevice *device, HWND window, const DXGI_SWAP_CHAIN_DESC1 *swapchain_desc, + const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *fullscreen_desc, IDXGISwapChain1 **swapchain) DECLSPEC_HIDDEN; HRESULT d3d11_swapchain_init(struct d3d11_swapchain *swapchain, struct dxgi_device *device, struct wined3d_swapchain_desc *desc, BOOL implicit) DECLSPEC_HIDDEN;
diff --git a/dlls/dxgi/factory.c b/dlls/dxgi/factory.c index 698680418f43..5c47c6d9189e 100644 --- a/dlls/dxgi/factory.c +++ b/dlls/dxgi/factory.c @@ -250,8 +250,6 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForHwnd(IWineDXGIFa const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *fullscreen_desc, IDXGIOutput *output, IDXGISwapChain1 **swapchain) { - struct wined3d_swapchain *wined3d_swapchain; - struct wined3d_swapchain_desc wined3d_desc; unsigned int min_buffer_count; IWineDXGIDevice *dxgi_device; HRESULT hr; @@ -275,22 +273,12 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForHwnd(IWineDXGIFa switch (swapchain_desc->SwapEffect) { case DXGI_SWAP_EFFECT_DISCARD: - wined3d_desc.swap_effect = WINED3D_SWAP_EFFECT_DISCARD; - min_buffer_count = 1; - break; - case DXGI_SWAP_EFFECT_SEQUENTIAL: - wined3d_desc.swap_effect = WINED3D_SWAP_EFFECT_SEQUENTIAL; min_buffer_count = 1; break;
case DXGI_SWAP_EFFECT_FLIP_DISCARD: - wined3d_desc.swap_effect = WINED3D_SWAP_EFFECT_FLIP_DISCARD; - min_buffer_count = 2; - break; - case DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL: - wined3d_desc.swap_effect = WINED3D_SWAP_EFFECT_FLIP_SEQUENTIAL; min_buffer_count = 2; break;
@@ -305,49 +293,15 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForHwnd(IWineDXGIFa return DXGI_ERROR_INVALID_CALL; }
- if (FAILED(hr = IUnknown_QueryInterface(device, &IID_IWineDXGIDevice, (void **)&dxgi_device))) - { - ERR("This is not the device we're looking for\n"); - return hr; - } - - if (swapchain_desc->Scaling != DXGI_SCALING_STRETCH) - FIXME("Ignoring scaling %#x.\n", swapchain_desc->Scaling); - if (swapchain_desc->AlphaMode != DXGI_ALPHA_MODE_IGNORE) - FIXME("Ignoring alpha mode %#x.\n", swapchain_desc->AlphaMode); - if (fullscreen_desc && fullscreen_desc->ScanlineOrdering) - FIXME("Unhandled scanline ordering %#x.\n", fullscreen_desc->ScanlineOrdering); - if (fullscreen_desc && fullscreen_desc->Scaling) - FIXME("Unhandled mode scaling %#x.\n", fullscreen_desc->Scaling); - - wined3d_desc.backbuffer_width = swapchain_desc->Width; - wined3d_desc.backbuffer_height = swapchain_desc->Height; - wined3d_desc.backbuffer_format = wined3dformat_from_dxgi_format(swapchain_desc->Format); - wined3d_desc.backbuffer_count = swapchain_desc->BufferCount; - wined3d_desc.backbuffer_usage = wined3d_usage_from_dxgi_usage(swapchain_desc->BufferUsage); - wined3d_sample_desc_from_dxgi(&wined3d_desc.multisample_type, - &wined3d_desc.multisample_quality, &swapchain_desc->SampleDesc); - wined3d_desc.device_window = window; - wined3d_desc.windowed = fullscreen_desc ? fullscreen_desc->Windowed : TRUE; - wined3d_desc.enable_auto_depth_stencil = FALSE; - wined3d_desc.auto_depth_stencil_format = 0; - wined3d_desc.flags = wined3d_swapchain_flags_from_dxgi(swapchain_desc->Flags); - wined3d_desc.refresh_rate = fullscreen_desc ? dxgi_rational_to_uint(&fullscreen_desc->RefreshRate) : 0; - wined3d_desc.auto_restore_display_mode = TRUE; - - hr = IWineDXGIDevice_create_swapchain(dxgi_device, &wined3d_desc, FALSE, &wined3d_swapchain); - IWineDXGIDevice_Release(dxgi_device); - if (FAILED(hr)) + if (SUCCEEDED(IUnknown_QueryInterface(device, &IID_IWineDXGIDevice, (void **)&dxgi_device))) { - WARN("Failed to create swapchain, hr %#x.\n", hr); + hr = d3d11_swapchain_create(dxgi_device, window, swapchain_desc, fullscreen_desc, swapchain); + IWineDXGIDevice_Release(dxgi_device); return hr; }
- wined3d_mutex_lock(); - *swapchain = wined3d_swapchain_get_parent(wined3d_swapchain); - wined3d_mutex_unlock(); - - return S_OK; + ERR("This is not the device we're looking for.\n"); + return DXGI_ERROR_UNSUPPORTED; }
static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForCoreWindow(IWineDXGIFactory *iface, diff --git a/dlls/dxgi/swapchain.c b/dlls/dxgi/swapchain.c index c85b742e4f80..7401a2e1e7fa 100644 --- a/dlls/dxgi/swapchain.c +++ b/dlls/dxgi/swapchain.c @@ -733,3 +733,66 @@ cleanup: IWineDXGIDevice_Release(swapchain->device); return hr; } + +HRESULT d3d11_swapchain_create(IWineDXGIDevice *device, HWND window, const DXGI_SWAP_CHAIN_DESC1 *swapchain_desc, + const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *fullscreen_desc, IDXGISwapChain1 **swapchain) +{ + struct wined3d_swapchain *wined3d_swapchain; + struct wined3d_swapchain_desc wined3d_desc; + HRESULT hr; + + if (swapchain_desc->Scaling != DXGI_SCALING_STRETCH) + FIXME("Ignoring scaling %#x.\n", swapchain_desc->Scaling); + if (swapchain_desc->AlphaMode != DXGI_ALPHA_MODE_IGNORE) + FIXME("Ignoring alpha mode %#x.\n", swapchain_desc->AlphaMode); + if (fullscreen_desc && fullscreen_desc->ScanlineOrdering) + FIXME("Unhandled scanline ordering %#x.\n", fullscreen_desc->ScanlineOrdering); + if (fullscreen_desc && fullscreen_desc->Scaling) + FIXME("Unhandled mode scaling %#x.\n", fullscreen_desc->Scaling); + + switch (swapchain_desc->SwapEffect) + { + case DXGI_SWAP_EFFECT_DISCARD: + wined3d_desc.swap_effect = WINED3D_SWAP_EFFECT_DISCARD; + break; + case DXGI_SWAP_EFFECT_SEQUENTIAL: + wined3d_desc.swap_effect = WINED3D_SWAP_EFFECT_SEQUENTIAL; + break; + case DXGI_SWAP_EFFECT_FLIP_DISCARD: + wined3d_desc.swap_effect = WINED3D_SWAP_EFFECT_FLIP_DISCARD; + break; + case DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL: + wined3d_desc.swap_effect = WINED3D_SWAP_EFFECT_FLIP_SEQUENTIAL; + break; + default: + WARN("Invalid swap effect %#x.\n", swapchain_desc->SwapEffect); + return DXGI_ERROR_INVALID_CALL; + } + + wined3d_desc.backbuffer_width = swapchain_desc->Width; + wined3d_desc.backbuffer_height = swapchain_desc->Height; + wined3d_desc.backbuffer_format = wined3dformat_from_dxgi_format(swapchain_desc->Format); + wined3d_desc.backbuffer_count = swapchain_desc->BufferCount; + wined3d_desc.backbuffer_usage = wined3d_usage_from_dxgi_usage(swapchain_desc->BufferUsage); + wined3d_sample_desc_from_dxgi(&wined3d_desc.multisample_type, + &wined3d_desc.multisample_quality, &swapchain_desc->SampleDesc); + wined3d_desc.device_window = window; + wined3d_desc.windowed = fullscreen_desc ? fullscreen_desc->Windowed : TRUE; + wined3d_desc.enable_auto_depth_stencil = FALSE; + wined3d_desc.auto_depth_stencil_format = 0; + wined3d_desc.flags = wined3d_swapchain_flags_from_dxgi(swapchain_desc->Flags); + wined3d_desc.refresh_rate = fullscreen_desc ? dxgi_rational_to_uint(&fullscreen_desc->RefreshRate) : 0; + wined3d_desc.auto_restore_display_mode = TRUE; + + if (FAILED(hr = IWineDXGIDevice_create_swapchain(device, &wined3d_desc, FALSE, &wined3d_swapchain))) + { + WARN("Failed to create swapchain, hr %#x.\n", hr); + return hr; + } + + wined3d_mutex_lock(); + *swapchain = wined3d_swapchain_get_parent(wined3d_swapchain); + wined3d_mutex_unlock(); + + return S_OK; +}
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com ---
The current plan is to have two implementations of the IDXGISwapChain interface (one for Vulkan and one for wined3d). Other DXGI interfaces have to be shared between D3D11 and D3D12, e.g. D3D11 and D3D12 devices can be created from the same adapter.
--- dlls/dxgi/dxgi_private.h | 7 +- dlls/dxgi/factory.c | 8 + dlls/dxgi/swapchain.c | 546 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 560 insertions(+), 1 deletion(-)
diff --git a/dlls/dxgi/dxgi_private.h b/dlls/dxgi/dxgi_private.h index 900906cfa425..547bd19249a7 100644 --- a/dlls/dxgi/dxgi_private.h +++ b/dlls/dxgi/dxgi_private.h @@ -31,8 +31,9 @@ #include "objbase.h" #include "winnls.h"
-#include "d3d10_1.h" #include "dxgi1_6.h" +#include "d3d10_1.h" +#include "d3d12.h" #ifdef DXGI_INIT_GUID #include "initguid.h" #endif @@ -178,6 +179,10 @@ HRESULT d3d11_swapchain_create(IWineDXGIDevice *device, HWND window, const DXGI_ HRESULT d3d11_swapchain_init(struct d3d11_swapchain *swapchain, struct dxgi_device *device, struct wined3d_swapchain_desc *desc, BOOL implicit) DECLSPEC_HIDDEN;
+HRESULT d3d12_swapchain_create(IWineDXGIFactory *factory, ID3D12CommandQueue *queue, HWND window, + const DXGI_SWAP_CHAIN_DESC1 *swapchain_desc, const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *fullscreen_desc, + IDXGISwapChain1 **swapchain) DECLSPEC_HIDDEN; + /* IDXGISurface */ struct dxgi_surface { diff --git a/dlls/dxgi/factory.c b/dlls/dxgi/factory.c index 5c47c6d9189e..a3eb1085b309 100644 --- a/dlls/dxgi/factory.c +++ b/dlls/dxgi/factory.c @@ -250,6 +250,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForHwnd(IWineDXGIFa const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *fullscreen_desc, IDXGIOutput *output, IDXGISwapChain1 **swapchain) { + ID3D12CommandQueue *command_queue; unsigned int min_buffer_count; IWineDXGIDevice *dxgi_device; HRESULT hr; @@ -300,6 +301,13 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForHwnd(IWineDXGIFa return hr; }
+ if (SUCCEEDED(IUnknown_QueryInterface(device, &IID_ID3D12CommandQueue, (void **)&command_queue))) + { + hr = d3d12_swapchain_create(iface, command_queue, window, swapchain_desc, fullscreen_desc, swapchain); + ID3D12CommandQueue_Release(command_queue); + return hr; + } + ERR("This is not the device we're looking for.\n"); return DXGI_ERROR_UNSUPPORTED; } diff --git a/dlls/dxgi/swapchain.c b/dlls/dxgi/swapchain.c index 7401a2e1e7fa..ca4e59004ef2 100644 --- a/dlls/dxgi/swapchain.c +++ b/dlls/dxgi/swapchain.c @@ -796,3 +796,549 @@ HRESULT d3d11_swapchain_create(IWineDXGIDevice *device, HWND window, const DXGI_
return S_OK; } + +struct d3d12_swapchain +{ + IDXGISwapChain3 IDXGISwapChain3_iface; + LONG refcount; + struct wined3d_private_store private_store; + + ID3D12CommandQueue *command_queue; + ID3D12Device *device; + IWineDXGIFactory *factory; + + HWND window; + DXGI_SWAP_CHAIN_DESC1 desc; + DXGI_SWAP_CHAIN_FULLSCREEN_DESC fullscreen_desc; +}; + +static inline struct d3d12_swapchain *d3d12_swapchain_from_IDXGISwapChain3(IDXGISwapChain3 *iface) +{ + return CONTAINING_RECORD(iface, struct d3d12_swapchain, IDXGISwapChain3_iface); +} + +/* IUnknown methods */ + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_QueryInterface(IDXGISwapChain3 *iface, REFIID iid, void **object) +{ + TRACE("iface %p, iid %s, object %p.\n", iface, debugstr_guid(iid), object); + + if (IsEqualGUID(iid, &IID_IUnknown) + || IsEqualGUID(iid, &IID_IDXGIObject) + || IsEqualGUID(iid, &IID_IDXGIDeviceSubObject) + || IsEqualGUID(iid, &IID_IDXGISwapChain) + || IsEqualGUID(iid, &IID_IDXGISwapChain1) + || IsEqualGUID(iid, &IID_IDXGISwapChain2) + || IsEqualGUID(iid, &IID_IDXGISwapChain3)) + { + IUnknown_AddRef(iface); + *object = iface; + return S_OK; + } + + WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); + + *object = NULL; + return E_NOINTERFACE; +} + +static ULONG STDMETHODCALLTYPE d3d12_swapchain_AddRef(IDXGISwapChain3 *iface) +{ + struct d3d12_swapchain *swapchain = d3d12_swapchain_from_IDXGISwapChain3(iface); + ULONG refcount = InterlockedIncrement(&swapchain->refcount); + + TRACE("%p increasing refcount to %u.\n", swapchain, refcount); + + return refcount; +} + +static ULONG STDMETHODCALLTYPE d3d12_swapchain_Release(IDXGISwapChain3 *iface) +{ + struct d3d12_swapchain *swapchain = d3d12_swapchain_from_IDXGISwapChain3(iface); + ULONG refcount = InterlockedDecrement(&swapchain->refcount); + + TRACE("%p decreasing refcount to %u.\n", swapchain, refcount); + + if (!refcount) + { + ID3D12CommandQueue_Release(swapchain->command_queue); + IWineDXGIFactory_Release(swapchain->factory); + + wined3d_private_store_cleanup(&swapchain->private_store); + + ID3D12Device_Release(swapchain->device); + + heap_free(swapchain); + } + + return refcount; +} + +/* IDXGIObject methods */ + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_SetPrivateData(IDXGISwapChain3 *iface, + REFGUID guid, UINT data_size, const void *data) +{ + struct d3d12_swapchain *swapchain = d3d12_swapchain_from_IDXGISwapChain3(iface); + + TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data); + + return dxgi_set_private_data(&swapchain->private_store, guid, data_size, data); +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_SetPrivateDataInterface(IDXGISwapChain3 *iface, + REFGUID guid, const IUnknown *object) +{ + struct d3d12_swapchain *swapchain = d3d12_swapchain_from_IDXGISwapChain3(iface); + + TRACE("iface %p, guid %s, object %p.\n", iface, debugstr_guid(guid), object); + + return dxgi_set_private_data_interface(&swapchain->private_store, guid, object); +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_GetPrivateData(IDXGISwapChain3 *iface, + REFGUID guid, UINT *data_size, void *data) +{ + struct d3d12_swapchain *swapchain = d3d12_swapchain_from_IDXGISwapChain3(iface); + + TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data); + + return dxgi_get_private_data(&swapchain->private_store, guid, data_size, data); +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_GetParent(IDXGISwapChain3 *iface, REFIID iid, void **parent) +{ + struct d3d12_swapchain *swapchain = d3d12_swapchain_from_IDXGISwapChain3(iface); + + TRACE("iface %p, iid %s, parent %p.\n", iface, debugstr_guid(iid), parent); + + return IWineDXGIFactory_QueryInterface(swapchain->factory, iid, parent); +} + +/* IDXGIDeviceSubObject methods */ + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_GetDevice(IDXGISwapChain3 *iface, REFIID iid, void **device) +{ + struct d3d12_swapchain *swapchain = d3d12_swapchain_from_IDXGISwapChain3(iface); + + TRACE("iface %p, iid %s, device %p.\n", iface, debugstr_guid(iid), device); + + return ID3D12Device_QueryInterface(swapchain->device, iid, device); +} + +/* IDXGISwapChain methods */ + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_Present(IDXGISwapChain3 *iface, UINT sync_interval, UINT flags) +{ + struct d3d12_swapchain *swapchain = d3d12_swapchain_from_IDXGISwapChain3(iface); + + TRACE("iface %p, sync_interval %u, flags %#x.\n", iface, sync_interval, flags); + + return IDXGISwapChain3_Present1(&swapchain->IDXGISwapChain3_iface, sync_interval, flags, NULL); +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_GetBuffer(IDXGISwapChain3 *iface, + UINT buffer_idx, REFIID iid, void **surface) +{ + FIXME("iface %p, buffer_idx %u, iid %s, surface %p stub!\n", + iface, buffer_idx, debugstr_guid(iid), surface); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE DECLSPEC_HOTPATCH d3d12_swapchain_SetFullscreenState(IDXGISwapChain3 *iface, + BOOL fullscreen, IDXGIOutput *target) +{ + FIXME("iface %p, fullscreen %#x, target %p stub!\n", iface, fullscreen, target); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_GetFullscreenState(IDXGISwapChain3 *iface, + BOOL *fullscreen, IDXGIOutput **target) +{ + FIXME("iface %p, fullscreen %p, target %p stub!n", iface, fullscreen, target); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_GetDesc(IDXGISwapChain3 *iface, DXGI_SWAP_CHAIN_DESC *desc) +{ + struct d3d12_swapchain *swapchain = d3d12_swapchain_from_IDXGISwapChain3(iface); + const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *fullscreen_desc = &swapchain->fullscreen_desc; + const DXGI_SWAP_CHAIN_DESC1 *swapchain_desc = &swapchain->desc; + + TRACE("iface %p, desc %p.\n", iface, desc); + + if (!desc) + { + WARN("Invalid pointer.\n"); + return E_INVALIDARG; + } + + desc->BufferDesc.Width = swapchain_desc->Width; + desc->BufferDesc.Height = swapchain_desc->Height; + desc->BufferDesc.RefreshRate = fullscreen_desc->RefreshRate; + desc->BufferDesc.Format = swapchain_desc->Format; + desc->BufferDesc.ScanlineOrdering = fullscreen_desc->ScanlineOrdering; + desc->BufferDesc.Scaling = fullscreen_desc->Scaling; + desc->SampleDesc = swapchain_desc->SampleDesc; + desc->BufferUsage = swapchain_desc->BufferUsage; + desc->BufferCount = swapchain_desc->BufferCount; + desc->OutputWindow = swapchain->window; + desc->Windowed = fullscreen_desc->Windowed; + desc->SwapEffect = swapchain_desc->SwapEffect; + desc->Flags = swapchain_desc->Flags; + + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_ResizeBuffers(IDXGISwapChain3 *iface, + UINT buffer_count, UINT width, UINT height, DXGI_FORMAT format, UINT flags) +{ + FIXME("iface %p, buffer_count %u, width %u, height %u, format %s, flags %#x stub!\n", + iface, buffer_count, width, height, debug_dxgi_format(format), flags); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_ResizeTarget(IDXGISwapChain3 *iface, + const DXGI_MODE_DESC *target_mode_desc) +{ + FIXME("iface %p, target_mode_desc %p stub!\n", iface, target_mode_desc); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_GetContainingOutput(IDXGISwapChain3 *iface, + IDXGIOutput **output) +{ + FIXME("iface %p, output %p stub!\n", iface, output); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_GetFrameStatistics(IDXGISwapChain3 *iface, + DXGI_FRAME_STATISTICS *stats) +{ + FIXME("iface %p, stats %p stub!\n", iface, stats); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_GetLastPresentCount(IDXGISwapChain3 *iface, + UINT *last_present_count) +{ + FIXME("iface %p, last_present_count %p stub!\n", iface, last_present_count); + + return E_NOTIMPL; +} + +/* IDXGISwapChain1 methods */ + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_GetDesc1(IDXGISwapChain3 *iface, DXGI_SWAP_CHAIN_DESC1 *desc) +{ + struct d3d12_swapchain *swapchain = d3d12_swapchain_from_IDXGISwapChain3(iface); + + TRACE("iface %p, desc %p.\n", iface, desc); + + if (!desc) + { + WARN("Invalid pointer.\n"); + return E_INVALIDARG; + } + + *desc = swapchain->desc; + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_GetFullscreenDesc(IDXGISwapChain3 *iface, + DXGI_SWAP_CHAIN_FULLSCREEN_DESC *desc) +{ + struct d3d12_swapchain *swapchain = d3d12_swapchain_from_IDXGISwapChain3(iface); + + TRACE("iface %p, desc %p.\n", iface, desc); + + if (!desc) + { + WARN("Invalid pointer.\n"); + return E_INVALIDARG; + } + + *desc = swapchain->fullscreen_desc; + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_GetHwnd(IDXGISwapChain3 *iface, HWND *hwnd) +{ + struct d3d12_swapchain *swapchain = d3d12_swapchain_from_IDXGISwapChain3(iface); + + TRACE("iface %p, hwnd %p.\n", iface, hwnd); + + if (!hwnd) + { + WARN("Invalid pointer.\n"); + return DXGI_ERROR_INVALID_CALL; + } + + *hwnd = swapchain->window; + return S_OK; +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_GetCoreWindow(IDXGISwapChain3 *iface, + REFIID iid, void **core_window) +{ + FIXME("iface %p, iid %s, core_window %p stub!\n", iface, debugstr_guid(iid), core_window); + + if (core_window) + *core_window = NULL; + + return DXGI_ERROR_INVALID_CALL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_Present1(IDXGISwapChain3 *iface, + UINT sync_interval, UINT flags, const DXGI_PRESENT_PARAMETERS *present_parameters) +{ + FIXME("iface %p, sync_interval %u, flags %#x, present_parameters %p stub!\n", + iface, sync_interval, flags, present_parameters); + + return E_NOTIMPL; +} + +static BOOL STDMETHODCALLTYPE d3d12_swapchain_IsTemporaryMonoSupported(IDXGISwapChain3 *iface) +{ + FIXME("iface %p stub!\n", iface); + + return FALSE; +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_GetRestrictToOutput(IDXGISwapChain3 *iface, IDXGIOutput **output) +{ + FIXME("iface %p, output %p stub!\n", iface, output); + + if (!output) + { + WARN("Invalid pointer.\n"); + return E_INVALIDARG; + } + + *output = NULL; + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_SetBackgroundColor(IDXGISwapChain3 *iface, const DXGI_RGBA *color) +{ + FIXME("iface %p, color %p stub!\n", iface, color); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_GetBackgroundColor(IDXGISwapChain3 *iface, DXGI_RGBA *color) +{ + FIXME("iface %p, color %p stub!\n", iface, color); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_SetRotation(IDXGISwapChain3 *iface, DXGI_MODE_ROTATION rotation) +{ + FIXME("iface %p, rotation %#x stub!\n", iface, rotation); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_GetRotation(IDXGISwapChain3 *iface, DXGI_MODE_ROTATION *rotation) +{ + FIXME("iface %p, rotation %p stub!\n", iface, rotation); + + return E_NOTIMPL; +} + +/* IDXGISwapChain2 methods */ + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_SetSourceSize(IDXGISwapChain3 *iface, UINT width, UINT height) +{ + FIXME("iface %p, width %u, height %u stub!\n", iface, width, height); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_GetSourceSize(IDXGISwapChain3 *iface, UINT *width, UINT *height) +{ + FIXME("iface %p, width %p, height %p stub!\n", iface, width, height); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_SetMaximumFrameLatency(IDXGISwapChain3 *iface, UINT max_latency) +{ + FIXME("iface %p, max_latency %u stub!\n", iface, max_latency); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_GetMaximumFrameLatency(IDXGISwapChain3 *iface, UINT *max_latency) +{ + FIXME("iface %p, max_latency %p stub!\n", iface, max_latency); + + return E_NOTIMPL; +} + +static HANDLE STDMETHODCALLTYPE d3d12_swapchain_GetFrameLatencyWaitableObject(IDXGISwapChain3 *iface) +{ + FIXME("iface %p stub!\n", iface); + + return NULL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_SetMatrixTransform(IDXGISwapChain3 *iface, + const DXGI_MATRIX_3X2_F *matrix) +{ + FIXME("iface %p, matrix %p stub!\n", iface, matrix); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_GetMatrixTransform(IDXGISwapChain3 *iface, + DXGI_MATRIX_3X2_F *matrix) +{ + FIXME("iface %p, matrix %p stub!\n", iface, matrix); + + return E_NOTIMPL; +} + +/* IDXGISwapChain3 methods */ + +static UINT STDMETHODCALLTYPE d3d12_swapchain_GetCurrentBackBufferIndex(IDXGISwapChain3 *iface) +{ + FIXME("iface %p stub!\n", iface); + + return 0; +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_CheckColorSpaceSupport(IDXGISwapChain3 *iface, + DXGI_COLOR_SPACE_TYPE colour_space, UINT *colour_space_support) +{ + FIXME("iface %p, colour_space %#x, colour_space_support %p stub!\n", + iface, colour_space, colour_space_support); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_SetColorSpace1(IDXGISwapChain3 *iface, + DXGI_COLOR_SPACE_TYPE colour_space) +{ + FIXME("iface %p, colour_space %#x stub!\n", iface, colour_space); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d12_swapchain_ResizeBuffers1(IDXGISwapChain3 *iface, + UINT buffer_count, UINT width, UINT height, DXGI_FORMAT format, UINT flags, + const UINT *node_mask, IUnknown * const *present_queue) +{ + FIXME("iface %p, buffer_count %u, width %u, height %u, format %s, flags %#x, " + "node_mask %p, present_queue %p stub!\n", + iface, buffer_count, width, height, debug_dxgi_format(format), flags, node_mask, present_queue); + + return E_NOTIMPL; +} + +static const struct IDXGISwapChain3Vtbl d3d12_swapchain_vtbl = +{ + /* IUnknown methods */ + d3d12_swapchain_QueryInterface, + d3d12_swapchain_AddRef, + d3d12_swapchain_Release, + /* IDXGIObject methods */ + d3d12_swapchain_SetPrivateData, + d3d12_swapchain_SetPrivateDataInterface, + d3d12_swapchain_GetPrivateData, + d3d12_swapchain_GetParent, + /* IDXGIDeviceSubObject methods */ + d3d12_swapchain_GetDevice, + /* IDXGISwapChain methods */ + d3d12_swapchain_Present, + d3d12_swapchain_GetBuffer, + d3d12_swapchain_SetFullscreenState, + d3d12_swapchain_GetFullscreenState, + d3d12_swapchain_GetDesc, + d3d12_swapchain_ResizeBuffers, + d3d12_swapchain_ResizeTarget, + d3d12_swapchain_GetContainingOutput, + d3d12_swapchain_GetFrameStatistics, + d3d12_swapchain_GetLastPresentCount, + /* IDXGISwapChain1 methods */ + d3d12_swapchain_GetDesc1, + d3d12_swapchain_GetFullscreenDesc, + d3d12_swapchain_GetHwnd, + d3d12_swapchain_GetCoreWindow, + d3d12_swapchain_Present1, + d3d12_swapchain_IsTemporaryMonoSupported, + d3d12_swapchain_GetRestrictToOutput, + d3d12_swapchain_SetBackgroundColor, + d3d12_swapchain_GetBackgroundColor, + d3d12_swapchain_SetRotation, + d3d12_swapchain_GetRotation, + /* IDXGISwapChain2 methods */ + d3d12_swapchain_SetSourceSize, + d3d12_swapchain_GetSourceSize, + d3d12_swapchain_SetMaximumFrameLatency, + d3d12_swapchain_GetMaximumFrameLatency, + d3d12_swapchain_GetFrameLatencyWaitableObject, + d3d12_swapchain_SetMatrixTransform, + d3d12_swapchain_GetMatrixTransform, + /* IDXGISwapChain3 methods */ + d3d12_swapchain_GetCurrentBackBufferIndex, + d3d12_swapchain_CheckColorSpaceSupport, + d3d12_swapchain_SetColorSpace1, + d3d12_swapchain_ResizeBuffers1, +}; + +HRESULT d3d12_swapchain_create(IWineDXGIFactory *factory, ID3D12CommandQueue *queue, HWND window, + const DXGI_SWAP_CHAIN_DESC1 *swapchain_desc, const DXGI_SWAP_CHAIN_FULLSCREEN_DESC *fullscreen_desc, + IDXGISwapChain1 **swapchain) +{ + struct d3d12_swapchain *object; + ID3D12Device *device; + HRESULT hr; + + if (FAILED(hr = ID3D12CommandQueue_GetDevice(queue, &IID_ID3D12Device, (void **)&device))) + { + ERR("Failed to get D3D12 device, hr %#x.\n", hr); + return hr; + } + + if (!(object = heap_alloc_zero(sizeof(*object)))) + { + ID3D12Device_Release(device); + return E_OUTOFMEMORY; + } + + object->IDXGISwapChain3_iface.lpVtbl = &d3d12_swapchain_vtbl; + object->refcount = 1; + + wined3d_private_store_init(&object->private_store); + + ID3D12CommandQueue_AddRef(object->command_queue = queue); + object->device = device; + IWineDXGIFactory_AddRef(object->factory = factory); + + object->window = window; + object->desc = *swapchain_desc; + if (fullscreen_desc) + { + object->fullscreen_desc = *fullscreen_desc; + } + else + { + memset(&object->fullscreen_desc, 0, sizeof(object->fullscreen_desc)); + object->fullscreen_desc.Windowed = TRUE; + } + + TRACE("Created swapchain %p.\n", object); + + *swapchain = (IDXGISwapChain1 *)&object->IDXGISwapChain3_iface; + + return S_OK; +}
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com