1 | /*
|
---|
2 | * IDirect3DVertexDeclaration8 implementation
|
---|
3 | *
|
---|
4 | * Copyright 2007 Henri Verbeet
|
---|
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 | * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
|
---|
23 | * other than GPL or LGPL is available it will apply instead, Sun elects to use only
|
---|
24 | * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
|
---|
25 | * a choice of LGPL license versions is made available with the language indicating
|
---|
26 | * that LGPLv2 or any later version may be used, or where a choice of which version
|
---|
27 | * of the LGPL is applied is otherwise unspecified.
|
---|
28 | */
|
---|
29 |
|
---|
30 | /* IDirect3DVertexDeclaration8 is internal to our implementation.
|
---|
31 | * It's not visible in the API. */
|
---|
32 |
|
---|
33 | #include "config.h"
|
---|
34 | #include "d3d8_private.h"
|
---|
35 |
|
---|
36 | WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
|
---|
37 |
|
---|
38 | /* IUnknown */
|
---|
39 | static HRESULT WINAPI IDirect3DVertexDeclaration8Impl_QueryInterface(IDirect3DVertexDeclaration8 *iface, REFIID riid, void **obj_ptr)
|
---|
40 | {
|
---|
41 | TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), obj_ptr);
|
---|
42 |
|
---|
43 | if (IsEqualGUID(riid, &IID_IUnknown)
|
---|
44 | || IsEqualGUID(riid, &IID_IDirect3DVertexDeclaration8))
|
---|
45 | {
|
---|
46 | IUnknown_AddRef(iface);
|
---|
47 | *obj_ptr = iface;
|
---|
48 | return S_OK;
|
---|
49 | }
|
---|
50 |
|
---|
51 | *obj_ptr = NULL;
|
---|
52 | return E_NOINTERFACE;
|
---|
53 | }
|
---|
54 |
|
---|
55 | static ULONG WINAPI IDirect3DVertexDeclaration8Impl_AddRef(IDirect3DVertexDeclaration8 *iface)
|
---|
56 | {
|
---|
57 | IDirect3DVertexDeclaration8Impl *This = (IDirect3DVertexDeclaration8Impl *)iface;
|
---|
58 |
|
---|
59 | ULONG ref_count = InterlockedIncrement(&This->ref_count);
|
---|
60 | TRACE("(%p) : AddRef increasing to %d\n", This, ref_count);
|
---|
61 |
|
---|
62 | return ref_count;
|
---|
63 | }
|
---|
64 |
|
---|
65 | static ULONG WINAPI IDirect3DVertexDeclaration8Impl_Release(IDirect3DVertexDeclaration8 *iface)
|
---|
66 | {
|
---|
67 | IDirect3DVertexDeclaration8Impl *This = (IDirect3DVertexDeclaration8Impl *)iface;
|
---|
68 |
|
---|
69 | ULONG ref_count = InterlockedDecrement(&This->ref_count);
|
---|
70 | TRACE("(%p) : Releasing to %d\n", This, ref_count);
|
---|
71 |
|
---|
72 | if (!ref_count) {
|
---|
73 | EnterCriticalSection(&d3d8_cs);
|
---|
74 | IWineD3DVertexDeclaration_Release(This->wined3d_vertex_declaration);
|
---|
75 | LeaveCriticalSection(&d3d8_cs);
|
---|
76 | HeapFree(GetProcessHeap(), 0, This->elements);
|
---|
77 | HeapFree(GetProcessHeap(), 0, This);
|
---|
78 | }
|
---|
79 |
|
---|
80 | return ref_count;
|
---|
81 | }
|
---|
82 |
|
---|
83 | static const char *debug_d3dvsdt_type(D3DVSDT_TYPE d3dvsdt_type)
|
---|
84 | {
|
---|
85 | switch (d3dvsdt_type)
|
---|
86 | {
|
---|
87 | #define D3DVSDT_TYPE_TO_STR(u) case u: return #u
|
---|
88 | D3DVSDT_TYPE_TO_STR(D3DVSDT_FLOAT1);
|
---|
89 | D3DVSDT_TYPE_TO_STR(D3DVSDT_FLOAT2);
|
---|
90 | D3DVSDT_TYPE_TO_STR(D3DVSDT_FLOAT3);
|
---|
91 | D3DVSDT_TYPE_TO_STR(D3DVSDT_FLOAT4);
|
---|
92 | D3DVSDT_TYPE_TO_STR(D3DVSDT_D3DCOLOR);
|
---|
93 | D3DVSDT_TYPE_TO_STR(D3DVSDT_UBYTE4);
|
---|
94 | D3DVSDT_TYPE_TO_STR(D3DVSDT_SHORT2);
|
---|
95 | D3DVSDT_TYPE_TO_STR(D3DVSDT_SHORT4);
|
---|
96 | #undef D3DVSDT_TYPE_TO_STR
|
---|
97 | default:
|
---|
98 | FIXME("Unrecognized D3DVSDT_TYPE %#x\n", d3dvsdt_type);
|
---|
99 | return "unrecognized";
|
---|
100 | }
|
---|
101 | }
|
---|
102 |
|
---|
103 | static const char *debug_d3dvsde_register(D3DVSDE_REGISTER d3dvsde_register)
|
---|
104 | {
|
---|
105 | switch (d3dvsde_register)
|
---|
106 | {
|
---|
107 | #define D3DVSDE_REGISTER_TO_STR(u) case u: return #u
|
---|
108 | D3DVSDE_REGISTER_TO_STR(D3DVSDE_POSITION);
|
---|
109 | D3DVSDE_REGISTER_TO_STR(D3DVSDE_BLENDWEIGHT);
|
---|
110 | D3DVSDE_REGISTER_TO_STR(D3DVSDE_BLENDINDICES);
|
---|
111 | D3DVSDE_REGISTER_TO_STR(D3DVSDE_NORMAL);
|
---|
112 | D3DVSDE_REGISTER_TO_STR(D3DVSDE_PSIZE);
|
---|
113 | D3DVSDE_REGISTER_TO_STR(D3DVSDE_DIFFUSE);
|
---|
114 | D3DVSDE_REGISTER_TO_STR(D3DVSDE_SPECULAR);
|
---|
115 | D3DVSDE_REGISTER_TO_STR(D3DVSDE_TEXCOORD0);
|
---|
116 | D3DVSDE_REGISTER_TO_STR(D3DVSDE_TEXCOORD1);
|
---|
117 | D3DVSDE_REGISTER_TO_STR(D3DVSDE_TEXCOORD2);
|
---|
118 | D3DVSDE_REGISTER_TO_STR(D3DVSDE_TEXCOORD3);
|
---|
119 | D3DVSDE_REGISTER_TO_STR(D3DVSDE_TEXCOORD4);
|
---|
120 | D3DVSDE_REGISTER_TO_STR(D3DVSDE_TEXCOORD5);
|
---|
121 | D3DVSDE_REGISTER_TO_STR(D3DVSDE_TEXCOORD6);
|
---|
122 | D3DVSDE_REGISTER_TO_STR(D3DVSDE_TEXCOORD7);
|
---|
123 | D3DVSDE_REGISTER_TO_STR(D3DVSDE_POSITION2);
|
---|
124 | D3DVSDE_REGISTER_TO_STR(D3DVSDE_NORMAL2);
|
---|
125 | #undef D3DVSDE_REGISTER_TO_STR
|
---|
126 | default:
|
---|
127 | FIXME("Unrecognized D3DVSDE_REGISTER %#x\n", d3dvsde_register);
|
---|
128 | return "unrecognized";
|
---|
129 | }
|
---|
130 | }
|
---|
131 |
|
---|
132 | size_t parse_token(const DWORD* pToken)
|
---|
133 | {
|
---|
134 | const DWORD token = *pToken;
|
---|
135 | size_t tokenlen = 1;
|
---|
136 |
|
---|
137 | switch ((token & D3DVSD_TOKENTYPEMASK) >> D3DVSD_TOKENTYPESHIFT) { /* maybe a macro to inverse ... */
|
---|
138 | case D3DVSD_TOKEN_NOP:
|
---|
139 | TRACE(" 0x%08x NOP()\n", token);
|
---|
140 | break;
|
---|
141 |
|
---|
142 | case D3DVSD_TOKEN_STREAM:
|
---|
143 | if (token & D3DVSD_STREAMTESSMASK)
|
---|
144 | {
|
---|
145 | TRACE(" 0x%08x STREAM_TESS()\n", token);
|
---|
146 | } else {
|
---|
147 | TRACE(" 0x%08x STREAM(%u)\n", token, ((token & D3DVSD_STREAMNUMBERMASK) >> D3DVSD_STREAMNUMBERSHIFT));
|
---|
148 | }
|
---|
149 | break;
|
---|
150 |
|
---|
151 | case D3DVSD_TOKEN_STREAMDATA:
|
---|
152 | if (token & 0x10000000)
|
---|
153 | {
|
---|
154 | TRACE(" 0x%08x SKIP(%u)\n", token, ((token & D3DVSD_SKIPCOUNTMASK) >> D3DVSD_SKIPCOUNTSHIFT));
|
---|
155 | } else {
|
---|
156 | DWORD type = ((token & D3DVSD_DATATYPEMASK) >> D3DVSD_DATATYPESHIFT);
|
---|
157 | DWORD reg = ((token & D3DVSD_VERTEXREGMASK) >> D3DVSD_VERTEXREGSHIFT);
|
---|
158 | TRACE(" 0x%08x REG(%s, %s)\n", token, debug_d3dvsde_register(reg), debug_d3dvsdt_type(type));
|
---|
159 | }
|
---|
160 | break;
|
---|
161 |
|
---|
162 | case D3DVSD_TOKEN_TESSELLATOR:
|
---|
163 | if (token & 0x10000000)
|
---|
164 | {
|
---|
165 | DWORD type = ((token & D3DVSD_DATATYPEMASK) >> D3DVSD_DATATYPESHIFT);
|
---|
166 | DWORD reg = ((token & D3DVSD_VERTEXREGMASK) >> D3DVSD_VERTEXREGSHIFT);
|
---|
167 | TRACE(" 0x%08x TESSUV(%s) as %s\n", token, debug_d3dvsde_register(reg), debug_d3dvsdt_type(type));
|
---|
168 | } else {
|
---|
169 | DWORD type = ((token & D3DVSD_DATATYPEMASK) >> D3DVSD_DATATYPESHIFT);
|
---|
170 | DWORD regout = ((token & D3DVSD_VERTEXREGMASK) >> D3DVSD_VERTEXREGSHIFT);
|
---|
171 | DWORD regin = ((token & D3DVSD_VERTEXREGINMASK) >> D3DVSD_VERTEXREGINSHIFT);
|
---|
172 | TRACE(" 0x%08x TESSNORMAL(%s, %s) as %s\n", token, debug_d3dvsde_register(regin),
|
---|
173 | debug_d3dvsde_register(regout), debug_d3dvsdt_type(type));
|
---|
174 | }
|
---|
175 | break;
|
---|
176 |
|
---|
177 | case D3DVSD_TOKEN_CONSTMEM:
|
---|
178 | {
|
---|
179 | DWORD count = ((token & D3DVSD_CONSTCOUNTMASK) >> D3DVSD_CONSTCOUNTSHIFT);
|
---|
180 | tokenlen = (4 * count) + 1;
|
---|
181 | }
|
---|
182 | break;
|
---|
183 |
|
---|
184 | case D3DVSD_TOKEN_EXT:
|
---|
185 | {
|
---|
186 | DWORD count = ((token & D3DVSD_CONSTCOUNTMASK) >> D3DVSD_CONSTCOUNTSHIFT);
|
---|
187 | DWORD extinfo = ((token & D3DVSD_EXTINFOMASK) >> D3DVSD_EXTINFOSHIFT);
|
---|
188 | TRACE(" 0x%08x EXT(%u, %u)\n", token, count, extinfo);
|
---|
189 | /* todo ... print extension */
|
---|
190 | tokenlen = count + 1;
|
---|
191 | }
|
---|
192 | break;
|
---|
193 |
|
---|
194 | case D3DVSD_TOKEN_END:
|
---|
195 | TRACE(" 0x%08x END()\n", token);
|
---|
196 | break;
|
---|
197 |
|
---|
198 | default:
|
---|
199 | TRACE(" 0x%08x UNKNOWN\n", token);
|
---|
200 | /* argg error */
|
---|
201 | }
|
---|
202 |
|
---|
203 | return tokenlen;
|
---|
204 | }
|
---|
205 |
|
---|
206 | void load_local_constants(const DWORD *d3d8_elements, IWineD3DVertexShader *wined3d_vertex_shader)
|
---|
207 | {
|
---|
208 | const DWORD *token = d3d8_elements;
|
---|
209 |
|
---|
210 | while (*token != D3DVSD_END())
|
---|
211 | {
|
---|
212 | if (((*token & D3DVSD_TOKENTYPEMASK) >> D3DVSD_TOKENTYPESHIFT) == D3DVSD_TOKEN_CONSTMEM)
|
---|
213 | {
|
---|
214 | DWORD count = ((*token & D3DVSD_CONSTCOUNTMASK) >> D3DVSD_CONSTCOUNTSHIFT);
|
---|
215 | DWORD constant_idx = ((*token & D3DVSD_CONSTADDRESSMASK) >> D3DVSD_CONSTADDRESSSHIFT);
|
---|
216 | HRESULT hr;
|
---|
217 |
|
---|
218 | if (TRACE_ON(d3d8))
|
---|
219 | {
|
---|
220 | DWORD i;
|
---|
221 | for (i = 0; i < count; ++i)
|
---|
222 | {
|
---|
223 | TRACE("c[%u] = (%8f, %8f, %8f, %8f)\n",
|
---|
224 | constant_idx,
|
---|
225 | *(const float *)(token + i * 4 + 1),
|
---|
226 | *(const float *)(token + i * 4 + 2),
|
---|
227 | *(const float *)(token + i * 4 + 3),
|
---|
228 | *(const float *)(token + i * 4 + 4));
|
---|
229 | }
|
---|
230 | }
|
---|
231 | hr = IWineD3DVertexShader_SetLocalConstantsF(wined3d_vertex_shader, constant_idx, (const float *)token+1, count);
|
---|
232 | if (FAILED(hr)) ERR("Failed setting shader constants\n");
|
---|
233 | }
|
---|
234 |
|
---|
235 | token += parse_token(token);
|
---|
236 | }
|
---|
237 | }
|
---|
238 |
|
---|
239 | /* NOTE: Make sure these are in the correct numerical order. (see /include/wined3d_types.h) */
|
---|
240 | static const size_t wined3d_type_sizes[] =
|
---|
241 | {
|
---|
242 | /*WINED3DDECLTYPE_FLOAT1*/ 1 * sizeof(float),
|
---|
243 | /*WINED3DDECLTYPE_FLOAT2*/ 2 * sizeof(float),
|
---|
244 | /*WINED3DDECLTYPE_FLOAT3*/ 3 * sizeof(float),
|
---|
245 | /*WINED3DDECLTYPE_FLOAT4*/ 4 * sizeof(float),
|
---|
246 | /*WINED3DDECLTYPE_D3DCOLOR*/ 4 * sizeof(BYTE),
|
---|
247 | /*WINED3DDECLTYPE_UBYTE4*/ 4 * sizeof(BYTE),
|
---|
248 | /*WINED3DDECLTYPE_SHORT2*/ 2 * sizeof(short int),
|
---|
249 | /*WINED3DDECLTYPE_SHORT4*/ 4 * sizeof(short int),
|
---|
250 | /*WINED3DDECLTYPE_UBYTE4N*/ 4 * sizeof(BYTE),
|
---|
251 | /*WINED3DDECLTYPE_SHORT2N*/ 2 * sizeof(short int),
|
---|
252 | /*WINED3DDECLTYPE_SHORT4N*/ 4 * sizeof(short int),
|
---|
253 | /*WINED3DDECLTYPE_USHORT2N*/ 2 * sizeof(short int),
|
---|
254 | /*WINED3DDECLTYPE_USHORT4N*/ 4 * sizeof(short int),
|
---|
255 | /*WINED3DDECLTYPE_UDEC3*/ 3 * sizeof(short int),
|
---|
256 | /*WINED3DDECLTYPE_DEC3N*/ 3 * sizeof(short int),
|
---|
257 | /*WINED3DDECLTYPE_FLOAT16_2*/ 2 * sizeof(short int),
|
---|
258 | /*WINED3DDECLTYPE_FLOAT16_4*/ 4 * sizeof(short int)
|
---|
259 | };
|
---|
260 |
|
---|
261 | static const WINED3DFORMAT wined3d_format_lookup[] =
|
---|
262 | {
|
---|
263 | /*WINED3DDECLTYPE_FLOAT1*/ WINED3DFMT_R32_FLOAT,
|
---|
264 | /*WINED3DDECLTYPE_FLOAT2*/ WINED3DFMT_R32G32_FLOAT,
|
---|
265 | /*WINED3DDECLTYPE_FLOAT3*/ WINED3DFMT_R32G32B32_FLOAT,
|
---|
266 | /*WINED3DDECLTYPE_FLOAT4*/ WINED3DFMT_R32G32B32A32_FLOAT,
|
---|
267 | /*WINED3DDECLTYPE_D3DCOLOR*/ WINED3DFMT_A8R8G8B8,
|
---|
268 | /*WINED3DDECLTYPE_UBYTE4*/ WINED3DFMT_R8G8B8A8_UINT,
|
---|
269 | /*WINED3DDECLTYPE_SHORT2*/ WINED3DFMT_R16G16_SINT,
|
---|
270 | /*WINED3DDECLTYPE_SHORT4*/ WINED3DFMT_R16G16B16A16_SINT,
|
---|
271 | /*WINED3DDECLTYPE_UBYTE4N*/ WINED3DFMT_R8G8B8A8_UNORM,
|
---|
272 | /*WINED3DDECLTYPE_SHORT2N*/ WINED3DFMT_R16G16_SNORM,
|
---|
273 | /*WINED3DDECLTYPE_SHORT4N*/ WINED3DFMT_R16G16B16A16_SNORM,
|
---|
274 | /*WINED3DDECLTYPE_USHORT2N*/ WINED3DFMT_R16G16_UNORM,
|
---|
275 | /*WINED3DDECLTYPE_USHORT4N*/ WINED3DFMT_R16G16B16A16_UNORM,
|
---|
276 | /*WINED3DDECLTYPE_UDEC3*/ WINED3DFMT_R10G10B10A2_UINT,
|
---|
277 | /*WINED3DDECLTYPE_DEC3N*/ WINED3DFMT_R10G10B10A2_SNORM,
|
---|
278 | /*WINED3DDECLTYPE_FLOAT16_2*/ WINED3DFMT_R16G16_FLOAT,
|
---|
279 | /*WINED3DDECLTYPE_FLOAT16_4*/ WINED3DFMT_R16G16B16A16_FLOAT,
|
---|
280 | };
|
---|
281 |
|
---|
282 | typedef struct {
|
---|
283 | BYTE usage;
|
---|
284 | BYTE usage_idx;
|
---|
285 | } wined3d_usage_t;
|
---|
286 |
|
---|
287 | static const wined3d_usage_t wined3d_usage_lookup[] = {
|
---|
288 | /*D3DVSDE_POSITION*/ {WINED3DDECLUSAGE_POSITION, 0},
|
---|
289 | /*D3DVSDE_BLENDWEIGHT*/ {WINED3DDECLUSAGE_BLENDWEIGHT, 0},
|
---|
290 | /*D3DVSDE_BLENDINDICES*/ {WINED3DDECLUSAGE_BLENDINDICES, 0},
|
---|
291 | /*D3DVSDE_NORMAL*/ {WINED3DDECLUSAGE_NORMAL, 0},
|
---|
292 | /*D3DVSDE_PSIZE*/ {WINED3DDECLUSAGE_PSIZE, 0},
|
---|
293 | /*D3DVSDE_DIFFUSE*/ {WINED3DDECLUSAGE_COLOR, 0},
|
---|
294 | /*D3DVSDE_SPECULAR*/ {WINED3DDECLUSAGE_COLOR, 1},
|
---|
295 | /*D3DVSDE_TEXCOORD0*/ {WINED3DDECLUSAGE_TEXCOORD, 0},
|
---|
296 | /*D3DVSDE_TEXCOORD1*/ {WINED3DDECLUSAGE_TEXCOORD, 1},
|
---|
297 | /*D3DVSDE_TEXCOORD2*/ {WINED3DDECLUSAGE_TEXCOORD, 2},
|
---|
298 | /*D3DVSDE_TEXCOORD3*/ {WINED3DDECLUSAGE_TEXCOORD, 3},
|
---|
299 | /*D3DVSDE_TEXCOORD4*/ {WINED3DDECLUSAGE_TEXCOORD, 4},
|
---|
300 | /*D3DVSDE_TEXCOORD5*/ {WINED3DDECLUSAGE_TEXCOORD, 5},
|
---|
301 | /*D3DVSDE_TEXCOORD6*/ {WINED3DDECLUSAGE_TEXCOORD, 6},
|
---|
302 | /*D3DVSDE_TEXCOORD7*/ {WINED3DDECLUSAGE_TEXCOORD, 7},
|
---|
303 | /*D3DVSDE_POSITION2*/ {WINED3DDECLUSAGE_POSITION, 1},
|
---|
304 | /*D3DVSDE_NORMAL2*/ {WINED3DDECLUSAGE_NORMAL, 1},
|
---|
305 | };
|
---|
306 |
|
---|
307 | /* TODO: find out where rhw (or positionT) is for declaration8 */
|
---|
308 | UINT convert_to_wined3d_declaration(const DWORD *d3d8_elements, DWORD *d3d8_elements_size, WINED3DVERTEXELEMENT **wined3d_elements)
|
---|
309 | {
|
---|
310 | const DWORD *token = d3d8_elements;
|
---|
311 | WINED3DVERTEXELEMENT *element;
|
---|
312 | D3DVSD_TOKENTYPE token_type;
|
---|
313 | unsigned int element_count = 0;
|
---|
314 | DWORD stream = 0;
|
---|
315 | int offset = 0;
|
---|
316 |
|
---|
317 | TRACE("d3d8_elements %p, wined3d_elements %p\n", d3d8_elements, wined3d_elements);
|
---|
318 |
|
---|
319 | /* 128 should be enough for anyone... */
|
---|
320 | *wined3d_elements = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 128 * sizeof(WINED3DVERTEXELEMENT));
|
---|
321 | while (D3DVSD_END() != *token)
|
---|
322 | {
|
---|
323 | token_type = ((*token & D3DVSD_TOKENTYPEMASK) >> D3DVSD_TOKENTYPESHIFT);
|
---|
324 |
|
---|
325 | if (token_type == D3DVSD_TOKEN_STREAM && !(*token & D3DVSD_STREAMTESSMASK))
|
---|
326 | {
|
---|
327 | stream = ((*token & D3DVSD_STREAMNUMBERMASK) >> D3DVSD_STREAMNUMBERSHIFT);
|
---|
328 | offset = 0;
|
---|
329 | } else if (token_type == D3DVSD_TOKEN_STREAMDATA && !(token_type & 0x10000000)) {
|
---|
330 | DWORD type = ((*token & D3DVSD_DATATYPEMASK) >> D3DVSD_DATATYPESHIFT);
|
---|
331 | DWORD reg = ((*token & D3DVSD_VERTEXREGMASK) >> D3DVSD_VERTEXREGSHIFT);
|
---|
332 |
|
---|
333 | TRACE("Adding element %d:\n", element_count);
|
---|
334 |
|
---|
335 | element = *wined3d_elements + element_count++;
|
---|
336 | element->format = wined3d_format_lookup[type];
|
---|
337 | element->input_slot = stream;
|
---|
338 | element->offset = offset;
|
---|
339 | element->output_slot = reg;
|
---|
340 | element->method = WINED3DDECLMETHOD_DEFAULT;
|
---|
341 | element->usage = wined3d_usage_lookup[reg].usage;
|
---|
342 | element->usage_idx = wined3d_usage_lookup[reg].usage_idx;
|
---|
343 |
|
---|
344 | offset += wined3d_type_sizes[type];
|
---|
345 | } else if (token_type == D3DVSD_TOKEN_STREAMDATA && (token_type & 0x10000000)) {
|
---|
346 | TRACE(" 0x%08x SKIP(%u)\n", token_type, ((token_type & D3DVSD_SKIPCOUNTMASK) >> D3DVSD_SKIPCOUNTSHIFT));
|
---|
347 | offset += sizeof(DWORD) * ((token_type & D3DVSD_SKIPCOUNTMASK) >> D3DVSD_SKIPCOUNTSHIFT);
|
---|
348 | }
|
---|
349 |
|
---|
350 | if (element_count >= 127) {
|
---|
351 | ERR("More than 127 elements?\n");
|
---|
352 | break;
|
---|
353 | }
|
---|
354 |
|
---|
355 | token += parse_token(token);
|
---|
356 | }
|
---|
357 |
|
---|
358 | *d3d8_elements_size = (++token - d3d8_elements) * sizeof(DWORD);
|
---|
359 |
|
---|
360 | return element_count;
|
---|
361 | }
|
---|
362 |
|
---|
363 | const IDirect3DVertexDeclaration8Vtbl Direct3DVertexDeclaration8_Vtbl =
|
---|
364 | {
|
---|
365 | IDirect3DVertexDeclaration8Impl_QueryInterface,
|
---|
366 | IDirect3DVertexDeclaration8Impl_AddRef,
|
---|
367 | IDirect3DVertexDeclaration8Impl_Release
|
---|
368 | };
|
---|