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,75 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
|
3
|
+
#pragma once
|
4
|
+
|
5
|
+
#include "sgl/device/fwd.h"
|
6
|
+
#include "sgl/device/types.h"
|
7
|
+
#include "sgl/device/reflection.h"
|
8
|
+
#include "sgl/device/device_resource.h"
|
9
|
+
|
10
|
+
#include "sgl/core/fwd.h"
|
11
|
+
#include "sgl/core/object.h"
|
12
|
+
#include "sgl/core/enum.h"
|
13
|
+
|
14
|
+
#include <slang.h>
|
15
|
+
|
16
|
+
#include <exception>
|
17
|
+
#include <map>
|
18
|
+
#include <set>
|
19
|
+
#include <string>
|
20
|
+
#include <vector>
|
21
|
+
|
22
|
+
namespace sgl {
|
23
|
+
|
24
|
+
/// Shader hot reload management, detects when relevant slang files
|
25
|
+
/// have been editor and triggers session recreates as necessary.
|
26
|
+
class SGL_API HotReload : public Object {
|
27
|
+
SGL_OBJECT(HotReload)
|
28
|
+
public:
|
29
|
+
HotReload(ref<Device> device);
|
30
|
+
|
31
|
+
/// Force immediate recreation of all registered sessions and
|
32
|
+
/// any modules/programs they've loaded/linked.
|
33
|
+
void recreate_all_sessions();
|
34
|
+
|
35
|
+
/// Updates internal file system monitor for change detection.
|
36
|
+
void update();
|
37
|
+
|
38
|
+
// Enable/disable auto rebuild in response to file system events.
|
39
|
+
bool auto_detect_changes() const { return m_auto_detect_changes; }
|
40
|
+
void set_auto_detect_changes(bool val) { m_auto_detect_changes = val; }
|
41
|
+
|
42
|
+
// Adjust delay used by internal fs monitor before reponding to file system events.
|
43
|
+
uint32_t auto_detect_delay() const;
|
44
|
+
void set_auto_detect_delay(uint32_t delay_ms);
|
45
|
+
|
46
|
+
/// Return true if last attempt to recreate sessions failed with exception.
|
47
|
+
bool last_build_failed() const { return m_last_build_failed; }
|
48
|
+
|
49
|
+
// Internal functions called from session constructor/destructor
|
50
|
+
// to register sessions with hot reload system.
|
51
|
+
void _register_slang_session(SlangSession* session);
|
52
|
+
void _unregister_slang_session(SlangSession* session);
|
53
|
+
|
54
|
+
// Called from session when modules have updated, meaning dependencies may have changed
|
55
|
+
void _on_session_modules_changed(SlangSession* session);
|
56
|
+
|
57
|
+
/// Exclusively for testing, erase all existing file watches
|
58
|
+
void _clear_file_watches();
|
59
|
+
void _reset_reloaded() { m_has_reloaded = false; }
|
60
|
+
bool _has_reloaded() const { return m_has_reloaded; }
|
61
|
+
|
62
|
+
private:
|
63
|
+
void on_file_system_event(std::span<FileSystemWatchEvent> events);
|
64
|
+
void update_watched_paths_for_session(SlangSession* session);
|
65
|
+
|
66
|
+
Device* m_device;
|
67
|
+
bool m_auto_detect_changes{true};
|
68
|
+
ref<FileSystemWatcher> m_file_system_watcher;
|
69
|
+
std::set<SlangSession*> m_all_slang_sessions;
|
70
|
+
bool m_last_build_failed{false};
|
71
|
+
std::set<std::filesystem::path> m_watched_paths;
|
72
|
+
bool m_has_reloaded;
|
73
|
+
};
|
74
|
+
|
75
|
+
} // namespace sgl
|
@@ -0,0 +1,74 @@
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
2
|
+
|
3
|
+
#pragma once
|
4
|
+
|
5
|
+
#include "sgl/core/enum.h"
|
6
|
+
|
7
|
+
#include "sgl/device/device_resource.h"
|
8
|
+
#include "sgl/device/formats.h"
|
9
|
+
|
10
|
+
#include <slang-gfx.h>
|
11
|
+
|
12
|
+
#include <string>
|
13
|
+
|
14
|
+
namespace sgl {
|
15
|
+
|
16
|
+
enum class InputSlotClass : uint8_t {
|
17
|
+
per_vertex = static_cast<uint8_t>(gfx::InputSlotClass::PerVertex),
|
18
|
+
per_instance = static_cast<uint8_t>(gfx::InputSlotClass::PerInstance),
|
19
|
+
};
|
20
|
+
|
21
|
+
SGL_ENUM_INFO(
|
22
|
+
InputSlotClass,
|
23
|
+
{
|
24
|
+
{InputSlotClass::per_vertex, "per_vertex"},
|
25
|
+
{InputSlotClass::per_instance, "per_instance"},
|
26
|
+
}
|
27
|
+
);
|
28
|
+
SGL_ENUM_REGISTER(InputSlotClass);
|
29
|
+
|
30
|
+
struct InputElementDesc {
|
31
|
+
/// The name of the corresponding parameter in shader code.
|
32
|
+
std::string semantic_name;
|
33
|
+
/// The index of the corresponding parameter in shader code.
|
34
|
+
/// Only needed if multiple parameters share a semantic name.
|
35
|
+
uint32_t semantic_index{0};
|
36
|
+
/// The format of the data being fetched for this element.
|
37
|
+
Format format{Format::unknown};
|
38
|
+
/// The offset in bytes of this element from the start of the corresponding chunk of vertex stream data.
|
39
|
+
size_t offset{0};
|
40
|
+
/// The index of the vertex stream to fetch this element's data from.
|
41
|
+
uint32_t buffer_slot_index{0};
|
42
|
+
};
|
43
|
+
|
44
|
+
struct VertexStreamDesc {
|
45
|
+
/// The stride in bytes for this vertex stream.
|
46
|
+
size_t stride{0};
|
47
|
+
/// Whether the stream contains per-vertex or per-instance data.
|
48
|
+
InputSlotClass slot_class{InputSlotClass::per_vertex};
|
49
|
+
/// How many instances to draw per chunk of data.
|
50
|
+
uint32_t instance_data_step_rate{0};
|
51
|
+
};
|
52
|
+
|
53
|
+
struct InputLayoutDesc {
|
54
|
+
std::vector<InputElementDesc> input_elements;
|
55
|
+
std::vector<VertexStreamDesc> vertex_streams;
|
56
|
+
};
|
57
|
+
|
58
|
+
class SGL_API InputLayout : public DeviceResource {
|
59
|
+
SGL_OBJECT(InputLayout)
|
60
|
+
public:
|
61
|
+
InputLayout(ref<Device> device, InputLayoutDesc desc);
|
62
|
+
|
63
|
+
const InputLayoutDesc& desc() const { return m_desc; }
|
64
|
+
|
65
|
+
gfx::IInputLayout* gfx_input_layout() const { return m_gfx_input_layout.get(); }
|
66
|
+
|
67
|
+
std::string to_string() const override;
|
68
|
+
|
69
|
+
private:
|
70
|
+
InputLayoutDesc m_desc;
|
71
|
+
Slang::ComPtr<gfx::IInputLayout> m_gfx_input_layout;
|
72
|
+
};
|
73
|
+
|
74
|
+
} // namespace sgl
|
@@ -0,0 +1,69 @@
|
|
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/shader_cursor.h"
|
8
|
+
|
9
|
+
#include "sgl/core/macros.h"
|
10
|
+
#include "sgl/core/object.h"
|
11
|
+
|
12
|
+
#include <functional>
|
13
|
+
|
14
|
+
namespace sgl {
|
15
|
+
|
16
|
+
class SGL_API Kernel : public DeviceResource {
|
17
|
+
SGL_OBJECT(Kernel)
|
18
|
+
public:
|
19
|
+
using BindVarsCallback = std::function<void(ShaderCursor)>;
|
20
|
+
|
21
|
+
virtual ~Kernel() = default;
|
22
|
+
|
23
|
+
ShaderProgram* program() const { return m_program; }
|
24
|
+
ReflectionCursor reflection() const { return ReflectionCursor(program()); }
|
25
|
+
|
26
|
+
protected:
|
27
|
+
Kernel(ref<Device> device, ref<ShaderProgram> program);
|
28
|
+
|
29
|
+
ref<ShaderProgram> m_program;
|
30
|
+
};
|
31
|
+
|
32
|
+
struct ComputeKernelDesc {
|
33
|
+
ref<ShaderProgram> program;
|
34
|
+
};
|
35
|
+
|
36
|
+
class SGL_API ComputeKernel : public Kernel {
|
37
|
+
SGL_OBJECT(ComputeKernel)
|
38
|
+
public:
|
39
|
+
ComputeKernel(ref<Device> device, ComputeKernelDesc desc);
|
40
|
+
~ComputeKernel() = default;
|
41
|
+
|
42
|
+
ComputePipeline* pipeline() const;
|
43
|
+
|
44
|
+
void dispatch(uint3 thread_count, BindVarsCallback bind_vars, ComputeCommandEncoder& encoder);
|
45
|
+
|
46
|
+
void dispatch(uint3 thread_count, BindVarsCallback bind_vars, CommandBuffer* command_buffer = nullptr);
|
47
|
+
|
48
|
+
private:
|
49
|
+
uint3 m_thread_group_size;
|
50
|
+
mutable ref<ComputePipeline> m_pipeline;
|
51
|
+
};
|
52
|
+
|
53
|
+
class SGL_API RayTracingKernel : public Kernel {
|
54
|
+
SGL_OBJECT(RayTracingKernel)
|
55
|
+
public:
|
56
|
+
RayTracingKernel(ref<Device> device, ref<ShaderProgram> program);
|
57
|
+
~RayTracingKernel() = default;
|
58
|
+
|
59
|
+
RayTracingPipeline* pipeline() const;
|
60
|
+
|
61
|
+
void dispatch(uint3 thread_count, BindVarsCallback bind_vars, RayTracingCommandEncoder& encoder);
|
62
|
+
|
63
|
+
void dispatch(uint3 thread_count, BindVarsCallback bind_vars, CommandBuffer* command_buffer = nullptr);
|
64
|
+
|
65
|
+
private:
|
66
|
+
mutable ref<RayTracingPipeline> m_pipeline;
|
67
|
+
};
|
68
|
+
|
69
|
+
} // namespace sgl
|
@@ -0,0 +1,155 @@
|
|
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/resource.h"
|
8
|
+
|
9
|
+
#include <memory>
|
10
|
+
#include <vector>
|
11
|
+
#include <deque>
|
12
|
+
|
13
|
+
namespace sgl {
|
14
|
+
|
15
|
+
struct MemoryHeapDesc {
|
16
|
+
/// The memory type of the heap.
|
17
|
+
MemoryType memory_type{MemoryType::upload};
|
18
|
+
/// The resource usage of the heap.
|
19
|
+
ResourceUsage usage{ResourceUsage::none};
|
20
|
+
/// The size of a page in bytes.
|
21
|
+
DeviceSize page_size{4 * 1024 * 1024};
|
22
|
+
/// True to retain large pages, false to release them after use.
|
23
|
+
bool retain_large_pages{false};
|
24
|
+
/// The debug name of the heap.
|
25
|
+
std::string debug_name;
|
26
|
+
};
|
27
|
+
|
28
|
+
/**
|
29
|
+
* \brief A memory heap is used to allocate temporary host-visible memory.
|
30
|
+
*
|
31
|
+
* A memory heap is a collection of memory pages. Each page has a buffer of size \c page_size.
|
32
|
+
* When allocating memory, the heap tries to add the allocation to the current page.
|
33
|
+
* If the allocation does not fit, a new page is allocated.
|
34
|
+
* For allocations larger than the configured page size, a new large page is allocated.
|
35
|
+
*
|
36
|
+
* The memory heap is tied to a fence. Each allocation records the currently signaled fence
|
37
|
+
* value when it is created. On release, the allocation is put on a deferred release queue.
|
38
|
+
* Only if the fence value of the memory heap is greater than the fence value of the allocation,
|
39
|
+
* the allocation is actually freed. This ensures that memory is not freed while still in use
|
40
|
+
* by the device.
|
41
|
+
*
|
42
|
+
* Allocations are returned as unique pointers. When the pointer is destroyed, the allocation
|
43
|
+
* is released. This ensures that the memory is freed when it is no longer used.
|
44
|
+
*/
|
45
|
+
class SGL_API MemoryHeap : public DeviceResource {
|
46
|
+
SGL_OBJECT(MemoryHeap)
|
47
|
+
public:
|
48
|
+
SGL_NON_COPYABLE_AND_MOVABLE(MemoryHeap);
|
49
|
+
|
50
|
+
using PageID = uint64_t;
|
51
|
+
|
52
|
+
struct AllocationData {
|
53
|
+
/// The heap this allocation belongs to.
|
54
|
+
const ref<MemoryHeap> heap;
|
55
|
+
/// The buffer this allocation belongs to.
|
56
|
+
const ref<Buffer> buffer;
|
57
|
+
/// The size of the allocation.
|
58
|
+
const DeviceSize size;
|
59
|
+
/// The offset of the allocation within the buffer.
|
60
|
+
const DeviceOffset offset;
|
61
|
+
/// Pointer to the host-visible memory.
|
62
|
+
uint8_t* const data;
|
63
|
+
|
64
|
+
/// The page where the allocation is stored.
|
65
|
+
PageID page_id;
|
66
|
+
/// The signaled fence value at the time when the allocation was created.
|
67
|
+
const uint64_t fence_value;
|
68
|
+
|
69
|
+
~AllocationData() { heap->release(this); }
|
70
|
+
|
71
|
+
/// The device address of the allocation.
|
72
|
+
DeviceAddress device_address() const { return buffer->device_address() + offset; }
|
73
|
+
};
|
74
|
+
|
75
|
+
using Allocation = std::unique_ptr<AllocationData>;
|
76
|
+
|
77
|
+
struct Stats {
|
78
|
+
/// The total size of the heap.
|
79
|
+
DeviceSize total_size{0};
|
80
|
+
/// The used size of the heap.
|
81
|
+
DeviceSize used_size{0};
|
82
|
+
/// The number of pages in the heap.
|
83
|
+
uint32_t page_count{0};
|
84
|
+
/// The number of large pages in the heap.
|
85
|
+
uint32_t large_page_count{0};
|
86
|
+
};
|
87
|
+
|
88
|
+
MemoryHeap(ref<Device> device, ref<Fence> fence, MemoryHeapDesc desc);
|
89
|
+
~MemoryHeap();
|
90
|
+
|
91
|
+
/// Description of the heap.
|
92
|
+
const MemoryHeapDesc& desc() const { return m_desc; }
|
93
|
+
/// Statistics of the heap.
|
94
|
+
const Stats& stats() const { return m_stats; }
|
95
|
+
|
96
|
+
/**
|
97
|
+
* \brief Allocate memory from this heap.
|
98
|
+
*
|
99
|
+
* \param size The number of bytes to allocate.
|
100
|
+
* \param alignment The alignment of the allocation.
|
101
|
+
* \return Returns a unique pointer to the allocation.
|
102
|
+
*/
|
103
|
+
Allocation allocate(DeviceSize size, DeviceSize alignment = 16);
|
104
|
+
|
105
|
+
/**
|
106
|
+
* \brief Execute deferred releases.
|
107
|
+
*
|
108
|
+
* This function should be called regularly to execute deferred releases.
|
109
|
+
*/
|
110
|
+
void execute_deferred_releases();
|
111
|
+
|
112
|
+
std::string to_string() const override;
|
113
|
+
|
114
|
+
private:
|
115
|
+
void release(AllocationData* allocation);
|
116
|
+
|
117
|
+
PageID allocate_page(DeviceSize size);
|
118
|
+
void free_page(PageID page_id);
|
119
|
+
|
120
|
+
PageID reclaim_or_allocate_page();
|
121
|
+
|
122
|
+
struct Page {
|
123
|
+
ref<Buffer> buffer;
|
124
|
+
uint8_t* data{nullptr};
|
125
|
+
uint32_t allocation_count{0};
|
126
|
+
DeviceOffset current_offset{0};
|
127
|
+
|
128
|
+
void reset()
|
129
|
+
{
|
130
|
+
allocation_count = 0;
|
131
|
+
current_offset = 0;
|
132
|
+
}
|
133
|
+
};
|
134
|
+
|
135
|
+
struct DeferredRelease {
|
136
|
+
uint64_t fence_value;
|
137
|
+
PageID page_id;
|
138
|
+
DeviceSize size;
|
139
|
+
};
|
140
|
+
|
141
|
+
static constexpr PageID INVALID_PAGE = PageID(-1);
|
142
|
+
|
143
|
+
ref<Fence> m_fence;
|
144
|
+
MemoryHeapDesc m_desc;
|
145
|
+
Stats m_stats;
|
146
|
+
|
147
|
+
std::vector<Page> m_pages;
|
148
|
+
std::vector<PageID> m_free_pages;
|
149
|
+
std::vector<PageID> m_available_pages;
|
150
|
+
PageID m_current_page{INVALID_PAGE};
|
151
|
+
|
152
|
+
std::deque<DeferredRelease> m_deferred_releases;
|
153
|
+
};
|
154
|
+
|
155
|
+
} // namespace sgl
|