#include "rendering/shader_program_lookups/mesh_lookup.hpp" #include "util/logger.hpp" // TODO remove #include // TODO remove namespace rendering::shader_program_lookups { void mesh_lookup::add( const zgl::shader_program_handle& shader_program_handle ) { m_shader_program_lookup.add( shader_program_handle, shading::attributes::mesh::all, shading::uniforms::mesh::all ); } std::optional mesh_lookup::find( requirements::mesh::flags requirements ) const { auto capability = shading::features::mesh::type{}; auto index = std::size_t{}; auto requirement_flags = static_cast(requirements); while (requirement_flags) { if (requirement_flags & 1) { const auto shader_requirements_index = requirements::mesh::all[index].shader_program_requirement_index; const auto& [ attributes, uniforms ] = shading::features::mesh::all[shader_requirements_index]; capability.attributes |= attributes; capability.uniforms |= uniforms; } requirement_flags >>= 1; ++index; } // TODO if not textured and not colored add ucolor "for free" ztu::logger::debug("attributes reqs: %", std::bitset<32>{ static_cast(static_cast(capability.attributes)) }); ztu::logger::debug("uniforms reqs: %", std::bitset<32>{ static_cast(static_cast(capability.uniforms)) }); return m_shader_program_lookup.find( static_cast(capability.attributes), static_cast(capability.uniforms), shading::attributes::mesh::all ); } void mesh_lookup::print() { m_shader_program_lookup.print(); } }