ReactOS  0.4.13-dev-464-g6b95727
d3d9_main.c
Go to the documentation of this file.
1 /*
2  * Direct3D 9
3  *
4  * Copyright 2002-2003 Jason Edmeades
5  * Copyright 2002-2003 Raphael Junqueira
6  * Copyright 2005 Oliver Stieber
7  *
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.
12  *
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.
17  *
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
21  *
22  */
23 
24 #include "config.h"
25 #include "initguid.h"
26 #include "d3d9_private.h"
27 
29 
30 static int D3DPERF_event_level = 0;
31 
32 void WINAPI DebugSetMute(void) {
33  /* nothing to do */
34 }
35 
36 IDirect3D9 * WINAPI DECLSPEC_HOTPATCH Direct3DCreate9(UINT sdk_version)
37 {
38  struct d3d9 *object;
39 
40  TRACE("sdk_version %#x.\n", sdk_version);
41 
42  if (!(object = heap_alloc_zero(sizeof(*object))))
43  return NULL;
44 
45  if (!d3d9_init(object, FALSE))
46  {
47  WARN("Failed to initialize d3d9.\n");
48  heap_free(object);
49  return NULL;
50  }
51 
52  TRACE("Created d3d9 object %p.\n", object);
53 
54  return (IDirect3D9 *)&object->IDirect3D9Ex_iface;
55 }
56 
57 HRESULT WINAPI DECLSPEC_HOTPATCH Direct3DCreate9Ex(UINT sdk_version, IDirect3D9Ex **d3d9ex)
58 {
59  struct d3d9 *object;
60 
61  TRACE("sdk_version %#x, d3d9ex %p.\n", sdk_version, d3d9ex);
62 
63  if (!(object = heap_alloc_zero(sizeof(*object))))
64  return E_OUTOFMEMORY;
65 
66  if (!d3d9_init(object, TRUE))
67  {
68  WARN("Failed to initialize d3d9.\n");
69  heap_free(object);
70  return D3DERR_NOTAVAILABLE;
71  }
72 
73  TRACE("Created d3d9 object %p.\n", object);
74  *d3d9ex = &object->IDirect3D9Ex_iface;
75 
76  return D3D_OK;
77 }
78 
79 /*******************************************************************
80  * Direct3DShaderValidatorCreate9 (D3D9.@)
81  *
82  * No documentation available for this function.
83  * SDK only says it is internal and shouldn't be used.
84  */
86 {
87  static int once;
88 
89  if (!once++) FIXME("stub\n");
90  return NULL;
91 }
92 
93 /***********************************************************************
94  * D3DPERF_BeginEvent (D3D9.@)
95  */
97 {
98  TRACE("color 0x%08x, name %s.\n", color, debugstr_w(name));
99 
100  return D3DPERF_event_level++;
101 }
102 
103 /***********************************************************************
104  * D3DPERF_EndEvent (D3D9.@)
105  */
107  TRACE("(void) : stub\n");
108 
109  return --D3DPERF_event_level;
110 }
111 
112 /***********************************************************************
113  * D3DPERF_GetStatus (D3D9.@)
114  */
116  FIXME("(void) : stub\n");
117 
118  return 0;
119 }
120 
121 /***********************************************************************
122  * D3DPERF_SetOptions (D3D9.@)
123  *
124  */
126 {
127  FIXME("(%#x) : stub\n", options);
128 }
129 
130 /***********************************************************************
131  * D3DPERF_QueryRepeatFrame (D3D9.@)
132  */
134  FIXME("(void) : stub\n");
135 
136  return FALSE;
137 }
138 
139 /***********************************************************************
140  * D3DPERF_SetMarker (D3D9.@)
141  */
143 {
144  FIXME("color 0x%08x, name %s stub!\n", color, debugstr_w(name));
145 }
146 
147 /***********************************************************************
148  * D3DPERF_SetRegion (D3D9.@)
149  */
151 {
152  FIXME("color 0x%08x, name %s stub!\n", color, debugstr_w(name));
153 }
154 
156 {
157  wined3d_private_store_cleanup(&resource->private_store);
158 }
159 
161 {
162  struct wined3d_private_data *entry;
163 
166  if (!entry)
167  {
169  return D3DERR_NOTFOUND;
170  }
171 
174 
175  return D3D_OK;
176 }
177 
179  void *data, DWORD *data_size)
180 {
181  const struct wined3d_private_data *stored_data;
182  DWORD size_in;
183  HRESULT hr;
184 
186  stored_data = wined3d_private_store_get_private_data(&resource->private_store, guid);
187  if (!stored_data)
188  {
190  goto done;
191  }
192 
193  size_in = *data_size;
194  *data_size = stored_data->size;
195  if (!data)
196  {
197  hr = D3D_OK;
198  goto done;
199  }
200  if (size_in < stored_data->size)
201  {
203  goto done;
204  }
205 
206  if (stored_data->flags & WINED3DSPD_IUNKNOWN)
207  IUnknown_AddRef(stored_data->content.object);
208  memcpy(data, stored_data->content.data, stored_data->size);
209  hr = D3D_OK;
210 
211 done:
213  return hr;
214 }
215 
217 {
218  resource->refcount = 1;
219  wined3d_private_store_init(&resource->private_store);
220 }
221 
223  const void *data, DWORD data_size, DWORD flags)
224 {
225  HRESULT hr;
226 
228  hr = wined3d_private_store_set_private_data(&resource->private_store, guid, data, data_size, flags);
230  return hr;
231 }
void WINAPI D3DPERF_SetMarker(D3DCOLOR color, const WCHAR *name)
Definition: d3d9_main.c:142
#define TRUE
Definition: types.h:120
int WINAPI D3DPERF_EndEvent(void)
Definition: d3d9_main.c:106
static void wined3d_private_store_free_private_data(struct wined3d_private_store *store, struct wined3d_private_data *entry)
Definition: wined3d.h:2536
HRESULT hr
Definition: shlfolder.c:183
#define WARN(fmt,...)
Definition: debug.h:111
void d3d9_resource_init(struct d3d9_resource *resource)
Definition: d3d9_main.c:216
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:360
BOOL d3d9_init(struct d3d9 *d3d9, BOOL extended) DECLSPEC_HIDDEN
Definition: directx.c:583
int WINAPI D3DPERF_BeginEvent(D3DCOLOR color, const WCHAR *name)
Definition: d3d9_main.c:96
static int D3DPERF_event_level
Definition: d3d9_main.c:30
void WINAPI D3DPERF_SetOptions(DWORD options)
Definition: d3d9_main.c:125
#define D3DERR_NOTFOUND
Definition: d3d8.h:80
HRESULT d3d9_resource_set_private_data(struct d3d9_resource *resource, const GUID *guid, const void *data, DWORD data_size, DWORD flags)
Definition: d3d9_main.c:222
DWORD WINAPI D3DPERF_GetStatus(void)
Definition: d3d9_main.c:115
static void wined3d_private_store_init(struct wined3d_private_store *store)
Definition: wined3d.h:2516
IDirect3D9 *WINAPI DECLSPEC_HOTPATCH Direct3DCreate9(UINT sdk_version)
Definition: d3d9_main.c:36
const GUID * guid
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint color
Definition: glext.h:6243
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
#define D3DERR_NOTAVAILABLE
Definition: d3d8.h:84
#define D3DERR_MOREDATA
Definition: d3d8.h:81
void *WINAPI Direct3DShaderValidatorCreate9(void)
Definition: d3d9_main.c:85
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI D3DPERF_QueryRepeatFrame(void)
Definition: d3d9_main.c:133
static HRESULT wined3d_private_store_set_private_data(struct wined3d_private_store *store, const GUID *guid, const void *data, DWORD data_size, DWORD flags)
Definition: wined3d.h:2557
#define DECLSPEC_HOTPATCH
Definition: _mingw.h:240
#define WINED3DSPD_IUNKNOWN
Definition: wined3d.h:1008
void WINAPI D3DPERF_SetRegion(D3DCOLOR color, const WCHAR *name)
Definition: d3d9_main.c:150
HRESULT d3d9_resource_get_private_data(struct d3d9_resource *resource, const GUID *guid, void *data, DWORD *data_size)
Definition: d3d9_main.c:178
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define WINAPI
Definition: msvc.h:8
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLbitfield flags
Definition: glext.h:7161
uint32_t entry
Definition: isohybrid.c:63
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define D3D_OK
Definition: d3d.h:106
WINE_DEFAULT_DEBUG_CHANNEL(d3d9)
IUnknown * object
Definition: wined3d.h:2166
static struct wined3d_private_data * wined3d_private_store_get_private_data(const struct wined3d_private_store *store, const GUID *tag)
Definition: wined3d.h:2521
unsigned int UINT
Definition: ndis.h:50
static void wined3d_private_store_cleanup(struct wined3d_private_store *store)
Definition: wined3d.h:2545
HRESULT WINAPI DECLSPEC_HOTPATCH Direct3DCreate9Ex(UINT sdk_version, IDirect3D9Ex **d3d9ex)
Definition: d3d9_main.c:57
void WINAPI DebugSetMute(void)
Definition: d3d9_main.c:32
void d3d9_resource_cleanup(struct d3d9_resource *resource)
Definition: d3d9_main.c:155
Definition: name.c:36
union wined3d_private_data::@3524 content
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:365
void * object
Definition: jmemsys.h:48
static BOOL heap_free(void *mem)
Definition: appwiz.h:75
HRESULT d3d9_resource_free_private_data(struct d3d9_resource *resource, const GUID *guid)
Definition: d3d9_main.c:160