Move DataFormat to vk Format conversion to cast operator
This commit is contained in:
@@ -9,6 +9,11 @@
|
|||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
|
namespace vk
|
||||||
|
{
|
||||||
|
enum class Format;
|
||||||
|
}
|
||||||
|
|
||||||
namespace OpenVulkano
|
namespace OpenVulkano
|
||||||
{
|
{
|
||||||
class DataFormat
|
class DataFormat
|
||||||
@@ -361,6 +366,11 @@ namespace OpenVulkano
|
|||||||
return m_format;
|
return m_format;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] operator const vk::Format&() const
|
||||||
|
{
|
||||||
|
return reinterpret_cast<const vk::Format&>(m_format);
|
||||||
|
}
|
||||||
|
|
||||||
static DataFormat GetFromName(std::string_view name);
|
static DataFormat GetFromName(std::string_view name);
|
||||||
private:
|
private:
|
||||||
Format m_format;
|
Format m_format;
|
||||||
|
|||||||
@@ -35,11 +35,9 @@ namespace OpenVulkano::Vulkan
|
|||||||
{}, nullptr, nullptr, imgMemBarrier);
|
{}, nullptr, nullptr, imgMemBarrier);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Image::Init(const Device* device, const DataFormat format, 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, format, 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.usage = vk::ImageUsageFlagBits::eTransferDst | vk::ImageUsageFlagBits::eSampled;
|
||||||
imgCreateInfo.tiling = vk::ImageTiling::eOptimal;
|
imgCreateInfo.tiling = vk::ImageTiling::eOptimal;
|
||||||
|
|||||||
@@ -39,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::ImageCreateInfo& imageCreateInfo, vk::ImageViewCreateInfo imageViewCreateInfo, const vk::MemoryPropertyFlags& memoryPropertyFlags = vk::MemoryPropertyFlagBits::eDeviceLocal);
|
||||||
|
|
||||||
void Init(const Device* device, const DataFormat format, const vk::Extent3D& resolution);
|
void Init(const Device* device, const DataFormat& format, const vk::Extent3D& resolution);
|
||||||
|
|
||||||
void SetLayout(vk::CommandBuffer& cmdBuffer, const vk::ImageSubresourceRange& subResourceRange, vk::ImageLayout newLayout, vk::ImageLayout oldLayout = vk::ImageLayout::eUndefined) const;
|
void SetLayout(vk::CommandBuffer& cmdBuffer, const vk::ImageSubresourceRange& subResourceRange, vk::ImageLayout newLayout, vk::ImageLayout oldLayout = vk::ImageLayout::eUndefined) const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user