fix some crashes (how) and bitset wierdness
Some checks are pending
ContinuousDelivery / linux-ubuntu (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousDelivery / windows (push) Waiting to run
ContinuousDelivery / windows-asan (push) Waiting to run
ContinuousDelivery / release (push) Blocked by required conditions
ContinuousIntegration / linux (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousIntegration / macos (push) Waiting to run
ContinuousIntegration / windows (push) Waiting to run
Some checks are pending
ContinuousDelivery / linux-ubuntu (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Waiting to run
ContinuousDelivery / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousDelivery / windows (push) Waiting to run
ContinuousDelivery / windows-asan (push) Waiting to run
ContinuousDelivery / release (push) Blocked by required conditions
ContinuousIntegration / linux (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:arm64-v8a vcpkg_toolkit:arm64-android]) (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:armeabi-v7a vcpkg_toolkit:arm-neon-android]) (push) Waiting to run
ContinuousIntegration / android (map[ndk_abi:x86_64 vcpkg_toolkit:x64-android]) (push) Waiting to run
ContinuousIntegration / macos (push) Waiting to run
ContinuousIntegration / windows (push) Waiting to run
This commit is contained in:
parent
876f482391
commit
bb510b685a
@ -51,14 +51,13 @@ std::optional<TextureEntry> BitsetImageLoader::haveToTexture(TextureUploaderI& t
|
|||||||
|
|
||||||
TextureEntry new_entry;
|
TextureEntry new_entry;
|
||||||
new_entry.timestamp_last_rendered = Message::getTimeMS();
|
new_entry.timestamp_last_rendered = Message::getTimeMS();
|
||||||
new_entry.current_texture = 0;
|
|
||||||
new_entry.width = have.size_bits();
|
new_entry.width = have.size_bits();
|
||||||
new_entry.height = 1;
|
new_entry.height = 1;
|
||||||
|
|
||||||
const auto n_t = tu.upload(static_cast<uint8_t*>(conv_surf->pixels), conv_surf->w, conv_surf->h, TextureUploaderI::RGBA);
|
const auto n_t = tu.upload(static_cast<uint8_t*>(conv_surf->pixels), conv_surf->w, conv_surf->h, TextureUploaderI::RGBA);
|
||||||
assert(n_t != 0);
|
assert(n_t != 0);
|
||||||
new_entry.textures.push_back(n_t);
|
new_entry.textures.push_back(n_t);
|
||||||
new_entry.frame_duration.push_back(0);
|
new_entry.frame_duration.push_back(1);
|
||||||
|
|
||||||
std::cout << "BIL: genereated bitset image o:" << entt::to_integral(o.entity()) << "\n";
|
std::cout << "BIL: genereated bitset image o:" << entt::to_integral(o.entity()) << "\n";
|
||||||
|
|
||||||
@ -74,13 +73,13 @@ BitsetImageLoader::BitsetImageLoader(void) {
|
|||||||
TextureLoaderResult BitsetImageLoader::load(TextureUploaderI& tu, ObjectHandle o) {
|
TextureLoaderResult BitsetImageLoader::load(TextureUploaderI& tu, ObjectHandle o) {
|
||||||
if (!static_cast<bool>(o)) {
|
if (!static_cast<bool>(o)) {
|
||||||
std::cerr << "BIL error: trying to load invalid object\n";
|
std::cerr << "BIL error: trying to load invalid object\n";
|
||||||
return {std::nullopt};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!o.any_of<ObjComp::F::LocalHaveBitset, ObjComp::F::RemoteHaveBitset>()) {
|
if (!o.any_of<ObjComp::F::LocalHaveBitset, ObjComp::F::RemoteHaveBitset>()) {
|
||||||
// after completion, this is called until the texture times out
|
// after completion, this is called until the texture times out
|
||||||
//std::cout << "BIL: no local have bitset\n";
|
//std::cout << "BIL: no have bitset\n";
|
||||||
return {std::nullopt};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (o.all_of<ObjComp::F::LocalHaveBitset>()) {
|
if (o.all_of<ObjComp::F::LocalHaveBitset>()) {
|
||||||
@ -91,7 +90,8 @@ TextureLoaderResult BitsetImageLoader::load(TextureUploaderI& tu, ObjectHandle o
|
|||||||
auto& list = o.get<ObjComp::F::RemoteHaveBitset>().others;
|
auto& list = o.get<ObjComp::F::RemoteHaveBitset>().others;
|
||||||
if (list.empty()) {
|
if (list.empty()) {
|
||||||
std::cout << "BIL: remote set list empty\n";
|
std::cout << "BIL: remote set list empty\n";
|
||||||
return {std::nullopt};
|
_tmp_bitset = {8};
|
||||||
|
return {haveToTexture(tu, _tmp_bitset, o)};
|
||||||
}
|
}
|
||||||
const auto& first_entry = list.begin()->second;
|
const auto& first_entry = list.begin()->second;
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ TextureLoaderResult BitsetImageLoader::load(TextureUploaderI& tu, ObjectHandle o
|
|||||||
return {haveToTexture(tu, _tmp_bitset, o)};
|
return {haveToTexture(tu, _tmp_bitset, o)};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {std::nullopt};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<TextureEntry> BitsetImageLoader::load(TextureUploaderI& tu, ObjectContactSub ocs) {
|
std::optional<TextureEntry> BitsetImageLoader::load(TextureUploaderI& tu, ObjectContactSub ocs) {
|
||||||
|
@ -5,8 +5,11 @@
|
|||||||
#include <entt/container/dense_map.hpp>
|
#include <entt/container/dense_map.hpp>
|
||||||
#include <entt/container/dense_set.hpp>
|
#include <entt/container/dense_set.hpp>
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include <vector>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
struct TextureEntry {
|
struct TextureEntry {
|
||||||
uint32_t width {0};
|
uint32_t width {0};
|
||||||
@ -163,7 +166,10 @@ struct TextureCache {
|
|||||||
const uint64_t ts_next = te.doAnimation(ts_now);
|
const uint64_t ts_next = te.doAnimation(ts_now);
|
||||||
te.rendered_this_frame = false;
|
te.rendered_this_frame = false;
|
||||||
ts_min_next = std::min(ts_min_next, ts_next);
|
ts_min_next = std::min(ts_min_next, ts_next);
|
||||||
} else if (_cache.size() > min_count_before_purge && ts_now - te.timestamp_last_rendered >= ms_before_purge) {
|
} else if (
|
||||||
|
_cache.size() > min_count_before_purge &&
|
||||||
|
ts_now - te.timestamp_last_rendered >= ms_before_purge
|
||||||
|
) {
|
||||||
to_purge.push_back(key);
|
to_purge.push_back(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,31 +184,38 @@ struct TextureCache {
|
|||||||
|
|
||||||
void invalidate(const std::vector<KeyType>& to_purge) {
|
void invalidate(const std::vector<KeyType>& to_purge) {
|
||||||
for (const auto& key : to_purge) {
|
for (const auto& key : to_purge) {
|
||||||
|
if (_to_load.count(key)) {
|
||||||
|
// TODO: only remove if not keep trying
|
||||||
|
_to_load.erase(key);
|
||||||
|
}
|
||||||
if (_cache.count(key)) {
|
if (_cache.count(key)) {
|
||||||
for (const auto& tex_id : _cache.at(key).textures) {
|
for (const auto& tex_id : _cache.at(key).textures) {
|
||||||
_tu.destroy(tex_id);
|
_tu.destroy(tex_id);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_cache.erase(key);
|
_cache.erase(key);
|
||||||
_to_load.erase(key);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns true if there is still work queued up
|
// returns true if there is still work queued up
|
||||||
bool workLoadQueue(void) {
|
bool workLoadQueue(void) {
|
||||||
auto it = _to_load.begin();
|
auto it = _to_load.cbegin();
|
||||||
for (; it != _to_load.end(); it++) {
|
for (; it != _to_load.cend(); it++) {
|
||||||
if (_cache.count(*it)) {
|
|
||||||
auto new_entry_opt = _l.load(_tu, *it);
|
auto new_entry_opt = _l.load(_tu, *it);
|
||||||
|
if (_cache.count(*it)) {
|
||||||
if (new_entry_opt.texture.has_value()) {
|
if (new_entry_opt.texture.has_value()) {
|
||||||
auto old_entry = _cache.at(*it);
|
auto old_entry = _cache.at(*it); // copy
|
||||||
|
assert(!old_entry.textures.empty());
|
||||||
for (const auto& tex_id : old_entry.textures) {
|
for (const auto& tex_id : old_entry.textures) {
|
||||||
_tu.destroy(tex_id);
|
_tu.destroy(tex_id);
|
||||||
}
|
}
|
||||||
auto [new_it, _] = _cache.insert_or_assign(*it, new_entry_opt.texture.value());
|
|
||||||
//new_it->second.current_texture = old_entry.current_texture; // ??
|
_cache.erase(*it);
|
||||||
new_it->second.rendered_this_frame = old_entry.rendered_this_frame;
|
auto& new_entry = _cache[*it] = new_entry_opt.texture.value();
|
||||||
new_it->second.timestamp_last_rendered = old_entry.timestamp_last_rendered;
|
// TODO: make update interface and let loader handle this
|
||||||
|
//new_entry.current_texture = old_entry.current_texture; // ??
|
||||||
|
new_entry.rendered_this_frame = old_entry.rendered_this_frame;
|
||||||
|
new_entry.timestamp_last_rendered = old_entry.timestamp_last_rendered;
|
||||||
|
|
||||||
it = _to_load.erase(it);
|
it = _to_load.erase(it);
|
||||||
|
|
||||||
@ -213,9 +226,9 @@ struct TextureCache {
|
|||||||
it = _to_load.erase(it);
|
it = _to_load.erase(it);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto new_entry_opt = _l.load(_tu, *it);
|
|
||||||
if (new_entry_opt.texture.has_value()) {
|
if (new_entry_opt.texture.has_value()) {
|
||||||
_cache.emplace(*it, new_entry_opt.texture.value());
|
_cache.emplace(*it, new_entry_opt.texture.value());
|
||||||
|
_cache.at(*it).rendered_this_frame = true; // ?
|
||||||
it = _to_load.erase(it);
|
it = _to_load.erase(it);
|
||||||
|
|
||||||
// TODO: not a good idea?
|
// TODO: not a good idea?
|
||||||
@ -227,8 +240,8 @@ struct TextureCache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// peak
|
// peek
|
||||||
return it != _to_load.end();
|
return it != _to_load.cend();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user