4 * Copyright 2005 Oliver Stieber
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "d3d8_private.h"
24 #include "wine/debug.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(d3d8
);
28 HRESULT WINAPI
D3D8GetSWInfo(void) {
29 FIXME("(void): stub\n");
33 void WINAPI
DebugSetMute(void) {
37 IDirect3D8
* WINAPI DECLSPEC_HOTPATCH
Direct3DCreate8(UINT sdk_version
)
41 TRACE("sdk_version %#x.\n", sdk_version
);
43 if (!(object
= heap_alloc_zero(sizeof(*object
))))
46 if (!d3d8_init(object
))
48 WARN("Failed to initialize d3d8.\n");
53 TRACE("Created d3d8 object %p.\n", object
);
55 return &object
->IDirect3D8_iface
;
58 /* FIXME: We should probably use libvkd3d-shader for validation. */
59 HRESULT WINAPI
ValidateVertexShader(const DWORD
*vs_code
, const DWORD
*declaration
,
60 const D3DCAPS8
*caps
, BOOL return_error
, char **errors
)
62 const char *message
= "";
66 TRACE("vs_code %p, declaration %p, caps %p, return_error %#x, errors %p.\n",
67 vs_code
, declaration
, caps
, return_error
, errors
);
71 message
= "Invalid code pointer.\n";
77 case D3DVS_VERSION(1, 1):
78 case D3DVS_VERSION(1, 0):
82 message
= "Unsupported shader version.\n";
86 if (caps
&& *vs_code
> caps
->VertexShaderVersion
)
88 message
= "Shader version not supported by caps.\n";
97 message_size
= strlen(message
) + 1;
98 if (errors
&& (*errors
= heap_alloc(message_size
)))
99 memcpy(*errors
, message
, message_size
);
104 HRESULT WINAPI
ValidatePixelShader(const DWORD
*ps_code
,
105 const D3DCAPS8
*caps
, BOOL return_error
, char **errors
)
107 const char *message
= "";
111 TRACE("ps_code %p, caps %p, return_error %#x, errors %p.\n",
112 ps_code
, caps
, return_error
, errors
);
119 case D3DPS_VERSION(1, 4):
120 case D3DPS_VERSION(1, 3):
121 case D3DPS_VERSION(1, 2):
122 case D3DPS_VERSION(1, 1):
123 case D3DPS_VERSION(1, 0):
127 message
= "Unsupported shader version.\n";
131 if (caps
&& *ps_code
> caps
->PixelShaderVersion
)
133 message
= "Shader version not supported by caps.\n";
142 message_size
= strlen(message
) + 1;
143 if (errors
&& (*errors
= heap_alloc(message_size
)))
144 memcpy(*errors
, message
, message_size
);
149 void d3d8_resource_cleanup(struct d3d8_resource
*resource
)
151 wined3d_private_store_cleanup(&resource
->private_store
);
154 HRESULT
d3d8_resource_free_private_data(struct d3d8_resource
*resource
, const GUID
*guid
)
156 struct wined3d_private_data
*entry
;
158 wined3d_mutex_lock();
159 entry
= wined3d_private_store_get_private_data(&resource
->private_store
, guid
);
162 wined3d_mutex_unlock();
163 return D3DERR_NOTFOUND
;
166 wined3d_private_store_free_private_data(&resource
->private_store
, entry
);
167 wined3d_mutex_unlock();
172 HRESULT
d3d8_resource_get_private_data(struct d3d8_resource
*resource
, const GUID
*guid
,
173 void *data
, DWORD
*data_size
)
175 const struct wined3d_private_data
*stored_data
;
179 wined3d_mutex_lock();
180 stored_data
= wined3d_private_store_get_private_data(&resource
->private_store
, guid
);
183 hr
= D3DERR_NOTFOUND
;
187 size_in
= *data_size
;
188 *data_size
= stored_data
->size
;
194 if (size_in
< stored_data
->size
)
196 hr
= D3DERR_MOREDATA
;
200 if (stored_data
->flags
& WINED3DSPD_IUNKNOWN
)
201 IUnknown_AddRef(stored_data
->content
.object
);
202 memcpy(data
, stored_data
->content
.data
, stored_data
->size
);
206 wined3d_mutex_unlock();
210 void d3d8_resource_init(struct d3d8_resource
*resource
)
212 resource
->refcount
= 1;
213 wined3d_private_store_init(&resource
->private_store
);
216 HRESULT
d3d8_resource_set_private_data(struct d3d8_resource
*resource
, const GUID
*guid
,
217 const void *data
, DWORD data_size
, DWORD flags
)
221 wined3d_mutex_lock();
222 hr
= wined3d_private_store_set_private_data(&resource
->private_store
, guid
, data
, data_size
, flags
);
223 wined3d_mutex_unlock();