mirror of
https://github.com/PancakeTAS/lsfg-vk.git
synced 2026-04-22 10:21:43 +00:00
fixes
This commit is contained in:
parent
e5eb4cb740
commit
ce6542a039
10 changed files with 35 additions and 10 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -6,3 +6,6 @@
|
|||
/.clangd
|
||||
/.cache
|
||||
/.ccls
|
||||
|
||||
# private shaders
|
||||
/shaders
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "core/commandpool.hpp"
|
||||
#include "core/semaphore.hpp"
|
||||
#include "device.hpp"
|
||||
|
||||
#include <vulkan/vulkan_core.h>
|
||||
|
||||
#include <optional>
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
|
||||
#include "device.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <vulkan/vulkan_core.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
namespace Vulkan::Core {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#include "core/commandbuffer.hpp"
|
||||
#include "core/semaphore.hpp"
|
||||
#include "utils/exceptions.hpp"
|
||||
|
||||
using namespace Vulkan::Core;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
#include "core/fence.hpp"
|
||||
#include "utils/exceptions.hpp"
|
||||
#include <vulkan/vulkan_core.h>
|
||||
|
||||
using namespace Vulkan::Core;
|
||||
|
||||
|
|
@ -29,7 +28,7 @@ Fence::Fence(const Device& device) {
|
|||
|
||||
void Fence::reset() const {
|
||||
if (!this->isValid())
|
||||
throw std::runtime_error("Invalid fence");
|
||||
throw std::logic_error("Invalid fence");
|
||||
|
||||
VkFence fenceHandle = this->handle();
|
||||
auto res = vkResetFences(this->device, 1, &fenceHandle);
|
||||
|
|
@ -39,7 +38,7 @@ void Fence::reset() const {
|
|||
|
||||
bool Fence::wait(uint64_t timeout) {
|
||||
if (!this->isValid())
|
||||
throw std::runtime_error("Invalid fence");
|
||||
throw std::logic_error("Invalid fence");
|
||||
|
||||
VkFence fenceHandle = this->handle();
|
||||
auto res = vkWaitForFences(this->device, 1, &fenceHandle, VK_TRUE, timeout);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ Semaphore::Semaphore(const Device& device, std::optional<uint32_t> initial) {
|
|||
|
||||
void Semaphore::signal(uint64_t value) const {
|
||||
if (!this->isValid() || !this->isTimeline)
|
||||
throw std::runtime_error("Invalid timeline semaphore");
|
||||
throw std::logic_error("Invalid timeline semaphore");
|
||||
|
||||
const VkSemaphoreSignalInfo signalInfo{
|
||||
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_SIGNAL_INFO,
|
||||
|
|
@ -49,7 +49,7 @@ void Semaphore::signal(uint64_t value) const {
|
|||
|
||||
bool Semaphore::wait(uint64_t value, uint64_t timeout) {
|
||||
if (!this->isValid() || !this->isTimeline)
|
||||
throw std::runtime_error("Invalid timeline semaphore");
|
||||
throw std::logic_error("Invalid timeline semaphore");
|
||||
|
||||
VkSemaphore semaphore = this->handle();
|
||||
const VkSemaphoreWaitInfo waitInfo{
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ ShaderModule::ShaderModule(const Device& device, const std::string& path,
|
|||
const uint8_t* data_ptr = code.data();
|
||||
const VkShaderModuleCreateInfo createInfo{
|
||||
.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
|
||||
.codeSize = code.size() * sizeof(uint32_t),
|
||||
.codeSize = code.size(),
|
||||
.pCode = reinterpret_cast<const uint32_t*>(data_ptr)
|
||||
};
|
||||
VkShaderModule shaderModuleHandle{};
|
||||
|
|
|
|||
|
|
@ -52,6 +52,11 @@ Device::Device(const Instance& instance) {
|
|||
|
||||
// create logical device
|
||||
const float queuePriority{1.0F}; // highest priority
|
||||
const VkPhysicalDeviceVulkan12Features features{
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES,
|
||||
.timelineSemaphore = VK_TRUE,
|
||||
.vulkanMemoryModel = VK_TRUE,
|
||||
};
|
||||
const VkDeviceQueueCreateInfo computeQueueDesc{
|
||||
.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,
|
||||
.queueFamilyIndex = *computeFamilyIdx,
|
||||
|
|
@ -60,6 +65,7 @@ Device::Device(const Instance& instance) {
|
|||
};
|
||||
const VkDeviceCreateInfo deviceCreateInfo{
|
||||
.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO,
|
||||
.pNext = &features,
|
||||
.queueCreateInfoCount = 1,
|
||||
.pQueueCreateInfos = &computeQueueDesc
|
||||
};
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ Instance::Instance() {
|
|||
.applicationVersion = VK_MAKE_VERSION(0, 0, 1),
|
||||
.pEngineName = "lsfg-vk-base",
|
||||
.engineVersion = VK_MAKE_VERSION(0, 0, 1),
|
||||
.apiVersion = VK_API_VERSION_1_4
|
||||
.apiVersion = VK_API_VERSION_1_3
|
||||
};
|
||||
const VkInstanceCreateInfo createInfo{
|
||||
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
|
||||
|
|
|
|||
17
src/main.cpp
17
src/main.cpp
|
|
@ -1,12 +1,29 @@
|
|||
#include "core/shadermodule.hpp"
|
||||
#include "device.hpp"
|
||||
#include "instance.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <vulkan/vulkan_core.h>
|
||||
|
||||
int main() {
|
||||
const Vulkan::Instance instance;
|
||||
const Vulkan::Device device(instance);
|
||||
|
||||
const Vulkan::Core::ShaderModule computeShader(device, "shaders/downsample.spv",
|
||||
{
|
||||
VK_DESCRIPTOR_TYPE_SAMPLER,
|
||||
VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
||||
VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
||||
VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
||||
VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
||||
VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
||||
VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
||||
VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
||||
VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
||||
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER
|
||||
}
|
||||
);
|
||||
|
||||
std::cerr << "Application finished" << '\n';
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue