std140 implementation

This commit is contained in:
ZY4N
2025-03-27 19:47:32 +01:00
parent 70893c083b
commit 6f60cc11c8
45 changed files with 789 additions and 234 deletions

View File

@@ -4,9 +4,9 @@
#include "opengl/error.hpp"
#include "opengl/type_utils.hpp"
void zgl::mesh_index_buffer_manager::process(const assets::data_stores& stores)
void zgl::mesh_index_buffer_manager::process(const store_type& meshes)
{
for (const auto& [ id, mesh ] : stores.meshes)
for (const auto& [ id, mesh ] : meshes)
{
if (not m_resource_manager.has_resource(id))
{

View File

@@ -2,12 +2,12 @@
#include "util/logger.hpp"
#include "opengl/error.hpp"
#include "opengl/vertex_buffer_utils.hpp"
#include "opengl/type_utils.hpp"
void zgl::mesh_vertex_buffer_manager::process(const assets::data_stores& stores)
void zgl::mesh_vertex_buffer_manager::process(const store_type& meshes)
{
for (const auto& [ id, mesh ] : stores.meshes)
for (const auto& [ id, mesh ] : meshes)
{
if (not m_resource_manager.has_resource(id))
{
@@ -30,16 +30,10 @@ void zgl::mesh_vertex_buffer_manager::process(const assets::data_stores& stores)
m_byte_buffer.clear();
std::apply(
[&](const auto&... component_buffers)
{
vertex_buffer_utils::interlace(
m_byte_buffer,
mesh.component_flags,
mesh.vertex_count,
component_buffers...
);
},
type_utils::interlace_vertex_buffer(
m_byte_buffer,
mesh.component_flags,
mesh.vertex_count,
mesh.vertex_component_arrays
);

View File

@@ -2,12 +2,12 @@
#include "util/logger.hpp"
#include "opengl/error.hpp"
#include "opengl/vertex_buffer_utils.hpp"
#include "opengl/type_utils.hpp"
void zgl::point_cloud_vertex_buffer_manager::process(const assets::data_stores& stores)
void zgl::point_cloud_vertex_buffer_manager::process(const store_type& point_clouds)
{
for (const auto& [ id, point_cloud ] : stores.point_clouds)
for (const auto& [ id, point_cloud ] : point_clouds)
{
if (not m_resource_manager.has_resource(id))
{
@@ -30,16 +30,10 @@ void zgl::point_cloud_vertex_buffer_manager::process(const assets::data_stores&
m_byte_buffer.clear();
std::apply(
[&](const auto&... component_buffers)
{
vertex_buffer_utils::interlace(
m_byte_buffer,
point_cloud.vertex_component_flags,
point_cloud.point_count,
component_buffers...
);
},
type_utils::interlace_vertex_buffer(
m_byte_buffer,
point_cloud.vertex_component_flags,
point_cloud.point_count,
point_cloud.vertex_component_arrays
);

View File

@@ -79,6 +79,11 @@ std::optional<std::pair<zgl::shader_metadata, zgl::shader_handle>> zgl::shader_m
return std::nullopt;
}
void zgl::shader_manager::process(const store_type& shader_sources)
{
m_preprocessor.process(shader_sources);
}
void zgl::shader_manager::get_handles(
const assets::shader_source_store& shader_sources,
std::span<const shading::shader_set_requirements> requirements,
@@ -256,9 +261,3 @@ bool zgl::shader_manager::compile_shader(
return true;
}
void zgl::shader_manager::process(
const assets::data_stores& stores
) {
m_preprocessor.process(stores);
}

View File

@@ -24,10 +24,9 @@ struct prioritized_metadata_comparator
}
};
void zgl::shader_program_manager::process(
const assets::data_stores& stores
) {
m_shader_manager.preprocess(stores);
void zgl::shader_program_manager::process(const store_type& shader_sources)
{
m_shader_manager.process(shader_sources);
}
void zgl::shader_program_manager::get_handles(

View File

@@ -76,12 +76,11 @@ private:
void zgl::shader_source_manager::process(
const assets::data_stores& stores
) {
void zgl::shader_source_manager::process(const store_type& shader_sources)
{
namespace language = shading::shader_metadata_language;
for (const auto& [ id, shader_source ] : stores.shader_sources)
for (const auto& [ id, shader_source ] : shader_sources)
{
m_value_token_buffer.clear();
m_declaration_token_count_buffer.clear();

View File

@@ -5,12 +5,11 @@
#include "opengl/error.hpp"
void zgl::texture_manager::process(
const assets::data_stores& stores
) {
void zgl::texture_manager::process(const store_type& textures)
{
m_texture_buffer.clear();
for (const auto& [ id, texture ] : stores.textures)
for (const auto& [ id, texture ] : textures)
{
if (not m_resource_manager.has_resource(id))
{

View File

@@ -9,7 +9,7 @@ namespace zgl
{
shader_program_handle::attribute_support_type shader_program_handle::check_attribute_support(
const std::span<const shader_program_variable> attributes
const std::span<const shader_uniform> attributes
) const {
auto attribute_candidates = attribute_support_type{};
@@ -76,7 +76,7 @@ shader_program_handle::attribute_support_type shader_program_handle::check_attri
}
shader_program_handle::uniform_support_type shader_program_handle::check_uniform_support(
const std::span<const shader_program_variable> uniforms
const std::span<const shader_uniform> uniforms
) const {
auto uniform_candidates = uniform_support_type{};

View File

@@ -17,7 +17,7 @@ inline void shader_program_handle::unbind()
glUseProgram(0);
}
template<shader_program_variable::info_type VariableInfo, typename T>
template<shader_uniform::info_type VariableInfo, typename T>
void shader_program_handle::set_uniform(const T& value) const
{
if constexpr (std::same_as<T, glm::mat4x4>)

View File

@@ -11,8 +11,8 @@ namespace zgl
void shader_program_lookup::add(
const shader_program_handle& shader_program_handle,
const std::span<const shader_program_variable> all_attributes,
const std::span<const shader_program_variable> all_uniforms
const std::span<const shader_uniform> all_attributes,
const std::span<const shader_uniform> all_uniforms
) {
const auto attributes = shader_program_handle.check_attribute_support(all_attributes);
const auto uniforms = shader_program_handle.check_uniform_support(all_uniforms);
@@ -72,7 +72,7 @@ void shader_program_lookup::add(
std::optional<shader_program_handle> shader_program_lookup::find(
shader_program_handle::attribute_support_type attributes,
shader_program_handle::uniform_support_type uniforms,
const std::span<const shader_program_variable> all_attributes
const std::span<const shader_uniform> all_attributes
) const {
const auto lower_uniform = std::ranges::lower_bound(
@@ -158,7 +158,7 @@ std::optional<shader_program_handle> shader_program_lookup::find(
shader_program_lookup::attribute_locations_type shader_program_lookup::attribute_location_flags(
shader_program_handle::attribute_support_type attributes,
std::span<const shader_program_variable> all_attributes
std::span<const shader_uniform> all_attributes
) {
auto location_flags = ztu::u32{ 0 };