diff --git a/include/core/shadermodule.hpp b/include/core/shadermodule.hpp index 9971f56..0cce6df 100644 --- a/include/core/shadermodule.hpp +++ b/include/core/shadermodule.hpp @@ -3,9 +3,9 @@ #include "device.hpp" -#include #include +#include #include #include #include diff --git a/src/core/commandbuffer.cpp b/src/core/commandbuffer.cpp index 6a03d99..3b66840 100644 --- a/src/core/commandbuffer.cpp +++ b/src/core/commandbuffer.cpp @@ -16,7 +16,7 @@ CommandBuffer::CommandBuffer(const Device& device, const CommandPool& pool) { }; VkCommandBuffer commandBufferHandle{}; auto res = vkAllocateCommandBuffers(device.handle(), &desc, &commandBufferHandle); - if (res != VK_SUCCESS || commandBuffer == VK_NULL_HANDLE) + if (res != VK_SUCCESS || commandBufferHandle == VK_NULL_HANDLE) throw ls::vulkan_error(res, "Unable to allocate command buffer"); // store command buffer in shared ptr diff --git a/src/core/fence.cpp b/src/core/fence.cpp index 7fd9088..a0ddd75 100644 --- a/src/core/fence.cpp +++ b/src/core/fence.cpp @@ -9,7 +9,7 @@ Fence::Fence(const Device& device) { // create fence const VkFenceCreateInfo desc = { - .sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO + .sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO }; VkFence fenceHandle{}; auto res = vkCreateFence(device.handle(), &desc, nullptr, &fenceHandle); diff --git a/src/main.cpp b/src/main.cpp index d55ef02..5613bb5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,21 +1,43 @@ +#include "core/commandbuffer.hpp" +#include "core/commandpool.hpp" +#include "core/fence.hpp" #include "core/pipeline.hpp" #include "core/shadermodule.hpp" #include "device.hpp" #include "instance.hpp" +#include #include -#include + +using namespace Vulkan; int main() { - const Vulkan::Instance instance; - const Vulkan::Device device(instance); + // initialize Vulkan + const Instance instance; + const Device device(instance); - const Vulkan::Core::ShaderModule computeShader(device, "shaders/downsample.spv", + // prepare render pass + const Core::CommandPool commandPool(device, Core::CommandPoolType::Compute); + + // prepare shader + const Core::ShaderModule computeShader(device, "shaders/downsample.spv", { { 1, VK_DESCRIPTOR_TYPE_SAMPLER}, { 1, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE}, { 7, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE}, { 1, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER} }); - const Vulkan::Core::Pipeline computePipeline(device, computeShader); + const Core::Pipeline computePipeline(device, computeShader); + + // start pass + Core::Fence fence(device); + + Core::CommandBuffer commandBuffer(device, commandPool); + commandBuffer.begin(); + + // end pass + commandBuffer.end(); + + commandBuffer.submit(device.getComputeQueue(), fence); + assert(fence.wait() && "Synchronization fence timed out"); std::cerr << "Application finished" << '\n'; return 0;