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,539 @@
|
|
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/fence.h"
|
8
|
+
#include "sgl/device/resource.h"
|
9
|
+
#include "sgl/device/shader_object.h"
|
10
|
+
#include "sgl/device/raytracing.h"
|
11
|
+
|
12
|
+
#include "sgl/core/object.h"
|
13
|
+
#include "sgl/math/vector_types.h"
|
14
|
+
|
15
|
+
#include <span>
|
16
|
+
|
17
|
+
namespace sgl {
|
18
|
+
|
19
|
+
class SGL_API ComputeCommandEncoder {
|
20
|
+
public:
|
21
|
+
ComputeCommandEncoder(ComputeCommandEncoder&& other) noexcept
|
22
|
+
: m_command_buffer(std::exchange(other.m_command_buffer, nullptr))
|
23
|
+
, m_gfx_compute_command_encoder(std::exchange(other.m_gfx_compute_command_encoder, nullptr))
|
24
|
+
{
|
25
|
+
}
|
26
|
+
|
27
|
+
~ComputeCommandEncoder();
|
28
|
+
|
29
|
+
void end();
|
30
|
+
|
31
|
+
ref<TransientShaderObject> bind_pipeline(const ComputePipeline* pipeline);
|
32
|
+
void bind_pipeline(const ComputePipeline* pipeline, const ShaderObject* shader_object);
|
33
|
+
void dispatch(uint3 thread_count);
|
34
|
+
void dispatch_thread_groups(uint3 thread_group_count);
|
35
|
+
void dispatch_thread_groups_indirect(const Buffer* cmd_buffer, DeviceOffset offset);
|
36
|
+
|
37
|
+
private:
|
38
|
+
ComputeCommandEncoder(CommandBuffer* command_buffer, gfx::IComputeCommandEncoder* gfx_compute_command_encoder)
|
39
|
+
: m_command_buffer(command_buffer)
|
40
|
+
, m_gfx_compute_command_encoder(gfx_compute_command_encoder)
|
41
|
+
{
|
42
|
+
}
|
43
|
+
|
44
|
+
ComputeCommandEncoder(const ComputeCommandEncoder&) = delete;
|
45
|
+
ComputeCommandEncoder& operator=(const ComputeCommandEncoder&) = delete;
|
46
|
+
ComputeCommandEncoder& operator=(ComputeCommandEncoder&& other) noexcept = delete;
|
47
|
+
|
48
|
+
CommandBuffer* m_command_buffer;
|
49
|
+
gfx::IComputeCommandEncoder* m_gfx_compute_command_encoder;
|
50
|
+
const ComputePipeline* m_bound_pipeline{nullptr};
|
51
|
+
ref<const ShaderObject> m_bound_shader_object;
|
52
|
+
|
53
|
+
friend class CommandBuffer;
|
54
|
+
};
|
55
|
+
|
56
|
+
class SGL_API RenderCommandEncoder {
|
57
|
+
public:
|
58
|
+
RenderCommandEncoder(RenderCommandEncoder&& other) noexcept
|
59
|
+
: m_command_buffer(std::exchange(other.m_command_buffer, nullptr))
|
60
|
+
, m_gfx_render_command_encoder(std::exchange(other.m_gfx_render_command_encoder, nullptr))
|
61
|
+
{
|
62
|
+
}
|
63
|
+
|
64
|
+
~RenderCommandEncoder();
|
65
|
+
|
66
|
+
void end();
|
67
|
+
|
68
|
+
ref<TransientShaderObject> bind_pipeline(const GraphicsPipeline* pipeline);
|
69
|
+
void bind_pipeline(const GraphicsPipeline* pipeline, const ShaderObject* shader_object);
|
70
|
+
|
71
|
+
void set_viewports(std::span<Viewport> viewports);
|
72
|
+
void set_scissor_rects(std::span<ScissorRect> scissor_rects);
|
73
|
+
void set_viewport_and_scissor_rect(const Viewport& viewport);
|
74
|
+
|
75
|
+
void set_primitive_topology(PrimitiveTopology topology);
|
76
|
+
|
77
|
+
void set_stencil_reference(uint32_t reference_value);
|
78
|
+
|
79
|
+
// void set_sample_positions(
|
80
|
+
// gfx_count samples_per_pixel, gfx_count pixel_count, const sample_position* sample_positions) = 0;
|
81
|
+
|
82
|
+
|
83
|
+
struct Slot {
|
84
|
+
const Buffer* buffer;
|
85
|
+
DeviceOffset offset;
|
86
|
+
};
|
87
|
+
void set_vertex_buffers(uint32_t start_slot, std::span<Slot> slots);
|
88
|
+
void set_vertex_buffer(uint32_t slot, const Buffer* buffer, DeviceOffset offset = 0);
|
89
|
+
void set_index_buffer(const Buffer* buffer, Format index_format, DeviceOffset offset = 0);
|
90
|
+
|
91
|
+
void draw(uint32_t vertex_count, uint32_t start_vertex = 0);
|
92
|
+
|
93
|
+
void draw_indexed(uint32_t index_count, uint32_t start_index = 0, uint32_t base_vertex = 0);
|
94
|
+
|
95
|
+
void draw_instanced(
|
96
|
+
uint32_t vertex_count,
|
97
|
+
uint32_t instance_count,
|
98
|
+
uint32_t start_vertex = 0,
|
99
|
+
uint32_t start_instance = 0
|
100
|
+
);
|
101
|
+
|
102
|
+
void draw_indexed_instanced(
|
103
|
+
uint32_t index_count,
|
104
|
+
uint32_t instance_count,
|
105
|
+
uint32_t start_index = 0,
|
106
|
+
uint32_t base_vertex = 0,
|
107
|
+
uint32_t start_instance = 0
|
108
|
+
);
|
109
|
+
|
110
|
+
void draw_indirect(
|
111
|
+
uint32_t max_draw_count,
|
112
|
+
const Buffer* arg_buffer,
|
113
|
+
DeviceOffset arg_offset,
|
114
|
+
const Buffer* count_buffer = nullptr,
|
115
|
+
DeviceOffset count_offset = 0
|
116
|
+
);
|
117
|
+
|
118
|
+
void draw_indexed_indirect(
|
119
|
+
uint32_t max_draw_count,
|
120
|
+
const Buffer* arg_buffer,
|
121
|
+
DeviceOffset arg_offset,
|
122
|
+
const Buffer* count_buffer = nullptr,
|
123
|
+
DeviceOffset count_offset = 0
|
124
|
+
);
|
125
|
+
|
126
|
+
void draw_mesh_tasks(uint32_t x, uint32_t y, uint32_t z);
|
127
|
+
|
128
|
+
private:
|
129
|
+
RenderCommandEncoder(CommandBuffer* command_buffer, gfx::IRenderCommandEncoder* gfx_render_command_encoder)
|
130
|
+
: m_command_buffer(command_buffer)
|
131
|
+
, m_gfx_render_command_encoder(gfx_render_command_encoder)
|
132
|
+
{
|
133
|
+
}
|
134
|
+
|
135
|
+
RenderCommandEncoder(const RenderCommandEncoder&) = delete;
|
136
|
+
RenderCommandEncoder& operator=(const RenderCommandEncoder&) = delete;
|
137
|
+
RenderCommandEncoder& operator=(RenderCommandEncoder&& other) noexcept = delete;
|
138
|
+
|
139
|
+
CommandBuffer* m_command_buffer;
|
140
|
+
gfx::IRenderCommandEncoder* m_gfx_render_command_encoder;
|
141
|
+
const GraphicsPipeline* m_bound_pipeline{nullptr};
|
142
|
+
ref<const ShaderObject> m_bound_shader_object;
|
143
|
+
|
144
|
+
friend class CommandBuffer;
|
145
|
+
};
|
146
|
+
|
147
|
+
class SGL_API RayTracingCommandEncoder {
|
148
|
+
public:
|
149
|
+
RayTracingCommandEncoder(RayTracingCommandEncoder&& other) noexcept
|
150
|
+
: m_command_buffer(std::exchange(other.m_command_buffer, nullptr))
|
151
|
+
, m_gfx_ray_tracing_command_encoder(std::exchange(other.m_gfx_ray_tracing_command_encoder, nullptr))
|
152
|
+
{
|
153
|
+
}
|
154
|
+
|
155
|
+
~RayTracingCommandEncoder();
|
156
|
+
|
157
|
+
void end();
|
158
|
+
|
159
|
+
ref<TransientShaderObject> bind_pipeline(const RayTracingPipeline* pipeline);
|
160
|
+
void bind_pipeline(const RayTracingPipeline* pipeline, const ShaderObject* shader_object);
|
161
|
+
void dispatch_rays(uint32_t ray_gen_shader_index, const ShaderTable* shader_table, uint3 dimensions);
|
162
|
+
|
163
|
+
void build_acceleration_structure(
|
164
|
+
const AccelerationStructureBuildDesc& desc,
|
165
|
+
std::span<AccelerationStructureQueryDesc> queries = std::span<AccelerationStructureQueryDesc>()
|
166
|
+
);
|
167
|
+
|
168
|
+
void copy_acceleration_structure(
|
169
|
+
AccelerationStructure* dst,
|
170
|
+
const AccelerationStructure* src,
|
171
|
+
AccelerationStructureCopyMode mode
|
172
|
+
);
|
173
|
+
|
174
|
+
void query_acceleration_structure_properties(
|
175
|
+
std::span<const AccelerationStructure*> acceleration_structures,
|
176
|
+
std::span<AccelerationStructureQueryDesc> queries
|
177
|
+
);
|
178
|
+
|
179
|
+
void serialize_acceleration_structure(DeviceAddress dst, const AccelerationStructure* src);
|
180
|
+
void deserialize_acceleration_structure(AccelerationStructure* dst, DeviceAddress src);
|
181
|
+
|
182
|
+
private:
|
183
|
+
RayTracingCommandEncoder(
|
184
|
+
CommandBuffer* command_buffer,
|
185
|
+
gfx::IRayTracingCommandEncoder* gfx_ray_tracing_command_encoder
|
186
|
+
)
|
187
|
+
: m_command_buffer(command_buffer)
|
188
|
+
, m_gfx_ray_tracing_command_encoder(gfx_ray_tracing_command_encoder)
|
189
|
+
{
|
190
|
+
}
|
191
|
+
|
192
|
+
RayTracingCommandEncoder(const RayTracingCommandEncoder&) = delete;
|
193
|
+
RayTracingCommandEncoder& operator=(const RayTracingCommandEncoder&) = delete;
|
194
|
+
RayTracingCommandEncoder& operator=(RayTracingCommandEncoder&& other) noexcept = delete;
|
195
|
+
|
196
|
+
CommandBuffer* m_command_buffer;
|
197
|
+
gfx::IRayTracingCommandEncoder* m_gfx_ray_tracing_command_encoder;
|
198
|
+
const RayTracingPipeline* m_bound_pipeline{nullptr};
|
199
|
+
ref<const ShaderObject> m_bound_shader_object;
|
200
|
+
|
201
|
+
friend class CommandBuffer;
|
202
|
+
};
|
203
|
+
|
204
|
+
class SGL_API CommandBuffer : public DeviceResource {
|
205
|
+
SGL_OBJECT(CommandBuffer)
|
206
|
+
public:
|
207
|
+
CommandBuffer(ref<Device> device);
|
208
|
+
~CommandBuffer();
|
209
|
+
|
210
|
+
/**
|
211
|
+
* \brief Open the command buffer for recording.
|
212
|
+
*
|
213
|
+
* No-op if command buffer is already open.
|
214
|
+
*
|
215
|
+
* \note Due to current limitations, only a single command buffer can be open at any given time.
|
216
|
+
*/
|
217
|
+
void open();
|
218
|
+
|
219
|
+
/**
|
220
|
+
* \brief Close the command buffer.
|
221
|
+
*
|
222
|
+
* No-op if command buffer is already closed.
|
223
|
+
*/
|
224
|
+
void close();
|
225
|
+
|
226
|
+
/// True if the command buffer is open.
|
227
|
+
bool is_open() const { return m_open; }
|
228
|
+
|
229
|
+
/**
|
230
|
+
* \brief Submit the command buffer to the device.
|
231
|
+
*
|
232
|
+
* The returned submission ID can be used to wait for the command buffer to complete.
|
233
|
+
*
|
234
|
+
* \param queue Command queue to submit to.
|
235
|
+
* \return Submission ID.
|
236
|
+
*/
|
237
|
+
uint64_t submit(CommandQueueType queue = CommandQueueType::graphics);
|
238
|
+
|
239
|
+
// ------------------------------------------------------------------------
|
240
|
+
// Queries
|
241
|
+
// ------------------------------------------------------------------------
|
242
|
+
|
243
|
+
/**
|
244
|
+
* \brief Write a timestamp.
|
245
|
+
*
|
246
|
+
* \param query_pool Query pool.
|
247
|
+
* \param index Index of the query.
|
248
|
+
*/
|
249
|
+
void write_timestamp(QueryPool* query_pool, uint32_t index);
|
250
|
+
|
251
|
+
/**
|
252
|
+
* \brief Resolve a list of queries and write the results to a buffer.
|
253
|
+
*
|
254
|
+
* \param query_pool Query pool.
|
255
|
+
* \param index Index of the first query.
|
256
|
+
* \param count Number of queries to resolve.
|
257
|
+
* \param buffer Destination buffer.
|
258
|
+
* \param offset Offset into the destination buffer.
|
259
|
+
*/
|
260
|
+
void resolve_query(QueryPool* query_pool, uint32_t index, uint32_t count, Buffer* buffer, DeviceOffset offset);
|
261
|
+
|
262
|
+
// ------------------------------------------------------------------------
|
263
|
+
// Resource state tracking
|
264
|
+
// ------------------------------------------------------------------------
|
265
|
+
|
266
|
+
/**
|
267
|
+
* Transition resource state of a resource and add a barrier if state has changed.
|
268
|
+
* \param resource Resource
|
269
|
+
* \param new_state New state
|
270
|
+
* \return True if barrier was recorded (i.e. state has changed).
|
271
|
+
*/
|
272
|
+
bool set_resource_state(const Resource* resource, ResourceState new_state);
|
273
|
+
|
274
|
+
/**
|
275
|
+
* Transition resource state of a resource and add a barrier if state has changed.
|
276
|
+
* For buffer views, this will set the resource state of the entire buffer.
|
277
|
+
* For texture views, this will set the resource state of all its sub-resources.
|
278
|
+
* \param resource_view Resource view
|
279
|
+
* \param new_state New state
|
280
|
+
* \return True if barrier was recorded (i.e. state has changed).
|
281
|
+
*/
|
282
|
+
bool set_resource_state(const ResourceView* resource_view, ResourceState new_state);
|
283
|
+
|
284
|
+
/**
|
285
|
+
* Transition resource state of a buffer and add a barrier if state has changed.
|
286
|
+
* \param buffer Buffer
|
287
|
+
* \param new_state New state
|
288
|
+
* \return True if barrier was recorded (i.e. state has changed).
|
289
|
+
*/
|
290
|
+
bool set_buffer_state(const Buffer* buffer, ResourceState new_state);
|
291
|
+
|
292
|
+
/**
|
293
|
+
* Transition resource state of a texture and add a barrier if state has changed.
|
294
|
+
* \param texture Texture
|
295
|
+
* \param new_state New state
|
296
|
+
* \return True if barrier was recorded (i.e. state has changed).
|
297
|
+
*/
|
298
|
+
bool set_texture_state(const Texture* texture, ResourceState new_state);
|
299
|
+
|
300
|
+
/**
|
301
|
+
* Transition resource state of texture sub-resources and add a barrier if state has changed.
|
302
|
+
* \param texture Texture
|
303
|
+
* \param range Subresource range
|
304
|
+
* \param new_state New state
|
305
|
+
* \return True if barrier was recorded (i.e. state has changed).
|
306
|
+
*/
|
307
|
+
bool set_texture_subresource_state(const Texture* texture, SubresourceRange range, ResourceState new_state);
|
308
|
+
|
309
|
+
/**
|
310
|
+
* Insert a UAV barrier
|
311
|
+
*/
|
312
|
+
void uav_barrier(const Resource* resource);
|
313
|
+
|
314
|
+
// ------------------------------------------------------------------------
|
315
|
+
// Resources
|
316
|
+
// ------------------------------------------------------------------------
|
317
|
+
|
318
|
+
void clear_resource_view(ResourceView* resource_view, float4 clear_value);
|
319
|
+
|
320
|
+
void clear_resource_view(ResourceView* resource_view, uint4 clear_value);
|
321
|
+
|
322
|
+
void clear_resource_view(
|
323
|
+
ResourceView* resource_view,
|
324
|
+
float depth_value,
|
325
|
+
uint32_t stencil_value,
|
326
|
+
bool clear_depth,
|
327
|
+
bool clear_stencil
|
328
|
+
);
|
329
|
+
|
330
|
+
void clear_texture(Texture* texture, float4 clear_value);
|
331
|
+
|
332
|
+
void clear_texture(Texture* texture, uint4 clear_value);
|
333
|
+
|
334
|
+
/**
|
335
|
+
* \brief Copy an entire resource.
|
336
|
+
*
|
337
|
+
* \param dst Destination resource.
|
338
|
+
* \param src Source resource.
|
339
|
+
*/
|
340
|
+
void copy_resource(Resource* dst, const Resource* src);
|
341
|
+
|
342
|
+
/**
|
343
|
+
* \brief Copy a buffer region.
|
344
|
+
*
|
345
|
+
* \param dst Destination buffer.
|
346
|
+
* \param dst_offset Destination offset in bytes.
|
347
|
+
* \param src Source buffer.
|
348
|
+
* \param src_offset Source offset in bytes.
|
349
|
+
* \param size Size in bytes.
|
350
|
+
*/
|
351
|
+
void copy_buffer_region(
|
352
|
+
Buffer* dst,
|
353
|
+
DeviceOffset dst_offset,
|
354
|
+
const Buffer* src,
|
355
|
+
DeviceOffset src_offset,
|
356
|
+
DeviceSize size
|
357
|
+
);
|
358
|
+
|
359
|
+
/**
|
360
|
+
* \brief Copy a texture region.
|
361
|
+
*
|
362
|
+
* \param dst Destination texture.
|
363
|
+
* \param dst_subresource Destination subresource index.
|
364
|
+
* \param dst_offset Destination offset in texels.
|
365
|
+
* \param src Source texture.
|
366
|
+
* \param src_subresource Source subresource index.
|
367
|
+
* \param src_offset Source offset in texels.
|
368
|
+
* \param extent Size in texels (-1 for maximum possible size).
|
369
|
+
*/
|
370
|
+
void copy_texture_region(
|
371
|
+
Texture* dst,
|
372
|
+
uint32_t dst_subresource,
|
373
|
+
uint3 dst_offset,
|
374
|
+
const Texture* src,
|
375
|
+
uint32_t src_subresource,
|
376
|
+
uint3 src_offset,
|
377
|
+
uint3 extent = uint3(-1)
|
378
|
+
);
|
379
|
+
|
380
|
+
/**
|
381
|
+
* \brief Copy a texture to a buffer.
|
382
|
+
*
|
383
|
+
* \param dst Destination buffer.
|
384
|
+
* \param dst_offset Destination offset in bytes.
|
385
|
+
* \param dst_size Destination size in bytes.
|
386
|
+
* \param dst_row_stride Destination row stride in bytes.
|
387
|
+
* \param src Source texture.
|
388
|
+
* \param src_subresource Source subresource index.
|
389
|
+
* \param src_offset Source offset in texels.
|
390
|
+
* \param extent Extent in texels (-1 for maximum possible extent).
|
391
|
+
*/
|
392
|
+
void copy_texture_to_buffer(
|
393
|
+
Buffer* dst,
|
394
|
+
DeviceOffset dst_offset,
|
395
|
+
DeviceSize dst_size,
|
396
|
+
DeviceSize dst_row_stride,
|
397
|
+
const Texture* src,
|
398
|
+
uint32_t src_subresource,
|
399
|
+
uint3 src_offset = uint3(0),
|
400
|
+
uint3 extent = uint3(-1)
|
401
|
+
);
|
402
|
+
|
403
|
+
/**
|
404
|
+
* \brief Upload host memory to a buffer.
|
405
|
+
*
|
406
|
+
* \param buffer Buffer to write to.
|
407
|
+
* \param offset Buffer offset in bytes.
|
408
|
+
* \param size Number of bytes to write.
|
409
|
+
* \param data Host memory to write.
|
410
|
+
*/
|
411
|
+
void upload_buffer_data(Buffer* buffer, size_t offset, size_t size, const void* data);
|
412
|
+
|
413
|
+
/**
|
414
|
+
* \brief Upload host memory to a texture.
|
415
|
+
*
|
416
|
+
* \param texture Texture to write to.
|
417
|
+
* \param subresource Subresource index.
|
418
|
+
* \param subresource_data Subresource data.
|
419
|
+
*/
|
420
|
+
void upload_texture_data(Texture* texture, uint32_t subresource, SubresourceData subresource_data);
|
421
|
+
|
422
|
+
/**
|
423
|
+
* \brief Resolve a multi-sampled texture.
|
424
|
+
*
|
425
|
+
* Both \c dst and \c src must have the same dimensions, array-size, mip-count and format.
|
426
|
+
* If any of these properties don't match, use \c resolve_subresource.
|
427
|
+
*
|
428
|
+
* \param dst Destination texture.
|
429
|
+
* \param src Source texture.
|
430
|
+
*/
|
431
|
+
void resolve_texture(Texture* dst, const Texture* src);
|
432
|
+
|
433
|
+
/**
|
434
|
+
* \brief Resolve a multi-sampled texture sub-resource.
|
435
|
+
*
|
436
|
+
* Both \c dst and \c src sub-resources must have the same dimensions and format.
|
437
|
+
*
|
438
|
+
* \param dst Destination texture.
|
439
|
+
* \param dst_subresource Destination sub-resource index.
|
440
|
+
* \param src Source texture.
|
441
|
+
* \param src_subresource Source sub-resource index.
|
442
|
+
*/
|
443
|
+
void resolve_subresource(Texture* dst, uint32_t dst_subresource, const Texture* src, uint32_t src_subresource);
|
444
|
+
|
445
|
+
/**
|
446
|
+
* \brief Blit a SRV to an RTV.
|
447
|
+
*
|
448
|
+
* Blits the full extent of the source texture to the destination texture.
|
449
|
+
*
|
450
|
+
* \param dst RTV of the destination texture.
|
451
|
+
* \param src SRV of the source texture.
|
452
|
+
* \param filter Filtering mode to use.
|
453
|
+
*/
|
454
|
+
void blit(ResourceView* dst, ResourceView* src, TextureFilteringMode filter = TextureFilteringMode::linear);
|
455
|
+
|
456
|
+
/**
|
457
|
+
* \brief Blit a texture to another texture.
|
458
|
+
*
|
459
|
+
* Blits the full extent of the source texture to the destination texture.
|
460
|
+
*
|
461
|
+
* \param dst Destination texture.
|
462
|
+
* \param src Source texture.
|
463
|
+
* \param filter Filtering mode to use.
|
464
|
+
*/
|
465
|
+
void blit(Texture* dst, Texture* src, TextureFilteringMode filter = TextureFilteringMode::linear);
|
466
|
+
|
467
|
+
/**
|
468
|
+
* \brief Start encoding compute commands.
|
469
|
+
*
|
470
|
+
* The returned \c ComputeCommandEncoder is used to bind compute pipelines and issue dispatches.
|
471
|
+
* The encoding is ended when the \c ComputeCommandEncoder is destroyed.
|
472
|
+
*/
|
473
|
+
ComputeCommandEncoder encode_compute_commands();
|
474
|
+
|
475
|
+
/**
|
476
|
+
* \brief Start encoding render commands.
|
477
|
+
*
|
478
|
+
* The returned \c RenderCommandEncoder is used to bind graphics pipelines and issue dispatches.
|
479
|
+
* The encoding is ended when the \c RenderCommandEncoder is destroyed.
|
480
|
+
*/
|
481
|
+
RenderCommandEncoder encode_render_commands(Framebuffer* framebuffer);
|
482
|
+
|
483
|
+
/**
|
484
|
+
* \brief Start encoding ray tracing commands.
|
485
|
+
*
|
486
|
+
* The returned \c RayTracingCommandEncoder is used to bind ray tracing pipelines and issue dispatches.
|
487
|
+
* It also serves for building and managing acceleration structures.
|
488
|
+
* The encoding is ended when the \c RayTracingCommandEncoder is destroyed.
|
489
|
+
*/
|
490
|
+
RayTracingCommandEncoder encode_ray_tracing_commands();
|
491
|
+
|
492
|
+
// ------------------------------------------------------------------------
|
493
|
+
// Debug events
|
494
|
+
// ------------------------------------------------------------------------
|
495
|
+
|
496
|
+
/// Begin a debug event.
|
497
|
+
void begin_debug_event(const char* name, float3 color);
|
498
|
+
|
499
|
+
/// End a debug event.
|
500
|
+
void end_debug_event();
|
501
|
+
|
502
|
+
gfx::ICommandBuffer* gfx_command_buffer() const { return m_gfx_command_buffer; }
|
503
|
+
|
504
|
+
std::string to_string() const override;
|
505
|
+
|
506
|
+
private:
|
507
|
+
/// Called by command encoders when they are destroyed.
|
508
|
+
void end_encoder();
|
509
|
+
|
510
|
+
gfx::IResourceCommandEncoder* get_gfx_resource_command_encoder();
|
511
|
+
void end_current_gfx_encoder();
|
512
|
+
|
513
|
+
Slang::ComPtr<gfx::ITransientResourceHeap> m_gfx_transient_resource_heap;
|
514
|
+
Slang::ComPtr<gfx::ICommandBuffer> m_gfx_command_buffer;
|
515
|
+
|
516
|
+
bool m_open{false};
|
517
|
+
bool m_encoder_open{false};
|
518
|
+
|
519
|
+
enum class EncoderType {
|
520
|
+
none,
|
521
|
+
resource,
|
522
|
+
compute,
|
523
|
+
render,
|
524
|
+
raytracing,
|
525
|
+
};
|
526
|
+
|
527
|
+
EncoderType m_active_gfx_encoder{EncoderType::none};
|
528
|
+
Slang::ComPtr<gfx::ICommandEncoder> m_gfx_command_encoder;
|
529
|
+
|
530
|
+
std::vector<ref<cuda::InteropBuffer>> m_cuda_interop_buffers;
|
531
|
+
|
532
|
+
// TODO remove this
|
533
|
+
friend class Device;
|
534
|
+
friend class ComputeCommandEncoder;
|
535
|
+
friend class RenderCommandEncoder;
|
536
|
+
friend class RayTracingCommandEncoder;
|
537
|
+
};
|
538
|
+
|
539
|
+
} // namespace sgl
|