Browse Source

is_valid -> is_null.

master
Draklaw 4 years ago
parent
commit
b4cb6ebbbc
  1. 12
      src/vk/Buffer.cpp
  2. 6
      src/vk/Buffer.h
  3. 6
      src/vk/Context.h
  4. 10
      src/vk/Fence.cpp
  5. 6
      src/vk/Fence.h
  6. 14
      src/vk/Memory.cpp
  7. 10
      src/vk/Memory.h
  8. 4
      src/vk/RenderPass.cpp
  9. 6
      src/vk/RenderPass.h

12
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) {

6
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 {

6
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();

10
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(

6
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 {

14
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,

10
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 {

4
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(

6
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 {

Loading…
Cancel
Save