mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
Defer normal map generation to reduce GPU model upload stalls by ~50%
Some checks are pending
Build / Build (arm64) (push) Waiting to run
Build / Build (x86-64) (push) Waiting to run
Build / Build (macOS arm64) (push) Waiting to run
Build / Build (windows-arm64) (push) Waiting to run
Build / Build (windows-x86-64) (push) Waiting to run
Security / CodeQL (C/C++) (push) Waiting to run
Security / Semgrep (push) Waiting to run
Security / Sanitizer Build (ASan/UBSan) (push) Waiting to run
Some checks are pending
Build / Build (arm64) (push) Waiting to run
Build / Build (x86-64) (push) Waiting to run
Build / Build (macOS arm64) (push) Waiting to run
Build / Build (windows-arm64) (push) Waiting to run
Build / Build (windows-x86-64) (push) Waiting to run
Security / CodeQL (C/C++) (push) Waiting to run
Security / Semgrep (push) Waiting to run
Security / Sanitizer Build (ASan/UBSan) (push) Waiting to run
Each loadTexture call was generating a normal/height map inline (3 full-image passes: luminance + blur + Sobel). For models with 15-20 textures this added 30-40ms to the 70ms model upload. Now deferred to a per-frame budget (2/frame in-game, 10/frame during load screen). Models render without POM until their normal maps are ready.
This commit is contained in:
parent
faca22ac5f
commit
24f2ec75ec
3 changed files with 62 additions and 9 deletions
|
|
@ -12,6 +12,7 @@
|
|||
#include <string>
|
||||
#include <utility>
|
||||
#include <future>
|
||||
#include <deque>
|
||||
|
||||
namespace wowee {
|
||||
namespace pipeline { class AssetManager; }
|
||||
|
|
@ -278,6 +279,7 @@ private:
|
|||
uint64_t lastUse = 0;
|
||||
bool hasAlpha = false;
|
||||
bool colorKeyBlack = false;
|
||||
bool normalMapPending = false; // deferred normal map generation
|
||||
};
|
||||
std::unordered_map<std::string, TextureCacheEntry> textureCache;
|
||||
std::unordered_map<VkTexture*, bool> textureHasAlphaByPtr_;
|
||||
|
|
@ -302,6 +304,17 @@ private:
|
|||
std::unique_ptr<VkTexture> generateNormalHeightMap(
|
||||
const uint8_t* pixels, uint32_t width, uint32_t height, float& outVariance);
|
||||
|
||||
// Deferred normal map generation — avoids stalling loadModel
|
||||
struct PendingNormalMap {
|
||||
std::string cacheKey;
|
||||
std::vector<uint8_t> pixels; // RGBA pixel data
|
||||
uint32_t width, height;
|
||||
};
|
||||
std::deque<PendingNormalMap> pendingNormalMaps_;
|
||||
public:
|
||||
void processPendingNormalMaps(int budget = 2);
|
||||
private:
|
||||
|
||||
// Normal mapping / POM settings
|
||||
bool normalMappingEnabled_ = true;
|
||||
float normalMapStrength_ = 0.8f;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue