Handle texture data format
This commit is contained in:
@@ -35,11 +35,11 @@ namespace OpenVulkano::Vulkan
|
||||
{}, nullptr, nullptr, imgMemBarrier);
|
||||
}
|
||||
|
||||
void Image::Init(const Device* device, const vk::Extent3D& resolution)
|
||||
void Image::Init(const Device* device, const DataFormat format, const vk::Extent3D& resolution)
|
||||
{
|
||||
this->device = device->device;
|
||||
|
||||
vk::ImageCreateInfo imgCreateInfo { {}, vk::ImageType::e2D, vk::Format::eB8G8R8A8Unorm, resolution, 1, 1 };
|
||||
vk::ImageCreateInfo imgCreateInfo { {}, vk::ImageType::e2D, reinterpret_cast<const vk::Format&>(format), resolution, 1, 1 };
|
||||
|
||||
imgCreateInfo.usage = vk::ImageUsageFlagBits::eTransferDst | vk::ImageUsageFlagBits::eSampled;
|
||||
imgCreateInfo.tiling = vk::ImageTiling::eOptimal;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Buffer.hpp"
|
||||
#include "Scene/DataFormat.hpp"
|
||||
#include "VulkanUtils.hpp"
|
||||
#include <vulkan/vulkan.hpp>
|
||||
|
||||
@@ -38,7 +39,7 @@ namespace OpenVulkano::Vulkan
|
||||
*/
|
||||
void Init(const Device* device, const vk::ImageCreateInfo& imageCreateInfo, vk::ImageViewCreateInfo imageViewCreateInfo, const vk::MemoryPropertyFlags& memoryPropertyFlags = vk::MemoryPropertyFlagBits::eDeviceLocal);
|
||||
|
||||
void Init(const Device* device, const vk::Extent3D& resolution);
|
||||
void Init(const Device* device, const DataFormat format, const vk::Extent3D& resolution);
|
||||
|
||||
void SetLayout(vk::CommandBuffer& cmdBuffer, vk::ImageSubresourceRange subResourceRange, vk::ImageLayout newLayout, vk::ImageLayout oldLayout = vk::ImageLayout::eUndefined) const;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OpenVulkano::Vulkan
|
||||
virtual void Init(ResourceManager* resManager, Scene::Texture* texture, vk::DescriptorSetLayout* descriptorSetLayout, const DescriptorSetLayoutBinding& binding)
|
||||
{
|
||||
m_texture = texture;
|
||||
Image::Init(resManager->GetContext()->device.get(), { texture->resolution.x, texture->resolution.y, texture->resolution.z });
|
||||
Image::Init(resManager->GetContext()->device.get(), texture->format, { texture->resolution.x, texture->resolution.y, texture->resolution.z });
|
||||
resManager->CopyDataToImage(m_texture->size, m_texture->textureBuffer, this);
|
||||
texture->updated = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user