59 lines
1.6 KiB
C++
59 lines
1.6 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 "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 shader_lookup_entry_type = std::pair<shader_metadata, shader_data>;
|
|
public:
|
|
|
|
void process(
|
|
const assets::shader_source_store& shader_sources
|
|
);
|
|
|
|
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<std::pair<shader_metadata, shader_handle>> find_shader(
|
|
const shading::shader_requirements& requirements
|
|
);
|
|
|
|
static bool compile_shader(
|
|
GLenum shader_type,
|
|
std::span<const char*> source_strings,
|
|
shader_data& shader
|
|
);
|
|
|
|
private:
|
|
shader_source_manager m_preprocessor{};
|
|
|
|
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{};
|
|
std::vector<shader_lookup_entry_type> m_shader_lookup{};
|
|
};
|
|
}
|