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,12 +7,12 @@ struct prioritized_metadata_comparator
bool operator()(const type& a, const type& b) const noexcept
{
if (a.geometry != b.geometry)
if (a.geometry_type != b.geometry_type)
{
return a.geometry > b.geometry;
return a.geometry_type > b.geometry_type;
}
static constexpr auto more_features = std::popcount<zgl::shading::features::generic::type>;
static constexpr auto more_features = std::popcount<assets::shader_components::stage>;
return std::ranges::lexicographical_compare(
std::array{ a.dynamic_enable, a.static_enabled },
@@ -29,7 +29,7 @@ void zgl::shader_program_manager::process(const store_type& shader_sources)
m_shader_manager.process(shader_sources);
}
void zgl::shader_program_manager::get_handles(
void zgl::shader_program_manager::fetch(
const assets::shader_source_store& shader_sources,
std::span<const shading::shader_program_requirements> requirements,
std::span<shader_program_metadata> metadata,
@@ -55,8 +55,8 @@ void zgl::shader_program_manager::get_handles(
program_meta = {};
program_handle = {};
m_shader_requirements_buffer.emplace_back(
req.geometry,
req.features
req.geometry_type,
req.components
);
}
}
@@ -66,7 +66,7 @@ void zgl::shader_program_manager::get_handles(
m_shader_metadata_buffer.resize(m_shader_requirements_buffer.size());
shader_set_buffer.clear();
m_shader_manager.get_handles(
m_shader_manager.fetch(
shader_sources,
m_shader_requirements_buffer,
m_shader_metadata_buffer,
@@ -92,7 +92,7 @@ void zgl::shader_program_manager::get_handles(
program_handle = program.handle;
program_meta = shader_program_metadata{
.geometry = shader_set_req_it->geometry,
.geometry_type = shader_set_req_it->geometry_type,
.static_enabled = shader_set_meta_it->static_enabled,
.dynamic_enable = shader_set_meta_it->dynamic_enable
};
@@ -113,14 +113,14 @@ void zgl::shader_program_manager::get_handles(
std::ranges::sort(
new_shader_programs,
prioritized_metadata_comparator{},
&shader_program_lookup_entry_type::first
&entry_type::first
);
std::ranges::inplace_merge(
m_shader_program_lookup,
m_shader_program_lookup.begin() + prev_shader_program_count,
prioritized_metadata_comparator{},
&shader_program_lookup_entry_type::first
&entry_type::first
);
}
@@ -130,23 +130,23 @@ std::optional<std::pair<zgl::shader_program_metadata, zgl::shader_program_handle
auto shader_program_it = std::ranges::lower_bound(
m_shader_program_lookup,
requirements.geometry,
requirements.geometry_type,
std::greater{},
[](const shader_program_lookup_entry_type& entry)
[](const entry_type& entry)
{
const auto& meta = entry.first;
return meta.geometry;
return meta.geometry_type;
}
);
while (
shader_program_it != m_shader_program_lookup.end() and
shader_program_it->first.geometry == requirements.geometry
shader_program_it->first.geometry_type == requirements.geometry_type
) {
const auto& [ meta, data ] = *shader_program_it;
const auto unwanted_static_features = meta.static_enabled & ~requirements.features;
const auto required_dynamic_features = requirements.features & ~meta.static_enabled;
const auto unwanted_static_features = meta.static_enabled & ~requirements.components;
const auto required_dynamic_features = requirements.components & ~meta.static_enabled;
const auto missing_dynamic_features = required_dynamic_features & ~meta.dynamic_enable;
if (unwanted_static_features == 0 and missing_dynamic_features == 0)