-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor DDS loading code #80900
Refactor DDS loading code #80900
Conversation
dd568c1
to
87813ee
Compare
There's an issue with RGB10A2 files: Microsoft's official tools (DirectXTex, DirectX Texture Tool) set the files' bitmasks as R10G10B10A2, but write/read the data as B10G10R10A2 and vice-versa. Other tools such as GIMP save/read the data according to the bitmasks, which causes compatibility breakage between them. Additionally, official documentation states the data should be laid out according to the bitmasks. Should Godot support the DirectXTex version or the standard version (which it used previously)? |
38c9cd7
to
508a0d9
Compare
After doing some testing I believe this PR doesn't break compatibility with existing projects. The aforementioned issue appears to only be caused by Microsoft's tools, so I think the code should follow the standard set by other programs and the documentation. |
508a0d9
to
f34d18f
Compare
f34d18f
to
cfe9cd5
Compare
Is there a way to reconnect the dds-loading-refactor branch to this PR or should I open a new one? |
Just push to it :) |
I did, but it only updated the branch, not the PR |
@BlueCube3310 Your last push doesn't contain any changes compared to the master branch. That's why the PR auto-closed when you pushed the branch. |
Hmm, interesting, your commit showed up once the PR was reopened. Well, all good then! |
2a49c0a
to
9ec9e35
Compare
9ec9e35
to
0b59f27
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Tested locally and confirm it looks the same as master with the provided textures. The new code is a significant improvement.
0b59f27
to
f5fe58c
Compare
f5fe58c
to
e6766da
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving on style 🎉
Thanks! |
First of all, #80862 should be merged before this, as this PR is still requires some testing.After testing, this PR doesn't seem to cause issues, and the changes done haven't altered the code in a way that would affect existing projects, so it most likely doesn't break compatibility.
The code for the DDS loading module hasn't been updated much since Godot 1.0, which makes it difficult to fix/add new features. This PR attempts to clean it up a little.
The biggest issue is the large amount of unnecessary repeated conditions while checking the format. For instance, the code checks for the FourCC flag six times in total, and for RGB flags - seven times. This not only makes the code difficult to evaluate, but also adds unneeded repeated checks.
There is also some leftover code intended to be used for palette-based image formats, but given that this feature has been broken for a long time and the indexed format isn't considered official, removing it for now seems to be the best course of action.
Another, smaller issue is the amount of commented-out debug print lines, which also contribute to the code being hard to read.
The idea I have is to 'split' the format-checking code into 3 blocks: FourCC formats, channel-masked formats, and other miscellaneous formats via nested if-statements. This serves to make the code easier to read, and it also decreases the amount of checks the engine does, improving the performance.
Another addition is the DDSFourCC enum, which contains the possible FourCC values. In the future, this could make it easier to add support for more FourCC formats, such as DX10 or float-based formats which are referenced by number, rather than by signature.
As stated before, this PR is a work-in-progress, so it may cause issues with existing projects. Extensive testing is required in order to ensure it doesn't affect anything.An MRP containing several DDS files with different formats for testing: dds_test_images.zip
All of these images can be imported correctly by 4.2-dev3 (save for l8 and l8a8 images, but that is fixed by #81134)