Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ find_package(Stb REQUIRED)

find_package(spdlog CONFIG REQUIRED)


find_path(CGLTF_INCLUDE_DIRS "cgltf.h")

add_compile_definitions(ENABLE_TELEMETRY)

add_compile_options(
$<$<COMPILE_LANGUAGE:CXX>:-Wall>
$<$<COMPILE_LANGUAGE:CXX>:-Wextra>
Expand All @@ -28,7 +29,4 @@ add_compile_options(
$<$<COMPILE_LANGUAGE:CXX>:-Wshadow>
)



add_subdirectory(src)

3 changes: 0 additions & 3 deletions src/backend/core/vk_backend_ctx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
#include <vk_mem_alloc.h>
#include <vulkan/vulkan_core.h>

DEFINE_TU_LOGGER("Backend.Ctx");
#define LOG_TU_LOGGER() ThisLogger()

bool VkBackendCtx::init(std::span<const char *const> platformExtensions,
bool enableValidation) {
shutdown();
Expand Down
3 changes: 0 additions & 3 deletions src/backend/core/vk_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
#include <vector>
#include <vulkan/vulkan_core.h>

DEFINE_TU_LOGGER("Backend.Device");
#define LOG_TU_LOGGER() ThisLogger()

namespace {

#ifdef __APPLE__
Expand Down
3 changes: 0 additions & 3 deletions src/backend/core/vk_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
#include <vulkan/vulkan.h>
#include <vulkan/vulkan_core.h>

DEFINE_TU_LOGGER("Backend.Instance");
#define LOG_TU_LOGGER() ThisLogger()

#ifndef NDEBUG
constexpr bool kEnableValidationLayers = true;
#else
Expand Down
1 change: 0 additions & 1 deletion src/backend/frame/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ target_link_libraries(quark_backend_frame
PUBLIC
Vulkan::Vulkan
quark::backend::core
quark::backend::profiling
)

add_library(quark::backend::frame ALIAS quark_backend_frame)
29 changes: 10 additions & 19 deletions src/backend/frame/vk_commands.cpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
#include "vk_commands.hpp"

#include "backend/core/vk_backend_ctx.hpp"
#include "engine/logging/log.hpp"

#include <cstdint>
#include <iostream>
#include <fmt/format.h>
#include <vulkan/vulkan_core.h>

bool VkCommands::init(VkBackendCtx &ctx, VkCommandPoolCreateFlags flags) {
if (ctx.device() == VK_NULL_HANDLE) {
std::cerr << "[Cmd] Device is null\n";
return false;
}

uint32_t family = ctx.graphicsQueueFamily();
if (family == UINT32_MAX) {
std::cerr << "[Cmd] ctx.graphicsQueueFamily invalid\n";
return false;
}

// Re-init
shutdown();

m_ctx = &ctx;
Expand All @@ -30,21 +19,21 @@ bool VkCommands::init(VkBackendCtx &ctx, VkCommandPoolCreateFlags flags) {

VkResult res = vkCreateCommandPool(ctx.device(), &poolInfo, nullptr, &m_pool);
if (res != VK_SUCCESS) {
std::cerr << "[Cmd] vkCreateCommandPool failed: " << res << "\n";
LOGE("vkCreateCommandPool failed: {}", fmt::underlying(res));
m_pool = VK_NULL_HANDLE;
m_ctx = VK_NULL_HANDLE;
return false;
}

std::cout << "[Cmd] Command pool created\n";
LOGI("Command pool created");
return true;
}

bool VkCommands::allocate(uint32_t count, VkCommandBufferLevel level) {
VkDevice device = m_ctx->device();

if (device == VK_NULL_HANDLE || m_pool == VK_NULL_HANDLE) {
std::cerr << "[Cmd] Device or command pool not read\n";
if (m_pool == VK_NULL_HANDLE) {
LOGE("Command pool not created");
return false;
}

Expand All @@ -60,12 +49,12 @@ bool VkCommands::allocate(uint32_t count, VkCommandBufferLevel level) {

VkResult res = vkAllocateCommandBuffers(device, &allocInfo, m_buffers.data());
if (res != VK_SUCCESS) {
std::cerr << "[Cmd] vkAllocateCommandBuffers failed: " << res << "\n";
LOGE("vkAllocatedCommandBuffers failed: {}", fmt::underlying(res));
m_buffers.clear();
return false;
}

std::cout << "[Cmd] Allocated " << m_buffers.size() << " command buffers\n";
LOGI("Allocated {} command buffers", m_buffers.size());
return true;
}

Expand All @@ -76,6 +65,7 @@ void VkCommands::free() noexcept {
static_cast<uint32_t>(m_buffers.size()),
m_buffers.data());
}

m_buffers.clear();
}

Expand All @@ -84,6 +74,7 @@ void VkCommands::shutdown() noexcept {

if (m_ctx != nullptr && m_ctx->device() != VK_NULL_HANDLE &&
m_pool != VK_NULL_HANDLE) {
LOGD("Destroying command pool");
vkDestroyCommandPool(m_ctx->device(), m_pool, nullptr);
}

Expand Down
4 changes: 3 additions & 1 deletion src/backend/frame/vk_commands.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ class VkCommands {

m_ctx = std::exchange(other.m_ctx, nullptr);
m_pool = std::exchange(other.m_pool, VK_NULL_HANDLE);
m_buffers = std::exchange(other.m_buffers, std::vector<VkCommandBuffer>{});
m_buffers = std::move(other.m_buffers);
other.m_buffers.clear();

return *this;
}

Expand Down
Loading