bugfix(textureloader): Fix faulty texture reduction implementations#2789
bugfix(textureloader): Fix faulty texture reduction implementations#2789xezon wants to merge 4 commits into
Conversation
|
| Filename | Overview |
|---|---|
| Core/Libraries/Source/WWVegas/WW3D2/textureloader.cpp | Refactored texture reduction logic into extracted helpers; fixes previously identified argument-order and signed/unsigned bugs. One logic gap remains: Apply_Mip_Reduction receives Width/Height (original, non-reduced dimensions) instead of reduced_width/reduced_height, causing its max_mip_level_count guard to compute an upper bound from the wrong (larger) base, which can silently allow too many mip levels when hardware-limit reduction is applied. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Begin_Compressed_Load] --> B[Get_Texture_Information]
B --> C[Set Width/Height to orig_width/height]
C --> D[Validate_Texture_Size on Width/Height]
D --> E[Validate_Reduction\nclamps Reduction to MipLevelCount-1\nand mip_count-1]
E --> F[Apply_Dim_Reduction\nreduced_width/height = orig >> r\ntries r=Reduction r+1 ... until HW fits]
F --> G[Apply_Mip_Reduction\nmip_level_count = mip_count - Reduction\nmax clamped by Width/Height NOT reduced_width/height]
G --> H[_Create_DX8_Texture with reduced_width/height]
H --> I[Load_Compressed_Mipmap\nwidth = Get_Width >> Reduction]
style G fill:#ffe066,stroke:#cc9900
Reviews (6): Last reviewed commit: "fixup! bugfix(textureloader): Fix faulty..." | Re-trigger Greptile
…TextureLoadTaskClass::Begin_Uncompressed_Load() (#2789)
fd662d0 to
f0e9d84
Compare
|
Bot says:
This is what the original code did and I did not encounter any issues with it so I left this behavior. The original code even has a comment there which explicitly describes this behavior. I have restored the comment now. |
f0e9d84 to
6ec79f4
Compare
6ec79f4 to
70eb9cc
Compare
|
The bot says:
This is what the original code did as well and it not clear to me why it does that and I did not observe a problem with it so I did not change it. |
Skyaero42
left a comment
There was a problem hiding this comment.
There is some hilariously bad code in the original.
This is a nice improvement.
Merge with Rebase
This change attempts to fix the faulty implementations related to texture reduction.
It has 3 commits:
The first commit removes some dead code, streamlines some variable names and simplifies some code related to texture reduction in the 3 texture load classes:
TextureLoadTaskClass,CubeTextureLoadTaskClass,VolumeTextureLoadTaskClassThe second commit removes the texture reduction code from
TextureLoadTaskClass::Begin_Uncompressed_Loadbecause the reduction was always 0 as far as I could see and the game never reduced TGA texture size.The third commit fixes and streamlines the texture reduction code in
TextureLoadTaskClass::Begin_Compressed_Load,CubeTextureLoadTaskClass::Begin_Compressed_Load,VolumeTextureLoadTaskClass::Begin_Compressed_Load. The former logic was incoherent and nonsensical. The new logic does work in so far that the binary stream texture in Generals would render correctly with an auto reduction to the lowest mip to satisfy the original 1:8 texture aspect ratio limit. No new issues have been observed. Texture reduction from Options Menu also still works.TODO