Pcsx2: Feature request: Hardware Antialiasing: MSAA and SSAA for OpenGL?

Created on 5 Jul 2015  路  18Comments  路  Source: PCSX2/pcsx2

I noticed that the D3D backend has MSAA but the OpenGL backend is missing it. Could it be implemented? Maybe even SSAA too, Dolphin can do SSAA with OpenGL.
https://www.opengl.org/registry/specs/ARB/sample_shading.txt

Enhancement / Feature Request Low Priority GS

Most helpful comment

So, I've been trying out new native x86_64 builds of PCSX2 and it reminded me that there is no anti-aliasing. It doesn't matter much since 1440p on 1080p is pretty crisp, however, Mesa drivers have these interesting options:
https://gitlab.freedesktop.org/mesa/mesa/-/commit/a969f184cf3e8f2d9089fc4df424fa590f967983
https://gitlab.freedesktop.org/mesa/mesa/-/blob/master/src/gallium/drivers/radeonsi/si_state.c#L3412

    * Sensible AA configurations:
    *   EQAA 16s 8z 8f - might look the same as 16x MSAA if Z is compressed
    *   EQAA 16s 8z 4f - might look the same as 16x MSAA if Z is compressed
    *   EQAA 16s 4z 4f - might look the same as 16x MSAA if Z is compressed
    *   EQAA  8s 8z 8f = 8x MSAA
    *   EQAA  8s 8z 4f - might look the same as 8x MSAA
    *   EQAA  8s 8z 2f - might look the same as 8x MSAA with low-density geometry
    *   EQAA  8s 4z 4f - might look the same as 8x MSAA if Z is compressed
    *   EQAA  8s 4z 2f - might look the same as 8x MSAA with low-density geometry if Z is compressed
    *   EQAA  4s 4z 4f = 4x MSAA
    *   EQAA  4s 4z 2f - might look the same as 4x MSAA with low-density geometry
    *   EQAA  2s 2z 2f = 2x MSAA

https://gitlab.freedesktop.org/mesa/mesa/-/blob/master/docs/gallium/postprocess.rst

pp_jimenezmlaa, pp_jimenezmlaa_color - Jimenez's MLAA is a morphological antialiasing filter.
The two versions use depth and color data, respectively. Which works better depends on the app -
depth will not blur text, but it will miss transparent textures for example.
Set to a number from 2 to 32, roughly corresponding to quality. Numbers higher than 8 see minimizing gains.

All 18 comments

Hopefully this is something @gregory38 can do, as hardware AA is always nice to have. He was able to implement AF pretty quickly to OGL back when I made an issue about it so hopefully this is also an easy fix. :)

MSAA is doable, most of DX code can be used. But what are the pros and cons versus upscaling (which is another AA). Honestly I prefer increase accuracy.

@gregory38 Well upscaling with antialiasing is better than just higher resolution alone. Maybe even SSAA might be copyable from Dolphin's OpenGL?

Yeah upscaling/downsampling is not a substitute for proper MSAA or SSAA IMO.

@gabest11 Would it be hard to implement in OpenGL?

What is (does) SSAA/MSAA for you ?

The generic word is fsaa as full screen. The basic implementation is upscaling/downscaling (AKA SSAA) It is very costly for the GPU but everything is AA (texture/edge).

Msaa was created as a cheap solution. Only the depth is upscaled so fragment shader are run once for S samples. Only edges are aliased. Besides it doesn't work for alpha test (1 run means all or nothing)

The above extension is a workaround of msaa to run a shader N times for S shader with 1<=N<=S. 1 is msaa. S is upscaling (SSAA)

Wouldn't SSAA have the same side effects of upscaling?

Also, I remember AMD has an option in the control panel which generally applies MSAA to the whole scene, and SSAA only to the transparent textures when needed.
http://www.bit-tech.net/hardware/graphics/2006/04/07/transparency_adaptive_aa_explained/1

The more AA is powerful, the more glitches will be created. Rendering of the GS depends on the aliasing. However I think FSAA will less suffer from ghosting but I think it would be possible to correct texture coordinate to avoid it.

