mirror of
https://github.com/PancakeTAS/lsfg-vk.git
synced 2025-10-30 07:01:10 +00:00
fixing bugs and continuing main
This commit is contained in:
parent
93ecfbd79e
commit
2832020d10
4 changed files with 30 additions and 8 deletions
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
#include "device.hpp"
|
||||
|
||||
#include <utility>
|
||||
#include <vulkan/vulkan_core.h>
|
||||
|
||||
#include <utility>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
32
src/main.cpp
32
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 <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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue