Skip to content

bugfix(textureloader): Lift hardcoded texture aspect ratio limit of 1:8 to allow load all textures with modern gpu#2788

Open
xezon wants to merge 2 commits into
TheSuperHackers:mainfrom
xezon:xezon/fix-texture-aspect-ratio-limit
Open

bugfix(textureloader): Lift hardcoded texture aspect ratio limit of 1:8 to allow load all textures with modern gpu#2788
xezon wants to merge 2 commits into
TheSuperHackers:mainfrom
xezon:xezon/fix-texture-aspect-ratio-limit

Conversation

@xezon

@xezon xezon commented Jun 13, 2026

Copy link
Copy Markdown

This change lifts the hardcoded texture aspect ratio limit of 1:8 to allow load all textures with modern gpu.

The 1:8 texture limit was a concern on gpu's 25 years ago. DX8 caps has a flag to test the aspect ratio limit. With the limit lifted, the Binary Stream texture (1:16 aspect) of Lotus and Patriots renders normally.

@xezon xezon added Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour Rendering Is Rendering related labels Jun 13, 2026
@greptile-apps

greptile-apps Bot commented Jun 13, 2026

Copy link
Copy Markdown

Greptile Summary

Replaces the hardcoded 1:8 texture aspect ratio cap in Validate_Texture_Size with the actual hardware limit reported via D3DCAPS8::MaxTextureAspectRatio, and skips enforcement entirely when the GPU reports 0 (meaning no limit). This unblocks loading of wide-ratio textures such as the Binary Stream texture (1:16) used by Lotus and Patriots on modern GPUs.

  • The aspect ratio guard is now conditionally applied only when maxTextureAspectRatio != 0, correctly matching the DX8 caps semantics where 0 signals an unconstrained GPU.
  • The inner while-loop logic is unchanged; it now divides by maxTextureAspectRatio instead of the literal 8, so all existing behaviour on legacy hardware that reports a non-zero limit is preserved.

Confidence Score: 5/5

Safe to merge — the change is narrow, well-scoped, and correctly delegates the aspect ratio policy to the hardware.

The change reads the hardware-reported MaxTextureAspectRatio from D3DCAPS8 and skips enforcement when the GPU reports 0, which matches the documented DirectX 8 semantics. Legacy hardware that reports a non-zero limit still gets the same while-loop enforcement as before, just against the real cap instead of the literal 8. The surrounding caps on MaxTextureWidth and MaxTextureHeight remain untouched, so there is no risk of the doubling loops running unboundedly on realistic texture dimensions.

No files require special attention.

Important Files Changed

Filename Overview
Core/Libraries/Source/WWVegas/WW3D2/textureloader.cpp Replaces hardcoded aspect ratio limit of 8 with GPU-reported dx8caps.MaxTextureAspectRatio, skipping enforcement when the value is 0 (no hardware limit); a whitespace-only fix is also included.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Validate_Texture_Size called] --> B[Round width/height/depth up to power of two]
    B --> C[Cap width to MaxTextureWidth]
    C --> D[Cap height to MaxTextureHeight]
    D --> E[Cap depth to MaxVolumeExtent]
    E --> F{maxTextureAspectRatio == 0?}
    F -- Yes / No hardware limit --> G[Skip aspect ratio enforcement]
    F -- No / Limit exists --> H{width > height?}
    H -- Yes --> I[while width/height > maxTextureAspectRatio double height]
    H -- No --> J[while height/width > maxTextureAspectRatio double width]
    I --> K[Write back width/height/depth]
    J --> K
    G --> K
Loading

Reviews (2): Last reviewed commit: "Fix type" | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gen Relates to Generals Minor Severity: Minor < Major < Critical < Blocker Rendering Is Rendering related ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Binarystream texture is not drawing in Generals

1 participant