1bf215546Sopenharmony_ci
2bf215546Sopenharmony_ci///////////////////////////////////////////////////////////////////////////////
3bf215546Sopenharmony_ci//                                                                           //
4bf215546Sopenharmony_ci// dxcapi.h                                                                  //
5bf215546Sopenharmony_ci// Copyright (C) Microsoft Corporation. All rights reserved.                 //
6bf215546Sopenharmony_ci// This file is distributed under the University of Illinois Open Source     //
7bf215546Sopenharmony_ci// License. See LICENSE.TXT for details.                                     //
8bf215546Sopenharmony_ci//                                                                           //
9bf215546Sopenharmony_ci// Provides declarations for the DirectX Compiler API entry point.           //
10bf215546Sopenharmony_ci//                                                                           //
11bf215546Sopenharmony_ci///////////////////////////////////////////////////////////////////////////////
12bf215546Sopenharmony_ci
13bf215546Sopenharmony_ci#ifndef __DXC_API__
14bf215546Sopenharmony_ci#define __DXC_API__
15bf215546Sopenharmony_ci
16bf215546Sopenharmony_ci#ifdef _WIN32
17bf215546Sopenharmony_ci#ifndef DXC_API_IMPORT
18bf215546Sopenharmony_ci#define DXC_API_IMPORT __declspec(dllimport)
19bf215546Sopenharmony_ci#endif
20bf215546Sopenharmony_ci#else
21bf215546Sopenharmony_ci#ifndef DXC_API_IMPORT
22bf215546Sopenharmony_ci#define DXC_API_IMPORT __attribute__ ((visibility ("default")))
23bf215546Sopenharmony_ci#endif
24bf215546Sopenharmony_ci#endif
25bf215546Sopenharmony_ci
26bf215546Sopenharmony_ci#include <stdint.h>
27bf215546Sopenharmony_ci#ifndef CROSS_PLATFORM_UUIDOF
28bf215546Sopenharmony_ci// Warning: This macro exists in WinAdapter.h as well
29bf215546Sopenharmony_ci#if defined(_MSC_VER)
30bf215546Sopenharmony_ci#define CROSS_PLATFORM_UUIDOF(iface, spec)                                 \
31bf215546Sopenharmony_ci   struct __declspec(uuid(spec)) iface;
32bf215546Sopenharmony_ci#else /* defined(_MSC_VER) */
33bf215546Sopenharmony_ci#if defined(__MINGW32__)
34bf215546Sopenharmony_ci#include <guiddef.h>
35bf215546Sopenharmony_ci#include <sal.h>
36bf215546Sopenharmony_ci#ifndef _Maybenull_
37bf215546Sopenharmony_ci#define _Maybenull_
38bf215546Sopenharmony_ci#endif
39bf215546Sopenharmony_ci#ifndef _In_count_
40bf215546Sopenharmony_ci#define _In_count_(x)
41bf215546Sopenharmony_ci#endif
42bf215546Sopenharmony_ci#ifndef _In_opt_count_
43bf215546Sopenharmony_ci#define _In_opt_count_(x)
44bf215546Sopenharmony_ci#endif
45bf215546Sopenharmony_ci#ifndef _In_bytecount_
46bf215546Sopenharmony_ci#define _In_bytecount_(x)
47bf215546Sopenharmony_ci#endif
48bf215546Sopenharmony_ci#endif /*  defined(__MINGW32__) */
49bf215546Sopenharmony_ci#ifndef __CRT_UUID_DECL
50bf215546Sopenharmony_ci#define __CRT_UUID_DECL(type, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
51bf215546Sopenharmony_ci   extern "C++"                                                          \
52bf215546Sopenharmony_ci   {                                                                     \
53bf215546Sopenharmony_ci      template <>                                                        \
54bf215546Sopenharmony_ci      struct __mesa_emulated_uuidof_s<type>                              \
55bf215546Sopenharmony_ci      {                                                                  \
56bf215546Sopenharmony_ci         static constexpr IID __uuid_inst = {                            \
57bf215546Sopenharmony_ci             l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}};               \
58bf215546Sopenharmony_ci      };                                                                 \
59bf215546Sopenharmony_ci      template <>                                                        \
60bf215546Sopenharmony_ci      constexpr const GUID &__mesa_emulated_uuidof<type>()               \
61bf215546Sopenharmony_ci      {                                                                  \
62bf215546Sopenharmony_ci         return __mesa_emulated_uuidof_s<type>::__uuid_inst;             \
63bf215546Sopenharmony_ci      }                                                                  \
64bf215546Sopenharmony_ci      template <>                                                        \
65bf215546Sopenharmony_ci      constexpr const GUID &__mesa_emulated_uuidof<type *>()             \
66bf215546Sopenharmony_ci      {                                                                  \
67bf215546Sopenharmony_ci         return __mesa_emulated_uuidof_s<type>::__uuid_inst;             \
68bf215546Sopenharmony_ci      }                                                                  \
69bf215546Sopenharmony_ci   }
70bf215546Sopenharmony_ci#define __uuidof(T) __mesa_emulated_uuidof<typename std::decay<T>::type>()
71bf215546Sopenharmony_ci#endif /*__CRT_UUID_DECL */
72bf215546Sopenharmony_ciconstexpr uint8_t nybble_from_hex(char c) {
73bf215546Sopenharmony_ci   return ((c >= '0' && c <= '9')
74bf215546Sopenharmony_ci               ? (c - '0')
75bf215546Sopenharmony_ci               : ((c >= 'a' && c <= 'f')
76bf215546Sopenharmony_ci                  ? (c - 'a' + 10)
77bf215546Sopenharmony_ci                  : ((c >= 'A' && c <= 'F') ? (c - 'A' + 10)
78bf215546Sopenharmony_ci                     : /* Should be an error */ -1)));
79bf215546Sopenharmony_ci}
80bf215546Sopenharmony_ci
81bf215546Sopenharmony_ciconstexpr uint8_t byte_from_hex(char c1, char c2) {
82bf215546Sopenharmony_ci   return nybble_from_hex(c1) << 4 | nybble_from_hex(c2);
83bf215546Sopenharmony_ci}
84bf215546Sopenharmony_ci
85bf215546Sopenharmony_ciconstexpr uint8_t byte_from_hexstr(const char str[2]) {
86bf215546Sopenharmony_ci   return nybble_from_hex(str[0]) << 4 | nybble_from_hex(str[1]);
87bf215546Sopenharmony_ci}
88bf215546Sopenharmony_ci
89bf215546Sopenharmony_ciconstexpr unsigned short short_from_hexstr(const char str[2], unsigned shift)
90bf215546Sopenharmony_ci{
91bf215546Sopenharmony_ci   return ((unsigned short)(nybble_from_hex(str[0]) << 4 |
92bf215546Sopenharmony_ci                            nybble_from_hex(str[1])))
93bf215546Sopenharmony_ci          << shift;
94bf215546Sopenharmony_ci}
95bf215546Sopenharmony_ci
96bf215546Sopenharmony_ciconstexpr unsigned long word_from_hexstr(const char str[2], unsigned shift)
97bf215546Sopenharmony_ci{
98bf215546Sopenharmony_ci   return ((unsigned long)(nybble_from_hex(str[0]) << 4 |
99bf215546Sopenharmony_ci                           nybble_from_hex(str[1])))
100bf215546Sopenharmony_ci          << shift;
101bf215546Sopenharmony_ci}
102bf215546Sopenharmony_ci
103bf215546Sopenharmony_ci#define CROSS_PLATFORM_UUIDOF(iface, spec)                                \
104bf215546Sopenharmony_ci   struct iface;                                                          \
105bf215546Sopenharmony_ci   __CRT_UUID_DECL(                                                       \
106bf215546Sopenharmony_ci       iface,                                                             \
107bf215546Sopenharmony_ci       word_from_hexstr(spec, 24) | word_from_hexstr(spec + 2, 16) |      \
108bf215546Sopenharmony_ci           word_from_hexstr(spec + 4, 8) | word_from_hexstr(spec + 6, 0), \
109bf215546Sopenharmony_ci       short_from_hexstr(spec + 9, 8) | short_from_hexstr(spec + 11, 0),  \
110bf215546Sopenharmony_ci       short_from_hexstr(spec + 14, 8) | short_from_hexstr(spec + 16, 0), \
111bf215546Sopenharmony_ci       byte_from_hexstr(spec + 19), byte_from_hexstr(spec + 21),          \
112bf215546Sopenharmony_ci       byte_from_hexstr(spec + 24), byte_from_hexstr(spec + 26),          \
113bf215546Sopenharmony_ci       byte_from_hexstr(spec + 28), byte_from_hexstr(spec + 30),          \
114bf215546Sopenharmony_ci       byte_from_hexstr(spec + 32), byte_from_hexstr(spec + 34))
115bf215546Sopenharmony_ci
116bf215546Sopenharmony_ci#endif /* defined(_MSC_VER) */
117bf215546Sopenharmony_ci#endif /* CROSS_PLATFORM_UUIDOF */
118bf215546Sopenharmony_ci
119bf215546Sopenharmony_ci#ifndef _WIN32
120bf215546Sopenharmony_ci
121bf215546Sopenharmony_ciCROSS_PLATFORM_UUIDOF(INoMarshal, "ECC8691B-C1DB-4DC0-855E-65F6C551AF49")
122bf215546Sopenharmony_cistruct INoMarshal : public IUnknown {};
123bf215546Sopenharmony_ci
124bf215546Sopenharmony_ciCROSS_PLATFORM_UUIDOF(IMalloc, "00000002-0000-0000-C000-000000000046")
125bf215546Sopenharmony_cistruct IMalloc : public IUnknown {
126bf215546Sopenharmony_ci   virtual void *Alloc(size_t size);
127bf215546Sopenharmony_ci   virtual void *Realloc(void *ptr, size_t size);
128bf215546Sopenharmony_ci   virtual void Free(void *ptr);
129bf215546Sopenharmony_ci   virtual HRESULT QueryInterface(REFIID riid, void **ppvObject);
130bf215546Sopenharmony_ci};
131bf215546Sopenharmony_ci
132bf215546Sopenharmony_ciCROSS_PLATFORM_UUIDOF(ISequentialStream, "0C733A30-2A1C-11CE-ADE5-00AA0044773D")
133bf215546Sopenharmony_cistruct ISequentialStream : public IUnknown {
134bf215546Sopenharmony_ci   virtual HRESULT Read(void *pv, ULONG cb, ULONG *pcbRead) = 0;
135bf215546Sopenharmony_ci   virtual HRESULT Write(const void *pv, ULONG cb, ULONG *pcbWritten) = 0;
136bf215546Sopenharmony_ci};
137bf215546Sopenharmony_ci
138bf215546Sopenharmony_ciCROSS_PLATFORM_UUIDOF(IStream, "0000000c-0000-0000-C000-000000000046")
139bf215546Sopenharmony_cistruct IStream : public ISequentialStream {
140bf215546Sopenharmony_ci   virtual HRESULT Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin,
141bf215546Sopenharmony_ci                        ULARGE_INTEGER *plibNewPosition) = 0;
142bf215546Sopenharmony_ci   virtual HRESULT SetSize(ULARGE_INTEGER libNewSize) = 0;
143bf215546Sopenharmony_ci   virtual HRESULT CopyTo(IStream *pstm, ULARGE_INTEGER cb,
144bf215546Sopenharmony_ci                          ULARGE_INTEGER *pcbRead,
145bf215546Sopenharmony_ci                          ULARGE_INTEGER *pcbWritten) = 0;
146bf215546Sopenharmony_ci
147bf215546Sopenharmony_ci   virtual HRESULT Commit(DWORD grfCommitFlags) = 0;
148bf215546Sopenharmony_ci
149bf215546Sopenharmony_ci   virtual HRESULT Revert(void) = 0;
150bf215546Sopenharmony_ci
151bf215546Sopenharmony_ci   virtual HRESULT LockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb,
152bf215546Sopenharmony_ci                              DWORD dwLockType) = 0;
153bf215546Sopenharmony_ci
154bf215546Sopenharmony_ci   virtual HRESULT UnlockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb,
155bf215546Sopenharmony_ci                                DWORD dwLockType) = 0;
156bf215546Sopenharmony_ci
157bf215546Sopenharmony_ci   virtual HRESULT Stat(STATSTG *pstatstg, DWORD grfStatFlag) = 0;
158bf215546Sopenharmony_ci
159bf215546Sopenharmony_ci   virtual HRESULT Clone(IStream **ppstm) = 0;
160bf215546Sopenharmony_ci};
161bf215546Sopenharmony_ci
162bf215546Sopenharmony_ci#endif
163bf215546Sopenharmony_ci
164bf215546Sopenharmony_cistruct IMalloc;
165bf215546Sopenharmony_ci
166bf215546Sopenharmony_cistruct IDxcIncludeHandler;
167bf215546Sopenharmony_ci
168bf215546Sopenharmony_citypedef HRESULT (__stdcall *DxcCreateInstanceProc)(
169bf215546Sopenharmony_ci    _In_ REFCLSID   rclsid,
170bf215546Sopenharmony_ci    _In_ REFIID     riid,
171bf215546Sopenharmony_ci    _Out_ LPVOID*   ppv
172bf215546Sopenharmony_ci);
173bf215546Sopenharmony_ci
174bf215546Sopenharmony_citypedef HRESULT(__stdcall *DxcCreateInstance2Proc)(
175bf215546Sopenharmony_ci  _In_ IMalloc    *pMalloc,
176bf215546Sopenharmony_ci  _In_ REFCLSID   rclsid,
177bf215546Sopenharmony_ci  _In_ REFIID     riid,
178bf215546Sopenharmony_ci  _Out_ LPVOID*   ppv
179bf215546Sopenharmony_ci  );
180bf215546Sopenharmony_ci
181bf215546Sopenharmony_ci/// <summary>
182bf215546Sopenharmony_ci/// Creates a single uninitialized object of the class associated with a specified CLSID.
183bf215546Sopenharmony_ci/// </summary>
184bf215546Sopenharmony_ci/// <param name="rclsid">
185bf215546Sopenharmony_ci/// The CLSID associated with the data and code that will be used to create the object.
186bf215546Sopenharmony_ci/// </param>
187bf215546Sopenharmony_ci/// <param name="riid">
188bf215546Sopenharmony_ci/// A reference to the identifier of the interface to be used to communicate
189bf215546Sopenharmony_ci/// with the object.
190bf215546Sopenharmony_ci/// </param>
191bf215546Sopenharmony_ci/// <param name="ppv">
192bf215546Sopenharmony_ci/// Address of pointer variable that receives the interface pointer requested
193bf215546Sopenharmony_ci/// in riid. Upon successful return, *ppv contains the requested interface
194bf215546Sopenharmony_ci/// pointer. Upon failure, *ppv contains NULL.</param>
195bf215546Sopenharmony_ci/// <remarks>
196bf215546Sopenharmony_ci/// While this function is similar to CoCreateInstance, there is no COM involvement.
197bf215546Sopenharmony_ci/// </remarks>
198bf215546Sopenharmony_ci
199bf215546Sopenharmony_ciextern "C"
200bf215546Sopenharmony_ciDXC_API_IMPORT HRESULT __stdcall DxcCreateInstance(
201bf215546Sopenharmony_ci  _In_ REFCLSID   rclsid,
202bf215546Sopenharmony_ci  _In_ REFIID     riid,
203bf215546Sopenharmony_ci  _Out_ LPVOID*   ppv
204bf215546Sopenharmony_ci  );
205bf215546Sopenharmony_ci
206bf215546Sopenharmony_ciextern "C"
207bf215546Sopenharmony_ciDXC_API_IMPORT HRESULT __stdcall DxcCreateInstance2(
208bf215546Sopenharmony_ci  _In_ IMalloc    *pMalloc,
209bf215546Sopenharmony_ci  _In_ REFCLSID   rclsid,
210bf215546Sopenharmony_ci  _In_ REFIID     riid,
211bf215546Sopenharmony_ci  _Out_ LPVOID*   ppv
212bf215546Sopenharmony_ci);
213bf215546Sopenharmony_ci
214bf215546Sopenharmony_ci// For convenience, equivalent definitions to CP_UTF8 and CP_UTF16.
215bf215546Sopenharmony_ci#define DXC_CP_UTF8 65001
216bf215546Sopenharmony_ci#define DXC_CP_UTF16 1200
217bf215546Sopenharmony_ci// Use DXC_CP_ACP for: Binary;  ANSI Text;  Autodetect UTF with BOM
218bf215546Sopenharmony_ci#define DXC_CP_ACP 0
219bf215546Sopenharmony_ci
220bf215546Sopenharmony_ci// This flag indicates that the shader hash was computed taking into account source information (-Zss)
221bf215546Sopenharmony_ci#define DXC_HASHFLAG_INCLUDES_SOURCE  1
222bf215546Sopenharmony_ci
223bf215546Sopenharmony_ci// Hash digest type for ShaderHash
224bf215546Sopenharmony_citypedef struct DxcShaderHash {
225bf215546Sopenharmony_ci  UINT32 Flags; // DXC_HASHFLAG_*
226bf215546Sopenharmony_ci  BYTE HashDigest[16];
227bf215546Sopenharmony_ci} DxcShaderHash;
228bf215546Sopenharmony_ci
229bf215546Sopenharmony_ci#define DXC_FOURCC(ch0, ch1, ch2, ch3) (                     \
230bf215546Sopenharmony_ci  (UINT32)(UINT8)(ch0)        | (UINT32)(UINT8)(ch1) << 8  | \
231bf215546Sopenharmony_ci  (UINT32)(UINT8)(ch2) << 16  | (UINT32)(UINT8)(ch3) << 24   \
232bf215546Sopenharmony_ci  )
233bf215546Sopenharmony_ci#define DXC_PART_PDB                      DXC_FOURCC('I', 'L', 'D', 'B')
234bf215546Sopenharmony_ci#define DXC_PART_PDB_NAME                 DXC_FOURCC('I', 'L', 'D', 'N')
235bf215546Sopenharmony_ci#define DXC_PART_PRIVATE_DATA             DXC_FOURCC('P', 'R', 'I', 'V')
236bf215546Sopenharmony_ci#define DXC_PART_ROOT_SIGNATURE           DXC_FOURCC('R', 'T', 'S', '0')
237bf215546Sopenharmony_ci#define DXC_PART_DXIL                     DXC_FOURCC('D', 'X', 'I', 'L')
238bf215546Sopenharmony_ci#define DXC_PART_REFLECTION_DATA          DXC_FOURCC('S', 'T', 'A', 'T')
239bf215546Sopenharmony_ci#define DXC_PART_SHADER_HASH              DXC_FOURCC('H', 'A', 'S', 'H')
240bf215546Sopenharmony_ci#define DXC_PART_INPUT_SIGNATURE          DXC_FOURCC('I', 'S', 'G', '1')
241bf215546Sopenharmony_ci#define DXC_PART_OUTPUT_SIGNATURE         DXC_FOURCC('O', 'S', 'G', '1')
242bf215546Sopenharmony_ci#define DXC_PART_PATCH_CONSTANT_SIGNATURE DXC_FOURCC('P', 'S', 'G', '1')
243bf215546Sopenharmony_ci
244bf215546Sopenharmony_ci// Some option arguments are defined here for continuity with D3DCompile interface
245bf215546Sopenharmony_ci#define DXC_ARG_DEBUG L"-Zi"
246bf215546Sopenharmony_ci#define DXC_ARG_SKIP_VALIDATION L"-Vd"
247bf215546Sopenharmony_ci#define DXC_ARG_SKIP_OPTIMIZATIONS L"-Od"
248bf215546Sopenharmony_ci#define DXC_ARG_PACK_MATRIX_ROW_MAJOR L"-Zpr"
249bf215546Sopenharmony_ci#define DXC_ARG_PACK_MATRIX_COLUMN_MAJOR L"-Zpc"
250bf215546Sopenharmony_ci#define DXC_ARG_AVOID_FLOW_CONTROL L"-Gfa"
251bf215546Sopenharmony_ci#define DXC_ARG_PREFER_FLOW_CONTROL L"-Gfp"
252bf215546Sopenharmony_ci#define DXC_ARG_ENABLE_STRICTNESS L"-Ges"
253bf215546Sopenharmony_ci#define DXC_ARG_ENABLE_BACKWARDS_COMPATIBILITY L"-Gec"
254bf215546Sopenharmony_ci#define DXC_ARG_IEEE_STRICTNESS L"-Gis"
255bf215546Sopenharmony_ci#define DXC_ARG_OPTIMIZATION_LEVEL0 L"-O0"
256bf215546Sopenharmony_ci#define DXC_ARG_OPTIMIZATION_LEVEL1 L"-O1"
257bf215546Sopenharmony_ci#define DXC_ARG_OPTIMIZATION_LEVEL2 L"-O2"
258bf215546Sopenharmony_ci#define DXC_ARG_OPTIMIZATION_LEVEL3 L"-O3"
259bf215546Sopenharmony_ci#define DXC_ARG_WARNINGS_ARE_ERRORS L"-WX"
260bf215546Sopenharmony_ci#define DXC_ARG_RESOURCES_MAY_ALIAS L"-res_may_alias"
261bf215546Sopenharmony_ci#define DXC_ARG_ALL_RESOURCES_BOUND L"-all_resources_bound"
262bf215546Sopenharmony_ci#define DXC_ARG_DEBUG_NAME_FOR_SOURCE L"-Zss"
263bf215546Sopenharmony_ci#define DXC_ARG_DEBUG_NAME_FOR_BINARY L"-Zsb"
264bf215546Sopenharmony_ci
265bf215546Sopenharmony_ci// IDxcBlob is an alias of ID3D10Blob and ID3DBlob
266bf215546Sopenharmony_ciCROSS_PLATFORM_UUIDOF(IDxcBlob, "8BA5FB08-5195-40e2-AC58-0D989C3A0102")
267bf215546Sopenharmony_cistruct IDxcBlob : public IUnknown {
268bf215546Sopenharmony_cipublic:
269bf215546Sopenharmony_ci  virtual LPVOID STDMETHODCALLTYPE GetBufferPointer(void) = 0;
270bf215546Sopenharmony_ci  virtual SIZE_T STDMETHODCALLTYPE GetBufferSize(void) = 0;
271bf215546Sopenharmony_ci};
272bf215546Sopenharmony_ci
273bf215546Sopenharmony_ciCROSS_PLATFORM_UUIDOF(IDxcBlobEncoding, "7241d424-2646-4191-97c0-98e96e42fc68")
274bf215546Sopenharmony_cistruct IDxcBlobEncoding : public IDxcBlob {
275bf215546Sopenharmony_cipublic:
276bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE GetEncoding(_Out_ BOOL *pKnown,
277bf215546Sopenharmony_ci                                                _Out_ UINT32 *pCodePage) = 0;
278bf215546Sopenharmony_ci};
279bf215546Sopenharmony_ci
280bf215546Sopenharmony_ci// Notes on IDxcBlobUtf16 and IDxcBlobUtf8
281bf215546Sopenharmony_ci// These guarantee null-terminated text and the stated encoding.
282bf215546Sopenharmony_ci// GetBufferSize() will return the size in bytes, including null-terminator
283bf215546Sopenharmony_ci// GetStringLength() will return the length in characters, excluding the null-terminator
284bf215546Sopenharmony_ci// Name strings will use IDxcBlobUtf16, while other string output blobs,
285bf215546Sopenharmony_ci// such as errors/warnings, preprocessed HLSL, or other text will be based
286bf215546Sopenharmony_ci// on the -encoding option.
287bf215546Sopenharmony_ci
288bf215546Sopenharmony_ci// The API will use this interface for output name strings
289bf215546Sopenharmony_ciCROSS_PLATFORM_UUIDOF(IDxcBlobUtf16, "A3F84EAB-0FAA-497E-A39C-EE6ED60B2D84")
290bf215546Sopenharmony_cistruct IDxcBlobUtf16 : public IDxcBlobEncoding {
291bf215546Sopenharmony_cipublic:
292bf215546Sopenharmony_ci  virtual LPCWSTR STDMETHODCALLTYPE GetStringPointer(void) = 0;
293bf215546Sopenharmony_ci  virtual SIZE_T STDMETHODCALLTYPE GetStringLength(void) = 0;
294bf215546Sopenharmony_ci};
295bf215546Sopenharmony_ciCROSS_PLATFORM_UUIDOF(IDxcBlobUtf8, "3DA636C9-BA71-4024-A301-30CBF125305B")
296bf215546Sopenharmony_cistruct IDxcBlobUtf8 : public IDxcBlobEncoding {
297bf215546Sopenharmony_cipublic:
298bf215546Sopenharmony_ci  virtual LPCSTR STDMETHODCALLTYPE GetStringPointer(void) = 0;
299bf215546Sopenharmony_ci  virtual SIZE_T STDMETHODCALLTYPE GetStringLength(void) = 0;
300bf215546Sopenharmony_ci};
301bf215546Sopenharmony_ci
302bf215546Sopenharmony_ciCROSS_PLATFORM_UUIDOF(IDxcIncludeHandler, "7f61fc7d-950d-467f-b3e3-3c02fb49187c")
303bf215546Sopenharmony_cistruct IDxcIncludeHandler : public IUnknown {
304bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE LoadSource(
305bf215546Sopenharmony_ci    _In_z_ LPCWSTR pFilename,                                 // Candidate filename.
306bf215546Sopenharmony_ci    _COM_Outptr_result_maybenull_ IDxcBlob **ppIncludeSource  // Resultant source object for included file, nullptr if not found.
307bf215546Sopenharmony_ci    ) = 0;
308bf215546Sopenharmony_ci};
309bf215546Sopenharmony_ci
310bf215546Sopenharmony_ci// Structure for supplying bytes or text input to Dxc APIs.
311bf215546Sopenharmony_ci// Use Encoding = 0 for non-text bytes, ANSI text, or unknown with BOM.
312bf215546Sopenharmony_citypedef struct DxcBuffer {
313bf215546Sopenharmony_ci  LPCVOID Ptr;
314bf215546Sopenharmony_ci  SIZE_T Size;
315bf215546Sopenharmony_ci  UINT Encoding;
316bf215546Sopenharmony_ci} DxcText;
317bf215546Sopenharmony_ci
318bf215546Sopenharmony_cistruct DxcDefine {
319bf215546Sopenharmony_ci  LPCWSTR Name;
320bf215546Sopenharmony_ci  _Maybenull_ LPCWSTR Value;
321bf215546Sopenharmony_ci};
322bf215546Sopenharmony_ci
323bf215546Sopenharmony_ciCROSS_PLATFORM_UUIDOF(IDxcCompilerArgs, "73EFFE2A-70DC-45F8-9690-EFF64C02429D")
324bf215546Sopenharmony_cistruct IDxcCompilerArgs : public IUnknown {
325bf215546Sopenharmony_ci  // Pass GetArguments() and GetCount() to Compile
326bf215546Sopenharmony_ci  virtual LPCWSTR* STDMETHODCALLTYPE GetArguments() = 0;
327bf215546Sopenharmony_ci  virtual UINT32 STDMETHODCALLTYPE GetCount() = 0;
328bf215546Sopenharmony_ci
329bf215546Sopenharmony_ci  // Add additional arguments or defines here, if desired.
330bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE AddArguments(
331bf215546Sopenharmony_ci    _In_opt_count_(argCount) LPCWSTR *pArguments,       // Array of pointers to arguments to add
332bf215546Sopenharmony_ci    _In_ UINT32 argCount                                // Number of arguments to add
333bf215546Sopenharmony_ci  ) = 0;
334bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE AddArgumentsUTF8(
335bf215546Sopenharmony_ci    _In_opt_count_(argCount)LPCSTR *pArguments,         // Array of pointers to UTF-8 arguments to add
336bf215546Sopenharmony_ci    _In_ UINT32 argCount                                // Number of arguments to add
337bf215546Sopenharmony_ci  ) = 0;
338bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE AddDefines(
339bf215546Sopenharmony_ci      _In_count_(defineCount) const DxcDefine *pDefines, // Array of defines
340bf215546Sopenharmony_ci      _In_ UINT32 defineCount                            // Number of defines
341bf215546Sopenharmony_ci  ) = 0;
342bf215546Sopenharmony_ci};
343bf215546Sopenharmony_ci
344bf215546Sopenharmony_ci//////////////////////////
345bf215546Sopenharmony_ci// Legacy Interfaces
346bf215546Sopenharmony_ci/////////////////////////
347bf215546Sopenharmony_ci
348bf215546Sopenharmony_ci// NOTE: IDxcUtils replaces IDxcLibrary
349bf215546Sopenharmony_ciCROSS_PLATFORM_UUIDOF(IDxcLibrary, "e5204dc7-d18c-4c3c-bdfb-851673980fe7")
350bf215546Sopenharmony_cistruct IDxcLibrary : public IUnknown {
351bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE SetMalloc(_In_opt_ IMalloc *pMalloc) = 0;
352bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE CreateBlobFromBlob(
353bf215546Sopenharmony_ci    _In_ IDxcBlob *pBlob, UINT32 offset, UINT32 length, _COM_Outptr_ IDxcBlob **ppResult) = 0;
354bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE CreateBlobFromFile(
355bf215546Sopenharmony_ci    _In_z_ LPCWSTR pFileName, _In_opt_ UINT32* codePage,
356bf215546Sopenharmony_ci    _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;
357bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE CreateBlobWithEncodingFromPinned(
358bf215546Sopenharmony_ci    _In_bytecount_(size) LPCVOID pText, UINT32 size, UINT32 codePage,
359bf215546Sopenharmony_ci    _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;
360bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE CreateBlobWithEncodingOnHeapCopy(
361bf215546Sopenharmony_ci    _In_bytecount_(size) LPCVOID pText, UINT32 size, UINT32 codePage,
362bf215546Sopenharmony_ci    _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;
363bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE CreateBlobWithEncodingOnMalloc(
364bf215546Sopenharmony_ci    _In_bytecount_(size) LPCVOID pText, IMalloc *pIMalloc, UINT32 size, UINT32 codePage,
365bf215546Sopenharmony_ci    _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;
366bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE CreateIncludeHandler(
367bf215546Sopenharmony_ci    _COM_Outptr_ IDxcIncludeHandler **ppResult) = 0;
368bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE CreateStreamFromBlobReadOnly(
369bf215546Sopenharmony_ci    _In_ IDxcBlob *pBlob, _COM_Outptr_ IStream **ppStream) = 0;
370bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE GetBlobAsUtf8(
371bf215546Sopenharmony_ci    _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;
372bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE GetBlobAsUtf16(
373bf215546Sopenharmony_ci    _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;
374bf215546Sopenharmony_ci};
375bf215546Sopenharmony_ci
376bf215546Sopenharmony_ci// NOTE: IDxcResult replaces IDxcOperationResult
377bf215546Sopenharmony_ciCROSS_PLATFORM_UUIDOF(IDxcOperationResult, "CEDB484A-D4E9-445A-B991-CA21CA157DC2")
378bf215546Sopenharmony_cistruct IDxcOperationResult : public IUnknown {
379bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE GetStatus(_Out_ HRESULT *pStatus) = 0;
380bf215546Sopenharmony_ci
381bf215546Sopenharmony_ci  // GetResult returns the main result of the operation.
382bf215546Sopenharmony_ci  // This corresponds to:
383bf215546Sopenharmony_ci  // DXC_OUT_OBJECT - Compile() with shader or library target
384bf215546Sopenharmony_ci  // DXC_OUT_DISASSEMBLY - Disassemble()
385bf215546Sopenharmony_ci  // DXC_OUT_HLSL - Compile() with -P
386bf215546Sopenharmony_ci  // DXC_OUT_ROOT_SIGNATURE - Compile() with rootsig_* target
387bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE GetResult(_COM_Outptr_result_maybenull_ IDxcBlob **ppResult) = 0;
388bf215546Sopenharmony_ci
389bf215546Sopenharmony_ci  // GetErrorBuffer Corresponds to DXC_OUT_ERRORS.
390bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE GetErrorBuffer(_COM_Outptr_result_maybenull_ IDxcBlobEncoding **ppErrors) = 0;
391bf215546Sopenharmony_ci};
392bf215546Sopenharmony_ci
393bf215546Sopenharmony_ci// NOTE: IDxcCompiler3 replaces IDxcCompiler and IDxcCompiler2
394bf215546Sopenharmony_ciCROSS_PLATFORM_UUIDOF(IDxcCompiler, "8c210bf3-011f-4422-8d70-6f9acb8db617")
395bf215546Sopenharmony_cistruct IDxcCompiler : public IUnknown {
396bf215546Sopenharmony_ci  // Compile a single entry point to the target shader model
397bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE Compile(
398bf215546Sopenharmony_ci    _In_ IDxcBlob *pSource,                       // Source text to compile
399bf215546Sopenharmony_ci    _In_opt_z_ LPCWSTR pSourceName,               // Optional file name for pSource. Used in errors and include handlers.
400bf215546Sopenharmony_ci    _In_opt_z_ LPCWSTR pEntryPoint,               // entry point name
401bf215546Sopenharmony_ci    _In_z_ LPCWSTR pTargetProfile,                // shader profile to compile
402bf215546Sopenharmony_ci    _In_opt_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments
403bf215546Sopenharmony_ci    _In_ UINT32 argCount,                         // Number of arguments
404bf215546Sopenharmony_ci    _In_count_(defineCount)
405bf215546Sopenharmony_ci      const DxcDefine *pDefines,                  // Array of defines
406bf215546Sopenharmony_ci    _In_ UINT32 defineCount,                      // Number of defines
407bf215546Sopenharmony_ci    _In_opt_ IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle #include directives (optional)
408bf215546Sopenharmony_ci    _COM_Outptr_ IDxcOperationResult **ppResult   // Compiler output status, buffer, and errors
409bf215546Sopenharmony_ci  ) = 0;
410bf215546Sopenharmony_ci
411bf215546Sopenharmony_ci  // Preprocess source text
412bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE Preprocess(
413bf215546Sopenharmony_ci    _In_ IDxcBlob *pSource,                       // Source text to preprocess
414bf215546Sopenharmony_ci    _In_opt_z_ LPCWSTR pSourceName,               // Optional file name for pSource. Used in errors and include handlers.
415bf215546Sopenharmony_ci    _In_opt_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments
416bf215546Sopenharmony_ci    _In_ UINT32 argCount,                         // Number of arguments
417bf215546Sopenharmony_ci    _In_count_(defineCount)
418bf215546Sopenharmony_ci      const DxcDefine *pDefines,                  // Array of defines
419bf215546Sopenharmony_ci    _In_ UINT32 defineCount,                      // Number of defines
420bf215546Sopenharmony_ci    _In_opt_ IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle #include directives (optional)
421bf215546Sopenharmony_ci    _COM_Outptr_ IDxcOperationResult **ppResult   // Preprocessor output status, buffer, and errors
422bf215546Sopenharmony_ci  ) = 0;
423bf215546Sopenharmony_ci
424bf215546Sopenharmony_ci  // Disassemble a program.
425bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE Disassemble(
426bf215546Sopenharmony_ci    _In_ IDxcBlob *pSource,                         // Program to disassemble.
427bf215546Sopenharmony_ci    _COM_Outptr_ IDxcBlobEncoding **ppDisassembly   // Disassembly text.
428bf215546Sopenharmony_ci    ) = 0;
429bf215546Sopenharmony_ci};
430bf215546Sopenharmony_ci
431bf215546Sopenharmony_ci// NOTE: IDxcCompiler3 replaces IDxcCompiler and IDxcCompiler2
432bf215546Sopenharmony_ciCROSS_PLATFORM_UUIDOF(IDxcCompiler2, "A005A9D9-B8BB-4594-B5C9-0E633BEC4D37")
433bf215546Sopenharmony_cistruct IDxcCompiler2 : public IDxcCompiler {
434bf215546Sopenharmony_ci  // Compile a single entry point to the target shader model with debug information.
435bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE CompileWithDebug(
436bf215546Sopenharmony_ci    _In_ IDxcBlob *pSource,                       // Source text to compile
437bf215546Sopenharmony_ci    _In_opt_z_ LPCWSTR pSourceName,               // Optional file name for pSource. Used in errors and include handlers.
438bf215546Sopenharmony_ci    _In_opt_z_ LPCWSTR pEntryPoint,               // Entry point name
439bf215546Sopenharmony_ci    _In_z_ LPCWSTR pTargetProfile,                // Shader profile to compile
440bf215546Sopenharmony_ci    _In_opt_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments
441bf215546Sopenharmony_ci    _In_ UINT32 argCount,                         // Number of arguments
442bf215546Sopenharmony_ci    _In_count_(defineCount)
443bf215546Sopenharmony_ci      const DxcDefine *pDefines,                  // Array of defines
444bf215546Sopenharmony_ci    _In_ UINT32 defineCount,                      // Number of defines
445bf215546Sopenharmony_ci    _In_opt_ IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle #include directives (optional)
446bf215546Sopenharmony_ci    _COM_Outptr_ IDxcOperationResult **ppResult,  // Compiler output status, buffer, and errors
447bf215546Sopenharmony_ci    _Outptr_opt_result_z_ LPWSTR *ppDebugBlobName,// Suggested file name for debug blob. (Must be HeapFree()'d!)
448bf215546Sopenharmony_ci    _COM_Outptr_opt_ IDxcBlob **ppDebugBlob       // Debug blob
449bf215546Sopenharmony_ci  ) = 0;
450bf215546Sopenharmony_ci};
451bf215546Sopenharmony_ci
452bf215546Sopenharmony_ciCROSS_PLATFORM_UUIDOF(IDxcLinker, "F1B5BE2A-62DD-4327-A1C2-42AC1E1E78E6")
453bf215546Sopenharmony_cistruct IDxcLinker : public IUnknown {
454bf215546Sopenharmony_cipublic:
455bf215546Sopenharmony_ci  // Register a library with name to ref it later.
456bf215546Sopenharmony_ci  virtual HRESULT RegisterLibrary(
457bf215546Sopenharmony_ci    _In_opt_ LPCWSTR pLibName,          // Name of the library.
458bf215546Sopenharmony_ci    _In_ IDxcBlob *pLib                 // Library blob.
459bf215546Sopenharmony_ci  ) = 0;
460bf215546Sopenharmony_ci
461bf215546Sopenharmony_ci  // Links the shader and produces a shader blob that the Direct3D runtime can
462bf215546Sopenharmony_ci  // use.
463bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE Link(
464bf215546Sopenharmony_ci    _In_opt_ LPCWSTR pEntryName,        // Entry point name
465bf215546Sopenharmony_ci    _In_ LPCWSTR pTargetProfile,        // shader profile to link
466bf215546Sopenharmony_ci    _In_count_(libCount)
467bf215546Sopenharmony_ci        const LPCWSTR *pLibNames,       // Array of library names to link
468bf215546Sopenharmony_ci    _In_ UINT32 libCount,               // Number of libraries to link
469bf215546Sopenharmony_ci    _In_opt_count_(argCount) const LPCWSTR *pArguments, // Array of pointers to arguments
470bf215546Sopenharmony_ci    _In_ UINT32 argCount,               // Number of arguments
471bf215546Sopenharmony_ci    _COM_Outptr_
472bf215546Sopenharmony_ci        IDxcOperationResult **ppResult  // Linker output status, buffer, and errors
473bf215546Sopenharmony_ci  ) = 0;
474bf215546Sopenharmony_ci};
475bf215546Sopenharmony_ci
476bf215546Sopenharmony_ci/////////////////////////
477bf215546Sopenharmony_ci// Latest interfaces. Please use these
478bf215546Sopenharmony_ci////////////////////////
479bf215546Sopenharmony_ci
480bf215546Sopenharmony_ci// NOTE: IDxcUtils replaces IDxcLibrary
481bf215546Sopenharmony_ciCROSS_PLATFORM_UUIDOF(IDxcUtils, "4605C4CB-2019-492A-ADA4-65F20BB7D67F")
482bf215546Sopenharmony_cistruct IDxcUtils : public IUnknown {
483bf215546Sopenharmony_ci  // Create a sub-blob that holds a reference to the outer blob and points to its memory.
484bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE CreateBlobFromBlob(
485bf215546Sopenharmony_ci    _In_ IDxcBlob *pBlob, UINT32 offset, UINT32 length, _COM_Outptr_ IDxcBlob **ppResult) = 0;
486bf215546Sopenharmony_ci
487bf215546Sopenharmony_ci  // For codePage, use 0 (or DXC_CP_ACP) for raw binary or ANSI code page
488bf215546Sopenharmony_ci
489bf215546Sopenharmony_ci  // Creates a blob referencing existing memory, with no copy.
490bf215546Sopenharmony_ci  // User must manage the memory lifetime separately.
491bf215546Sopenharmony_ci  // (was: CreateBlobWithEncodingFromPinned)
492bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE CreateBlobFromPinned(
493bf215546Sopenharmony_ci    _In_bytecount_(size) LPCVOID pData, UINT32 size, UINT32 codePage,
494bf215546Sopenharmony_ci    _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;
495bf215546Sopenharmony_ci
496bf215546Sopenharmony_ci  // Create blob, taking ownership of memory allocated with supplied allocator.
497bf215546Sopenharmony_ci  // (was: CreateBlobWithEncodingOnMalloc)
498bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE MoveToBlob(
499bf215546Sopenharmony_ci    _In_bytecount_(size) LPCVOID pData, IMalloc *pIMalloc, UINT32 size, UINT32 codePage,
500bf215546Sopenharmony_ci    _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;
501bf215546Sopenharmony_ci
502bf215546Sopenharmony_ci  ////
503bf215546Sopenharmony_ci  // New blobs and copied contents are allocated with the current allocator
504bf215546Sopenharmony_ci
505bf215546Sopenharmony_ci  // Copy blob contents to memory owned by the new blob.
506bf215546Sopenharmony_ci  // (was: CreateBlobWithEncodingOnHeapCopy)
507bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE CreateBlob(
508bf215546Sopenharmony_ci    _In_bytecount_(size) LPCVOID pData, UINT32 size, UINT32 codePage,
509bf215546Sopenharmony_ci    _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;
510bf215546Sopenharmony_ci
511bf215546Sopenharmony_ci  // (was: CreateBlobFromFile)
512bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE LoadFile(
513bf215546Sopenharmony_ci    _In_z_ LPCWSTR pFileName, _In_opt_ UINT32* pCodePage,
514bf215546Sopenharmony_ci    _COM_Outptr_ IDxcBlobEncoding **pBlobEncoding) = 0;
515bf215546Sopenharmony_ci
516bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE CreateReadOnlyStreamFromBlob(
517bf215546Sopenharmony_ci    _In_ IDxcBlob *pBlob, _COM_Outptr_ IStream **ppStream) = 0;
518bf215546Sopenharmony_ci
519bf215546Sopenharmony_ci  // Create default file-based include handler
520bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE CreateDefaultIncludeHandler(
521bf215546Sopenharmony_ci    _COM_Outptr_ IDxcIncludeHandler **ppResult) = 0;
522bf215546Sopenharmony_ci
523bf215546Sopenharmony_ci  // Convert or return matching encoded text blobs
524bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE GetBlobAsUtf8(
525bf215546Sopenharmony_ci    _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobUtf8 **pBlobEncoding) = 0;
526bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE GetBlobAsUtf16(
527bf215546Sopenharmony_ci    _In_ IDxcBlob *pBlob, _COM_Outptr_ IDxcBlobUtf16 **pBlobEncoding) = 0;
528bf215546Sopenharmony_ci
529bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE GetDxilContainerPart(
530bf215546Sopenharmony_ci    _In_ const DxcBuffer *pShader,
531bf215546Sopenharmony_ci    _In_ UINT32 DxcPart,
532bf215546Sopenharmony_ci    _Outptr_result_nullonfailure_ void **ppPartData,
533bf215546Sopenharmony_ci    _Out_ UINT32 *pPartSizeInBytes) = 0;
534bf215546Sopenharmony_ci
535bf215546Sopenharmony_ci  // Create reflection interface from serialized Dxil container, or DXC_PART_REFLECTION_DATA.
536bf215546Sopenharmony_ci  // TBD: Require part header for RDAT?  (leaning towards yes)
537bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE CreateReflection(
538bf215546Sopenharmony_ci    _In_ const DxcBuffer *pData, REFIID iid, void **ppvReflection) = 0;
539bf215546Sopenharmony_ci
540bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE BuildArguments(
541bf215546Sopenharmony_ci    _In_opt_z_ LPCWSTR pSourceName,               // Optional file name for pSource. Used in errors and include handlers.
542bf215546Sopenharmony_ci    _In_opt_z_ LPCWSTR pEntryPoint,               // Entry point name. (-E)
543bf215546Sopenharmony_ci    _In_z_ LPCWSTR pTargetProfile,                // Shader profile to compile. (-T)
544bf215546Sopenharmony_ci    _In_opt_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments
545bf215546Sopenharmony_ci    _In_ UINT32 argCount,                         // Number of arguments
546bf215546Sopenharmony_ci    _In_count_(defineCount)
547bf215546Sopenharmony_ci      const DxcDefine *pDefines,                  // Array of defines
548bf215546Sopenharmony_ci    _In_ UINT32 defineCount,                      // Number of defines
549bf215546Sopenharmony_ci    _COM_Outptr_ IDxcCompilerArgs **ppArgs        // Arguments you can use with Compile() method
550bf215546Sopenharmony_ci  ) = 0;
551bf215546Sopenharmony_ci
552bf215546Sopenharmony_ci  // Takes the shader PDB and returns the hash and the container inside it
553bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE GetPDBContents(
554bf215546Sopenharmony_ci    _In_ IDxcBlob *pPDBBlob, _COM_Outptr_ IDxcBlob **ppHash, _COM_Outptr_ IDxcBlob **ppContainer) = 0;
555bf215546Sopenharmony_ci};
556bf215546Sopenharmony_ci
557bf215546Sopenharmony_ci// For use with IDxcResult::[Has|Get]Output dxcOutKind argument
558bf215546Sopenharmony_ci// Note: text outputs returned from version 2 APIs are UTF-8 or UTF-16 based on -encoding option
559bf215546Sopenharmony_citypedef enum DXC_OUT_KIND {
560bf215546Sopenharmony_ci  DXC_OUT_NONE = 0,
561bf215546Sopenharmony_ci  DXC_OUT_OBJECT = 1,         // IDxcBlob - Shader or library object
562bf215546Sopenharmony_ci  DXC_OUT_ERRORS = 2,         // IDxcBlobUtf8 or IDxcBlobUtf16
563bf215546Sopenharmony_ci  DXC_OUT_PDB = 3,            // IDxcBlob
564bf215546Sopenharmony_ci  DXC_OUT_SHADER_HASH = 4,    // IDxcBlob - DxcShaderHash of shader or shader with source info (-Zsb/-Zss)
565bf215546Sopenharmony_ci  DXC_OUT_DISASSEMBLY = 5,    // IDxcBlobUtf8 or IDxcBlobUtf16 - from Disassemble
566bf215546Sopenharmony_ci  DXC_OUT_HLSL = 6,           // IDxcBlobUtf8 or IDxcBlobUtf16 - from Preprocessor or Rewriter
567bf215546Sopenharmony_ci  DXC_OUT_TEXT = 7,           // IDxcBlobUtf8 or IDxcBlobUtf16 - other text, such as -ast-dump or -Odump
568bf215546Sopenharmony_ci  DXC_OUT_REFLECTION = 8,     // IDxcBlob - RDAT part with reflection data
569bf215546Sopenharmony_ci  DXC_OUT_ROOT_SIGNATURE = 9, // IDxcBlob - Serialized root signature output
570bf215546Sopenharmony_ci  DXC_OUT_EXTRA_OUTPUTS  = 10,// IDxcExtraResults - Extra outputs
571bf215546Sopenharmony_ci
572bf215546Sopenharmony_ci  DXC_OUT_FORCE_DWORD = 0xFFFFFFFF
573bf215546Sopenharmony_ci} DXC_OUT_KIND;
574bf215546Sopenharmony_ci
575bf215546Sopenharmony_ciCROSS_PLATFORM_UUIDOF(IDxcResult, "58346CDA-DDE7-4497-9461-6F87AF5E0659")
576bf215546Sopenharmony_cistruct IDxcResult : public IDxcOperationResult {
577bf215546Sopenharmony_ci  virtual BOOL STDMETHODCALLTYPE HasOutput(_In_ DXC_OUT_KIND dxcOutKind) = 0;
578bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE GetOutput(_In_ DXC_OUT_KIND dxcOutKind,
579bf215546Sopenharmony_ci    _In_ REFIID iid, _COM_Outptr_opt_result_maybenull_ void **ppvObject,
580bf215546Sopenharmony_ci    _COM_Outptr_ IDxcBlobUtf16 **ppOutputName) = 0;
581bf215546Sopenharmony_ci
582bf215546Sopenharmony_ci  virtual UINT32 GetNumOutputs() = 0;
583bf215546Sopenharmony_ci  virtual DXC_OUT_KIND GetOutputByIndex(UINT32 Index) = 0;
584bf215546Sopenharmony_ci  virtual DXC_OUT_KIND PrimaryOutput() = 0;
585bf215546Sopenharmony_ci};
586bf215546Sopenharmony_ci
587bf215546Sopenharmony_ci// Special names for extra output that should get written to specific streams
588bf215546Sopenharmony_ci#define DXC_EXTRA_OUTPUT_NAME_STDOUT L"*stdout*"
589bf215546Sopenharmony_ci#define DXC_EXTRA_OUTPUT_NAME_STDERR L"*stderr*"
590bf215546Sopenharmony_ci
591bf215546Sopenharmony_ciCROSS_PLATFORM_UUIDOF(IDxcExtraOutputs, "319b37a2-a5c2-494a-a5de-4801b2faf989")
592bf215546Sopenharmony_cistruct IDxcExtraOutputs : public IUnknown {
593bf215546Sopenharmony_ci
594bf215546Sopenharmony_ci  virtual UINT32 STDMETHODCALLTYPE GetOutputCount() = 0;
595bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE GetOutput(_In_ UINT32 uIndex,
596bf215546Sopenharmony_ci    _In_ REFIID iid, _COM_Outptr_opt_result_maybenull_ void **ppvObject,
597bf215546Sopenharmony_ci    _COM_Outptr_opt_result_maybenull_ IDxcBlobUtf16 **ppOutputType,
598bf215546Sopenharmony_ci    _COM_Outptr_opt_result_maybenull_ IDxcBlobUtf16 **ppOutputName) = 0;
599bf215546Sopenharmony_ci};
600bf215546Sopenharmony_ci
601bf215546Sopenharmony_ciCROSS_PLATFORM_UUIDOF(IDxcCompiler3, "228B4687-5A6A-4730-900C-9702B2203F54")
602bf215546Sopenharmony_cistruct IDxcCompiler3 : public IUnknown {
603bf215546Sopenharmony_ci  // Compile a single entry point to the target shader model,
604bf215546Sopenharmony_ci  // Compile a library to a library target (-T lib_*),
605bf215546Sopenharmony_ci  // Compile a root signature (-T rootsig_*), or
606bf215546Sopenharmony_ci  // Preprocess HLSL source (-P)
607bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE Compile(
608bf215546Sopenharmony_ci    _In_ const DxcBuffer *pSource,                // Source text to compile
609bf215546Sopenharmony_ci    _In_opt_count_(argCount) LPCWSTR *pArguments, // Array of pointers to arguments
610bf215546Sopenharmony_ci    _In_ UINT32 argCount,                         // Number of arguments
611bf215546Sopenharmony_ci    _In_opt_ IDxcIncludeHandler *pIncludeHandler, // user-provided interface to handle #include directives (optional)
612bf215546Sopenharmony_ci    _In_ REFIID riid, _Out_ LPVOID *ppResult      // IDxcResult: status, buffer, and errors
613bf215546Sopenharmony_ci  ) = 0;
614bf215546Sopenharmony_ci
615bf215546Sopenharmony_ci  // Disassemble a program.
616bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE Disassemble(
617bf215546Sopenharmony_ci    _In_ const DxcBuffer *pObject,                // Program to disassemble: dxil container or bitcode.
618bf215546Sopenharmony_ci    _In_ REFIID riid, _Out_ LPVOID *ppResult      // IDxcResult: status, disassembly text, and errors
619bf215546Sopenharmony_ci    ) = 0;
620bf215546Sopenharmony_ci};
621bf215546Sopenharmony_ci
622bf215546Sopenharmony_cistatic const UINT32 DxcValidatorFlags_Default = 0;
623bf215546Sopenharmony_cistatic const UINT32 DxcValidatorFlags_InPlaceEdit = 1;  // Validator is allowed to update shader blob in-place.
624bf215546Sopenharmony_cistatic const UINT32 DxcValidatorFlags_RootSignatureOnly = 2;
625bf215546Sopenharmony_cistatic const UINT32 DxcValidatorFlags_ModuleOnly = 4;
626bf215546Sopenharmony_cistatic const UINT32 DxcValidatorFlags_ValidMask = 0x7;
627bf215546Sopenharmony_ci
628bf215546Sopenharmony_ciCROSS_PLATFORM_UUIDOF(IDxcValidator, "A6E82BD2-1FD7-4826-9811-2857E797F49A")
629bf215546Sopenharmony_cistruct IDxcValidator : public IUnknown {
630bf215546Sopenharmony_ci  // Validate a shader.
631bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE Validate(
632bf215546Sopenharmony_ci    _In_ IDxcBlob *pShader,                       // Shader to validate.
633bf215546Sopenharmony_ci    _In_ UINT32 Flags,                            // Validation flags.
634bf215546Sopenharmony_ci    _COM_Outptr_ IDxcOperationResult **ppResult   // Validation output status, buffer, and errors
635bf215546Sopenharmony_ci    ) = 0;
636bf215546Sopenharmony_ci};
637bf215546Sopenharmony_ci
638bf215546Sopenharmony_ciCROSS_PLATFORM_UUIDOF(IDxcContainerBuilder, "334b1f50-2292-4b35-99a1-25588d8c17fe")
639bf215546Sopenharmony_cistruct IDxcContainerBuilder : public IUnknown {
640bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE Load(_In_ IDxcBlob *pDxilContainerHeader) = 0;                // Loads DxilContainer to the builder
641bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE AddPart(_In_ UINT32 fourCC, _In_ IDxcBlob *pSource) = 0;      // Part to add to the container
642bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE RemovePart(_In_ UINT32 fourCC) = 0;                           // Remove the part with fourCC
643bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE SerializeContainer(_Out_ IDxcOperationResult **ppResult) = 0; // Builds a container of the given container builder state
644bf215546Sopenharmony_ci};
645bf215546Sopenharmony_ci
646bf215546Sopenharmony_ciCROSS_PLATFORM_UUIDOF(IDxcAssembler, "091f7a26-1c1f-4948-904b-e6e3a8a771d5")
647bf215546Sopenharmony_cistruct IDxcAssembler : public IUnknown {
648bf215546Sopenharmony_ci  // Assemble dxil in ll or llvm bitcode to DXIL container.
649bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE AssembleToContainer(
650bf215546Sopenharmony_ci    _In_ IDxcBlob *pShader,                       // Shader to assemble.
651bf215546Sopenharmony_ci    _COM_Outptr_ IDxcOperationResult **ppResult   // Assembly output status, buffer, and errors
652bf215546Sopenharmony_ci    ) = 0;
653bf215546Sopenharmony_ci};
654bf215546Sopenharmony_ci
655bf215546Sopenharmony_ciCROSS_PLATFORM_UUIDOF(IDxcContainerReflection, "d2c21b26-8350-4bdc-976a-331ce6f4c54c")
656bf215546Sopenharmony_cistruct IDxcContainerReflection : public IUnknown {
657bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE Load(_In_ IDxcBlob *pContainer) = 0; // Container to load.
658bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE GetPartCount(_Out_ UINT32 *pResult) = 0;
659bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE GetPartKind(UINT32 idx, _Out_ UINT32 *pResult) = 0;
660bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE GetPartContent(UINT32 idx, _COM_Outptr_ IDxcBlob **ppResult) = 0;
661bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE FindFirstPartKind(UINT32 kind, _Out_ UINT32 *pResult) = 0;
662bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE GetPartReflection(UINT32 idx, REFIID iid, void **ppvObject) = 0;
663bf215546Sopenharmony_ci};
664bf215546Sopenharmony_ci
665bf215546Sopenharmony_ciCROSS_PLATFORM_UUIDOF(IDxcOptimizerPass, "AE2CD79F-CC22-453F-9B6B-B124E7A5204C")
666bf215546Sopenharmony_cistruct IDxcOptimizerPass : public IUnknown {
667bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE GetOptionName(_COM_Outptr_ LPWSTR *ppResult) = 0;
668bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE GetDescription(_COM_Outptr_ LPWSTR *ppResult) = 0;
669bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE GetOptionArgCount(_Out_ UINT32 *pCount) = 0;
670bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE GetOptionArgName(UINT32 argIndex, _COM_Outptr_ LPWSTR *ppResult) = 0;
671bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE GetOptionArgDescription(UINT32 argIndex, _COM_Outptr_ LPWSTR *ppResult) = 0;
672bf215546Sopenharmony_ci};
673bf215546Sopenharmony_ci
674bf215546Sopenharmony_ciCROSS_PLATFORM_UUIDOF(IDxcOptimizer, "25740E2E-9CBA-401B-9119-4FB42F39F270")
675bf215546Sopenharmony_cistruct IDxcOptimizer : public IUnknown {
676bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE GetAvailablePassCount(_Out_ UINT32 *pCount) = 0;
677bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE GetAvailablePass(UINT32 index, _COM_Outptr_ IDxcOptimizerPass** ppResult) = 0;
678bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE RunOptimizer(IDxcBlob *pBlob,
679bf215546Sopenharmony_ci    _In_count_(optionCount) LPCWSTR *ppOptions, UINT32 optionCount,
680bf215546Sopenharmony_ci    _COM_Outptr_ IDxcBlob **pOutputModule,
681bf215546Sopenharmony_ci    _COM_Outptr_opt_ IDxcBlobEncoding **ppOutputText) = 0;
682bf215546Sopenharmony_ci};
683bf215546Sopenharmony_ci
684bf215546Sopenharmony_cistatic const UINT32 DxcVersionInfoFlags_None = 0;
685bf215546Sopenharmony_cistatic const UINT32 DxcVersionInfoFlags_Debug = 1; // Matches VS_FF_DEBUG
686bf215546Sopenharmony_cistatic const UINT32 DxcVersionInfoFlags_Internal = 2; // Internal Validator (non-signing)
687bf215546Sopenharmony_ci
688bf215546Sopenharmony_ciCROSS_PLATFORM_UUIDOF(IDxcVersionInfo, "b04f5b50-2059-4f12-a8ff-a1e0cde1cc7e")
689bf215546Sopenharmony_cistruct IDxcVersionInfo : public IUnknown {
690bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE GetVersion(_Out_ UINT32 *pMajor, _Out_ UINT32 *pMinor) = 0;
691bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE GetFlags(_Out_ UINT32 *pFlags) = 0;
692bf215546Sopenharmony_ci};
693bf215546Sopenharmony_ci
694bf215546Sopenharmony_ciCROSS_PLATFORM_UUIDOF(IDxcVersionInfo2, "fb6904c4-42f0-4b62-9c46-983af7da7c83")
695bf215546Sopenharmony_cistruct IDxcVersionInfo2 : public IDxcVersionInfo {
696bf215546Sopenharmony_ci  virtual HRESULT STDMETHODCALLTYPE GetCommitInfo(_Out_ UINT32 *pCommitCount, _Out_ char **pCommitHash) = 0;
697bf215546Sopenharmony_ci};
698bf215546Sopenharmony_ci
699bf215546Sopenharmony_ci// Note: __declspec(selectany) requires 'extern'
700bf215546Sopenharmony_ci// On Linux __declspec(selectany) is removed and using 'extern' results in link error.
701bf215546Sopenharmony_ci#ifdef _MSC_VER
702bf215546Sopenharmony_ci#define CLSID_SCOPE __declspec(selectany) extern
703bf215546Sopenharmony_ci#else
704bf215546Sopenharmony_ci#define CLSID_SCOPE
705bf215546Sopenharmony_ci#endif
706bf215546Sopenharmony_ci
707bf215546Sopenharmony_ciCLSID_SCOPE const CLSID CLSID_DxcCompiler = {
708bf215546Sopenharmony_ci    0x73e22d93,
709bf215546Sopenharmony_ci    0xe6ce,
710bf215546Sopenharmony_ci    0x47f3,
711bf215546Sopenharmony_ci    {0xb5, 0xbf, 0xf0, 0x66, 0x4f, 0x39, 0xc1, 0xb0}};
712bf215546Sopenharmony_ci
713bf215546Sopenharmony_ci// {EF6A8087-B0EA-4D56-9E45-D07E1A8B7806}
714bf215546Sopenharmony_ciCLSID_SCOPE const GUID CLSID_DxcLinker = {
715bf215546Sopenharmony_ci    0xef6a8087,
716bf215546Sopenharmony_ci    0xb0ea,
717bf215546Sopenharmony_ci    0x4d56,
718bf215546Sopenharmony_ci    {0x9e, 0x45, 0xd0, 0x7e, 0x1a, 0x8b, 0x78, 0x6}};
719bf215546Sopenharmony_ci
720bf215546Sopenharmony_ci// {CD1F6B73-2AB0-484D-8EDC-EBE7A43CA09F}
721bf215546Sopenharmony_ciCLSID_SCOPE const CLSID CLSID_DxcDiaDataSource = {
722bf215546Sopenharmony_ci    0xcd1f6b73,
723bf215546Sopenharmony_ci    0x2ab0,
724bf215546Sopenharmony_ci    0x484d,
725bf215546Sopenharmony_ci    {0x8e, 0xdc, 0xeb, 0xe7, 0xa4, 0x3c, 0xa0, 0x9f}};
726bf215546Sopenharmony_ci
727bf215546Sopenharmony_ci// {3E56AE82-224D-470F-A1A1-FE3016EE9F9D}
728bf215546Sopenharmony_ciCLSID_SCOPE const CLSID CLSID_DxcCompilerArgs = {
729bf215546Sopenharmony_ci    0x3e56ae82,
730bf215546Sopenharmony_ci    0x224d,
731bf215546Sopenharmony_ci    0x470f,
732bf215546Sopenharmony_ci    {0xa1, 0xa1, 0xfe, 0x30, 0x16, 0xee, 0x9f, 0x9d}};
733bf215546Sopenharmony_ci
734bf215546Sopenharmony_ci// {6245D6AF-66E0-48FD-80B4-4D271796748C}
735bf215546Sopenharmony_ciCLSID_SCOPE const GUID CLSID_DxcLibrary = {
736bf215546Sopenharmony_ci    0x6245d6af,
737bf215546Sopenharmony_ci    0x66e0,
738bf215546Sopenharmony_ci    0x48fd,
739bf215546Sopenharmony_ci    {0x80, 0xb4, 0x4d, 0x27, 0x17, 0x96, 0x74, 0x8c}};
740bf215546Sopenharmony_ci
741bf215546Sopenharmony_ciCLSID_SCOPE const GUID CLSID_DxcUtils = CLSID_DxcLibrary;
742bf215546Sopenharmony_ci
743bf215546Sopenharmony_ci// {8CA3E215-F728-4CF3-8CDD-88AF917587A1}
744bf215546Sopenharmony_ciCLSID_SCOPE const GUID CLSID_DxcValidator = {
745bf215546Sopenharmony_ci    0x8ca3e215,
746bf215546Sopenharmony_ci    0xf728,
747bf215546Sopenharmony_ci    0x4cf3,
748bf215546Sopenharmony_ci    {0x8c, 0xdd, 0x88, 0xaf, 0x91, 0x75, 0x87, 0xa1}};
749bf215546Sopenharmony_ci
750bf215546Sopenharmony_ci// {D728DB68-F903-4F80-94CD-DCCF76EC7151}
751bf215546Sopenharmony_ciCLSID_SCOPE const GUID CLSID_DxcAssembler = {
752bf215546Sopenharmony_ci    0xd728db68,
753bf215546Sopenharmony_ci    0xf903,
754bf215546Sopenharmony_ci    0x4f80,
755bf215546Sopenharmony_ci    {0x94, 0xcd, 0xdc, 0xcf, 0x76, 0xec, 0x71, 0x51}};
756bf215546Sopenharmony_ci
757bf215546Sopenharmony_ci// {b9f54489-55b8-400c-ba3a-1675e4728b91}
758bf215546Sopenharmony_ciCLSID_SCOPE const GUID CLSID_DxcContainerReflection = {
759bf215546Sopenharmony_ci    0xb9f54489,
760bf215546Sopenharmony_ci    0x55b8,
761bf215546Sopenharmony_ci    0x400c,
762bf215546Sopenharmony_ci    {0xba, 0x3a, 0x16, 0x75, 0xe4, 0x72, 0x8b, 0x91}};
763bf215546Sopenharmony_ci
764bf215546Sopenharmony_ci// {AE2CD79F-CC22-453F-9B6B-B124E7A5204C}
765bf215546Sopenharmony_ciCLSID_SCOPE const GUID CLSID_DxcOptimizer = {
766bf215546Sopenharmony_ci    0xae2cd79f,
767bf215546Sopenharmony_ci    0xcc22,
768bf215546Sopenharmony_ci    0x453f,
769bf215546Sopenharmony_ci    {0x9b, 0x6b, 0xb1, 0x24, 0xe7, 0xa5, 0x20, 0x4c}};
770bf215546Sopenharmony_ci
771bf215546Sopenharmony_ci// {94134294-411f-4574-b4d0-8741e25240d2}
772bf215546Sopenharmony_ciCLSID_SCOPE const GUID CLSID_DxcContainerBuilder = {
773bf215546Sopenharmony_ci    0x94134294,
774bf215546Sopenharmony_ci    0x411f,
775bf215546Sopenharmony_ci    0x4574,
776bf215546Sopenharmony_ci    {0xb4, 0xd0, 0x87, 0x41, 0xe2, 0x52, 0x40, 0xd2}};
777bf215546Sopenharmony_ci#endif
778