Skip to content

Commit 11d527f

Browse files
committed
Limit line length in framework/core to 120
1 parent 89dd3af commit 11d527f

57 files changed

Lines changed: 1958 additions & 1206 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

framework/core/acceleration_structure.cpp

Lines changed: 81 additions & 73 deletions
Large diffs are not rendered by default.

framework/core/acceleration_structure.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2021-2025, Sascha Willems
1+
/* Copyright (c) 2021-2026, Sascha Willems
22
*
33
* SPDX-License-Identifier: Apache-2.0
44
*
@@ -40,8 +40,7 @@ class AccelerationStructure
4040
* @param device A valid Vulkan device
4141
* @param type The type of the acceleration structure (top- or bottom-level)
4242
*/
43-
AccelerationStructure(vkb::core::DeviceC &device,
44-
VkAccelerationStructureTypeKHR type);
43+
AccelerationStructure(vkb::core::DeviceC &device, VkAccelerationStructureTypeKHR type);
4544

4645
~AccelerationStructure();
4746

@@ -76,15 +75,16 @@ class AccelerationStructure
7675
uint64_t index_buffer_data_address = 0,
7776
uint64_t transform_buffer_data_address = 0);
7877

79-
void update_triangle_geometry(uint64_t triangleUUID, std::unique_ptr<vkb::core::BufferC> &vertex_buffer,
78+
void update_triangle_geometry(uint64_t triangleUUID,
79+
std::unique_ptr<vkb::core::BufferC> &vertex_buffer,
8080
std::unique_ptr<vkb::core::BufferC> &index_buffer,
8181
std::unique_ptr<vkb::core::BufferC> &transform_buffer,
8282
uint32_t triangle_count,
8383
uint32_t max_vertex,
8484
VkDeviceSize vertex_stride,
85-
uint32_t transform_offset = 0,
86-
VkFormat vertex_format = VK_FORMAT_R32G32B32_SFLOAT,
87-
VkGeometryFlagsKHR flags = VK_GEOMETRY_OPAQUE_BIT_KHR,
85+
uint32_t transform_offset = 0,
86+
VkFormat vertex_format = VK_FORMAT_R32G32B32_SFLOAT,
87+
VkGeometryFlagsKHR flags = VK_GEOMETRY_OPAQUE_BIT_KHR,
8888
uint64_t vertex_buffer_data_address = 0,
8989
uint64_t index_buffer_data_address = 0,
9090
uint64_t transform_buffer_data_address = 0);
@@ -102,10 +102,11 @@ class AccelerationStructure
102102
uint32_t transform_offset = 0,
103103
VkGeometryFlagsKHR flags = VK_GEOMETRY_OPAQUE_BIT_KHR);
104104

105-
void update_instance_geometry(uint64_t instance_UID, std::unique_ptr<vkb::core::BufferC> &instance_buffer,
106-
uint32_t instance_count,
107-
uint32_t transform_offset = 0,
108-
VkGeometryFlagsKHR flags = VK_GEOMETRY_OPAQUE_BIT_KHR);
105+
void update_instance_geometry(uint64_t instance_UID,
106+
std::unique_ptr<vkb::core::BufferC> &instance_buffer,
107+
uint32_t instance_count,
108+
uint32_t transform_offset = 0,
109+
VkGeometryFlagsKHR flags = VK_GEOMETRY_OPAQUE_BIT_KHR);
109110

