Blender V5.3
vk_ray_tracing.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2026 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "vk_ray_tracing.hh"
10
11#include "vk_backend.hh"
12#include "vk_context.hh"
13#include "vk_index_buffer.hh"
14#include "vk_state_manager.hh"
15#include "vk_vertex_buffer.hh"
16
17#include "CLG_log.h"
18
19static CLG_LogRef LOG = {"blender.gpu"};
20
21namespace blender::gpu {
22
23/* -------------------------------------------------------------------- */
26
27VKTopLevelAS::VKTopLevelAS(const char *name) : TopLevelAS(name), max_primitive_count_(0)
28{
30 build_acceleration_structure_info_.node_data;
31
33 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_GEOMETRY_INFO_KHR,
34 nullptr,
35 VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR,
36 VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR |
37 VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_UPDATE_BIT_KHR,
38 VK_BUILD_ACCELERATION_STRUCTURE_MODE_BUILD_KHR,
39 VK_NULL_HANDLE,
40 VK_NULL_HANDLE,
41 0,
42 nullptr,
43 nullptr,
44 {0}};
45}
46
48{
50 if (vk_acceleration_structure_) {
51 discard_pool.discard_acceleration_structure(vk_acceleration_structure_);
52 vk_acceleration_structure_ = VK_NULL_HANDLE;
53 }
54 if (buffer_.is_allocated()) {
55 buffer_.free();
56 }
57}
58
60 const float4x4 &mat,
61 const uint8_t mask)
62{
63 BLI_assert_msg(vk_acceleration_structure_ == VK_NULL_HANDLE,
64 "Adding instances to an existing acceleration structure isn't supported. "
65 "Updating an existing instance of an acceleration structure is supported via the "
66 "update_instance methods.");
67
68 VKDevice &device = VKBackend::get().device;
69 const VkPhysicalDeviceAccelerationStructurePropertiesKHR &acceleration_structure_properties =
71 if (max_primitive_count_ == acceleration_structure_properties.maxInstanceCount) {
73 "Cannot add instance to top level acceleration structure as the number of "
74 "instances is larger than the GPU can handle.");
75 return {-1};
76 }
77
78 InstanceID instance_id = {max_primitive_count_};
79 /* The API order is row major. Transpose the matrix. */
80 instances_.append({
81 {{{mat.x.x, mat.y.x, mat.z.x, mat.w.x},
82 {mat.x.y, mat.y.y, mat.z.y, mat.w.y},
83 {mat.x.z, mat.y.z, mat.z.z, mat.w.z}}},
84 0, /* instanceCustomIndex */
85 mask, /* mask */
86 0, /* instanceShaderBindingTableRecordOffset */
87 0, /* flags */
88 0, /* device address */
89 });
90 blas_per_instance_.append(&blas_);
91 max_primitive_count_ += 1;
92 is_dirty_ = true;
93
94 return instance_id;
95}
96
98{
99 BLI_assert(instance_id.id < max_primitive_count_);
100 if (instance_id.id < 0 || instance_id.id >= max_primitive_count_) {
101 return;
102 }
103
104 VkAccelerationStructureInstanceKHR &instance = instances_[instance_id.id];
105 /* The API order is row major. Transpose the matrix. */
106 instance.transform.matrix[0][0] = mat.x.x;
107 instance.transform.matrix[0][1] = mat.y.x;
108 instance.transform.matrix[0][2] = mat.z.x;
109 instance.transform.matrix[0][3] = mat.w.x;
110 instance.transform.matrix[1][0] = mat.x.y;
111 instance.transform.matrix[1][1] = mat.y.y;
112 instance.transform.matrix[1][2] = mat.z.y;
113 instance.transform.matrix[1][3] = mat.w.y;
114 instance.transform.matrix[2][0] = mat.x.z;
115 instance.transform.matrix[2][1] = mat.y.z;
116 instance.transform.matrix[2][2] = mat.z.z;
117 instance.transform.matrix[2][3] = mat.w.z;
118 instance.mask = mask;
119
120 is_dirty_ = true;
121}
122
124{
125 VKDevice &device = VKBackend::get().device;
126 const VkPhysicalDeviceAccelerationStructurePropertiesKHR &acceleration_structure_properties =
128
129 const bool do_update = vk_acceleration_structure_ != VK_NULL_HANDLE;
130 if (do_update && !is_dirty_) {
131 return;
132 }
133
134 build_acceleration_structure_info_.src_buffers.clear_and_keep_capacity();
135 build_acceleration_structure_info_.src_acceleration_structures.clear_and_keep_capacity();
136
137 for (int64_t blas_index : instances_.index_range()) {
138 VkAccelerationStructureInstanceKHR &instance = instances_[blas_index];
139 const VKBottomLevelAS &blas = unwrap(*blas_per_instance_[blas_index]);
140 if (blas.vk_device_address() == 0) {
142 "Cannot add blas to top level acceleration structure as the blas "
143 "doesn't have a device address.");
144 return;
145 }
146 instance.accelerationStructureReference = blas.vk_device_address();
147 build_acceleration_structure_info_.src_acceleration_structures.add(blas.vk_buffer());
148 }
149
150 /* Create the instances buffer and upload the instance data. */
151 VKContext &context = *VKContext::get();
152 size_t instances_buffer_size = instances_.size() * sizeof(VkAccelerationStructureInstanceKHR);
153 if (!instances_buffer_.is_allocated()) {
154 instances_buffer_.create(
155 instances_buffer_size,
156 VK_BUFFER_USAGE_TRANSFER_DST_BIT |
157 VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR |
158 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
159 VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE,
160 0,
161 0.8f,
162 false,
163 name_get());
164 }
165
166 /* Update the instances buffer. */
167 if (instances_buffer_size != 0) {
168 if (instances_buffer_size < 65536) {
169 /* Only use udpate_render_graph for buffers < 64Kb. */
170 /* Make a copy of the instances data as the update render graph takes ownership and needs to
171 * be a guarded allocation. */
172 void *copy_of_data = MEM_new_uninitialized(instances_buffer_size, __func__);
173 memcpy(copy_of_data, instances_.data(), instances_buffer_size);
174 instances_buffer_.update_render_graph(context, copy_of_data);
175 }
176 else {
177 /* Create a staging buffer otherwise. */
178 VKStagingBuffer staging_buffer(instances_buffer_, VKStagingBuffer::Direction::HostToDevice);
179 VKBuffer &buffer = staging_buffer.host_buffer_get();
180 if (buffer.is_allocated()) {
181 staging_buffer.host_buffer_get().update_immediately(instances_.data());
182 staging_buffer.copy_to_device(context);
183 }
184 else {
185 buffer_.clear(context, 0u);
187 &LOG,
188 "Unable to upload data to TLAS buffer via a staging buffer as the staging buffer "
189 "could not be allocated.");
190 }
191 }
192 }
193
194 build_acceleration_structure_info_.src_buffers.add(instances_buffer_.resource());
195
197 build_acceleration_structure_info_.node_data;
198 VkAccelerationStructureKHR old_acceleration_structure = vk_acceleration_structure_;
199
200 if (!do_update) {
201 /* Initialize the geometry data with the instances. */
202 node_data.vk_acceleration_structure_build_range_infos.append({max_primitive_count_, 0, 0, 0});
203 VkAccelerationStructureGeometryKHR vk_acceleration_structure_geometry = {
204 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_KHR,
205 nullptr,
206 VK_GEOMETRY_TYPE_INSTANCES_KHR};
207 vk_acceleration_structure_geometry.geometry.instances = {
208 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR,
209 nullptr,
210 VK_FALSE,
211 {instances_buffer_.device_address_get()}};
212 vk_acceleration_structure_geometry.flags = VK_GEOMETRY_OPAQUE_BIT_KHR;
213 node_data.vk_acceleration_structure_geometries.append(vk_acceleration_structure_geometry);
214 }
215 else {
217 VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR;
218 node_data.vk_acceleration_structure_build_geometry_info.srcAccelerationStructure =
219 old_acceleration_structure;
220 }
221
222 VkAccelerationStructureBuildGeometryInfoKHR build_geometry_infos = {
223 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_GEOMETRY_INFO_KHR,
224 nullptr,
225 VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR,
226 VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR |
227 VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_UPDATE_BIT_KHR,
228 do_update ? VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR :
229 VK_BUILD_ACCELERATION_STRUCTURE_MODE_BUILD_KHR,
230 do_update ? old_acceleration_structure : VK_NULL_HANDLE,
231 VK_NULL_HANDLE,
234 nullptr,
235 {0}};
236
237 /* Determine acceleration structure + scratch space */
238 VkAccelerationStructureBuildSizesInfoKHR vk_acceleration_structure_build_sizes_info = {
239 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_SIZES_INFO_KHR};
240 device.functions.vkGetAccelerationStructureBuildSizesKHR(
241 device.vk_handle(),
242 VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR,
243 &build_geometry_infos,
244 &max_primitive_count_,
245 &vk_acceleration_structure_build_sizes_info);
246
247 /* Allocate acceleration structure + backing buffer */
248 if (buffer_.is_allocated()) {
249 buffer_.free();
250 }
251 buffer_.create(vk_acceleration_structure_build_sizes_info.accelerationStructureSize,
252 VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR |
253 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
254 VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE,
255 0,
256 1.0f,
257 false,
258 name_get());
259 BLI_assert(buffer_.is_allocated());
260
261 VkAccelerationStructureCreateInfoKHR vk_acceleration_structure_create_info = {
262 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_CREATE_INFO_KHR,
263 nullptr,
264 0,
265 buffer_.vk_handle(),
266 0,
267 vk_acceleration_structure_build_sizes_info.accelerationStructureSize,
268 VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR,
269 0};
270 device.functions.vkCreateAccelerationStructureKHR(device.vk_handle(),
271 &vk_acceleration_structure_create_info,
272 nullptr,
273 &vk_acceleration_structure_);
274 BLI_assert(vk_acceleration_structure_ != VK_NULL_HANDLE);
275 debug::object_label(vk_acceleration_structure_, name_get());
276
277 BLI_assert((do_update && vk_device_address_ != 0) || (!do_update && vk_device_address_ == 0));
278 vk_device_address_ = 0;
279 VkAccelerationStructureDeviceAddressInfoKHR vk_acceleration_structure_device_address_info = {
280 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_DEVICE_ADDRESS_INFO_KHR,
281 nullptr,
282 vk_acceleration_structure_,
283 };
284 vk_device_address_ = device.functions.vkGetAccelerationStructureDeviceAddressKHR(
285 device.vk_handle(), &vk_acceleration_structure_device_address_info);
286 BLI_assert(vk_device_address_ != 0);
287
288 /* Create scratch space for building */
289 /* TODO: Only create when size differs from previous allocation. */
290 VKBuffer device_scratch_space;
291 device_scratch_space.create(
292 do_update ? vk_acceleration_structure_build_sizes_info.updateScratchSize :
293 vk_acceleration_structure_build_sizes_info.buildScratchSize,
294 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
295 VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE,
296 VmaAllocationCreateFlags(0),
297 1.0,
298 false,
299 name_get(),
300 acceleration_structure_properties.minAccelerationStructureScratchOffsetAlignment);
301 BLI_assert(device_scratch_space.is_allocated());
302 BLI_assert(device_scratch_space.device_address_get());
303
304 build_geometry_infos.scratchData.deviceAddress = device_scratch_space.device_address_get();
305 node_data.vk_acceleration_structure_build_geometry_info.scratchData.deviceAddress =
306 device_scratch_space.device_address_get();
307 node_data.vk_acceleration_structure_build_geometry_info.dstAccelerationStructure =
308 vk_acceleration_structure_;
309 build_acceleration_structure_info_.dst_acceleration_structure = buffer_.resource();
310 build_acceleration_structure_info_.scratch_buffer = device_scratch_space.resource();
311
312 render_graph::VKRenderGraph &render_graph = context.render_graph();
313 render_graph.add_node(build_acceleration_structure_info_);
314 if (old_acceleration_structure) {
315 context.discard_pool.discard_acceleration_structure(old_acceleration_structure);
316 }
317 is_dirty_ = false;
318}
319
320void VKTopLevelAS::bind(int slot)
321{
322 VKContext &context = *VKContext::get();
323 context.state_manager_get().toplevelas_bind(*this, slot);
324}
325
327
328/* -------------------------------------------------------------------- */
331
333{
335 build_acceleration_structure_info_.node_data;
337 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_GEOMETRY_INFO_KHR,
338 nullptr,
339 VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR,
340 VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR,
341 VK_BUILD_ACCELERATION_STRUCTURE_MODE_BUILD_KHR,
342 VK_NULL_HANDLE,
343 VK_NULL_HANDLE,
344 0,
345 nullptr,
346 nullptr,
347 {0}};
348}
349
351{
353 if (vk_acceleration_structure_) {
354 discard_pool.discard_acceleration_structure(vk_acceleration_structure_);
355 vk_acceleration_structure_ = VK_NULL_HANDLE;
356 }
357 if (buffer_.is_allocated()) {
358 buffer_.free();
359 }
360}
361
362void VKBottomLevelAS::add_geometry(IndexBuf &index_buffer_, VertBuf &vertex_buffer_)
363{
364 BLI_assert_msg(vk_acceleration_structure_ == VK_NULL_HANDLE,
365 "Updating an existing acceleration structure isn't implemented.");
366
367 VKDevice &device = VKBackend::get().device;
368 const VkPhysicalDeviceAccelerationStructurePropertiesKHR &acceleration_structure_properties =
370 if (build_acceleration_structure_info_.node_data.vk_acceleration_structure_geometries.size() >=
371 acceleration_structure_properties.maxGeometryCount)
372 {
374 "Cannot add geometry to bottom level acceleration structure as the number of "
375 "geometries is larger than the GPU can handle.");
376 return;
377 }
378
379 VKVertexBuffer &vertex_buffer = unwrap(vertex_buffer_);
380 VKIndexBuffer &index_buffer = unwrap(index_buffer_);
381 index_buffer.ensure_updated();
382 vertex_buffer.ensure_updated();
383
384 if (!vertex_buffer.has_device_address()) {
386 "Cannot add geometry to bottom level acceleration structure as the vertex buffer "
387 "doesn't have a device address. This could be an out of memory issue.");
388 return;
389 }
390 if (!index_buffer.has_device_address()) {
392 "Cannot add geometry to bottom level acceleration structure as the index buffer "
393 "doesn't have a device address. This could be an out of memory issue.");
394 return;
395 }
396 const VkFormat vertex_format = vertex_buffer.to_vk_format();
397 if (vertex_format == VK_FORMAT_UNDEFINED) {
399 "Cannot add geometry to bottom level acceleration structure as the format of the "
400 "vertex buffer cannot be determined.");
401 return;
402 }
403
404 build_acceleration_structure_info_.node_data.vk_acceleration_structure_geometries.append(
405 {VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_KHR,
406 nullptr,
407 VK_GEOMETRY_TYPE_TRIANGLES_KHR,
408 {
409 {VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR,
410 nullptr,
411 vertex_format,
412 {vertex_buffer.device_address_get()},
413 vertex_buffer.format.stride,
414 vertex_buffer.vertex_len - 1,
415 index_buffer.vk_index_type(),
416 {index_buffer.device_address_get()},
417 {0}},
418 },
419 VK_GEOMETRY_OPAQUE_BIT_KHR});
420 const uint32_t num_primitives = uint32_t(index_buffer.index_len_get() / 3);
421 build_acceleration_structure_info_.node_data.vk_acceleration_structure_build_range_infos.append(
422 {num_primitives,
423 index_buffer.index_start_get() * (index_buffer.is_32bit() ? 4u : 2u),
424 index_buffer.index_base_get(),
425 0});
426 max_primitive_count_per_geometry_.append(num_primitives);
427
428 build_acceleration_structure_info_.src_buffers.add(index_buffer.resource());
429 build_acceleration_structure_info_.src_buffers.add(vertex_buffer.resource());
430}
431
433{
434 BLI_assert(vk_acceleration_structure_ == VK_NULL_HANDLE);
435 VKDevice &device = VKBackend::get().device;
436 const VkPhysicalDeviceAccelerationStructurePropertiesKHR &acceleration_structure_properties =
438
440 build_acceleration_structure_info_.node_data;
441
442 VkAccelerationStructureBuildGeometryInfoKHR build_geometry_infos = {
443 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_GEOMETRY_INFO_KHR,
444 nullptr,
445 VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR,
446 VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR,
447 VK_BUILD_ACCELERATION_STRUCTURE_MODE_BUILD_KHR,
448 VK_NULL_HANDLE,
449 VK_NULL_HANDLE,
452 nullptr,
453 {0}};
454
455 /* Determine acceleration structure + scratch space */
456 VkAccelerationStructureBuildSizesInfoKHR vk_acceleration_structure_build_sizes_info = {
457 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_SIZES_INFO_KHR};
458 device.functions.vkGetAccelerationStructureBuildSizesKHR(
459 device.vk_handle(),
460 VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR,
461 &build_geometry_infos,
462 max_primitive_count_per_geometry_.data(),
463 &vk_acceleration_structure_build_sizes_info);
464
465 /* Allocate acceleration structure + backing buffer */
466 buffer_.create(vk_acceleration_structure_build_sizes_info.accelerationStructureSize,
467 VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR |
468 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
469 VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE,
470 0,
471 1.0f,
472 false,
473 name_get());
474 BLI_assert(buffer_.is_allocated());
475
476 VkAccelerationStructureCreateInfoKHR vk_acceleration_structure_create_info = {
477 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_CREATE_INFO_KHR,
478 nullptr,
479 0,
480 buffer_.vk_handle(),
481 0,
482 vk_acceleration_structure_build_sizes_info.accelerationStructureSize,
483 VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR,
484 0};
485 device.functions.vkCreateAccelerationStructureKHR(device.vk_handle(),
486 &vk_acceleration_structure_create_info,
487 nullptr,
488 &vk_acceleration_structure_);
489 BLI_assert(vk_acceleration_structure_ != VK_NULL_HANDLE);
490 debug::object_label(vk_acceleration_structure_, name_get());
491
492 BLI_assert(vk_device_address_ == 0);
493 VkAccelerationStructureDeviceAddressInfoKHR vk_acceleration_structure_device_address_info = {
494 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_DEVICE_ADDRESS_INFO_KHR,
495 nullptr,
496 vk_acceleration_structure_,
497 };
498 vk_device_address_ = device.functions.vkGetAccelerationStructureDeviceAddressKHR(
499 device.vk_handle(), &vk_acceleration_structure_device_address_info);
500 BLI_assert(vk_device_address_ != 0);
501
502 /* Create scratch space for building */
503 VKBuffer device_scratch_space;
504 device_scratch_space.create(
505 vk_acceleration_structure_build_sizes_info.buildScratchSize,
506 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
507 VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE,
508 0,
509 1.0,
510 false,
511 name_get(),
512 acceleration_structure_properties.minAccelerationStructureScratchOffsetAlignment);
513 BLI_assert(device_scratch_space.is_allocated());
514 BLI_assert(device_scratch_space.device_address_get());
515
516 build_geometry_infos.scratchData.deviceAddress = device_scratch_space.device_address_get();
517 node_data.vk_acceleration_structure_build_geometry_info.scratchData.deviceAddress =
518 device_scratch_space.device_address_get();
519 node_data.vk_acceleration_structure_build_geometry_info.dstAccelerationStructure =
520 vk_acceleration_structure_;
521 build_acceleration_structure_info_.dst_acceleration_structure = buffer_.resource();
522 build_acceleration_structure_info_.scratch_buffer = device_scratch_space.resource();
523
524 VKContext &context = *VKContext::get();
525 render_graph::VKRenderGraph &render_graph = context.render_graph();
526 render_graph.add_node(build_acceleration_structure_info_);
527}
528
530
531} // namespace blender::gpu
#define CLOG_ERROR(clg_ref,...)
Definition CLG_log.h:188
#define BLI_assert_msg(a, msg)
const char * name_get() const
BottomLevelAS(const char *name)
uint32_t index_start_get() const
uint32_t index_base_get() const
uint32_t index_len_get() const
const char * name_get() const
TopLevelAS(const char *name)
static VKBackend & get()
const VKResourceWithHandle< VkBuffer > & vk_buffer() const
void add_geometry(IndexBuf &index_buffer, VertBuf &vertex_buffer) override
VkDeviceAddress vk_device_address() const
void update_immediately(const void *data) const
Definition vk_buffer.cc:144
bool is_allocated() const
Definition vk_buffer.hh:169
VkDeviceAddress device_address_get() const
Definition vk_buffer.hh:120
bool create(size_t size, VkBufferUsageFlags buffer_usage, VmaMemoryUsage vma_memory_usage, VmaAllocationCreateFlags vma_allocation_flags, float priority, bool export_memory=false, const char *debug_name="VKBuffer", size_t alignment=0)
Definition vk_buffer.cc:29
const VKResourceWithHandle< VkBuffer > & resource() const
Definition vk_buffer.hh:104
static VKContext * get()
VkDevice vk_handle() const
Definition vk_device.hh:338
VolkDeviceTable functions
Definition vk_device.hh:280
const VkPhysicalDeviceAccelerationStructurePropertiesKHR & physical_device_acceleration_structure_properties_get()
Definition vk_device.hh:317
static VKDiscardPool & discard_pool_get()
void discard_acceleration_structure(VkAccelerationStructureKHR vk_acceleration_structure)
VkIndexType vk_index_type() const
VkDeviceAddress device_address_get() const
const VKResourceWithHandle< VkBuffer > & resource() const
void copy_to_device(VKContext &context)
VKTopLevelAS(const char *name)
void bind(int slot) override
void update_instance(InstanceID instance_id, const float4x4 &mat, uint8_t mask) override
InstanceID add_instance(const BottomLevelAS &blas, const float4x4 &mat, uint8_t mask) override
VkDeviceAddress device_address_get() const
const VKResourceWithHandle< VkBuffer > & resource() const
#define instance_id
#define LOG(level)
Definition log.h:97
void object_label(GLenum type, GLuint object, const char *name)
Definition gl_debug.cc:331
BLI_INLINE MTLTexture * unwrap(Texture *tex)
void * MEM_new_uninitialized(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
__int64 int64_t
Definition BKE_text.h:90
MatBase< float, 4, 4 > float4x4
unsigned int uint32_t
Definition BKE_text.h:81
unsigned char uint8_t
Definition BKE_text.h:79
VkAccelerationStructureBuildGeometryInfoKHR vk_acceleration_structure_build_geometry_info
Vector< VkAccelerationStructureBuildRangeInfoKHR > vk_acceleration_structure_build_range_infos
int size() const
Definition vector.hh:130