Commit Graph

77 Commits

Author SHA1 Message Date
Tillmann Karras 24ba3bf2f2 TextureConversionShader: fix XFB decoding shader 2019-03-01 21:54:33 +00:00
Stenzek 8192c0dd48 TextureConversionShader: Fix XFB decoding shader for D3D
D3D has no mix() equivalent with a bool parameter. Compilers should be
able to optimize the ternary into a select anyway.
2019-02-28 20:43:50 +10:00
Stenzek f039149198 Move most backend functionality to VideoCommon 2019-02-19 16:57:54 +10:00
Stenzek f74dbc794c EFB2RAM: Apply copy filter as a float coefficient after sampling
Using 8-bit integer math here lead to precision loss for depth copies,
which broke various effects in games, e.g. lens flare in MK:DD.

It's unlikely the console implements this as a floating-point multiply
(fixed-point perhaps), but since we have the float round trip in our
EFB2RAM shaders anyway, it's not going to make things any worse. If we
do rewrite our shaders to use integer math completely, then it might be
worth switching this conversion back to integers.

However, the range of the values (format) should be known, or we should
expand all values out to 24-bits first.
2018-05-22 12:24:08 +10:00
Markus Wick c485efdfe1
Merge pull request #6743 from stenzek/faster-disabled-copy-filter
TextureConversionShader: Don't sample from adjacent rows when not needed
2018-05-17 10:45:50 +02:00
Stenzek 4faac3a627 TextureConversionShader: Don't sample from adjacent rows when not needed 2018-05-03 14:09:32 +10:00
Stenzek a93830056f TextureConversionShader: Fix more implicit conversion errors 2018-05-03 11:32:06 +10:00
Stenzek 2c6b20bb03 TextureConversionShader: Fix compile errors in OpenGL ES 2018-05-02 21:54:13 +10:00
Stenzek 9e798eec94 Implement EFB copy filter and gamma in hardware backends
Also makes y_scale a dynamic parameter for EFB copies, as it doesn't
make sense to keep it as part of the uid, otherwise we're generating
redundant shaders.
2018-04-29 19:05:20 +10:00
Jonathan Hamilton 46254a2cf2 Some more implicit uint/float conversions in the texture decode shaders 2018-01-11 11:15:40 -08:00
Jonathan Hamilton f23dd992dd GLSL-ES doesn't allow implicit int/uint conversions 2018-01-11 10:54:55 -08:00
Stenzek d0601c0a83 TextureConversionShader: Use round() instead of roundEven() in HLSL
HLSL does not define roundEven(), only round(). This means that the
output may differ slightly for OpenGL vs Direct3D. However, it ensures
consistency across OpenGL drivers, as round() in GLSL can go either way.
2017-12-06 03:33:50 +10:00
Markus Wick 76fbdbb06e
Merge pull request #5903 from linkmauve/fix-mp2e
Round values in swizzlers
2017-12-02 17:38:21 +01:00
degasus e2a9ee384f VideoCommon: Rename TextureConversionShader namespace. 2017-12-02 15:17:39 +01:00
iwubcode 53684701fa HybridXFB: Fix lint errors 2017-11-17 22:11:31 -06:00
iwubcode 76b775d5be Video Common: Add XFB decoding via the GPU 2017-11-17 22:11:30 -06:00
iwubcode b285188de1 Video Backends: Implement vertical scaling for xfb copies. This fixes the
display of PAL games that run in 50hz mode.
2017-11-17 22:11:29 -06:00
iwubcode 79387dddb2 Add support for hybrid XFB 2017-11-17 19:47:56 -06:00
Emmanuel Gil Peyrot 1b32751367 VideoCommon: Round values in swizzlers.
This was breaking Metroid Prime 2: Echoes’s scanner in some rooms, such
as the one in https://fifoci.dolphin-emu.org/dff/mp2-scanner/

It was found on Ivy Bridge on Mesa, the alpha value read back from the
EFB was off-by-4 in multiple objects, which was a conversion error
because int4() is equivalent to floor() and the value wasn’t always
higher.
2017-08-07 20:20:36 +02:00
N.E.C c3a57bbad5 Video: Clearly separate Texture and EFB Copy formats
Improve bookkeeping around formats. Hopefully make code less confusing.

- Rename TlutFormat -> TLUTFormat to follow conventions.
- Use enum classes to prevent using a Texture format where an EFB Copy format
  is expected or vice-versa.
- Use common EFBCopyFormat names regardless of depth and YUV configurations.
2017-08-03 18:35:29 -07:00
Stenzek adebe2239e TextureConversionShader: Use integer math for truncating EFB format 2017-06-17 12:17:09 +10:00
Michael Maltese 05b4d14bf0 TextureConversionShader: fix syntax error
Fixes a situation where the following invalid GLSL code is generated:

