Files
Z3D/include/opengl/shader_program_lookup.hpp
2024-12-22 16:58:40 +01:00

44 lines
1.2 KiB
C++

#pragma once
#include "opengl/handles/shader_program_handle.hpp"
#include <optional>
#include <vector>
namespace zgl {
class shader_program_lookup
{
public:
void add(
const shader_program_handle& shader_program_handle,
std::span<const shader_program_variable> all_attributes,
std::span<const shader_program_variable> all_uniforms
);
[[nodiscard]] std::optional<shader_program_handle> find(
shader_program_handle::attribute_support_type attributes,
shader_program_handle::uniform_support_type uniforms,
std::span<const shader_program_variable> all_attributes
) const;
void print();
private:
using attribute_locations_type = ztu::u32;
[[nodiscard]] static attribute_locations_type attribute_location_flags(
shader_program_handle::attribute_support_type attributes,
std::span<const shader_program_variable> all_attributes
);
struct attribute_entry_type
{
shader_program_handle::attribute_support_type attributes;
attribute_locations_type locations; // Do not go past location 31!!!
};
std::vector<shader_program_handle::uniform_support_type> m_mesh_shader_program_uniforms;
std::vector<attribute_entry_type> m_mesh_shader_program_attributes;
std::vector<shader_program_handle> m_mesh_shader_programs;
};
}