/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #include "ShaderRegistry.hpp" extern "C" { #include "Shaders.h" } namespace OpenVulkano { ShaderRegistry& ShaderRegistry::GetInstance() { static ShaderRegistry instance; return instance; } ShaderRegistry::ShaderRegistry() { RegisterShaderTable(reinterpret_cast(fileTable), fileTableSize); } void ShaderRegistry::RegisterShaderTable(const ShaderTableEntry* table, uint32_t size) { for(uint32_t i = 0; i < size; i++) { RegisterShader(table[i].entryName, { table[i].data, static_cast(table[i].size) }); } } void ShaderRegistry::RegisterShader(std::string_view name, std::pair shader) { m_shaderMap.emplace(name, shader); } std::pair ShaderRegistry::GetShader(std::string_view shaderName) { auto it = m_shaderMap.find(shaderName); if (it == m_shaderMap.end()) return { 0, 0 }; return it->second; } }