Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1010 lines
37 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) Microsoft Corporation. All rights reserved.
  4. //
  5. // File: d3dx9shader.h
  6. // Content: D3DX Shader APIs
  7. //
  8. //////////////////////////////////////////////////////////////////////////////
  9. #include "d3dx9.h"
  10. #ifndef __D3DX9SHADER_H__
  11. #define __D3DX9SHADER_H__
  12. //---------------------------------------------------------------------------
  13. // D3DXTX_VERSION:
  14. // --------------
  15. // Version token used to create a procedural texture filler in effects
  16. // Used by D3DXFill[]TX functions
  17. //---------------------------------------------------------------------------
  18. #define D3DXTX_VERSION(_Major,_Minor) (('T' << 24) | ('X' << 16) | ((_Major) << 8) | (_Minor))
  19. //----------------------------------------------------------------------------
  20. // D3DXSHADER flags:
  21. // -----------------
  22. // D3DXSHADER_DEBUG
  23. // Insert debug file/line/type/symbol information.
  24. //
  25. // D3DXSHADER_SKIPVALIDATION
  26. // Do not validate the generated code against known capabilities and
  27. // constraints. This option is only recommended when compiling shaders
  28. // you KNOW will work. (ie. have compiled before without this option.)
  29. // Shaders are always validated by D3D before they are set to the device.
  30. //
  31. // D3DXSHADER_SKIPOPTIMIZATION
  32. // Instructs the compiler to skip optimization steps during code generation.
  33. // Unless you are trying to isolate a problem in your code using this option
  34. // is not recommended.
  35. //
  36. // D3DXSHADER_PACKMATRIX_ROWMAJOR
  37. // Unless explicitly specified, matrices will be packed in row-major order
  38. // on input and output from the shader.
  39. //
  40. // D3DXSHADER_PACKMATRIX_COLUMNMAJOR
  41. // Unless explicitly specified, matrices will be packed in column-major
  42. // order on input and output from the shader. This is generally more
  43. // efficient, since it allows vector-matrix multiplication to be performed
  44. // using a series of dot-products.
  45. //
  46. // D3DXSHADER_PARTIALPRECISION
  47. // Force all computations in resulting shader to occur at partial precision.
  48. // This may result in faster evaluation of shaders on some hardware.
  49. //
  50. // D3DXSHADER_FORCE_VS_SOFTWARE_NOOPT
  51. // Force compiler to compile against the next highest available software
  52. // target for vertex shaders. This flag also turns optimizations off,
  53. // and debugging on.
  54. //
  55. // D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT
  56. // Force compiler to compile against the next highest available software
  57. // target for pixel shaders. This flag also turns optimizations off,
  58. // and debugging on.
  59. //
  60. // D3DXSHADER_NO_PRESHADER
  61. // Disables Preshaders. Using this flag will cause the compiler to not
  62. // pull out static expression for evaluation on the host cpu
  63. //
  64. // D3DXSHADER_AVOID_FLOW_CONTROL
  65. // Hint compiler to avoid flow-control constructs where possible.
  66. //
  67. // D3DXSHADER_PREFER_FLOW_CONTROL
  68. // Hint compiler to prefer flow-control constructs where possible.
  69. //
  70. //----------------------------------------------------------------------------
  71. #define D3DXSHADER_DEBUG (1 << 0)
  72. #define D3DXSHADER_SKIPVALIDATION (1 << 1)
  73. #define D3DXSHADER_SKIPOPTIMIZATION (1 << 2)
  74. #define D3DXSHADER_PACKMATRIX_ROWMAJOR (1 << 3)
  75. #define D3DXSHADER_PACKMATRIX_COLUMNMAJOR (1 << 4)
  76. #define D3DXSHADER_PARTIALPRECISION (1 << 5)
  77. #define D3DXSHADER_FORCE_VS_SOFTWARE_NOOPT (1 << 6)
  78. #define D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT (1 << 7)
  79. #define D3DXSHADER_NO_PRESHADER (1 << 8)
  80. #define D3DXSHADER_AVOID_FLOW_CONTROL (1 << 9)
  81. #define D3DXSHADER_PREFER_FLOW_CONTROL (1 << 10)
  82. #define D3DXSHADER_ENABLE_BACKWARDS_COMPATIBILITY (1 << 12)
  83. #define D3DXSHADER_IEEE_STRICTNESS (1 << 13)
  84. #define D3DXSHADER_USE_LEGACY_D3DX9_31_DLL (1 << 16)
  85. // optimization level flags
  86. #define D3DXSHADER_OPTIMIZATION_LEVEL0 (1 << 14)
  87. #define D3DXSHADER_OPTIMIZATION_LEVEL1 0
  88. #define D3DXSHADER_OPTIMIZATION_LEVEL2 ((1 << 14) | (1 << 15))
  89. #define D3DXSHADER_OPTIMIZATION_LEVEL3 (1 << 15)
  90. //----------------------------------------------------------------------------
  91. // D3DXCONSTTABLE flags:
  92. // -------------------
  93. #define D3DXCONSTTABLE_LARGEADDRESSAWARE (1 << 17)
  94. //----------------------------------------------------------------------------
  95. // D3DXHANDLE:
  96. // -----------
  97. // Handle values used to efficiently reference shader and effect parameters.
  98. // Strings can be used as handles. However, handles are not always strings.
  99. //----------------------------------------------------------------------------
  100. #ifndef D3DXFX_LARGEADDRESS_HANDLE
  101. typedef LPCSTR D3DXHANDLE;
  102. #else
  103. typedef UINT_PTR D3DXHANDLE;
  104. #endif
  105. typedef D3DXHANDLE *LPD3DXHANDLE;
  106. //----------------------------------------------------------------------------
  107. // D3DXMACRO:
  108. // ----------
  109. // Preprocessor macro definition. The application pass in a NULL-terminated
  110. // array of this structure to various D3DX APIs. This enables the application
  111. // to #define tokens at runtime, before the file is parsed.
  112. //----------------------------------------------------------------------------
  113. typedef struct _D3DXMACRO
  114. {
  115. LPCSTR Name;
  116. LPCSTR Definition;
  117. } D3DXMACRO, *LPD3DXMACRO;
  118. //----------------------------------------------------------------------------
  119. // D3DXSEMANTIC:
  120. //----------------------------------------------------------------------------
  121. typedef struct _D3DXSEMANTIC
  122. {
  123. UINT Usage;
  124. UINT UsageIndex;
  125. } D3DXSEMANTIC, *LPD3DXSEMANTIC;
  126. //----------------------------------------------------------------------------
  127. // D3DXREGISTER_SET:
  128. //----------------------------------------------------------------------------
  129. typedef enum _D3DXREGISTER_SET
  130. {
  131. D3DXRS_BOOL,
  132. D3DXRS_INT4,
  133. D3DXRS_FLOAT4,
  134. D3DXRS_SAMPLER,
  135. // force 32-bit size enum
  136. D3DXRS_FORCE_DWORD = 0x7fffffff
  137. } D3DXREGISTER_SET, *LPD3DXREGISTER_SET;
  138. //----------------------------------------------------------------------------
  139. // D3DXPARAMETER_CLASS:
  140. //----------------------------------------------------------------------------
  141. typedef enum _D3DXPARAMETER_CLASS
  142. {
  143. D3DXPC_SCALAR,
  144. D3DXPC_VECTOR,
  145. D3DXPC_MATRIX_ROWS,
  146. D3DXPC_MATRIX_COLUMNS,
  147. D3DXPC_OBJECT,
  148. D3DXPC_STRUCT,
  149. // force 32-bit size enum
  150. D3DXPC_FORCE_DWORD = 0x7fffffff
  151. } D3DXPARAMETER_CLASS, *LPD3DXPARAMETER_CLASS;
  152. //----------------------------------------------------------------------------
  153. // D3DXPARAMETER_TYPE:
  154. //----------------------------------------------------------------------------
  155. typedef enum _D3DXPARAMETER_TYPE
  156. {
  157. D3DXPT_VOID,
  158. D3DXPT_BOOL,
  159. D3DXPT_INT,
  160. D3DXPT_FLOAT,
  161. D3DXPT_STRING,
  162. D3DXPT_TEXTURE,
  163. D3DXPT_TEXTURE1D,
  164. D3DXPT_TEXTURE2D,
  165. D3DXPT_TEXTURE3D,
  166. D3DXPT_TEXTURECUBE,
  167. D3DXPT_SAMPLER,
  168. D3DXPT_SAMPLER1D,
  169. D3DXPT_SAMPLER2D,
  170. D3DXPT_SAMPLER3D,
  171. D3DXPT_SAMPLERCUBE,
  172. D3DXPT_PIXELSHADER,
  173. D3DXPT_VERTEXSHADER,
  174. D3DXPT_PIXELFRAGMENT,
  175. D3DXPT_VERTEXFRAGMENT,
  176. D3DXPT_UNSUPPORTED,
  177. // force 32-bit size enum
  178. D3DXPT_FORCE_DWORD = 0x7fffffff
  179. } D3DXPARAMETER_TYPE, *LPD3DXPARAMETER_TYPE;
  180. //----------------------------------------------------------------------------
  181. // D3DXCONSTANTTABLE_DESC:
  182. //----------------------------------------------------------------------------
  183. typedef struct _D3DXCONSTANTTABLE_DESC
  184. {
  185. LPCSTR Creator; // Creator string
  186. DWORD Version; // Shader version
  187. UINT Constants; // Number of constants
  188. } D3DXCONSTANTTABLE_DESC, *LPD3DXCONSTANTTABLE_DESC;
  189. //----------------------------------------------------------------------------
  190. // D3DXCONSTANT_DESC:
  191. //----------------------------------------------------------------------------
  192. typedef struct _D3DXCONSTANT_DESC
  193. {
  194. LPCSTR Name; // Constant name
  195. D3DXREGISTER_SET RegisterSet; // Register set
  196. UINT RegisterIndex; // Register index
  197. UINT RegisterCount; // Number of registers occupied
  198. D3DXPARAMETER_CLASS Class; // Class
  199. D3DXPARAMETER_TYPE Type; // Component type
  200. UINT Rows; // Number of rows
  201. UINT Columns; // Number of columns
  202. UINT Elements; // Number of array elements
  203. UINT StructMembers; // Number of structure member sub-parameters
  204. UINT Bytes; // Data size, in bytes
  205. LPCVOID DefaultValue; // Pointer to default value
  206. } D3DXCONSTANT_DESC, *LPD3DXCONSTANT_DESC;
  207. //----------------------------------------------------------------------------
  208. // ID3DXConstantTable:
  209. //----------------------------------------------------------------------------
  210. typedef interface ID3DXConstantTable ID3DXConstantTable;
  211. typedef interface ID3DXConstantTable *LPD3DXCONSTANTTABLE;
  212. // {AB3C758F-093E-4356-B762-4DB18F1B3A01}
  213. DEFINE_GUID(IID_ID3DXConstantTable,
  214. 0xab3c758f, 0x93e, 0x4356, 0xb7, 0x62, 0x4d, 0xb1, 0x8f, 0x1b, 0x3a, 0x1);
  215. #undef INTERFACE
  216. #define INTERFACE ID3DXConstantTable
  217. DECLARE_INTERFACE_(ID3DXConstantTable, IUnknown)
  218. {
  219. // IUnknown
  220. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  221. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  222. STDMETHOD_(ULONG, Release)(THIS) PURE;
  223. // Buffer
  224. STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE;
  225. STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE;
  226. // Descs
  227. STDMETHOD(GetDesc)(THIS_ D3DXCONSTANTTABLE_DESC *pDesc) PURE;
  228. STDMETHOD(GetConstantDesc)(THIS_ D3DXHANDLE hConstant, D3DXCONSTANT_DESC *pConstantDesc, UINT *pCount) PURE;
  229. STDMETHOD_(UINT, GetSamplerIndex)(THIS_ D3DXHANDLE hConstant) PURE;
  230. // Handle operations
  231. STDMETHOD_(D3DXHANDLE, GetConstant)(THIS_ D3DXHANDLE hConstant, UINT Index) PURE;
  232. STDMETHOD_(D3DXHANDLE, GetConstantByName)(THIS_ D3DXHANDLE hConstant, LPCSTR pName) PURE;
  233. STDMETHOD_(D3DXHANDLE, GetConstantElement)(THIS_ D3DXHANDLE hConstant, UINT Index) PURE;
  234. // Set Constants
  235. STDMETHOD(SetDefaults)(THIS_ LPDIRECT3DDEVICE9 pDevice) PURE;
  236. STDMETHOD(SetValue)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, LPCVOID pData, UINT Bytes) PURE;
  237. STDMETHOD(SetBool)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, BOOL b) PURE;
  238. STDMETHOD(SetBoolArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST BOOL* pb, UINT Count) PURE;
  239. STDMETHOD(SetInt)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, INT n) PURE;
  240. STDMETHOD(SetIntArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST INT* pn, UINT Count) PURE;
  241. STDMETHOD(SetFloat)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, FLOAT f) PURE;
  242. STDMETHOD(SetFloatArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST FLOAT* pf, UINT Count) PURE;
  243. STDMETHOD(SetVector)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXVECTOR4* pVector) PURE;
  244. STDMETHOD(SetVectorArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXVECTOR4* pVector, UINT Count) PURE;
  245. STDMETHOD(SetMatrix)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix) PURE;
  246. STDMETHOD(SetMatrixArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix, UINT Count) PURE;
  247. STDMETHOD(SetMatrixPointerArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE;
  248. STDMETHOD(SetMatrixTranspose)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix) PURE;
  249. STDMETHOD(SetMatrixTransposeArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix, UINT Count) PURE;
  250. STDMETHOD(SetMatrixTransposePointerArray)(THIS_ LPDIRECT3DDEVICE9 pDevice, D3DXHANDLE hConstant, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE;
  251. };
  252. //----------------------------------------------------------------------------
  253. // ID3DXTextureShader:
  254. //----------------------------------------------------------------------------
  255. typedef interface ID3DXTextureShader ID3DXTextureShader;
  256. typedef interface ID3DXTextureShader *LPD3DXTEXTURESHADER;
  257. // {3E3D67F8-AA7A-405d-A857-BA01D4758426}
  258. DEFINE_GUID(IID_ID3DXTextureShader,
  259. 0x3e3d67f8, 0xaa7a, 0x405d, 0xa8, 0x57, 0xba, 0x1, 0xd4, 0x75, 0x84, 0x26);
  260. #undef INTERFACE
  261. #define INTERFACE ID3DXTextureShader
  262. DECLARE_INTERFACE_(ID3DXTextureShader, IUnknown)
  263. {
  264. // IUnknown
  265. STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
  266. STDMETHOD_(ULONG, AddRef)(THIS) PURE;
  267. STDMETHOD_(ULONG, Release)(THIS) PURE;
  268. // Gets
  269. STDMETHOD(GetFunction)(THIS_ LPD3DXBUFFER *ppFunction) PURE;
  270. STDMETHOD(GetConstantBuffer)(THIS_ LPD3DXBUFFER *ppConstantBuffer) PURE;
  271. // Descs
  272. STDMETHOD(GetDesc)(THIS_ D3DXCONSTANTTABLE_DESC *pDesc) PURE;
  273. STDMETHOD(GetConstantDesc)(THIS_ D3DXHANDLE hConstant, D3DXCONSTANT_DESC *pConstantDesc, UINT *pCount) PURE;
  274. // Handle operations
  275. STDMETHOD_(D3DXHANDLE, GetConstant)(THIS_ D3DXHANDLE hConstant, UINT Index) PURE;
  276. STDMETHOD_(D3DXHANDLE, GetConstantByName)(THIS_ D3DXHANDLE hConstant, LPCSTR pName) PURE;
  277. STDMETHOD_(D3DXHANDLE, GetConstantElement)(THIS_ D3DXHANDLE hConstant, UINT Index) PURE;
  278. // Set Constants
  279. STDMETHOD(SetDefaults)(THIS) PURE;
  280. STDMETHOD(SetValue)(THIS_ D3DXHANDLE hConstant, LPCVOID pData, UINT Bytes) PURE;
  281. STDMETHOD(SetBool)(THIS_ D3DXHANDLE hConstant, BOOL b) PURE;
  282. STDMETHOD(SetBoolArray)(THIS_ D3DXHANDLE hConstant, CONST BOOL* pb, UINT Count) PURE;
  283. STDMETHOD(SetInt)(THIS_ D3DXHANDLE hConstant, INT n) PURE;
  284. STDMETHOD(SetIntArray)(THIS_ D3DXHANDLE hConstant, CONST INT* pn, UINT Count) PURE;
  285. STDMETHOD(SetFloat)(THIS_ D3DXHANDLE hConstant, FLOAT f) PURE;
  286. STDMETHOD(SetFloatArray)(THIS_ D3DXHANDLE hConstant, CONST FLOAT* pf, UINT Count) PURE;
  287. STDMETHOD(SetVector)(THIS_ D3DXHANDLE hConstant, CONST D3DXVECTOR4* pVector) PURE;
  288. STDMETHOD(SetVectorArray)(THIS_ D3DXHANDLE hConstant, CONST D3DXVECTOR4* pVector, UINT Count) PURE;
  289. STDMETHOD(SetMatrix)(THIS_ D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix) PURE;
  290. STDMETHOD(SetMatrixArray)(THIS_ D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix, UINT Count) PURE;
  291. STDMETHOD(SetMatrixPointerArray)(THIS_ D3DXHANDLE hConstant, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE;
  292. STDMETHOD(SetMatrixTranspose)(THIS_ D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix) PURE;
  293. STDMETHOD(SetMatrixTransposeArray)(THIS_ D3DXHANDLE hConstant, CONST D3DXMATRIX* pMatrix, UINT Count) PURE;
  294. STDMETHOD(SetMatrixTransposePointerArray)(THIS_ D3DXHANDLE hConstant, CONST D3DXMATRIX** ppMatrix, UINT Count) PURE;
  295. };
  296. //----------------------------------------------------------------------------
  297. // D3DXINCLUDE_TYPE:
  298. //----------------------------------------------------------------------------
  299. typedef enum _D3DXINCLUDE_TYPE
  300. {
  301. D3DXINC_LOCAL,
  302. D3DXINC_SYSTEM,
  303. // force 32-bit size enum
  304. D3DXINC_FORCE_DWORD = 0x7fffffff
  305. } D3DXINCLUDE_TYPE, *LPD3DXINCLUDE_TYPE;
  306. //----------------------------------------------------------------------------
  307. // ID3DXInclude:
  308. // -------------
  309. // This interface is intended to be implemented by the application, and can
  310. // be used by various D3DX APIs. This enables application-specific handling
  311. // of #include directives in source files.
  312. //
  313. // Open()
  314. // Opens an include file. If successful, it should fill in ppData and
  315. // pBytes. The data pointer returned must remain valid until Close is
  316. // subsequently called. The name of the file is encoded in UTF-8 format.
  317. // Close()
  318. // Closes an include file. If Open was successful, Close is guaranteed
  319. // to be called before the API using this interface returns.
  320. //----------------------------------------------------------------------------
  321. typedef interface ID3DXInclude ID3DXInclude;
  322. typedef interface ID3DXInclude *LPD3DXINCLUDE;
  323. #undef INTERFACE
  324. #define INTERFACE ID3DXInclude
  325. DECLARE_INTERFACE(ID3DXInclude)
  326. {
  327. STDMETHOD(Open)(THIS_ D3DXINCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, LPCVOID *ppData, UINT *pBytes) PURE;
  328. STDMETHOD(Close)(THIS_ LPCVOID pData) PURE;
  329. };
  330. //////////////////////////////////////////////////////////////////////////////
  331. // APIs //////////////////////////////////////////////////////////////////////
  332. //////////////////////////////////////////////////////////////////////////////
  333. #ifdef __cplusplus
  334. extern "C" {
  335. #endif //__cplusplus
  336. //----------------------------------------------------------------------------
  337. // D3DXAssembleShader:
  338. // -------------------
  339. // Assembles a shader.
  340. //
  341. // Parameters:
  342. // pSrcFile
  343. // Source file name
  344. // hSrcModule
  345. // Module handle. if NULL, current module will be used
  346. // pSrcResource
  347. // Resource name in module
  348. // pSrcData
  349. // Pointer to source code
  350. // SrcDataLen
  351. // Size of source code, in bytes
  352. // pDefines
  353. // Optional NULL-terminated array of preprocessor macro definitions.
  354. // pInclude
  355. // Optional interface pointer to use for handling #include directives.
  356. // If this parameter is NULL, #includes will be honored when assembling
  357. // from file, and will error when assembling from resource or memory.
  358. // Flags
  359. // See D3DXSHADER_xxx flags
  360. // ppShader
  361. // Returns a buffer containing the created shader. This buffer contains
  362. // the assembled shader code, as well as any embedded debug info.
  363. // ppErrorMsgs
  364. // Returns a buffer containing a listing of errors and warnings that were
  365. // encountered during assembly. If you are running in a debugger,
  366. // these are the same messages you will see in your debug output.
  367. //----------------------------------------------------------------------------
  368. HRESULT WINAPI
  369. D3DXAssembleShaderFromFileA(
  370. LPCSTR pSrcFile,
  371. CONST D3DXMACRO* pDefines,
  372. LPD3DXINCLUDE pInclude,
  373. DWORD Flags,
  374. LPD3DXBUFFER* ppShader,
  375. LPD3DXBUFFER* ppErrorMsgs);
  376. HRESULT WINAPI
  377. D3DXAssembleShaderFromFileW(
  378. LPCWSTR pSrcFile,
  379. CONST D3DXMACRO* pDefines,
  380. LPD3DXINCLUDE pInclude,
  381. DWORD Flags,
  382. LPD3DXBUFFER* ppShader,
  383. LPD3DXBUFFER* ppErrorMsgs);
  384. #ifdef UNICODE
  385. #define D3DXAssembleShaderFromFile D3DXAssembleShaderFromFileW
  386. #else
  387. #define D3DXAssembleShaderFromFile D3DXAssembleShaderFromFileA
  388. #endif
  389. HRESULT WINAPI
  390. D3DXAssembleShaderFromResourceA(
  391. HMODULE hSrcModule,
  392. LPCSTR pSrcResource,
  393. CONST D3DXMACRO* pDefines,
  394. LPD3DXINCLUDE pInclude,
  395. DWORD Flags,
  396. LPD3DXBUFFER* ppShader,
  397. LPD3DXBUFFER* ppErrorMsgs);
  398. HRESULT WINAPI
  399. D3DXAssembleShaderFromResourceW(
  400. HMODULE hSrcModule,
  401. LPCWSTR pSrcResource,
  402. CONST D3DXMACRO* pDefines,
  403. LPD3DXINCLUDE pInclude,
  404. DWORD Flags,
  405. LPD3DXBUFFER* ppShader,
  406. LPD3DXBUFFER* ppErrorMsgs);
  407. #ifdef UNICODE
  408. #define D3DXAssembleShaderFromResource D3DXAssembleShaderFromResourceW
  409. #else
  410. #define D3DXAssembleShaderFromResource D3DXAssembleShaderFromResourceA
  411. #endif
  412. HRESULT WINAPI
  413. D3DXAssembleShader(
  414. LPCSTR pSrcData,
  415. UINT SrcDataLen,
  416. CONST D3DXMACRO* pDefines,
  417. LPD3DXINCLUDE pInclude,
  418. DWORD Flags,
  419. LPD3DXBUFFER* ppShader,
  420. LPD3DXBUFFER* ppErrorMsgs);
  421. //----------------------------------------------------------------------------
  422. // D3DXCompileShader:
  423. // ------------------
  424. // Compiles a shader.
  425. //
  426. // Parameters:
  427. // pSrcFile
  428. // Source file name.
  429. // hSrcModule
  430. // Module handle. if NULL, current module will be used.
  431. // pSrcResource
  432. // Resource name in module.
  433. // pSrcData
  434. // Pointer to source code.
  435. // SrcDataLen
  436. // Size of source code, in bytes.
  437. // pDefines
  438. // Optional NULL-terminated array of preprocessor macro definitions.
  439. // pInclude
  440. // Optional interface pointer to use for handling #include directives.
  441. // If this parameter is NULL, #includes will be honored when compiling
  442. // from file, and will error when compiling from resource or memory.
  443. // pFunctionName
  444. // Name of the entrypoint function where execution should begin.
  445. // pProfile
  446. // Instruction set to be used when generating code. Currently supported
  447. // profiles are "vs_1_1", "vs_2_0", "vs_2_a", "vs_2_sw", "ps_1_1",
  448. // "ps_1_2", "ps_1_3", "ps_1_4", "ps_2_0", "ps_2_a", "ps_2_sw", "tx_1_0"
  449. // Flags
  450. // See D3DXSHADER_xxx flags.
  451. // ppShader
  452. // Returns a buffer containing the created shader. This buffer contains
  453. // the compiled shader code, as well as any embedded debug and symbol
  454. // table info. (See D3DXGetShaderConstantTable)
  455. // ppErrorMsgs
  456. // Returns a buffer containing a listing of errors and warnings that were
  457. // encountered during the compile. If you are running in a debugger,
  458. // these are the same messages you will see in your debug output.
  459. // ppConstantTable
  460. // Returns a ID3DXConstantTable object which can be used to set
  461. // shader constants to the device. Alternatively, an application can
  462. // parse the D3DXSHADER_CONSTANTTABLE block embedded as a comment within
  463. // the shader.
  464. //----------------------------------------------------------------------------
  465. HRESULT WINAPI
  466. D3DXCompileShaderFromFileA(
  467. LPCSTR pSrcFile,
  468. CONST D3DXMACRO* pDefines,
  469. LPD3DXINCLUDE pInclude,
  470. LPCSTR pFunctionName,
  471. LPCSTR pProfile,
  472. DWORD Flags,
  473. LPD3DXBUFFER* ppShader,
  474. LPD3DXBUFFER* ppErrorMsgs,
  475. LPD3DXCONSTANTTABLE* ppConstantTable);
  476. HRESULT WINAPI
  477. D3DXCompileShaderFromFileW(
  478. LPCWSTR pSrcFile,
  479. CONST D3DXMACRO* pDefines,
  480. LPD3DXINCLUDE pInclude,
  481. LPCSTR pFunctionName,
  482. LPCSTR pProfile,
  483. DWORD Flags,
  484. LPD3DXBUFFER* ppShader,
  485. LPD3DXBUFFER* ppErrorMsgs,
  486. LPD3DXCONSTANTTABLE* ppConstantTable);
  487. #ifdef UNICODE
  488. #define D3DXCompileShaderFromFile D3DXCompileShaderFromFileW
  489. #else
  490. #define D3DXCompileShaderFromFile D3DXCompileShaderFromFileA
  491. #endif
  492. HRESULT WINAPI
  493. D3DXCompileShaderFromResourceA(
  494. HMODULE hSrcModule,
  495. LPCSTR pSrcResource,
  496. CONST D3DXMACRO* pDefines,
  497. LPD3DXINCLUDE pInclude,
  498. LPCSTR pFunctionName,
  499. LPCSTR pProfile,
  500. DWORD Flags,
  501. LPD3DXBUFFER* ppShader,
  502. LPD3DXBUFFER* ppErrorMsgs,
  503. LPD3DXCONSTANTTABLE* ppConstantTable);
  504. HRESULT WINAPI
  505. D3DXCompileShaderFromResourceW(
  506. HMODULE hSrcModule,
  507. LPCWSTR pSrcResource,
  508. CONST D3DXMACRO* pDefines,
  509. LPD3DXINCLUDE pInclude,
  510. LPCSTR pFunctionName,
  511. LPCSTR pProfile,
  512. DWORD Flags,
  513. LPD3DXBUFFER* ppShader,
  514. LPD3DXBUFFER* ppErrorMsgs,
  515. LPD3DXCONSTANTTABLE* ppConstantTable);
  516. #ifdef UNICODE
  517. #define D3DXCompileShaderFromResource D3DXCompileShaderFromResourceW
  518. #else
  519. #define D3DXCompileShaderFromResource D3DXCompileShaderFromResourceA
  520. #endif
  521. HRESULT WINAPI
  522. D3DXCompileShader(
  523. LPCSTR pSrcData,
  524. UINT SrcDataLen,
  525. CONST D3DXMACRO* pDefines,
  526. LPD3DXINCLUDE pInclude,
  527. LPCSTR pFunctionName,
  528. LPCSTR pProfile,
  529. DWORD Flags,
  530. LPD3DXBUFFER* ppShader,
  531. LPD3DXBUFFER* ppErrorMsgs,
  532. LPD3DXCONSTANTTABLE* ppConstantTable);
  533. //----------------------------------------------------------------------------
  534. // D3DXDisassembleShader:
  535. // ----------------------
  536. // Takes a binary shader, and returns a buffer containing text assembly.
  537. //
  538. // Parameters:
  539. // pShader
  540. // Pointer to the shader byte code.
  541. // ShaderSizeInBytes
  542. // Size of the shader byte code in bytes.
  543. // EnableColorCode
  544. // Emit HTML tags for color coding the output?
  545. // pComments
  546. // Pointer to a comment string to include at the top of the shader.
  547. // ppDisassembly
  548. // Returns a buffer containing the disassembled shader.
  549. //----------------------------------------------------------------------------
  550. HRESULT WINAPI
  551. D3DXDisassembleShader(
  552. CONST DWORD* pShader,
  553. BOOL EnableColorCode,
  554. LPCSTR pComments,
  555. LPD3DXBUFFER* ppDisassembly);
  556. //----------------------------------------------------------------------------
  557. // D3DXGetPixelShaderProfile/D3DXGetVertexShaderProfile:
  558. // -----------------------------------------------------
  559. // Returns the name of the HLSL profile best suited to a given device.
  560. //
  561. // Parameters:
  562. // pDevice
  563. // Pointer to the device in question
  564. //----------------------------------------------------------------------------
  565. LPCSTR WINAPI
  566. D3DXGetPixelShaderProfile(
  567. LPDIRECT3DDEVICE9 pDevice);
  568. LPCSTR WINAPI
  569. D3DXGetVertexShaderProfile(
  570. LPDIRECT3DDEVICE9 pDevice);
  571. //----------------------------------------------------------------------------
  572. // D3DXFindShaderComment:
  573. // ----------------------
  574. // Searches through a shader for a particular comment, denoted by a FourCC in
  575. // the first DWORD of the comment. If the comment is not found, and no other
  576. // error has occurred, S_FALSE is returned.
  577. //
  578. // Parameters:
  579. // pFunction
  580. // Pointer to the function DWORD stream
  581. // FourCC
  582. // FourCC used to identify the desired comment block.
  583. // ppData
  584. // Returns a pointer to the comment data (not including comment token
  585. // and FourCC). Can be NULL.
  586. // pSizeInBytes
  587. // Returns the size of the comment data in bytes. Can be NULL.
  588. //----------------------------------------------------------------------------
  589. HRESULT WINAPI
  590. D3DXFindShaderComment(
  591. CONST DWORD* pFunction,
  592. DWORD FourCC,
  593. LPCVOID* ppData,
  594. UINT* pSizeInBytes);
  595. //----------------------------------------------------------------------------
  596. // D3DXGetShaderSize:
  597. // ------------------
  598. // Returns the size of the shader byte-code, in bytes.
  599. //
  600. // Parameters:
  601. // pFunction
  602. // Pointer to the function DWORD stream
  603. //----------------------------------------------------------------------------
  604. UINT WINAPI
  605. D3DXGetShaderSize(
  606. CONST DWORD* pFunction);
  607. //----------------------------------------------------------------------------
  608. // D3DXGetShaderVersion:
  609. // -----------------------
  610. // Returns the shader version of a given shader. Returns zero if the shader
  611. // function is NULL.
  612. //
  613. // Parameters:
  614. // pFunction
  615. // Pointer to the function DWORD stream
  616. //----------------------------------------------------------------------------
  617. DWORD WINAPI
  618. D3DXGetShaderVersion(
  619. CONST DWORD* pFunction);
  620. //----------------------------------------------------------------------------
  621. // D3DXGetShaderSemantics:
  622. // -----------------------
  623. // Gets semantics for all input elements referenced inside a given shader.
  624. //
  625. // Parameters:
  626. // pFunction
  627. // Pointer to the function DWORD stream
  628. // pSemantics
  629. // Pointer to an array of D3DXSEMANTIC structures. The function will
  630. // fill this array with the semantics for each input element referenced
  631. // inside the shader. This array is assumed to contain at least
  632. // MAXD3DDECLLENGTH elements.
  633. // pCount
  634. // Returns the number of elements referenced by the shader
  635. //----------------------------------------------------------------------------
  636. HRESULT WINAPI
  637. D3DXGetShaderInputSemantics(
  638. CONST DWORD* pFunction,
  639. D3DXSEMANTIC* pSemantics,
  640. UINT* pCount);
  641. HRESULT WINAPI
  642. D3DXGetShaderOutputSemantics(
  643. CONST DWORD* pFunction,
  644. D3DXSEMANTIC* pSemantics,
  645. UINT* pCount);
  646. //----------------------------------------------------------------------------
  647. // D3DXGetShaderSamplers:
  648. // ----------------------
  649. // Gets semantics for all input elements referenced inside a given shader.
  650. //
  651. // pFunction
  652. // Pointer to the function DWORD stream
  653. // pSamplers
  654. // Pointer to an array of LPCSTRs. The function will fill this array
  655. // with pointers to the sampler names contained within pFunction, for
  656. // each sampler referenced inside the shader. This array is assumed to
  657. // contain at least 16 elements.
  658. // pCount
  659. // Returns the number of samplers referenced by the shader
  660. //----------------------------------------------------------------------------
  661. HRESULT WINAPI
  662. D3DXGetShaderSamplers(
  663. CONST DWORD* pFunction,
  664. LPCSTR* pSamplers,
  665. UINT* pCount);
  666. //----------------------------------------------------------------------------
  667. // D3DXGetShaderConstantTable:
  668. // ---------------------------
  669. // Gets shader constant table embedded inside shader. A constant table is
  670. // generated by D3DXAssembleShader and D3DXCompileShader, and is embedded in
  671. // the body of the shader.
  672. //
  673. // Parameters:
  674. // pFunction
  675. // Pointer to the function DWORD stream
  676. // Flags
  677. // See D3DXCONSTTABLE_xxx
  678. // ppConstantTable
  679. // Returns a ID3DXConstantTable object which can be used to set
  680. // shader constants to the device. Alternatively, an application can
  681. // parse the D3DXSHADER_CONSTANTTABLE block embedded as a comment within
  682. // the shader.
  683. //----------------------------------------------------------------------------
  684. HRESULT WINAPI
  685. D3DXGetShaderConstantTable(
  686. CONST DWORD* pFunction,
  687. LPD3DXCONSTANTTABLE* ppConstantTable);
  688. HRESULT WINAPI
  689. D3DXGetShaderConstantTableEx(
  690. CONST DWORD* pFunction,
  691. DWORD Flags,
  692. LPD3DXCONSTANTTABLE* ppConstantTable);
  693. //----------------------------------------------------------------------------
  694. // D3DXCreateTextureShader:
  695. // ------------------------
  696. // Creates a texture shader object, given the compiled shader.
  697. //
  698. // Parameters
  699. // pFunction
  700. // Pointer to the function DWORD stream
  701. // ppTextureShader
  702. // Returns a ID3DXTextureShader object which can be used to procedurally
  703. // fill the contents of a texture using the D3DXFillTextureTX functions.
  704. //----------------------------------------------------------------------------
  705. HRESULT WINAPI
  706. D3DXCreateTextureShader(
  707. CONST DWORD* pFunction,
  708. LPD3DXTEXTURESHADER* ppTextureShader);
  709. //----------------------------------------------------------------------------
  710. // D3DXPreprocessShader:
  711. // ---------------------
  712. // Runs the preprocessor on the specified shader or effect, but does
  713. // not actually compile it. This is useful for evaluating the #includes
  714. // and #defines in a shader and then emitting a reformatted token stream
  715. // for debugging purposes or for generating a self-contained shader.
  716. //
  717. // Parameters:
  718. // pSrcFile
  719. // Source file name
  720. // hSrcModule
  721. // Module handle. if NULL, current module will be used
  722. // pSrcResource
  723. // Resource name in module
  724. // pSrcData
  725. // Pointer to source code
  726. // SrcDataLen
  727. // Size of source code, in bytes
  728. // pDefines
  729. // Optional NULL-terminated array of preprocessor macro definitions.
  730. // pInclude
  731. // Optional interface pointer to use for handling #include directives.
  732. // If this parameter is NULL, #includes will be honored when assembling
  733. // from file, and will error when assembling from resource or memory.
  734. // ppShaderText
  735. // Returns a buffer containing a single large string that represents
  736. // the resulting formatted token stream
  737. // ppErrorMsgs
  738. // Returns a buffer containing a listing of errors and warnings that were
  739. // encountered during assembly. If you are running in a debugger,
  740. // these are the same messages you will see in your debug output.
  741. //----------------------------------------------------------------------------
  742. HRESULT WINAPI
  743. D3DXPreprocessShaderFromFileA(
  744. LPCSTR pSrcFile,
  745. CONST D3DXMACRO* pDefines,
  746. LPD3DXINCLUDE pInclude,
  747. LPD3DXBUFFER* ppShaderText,
  748. LPD3DXBUFFER* ppErrorMsgs);
  749. HRESULT WINAPI
  750. D3DXPreprocessShaderFromFileW(
  751. LPCWSTR pSrcFile,
  752. CONST D3DXMACRO* pDefines,
  753. LPD3DXINCLUDE pInclude,
  754. LPD3DXBUFFER* ppShaderText,
  755. LPD3DXBUFFER* ppErrorMsgs);
  756. #ifdef UNICODE
  757. #define D3DXPreprocessShaderFromFile D3DXPreprocessShaderFromFileW
  758. #else
  759. #define D3DXPreprocessShaderFromFile D3DXPreprocessShaderFromFileA
  760. #endif
  761. HRESULT WINAPI
  762. D3DXPreprocessShaderFromResourceA(
  763. HMODULE hSrcModule,
  764. LPCSTR pSrcResource,
  765. CONST D3DXMACRO* pDefines,
  766. LPD3DXINCLUDE pInclude,
  767. LPD3DXBUFFER* ppShaderText,
  768. LPD3DXBUFFER* ppErrorMsgs);
  769. HRESULT WINAPI
  770. D3DXPreprocessShaderFromResourceW(
  771. HMODULE hSrcModule,
  772. LPCWSTR pSrcResource,
  773. CONST D3DXMACRO* pDefines,
  774. LPD3DXINCLUDE pInclude,
  775. LPD3DXBUFFER* ppShaderText,
  776. LPD3DXBUFFER* ppErrorMsgs);
  777. #ifdef UNICODE
  778. #define D3DXPreprocessShaderFromResource D3DXPreprocessShaderFromResourceW
  779. #else
  780. #define D3DXPreprocessShaderFromResource D3DXPreprocessShaderFromResourceA
  781. #endif
  782. HRESULT WINAPI
  783. D3DXPreprocessShader(
  784. LPCSTR pSrcData,
  785. UINT SrcDataSize,
  786. CONST D3DXMACRO* pDefines,
  787. LPD3DXINCLUDE pInclude,
  788. LPD3DXBUFFER* ppShaderText,
  789. LPD3DXBUFFER* ppErrorMsgs);
  790. #ifdef __cplusplus
  791. }
  792. #endif //__cplusplus
  793. //////////////////////////////////////////////////////////////////////////////
  794. // Shader comment block layouts //////////////////////////////////////////////
  795. //////////////////////////////////////////////////////////////////////////////
  796. //----------------------------------------------------------------------------
  797. // D3DXSHADER_CONSTANTTABLE:
  798. // -------------------------
  799. // Shader constant information; included as an CTAB comment block inside
  800. // shaders. All offsets are BYTE offsets from start of CONSTANTTABLE struct.
  801. // Entries in the table are sorted by Name in ascending order.
  802. //----------------------------------------------------------------------------
  803. typedef struct _D3DXSHADER_CONSTANTTABLE
  804. {
  805. DWORD Size; // sizeof(D3DXSHADER_CONSTANTTABLE)
  806. DWORD Creator; // LPCSTR offset
  807. DWORD Version; // shader version
  808. DWORD Constants; // number of constants
  809. DWORD ConstantInfo; // D3DXSHADER_CONSTANTINFO[Constants] offset
  810. DWORD Flags; // flags shader was compiled with
  811. DWORD Target; // LPCSTR offset
  812. } D3DXSHADER_CONSTANTTABLE, *LPD3DXSHADER_CONSTANTTABLE;
  813. typedef struct _D3DXSHADER_CONSTANTINFO
  814. {
  815. DWORD Name; // LPCSTR offset
  816. WORD RegisterSet; // D3DXREGISTER_SET
  817. WORD RegisterIndex; // register number
  818. WORD RegisterCount; // number of registers
  819. WORD Reserved; // reserved
  820. DWORD TypeInfo; // D3DXSHADER_TYPEINFO offset
  821. DWORD DefaultValue; // offset of default value
  822. } D3DXSHADER_CONSTANTINFO, *LPD3DXSHADER_CONSTANTINFO;
  823. typedef struct _D3DXSHADER_TYPEINFO
  824. {
  825. WORD Class; // D3DXPARAMETER_CLASS
  826. WORD Type; // D3DXPARAMETER_TYPE
  827. WORD Rows; // number of rows (matrices)
  828. WORD Columns; // number of columns (vectors and matrices)
  829. WORD Elements; // array dimension
  830. WORD StructMembers; // number of struct members
  831. DWORD StructMemberInfo; // D3DXSHADER_STRUCTMEMBERINFO[Members] offset
  832. } D3DXSHADER_TYPEINFO, *LPD3DXSHADER_TYPEINFO;
  833. typedef struct _D3DXSHADER_STRUCTMEMBERINFO
  834. {
  835. DWORD Name; // LPCSTR offset
  836. DWORD TypeInfo; // D3DXSHADER_TYPEINFO offset
  837. } D3DXSHADER_STRUCTMEMBERINFO, *LPD3DXSHADER_STRUCTMEMBERINFO;
  838. #endif //__D3DX9SHADER_H__