Skip to content

Commit de659a3

Browse files
Make getBufferSize() public API
1 parent f42cb37 commit de659a3

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

lvk/vulkan/VulkanClasses.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -706,11 +706,6 @@ VkSurfaceFormatKHR chooseSwapSurfaceFormat(const std::vector<VkSurfaceFormatKHR>
706706
return formats[0];
707707
}
708708

709-
VkDeviceSize bufferSize(lvk::VulkanContext& ctx, const lvk::Holder<lvk::BufferHandle>& handle) {
710-
lvk::VulkanBuffer* buffer = ctx.buffersPool_.get(handle);
711-
return buffer ? buffer->bufferSize_ : 0;
712-
}
713-
714709
} // namespace
715710

716711
namespace lvk {
@@ -2865,7 +2860,7 @@ void lvk::CommandBuffer::cmdUpdateTLAS(AccelStructHandle handle, BufferHandle in
28652860
&as->buildRangeInfo.primitiveCount,
28662861
&accelerationStructureBuildSizesInfo);
28672862

2868-
if (!as->scratchBuffer.valid() || bufferSize(*ctx_, as->scratchBuffer) < accelerationStructureBuildSizesInfo.buildScratchSize) {
2863+
if (!as->scratchBuffer.valid() || getBufferSize(ctx_, as->scratchBuffer) < accelerationStructureBuildSizesInfo.buildScratchSize) {
28692864
LLOGD("Recreating scratch buffer for TLAS update");
28702865
as->scratchBuffer = ctx_->createBuffer(
28712866
lvk::BufferDesc{

lvk/vulkan/VulkanUtils.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ lvk::Format lvk::vkFormatToFormat(VkFormat format) {
248248
case VK_FORMAT_D32_SFLOAT_S8_UINT:
249249
return Format_Z_F32_S_UI8;
250250
case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM:
251-
return Format_YUV_NV12;
251+
return Format_YUV_NV12;
252252
case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM:
253253
return Format_YUV_420p;
254254
default:;
@@ -305,8 +305,7 @@ uint32_t lvk::findQueueFamilyIndex(VkPhysicalDevice physDev, VkQueueFlags flags)
305305
std::vector<VkQueueFamilyProperties> props(queueFamilyCount);
306306
vkGetPhysicalDeviceQueueFamilyProperties(physDev, &queueFamilyCount, props.data());
307307

308-
auto findDedicatedQueueFamilyIndex = [&props](VkQueueFlags require,
309-
VkQueueFlags avoid) -> uint32_t {
308+
auto findDedicatedQueueFamilyIndex = [&props](VkQueueFlags require, VkQueueFlags avoid) -> uint32_t {
310309
for (uint32_t i = 0; i != props.size(); i++) {
311310
const bool isSuitable = (props[i].queueFlags & require) == require;
312311
const bool isDedicated = (props[i].queueFlags & avoid) == 0;
@@ -334,10 +333,7 @@ uint32_t lvk::findQueueFamilyIndex(VkPhysicalDevice physDev, VkQueueFlags flags)
334333
return findDedicatedQueueFamilyIndex(flags, 0);
335334
}
336335

337-
VmaAllocator lvk::createVmaAllocator(VkPhysicalDevice physDev,
338-
VkDevice device,
339-
VkInstance instance,
340-
uint32_t apiVersion) {
336+
VmaAllocator lvk::createVmaAllocator(VkPhysicalDevice physDev, VkDevice device, VkInstance instance, uint32_t apiVersion) {
341337
const VmaVulkanFunctions funcs = {
342338
.vkGetInstanceProcAddr = vkGetInstanceProcAddr,
343339
.vkGetDeviceProcAddr = vkGetDeviceProcAddr,
@@ -543,7 +539,7 @@ VkSamplerAddressMode samplerWrapModeToVkSamplerAddressMode(lvk::SamplerWrap mode
543539
return VK_SAMPLER_ADDRESS_MODE_REPEAT;
544540
}
545541

546-
} // namespace
542+
} // namespace
547543

548544
VkSamplerCreateInfo lvk::samplerStateDescToVkSamplerCreateInfo(const lvk::SamplerStateDesc& desc, const VkPhysicalDeviceLimits& limits) {
549545
LVK_ASSERT_MSG(desc.mipLodMax >= desc.mipLodMin,
@@ -1131,3 +1127,8 @@ VkPipelineLayout lvk::getVkPipelineLayout(const IContext* ctx, RayTracingPipelin
11311127

11321128
return static_cast<const VulkanContext*>(ctx)->rayTracingPipelinesPool_.get(pipeline)->pipelineLayout_;
11331129
}
1130+
1131+
VkDeviceSize lvk::getBufferSize(const IContext* ctx, lvk::BufferHandle handle) {
1132+
const lvk::VulkanBuffer* buffer = static_cast<const VulkanContext*>(ctx)->buffersPool_.get(handle);
1133+
return buffer ? buffer->bufferSize_ : 0;
1134+
}

lvk/vulkan/VulkanUtils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,5 @@ VkBuffer getVkBuffer(const IContext* ctx, AccelStructHandle accelStruct);
137137
VkPipeline getVkPipeline(const IContext* ctx, RayTracingPipelineHandle pipeline);
138138
VkPipelineLayout getVkPipelineLayout(const IContext* ctx, RayTracingPipelineHandle pipeline);
139139

140+
VkDeviceSize getBufferSize(const IContext* ctx, lvk::BufferHandle handle);
140141
} // namespace lvk

0 commit comments

Comments
 (0)