d3d10core: Implement d3d10_device_GetPredication().
[wine/multimedia.git] / dlls / d3d10core / async.c
blob830b2b4a725539eba1feb3032423cd71b3850514
1 /*
2 * Copyright 2009 Henri Verbeet for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "config.h"
21 #include "wine/port.h"
23 #include "d3d10core_private.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(d3d10core);
27 static inline struct d3d10_query *impl_from_ID3D10Query(ID3D10Query *iface)
29 return CONTAINING_RECORD(iface, struct d3d10_query, ID3D10Query_iface);
32 /* IUnknown methods */
34 static HRESULT STDMETHODCALLTYPE d3d10_query_QueryInterface(ID3D10Query *iface, REFIID riid, void **object)
36 struct d3d10_query *query = impl_from_ID3D10Query(iface);
38 TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
40 if ((IsEqualGUID(riid, &IID_ID3D10Predicate) && query->predicate)
41 || IsEqualGUID(riid, &IID_ID3D10Query)
42 || IsEqualGUID(riid, &IID_ID3D10Asynchronous)
43 || IsEqualGUID(riid, &IID_ID3D10DeviceChild)
44 || IsEqualGUID(riid, &IID_IUnknown))
46 IUnknown_AddRef(iface);
47 *object = iface;
48 return S_OK;
51 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
53 *object = NULL;
54 return E_NOINTERFACE;
57 static ULONG STDMETHODCALLTYPE d3d10_query_AddRef(ID3D10Query *iface)
59 struct d3d10_query *This = impl_from_ID3D10Query(iface);
60 ULONG refcount = InterlockedIncrement(&This->refcount);
62 TRACE("%p increasing refcount to %u.\n", This, refcount);
64 return refcount;
67 static ULONG STDMETHODCALLTYPE d3d10_query_Release(ID3D10Query *iface)
69 struct d3d10_query *This = impl_from_ID3D10Query(iface);
70 ULONG refcount = InterlockedDecrement(&This->refcount);
72 TRACE("%p decreasing refcount to %u.\n", This, refcount);
74 if (!refcount)
76 ID3D10Device1_Release(This->device);
77 HeapFree(GetProcessHeap(), 0, This);
80 return refcount;
83 /* ID3D10DeviceChild methods */
85 static void STDMETHODCALLTYPE d3d10_query_GetDevice(ID3D10Query *iface, ID3D10Device **device)
87 struct d3d10_query *query = impl_from_ID3D10Query(iface);
89 TRACE("iface %p, device %p.\n", iface, device);
91 *device = (ID3D10Device *)query->device;
92 ID3D10Device_AddRef(*device);
95 static HRESULT STDMETHODCALLTYPE d3d10_query_GetPrivateData(ID3D10Query *iface,
96 REFGUID guid, UINT *data_size, void *data)
98 FIXME("iface %p, guid %s, data_size %p, data %p stub!\n",
99 iface, debugstr_guid(guid), data_size, data);
101 return E_NOTIMPL;
104 static HRESULT STDMETHODCALLTYPE d3d10_query_SetPrivateData(ID3D10Query *iface,
105 REFGUID guid, UINT data_size, const void *data)
107 FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
108 iface, debugstr_guid(guid), data_size, data);
110 return E_NOTIMPL;
113 static HRESULT STDMETHODCALLTYPE d3d10_query_SetPrivateDataInterface(ID3D10Query *iface,
114 REFGUID guid, const IUnknown *data)
116 FIXME("iface %p, guid %s, data %p stub!\n", iface, debugstr_guid(guid), data);
118 return E_NOTIMPL;
121 /* ID3D10Asynchronous methods */
123 static void STDMETHODCALLTYPE d3d10_query_Begin(ID3D10Query *iface)
125 FIXME("iface %p stub!\n", iface);
128 static void STDMETHODCALLTYPE d3d10_query_End(ID3D10Query *iface)
130 FIXME("iface %p stub!\n", iface);
133 static HRESULT STDMETHODCALLTYPE d3d10_query_GetData(ID3D10Query *iface, void *data, UINT data_size, UINT flags)
135 FIXME("iface %p, data %p, data_size %u, flags %#x stub!\n", iface, data, data_size, flags);
137 return E_NOTIMPL;
140 static UINT STDMETHODCALLTYPE d3d10_query_GetDataSize(ID3D10Query *iface)
142 FIXME("iface %p stub!\n", iface);
144 return 0;
147 /* ID3D10Query methods */
149 static void STDMETHODCALLTYPE d3d10_query_GetDesc(ID3D10Query *iface, D3D10_QUERY_DESC *desc)
151 FIXME("iface %p, desc %p stub!\n", iface, desc);
154 static const struct ID3D10QueryVtbl d3d10_query_vtbl =
156 /* IUnknown methods */
157 d3d10_query_QueryInterface,
158 d3d10_query_AddRef,
159 d3d10_query_Release,
160 /* ID3D10DeviceChild methods */
161 d3d10_query_GetDevice,
162 d3d10_query_GetPrivateData,
163 d3d10_query_SetPrivateData,
164 d3d10_query_SetPrivateDataInterface,
165 /* ID3D10Asynchronous methods */
166 d3d10_query_Begin,
167 d3d10_query_End,
168 d3d10_query_GetData,
169 d3d10_query_GetDataSize,
170 /* ID3D10Query methods */
171 d3d10_query_GetDesc,
174 struct d3d10_query *unsafe_impl_from_ID3D10Query(ID3D10Query *iface)
176 if (!iface)
177 return NULL;
178 assert(iface->lpVtbl == &d3d10_query_vtbl);
179 return CONTAINING_RECORD(iface, struct d3d10_query, ID3D10Query_iface);
182 HRESULT d3d10_query_init(struct d3d10_query *query, struct d3d10_device *device,
183 const D3D10_QUERY_DESC *desc, BOOL predicate)
185 HRESULT hr;
187 static const enum wined3d_query_type query_type_map[] =
189 /* D3D10_QUERY_EVENT */ WINED3D_QUERY_TYPE_EVENT,
190 /* D3D10_QUERY_OCCLUSION */ WINED3D_QUERY_TYPE_OCCLUSION,
191 /* D3D10_QUERY_TIMESTAMP */ WINED3D_QUERY_TYPE_TIMESTAMP,
192 /* D3D10_QUERY_TIMESTAMP_DISJOINT */ WINED3D_QUERY_TYPE_TIMESTAMP_DISJOINT,
193 /* D3D10_QUERY_PIPELINE_STATISTICS */ WINED3D_QUERY_TYPE_PIPELINE_STATISTICS,
194 /* D3D10_QUERY_OCCLUSION_PREDICATE */ WINED3D_QUERY_TYPE_OCCLUSION,
195 /* D3D10_QUERY_SO_STATISTICS */ WINED3D_QUERY_TYPE_SO_STATISTICS,
196 /* D3D10_QUERY_SO_OVERFLOW_PREDICATE */ WINED3D_QUERY_TYPE_SO_OVERFLOW,
199 if (desc->Query > sizeof(query_type_map) / sizeof(*query_type_map))
201 FIXME("Unhandled query type %#x.\n", desc->Query);
202 return E_INVALIDARG;
205 if (desc->MiscFlags)
206 FIXME("Ignoring MiscFlags %#x.\n", desc->MiscFlags);
208 query->ID3D10Query_iface.lpVtbl = &d3d10_query_vtbl;
209 query->refcount = 1;
211 if (FAILED(hr = wined3d_query_create(device->wined3d_device,
212 query_type_map[desc->Query], query, &query->wined3d_query)))
214 WARN("Failed to create wined3d query, hr %#x.\n", hr);
215 return hr;
218 query->predicate = predicate;
219 query->device = &device->ID3D10Device1_iface;
220 ID3D10Device1_AddRef(query->device);
222 return S_OK;