69 lines
1.8 KiB
C++
69 lines
1.8 KiB
C++
#pragma once
|
|
|
|
#include <unordered_map>
|
|
#include <bit>
|
|
#include <format>
|
|
#include <ranges>
|
|
#include <bits/ranges_algo.h>
|
|
|
|
#include "assets/dynamic_data_stores/dynamic_shader_source_store.hpp"
|
|
#include "opengl/shader_program_lookup.hpp"
|
|
#include "opengl/handles/shader_handle.hpp"
|
|
#include "util/string_lookup.hpp"
|
|
#include "shader_preprocessor.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_program_compiler
|
|
{
|
|
using shader_lookup_entry_type = std::pair<shader_metadata, shader_data>;
|
|
|
|
static constexpr auto gl_shader_types = std::array<GLenum, shading::stage::count>{
|
|
GL_VERTEX_SHADER,
|
|
GL_TESS_CONTROL_SHADER,
|
|
GL_TESS_EVALUATION_SHADER,
|
|
GL_GEOMETRY_SHADER,
|
|
GL_FRAGMENT_SHADER
|
|
};
|
|
|
|
|
|
public:
|
|
|
|
void preprocess(
|
|
const dynamic_shader_source_store& shader_sources
|
|
);
|
|
|
|
void compile_shaders(
|
|
const dynamic_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:
|
|
shader_handle find_shader(
|
|
const shading::shader_requirements& requirements
|
|
);
|
|
|
|
bool compile_shader(
|
|
GLenum shader_type,
|
|
std::span<const char*> source_strings,
|
|
shader_data& shader
|
|
);
|
|
|
|
private:
|
|
shader_preprocessor 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;
|
|
};
|
|
}
|