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.
- 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 +142 -0
- nv_sgl-0.6.0.dist-info/WHEEL +5 -0
- nv_sgl-0.6.0.dist-info/top_level.txt +1 -0
- sgl/__init__.py +15 -0
- sgl/__init__.pyi +6738 -0
- sgl/d3d12/D3D12Core.dll +0 -0
- sgl/d3d12/d3d12SDKLayers.dll +0 -0
- sgl/dxcompiler.dll +0 -0
- sgl/dxil.dll +0 -0
- sgl/gfx.dll +0 -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/math/__init__.pyi +5083 -0
- sgl/platform/__init__.pyi +102 -0
- sgl/renderdoc/__init__.pyi +51 -0
- sgl/sgl.dll +0 -0
- sgl/sgl_ext.cp313-win_amd64.pyd +0 -0
- sgl/shaders/nvapi/nvHLSLExtns.h +2315 -0
- sgl/shaders/nvapi/nvHLSLExtnsInternal.h +758 -0
- sgl/shaders/nvapi/nvShaderExtnEnums.h +142 -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/slang-glslang.dll +0 -0
- sgl/slang-llvm.dll +0 -0
- sgl/slang-rt.dll +0 -0
- sgl/slang.dll +0 -0
- sgl/slangpy/__init__.pyi +268 -0
- sgl/tev/__init__.pyi +108 -0
- sgl/tevclient.lib +0 -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 +108 -0
@@ -0,0 +1,91 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
|
3
|
+
#pragma once
|
4
|
+
|
5
|
+
#include "sgl/device/fwd.h"
|
6
|
+
#include "sgl/device/device_resource.h"
|
7
|
+
#include "sgl/device/shared_handle.h"
|
8
|
+
#include "sgl/device/native_handle.h"
|
9
|
+
|
10
|
+
#include "sgl/core/macros.h"
|
11
|
+
#include "sgl/core/object.h"
|
12
|
+
|
13
|
+
#include <slang-gfx.h>
|
14
|
+
|
15
|
+
namespace sgl {
|
16
|
+
|
17
|
+
/// Fence descriptor.
|
18
|
+
struct FenceDesc {
|
19
|
+
/// Initial fence value.
|
20
|
+
uint64_t initial_value{0};
|
21
|
+
/// Create a shared fence.
|
22
|
+
bool shared{false};
|
23
|
+
};
|
24
|
+
|
25
|
+
/// Fence.
|
26
|
+
class SGL_API Fence : public DeviceResource {
|
27
|
+
SGL_OBJECT(Fence)
|
28
|
+
public:
|
29
|
+
static constexpr uint64_t AUTO = uint64_t(-1);
|
30
|
+
static constexpr uint64_t TIMEOUT_INFINITE = uint64_t(-1);
|
31
|
+
|
32
|
+
/// Constructor.
|
33
|
+
/// Do not use directly, instead use \c Device::create_fence.
|
34
|
+
Fence(ref<Device> device, FenceDesc desc);
|
35
|
+
|
36
|
+
const FenceDesc& desc() const { return m_desc; }
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Signal the fence.
|
40
|
+
* This signals the fence from the host.
|
41
|
+
* \param value The value to signal. If \c AUTO, the signaled value will be auto-incremented.
|
42
|
+
* \return The signaled value.
|
43
|
+
*/
|
44
|
+
uint64_t signal(uint64_t value = AUTO);
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Wait for the fence to be signaled on the host.
|
48
|
+
* Blocks the host until the fence reaches or exceeds the specified value.
|
49
|
+
* \param value The value to wait for. If \c AUTO, wait for the last signaled value.
|
50
|
+
* \param timeout_ns The timeout in nanoseconds. If \c TIMEOUT_INFINITE, the function will block indefinitely.
|
51
|
+
*/
|
52
|
+
void wait(uint64_t value = AUTO, uint64_t timeout_ns = TIMEOUT_INFINITE);
|
53
|
+
|
54
|
+
/// Returns the currently signaled value on the device.
|
55
|
+
uint64_t current_value() const;
|
56
|
+
|
57
|
+
/// Returns the last signaled value on the device.
|
58
|
+
uint64_t signaled_value() const { return m_signaled_value; }
|
59
|
+
|
60
|
+
/**
|
61
|
+
* Updates or increments the signaled value.
|
62
|
+
* This is used before signaling a fence (from the host, on the device or
|
63
|
+
* from an external source), to update the internal state.
|
64
|
+
* The passed value is stored, or if \c AUTO, the last signaled
|
65
|
+
* value is auto-incremented by one. The returned value is what the caller
|
66
|
+
* should signal to the fence.
|
67
|
+
* \param value The value to signal. If \c AUTO, the signaled value will be auto-incremented.
|
68
|
+
* \return The value to signal to the fence.
|
69
|
+
*/
|
70
|
+
uint64_t update_signaled_value(uint64_t value = AUTO);
|
71
|
+
|
72
|
+
gfx::IFence* gfx_fence() const { return m_gfx_fence; }
|
73
|
+
|
74
|
+
/// Get the shared fence handle.
|
75
|
+
/// Throws if the fence was not created with the \c FenceDesc::shared flag.
|
76
|
+
SharedFenceHandle get_shared_handle() const;
|
77
|
+
|
78
|
+
/// Returns the native API handle:
|
79
|
+
/// - D3D12: ID3D12Fence*
|
80
|
+
/// - Vulkan: currently not supported
|
81
|
+
NativeHandle get_native_handle() const;
|
82
|
+
|
83
|
+
std::string to_string() const override;
|
84
|
+
|
85
|
+
public:
|
86
|
+
FenceDesc m_desc;
|
87
|
+
Slang::ComPtr<gfx::IFence> m_gfx_fence;
|
88
|
+
uint64_t m_signaled_value;
|
89
|
+
};
|
90
|
+
|
91
|
+
} // namespace sgl
|
@@ -0,0 +1,330 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
|
3
|
+
#pragma once
|
4
|
+
|
5
|
+
#include "sgl/core/macros.h"
|
6
|
+
#include "sgl/core/enum.h"
|
7
|
+
#include "sgl/math/vector_types.h"
|
8
|
+
|
9
|
+
#include <slang-gfx.h>
|
10
|
+
|
11
|
+
#include <array>
|
12
|
+
|
13
|
+
namespace sgl {
|
14
|
+
|
15
|
+
/// Resource formats.
|
16
|
+
enum class Format : uint32_t {
|
17
|
+
unknown = static_cast<uint32_t>(gfx::Format::Unknown),
|
18
|
+
|
19
|
+
rgba32_typeless = static_cast<uint32_t>(gfx::Format::R32G32B32A32_TYPELESS),
|
20
|
+
rgb32_typeless = static_cast<uint32_t>(gfx::Format::R32G32B32_TYPELESS),
|
21
|
+
rg32_typeless = static_cast<uint32_t>(gfx::Format::R32G32_TYPELESS),
|
22
|
+
r32_typeless = static_cast<uint32_t>(gfx::Format::R32_TYPELESS),
|
23
|
+
|
24
|
+
rgba16_typeless = static_cast<uint32_t>(gfx::Format::R16G16B16A16_TYPELESS),
|
25
|
+
rg16_typeless = static_cast<uint32_t>(gfx::Format::R16G16_TYPELESS),
|
26
|
+
r16_typeless = static_cast<uint32_t>(gfx::Format::R16_TYPELESS),
|
27
|
+
|
28
|
+
rgba8_typeless = static_cast<uint32_t>(gfx::Format::R8G8B8A8_TYPELESS),
|
29
|
+
rg8_typeless = static_cast<uint32_t>(gfx::Format::R8G8_TYPELESS),
|
30
|
+
r8_typeless = static_cast<uint32_t>(gfx::Format::R8_TYPELESS),
|
31
|
+
bgra8_typeless = static_cast<uint32_t>(gfx::Format::B8G8R8A8_TYPELESS),
|
32
|
+
|
33
|
+
rgba32_float = static_cast<uint32_t>(gfx::Format::R32G32B32A32_FLOAT),
|
34
|
+
rgb32_float = static_cast<uint32_t>(gfx::Format::R32G32B32_FLOAT),
|
35
|
+
rg32_float = static_cast<uint32_t>(gfx::Format::R32G32_FLOAT),
|
36
|
+
r32_float = static_cast<uint32_t>(gfx::Format::R32_FLOAT),
|
37
|
+
|
38
|
+
rgba16_float = static_cast<uint32_t>(gfx::Format::R16G16B16A16_FLOAT),
|
39
|
+
rg16_float = static_cast<uint32_t>(gfx::Format::R16G16_FLOAT),
|
40
|
+
r16_float = static_cast<uint32_t>(gfx::Format::R16_FLOAT),
|
41
|
+
|
42
|
+
rgba32_uint = static_cast<uint32_t>(gfx::Format::R32G32B32A32_UINT),
|
43
|
+
rgb32_uint = static_cast<uint32_t>(gfx::Format::R32G32B32_UINT),
|
44
|
+
rg32_uint = static_cast<uint32_t>(gfx::Format::R32G32_UINT),
|
45
|
+
r32_uint = static_cast<uint32_t>(gfx::Format::R32_UINT),
|
46
|
+
|
47
|
+
rgba16_uint = static_cast<uint32_t>(gfx::Format::R16G16B16A16_UINT),
|
48
|
+
rg16_uint = static_cast<uint32_t>(gfx::Format::R16G16_UINT),
|
49
|
+
r16_uint = static_cast<uint32_t>(gfx::Format::R16_UINT),
|
50
|
+
|
51
|
+
rgba8_uint = static_cast<uint32_t>(gfx::Format::R8G8B8A8_UINT),
|
52
|
+
rg8_uint = static_cast<uint32_t>(gfx::Format::R8G8_UINT),
|
53
|
+
r8_uint = static_cast<uint32_t>(gfx::Format::R8_UINT),
|
54
|
+
|
55
|
+
rgba32_sint = static_cast<uint32_t>(gfx::Format::R32G32B32A32_SINT),
|
56
|
+
rgb32_sint = static_cast<uint32_t>(gfx::Format::R32G32B32_SINT),
|
57
|
+
rg32_sint = static_cast<uint32_t>(gfx::Format::R32G32_SINT),
|
58
|
+
r32_sint = static_cast<uint32_t>(gfx::Format::R32_SINT),
|
59
|
+
|
60
|
+
rgba16_sint = static_cast<uint32_t>(gfx::Format::R16G16B16A16_SINT),
|
61
|
+
rg16_sint = static_cast<uint32_t>(gfx::Format::R16G16_SINT),
|
62
|
+
r16_sint = static_cast<uint32_t>(gfx::Format::R16_SINT),
|
63
|
+
|
64
|
+
rgba8_sint = static_cast<uint32_t>(gfx::Format::R8G8B8A8_SINT),
|
65
|
+
rg8_sint = static_cast<uint32_t>(gfx::Format::R8G8_SINT),
|
66
|
+
r8_sint = static_cast<uint32_t>(gfx::Format::R8_SINT),
|
67
|
+
|
68
|
+
rgba16_unorm = static_cast<uint32_t>(gfx::Format::R16G16B16A16_UNORM),
|
69
|
+
rg16_unorm = static_cast<uint32_t>(gfx::Format::R16G16_UNORM),
|
70
|
+
r16_unorm = static_cast<uint32_t>(gfx::Format::R16_UNORM),
|
71
|
+
|
72
|
+
rgba8_unorm = static_cast<uint32_t>(gfx::Format::R8G8B8A8_UNORM),
|
73
|
+
rgba8_unorm_srgb = static_cast<uint32_t>(gfx::Format::R8G8B8A8_UNORM_SRGB),
|
74
|
+
rg8_unorm = static_cast<uint32_t>(gfx::Format::R8G8_UNORM),
|
75
|
+
r8_unorm = static_cast<uint32_t>(gfx::Format::R8_UNORM),
|
76
|
+
bgra8_unorm = static_cast<uint32_t>(gfx::Format::B8G8R8A8_UNORM),
|
77
|
+
bgra8_unorm_srgb = static_cast<uint32_t>(gfx::Format::B8G8R8A8_UNORM_SRGB),
|
78
|
+
bgrx8_unorm = static_cast<uint32_t>(gfx::Format::B8G8R8X8_UNORM),
|
79
|
+
bgrx8_unorm_srgb = static_cast<uint32_t>(gfx::Format::B8G8R8X8_UNORM_SRGB),
|
80
|
+
|
81
|
+
rgba16_snorm = static_cast<uint32_t>(gfx::Format::R16G16B16A16_SNORM),
|
82
|
+
rg16_snorm = static_cast<uint32_t>(gfx::Format::R16G16_SNORM),
|
83
|
+
r16_snorm = static_cast<uint32_t>(gfx::Format::R16_SNORM),
|
84
|
+
|
85
|
+
rgba8_snorm = static_cast<uint32_t>(gfx::Format::R8G8B8A8_SNORM),
|
86
|
+
rg8_snorm = static_cast<uint32_t>(gfx::Format::R8G8_SNORM),
|
87
|
+
r8_snorm = static_cast<uint32_t>(gfx::Format::R8_SNORM),
|
88
|
+
|
89
|
+
d32_float = static_cast<uint32_t>(gfx::Format::D32_FLOAT),
|
90
|
+
d16_unorm = static_cast<uint32_t>(gfx::Format::D16_UNORM),
|
91
|
+
d32_float_s8_uint = static_cast<uint32_t>(gfx::Format::D32_FLOAT_S8_UINT),
|
92
|
+
r32_float_x32_typeless = static_cast<uint32_t>(gfx::Format::R32_FLOAT_X32_TYPELESS),
|
93
|
+
|
94
|
+
bgra4_unorm = static_cast<uint32_t>(gfx::Format::B4G4R4A4_UNORM),
|
95
|
+
b5g6r5_unorm = static_cast<uint32_t>(gfx::Format::B5G6R5_UNORM),
|
96
|
+
b5g5r5a1_unorm = static_cast<uint32_t>(gfx::Format::B5G5R5A1_UNORM),
|
97
|
+
|
98
|
+
r9g9b9e5_sharedexp = static_cast<uint32_t>(gfx::Format::R9G9B9E5_SHAREDEXP),
|
99
|
+
r10g10b10a2_typeless = static_cast<uint32_t>(gfx::Format::R10G10B10A2_TYPELESS),
|
100
|
+
r10g10b10a2_unorm = static_cast<uint32_t>(gfx::Format::R10G10B10A2_UNORM),
|
101
|
+
r10g10b10a2_uint = static_cast<uint32_t>(gfx::Format::R10G10B10A2_UINT),
|
102
|
+
r11g11b10_float = static_cast<uint32_t>(gfx::Format::R11G11B10_FLOAT),
|
103
|
+
|
104
|
+
bc1_unorm = static_cast<uint32_t>(gfx::Format::BC1_UNORM),
|
105
|
+
bc1_unorm_srgb = static_cast<uint32_t>(gfx::Format::BC1_UNORM_SRGB),
|
106
|
+
bc2_unorm = static_cast<uint32_t>(gfx::Format::BC2_UNORM),
|
107
|
+
bc2_unorm_srgb = static_cast<uint32_t>(gfx::Format::BC2_UNORM_SRGB),
|
108
|
+
bc3_unorm = static_cast<uint32_t>(gfx::Format::BC3_UNORM),
|
109
|
+
bc3_unorm_srgb = static_cast<uint32_t>(gfx::Format::BC3_UNORM_SRGB),
|
110
|
+
bc4_unorm = static_cast<uint32_t>(gfx::Format::BC4_UNORM),
|
111
|
+
bc4_snorm = static_cast<uint32_t>(gfx::Format::BC4_SNORM),
|
112
|
+
bc5_unorm = static_cast<uint32_t>(gfx::Format::BC5_UNORM),
|
113
|
+
bc5_snorm = static_cast<uint32_t>(gfx::Format::BC5_SNORM),
|
114
|
+
bc6h_uf16 = static_cast<uint32_t>(gfx::Format::BC6H_UF16),
|
115
|
+
bc6h_sf16 = static_cast<uint32_t>(gfx::Format::BC6H_SF16),
|
116
|
+
bc7_unorm = static_cast<uint32_t>(gfx::Format::BC7_UNORM),
|
117
|
+
bc7_unorm_srgb = static_cast<uint32_t>(gfx::Format::BC7_UNORM_SRGB),
|
118
|
+
|
119
|
+
count,
|
120
|
+
};
|
121
|
+
|
122
|
+
/// Resource format types.
|
123
|
+
enum class FormatType {
|
124
|
+
/// Unknown format.
|
125
|
+
unknown,
|
126
|
+
/// Typeless formats.
|
127
|
+
typeless,
|
128
|
+
/// Floating-point formats.
|
129
|
+
float_,
|
130
|
+
/// Unsigned normalized formats.
|
131
|
+
unorm,
|
132
|
+
/// Unsigned normalized SRGB formats.
|
133
|
+
unorm_srgb,
|
134
|
+
/// Signed normalized formats.
|
135
|
+
snorm,
|
136
|
+
/// Unsigned integer formats.
|
137
|
+
uint,
|
138
|
+
/// Signed integer formats.
|
139
|
+
sint
|
140
|
+
};
|
141
|
+
|
142
|
+
SGL_ENUM_INFO(
|
143
|
+
FormatType,
|
144
|
+
{
|
145
|
+
{FormatType::unknown, "unknown"},
|
146
|
+
{FormatType::typeless, "typeless"},
|
147
|
+
{FormatType::float_, "float"},
|
148
|
+
{FormatType::unorm, "unorm"},
|
149
|
+
{FormatType::unorm_srgb, "unorm_srgb"},
|
150
|
+
{FormatType::snorm, "snorm"},
|
151
|
+
{FormatType::uint, "uint"},
|
152
|
+
{FormatType::sint, "sint"},
|
153
|
+
}
|
154
|
+
);
|
155
|
+
SGL_ENUM_REGISTER(FormatType);
|
156
|
+
|
157
|
+
enum class FormatChannels : uint32_t {
|
158
|
+
none = 0x0,
|
159
|
+
r = 0x1,
|
160
|
+
g = 0x2,
|
161
|
+
b = 0x4,
|
162
|
+
a = 0x8,
|
163
|
+
rg = r | g,
|
164
|
+
rgb = r | g | b,
|
165
|
+
rgba = r | g | b | a,
|
166
|
+
};
|
167
|
+
|
168
|
+
SGL_ENUM_CLASS_OPERATORS(FormatChannels);
|
169
|
+
SGL_ENUM_INFO(
|
170
|
+
FormatChannels,
|
171
|
+
{
|
172
|
+
{FormatChannels::none, "none"},
|
173
|
+
{FormatChannels::r, "r"},
|
174
|
+
{FormatChannels::g, "g"},
|
175
|
+
{FormatChannels::b, "b"},
|
176
|
+
{FormatChannels::a, "a"},
|
177
|
+
{FormatChannels::rg, "rg"},
|
178
|
+
{FormatChannels::rgb, "rgb"},
|
179
|
+
{FormatChannels::rgba, "rgba"},
|
180
|
+
}
|
181
|
+
);
|
182
|
+
SGL_ENUM_REGISTER(FormatChannels);
|
183
|
+
|
184
|
+
/// Resource format information.
|
185
|
+
struct SGL_API FormatInfo {
|
186
|
+
/// Resource format.
|
187
|
+
Format format;
|
188
|
+
/// Format name.
|
189
|
+
std::string name;
|
190
|
+
/// Number of bytes per block (compressed) or pixel (uncompressed).
|
191
|
+
uint32_t bytes_per_block;
|
192
|
+
/// Number of channels.
|
193
|
+
uint32_t channel_count;
|
194
|
+
/// Format type (typeless, float, unorm, unorm_srgb, snorm, uint, sint).
|
195
|
+
FormatType type;
|
196
|
+
/// True if format has a depth component.
|
197
|
+
bool is_depth;
|
198
|
+
/// True if format has a stencil component.
|
199
|
+
bool is_stencil;
|
200
|
+
/// True if format is compressed.
|
201
|
+
bool is_compressed;
|
202
|
+
/// Block width for compressed formats (1 for uncompressed formats).
|
203
|
+
uint32_t block_width;
|
204
|
+
/// Block height for compressed formats (1 for uncompressed formats).
|
205
|
+
uint32_t block_height;
|
206
|
+
/// Number of bits per channel.
|
207
|
+
std::array<uint32_t, 4> channel_bit_count;
|
208
|
+
/// DXGI format.
|
209
|
+
uint32_t dxgi_format;
|
210
|
+
/// Vulkan format.
|
211
|
+
uint32_t vk_format;
|
212
|
+
|
213
|
+
/// True if format has a depth or stencil component.
|
214
|
+
bool is_depth_stencil() const { return is_depth || is_stencil; }
|
215
|
+
|
216
|
+
/// True if format is typeless.
|
217
|
+
bool is_typeless_format() const { return type == FormatType::typeless; }
|
218
|
+
/// True if format is floating point.
|
219
|
+
bool is_float_format() const { return type == FormatType::float_; }
|
220
|
+
/// True if format is integer.
|
221
|
+
bool is_integer_format() const { return type == FormatType::uint || type == FormatType::sint; }
|
222
|
+
/// True if format is normalized.
|
223
|
+
bool is_normalized_format() const
|
224
|
+
{
|
225
|
+
return type == FormatType::unorm || type == FormatType::unorm_srgb || type == FormatType::snorm;
|
226
|
+
}
|
227
|
+
/// True if format is sRGB.
|
228
|
+
bool is_srgb_format() const { return type == FormatType::unorm_srgb; }
|
229
|
+
|
230
|
+
/// Get the channels for the format (only for color formats).
|
231
|
+
FormatChannels get_channels() const
|
232
|
+
{
|
233
|
+
FormatChannels channels = FormatChannels::none;
|
234
|
+
channels |= channel_count >= 1 ? FormatChannels::r : FormatChannels::none;
|
235
|
+
channels |= channel_count >= 2 ? FormatChannels::g : FormatChannels::none;
|
236
|
+
channels |= channel_count >= 3 ? FormatChannels::b : FormatChannels::none;
|
237
|
+
channels |= channel_count >= 4 ? FormatChannels::a : FormatChannels::none;
|
238
|
+
return channels;
|
239
|
+
}
|
240
|
+
|
241
|
+
/// Get the number of bits for the specified channels.
|
242
|
+
uint32_t get_channel_bits(FormatChannels channels) const
|
243
|
+
{
|
244
|
+
uint32_t bits = 0;
|
245
|
+
bits += (is_set(channels, FormatChannels::r)) ? channel_bit_count[0] : 0;
|
246
|
+
bits += (is_set(channels, FormatChannels::g)) ? channel_bit_count[1] : 0;
|
247
|
+
bits += (is_set(channels, FormatChannels::b)) ? channel_bit_count[2] : 0;
|
248
|
+
bits += (is_set(channels, FormatChannels::a)) ? channel_bit_count[3] : 0;
|
249
|
+
return bits;
|
250
|
+
}
|
251
|
+
|
252
|
+
/// Check if all channels have the same number of bits.
|
253
|
+
bool has_equal_channel_bits() const
|
254
|
+
{
|
255
|
+
uint32_t bits = channel_bit_count[0];
|
256
|
+
for (uint32_t i = 1; i < channel_count; ++i)
|
257
|
+
if (channel_bit_count[i] != bits)
|
258
|
+
return false;
|
259
|
+
return true;
|
260
|
+
}
|
261
|
+
|
262
|
+
std::string to_string() const;
|
263
|
+
};
|
264
|
+
|
265
|
+
SGL_API const FormatInfo& get_format_info(Format format);
|
266
|
+
|
267
|
+
namespace detail {
|
268
|
+
template<typename T>
|
269
|
+
struct HostTypeToFormat {
|
270
|
+
static constexpr Format value = Format::unknown;
|
271
|
+
};
|
272
|
+
|
273
|
+
#define SGL_HOST_TYPE_TO_FORMAT(type, format) \
|
274
|
+
template<> \
|
275
|
+
struct HostTypeToFormat<type> { \
|
276
|
+
static constexpr Format value = format; \
|
277
|
+
}
|
278
|
+
|
279
|
+
SGL_HOST_TYPE_TO_FORMAT(int8_t, Format::r8_sint);
|
280
|
+
SGL_HOST_TYPE_TO_FORMAT(uint8_t, Format::r8_uint);
|
281
|
+
SGL_HOST_TYPE_TO_FORMAT(int16_t, Format::r16_sint);
|
282
|
+
SGL_HOST_TYPE_TO_FORMAT(uint16_t, Format::r16_uint);
|
283
|
+
SGL_HOST_TYPE_TO_FORMAT(int, Format::r32_sint);
|
284
|
+
SGL_HOST_TYPE_TO_FORMAT(int2, Format::rg32_sint);
|
285
|
+
SGL_HOST_TYPE_TO_FORMAT(int4, Format::rgba32_sint);
|
286
|
+
SGL_HOST_TYPE_TO_FORMAT(uint, Format::r32_uint);
|
287
|
+
SGL_HOST_TYPE_TO_FORMAT(uint2, Format::rg32_uint);
|
288
|
+
SGL_HOST_TYPE_TO_FORMAT(uint4, Format::rgba32_uint);
|
289
|
+
SGL_HOST_TYPE_TO_FORMAT(float16_t, Format::r16_float);
|
290
|
+
SGL_HOST_TYPE_TO_FORMAT(float16_t2, Format::rg16_float);
|
291
|
+
SGL_HOST_TYPE_TO_FORMAT(float16_t4, Format::rgba16_float);
|
292
|
+
SGL_HOST_TYPE_TO_FORMAT(float, Format::r32_float);
|
293
|
+
SGL_HOST_TYPE_TO_FORMAT(float2, Format::rg32_float);
|
294
|
+
SGL_HOST_TYPE_TO_FORMAT(float3, Format::rgb32_float);
|
295
|
+
SGL_HOST_TYPE_TO_FORMAT(float4, Format::rgba32_float);
|
296
|
+
|
297
|
+
#undef SGL_HOST_TYPE_TO_FORMAT
|
298
|
+
} // namespace detail
|
299
|
+
|
300
|
+
template<typename T>
|
301
|
+
inline constexpr Format host_type_to_format()
|
302
|
+
{
|
303
|
+
return detail::HostTypeToFormat<T>::value;
|
304
|
+
}
|
305
|
+
|
306
|
+
// Manually define the struct that SGL_ENUM_INFO(Format) would generate so we
|
307
|
+
// can use the existing table of resource formats.
|
308
|
+
struct Format_info {
|
309
|
+
static const std::string& name()
|
310
|
+
{
|
311
|
+
static const std::string name = "Format";
|
312
|
+
return name;
|
313
|
+
}
|
314
|
+
|
315
|
+
static std::span<std::pair<Format, std::string>> items()
|
316
|
+
{
|
317
|
+
auto create_items = []()
|
318
|
+
{
|
319
|
+
std::vector<std::pair<Format, std::string>> items((size_t)Format::count);
|
320
|
+
for (size_t i = 0; i < (size_t)Format::count; ++i)
|
321
|
+
items[i] = std::make_pair(Format(i), get_format_info(Format(i)).name);
|
322
|
+
return items;
|
323
|
+
};
|
324
|
+
static std::vector<std::pair<Format, std::string>> items = create_items();
|
325
|
+
return items;
|
326
|
+
}
|
327
|
+
};
|
328
|
+
SGL_ENUM_REGISTER(Format);
|
329
|
+
|
330
|
+
} // namespace sgl
|
@@ -0,0 +1,85 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
|
3
|
+
#pragma once
|
4
|
+
|
5
|
+
#include "sgl/device/fwd.h"
|
6
|
+
#include "sgl/device/device_resource.h"
|
7
|
+
#include "sgl/device/formats.h"
|
8
|
+
|
9
|
+
#include "sgl/core/object.h"
|
10
|
+
#include "sgl/core/macros.h"
|
11
|
+
|
12
|
+
#include <slang-gfx.h>
|
13
|
+
|
14
|
+
namespace sgl {
|
15
|
+
|
16
|
+
struct FramebufferLayoutTargetDesc {
|
17
|
+
Format format{Format::unknown};
|
18
|
+
uint32_t sample_count{0};
|
19
|
+
|
20
|
+
auto operator<=>(const FramebufferLayoutTargetDesc&) const = default;
|
21
|
+
};
|
22
|
+
|
23
|
+
struct FramebufferLayoutDesc {
|
24
|
+
std::vector<FramebufferLayoutTargetDesc> render_targets;
|
25
|
+
std::optional<FramebufferLayoutTargetDesc> depth_stencil;
|
26
|
+
|
27
|
+
#if SGL_MACOS
|
28
|
+
// macOS clang stdc++ doesn't support C++20 <=> operator for standard containers yet.
|
29
|
+
bool operator<(const FramebufferLayoutDesc& other) const
|
30
|
+
{
|
31
|
+
return std::tie(render_targets, depth_stencil) < std::tie(other.render_targets, other.depth_stencil);
|
32
|
+
}
|
33
|
+
#else
|
34
|
+
auto operator<=>(const FramebufferLayoutDesc&) const = default;
|
35
|
+
#endif
|
36
|
+
};
|
37
|
+
|
38
|
+
class SGL_API FramebufferLayout : public DeviceResource {
|
39
|
+
SGL_OBJECT(FramebufferLayout)
|
40
|
+
public:
|
41
|
+
FramebufferLayout(ref<Device> device, FramebufferLayoutDesc desc);
|
42
|
+
virtual ~FramebufferLayout();
|
43
|
+
|
44
|
+
const FramebufferLayoutDesc& desc() const { return m_desc; }
|
45
|
+
|
46
|
+
gfx::IFramebufferLayout* gfx_framebuffer_layout() const { return m_gfx_framebuffer_layout; }
|
47
|
+
|
48
|
+
std::string to_string() const override;
|
49
|
+
|
50
|
+
private:
|
51
|
+
FramebufferLayoutDesc m_desc;
|
52
|
+
Slang::ComPtr<gfx::IFramebufferLayout> m_gfx_framebuffer_layout;
|
53
|
+
};
|
54
|
+
|
55
|
+
struct FramebufferDesc {
|
56
|
+
/// List of render targets.
|
57
|
+
std::vector<ref<ResourceView>> render_targets;
|
58
|
+
/// Depth-stencil target (optional).
|
59
|
+
ref<ResourceView> depth_stencil;
|
60
|
+
/// Framebuffer layout (optional). If not provided, framebuffer layout is determined from the render targets.
|
61
|
+
ref<FramebufferLayout> layout;
|
62
|
+
};
|
63
|
+
|
64
|
+
class SGL_API Framebuffer : public DeviceResource {
|
65
|
+
SGL_OBJECT(Framebuffer)
|
66
|
+
public:
|
67
|
+
Framebuffer(ref<Device> device, FramebufferDesc desc);
|
68
|
+
virtual ~Framebuffer();
|
69
|
+
|
70
|
+
const FramebufferDesc& desc() const { return m_desc; }
|
71
|
+
|
72
|
+
const ref<FramebufferLayout>& layout() const { return m_desc.layout; }
|
73
|
+
|
74
|
+
gfx::IFramebuffer* gfx_framebuffer() const { return m_gfx_framebuffer; }
|
75
|
+
gfx::IRenderPassLayout* gfx_render_pass_layout() const { return m_gfx_render_pass_layout; }
|
76
|
+
|
77
|
+
std::string to_string() const override;
|
78
|
+
|
79
|
+
private:
|
80
|
+
FramebufferDesc m_desc;
|
81
|
+
Slang::ComPtr<gfx::IFramebuffer> m_gfx_framebuffer;
|
82
|
+
Slang::ComPtr<gfx::IRenderPassLayout> m_gfx_render_pass_layout;
|
83
|
+
};
|
84
|
+
|
85
|
+
} // namespace sgl
|
@@ -0,0 +1,164 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
|
3
|
+
#pragma once
|
4
|
+
|
5
|
+
#include "sgl/core/object.h"
|
6
|
+
|
7
|
+
namespace sgl {
|
8
|
+
|
9
|
+
// device.h
|
10
|
+
|
11
|
+
struct DeviceDesc;
|
12
|
+
class Device;
|
13
|
+
|
14
|
+
// swapchain.h
|
15
|
+
|
16
|
+
struct SwapchainDesc;
|
17
|
+
class Swapchain;
|
18
|
+
|
19
|
+
// buffer_cursor.h
|
20
|
+
class BufferCursor;
|
21
|
+
class BufferElementCursor;
|
22
|
+
|
23
|
+
// resource.h
|
24
|
+
|
25
|
+
class Resource;
|
26
|
+
|
27
|
+
struct BufferDesc;
|
28
|
+
class Buffer;
|
29
|
+
|
30
|
+
struct TextureDesc;
|
31
|
+
class Texture;
|
32
|
+
|
33
|
+
struct ResourceViewDesc;
|
34
|
+
class ResourceView;
|
35
|
+
|
36
|
+
// sampler.h
|
37
|
+
|
38
|
+
struct SamplerDesc;
|
39
|
+
class Sampler;
|
40
|
+
|
41
|
+
// fence.h
|
42
|
+
|
43
|
+
struct FenceDesc;
|
44
|
+
class Fence;
|
45
|
+
|
46
|
+
// framebuffer.h
|
47
|
+
|
48
|
+
struct FramebufferLayoutTargetDesc;
|
49
|
+
struct FramebufferLayoutDesc;
|
50
|
+
class FramebufferLayout;
|
51
|
+
struct FramebufferDesc;
|
52
|
+
class Framebuffer;
|
53
|
+
|
54
|
+
// shader.h
|
55
|
+
|
56
|
+
struct SlangSessionDesc;
|
57
|
+
class SlangSession;
|
58
|
+
|
59
|
+
class SlangModule;
|
60
|
+
class SlangComponentType;
|
61
|
+
class SlangGlobalScope;
|
62
|
+
class SlangEntryPoint;
|
63
|
+
|
64
|
+
class ShaderProgram;
|
65
|
+
|
66
|
+
// reflection.h
|
67
|
+
|
68
|
+
class DeclReflection;
|
69
|
+
class DeclReflectionChildList;
|
70
|
+
class DeclReflectionIndexedChildList;
|
71
|
+
class TypeReflection;
|
72
|
+
class TypeReflectionFieldList;
|
73
|
+
class TypeLayoutReflection;
|
74
|
+
class TypeLayoutReflectionFieldList;
|
75
|
+
class FunctionReflection;
|
76
|
+
class FunctionReflectionParameterList;
|
77
|
+
class FunctionReflectionOverloadList;
|
78
|
+
class VariableReflection;
|
79
|
+
class VariableLayoutReflection;
|
80
|
+
class EntryPointLayout;
|
81
|
+
class EntryPointLayoutParameterList;
|
82
|
+
class ProgramLayout;
|
83
|
+
class ProgramLayoutParameterList;
|
84
|
+
class ProgramLayoutEntryPointList;
|
85
|
+
|
86
|
+
// kernel.h
|
87
|
+
|
88
|
+
class Kernel;
|
89
|
+
struct ComputeKernelDesc;
|
90
|
+
class ComputeKernel;
|
91
|
+
|
92
|
+
// pipeline.h
|
93
|
+
|
94
|
+
class Pipeline;
|
95
|
+
struct ComputePipelineDesc;
|
96
|
+
class ComputePipeline;
|
97
|
+
struct GraphicsPipelineDesc;
|
98
|
+
class GraphicsPipeline;
|
99
|
+
struct RayTracingPipelineDesc;
|
100
|
+
class RayTracingPipeline;
|
101
|
+
|
102
|
+
// query.h
|
103
|
+
|
104
|
+
struct QueryPoolDesc;
|
105
|
+
class QueryPool;
|
106
|
+
|
107
|
+
// raytracing.h
|
108
|
+
|
109
|
+
struct AccelerationStructureDesc;
|
110
|
+
class AccelerationStructure;
|
111
|
+
struct ShaderTableDesc;
|
112
|
+
class ShaderTable;
|
113
|
+
|
114
|
+
// command.h
|
115
|
+
|
116
|
+
class CommandBuffer;
|
117
|
+
class ComputeCommandEncoder;
|
118
|
+
class RenderCommandEncoder;
|
119
|
+
class RayTracingCommandEncoder;
|
120
|
+
|
121
|
+
// shader_cursor.h
|
122
|
+
|
123
|
+
class ShaderCursor;
|
124
|
+
class ShaderObject;
|
125
|
+
class TransientShaderObject;
|
126
|
+
class MutableShaderObject;
|
127
|
+
|
128
|
+
// input_layout.h
|
129
|
+
|
130
|
+
struct InputLayoutDesc;
|
131
|
+
class InputLayout;
|
132
|
+
|
133
|
+
// memory_heap.h
|
134
|
+
|
135
|
+
struct MemoryHeapDesc;
|
136
|
+
class MemoryHeap;
|
137
|
+
|
138
|
+
// blit.h
|
139
|
+
|
140
|
+
class Blitter;
|
141
|
+
|
142
|
+
// texture_loader.h
|
143
|
+
|
144
|
+
class TextureLoader;
|
145
|
+
|
146
|
+
// hot_reload.h
|
147
|
+
class HotReload;
|
148
|
+
|
149
|
+
// cuda_interop.h
|
150
|
+
|
151
|
+
namespace cuda {
|
152
|
+
struct TensorView;
|
153
|
+
class InteropBuffer;
|
154
|
+
} // namespace cuda
|
155
|
+
|
156
|
+
// cuda_utils.h
|
157
|
+
|
158
|
+
namespace cuda {
|
159
|
+
class Device;
|
160
|
+
class ExternalMemory;
|
161
|
+
class ExternalSemaphore;
|
162
|
+
} // namespace cuda
|
163
|
+
|
164
|
+
} // namespace sgl
|
@@ -0,0 +1,20 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
|
3
|
+
#pragma once
|
4
|
+
|
5
|
+
#include "sgl/core/error.h"
|
6
|
+
|
7
|
+
#include <slang-gfx.h>
|
8
|
+
|
9
|
+
|
10
|
+
namespace sgl {
|
11
|
+
SGL_API std::string build_slang_failed_message(const char* call, SlangResult result);
|
12
|
+
}
|
13
|
+
|
14
|
+
#define SLANG_CALL(call) \
|
15
|
+
{ \
|
16
|
+
SlangResult result_ = call; \
|
17
|
+
if (SLANG_FAILED(result_)) { \
|
18
|
+
SGL_THROW(build_slang_failed_message(#call, result_)); \
|
19
|
+
} \
|
20
|
+
}
|