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
25 #include "wine/port.h"
27 #include "d3d9_private.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(d3d9
);
31 static int D3DPERF_event_level
= 0;
33 void WINAPI
DebugSetMute(void) {
37 IDirect3D9
* WINAPI DECLSPEC_HOTPATCH
Direct3DCreate9(UINT sdk_version
)
41 TRACE("sdk_version %#x.\n", sdk_version
);
43 if (!(object
= heap_alloc_zero(sizeof(*object
))))
46 if (!d3d9_init(object
, FALSE
))
48 WARN("Failed to initialize d3d9.\n");
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
)
62 TRACE("sdk_version %#x, d3d9ex %p.\n", sdk_version
, d3d9ex
);
64 if (!(object
= heap_alloc_zero(sizeof(*object
))))
67 if (!d3d9_init(object
, TRUE
))
69 WARN("Failed to initialize d3d9.\n");
71 return D3DERR_NOTAVAILABLE
;
74 TRACE("Created d3d9 object %p.\n", object
);
75 *d3d9ex
= &object
->IDirect3D9Ex_iface
;
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)
90 if (!once
++) FIXME("stub\n");
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");
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");
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
);
169 wined3d_mutex_unlock();
170 return D3DERR_NOTFOUND
;
173 wined3d_private_store_free_private_data(&resource
->private_store
, entry
);
174 wined3d_mutex_unlock();
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
;
186 wined3d_mutex_lock();
187 stored_data
= wined3d_private_store_get_private_data(&resource
->private_store
, guid
);
190 hr
= D3DERR_NOTFOUND
;
194 size_in
= *data_size
;
195 *data_size
= stored_data
->size
;
201 if (size_in
< stored_data
->size
)
203 hr
= D3DERR_MOREDATA
;
207 if (stored_data
->flags
& WINED3DSPD_IUNKNOWN
)
208 IUnknown_AddRef(stored_data
->content
.object
);
209 memcpy(data
, stored_data
->content
.data
, stored_data
->size
);
213 wined3d_mutex_unlock();
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
)
228 wined3d_mutex_lock();
229 hr
= wined3d_private_store_set_private_data(&resource
->private_store
, guid
, data
, data_size
, flags
);
230 wined3d_mutex_unlock();