Browse Source

Improve wrapper.

master
Draklaw 4 years ago
parent
commit
46b2698abb
  1. 7
      src/vk/Context.cpp
  2. 2
      src/vk/DescriptorSet.cpp
  3. 14
      src/vk/DescriptorSet.h
  4. 6
      src/vk/Swapchain.cpp
  5. 1
      src/vk/Wrapper.cpp
  6. 13
      src/vk/Wrapper.h

7
src/vk/Context.cpp

@ -803,6 +803,9 @@ VKAPI_ATTR VkBool32 VKAPI_CALL Context::log_debug_message(
const VkDebugUtilsMessengerCallbackDataEXT* data, const VkDebugUtilsMessengerCallbackDataEXT* data,
void* user_data void* user_data
) { ) {
if(data->messageIdNumber == 0) // Loader message
return VK_FALSE;
{ {
auto stream = [severity]() { auto stream = [severity]() {
switch(severity) { switch(severity) {
@ -834,7 +837,9 @@ VKAPI_ATTR VkBool32 VKAPI_CALL Context::log_debug_message(
} }
if(severity == VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT if(severity == VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT
&& data->messageIdNumber != 2094043421 // wrong swapchain extent && (
data->messageIdNumber != 2094043421 // wrong swapchain extent
)
) )
abort(); abort();

2
src/vk/DescriptorSet.cpp

@ -17,7 +17,7 @@ DescriptorSet::DescriptorSet(
VkDescriptorPool descriptor_pool, VkDescriptorPool descriptor_pool,
const VkDescriptorSetLayout& set_layout const VkDescriptorSetLayout& set_layout
) )
: Wrapper(context, 0) : Wrapper(context, DontOwnUnderlyingObject)
, m_descriptor_pool(descriptor_pool) , m_descriptor_pool(descriptor_pool)
{ {
assert(m_descriptor_pool != VK_NULL_HANDLE); assert(m_descriptor_pool != VK_NULL_HANDLE);

14
src/vk/DescriptorSet.h

@ -18,11 +18,11 @@ public:
VkDescriptorPool descriptor_pool, VkDescriptorPool descriptor_pool,
const VkDescriptorSetLayout& set_layout const VkDescriptorSetLayout& set_layout
); );
DescriptorSet(const DescriptorSet&) = delete; DescriptorSet(const DescriptorSet&) = default;
DescriptorSet(DescriptorSet&& other) noexcept; DescriptorSet(DescriptorSet&& other) noexcept;
~DescriptorSet() noexcept; ~DescriptorSet() noexcept;
DescriptorSet& operator=(const DescriptorSet&) = delete; DescriptorSet& operator=(const DescriptorSet&) = default;
DescriptorSet& operator=(DescriptorSet&& other) noexcept; DescriptorSet& operator=(DescriptorSet&& other) noexcept;
explicit inline operator bool() const noexcept { explicit inline operator bool() const noexcept {
@ -33,14 +33,6 @@ public:
return m_descriptor_set == VK_NULL_HANDLE; return m_descriptor_set == VK_NULL_HANDLE;
} }
inline const Context* context() const noexcept {
return m_context;
}
inline Context* context() noexcept {
return m_context;
}
inline const VkDescriptorPool descriptor_pool() const noexcept { inline const VkDescriptorPool descriptor_pool() const noexcept {
return m_descriptor_pool; return m_descriptor_pool;
} }
@ -59,7 +51,7 @@ public:
inline void swap(DescriptorSet& other) noexcept { inline void swap(DescriptorSet& other) noexcept {
using std::swap; using std::swap;
swap(m_context, other.m_context); Wrapper::swap(other);
swap(m_descriptor_pool, other.m_descriptor_pool); swap(m_descriptor_pool, other.m_descriptor_pool);
swap(m_descriptor_set, other.m_descriptor_set); swap(m_descriptor_set, other.m_descriptor_set);
} }

6
src/vk/Swapchain.cpp

@ -137,9 +137,9 @@ void Swapchain::begin_frame() {
} }
} }
logger.info() << "begin frame " << m_frame_index // logger.info() << "begin frame " << m_frame_index
<< ": image " << m_current_image_index // << ": image " << m_current_image_index
<< ", frame: " << m_frame_resources_index; // << ", frame: " << m_frame_resources_index;
auto& image_resources = m_image_resources[m_current_image_index]; auto& image_resources = m_image_resources[m_current_image_index];

1
src/vk/Wrapper.cpp

@ -35,6 +35,7 @@ Wrapper::~Wrapper() noexcept {
Wrapper& Wrapper::operator=(const Wrapper& other) noexcept { Wrapper& Wrapper::operator=(const Wrapper& other) noexcept {
if (&other != this) { if (&other != this) {
m_context = other.m_context; m_context = other.m_context;
m_flags = other.m_flags & ~OwnUnderlyingObject;
} }
return *this; return *this;
} }

13
src/vk/Wrapper.h

@ -12,7 +12,8 @@ namespace vk {
class Wrapper { class Wrapper {
public: public:
enum Flag { enum Flag {
OwnUnderlyingObject = 0x01, DontOwnUnderlyingObject = 0x00,
OwnUnderlyingObject = 0x01,
}; };
using Flags = unsigned; using Flags = unsigned;
@ -35,12 +36,20 @@ public:
} }
inline bool own_underlying_object() const noexcept { inline bool own_underlying_object() const noexcept {
return (m_flags & Flags(OwnUnderlyingObject)) != 0; return (m_flags & OwnUnderlyingObject) != 0;
}
inline void set_own_underlying_object(bool own_underlying_object) noexcept {
if(own_underlying_object)
m_flags |= OwnUnderlyingObject;
else
m_flags &= ~OwnUnderlyingObject;
} }
inline void swap(Wrapper& other) noexcept { inline void swap(Wrapper& other) noexcept {
using std::swap; using std::swap;
swap(m_context, other.m_context); swap(m_context, other.m_context);
swap(m_flags, other.m_flags);
} }
friend inline void swap(Wrapper& wrapper_0, Wrapper& wrapper_1) noexcept { friend inline void swap(Wrapper& wrapper_0, Wrapper& wrapper_1) noexcept {

Loading…
Cancel
Save