#pragma once #include #include #include #include #include "assets/data_stores.hpp" #include "util/string_lookup.hpp" #include "opengl/metadata/shader_source_metadata.hpp" #include "opengl/shading/requirements/shader_source_requirements.hpp" #include "opengl/metadata/preprocessed_shader_source_metadata.hpp" #include "assets/data_stores/shader_source_store.hpp" #include "opengl/shading/shader_source_set.hpp" namespace zgl { class shader_source_manager { public: using store_type = assets::shader_source_store; using store_id_type = store_type::id_type; using metadata_type = shader_source_metadata; using data_type = char*; using handle_type = const char*; using entry_type = std::pair; using entry_view_type = std::pair; void process(const assets::data_stores& stores); void get_shader_sources( const assets::shader_source_store& shader_sources, std::span requirements, std::span metadata, std::vector& shader_strings ); protected: void tokenize_declarations(std::string_view source); std::optional parse_metadata_from_tokens(); [[nodiscard]] static bool parse_stage_declaration( std::span values, shader_source_metadata& metadata ); [[nodiscard]] static bool parse_geometry_declaration( std::span tokens, shader_source_metadata& metadata ); [[nodiscard]] static bool parse_features_declaration( std::span values, shader_source_metadata& metadata ); [[nodiscard]] static bool parse_static_enable_declaration( std::span values, shader_source_metadata& metadata ); [[nodiscard]] static bool parse_dynamic_enable_declaration( std::span values, shader_source_metadata& metadata ); template static void parse_feature_tokens( std::span values, const ztu::string_lookup& feature_lookup, T& features ); static void get_define_strings( shading::model_geometry::types geometry, shading::features::generic::type features, shading::features::generic::type& feature_count, std::vector& defines ); std::vector m_shader_source_lookup; private: std::vector m_value_token_buffer; std::vector m_declaration_token_count_buffer; std::array m_declaration_type_index_buffer; }; }