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,207 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
|
3
|
+
#pragma once
|
4
|
+
|
5
|
+
#include "sgl/math/scalar_types.h"
|
6
|
+
#include "sgl/math/vector_types.h"
|
7
|
+
#include "sgl/core/error.h"
|
8
|
+
|
9
|
+
#include <array>
|
10
|
+
#include <initializer_list>
|
11
|
+
#include <limits>
|
12
|
+
|
13
|
+
namespace sgl::math {
|
14
|
+
|
15
|
+
/**
|
16
|
+
* Matrix type with row-major storage.
|
17
|
+
*
|
18
|
+
* The semantics are aligned with Slang:
|
19
|
+
* - Row major storage
|
20
|
+
* - Math operators are element-wise (e.g. +, -, *, /)
|
21
|
+
* - Free standing functions for matrix operations (e.g. mul(), transpose(), etc.)
|
22
|
+
*
|
23
|
+
* \tparam T Scalar type
|
24
|
+
* \tparam RowCount Number of rows (1-4)
|
25
|
+
* \tparam ColCount Number of columns (1-4)
|
26
|
+
*/
|
27
|
+
template<typename T, int RowCount, int ColCount>
|
28
|
+
class matrix {
|
29
|
+
static_assert(RowCount >= 1 && RowCount <= 4);
|
30
|
+
static_assert(ColCount >= 1 && ColCount <= 4);
|
31
|
+
|
32
|
+
// For now, we only support float, but want to have the type T visible
|
33
|
+
static_assert(std::is_same_v<float, T>);
|
34
|
+
|
35
|
+
private:
|
36
|
+
template<typename, int, int>
|
37
|
+
friend class matrix;
|
38
|
+
|
39
|
+
public:
|
40
|
+
static constexpr int rows = RowCount;
|
41
|
+
static constexpr int cols = ColCount;
|
42
|
+
using value_type = T;
|
43
|
+
using row_type = vector<T, ColCount>;
|
44
|
+
using col_type = vector<T, RowCount>;
|
45
|
+
|
46
|
+
matrix()
|
47
|
+
: matrix(Form::Identity)
|
48
|
+
{
|
49
|
+
}
|
50
|
+
|
51
|
+
template<arithmetic U>
|
52
|
+
explicit matrix(std::initializer_list<U> a)
|
53
|
+
{
|
54
|
+
SGL_CHECK(
|
55
|
+
a.size() == RowCount * ColCount,
|
56
|
+
"Invalid number of coefficients (expected {}, got {})",
|
57
|
+
RowCount * ColCount,
|
58
|
+
a.size()
|
59
|
+
);
|
60
|
+
T* f = &m_rows[0][0];
|
61
|
+
for (auto it = a.begin(); it != a.end(); ++it, ++f)
|
62
|
+
*f = static_cast<T>(*it);
|
63
|
+
}
|
64
|
+
|
65
|
+
template<typename U>
|
66
|
+
explicit matrix(const std::array<U, RowCount * ColCount>& a)
|
67
|
+
{
|
68
|
+
T* f = &m_rows[0][0];
|
69
|
+
for (const auto v : a)
|
70
|
+
*f++ = static_cast<T>(v);
|
71
|
+
}
|
72
|
+
|
73
|
+
matrix(const matrix&) = default;
|
74
|
+
matrix(matrix&&) noexcept = default;
|
75
|
+
|
76
|
+
/// Construct matrix from another matrix with different dimensions.
|
77
|
+
/// In HLSL/Slang, destination matrix must be equal or smaller than source matrix.
|
78
|
+
/// In sgl, destination matrix can be larger than source matrix (initialized with identity).
|
79
|
+
template<int R, int C>
|
80
|
+
matrix(const matrix<T, R, C>& other)
|
81
|
+
: matrix(Form::Identity)
|
82
|
+
{
|
83
|
+
for (int r = 0; r < std::min(RowCount, R); ++r) {
|
84
|
+
std::memcpy(&m_rows[r], &other.m_rows[r], std::min(ColCount, C) * sizeof(T));
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
matrix& operator=(const matrix&) = default;
|
89
|
+
matrix& operator=(matrix&&) = default;
|
90
|
+
|
91
|
+
template<int R, int C>
|
92
|
+
matrix& operator=(const matrix<T, R, C>& other)
|
93
|
+
{
|
94
|
+
for (int r = 0; r < std::min(RowCount, R); ++r) {
|
95
|
+
std::memcpy(&m_rows[r], &other.m_rows[r], std::min(ColCount, C) * sizeof(T));
|
96
|
+
}
|
97
|
+
|
98
|
+
return *this;
|
99
|
+
}
|
100
|
+
|
101
|
+
/// Zero matrix.
|
102
|
+
[[nodiscard]] static matrix zeros() { return matrix(Form::Zeros); }
|
103
|
+
|
104
|
+
/// Identity matrix.
|
105
|
+
[[nodiscard]] static matrix identity() { return matrix(Form::Identity); }
|
106
|
+
|
107
|
+
T* data() { return &m_rows[0][0]; }
|
108
|
+
const T* data() const { return &m_rows[0][0]; }
|
109
|
+
|
110
|
+
row_type& operator[](int r)
|
111
|
+
{
|
112
|
+
SGL_ASSERT_LT(r, RowCount);
|
113
|
+
return m_rows[r];
|
114
|
+
}
|
115
|
+
const row_type& operator[](int r) const
|
116
|
+
{
|
117
|
+
SGL_ASSERT_LT(r, RowCount);
|
118
|
+
return m_rows[r];
|
119
|
+
}
|
120
|
+
|
121
|
+
row_type& get_row(int r)
|
122
|
+
{
|
123
|
+
SGL_ASSERT_LT(r, RowCount);
|
124
|
+
return m_rows[r];
|
125
|
+
}
|
126
|
+
const row_type& get_row(int r) const
|
127
|
+
{
|
128
|
+
SGL_ASSERT_LT(r, RowCount);
|
129
|
+
return m_rows[r];
|
130
|
+
}
|
131
|
+
|
132
|
+
void set_row(int r, const row_type& v)
|
133
|
+
{
|
134
|
+
SGL_ASSERT_LT(r, RowCount);
|
135
|
+
m_rows[r] = v;
|
136
|
+
}
|
137
|
+
|
138
|
+
col_type get_col(int col) const
|
139
|
+
{
|
140
|
+
SGL_ASSERT_LT(col, ColCount);
|
141
|
+
col_type result;
|
142
|
+
for (int r = 0; r < RowCount; ++r)
|
143
|
+
result[r] = m_rows[r][col];
|
144
|
+
return result;
|
145
|
+
}
|
146
|
+
|
147
|
+
void set_col(int col, const col_type& v)
|
148
|
+
{
|
149
|
+
SGL_ASSERT_LT(col, ColCount);
|
150
|
+
for (int r = 0; r < RowCount; ++r)
|
151
|
+
m_rows[r][col] = v[r];
|
152
|
+
}
|
153
|
+
|
154
|
+
bool operator==(const matrix& rhs) const { return std::memcmp(this, &rhs, sizeof(*this)) == 0; }
|
155
|
+
bool operator!=(const matrix& rhs) const { return !(*this == rhs); }
|
156
|
+
|
157
|
+
private:
|
158
|
+
enum class Form {
|
159
|
+
Undefined,
|
160
|
+
Zeros,
|
161
|
+
Identity,
|
162
|
+
};
|
163
|
+
|
164
|
+
explicit matrix(Form form)
|
165
|
+
{
|
166
|
+
switch (form) {
|
167
|
+
case Form::Undefined:
|
168
|
+
#ifdef _DEBUG
|
169
|
+
for (int i = 0; i < RowCount; ++i)
|
170
|
+
m_rows[i] = row_type(std::numeric_limits<T>::quiet_NaN());
|
171
|
+
#endif
|
172
|
+
break;
|
173
|
+
case Form::Zeros:
|
174
|
+
std::memset(this, 0, sizeof(*this));
|
175
|
+
break;
|
176
|
+
case Form::Identity:
|
177
|
+
std::memset(this, 0, sizeof(*this));
|
178
|
+
for (int i = 0; i < std::min(RowCount, ColCount); ++i)
|
179
|
+
m_rows[i][i] = T(1);
|
180
|
+
break;
|
181
|
+
}
|
182
|
+
}
|
183
|
+
|
184
|
+
row_type m_rows[RowCount];
|
185
|
+
};
|
186
|
+
|
187
|
+
using float2x2 = matrix<float, 2, 2>;
|
188
|
+
|
189
|
+
using float3x3 = matrix<float, 3, 3>;
|
190
|
+
|
191
|
+
using float2x4 = matrix<float, 2, 4>;
|
192
|
+
using float3x4 = matrix<float, 3, 4>;
|
193
|
+
using float4x4 = matrix<float, 4, 4>;
|
194
|
+
|
195
|
+
} // namespace sgl::math
|
196
|
+
|
197
|
+
namespace sgl {
|
198
|
+
|
199
|
+
using float2x2 = math::float2x2;
|
200
|
+
|
201
|
+
using float3x3 = math::float3x3;
|
202
|
+
|
203
|
+
using float2x4 = math::float2x4;
|
204
|
+
using float3x4 = math::float3x4;
|
205
|
+
using float4x4 = math::float4x4;
|
206
|
+
|
207
|
+
} // namespace sgl
|
@@ -0,0 +1,33 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
|
3
|
+
#include "nanobind.h"
|
4
|
+
#include "sgl/core/error.h"
|
5
|
+
|
6
|
+
namespace sgl::math {
|
7
|
+
|
8
|
+
template<class T>
|
9
|
+
struct PrimitiveType {
|
10
|
+
static PyObject* python_type() { SGL_THROW("Unknown primitive type"); }
|
11
|
+
};
|
12
|
+
template<>
|
13
|
+
struct PrimitiveType<float16_t> {
|
14
|
+
static PyObject* python_type() { return (PyObject*)&PyFloat_Type; }
|
15
|
+
};
|
16
|
+
template<>
|
17
|
+
struct PrimitiveType<float> {
|
18
|
+
static PyObject* python_type() { return (PyObject*)&PyFloat_Type; }
|
19
|
+
};
|
20
|
+
template<>
|
21
|
+
struct PrimitiveType<int> {
|
22
|
+
static PyObject* python_type() { return (PyObject*)&PyLong_Type; }
|
23
|
+
};
|
24
|
+
template<>
|
25
|
+
struct PrimitiveType<uint32_t> {
|
26
|
+
static PyObject* python_type() { return (PyObject*)&PyLong_Type; }
|
27
|
+
};
|
28
|
+
template<>
|
29
|
+
struct PrimitiveType<bool> {
|
30
|
+
static PyObject* python_type() { return (PyObject*)&PyBool_Type; }
|
31
|
+
};
|
32
|
+
|
33
|
+
} // namespace sgl::math
|