nv-sgl 0.6.0__cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Sign up to get free protection for your applications and to get access to all the features.
- include/tevclient.h +393 -0
- nv_sgl-0.6.0.dist-info/LICENSE +29 -0
- nv_sgl-0.6.0.dist-info/METADATA +21 -0
- nv_sgl-0.6.0.dist-info/RECORD +133 -0
- nv_sgl-0.6.0.dist-info/WHEEL +6 -0
- nv_sgl-0.6.0.dist-info/top_level.txt +1 -0
- sgl/__init__.py +15 -0
- sgl/__init__.pyi +6738 -0
- sgl/include/sgl/app/app.h +113 -0
- sgl/include/sgl/core/bitmap.h +302 -0
- sgl/include/sgl/core/crypto.h +89 -0
- sgl/include/sgl/core/data_type.h +46 -0
- sgl/include/sgl/core/dds_file.h +103 -0
- sgl/include/sgl/core/enum.h +201 -0
- sgl/include/sgl/core/error.h +161 -0
- sgl/include/sgl/core/file_stream.h +77 -0
- sgl/include/sgl/core/file_system_watcher.h +141 -0
- sgl/include/sgl/core/format.h +36 -0
- sgl/include/sgl/core/fwd.h +90 -0
- sgl/include/sgl/core/hash.h +45 -0
- sgl/include/sgl/core/input.h +522 -0
- sgl/include/sgl/core/logger.h +214 -0
- sgl/include/sgl/core/macros.h +184 -0
- sgl/include/sgl/core/maths.h +45 -0
- sgl/include/sgl/core/memory_mapped_file.h +112 -0
- sgl/include/sgl/core/memory_mapped_file_stream.h +32 -0
- sgl/include/sgl/core/memory_stream.h +74 -0
- sgl/include/sgl/core/object.h +683 -0
- sgl/include/sgl/core/platform.h +239 -0
- sgl/include/sgl/core/plugin.h +331 -0
- sgl/include/sgl/core/resolver.h +39 -0
- sgl/include/sgl/core/short_vector.h +141 -0
- sgl/include/sgl/core/static_vector.h +111 -0
- sgl/include/sgl/core/stream.h +54 -0
- sgl/include/sgl/core/string.h +276 -0
- sgl/include/sgl/core/struct.h +360 -0
- sgl/include/sgl/core/thread.h +28 -0
- sgl/include/sgl/core/timer.h +52 -0
- sgl/include/sgl/core/traits.h +15 -0
- sgl/include/sgl/core/type_utils.h +19 -0
- sgl/include/sgl/core/window.h +177 -0
- sgl/include/sgl/device/agility_sdk.h +24 -0
- sgl/include/sgl/device/blit.h +88 -0
- sgl/include/sgl/device/buffer_cursor.h +162 -0
- sgl/include/sgl/device/command.h +539 -0
- sgl/include/sgl/device/cuda_api.h +766 -0
- sgl/include/sgl/device/cuda_interop.h +39 -0
- sgl/include/sgl/device/cuda_utils.h +107 -0
- sgl/include/sgl/device/cursor_utils.h +129 -0
- sgl/include/sgl/device/device.h +668 -0
- sgl/include/sgl/device/device_resource.h +37 -0
- sgl/include/sgl/device/fence.h +91 -0
- sgl/include/sgl/device/formats.h +330 -0
- sgl/include/sgl/device/framebuffer.h +85 -0
- sgl/include/sgl/device/fwd.h +164 -0
- sgl/include/sgl/device/helpers.h +20 -0
- sgl/include/sgl/device/hot_reload.h +75 -0
- sgl/include/sgl/device/input_layout.h +74 -0
- sgl/include/sgl/device/kernel.h +69 -0
- sgl/include/sgl/device/memory_heap.h +155 -0
- sgl/include/sgl/device/native_formats.h +342 -0
- sgl/include/sgl/device/native_handle.h +73 -0
- sgl/include/sgl/device/native_handle_traits.h +65 -0
- sgl/include/sgl/device/pipeline.h +138 -0
- sgl/include/sgl/device/print.h +45 -0
- sgl/include/sgl/device/python/cursor_utils.h +853 -0
- sgl/include/sgl/device/query.h +52 -0
- sgl/include/sgl/device/raytracing.h +84 -0
- sgl/include/sgl/device/reflection.h +1254 -0
- sgl/include/sgl/device/resource.h +705 -0
- sgl/include/sgl/device/sampler.h +57 -0
- sgl/include/sgl/device/shader.h +516 -0
- sgl/include/sgl/device/shader_cursor.h +85 -0
- sgl/include/sgl/device/shader_object.h +94 -0
- sgl/include/sgl/device/shader_offset.h +67 -0
- sgl/include/sgl/device/shared_handle.h +12 -0
- sgl/include/sgl/device/slang_utils.h +54 -0
- sgl/include/sgl/device/swapchain.h +74 -0
- sgl/include/sgl/device/types.h +782 -0
- sgl/include/sgl/math/colorspace.h +56 -0
- sgl/include/sgl/math/constants.h +7 -0
- sgl/include/sgl/math/float16.h +146 -0
- sgl/include/sgl/math/matrix.h +6 -0
- sgl/include/sgl/math/matrix_math.h +746 -0
- sgl/include/sgl/math/matrix_types.h +207 -0
- sgl/include/sgl/math/python/primitivetype.h +33 -0
- sgl/include/sgl/math/quaternion.h +6 -0
- sgl/include/sgl/math/quaternion_math.h +484 -0
- sgl/include/sgl/math/quaternion_types.h +83 -0
- sgl/include/sgl/math/ray.h +47 -0
- sgl/include/sgl/math/scalar_math.h +249 -0
- sgl/include/sgl/math/scalar_types.h +107 -0
- sgl/include/sgl/math/vector.h +6 -0
- sgl/include/sgl/math/vector_math.h +1796 -0
- sgl/include/sgl/math/vector_types.h +336 -0
- sgl/include/sgl/python/nanobind.h +489 -0
- sgl/include/sgl/python/py_doc.h +11600 -0
- sgl/include/sgl/python/sgl_ext_pch.h +8 -0
- sgl/include/sgl/sgl.h +21 -0
- sgl/include/sgl/sgl_pch.h +6 -0
- sgl/include/sgl/stl/bit.h +377 -0
- sgl/include/sgl/tests/testing.h +54 -0
- sgl/include/sgl/ui/fwd.h +34 -0
- sgl/include/sgl/ui/imgui_config.h +43 -0
- sgl/include/sgl/ui/ui.h +71 -0
- sgl/include/sgl/ui/widgets.h +918 -0
- sgl/include/sgl/utils/python/slangpy.h +366 -0
- sgl/include/sgl/utils/renderdoc.h +50 -0
- sgl/include/sgl/utils/slangpy.h +153 -0
- sgl/include/sgl/utils/tev.h +93 -0
- sgl/include/sgl/utils/texture_loader.h +106 -0
- sgl/libgfx.so +0 -0
- sgl/libsgl.so +0 -0
- sgl/libslang-glslang.so +0 -0
- sgl/libslang.so +0 -0
- sgl/libtevclient.a +0 -0
- sgl/math/__init__.pyi +5083 -0
- sgl/platform/__init__.pyi +102 -0
- sgl/renderdoc/__init__.pyi +51 -0
- sgl/sgl_ext.cpython-313-x86_64-linux-gnu.so +0 -0
- sgl/shaders/sgl/device/blit.slang +93 -0
- sgl/shaders/sgl/device/nvapi.slang +5 -0
- sgl/shaders/sgl/device/nvapi.slangh +7 -0
- sgl/shaders/sgl/device/print.slang +445 -0
- sgl/shaders/sgl/math/constants.slang +4 -0
- sgl/shaders/sgl/math/ray.slang +29 -0
- sgl/shaders/sgl/ui/imgui.slang +49 -0
- sgl/slangpy/__init__.pyi +268 -0
- sgl/tev/__init__.pyi +108 -0
- sgl/thread/__init__.pyi +4 -0
- sgl/ui/__init__.pyi +1118 -0
- share/cmake/tevclient/tevclient-config-release.cmake +19 -0
- share/cmake/tevclient/tevclient-config.cmake +103 -0
@@ -0,0 +1,1254 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
|
3
|
+
#pragma once
|
4
|
+
|
5
|
+
#include "sgl/device/types.h"
|
6
|
+
#include "sgl/device/fwd.h"
|
7
|
+
|
8
|
+
#include "sgl/core/macros.h"
|
9
|
+
#include "sgl/core/enum.h"
|
10
|
+
#include "sgl/core/error.h"
|
11
|
+
#include "sgl/core/type_utils.h"
|
12
|
+
|
13
|
+
#include "sgl/math/vector_types.h"
|
14
|
+
|
15
|
+
#include <slang.h>
|
16
|
+
|
17
|
+
#include <map>
|
18
|
+
#include <string>
|
19
|
+
#include <vector>
|
20
|
+
|
21
|
+
namespace sgl {
|
22
|
+
|
23
|
+
namespace detail {
|
24
|
+
|
25
|
+
SGL_API ref<const DeclReflection> from_slang(ref<const Object> owner, slang::DeclReflection* decl_reflection);
|
26
|
+
SGL_API ref<const TypeReflection> from_slang(ref<const Object> owner, slang::TypeReflection* type_reflection);
|
27
|
+
SGL_API ref<const TypeLayoutReflection>
|
28
|
+
from_slang(ref<const Object> owner, slang::TypeLayoutReflection* type_layout_reflection);
|
29
|
+
SGL_API ref<const FunctionReflection>
|
30
|
+
from_slang(ref<const Object> owner, slang::FunctionReflection* variable_reflection);
|
31
|
+
SGL_API ref<const VariableReflection>
|
32
|
+
from_slang(ref<const Object> owner, slang::VariableReflection* variable_reflection);
|
33
|
+
SGL_API ref<const VariableLayoutReflection>
|
34
|
+
from_slang(ref<const Object> owner, slang::VariableLayoutReflection* variable_layout_reflection);
|
35
|
+
SGL_API ref<const EntryPointLayout>
|
36
|
+
from_slang(ref<const Object> owner, slang::EntryPointLayout* entry_point_reflection);
|
37
|
+
SGL_API ref<const ProgramLayout> from_slang(ref<const Object> owner, slang::ProgramLayout* program_layout);
|
38
|
+
|
39
|
+
SGL_API void on_slang_wrapper_destroyed(void* slang_reflection);
|
40
|
+
|
41
|
+
SGL_API void invalidate_all_reflection_data();
|
42
|
+
} // namespace detail
|
43
|
+
|
44
|
+
|
45
|
+
enum class ModifierID {
|
46
|
+
shared = slang::Modifier::ID::Shared,
|
47
|
+
nodiff = slang::Modifier::ID::NoDiff,
|
48
|
+
static_ = slang::Modifier::ID::Static,
|
49
|
+
const_ = slang::Modifier::ID::Const,
|
50
|
+
export_ = slang::Modifier::ID::Export,
|
51
|
+
extern_ = slang::Modifier::ID::Extern,
|
52
|
+
differentiable = slang::Modifier::ID::Differentiable,
|
53
|
+
mutating = slang::Modifier::ID::Mutating,
|
54
|
+
in = slang::Modifier::ID::In,
|
55
|
+
out = slang::Modifier::ID::Out,
|
56
|
+
inout = slang::Modifier::ID::InOut,
|
57
|
+
};
|
58
|
+
|
59
|
+
SGL_ENUM_INFO(
|
60
|
+
ModifierID,
|
61
|
+
{
|
62
|
+
{ModifierID::shared, "shared"},
|
63
|
+
{ModifierID::nodiff, "nodiff"},
|
64
|
+
{ModifierID::static_, "static"},
|
65
|
+
{ModifierID::const_, "const"},
|
66
|
+
{ModifierID::export_, "export"},
|
67
|
+
{ModifierID::extern_, "extern"},
|
68
|
+
{ModifierID::differentiable, "differentiable"},
|
69
|
+
{ModifierID::mutating, "mutating"},
|
70
|
+
{ModifierID::in, "inn"},
|
71
|
+
{ModifierID::out, "out"},
|
72
|
+
{ModifierID::inout, "inout"},
|
73
|
+
}
|
74
|
+
);
|
75
|
+
SGL_ENUM_REGISTER(ModifierID);
|
76
|
+
|
77
|
+
/// Base class for read-only lazy evaluation list. This only maintains
|
78
|
+
/// a reference to the parent, and allocates/returns children on demand.
|
79
|
+
template<class ParentType, class ChildType>
|
80
|
+
class BaseReflectionList {
|
81
|
+
public:
|
82
|
+
class Iterator {
|
83
|
+
public:
|
84
|
+
using value_type = ref<const ChildType>;
|
85
|
+
|
86
|
+
explicit Iterator(const BaseReflectionList* list, uint32_t index)
|
87
|
+
: m_list(list)
|
88
|
+
, m_index(index)
|
89
|
+
{
|
90
|
+
}
|
91
|
+
Iterator& operator++()
|
92
|
+
{
|
93
|
+
if (m_index >= m_list->size())
|
94
|
+
SGL_THROW("Iterator out of range");
|
95
|
+
m_index++;
|
96
|
+
return *this;
|
97
|
+
}
|
98
|
+
Iterator operator++(int)
|
99
|
+
{
|
100
|
+
Iterator retval = *this;
|
101
|
+
++(*this);
|
102
|
+
return retval;
|
103
|
+
}
|
104
|
+
bool operator==(Iterator other) const { return m_list == other.m_list && m_index == other.m_index; }
|
105
|
+
bool operator!=(Iterator other) const { return !(*this == other); }
|
106
|
+
ref<const ChildType> operator*() const { return (*m_list)[m_index]; }
|
107
|
+
|
108
|
+
private:
|
109
|
+
const BaseReflectionList* m_list;
|
110
|
+
uint32_t m_index;
|
111
|
+
};
|
112
|
+
|
113
|
+
/// Iterator type def for STL
|
114
|
+
using iterator = BaseReflectionList<ParentType, ChildType>::Iterator;
|
115
|
+
|
116
|
+
BaseReflectionList(ref<const ParentType> owner)
|
117
|
+
: m_owner(std::move(owner))
|
118
|
+
{
|
119
|
+
}
|
120
|
+
|
121
|
+
BaseReflectionList(const BaseReflectionList& other) noexcept
|
122
|
+
: m_owner(other.m_owner)
|
123
|
+
{
|
124
|
+
}
|
125
|
+
|
126
|
+
BaseReflectionList(BaseReflectionList&& other) noexcept
|
127
|
+
: m_owner(std::move(other.m_owner))
|
128
|
+
{
|
129
|
+
}
|
130
|
+
|
131
|
+
virtual ~BaseReflectionList() = default;
|
132
|
+
|
133
|
+
/// Number of entries in list.
|
134
|
+
virtual uint32_t size() const = 0;
|
135
|
+
|
136
|
+
/// Index operator
|
137
|
+
virtual ref<const ChildType> operator[](uint32_t index) const { return evaluate(index); }
|
138
|
+
|
139
|
+
/// Begin iterator
|
140
|
+
Iterator begin() const { return Iterator(this, 0); }
|
141
|
+
|
142
|
+
/// End iterator
|
143
|
+
Iterator end() const { return Iterator(this, size()); }
|
144
|
+
|
145
|
+
protected:
|
146
|
+
ref<const ParentType> m_owner;
|
147
|
+
|
148
|
+
/// Evaluate and return a specific child in the parent object.
|
149
|
+
virtual ref<const ChildType> evaluate(uint32_t child_index) const = 0;
|
150
|
+
};
|
151
|
+
|
152
|
+
/// Base class for read-only lazy evaluation list of search results.
|
153
|
+
/// To use it, the search function (e.g. children_of_kind) fills out the indices of
|
154
|
+
/// the children matching the search. The list can then be accessed as usual, and only
|
155
|
+
/// allocates/evaluates children as they're requested.
|
156
|
+
template<class ParentType, class ChildType>
|
157
|
+
class BaseReflectionIndexedList : public BaseReflectionList<ParentType, ChildType> {
|
158
|
+
public:
|
159
|
+
BaseReflectionIndexedList(ref<const ParentType> owner, std::vector<uint32_t> indices)
|
160
|
+
: BaseReflectionList<ParentType, ChildType>(std::move(owner))
|
161
|
+
, m_indices(std::move(indices))
|
162
|
+
{
|
163
|
+
}
|
164
|
+
|
165
|
+
BaseReflectionIndexedList(const BaseReflectionIndexedList& other) noexcept
|
166
|
+
: BaseReflectionList<ParentType, ChildType>(other.m_owner)
|
167
|
+
, m_indices(other.m_indices)
|
168
|
+
{
|
169
|
+
}
|
170
|
+
|
171
|
+
BaseReflectionIndexedList(BaseReflectionIndexedList&& other) noexcept
|
172
|
+
: BaseReflectionList<ParentType, ChildType>(std::move(other.m_owner))
|
173
|
+
, m_indices(std::move(other.m_indices))
|
174
|
+
{
|
175
|
+
}
|
176
|
+
|
177
|
+
virtual ~BaseReflectionIndexedList() = default;
|
178
|
+
|
179
|
+
/// Number of search results in list.
|
180
|
+
uint32_t size() const override { return static_cast<uint32_t>(m_indices.size()); }
|
181
|
+
|
182
|
+
/// Index operator
|
183
|
+
ref<const ChildType> operator[](uint32_t index) const override { return this->evaluate(m_indices[index]); }
|
184
|
+
|
185
|
+
private:
|
186
|
+
std::vector<uint32_t> m_indices;
|
187
|
+
};
|
188
|
+
|
189
|
+
class SGL_API BaseReflectionObject : public Object {
|
190
|
+
public:
|
191
|
+
BaseReflectionObject(ref<const Object> owner)
|
192
|
+
: m_owner(std::move(owner))
|
193
|
+
{
|
194
|
+
}
|
195
|
+
|
196
|
+
virtual void _hot_reload_invalidate() { m_owner = nullptr; }
|
197
|
+
|
198
|
+
bool is_valid() const { return m_owner != nullptr; }
|
199
|
+
|
200
|
+
protected:
|
201
|
+
ref<const Object> m_owner;
|
202
|
+
};
|
203
|
+
|
204
|
+
template<class SlangType>
|
205
|
+
class SGL_API BaseReflectionObjectImpl : public BaseReflectionObject {
|
206
|
+
public:
|
207
|
+
BaseReflectionObjectImpl(ref<const Object> owner, SlangType* target)
|
208
|
+
: BaseReflectionObject(std::move(owner))
|
209
|
+
, m_target(target)
|
210
|
+
{
|
211
|
+
}
|
212
|
+
~BaseReflectionObjectImpl() { detail::on_slang_wrapper_destroyed(m_target); }
|
213
|
+
|
214
|
+
SlangType* slang_target() const
|
215
|
+
{
|
216
|
+
SGL_CHECK(m_target, "Reflection object has been invalidated");
|
217
|
+
return m_target;
|
218
|
+
}
|
219
|
+
|
220
|
+
void _hot_reload_invalidate() override
|
221
|
+
{
|
222
|
+
BaseReflectionObject::_hot_reload_invalidate();
|
223
|
+
m_target = nullptr;
|
224
|
+
}
|
225
|
+
|
226
|
+
private:
|
227
|
+
SlangType* m_target;
|
228
|
+
};
|
229
|
+
|
230
|
+
class SGL_API DeclReflection : public BaseReflectionObjectImpl<slang::DeclReflection> {
|
231
|
+
|
232
|
+
public:
|
233
|
+
DeclReflection(ref<const Object> owner, slang::DeclReflection* target)
|
234
|
+
: BaseReflectionObjectImpl(std::move(owner), target)
|
235
|
+
{
|
236
|
+
}
|
237
|
+
|
238
|
+
|
239
|
+
/// Different kinds of decl slang can return.
|
240
|
+
enum class Kind {
|
241
|
+
unsupported = SLANG_DECL_KIND_UNSUPPORTED_FOR_REFLECTION,
|
242
|
+
struct_ = SLANG_DECL_KIND_STRUCT,
|
243
|
+
func = SLANG_DECL_KIND_FUNC,
|
244
|
+
module = SLANG_DECL_KIND_MODULE,
|
245
|
+
generic = SLANG_DECL_KIND_GENERIC,
|
246
|
+
variable = SLANG_DECL_KIND_VARIABLE,
|
247
|
+
};
|
248
|
+
SGL_ENUM_INFO(
|
249
|
+
Kind,
|
250
|
+
{
|
251
|
+
{Kind::unsupported, "unsupported"},
|
252
|
+
{Kind::struct_, "struct"},
|
253
|
+
{Kind::func, "func"},
|
254
|
+
{Kind::module, "module"},
|
255
|
+
{Kind::generic, "generic"},
|
256
|
+
{Kind::variable, "variable"},
|
257
|
+
}
|
258
|
+
);
|
259
|
+
|
260
|
+
/// Decl kind (struct/function/module/generic/variable).
|
261
|
+
Kind kind() const { return static_cast<Kind>(slang_target()->getKind()); }
|
262
|
+
|
263
|
+
/// List of children of this cursor.
|
264
|
+
DeclReflectionChildList children() const;
|
265
|
+
|
266
|
+
/// Get number of children.
|
267
|
+
uint32_t child_count() const { return slang_target()->getChildrenCount(); }
|
268
|
+
|
269
|
+
/// Get a child by index.
|
270
|
+
ref<const DeclReflection> child(uint32_t index) const
|
271
|
+
{
|
272
|
+
if (index > child_count())
|
273
|
+
SGL_THROW("Child index out of range: {}", index);
|
274
|
+
return detail::from_slang(m_owner, slang_target()->getChild(index));
|
275
|
+
}
|
276
|
+
|
277
|
+
/// Get the name of this decl (if it is of a kind that has a name).
|
278
|
+
/// Note: Only supported for types, functions and variables.
|
279
|
+
std::string name() const;
|
280
|
+
|
281
|
+
/// List of children of this cursor of a specific kind.
|
282
|
+
DeclReflectionIndexedChildList children_of_kind(Kind kind) const;
|
283
|
+
|
284
|
+
/// Index operator to get nth child.
|
285
|
+
ref<const DeclReflection> operator[](uint32_t index) const
|
286
|
+
{
|
287
|
+
return detail::from_slang(m_owner, slang_target()->getChild(index));
|
288
|
+
}
|
289
|
+
|
290
|
+
/// Description as string.
|
291
|
+
std::string to_string() const;
|
292
|
+
|
293
|
+
/// Get type corresponding to this decl ref.
|
294
|
+
ref<const TypeReflection> as_type() const;
|
295
|
+
|
296
|
+
/// Get variable corresponding to this decl ref.
|
297
|
+
ref<const VariableReflection> as_variable() const
|
298
|
+
{
|
299
|
+
return detail::from_slang(m_owner, slang_target()->asVariable());
|
300
|
+
}
|
301
|
+
|
302
|
+
/// Get function corresponding to this decl ref.
|
303
|
+
ref<const FunctionReflection> as_function() const
|
304
|
+
{
|
305
|
+
return detail::from_slang(m_owner, slang_target()->asFunction());
|
306
|
+
}
|
307
|
+
|
308
|
+
/// Finds all children of a specific kind with a given name.
|
309
|
+
/// Note: Only supported for types, functions and variables.
|
310
|
+
DeclReflectionIndexedChildList find_children_of_kind(Kind kind, std::string_view child_name) const;
|
311
|
+
|
312
|
+
/// Finds the first child of a specific kind with a given name.
|
313
|
+
/// Note: Only supported for types, functions and variables.
|
314
|
+
ref<const DeclReflection> find_first_child_of_kind(Kind kind, std::string_view child_name) const;
|
315
|
+
};
|
316
|
+
SGL_ENUM_REGISTER(DeclReflection::Kind);
|
317
|
+
|
318
|
+
/// DeclReflection lazy child list evaluation.
|
319
|
+
class SGL_API DeclReflectionChildList : public BaseReflectionList<DeclReflection, DeclReflection> {
|
320
|
+
public:
|
321
|
+
DeclReflectionChildList(ref<const DeclReflection> owner)
|
322
|
+
: BaseReflectionList(std::move(owner))
|
323
|
+
{
|
324
|
+
}
|
325
|
+
|
326
|
+
/// Number of entries in list.
|
327
|
+
uint32_t size() const override { return m_owner->child_count(); }
|
328
|
+
|
329
|
+
protected:
|
330
|
+
/// Get a specific search result.
|
331
|
+
ref<const DeclReflection> evaluate(uint32_t index) const override { return m_owner->child(index); }
|
332
|
+
};
|
333
|
+
|
334
|
+
/// DeclReflection lazy search result evaluation.
|
335
|
+
class SGL_API DeclReflectionIndexedChildList : public BaseReflectionIndexedList<DeclReflection, DeclReflection> {
|
336
|
+
public:
|
337
|
+
DeclReflectionIndexedChildList(ref<const DeclReflection> owner, std::vector<uint32_t> results)
|
338
|
+
: BaseReflectionIndexedList(std::move(owner), std::move(results))
|
339
|
+
{
|
340
|
+
}
|
341
|
+
|
342
|
+
protected:
|
343
|
+
/// Get a specific search result.
|
344
|
+
ref<const DeclReflection> evaluate(uint32_t index) const override { return m_owner->child(index); }
|
345
|
+
};
|
346
|
+
|
347
|
+
class SGL_API TypeReflection : public BaseReflectionObjectImpl<slang::TypeReflection> {
|
348
|
+
public:
|
349
|
+
enum class Kind {
|
350
|
+
none = SLANG_TYPE_KIND_NONE,
|
351
|
+
struct_ = SLANG_TYPE_KIND_STRUCT,
|
352
|
+
array = SLANG_TYPE_KIND_ARRAY,
|
353
|
+
matrix = SLANG_TYPE_KIND_MATRIX,
|
354
|
+
vector = SLANG_TYPE_KIND_VECTOR,
|
355
|
+
scalar = SLANG_TYPE_KIND_SCALAR,
|
356
|
+
constant_buffer = SLANG_TYPE_KIND_CONSTANT_BUFFER,
|
357
|
+
resource = SLANG_TYPE_KIND_RESOURCE,
|
358
|
+
sampler_state = SLANG_TYPE_KIND_SAMPLER_STATE,
|
359
|
+
texture_buffer = SLANG_TYPE_KIND_TEXTURE_BUFFER,
|
360
|
+
shader_storage_buffer = SLANG_TYPE_KIND_SHADER_STORAGE_BUFFER,
|
361
|
+
parameter_block = SLANG_TYPE_KIND_PARAMETER_BLOCK,
|
362
|
+
generic_type_parameter = SLANG_TYPE_KIND_GENERIC_TYPE_PARAMETER,
|
363
|
+
interface = SLANG_TYPE_KIND_INTERFACE,
|
364
|
+
output_stream = SLANG_TYPE_KIND_OUTPUT_STREAM,
|
365
|
+
specialized = SLANG_TYPE_KIND_SPECIALIZED,
|
366
|
+
feedback = SLANG_TYPE_KIND_FEEDBACK,
|
367
|
+
pointer = SLANG_TYPE_KIND_POINTER,
|
368
|
+
};
|
369
|
+
|
370
|
+
SGL_ENUM_INFO(
|
371
|
+
Kind,
|
372
|
+
{
|
373
|
+
{Kind::none, "none"},
|
374
|
+
{Kind::struct_, "struct"},
|
375
|
+
{Kind::array, "array"},
|
376
|
+
{Kind::matrix, "matrix"},
|
377
|
+
{Kind::vector, "vector"},
|
378
|
+
{Kind::scalar, "scalar"},
|
379
|
+
{Kind::constant_buffer, "constant_buffer"},
|
380
|
+
{Kind::resource, "resource"},
|
381
|
+
{Kind::sampler_state, "sampler_state"},
|
382
|
+
{Kind::texture_buffer, "texture_buffer"},
|
383
|
+
{Kind::shader_storage_buffer, "shader_storage_buffer"},
|
384
|
+
{Kind::parameter_block, "parameter_block"},
|
385
|
+
{Kind::generic_type_parameter, "generic_type_parameter"},
|
386
|
+
{Kind::interface, "interface"},
|
387
|
+
{Kind::output_stream, "output_stream"},
|
388
|
+
{Kind::specialized, "specialized"},
|
389
|
+
{Kind::feedback, "feedback"},
|
390
|
+
{Kind::pointer, "pointer"},
|
391
|
+
}
|
392
|
+
);
|
393
|
+
|
394
|
+
enum class ScalarType {
|
395
|
+
none_ = SLANG_SCALAR_TYPE_NONE,
|
396
|
+
void_ = SLANG_SCALAR_TYPE_VOID,
|
397
|
+
bool_ = SLANG_SCALAR_TYPE_BOOL,
|
398
|
+
int32 = SLANG_SCALAR_TYPE_INT32,
|
399
|
+
uint32 = SLANG_SCALAR_TYPE_UINT32,
|
400
|
+
int64 = SLANG_SCALAR_TYPE_INT64,
|
401
|
+
uint64 = SLANG_SCALAR_TYPE_UINT64,
|
402
|
+
float16 = SLANG_SCALAR_TYPE_FLOAT16,
|
403
|
+
float32 = SLANG_SCALAR_TYPE_FLOAT32,
|
404
|
+
float64 = SLANG_SCALAR_TYPE_FLOAT64,
|
405
|
+
int8 = SLANG_SCALAR_TYPE_INT8,
|
406
|
+
uint8 = SLANG_SCALAR_TYPE_UINT8,
|
407
|
+
int16 = SLANG_SCALAR_TYPE_INT16,
|
408
|
+
uint16 = SLANG_SCALAR_TYPE_UINT16,
|
409
|
+
intptr = SLANG_SCALAR_TYPE_INTPTR,
|
410
|
+
uintptr = SLANG_SCALAR_TYPE_UINTPTR,
|
411
|
+
COUNT,
|
412
|
+
};
|
413
|
+
|
414
|
+
SGL_ENUM_INFO(
|
415
|
+
ScalarType,
|
416
|
+
{
|
417
|
+
{ScalarType::none_, "none"},
|
418
|
+
{ScalarType::void_, "void"},
|
419
|
+
{ScalarType::bool_, "bool"},
|
420
|
+
{ScalarType::int32, "int32"},
|
421
|
+
{ScalarType::uint32, "uint32"},
|
422
|
+
{ScalarType::int64, "int64"},
|
423
|
+
{ScalarType::uint64, "uint64"},
|
424
|
+
{ScalarType::float16, "float16"},
|
425
|
+
{ScalarType::float32, "float32"},
|
426
|
+
{ScalarType::float64, "float64"},
|
427
|
+
{ScalarType::int8, "int8"},
|
428
|
+
{ScalarType::uint8, "uint8"},
|
429
|
+
{ScalarType::int16, "int16"},
|
430
|
+
{ScalarType::uint16, "uint16"},
|
431
|
+
}
|
432
|
+
);
|
433
|
+
|
434
|
+
enum class ResourceShape {
|
435
|
+
base_shape_mask = SLANG_RESOURCE_BASE_SHAPE_MASK,
|
436
|
+
|
437
|
+
none = SLANG_RESOURCE_NONE,
|
438
|
+
texture_1d = SLANG_TEXTURE_1D,
|
439
|
+
texture_2d = SLANG_TEXTURE_2D,
|
440
|
+
texture_3d = SLANG_TEXTURE_3D,
|
441
|
+
texture_cube = SLANG_TEXTURE_CUBE,
|
442
|
+
texture_buffer = SLANG_TEXTURE_BUFFER,
|
443
|
+
|
444
|
+
structured_buffer = SLANG_STRUCTURED_BUFFER,
|
445
|
+
byte_address_buffer = SLANG_BYTE_ADDRESS_BUFFER,
|
446
|
+
unknown = SLANG_RESOURCE_UNKNOWN,
|
447
|
+
acceleration_structure = SLANG_ACCELERATION_STRUCTURE,
|
448
|
+
|
449
|
+
ext_shape_mask = SLANG_RESOURCE_EXT_SHAPE_MASK,
|
450
|
+
|
451
|
+
texture_feedback_flag = SLANG_TEXTURE_FEEDBACK_FLAG,
|
452
|
+
texture_array_flag = SLANG_TEXTURE_ARRAY_FLAG,
|
453
|
+
texture_multisample_flag = SLANG_TEXTURE_MULTISAMPLE_FLAG,
|
454
|
+
|
455
|
+
texture_1d_array = texture_1d | texture_array_flag,
|
456
|
+
texture_2d_array = texture_2d | texture_array_flag,
|
457
|
+
texture_cube_array = texture_cube | texture_array_flag,
|
458
|
+
|
459
|
+
texture_2d_multisample = texture_2d | texture_multisample_flag,
|
460
|
+
texture_2d_multisample_array = texture_2d | texture_multisample_flag | texture_array_flag,
|
461
|
+
};
|
462
|
+
|
463
|
+
SGL_ENUM_INFO(
|
464
|
+
ResourceShape,
|
465
|
+
{
|
466
|
+
{ResourceShape::none, "none"},
|
467
|
+
{ResourceShape::texture_1d, "texture_1d"},
|
468
|
+
{ResourceShape::texture_2d, "texture_2d"},
|
469
|
+
{ResourceShape::texture_3d, "texture_3d"},
|
470
|
+
{ResourceShape::texture_cube, "texture_cube"},
|
471
|
+
{ResourceShape::texture_buffer, "texture_buffer"},
|
472
|
+
{ResourceShape::structured_buffer, "structured_buffer"},
|
473
|
+
{ResourceShape::byte_address_buffer, "byte_address_buffer"},
|
474
|
+
{ResourceShape::unknown, "unknown"},
|
475
|
+
{ResourceShape::acceleration_structure, "acceleration_structure"},
|
476
|
+
{ResourceShape::texture_feedback_flag, "texture_feedback_flag"},
|
477
|
+
{ResourceShape::texture_array_flag, "texture_array_flag"},
|
478
|
+
{ResourceShape::texture_multisample_flag, "texture_multisample_flag"},
|
479
|
+
{ResourceShape::texture_1d_array, "texture_1d_array"},
|
480
|
+
{ResourceShape::texture_2d_array, "texture_2d_array"},
|
481
|
+
{ResourceShape::texture_cube_array, "texture_cube_array"},
|
482
|
+
{ResourceShape::texture_2d_multisample, "texture_2d_multisample"},
|
483
|
+
{ResourceShape::texture_2d_multisample_array, "texture_2d_multisample_array"},
|
484
|
+
}
|
485
|
+
);
|
486
|
+
|
487
|
+
enum class ResourceAccess {
|
488
|
+
none = SLANG_RESOURCE_ACCESS_NONE,
|
489
|
+
read = SLANG_RESOURCE_ACCESS_READ,
|
490
|
+
read_write = SLANG_RESOURCE_ACCESS_READ_WRITE,
|
491
|
+
raster_ordered = SLANG_RESOURCE_ACCESS_RASTER_ORDERED,
|
492
|
+
access_append = SLANG_RESOURCE_ACCESS_APPEND,
|
493
|
+
access_consume = SLANG_RESOURCE_ACCESS_CONSUME,
|
494
|
+
access_write = SLANG_RESOURCE_ACCESS_WRITE,
|
495
|
+
};
|
496
|
+
|
497
|
+
SGL_ENUM_INFO(
|
498
|
+
ResourceAccess,
|
499
|
+
{
|
500
|
+
{ResourceAccess::none, "none"},
|
501
|
+
{ResourceAccess::read, "read"},
|
502
|
+
{ResourceAccess::read_write, "read_write"},
|
503
|
+
{ResourceAccess::raster_ordered, "raster_ordered"},
|
504
|
+
{ResourceAccess::access_append, "access_append"},
|
505
|
+
{ResourceAccess::access_consume, "access_consume"},
|
506
|
+
{ResourceAccess::access_write, "access_write"},
|
507
|
+
}
|
508
|
+
);
|
509
|
+
|
510
|
+
enum class ParameterCategory {
|
511
|
+
none = SLANG_PARAMETER_CATEGORY_NONE,
|
512
|
+
mixed = SLANG_PARAMETER_CATEGORY_MIXED,
|
513
|
+
constant_buffer = SLANG_PARAMETER_CATEGORY_CONSTANT_BUFFER,
|
514
|
+
shader_resource = SLANG_PARAMETER_CATEGORY_SHADER_RESOURCE,
|
515
|
+
unordered_access = SLANG_PARAMETER_CATEGORY_UNORDERED_ACCESS,
|
516
|
+
varying_input = SLANG_PARAMETER_CATEGORY_VARYING_INPUT,
|
517
|
+
varying_output = SLANG_PARAMETER_CATEGORY_VARYING_OUTPUT,
|
518
|
+
sampler_state = SLANG_PARAMETER_CATEGORY_SAMPLER_STATE,
|
519
|
+
uniform = SLANG_PARAMETER_CATEGORY_UNIFORM,
|
520
|
+
descriptor_table_slot = SLANG_PARAMETER_CATEGORY_DESCRIPTOR_TABLE_SLOT,
|
521
|
+
specialization_constant = SLANG_PARAMETER_CATEGORY_SPECIALIZATION_CONSTANT,
|
522
|
+
push_constant_buffer = SLANG_PARAMETER_CATEGORY_PUSH_CONSTANT_BUFFER,
|
523
|
+
register_space = SLANG_PARAMETER_CATEGORY_REGISTER_SPACE,
|
524
|
+
generic = SLANG_PARAMETER_CATEGORY_GENERIC,
|
525
|
+
ray_payload = SLANG_PARAMETER_CATEGORY_RAY_PAYLOAD,
|
526
|
+
hit_attributes = SLANG_PARAMETER_CATEGORY_HIT_ATTRIBUTES,
|
527
|
+
callable_payload = SLANG_PARAMETER_CATEGORY_CALLABLE_PAYLOAD,
|
528
|
+
shader_record = SLANG_PARAMETER_CATEGORY_SHADER_RECORD,
|
529
|
+
existential_type_param = SLANG_PARAMETER_CATEGORY_EXISTENTIAL_TYPE_PARAM,
|
530
|
+
existential_object_param = SLANG_PARAMETER_CATEGORY_EXISTENTIAL_OBJECT_PARAM,
|
531
|
+
};
|
532
|
+
|
533
|
+
SGL_ENUM_INFO(
|
534
|
+
ParameterCategory,
|
535
|
+
{
|
536
|
+
{ParameterCategory::none, "none"},
|
537
|
+
{ParameterCategory::mixed, "mixed"},
|
538
|
+
{ParameterCategory::constant_buffer, "constant_buffer"},
|
539
|
+
{ParameterCategory::shader_resource, "shader_resource"},
|
540
|
+
{ParameterCategory::unordered_access, "unordered_access"},
|
541
|
+
{ParameterCategory::varying_input, "varying_input"},
|
542
|
+
{ParameterCategory::varying_output, "varying_output"},
|
543
|
+
{ParameterCategory::sampler_state, "sampler_state"},
|
544
|
+
{ParameterCategory::uniform, "uniform"},
|
545
|
+
{ParameterCategory::descriptor_table_slot, "descriptor_table_slot"},
|
546
|
+
{ParameterCategory::specialization_constant, "specialization_constant"},
|
547
|
+
{ParameterCategory::push_constant_buffer, "push_constant_buffer"},
|
548
|
+
{ParameterCategory::register_space, "register_space"},
|
549
|
+
{ParameterCategory::generic, "generic"},
|
550
|
+
{ParameterCategory::ray_payload, "ray_payload"},
|
551
|
+
{ParameterCategory::hit_attributes, "hit_attributes"},
|
552
|
+
{ParameterCategory::callable_payload, "callable_payload"},
|
553
|
+
{ParameterCategory::shader_record, "shader_record"},
|
554
|
+
{ParameterCategory::existential_type_param, "existential_type_param"},
|
555
|
+
{ParameterCategory::existential_object_param, "existential_object_param"},
|
556
|
+
}
|
557
|
+
);
|
558
|
+
|
559
|
+
TypeReflection(ref<const Object> owner, slang::TypeReflection* target)
|
560
|
+
: BaseReflectionObjectImpl(std::move(owner), target)
|
561
|
+
{
|
562
|
+
}
|
563
|
+
|
564
|
+
Kind kind() const { return static_cast<Kind>(slang_target()->getKind()); }
|
565
|
+
|
566
|
+
char const* name() const { return slang_target()->getName(); }
|
567
|
+
|
568
|
+
std::string full_name() const;
|
569
|
+
|
570
|
+
bool is_struct() const { return kind() == Kind::struct_; }
|
571
|
+
|
572
|
+
uint32_t field_count() const
|
573
|
+
{
|
574
|
+
SGL_CHECK(is_struct(), "Type is not a struct");
|
575
|
+
return slang_target()->getFieldCount();
|
576
|
+
}
|
577
|
+
|
578
|
+
ref<const VariableReflection> get_field_by_index(uint32_t index) const
|
579
|
+
{
|
580
|
+
SGL_CHECK(is_struct(), "Type is not a struct");
|
581
|
+
return detail::from_slang(m_owner, slang_target()->getFieldByIndex(index));
|
582
|
+
}
|
583
|
+
|
584
|
+
TypeReflectionFieldList fields() const;
|
585
|
+
|
586
|
+
bool is_array() const { return kind() == Kind::array; }
|
587
|
+
|
588
|
+
size_t element_count() const
|
589
|
+
{
|
590
|
+
SGL_CHECK(is_array(), "Type is not an array");
|
591
|
+
return slang_target()->getElementCount();
|
592
|
+
}
|
593
|
+
|
594
|
+
size_t total_element_count() const
|
595
|
+
{
|
596
|
+
SGL_CHECK(is_array(), "Type is not an array");
|
597
|
+
size_t result = 1;
|
598
|
+
ref<const TypeReflection> type = ref(this);
|
599
|
+
while (type->is_array()) {
|
600
|
+
result *= type->element_count();
|
601
|
+
type = type->element_type();
|
602
|
+
}
|
603
|
+
return result;
|
604
|
+
}
|
605
|
+
|
606
|
+
ref<const TypeReflection> element_type() const
|
607
|
+
{
|
608
|
+
SGL_CHECK(is_array(), "Type is not an array");
|
609
|
+
return detail::from_slang(m_owner, slang_target()->getElementType());
|
610
|
+
}
|
611
|
+
|
612
|
+
ref<const TypeReflection> unwrap_array() const
|
613
|
+
{
|
614
|
+
ref<const TypeReflection> type = ref(this);
|
615
|
+
while (type->is_array()) {
|
616
|
+
type = type->element_type();
|
617
|
+
}
|
618
|
+
return type;
|
619
|
+
}
|
620
|
+
|
621
|
+
uint32_t row_count() const { return slang_target()->getRowCount(); }
|
622
|
+
|
623
|
+
uint32_t col_count() const { return slang_target()->getColumnCount(); }
|
624
|
+
|
625
|
+
ScalarType scalar_type() const { return static_cast<ScalarType>(slang_target()->getScalarType()); }
|
626
|
+
|
627
|
+
ref<const TypeReflection> resource_result_type() const
|
628
|
+
{
|
629
|
+
return detail::from_slang(m_owner, slang_target()->getResourceResultType());
|
630
|
+
}
|
631
|
+
|
632
|
+
ResourceShape resource_shape() const { return static_cast<ResourceShape>(slang_target()->getResourceShape()); }
|
633
|
+
|
634
|
+
ResourceAccess resource_access() const { return static_cast<ResourceAccess>(slang_target()->getResourceAccess()); }
|
635
|
+
|
636
|
+
#if 0
|
637
|
+
unsigned int getUserAttributeCount() { return spReflectionType_GetUserAttributeCount((SlangReflectionType*)this); }
|
638
|
+
UserAttribute* getUserAttributeByIndex(unsigned int index)
|
639
|
+
{
|
640
|
+
return (UserAttribute*)spReflectionType_GetUserAttribute((SlangReflectionType*)this, index);
|
641
|
+
}
|
642
|
+
UserAttribute* findUserAttributeByName(char const* name)
|
643
|
+
{
|
644
|
+
return (UserAttribute*)spReflectionType_FindUserAttributeByName((SlangReflectionType*)this, name);
|
645
|
+
}
|
646
|
+
#endif
|
647
|
+
|
648
|
+
std::string to_string() const;
|
649
|
+
};
|
650
|
+
|
651
|
+
SGL_ENUM_CLASS_OPERATORS(TypeReflection::ResourceShape);
|
652
|
+
|
653
|
+
SGL_ENUM_REGISTER(TypeReflection::Kind);
|
654
|
+
SGL_ENUM_REGISTER(TypeReflection::ScalarType);
|
655
|
+
SGL_ENUM_REGISTER(TypeReflection::ResourceShape);
|
656
|
+
SGL_ENUM_REGISTER(TypeReflection::ResourceAccess);
|
657
|
+
SGL_ENUM_REGISTER(TypeReflection::ParameterCategory);
|
658
|
+
|
659
|
+
/// TypeReflection lazy field list evaluation.
|
660
|
+
class SGL_API TypeReflectionFieldList : public BaseReflectionList<TypeReflection, VariableReflection> {
|
661
|
+
|
662
|
+
public:
|
663
|
+
TypeReflectionFieldList(ref<const TypeReflection> owner)
|
664
|
+
: BaseReflectionList(std::move(owner))
|
665
|
+
{
|
666
|
+
}
|
667
|
+
|
668
|
+
/// Number of entries in list.
|
669
|
+
uint32_t size() const override { return m_owner->field_count(); }
|
670
|
+
|
671
|
+
protected:
|
672
|
+
/// Get a specific child.
|
673
|
+
ref<const VariableReflection> evaluate(uint32_t index) const override { return m_owner->get_field_by_index(index); }
|
674
|
+
};
|
675
|
+
|
676
|
+
|
677
|
+
class SGL_API TypeLayoutReflection : public BaseReflectionObjectImpl<slang::TypeLayoutReflection> {
|
678
|
+
public:
|
679
|
+
static ref<const TypeLayoutReflection>
|
680
|
+
from_slang(ref<const Object> owner, slang::TypeLayoutReflection* type_layout_reflection)
|
681
|
+
{
|
682
|
+
return detail::from_slang(std::move(owner), type_layout_reflection);
|
683
|
+
}
|
684
|
+
|
685
|
+
TypeLayoutReflection(ref<const Object> owner, slang::TypeLayoutReflection* target)
|
686
|
+
: BaseReflectionObjectImpl(std::move(owner), target)
|
687
|
+
{
|
688
|
+
}
|
689
|
+
|
690
|
+
slang::TypeLayoutReflection* get_slang_type_layout() const { return slang_target(); }
|
691
|
+
|
692
|
+
ref<const TypeReflection> type() const { return detail::from_slang(m_owner, slang_target()->getType()); }
|
693
|
+
|
694
|
+
TypeReflection::Kind kind() const { return static_cast<TypeReflection::Kind>(slang_target()->getKind()); }
|
695
|
+
|
696
|
+
const char* name() const { return slang_target()->getName(); }
|
697
|
+
|
698
|
+
size_t size() const { return slang_target()->getSize(SlangParameterCategory::SLANG_PARAMETER_CATEGORY_UNIFORM); }
|
699
|
+
size_t stride() const
|
700
|
+
{
|
701
|
+
return slang_target()->getStride(SlangParameterCategory::SLANG_PARAMETER_CATEGORY_UNIFORM);
|
702
|
+
}
|
703
|
+
int32_t alignment() const
|
704
|
+
{
|
705
|
+
return slang_target()->getAlignment(SlangParameterCategory::SLANG_PARAMETER_CATEGORY_UNIFORM);
|
706
|
+
}
|
707
|
+
|
708
|
+
uint32_t field_count() const { return slang_target()->getFieldCount(); }
|
709
|
+
|
710
|
+
ref<const VariableLayoutReflection> get_field_by_index(uint32_t index) const
|
711
|
+
{
|
712
|
+
// TODO field_count() does not always return the right number of fields
|
713
|
+
// SGL_CHECK(index < field_count(), "Field index out of range");
|
714
|
+
return detail::from_slang(m_owner, slang_target()->getFieldByIndex(index));
|
715
|
+
}
|
716
|
+
|
717
|
+
int32_t find_field_index_by_name(const char* name_begin, const char* name_end = nullptr) const
|
718
|
+
{
|
719
|
+
return narrow_cast<int32_t>(slang_target()->findFieldIndexByName(name_begin, name_end));
|
720
|
+
}
|
721
|
+
|
722
|
+
ref<const VariableLayoutReflection> find_field_by_name(const char* name_begin, const char* name_end = nullptr) const
|
723
|
+
{
|
724
|
+
if (auto index = slang_target()->findFieldIndexByName(name_begin, name_end); index >= 0)
|
725
|
+
return detail::from_slang(m_owner, slang_target()->getFieldByIndex(narrow_cast<unsigned int>(index)));
|
726
|
+
return nullptr;
|
727
|
+
}
|
728
|
+
|
729
|
+
TypeLayoutReflectionFieldList fields() const;
|
730
|
+
|
731
|
+
bool is_array() const { return kind() == TypeReflection::Kind::array; }
|
732
|
+
|
733
|
+
ref<const TypeLayoutReflection> unwrap_array() const
|
734
|
+
{
|
735
|
+
ref<const TypeLayoutReflection> type_layout = ref(this);
|
736
|
+
while (type_layout->is_array()) {
|
737
|
+
type_layout = type_layout->element_type_layout();
|
738
|
+
}
|
739
|
+
return type_layout;
|
740
|
+
}
|
741
|
+
|
742
|
+
size_t element_count() const { return slang_target()->getElementCount(); }
|
743
|
+
|
744
|
+
size_t element_stride(TypeReflection::ParameterCategory category = TypeReflection::ParameterCategory::uniform) const
|
745
|
+
{
|
746
|
+
return slang_target()->getElementStride(static_cast<SlangParameterCategory>(category));
|
747
|
+
}
|
748
|
+
|
749
|
+
ref<const TypeLayoutReflection> element_type_layout() const
|
750
|
+
{
|
751
|
+
return detail::from_slang(m_owner, slang_target()->getElementTypeLayout());
|
752
|
+
}
|
753
|
+
|
754
|
+
ref<const VariableLayoutReflection> element_var_layout() const
|
755
|
+
{
|
756
|
+
return detail::from_slang(m_owner, slang_target()->getElementVarLayout());
|
757
|
+
}
|
758
|
+
|
759
|
+
ref<const VariableLayoutReflection> container_var_layout() const
|
760
|
+
{
|
761
|
+
return detail::from_slang(m_owner, slang_target()->getContainerVarLayout());
|
762
|
+
}
|
763
|
+
|
764
|
+
// How is this type supposed to be bound?
|
765
|
+
TypeReflection::ParameterCategory parameter_category() const
|
766
|
+
{
|
767
|
+
return static_cast<TypeReflection::ParameterCategory>(slang_target()->getParameterCategory());
|
768
|
+
}
|
769
|
+
|
770
|
+
uint32_t get_field_binding_range_offset(uint32_t field_index) const
|
771
|
+
{
|
772
|
+
return narrow_cast<uint32_t>(slang_target()->getFieldBindingRangeOffset(field_index));
|
773
|
+
}
|
774
|
+
|
775
|
+
std::string to_string() const;
|
776
|
+
};
|
777
|
+
|
778
|
+
/// TypeLayoutReflection lazy field list evaluation.
|
779
|
+
class SGL_API TypeLayoutReflectionFieldList
|
780
|
+
: public BaseReflectionList<TypeLayoutReflection, VariableLayoutReflection> {
|
781
|
+
|
782
|
+
public:
|
783
|
+
TypeLayoutReflectionFieldList(ref<const TypeLayoutReflection> owner)
|
784
|
+
: BaseReflectionList(std::move(owner))
|
785
|
+
{
|
786
|
+
}
|
787
|
+
|
788
|
+
/// Number of entries in list.
|
789
|
+
uint32_t size() const override { return m_owner->field_count(); }
|
790
|
+
|
791
|
+
protected:
|
792
|
+
/// Get a specific child.
|
793
|
+
ref<const VariableLayoutReflection> evaluate(uint32_t index) const override
|
794
|
+
{
|
795
|
+
return m_owner->get_field_by_index(index);
|
796
|
+
}
|
797
|
+
};
|
798
|
+
|
799
|
+
class SGL_API FunctionReflection : public BaseReflectionObjectImpl<slang::FunctionReflection> {
|
800
|
+
public:
|
801
|
+
FunctionReflection(ref<const Object> owner, slang::FunctionReflection* target)
|
802
|
+
: BaseReflectionObjectImpl(std::move(owner), target)
|
803
|
+
{
|
804
|
+
}
|
805
|
+
|
806
|
+
/// Function name.
|
807
|
+
char const* name() const { return slang_target()->getName(); }
|
808
|
+
|
809
|
+
/// Function return type.
|
810
|
+
ref<const TypeReflection> return_type() { return detail::from_slang(m_owner, slang_target()->getReturnType()); }
|
811
|
+
|
812
|
+
/// Number of function parameters.
|
813
|
+
uint32_t parameter_count() const { return slang_target()->getParameterCount(); }
|
814
|
+
|
815
|
+
/// Get a single parameter.
|
816
|
+
ref<const VariableReflection> get_parameter_by_index(uint32_t index) const
|
817
|
+
{
|
818
|
+
SGL_CHECK(index < parameter_count(), "Parameter index out of range");
|
819
|
+
return detail::from_slang(m_owner, slang_target()->getParameterByIndex(index));
|
820
|
+
}
|
821
|
+
|
822
|
+
/// List of all function parameters.
|
823
|
+
FunctionReflectionParameterList parameters() const;
|
824
|
+
|
825
|
+
/// Check if the function has a given modifier (e.g. 'differentiable').
|
826
|
+
bool has_modifier(ModifierID modifier) const
|
827
|
+
{
|
828
|
+
return slang_target()->findModifier(static_cast<slang::Modifier::ID>(modifier)) != nullptr;
|
829
|
+
}
|
830
|
+
|
831
|
+
/// Specialize a generic or interface based function with a set of concrete
|
832
|
+
/// argument types. Calling on a none-generic/interface function will simply
|
833
|
+
/// validate all argument types can be implicitly converted to their respective
|
834
|
+
/// parameter types. Where a function contains multiple overloads, specialize
|
835
|
+
/// will identify the correct overload based on the arguments.
|
836
|
+
ref<const FunctionReflection> specialize_with_arg_types(const std::vector<ref<TypeReflection>>& types) const
|
837
|
+
{
|
838
|
+
if (types.empty()) {
|
839
|
+
return detail::from_slang(m_owner, slang_target()->specializeWithArgTypes(0, nullptr));
|
840
|
+
} else {
|
841
|
+
std::vector<slang::TypeReflection*> slang_types;
|
842
|
+
slang_types.reserve(types.size());
|
843
|
+
for (const auto& type : types) {
|
844
|
+
SGL_CHECK(type, "Null type provided to specialize_with_arg_types");
|
845
|
+
slang_types.push_back(type->slang_target());
|
846
|
+
}
|
847
|
+
|
848
|
+
return detail::from_slang(
|
849
|
+
m_owner,
|
850
|
+
slang_target()->specializeWithArgTypes((uint32_t)slang_types.size(), &slang_types[0])
|
851
|
+
);
|
852
|
+
}
|
853
|
+
}
|
854
|
+
|
855
|
+
/// Check whether this function object represents a group of overloaded functions,
|
856
|
+
/// accessible via the overloads list.
|
857
|
+
bool is_overloaded() const { return slang_target()->isOverloaded(); }
|
858
|
+
|
859
|
+
/// Get number of available overloads of this function.
|
860
|
+
uint32_t overload_count() const { return is_overloaded() ? slang_target()->getOverloadCount() : 0; }
|
861
|
+
|
862
|
+
/// Get a given overload of this function.
|
863
|
+
ref<const FunctionReflection> get_overload_by_index(uint32_t index) const
|
864
|
+
{
|
865
|
+
return detail::from_slang(m_owner, slang_target()->getOverload(index));
|
866
|
+
}
|
867
|
+
|
868
|
+
/// List of all overloads of this function.
|
869
|
+
FunctionReflectionOverloadList overloads() const;
|
870
|
+
};
|
871
|
+
|
872
|
+
/// FunctionReflection lazy parameter list evaluation.
|
873
|
+
class SGL_API FunctionReflectionParameterList : public BaseReflectionList<FunctionReflection, VariableReflection> {
|
874
|
+
|
875
|
+
public:
|
876
|
+
FunctionReflectionParameterList(ref<const FunctionReflection> owner)
|
877
|
+
: BaseReflectionList(std::move(owner))
|
878
|
+
{
|
879
|
+
}
|
880
|
+
|
881
|
+
/// Number of entries in list.
|
882
|
+
uint32_t size() const override { return m_owner->parameter_count(); }
|
883
|
+
|
884
|
+
protected:
|
885
|
+
/// Get a specific child.
|
886
|
+
ref<const VariableReflection> evaluate(uint32_t index) const override
|
887
|
+
{
|
888
|
+
return m_owner->get_parameter_by_index(index);
|
889
|
+
}
|
890
|
+
};
|
891
|
+
|
892
|
+
/// FunctionReflection lazy overload list evaluation.
|
893
|
+
class SGL_API FunctionReflectionOverloadList : public BaseReflectionList<FunctionReflection, FunctionReflection> {
|
894
|
+
|
895
|
+
public:
|
896
|
+
FunctionReflectionOverloadList(ref<const FunctionReflection> owner)
|
897
|
+
: BaseReflectionList(std::move(owner))
|
898
|
+
{
|
899
|
+
}
|
900
|
+
|
901
|
+
/// Number of entries in list.
|
902
|
+
uint32_t size() const override { return m_owner->overload_count(); }
|
903
|
+
|
904
|
+
protected:
|
905
|
+
/// Get a specific child.
|
906
|
+
ref<const FunctionReflection> evaluate(uint32_t index) const override
|
907
|
+
{
|
908
|
+
return m_owner->get_overload_by_index(index);
|
909
|
+
}
|
910
|
+
};
|
911
|
+
|
912
|
+
class SGL_API VariableReflection : public BaseReflectionObjectImpl<slang::VariableReflection> {
|
913
|
+
public:
|
914
|
+
static ref<const VariableReflection>
|
915
|
+
from_slang(ref<const Object> owner, slang::VariableReflection* variable_reflection)
|
916
|
+
{
|
917
|
+
return detail::from_slang(std::move(owner), variable_reflection);
|
918
|
+
}
|
919
|
+
|
920
|
+
VariableReflection(ref<const Object> owner, slang::VariableReflection* target)
|
921
|
+
: BaseReflectionObjectImpl(std::move(owner), target)
|
922
|
+
{
|
923
|
+
}
|
924
|
+
|
925
|
+
/// Variable name.
|
926
|
+
const char* name() const { return slang_target()->getName(); }
|
927
|
+
|
928
|
+
/// Variable type reflection.
|
929
|
+
ref<const TypeReflection> type() const { return detail::from_slang(m_owner, slang_target()->getType()); }
|
930
|
+
|
931
|
+
/// Check if variable has a given modifier (e.g. 'inout').
|
932
|
+
bool has_modifier(ModifierID modifier) const
|
933
|
+
{
|
934
|
+
return slang_target()->findModifier(static_cast<slang::Modifier::ID>(modifier)) != nullptr;
|
935
|
+
}
|
936
|
+
};
|
937
|
+
|
938
|
+
class SGL_API VariableLayoutReflection : public BaseReflectionObjectImpl<slang::VariableLayoutReflection> {
|
939
|
+
public:
|
940
|
+
VariableLayoutReflection(ref<const Object> owner, slang::VariableLayoutReflection* target)
|
941
|
+
: BaseReflectionObjectImpl(std::move(owner), target)
|
942
|
+
{
|
943
|
+
}
|
944
|
+
|
945
|
+
ref<const VariableReflection> variable() const
|
946
|
+
{
|
947
|
+
return detail::from_slang(m_owner, slang_target()->getVariable());
|
948
|
+
}
|
949
|
+
|
950
|
+
const char* name() const { return slang_target()->getName(); }
|
951
|
+
|
952
|
+
ref<const TypeLayoutReflection> type_layout() const
|
953
|
+
{
|
954
|
+
return detail::from_slang(m_owner, slang_target()->getTypeLayout());
|
955
|
+
}
|
956
|
+
|
957
|
+
size_t offset() const
|
958
|
+
{
|
959
|
+
return slang_target()->getOffset(SlangParameterCategory::SLANG_PARAMETER_CATEGORY_UNIFORM);
|
960
|
+
}
|
961
|
+
|
962
|
+
std::string to_string() const;
|
963
|
+
};
|
964
|
+
|
965
|
+
class SGL_API EntryPointLayout : public BaseReflectionObjectImpl<slang::EntryPointLayout> {
|
966
|
+
public:
|
967
|
+
static ref<const EntryPointLayout>
|
968
|
+
from_slang(ref<const Object> owner, slang::EntryPointLayout* entry_point_reflection)
|
969
|
+
{
|
970
|
+
return detail::from_slang(std::move(owner), entry_point_reflection);
|
971
|
+
}
|
972
|
+
|
973
|
+
EntryPointLayout(ref<const Object> owner, slang::EntryPointLayout* target)
|
974
|
+
: BaseReflectionObjectImpl(std::move(owner), target)
|
975
|
+
{
|
976
|
+
}
|
977
|
+
|
978
|
+
const char* name() const { return slang_target()->getName(); }
|
979
|
+
|
980
|
+
const char* name_override() const { return slang_target()->getNameOverride(); }
|
981
|
+
|
982
|
+
ShaderStage stage() const { return static_cast<ShaderStage>(slang_target()->getStage()); }
|
983
|
+
|
984
|
+
uint32_t parameter_count() const { return slang_target()->getParameterCount(); }
|
985
|
+
|
986
|
+
ref<const VariableLayoutReflection> get_parameter_by_index(uint32_t index) const
|
987
|
+
{
|
988
|
+
SGL_CHECK(index < parameter_count(), "Parameter index out of range");
|
989
|
+
return detail::from_slang(m_owner, slang_target()->getParameterByIndex(index));
|
990
|
+
}
|
991
|
+
|
992
|
+
EntryPointLayoutParameterList parameters() const;
|
993
|
+
|
994
|
+
uint3 compute_thread_group_size() const
|
995
|
+
{
|
996
|
+
SlangUInt size[3];
|
997
|
+
slang_target()->getComputeThreadGroupSize(3, size);
|
998
|
+
return uint3(narrow_cast<uint32_t>(size[0]), narrow_cast<uint32_t>(size[1]), narrow_cast<uint32_t>(size[2]));
|
999
|
+
}
|
1000
|
+
|
1001
|
+
bool uses_any_sample_rate_input() const { return slang_target()->usesAnySampleRateInput(); }
|
1002
|
+
|
1003
|
+
std::string to_string() const;
|
1004
|
+
};
|
1005
|
+
|
1006
|
+
|
1007
|
+
/// EntryPointLayout lazy parameter list evaluation.
|
1008
|
+
class SGL_API EntryPointLayoutParameterList : public BaseReflectionList<EntryPointLayout, VariableLayoutReflection> {
|
1009
|
+
|
1010
|
+
public:
|
1011
|
+
EntryPointLayoutParameterList(ref<const EntryPointLayout> owner)
|
1012
|
+
: BaseReflectionList(std::move(owner))
|
1013
|
+
{
|
1014
|
+
}
|
1015
|
+
|
1016
|
+
/// Number of entries in list.
|
1017
|
+
uint32_t size() const override { return m_owner->parameter_count(); }
|
1018
|
+
|
1019
|
+
protected:
|
1020
|
+
/// Get a specific child.
|
1021
|
+
ref<const VariableLayoutReflection> evaluate(uint32_t index) const override
|
1022
|
+
{
|
1023
|
+
return m_owner->get_parameter_by_index(index);
|
1024
|
+
}
|
1025
|
+
};
|
1026
|
+
|
1027
|
+
|
1028
|
+
class SGL_API ProgramLayout : public BaseReflectionObjectImpl<slang::ProgramLayout> {
|
1029
|
+
public:
|
1030
|
+
static ref<const ProgramLayout> from_slang(ref<const Object> owner, slang::ProgramLayout* program_layout)
|
1031
|
+
{
|
1032
|
+
return detail::from_slang(owner, program_layout);
|
1033
|
+
}
|
1034
|
+
|
1035
|
+
ProgramLayout(ref<const Object> owner, slang::ProgramLayout* target)
|
1036
|
+
: BaseReflectionObjectImpl(std::move(owner), target)
|
1037
|
+
{
|
1038
|
+
}
|
1039
|
+
|
1040
|
+
ref<const TypeLayoutReflection> globals_type_layout() const
|
1041
|
+
{
|
1042
|
+
return detail::from_slang(m_owner, slang_target()->getGlobalParamsTypeLayout());
|
1043
|
+
}
|
1044
|
+
|
1045
|
+
ref<const VariableLayoutReflection> globals_variable_layout() const
|
1046
|
+
{
|
1047
|
+
return detail::from_slang(m_owner, slang_target()->getGlobalParamsVarLayout());
|
1048
|
+
}
|
1049
|
+
|
1050
|
+
uint32_t parameter_count() const { return slang_target()->getParameterCount(); }
|
1051
|
+
|
1052
|
+
ref<const VariableLayoutReflection> get_parameter_by_index(uint32_t index) const
|
1053
|
+
{
|
1054
|
+
SGL_CHECK(index < parameter_count(), "Parameter index out of range");
|
1055
|
+
return detail::from_slang(m_owner, slang_target()->getParameterByIndex(index));
|
1056
|
+
}
|
1057
|
+
|
1058
|
+
ProgramLayoutParameterList parameters() const;
|
1059
|
+
|
1060
|
+
uint32_t type_parameter_count() const { return slang_target()->getTypeParameterCount(); }
|
1061
|
+
|
1062
|
+
uint32_t entry_point_count() const { return narrow_cast<uint32_t>(slang_target()->getEntryPointCount()); }
|
1063
|
+
|
1064
|
+
ref<const EntryPointLayout> get_entry_point_by_index(uint32_t index) const
|
1065
|
+
{
|
1066
|
+
SGL_CHECK(index < entry_point_count(), "Entry point index out of range");
|
1067
|
+
return detail::from_slang(m_owner, slang_target()->getEntryPointByIndex(index));
|
1068
|
+
}
|
1069
|
+
|
1070
|
+
ref<const EntryPointLayout> get_entry_point_by_name(const char* name) const
|
1071
|
+
{
|
1072
|
+
return detail::from_slang(m_owner, slang_target()->findEntryPointByName(name));
|
1073
|
+
}
|
1074
|
+
|
1075
|
+
ref<const EntryPointLayout> get_entry_point_by_name(std::string_view name) const
|
1076
|
+
{
|
1077
|
+
std::string name_str(name);
|
1078
|
+
return get_entry_point_by_name(name_str.c_str());
|
1079
|
+
}
|
1080
|
+
|
1081
|
+
ref<const EntryPointLayout> find_entry_point_by_name(const char* name) const
|
1082
|
+
{
|
1083
|
+
if (auto entry_point = slang_target()->findEntryPointByName(name)) {
|
1084
|
+
return detail::from_slang(m_owner, entry_point);
|
1085
|
+
}
|
1086
|
+
return nullptr;
|
1087
|
+
}
|
1088
|
+
|
1089
|
+
ref<const EntryPointLayout> find_entry_point_by_name(std::string_view name) const
|
1090
|
+
{
|
1091
|
+
std::string name_str(name);
|
1092
|
+
return find_entry_point_by_name(name_str.c_str());
|
1093
|
+
}
|
1094
|
+
|
1095
|
+
ProgramLayoutEntryPointList entry_points() const;
|
1096
|
+
|
1097
|
+
/// Find a given type by name. Handles generic specilization if generic
|
1098
|
+
/// variable values are provided.
|
1099
|
+
ref<const TypeReflection> find_type_by_name(const char* name) const
|
1100
|
+
{
|
1101
|
+
return detail::from_slang(m_owner, slang_target()->findTypeByName(name));
|
1102
|
+
}
|
1103
|
+
|
1104
|
+
/// Find a given function by name. Handles generic specilization if generic
|
1105
|
+
/// variable values are provided.
|
1106
|
+
ref<const FunctionReflection> find_function_by_name(const char* name)
|
1107
|
+
{
|
1108
|
+
return detail::from_slang(m_owner, slang_target()->findFunctionByName(name));
|
1109
|
+
}
|
1110
|
+
|
1111
|
+
/// Find a given function in a type by name. Handles generic specilization if generic
|
1112
|
+
/// variable values are provided.
|
1113
|
+
ref<const FunctionReflection> find_function_by_name_in_type(const TypeReflection* type, const char* name)
|
1114
|
+
{
|
1115
|
+
return detail::from_slang(m_owner, slang_target()->findFunctionByNameInType(type->slang_target(), name));
|
1116
|
+
}
|
1117
|
+
|
1118
|
+
/// Test whether a type is a sub type of another type. Handles both
|
1119
|
+
/// struct inheritance and interface implementation.
|
1120
|
+
bool is_sub_type(const TypeReflection* sub_type, const TypeReflection* super_type)
|
1121
|
+
{
|
1122
|
+
return slang_target()->isSubType(sub_type->slang_target(), super_type->slang_target());
|
1123
|
+
}
|
1124
|
+
|
1125
|
+
/// Get corresponding type layout from a given type.
|
1126
|
+
ref<const TypeLayoutReflection> get_type_layout(const TypeReflection* type)
|
1127
|
+
{
|
1128
|
+
// TODO: Once device is available via session reference, pass metal layout rules for metal target
|
1129
|
+
return detail::from_slang(
|
1130
|
+
m_owner,
|
1131
|
+
slang_target()->getTypeLayout(type->slang_target(), slang::LayoutRules::Default)
|
1132
|
+
);
|
1133
|
+
}
|
1134
|
+
|
1135
|
+
uint32_t hashed_string_count() const { return narrow_cast<uint32_t>(slang_target()->getHashedStringCount()); }
|
1136
|
+
|
1137
|
+
struct HashedString {
|
1138
|
+
std::string string;
|
1139
|
+
uint32_t hash;
|
1140
|
+
};
|
1141
|
+
|
1142
|
+
HashedString get_hashed_string(uint32_t index) const
|
1143
|
+
{
|
1144
|
+
SGL_CHECK(index < hashed_string_count(), "Hashed string index out of range");
|
1145
|
+
size_t size;
|
1146
|
+
const char* str = slang_target()->getHashedString(index, &size);
|
1147
|
+
return {std::string(str, str + size), spComputeStringHash(str, size)};
|
1148
|
+
}
|
1149
|
+
|
1150
|
+
std::vector<HashedString> hashed_strings() const
|
1151
|
+
{
|
1152
|
+
std::vector<HashedString> result;
|
1153
|
+
for (uint32_t i = 0; i < slang_target()->getHashedStringCount(); ++i) {
|
1154
|
+
size_t size;
|
1155
|
+
const char* str = slang_target()->getHashedString(i, &size);
|
1156
|
+
result.push_back({std::string(str, str + size), spComputeStringHash(str, size)});
|
1157
|
+
}
|
1158
|
+
return result;
|
1159
|
+
}
|
1160
|
+
|
1161
|
+
std::map<uint32_t, std::string> hashed_strings_map() const
|
1162
|
+
{
|
1163
|
+
std::map<uint32_t, std::string> result;
|
1164
|
+
for (uint32_t i = 0; i < slang_target()->getHashedStringCount(); ++i) {
|
1165
|
+
size_t size;
|
1166
|
+
const char* str = slang_target()->getHashedString(i, &size);
|
1167
|
+
uint32_t hash = spComputeStringHash(str, size);
|
1168
|
+
result.emplace(hash, std::string(str, str + size));
|
1169
|
+
}
|
1170
|
+
return result;
|
1171
|
+
}
|
1172
|
+
|
1173
|
+
std::string to_string() const;
|
1174
|
+
};
|
1175
|
+
|
1176
|
+
/// ProgramLayout lazy parameter list evaluation.
|
1177
|
+
class SGL_API ProgramLayoutParameterList : public BaseReflectionList<ProgramLayout, VariableLayoutReflection> {
|
1178
|
+
|
1179
|
+
public:
|
1180
|
+
ProgramLayoutParameterList(ref<const ProgramLayout> owner)
|
1181
|
+
: BaseReflectionList(std::move(owner))
|
1182
|
+
{
|
1183
|
+
}
|
1184
|
+
|
1185
|
+
/// Number of entries in list.
|
1186
|
+
uint32_t size() const override { return m_owner->parameter_count(); }
|
1187
|
+
|
1188
|
+
protected:
|
1189
|
+
/// Get a specific child.
|
1190
|
+
ref<const VariableLayoutReflection> evaluate(uint32_t index) const override
|
1191
|
+
{
|
1192
|
+
return m_owner->get_parameter_by_index(index);
|
1193
|
+
}
|
1194
|
+
};
|
1195
|
+
|
1196
|
+
/// ProgramLayout lazy entry point list evaluation.
|
1197
|
+
class SGL_API ProgramLayoutEntryPointList : public BaseReflectionList<ProgramLayout, EntryPointLayout> {
|
1198
|
+
|
1199
|
+
public:
|
1200
|
+
ProgramLayoutEntryPointList(ref<const ProgramLayout> owner)
|
1201
|
+
: BaseReflectionList(std::move(owner))
|
1202
|
+
{
|
1203
|
+
}
|
1204
|
+
|
1205
|
+
/// Number of entries in list.
|
1206
|
+
uint32_t size() const override { return m_owner->entry_point_count(); }
|
1207
|
+
|
1208
|
+
protected:
|
1209
|
+
/// Get a specific child.
|
1210
|
+
ref<const EntryPointLayout> evaluate(uint32_t index) const override
|
1211
|
+
{
|
1212
|
+
return m_owner->get_entry_point_by_index(index);
|
1213
|
+
}
|
1214
|
+
};
|
1215
|
+
|
1216
|
+
|
1217
|
+
class ShaderProgram;
|
1218
|
+
|
1219
|
+
class SGL_API ReflectionCursor {
|
1220
|
+
public:
|
1221
|
+
ReflectionCursor() = default;
|
1222
|
+
|
1223
|
+
ReflectionCursor(const ShaderProgram* shader_program);
|
1224
|
+
ReflectionCursor(ref<const EntryPointLayout> entry_point_layout);
|
1225
|
+
ReflectionCursor(const TypeLayoutReflection* type_layout);
|
1226
|
+
|
1227
|
+
ref<const TypeLayoutReflection> type_layout() const { return m_type_layout; }
|
1228
|
+
ref<const TypeReflection> type() const { return m_type_layout->type(); }
|
1229
|
+
|
1230
|
+
bool is_valid() const { return m_valid; }
|
1231
|
+
|
1232
|
+
// operator bool() const { return is_valid(); }
|
1233
|
+
|
1234
|
+
operator ref<const TypeLayoutReflection>() const { return type_layout(); }
|
1235
|
+
|
1236
|
+
ReflectionCursor operator[](std::string_view name) const;
|
1237
|
+
ReflectionCursor operator[](uint32_t index) const;
|
1238
|
+
|
1239
|
+
ReflectionCursor find_field(std::string_view name) const;
|
1240
|
+
ReflectionCursor find_element(uint32_t index) const;
|
1241
|
+
|
1242
|
+
bool has_field(std::string_view name) const { return find_field(name).is_valid(); }
|
1243
|
+
bool has_element(uint32_t index) const { return find_element(index).is_valid(); }
|
1244
|
+
|
1245
|
+
std::string to_string() const;
|
1246
|
+
|
1247
|
+
private:
|
1248
|
+
const ShaderProgram* m_shader_program{nullptr};
|
1249
|
+
ref<const EntryPointLayout> m_entry_point_layout{nullptr};
|
1250
|
+
ref<const TypeLayoutReflection> m_type_layout{nullptr};
|
1251
|
+
bool m_valid{false};
|
1252
|
+
};
|
1253
|
+
|
1254
|
+
} // namespace sgl
|