dxcapi.internal.h 13 KB

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