Commit Graph

101 Commits

Author SHA1 Message Date
Lioncash 784a216927 Common/MathUtil: Move IntLog2 into MathUtil namespace
Gets this out of the global namespace.
2023-04-15 03:35:05 -04:00
Minty-Meeo bf079d6d3a [[unlikely]] ASSERT
and other ASSERT usage changes
2023-03-02 19:54:15 -06:00
JosJuice 724bd3e597 VideoCommon: Fix OpenGL ES GPU texture decoding 2022-08-20 23:21:23 +02:00
TellowKrinkle 716c0980d7 VideoBackends: Add Metal renderer 2022-07-21 20:44:19 -05:00
Admiral H. Curtiss b0b5faa793
Merge pull request #10874 from JosJuice/cmpr-layout
VideoCommon: Fix CMPR compute shader layout
2022-07-19 12:05:29 +02:00
JosJuice 1a2bc2eff9 VideoCommon: Fix CMPR compute shader layout
Looks like a copy-paste gone wrong. The compute shaders for the other
formats use a group size of 8 * 8, whereas the CMPR compute shader
is supposed to use a flattened 64 * 1 as I understand it.
2022-07-18 18:56:50 +02:00
Joon Park 319288de8e Fix OpenGL error on M1 Mac.
Followup to #10466. Resolves the following error:

ERROR: 0:85: '&' does not operate on 'uvec3' and 'int'
2022-07-17 08:54:39 -04:00
Pokechu22 a6e06f38ad Add notes about precision of YUV->RGB conversion factors for XFB 2022-07-16 00:07:10 -07:00
Pokechu22 e7339d63f1 Rework TextureConversionShader for hardware accuracy and simplicity 2022-07-16 00:07:10 -07:00
Pokechu22 791bd16b28 Restructure parameters to TetxureConverterShaderGen/TextureConversionShader
This will be used for later refactoring for increased accuracy.
2022-07-16 00:07:10 -07:00
Pokechu22 290e62f179 Remove casts to integers for texture and EFB formats
The only remaining casts for these types that I know of are in TextureInfo (where format_name is set to the int version of the format, and since that affects filenames and probably would break resource packs, I'm not changing it) and in TextureDecoder_Common's TexDecoder_DrawOverlay, which will be handled separately.
2022-07-15 12:29:40 -07:00
JMC47 fac66897af
Merge pull request #10819 from Dentomologist/fix_shader_compilation_warnings
VideoCommon: Fix D3D shader compilation warnings
2022-07-08 18:46:29 -04:00
Dentomologist 0fac1d6e87 VideoCommon: Fix D3D shader warning X3571 (negative base for pow())
Add abs() to fix "pow(f, e) will not work for negative f, use abs(f) or
conditionally handle negative values if you expect them".
2022-07-08 00:19:05 -07:00
iwubcode 5dd2704416 D3D / VideoCommon: generate HLSL from SPIRV 2022-06-24 18:09:53 -05:00
TellowKrinkle 23c1721fbd VideoCommon: Reduce duplicates of non-palette-requiring texture decode shaders 2022-06-16 02:08:45 -05:00
Pierre Bourdon e149ad4f0a
treewide: convert GPLv2+ license info to SPDX tags
SPDX standardizes how source code conveys its copyright and licensing
information. See https://spdx.github.io/spdx-spec/1-rationale/ . SPDX
tags are adopted in many large projects, including things like the Linux
kernel.
2021-07-05 04:35:56 +02:00
Pokechu22 70f9fc4e75 Convert BPMemory to BitField and enum class
Additional changes:
- For TevStageCombiner's ColorCombiner and AlphaCombiner, op/comparison and scale/compare_mode have been split as there are different meanings and enums if bias is set to compare.  (Shift has also been renamed to scale)
- In TexMode0, min_filter has been split into min_mip and min_filter.
- In TexImage1, image_type is now cache_manually_managed.
- The unused bit in GenMode is now exposed.
- LPSize's lineaspect is now named adjust_for_aspect_ratio.
2021-03-06 19:27:19 -08:00
Lioncash 3d9b2aa005 VideoCommon: Migrate over to fmt
Migrates off the printf-based formatting where applicable.
2020-11-17 21:23:58 -05:00
Lioncash a5b28f1f07 ShaderGenCommon: Rename WriteFmt() to Write()
Now that we've converted all of the shader generators over to using fmt,
we can drop the old Write() member function and perform a rename
operation on the WriteFmt() to turn it into the new Write() function.

All changes within this are the removal of a <cstdarg> header, since the
previous printf-based Write() required it, and renaming. No functional
changes are made at all.
2020-11-09 02:31:49 -05:00
Lioncash 687f1f0330 VideoCommon/TextureConversionShader: Make use of fmt where applicable
Now that we've converted the shader generation over to ShaderCode, we
can now make use of the fmt-capable WriteFmt function.
2020-01-23 14:19:40 -05:00
Lioncash aa77dff3a2 VideoCommon/TextureConversionShader: Convert over to using ShaderCode
Migrates the shader generator off the use of a global array, eliminating
the use of some global state. This also allows us to move the shader
generation over to using fmt in a subsequent change.
2020-01-23 14:19:36 -05:00
David Korth c2dd2e8a2e Use std::istringstream or std::ostringstream instead of std::stringstream where possible.
This removes std::iostream from the inheritance chain, which reduces
overhead slightly.
2019-12-29 23:45:02 -05:00
Stenzek dfae87d69a TextureConversionShader: Swap bytes for RG8/GB8 format
Matches the software renderer.
2019-07-14 13:36:43 +10:00
Stenzek eddde3e6c8 ShaderGen: Use interface blocks when geometry shaders are supported
We don't use explicit locations in OpenGL currently, so this breaks
when we use alternative names in the geometry shaders.
2019-04-20 23:44:33 +10:00
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