ReactOS 0.4.17-dev-966-gf06eace
d3d8_main.c
Go to the documentation of this file.
1/*
2 * Direct3D 8
3 *
4 * Copyright 2005 Oliver Stieber
5 *
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.
10 *
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.
15 *
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
19 *
20 */
21
22#include "initguid.h"
23#include "d3d8_private.h"
24#include "wine/debug.h"
25
27
29 FIXME("(void): stub\n");
30 return 0;
31}
32
33void WINAPI DebugSetMute(void) {
34 /* nothing to do */
35}
36
38{
39 struct d3d8 *object;
40
41 TRACE("sdk_version %#x.\n", sdk_version);
42
43 if (!(object = calloc(1, sizeof(*object))))
44 return NULL;
45
46 if (!d3d8_init(object))
47 {
48 WARN("Failed to initialize d3d8.\n");
49 free(object);
50 return NULL;
51 }
52
53 TRACE("Created d3d8 object %p.\n", object);
54
55 return &object->IDirect3D8_iface;
56}
57
58/* FIXME: We should probably use libvkd3d-shader for validation. */
60 const D3DCAPS8 *caps, BOOL return_error, char **errors)
61{
62 const char *message = "";
63 SIZE_T message_size;
65
66 TRACE("vs_code %p, declaration %p, caps %p, return_error %#x, errors %p.\n",
67 vs_code, declaration, caps, return_error, errors);
68
69 if (!vs_code)
70 {
71 message = "Invalid code pointer.\n";
72 goto done;
73 }
74
75 switch (*vs_code)
76 {
77 case D3DVS_VERSION(1, 1):
78 case D3DVS_VERSION(1, 0):
79 break;
80
81 default:
82 message = "Unsupported shader version.\n";
83 goto done;
84 }
85
86 if (caps && *vs_code > caps->VertexShaderVersion)
87 {
88 message = "Shader version not supported by caps.\n";
89 goto done;
90 }
91
92 hr = S_OK;
93
94done:
95 if (!return_error)
96 message = "";
97 message_size = strlen(message) + 1;
98 if (errors && (*errors = HeapAlloc(GetProcessHeap(), 0, message_size)))
99 memcpy(*errors, message, message_size);
100
101 return hr;
102}
103
105 const D3DCAPS8 *caps, BOOL return_error, char **errors)
106{
107 const char *message = "";
108 SIZE_T message_size;
109 HRESULT hr = E_FAIL;
110
111 TRACE("ps_code %p, caps %p, return_error %#x, errors %p.\n",
112 ps_code, caps, return_error, errors);
113
114 if (!ps_code)
115 return E_FAIL;
116
117 switch (*ps_code)
118 {
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):
124 break;
125
126 default:
127 message = "Unsupported shader version.\n";
128 goto done;
129 }
130
131 if (caps && *ps_code > caps->PixelShaderVersion)
132 {
133 message = "Shader version not supported by caps.\n";
134 goto done;
135 }
136
137 hr = S_OK;
138
139done:
140 if (!return_error)
141 message = "";
142 message_size = strlen(message) + 1;
143 if (errors && (*errors = HeapAlloc(GetProcessHeap(), 0, message_size)))
144 memcpy(*errors, message, message_size);
145
146 return hr;
147}
148
150{
152}
153
155{
157
160 if (!entry)
161 {
163 return D3DERR_NOTFOUND;
164 }
165
168
169 return D3D_OK;
170}
171
173 void *data, DWORD *data_size)
174{
175 const struct wined3d_private_data *stored_data;
176 DWORD size_in;
177 HRESULT hr;
178
180 stored_data = wined3d_private_store_get_private_data(&resource->private_store, guid);
181 if (!stored_data)
182 {
184 goto done;
185 }
186
187 size_in = *data_size;
188 *data_size = stored_data->size;
189 if (!data)
190 {
191 hr = D3D_OK;
192 goto done;
193 }
194 if (size_in < stored_data->size)
195 {
197 goto done;
198 }
199
200 if (stored_data->flags & WINED3DSPD_IUNKNOWN)
201 IUnknown_AddRef(stored_data->content.object);
202 memcpy(data, stored_data->content.data, stored_data->size);
203 hr = D3D_OK;
204
205done:
207 return hr;
208}
209
211{
212 resource->refcount = 1;
213 wined3d_private_store_init(&resource->private_store);
214}
215
217 const void *data, DWORD data_size, DWORD flags)
218{
219 HRESULT hr;
220
222 hr = wined3d_private_store_set_private_data(&resource->private_store, guid, data, data_size, flags);
224 return hr;
225}
#define DECLSPEC_HOTPATCH
Definition: _mingw.h:240
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
HRESULT WINAPI ValidatePixelShader(const DWORD *ps_code, const D3DCAPS8 *caps, BOOL return_error, char **errors)
Definition: d3d8_main.c:104
IDirect3D8 *WINAPI DECLSPEC_HOTPATCH Direct3DCreate8(UINT sdk_version)
Definition: d3d8_main.c:37
HRESULT d3d8_resource_get_private_data(struct d3d8_resource *resource, const GUID *guid, void *data, DWORD *data_size)
Definition: d3d8_main.c:172
HRESULT WINAPI ValidateVertexShader(const DWORD *vs_code, const DWORD *declaration, const D3DCAPS8 *caps, BOOL return_error, char **errors)
Definition: d3d8_main.c:59
void d3d8_resource_cleanup(struct d3d8_resource *resource)
Definition: d3d8_main.c:149
void WINAPI DebugSetMute(void)
Definition: d3d8_main.c:33
void d3d8_resource_init(struct d3d8_resource *resource)
Definition: d3d8_main.c:210
HRESULT WINAPI D3D8GetSWInfo(void)
Definition: d3d8_main.c:28
HRESULT d3d8_resource_set_private_data(struct d3d8_resource *resource, const GUID *guid, const void *data, DWORD data_size, DWORD flags)
Definition: d3d8_main.c:216
HRESULT d3d8_resource_free_private_data(struct d3d8_resource *resource, const GUID *guid)
Definition: d3d8_main.c:154
BOOL d3d8_init(struct d3d8 *d3d8)
Definition: directx.c:474
#define D3DPS_VERSION(major, minor)
Definition: d3d8types.h:474
#define D3DVS_VERSION(major, minor)
Definition: d3d8types.h:475
#define D3D_OK
Definition: d3d.h:106
#define E_FAIL
Definition: ddrawi.h:102
#define free
Definition: debug_ros.c:5
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
GUID guid
Definition: version.c:147
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
GLbitfield flags
Definition: glext.h:7161
unsigned int UINT
Definition: sysinfo.c:13
static D3D_DRIVER_TYPE HMODULE UINT const D3D_FEATURE_LEVEL UINT UINT sdk_version
Definition: hlsl_d3d11.c:29
#define S_OK
Definition: intsafe.h:52
uint32_t entry
Definition: isohybrid.c:63
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define calloc
Definition: rosglue.h:14
#define D3DERR_MOREDATA
Definition: d3d8.h:77
#define D3DERR_NOTFOUND
Definition: d3d8.h:76
#define TRACE(s)
Definition: solgame.cpp:4
DWORD PixelShaderVersion
Definition: d3d8caps.h:242
DWORD VertexShaderVersion
Definition: d3d8caps.h:240
Definition: tftpd.h:60
union wined3d_private_data::@4825 content
IUnknown * object
Definition: wined3d.h:2285
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define WINAPI
Definition: msvc.h:6
static void wined3d_private_store_cleanup(struct wined3d_private_store *store)
Definition: wined3d.h:2636
static struct wined3d_private_data * wined3d_private_store_get_private_data(const struct wined3d_private_store *store, const GUID *tag)
Definition: wined3d.h:2612
static void wined3d_private_store_free_private_data(struct wined3d_private_store *store, struct wined3d_private_data *entry)
Definition: wined3d.h:2627
static void wined3d_private_store_init(struct wined3d_private_store *store)
Definition: wined3d.h:2607
#define WINED3DSPD_IUNKNOWN
Definition: wined3d.h:1018
static HRESULT wined3d_private_store_set_private_data(struct wined3d_private_store *store, const GUID *guid, const void *data, DWORD data_size, uint32_t flags)
Definition: wined3d.h:2648
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:544
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:539