summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-type-system-shared.h
blob: aa9b07d89762b4cc9fd412c886df906dd36a6214 (plain)
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#ifndef SLANG_TYPE_SYSTEM_SHARED_H
#define SLANG_TYPE_SYSTEM_SHARED_H

#include "slang.h"

namespace Slang
{
#define FOREACH_BASE_TYPE(X) \
    X(Void)                  \
    X(Bool)                  \
    X(Int8)                  \
    X(Int16)                 \
    X(Int)                   \
    X(Int64)                 \
    X(UInt8)                 \
    X(UInt16)                \
    X(UInt)                  \
    X(UInt64)                \
    X(Half)                  \
    X(Float)                 \
    X(Double)                \
    X(Char)                  \
    X(IntPtr)                \
    X(UIntPtr)               \
    X(CountOfPrimitives)     \
    /* end */

enum class BaseType
{
#define DEFINE_BASE_TYPE(NAME) NAME,
    FOREACH_BASE_TYPE(DEFINE_BASE_TYPE)
#undef DEFINE_BASE_TYPE

        CountOf,
};

enum class SamplerStateFlavor : uint8_t
{
    SamplerState,
    SamplerComparisonState,
};

const int kCoreModule_ResourceAccessReadOnly = 0;
const int kCoreModule_ResourceAccessReadWrite = 1;
const int kCoreModule_ResourceAccessWriteOnly = 2;
const int kCoreModule_ResourceAccessRasterizerOrdered = 3;
const int kCoreModule_ResourceAccessFeedback = 4;

const int kCoreModule_ShapeIndex1D = 0;
const int kCoreModule_ShapeIndex2D = 1;
const int kCoreModule_ShapeIndex3D = 2;
const int kCoreModule_ShapeIndexCube = 3;
const int kCoreModule_ShapeIndexBuffer = 4;

const int kCoreModule_TextureShapeParameterIndex = 1;
const int kCoreModule_TextureIsArrayParameterIndex = 2;
const int kCoreModule_TextureIsMultisampleParameterIndex = 3;
const int kCoreModule_TextureSampleCountParameterIndex = 4;
const int kCoreModule_TextureAccessParameterIndex = 5;
const int kCoreModule_TextureIsShadowParameterIndex = 6;
const int kCoreModule_TextureIsCombinedParameterIndex = 7;
const int kCoreModule_TextureFormatParameterIndex = 8;

enum class AddressSpace : uint64_t
{
    Generic = 0x7fffffff,
    // Corresponds to SPIR-V's SpvStorageClassPrivate
    ThreadLocal = 1,
    Global,
    // Corresponds to SPIR-V's SpvStorageClassWorkgroup
    GroupShared,
    // Corresponds to SPIR-V's SpvStorageClassUniform
    Uniform,
    // specific address space for payload data in metal
    MetalObjectData,
    // Corresponds to SPIR-V's SpvStorageClassInput
    Input,
    // Same as `Input`, but used for builtin input variables.
    BuiltinInput,
    // Corresponds to SPIR-V's SpvStorageClassOutput
    Output,
    // Same as `Output`, but used for builtin output variables.
    BuiltinOutput,
    // Corresponds to SPIR-V's SpvStorageClassTaskPayloadWorkgroupEXT
    TaskPayloadWorkgroup,
    // Corresponds to SPIR-V's SpvStorageClassFunction
    Function,
    // Corresponds to SPIR-V's SpvStorageClassStorageBuffer
    StorageBuffer,
    // Corresponds to SPIR-V's SpvStorageClassPushConstant,
    PushConstant,
    // Corresponds to SPIR-V's SpvStorageClassRayPayloadKHR,
    RayPayloadKHR,
    // Corresponds to SPIR-V's SpvStorageClassIncomingRayPayloadKHR,
    IncomingRayPayload,
    // Corresponds to SPIR-V's SpvStorageClassCallableDataKHR
    CallableDataKHR,
    // Corresponds to SPIR-V's SpvStorageClassIncomingCallableDataKHR
    IncomingCallableData,
    // Corresponds to SPIR-V's SpvStorageClassHitObjectAttributeNV,
    HitObjectAttribute,
    // Corresponds to SPIR-V's SpvStorageClassHitAttributeKHR,
    HitAttribute,
    // Corresponds to SPIR-V's SpvStorageClassShaderRecordBufferKHR,
    ShaderRecordBuffer,
    // Corresponds to SPIR-V's SpvStorageClassUniformConstant,
    UniformConstant,
    // Corresponds to SPIR-V's SpvStorageClassImage
    Image,
    // Represents a SPIR-V specialization constant
    SpecializationConstant,
    // Corresponds to SPIR-V's SpvStorageClassNodePayloadAMDX,
    NodePayloadAMDX,

    // Default address space for a user-defined pointer
    UserPointer = 0x100000001ULL,
};

// https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#_scope_id
// must be 32 bit to match SPIR-V
enum class MemoryScope : int32_t
{
    CrossDevice = 0,
    Device = 1,
    Workgroup = 2,
    Subgroup = 3,
    Invocation = 4,
    QueueFamily = 5,
    ShaderCall = 6,
};

enum class AccessQualifier : uint64_t
{
    ReadWrite = 0,
    Read = 1,
};

} // namespace Slang

#endif