mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-25 08:30:13 +00:00
Background BLP texture pre-decoding + deferred WMO normal maps (12x streaming perf)
Move CPU-heavy BLP texture decoding from main thread to background worker threads for all hot paths: terrain M2 models, WMO doodad M2s, WMO textures, creature models, and gameobject WMOs. Each renderer (M2, WMO, Character) now accepts a pre-decoded BLP cache that loadTexture() checks before falling back to synchronous decode. Defer WMO normal/height map generation (3 per-pixel passes: luminance, box blur, Sobel) during terrain streaming finalization — this was the dominant remaining bottleneck after BLP pre-decoding. Terrain streaming stalls: 1576ms → 124ms worst case.
This commit is contained in:
parent
0313bd8692
commit
7ac990cff4
13 changed files with 573 additions and 109 deletions
|
|
@ -2325,13 +2325,27 @@ VkTexture* WMORenderer::loadTexture(const std::string& path) {
|
|||
const auto& attemptedCandidates = uniqueCandidates;
|
||||
|
||||
// Try loading all candidates until one succeeds
|
||||
// Check pre-decoded BLP cache first (populated by background worker threads)
|
||||
pipeline::BLPImage blp;
|
||||
std::string resolvedKey;
|
||||
for (const auto& c : attemptedCandidates) {
|
||||
blp = assetManager->loadTexture(c);
|
||||
if (blp.isValid()) {
|
||||
resolvedKey = c;
|
||||
break;
|
||||
if (predecodedBLPCache_) {
|
||||
for (const auto& c : uniqueCandidates) {
|
||||
auto pit = predecodedBLPCache_->find(c);
|
||||
if (pit != predecodedBLPCache_->end()) {
|
||||
blp = std::move(pit->second);
|
||||
predecodedBLPCache_->erase(pit);
|
||||
resolvedKey = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!blp.isValid()) {
|
||||
for (const auto& c : attemptedCandidates) {
|
||||
blp = assetManager->loadTexture(c);
|
||||
if (blp.isValid()) {
|
||||
resolvedKey = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!blp.isValid()) {
|
||||
|
|
@ -2369,10 +2383,10 @@ VkTexture* WMORenderer::loadTexture(const std::string& path) {
|
|||
texture->createSampler(vkCtx_->getDevice(), VK_FILTER_LINEAR, VK_FILTER_LINEAR,
|
||||
VK_SAMPLER_ADDRESS_MODE_REPEAT);
|
||||
|
||||
// Generate normal+height map from diffuse pixels
|
||||
// Generate normal+height map from diffuse pixels (skip during streaming to avoid CPU stalls)
|
||||
float nhVariance = 0.0f;
|
||||
std::unique_ptr<VkTexture> nhMap;
|
||||
if (normalMappingEnabled_ || pomEnabled_) {
|
||||
if ((normalMappingEnabled_ || pomEnabled_) && !deferNormalMaps_) {
|
||||
nhMap = generateNormalHeightMap(blp.data.data(), blp.width, blp.height, nhVariance);
|
||||
if (nhMap) {
|
||||
approxBytes *= 2; // account for normal map in budget
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue