BodbDearg / PsyDoom

A backport of PSX Doom to PC
GNU General Public License v3.0
408 stars 24 forks source link

MSAA doesn't apply inside textures on Steam Deck #113

Closed krittinen closed 2 months ago

krittinen commented 3 months ago

PsyDoom on Steam Deck doesn't apply antialiasing inside textures, resulting in jaggies in texture surfaces even at 8x MSAA.

Steam Deck 2560x1440 8xMSAA Screenshot_20240818_220820

On Windows with a 3060 Ti and 560.81 drivers 8x MSAA applies inside textures, resulting in a much more temporally stable image.

3060 Ti 2560x1440 8xMSAA PsyDoom 2024-08-18 22-13-54

I assume this must be some Mesa vs Nvidia drivers thing, if it's not fixable then I suggest implementing a downscaling filter for resolutions higher than native, in order to use the internal resolution setting for supersampling. FWIW the Steam Deck has no issues running PsyDoom at 1440p so downscaling from there to 720p for effective 2x Supersampling would work very well.

BodbDearg commented 3 months ago

Very strange. PsyDoom uses a feature called 'Sample Rate Shading' in order to get the high quality multi-sampled shading inside polygons, not just on the edges. It is described here: https://vulkan-tutorial.com/Multisampling

It seems like this feature should be supported practically everywhere according to the Vulkan HW DB: https://vulkan.gpuinfo.org/listfeaturescore10.php (see sampleRateShading row)

Maybe Steam Deck is one of the exceptions somehow? Or there is a driver bug. Unfortunately I do not own a Steam deck so I can only speculate.

krittinen commented 3 months ago

This might be a bug with AMD's Vulkan drivers, at least this person reports that Sample Rate Shading isn't working as expected on their 7900XTX and Steam Deck but it's not clear if he's running on Linux or Windows.

https://community.amd.com/t5/drivers-software/please-provide-support-for-vulkan-supersampling-sample-rate/td-p/670894

I don't have Windows installed on my Steam Deck to test, when I have the time I'll give it a go.

BodbDearg commented 3 months ago

Thanks for the link. Yeah that does sound like the same issue since PsyDoom uses nearest-neighbor/point sampling too. I couldn't use bilinear filtering even if I wanted to because I have to do a palette lookup in all the shaders to read the 8-bit textures - something that no modern hardware natively supports.

I have some AMD hardware lying around - could check to see if its working as expected on Windows.

krittinen commented 2 months ago

I suggest looking into what the Ironwail Quake 1 source port does for MSAA, as their MSAA implementation correctly antialiases both polygon edges as well as unfiltered textures on my Steam Deck.

BodbDearg commented 2 months ago

Thanks. I did check out Ironwail and it looks like it is using GL_SAMPLE_SHADING (https://registry.khronos.org/OpenGL-Refpages/gl4/html/glMinSampleShading.xhtml) which is essentially the OpenGL equivalent of the sampleRateShading feature mentioned above. I also got round to trying this out on Windows with a Radeon 5600 XT and found no issues.

So it seems like it is a driver bug specific to Linux, and Vulkan. I'm thinking this ticket should be closed given that it is not bug with PsyDoom and that we should instead wait for AMD to fix the problem with their drivers. In the meantime there also might be driver or third party workarounds which perform the kind of downscaling that you describe - like the 'Virtual Super Resolution' feature on Windows.