summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/PixelShaderGen.cpp
AgeCommit message (Collapse)Author
2022-04-10MoltenVK: Fix pixel shader typoJosJuice
2022-02-28Shadergen: Use real_ocol0 workaround for shader logic opsJosJuice
Previously we were using this workaround when using framebuffer fetch to emulate dual source blending, but it seems like we also need to use it when using framebuffer fetch to emulate logic ops, otherwise some Adreno devices get a crash when compiling OpenGL ES ubershaders. Using the workaround in specialized shaders doesn't seem to be necessary, but I've made the same change there for consistency. This gets us closer to fixing https://bugs.dolphin-emu.org/issues/12791 but doesn't actually fix it.
2022-02-28PixelShaderGen: Check uid_data for use_shader_logic_opJosJuice
On devices which have hardware support for dual source blending but not logic ops, this lets us skip performing the framebuffer fetch in situations where the game isn't actually using logic ops.
2022-02-08Treat alpha as 0 if alpha is 1 for blendingPokechu22
This removes the white box in fortune street again, without causing Mario Kart Wii to regress.
2022-02-08Use the same logic for lerp bias for color and alphaPokechu22
It doesn't make sense for alpha to add the bias ONLY when dividing by 2, while color doesn't apply the bias for divide by 2 only; hardware testing indicates that alpha should have the bias. This fixes the menus in Mario Kart Wii (https://bugs.dolphin-emu.org/issues/11909) but reintroduces the white rectangle in Fortune Street. This reverts commit 5aaa5141ed76acc3fffc70561a6b6e7fe3b9b470 (and several other matching changes elsewhere).
2022-01-13Fix non-constexpr format stringsPokechu22
2022-01-12PixelShaderGen: Fix invalid use of int3(0)Pokechu22
This syntax is allowed by GLSL, but HLSL doesn't allow it. This meant that games using R8 comparisons in equal mode would produce shaders that failed to compile. Super Mario Galaxy's water levels were affected by this.
2021-12-28GLES: Fix LOD bias int/float mismatchJosJuice
Another simple GLES shader compilation error.
2021-12-28PixelShaderGen: Add LOD bias to texture() call on systems that don't support ↵OatmealDome
it in the sampler
2021-12-22Merge pull request #10215 from OatmealDome/shader-logic-opsJMC47
VideoCommon: Support shader logic ops on Metal (Apple GPUs) and OpenGL ES
2021-12-18PixelShaderGen: Convert to EnumMapPokechu22
2021-12-06PixelShaderGen: Add shader logic ops support on OpenGL ESOatmealDome
To do this, I had to decouple framebuffer fetch from shader blending. We need to be able to access framebuffer fetch input when using shader logic ops.
2021-12-06PixelShaderGen: Add shader logic ops support on MetalOatmealDome
2021-12-06PixelShaderGen: Add logic ops to pixel_shader_uid_dataOatmealDome
2021-11-24ConstantManager: Add logic ops to PixelShaderConstantsOatmealDome
2021-11-17VideoCommon: Skip textureQueryLevels if it doesn't existPokechu22
2021-11-17VideoCommon: Handle custom texture sizes correctlyPokechu22
Specifically, when using Manual Texture Sampling, if textures sizes don't match the size the game specifies, things previously broke. That can happen with custom textures, and also with scaled EFB copies at non-native IRs. It breaks most obviously by not scaling the texture coordinates (so only part of the texture shows up), but the hardware wrapping functionality also assumes texture sizes are a power of 2 (or else it will behave weirdly in a way that matches how hardware behaves weirdly). The fix is to provide alternative texture wrapping logic when custom texture sizes are possible.
2021-11-17VideoCommon: Add option to use old behavior (Fast Texture Sampling)Pokechu22
Co-authored-by: JosJuice <josjuice@gmail.com>
2021-11-17VideoCommon: Implement diagonal LODPokechu22
Note that both GLSL and HLSL provide a fwidth (fragment width) function defined as `fwidth(p) = abs(dFdx(p)) + abs(dFdy(p))`. However, it's easy enough to implement this ourselves (and it makes the code a bit more obvious).
2021-11-17VideoCommon: Use coarse derivatives for Manual Texture Sampling if possiblePokechu22
2021-11-17VideoCommon: Manually handle texture wrapping and samplingPokechu22
2021-11-17VideoCommon: Expose SamplerState to shadersPokechu22
The benefit to exposing this over the raw BP state is that adjustments Dolphin makes, such as LOD biases from arbitrary mipmap detection, will work properly.
2021-11-17VideoCommon: Provide raw texdims to shadersPokechu22
2021-11-17VideoCommon: Allow BitfieldExtract in specialized shadersPokechu22
2021-10-13VideoCommon: Fix color channel logic when per-pixel lighting is in usePokechu22
This was broken in #10012 (specifically by 06579e4d53844e5a45ae18f8eda6c4ee69ebad2c and c3dec343918ff44e90886daf71a6bf0c49033de1).
2021-10-04VideoCommon: Abstract bounding boxTechjar
This moves much of the duplicated bounding box code into VideoCommon, leaving only the specific buffer implementations in each backend.
2021-07-20PixelShaderGen: Fix OpenGL ES bounding box compilation errorJosJuice
2021-07-20VideoCommon: Expand vector comparisons instead of overloading any()Techjar
For whatever stupid reason, Mali drivers do not allow overloading built-in functions.
2021-07-08Fix indentation for alphabumpPokechu22
2021-07-08Fix indirect textures when format is not ITF_8Pokechu22
2021-07-05treewide: convert GPLv2+ license info to SPDX tagsPierre Bourdon
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-06-13VideoCommon: Define scalar any() and all() functions in GLSLTechjar
This fixes bounding box shaders failing to compile under Vulkan, due to differences between GLSL and HLSL in the return value of vector comparisons and what types these functions accept. I included all() for the sake of completeness.
2021-06-11Merge pull request #9801 from Techjar/bbox-rounding-hackJMC47
VideoCommon: Only include centered pixels in bounding box
2021-06-10VideoCommon: Only include centered pixels in bounding boxTechjar
At higher resolutions, our bounding box dimensions end up being slightly larger than original hardware in some cases. This is not necessarily wrong, it's just an artifact of rendering at a higher resolution, due to bringing out detail that wouldn't have appeared on original hardware. It causes a texel to fall partially on what would have been a single pixel at native resolution, resulting in the coordinates getting bumped up to the next valid value. In many cases, these slightly larger bounding boxes are perfectly fine, as games don't hard-code expected dimensions. It is problematic in Paper Mario TTYD though, for a somewhat complicated reason. Paper Mario TTYD frequently uses EFB copies to pre-render a bunch of animation frames for a character sprite (especially in Chapter 2), so that it can then render 100 or more of them without bringing the GameCube to its knees. Based on my observation, the game seems to set aside a region of memory to store these EFB copies. This region is obviously fairly small, as the GameCube only has 24MB of RAM. There are 2 rooms in Chapter 2 where you fight a horde of as many as 100 Jabbies, which are also rendered using EFB copies, so in this room the game ends up making 130(!) EFB copies just for Puni and Jabbi sprites. This seems to nearly fill the region of memory it set aside for them. Unfortunately, our slightly larger bounding boxes at higher resolutions results in overflowing this memory, causing very strange behavior. Some EFB copies partially overlap game state, resulting in reading it as a garbage RGB5A3 texture that constantly changes. Others apparently somehow trigger a corner case in our persistent buffer mapping, causing them to partially overwrite earlier EFB copies. What this change does is only include the screen coordinates that align with the equivalent native resolution pixel centers, which generally results in the bounding boxes being more in line with original hardware. It isn't perfect, but it's enough to fix Paper Mario TTYD's Jabbi rooms by avoiding the buffer overflow. Notably, it is more accurate at odd resolutions than at even resolutions. Native resolution is completely unaffected by this change, as should be the case. This change may also have a small positive impact on shader performance at higher resolutions, as there will be less atomic operations performed.
2021-06-09Remove PixelShaderGen hasindstagePokechu22
2021-06-06VideoCommon: Perform OpenGL bounding box inversion in pixel shaderTechjar
Running the min/max operation on the upside down, quad-rounded pixel coordinates before inverting them to the standard upper-left origin produces wrong results. Therefore, we need to do the inversion before rounding to pixel quads.
2021-06-05VideoCommon: Round bounding box coordinates down and remove pixel center offsetTechjar
Fragment coordinates always have a 0.5 offset from a whole integer, as that's where the pixel center is on modern GPUs. Therefore, we want to always round the fragment coordinates down for bounding box calculations. This also renders the pixel center offset useless, as 0.5 vs ~0.5833333 makes no difference when rounding down.
2021-05-31VideoCommon: Fix bounding box on AMD/OpenGL/WindowsPokechu22
Co-authored-by: Techjar <tecknojar@gmail.com>
2021-05-28VideoCommon: Move bounding box pixel quads rounding to shaderTechjar
This avoids rounding values that the game writes to the bounding box registers, especially the default values.
2021-05-27Skip indirect operation for out of bounds indirect stagesPokechu22
This fixes rendering issues in Viewtiful Joe (https://bugs.dolphin-emu.org/issues/12525), but it is not entirely hardware accurate, as hardware testing showed other, more complex behavior in this case. However, it should be good enough for our purposes.
2021-05-07PixelShaderGen: always run indirect stage logicPokechu22
Hardware testing has confirmed that fb_addprev and wrapping both run even when the indirect stage is disabled.
2021-05-07PixelShaderGen: Fix OOB tex coord indicesTillmann Karras
Previously we set the texture coordinate to zero, now we set the texture coordinate *index* to zero. This fixes the ripple effect of the Mario painting in Luigi's Mansion. Co-authored-by: Pokechu22 <Pokechu022@gmail.com>
2021-05-07PixelShaderGen: Remove unused num_texgens argumentPokechu22
It became unused in f039149198657c1891e1c6462ed30c31ed4b8486.
2021-05-07Split TevStageIndirect::mid into matrix_index and matrix_idPokechu22
2021-04-11DriverDetails: Fix broken vector bitwise AND on Mali driverssspacelynx
2021-03-06Convert BPMemory to BitField and enum classPokechu22
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-06Convert XFMemory to BitField and enum classPokechu22
Additionally a new ClipDisable union has been added (though it is not currently used by Dolphin).
2020-11-20LightingShaderGen: Always calculate lighting for both color channelsStenzek
Cel-damage depends on lighting being calculated for the first channel even though there is no color in the vertex format (defaults to the material color). If lighting for the channel is not enabled, the vertex will use the default color as before. The default value of the color is determined by the number of elements in the vertex format. This fixes the grey cubes in Super Mario Sunshine. If the color channel count is zero, we set the color to black before the end of the vertex shader. It's possible that this would be undefined behavior on hardware if a vertex color index that was greater than the channel count was used within TEV.
2020-11-17VideoCommon: Migrate over to fmtLioncash
Migrates off the printf-based formatting where applicable.
2020-11-09ShaderGenCommon: Rename WriteFmt() to Write()Lioncash
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.