From e64096ce3c87221367a204d80bb764910d40599d Mon Sep 17 00:00:00 2001 From: Anish Bhobe Date: Wed, 28 Aug 2024 13:55:42 +0200 Subject: [PATCH] If it's host visible, is should be mapped. --- aster/buffer.cpp | 3 +-- aster/buffer.h | 9 +++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/aster/buffer.cpp b/aster/buffer.cpp index cfc01b2..176f897 100644 --- a/aster/buffer.cpp +++ b/aster/buffer.cpp @@ -6,7 +6,6 @@ #include "buffer.h" #include "device.h" -#include void Buffer::Destroy(const Device *device) @@ -47,7 +46,7 @@ Buffer::Allocate(const Device *device, usize size, vk::BufferUsageFlags bufferUs bool hostAccessible = Cast(memoryPropertyFlags & vk::MemoryPropertyFlagBits::eHostVisible); m_Buffer = buffer; - m_Size_ = size | VALID_BUFFER_BIT | OWNED_BIT | (hostAccessible ? HOST_ACCESSIBLE_BIT : 0); + m_Size_ = size | VALID_BUFFER_BIT | OWNED_BIT; m_Allocation = allocation; m_Mapped = Cast(allocationInfo.pMappedData); diff --git a/aster/buffer.h b/aster/buffer.h index 2467df2..4bb7917 100644 --- a/aster/buffer.h +++ b/aster/buffer.h @@ -13,6 +13,8 @@ struct Buffer { vk::Buffer m_Buffer = nullptr; VmaAllocation m_Allocation = nullptr; + + // If the buffer is host visible, it should be (and stay) mapped. u8 *m_Mapped = nullptr; [[nodiscard]] usize GetSize() const; @@ -32,9 +34,8 @@ struct Buffer usize m_Size_ = 0; constexpr static usize VALID_BUFFER_BIT = Cast(1llu << 63); - constexpr static usize HOST_ACCESSIBLE_BIT = 1llu << 62; - constexpr static usize OWNED_BIT = 1llu << 61; - constexpr static usize SIZE_MASK = ~(VALID_BUFFER_BIT | HOST_ACCESSIBLE_BIT | OWNED_BIT); + constexpr static usize OWNED_BIT = 1llu << 62; + constexpr static usize SIZE_MASK = ~(VALID_BUFFER_BIT | OWNED_BIT); }; // Ensure that m_Size doesn't get used intrusively since it manages the state. @@ -76,7 +77,7 @@ Buffer::GetSize() const inline bool Buffer::IsHostVisible() const { - return m_Size_ & HOST_ACCESSIBLE_BIT; + return IsMapped(); } inline bool