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 "d3d9_private.h"
26 static int D3DPERF_event_level
= 0;
28 void WINAPI
DebugSetMute(void) {
32 IDirect3D9
* WINAPI DECLSPEC_HOTPATCH
Direct3DCreate9(UINT sdk_version
)
36 TRACE("sdk_version %#x.\n", sdk_version
);
38 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
41 if (!d3d9_init(object
, FALSE
))
43 WARN("Failed to initialize d3d9.\n");
44 HeapFree(GetProcessHeap(), 0, object
);
48 TRACE("Created d3d9 object %p.\n", object
);
50 return (IDirect3D9
*)&object
->IDirect3D9Ex_iface
;
53 HRESULT WINAPI DECLSPEC_HOTPATCH
Direct3DCreate9Ex(UINT sdk_version
, IDirect3D9Ex
**d3d9ex
)
57 TRACE("sdk_version %#x, d3d9ex %p.\n", sdk_version
, d3d9ex
);
59 if (!(object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*object
))))
62 if (!d3d9_init(object
, TRUE
))
64 WARN("Failed to initialize d3d9.\n");
65 HeapFree(GetProcessHeap(), 0, object
);
66 return D3DERR_NOTAVAILABLE
;
69 TRACE("Created d3d9 object %p.\n", object
);
70 *d3d9ex
= &object
->IDirect3D9Ex_iface
;
75 /*******************************************************************
76 * Direct3DShaderValidatorCreate9 (D3D9.@)
78 * No documentation available for this function.
79 * SDK only says it is internal and shouldn't be used.
81 void* WINAPI
Direct3DShaderValidatorCreate9(void)
85 if (!once
++) FIXME("stub\n");
89 /*******************************************************************
92 BOOL WINAPI
DllMain(HINSTANCE inst
, DWORD reason
, void *reserved
)
94 if (reason
== DLL_PROCESS_ATTACH
)
95 DisableThreadLibraryCalls(inst
);
100 /***********************************************************************
101 * D3DPERF_BeginEvent (D3D9.@)
103 int WINAPI
D3DPERF_BeginEvent(D3DCOLOR color
, const WCHAR
*name
)
105 TRACE("color 0x%08x, name %s.\n", color
, debugstr_w(name
));
107 return D3DPERF_event_level
++;
110 /***********************************************************************
111 * D3DPERF_EndEvent (D3D9.@)
113 int WINAPI
D3DPERF_EndEvent(void) {
114 TRACE("(void) : stub\n");
116 return --D3DPERF_event_level
;
119 /***********************************************************************
120 * D3DPERF_GetStatus (D3D9.@)
122 DWORD WINAPI
D3DPERF_GetStatus(void) {
123 FIXME("(void) : stub\n");
128 /***********************************************************************
129 * D3DPERF_SetOptions (D3D9.@)
132 void WINAPI
D3DPERF_SetOptions(DWORD options
)
134 FIXME("(%#x) : stub\n", options
);
137 /***********************************************************************
138 * D3DPERF_QueryRepeatFrame (D3D9.@)
140 BOOL WINAPI
D3DPERF_QueryRepeatFrame(void) {
141 FIXME("(void) : stub\n");
146 /***********************************************************************
147 * D3DPERF_SetMarker (D3D9.@)
149 void WINAPI
D3DPERF_SetMarker(D3DCOLOR color
, const WCHAR
*name
)
151 FIXME("color 0x%08x, name %s stub!\n", color
, debugstr_w(name
));
154 /***********************************************************************
155 * D3DPERF_SetRegion (D3D9.@)
157 void WINAPI
D3DPERF_SetRegion(D3DCOLOR color
, const WCHAR
*name
)
159 FIXME("color 0x%08x, name %s stub!\n", color
, debugstr_w(name
));
162 void d3d9_resource_cleanup(struct d3d9_resource
*resource
)
164 wined3d_private_store_cleanup(&resource
->private_store
);
167 HRESULT
d3d9_resource_free_private_data(struct d3d9_resource
*resource
, const GUID
*guid
)
169 struct wined3d_private_data
*entry
;
171 wined3d_mutex_lock();
172 entry
= wined3d_private_store_get_private_data(&resource
->private_store
, guid
);
175 wined3d_mutex_unlock();
176 return D3DERR_NOTFOUND
;
179 wined3d_private_store_free_private_data(&resource
->private_store
, entry
);
180 wined3d_mutex_unlock();
185 HRESULT
d3d9_resource_get_private_data(struct d3d9_resource
*resource
, const GUID
*guid
,
186 void *data
, DWORD
*data_size
)
188 const struct wined3d_private_data
*stored_data
;
192 wined3d_mutex_lock();
193 stored_data
= wined3d_private_store_get_private_data(&resource
->private_store
, guid
);
196 hr
= D3DERR_NOTFOUND
;
200 size_in
= *data_size
;
201 *data_size
= stored_data
->size
;
207 if (size_in
< stored_data
->size
)
209 hr
= D3DERR_MOREDATA
;
213 if (stored_data
->flags
& WINED3DSPD_IUNKNOWN
)
214 IUnknown_AddRef(stored_data
->content
.object
);
215 memcpy(data
, stored_data
->content
.data
, stored_data
->size
);
219 wined3d_mutex_unlock();
223 void d3d9_resource_init(struct d3d9_resource
*resource
)
225 resource
->refcount
= 1;
226 wined3d_private_store_init(&resource
->private_store
);
229 HRESULT
d3d9_resource_set_private_data(struct d3d9_resource
*resource
, const GUID
*guid
,
230 const void *data
, DWORD data_size
, DWORD flags
)
234 wined3d_mutex_lock();
235 hr
= wined3d_private_store_set_private_data(&resource
->private_store
, guid
, data
, data_size
, flags
);
236 wined3d_mutex_unlock();