Refactor tracing
This commit is contained in:
@@ -13,7 +13,7 @@ namespace Copium
|
||||
createInfo.usage = usage;
|
||||
createInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||
|
||||
CP_VK_ASSERT(vkCreateBuffer(Vulkan::GetDevice(), &createInfo, nullptr, &handle), "Buffer : Failed to initialize buffer");
|
||||
CP_VK_ASSERT(vkCreateBuffer(Vulkan::GetDevice(), &createInfo, nullptr, &handle), "Failed to initialize buffer");
|
||||
|
||||
VkMemoryRequirements memoryRequirements;
|
||||
vkGetBufferMemoryRequirements(Vulkan::GetDevice(), handle, &memoryRequirements);
|
||||
@@ -23,7 +23,7 @@ namespace Copium
|
||||
allocateInfo.allocationSize = memoryRequirements.size;
|
||||
allocateInfo.memoryTypeIndex = Vulkan::GetDevice().FindMemoryType(memoryRequirements.memoryTypeBits, properties);
|
||||
|
||||
CP_VK_ASSERT(vkAllocateMemory(Vulkan::GetDevice(), &allocateInfo, nullptr, &memory), "Buffer : Failed to allocate buffer memory");
|
||||
CP_VK_ASSERT(vkAllocateMemory(Vulkan::GetDevice(), &allocateInfo, nullptr, &memory), "Failed to allocate buffer memory");
|
||||
|
||||
vkBindBufferMemory(Vulkan::GetDevice(), handle, memory, 0);
|
||||
}
|
||||
@@ -36,7 +36,7 @@ namespace Copium
|
||||
|
||||
void Buffer::Update(void* indexData, int index)
|
||||
{
|
||||
CP_ASSERT(index >= 0 && index < count, "Update : Index is outside of the buffer");
|
||||
CP_ASSERT(index >= 0 && index < count, "Index is outside of the buffer");
|
||||
|
||||
if (mappedData == nullptr)
|
||||
{
|
||||
@@ -72,14 +72,14 @@ namespace Copium
|
||||
|
||||
void* Buffer::Map()
|
||||
{
|
||||
CP_ASSERT(mappedData == nullptr, "Map : Mapping an already mapped buffer");
|
||||
CP_ASSERT(mappedData == nullptr, "Mapping an already mapped buffer");
|
||||
vkMapMemory(Vulkan::GetDevice(), memory, 0, size * count, 0, &mappedData);
|
||||
return mappedData;
|
||||
}
|
||||
|
||||
void Buffer::Unmap()
|
||||
{
|
||||
CP_ASSERT(mappedData != nullptr, "Unmap : Unmapping an already unmapped buffer");
|
||||
CP_ASSERT(mappedData != nullptr, "Unmapping an already unmapped buffer");
|
||||
|
||||
vkUnmapMemory(Vulkan::GetDevice(), memory);
|
||||
mappedData = nullptr;
|
||||
@@ -97,7 +97,7 @@ namespace Copium
|
||||
|
||||
VkDeviceSize Buffer::GetPosition(int index) const
|
||||
{
|
||||
CP_ASSERT(index >= 0 && index < count, "GetPosition : Index is outside of the buffer");
|
||||
CP_ASSERT(index >= 0 && index < count, "Index is outside of the buffer");
|
||||
return size * (VkDeviceSize)index;
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace Copium
|
||||
allocateInfo.commandBufferCount = 1;
|
||||
|
||||
VkCommandBuffer commandBuffer;
|
||||
CP_VK_ASSERT(vkAllocateCommandBuffers(Vulkan::GetDevice(), &allocateInfo, &commandBuffer), "CopyBuffer : Failed to initialize command buffer");
|
||||
CP_VK_ASSERT(vkAllocateCommandBuffers(Vulkan::GetDevice(), &allocateInfo, &commandBuffer), "Failed to initialize command buffer");
|
||||
|
||||
VkCommandBufferBeginInfo beginInfo{};
|
||||
beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Copium
|
||||
commandBuffers.resize(SwapChain::MAX_FRAMES_IN_FLIGHT);
|
||||
break;
|
||||
default:
|
||||
CP_ABORT("CommandBuffer : Unreachable switch case");
|
||||
CP_ABORT("Unreachable switch case");
|
||||
}
|
||||
|
||||
VkCommandBufferAllocateInfo allocateInfo{};
|
||||
@@ -24,7 +24,7 @@ namespace Copium
|
||||
allocateInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
|
||||
allocateInfo.commandPool = Vulkan::GetDevice().GetCommandPool();
|
||||
allocateInfo.commandBufferCount = commandBuffers.size();
|
||||
CP_VK_ASSERT(vkAllocateCommandBuffers(Vulkan::GetDevice(), &allocateInfo, commandBuffers.data()), "CommandBuffer : Failed to allocate CommandBuffer");
|
||||
CP_VK_ASSERT(vkAllocateCommandBuffers(Vulkan::GetDevice(), &allocateInfo, commandBuffers.data()), "Failed to allocate CommandBuffer");
|
||||
}
|
||||
|
||||
CommandBuffer::~CommandBuffer()
|
||||
@@ -48,11 +48,11 @@ namespace Copium
|
||||
case Type::Dynamic:
|
||||
break;
|
||||
default:
|
||||
CP_ABORT("Begin : Unreachable switch case");
|
||||
CP_ABORT("Unreachable switch case");
|
||||
}
|
||||
|
||||
vkResetCommandBuffer(commandBuffers[Vulkan::GetSwapChain().GetFlightIndex()], 0);
|
||||
CP_VK_ASSERT(vkBeginCommandBuffer(commandBuffers[Vulkan::GetSwapChain().GetFlightIndex()], &beginInfo), "Begin : Failed to begin command buffer");
|
||||
CP_VK_ASSERT(vkBeginCommandBuffer(commandBuffers[Vulkan::GetSwapChain().GetFlightIndex()], &beginInfo), "Failed to begin command buffer");
|
||||
}
|
||||
|
||||
void CommandBuffer::End()
|
||||
|
||||
@@ -168,7 +168,7 @@ namespace Copium
|
||||
renderPassCreateInfo.dependencyCount = dependencies.size();
|
||||
renderPassCreateInfo.pDependencies = dependencies.data();
|
||||
|
||||
CP_VK_ASSERT(vkCreateRenderPass(Vulkan::GetDevice(), &renderPassCreateInfo, nullptr, &renderPass), "InitializeRenderPass : Failed to initialze render pass");
|
||||
CP_VK_ASSERT(vkCreateRenderPass(Vulkan::GetDevice(), &renderPassCreateInfo, nullptr, &renderPass), "Failed to initialze render pass");
|
||||
}
|
||||
|
||||
void Framebuffer::InitializeFramebuffers()
|
||||
@@ -187,7 +187,7 @@ namespace Copium
|
||||
createInfo.height = height;
|
||||
createInfo.layers = 1;
|
||||
|
||||
CP_VK_ASSERT(vkCreateFramebuffer(Vulkan::GetDevice(), &createInfo, nullptr, &framebuffers[i]), "InitializeFramebuffers : Failed to initialize framebuffer");
|
||||
CP_VK_ASSERT(vkCreateFramebuffer(Vulkan::GetDevice(), &createInfo, nullptr, &framebuffers[i]), "Failed to initialize framebuffer");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ namespace Copium
|
||||
|
||||
void IndexBuffer::Draw(const CommandBuffer& commandBuffer, int indices)
|
||||
{
|
||||
CP_ASSERT(indices > 0 && indices <= indexCount, "Draw : amount of indices is out of range");
|
||||
CP_ASSERT(indices > 0 && indices <= indexCount, "amount of indices is out of range");
|
||||
vkCmdDrawIndexed(commandBuffer, indices, 1, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
@@ -21,49 +21,49 @@ namespace Copium
|
||||
|
||||
void UniformBuffer::Set(const std::string& str, const glm::mat3& data)
|
||||
{
|
||||
CP_ASSERT(binding.GetUniformType(str) == UniformType::Mat3, "Set : Uniform type missmatch = %s", str.c_str());
|
||||
CP_ASSERT(binding.GetUniformType(str) == UniformType::Mat3, "Uniform type missmatch = %s", str.c_str());
|
||||
uint32_t offset = binding.GetUniformOffset(str);
|
||||
memcpy(buffer.data() + offset, &data, sizeof(glm::mat3));
|
||||
}
|
||||
|
||||
void UniformBuffer::Set(const std::string& str, const glm::mat4& data)
|
||||
{
|
||||
CP_ASSERT(binding.GetUniformType(str) == UniformType::Mat4, "Set : Uniform type missmatch = %s", str.c_str());
|
||||
CP_ASSERT(binding.GetUniformType(str) == UniformType::Mat4, "Uniform type missmatch = %s", str.c_str());
|
||||
uint32_t offset = binding.GetUniformOffset(str);
|
||||
memcpy(buffer.data() + offset, &data, sizeof(glm::mat4));
|
||||
}
|
||||
|
||||
void UniformBuffer::Set(const std::string& str, const glm::vec2& data)
|
||||
{
|
||||
CP_ASSERT(binding.GetUniformType(str) == UniformType::Vec2, "Set : Uniform type missmatch = %s", str.c_str());
|
||||
CP_ASSERT(binding.GetUniformType(str) == UniformType::Vec2, "Uniform type missmatch = %s", str.c_str());
|
||||
uint32_t offset = binding.GetUniformOffset(str);
|
||||
memcpy(buffer.data() + offset, &data, sizeof(glm::vec2));
|
||||
}
|
||||
|
||||
void UniformBuffer::Set(const std::string& str, const glm::vec3& data)
|
||||
{
|
||||
CP_ASSERT(binding.GetUniformType(str) == UniformType::Vec3, "Set : Uniform type missmatch = %s", str.c_str());
|
||||
CP_ASSERT(binding.GetUniformType(str) == UniformType::Vec3, "Uniform type missmatch = %s", str.c_str());
|
||||
uint32_t offset = binding.GetUniformOffset(str);
|
||||
memcpy(buffer.data() + offset, &data, sizeof(glm::vec3));
|
||||
}
|
||||
|
||||
void UniformBuffer::Set(const std::string& str, const glm::vec4& data)
|
||||
{
|
||||
CP_ASSERT(binding.GetUniformType(str) == UniformType::Vec4, "Set : Uniform type missmatch = %s", str.c_str());
|
||||
CP_ASSERT(binding.GetUniformType(str) == UniformType::Vec4, "Uniform type missmatch = %s", str.c_str());
|
||||
uint32_t offset = binding.GetUniformOffset(str);
|
||||
memcpy(buffer.data() + offset, &data, sizeof(glm::vec4));
|
||||
}
|
||||
|
||||
void UniformBuffer::Set(const std::string& str, float data)
|
||||
{
|
||||
CP_ASSERT(binding.GetUniformType(str) == UniformType::Float, "Set : Uniform type missmatch = %s", str.c_str());
|
||||
CP_ASSERT(binding.GetUniformType(str) == UniformType::Float, "Uniform type missmatch = %s", str.c_str());
|
||||
uint32_t offset = binding.GetUniformOffset(str);
|
||||
memcpy(buffer.data() + offset, &data, sizeof(float));
|
||||
}
|
||||
|
||||
void UniformBuffer::Set(const std::string& str, int data)
|
||||
{
|
||||
CP_ASSERT(binding.GetUniformType(str) == UniformType::Int, "Set : Uniform type missmatch = %s", str.c_str());
|
||||
CP_ASSERT(binding.GetUniformType(str) == UniformType::Int, "Uniform type missmatch = %s", str.c_str());
|
||||
uint32_t offset = binding.GetUniformOffset(str);
|
||||
memcpy(buffer.data() + offset, &data, sizeof(int));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user