nv-sgl 0.6.0__cp313-cp313-win_amd64.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. include/tevclient.h +393 -0
  2. nv_sgl-0.6.0.dist-info/LICENSE +29 -0
  3. nv_sgl-0.6.0.dist-info/METADATA +21 -0
  4. nv_sgl-0.6.0.dist-info/RECORD +142 -0
  5. nv_sgl-0.6.0.dist-info/WHEEL +5 -0
  6. nv_sgl-0.6.0.dist-info/top_level.txt +1 -0
  7. sgl/__init__.py +15 -0
  8. sgl/__init__.pyi +6738 -0
  9. sgl/d3d12/D3D12Core.dll +0 -0
  10. sgl/d3d12/d3d12SDKLayers.dll +0 -0
  11. sgl/dxcompiler.dll +0 -0
  12. sgl/dxil.dll +0 -0
  13. sgl/gfx.dll +0 -0
  14. sgl/include/sgl/app/app.h +113 -0
  15. sgl/include/sgl/core/bitmap.h +302 -0
  16. sgl/include/sgl/core/crypto.h +89 -0
  17. sgl/include/sgl/core/data_type.h +46 -0
  18. sgl/include/sgl/core/dds_file.h +103 -0
  19. sgl/include/sgl/core/enum.h +201 -0
  20. sgl/include/sgl/core/error.h +161 -0
  21. sgl/include/sgl/core/file_stream.h +77 -0
  22. sgl/include/sgl/core/file_system_watcher.h +141 -0
  23. sgl/include/sgl/core/format.h +36 -0
  24. sgl/include/sgl/core/fwd.h +90 -0
  25. sgl/include/sgl/core/hash.h +45 -0
  26. sgl/include/sgl/core/input.h +522 -0
  27. sgl/include/sgl/core/logger.h +214 -0
  28. sgl/include/sgl/core/macros.h +184 -0
  29. sgl/include/sgl/core/maths.h +45 -0
  30. sgl/include/sgl/core/memory_mapped_file.h +112 -0
  31. sgl/include/sgl/core/memory_mapped_file_stream.h +32 -0
  32. sgl/include/sgl/core/memory_stream.h +74 -0
  33. sgl/include/sgl/core/object.h +683 -0
  34. sgl/include/sgl/core/platform.h +239 -0
  35. sgl/include/sgl/core/plugin.h +331 -0
  36. sgl/include/sgl/core/resolver.h +39 -0
  37. sgl/include/sgl/core/short_vector.h +141 -0
  38. sgl/include/sgl/core/static_vector.h +111 -0
  39. sgl/include/sgl/core/stream.h +54 -0
  40. sgl/include/sgl/core/string.h +276 -0
  41. sgl/include/sgl/core/struct.h +360 -0
  42. sgl/include/sgl/core/thread.h +28 -0
  43. sgl/include/sgl/core/timer.h +52 -0
  44. sgl/include/sgl/core/traits.h +15 -0
  45. sgl/include/sgl/core/type_utils.h +19 -0
  46. sgl/include/sgl/core/window.h +177 -0
  47. sgl/include/sgl/device/agility_sdk.h +24 -0
  48. sgl/include/sgl/device/blit.h +88 -0
  49. sgl/include/sgl/device/buffer_cursor.h +162 -0
  50. sgl/include/sgl/device/command.h +539 -0
  51. sgl/include/sgl/device/cuda_api.h +766 -0
  52. sgl/include/sgl/device/cuda_interop.h +39 -0
  53. sgl/include/sgl/device/cuda_utils.h +107 -0
  54. sgl/include/sgl/device/cursor_utils.h +129 -0
  55. sgl/include/sgl/device/device.h +668 -0
  56. sgl/include/sgl/device/device_resource.h +37 -0
  57. sgl/include/sgl/device/fence.h +91 -0
  58. sgl/include/sgl/device/formats.h +330 -0
  59. sgl/include/sgl/device/framebuffer.h +85 -0
  60. sgl/include/sgl/device/fwd.h +164 -0
  61. sgl/include/sgl/device/helpers.h +20 -0
  62. sgl/include/sgl/device/hot_reload.h +75 -0
  63. sgl/include/sgl/device/input_layout.h +74 -0
  64. sgl/include/sgl/device/kernel.h +69 -0
  65. sgl/include/sgl/device/memory_heap.h +155 -0
  66. sgl/include/sgl/device/native_formats.h +342 -0
  67. sgl/include/sgl/device/native_handle.h +73 -0
  68. sgl/include/sgl/device/native_handle_traits.h +65 -0
  69. sgl/include/sgl/device/pipeline.h +138 -0
  70. sgl/include/sgl/device/print.h +45 -0
  71. sgl/include/sgl/device/python/cursor_utils.h +853 -0
  72. sgl/include/sgl/device/query.h +52 -0
  73. sgl/include/sgl/device/raytracing.h +84 -0
  74. sgl/include/sgl/device/reflection.h +1254 -0
  75. sgl/include/sgl/device/resource.h +705 -0
  76. sgl/include/sgl/device/sampler.h +57 -0
  77. sgl/include/sgl/device/shader.h +516 -0
  78. sgl/include/sgl/device/shader_cursor.h +85 -0
  79. sgl/include/sgl/device/shader_object.h +94 -0
  80. sgl/include/sgl/device/shader_offset.h +67 -0
  81. sgl/include/sgl/device/shared_handle.h +12 -0
  82. sgl/include/sgl/device/slang_utils.h +54 -0
  83. sgl/include/sgl/device/swapchain.h +74 -0
  84. sgl/include/sgl/device/types.h +782 -0
  85. sgl/include/sgl/math/colorspace.h +56 -0
  86. sgl/include/sgl/math/constants.h +7 -0
  87. sgl/include/sgl/math/float16.h +146 -0
  88. sgl/include/sgl/math/matrix.h +6 -0
  89. sgl/include/sgl/math/matrix_math.h +746 -0
  90. sgl/include/sgl/math/matrix_types.h +207 -0
  91. sgl/include/sgl/math/python/primitivetype.h +33 -0
  92. sgl/include/sgl/math/quaternion.h +6 -0
  93. sgl/include/sgl/math/quaternion_math.h +484 -0
  94. sgl/include/sgl/math/quaternion_types.h +83 -0
  95. sgl/include/sgl/math/ray.h +47 -0
  96. sgl/include/sgl/math/scalar_math.h +249 -0
  97. sgl/include/sgl/math/scalar_types.h +107 -0
  98. sgl/include/sgl/math/vector.h +6 -0
  99. sgl/include/sgl/math/vector_math.h +1796 -0
  100. sgl/include/sgl/math/vector_types.h +336 -0
  101. sgl/include/sgl/python/nanobind.h +489 -0
  102. sgl/include/sgl/python/py_doc.h +11600 -0
  103. sgl/include/sgl/python/sgl_ext_pch.h +8 -0
  104. sgl/include/sgl/sgl.h +21 -0
  105. sgl/include/sgl/sgl_pch.h +6 -0
  106. sgl/include/sgl/stl/bit.h +377 -0
  107. sgl/include/sgl/tests/testing.h +54 -0
  108. sgl/include/sgl/ui/fwd.h +34 -0
  109. sgl/include/sgl/ui/imgui_config.h +43 -0
  110. sgl/include/sgl/ui/ui.h +71 -0
  111. sgl/include/sgl/ui/widgets.h +918 -0
  112. sgl/include/sgl/utils/python/slangpy.h +366 -0
  113. sgl/include/sgl/utils/renderdoc.h +50 -0
  114. sgl/include/sgl/utils/slangpy.h +153 -0
  115. sgl/include/sgl/utils/tev.h +93 -0
  116. sgl/include/sgl/utils/texture_loader.h +106 -0
  117. sgl/math/__init__.pyi +5083 -0
  118. sgl/platform/__init__.pyi +102 -0
  119. sgl/renderdoc/__init__.pyi +51 -0
  120. sgl/sgl.dll +0 -0
  121. sgl/sgl_ext.cp313-win_amd64.pyd +0 -0
  122. sgl/shaders/nvapi/nvHLSLExtns.h +2315 -0
  123. sgl/shaders/nvapi/nvHLSLExtnsInternal.h +758 -0
  124. sgl/shaders/nvapi/nvShaderExtnEnums.h +142 -0
  125. sgl/shaders/sgl/device/blit.slang +93 -0
  126. sgl/shaders/sgl/device/nvapi.slang +5 -0
  127. sgl/shaders/sgl/device/nvapi.slangh +7 -0
  128. sgl/shaders/sgl/device/print.slang +445 -0
  129. sgl/shaders/sgl/math/constants.slang +4 -0
  130. sgl/shaders/sgl/math/ray.slang +29 -0
  131. sgl/shaders/sgl/ui/imgui.slang +49 -0
  132. sgl/slang-glslang.dll +0 -0
  133. sgl/slang-llvm.dll +0 -0
  134. sgl/slang-rt.dll +0 -0
  135. sgl/slang.dll +0 -0
  136. sgl/slangpy/__init__.pyi +268 -0
  137. sgl/tev/__init__.pyi +108 -0
  138. sgl/tevclient.lib +0 -0
  139. sgl/thread/__init__.pyi +4 -0
  140. sgl/ui/__init__.pyi +1118 -0
  141. share/cmake/tevclient/tevclient-config-release.cmake +19 -0
  142. share/cmake/tevclient/tevclient-config.cmake +108 -0
