Add printable Enum

This commit is contained in:
Thraix
2023-05-01 18:23:22 +02:00
parent ca7286807a
commit ad69293faa
17 changed files with 122 additions and 76 deletions
@@ -4,19 +4,19 @@
namespace Copium
{
CommandBuffer::CommandBuffer(Type type)
CommandBuffer::CommandBuffer(CommandBufferType type)
: type{type}
{
switch (type)
{
case Type::SingleUse:
case CommandBufferType::SingleUse:
commandBuffers.resize(1);
break;
case Type::Dynamic:
case CommandBufferType::Dynamic:
commandBuffers.resize(SwapChain::MAX_FRAMES_IN_FLIGHT);
break;
default:
CP_ABORT("Unreachable switch case");
CP_ABORT("Unreachable switch case: %s", ToString(type).c_str());
}
VkCommandBufferAllocateInfo allocateInfo{};
@@ -42,13 +42,13 @@ namespace Copium
switch (type)
{
case Type::SingleUse:
case CommandBufferType::SingleUse:
beginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
break;
case Type::Dynamic:
case CommandBufferType::Dynamic:
break;
default:
CP_ABORT("Unreachable switch case");
CP_ABORT("Unreachable switch case: %s", ToString(type).c_str());
}
vkResetCommandBuffer(commandBuffers[Vulkan::GetSwapChain().GetFlightIndex()], 0);
@@ -1,25 +1,24 @@
#pragma once
#include "copium/util/Common.h"
#include "copium/util/Enum.h"
#include <vulkan/vulkan.hpp>
#define CP_COMMAND_BUFFER_TYPE_ENUMS SingleUse, Dynamic
CP_ENUM_CREATOR(Copium, CommandBufferType, CP_COMMAND_BUFFER_TYPE_ENUMS);
namespace Copium
{
class CommandBuffer
{
CP_DELETE_COPY_AND_MOVE_CTOR(CommandBuffer);
public:
enum class Type
{
SingleUse, Dynamic
};
private:
std::vector<VkCommandBuffer> commandBuffers;
const Type type;
const CommandBufferType type;
public:
CommandBuffer(Type type);
CommandBuffer(CommandBufferType type);
virtual ~CommandBuffer();
void Begin();
@@ -3,7 +3,7 @@
namespace Copium
{
CommandBufferScoped::CommandBufferScoped()
: CommandBuffer{Type::SingleUse}
: CommandBuffer{CommandBufferType::SingleUse}
{
CommandBuffer::Begin();
}