VulkanRenderer/Swapchain: Rename Buffer to Image

This commit is contained in:
Jérôme Leclercq 2020-09-04 15:58:07 +02:00
parent 55ac0ccdf6
commit 53e5aa924f
3 changed files with 19 additions and 19 deletions

View File

@ -20,7 +20,7 @@ namespace Nz
friend DeviceObject; friend DeviceObject;
public: public:
struct Buffer; struct Image;
Swapchain() = default; Swapchain() = default;
Swapchain(const Swapchain&) = delete; Swapchain(const Swapchain&) = delete;
@ -31,16 +31,16 @@ namespace Nz
inline bool Create(Device& device, const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr); inline bool Create(Device& device, const VkSwapchainCreateInfoKHR& createInfo, const VkAllocationCallbacks* allocator = nullptr);
inline const Buffer& GetBuffer(UInt32 index) const; inline const Image& GetImage(UInt32 index) const;
inline const std::vector<Buffer>& GetBuffers() const; inline const std::vector<Image>& GetImages() const;
inline UInt32 GetBufferCount() const; inline UInt32 GetImageCount() const;
inline bool IsSupported() const; inline bool IsSupported() const;
Swapchain& operator=(const Swapchain&) = delete; Swapchain& operator=(const Swapchain&) = delete;
Swapchain& operator=(Swapchain&&) = default; Swapchain& operator=(Swapchain&&) = default;
struct Buffer struct Image
{ {
VkImage image; VkImage image;
ImageView view; ImageView view;
@ -50,7 +50,7 @@ namespace Nz
static inline VkResult CreateHelper(Device& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle); static inline VkResult CreateHelper(Device& device, const VkSwapchainCreateInfoKHR* createInfo, const VkAllocationCallbacks* allocator, VkSwapchainKHR* handle);
static inline void DestroyHelper(Device& device, VkSwapchainKHR handle, const VkAllocationCallbacks* allocator); static inline void DestroyHelper(Device& device, VkSwapchainKHR handle, const VkAllocationCallbacks* allocator);
std::vector<Buffer> m_buffers; std::vector<Image> m_images;
}; };
} }
} }

View File

@ -50,16 +50,16 @@ namespace Nz
return false; return false;
} }
m_buffers.resize(imageCount); m_images.resize(imageCount);
for (UInt32 i = 0; i < imageCount; ++i) for (UInt32 i = 0; i < imageCount; ++i)
{ {
m_buffers[i].image = images[i]; m_images[i].image = images[i];
VkImageViewCreateInfo imageViewCreateInfo = { VkImageViewCreateInfo imageViewCreateInfo = {
VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // VkStructureType sType; VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // VkStructureType sType;
nullptr, // const void* pNext; nullptr, // const void* pNext;
0, // VkImageViewCreateFlags flags; 0, // VkImageViewCreateFlags flags;
m_buffers[i].image, // VkImage image; m_images[i].image, // VkImage image;
VK_IMAGE_VIEW_TYPE_2D, // VkImageViewType viewType; VK_IMAGE_VIEW_TYPE_2D, // VkImageViewType viewType;
createInfo.imageFormat, // VkFormat format; createInfo.imageFormat, // VkFormat format;
{ // VkComponentMapping components; { // VkComponentMapping components;
@ -77,7 +77,7 @@ namespace Nz
} }
}; };
if (!m_buffers[i].view.Create(*m_device, imageViewCreateInfo)) if (!m_images[i].view.Create(*m_device, imageViewCreateInfo))
{ {
NazaraError("Failed to create image view for image #" + String::Number(i)); NazaraError("Failed to create image view for image #" + String::Number(i));
return false; return false;
@ -87,24 +87,24 @@ namespace Nz
return true; return true;
} }
inline const Swapchain::Buffer& Swapchain::GetBuffer(UInt32 index) const inline const Swapchain::Image& Swapchain::GetImage(UInt32 index) const
{ {
return m_buffers[index]; return m_images[index];
} }
inline const std::vector<Swapchain::Buffer>& Swapchain::GetBuffers() const inline const std::vector<Swapchain::Image>& Swapchain::GetImages() const
{ {
return m_buffers; return m_images;
} }
inline UInt32 Swapchain::GetBufferCount() const inline UInt32 Swapchain::GetImageCount() const
{ {
return static_cast<UInt32>(m_buffers.size()); return static_cast<UInt32>(m_images.size());
} }
inline bool Swapchain::IsSupported() const inline bool Swapchain::IsSupported() const
{ {
if (!m_device->IsExtensionLoaded("VK_KHR_swapchain")) if (!m_device->IsExtensionLoaded(VK_KHR_SWAPCHAIN_EXTENSION_NAME))
return false; return false;
return true; return true;

View File

@ -368,12 +368,12 @@ namespace Nz
bool VkRenderWindow::SetupFrameBuffers(const Vector2ui& size) bool VkRenderWindow::SetupFrameBuffers(const Vector2ui& size)
{ {
UInt32 imageCount = m_swapchain.GetBufferCount(); UInt32 imageCount = m_swapchain.GetImageCount();
Nz::StackArray<Vk::Framebuffer> framebuffers = NazaraStackArray(Vk::Framebuffer, imageCount); Nz::StackArray<Vk::Framebuffer> framebuffers = NazaraStackArray(Vk::Framebuffer, imageCount);
for (UInt32 i = 0; i < imageCount; ++i) for (UInt32 i = 0; i < imageCount; ++i)
{ {
std::array<VkImageView, 2> attachments = { m_swapchain.GetBuffer(i).view, m_depthBufferView }; std::array<VkImageView, 2> attachments = { m_swapchain.GetImage(i).view, m_depthBufferView };
VkFramebufferCreateInfo frameBufferCreate = { VkFramebufferCreateInfo frameBufferCreate = {
VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,