Skip to content

Add DXT1-5 decompression on ARM#16698

Merged
kd-11 merged 5 commits into
RPCS3:masterfrom
ginkage:master
Feb 20, 2025
Merged

Add DXT1-5 decompression on ARM#16698
kd-11 merged 5 commits into
RPCS3:masterfrom
ginkage:master

Conversation

@ginkage
Copy link
Copy Markdown
Contributor

@ginkage ginkage commented Feb 11, 2025

This is for #16542 — I went ahead and implemented the software texture decompression on ARM.

I've tested this with libmali, and it works beautifully, I was able to run a few (simple) games in 720p full-speed (e.g. Demon's Souls at 30 fps) on my Rock 5A. I've made it a blanket change for all AARCH64 (otherwise propagating the corresponding caps would be a pain), but I do believe that it could even benefit the Mesa driver: that is, instead of doing a texture copy (rpcs3 to driver) followed by decompression (on the driver side), we can decompress directly to the driver's memory, skipping the copy step.

The library I used for decompression, bcdec, is one of the fastest out there (see e.g. https://aras-p.info/blog/2022/06/23/Comparing-BCn-texture-decoders/) and is available with an "Unlicense" (basically, public domain), not to mention the code is pretty compact.

I've also added the new driver enumeration, just in case...

Note that I was unable to verify the OpenGL changes, though I did mirror the said changes, just in case: even Raspberry Pi 5 can't run RPCS3 with OpenGL (fails to create context), and I doubt anyone in their right mind will ever try using RPCS3 without a Vulkan backend on ARM, so this shouldn't matter that much. But, of course, all changes were made sure to be exclusively ARM-specific.

@AniLeo
Copy link
Copy Markdown
Member

AniLeo commented Feb 11, 2025

Raspberry Pi 5 can't run RPCS3 with OpenGL

It can, you have to override feature level to 4.5. Our entire RPI5 showcase is done on OpenGL.

@AniLeo AniLeo requested a review from kd-11 February 11, 2025 20:39
@ginkage
Copy link
Copy Markdown
Contributor Author

ginkage commented Feb 11, 2025

It can, you have to override feature level to 4.5.

Ah, interesting! Alas, on my RPi5, when I run with MESA_GL_VERSION_OVERRIDE=4.5, this build https://github.com/RPCS3/rpcs3-binaries-linux-arm64/releases/tag/build-cd87a646219024b136f7cc4d0ceeb1a19d5c43ad doesn't quite work. The game launches, but only shows black screen. Am I missing something else?

@ginkage
Copy link
Copy Markdown
Contributor Author

ginkage commented Feb 11, 2025

Oh, you were also using Arch Linux (I'm guessing, for more up-to-date drivers, right?), rather than Raspberry Pi OS...
I guess I should follow suit for testing with OpenGL on RPi5.

Copy link
Copy Markdown
Contributor

@kd-11 kd-11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made it a blanket change for all AARCH64 (otherwise propagating the corresponding caps would be a pain), but I do believe that it could even benefit the Mesa driver: that is, instead of doing a texture copy (rpcs3 to driver) followed by decompression (on the driver side), we can decompress directly to the driver's memory, skipping the copy step.

  1. Arm is not only used in embedded you know. High performance parts also run on arm, so this is unacceptable. Decoding a 4k image is going to be faster on a 4090 than cpu.
  2. Move this code to it's own file, it should be self-contained thing. If you're using imported code from a separate project, store it in 3rd party. If you wrote it yourself, it can live in a decoders folder somewhere.
  3. Make link-time optional if possible via a cmake var.

Comment thread rpcs3/Emu/RSX/GL/GLTexture.cpp Outdated
Comment thread rpcs3/Emu/RSX/VK/vkutils/device.cpp Outdated
@ginkage
Copy link
Copy Markdown
Contributor Author

ginkage commented Feb 12, 2025

Thank you for the review. All good points.

  1. I'll try to propagate the capabilities more cleanly.
  2. bcdec code is technically 3rdparty, but I've modified it somewhat: stripped down, adapted to rpcs3 types, moved around color bits... It's available as Unlicense (public domain), and there's no need to pull in the whole project when we only need 10% of it (modified, too). I'll move it to a separate file in the same folder.
  3. Not really possible to make it link-time optional: all Linux-ARM64 builds potentially need this.

@ginkage
Copy link
Copy Markdown
Contributor Author

ginkage commented Feb 12, 2025

I've reworked the code somewhat, please take a look. I'm happy to revert the changes to GL if you want to make sure that the GL side remains unaffected. For VK, I tried to stick with the current logic as close as possible.

Comment thread rpcs3/Emu/RSX/GL/GLTexture.cpp
@kd-11
Copy link
Copy Markdown
Contributor

kd-11 commented Feb 12, 2025

I've reworked the code somewhat, please take a look. I'm happy to revert the changes to GL if you want to make sure that the GL side remains unaffected. For VK, I tried to stick with the current logic as close as possible.

Firstly, this is nice, clean work. This is almost exactly what was required, thanks a lot.

Secondly, as for the 3rd party thing - it's better to move it there otherwise someone else will likely do it during some header cleanup and mess up the history. We do import partial things there too from projects such as GPUOpen.
If possible, please create a folder there called "bcdec" and put the hpp there.

Third, the attribution included is quite truncated and the license missing. Even with the permissive "unlicense" license available, it's good to acknowledge the authors with each distribution. As a FOSS project, we try to stick to FOSS licensing as much as possible, and in this case the MIT option looks good enough that we really should include the attribution and original license in our codebase. With MIT you can also just paste the license at the top of the file in full and be done with it.

CC @AniLeo for licensing thoughts.

@ginkage
Copy link
Copy Markdown
Contributor Author

ginkage commented Feb 12, 2025

Re: 3rdparty licensing — understood, acknowledged, will do!

@ginkage
Copy link
Copy Markdown
Contributor Author

ginkage commented Feb 12, 2025

...and done.

@ginkage
Copy link
Copy Markdown
Contributor Author

ginkage commented Feb 18, 2025

Should be ready to merge?..

@kd-11 kd-11 merged commit e72cb68 into RPCS3:master Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants