Added parsing for dynamic_enable in lazy shader compilation.

This commit is contained in:
zy4n
2025-03-03 21:19:08 +01:00
parent fde6a2fd7b
commit e01b8c2e09
4 changed files with 49 additions and 29 deletions

View File

@@ -23,14 +23,6 @@ class shader_program_compiler
public:
// compile shader programs for given requirements
// cache shader programs with their capabilities
// store sstream for creating defines
// register shader source code
// store define types for these shaders as bitmap
void register_shader_sources(
const dynamic_shader_source_store& shader_sources
);
@@ -71,7 +63,12 @@ protected:
shader_program::metadata_type& metadata
);
[[nodiscard]] static bool parse_feature_toggles_declaration(
[[nodiscard]] static bool parse_static_enable_declaration(
std::span<const std::string_view> tokens,
shader_program::metadata_type& metadata
);
[[nodiscard]] static bool parse_dynamic_enable_declaration(
std::span<const std::string_view> tokens,
shader_program::metadata_type& metadata
);
@@ -100,7 +97,8 @@ private:
stage = 0,
geometry = 1,
features = 2,
feature_toggles = 3,
static_enable = 3,
dynamic_enable = 4,
invalid = std::numeric_limits<std::size_t>::max()
};
@@ -108,18 +106,19 @@ private:
{ "STAGE", metadata_declaration_type::stage },
{ "GEOMETRY", metadata_declaration_type::geometry },
{ "FEATURES", metadata_declaration_type::features },
{ "FEATURE_TOGGLES", metadata_declaration_type::feature_toggles }
{ "STATIC_ENABLE", metadata_declaration_type::static_enable }
{ "DYNAMIC_ENABLE", metadata_declaration_type::dynamic_enable }
};
inline static auto stage_lookup = ztu::string_lookup<shader_program::stages>{
{ "VERTEX", shader_program::stages::vertex },
{ "GEOMETRY", shader_program::stages::geometry },
{ "FRAGMENT", shader_program::stages::fragment },
inline static auto stage_lookup = ztu::string_lookup<shader_program::stage::types>{
{ "VERTEX", shader_program::stage::types::vertex },
{ "GEOMETRY", shader_program::stage::types::geometry },
{ "FRAGMENT", shader_program::stage::types::fragment },
};
inline static auto geometry_lookup = ztu::string_lookup<shader_program::geometries>{
{ "MESH", shader_program::geometries::mesh },
{ "POINT_CLOUD", shader_program::geometries::point_cloud }
inline static auto geometry_lookup = ztu::string_lookup<shader_program::geometry::types>{
{ "MESH", shader_program::geometry::types::mesh },
{ "POINT_CLOUD", shader_program::geometry::types::point_cloud }
};
inline static auto mesh_feature_lookup = []

View File

@@ -22,12 +22,12 @@ class shader_program_compiler
const dynamic_shader_source_store& shader_sources
);
void find_or_compile_shader_programs(
std::span<const Capabilities> required_capabilities,
zgl::shader_program_lookup& shader_program_lookup
void compile_shaders(
const dynamic_shader_source_store& shader_sources,
std::span<const shader_program::metadata_type> required_capabilities,
std::vector<shader_handle>& shader_handles
);
// create metadata for all sources
// get