xemu-project / xemu

Original Xbox Emulator for Windows, macOS, and Linux (Active Development)
https://xemu.app
Other
2.71k stars 271 forks source link

Convolution texture filter (MAG interpolation) not implemented #1038

Open Triticum0 opened 2 years ago

Triticum0 commented 2 years ago

The GPU supports a special "convolution" MIN/MAG filter. This might be for D3D, or it might be a custom extension by nvidia. I was unable to find an OpenGL extension for it.

In XQEMU, when this mode is active, no warning or error is generated - the mode is silently treated as LINEAR:

MIN filter:

https://github.com/mborgerson/xemu/pull/93/commits/82800e240c676d907ac613dba39584d66ac4ab89

MAG filter:

https://github.com/mborgerson/xemu/blob/176b574403e0f4a08bfb1f8ab58e0f819a45cf81/hw/xbox/nv2a/pgraph.c#L109

In addition to the mode 0x7 (MIN) and mode 0x4 (MAG) being used to indicate the convolution filter, there's also a field to select the used kernel:

#   define NV097_SET_TEXTURE_FILTER_CONVOLUTION_KERNEL_QUINCUNX             0x1
#   define NV097_SET_TEXTURE_FILTER_CONVOLUTION_KERNEL_GAUSSIAN_3           0x2

at bit 13-14 of said register; and also in NV_PGRAPH_TEXFILTER0_CONVOLUTION_KERNEL.

I've actually prototyped a software emulation in GLSL in a custom software renderer: https://github.com/JayFoxRox/software-shader-texture .

Integration in XQEMU is unlikely for now, due to performance and added code complexity. However, a similar solution should be considered in the future.

The results of said software emulation have not been confirmed yet (and mipmapping isn't implemented yet).

I'll produce framedumps on a physical Xbox soon, the following images are from the emulator, which is based on guesswork, modeling the shaders after what I observed on my TV (Xbox output).

The white dots are individual pixels in a 16x16 texture.

NEAREST image

LINEAR image

Convolution (Gaussian 3x3) image

Convolution (Quincunx) image

Additional Context

This was ripped directly from https://github.com/xqemu/xqemu/issues/238 So big thanks to JayFoxRox for the information.

mborgerson commented 2 years ago

It is partially implemented

Triticum0 commented 2 years ago

That is why I Pointed to your pr for the MIN filter. when it is fully implemented I will close the issue