71 vk::CommandBuffer
cmd;
89 std::shared_ptr<Core::VKShaderModule>
module;
116 const
std::shared_ptr<Core::VulkanBackend>& backend,
172 const std::string& content,
173 std::optional<ShaderStage> stage = std::nullopt,
174 const std::string& entry_point =
"main");
186 ShaderID reload_shader(
const std::string& filepath);
191 void destroy_shader(
ShaderID shader_id);
201 std::shared_ptr<Core::VKShaderModule> compile(
const ShaderSource& shader_source);
229 std::string get_shader_entry_point(
ShaderID shader_id);
242 void invalidate_cache(
const std::string& cache_key);
260 std::shared_ptr<Core::VKShaderModule> hot_reload(
const std::string& filepath);
286 void add_include_directory(
const std::string& directory);
295 void add_define(
const std::string& name,
const std::string& value =
"");
305 [[nodiscard]]
bool is_cached(
const std::string& cache_key)
const;
310 [[nodiscard]] std::vector<std::string> get_cached_keys()
const;
327 DescriptorSetID allocate_descriptor_set(vk::DescriptorSetLayout layout);
338 void update_descriptor_buffer(
341 vk::DescriptorType type,
355 void update_descriptor_image(
358 vk::ImageView image_view,
360 vk::ImageLayout layout = vk::ImageLayout::eShaderReadOnlyOptimal,
361 uint32_t array_element = 0);
370 void update_descriptor_storage_image(
373 vk::ImageView image_view,
374 vk::ImageLayout layout = vk::ImageLayout::eGeneral);
381 vk::DescriptorSet get_descriptor_set(
DescriptorSetID descriptor_set_id);
420 void free_all_command_buffers();
450 void wait_for_fence(
FenceID fence_id);
456 void wait_for_fences(
const std::vector<FenceID>& fence_ids);
463 bool is_fence_signaled(
FenceID fence_id);
473 CommandBufferType type,
475 vk::PipelineStageFlags wait_stage);
481 vk::Semaphore get_semaphore_handle(
SemaphoreID semaphore_id);
489 vk::AccessFlags src_access,
490 vk::AccessFlags dst_access,
491 vk::PipelineStageFlags src_stage,
492 vk::PipelineStageFlags dst_stage);
500 vk::ImageLayout old_layout,
501 vk::ImageLayout new_layout,
502 vk::AccessFlags src_access,
503 vk::AccessFlags dst_access,
504 vk::PipelineStageFlags src_stage,
505 vk::PipelineStageFlags dst_stage);
529 [[nodiscard]] vk::Queue get_graphics_queue()
const;
534 [[nodiscard]] vk::Queue get_compute_queue()
const;
539 [[nodiscard]] vk::Queue get_transfer_queue()
const;
545 void begin_timestamp(
CommandBufferID cmd_id,
const std::string& label =
"");
546 void end_timestamp(
CommandBufferID cmd_id,
const std::string& label =
"");
563 static vk::ShaderStageFlagBits to_vulkan_stage(
ShaderStage stage);
572 static std::optional<ShaderStage> detect_stage_from_extension(
const std::string& filepath);
581 [[nodiscard]] vk::Device get_device()
const;
590 [[nodiscard]] vk::PhysicalDevice get_physical_device()
const;
610 std::unordered_map<std::string, std::shared_ptr<Core::VKShaderModule>>
m_shader_cache;
625 std::atomic<uint64_t> m_next_shader_id { 1 };
626 std::atomic<uint64_t> m_next_descriptor_set_id { 1 };
627 std::atomic<uint64_t> m_next_command_id { 1 };
628 std::atomic<uint64_t> m_next_fence_id { 1 };
629 std::atomic<uint64_t> m_next_semaphore_id { 1 };
631 DetectedSourceType detect_source_type(
const std::string& content)
const;
632 std::optional<std::filesystem::path> resolve_shader_path(
const std::string& filepath)
const;
633 std::string generate_source_cache_key(
const std::string& source,
ShaderStage stage)
const;
635 std::shared_ptr<Core::VKShaderModule> create_shader_module();
637 void cleanup_sync_objects();
638 void cleanup_descriptor_resources();
639 void cleanup_shader_modules();
645 std::shared_ptr<Core::VKShaderModule> compile_from_file(
646 const std::string& filepath,
647 std::optional<ShaderStage> stage = std::nullopt,
648 const std::string& entry_point =
"main");
650 std::shared_ptr<Core::VKShaderModule> compile_from_source(
651 const std::string& source,
653 const std::string& entry_point =
"main");
655 std::shared_ptr<Core::VKShaderModule> compile_from_source_cached(
656 const std::string& source,
658 const std::string& cache_key,
659 const std::string& entry_point =
"main");
661 std::shared_ptr<Core::VKShaderModule> compile_from_spirv(
662 const std::string& spirv_path,
664 const std::string& entry_point =
"main");
666 std::shared_ptr<Core::VKShaderModule> get_vk_shader_module(
ShaderID shader_id);