Proper X360 tiling/detiling support#13
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 92e458f633
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| { | ||
| LogVerbose(verbose, $"Tiling X360 bitmap data ({Math.Max(1, (int)destTiled.MipmapLevels)} mip level(s))..."); | ||
| byte[] linearData = await File.ReadAllBytesAsync(destinationBitmapPath, cancellationToken); | ||
| byte[] tiledData = X360TextureUtilities.GetTiled360TextureData(destTiled, linearData); |
There was a problem hiding this comment.
Swap X360 texture words before tiling
When porting TUB/BPR data to X360, ConvertFormat leaves the destination fetch constant at the GPUTEXTURE_FETCH_CONSTANT default GPUENDIAN_8IN16, and this path now marks the payload tiled. This new write-back only calls GetTiled360TextureData, which reorders blocks but never applies the new SwapEndian8in16 helper, so multi-byte texel/block data is written in PC byte order while the X360 header advertises 8-in-16 endian storage; those converted textures will be byte-swapped incorrectly on load and render corrupted.
Useful? React with 👍 / 👎.
| int blockWidth = Math.Max(1, mipWidth / blockSize); | ||
| int blockHeight = Math.Max(1, mipHeight / blockSize); |
There was a problem hiding this comment.
Use ceil block counts for compressed X360 mips
For block-compressed formats GetX360BlockInfo returns BlockSize = 4, but these calculations floor-divide the mip dimensions. A 10x10 DXT1 mip has 3x3 blocks, while this code treats it as 2x2, dropping the final block row/column and advancing subsequent mip offsets too little; the same floor division appears in ConvertToLinearTexture, so both porting to X360 and detiling existing X360 NPOT compressed textures corrupt their bitmap data. The older CalculateMipSize already uses (width + 3) / 4, which is the shape needed here too.
Useful? React with 👍 / 👎.
No description provided.