MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ initialise()

bool MayaFlux::Yantra::GpuResourceManager::initialise ( const GpuShaderConfig config,
const std::vector< GpuBufferBinding > &  bindings 
)

Definition at line 120 of file GpuResourceManager.cpp.

122{
123 if (m_ready)
124 return true;
125
126 auto& foundry = Portal::Graphics::get_shader_foundry();
127 auto& compute_press = Portal::Graphics::get_compute_press();
128
129 m_shader_id = foundry.load_shader(config.shader_path);
132 "GpuResourceManager: failed to load shader '{}'", config.shader_path);
133 return false;
134 }
135
136 std::map<uint32_t, std::vector<Portal::Graphics::DescriptorBindingInfo>> by_set;
137 for (const auto& b : bindings) {
138 const auto et = b.element_type;
141 if (is_image) {
142 by_set[b.set].push_back({
143 .set = b.set,
144 .binding = b.binding,
145 .type = element_type_to_vk(et),
146 });
147 }
148 }
149
150 for (const auto& b : bindings) {
151 const auto et = b.element_type;
154 if (!is_image) {
155 by_set[b.set].push_back({
156 .set = b.set,
157 .binding = b.binding,
158 .type = vk::DescriptorType::eStorageBuffer,
159 });
160 }
161 }
162
163 std::vector<std::vector<Portal::Graphics::DescriptorBindingInfo>> descriptor_sets;
164 descriptor_sets.reserve(by_set.size());
165 for (auto& [set_idx, set_bindings] : by_set)
166 descriptor_sets.push_back(std::move(set_bindings));
167
168 m_pipeline_id = compute_press.create_pipeline(
169 m_shader_id, descriptor_sets, config.push_constant_size);
170
173 "GpuResourceManager: failed to create pipeline for '{}'",
174 config.shader_path);
175 foundry.destroy_shader(m_shader_id);
177 return false;
178 }
179
180 m_descriptor_set_ids = compute_press.allocate_pipeline_descriptors(m_pipeline_id);
181 if (m_descriptor_set_ids.empty()) {
183 "GpuResourceManager: failed to allocate descriptor sets");
184 compute_press.destroy_pipeline(m_pipeline_id);
186 foundry.destroy_shader(m_shader_id);
188 return false;
189 }
190
191 m_impl = std::make_unique<GpuResourceManagerImpl>();
192 m_impl->buffers.resize(bindings.size());
193 m_buffer_slots.resize(bindings.size());
194 m_image_slots.resize(bindings.size());
195
196 m_ready = true;
197 return true;
198}
#define MF_ERROR(comp, ctx,...)
size_t b
Portal::Graphics::ComputePipelineID m_pipeline_id
std::vector< std::shared_ptr< Core::VKImage > > m_image_slots
std::vector< Portal::Graphics::DescriptorSetID > m_descriptor_set_ids
std::unique_ptr< GpuResourceManagerImpl > m_impl
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Yantra
DSP algorithms, computational units, matrix operations, Grammar.
constexpr ShaderID INVALID_SHADER
MAYAFLUX_API ShaderFoundry & get_shader_foundry()
Get the global shader compiler instance.
constexpr ComputePipelineID INVALID_COMPUTE_PIPELINE
MAYAFLUX_API ComputePress & get_compute_press()
bool is_image(const fs::path &filepath)
Definition Depot.cpp:108

References b, MayaFlux::Journal::BufferProcessing, MayaFlux::Portal::Graphics::get_compute_press(), MayaFlux::Portal::Graphics::get_shader_foundry(), MayaFlux::Yantra::GpuBufferBinding::IMAGE_SAMPLED, MayaFlux::Yantra::GpuBufferBinding::IMAGE_STORAGE, MayaFlux::Portal::Graphics::INVALID_COMPUTE_PIPELINE, MayaFlux::Portal::Graphics::INVALID_SHADER, MayaFlux::is_image(), m_buffer_slots, m_descriptor_set_ids, m_image_slots, m_impl, m_pipeline_id, m_ready, m_shader_id, MF_ERROR, MayaFlux::Yantra::GpuShaderConfig::push_constant_size, MayaFlux::Yantra::GpuShaderConfig::shader_path, and MayaFlux::Journal::Yantra.

Referenced by MayaFlux::Yantra::GpuDispatchCore::ensure_gpu_ready().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: