48 lines
1.2 KiB
C++
48 lines
1.2 KiB
C++
#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::features::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::features::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
|
|
);
|
|
}
|
|
|
|
}
|