In the middle of multithreading parsers.

This commit is contained in:
zy4n
2025-03-30 22:38:06 +02:00
parent d18b40a7fc
commit 144126ee7a
80 changed files with 2904 additions and 1450 deletions

View File

@@ -7,9 +7,9 @@ namespace zgl
struct material_metadata
{
texture_handle ambient_color_texture_handle;
texture_handle diffuse_color_texture_handle;
texture_handle specular_color_texture_handle;
texture_handle specular_filter_texture_handle;
texture_handle diffuse_filter_texture_handle;
texture_handle specular_filter_texture_handle;
texture_handle shininess_texture_handle;
texture_handle alpha_texture_handle;
texture_handle bump_texture_handle;

View File

@@ -1,13 +1,15 @@
#pragma once
#include "opengl/shading/features/generic_features.hpp"
#include "assets/components/shader_components.hpp"
namespace zgl
{
struct preprocessed_shader_source_metadata
{
shading::features::generic::type static_enabled{};
shading::features::generic::type dynamic_enable{};
shading::features::generic::type string_count{};
assets::shader_components::flags static_enabled{};
assets::shader_components::flags dynamic_enable{};
// Use same integer type as it guarantees good alignment.
// (even an unsigned byte should hold the maximum number of defines.)
assets::shader_components::flags string_count{};
};
}

View File

@@ -1,16 +1,17 @@
#pragma once
#include "opengl/shading/model_geometry.hpp"
#include "opengl/shading/shader_stage.hpp"
#include "opengl/shading/features/generic_features.hpp"
#include "assets/model_geometry.hpp"
#include "assets/components/shader_components.hpp"
namespace zgl
{
struct shader_metadata
{
shading::model_geometry::types geometry;
shading::stage::types stage;
shading::features::generic::type static_enabled{};
shading::features::generic::type dynamic_enable{};
assets::model_geometry::types geometry_type;
assets::shader_components::stage stage;
assets::shader_components::flags static_enabled{};
assets::shader_components::flags dynamic_enable{};
};
}

View File

@@ -1,15 +1,16 @@
#pragma once
#include "opengl/shading/model_geometry.hpp"
#include "opengl/shading/features/generic_features.hpp"
#include "assets/model_geometry.hpp"
#include "assets/components/shader_components.hpp"
namespace zgl {
namespace zgl
{
struct shader_program_metadata
{
shading::model_geometry::types geometry;
shading::features::generic::type static_enabled{};
shading::features::generic::type dynamic_enable{};
assets::model_geometry::types geometry_type;
assets::shader_components::stage static_enabled{};
assets::shader_components::stage dynamic_enable{};
};
}

View File

@@ -1,12 +1,12 @@
#pragma once
#include "opengl/shading/features/generic_features.hpp"
#include "assets/components/shader_components.hpp"
namespace zgl
{
struct shader_set_metadata
{
shading::features::generic::type static_enabled{};
shading::features::generic::type dynamic_enable{};
assets::shader_components::flags static_enabled{};
assets::shader_components::flags dynamic_enable{};
};
}

View File

@@ -1,91 +1,18 @@
#pragma once
#include <limits>
#include <utility>
#include "assets/model_geometry.hpp"
#include "assets/components/shader_components.hpp"
#include "../shading/model_geometry.hpp"
#include "../shading/shader_stage.hpp"
#include "../shading/features/mesh_features.hpp"
#include "../shading/features/point_cloud_features.hpp"
#include "../shading/features/generic_features.hpp"
#include <algorithm>
// TODO move implementation to .ipp file
namespace zgl
{
template<typename T>
struct shader_features_set
{
T features, static_enable, dynamic_enable;
template<typename U>
[[nodiscard]] shader_features_set<U> cast() const noexcept
{
return {
.features = static_cast<U>(features),
.static_enable = static_cast<U>(static_enable),
.dynamic_enable = static_cast<U>(dynamic_enable)
};
}
// TODO this may not compile
[[nodiscard]] bool operator==(const shader_features_set& other) const noexcept = default;
};
struct shader_source_metadata
{
union combined_feature_set_type {
shader_features_set<shading::features::mesh::flags> mesh;
shader_features_set<shading::features::point_cloud::flags> point_cloud;
};
using generic_feature_set_type = shader_features_set<shading::features::generic::type>;
shading::model_geometry::types geometry;
combined_feature_set_type feature_set;
shading::stage::types stage;
[[nodiscard]] generic_feature_set_type generic_feature_set() const noexcept
{
switch (geometry)
{
case shading::model_geometry::types::mesh:
return feature_set.mesh.cast<shading::features::generic::type>();
case shading::model_geometry::types::point_cloud:
return feature_set.point_cloud.cast<shading::features::generic::type>();
default:
std::unreachable();
}
}
void from_generic_feature_set(const generic_feature_set_type& generic_feature_set) noexcept
{
switch (geometry)
{
case shading::model_geometry::types::mesh:
feature_set.mesh = generic_feature_set.cast<shading::features::mesh::flags>();
case shading::model_geometry::types::point_cloud:
feature_set.point_cloud = generic_feature_set.cast<shading::features::point_cloud::flags>();
}
std::unreachable();
}
bool operator==(const shader_source_metadata& other) const noexcept
{
if (this->stage != other.stage)
{
return false;
}
if (this->geometry != other.geometry)
{
return false;
}
return this->generic_feature_set() == other.generic_feature_set();
}
assets::model_geometry::types geometry_type;
assets::shader_components::stage stage;
assets::shader_components::flags components{};
assets::shader_components::flags static_enable{};
assets::shader_components::flags dynamic_enable{};
};
}