This commit is contained in:
ZY4N
2024-12-22 16:58:40 +01:00
parent 2704814de2
commit db8db8f9d7
161 changed files with 17102 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
#include "rendering/shader_program_lookups/mesh_lookup.hpp"
#include "util/logger.hpp" // TODO remove
#include <bitset> // 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,
shader_program::attributes::mesh::all,
shader_program::uniforms::mesh::all
);
}
std::optional<zgl::shader_program_handle> mesh_lookup::find(
requirements::mesh::flags requirements
) const {
auto capability = shader_program::capabilities::mesh::type{};
auto index = std::size_t{};
auto requirement_flags = static_cast<ztu::u32>(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 ] = shader_program::capabilities::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<unsigned long long>(static_cast<int>(capability.attributes)) });
ztu::logger::debug("uniforms reqs: %", std::bitset<32>{ static_cast<unsigned long long>(static_cast<int>(capability.uniforms)) });
return m_shader_program_lookup.find(
static_cast<ztu::u32>(capability.attributes),
static_cast<ztu::u32>(capability.uniforms),
shader_program::attributes::mesh::all
);
}
void mesh_lookup::print() {
m_shader_program_lookup.print();
}
}