Further shader compilation development.

This commit is contained in:
zy4n
2025-03-22 17:40:08 +01:00
parent e01b8c2e09
commit 510398423a
45 changed files with 1567 additions and 1097 deletions

View File

@@ -0,0 +1,13 @@
#pragma once
#include "opengl/shading/features/generic_features.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{};
};
}

View File

@@ -0,0 +1,16 @@
#pragma once
#include "opengl/shading/model_geometry.hpp"
#include "opengl/shading/shader_stage.hpp"
#include "opengl/shading/features/generic_features.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{};
};
}

View File

@@ -0,0 +1,14 @@
#pragma once
#include "opengl/shading/model_geometry.hpp"
#include "opengl/shading/shader_stage.hpp"
#include "opengl/shading/features/generic_features.hpp"
namespace zgl
{
struct shader_set_metadata
{
shading::features::generic::type static_enabled{};
shading::features::generic::type dynamic_enable{};
};
}

View File

@@ -0,0 +1,91 @@
#pragma once
#include <limits>
#include <utility>
#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();
}
};
}