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

Merge branch 'develop' into 73-runtime-shader-compilation

parents 96b15160 2b783d40
No related branches found
No related tags found
1 merge request!60Resolve "Runtime shader compilation"
Pipeline #25742 passed
......@@ -41,7 +41,6 @@ set(vkcv_sources
${vkcv_source}/vkcv/ShaderProgram.cpp
${vkcv_include}/vkcv/PipelineConfig.hpp
${vkcv_source}/vkcv/PipelineConfig.cpp
${vkcv_source}/vkcv/PipelineManager.hpp
${vkcv_source}/vkcv/PipelineManager.cpp
......
......@@ -14,28 +14,9 @@
namespace vkcv {
struct PipelineConfig {
/**
* Constructor for the pipeline. Creates a pipeline using @p vertexCode, @p fragmentCode as well as the
* dimensions of the application window @p width and @p height. A handle for the Render Pass is also needed, @p passHandle.
*
* @param shaderProgram shaders of the pipeline
* @param height height of the application window
* @param width width of the application window
* @param passHandle handle for render pass
* @param vertexLayout layout of vertex buffer, comprised of its bindings and the bindings' attachments
*/
PipelineConfig(
const ShaderProgram& shaderProgram,
uint32_t width,
uint32_t height,
const PassHandle &passHandle,
const VertexLayout &vertexLayouts,
const std::vector<vk::DescriptorSetLayout> &descriptorLayouts,
bool useDynamicViewport);
ShaderProgram m_ShaderProgram;
uint32_t m_Height;
uint32_t m_Width;
uint32_t m_Height;
PassHandle m_PassHandle;
VertexLayout m_VertexLayout;
std::vector<vk::DescriptorSetLayout> m_DescriptorLayouts;
......
......@@ -119,14 +119,16 @@ int main(int argc, const char** argv) {
std::vector<vkcv::DescriptorBinding> descriptorBindings = { firstMeshProgram.getReflectedDescriptors()[0] };
vkcv::DescriptorSetHandle descriptorSet = core.createDescriptorSet(descriptorBindings);
const vkcv::PipelineConfig firstMeshPipelineConfig(
const vkcv::PipelineConfig firstMeshPipelineConfig {
firstMeshProgram,
windowWidth,
windowHeight,
firstMeshPass,
{firstMeshLayout},
firstMeshLayout,
{ core.getDescriptorSet(descriptorSet).layout },
true);
true
};
vkcv::PipelineHandle firstMeshPipeline = core.createGraphicsPipeline(firstMeshPipelineConfig);
if (!firstMeshPipeline) {
......@@ -192,14 +194,16 @@ int main(int argc, const char** argv) {
const uint32_t shadowMapResolution = 1024;
const vkcv::Image shadowMap = core.createImage(shadowMapFormat, shadowMapResolution, shadowMapResolution, 1);
const vkcv::PipelineConfig shadowPipeConfig(
const vkcv::PipelineConfig shadowPipeConfig {
shadowShader,
shadowMapResolution,
shadowMapResolution,
shadowPass,
{firstMeshLayout},
{},
false);
firstMeshLayout,
{},
false
};
const vkcv::PipelineHandle shadowPipe = core.createGraphicsPipeline(shadowPipeConfig);
struct LightInfo {
......
......@@ -102,14 +102,15 @@ int main(int argc, const char** argv) {
std::vector<vkcv::DescriptorBinding> descriptorBindings = { firstMeshProgram.getReflectedDescriptors()[setID] };
vkcv::DescriptorSetHandle descriptorSet = core.createDescriptorSet(descriptorBindings);
const vkcv::PipelineConfig firstMeshPipelineConfig(
const vkcv::PipelineConfig firstMeshPipelineConfig {
firstMeshProgram,
UINT32_MAX,
UINT32_MAX,
firstMeshPass,
{firstMeshLayout},
{ core.getDescriptorSet(descriptorSet).layout },
true);
true
};
vkcv::PipelineHandle firstMeshPipeline = core.createGraphicsPipeline(firstMeshPipelineConfig);
if (!firstMeshPipeline) {
......
......@@ -19,7 +19,7 @@ int main(int argc, const char** argv) {
);
window.initEvents();
vkcv::Core core = vkcv::Core::create(
window,
applicationName,
......@@ -105,14 +105,15 @@ int main(int argc, const char** argv) {
triangleShaderProgram.addShader(shaderStage, path);
});
const vkcv::PipelineConfig trianglePipelineDefinition(
const vkcv::PipelineConfig trianglePipelineDefinition {
triangleShaderProgram,
(uint32_t)windowWidth,
(uint32_t)windowHeight,
trianglePass,
{},
{},
false);
false
};
vkcv::PipelineHandle trianglePipeline = core.createGraphicsPipeline(trianglePipelineDefinition);
......@@ -168,7 +169,7 @@ int main(int argc, const char** argv) {
vkcv::DrawcallInfo drawcall(renderMesh, {});
const vkcv::ImageHandle swapchainInput = vkcv::ImageHandle::createSwapchainImageHandle();
vkcv::camera::CameraManager cameraManager(window);
uint32_t camIndex = cameraManager.addCamera(vkcv::camera::ControllerType::PILOT);
uint32_t camIndex2 = cameraManager.addCamera(vkcv::camera::ControllerType::TRACKBALL);
......
/**
* @authors Mara Vogt, Mark Mints
* @file src/vkcv/Pipeline.cpp
* @brief Pipeline class to handle shader stages
*/
#include "vkcv/PipelineConfig.hpp"
namespace vkcv {
PipelineConfig::PipelineConfig(
const ShaderProgram& shaderProgram,
uint32_t width,
uint32_t height,
const PassHandle &passHandle,
const VertexLayout &vertexLayout,
const std::vector<vk::DescriptorSetLayout> &descriptorLayouts,
bool useDynamicViewport)
:
m_ShaderProgram(shaderProgram),
m_Height(height),
m_Width(width),
m_PassHandle(passHandle),
m_VertexLayout(vertexLayout),
m_DescriptorLayouts(descriptorLayouts),
m_UseDynamicViewport(useDynamicViewport)
{}
}
......@@ -7,8 +7,7 @@ namespace vkcv
PipelineManager::PipelineManager(vk::Device device) noexcept :
m_Device{device},
m_Pipelines{},
m_Configs{}
m_Pipelines{}
{}
PipelineManager::~PipelineManager() noexcept
......@@ -271,8 +270,7 @@ namespace vkcv
m_Device.destroy(fragmentModule);
const uint64_t id = m_Pipelines.size();
m_Pipelines.push_back({ vkPipeline, vkPipelineLayout });
m_Configs.push_back(config);
m_Pipelines.push_back({ vkPipeline, vkPipelineLayout, config });
return PipelineHandle(id, [&](uint64_t id) { destroyPipelineById(id); });
}
......@@ -320,10 +318,17 @@ namespace vkcv
}
}
const PipelineConfig &PipelineManager::getPipelineConfig(const PipelineHandle &handle) const
const PipelineConfig& PipelineManager::getPipelineConfig(const PipelineHandle &handle) const
{
const uint64_t id = handle.getId();
return m_Configs.at(id);
if (id >= m_Pipelines.size()) {
static PipelineConfig dummyConfig;
vkcv_log(LogLevel::ERROR, "Invalid handle");
return dummyConfig;
}
return m_Pipelines[id].m_config;
}
PipelineHandle PipelineManager::createComputePipeline(
......@@ -373,7 +378,7 @@ namespace vkcv
m_Device.destroy(computeModule);
const uint64_t id = m_Pipelines.size();
m_Pipelines.push_back({ vkPipeline, vkPipelineLayout });
m_Pipelines.push_back({ vkPipeline, vkPipelineLayout, PipelineConfig() });
return PipelineHandle(id, [&](uint64_t id) { destroyPipelineById(id); });
}
......
......@@ -14,11 +14,11 @@ namespace vkcv
struct Pipeline {
vk::Pipeline m_handle;
vk::PipelineLayout m_layout;
PipelineConfig m_config;
};
vk::Device m_Device;
std::vector<Pipeline> m_Pipelines;
std::vector<PipelineConfig> m_Configs;
void destroyPipelineById(uint64_t id);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment