dxcapi.internal.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // //
  3. // dxcapi.internal.h //
  4. // Copyright (C) Microsoft Corporation. All rights reserved. //
  5. // This file is distributed under the University of Illinois Open Source //
  6. // License. See LICENSE.TXT for details. //
  7. // //
  8. // Provides non-public declarations for the DirectX Compiler component. //
  9. // //
  10. ///////////////////////////////////////////////////////////////////////////////
  11. #ifndef __DXC_API_INTERNAL__
  12. #define __DXC_API_INTERNAL__
  13. #include "dxcapi.h"
  14. ///////////////////////////////////////////////////////////////////////////////
  15. // Forward declarations.
  16. typedef interface ITextFont ITextFont;
  17. typedef interface IEnumSTATSTG IEnumSTATSTG;
  18. typedef interface ID3D10Blob ID3D10Blob;
  19. ///////////////////////////////////////////////////////////////////////////////
  20. // Intrinsic definitions.
  21. #define AR_QUAL_IN 0x0000000000000010UI64
  22. #define AR_QUAL_OUT 0x0000000000000020UI64
  23. #define AR_QUAL_CONST 0x0000000000000200UI64
  24. #define AR_QUAL_ROWMAJOR 0x0000000000000400UI64
  25. #define AR_QUAL_COLMAJOR 0x0000000000000800UI64
  26. #define AR_QUAL_IN_OUT (AR_QUAL_IN | AR_QUAL_OUT)
  27. static const BYTE INTRIN_TEMPLATE_FROM_TYPE = 0xff;
  28. static const BYTE INTRIN_TEMPLATE_VARARGS = 0xfe;
  29. // Use this enumeration to describe allowed templates (layouts) in intrinsics.
  30. enum LEGAL_INTRINSIC_TEMPLATES {
  31. LITEMPLATE_VOID = 0, // No return type.
  32. LITEMPLATE_SCALAR = 1, // Scalar types.
  33. LITEMPLATE_VECTOR = 2, // Vector types (eg. float3).
  34. LITEMPLATE_MATRIX = 3, // Matrix types (eg. float3x3).
  35. LITEMPLATE_ANY = 4, // Any one of scalar, vector or matrix types (but not object).
  36. LITEMPLATE_OBJECT = 5, // Object types.
  37. LITEMPLATE_COUNT = 6
  38. };
  39. // INTRIN_COMPTYPE_FROM_TYPE_ELT0 is for object method intrinsics to indicate
  40. // that the component type of the type is taken from the first subelement of the
  41. // object's template type; see for example Texture2D.Gather
  42. static const BYTE INTRIN_COMPTYPE_FROM_TYPE_ELT0 = 0xff;
  43. enum LEGAL_INTRINSIC_COMPTYPES {
  44. LICOMPTYPE_VOID = 0, // void, used for function returns
  45. LICOMPTYPE_BOOL = 1, // bool
  46. LICOMPTYPE_INT = 2, // i32, int-literal
  47. LICOMPTYPE_UINT = 3, // u32, int-literal
  48. LICOMPTYPE_ANY_INT = 4, // i32, u32, i64, u64, int-literal
  49. LICOMPTYPE_ANY_INT32 = 5, // i32, u32, int-literal
  50. LICOMPTYPE_UINT_ONLY = 6, // u32, u64, int-literal; no casts allowed
  51. LICOMPTYPE_FLOAT = 7, // f32, partial-precision-f32, float-literal
  52. LICOMPTYPE_ANY_FLOAT = 8, // f32, partial-precision-f32, f64, float-literal, min10-float, min16-float, half
  53. LICOMPTYPE_FLOAT_LIKE = 9, // f32, partial-precision-f32, float-literal, min10-float, min16-float, half
  54. LICOMPTYPE_FLOAT_DOUBLE = 10, // f32, partial-precision-f32, f64, float-literal
  55. LICOMPTYPE_DOUBLE = 11, // f64, float-literal
  56. LICOMPTYPE_DOUBLE_ONLY = 12, // f64; no casts allowed
  57. LICOMPTYPE_NUMERIC = 13, // float-literal, f32, partial-precision-f32, f64, min10-float, min16-float, int-literal, i32, u32, min12-int, min16-int, min16-uint, i64, u64
  58. LICOMPTYPE_NUMERIC32 = 14, // float-literal, f32, partial-precision-f32, int-literal, i32, u32
  59. LICOMPTYPE_NUMERIC32_ONLY = 15, // float-literal, f32, partial-precision-f32, int-literal, i32, u32; no casts allowed
  60. LICOMPTYPE_ANY = 16, // float-literal, f32, partial-precision-f32, f64, min10-float, min16-float, int-literal, i32, u32, min12-int, min16-int, min16-uint, bool, i64, u64
  61. LICOMPTYPE_SAMPLER1D = 17,
  62. LICOMPTYPE_SAMPLER2D = 18,
  63. LICOMPTYPE_SAMPLER3D = 19,
  64. LICOMPTYPE_SAMPLERCUBE = 20,
  65. LICOMPTYPE_SAMPLERCMP = 21,
  66. LICOMPTYPE_SAMPLER = 22,
  67. LICOMPTYPE_STRING = 23,
  68. LICOMPTYPE_WAVE = 24,
  69. LICOMPTYPE_UINT64 = 25, // u64, int-literal
  70. LICOMPTYPE_UINT16_32_64 = 26, // u16, u32, u64, int-literal
  71. LICOMPTYPE_FLOAT16 = 27,
  72. LICOMPTYPE_INT16 = 28,
  73. LICOMPTYPE_UINT16 = 29,
  74. LICOMPTYPE_NUMERIC16_ONLY = 30,
  75. LICOMPTYPE_COUNT = 31
  76. };
  77. static const BYTE IA_SPECIAL_BASE = 0xf0;
  78. static const BYTE IA_R = 0xf0;
  79. static const BYTE IA_C = 0xf1;
  80. static const BYTE IA_R2 = 0xf2;
  81. static const BYTE IA_C2 = 0xf3;
  82. static const BYTE IA_SPECIAL_SLOTS = 4;
  83. struct HLSL_INTRINSIC_ARGUMENT {
  84. LPCSTR pName; // Name of the argument; the first argument has the function name.
  85. UINT64 qwUsage; // A combination of AR_QUAL_IN|AR_QUAL_OUT|AR_QUAL_COLMAJOR|AR_QUAL_ROWMAJOR in parameter tables; other values possible elsewhere.
  86. BYTE uTemplateId; // One of INTRIN_TEMPLATE_FROM_TYPE, INTRIN_TEMPLATE_VARARGS or the argument # the template (layout) must match (trivially itself).
  87. BYTE uLegalTemplates; // A LEGAL_INTRINSIC_TEMPLATES value for allowed templates.
  88. BYTE uComponentTypeId; // INTRIN_COMPTYPE_FROM_TYPE_ELT0, or the argument # the component (element type) must match (trivially itself).
  89. BYTE uLegalComponentTypes; // A LEGAL_INTRINSIC_COMPTYPES value for allowed components.
  90. BYTE uRows; // Required number of rows, or one of IA_R/IA_C/IA_R2/IA_C2 for matching input constraints.
  91. BYTE uCols; // Required number of cols, or one of IA_R/IA_C/IA_R2/IA_C2 for matching input constraints.
  92. };
  93. struct HLSL_INTRINSIC {
  94. UINT Op; // Intrinsic Op ID
  95. BOOL bReadOnly; // Only read memory
  96. BOOL bReadNone; // Not read memory
  97. INT iOverloadParamIndex; // Parameter decide the overload type, -1 means ret type
  98. UINT uNumArgs; // Count of arguments in pArgs.
  99. const HLSL_INTRINSIC_ARGUMENT* pArgs; // Pointer to first argument.
  100. };
  101. ///////////////////////////////////////////////////////////////////////////////
  102. // Interfaces.
  103. struct __declspec(uuid("f0d4da3f-f863-4660-b8b4-dfd94ded6215"))
  104. IDxcIntrinsicTable : public IUnknown
  105. {
  106. public:
  107. virtual HRESULT STDMETHODCALLTYPE GetTableName(_Outptr_ LPCSTR *pTableName) = 0;
  108. virtual HRESULT STDMETHODCALLTYPE LookupIntrinsic(
  109. LPCWSTR typeName, LPCWSTR functionName,
  110. const HLSL_INTRINSIC** pIntrinsic,
  111. _Inout_ UINT64* pLookupCookie) = 0;
  112. // Get the lowering strategy for an hlsl extension intrinsic.
  113. virtual HRESULT STDMETHODCALLTYPE GetLoweringStrategy(UINT opcode, LPCSTR *pStrategy) = 0;
  114. // Callback to support custom naming of hlsl extension intrinsic functions in dxil.
  115. // Return the empty string to get the default intrinsic name, which is the mangled
  116. // name of the high level intrinsic function.
  117. //
  118. // Overloaded intrinsics are supported by use of an overload place holder in the
  119. // name. The string "$o" in the name will be replaced by the return type of the
  120. // intrinsic.
  121. virtual HRESULT STDMETHODCALLTYPE GetIntrinsicName(UINT opcode, LPCSTR *pName) = 0;
  122. // Callback to support the 'dxil' lowering strategy.
  123. // Returns the dxil opcode that the intrinsic should use for lowering.
  124. virtual HRESULT STDMETHODCALLTYPE GetDxilOpCode(UINT opcode, UINT *pDxilOpcode) = 0;
  125. };
  126. struct __declspec(uuid("1d063e4f-515a-4d57-a12a-431f6a44cfb9"))
  127. IDxcSemanticDefineValidator : public IUnknown
  128. {
  129. public:
  130. virtual HRESULT STDMETHODCALLTYPE GetSemanticDefineWarningsAndErrors(LPCSTR pName, LPCSTR pValue, IDxcBlobEncoding **ppWarningBlob, IDxcBlobEncoding **ppErrorBlob) = 0;
  131. };
  132. struct __declspec(uuid("282a56b4-3f56-4360-98c7-9ea04a752272"))
  133. IDxcLangExtensions : public IUnknown
  134. {
  135. public:
  136. /// <summary>
  137. /// Registers the name of a preprocessor define that has semantic meaning
  138. /// and should be preserved for downstream consumers.
  139. /// </summary>
  140. virtual HRESULT STDMETHODCALLTYPE RegisterSemanticDefine(LPCWSTR name) = 0;
  141. /// <summary>Registers a name to exclude from semantic defines.</summary>
  142. virtual HRESULT STDMETHODCALLTYPE RegisterSemanticDefineExclusion(LPCWSTR name) = 0;
  143. /// <summary>Registers a definition for compilation.</summary>
  144. virtual HRESULT STDMETHODCALLTYPE RegisterDefine(LPCWSTR name) = 0;
  145. /// <summary>Registers a table of built-in intrinsics.</summary>
  146. virtual HRESULT STDMETHODCALLTYPE RegisterIntrinsicTable(_In_ IDxcIntrinsicTable* pTable) = 0;
  147. /// <summary>Sets an (optional) validator for parsed semantic defines.<summary>
  148. /// This provides a hook to check that the semantic defines present in the source
  149. /// contain valid data. One validator is used to validate all parsed semantic defines.
  150. virtual HRESULT STDMETHODCALLTYPE SetSemanticDefineValidator(_In_ IDxcSemanticDefineValidator* pValidator) = 0;
  151. /// <summary>Sets the name for the root metadata node used in DXIL to hold the semantic defines.</summary>
  152. virtual HRESULT STDMETHODCALLTYPE SetSemanticDefineMetaDataName(LPCSTR name) = 0;
  153. };
  154. struct __declspec(uuid("454b764f-3549-475b-958c-a7a6fcd05fbc"))
  155. IDxcSystemAccess : public IUnknown
  156. {
  157. public:
  158. virtual HRESULT STDMETHODCALLTYPE EnumFiles(LPCWSTR fileName, IEnumSTATSTG** pResult) = 0;
  159. virtual HRESULT STDMETHODCALLTYPE OpenStorage(
  160. _In_ LPCWSTR lpFileName,
  161. _In_ DWORD dwDesiredAccess,
  162. _In_ DWORD dwShareMode,
  163. _In_ DWORD dwCreationDisposition,
  164. _In_ DWORD dwFlagsAndAttributes, IUnknown** pResult) = 0;
  165. virtual HRESULT STDMETHODCALLTYPE SetStorageTime(_In_ IUnknown* storage,
  166. _In_opt_ const FILETIME *lpCreationTime,
  167. _In_opt_ const FILETIME *lpLastAccessTime,
  168. _In_opt_ const FILETIME *lpLastWriteTime) = 0;
  169. virtual HRESULT STDMETHODCALLTYPE GetFileInformationForStorage(_In_ IUnknown* storage, _Out_ LPBY_HANDLE_FILE_INFORMATION lpFileInformation) = 0;
  170. virtual HRESULT STDMETHODCALLTYPE GetFileTypeForStorage(_In_ IUnknown* storage, _Out_ DWORD* fileType) = 0;
  171. virtual HRESULT STDMETHODCALLTYPE CreateHardLinkInStorage(_In_ LPCWSTR lpFileName, _In_ LPCWSTR lpExistingFileName) = 0;
  172. virtual HRESULT STDMETHODCALLTYPE MoveStorage(_In_ LPCWSTR lpExistingFileName, _In_opt_ LPCWSTR lpNewFileName, _In_ DWORD dwFlags) = 0;
  173. virtual HRESULT STDMETHODCALLTYPE GetFileAttributesForStorage(_In_ LPCWSTR lpFileName, _Out_ DWORD* pResult) = 0;
  174. virtual HRESULT STDMETHODCALLTYPE DeleteStorage(_In_ LPCWSTR lpFileName) = 0;
  175. virtual HRESULT STDMETHODCALLTYPE RemoveDirectoryStorage(LPCWSTR lpFileName) = 0;
  176. virtual HRESULT STDMETHODCALLTYPE CreateDirectoryStorage(_In_ LPCWSTR lpPathName) = 0;
  177. virtual HRESULT STDMETHODCALLTYPE GetCurrentDirectoryForStorage(DWORD nBufferLength, _Out_writes_(nBufferLength) LPWSTR lpBuffer, _Out_ DWORD* written) = 0;
  178. virtual HRESULT STDMETHODCALLTYPE GetMainModuleFileNameW(DWORD nBufferLength, _Out_writes_(nBufferLength) LPWSTR lpBuffer, _Out_ DWORD* written) = 0;
  179. virtual HRESULT STDMETHODCALLTYPE GetTempStoragePath(DWORD nBufferLength, _Out_writes_(nBufferLength) LPWSTR lpBuffer, _Out_ DWORD* written) = 0;
  180. virtual HRESULT STDMETHODCALLTYPE SupportsCreateSymbolicLink(_Out_ BOOL* pResult) = 0;
  181. virtual HRESULT STDMETHODCALLTYPE CreateSymbolicLinkInStorage(_In_ LPCWSTR lpSymlinkFileName, _In_ LPCWSTR lpTargetFileName, DWORD dwFlags) = 0;
  182. virtual HRESULT STDMETHODCALLTYPE CreateStorageMapping(
  183. _In_ IUnknown* hFile,
  184. _In_ DWORD flProtect,
  185. _In_ DWORD dwMaximumSizeHigh,
  186. _In_ DWORD dwMaximumSizeLow,
  187. _Outptr_ IUnknown** pResult) = 0;
  188. virtual HRESULT MapViewOfFile(
  189. _In_ IUnknown* hFileMappingObject,
  190. _In_ DWORD dwDesiredAccess,
  191. _In_ DWORD dwFileOffsetHigh,
  192. _In_ DWORD dwFileOffsetLow,
  193. _In_ SIZE_T dwNumberOfBytesToMap,
  194. _Outptr_ ID3D10Blob** pResult) = 0;
  195. virtual HRESULT STDMETHODCALLTYPE OpenStdStorage(int standardFD, _Outptr_ IUnknown** pResult) = 0;
  196. virtual HRESULT STDMETHODCALLTYPE GetStreamDisplay(_COM_Outptr_result_maybenull_ ITextFont** textFont, _Out_ unsigned* columnCount) = 0;
  197. };
  198. struct __declspec(uuid("e991ca8d-2045-413c-a8b8-788b2c06e14d"))
  199. IDxcContainerEventsHandler : public IUnknown
  200. {
  201. public:
  202. virtual HRESULT STDMETHODCALLTYPE OnDxilContainerBuilt(_In_ IDxcBlob *pSource, _Out_ IDxcBlob **ppTarget) = 0;
  203. };
  204. struct __declspec(uuid("0cfc5058-342b-4ff2-83f7-04c12aad3d01"))
  205. IDxcContainerEvent : public IUnknown
  206. {
  207. public:
  208. virtual HRESULT STDMETHODCALLTYPE RegisterDxilContainerEventHandler(IDxcContainerEventsHandler *pHandler, UINT64 *pCookie) = 0;
  209. virtual HRESULT STDMETHODCALLTYPE UnRegisterDxilContainerEventHandler(UINT64 cookie) = 0;
  210. };
  211. #endif