diff --git a/src/vk/Buffer.cpp b/src/vk/Buffer.cpp index 43bfba6..41231ba 100644 --- a/src/vk/Buffer.cpp +++ b/src/vk/Buffer.cpp @@ -61,7 +61,7 @@ Buffer::Buffer(Buffer&& other) noexcept } Buffer::~Buffer() noexcept { - if(is_valid()) { + if(!is_null()) { logger.warning() << "Buffer deleted before being destroyed"; destroy(); } @@ -79,7 +79,7 @@ Buffer& Buffer::operator=(Buffer&& other) noexcept { VkMemoryRequirements Buffer::memory_requirements() const noexcept { - assert(is_valid()); + assert(!is_null()); assert(*m_context); VkMemoryRequirements memory_requirements; @@ -94,7 +94,7 @@ VkMemoryRequirements Buffer::memory_requirements() const noexcept { void Buffer::bind_memory(const MemoryBlock& memory_block, VkDeviceSize offset) { - assert(is_valid()); + assert(!is_null()); assert(*m_context); assert(memory_block); @@ -114,7 +114,7 @@ void Buffer::bind_memory(MemoryBlock&& memory_block) { } void Buffer::allocate_and_bind_memory(VkMemoryPropertyFlags memory_properties) { - assert(is_valid()); + assert(!is_null()); assert(*m_context); const auto memory_requirements = this->memory_requirements(); @@ -129,7 +129,7 @@ void Buffer::allocate_and_bind_memory(VkMemoryPropertyFlags memory_properties) { void Buffer::upload(size_t size, void* src_buffer, uint32_t dst_queue_family) { - assert(is_valid()); + assert(!is_null()); assert(*m_context); const bool use_staging_buffer = @@ -166,7 +166,7 @@ void Buffer::upload(size_t size, void* src_buffer, uint32_t dst_queue_family) { void Buffer::destroy() noexcept { - assert(is_valid()); + assert(!is_null()); assert(*m_context); if(m_memory) { diff --git a/src/vk/Buffer.h b/src/vk/Buffer.h index 59e8859..a495d49 100644 --- a/src/vk/Buffer.h +++ b/src/vk/Buffer.h @@ -37,11 +37,11 @@ public: Buffer& operator=(Buffer&& other) noexcept; inline explicit operator bool() const { - return is_valid(); + return !is_null(); } - inline bool is_valid() const { - return m_buffer != VK_NULL_HANDLE; + inline bool is_null() const { + return m_buffer == VK_NULL_HANDLE; } inline Context* context() noexcept { diff --git a/src/vk/Context.h b/src/vk/Context.h index 6dd2822..82b7c7e 100644 --- a/src/vk/Context.h +++ b/src/vk/Context.h @@ -67,11 +67,11 @@ public: Context& operator=(const Context&) = delete; explicit inline operator bool() const { - return is_valid(); + return !is_null(); } - inline bool is_valid() const { - return m_instance != nullptr; + inline bool is_null() const { + return m_instance == nullptr; } VkInstance instance(); diff --git a/src/vk/Fence.cpp b/src/vk/Fence.cpp index 03a81f1..2080292 100644 --- a/src/vk/Fence.cpp +++ b/src/vk/Fence.cpp @@ -36,7 +36,7 @@ Fence::Fence(Fence&& other) noexcept } Fence::~Fence() noexcept { - if(is_valid()) + if(!is_null()) destroy(); } @@ -51,7 +51,7 @@ Fence& Fence::operator=(Fence&& other) noexcept { VkResult Fence::get_status() const { assert(m_context); - assert(is_valid()); + assert(!is_null()); VkResult result = vkGetFenceStatus( m_context->device(), @@ -66,7 +66,7 @@ VkResult Fence::get_status() const { void Fence::reset() { assert(m_context); - assert(is_valid()); + assert(!is_null()); if(vkResetFences( m_context->device(), @@ -78,7 +78,7 @@ void Fence::reset() { void Fence::wait(uint64_t timeout) const { assert(m_context); - assert(is_valid()); + assert(!is_null()); wait_for_fences( m_context->device(), @@ -90,7 +90,7 @@ void Fence::wait(uint64_t timeout) const { void Fence::destroy() noexcept { - assert(is_valid()); + assert(!is_null()); assert(m_context); vkDestroyFence( diff --git a/src/vk/Fence.h b/src/vk/Fence.h index dd80aaf..80f05d4 100644 --- a/src/vk/Fence.h +++ b/src/vk/Fence.h @@ -23,11 +23,11 @@ public: Fence& operator=(Fence&& other) noexcept; explicit inline operator bool() const noexcept { - return is_valid(); + return !is_null(); } - inline bool is_valid() const noexcept { - return m_fence != VK_NULL_HANDLE; + inline bool is_null() const noexcept { + return m_fence == VK_NULL_HANDLE; } inline const Context* context() const noexcept { diff --git a/src/vk/Memory.cpp b/src/vk/Memory.cpp index d8f5303..31b6304 100644 --- a/src/vk/Memory.cpp +++ b/src/vk/Memory.cpp @@ -42,7 +42,7 @@ MemoryBlock::MemoryBlock(MemoryBlock&& other) noexcept } MemoryBlock::~MemoryBlock() noexcept { - if(is_valid()) { + if(!is_null()) { logger.warning() << "MemoryBlock deleted before being freed"; free(); } @@ -62,7 +62,7 @@ MemoryBlock& MemoryBlock::operator=(MemoryBlock&& other) noexcept { VkMemoryType MemoryBlock::memory_type_info(Context& context) const noexcept { - assert(is_valid()); + assert(!is_null()); assert(context); return context.memory_properties().memoryTypes[m_memory_type]; @@ -70,7 +70,7 @@ VkMemoryType MemoryBlock::memory_type_info(Context& context) const noexcept { void MemoryBlock::free() noexcept { - assert(is_valid()); + assert(!is_null()); m_memory_page->p_free(*this); @@ -87,7 +87,7 @@ void* MemoryBlock::map(Context& context) { } void* MemoryBlock::map(Context& context, VkDeviceSize offset, VkDeviceSize size) { - assert(is_valid()); + assert(!is_null()); assert(context); assert(offset + size <= m_size); @@ -106,7 +106,7 @@ void* MemoryBlock::map(Context& context, VkDeviceSize offset, VkDeviceSize size) } void MemoryBlock::unmap(Context& context) noexcept { - assert(is_valid()); + assert(!is_null()); vkUnmapMemory( context.device(), @@ -116,7 +116,7 @@ void MemoryBlock::unmap(Context& context) noexcept { void MemoryBlock::flush(Context& context) { - assert(is_valid()); + assert(!is_null()); VkMappedMemoryRange range { .sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, @@ -133,7 +133,7 @@ void MemoryBlock::flush(Context& context) { } void MemoryBlock::invalidate(Context& context) { - assert(is_valid()); + assert(!is_null()); VkMappedMemoryRange range { .sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, diff --git a/src/vk/Memory.h b/src/vk/Memory.h index e140c9c..e7f93d7 100644 --- a/src/vk/Memory.h +++ b/src/vk/Memory.h @@ -33,8 +33,8 @@ public: return m_size != 0; } - inline bool is_valid() const noexcept { - return m_size != 0; + inline bool is_null() const noexcept { + return m_size == 0; } inline VkDeviceSize size() const noexcept { @@ -92,11 +92,11 @@ public: MemoryPage& operator=(MemoryPage&&); explicit inline operator bool() const noexcept { - return is_valid(); + return !is_null(); } - inline bool is_valid() const noexcept { - return m_size != 0; + inline bool is_null() const noexcept { + return m_size == 0; } inline VkDeviceSize size() const noexcept { diff --git a/src/vk/RenderPass.cpp b/src/vk/RenderPass.cpp index e1cbe99..8c4d3ff 100644 --- a/src/vk/RenderPass.cpp +++ b/src/vk/RenderPass.cpp @@ -32,7 +32,7 @@ RenderPass::RenderPass(RenderPass&& other) noexcept } RenderPass::~RenderPass() noexcept { - if(is_valid()) + if(!is_null()) destroy(); } @@ -46,7 +46,7 @@ RenderPass& RenderPass::operator=(RenderPass&& other) noexcept { void RenderPass::destroy() noexcept { - assert(is_valid()); + assert(!is_null()); assert(m_context); vkDestroyRenderPass( diff --git a/src/vk/RenderPass.h b/src/vk/RenderPass.h index db1b9e6..3814262 100644 --- a/src/vk/RenderPass.h +++ b/src/vk/RenderPass.h @@ -21,11 +21,11 @@ public: RenderPass& operator=(RenderPass&& other) noexcept; explicit inline operator bool() const noexcept { - return is_valid(); + return !is_null(); } - inline bool is_valid() const noexcept { - return m_render_pass != VK_NULL_HANDLE; + inline bool is_null() const noexcept { + return m_render_pass == VK_NULL_HANDLE; } inline operator VkRenderPass() noexcept {