fixing bugs and continuing main

This commit is contained in:
PancakeTAS 2025-06-29 17:21:21 +02:00
parent 93ecfbd79e
commit 2832020d10
No known key found for this signature in database
4 changed files with 30 additions and 8 deletions

View file

@ -3,9 +3,9 @@
#include "device.hpp"
#include <utility>
#include <vulkan/vulkan_core.h>
#include <utility>
#include <string>
#include <vector>
#include <memory>

View file

@ -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

View file

@ -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);

View file

@ -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 <cassert>
#include <iostream>
#include <vulkan/vulkan_core.h>
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;