From 6d4909d3c87bc362acc9c702bd0b5af644b03104 Mon Sep 17 00:00:00 2001 From: Alejandro Saucedo Date: Tue, 11 Aug 2020 06:49:26 +0100 Subject: [PATCH] updated to have command buffer by default --- src/main.cpp | 41 ++++++++++------------------------------- 1 file changed, 10 insertions(+), 31 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index cf8e1324f..9fad4822c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -17,9 +17,7 @@ #include "VulkanTools.h" -#ifndef DEBUG -#define DEBUG (!NDEBUG) -#endif +#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_TRACE #define BUFFER_ELEMENTS 32 @@ -58,6 +56,10 @@ class VulkanCompute vk::DeviceSize aSize, void* aData = nullptr) const { + SPDLOG_LOGGER_DEBUG("Test Debug Logger"); + SPDLOG_LOGGER_DEBUG("Test Trace Logger"); + spdlog::debug("Creating buffer"); + vk::BufferCreateInfo bufferCreateInfo(vk::BufferCreateFlags(), aSize, aUsageFlags, @@ -90,7 +92,6 @@ class VulkanCompute memoryTypeIndex); *aMemory = this->mDevice.allocateMemory(memoryAllocateInfo); - this->mDevice.bindBufferMemory(*aBuffer, *aMemory, 0); if (aData != nullptr) { vk::DeviceSize offset = 0; @@ -99,6 +100,8 @@ class VulkanCompute memcpy(mapped, aData, aSize); this->mDevice.unmapMemory(*aMemory); } + + this->mDevice.bindBufferMemory(*aBuffer, *aMemory, 0); } /* @@ -263,6 +266,7 @@ class VulkanCompute } { + spdlog::info("Finding compute queue"); // Find compute queue std::vector allQueueFamilyProperties = this->mPhysicalDevice.getQueueFamilyProperties(); @@ -270,7 +274,7 @@ class VulkanCompute this->mComputeQueueFamilyIndex = -1; for (uint32_t i = 0; i < allQueueFamilyProperties.size(); i++) { vk::QueueFamilyProperties queueFamilyProperties = - allQueueFamilyProperties[this->mComputeQueueFamilyIndex]; + allQueueFamilyProperties[i]; if (queueFamilyProperties.queueFlags & vk::QueueFlagBits::eCompute) { @@ -306,6 +310,7 @@ class VulkanCompute // C API Vulkan // */ + spdlog::info("Allocating rest of components for backwards compat"); this->instance = static_cast(this->mInstance); this->physicalDevice = this->mPhysicalDevice; this->device = this->mDevice; @@ -324,32 +329,6 @@ class VulkanCompute const VkDeviceSize bufferSize = BUFFER_ELEMENTS * sizeof(uint32_t); - /* - - VkBuffer deviceBuffer, hostBuffer; - VkDeviceMemory deviceMemory, hostMemory; - - // Copy input data to VRAM using a staging buffer - { - createBuffer(VK_BUFFER_USAGE_TRANSFER_SRC_BIT | - VK_BUFFER_USAGE_TRANSFER_DST_BIT, - VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, - &hostBuffer, - &hostMemory, - bufferSize, - computeInput.data()); - - createBuffer(VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | - VK_BUFFER_USAGE_TRANSFER_SRC_BIT | - VK_BUFFER_USAGE_TRANSFER_DST_BIT, - VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, - &deviceBuffer, - &deviceMemory, - bufferSize); - } - - */ - vk::Buffer hostBuffer, deviceBuffer; vk::DeviceMemory hostMemory, deviceMemory;