bcrypt: Add BCryptDeriveKey stub.
[wine.git] / dlls / d3d9 / d3d9_main.c
blobbd0524b9da2ae000f9b28c1be4d6dfa8cc6b4f7c
1 /*
2 * Direct3D 9
4 * Copyright 2002-2003 Jason Edmeades
5 * Copyright 2002-2003 Raphael Junqueira
6 * Copyright 2005 Oliver Stieber
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "config.h"
25 #include "wine/port.h"
26 #include "initguid.h"
27 #include "d3d9_private.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
31 static int D3DPERF_event_level = 0;
33 void WINAPI DebugSetMute(void) {
34 /* nothing to do */
37 IDirect3D9 * WINAPI DECLSPEC_HOTPATCH Direct3DCreate9(UINT sdk_version)
39 struct d3d9 *object;
41 TRACE("sdk_version %#x.\n", sdk_version);
43 if (!(object = heap_alloc_zero(sizeof(*object))))
44 return NULL;
46 if (!d3d9_init(object, FALSE))
48 WARN("Failed to initialize d3d9.\n");
49 heap_free(object);
50 return NULL;
53 TRACE("Created d3d9 object %p.\n", object);
55 return (IDirect3D9 *)&object->IDirect3D9Ex_iface;
58 HRESULT WINAPI DECLSPEC_HOTPATCH Direct3DCreate9Ex(UINT sdk_version, IDirect3D9Ex **d3d9ex)
60 struct d3d9 *object;
62 TRACE("sdk_version %#x, d3d9ex %p.\n", sdk_version, d3d9ex);
64 if (!(object = heap_alloc_zero(sizeof(*object))))
65 return E_OUTOFMEMORY;
67 if (!d3d9_init(object, TRUE))
69 WARN("Failed to initialize d3d9.\n");
70 heap_free(object);
71 return D3DERR_NOTAVAILABLE;
74 TRACE("Created d3d9 object %p.\n", object);
75 *d3d9ex = &object->IDirect3D9Ex_iface;
77 return D3D_OK;
80 /*******************************************************************
81 * Direct3DShaderValidatorCreate9 (D3D9.@)
83 * No documentation available for this function.
84 * SDK only says it is internal and shouldn't be used.
86 void* WINAPI Direct3DShaderValidatorCreate9(void)
88 static int once;
90 if (!once++) FIXME("stub\n");
91 return NULL;
94 /***********************************************************************
95 * D3DPERF_BeginEvent (D3D9.@)
97 int WINAPI D3DPERF_BeginEvent(D3DCOLOR color, const WCHAR *name)
99 TRACE("color 0x%08x, name %s.\n", color, debugstr_w(name));
101 return D3DPERF_event_level++;
104 /***********************************************************************
105 * D3DPERF_EndEvent (D3D9.@)
107 int WINAPI D3DPERF_EndEvent(void) {
108 TRACE("(void) : stub\n");
110 return --D3DPERF_event_level;
113 /***********************************************************************
114 * D3DPERF_GetStatus (D3D9.@)
116 DWORD WINAPI D3DPERF_GetStatus(void) {
117 FIXME("(void) : stub\n");
119 return 0;
122 /***********************************************************************
123 * D3DPERF_SetOptions (D3D9.@)
126 void WINAPI D3DPERF_SetOptions(DWORD options)
128 FIXME("(%#x) : stub\n", options);
131 /***********************************************************************
132 * D3DPERF_QueryRepeatFrame (D3D9.@)
134 BOOL WINAPI D3DPERF_QueryRepeatFrame(void) {
135 FIXME("(void) : stub\n");
137 return FALSE;
140 /***********************************************************************
141 * D3DPERF_SetMarker (D3D9.@)
143 void WINAPI D3DPERF_SetMarker(D3DCOLOR color, const WCHAR *name)
145 FIXME("color 0x%08x, name %s stub!\n", color, debugstr_w(name));
148 /***********************************************************************
149 * D3DPERF_SetRegion (D3D9.@)
151 void WINAPI D3DPERF_SetRegion(D3DCOLOR color, const WCHAR *name)
153 FIXME("color 0x%08x, name %s stub!\n", color, debugstr_w(name));
156 void d3d9_resource_cleanup(struct d3d9_resource *resource)
158 wined3d_private_store_cleanup(&resource->private_store);
161 HRESULT d3d9_resource_free_private_data(struct d3d9_resource *resource, const GUID *guid)
163 struct wined3d_private_data *entry;
165 wined3d_mutex_lock();
166 entry = wined3d_private_store_get_private_data(&resource->private_store, guid);
167 if (!entry)
169 wined3d_mutex_unlock();
170 return D3DERR_NOTFOUND;
173 wined3d_private_store_free_private_data(&resource->private_store, entry);
174 wined3d_mutex_unlock();
176 return D3D_OK;
179 HRESULT d3d9_resource_get_private_data(struct d3d9_resource *resource, const GUID *guid,
180 void *data, DWORD *data_size)
182 const struct wined3d_private_data *stored_data;
183 DWORD size_in;
184 HRESULT hr;
186 wined3d_mutex_lock();
187 stored_data = wined3d_private_store_get_private_data(&resource->private_store, guid);
188 if (!stored_data)
190 hr = D3DERR_NOTFOUND;
191 goto done;
194 size_in = *data_size;
195 *data_size = stored_data->size;
196 if (!data)
198 hr = D3D_OK;
199 goto done;
201 if (size_in < stored_data->size)
203 hr = D3DERR_MOREDATA;
204 goto done;
207 if (stored_data->flags & WINED3DSPD_IUNKNOWN)
208 IUnknown_AddRef(stored_data->content.object);
209 memcpy(data, stored_data->content.data, stored_data->size);
210 hr = D3D_OK;
212 done:
213 wined3d_mutex_unlock();
214 return hr;
217 void d3d9_resource_init(struct d3d9_resource *resource)
219 resource->refcount = 1;
220 wined3d_private_store_init(&resource->private_store);
223 HRESULT d3d9_resource_set_private_data(struct d3d9_resource *resource, const GUID *guid,
224 const void *data, DWORD data_size, DWORD flags)
226 HRESULT hr;
228 wined3d_mutex_lock();
229 hr = wined3d_private_store_set_private_data(&resource->private_store, guid, data, data_size, flags);
230 wined3d_mutex_unlock();
231 return hr;