If it's host visible, is should be mapped.

This commit is contained in:
Anish Bhobe 2024-08-28 13:55:42 +02:00
parent 8fe9a953a4
commit e64096ce3c
2 changed files with 6 additions and 6 deletions

View File

@ -6,7 +6,6 @@
#include "buffer.h"
#include "device.h"
#include <ranges>
void
Buffer::Destroy(const Device *device)
@ -47,7 +46,7 @@ Buffer::Allocate(const Device *device, usize size, vk::BufferUsageFlags bufferUs
bool hostAccessible = Cast<bool>(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<u8 *>(allocationInfo.pMappedData);

View File

@ -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<usize>(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