The GL extension allow to easily switch between MSAA or Full SSAA (or partial SSAA). It will work nicely for standard rendering. However how will behave the post-processing effect. Effects are full screen so it impacts lots of pixels.
1/ Apply a blending/bit mask on the color. By fragment or by sample
2/ Conversion of the depth to a color and then move the green channel to the alpha channel. By fragment of by sample?
3/ Conversion of the depth to a color. Apply some blending/color operations. Then convert it back to a depth. By fragment or by sample?

An issue with upscaling is that RT is downscaled during the RT and reused as a smaller texture. It breaks the 1:1 mapping of the effect. I think it can be improved to keep higher resolution in the full rendering. MSAA does a down-sampling, I think it would be better to keep all the samples but it would badly hurt the performance.

The purpose of MSAA is do the depth test at sample frequency but keep color at fragment frequency. It is a lighter kind of SSAA so you can run it with more X. For example 4x MSAA vs 2x SSAA, my mid-end GPU (GTX760) seems to handle 3x/4x. I'm not sure there is any major difference with a bigger aliasing effects (aka 8x/16x MSAA).

Besides post filtering algorithms, MSAA at native resolution is the only option, because it does not sample textures at any other location than it is supposed to.

sure because as far as I understand it doesn't do any anti-aliasing effect on the texture. Hum on the link above, it says textures don't suffer from aliasing due to mipmap.

 In order to keep most of the benefit of supersampling without breaking the bank in terms of performance, we can observe that aliasing of triangle visibility function (AKA geometric aliasing) only occurs at the edges of rasterized triangles. If we hopped into a time machine and traveled back to 2001, we would also observe that pixel shading mostly consists of texture fetches and thus doesn鈥檛 suffer from aliasing (due to mipmaps). These observations would lead us to conclude that geometric aliasing is the primary form of aliasing for games, and should be our main focus. This conclusion is what what caused MSAA to be born.

Hum I'm curious. I never tested MSAA on GSdx. It would be interesting to compare the rendering between upscaling and MSAA.

isn't having MSAA as simple as,

glEnable(GL_MULTISAMPLE_ARB);

It's done like that setting a valid pixel format along with the WGL_SAMPLE_BUFFERS_ARB and WGL_SAMPLES_ARB attributes in Wgl.

Yes you have it but it doesn't mean you use it (neither correctly)

Additional reading:
http://www.beyond3d.com/content/articles/122
The article contains some nice screen-shot comparisons.

@gregory38 @gabest11
https://www.opengl.org/registry/specs/ARB/texture_multisample.txt
https://www.opengl.org/registry/specs/ARB/texture_storage_multisample.txt
https://www.khronos.org/registry/gles/extensions/EXT/EXT_multisampled_render_to_texture.txt
https://github.com/dolphin-emu/dolphin/pull/2934/files
https://github.com/dolphin-emu/dolphin/pull/3002/files
https://github.com/dolphin-emu/dolphin/pull/2986
http://www.tomshardware.com/reviews/anti-aliasing-nvidia-geforce-amd-radeon,2868.html
http://www.tomshardware.com/reviews/anti-aliasing-performance,3065.html
http://www.guru3d.com/articles-pages/mfaa-multi-frame-sample-aa-guide-review,1.html
http://naturalviolence.webs.com/sgssaa.htm
http://www.dahlsys.com/misc/antialias/
http://naturalviolence.webs.com/generalaa.htm
https://research.nvidia.com/publication/aggregate-g-buffer-anti-aliasing
http://www.humus.name/index.php?page=3D&ID=87
https://github.com/vispy/experimental/tree/master/fsaa
https://github.com/vispy/vispy/wiki/Tech.-Antialiasing
http://www.learnopengl.com/#!Advanced-OpenGL/Anti-aliasing
https://www.opengl.org/wiki/Multisampling
http://www.learnopengl.com/#!Advanced-Lighting/SSAO
Resolving multisampled depth buffer.
https://github.com/Tinob/Ishiiruka/commit/9dc73c0b166d09b550971bdb548f8568fe528ca4
https://github.com/gonetz/GLideN64/commit/663a0d76f1cc359e58ef5fd343146bee45c1a7ea
https://github.com/gonetz/GLideN64/commit/10c4fb801c01a150dfc7346a652ecba5510bc5f1
https://github.com/gonetz/GLideN64/commit/8b570cb273cf63447c504a0a34fb0080677fd7c2
https://github.com/gonetz/GLideN64/commit/7b730096b32eb7e346ebe405eda7c0da62f38d40
https://github.com/gonetz/GLideN64/commit/6be5ff63964e5b27d36d18d3fe9986c57c5b072a
https://github.com/gonetz/GLideN64/commit/12f9f8d5d0ed5ad2bd5be230efa08000b37cda33
https://github.com/gonetz/GLideN64/commit/5eee1ef01ef17bde3ba8283528aa6ac4c3e90b63
https://github.com/gonetz/GLideN64/commit/a02d284645bdddaaf6f6cdbc8246e6a69c6cb579
https://github.com/gonetz/GLideN64/commit/916e083bfaf67ad5b40199bba039b411b683e5e4
https://github.com/gonetz/GLideN64/commit/18172a6c0b6f4f3753fc877503fbe5289e4410b0
https://github.com/gonetz/GLideN64/commit/2feb8a24dd27d72ba179533f920e5904252ab752
https://github.com/gonetz/GLideN64/commit/b728ab97a7adc3c55b9076fbcbd11232eeb13b5e
https://github.com/gonetz/GLideN64/commit/59e86b779424b13c2979c29b9043a66dd7bad777

