~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/d3d8/vertexdeclaration.c

Version: ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.