```glsl
float3 texSample0 = texture(samp0, float3(uv0 + float2(0, 0) * sample_offset, 0.0)).rgb;
float3 texSample0 = floor(float3 texSample0 * 63.0) / 63.0;
float3 texSample1 = texture(samp0, float3(uv0 + float2(1, 0) * sample_offset, 0.0)).rgb;
float3 texSample1 = floor(float3 texSample1 * 63.0) / 63.0;
```
2017-04-12 14:23:25 -07:00
Stenzek 3847e226ab TextureConversionShader: Consider source format of EFB for EFB2RAM
Currently, we use the alpha channel from the EFB even if the current
format does not include an alpha channel. Now, the alpha channel is set
to 1 if the format does not have an alpha channel, as well as truncating
to 5/6 bits per channel. This matches the EFB-to-texture behavior.
2017-04-12 00:11:22 +10:00
Stenzek fdf2efdac6 TextureConversionShader: Add missing swap for index of C14X2 textures 2017-04-06 23:29:40 +10:00
Stenzek c6075f4c36 TextureConversionShader: Fix compile error in C14X2 decoder 2017-04-06 13:59:06 +10:00
Stenzek 6ffc16d1b0 VideoCommon: Add texture decoding shader generators 2017-04-01 12:32:10 +10:00
Stenzek a71381e80a VideoCommon: Add APIType entry for Vulkan 2016-10-01 01:09:11 +10:00
Stenzek d9c034e8cc ShaderGen: Specify attribute/output locations/bindings explicitly
This also shifts the SSBO index from index 3 to index 0.
2016-10-01 01:09:11 +10:00
Jules Blok 35a270d2a8 TextureConversionShader: Don't use the float specifier in shader code. 2016-08-24 17:42:32 +02:00
Lioncash 14e0b48ae4 VideoCommon: Make API_TYPE an enum class
Allows for forward declarations in most places, which prevents dumping
unrelated VideoCommon.h contents directly into headers.
2016-07-29 19:20:16 -04:00
Pierre Bourdon 3570c7f03a Reformat all the things. Have fun with merge conflicts. 2016-06-24 10:43:46 +02:00
Stenzek 1ce38a136d TextureConversionShader: Invert depth for Z24 encoder with D3D 2016-02-22 00:09:07 +10:00
Lioncash d9fec92628 VideoCommon: Header cleanup
Also remedies places where the video backends and core rely on things
being indirectly included.
2016-01-17 20:11:45 -05:00
Jules Blok daabd88d69 TextureConversionShader: Also invert color encoders if they're used to encode depth. 2016-01-13 01:08:27 +01:00
Scott Mansell b9be3245e1 Move common EFB copy code into VideoCommon
Addded a few duplicated depth copy texture formats to the enum
in TextureDecoder.h. These texture formats were already implemented
in TextureCacheBase and the ogl/dx11 texture cache implementations.
2015-09-06 21:16:51 +12:00
Markus Wick ff95fa8a6d Merge pull request #2861 from lioncash/param
VideoCommon: Remove unused parameters
2015-08-17 15:02:44 +02:00
Lioncash 8e17c710f3 TextureConversionShader: Remove an unused parameter 2015-08-16 21:10:54 -04:00
Jules Blok b01ca1794a Revert "VideoCommon: Clamp integer conversions."
This reverts commit 0f2c72f0f8.
2015-08-15 13:50:43 +02:00
galop1n 2975e53091 D3D: Depth range inversion.
Credits go to Galop1n for designing this technique and to BhaaLseN for cleaning up the commit.
2015-05-26 15:31:31 +02:00
Tillmann Karras 30ebb2459e Set copyright year to when a file was created 2015-05-25 13:22:31 +02:00
Tillmann Karras cefcb0ace9 Update license headers to GPLv2+ 2015-05-25 13:22:31 +02:00
Jules Blok d04af15ad4 TextureConversionShader: Use floating point values in clamp(). 2015-05-08 14:32:24 +02:00
Jules Blok 0f2c72f0f8 VideoCommon: Clamp integer conversions. 2015-05-08 14:32:16 +02:00
Jules Blok c4f85a38e6 VideoBackends: Use proper floating point depth precision. 2015-05-08 14:29:29 +02:00
Jules Blok 139ad3b2b9 TextureConversionShader: Use a Texture2DArray to match the shader resource view. 2015-02-21 11:50:20 +01:00
magumagu 57d94de2ad Fix regression for D3D EFB depth copies.
On D3D, we read from the depth buffer using the format
DXGI_FORMAT_R24_UNORM_X8_TYPELESS (essentially, the "r" component contains
the depth, and the other components contain nothing).
2015-02-03 11:27:27 -08:00
magumagu b56025e6eb Don't use boolean negation. 2015-01-25 23:28:59 -08:00
magumagu 92189823f3 Fix RGBA8 encoding. 2015-01-25 22:53:30 -08:00
magumagu b0b99b6922 Fix shader so it's possible to use with D3D Map().
Well, that's not strictly true, but trying to memcpy between two buffers
using different row lengths and different strides is at minimum extremely
unintuitive.
2015-01-25 19:57:09 -08:00
magumagu 6c1bdfe04c More work. 2015-01-25 19:57:07 -08:00