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.

397 lines
15 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) Microsoft Corporation. All rights reserved.
  4. //
  5. // File: D3DCompiler.h
  6. // Content: D3D Compilation Types and APIs
  7. //
  8. //////////////////////////////////////////////////////////////////////////////
  9. #ifndef __D3DCOMPILER_H__
  10. #define __D3DCOMPILER_H__
  11. // Current name of the DLL shipped in the same SDK as this header.
  12. #define D3DCOMPILER_DLL_W L"d3dcompiler_43.dll"
  13. #define D3DCOMPILER_DLL_A "d3dcompiler_43.dll"
  14. #ifdef UNICODE
  15. #define D3DCOMPILER_DLL D3DCOMPILER_DLL_W
  16. #else
  17. #define D3DCOMPILER_DLL D3DCOMPILER_DLL_A
  18. #endif
  19. #include "d3d11shader.h"
  20. //////////////////////////////////////////////////////////////////////////////
  21. // APIs //////////////////////////////////////////////////////////////////////
  22. //////////////////////////////////////////////////////////////////////////////
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif //__cplusplus
  26. //----------------------------------------------------------------------------
  27. // D3DCOMPILE flags:
  28. // -----------------
  29. // D3DCOMPILE_DEBUG
  30. // Insert debug file/line/type/symbol information.
  31. //
  32. // D3DCOMPILE_SKIP_VALIDATION
  33. // Do not validate the generated code against known capabilities and
  34. // constraints. This option is only recommended when compiling shaders
  35. // you KNOW will work. (ie. have compiled before without this option.)
  36. // Shaders are always validated by D3D before they are set to the device.
  37. //
  38. // D3DCOMPILE_SKIP_OPTIMIZATION
  39. // Instructs the compiler to skip optimization steps during code generation.
  40. // Unless you are trying to isolate a problem in your code using this option
  41. // is not recommended.
  42. //
  43. // D3DCOMPILE_PACK_MATRIX_ROW_MAJOR
  44. // Unless explicitly specified, matrices will be packed in row-major order
  45. // on input and output from the shader.
  46. //
  47. // D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR
  48. // Unless explicitly specified, matrices will be packed in column-major
  49. // order on input and output from the shader. This is generally more
  50. // efficient, since it allows vector-matrix multiplication to be performed
  51. // using a series of dot-products.
  52. //
  53. // D3DCOMPILE_PARTIAL_PRECISION
  54. // Force all computations in resulting shader to occur at partial precision.
  55. // This may result in faster evaluation of shaders on some hardware.
  56. //
  57. // D3DCOMPILE_FORCE_VS_SOFTWARE_NO_OPT
  58. // Force compiler to compile against the next highest available software
  59. // target for vertex shaders. This flag also turns optimizations off,
  60. // and debugging on.
  61. //
  62. // D3DCOMPILE_FORCE_PS_SOFTWARE_NO_OPT
  63. // Force compiler to compile against the next highest available software
  64. // target for pixel shaders. This flag also turns optimizations off,
  65. // and debugging on.
  66. //
  67. // D3DCOMPILE_NO_PRESHADER
  68. // Disables Preshaders. Using this flag will cause the compiler to not
  69. // pull out static expression for evaluation on the host cpu
  70. //
  71. // D3DCOMPILE_AVOID_FLOW_CONTROL
  72. // Hint compiler to avoid flow-control constructs where possible.
  73. //
  74. // D3DCOMPILE_PREFER_FLOW_CONTROL
  75. // Hint compiler to prefer flow-control constructs where possible.
  76. //
  77. // D3DCOMPILE_ENABLE_STRICTNESS
  78. // By default, the HLSL/Effect compilers are not strict on deprecated syntax.
  79. // Specifying this flag enables the strict mode. Deprecated syntax may be
  80. // removed in a future release, and enabling syntax is a good way to make
  81. // sure your shaders comply to the latest spec.
  82. //
  83. // D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY
  84. // This enables older shaders to compile to 4_0 targets.
  85. //
  86. //----------------------------------------------------------------------------
  87. #define D3DCOMPILE_DEBUG (1 << 0)
  88. #define D3DCOMPILE_SKIP_VALIDATION (1 << 1)
  89. #define D3DCOMPILE_SKIP_OPTIMIZATION (1 << 2)
  90. #define D3DCOMPILE_PACK_MATRIX_ROW_MAJOR (1 << 3)
  91. #define D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR (1 << 4)
  92. #define D3DCOMPILE_PARTIAL_PRECISION (1 << 5)
  93. #define D3DCOMPILE_FORCE_VS_SOFTWARE_NO_OPT (1 << 6)
  94. #define D3DCOMPILE_FORCE_PS_SOFTWARE_NO_OPT (1 << 7)
  95. #define D3DCOMPILE_NO_PRESHADER (1 << 8)
  96. #define D3DCOMPILE_AVOID_FLOW_CONTROL (1 << 9)
  97. #define D3DCOMPILE_PREFER_FLOW_CONTROL (1 << 10)
  98. #define D3DCOMPILE_ENABLE_STRICTNESS (1 << 11)
  99. #define D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY (1 << 12)
  100. #define D3DCOMPILE_IEEE_STRICTNESS (1 << 13)
  101. #define D3DCOMPILE_OPTIMIZATION_LEVEL0 (1 << 14)
  102. #define D3DCOMPILE_OPTIMIZATION_LEVEL1 0
  103. #define D3DCOMPILE_OPTIMIZATION_LEVEL2 ((1 << 14) | (1 << 15))
  104. #define D3DCOMPILE_OPTIMIZATION_LEVEL3 (1 << 15)
  105. #define D3DCOMPILE_RESERVED16 (1 << 16)
  106. #define D3DCOMPILE_RESERVED17 (1 << 17)
  107. #define D3DCOMPILE_WARNINGS_ARE_ERRORS (1 << 18)
  108. //----------------------------------------------------------------------------
  109. // D3DCOMPILE_EFFECT flags:
  110. // -------------------------------------
  111. // These flags are passed in when creating an effect, and affect
  112. // either compilation behavior or runtime effect behavior
  113. //
  114. // D3DCOMPILE_EFFECT_CHILD_EFFECT
  115. // Compile this .fx file to a child effect. Child effects have no
  116. // initializers for any shared values as these are initialied in the
  117. // master effect (pool).
  118. //
  119. // D3DCOMPILE_EFFECT_ALLOW_SLOW_OPS
  120. // By default, performance mode is enabled. Performance mode
  121. // disallows mutable state objects by preventing non-literal
  122. // expressions from appearing in state object definitions.
  123. // Specifying this flag will disable the mode and allow for mutable
  124. // state objects.
  125. //
  126. //----------------------------------------------------------------------------
  127. #define D3DCOMPILE_EFFECT_CHILD_EFFECT (1 << 0)
  128. #define D3DCOMPILE_EFFECT_ALLOW_SLOW_OPS (1 << 1)
  129. //----------------------------------------------------------------------------
  130. // D3DCompile:
  131. // ----------
  132. // Compile source text into bytecode appropriate for the given target.
  133. //----------------------------------------------------------------------------
  134. HRESULT WINAPI
  135. D3DCompile(__in_bcount(SrcDataSize) LPCVOID pSrcData,
  136. __in SIZE_T SrcDataSize,
  137. __in_opt LPCSTR pSourceName,
  138. __in_xcount_opt(pDefines->Name != NULL) CONST D3D_SHADER_MACRO* pDefines,
  139. __in_opt ID3DInclude* pInclude,
  140. __in LPCSTR pEntrypoint,
  141. __in LPCSTR pTarget,
  142. __in UINT Flags1,
  143. __in UINT Flags2,
  144. __out ID3DBlob** ppCode,
  145. __out_opt ID3DBlob** ppErrorMsgs);
  146. typedef HRESULT (WINAPI *pD3DCompile)
  147. (LPCVOID pSrcData,
  148. SIZE_T SrcDataSize,
  149. LPCSTR pFileName,
  150. CONST D3D_SHADER_MACRO* pDefines,
  151. ID3DInclude* pInclude,
  152. LPCSTR pEntrypoint,
  153. LPCSTR pTarget,
  154. UINT Flags1,
  155. UINT Flags2,
  156. ID3DBlob** ppCode,
  157. ID3DBlob** ppErrorMsgs);
  158. //----------------------------------------------------------------------------
  159. // D3DPreprocess:
  160. // ----------
  161. // Process source text with the compiler's preprocessor and return
  162. // the resulting text.
  163. //----------------------------------------------------------------------------
  164. HRESULT WINAPI
  165. D3DPreprocess(__in_bcount(SrcDataSize) LPCVOID pSrcData,
  166. __in SIZE_T SrcDataSize,
  167. __in_opt LPCSTR pSourceName,
  168. __in_opt CONST D3D_SHADER_MACRO* pDefines,
  169. __in_opt ID3DInclude* pInclude,
  170. __out ID3DBlob** ppCodeText,
  171. __out_opt ID3DBlob** ppErrorMsgs);
  172. typedef HRESULT (WINAPI *pD3DPreprocess)
  173. (LPCVOID pSrcData,
  174. SIZE_T SrcDataSize,
  175. LPCSTR pFileName,
  176. CONST D3D_SHADER_MACRO* pDefines,
  177. ID3DInclude* pInclude,
  178. ID3DBlob** ppCodeText,
  179. ID3DBlob** ppErrorMsgs);
  180. //----------------------------------------------------------------------------
  181. // D3DGetDebugInfo:
  182. // -----------------------
  183. // Gets shader debug info. Debug info is generated by D3DCompile and is
  184. // embedded in the body of the shader.
  185. //----------------------------------------------------------------------------
  186. HRESULT WINAPI
  187. D3DGetDebugInfo(__in_bcount(SrcDataSize) LPCVOID pSrcData,
  188. __in SIZE_T SrcDataSize,
  189. __out ID3DBlob** ppDebugInfo);
  190. //----------------------------------------------------------------------------
  191. // D3DReflect:
  192. // ----------
  193. // Shader code contains metadata that can be inspected via the
  194. // reflection APIs.
  195. //----------------------------------------------------------------------------
  196. HRESULT WINAPI
  197. D3DReflect(__in_bcount(SrcDataSize) LPCVOID pSrcData,
  198. __in SIZE_T SrcDataSize,
  199. __in REFIID pInterface,
  200. __out void** ppReflector);
  201. //----------------------------------------------------------------------------
  202. // D3DDisassemble:
  203. // ----------------------
  204. // Takes a binary shader and returns a buffer containing text assembly.
  205. //----------------------------------------------------------------------------
  206. #define D3D_DISASM_ENABLE_COLOR_CODE 0x00000001
  207. #define D3D_DISASM_ENABLE_DEFAULT_VALUE_PRINTS 0x00000002
  208. #define D3D_DISASM_ENABLE_INSTRUCTION_NUMBERING 0x00000004
  209. #define D3D_DISASM_ENABLE_INSTRUCTION_CYCLE 0x00000008
  210. #define D3D_DISASM_DISABLE_DEBUG_INFO 0x00000010
  211. HRESULT WINAPI
  212. D3DDisassemble(__in_bcount(SrcDataSize) LPCVOID pSrcData,
  213. __in SIZE_T SrcDataSize,
  214. __in UINT Flags,
  215. __in_opt LPCSTR szComments,
  216. __out ID3DBlob** ppDisassembly);
  217. typedef HRESULT (WINAPI *pD3DDisassemble)
  218. (__in_bcount(SrcDataSize) LPCVOID pSrcData,
  219. __in SIZE_T SrcDataSize,
  220. __in UINT Flags,
  221. __in_opt LPCSTR szComments,
  222. __out ID3DBlob** ppDisassembly);
  223. //----------------------------------------------------------------------------
  224. // D3DDisassemble10Effect:
  225. // -----------------------
  226. // Takes a D3D10 effect interface and returns a
  227. // buffer containing text assembly.
  228. //----------------------------------------------------------------------------
  229. HRESULT WINAPI
  230. D3DDisassemble10Effect(__in interface ID3D10Effect *pEffect,
  231. __in UINT Flags,
  232. __out ID3DBlob** ppDisassembly);
  233. //----------------------------------------------------------------------------
  234. // D3DGetInputSignatureBlob:
  235. // -----------------------
  236. // Retrieve the input signature from a compilation result.
  237. //----------------------------------------------------------------------------
  238. HRESULT WINAPI
  239. D3DGetInputSignatureBlob(__in_bcount(SrcDataSize) LPCVOID pSrcData,
  240. __in SIZE_T SrcDataSize,
  241. __out ID3DBlob** ppSignatureBlob);
  242. //----------------------------------------------------------------------------
  243. // D3DGetOutputSignatureBlob:
  244. // -----------------------
  245. // Retrieve the output signature from a compilation result.
  246. //----------------------------------------------------------------------------
  247. HRESULT WINAPI
  248. D3DGetOutputSignatureBlob(__in_bcount(SrcDataSize) LPCVOID pSrcData,
  249. __in SIZE_T SrcDataSize,
  250. __out ID3DBlob** ppSignatureBlob);
  251. //----------------------------------------------------------------------------
  252. // D3DGetInputAndOutputSignatureBlob:
  253. // -----------------------
  254. // Retrieve the input and output signatures from a compilation result.
  255. //----------------------------------------------------------------------------
  256. HRESULT WINAPI
  257. D3DGetInputAndOutputSignatureBlob(__in_bcount(SrcDataSize) LPCVOID pSrcData,
  258. __in SIZE_T SrcDataSize,
  259. __out ID3DBlob** ppSignatureBlob);
  260. //----------------------------------------------------------------------------
  261. // D3DStripShader:
  262. // -----------------------
  263. // Removes unwanted blobs from a compilation result
  264. //----------------------------------------------------------------------------
  265. typedef enum D3DCOMPILER_STRIP_FLAGS
  266. {
  267. D3DCOMPILER_STRIP_REFLECTION_DATA = 1,
  268. D3DCOMPILER_STRIP_DEBUG_INFO = 2,
  269. D3DCOMPILER_STRIP_TEST_BLOBS = 4,
  270. D3DCOMPILER_STRIP_FORCE_DWORD = 0x7fffffff,
  271. } D3DCOMPILER_STRIP_FLAGS;
  272. HRESULT WINAPI
  273. D3DStripShader(__in_bcount(BytecodeLength) LPCVOID pShaderBytecode,
  274. __in SIZE_T BytecodeLength,
  275. __in UINT uStripFlags,
  276. __out ID3DBlob** ppStrippedBlob);
  277. //----------------------------------------------------------------------------
  278. // D3DGetBlobPart:
  279. // -----------------------
  280. // Extracts information from a compilation result.
  281. //----------------------------------------------------------------------------
  282. typedef enum D3D_BLOB_PART
  283. {
  284. D3D_BLOB_INPUT_SIGNATURE_BLOB,
  285. D3D_BLOB_OUTPUT_SIGNATURE_BLOB,
  286. D3D_BLOB_INPUT_AND_OUTPUT_SIGNATURE_BLOB,
  287. D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB,
  288. D3D_BLOB_ALL_SIGNATURE_BLOB,
  289. D3D_BLOB_DEBUG_INFO,
  290. D3D_BLOB_LEGACY_SHADER,
  291. D3D_BLOB_XNA_PREPASS_SHADER,
  292. D3D_BLOB_XNA_SHADER,
  293. // Test parts are only produced by special compiler versions and so
  294. // are usually not present in shaders.
  295. D3D_BLOB_TEST_ALTERNATE_SHADER = 0x8000,
  296. D3D_BLOB_TEST_COMPILE_DETAILS,
  297. D3D_BLOB_TEST_COMPILE_PERF,
  298. } D3D_BLOB_PART;
  299. HRESULT WINAPI
  300. D3DGetBlobPart(__in_bcount(SrcDataSize) LPCVOID pSrcData,
  301. __in SIZE_T SrcDataSize,
  302. __in D3D_BLOB_PART Part,
  303. __in UINT Flags,
  304. __out ID3DBlob** ppPart);
  305. //----------------------------------------------------------------------------
  306. // D3DCompressShaders:
  307. // -----------------------
  308. // Compresses a set of shaders into a more compact form.
  309. //----------------------------------------------------------------------------
  310. typedef struct _D3D_SHADER_DATA
  311. {
  312. LPCVOID pBytecode;
  313. SIZE_T BytecodeLength;
  314. } D3D_SHADER_DATA;
  315. #define D3D_COMPRESS_SHADER_KEEP_ALL_PARTS 0x00000001
  316. HRESULT WINAPI
  317. D3DCompressShaders(__in UINT uNumShaders,
  318. __in_ecount(uNumShaders) D3D_SHADER_DATA* pShaderData,
  319. __in UINT uFlags,
  320. __out ID3DBlob** ppCompressedData);
  321. //----------------------------------------------------------------------------
  322. // D3DDecompressShaders:
  323. // -----------------------
  324. // Decompresses one or more shaders from a compressed set.
  325. //----------------------------------------------------------------------------
  326. HRESULT WINAPI
  327. D3DDecompressShaders(__in_bcount(SrcDataSize) LPCVOID pSrcData,
  328. __in SIZE_T SrcDataSize,
  329. __in UINT uNumShaders,
  330. __in UINT uStartIndex,
  331. __in_ecount_opt(uNumShaders) UINT* pIndices,
  332. __in UINT uFlags,
  333. __out_ecount(uNumShaders) ID3DBlob** ppShaders,
  334. __out_opt UINT* pTotalShaders);
  335. //----------------------------------------------------------------------------
  336. // D3DCreateBlob:
  337. // -----------------------
  338. // Create an ID3DBlob instance.
  339. //----------------------------------------------------------------------------
  340. HRESULT WINAPI
  341. D3DCreateBlob(__in SIZE_T Size,
  342. __out ID3DBlob** ppBlob);
  343. #ifdef __cplusplus
  344. }
  345. #endif //__cplusplus
  346. #endif // #ifndef __D3DCOMPILER_H__