@@ -0,0 +1,8 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+
3
+ #include "nanobind.h"
4
+
5
+ #include <fmt/format.h>
6
+ #include <fmt/ranges.h>
7
+
8
+ #include <filesystem>
sgl/include/sgl/sgl.h ADDED
@@ -0,0 +1,21 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+
3
+ #pragma once
4
+
5
+ #include "sgl/core/macros.h"
6
+
7
+ #define SGL_VERSION_MAJOR 0
8
+ #define SGL_VERSION_MINOR 6
9
+ #define SGL_VERSION_PATCH 0
10
+
11
+ #define SGL_VERSION \
12
+ SGL_TO_STRING(SGL_VERSION_MAJOR) "." SGL_TO_STRING(SGL_VERSION_MINOR) "." SGL_TO_STRING(SGL_VERSION_PATCH)
13
+
14
+ extern SGL_API const char* SGL_GIT_VERSION;
15
+
16
+ namespace sgl {
17
+
18
+ SGL_API void static_init();
19
+ SGL_API void static_shutdown();
20
+
21
+ } // namespace sgl
@@ -0,0 +1,6 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+
3
+ #include <fmt/format.h>
4
+ #include <fmt/ranges.h>
5
+
6
+ #include <filesystem>
@@ -0,0 +1,377 @@
1
+ //
2
+ // Copyright (c) 2020-2020 Martin Moene
3
+ //
4
+ // https://github.com/martinmoene/bit-lite
5
+ //
6
+ // Distributed under the Boost Software License, Version 1.0.
7
+ // (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8
+
9
+ // Modifications: Stripped down version assuming C++17 and placing into namespace stdx.
10
+
11
+ #pragma once
12
+
13
+ #include <cstdint>
14
+ #include <cstring> // std::memcpy()
15
+ #include <climits> // CHAR_BIT
16
+ #include <limits> // std::numeric_limits<>
17
+ #include <type_traits>
18
+
19
+ #if 0
20
+
21
+ // 26.5.3, bit_cast
22
+
23
+ template< class To, class From > constexpr To bit_cast( From const & from ) noexcept;
24
+
25
+ // 26.5.4, integral powers of 2
26
+
27
+ template< class T > constexpr bool has_single_bit(T x) noexcept;
28
+ template< class T > constexpr T bit_ceil(T x);
29
+ template< class T > constexpr T bit_floor(T x) noexcept;
30
+ template< class T > constexpr T bit_width(T x) noexcept;
31
+
32
+ // 26.5.5, rotating
33
+
34
+ template< class T > [[nodiscard]] constexpr T rotl(T x, int s) noexcept;
35
+ template< class T > [[nodiscard]] constexpr T rotr(T x, int s) noexcept;
36
+
37
+ // 26.5.6, counting
38
+
39
+ template< class T > constexpr int countl_zero(T x) noexcept;
40
+ template< class T > constexpr int countl_one(T x) noexcept;
41
+ template< class T > constexpr int countr_zero(T x) noexcept;
42
+ template< class T > constexpr int countr_one(T x) noexcept;
43
+ template< class T > constexpr int popcount(T x) noexcept;
44
+
45
+ #endif // 0: For reference
46
+
47
+ namespace stdx {
48
+ namespace bit {
49
+
50
+ template<typename T>
51
+ constexpr T bitmask(int i)
52
+ {
53
+ return static_cast<T>(T{1} << i);
54
+ }
55
+
56
+ // C++20 emulation:
57
+
58
+ namespace std20 {
59
+
60
+ template<class T, class U>
61
+ struct same_as : std::integral_constant<bool, std::is_same<T, U>::value && std::is_same<U, T>::value> { };
62
+
63
+ } // namespace std20
64
+
65
+ //
66
+ // Implementation:
67
+ //
68
+
69
+ // 26.5.3, bit_cast
70
+
71
+ // constexpr support needs compiler magic
72
+
73
+ template<class To, class From>
74
+ /*constexpr*/
75
+ typename std::enable_if<
76
+ ((sizeof(To) == sizeof(From)) && std::is_trivially_copyable<From>::value && std::is_trivial<To>::value
77
+ && (std::is_copy_constructible<To>::value || std::is_move_constructible<To>::value)),
78
+ To>::type
79
+ bit_cast(From const& src) noexcept
80
+ {
81
+ To dst;
82
+ std::memcpy(&dst, &src, sizeof(To));
83
+ return dst;
84
+ }
85
+
86
+ // 26.5.5, rotating
87
+
88
+ template<class T>
89
+ [[nodiscard]] constexpr T rotr_impl(T x, int s) noexcept;
90
+
91
+ template<class T>
92
+ [[nodiscard]] constexpr T rotl_impl(T x, int s) noexcept
93
+ {
94
+ constexpr int N = std::numeric_limits<T>::digits;
95
+ const int r = s % N;
96
+
97
+ if (r == 0)
98
+ return x;
99
+ else if (r > 0)
100
+ return static_cast<T>((x << r) | (x >> (N - r)));
101
+ else /*if ( r < 0 )*/
102
+ return rotr_impl(x, -r);
103
+ }
104
+
105
+ template<class T>
106
+ [[nodiscard]] constexpr T rotr_impl(T x, int s) noexcept
107
+ {
108
+ constexpr int N = std::numeric_limits<T>::digits;
109
+ const int r = s % N;
110
+
111
+ if (r == 0)
112
+ return x;
113
+ else if (r > 0)
114
+ return static_cast<T>((x >> r) | (x << (N - r)));
115
+ else /*if ( r < 0 )*/
116
+ return rotl_impl(x, -r);
117
+ }
118
+
119
+ template<class T, typename std::enable_if<std::is_unsigned<T>::value, int>::type = 0>
120
+ [[nodiscard]] constexpr T rotl(T x, int s) noexcept
121
+ {
122
+ return rotl_impl(x, s);
123
+ }
124
+
125
+ template<class T, typename std::enable_if<std::is_unsigned<T>::value, int>::type = 0>
126
+ [[nodiscard]] constexpr T rotr(T x, int s) noexcept
127
+ {
128
+ return rotr_impl(x, s);
129
+ }
130
+
131
+ // 26.5.6, counting
132
+
133
+ template<class T, typename std::enable_if<std::is_unsigned<T>::value, int>::type = 0>
134
+ constexpr int countl_zero(T x) noexcept
135
+ {
136
+ constexpr int N1 = CHAR_BIT * sizeof(T) - 1;
137
+
138
+ int result = 0;
139
+ for (int i = N1; i >= 0; --i, ++result) {
140
+ if (0 != (x & bitmask<T>(i)))
141
+ break;
142
+ }
143
+ return result;
144
+ }
145
+
146
+ template<class T, typename std::enable_if<std::is_unsigned<T>::value, int>::type = 0>
147
+ constexpr int countl_one(T x) noexcept
148
+ {
149
+ constexpr int N1 = CHAR_BIT * sizeof(T) - 1;
150
+
151
+ int result = 0;
152
+ for (int i = N1; i >= 0; --i, ++result) {
153
+ if (0 == (x & bitmask<T>(i)))
154
+ break;
155
+ }
156
+ return result;
157
+ }
158
+
159
+ template<class T, typename std::enable_if<std::is_unsigned<T>::value, int>::type = 0>
160
+ constexpr int countr_zero(T x) noexcept
161
+ {
162
+ constexpr int N = CHAR_BIT * sizeof(T);
163
+
164
+ int result = 0;
165
+ for (int i = 0; i < N; ++i, ++result) {
166
+ if (0 != (x & bitmask<T>(i)))
167
+ break;
168
+ }
169
+ return result;
170
+ }
171
+
172
+ template<class T, typename std::enable_if<std::is_unsigned<T>::value, int>::type = 0>
173
+ constexpr int countr_one(T x) noexcept
174
+ {
175
+ constexpr int N = CHAR_BIT * sizeof(T);
176
+
177
+ int result = 0;
178
+ for (int i = 0; i < N; ++i, ++result) {
179
+ if (0 == (x & bitmask<T>(i)))
180
+ break;
181
+ }
182
+ return result;
183
+ }
184
+
185
+ template<class T, typename std::enable_if<std::is_unsigned<T>::value, int>::type = 0>
186
+ constexpr int popcount(T x) noexcept
187
+ {
188
+ constexpr int N = CHAR_BIT * sizeof(T);
189
+
190
+ int result = 0;
191
+ for (int i = 0; i < N; ++i) {
192
+ if (0 != (x & bitmask<T>(i)))
193
+ ++result;
194
+ }
195
+ return result;
196
+ }
197
+
198
+ // 26.5.4, integral powers of 2
199
+
200
+ template<class T, typename std::enable_if<std::is_unsigned<T>::value, int>::type = 0>
201
+ constexpr bool has_single_bit(T x) noexcept
202
+ {
203
+ return x != 0 && (x & (x - 1)) == 0;
204
+ // return std::popcount(x) == 1;
205
+ }
206
+
207
+ template<class T, typename std::enable_if<std::is_unsigned<T>::value, int>::type = 0>
208
+ constexpr T bit_width(T x) noexcept
209
+ {
210
+ return static_cast<T>(std::numeric_limits<T>::digits - countl_zero(x));
211
+ }
212
+
213
+ template<class T>
214
+ constexpr T bit_ceil_impl(T x, std::true_type /*case: same type*/)
215
+ {
216
+ return T{1} << bit_width(T{x - 1});
217
+ }
218
+
219
+ template<class T>
220
+ constexpr T bit_ceil_impl(T x, std::false_type /*case: integral promotion*/)
221
+ {
222
+ constexpr T offset_for_ub
223
+ = static_cast<T>(std::numeric_limits<unsigned>::digits - std::numeric_limits<T>::digits);
224
+
225
+ return T{1u << (bit_width(T{x - 1}) + offset_for_ub) >> offset_for_ub};
226
+ }
227
+
228
+ // ToDo: pre-C++11 behaviour for types subject to integral promotion.
229
+
230
+ template<class T, typename std::enable_if<std::is_unsigned<T>::value, int>::type = 0>
231
+ constexpr T bit_ceil(T x)
232
+ {
233
+ return (x <= 1u) ? T{1} : bit_ceil_impl(x, std20::same_as<T, decltype(+x)>{});
234
+ }
235
+
236
+ template<class T, typename std::enable_if<std::is_unsigned<T>::value, int>::type = 0>
237
+ constexpr T bit_floor(T x) noexcept
238
+ {
239
+ return (x != 0) ? T{1} << (bit_width(x) - 1) : 0;
240
+ }
241
+
242
+ // 26.5.7, endian
243
+
244
+ enum class endian {
245
+ #ifdef _WIN32
246
+ little = 0,
247
+ big = 1,
248
+ native = little
249
+ #else
250
+ little = __ORDER_LITTLE_ENDIAN__,
251
+ big = __ORDER_BIG_ENDIAN__,
252
+ native = __BYTE_ORDER__
253
+ #endif
254
+ };
255
+
256
+ } // namespace bit
257
+ } // namespace stdx
258
+
259
+ //
260
+ // Make type available in namespace stdx:
261
+ //
262
+
263
+ #define STDX_HAS_BIT_INCLUDE __has_include(<bit>)
264
+
265
+ #if STDX_HAS_BIT_INCLUDE
266
+ #include <bit>
267
+ #endif
268
+
269
+ namespace stdx {
270
+ #if STDX_HAS_BIT_INCLUDE && defined(__cpp_lib_bit_cast)
271
+ using std::bit_cast;
272
+ #else
273
+ using bit::bit_cast;
274
+ #endif
275
+
276
+ #if STDX_HAS_BIT_INCLUDE && defined(__cpp_lib_bitops)
277
+ using std::has_single_bit;
278
+ using std::bit_ceil;
279
+ using std::bit_floor;
280
+ using std::bit_width;
281
+
282
+ using std::rotl;
283
+ using std::rotr;
284
+
285
+ using std::countl_zero;
286
+ using std::countl_one;
287
+ using std::countr_zero;
288
+ using std::countr_one;
289
+ using std::popcount;
290
+
291
+ using std::endian;
292
+ #else
293
+ using bit::has_single_bit;
294
+ using bit::bit_ceil;
295
+ using bit::bit_floor;
296
+ using bit::bit_width;
297
+
298
+ using bit::rotl;
299
+ using bit::rotr;
300
+
301
+ using bit::countl_zero;
302
+ using bit::countl_one;
303
+ using bit::countr_zero;
304
+ using bit::countr_one;
305
+ using bit::popcount;
306
+
307
+ using bit::endian;
308
+ #endif
309
+
310
+ // C++23 introduces byteswap() in <bit>:
311
+
312
+ template<typename T>
313
+ inline /*constexpr*/ T byteswap(T n) noexcept;
314
+
315
+ template<>
316
+ inline /*constexpr*/ uint8_t byteswap(uint8_t n) noexcept
317
+ {
318
+ return n;
319
+ }
320
+
321
+ template<>
322
+ inline /*constexpr*/ uint16_t byteswap(uint16_t n) noexcept
323
+ {
324
+ #if SGL_MSVC
325
+ return _byteswap_ushort(n);
326
+ #elif SGL_CLANG || SGL_GCC
327
+ return __builtin_bswap16(n);
328
+ #else
329
+ return (n >> 8) | (n << 8);
330
+ #endif
331
+ }
332
+
333
+ template<>
334
+ inline /*constexpr*/ uint32_t byteswap(uint32_t n) noexcept
335
+ {
336
+ #if SGL_MSVC
337
+ return _byteswap_ulong(n);
338
+ #elif SGL_CLANG || SGL_GCC
339
+ return __builtin_bswap32(n);
340
+ #else
341
+ return (n >> 24) | ((n >> 8) & 0x0000FF00) | ((n << 8) & 0x00FF0000) | (n << 24);
342
+ #endif
343
+ }
344
+
345
+ template<>
346
+ inline /*constexpr*/ uint64_t byteswap(uint64_t n) noexcept
347
+ {
348
+ #if SGL_MSVC
349
+ return _byteswap_uint64(n);
350
+ #elif SGL_CLANG || SGL_GCC
351
+ return __builtin_bswap64(n);
352
+ #else
353
+ return (n >> 56) | ((n >> 40) & 0x000000000000FF00) | ((n >> 24) & 0x0000000000FF0000)
354
+ | ((n >> 8) & 0x00000000FF000000) | ((n << 8) & 0x000000FF00000000) | ((n << 24) & 0x0000FF0000000000)
355
+ | ((n << 40) & 0x00FF000000000000) | (n << 56);
356
+ #endif
357
+ }
358
+
359
+ template<>
360
+ inline /*constexpr*/ int16_t byteswap(int16_t n) noexcept
361
+ {
362
+ return bit_cast<int16_t>(byteswap(bit_cast<uint16_t>(n)));
363
+ }
364
+
365
+ template<>
366
+ inline /*constexpr*/ int32_t byteswap(int32_t n) noexcept
367
+ {
368
+ return bit_cast<int32_t>(byteswap(bit_cast<uint32_t>(n)));
369
+ }
370
+
371
+ template<>
372
+ inline /*constexpr*/ int64_t byteswap(int64_t n) noexcept
373
+ {
374
+ return bit_cast<int64_t>(byteswap(bit_cast<uint64_t>(n)));
375
+ }
376
+
377
+ } // namespace stdx
@@ -0,0 +1,54 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+
3
+ #pragma once
4
+
5
+ #include <doctest/doctest.h>
6
+ #include <filesystem>
7
+
8
+ namespace sgl {
9
+
10
+ class Device;
11
+
12
+ } // namespace sgl
13
+
14
+ namespace sgl::testing {
15
+
16
+ /// Get name of running test suite (note: defined in sgl_tests.cpp).
17
+ std::string get_current_test_suite_name();
18
+
19
+ /// Get name of running test case (note: defined in sgl_tests.cpp).
20
+ std::string get_current_test_case_name();
21
+
22
+ /// Get global temp directory for tests.
23
+ std::filesystem::path get_test_temp_directory();
24
+
25
+ /// Get temp directory for current test suite.
26
+ std::filesystem::path get_suite_temp_directory();
27
+
28
+ /// Get temp directory for current test case.
29
+ std::filesystem::path get_case_temp_directory();
30
+
31
+ void static_init();
32
+ void static_shutdown();
33
+
34
+ struct GpuTestContext {
35
+ Device* device;
36
+ };
37
+
38
+ void run_gpu_test(void (*func)(GpuTestContext&));
39
+
40
+ void release_cached_devices();
41
+
42
+ } // namespace sgl::testing
43
+
44
+
45
+ #define DOCTEST_TEST_CASE_GPU(f, name) \
46
+ static void f(::sgl::testing::GpuTestContext& ctx); \
47
+ TEST_CASE(name) \
48
+ { \
49
+ ::sgl::testing::run_gpu_test(f); \
50
+ } \
51
+ static void f(::sgl::testing::GpuTestContext& ctx)
52
+
53
+
54
+ #define TEST_CASE_GPU(name) DOCTEST_TEST_CASE_GPU(DOCTEST_ANONYMOUS(gpu_test), name)
@@ -0,0 +1,34 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+
3
+ #pragma once
4
+
5
+ namespace sgl::ui {
6
+
7
+ // ui.h
8
+
9
+ class Context;
10
+
11
+ // widgets.h
12
+
13
+ class Widget;
14
+ class Screen;
15
+ class Window;
16
+ class Group;
17
+ class Text;
18
+ class ProgressBar;
19
+ class Button;
20
+ template<typename T>
21
+ class PropertyValue;
22
+ class CheckBox;
23
+ class ComboBox;
24
+ class ListBox;
25
+ template<typename T>
26
+ class Drag;
27
+ template<typename T>
28
+ class Slider;
29
+ class InputText;
30
+
31
+ class ScopedID;
32
+ class ScopedDisable;
33
+
34
+ } // namespace sgl::ui
@@ -0,0 +1,43 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+
3
+ #pragma once
4
+
5
+ // ImGui configuration file. See imconfig.h for more details.
6
+
7
+ #include "sgl/math/vector_types.h"
8
+
9
+ #define IM_VEC2_CLASS_EXTRA \
10
+ constexpr ImVec2(const ::sgl::float2& f) \
11
+ : x(f.x) \
12
+ , y(f.y) \
13
+ { \
14
+ } \
15
+ operator ::sgl::float2() const \
16
+ { \
17
+ return ::sgl::float2(x, y); \
18
+ }
19
+
20
+ #define IM_VEC3_CLASS_EXTRA \
21
+ constexpr ImVec3(const ::sgl::float3& f) \
22
+ : x(f.x) \
23
+ , y(f.y) \
24
+ , z(f.z) \
25
+ { \
26
+ } \
27
+ operator ::sgl::float3() const \
28
+ { \
29
+ return ::sgl::float3(x, y, z); \
30
+ }
31
+
32
+ #define IM_VEC4_CLASS_EXTRA \
33
+ constexpr ImVec4(const ::sgl::float4& f) \
34
+ : x(f.x) \
35
+ , y(f.y) \
36
+ , z(f.z) \
37
+ , w(f.w) \
38
+ { \
39
+ } \
40
+ operator ::sgl::float4() const \
41
+ { \
42
+ return ::sgl::float4(x, y, z, w); \
43
+ }
@@ -0,0 +1,71 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+
3
+ #pragma once
4
+
5
+ #include "sgl/ui/fwd.h"
6
+
7
+ #include "sgl/core/fwd.h"
8
+ #include "sgl/core/object.h"
9
+ #include "sgl/core/timer.h"
10
+
11
+ #include "sgl/device/fwd.h"
12
+ #include "sgl/device/framebuffer.h"
13
+
14
+ #include <map>
15
+
16
+ struct ImGuiContext;
17
+ struct ImFont;
18
+
19
+ namespace sgl::ui {
20
+
21
+ class SGL_API Context : public Object {
22
+ SGL_OBJECT(Context)
23
+ public:
24
+ Context(ref<Device> device);
25
+ ~Context();
26
+
27
+ ref<Screen> screen() const { return m_screen; }
28
+
29
+ ImFont* get_font(const char* name);
30
+
31
+ void new_frame(uint32_t width, uint32_t height);
32
+ void render(Framebuffer* framebuffer, CommandBuffer* command_buffer);
33
+
34
+ bool handle_keyboard_event(const KeyboardEvent& event);
35
+ bool handle_mouse_event(const MouseEvent& event);
36
+
37
+ void process_events();
38
+
39
+ private:
40
+ GraphicsPipeline* get_pipeline(Framebuffer* framebuffer);
41
+
42
+ static constexpr uint32_t FRAME_COUNT = 3;
43
+
44
+ ref<Device> m_device;
45
+ ImGuiContext* m_imgui_context;
46
+
47
+ ref<Screen> m_screen;
48
+
49
+ uint32_t m_frame_index{0};
50
+ Timer m_frame_timer;
51
+
52
+ ref<Sampler> m_sampler;
53
+ ref<Buffer> m_vertex_buffers[FRAME_COUNT];
54
+ ref<Buffer> m_index_buffers[FRAME_COUNT];
55
+ ref<ShaderProgram> m_program;
56
+ ref<Texture> m_font_texture;
57
+ ref<InputLayout> m_input_layout;
58
+
59
+ std::map<std::string, ImFont*> m_fonts;
60
+
61
+ std::map<FramebufferLayoutDesc, ref<GraphicsPipeline>> m_pipelines;
62
+ };
63
+
64
+ } // namespace sgl::ui
65
+
66
+ // Extend ImGui with some additional convenience functions.
67
+ namespace ImGui {
68
+
69
+ SGL_API void PushFont(const char* name);
70
+
71
+ }