Skip to content
Snippets Groups Projects
Verified Commit 04cc44e1 authored by Tobias Frisch's avatar Tobias Frisch
Browse files

Merge branch 'develop' into 33-pipeline-buffer-input

parents dc479587 f05dcda6
No related branches found
No related tags found
1 merge request!29Resolve "Pipeline Buffer Input"
Pipeline #25278 passed
variables:
RUN:
value: "all"
description: "The tests that should run. Possible values: ubuntu, win, all."
GIT_DEPTH: 1
stages:
- build
- deploy
build_ubuntu_gcc:
only:
variables:
- $RUN =~ /\bubuntu.*/i || $RUN =~ /\ball.*/i
stage: build
tags:
- ubuntu-gcc
variables:
GIT_SUBMODULE_STRATEGY: recursive
timeout: 10m
retry: 1
script:
- mkdir debug
- cd debug
......@@ -21,11 +32,16 @@ build_ubuntu_gcc:
expire_in: never
build_win10_msvc:
only:
variables:
- $RUN =~ /\bwin.*/i || $RUN =~ /\ball.*/i
stage: build
tags:
- win10-msvc
variables:
GIT_SUBMODULE_STRATEGY: recursive
timeout: 10m
retry: 1
script:
- cd 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\'
- .\Launch-VsDevShell.ps1
......@@ -37,6 +53,8 @@ build_win10_msvc:
deploy_doc_develop:
only:
variables:
- $RUN =~ /\bubuntu.*/i || $RUN =~ /\ball.*/i
refs:
- develop
stage: deploy
......@@ -52,6 +70,9 @@ deploy_doc_develop:
- echo "Check it out at https://vkcv.de/develop"
deploy_doc_branch:
only:
variables:
- $RUN =~ /\bubuntu.*/i || $RUN =~ /\ball.*/i
except:
refs:
- develop
......
......@@ -11,6 +11,8 @@ More information about Git LFS [here](https://git-lfs.github.com/).
## Build
[![pipeline status](https://gitlab.uni-koblenz.de/vulkan2021/vkcv-framework/badges/develop/pipeline.svg)](https://gitlab.uni-koblenz.de/vulkan2021/vkcv-framework/-/commits/develop)
Git submodules are used for libraries.
To download the submodules either clone using `git clone --recurse-submodules` or after `git clone` use `git submodule init` and `git submodule update`.
......@@ -22,4 +24,4 @@ https://vkcv.de/develop/
The documentation concerning the respective merge request is listed here:
https://vkcv.de/branch/
It is automatically generated and uploaded using the CI pipeline.
\ No newline at end of file
It is automatically generated and uploaded using the CI pipeline.
......@@ -54,6 +54,9 @@ set(vkcv_sources
${vkcv_source}/vkcv/Framebuffer.hpp
${vkcv_source}/vkcv/Framebuffer.cpp
${vkcv_include}/vkcv/VertexLayout.hpp
${vkcv_source}/vkcv/VertexLayout.cpp
${vkcv_include}/vkcv/Event.hpp
${vkcv_source}/vkcv/DescriptorManager.hpp
......@@ -61,7 +64,4 @@ set(vkcv_sources
${vkcv_include}/vkcv/DescriptorConfig.hpp
${vkcv_source}/vkcv/DescriptorConfig.cpp
${vkcv_include}/vkcv/VertexLayout.hpp
${vkcv_source}/vkcv/VertexLayout.cpp
)
......@@ -5,13 +5,63 @@
* @brief Central header file for all possible handles that the framework will hand out.
*/
#include <cstdint>
#include <iostream>
namespace vkcv
{
class Handle {
friend std::ostream& operator << (std::ostream& out, const Handle& handle);
private:
uint64_t m_id;
protected:
Handle();
explicit Handle(uint64_t id);
[[nodiscard]]
uint64_t getId() const;
public:
virtual ~Handle() = default;
Handle(const Handle& other) = default;
Handle(Handle&& other) = default;
Handle& operator=(const Handle& other) = default;
Handle& operator=(Handle&& other) = default;
explicit operator bool() const;
bool operator!() const;
};
std::ostream& operator << (std::ostream& out, const Handle& handle);
// Handle returned for any buffer created with the core/context objects
struct BufferHandle {uint64_t id;};
struct PassHandle {uint64_t id;};
struct PipelineHandle {uint64_t id;};
struct ResourcesHandle {uint64_t id;};
class BufferHandle : public Handle {
friend class BufferManager;
private:
using Handle::Handle;
};
class PassHandle : public Handle {
friend class PassManager;
private:
using Handle::Handle;
};
class PipelineHandle : public Handle {
friend class PipelineManager;
private:
using Handle::Handle;
};
class ResourcesHandle : public Handle {
friend class DescriptorManager;
private:
using Handle::Handle;
};
}
......@@ -65,8 +65,7 @@ int main(int argc, const char** argv) {
vkcv::PassConfig trianglePassDefinition({ present_color_attachment });
vkcv::PassHandle trianglePass = core.createPass(trianglePassDefinition);
if (trianglePass.id == 0)
{
if (!trianglePass) {
std::cout << "Error. Could not create renderpass. Exiting." << std::endl;
return EXIT_FAILURE;
}
......@@ -79,15 +78,14 @@ int main(int argc, const char** argv) {
const vkcv::PipelineConfig trianglePipelineDefinition(triangleShaderProgram, windowWidth, windowHeight, trianglePass);
vkcv::PipelineHandle trianglePipeline = core.createGraphicsPipeline(trianglePipelineDefinition);
if (trianglePipeline.id == 0)
{
if (!trianglePipeline) {
std::cout << "Error. Could not create graphics pipeline. Exiting." << std::endl;
return EXIT_FAILURE;
}
auto start = std::chrono::system_clock::now();
while (window.isWindowOpen())
{
while (window.isWindowOpen()) {
core.beginFrame();
window.pollEvents();
auto end = std::chrono::system_clock::now();
......
......@@ -82,7 +82,7 @@ int main(int argc, const char** argv) {
vkcv::PassConfig trianglePassDefinition({present_color_attachment});
vkcv::PassHandle trianglePass = core.createPass(trianglePassDefinition);
if (trianglePass.id == 0)
if (!trianglePass)
{
std::cout << "Error. Could not create renderpass. Exiting." << std::endl;
return EXIT_FAILURE;
......@@ -96,7 +96,8 @@ int main(int argc, const char** argv) {
const vkcv::PipelineConfig trianglePipelineDefinition(triangleShaderProgram, windowWidth, windowHeight, trianglePass);
vkcv::PipelineHandle trianglePipeline = core.createGraphicsPipeline(trianglePipelineDefinition);
if (trianglePipeline.id == 0)
if (!trianglePipeline)
{
std::cout << "Error. Could not create graphics pipeline. Exiting." << std::endl;
return EXIT_FAILURE;
......@@ -117,7 +118,7 @@ int main(int argc, const char** argv) {
sets.push_back(set);
auto resourceHandle = core.createResourceDescription(sets);
std::cout << "Resource " << resourceHandle.id << " created." << std::endl;
std::cout << "Resource " << resourceHandle << " created." << std::endl;
}
/*
......
......@@ -9,7 +9,7 @@
namespace vkcv {
BufferManager::BufferManager() noexcept :
m_core(nullptr), m_buffers(), m_stagingBuffer(BufferHandle{ UINT64_MAX })
m_core(nullptr), m_buffers(), m_stagingBuffer(BufferHandle())
{
}
......@@ -22,8 +22,8 @@ namespace vkcv {
}
BufferManager::~BufferManager() noexcept {
for (size_t id = 0; id < m_buffers.size(); id++) {
destroyBuffer(BufferHandle{ id });
for (uint64_t id = 0; id < m_buffers.size(); id++) {
destroyBuffer(BufferHandle(id));
}
}
......@@ -182,7 +182,7 @@ namespace vkcv {
}
vk::Buffer BufferManager::getBuffer(const BufferHandle& handle) const {
const uint64_t id = handle.id;
const uint64_t id = handle.getId();
if (id >= m_buffers.size()) {
return nullptr;
......@@ -194,7 +194,7 @@ namespace vkcv {
}
vk::DeviceMemory BufferManager::getDeviceMemory(const BufferHandle& handle) const {
const uint64_t id = handle.id;
const uint64_t id = handle.getId();
if (id >= m_buffers.size()) {
return nullptr;
......@@ -206,7 +206,7 @@ namespace vkcv {
}
void BufferManager::fillBuffer(const BufferHandle& handle, void *data, size_t size, size_t offset) {
const uint64_t id = handle.id;
const uint64_t id = handle.getId();
if (size == 0) {
size = SIZE_MAX;
......@@ -235,7 +235,7 @@ namespace vkcv {
memcpy(mapped, data, max_size);
device.unmapMemory(buffer.m_memory);
} else {
auto& stagingBuffer = m_buffers[ m_stagingBuffer.id ];
auto& stagingBuffer = m_buffers[ m_stagingBuffer.getId() ];
StagingStepInfo info;
info.data = data;
......@@ -256,7 +256,7 @@ namespace vkcv {
}
void* BufferManager::mapBuffer(const BufferHandle& handle, size_t offset, size_t size) {
const uint64_t id = handle.id;
const uint64_t id = handle.getId();
if (size == 0) {
size = SIZE_MAX;
......@@ -284,7 +284,7 @@ namespace vkcv {
}
void BufferManager::unmapBuffer(const BufferHandle& handle) {
const uint64_t id = handle.id;
const uint64_t id = handle.getId();
if (id >= m_buffers.size()) {
return;
......@@ -303,7 +303,7 @@ namespace vkcv {
}
void BufferManager::destroyBuffer(const BufferHandle& handle) {
const uint64_t id = handle.id;
const uint64_t id = handle.getId();
if (id >= m_buffers.size()) {
return;
......
......@@ -8,7 +8,7 @@ namespace vkcv
descriptorSetLayouts{std::move(layouts)}
{}
DescriptorManager::DescriptorManager(vk::Device device) noexcept:
m_Device{ device }, m_NextResourceDescriptionID{ 1 }
m_Device{ device }, m_NextResourceDescriptionID{ 0 }
{
/**
* Allocate a set size for the initial pool, namely 1000 units of each descriptor type below.
......@@ -64,7 +64,7 @@ namespace vkcv
if(m_Device.createDescriptorSetLayout(&layoutInfo, nullptr, &layout) != vk::Result::eSuccess)
{
std::cout << "FAILED TO CREATE DESCRIPTOR SET LAYOUT" << std::endl;
return ResourcesHandle{0};
return ResourcesHandle();
};
vk_setLayouts.push_back(layout);
}
......@@ -79,11 +79,11 @@ namespace vkcv
for(const auto &layout : vk_setLayouts)
m_Device.destroy(layout);
return ResourcesHandle{0};
return ResourcesHandle();
};
m_ResourceDescriptions.emplace_back(vk_sets, vk_setLayouts);
return ResourcesHandle{m_NextResourceDescriptionID++};
return ResourcesHandle(m_NextResourceDescriptionID++);
}
vk::DescriptorType DescriptorManager::convertDescriptorTypeFlag(DescriptorType type) {
......
#include "vkcv/Handles.hpp"
namespace vkcv {
Handle::Handle() :
m_id(UINT64_MAX)
{}
Handle::Handle(uint64_t id) :
m_id(id)
{}
uint64_t Handle::getId() const {
return m_id;
}
Handle::operator bool() const {
return (m_id < UINT64_MAX);
}
bool Handle::operator!() const {
return (m_id == UINT64_MAX);
}
std::ostream& operator << (std::ostream& out, const Handle& handle) {
if (handle) {
return out << "[Handle: " << handle.getId() << "]";
} else {
return out << "[Handle: none]";
}
}
}
......@@ -50,7 +50,7 @@ namespace vkcv
PassManager::PassManager(vk::Device device) noexcept :
m_Device{device},
m_RenderPasses{},
m_NextPassId{1}
m_NextPassId(0)
{}
PassManager::~PassManager() noexcept
......@@ -59,7 +59,7 @@ namespace vkcv
m_Device.destroy(pass);
m_RenderPasses.clear();
m_NextPassId = 1;
m_NextPassId = 0;
}
PassHandle PassManager::createPass(const PassConfig &config)
......@@ -122,14 +122,14 @@ namespace vkcv
vk::RenderPass vkObject{nullptr};
if(m_Device.createRenderPass(&passInfo, nullptr, &vkObject) != vk::Result::eSuccess)
return PassHandle{0};
return PassHandle();
m_RenderPasses.push_back(vkObject);
return PassHandle{m_NextPassId++};
return PassHandle(m_NextPassId++);
}
vk::RenderPass PassManager::getVkPass(const PassHandle &handle) const
{
return m_RenderPasses[handle.id - 1];
return m_RenderPasses[handle.getId()];
}
}
......@@ -7,7 +7,7 @@ namespace vkcv
m_Device{device},
m_Pipelines{},
m_PipelineLayouts{},
m_NextPipelineId{1}
m_NextPipelineId{0}
{}
PipelineManager::~PipelineManager() noexcept
......@@ -20,7 +20,7 @@ namespace vkcv
m_Pipelines.clear();
m_PipelineLayouts.clear();
m_NextPipelineId = 1;
m_NextPipelineId = 0;
}
PipelineHandle PipelineManager::createPipeline(const PipelineConfig &config, const vk::RenderPass &pass)
......@@ -30,7 +30,7 @@ namespace vkcv
if (!(existsVertexShader && existsFragmentShader))
{
std::cout << "Core::createGraphicsPipeline requires vertex and fragment shader code" << std::endl;
return PipelineHandle{0};
return PipelineHandle();
}
// vertex shader stage
......@@ -38,7 +38,7 @@ namespace vkcv
vk::ShaderModuleCreateInfo vertexModuleInfo({}, vertexCode.size(), reinterpret_cast<uint32_t*>(vertexCode.data()));
vk::ShaderModule vertexModule{};
if (m_Device.createShaderModule(&vertexModuleInfo, nullptr, &vertexModule) != vk::Result::eSuccess)
return PipelineHandle{0};
return PipelineHandle();
vk::PipelineShaderStageCreateInfo pipelineVertexShaderStageInfo(
{},
......@@ -55,7 +55,7 @@ namespace vkcv
if (m_Device.createShaderModule(&fragmentModuleInfo, nullptr, &fragmentModule) != vk::Result::eSuccess)
{
m_Device.destroy(vertexModule);
return PipelineHandle{0};
return PipelineHandle();
}
vk::PipelineShaderStageCreateInfo pipelineFragmentShaderStageInfo(
......@@ -168,7 +168,7 @@ namespace vkcv
{
m_Device.destroy(vertexModule);
m_Device.destroy(fragmentModule);
return PipelineHandle{0};
return PipelineHandle();
}
// graphics pipeline create
......@@ -198,7 +198,7 @@ namespace vkcv
{
m_Device.destroy(vertexModule);
m_Device.destroy(fragmentModule);
return PipelineHandle{0};
return PipelineHandle();
}
m_Device.destroy(vertexModule);
......@@ -206,16 +206,16 @@ namespace vkcv
m_Pipelines.push_back(vkPipeline);
m_PipelineLayouts.push_back(vkPipelineLayout);
return PipelineHandle{m_NextPipelineId++};
return PipelineHandle(m_NextPipelineId++);
}
vk::Pipeline PipelineManager::getVkPipeline(const PipelineHandle &handle) const
{
return m_Pipelines.at(handle.id -1);
return m_Pipelines.at(handle.getId());
}
vk::PipelineLayout PipelineManager::getVkPipelineLayout(const PipelineHandle &handle) const
{
return m_PipelineLayouts.at(handle.id - 1);
return m_PipelineLayouts.at(handle.getId());
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment