Fixing some potential crashes

This commit is contained in:
Dynamitos
2025-04-08 22:01:42 +02:00
parent 875ae450e7
commit e355f3e703
7 changed files with 22 additions and 97 deletions
+4
View File
@@ -11,6 +11,8 @@ using namespace Seele::Vulkan;
BufferAllocation::BufferAllocation(PGraphics graphics, const std::string& name, VkBufferCreateInfo bufferInfo,
VmaAllocationCreateInfo allocInfo, Gfx::QueueType owner, uint64 alignment)
: CommandBoundResource(graphics, name), size(bufferInfo.size), owner(owner) {
if (bufferInfo.size == 0)
return;
VK_CHECK(vmaCreateBufferWithAlignment(graphics->getAllocator(), &bufferInfo, &allocInfo, alignment, &buffer, &allocation, &info));
vmaGetAllocationMemoryProperties(graphics->getAllocator(), allocation, &properties);
assert(!name.empty());
@@ -437,6 +439,8 @@ void* ShaderBuffer::map() { return Vulkan::Buffer::map(); }
void ShaderBuffer::unmap() { Vulkan::Buffer::unmap(); }
void ShaderBuffer::clear() {
if (getAlloc() == nullptr)
return;
PCommand command = graphics->getQueueCommands(getAlloc()->owner)->getCommands();
command->bindResource(PBufferAllocation(getAlloc()));
vkCmdFillBuffer(command->getHandle(), Vulkan::Buffer::getHandle(), 0, VK_WHOLE_SIZE, 0);
+1 -1
View File
@@ -447,7 +447,7 @@ Gfx::OTopLevelAS Graphics::createTopLevelAccelerationStructure(const Gfx::TopLev
}
void Graphics::buildBottomLevelAccelerationStructures(Array<Gfx::PBottomLevelAS> data) {
if (!supportRayTracing())
if (!supportRayTracing() || data.empty())
return;
Gfx::PShaderBuffer verticesBuffer = StaticMeshVertexData::getInstance()->getPositionBuffer();
Gfx::PIndexBuffer indexBuffer = StaticMeshVertexData::getInstance()->getIndexBuffer();