-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompiler.h
More file actions
79 lines (70 loc) · 2.61 KB
/
Copy pathCompiler.h
File metadata and controls
79 lines (70 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#pragma once
#include <cstddef>
#include <cstdint>
#if defined(_WIN32)
#define VMSC_EXPORT __declspec(dllexport)
#define VMSC_CALL __cdecl
#else
#define VMSC_EXPORT
#define VMSC_CALL
#endif
enum VMSC_CompileFlags : std::uint32_t
{
VMSC_COMPILE_NONE = 0,
VMSC_COMPILE_DEBUG = 1u << 0,
VMSC_COMPILE_DISABLE_OPTIMIZATIONS = 1u << 1,
};
struct VMSC_IncludeRoot
{
// A Unity-style virtual prefix, for example
// "Packages/com.vivid.render-pipelines/". An empty prefix makes the
// physical path a normal include search root.
const char* logicalPrefixUtf8;
const char* physicalPathUtf8;
};
struct VMSC_CompileDesc
{
std::uint32_t structSize;
std::uint32_t abiVersion;
const char* sourceUtf8;
std::uint64_t sourceLength;
const char* sourceNameUtf8;
const char* entryPointUtf8;
const char* targetProfileUtf8;
const VMSC_IncludeRoot* includeRoots;
std::uint32_t includeRootCount;
std::uint32_t flags;
};
static_assert(sizeof(void*) == 8, "The VMSC ABI is 64-bit only.");
static_assert(sizeof(VMSC_IncludeRoot) == 16);
static_assert(offsetof(VMSC_IncludeRoot, physicalPathUtf8) == 8);
static_assert(sizeof(VMSC_CompileDesc) == 64);
static_assert(offsetof(VMSC_CompileDesc, sourceUtf8) == 8);
static_assert(offsetof(VMSC_CompileDesc, sourceLength) == 16);
static_assert(offsetof(VMSC_CompileDesc, sourceNameUtf8) == 24);
static_assert(offsetof(VMSC_CompileDesc, entryPointUtf8) == 32);
static_assert(offsetof(VMSC_CompileDesc, targetProfileUtf8) == 40);
static_assert(offsetof(VMSC_CompileDesc, includeRoots) == 48);
static_assert(offsetof(VMSC_CompileDesc, includeRootCount) == 56);
static_assert(offsetof(VMSC_CompileDesc, flags) == 60);
inline constexpr std::uint32_t VMSC_ABI_VERSION = 1;
extern "C"
{
VMSC_EXPORT std::uint32_t VMSC_CALL VMSC_GetAbiVersion();
VMSC_EXPORT const char* VMSC_CALL VMSC_GetCompilerVersion();
// The result handle owns immutable DXIL and diagnostics. Even compilation
// failures normally return a non-zero handle so callers can read diagnostics.
VMSC_EXPORT std::uint64_t VMSC_CALL VMSC_Compile(
const VMSC_CompileDesc* desc);
VMSC_EXPORT std::uint32_t VMSC_CALL VMSC_GetResultSuccess(
std::uint64_t resultHandle);
VMSC_EXPORT const void* VMSC_CALL VMSC_GetResultData(
std::uint64_t resultHandle);
VMSC_EXPORT std::uint64_t VMSC_CALL VMSC_GetResultSize(
std::uint64_t resultHandle);
VMSC_EXPORT const char* VMSC_CALL VMSC_GetResultDiagnostics(
std::uint64_t resultHandle);
VMSC_EXPORT std::uint64_t VMSC_CALL VMSC_GetResultDiagnosticsSize(
std::uint64_t resultHandle);
VMSC_EXPORT void VMSC_CALL VMSC_DestroyResult(std::uint64_t resultHandle);
}