bugfix(textureloader): Fix faulty texture reduction implementations#2789
Conversation
|
| Filename | Overview |
|---|---|
| Core/Libraries/Source/WWVegas/WW3D2/textureloader.cpp | Refactors texture reduction logic into shared helpers used by all three loader classes; fixes several pre-existing bugs but introduces a new one: Apply_Mip_Reduction is passed the pre-reduction Width/Height instead of reduced_width/reduced_height, allowing MipLevelCount to exceed what the reduced D3D texture can hold. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Begin_Compressed_Load] --> B[Get_Texture_Information\norig_width, orig_height, orig_reduction, orig_mip_count]
B --> C[Validate_Texture_Size\nWidth = orig_width → hw-clamped]
C --> D[Validate_Reduction\nclamp Reduction to mip bounds]
D --> E[Apply_Dim_Reduction\nreduced_width/height = max orig >> r 4u\nsets Reduction = r]
E --> F[Apply_Mip_Reduction\nMipLevelCount = mip_count - Reduction\ncaps at max_mip based on Width/Height]
F -->|Bug: should use reduced_width/height| G[_Create_DX8_Texture\nreduced_width x reduced_height\nMipLevelCount mips]
G --> H[Load_Compressed_Mipmap\nwidth = Width >> Reduction\ncopies DDS data per level]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[Begin_Compressed_Load] --> B[Get_Texture_Information\norig_width, orig_height, orig_reduction, orig_mip_count]
B --> C[Validate_Texture_Size\nWidth = orig_width → hw-clamped]
C --> D[Validate_Reduction\nclamp Reduction to mip bounds]
D --> E[Apply_Dim_Reduction\nreduced_width/height = max orig >> r 4u\nsets Reduction = r]
E --> F[Apply_Mip_Reduction\nMipLevelCount = mip_count - Reduction\ncaps at max_mip based on Width/Height]
F -->|Bug: should use reduced_width/height| G[_Create_DX8_Texture\nreduced_width x reduced_height\nMipLevelCount mips]
G --> H[Load_Compressed_Mipmap\nwidth = Width >> Reduction\ncopies DDS data per level]
Reviews (8): Last reviewed commit: "bugfix(textureloader): Fix faulty implem..." | Re-trigger Greptile
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.
13ce1a1 to
dbfdc77
Compare
…TextureLoadTaskClass::Begin_Uncompressed_Load() (#2789)
dbfdc77 to
32880a2
Compare
…TextureLoadTaskClass::Begin_Uncompressed_Load() (#2789)
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