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

Added barebones compute shaders and pipelines with debug labels

parent 4b45925b
Branches
Tags
1 merge request!103Added project wobble_bobble and refactored some parts of the framework
#version 450
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
void main() {
}
\ No newline at end of file
#version 450
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
void main() {
}
\ No newline at end of file
#version 450
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
void main() {
}
\ No newline at end of file
#version 450
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
void main() {
}
\ No newline at end of file
#version 450
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
void main() {
}
\ No newline at end of file
#version 450
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
void main() {
}
\ No newline at end of file
#version 450
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
void main() {
}
\ No newline at end of file
...@@ -44,6 +44,27 @@ void distributeParticles(Particle *particles, size_t count, const glm::vec3& cen ...@@ -44,6 +44,27 @@ void distributeParticles(Particle *particles, size_t count, const glm::vec3& cen
} }
} }
vkcv::ComputePipelineHandle createComputePipeline(vkcv::Core& core, vkcv::shader::GLSLCompiler& compiler,
const std::string& path,
const std::vector<vk::DescriptorSetLayout>& descriptorSetLayouts) {
vkcv::ShaderProgram shaderProgram;
compiler.compile(
vkcv::ShaderStage::COMPUTE,
path,
[&shaderProgram](vkcv::ShaderStage stage, const std::filesystem::path& path) {
shaderProgram.addShader(stage, path);
}
);
vkcv::ComputePipelineConfig config {
shaderProgram,
descriptorSetLayouts
};
return core.createComputePipeline(config);
}
int main(int argc, const char **argv) { int main(int argc, const char **argv) {
const char* applicationName = "Wobble Bobble"; const char* applicationName = "Wobble Bobble";
...@@ -110,6 +131,49 @@ int main(int argc, const char **argv) { ...@@ -110,6 +131,49 @@ int main(int argc, const char **argv) {
*/ */
vkcv::shader::GLSLCompiler compiler; vkcv::shader::GLSLCompiler compiler;
vkcv::ComputePipelineHandle transformParticlesToGridPipeline = createComputePipeline(
core, compiler,
"shaders/transform_particles_to_grid.comp",
{}
);
vkcv::ComputePipelineHandle initParticleVolumesPipeline = createComputePipeline(
core, compiler,
"shaders/init_particle_volumes.comp",
{}
);
vkcv::ComputePipelineHandle updateGridForcesPipeline = createComputePipeline(
core, compiler,
"shaders/update_grid_forces.comp",
{}
);
vkcv::ComputePipelineHandle updateGridVelocitiesPipeline = createComputePipeline(
core, compiler,
"shaders/update_grid_velocities.comp",
{}
);
vkcv::ComputePipelineHandle updateParticleDeformationPipeline = createComputePipeline(
core, compiler,
"shaders/update_particle_deformation.comp",
{}
);
vkcv::ComputePipelineHandle updateParticleVelocitiesPipeline = createComputePipeline(
core, compiler,
"shaders/update_particle_velocities.comp",
{}
);
vkcv::ComputePipelineHandle updateParticlePositionsPipeline = createComputePipeline(
core, compiler,
"shaders/update_particle_positions.comp",
{}
);
vkcv::ShaderProgram gfxProgram; vkcv::ShaderProgram gfxProgram;
compiler.compile( compiler.compile(
...@@ -199,11 +263,74 @@ int main(int argc, const char **argv) { ...@@ -199,11 +263,74 @@ int main(int argc, const char **argv) {
auto cmdStream = core.createCommandStream(vkcv::QueueType::Graphics); auto cmdStream = core.createCommandStream(vkcv::QueueType::Graphics);
const uint32_t dispatchSize [3] = { 1, 0, 0 };
core.recordBeginDebugLabel(cmdStream, "TRANSFORM PARTICLES TO GRID", { 1.0f, 0.0f, 0.0f, 1.0f });
core.recordComputeDispatchToCmdStream(
cmdStream,
transformParticlesToGridPipeline,
dispatchSize,
{},
pushConstants
);
core.recordEndDebugLabel(cmdStream);
core.recordBeginDebugLabel(cmdStream, "UPDATE GRID FORCES", { 1.0f, 0.0f, 0.0f, 1.0f });
core.recordComputeDispatchToCmdStream(
cmdStream,
updateGridForcesPipeline,
dispatchSize,
{},
pushConstants
);
core.recordEndDebugLabel(cmdStream);
core.recordBeginDebugLabel(cmdStream, "UPDATE GRID VELOCITIES", { 1.0f, 0.0f, 0.0f, 1.0f });
core.recordComputeDispatchToCmdStream(
cmdStream,
updateGridVelocitiesPipeline,
dispatchSize,
{},
pushConstants
);
core.recordEndDebugLabel(cmdStream);
core.recordBeginDebugLabel(cmdStream, "UPDATE PARTICLE DEFORMATION", { 0.0f, 1.0f, 0.0f, 1.0f });
core.recordComputeDispatchToCmdStream(
cmdStream,
updateParticleDeformationPipeline,
dispatchSize,
{},
pushConstants
);
core.recordEndDebugLabel(cmdStream);
core.recordBeginDebugLabel(cmdStream, "UPDATE PARTICLE VELOCITIES", { 0.0f, 1.0f, 0.0f, 1.0f });
core.recordComputeDispatchToCmdStream(
cmdStream,
updateParticleVelocitiesPipeline,
dispatchSize,
{},
pushConstants
);
core.recordEndDebugLabel(cmdStream);
core.recordBeginDebugLabel(cmdStream, "UPDATE PARTICLE POSITIONS", { 0.0f, 1.0f, 0.0f, 1.0f });
core.recordComputeDispatchToCmdStream(
cmdStream,
updateParticlePositionsPipeline,
dispatchSize,
{},
pushConstants
);
core.recordEndDebugLabel(cmdStream);
std::vector<vkcv::ImageHandle> renderTargets { std::vector<vkcv::ImageHandle> renderTargets {
vkcv::ImageHandle::createSwapchainImageHandle(), vkcv::ImageHandle::createSwapchainImageHandle(),
depthBuffer depthBuffer
}; };
core.recordBeginDebugLabel(cmdStream, "RENDER PARTICLES", { 0.0f, 0.0f, 1.0f, 1.0f });
core.recordDrawcallsToCmdStream( core.recordDrawcallsToCmdStream(
cmdStream, cmdStream,
gfxPass, gfxPass,
...@@ -213,6 +340,7 @@ int main(int argc, const char **argv) { ...@@ -213,6 +340,7 @@ int main(int argc, const char **argv) {
renderTargets, renderTargets,
windowHandle windowHandle
); );
core.recordEndDebugLabel(cmdStream);
core.prepareSwapchainImageForPresent(cmdStream); core.prepareSwapchainImageForPresent(cmdStream);
core.submitCommandStream(cmdStream); core.submitCommandStream(cmdStream);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment