Two bugs in the C# layer, both reproducible against the current main (f8b5db5).#102
Open
Moayad-Rahhal wants to merge 1 commit into
Open
Conversation
- KtxTexture.LoadTexture2D: copy m_Ktx.orientation to result.orientation in the direct-format branch (was only set in the transcoding branch), fixing IsYFlipped() returning true for files explicitly authored Y-up. - KtxNativeInstance.GetGraphicsFormat: add cases for ASTC_4x4, 5x5, 6x6, 10x10, 12x12 (sRGB and UNorm) and remove them from the unsupported fall-through. Previously only ASTC_8x8 loaded; other square ASTC files hit 'untested/unsupported format'.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug 1 — Orientation metadata dropped for direct-format paths
KtxTexture.LoadTexture2D copies m_Ktx.orientation to result.orientation only inside the m_Ktx.needsTranscoding branch. The direct-format else branch never sets it, so KTX2 files that don't need transcoding (any direct GPU format, e.g. ASTC_8x8 with KTXorientation: ru) silently lose their orientation. Consumers calling result.orientation.IsYFlipped() get true for files explicitly authored Y-up.
Fix: copy the orientation in the direct-format branch as well.
Bug 2 — GetGraphicsFormat() only maps ASTC_8x8
The switch in KtxNativeInstance.GetGraphicsFormat maps only Astc8X8SrgbBlock/Astc8X8UNormBlock. The other square ASTC variants (Astc4X4, Astc5X5, Astc6X6, Astc10X10, Astc12X12) are listed in the unsupported fall-through, even though Unity's GraphicsFormat enum has all of them. Loading a KTX2 with any of those formats hits the "untested/unsupported format" error.
Fix: add the missing square ASTC cases (sRGB + UNorm) and remove them from the unsupported fall-through.
Reproduction
ktx create --format ASTC_6x6_SRGB_BLOCK --astc-quality medium
--convert-texcoord-origin bottom-left --assign-tf srgb in.png out.ktx2
ktx info out.ktx2 shows KTXorientation: ru.
Load with KtxTexture.LoadFromBytes(...) against current main → LogError "untested/unsupported format" (Bug 2).
With this PR → file loads, and result.orientation.IsYFlipped() correctly returns false (Bug 1).
Tested on Unity 2022.3 in Editor (macOS) and on Android device. Verified end-to-end against ASTC_6x6 and ASTC_8x8 files. Diff is minimal — no behavioral change for previously-working formats.