64 lines
1.8 KiB
C++
64 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include <unordered_map>
|
|
#include <bit>
|
|
#include <format>
|
|
#include <ranges>
|
|
#include <bits/ranges_algo.h>
|
|
|
|
#include "assets/data_stores/shader_source_store.hpp"
|
|
#include "opengl/shader_program_lookup.hpp"
|
|
#include "opengl/handles/shader_handle.hpp"
|
|
#include "util/string_lookup.hpp"
|
|
#include "shader_source_manager.hpp"
|
|
#include "assets/data_stores.hpp"
|
|
#include "opengl/metadata/shader_metadata.hpp"
|
|
#include "opengl/data/shader_data.hpp"
|
|
#include "opengl/handles/shader_handle_set.hpp"
|
|
#include "opengl/shading/requirements/shader_requirements.hpp"
|
|
#include "opengl/metadata/shader_set_metadata.hpp"
|
|
#include "opengl/shading/requirements/shader_set_requirements.hpp"
|
|
|
|
namespace zgl
|
|
{
|
|
class shader_manager
|
|
{
|
|
using metadata_type = shader_metadata;
|
|
using data_type = shader_data;
|
|
using handle_type = shader_handle;
|
|
using entry_type = std::pair<metadata_type, data_type>;
|
|
using entry_view_type = std::pair<metadata_type, handle_type>;
|
|
|
|
public:
|
|
|
|
void process(const assets::data_stores& stores);
|
|
|
|
void get_handles(
|
|
const assets::shader_source_store& shader_sources,
|
|
std::span<const shading::shader_set_requirements> requirements,
|
|
std::span<shader_set_metadata> metadata,
|
|
std::span<shader_handle_set> shader_sets
|
|
);
|
|
|
|
protected:
|
|
std::optional<entry_view_type> find_shader(
|
|
const shading::shader_requirements& requirements
|
|
);
|
|
|
|
static bool compile_shader(
|
|
GLenum shader_type,
|
|
std::span<const char*> source_strings,
|
|
shader_data& shader
|
|
);
|
|
|
|
|
|
shader_source_manager m_preprocessor{};
|
|
std::vector<entry_type> m_shader_lookup{};
|
|
|
|
private:
|
|
std::vector<shading::shader_source_requirements> m_source_requirement_buffer{};
|
|
std::vector<preprocessed_shader_source_metadata> m_preprocessed_shader_source_metadata_buffer{};
|
|
std::vector<const char*> m_source_strings_buffer{};
|
|
};
|
|
}
|