https://github.com/jpd002/Play-/commit/e9ccfef932c1670f53d325d70ae49d662269f0f2
https://github.com/jpd002/Play-/commit/06ce2fe6aa65e4f458fd23770b96592d7798390b
https://sourceforge.net/p/desmume/code/5032/
https://sourceforge.net/p/desmume/code/4485/
https://sourceforge.net/p/desmume/code/4484/
https://sourceforge.net/p/desmume/code/4483/
https://github.com/jpd002/Play-/commit/02be94723b74bc02d54c3c1c085277e97c907f85

No need to post internet. Too muck information kill the information. Anyway nobody has time to work on that currently. Sorry but it is low priority.

Closing this one as well, there's also some talk about purging msaa from dx once depth get's added but we'll see.

So, I've been trying out new native x86_64 builds of PCSX2 and it reminded me that there is no anti-aliasing. It doesn't matter much since 1440p on 1080p is pretty crisp, however, Mesa drivers have these interesting options:
https://gitlab.freedesktop.org/mesa/mesa/-/commit/a969f184cf3e8f2d9089fc4df424fa590f967983
https://gitlab.freedesktop.org/mesa/mesa/-/blob/master/src/gallium/drivers/radeonsi/si_state.c#L3412

    * Sensible AA configurations:
    *   EQAA 16s 8z 8f - might look the same as 16x MSAA if Z is compressed
    *   EQAA 16s 8z 4f - might look the same as 16x MSAA if Z is compressed
    *   EQAA 16s 4z 4f - might look the same as 16x MSAA if Z is compressed
    *   EQAA  8s 8z 8f = 8x MSAA
    *   EQAA  8s 8z 4f - might look the same as 8x MSAA
    *   EQAA  8s 8z 2f - might look the same as 8x MSAA with low-density geometry
    *   EQAA  8s 4z 4f - might look the same as 8x MSAA if Z is compressed
    *   EQAA  8s 4z 2f - might look the same as 8x MSAA with low-density geometry if Z is compressed
    *   EQAA  4s 4z 4f = 4x MSAA
    *   EQAA  4s 4z 2f - might look the same as 4x MSAA with low-density geometry
    *   EQAA  2s 2z 2f = 2x MSAA

https://gitlab.freedesktop.org/mesa/mesa/-/blob/master/docs/gallium/postprocess.rst

pp_jimenezmlaa, pp_jimenezmlaa_color - Jimenez's MLAA is a morphological antialiasing filter.
The two versions use depth and color data, respectively. Which works better depends on the app -
depth will not blur text, but it will miss transparent textures for example.
Set to a number from 2 to 32, roughly corresponding to quality. Numbers higher than 8 see minimizing gains.
Was this page helpful?
0 / 5 - 0 ratings