2 * Copyright 2008 Luis Busquets
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "wine/port.h"
21 #include "wine/debug.h"
22 #include "wine/unicode.h"
26 #include "d3dx9shader.h"
27 #include "d3dx9_36_private.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(d3dx
);
31 LPCSTR WINAPI
D3DXGetPixelShaderProfile(LPDIRECT3DDEVICE9 device
)
35 TRACE("device %p\n", device
);
37 if (!device
) return NULL
;
39 IDirect3DDevice9_GetDeviceCaps(device
,&caps
);
41 switch (caps
.PixelShaderVersion
)
43 case D3DPS_VERSION(1, 1):
46 case D3DPS_VERSION(1, 2):
49 case D3DPS_VERSION(1, 3):
52 case D3DPS_VERSION(1, 4):
55 case D3DPS_VERSION(2, 0):
56 if ((caps
.PS20Caps
.NumTemps
>=22) &&
57 (caps
.PS20Caps
.Caps
&D3DPS20CAPS_ARBITRARYSWIZZLE
) &&
58 (caps
.PS20Caps
.Caps
&D3DPS20CAPS_GRADIENTINSTRUCTIONS
) &&
59 (caps
.PS20Caps
.Caps
&D3DPS20CAPS_PREDICATION
) &&
60 (caps
.PS20Caps
.Caps
&D3DPS20CAPS_NODEPENDENTREADLIMIT
) &&
61 (caps
.PS20Caps
.Caps
&D3DPS20CAPS_NOTEXINSTRUCTIONLIMIT
))
65 if ((caps
.PS20Caps
.NumTemps
>=32) &&
66 (caps
.PS20Caps
.Caps
&D3DPS20CAPS_NOTEXINSTRUCTIONLIMIT
))
72 case D3DPS_VERSION(3, 0):
79 UINT WINAPI
D3DXGetShaderSize(const DWORD
*byte_code
)
81 const DWORD
*ptr
= byte_code
;
83 TRACE("byte_code %p\n", byte_code
);
87 /* Look for the END token, skipping the VERSION token */
88 while (*++ptr
!= D3DSIO_END
)
91 if ((*ptr
& D3DSI_OPCODE_MASK
) == D3DSIO_COMMENT
)
93 ptr
+= ((*ptr
& D3DSI_COMMENTSIZE_MASK
) >> D3DSI_COMMENTSIZE_SHIFT
);
98 /* Return the shader size in bytes */
99 return (ptr
- byte_code
) * sizeof(*ptr
);
102 DWORD WINAPI
D3DXGetShaderVersion(const DWORD
*byte_code
)
104 TRACE("byte_code %p\n", byte_code
);
106 return byte_code
? *byte_code
: 0;
109 LPCSTR WINAPI
D3DXGetVertexShaderProfile(LPDIRECT3DDEVICE9 device
)
113 TRACE("device %p\n", device
);
115 if (!device
) return NULL
;
117 IDirect3DDevice9_GetDeviceCaps(device
,&caps
);
119 switch (caps
.VertexShaderVersion
)
121 case D3DVS_VERSION(1, 1):
123 case D3DVS_VERSION(2, 0):
124 if ((caps
.VS20Caps
.NumTemps
>=13) &&
125 (caps
.VS20Caps
.DynamicFlowControlDepth
==24) &&
126 (caps
.VS20Caps
.Caps
&D3DPS20CAPS_PREDICATION
))
131 case D3DVS_VERSION(3, 0):
138 HRESULT WINAPI
D3DXFindShaderComment(CONST DWORD
* byte_code
, DWORD fourcc
, LPCVOID
* data
, UINT
* size
)
140 CONST DWORD
*ptr
= byte_code
;
142 TRACE("(%p, %x, %p, %p)", byte_code
, fourcc
, data
, size
);
145 return D3DERR_INVALIDCALL
;
147 while (*++ptr
!= D3DSIO_END
)
149 /* Check if it is a comment */
150 if ((*ptr
& D3DSI_OPCODE_MASK
) == D3DSIO_COMMENT
)
152 DWORD comment_size
= (*ptr
& D3DSI_COMMENTSIZE_MASK
) >> D3DSI_COMMENTSIZE_SHIFT
;
154 /* Check if this is the comment we are looking for */
155 if (*(ptr
+ 1) == fourcc
)
157 UINT ctab_size
= (comment_size
- 1) * sizeof(DWORD
);
158 LPCVOID ctab_data
= ptr
+ 2;
163 TRACE("Returning comment data at %p with size %d\n", ctab_data
, ctab_size
);
173 HRESULT WINAPI
D3DXAssembleShader(LPCSTR data
,
175 CONST D3DXMACRO
* defines
,
176 LPD3DXINCLUDE include
,
178 LPD3DXBUFFER
* shader
,
179 LPD3DXBUFFER
* error_messages
)
181 FIXME("(%p, %d, %p, %p, %x, %p, %p): stub\n", data
, data_len
, defines
, include
, flags
, shader
, error_messages
);
182 return D3DERR_INVALIDCALL
;
185 HRESULT WINAPI
D3DXAssembleShaderFromFileA(LPCSTR filename
,
186 CONST D3DXMACRO
* defines
,
187 LPD3DXINCLUDE include
,
189 LPD3DXBUFFER
* shader
,
190 LPD3DXBUFFER
* error_messages
)
192 LPWSTR filename_w
= NULL
;
196 if (!filename
) return D3DXERR_INVALIDDATA
;
198 len
= MultiByteToWideChar(CP_ACP
, 0, filename
, -1, NULL
, 0);
199 filename_w
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
200 if (!filename_w
) return E_OUTOFMEMORY
;
201 MultiByteToWideChar(CP_ACP
, 0, filename
, -1, filename_w
, len
);
203 ret
= D3DXAssembleShaderFromFileW(filename_w
, defines
, include
, flags
, shader
, error_messages
);
205 HeapFree(GetProcessHeap(), 0, filename_w
);
209 HRESULT WINAPI
D3DXAssembleShaderFromFileW(LPCWSTR filename
,
210 CONST D3DXMACRO
* defines
,
211 LPD3DXINCLUDE include
,
213 LPD3DXBUFFER
* shader
,
214 LPD3DXBUFFER
* error_messages
)
216 FIXME("(%s, %p, %p, %x, %p, %p): stub\n", debugstr_w(filename
), defines
, include
, flags
, shader
, error_messages
);
217 return D3DERR_INVALIDCALL
;
220 HRESULT WINAPI
D3DXAssembleShaderFromResourceA(HMODULE module
,
222 CONST D3DXMACRO
* defines
,
223 LPD3DXINCLUDE include
,
225 LPD3DXBUFFER
* shader
,
226 LPD3DXBUFFER
* error_messages
)
232 if (!(res
= FindResourceA(module
, resource
, (LPCSTR
)RT_RCDATA
)))
233 return D3DXERR_INVALIDDATA
;
234 if (FAILED(load_resource_into_memory(module
, res
, (LPVOID
*)&buffer
, &len
)))
235 return D3DXERR_INVALIDDATA
;
236 return D3DXAssembleShader(buffer
, len
, defines
, include
, flags
,
237 shader
, error_messages
);
240 HRESULT WINAPI
D3DXAssembleShaderFromResourceW(HMODULE module
,
242 CONST D3DXMACRO
* defines
,
243 LPD3DXINCLUDE include
,
245 LPD3DXBUFFER
* shader
,
246 LPD3DXBUFFER
* error_messages
)
252 if (!(res
= FindResourceW(module
, resource
, (LPCWSTR
)RT_RCDATA
)))
253 return D3DXERR_INVALIDDATA
;
254 if (FAILED(load_resource_into_memory(module
, res
, (LPVOID
*)&buffer
, &len
)))
255 return D3DXERR_INVALIDDATA
;
256 return D3DXAssembleShader(buffer
, len
, defines
, include
, flags
,
257 shader
, error_messages
);
260 HRESULT WINAPI
D3DXCompileShader(LPCSTR pSrcData
,
262 CONST D3DXMACRO
* pDefines
,
263 LPD3DXINCLUDE pInclude
,
264 LPCSTR pFunctionName
,
267 LPD3DXBUFFER
* ppShader
,
268 LPD3DXBUFFER
* ppErrorMsgs
,
269 LPD3DXCONSTANTTABLE
* ppConstantTable
)
271 FIXME("(%p, %d, %p, %p, %p, %p, %d, %p, %p, %p): stub\n",
272 pSrcData
, srcDataLen
, pDefines
, pInclude
, pFunctionName
,
273 pProfile
, Flags
, ppShader
, ppErrorMsgs
, ppConstantTable
);
274 return D3DERR_INVALIDCALL
;
277 static const struct ID3DXConstantTableVtbl ID3DXConstantTable_Vtbl
;
279 typedef struct ID3DXConstantTableImpl
{
280 const ID3DXConstantTableVtbl
*lpVtbl
;
284 D3DXCONSTANTTABLE_DESC desc
;
285 } ID3DXConstantTableImpl
;
287 /*** IUnknown methods ***/
288 static HRESULT WINAPI
ID3DXConstantTableImpl_QueryInterface(ID3DXConstantTable
* iface
, REFIID riid
, void** ppvObject
)
290 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
292 TRACE("(%p)->(%s, %p)\n", This
, debugstr_guid(riid
), ppvObject
);
294 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
295 IsEqualGUID(riid
, &IID_ID3DXBuffer
) ||
296 IsEqualGUID(riid
, &IID_ID3DXConstantTable
))
298 ID3DXConstantTable_AddRef(iface
);
303 WARN("Interface %s not found.\n", debugstr_guid(riid
));
305 return E_NOINTERFACE
;
308 static ULONG WINAPI
ID3DXConstantTableImpl_AddRef(ID3DXConstantTable
* iface
)
310 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
312 TRACE("(%p)->(): AddRef from %d\n", This
, This
->ref
);
314 return InterlockedIncrement(&This
->ref
);
317 static ULONG WINAPI
ID3DXConstantTableImpl_Release(ID3DXConstantTable
* iface
)
319 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
320 ULONG ref
= InterlockedDecrement(&This
->ref
);
322 TRACE("(%p)->(): Release from %d\n", This
, ref
+ 1);
326 HeapFree(GetProcessHeap(), 0, This
->ctab
);
327 HeapFree(GetProcessHeap(), 0, This
);
333 /*** ID3DXBuffer methods ***/
334 static LPVOID WINAPI
ID3DXConstantTableImpl_GetBufferPointer(ID3DXConstantTable
* iface
)
336 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
338 TRACE("(%p)->()\n", This
);
343 static DWORD WINAPI
ID3DXConstantTableImpl_GetBufferSize(ID3DXConstantTable
* iface
)
345 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
347 TRACE("(%p)->()\n", This
);
352 /*** ID3DXConstantTable methods ***/
353 static HRESULT WINAPI
ID3DXConstantTableImpl_GetDesc(ID3DXConstantTable
* iface
, D3DXCONSTANTTABLE_DESC
*desc
)
355 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
357 TRACE("(%p)->(%p)\n", This
, desc
);
360 return D3DERR_INVALIDCALL
;
362 memcpy(desc
, &This
->desc
, sizeof(This
->desc
));
367 static HRESULT WINAPI
ID3DXConstantTableImpl_GetConstantDesc(ID3DXConstantTable
* iface
, D3DXHANDLE constant
,
368 D3DXCONSTANT_DESC
*desc
, UINT
*count
)
370 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
372 FIXME("(%p)->(%p, %p, %p): stub\n", This
, constant
, desc
, count
);
377 static UINT WINAPI
ID3DXConstantTableImpl_GetSamplerIndex(LPD3DXCONSTANTTABLE iface
, D3DXHANDLE constant
)
379 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
381 FIXME("(%p)->(%p): stub\n", This
, constant
);
386 static D3DXHANDLE WINAPI
ID3DXConstantTableImpl_GetConstant(ID3DXConstantTable
* iface
, D3DXHANDLE constant
, UINT index
)
388 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
390 FIXME("(%p)->(%p, %d): stub\n", This
, constant
, index
);
395 static D3DXHANDLE WINAPI
ID3DXConstantTableImpl_GetConstantByName(ID3DXConstantTable
* iface
, D3DXHANDLE constant
, LPCSTR name
)
397 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
399 FIXME("(%p)->(%p, %s): stub\n", This
, constant
, name
);
404 static D3DXHANDLE WINAPI
ID3DXConstantTableImpl_GetConstantElement(ID3DXConstantTable
* iface
, D3DXHANDLE constant
, UINT index
)
406 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
408 FIXME("(%p)->(%p, %d): stub\n", This
, constant
, index
);
413 static HRESULT WINAPI
ID3DXConstantTableImpl_SetDefaults(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
)
415 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
417 FIXME("(%p)->(%p): stub\n", This
, device
);
422 static HRESULT WINAPI
ID3DXConstantTableImpl_SetValue(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
423 D3DXHANDLE constant
, LPCVOID data
, UINT bytes
)
425 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
427 FIXME("(%p)->(%p, %p, %p, %d): stub\n", This
, device
, constant
, data
, bytes
);
432 static HRESULT WINAPI
ID3DXConstantTableImpl_SetBool(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
433 D3DXHANDLE constant
, BOOL b
)
435 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
437 FIXME("(%p)->(%p, %p, %d): stub\n", This
, device
, constant
, b
);
442 static HRESULT WINAPI
ID3DXConstantTableImpl_SetBoolArray(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
443 D3DXHANDLE constant
, CONST BOOL
* b
, UINT count
)
445 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
447 FIXME("(%p)->(%p, %p, %p, %d): stub\n", This
, device
, constant
, b
, count
);
452 static HRESULT WINAPI
ID3DXConstantTableImpl_SetInt(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
, D3DXHANDLE constant
, INT n
)
454 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
456 FIXME("(%p)->(%p, %p, %d): stub\n", This
, device
, constant
, n
);
461 static HRESULT WINAPI
ID3DXConstantTableImpl_SetIntArray(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
462 D3DXHANDLE constant
, CONST INT
* n
, UINT count
)
464 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
466 FIXME("(%p)->(%p, %p, %p, %d): stub\n", This
, device
, constant
, n
, count
);
471 static HRESULT WINAPI
ID3DXConstantTableImpl_SetFloat(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
472 D3DXHANDLE constant
, FLOAT f
)
474 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
476 FIXME("(%p)->(%p, %p, %f): stub\n", This
, device
, constant
, f
);
481 static HRESULT WINAPI
ID3DXConstantTableImpl_SetFloatArray(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
482 D3DXHANDLE constant
, CONST FLOAT
* f
, UINT count
)
484 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
486 FIXME("(%p)->(%p, %p, %p, %d): stub\n", This
, device
, constant
, f
, count
);
491 static HRESULT WINAPI
ID3DXConstantTableImpl_SetVector(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
492 D3DXHANDLE constant
, CONST D3DXVECTOR4
* vector
)
494 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
496 FIXME("(%p)->(%p, %p, %p): stub\n", This
, device
, constant
, vector
);
501 static HRESULT WINAPI
ID3DXConstantTableImpl_SetVectorArray(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
502 D3DXHANDLE constant
, CONST D3DXVECTOR4
* vector
, UINT count
)
504 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
506 FIXME("(%p)->(%p, %p, %p, %d): stub\n", This
, device
, constant
, vector
, count
);
511 static HRESULT WINAPI
ID3DXConstantTableImpl_SetMatrix(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
512 D3DXHANDLE constant
, CONST D3DXMATRIX
* matrix
)
514 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
516 FIXME("(%p)->(%p, %p, %p): stub\n", This
, device
, constant
, matrix
);
521 static HRESULT WINAPI
ID3DXConstantTableImpl_SetMatrixArray(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
522 D3DXHANDLE constant
, CONST D3DXMATRIX
* matrix
, UINT count
)
524 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
526 FIXME("(%p)->(%p, %p, %p, %d): stub\n", This
, device
, constant
, matrix
, count
);
531 static HRESULT WINAPI
ID3DXConstantTableImpl_SetMatrixPointerArray(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
532 D3DXHANDLE constant
, CONST D3DXMATRIX
** matrix
, UINT count
)
534 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
536 FIXME("(%p)->(%p, %p, %p, %d): stub\n", This
, device
, constant
, matrix
, count
);
541 static HRESULT WINAPI
ID3DXConstantTableImpl_SetMatrixTranspose(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
542 D3DXHANDLE constant
, CONST D3DXMATRIX
* matrix
)
544 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
546 FIXME("(%p)->(%p, %p, %p): stub\n", This
, device
, constant
, matrix
);
551 static HRESULT WINAPI
ID3DXConstantTableImpl_SetMatrixTransposeArray(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
552 D3DXHANDLE constant
, CONST D3DXMATRIX
* matrix
, UINT count
)
554 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
556 FIXME("(%p)->(%p, %p, %p, %d): stub\n", This
, device
, constant
, matrix
, count
);
561 static HRESULT WINAPI
ID3DXConstantTableImpl_SetMatrixTransposePointerArray(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
562 D3DXHANDLE constant
, CONST D3DXMATRIX
** matrix
, UINT count
)
564 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
566 FIXME("(%p)->(%p, %p, %p, %d): stub\n", This
, device
, constant
, matrix
, count
);
571 static const struct ID3DXConstantTableVtbl ID3DXConstantTable_Vtbl
=
573 /*** IUnknown methods ***/
574 ID3DXConstantTableImpl_QueryInterface
,
575 ID3DXConstantTableImpl_AddRef
,
576 ID3DXConstantTableImpl_Release
,
577 /*** ID3DXBuffer methods ***/
578 ID3DXConstantTableImpl_GetBufferPointer
,
579 ID3DXConstantTableImpl_GetBufferSize
,
580 /*** ID3DXConstantTable methods ***/
581 ID3DXConstantTableImpl_GetDesc
,
582 ID3DXConstantTableImpl_GetConstantDesc
,
583 ID3DXConstantTableImpl_GetSamplerIndex
,
584 ID3DXConstantTableImpl_GetConstant
,
585 ID3DXConstantTableImpl_GetConstantByName
,
586 ID3DXConstantTableImpl_GetConstantElement
,
587 ID3DXConstantTableImpl_SetDefaults
,
588 ID3DXConstantTableImpl_SetValue
,
589 ID3DXConstantTableImpl_SetBool
,
590 ID3DXConstantTableImpl_SetBoolArray
,
591 ID3DXConstantTableImpl_SetInt
,
592 ID3DXConstantTableImpl_SetIntArray
,
593 ID3DXConstantTableImpl_SetFloat
,
594 ID3DXConstantTableImpl_SetFloatArray
,
595 ID3DXConstantTableImpl_SetVector
,
596 ID3DXConstantTableImpl_SetVectorArray
,
597 ID3DXConstantTableImpl_SetMatrix
,
598 ID3DXConstantTableImpl_SetMatrixArray
,
599 ID3DXConstantTableImpl_SetMatrixPointerArray
,
600 ID3DXConstantTableImpl_SetMatrixTranspose
,
601 ID3DXConstantTableImpl_SetMatrixTransposeArray
,
602 ID3DXConstantTableImpl_SetMatrixTransposePointerArray
605 HRESULT WINAPI
D3DXGetShaderConstantTableEx(CONST DWORD
* byte_code
,
607 LPD3DXCONSTANTTABLE
* constant_table
)
609 ID3DXConstantTableImpl
* object
= NULL
;
613 D3DXSHADER_CONSTANTTABLE
* ctab_header
;
615 FIXME("(%p, %x, %p): semi-stub\n", byte_code
, flags
, constant_table
);
617 if (!byte_code
|| !constant_table
)
618 return D3DERR_INVALIDCALL
;
620 hr
= D3DXFindShaderComment(byte_code
, MAKEFOURCC('C','T','A','B'), &data
, &size
);
622 return D3DXERR_INVALIDDATA
;
624 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(ID3DXConstantTableImpl
));
627 ERR("Out of memory\n");
628 return E_OUTOFMEMORY
;
631 object
->lpVtbl
= &ID3DXConstantTable_Vtbl
;
634 if (size
< sizeof(D3DXSHADER_CONSTANTTABLE
))
637 object
->ctab
= HeapAlloc(GetProcessHeap(), 0, size
);
640 HeapFree(GetProcessHeap(), 0, object
);
641 ERR("Out of memory\n");
642 return E_OUTOFMEMORY
;
645 memcpy(object
->ctab
, data
, object
->size
);
647 ctab_header
= (D3DXSHADER_CONSTANTTABLE
*)data
;
648 if (ctab_header
->Size
!= sizeof(D3DXSHADER_CONSTANTTABLE
))
650 object
->desc
.Creator
= ctab_header
->Creator
? (LPCSTR
)object
->ctab
+ ctab_header
->Creator
: NULL
;
651 object
->desc
.Version
= ctab_header
->Version
;
652 object
->desc
.Constants
= ctab_header
->Constants
;
654 *constant_table
= (LPD3DXCONSTANTTABLE
)object
;
660 HeapFree(GetProcessHeap(), 0, object
->ctab
);
661 HeapFree(GetProcessHeap(), 0, object
);
663 return D3DXERR_INVALIDDATA
;
666 HRESULT WINAPI
D3DXGetShaderConstantTable(CONST DWORD
* byte_code
,
667 LPD3DXCONSTANTTABLE
* constant_table
)
669 TRACE("(%p, %p): Forwarded to D3DXGetShaderConstantTableEx\n", byte_code
, constant_table
);
671 return D3DXGetShaderConstantTableEx(byte_code
, 0, constant_table
);