Trying to add water

This commit is contained in:
Dynamitos
2024-08-13 22:44:04 +02:00
parent 97244e87c1
commit 252a241208
43 changed files with 1408 additions and 219 deletions
+16 -4
View File
@@ -3,9 +3,9 @@
#include "Enums.h"
#include "Graphics/Enums.h"
#include "Graphics/Initializer.h"
#include <fmt/format.h>
#include <math.h>
#include <vulkan/vulkan_core.h>
#include <fmt/format.h>
using namespace Seele;
using namespace Seele::Vulkan;
@@ -29,10 +29,13 @@ VkImageAspectFlags getAspectFromFormat(Gfx::SeFormat format) {
}
TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType, const TextureCreateInfo& createInfo, VkImage existingImage)
: CommandBoundResource(graphics, createInfo.name), image(existingImage), width(createInfo.width), height(createInfo.height), depth(createInfo.depth),
arrayCount(createInfo.elements), layerCount(createInfo.layers), mipLevels(createInfo.mipLevels), samples(createInfo.samples),
: CommandBoundResource(graphics, createInfo.name), image(existingImage), width(createInfo.width), height(createInfo.height),
depth(createInfo.depth), arrayCount(createInfo.elements), mipLevels(1), layerCount(createInfo.layers), samples(createInfo.samples),
format(createInfo.format), usage(createInfo.usage), layout(Gfx::SE_IMAGE_LAYOUT_UNDEFINED),
aspect(getAspectFromFormat(createInfo.format)), ownsImage(false), owner(createInfo.sourceData.owner) {
if (createInfo.useMip) {
mipLevels = static_cast<uint32_t>(std::floor(std::log2(std::max(width, height)))) + 1;
}
if (existingImage == VK_NULL_HANDLE) {
VkImageType type = VK_IMAGE_TYPE_MAX_ENUM;
VkImageCreateFlags flags = 0;
@@ -84,6 +87,14 @@ TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType, const
.usage = VMA_MEMORY_USAGE_AUTO,
};
VK_CHECK(vmaCreateImage(graphics->getAllocator(), &info, &allocInfo, &image, &allocation, nullptr));
VkDebugUtilsObjectNameInfoEXT nameInfo = {
.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT,
.pNext = nullptr,
.objectType = VK_OBJECT_TYPE_IMAGE,
.objectHandle = (uint64)image,
.pObjectName = name.c_str(),
};
vkSetDebugUtilsObjectNameEXT(graphics->getDevice(), &nameInfo);
ownsImage = true;
}
const DataSource& sourceData = createInfo.sourceData;
@@ -103,7 +114,8 @@ TextureHandle::TextureHandle(PGraphics graphics, VkImageViewType viewType, const
.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT | VMA_ALLOCATION_CREATE_MAPPED_BIT,
.usage = VMA_MEMORY_USAGE_AUTO,
};
OBufferAllocation stagingAlloc = new BufferAllocation(graphics, fmt::format("{}Staging", createInfo.name), stagingInfo, alloc, Gfx::QueueType::TRANSFER);
OBufferAllocation stagingAlloc =
new BufferAllocation(graphics, fmt::format("{}Staging", createInfo.name), stagingInfo, alloc, Gfx::QueueType::TRANSFER);
vmaMapMemory(graphics->getAllocator(), stagingAlloc->allocation, &data);
std::memcpy(data, sourceData.data, sourceData.size);
vmaUnmapMemory(graphics->getAllocator(), stagingAlloc->allocation);