2 * Copyright 2008 Luis Busquets
3 * Copyright 2009 Matteo Bruni
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/port.h"
22 #include "wine/debug.h"
23 #include "wine/unicode.h"
27 #include "d3dcommon.h"
28 #include "d3dx9_36_private.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(d3dx
);
32 /* This function is not declared in the SDK headers yet */
33 HRESULT WINAPI
D3DAssemble(LPCVOID data
, SIZE_T datasize
, LPCSTR filename
,
34 const D3D_SHADER_MACRO
*defines
, ID3DInclude
*include
,
36 ID3DBlob
**shader
, ID3DBlob
**error_messages
);
38 LPCSTR WINAPI
D3DXGetPixelShaderProfile(LPDIRECT3DDEVICE9 device
)
42 TRACE("device %p\n", device
);
44 if (!device
) return NULL
;
46 IDirect3DDevice9_GetDeviceCaps(device
,&caps
);
48 switch (caps
.PixelShaderVersion
)
50 case D3DPS_VERSION(1, 1):
53 case D3DPS_VERSION(1, 2):
56 case D3DPS_VERSION(1, 3):
59 case D3DPS_VERSION(1, 4):
62 case D3DPS_VERSION(2, 0):
63 if ((caps
.PS20Caps
.NumTemps
>=22) &&
64 (caps
.PS20Caps
.Caps
&D3DPS20CAPS_ARBITRARYSWIZZLE
) &&
65 (caps
.PS20Caps
.Caps
&D3DPS20CAPS_GRADIENTINSTRUCTIONS
) &&
66 (caps
.PS20Caps
.Caps
&D3DPS20CAPS_PREDICATION
) &&
67 (caps
.PS20Caps
.Caps
&D3DPS20CAPS_NODEPENDENTREADLIMIT
) &&
68 (caps
.PS20Caps
.Caps
&D3DPS20CAPS_NOTEXINSTRUCTIONLIMIT
))
72 if ((caps
.PS20Caps
.NumTemps
>=32) &&
73 (caps
.PS20Caps
.Caps
&D3DPS20CAPS_NOTEXINSTRUCTIONLIMIT
))
79 case D3DPS_VERSION(3, 0):
86 UINT WINAPI
D3DXGetShaderSize(const DWORD
*byte_code
)
88 const DWORD
*ptr
= byte_code
;
90 TRACE("byte_code %p\n", byte_code
);
94 /* Look for the END token, skipping the VERSION token */
95 while (*++ptr
!= D3DSIO_END
)
98 if ((*ptr
& D3DSI_OPCODE_MASK
) == D3DSIO_COMMENT
)
100 ptr
+= ((*ptr
& D3DSI_COMMENTSIZE_MASK
) >> D3DSI_COMMENTSIZE_SHIFT
);
105 /* Return the shader size in bytes */
106 return (ptr
- byte_code
) * sizeof(*ptr
);
109 DWORD WINAPI
D3DXGetShaderVersion(const DWORD
*byte_code
)
111 TRACE("byte_code %p\n", byte_code
);
113 return byte_code
? *byte_code
: 0;
116 LPCSTR WINAPI
D3DXGetVertexShaderProfile(LPDIRECT3DDEVICE9 device
)
120 TRACE("device %p\n", device
);
122 if (!device
) return NULL
;
124 IDirect3DDevice9_GetDeviceCaps(device
,&caps
);
126 switch (caps
.VertexShaderVersion
)
128 case D3DVS_VERSION(1, 1):
130 case D3DVS_VERSION(2, 0):
131 if ((caps
.VS20Caps
.NumTemps
>=13) &&
132 (caps
.VS20Caps
.DynamicFlowControlDepth
==24) &&
133 (caps
.VS20Caps
.Caps
&D3DPS20CAPS_PREDICATION
))
138 case D3DVS_VERSION(3, 0):
145 HRESULT WINAPI
D3DXFindShaderComment(CONST DWORD
* byte_code
, DWORD fourcc
, LPCVOID
* data
, UINT
* size
)
147 CONST DWORD
*ptr
= byte_code
;
149 TRACE("(%p, %x, %p, %p)\n", byte_code
, fourcc
, data
, size
);
152 return D3DERR_INVALIDCALL
;
154 while (*++ptr
!= D3DSIO_END
)
156 /* Check if it is a comment */
157 if ((*ptr
& D3DSI_OPCODE_MASK
) == D3DSIO_COMMENT
)
159 DWORD comment_size
= (*ptr
& D3DSI_COMMENTSIZE_MASK
) >> D3DSI_COMMENTSIZE_SHIFT
;
161 /* Check if this is the comment we are looking for */
162 if (*(ptr
+ 1) == fourcc
)
164 UINT ctab_size
= (comment_size
- 1) * sizeof(DWORD
);
165 LPCVOID ctab_data
= ptr
+ 2;
170 TRACE("Returning comment data at %p with size %d\n", ctab_data
, ctab_size
);
180 HRESULT WINAPI
D3DXAssembleShader(LPCSTR data
,
182 CONST D3DXMACRO
* defines
,
183 LPD3DXINCLUDE include
,
185 LPD3DXBUFFER
* shader
,
186 LPD3DXBUFFER
* error_messages
)
188 /* Forward to d3dcompiler: the parameter types aren't really different,
189 the actual data types are equivalent */
190 HRESULT hr
= D3DAssemble(data
, data_len
, NULL
, (D3D_SHADER_MACRO
*)defines
,
191 (ID3DInclude
*)include
, flags
, (ID3DBlob
**)shader
,
192 (ID3DBlob
**)error_messages
);
194 if(hr
== E_FAIL
) hr
= D3DXERR_INVALIDDATA
;
198 /* D3DXInclude private implementation, used to implement
199 D3DXAssembleShaderFromFile from D3DXAssembleShader */
200 /* To be able to correctly resolve include search paths we have to store
201 the pathname of each include file. We store the pathname pointer right
202 before the file data. */
203 static HRESULT WINAPI
d3dincludefromfile_open(ID3DXInclude
*iface
,
204 D3DXINCLUDE_TYPE include_type
,
205 LPCSTR filename
, LPCVOID parent_data
,
206 LPCVOID
*data
, UINT
*bytes
) {
207 const char *p
, *parent_name
= "";
208 char *pathname
= NULL
;
209 char **buffer
= NULL
;
213 if(parent_data
!= NULL
)
214 parent_name
= *((const char **)parent_data
- 1);
216 TRACE("Looking up for include file %s, parent %s\n", debugstr_a(filename
), debugstr_a(parent_name
));
218 if ((p
= strrchr(parent_name
, '\\')) || (p
= strrchr(parent_name
, '/'))) p
++;
219 else p
= parent_name
;
220 pathname
= HeapAlloc(GetProcessHeap(), 0, (p
- parent_name
) + strlen(filename
) + 1);
222 return HRESULT_FROM_WIN32(GetLastError());
224 memcpy(pathname
, parent_name
, p
- parent_name
);
225 strcpy(pathname
+ (p
- parent_name
), filename
);
227 file
= CreateFileA(pathname
, GENERIC_READ
, FILE_SHARE_READ
, 0, OPEN_EXISTING
, 0, 0);
228 if(file
== INVALID_HANDLE_VALUE
)
231 TRACE("Include file found at pathname = %s\n", debugstr_a(pathname
));
233 size
= GetFileSize(file
, NULL
);
234 if(size
== INVALID_FILE_SIZE
)
237 buffer
= HeapAlloc(GetProcessHeap(), 0, size
+ sizeof(char *));
241 if(!ReadFile(file
, buffer
+ 1, size
, bytes
, NULL
))
251 HeapFree(GetProcessHeap(), 0, pathname
);
252 HeapFree(GetProcessHeap(), 0, buffer
);
253 return HRESULT_FROM_WIN32(GetLastError());
256 static HRESULT WINAPI
d3dincludefromfile_close(ID3DXInclude
*iface
, LPCVOID data
) {
257 HeapFree(GetProcessHeap(), 0, *((char **)data
- 1));
258 HeapFree(GetProcessHeap(), 0, (char **)data
- 1);
262 static const struct ID3DXIncludeVtbl D3DXInclude_Vtbl
= {
263 d3dincludefromfile_open
,
264 d3dincludefromfile_close
267 struct D3DXIncludeImpl
{
268 const ID3DXIncludeVtbl
*lpVtbl
;
271 HRESULT WINAPI
D3DXAssembleShaderFromFileA(LPCSTR filename
,
272 CONST D3DXMACRO
* defines
,
273 LPD3DXINCLUDE include
,
275 LPD3DXBUFFER
* shader
,
276 LPD3DXBUFFER
* error_messages
)
278 LPWSTR filename_w
= NULL
;
282 if (!filename
) return D3DXERR_INVALIDDATA
;
284 len
= MultiByteToWideChar(CP_ACP
, 0, filename
, -1, NULL
, 0);
285 filename_w
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
286 if (!filename_w
) return E_OUTOFMEMORY
;
287 MultiByteToWideChar(CP_ACP
, 0, filename
, -1, filename_w
, len
);
289 ret
= D3DXAssembleShaderFromFileW(filename_w
, defines
, include
, flags
, shader
, error_messages
);
291 HeapFree(GetProcessHeap(), 0, filename_w
);
295 HRESULT WINAPI
D3DXAssembleShaderFromFileW(LPCWSTR filename
,
296 CONST D3DXMACRO
* defines
,
297 LPD3DXINCLUDE include
,
299 LPD3DXBUFFER
* shader
,
300 LPD3DXBUFFER
* error_messages
)
305 struct D3DXIncludeImpl includefromfile
;
307 if(FAILED(map_view_of_file(filename
, &buffer
, &len
)))
308 return D3DXERR_INVALIDDATA
;
312 includefromfile
.lpVtbl
= &D3DXInclude_Vtbl
;
313 include
= (LPD3DXINCLUDE
)&includefromfile
;
316 hr
= D3DXAssembleShader(buffer
, len
, defines
, include
, flags
,
317 shader
, error_messages
);
319 UnmapViewOfFile(buffer
);
323 HRESULT WINAPI
D3DXAssembleShaderFromResourceA(HMODULE module
,
325 CONST D3DXMACRO
* defines
,
326 LPD3DXINCLUDE include
,
328 LPD3DXBUFFER
* shader
,
329 LPD3DXBUFFER
* error_messages
)
335 if (!(res
= FindResourceA(module
, resource
, (LPCSTR
)RT_RCDATA
)))
336 return D3DXERR_INVALIDDATA
;
337 if (FAILED(load_resource_into_memory(module
, res
, (LPVOID
*)&buffer
, &len
)))
338 return D3DXERR_INVALIDDATA
;
339 return D3DXAssembleShader(buffer
, len
, defines
, include
, flags
,
340 shader
, error_messages
);
343 HRESULT WINAPI
D3DXAssembleShaderFromResourceW(HMODULE module
,
345 CONST D3DXMACRO
* defines
,
346 LPD3DXINCLUDE include
,
348 LPD3DXBUFFER
* shader
,
349 LPD3DXBUFFER
* error_messages
)
355 if (!(res
= FindResourceW(module
, resource
, (LPCWSTR
)RT_RCDATA
)))
356 return D3DXERR_INVALIDDATA
;
357 if (FAILED(load_resource_into_memory(module
, res
, (LPVOID
*)&buffer
, &len
)))
358 return D3DXERR_INVALIDDATA
;
359 return D3DXAssembleShader(buffer
, len
, defines
, include
, flags
,
360 shader
, error_messages
);
363 HRESULT WINAPI
D3DXCompileShader(LPCSTR pSrcData
,
365 CONST D3DXMACRO
* pDefines
,
366 LPD3DXINCLUDE pInclude
,
367 LPCSTR pFunctionName
,
370 LPD3DXBUFFER
* ppShader
,
371 LPD3DXBUFFER
* ppErrorMsgs
,
372 LPD3DXCONSTANTTABLE
* ppConstantTable
)
374 FIXME("(%p, %d, %p, %p, %s, %s, %x, %p, %p, %p): stub\n",
375 pSrcData
, srcDataLen
, pDefines
, pInclude
, debugstr_a(pFunctionName
),
376 debugstr_a(pProfile
), Flags
, ppShader
, ppErrorMsgs
, ppConstantTable
);
378 TRACE("Shader source:\n");
379 TRACE("%s\n", debugstr_an(pSrcData
, srcDataLen
));
382 D3DXCreateBuffer(1, ppErrorMsgs
); /* zero fill used as string end */
383 return D3DERR_INVALIDCALL
;
386 static const struct ID3DXConstantTableVtbl ID3DXConstantTable_Vtbl
;
388 typedef struct ID3DXConstantTableImpl
{
389 const ID3DXConstantTableVtbl
*lpVtbl
;
393 D3DXCONSTANTTABLE_DESC desc
;
394 } ID3DXConstantTableImpl
;
396 /*** IUnknown methods ***/
397 static HRESULT WINAPI
ID3DXConstantTableImpl_QueryInterface(ID3DXConstantTable
* iface
, REFIID riid
, void** ppvObject
)
399 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
401 TRACE("(%p)->(%s, %p)\n", This
, debugstr_guid(riid
), ppvObject
);
403 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
404 IsEqualGUID(riid
, &IID_ID3DXBuffer
) ||
405 IsEqualGUID(riid
, &IID_ID3DXConstantTable
))
407 ID3DXConstantTable_AddRef(iface
);
412 WARN("Interface %s not found.\n", debugstr_guid(riid
));
414 return E_NOINTERFACE
;
417 static ULONG WINAPI
ID3DXConstantTableImpl_AddRef(ID3DXConstantTable
* iface
)
419 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
421 TRACE("(%p)->(): AddRef from %d\n", This
, This
->ref
);
423 return InterlockedIncrement(&This
->ref
);
426 static ULONG WINAPI
ID3DXConstantTableImpl_Release(ID3DXConstantTable
* iface
)
428 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
429 ULONG ref
= InterlockedDecrement(&This
->ref
);
431 TRACE("(%p)->(): Release from %d\n", This
, ref
+ 1);
435 HeapFree(GetProcessHeap(), 0, This
->ctab
);
436 HeapFree(GetProcessHeap(), 0, This
);
442 /*** ID3DXBuffer methods ***/
443 static LPVOID WINAPI
ID3DXConstantTableImpl_GetBufferPointer(ID3DXConstantTable
* iface
)
445 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
447 TRACE("(%p)->()\n", This
);
452 static DWORD WINAPI
ID3DXConstantTableImpl_GetBufferSize(ID3DXConstantTable
* iface
)
454 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
456 TRACE("(%p)->()\n", This
);
461 /*** ID3DXConstantTable methods ***/
462 static HRESULT WINAPI
ID3DXConstantTableImpl_GetDesc(ID3DXConstantTable
* iface
, D3DXCONSTANTTABLE_DESC
*desc
)
464 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
466 TRACE("(%p)->(%p)\n", This
, desc
);
469 return D3DERR_INVALIDCALL
;
471 memcpy(desc
, &This
->desc
, sizeof(This
->desc
));
476 static HRESULT WINAPI
ID3DXConstantTableImpl_GetConstantDesc(ID3DXConstantTable
* iface
, D3DXHANDLE constant
,
477 D3DXCONSTANT_DESC
*desc
, UINT
*count
)
479 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
481 FIXME("(%p)->(%p, %p, %p): stub\n", This
, constant
, desc
, count
);
486 static UINT WINAPI
ID3DXConstantTableImpl_GetSamplerIndex(LPD3DXCONSTANTTABLE iface
, D3DXHANDLE constant
)
488 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
490 FIXME("(%p)->(%p): stub\n", This
, constant
);
495 static D3DXHANDLE WINAPI
ID3DXConstantTableImpl_GetConstant(ID3DXConstantTable
* iface
, D3DXHANDLE constant
, UINT index
)
497 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
499 FIXME("(%p)->(%p, %d): stub\n", This
, constant
, index
);
504 static D3DXHANDLE WINAPI
ID3DXConstantTableImpl_GetConstantByName(ID3DXConstantTable
* iface
, D3DXHANDLE constant
, LPCSTR name
)
506 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
508 FIXME("(%p)->(%p, %s): stub\n", This
, constant
, name
);
513 static D3DXHANDLE WINAPI
ID3DXConstantTableImpl_GetConstantElement(ID3DXConstantTable
* iface
, D3DXHANDLE constant
, UINT index
)
515 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
517 FIXME("(%p)->(%p, %d): stub\n", This
, constant
, index
);
522 static HRESULT WINAPI
ID3DXConstantTableImpl_SetDefaults(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
)
524 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
526 FIXME("(%p)->(%p): stub\n", This
, device
);
531 static HRESULT WINAPI
ID3DXConstantTableImpl_SetValue(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
532 D3DXHANDLE constant
, LPCVOID data
, UINT bytes
)
534 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
536 FIXME("(%p)->(%p, %p, %p, %d): stub\n", This
, device
, constant
, data
, bytes
);
541 static HRESULT WINAPI
ID3DXConstantTableImpl_SetBool(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
542 D3DXHANDLE constant
, BOOL b
)
544 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
546 FIXME("(%p)->(%p, %p, %d): stub\n", This
, device
, constant
, b
);
551 static HRESULT WINAPI
ID3DXConstantTableImpl_SetBoolArray(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
552 D3DXHANDLE constant
, CONST BOOL
* b
, UINT count
)
554 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
556 FIXME("(%p)->(%p, %p, %p, %d): stub\n", This
, device
, constant
, b
, count
);
561 static HRESULT WINAPI
ID3DXConstantTableImpl_SetInt(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
, D3DXHANDLE constant
, INT n
)
563 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
565 FIXME("(%p)->(%p, %p, %d): stub\n", This
, device
, constant
, n
);
570 static HRESULT WINAPI
ID3DXConstantTableImpl_SetIntArray(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
571 D3DXHANDLE constant
, CONST INT
* n
, UINT count
)
573 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
575 FIXME("(%p)->(%p, %p, %p, %d): stub\n", This
, device
, constant
, n
, count
);
580 static HRESULT WINAPI
ID3DXConstantTableImpl_SetFloat(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
581 D3DXHANDLE constant
, FLOAT f
)
583 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
585 FIXME("(%p)->(%p, %p, %f): stub\n", This
, device
, constant
, f
);
590 static HRESULT WINAPI
ID3DXConstantTableImpl_SetFloatArray(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
591 D3DXHANDLE constant
, CONST FLOAT
* f
, UINT count
)
593 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
595 FIXME("(%p)->(%p, %p, %p, %d): stub\n", This
, device
, constant
, f
, count
);
600 static HRESULT WINAPI
ID3DXConstantTableImpl_SetVector(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
601 D3DXHANDLE constant
, CONST D3DXVECTOR4
* vector
)
603 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
605 FIXME("(%p)->(%p, %p, %p): stub\n", This
, device
, constant
, vector
);
610 static HRESULT WINAPI
ID3DXConstantTableImpl_SetVectorArray(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
611 D3DXHANDLE constant
, CONST D3DXVECTOR4
* vector
, UINT count
)
613 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
615 FIXME("(%p)->(%p, %p, %p, %d): stub\n", This
, device
, constant
, vector
, count
);
620 static HRESULT WINAPI
ID3DXConstantTableImpl_SetMatrix(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
621 D3DXHANDLE constant
, CONST D3DXMATRIX
* matrix
)
623 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
625 FIXME("(%p)->(%p, %p, %p): stub\n", This
, device
, constant
, matrix
);
630 static HRESULT WINAPI
ID3DXConstantTableImpl_SetMatrixArray(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
631 D3DXHANDLE constant
, CONST D3DXMATRIX
* matrix
, UINT count
)
633 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
635 FIXME("(%p)->(%p, %p, %p, %d): stub\n", This
, device
, constant
, matrix
, count
);
640 static HRESULT WINAPI
ID3DXConstantTableImpl_SetMatrixPointerArray(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
641 D3DXHANDLE constant
, CONST D3DXMATRIX
** matrix
, UINT count
)
643 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
645 FIXME("(%p)->(%p, %p, %p, %d): stub\n", This
, device
, constant
, matrix
, count
);
650 static HRESULT WINAPI
ID3DXConstantTableImpl_SetMatrixTranspose(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
651 D3DXHANDLE constant
, CONST D3DXMATRIX
* matrix
)
653 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
655 FIXME("(%p)->(%p, %p, %p): stub\n", This
, device
, constant
, matrix
);
660 static HRESULT WINAPI
ID3DXConstantTableImpl_SetMatrixTransposeArray(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
661 D3DXHANDLE constant
, CONST D3DXMATRIX
* matrix
, UINT count
)
663 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
665 FIXME("(%p)->(%p, %p, %p, %d): stub\n", This
, device
, constant
, matrix
, count
);
670 static HRESULT WINAPI
ID3DXConstantTableImpl_SetMatrixTransposePointerArray(ID3DXConstantTable
* iface
, LPDIRECT3DDEVICE9 device
,
671 D3DXHANDLE constant
, CONST D3DXMATRIX
** matrix
, UINT count
)
673 ID3DXConstantTableImpl
*This
= (ID3DXConstantTableImpl
*)iface
;
675 FIXME("(%p)->(%p, %p, %p, %d): stub\n", This
, device
, constant
, matrix
, count
);
680 static const struct ID3DXConstantTableVtbl ID3DXConstantTable_Vtbl
=
682 /*** IUnknown methods ***/
683 ID3DXConstantTableImpl_QueryInterface
,
684 ID3DXConstantTableImpl_AddRef
,
685 ID3DXConstantTableImpl_Release
,
686 /*** ID3DXBuffer methods ***/
687 ID3DXConstantTableImpl_GetBufferPointer
,
688 ID3DXConstantTableImpl_GetBufferSize
,
689 /*** ID3DXConstantTable methods ***/
690 ID3DXConstantTableImpl_GetDesc
,
691 ID3DXConstantTableImpl_GetConstantDesc
,
692 ID3DXConstantTableImpl_GetSamplerIndex
,
693 ID3DXConstantTableImpl_GetConstant
,
694 ID3DXConstantTableImpl_GetConstantByName
,
695 ID3DXConstantTableImpl_GetConstantElement
,
696 ID3DXConstantTableImpl_SetDefaults
,
697 ID3DXConstantTableImpl_SetValue
,
698 ID3DXConstantTableImpl_SetBool
,
699 ID3DXConstantTableImpl_SetBoolArray
,
700 ID3DXConstantTableImpl_SetInt
,
701 ID3DXConstantTableImpl_SetIntArray
,
702 ID3DXConstantTableImpl_SetFloat
,
703 ID3DXConstantTableImpl_SetFloatArray
,
704 ID3DXConstantTableImpl_SetVector
,
705 ID3DXConstantTableImpl_SetVectorArray
,
706 ID3DXConstantTableImpl_SetMatrix
,
707 ID3DXConstantTableImpl_SetMatrixArray
,
708 ID3DXConstantTableImpl_SetMatrixPointerArray
,
709 ID3DXConstantTableImpl_SetMatrixTranspose
,
710 ID3DXConstantTableImpl_SetMatrixTransposeArray
,
711 ID3DXConstantTableImpl_SetMatrixTransposePointerArray
714 HRESULT WINAPI
D3DXGetShaderConstantTableEx(CONST DWORD
* byte_code
,
716 LPD3DXCONSTANTTABLE
* constant_table
)
718 ID3DXConstantTableImpl
* object
= NULL
;
722 const D3DXSHADER_CONSTANTTABLE
* ctab_header
;
724 FIXME("(%p, %x, %p): semi-stub\n", byte_code
, flags
, constant_table
);
726 if (!byte_code
|| !constant_table
)
727 return D3DERR_INVALIDCALL
;
729 hr
= D3DXFindShaderComment(byte_code
, MAKEFOURCC('C','T','A','B'), &data
, &size
);
731 return D3DXERR_INVALIDDATA
;
733 object
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(ID3DXConstantTableImpl
));
736 ERR("Out of memory\n");
737 return E_OUTOFMEMORY
;
740 object
->lpVtbl
= &ID3DXConstantTable_Vtbl
;
743 if (size
< sizeof(D3DXSHADER_CONSTANTTABLE
))
746 object
->ctab
= HeapAlloc(GetProcessHeap(), 0, size
);
749 HeapFree(GetProcessHeap(), 0, object
);
750 ERR("Out of memory\n");
751 return E_OUTOFMEMORY
;
754 memcpy(object
->ctab
, data
, object
->size
);
756 ctab_header
= (const D3DXSHADER_CONSTANTTABLE
*)data
;
757 if (ctab_header
->Size
!= sizeof(D3DXSHADER_CONSTANTTABLE
))
759 object
->desc
.Creator
= ctab_header
->Creator
? (LPCSTR
)object
->ctab
+ ctab_header
->Creator
: NULL
;
760 object
->desc
.Version
= ctab_header
->Version
;
761 object
->desc
.Constants
= ctab_header
->Constants
;
763 *constant_table
= (LPD3DXCONSTANTTABLE
)object
;
769 HeapFree(GetProcessHeap(), 0, object
->ctab
);
770 HeapFree(GetProcessHeap(), 0, object
);
772 return D3DXERR_INVALIDDATA
;
775 HRESULT WINAPI
D3DXGetShaderConstantTable(CONST DWORD
* byte_code
,
776 LPD3DXCONSTANTTABLE
* constant_table
)
778 TRACE("(%p, %p): Forwarded to D3DXGetShaderConstantTableEx\n", byte_code
, constant_table
);
780 return D3DXGetShaderConstantTableEx(byte_code
, 0, constant_table
);