fixes
This commit is contained in:
58
source/rendering/shader_program_lookups/mesh_lookup.cpp
Normal file
58
source/rendering/shader_program_lookups/mesh_lookup.cpp
Normal 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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
#include "rendering/shader_program_lookups/point_cloud_lookup.hpp"
|
||||
|
||||
namespace rendering::shader_program_lookups
|
||||
{
|
||||
|
||||
void point_cloud_lookup::add(
|
||||
const zgl::shader_program_handle& shader_program_handle
|
||||
) {
|
||||
m_program_lookup.add(
|
||||
shader_program_handle,
|
||||
shader_program::attributes::point_cloud::all,
|
||||
shader_program::uniforms::point_cloud::all
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
std::optional<zgl::shader_program_handle> point_cloud_lookup::find(
|
||||
requirements::point_cloud::flags requirements
|
||||
) const {
|
||||
auto capability = shader_program::capabilities::point_cloud::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::point_cloud::all[index].shader_program_requirement_index;
|
||||
const auto& [ attributes, uniforms ] = shader_program::capabilities::point_cloud::all[shader_requirements_index];
|
||||
capability.attributes |= attributes;
|
||||
capability.uniforms |= uniforms;
|
||||
}
|
||||
|
||||
requirement_flags >>= 1;
|
||||
++index;
|
||||
}
|
||||
|
||||
return m_program_lookup.find(
|
||||
static_cast<ztu::u32>(capability.attributes),
|
||||
static_cast<ztu::u32>(capability.uniforms),
|
||||
shader_program::attributes::point_cloud::all
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user