Skip to content

Commit

Permalink
merian-nodes: Add convenience ShaderCompiler to GraphRun
Browse files Browse the repository at this point in the history
  • Loading branch information
LDAP committed Feb 3, 2025
1 parent 5b701ce commit 9667192
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
14 changes: 8 additions & 6 deletions include/merian-nodes/graph/graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,14 @@ class Graph : public std::enable_shared_from_this<Graph<ITERATIONS_IN_FLIGHT>> {
registry(context, resource_allocator), ring_fences(context),
thread_pool(std::make_shared<ThreadPool>()),
cpu_queue(std::make_shared<CPUQueue>(context, thread_pool)),
run_profiler(std::make_shared<merian::Profiler>(context)), graph_run(ITERATIONS_IN_FLIGHT,
thread_pool,
cpu_queue,
run_profiler,
resource_allocator,
queue) {
run_profiler(std::make_shared<merian::Profiler>(context)),
graph_run(ITERATIONS_IN_FLIGHT,
thread_pool,
cpu_queue,
run_profiler,
resource_allocator,
queue,
ShaderCompiler::get(context)) {

for (uint32_t i = 0; i < ITERATIONS_IN_FLIGHT; i++) {
InFlightData& in_flight_data = ring_fences.get(i).user_data;
Expand Down
18 changes: 16 additions & 2 deletions include/merian-nodes/graph/graph_run.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "merian/vk/command/caching_command_pool.hpp"
#include "merian/vk/command/command_buffer.hpp"
#include "merian/vk/memory/resource_allocator.hpp"
#include "merian/vk/shader/shader_compiler.hpp"
#include "merian/vk/sync/semaphore_binary.hpp"
#include "merian/vk/sync/semaphore_timeline.hpp"
#include "merian/vk/utils/cpu_queue.hpp"
Expand All @@ -27,9 +28,17 @@ class GraphRun {
const CPUQueueHandle& cpu_queue,
const ProfilerHandle& profiler,
const ResourceAllocatorHandle& allocator,
const QueueHandle& queue)
const QueueHandle& queue,
const ShaderCompilerHandle& shader_compiler)
: iterations_in_flight(iterations_in_flight), thread_pool(thread_pool),
cpu_queue(cpu_queue), profiler(profiler), allocator(allocator), queue(queue) {}
cpu_queue(cpu_queue), profiler(profiler), allocator(allocator), queue(queue),
shader_compiler(shader_compiler) {}

GraphRun(GraphRun& graph_run) = delete;
GraphRun(GraphRun&& graph_run) = delete;

GraphRun& operator=(GraphRun& graph_run) = delete;
GraphRun& operator=(GraphRun&& graph_run) = delete;

// Enqueues a wait semaphore for the next submit. Note that during a graph run multiple submits
// might happen.
Expand Down Expand Up @@ -156,6 +165,10 @@ class GraphRun {
return cpu_queue;
}

const ShaderCompilerHandle& get_shader_compiler() const {
return shader_compiler;
}

// ------------------------------------------------------------------------------------
// Interact with graph runtime

Expand Down Expand Up @@ -239,6 +252,7 @@ class GraphRun {
const ProfilerHandle profiler;
const ResourceAllocatorHandle allocator;
const QueueHandle queue;
const ShaderCompilerHandle shader_compiler;

std::shared_ptr<CachingCommandPool> cmd_cache = nullptr;
CommandBufferHandle cmd = nullptr;
Expand Down

0 comments on commit 9667192

Please sign in to comment.