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
21 #ifndef __D3DX9SHADER_H__
22 #define __D3DX9SHADER_H__
24 #define D3DXSHADER_DEBUG 0x1
25 #define D3DXSHADER_SKIPVALIDATION 0x2
26 #define D3DXSHADER_SKIPOPTIMIZATION 0x4
27 #define D3DXSHADER_PACKMATRIX_ROWMAJOR 0x8
28 #define D3DXSHADER_PACKMATRIX_COLUMNMAJOR 0x10
29 #define D3DXSHADER_PARTIALPRECISION 0x20
30 #define D3DXSHADER_FORCE_VS_SOFTWARE_NOOPT 0x40
31 #define D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT 0x80
32 #define D3DXSHADER_NO_PRESHADER 0x100
33 #define D3DXSHADER_AVOID_FLOW_CONTROL 0x200
34 #define D3DXSHADER_PREFER_FLOW_CONTROL 0x400
35 #define D3DXSHADER_ENABLE_BACKWARDS_COMPATIBILITY 0x1000
36 #define D3DXSHADER_IEEE_STRICTNESS 0x2000
38 #define D3DXSHADER_OPTIMIZATION_LEVEL0 0x4000
39 #define D3DXSHADER_OPTIMIZATION_LEVEL1 0x0
40 #define D3DXSHADER_OPTIMIZATION_LEVEL2 0xC000
41 #define D3DXSHADER_OPTIMIZATION_LEVEL3 0x8000
43 #define D3DXSHADER_USE_LEGACY_D3DX9_31_DLL 0x10000
45 typedef LPCSTR D3DXHANDLE
;
47 typedef enum _D3DXREGISTER_SET
53 D3DXRS_FORCE_DWORD
= 0x7fffffff
54 } D3DXREGISTER_SET
, *LPD3DXREGISTER_SET
;
56 typedef enum D3DXPARAMETER_CLASS
61 D3DXPC_MATRIX_COLUMNS
,
64 D3DXPC_FORCE_DWORD
= 0x7fffffff,
65 } D3DXPARAMETER_CLASS
, *LPD3DXPARAMETER_CLASS
;
67 typedef enum D3DXPARAMETER_TYPE
87 D3DXPT_VERTEXFRAGMENT
,
89 D3DXPT_FORCE_DWORD
= 0x7fffffff,
90 } D3DXPARAMETER_TYPE
, *LPD3DXPARAMETER_TYPE
;
92 typedef struct _D3DXCONSTANTTABLE_DESC
97 } D3DXCONSTANTTABLE_DESC
, *LPD3DXCONSTANTTABLE_DESC
;
99 typedef struct _D3DXCONSTANT_DESC
102 D3DXREGISTER_SET RegisterSet
;
105 D3DXPARAMETER_CLASS Class
;
106 D3DXPARAMETER_TYPE Type
;
112 LPCVOID DefaultValue
;
113 } D3DXCONSTANT_DESC
, *LPD3DXCONSTANT_DESC
;
115 DEFINE_GUID(IID_ID3DXConstantTable
, 0x9dca3190, 0x38b9, 0x4fc3, 0x92, 0xe3, 0x39, 0xc6, 0xdd, 0xfb, 0x35, 0x8b);
118 #define INTERFACE ID3DXConstantTable
120 DECLARE_INTERFACE_(ID3DXConstantTable
, ID3DXBuffer
)
122 /*** IUnknown methods ***/
123 STDMETHOD(QueryInterface
)(THIS_ REFIID iid
, LPVOID
*ppv
) PURE
;
124 STDMETHOD_(ULONG
, AddRef
)(THIS
) PURE
;
125 STDMETHOD_(ULONG
, Release
)(THIS
) PURE
;
126 /*** ID3DXBuffer methods ***/
127 STDMETHOD_(LPVOID
, GetBufferPointer
)(THIS
) PURE
;
128 STDMETHOD_(DWORD
, GetBufferSize
)(THIS
) PURE
;
129 /*** ID3DXConstantTable methods ***/
130 STDMETHOD(GetDesc
)(THIS_ D3DXCONSTANTTABLE_DESC
*pDesc
) PURE
;
131 STDMETHOD(GetConstantDesc
)(THIS_ D3DXHANDLE hConstant
, D3DXCONSTANT_DESC
*pConstantDesc
, UINT
*pCount
) PURE
;
132 STDMETHOD_(UINT
, GetSamplerIndex
)(THIS_ D3DXHANDLE hConstant
) PURE
;
133 STDMETHOD_(D3DXHANDLE
, GetConstant
)(THIS_ D3DXHANDLE hConstant
, UINT Index
) PURE
;
134 STDMETHOD_(D3DXHANDLE
, GetConstantByName
)(THIS_ D3DXHANDLE hConstant
, LPCSTR pName
) PURE
;
135 STDMETHOD_(D3DXHANDLE
, GetConstantElement
)(THIS_ D3DXHANDLE hConstant
, UINT Index
) PURE
;
136 STDMETHOD(SetDefaults
)(THIS_
struct IDirect3DDevice9
*device
) PURE
;
137 STDMETHOD(SetValue
)(THIS_
struct IDirect3DDevice9
*device
, D3DXHANDLE constant
,
138 const void *data
, UINT data_size
) PURE
;
139 STDMETHOD(SetBool
)(THIS_
struct IDirect3DDevice9
*device
, D3DXHANDLE constant
, BOOL value
) PURE
;
140 STDMETHOD(SetBoolArray
)(THIS_
struct IDirect3DDevice9
*device
, D3DXHANDLE constant
,
141 const BOOL
*values
, UINT value_count
) PURE
;
142 STDMETHOD(SetInt
)(THIS_
struct IDirect3DDevice9
*device
, D3DXHANDLE constant
, INT value
) PURE
;
143 STDMETHOD(SetIntArray
)(THIS_
struct IDirect3DDevice9
*device
, D3DXHANDLE constant
,
144 const INT
*values
, UINT value_count
) PURE
;
145 STDMETHOD(SetFloat
)(THIS_
struct IDirect3DDevice9
*device
, D3DXHANDLE constant
, float value
) PURE
;
146 STDMETHOD(SetFloatArray
)(THIS_
struct IDirect3DDevice9
*device
, D3DXHANDLE constant
,
147 const float *values
, UINT value_count
) PURE
;
148 STDMETHOD(SetVector
)(THIS_
struct IDirect3DDevice9
*device
, D3DXHANDLE constant
, const D3DXVECTOR4
*value
) PURE
;
149 STDMETHOD(SetVectorArray
)(THIS_
struct IDirect3DDevice9
*device
, D3DXHANDLE constant
,
150 const D3DXVECTOR4
*values
, UINT value_count
) PURE
;
151 STDMETHOD(SetMatrix
)(THIS_
struct IDirect3DDevice9
*device
, D3DXHANDLE constant
, const D3DXMATRIX
*value
) PURE
;
152 STDMETHOD(SetMatrixArray
)(THIS_
struct IDirect3DDevice9
*device
, D3DXHANDLE constant
,
153 const D3DXMATRIX
*values
, UINT value_count
) PURE
;
154 STDMETHOD(SetMatrixPointerArray
)(THIS_
struct IDirect3DDevice9
*device
, D3DXHANDLE constant
,
155 const D3DXMATRIX
**values
, UINT value_count
) PURE
;
156 STDMETHOD(SetMatrixTranspose
)(THIS_
struct IDirect3DDevice9
*device
, D3DXHANDLE constant
,
157 const D3DXMATRIX
*value
) PURE
;
158 STDMETHOD(SetMatrixTransposeArray
)(THIS_
struct IDirect3DDevice9
*device
, D3DXHANDLE constant
,
159 const D3DXMATRIX
*values
, UINT value_count
) PURE
;
160 STDMETHOD(SetMatrixTransposePointerArray
)(THIS_
struct IDirect3DDevice9
*device
, D3DXHANDLE constant
,
161 const D3DXMATRIX
**values
, UINT value_count
) PURE
;
165 #if !defined(__cplusplus) || defined(CINTERFACE)
166 /*** IUnknown methods ***/
167 #define ID3DXConstantTable_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
168 #define ID3DXConstantTable_AddRef(p) (p)->lpVtbl->AddRef(p)
169 #define ID3DXConstantTable_Release(p) (p)->lpVtbl->Release(p)
170 /*** ID3DXBuffer methods ***/
171 #define ID3DXConstantTable_GetBufferPointer(p) (p)->lpVtbl->GetBufferPointer(p)
172 #define ID3DXConstantTable_GetBufferSize(p) (p)->lpVtbl->GetBufferSize(p)
173 /*** ID3DXConstantTable methods ***/
174 #define ID3DXConstantTable_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a)
175 #define ID3DXConstantTable_GetConstantDesc(p,a,b,c) (p)->lpVtbl->GetConstantDesc(p,a,b,c)
176 #define ID3DXConstantTable_GetSamplerIndex(p,a) (p)->lpVtbl->GetSamplerIndex(p,a)
177 #define ID3DXConstantTable_GetConstant(p,a,b) (p)->lpVtbl->GetConstant(p,a,b)
178 #define ID3DXConstantTable_GetConstantByName(p,a,b) (p)->lpVtbl->GetConstantByName(p,a,b)
179 #define ID3DXConstantTable_GetConstantElement(p,a,b) (p)->lpVtbl->GetConstantElement(p,a,b)
180 #define ID3DXConstantTable_SetDefaults(p,a) (p)->lpVtbl->SetDefaults(p,a)
181 #define ID3DXConstantTable_SetValue(p,a,b,c,d) (p)->lpVtbl->SetValue(p,a,b,c,d)
182 #define ID3DXConstantTable_SetBool(p,a,b,c) (p)->lpVtbl->SetBool(p,a,b,c)
183 #define ID3DXConstantTable_SetBoolArray(p,a,b,c,d) (p)->lpVtbl->SetBoolArray(p,a,b,c,d)
184 #define ID3DXConstantTable_SetInt(p,a,b,c) (p)->lpVtbl->SetInt(p,a,b,c)
185 #define ID3DXConstantTable_SetIntArray(p,a,b,c,d) (p)->lpVtbl->SetIntArray(p,a,b,c,d)
186 #define ID3DXConstantTable_SetFloat(p,a,b,c) (p)->lpVtbl->SetFloat(p,a,b,c)
187 #define ID3DXConstantTable_SetFloatArray(p,a,b,c,d) (p)->lpVtbl->SetFloatArray(p,a,b,c,d)
188 #define ID3DXConstantTable_SetVector(p,a,b,c) (p)->lpVtbl->SetVector(p,a,b,c)
189 #define ID3DXConstantTable_SetVectorArray(p,a,b,c,d) (p)->lpVtbl->SetVectorArray(p,a,b,c,d)
190 #define ID3DXConstantTable_SetMatrix(p,a,b,c) (p)->lpVtbl->SetMatrix(p,a,b,c)
191 #define ID3DXConstantTable_SetMatrixArray(p,a,b,c,d) (p)->lpVtbl->SetMatrixArray(p,a,b,c,d)
192 #define ID3DXConstantTable_SetMatrixPointerArray(p,a,b,c,d) (p)->lpVtbl->SetMatrixPointerArray(p,a,b,c,d)
193 #define ID3DXConstantTable_SetMatrixTranspose(p,a,b,c) (p)->lpVtbl->SetMatrixTranspose(p,a,b,c)
194 #define ID3DXConstantTable_SetMatrixTransposeArray(p,a,b,c,d) (p)->lpVtbl->SetMatrixTransposeArray(p,a,b,c,d)
195 #define ID3DXConstantTable_SetMatrixTransposePointerArray(p,a,b,c,d) (p)->lpVtbl->SetMatrixTransposePointerArray(p,a,b,c,d)
197 /*** IUnknown methods ***/
198 #define ID3DXConstantTable_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
199 #define ID3DXConstantTable_AddRef(p) (p)->AddRef()
200 #define ID3DXConstantTable_Release(p) (p)->Release()
201 /*** ID3DXBuffer methods ***/
202 #define ID3DXConstantTable_GetBufferPointer(p) (p)->GetBufferPointer()
203 #define ID3DXConstantTable_GetBufferSize(p) (p)->GetBufferSize()
204 /*** ID3DXConstantTable methods ***/
205 #define ID3DXConstantTable_GetDesc(p,a) (p)->GetDesc(a)
206 #define ID3DXConstantTable_GetConstantDesc(p,a,b,c) (p)->GetConstantDesc(a,b,c)
207 #define ID3DXConstantTable_GetSamplerIndex(p,a) (p)->GetConstantDesc(a)
208 #define ID3DXConstantTable_GetConstant(p,a,b) (p)->GetConstant(a,b)
209 #define ID3DXConstantTable_GetConstantByName(p,a,b) (p)->GetConstantByName(a,b)
210 #define ID3DXConstantTable_GetConstantElement(p,a,b) (p)->GetConstantElement(a,b)
211 #define ID3DXConstantTable_SetDefaults(p,a) (p)->SetDefaults(a)
212 #define ID3DXConstantTable_SetValue(p,a,b,c,d) (p)->SetValue(a,b,c,d)
213 #define ID3DXConstantTable_SetBool(p,a,b,c) (p)->SetBool(a,b,c)
214 #define ID3DXConstantTable_SetBoolArray(p,a,b,c,d) (p)->SetBoolArray(a,b,c,d)
215 #define ID3DXConstantTable_SetInt(p,a,b,c) (p)->SetInt(a,b,c)
216 #define ID3DXConstantTable_SetIntArray(p,a,b,c,d) (p)->SetIntArray(a,b,c,d)
217 #define ID3DXConstantTable_SetFloat(p,a,b,c) (p)->SetFloat(a,b,c)
218 #define ID3DXConstantTable_SetFloatArray(p,a,b,c,d) (p)->SetFloatArray(a,b,c,d)
219 #define ID3DXConstantTable_SetVector(p,a,b,c) (p)->SetVector(a,b,c)
220 #define ID3DXConstantTable_SetVectorArray(p,a,b,c,d) (p)->SetVectorArray(a,b,c,d)
221 #define ID3DXConstantTable_SetMatrix(p,a,b,c) (p)->SetMatrix(a,b,c)
222 #define ID3DXConstantTable_SetMatrixArray(p,a,b,c,d) (p)->SetMatrixArray(a,b,c,d)
223 #define ID3DXConstantTable_SetMatrixPointerArray(p,a,b,c,d) (p)->SetMatrixPointerArray(a,b,c,d)
224 #define ID3DXConstantTable_SetMatrixTranspose(p,a,b,c) (p)->SetMatrixTranspose(a,b,c)
225 #define ID3DXConstantTable_SetMatrixTransposeArray(p,a,b,c,d) (p)->SetMatrixTransposeArray(a,b,c,d)
226 #define ID3DXConstantTable_SetMatrixTransposePointerArray(p,a,b,c,d) (p)->SetMatrixTransposePointerArray(a,b,c,d)
229 typedef struct ID3DXConstantTable
*LPD3DXCONSTANTTABLE
;
231 typedef struct _D3DXMACRO
{
234 } D3DXMACRO
, *LPD3DXMACRO
;
236 typedef struct _D3DXSEMANTIC
{
239 } D3DXSEMANTIC
, *LPD3DXSEMANTIC
;
241 typedef enum _D3DXINCLUDE_TYPE
245 D3DXINC_FORCE_DWORD
= 0x7fffffff,
246 } D3DXINCLUDE_TYPE
, *LPD3DXINCLUDE_TYPE
;
248 #define INTERFACE ID3DXInclude
250 DECLARE_INTERFACE(ID3DXInclude
)
252 STDMETHOD(Open
)(THIS_ D3DXINCLUDE_TYPE include_type
, LPCSTR filename
, LPCVOID parent_data
, LPCVOID
*data
, UINT
*bytes
) PURE
;
253 STDMETHOD(Close
)(THIS_ LPCVOID data
) PURE
;
257 #define ID3DXInclude_Open(p,a,b,c,d,e) (p)->lpVtbl->Open(p,a,b,c,d,e)
258 #define ID3DXInclude_Close(p,a) (p)->lpVtbl->Close(p,a)
260 typedef struct ID3DXInclude
*LPD3DXINCLUDE
;
266 const char * WINAPI
D3DXGetPixelShaderProfile(struct IDirect3DDevice9
*device
);
267 UINT WINAPI
D3DXGetShaderSize(const DWORD
*byte_code
);
268 DWORD WINAPI
D3DXGetShaderVersion(const DWORD
*byte_code
);
269 const char * WINAPI
D3DXGetVertexShaderProfile(struct IDirect3DDevice9
*device
);
270 HRESULT WINAPI
D3DXFindShaderComment(CONST DWORD
* byte_code
, DWORD fourcc
, LPCVOID
* data
, UINT
* size
);
271 HRESULT WINAPI
D3DXGetShaderSamplers(CONST DWORD
*byte_code
, LPCSTR
*samplers
, UINT
*count
);
273 HRESULT WINAPI
D3DXAssembleShaderFromFileA(LPCSTR filename
,
274 CONST D3DXMACRO
* defines
,
275 LPD3DXINCLUDE include
,
277 LPD3DXBUFFER
* shader
,
278 LPD3DXBUFFER
* error_messages
);
279 HRESULT WINAPI
D3DXAssembleShaderFromFileW(LPCWSTR filename
,
280 CONST D3DXMACRO
* defines
,
281 LPD3DXINCLUDE include
,
283 LPD3DXBUFFER
* shader
,
284 LPD3DXBUFFER
* error_messages
);
285 #define D3DXAssembleShaderFromFile WINELIB_NAME_AW(D3DXAssembleShaderFromFile)
287 HRESULT WINAPI
D3DXAssembleShaderFromResourceA(HMODULE module
,
289 CONST D3DXMACRO
* defines
,
290 LPD3DXINCLUDE include
,
292 LPD3DXBUFFER
* shader
,
293 LPD3DXBUFFER
* error_messages
);
294 HRESULT WINAPI
D3DXAssembleShaderFromResourceW(HMODULE module
,
296 CONST D3DXMACRO
* defines
,
297 LPD3DXINCLUDE include
,
299 LPD3DXBUFFER
* shader
,
300 LPD3DXBUFFER
* error_messages
);
301 #define D3DXAssembleShaderFromResource WINELIB_NAME_AW(D3DXAssembleShaderFromResource)
303 HRESULT WINAPI
D3DXAssembleShader(LPCSTR data
,
305 CONST D3DXMACRO
* defines
,
306 LPD3DXINCLUDE include
,
308 LPD3DXBUFFER
* shader
,
309 LPD3DXBUFFER
* error_messages
);
311 HRESULT WINAPI
D3DXCompileShader(LPCSTR src_data
,
313 const D3DXMACRO
* defines
,
314 LPD3DXINCLUDE include
,
315 LPCSTR function_name
,
318 LPD3DXBUFFER
* shader
,
319 LPD3DXBUFFER
* error_messages
,
320 LPD3DXCONSTANTTABLE
* constant_table
);
322 HRESULT WINAPI
D3DXCompileShaderFromFileA(LPCSTR filename
,
323 CONST D3DXMACRO
* defines
,
324 LPD3DXINCLUDE include
,
328 LPD3DXBUFFER
* shader
,
329 LPD3DXBUFFER
* error_messages
,
330 LPD3DXCONSTANTTABLE
* constant_table
);
331 HRESULT WINAPI
D3DXCompileShaderFromFileW(LPCWSTR filename
,
332 CONST D3DXMACRO
* defines
,
333 LPD3DXINCLUDE include
,
337 LPD3DXBUFFER
* shader
,
338 LPD3DXBUFFER
* error_messages
,
339 LPD3DXCONSTANTTABLE
* constant_table
);
340 #define D3DXCompileShaderFromFile WINELIB_NAME_AW(D3DXCompileShaderFromFile)
342 HRESULT WINAPI
D3DXCompileShaderFromResourceA(HMODULE module
,
344 CONST D3DXMACRO
* defines
,
345 LPD3DXINCLUDE include
,
349 LPD3DXBUFFER
* shader
,
350 LPD3DXBUFFER
* error_messages
,
351 LPD3DXCONSTANTTABLE
* constant_table
);
352 HRESULT WINAPI
D3DXCompileShaderFromResourceW(HMODULE module
,
354 CONST D3DXMACRO
* defines
,
355 LPD3DXINCLUDE include
,
359 LPD3DXBUFFER
* shader
,
360 LPD3DXBUFFER
* error_messages
,
361 LPD3DXCONSTANTTABLE
* constant_table
);
362 #define D3DXCompileShaderFromResource WINELIB_NAME_AW(D3DXCompileShaderFromResource)
364 HRESULT WINAPI
D3DXPreprocessShader(LPCSTR data
,
366 CONST D3DXMACRO
* defines
,
367 LPD3DXINCLUDE include
,
368 LPD3DXBUFFER
* shader
,
369 LPD3DXBUFFER
* error_messages
);
371 HRESULT WINAPI
D3DXPreprocessShaderFromFileA(LPCSTR filename
,
372 CONST D3DXMACRO
* defines
,
373 LPD3DXINCLUDE include
,
374 LPD3DXBUFFER
* shader
,
375 LPD3DXBUFFER
* error_messages
);
376 HRESULT WINAPI
D3DXPreprocessShaderFromFileW(LPCWSTR filename
,
377 CONST D3DXMACRO
* defines
,
378 LPD3DXINCLUDE include
,
379 LPD3DXBUFFER
* shader
,
380 LPD3DXBUFFER
* error_messages
);
381 #define D3DXPreprocessShaderFromFile WINELIB_NAME_AW(D3DXPreprocessShaderFromFile)
383 HRESULT WINAPI
D3DXPreprocessShaderFromResourceA(HMODULE module
,
385 CONST D3DXMACRO
* defines
,
386 LPD3DXINCLUDE include
,
387 LPD3DXBUFFER
* shader
,
388 LPD3DXBUFFER
* error_messages
);
389 HRESULT WINAPI
D3DXPreprocessShaderFromResourceW(HMODULE module
,
391 CONST D3DXMACRO
* defines
,
392 LPD3DXINCLUDE include
,
393 LPD3DXBUFFER
* shader
,
394 LPD3DXBUFFER
* error_messages
);
395 #define D3DXPreprocessShaderFromResource WINELIB_NAME_AW(D3DXPreprocessShaderFromResource)
397 HRESULT WINAPI
D3DXGetShaderConstantTableEx(CONST DWORD
* byte_code
,
399 LPD3DXCONSTANTTABLE
* constant_table
);
401 HRESULT WINAPI
D3DXGetShaderConstantTable(CONST DWORD
* byte_code
,
402 LPD3DXCONSTANTTABLE
* constant_table
);
408 typedef struct _D3DXSHADER_CONSTANTTABLE
417 } D3DXSHADER_CONSTANTTABLE
, *LPD3DXSHADER_CONSTANTTABLE
;
419 typedef struct _D3DXSHADER_CONSTANTINFO
428 } D3DXSHADER_CONSTANTINFO
, *LPD3DXSHADER_CONSTANTINFO
;
430 typedef struct _D3DXSHADER_TYPEINFO
438 DWORD StructMemberInfo
;
439 } D3DXSHADER_TYPEINFO
, *LPD3DXSHADER_TYPEINFO
;
441 typedef struct _D3DXSHADER_STRUCTMEMBERINFO
445 } D3DXSHADER_STRUCTMEMBERINFO
, *LPD3DXSHADER_STRUCTMEMBERINFO
;
447 #endif /* __D3DX9SHADER_H__ */