110111
/**
111112
* @brief Builds the acceleration structure on the device (requires at least one geometry to be added)

framework/core/allocated.h

Lines changed: 50 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ void init(const DeviceType &device)
6161
allocator_info.device = static_cast<VkDevice>(device.get_handle());
6262
allocator_info.instance = static_cast<VkInstance>(device.get_gpu().get_instance().get_handle());
6363

64-
bool can_get_memory_requirements = device.get_gpu().is_extension_supported(VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME);
65-
bool has_dedicated_allocation = device.get_gpu().is_extension_supported(VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME);
66-
if (can_get_memory_requirements && has_dedicated_allocation && device.is_extension_enabled(VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME))
64+
bool can_get_memory_requirements =
65+
device.get_gpu().is_extension_supported(VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME);
66+
bool has_dedicated_allocation = device.get_gpu().is_extension_supported(VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME);
67+
if (can_get_memory_requirements && has_dedicated_allocation &&
68+
device.is_extension_enabled(VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME))
6769
{
6870
allocator_info.flags |= VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT;
6971
}
@@ -74,7 +76,8 @@ void init(const DeviceType &device)
7476
allocator_info.flags |= VMA_ALLOCATOR_CREATE_BUFFER_DEVICE_ADDRESS_BIT;
7577
}
7678

77-
if (device.get_gpu().is_extension_supported(VK_EXT_MEMORY_BUDGET_EXTENSION_NAME) && device.is_extension_enabled(VK_EXT_MEMORY_BUDGET_EXTENSION_NAME))
79+
if (device.get_gpu().is_extension_supported(VK_EXT_MEMORY_BUDGET_EXTENSION_NAME) &&
80+
device.is_extension_enabled(VK_EXT_MEMORY_BUDGET_EXTENSION_NAME))
7881
{
7982
allocator_info.flags |= VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT;
8083
}
@@ -85,7 +88,8 @@ void init(const DeviceType &device)
8588
allocator_info.flags |= VMA_ALLOCATOR_CREATE_EXT_MEMORY_PRIORITY_BIT;
8689
}
8790

88-
if (device.get_gpu().is_extension_supported(VK_KHR_BIND_MEMORY_2_EXTENSION_NAME) && device.is_extension_enabled(VK_KHR_BIND_MEMORY_2_EXTENSION_NAME))
91+
if (device.get_gpu().is_extension_supported(VK_KHR_BIND_MEMORY_2_EXTENSION_NAME) &&
92+
device.is_extension_enabled(VK_KHR_BIND_MEMORY_2_EXTENSION_NAME))
8993
{
9094
allocator_info.flags |= VMA_ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT;
9195
}
@@ -126,12 +130,16 @@ class Allocated : public vkb::core::VulkanResource<bindingType, HandleType>
126130
public:
127131
using ParentType = vkb::core::VulkanResource<bindingType, HandleType>;
128132

129-
using BufferType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vk::Buffer, VkBuffer>::type;
130-
using BufferCreateInfoType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vk::BufferCreateInfo, VkBufferCreateInfo>::type;
131-
using DeviceMemoryType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vk::DeviceMemory, VkDeviceMemory>::type;
132-
using DeviceSizeType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vk::DeviceSize, VkDeviceSize>::type;
133-
using ImageCreateInfoType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vk::ImageCreateInfo, VkImageCreateInfo>::type;
134-
using ImageType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vk::Image, VkImage>::type;
133+
using BufferType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vk::Buffer, VkBuffer>::type;
134+
using BufferCreateInfoType =
135+
typename std::conditional<bindingType == vkb::BindingType::Cpp, vk::BufferCreateInfo, VkBufferCreateInfo>::type;
136+
using DeviceMemoryType =
137+
typename std::conditional<bindingType == vkb::BindingType::Cpp, vk::DeviceMemory, VkDeviceMemory>::type;
138+
using DeviceSizeType =
139+
typename std::conditional<bindingType == vkb::BindingType::Cpp, vk::DeviceSize, VkDeviceSize>::type;
140+
using ImageCreateInfoType =
141+
typename std::conditional<bindingType == vkb::BindingType::Cpp, vk::ImageCreateInfo, VkImageCreateInfo>::type;
142+
using ImageType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vk::Image, VkImage>::type;
135143

136144
public:
137145
Allocated() = delete;
@@ -398,14 +406,13 @@ inline Allocated<bindingType, HandleType>::Allocated(Allocated &&other) noexcept
398406
mapped_data(std::exchange(other.mapped_data, {})),
399407
coherent(std::exchange(other.coherent, {})),
400408
persistent(std::exchange(other.persistent, {}))
401-
{
402-
}
409+
{}
403410

404411
template <vkb::BindingType bindingType, typename HandleType>
405412
template <typename... Args>
406-
inline Allocated<bindingType, HandleType>::Allocated(const VmaAllocationCreateInfo &allocation_create_info, Args &&...args) :
407-
ParentType{std::forward<Args>(args)...},
408-
allocation_create_info(allocation_create_info)
413+
inline Allocated<bindingType, HandleType>::Allocated(const VmaAllocationCreateInfo &allocation_create_info,
414+
Args &&...args) :
415+
ParentType{std::forward<Args>(args)...}, allocation_create_info(allocation_create_info)
409416
{}
410417

411418
template <vkb::BindingType bindingType, typename HandleType>
@@ -428,45 +435,46 @@ inline void Allocated<bindingType, HandleType>::clear()
428435
}
429436

430437
template <vkb::BindingType bindingType, typename HandleType>
431-
inline typename Allocated<bindingType, HandleType>::BufferType Allocated<bindingType, HandleType>::create_buffer(BufferCreateInfoType const &create_info, DeviceSizeType alignment)
438+
inline typename Allocated<bindingType, HandleType>::BufferType
439+
Allocated<bindingType, HandleType>::create_buffer(BufferCreateInfoType const &create_info, DeviceSizeType alignment)
432440
{
433441
if constexpr (bindingType == vkb::BindingType::Cpp)
434442
{
435443
return create_buffer_impl(create_info, alignment);
436444
}
437445
else
438446
{
439-
return static_cast<VkBuffer>(create_buffer_impl(reinterpret_cast<vk::BufferCreateInfo const &>(create_info), alignment));
447+
return static_cast<VkBuffer>(
448+
create_buffer_impl(reinterpret_cast<vk::BufferCreateInfo const &>(create_info), alignment));
440449
}
441450
}
442451

443452
template <vkb::BindingType bindingType, typename HandleType>
444-
inline vk::Buffer Allocated<bindingType, HandleType>::create_buffer_impl(vk::BufferCreateInfo const &create_info, DeviceSizeType alignment)
453+
inline vk::Buffer Allocated<bindingType, HandleType>::create_buffer_impl(vk::BufferCreateInfo const &create_info,
454+
DeviceSizeType alignment)
445455
{
446456
vk::Buffer buffer = VK_NULL_HANDLE;
447457
VmaAllocationInfo allocation_info{};
448458

449459
auto result = VK_SUCCESS;
450460
if (alignment == 0)
451461
{
452-
result = vmaCreateBuffer(
453-
get_memory_allocator(),
454-
reinterpret_cast<VkBufferCreateInfo const *>(&create_info),
455-
&allocation_create_info,
456-
reinterpret_cast<VkBuffer *>(&buffer),
457-
&allocation,
458-
&allocation_info);
462+
result = vmaCreateBuffer(get_memory_allocator(),
463+
reinterpret_cast<VkBufferCreateInfo const *>(&create_info),
464+
&allocation_create_info,
465+
reinterpret_cast<VkBuffer *>(&buffer),
466+
&allocation,
467+
&allocation_info);
459468
}
460469
else
461470
{
462-
result = vmaCreateBufferWithAlignment(
463-
get_memory_allocator(),
464-
reinterpret_cast<VkBufferCreateInfo const *>(&create_info),
465-
&allocation_create_info,
466-
alignment,
467-
reinterpret_cast<VkBuffer *>(&buffer),
468-
&allocation,
469-
&allocation_info);
471+
result = vmaCreateBufferWithAlignment(get_memory_allocator(),
472+
reinterpret_cast<VkBufferCreateInfo const *>(&create_info),
473+
&allocation_create_info,
474+
alignment,
475+
reinterpret_cast<VkBuffer *>(&buffer),
476+
&allocation,
477+
&allocation_info);
470478
}
471479

472480
if (result != VK_SUCCESS)
@@ -478,7 +486,8 @@ inline vk::Buffer Allocated<bindingType, HandleType>::create_buffer_impl(vk::Buf
478486
}
479487

480488
template <vkb::BindingType bindingType, typename HandleType>
481-
inline typename Allocated<bindingType, HandleType>::ImageType Allocated<bindingType, HandleType>::create_image(ImageCreateInfoType const &create_info)
489+
inline typename Allocated<bindingType, HandleType>::ImageType
490+
Allocated<bindingType, HandleType>::create_image(ImageCreateInfoType const &create_info)
482491
{
483492
if constexpr (bindingType == vkb::BindingType::Cpp)
484493
{
@@ -573,7 +582,8 @@ inline void Allocated<bindingType, HandleType>::flush(DeviceSizeType offset, Dev
573582
{
574583
if constexpr (bindingType == vkb::BindingType::Cpp)
575584
{
576-
vmaFlushAllocation(get_memory_allocator(), allocation, static_cast<VkDeviceSize>(offset), static_cast<VkDeviceSize>(size));
585+
vmaFlushAllocation(
586+
get_memory_allocator(), allocation, static_cast<VkDeviceSize>(offset), static_cast<VkDeviceSize>(size));
577587
}
578588
else
579589
{
@@ -589,7 +599,8 @@ inline const uint8_t *Allocated<bindingType, HandleType>::get_data() const
589599
}
590600

591601
template <vkb::BindingType bindingType, typename HandleType>
592-
inline typename Allocated<bindingType, HandleType>::DeviceMemoryType Allocated<bindingType, HandleType>::get_memory() const
602+
inline typename Allocated<bindingType, HandleType>::DeviceMemoryType
603+
Allocated<bindingType, HandleType>::get_memory() const
593604
{
594605
VmaAllocationInfo alloc_info;
595606
vmaGetAllocationInfo(get_memory_allocator(), allocation, &alloc_info);
@@ -604,7 +615,8 @@ inline typename Allocated<bindingType, HandleType>::DeviceMemoryType Allocated<b
604615
}
605616

606617
template <vkb::BindingType bindingType, typename HandleType>
607-
inline typename Allocated<bindingType, HandleType>::DeviceSizeType Allocated<bindingType, HandleType>::get_memory_offset() const
618+
inline typename Allocated<bindingType, HandleType>::DeviceSizeType
619+
Allocated<bindingType, HandleType>::get_memory_offset() const
608620
{
609621
VmaAllocationInfo alloc_info;
610622
vmaGetAllocationInfo(get_memory_allocator(), allocation, &alloc_info);

0 commit comments

Comments
 (0)