Commit graph

132 commits

Author SHA1 Message Date
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
Admiral H. Curtiss
b93adeaad7 VertexShaderGen: Fix unescaped { in D3D shader. 2020-10-19 20:05:07 +02:00
Lioncash
4b21bc7508 LightingShaderGen: Transition over to fmt 2020-07-24 13:50:09 -04:00
Lioncash
7f7db6d3e7 VertexShaderGen: Transition over to using fmt 2020-07-24 13:34:47 -04:00
Lioncash
149a97e396 VideoCommon: Remove unnecessary memset on ShaderUid instances.
Zero-initialization zeroes out all members and padding bits, so this is
safe to do. While we're at it, also add static assertions that enforce
the necessary requirements of a UID type explicitly within the ShaderUid
class.

This way, we can remove several memset calls around the shader
generation code that makes sure the underlying UID data is zeroed out.
Now our ShaderUid class enforces this for us, so we don't need to care about
it at the usage sites.
2019-05-30 06:41:54 -04:00
Stenzek
1d61041985 ShaderGen: Don't use interface blocks on Vulkan without GS
Doing so causes the Adreno driver to choke and spew errors about
too many output locations/components, when clearly we're under
the limit.
2019-01-24 17:02:17 +10:00
Stenzek
68cb24172b ShaderGen: Omit some unused varyings when possible
Removes the clipPos varying unless slow-depth is used, and the
clipDistance varyings if geometry shaders are not used.
2019-01-23 18:34:22 +10:00
Lioncash
50a476c371 Assert: Uppercase assertion macros
Macros should be all upper-cased. This is also kind of a wart that's
been sticking out for quite a while now (we avoid prefixing
underscores).
2018-03-14 22:03:12 -04:00
Stenzek
efb9759862 LightingShaderGen: Always calculate lighting for both color channels
Cel-damage uses the color from the lighting stage of the vertex pipeline
as texture coordinates, but sets numColorChans to zero.

We now calculate the colors in all cases, but override the color before
writing it from the vertex shader if numColorChans is set to a lower value.
2017-11-22 01:52:18 +10:00
Stenzek
e17efb1d8d ShaderGen: Use consistent variable names for texture coordinates 2017-07-30 17:43:59 +10:00
Stenzek
3ea9d86faa ShaderGen: Pass host config to shader generation functions
Also moves the host config checks to common.
2017-07-20 17:54:33 +10:00
Stenzek
82c27182a8 ShaderGen: Remove host state from shader uids 2017-07-20 17:46:59 +10:00
Michael Maltese
d10d09ccc1 VideoCommon: rework anamorphic widescreen heuristic
Some widescreen hacks (see below) properly force anamorphic output, but
don't make the last projection in a frame 16:9, so Dolphin doesn't
display it correctly.

This changes the heuristic code to assume a frame is anamorphic based on
the total number of vertex flushes in 4:3 and 16:9 projections that
frame. It also adds a bit of "aspect ratio inertia" by making it harder
to switch aspect ratios, which takes care of aspect ratio flickering
that some games / widescreen hacks would be susceptible with the new
logic.

I've tested this on SSX Tricky's native anamorphic support, Tom Clancy's
Splinter Cell (it stayed in 4:3 the whole time), and on the following
widescreen hacks for which the heuristic doesn't currently work:

Paper Mario: The Thousand-Year Door (Gecko widescreen code from Nintendont)
C202F310 00000003
3DC08042 3DE03FD8
91EEF6D8 4E800020
60000000 00000000
04199598 4E800020
C200F500 00000004
3DE08082 3DC0402B
61CE12A2 91CFA1BC
60000000 387D015C
60000000 00000000
C200F508 00000004
3DE08082 3DC04063
61CEE8D3 91CFA1BC
60000000 7FC3F378
60000000 00000000

The Simpsons: Hit & Run (AR widescreen code from the wiki)
04004600 C002A604
04004604 C09F0014
04004608 FC002040
0400460C 4082000C
04004610 C002A608
04004614 EC630032
04004618 48220508
04041A5C 38600001
04224344 C002A60C
04224B1C 4BDDFAE4
044786B0 3FAAAAAB
04479F28 3FA33333
2017-04-05 17:23:16 -07:00
iwubcode
a9d08a31a6 Add configurable toggle that rounds vertices to the nearest pixel when
w=1.  This fixes some games at higher IRs.
2017-04-04 09:52:18 -05:00
Jules Blok
cbfb07152f VertexShaderGen: Correct for negative viewport dimensions. 2017-03-16 12:34:19 +01:00
Lioncash
468f623d27 ShaderGenCommon: Remove unnecessary includes 2017-02-01 12:19:55 -05:00
Jules Blok
f866748006 VertexShaderGen: Remove the need for an extra UID. 2017-01-13 14:01:17 +01:00
Jules Blok
ee7a2edf35 Update comments 2016-12-27 21:32:52 +01:00
Jules Blok
ef82aebb97 VideoCommon: Don't process the depth range in the vertex shader if it's not oversized. 2016-12-27 14:31:17 +01:00
Vincent Duvert
8bb459aae5 VideoCommon: Fix GetInterpolationQualifier calls
Commit 4969415 modified calls to GetInterpolationQualifier, but mistakenly changed the order of some boolean parameters: GetInterpolationQualifier(true, false) was changed to GetInterpolationQualifier(…, false, true).

Should fix #9783.
2016-10-16 12:48:32 +02:00
degasus
083be0832f LightingShader: Drop xfmem usage.
Our shaders must only depend on the UID, not on any global state.
2016-10-04 10:13:46 +02:00
Stenzek
a71381e80a VideoCommon: Add APIType entry for Vulkan 2016-10-01 01:09:11 +10:00
Stenzek
7f3a876aae ShaderGen: posmtx should be a 4-component unsigned byte
This is a global change across backends, so should be tested for
regressions.
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
50984d85b0 Merge pull request #4164 from Armada651/sonic-clipping
VertexShaderGen: Move the sonic epsilon hack to the vertex shader.
2016-09-01 15:28:09 +02:00
EmptyChaos
e0d4dc6fed VertexShaderGen: Fix D3D X3014 compile error
float2 requires 2 parameters in HLSL apparently.
2016-09-01 14:43:19 +10:00
Jules Blok
debaf63fe8 VertexShaderGen: Move the sonic epsilon hack to the vertex shader.
In the vertex shader we have control over the depth clipping planes,
so we don't have to offset every floating point value and lose accuracy.
2016-09-01 01:14:14 +02:00
Preston Smith
94cbe0c12a Comments 2016-08-31 06:40:50 -05:00
Preston Smith
5a6b876dbd Hardware renderer fix 2016-08-30 18:33:23 -05:00
Jules Blok
7078216b61 Improve documentation. 2016-08-16 21:09:58 +02:00
Jules Blok
8c1c7fc2da Cosmetics. 2016-08-15 13:11:30 +02:00
Jules Blok
959d1879e5 VertexShaderGen: Fix far clipping.
We should only check whether z > 0, we don't care about w.
2016-08-15 13:11:29 +02:00
Jules Blok
94927f360f VideoCommon: Add a user-defined far clipping plane. 2016-08-15 13:11:28 +02:00
Jules Blok
a141e91dd2 OGL: Check for GL_DEPTH_CLAMP support.
It's not available in OpenGL ES and officially it's not supported on OpenGL 3.0/3.1.

Fallback to old depth range code if there is no method to disable depth clipping.
It's more important to have correct clipping than to have accurate depth values.
Inaccurate depth values can be fixed by slow depth.
2016-08-15 13:11:26 +02:00
Jules Blok
4582853af4 VertexShaderGen: Use reversed depth range. 2016-08-15 13:11:26 +02:00
Jules Blok
e9e81ece65 VideoBackends: Enable depth clamping. 2016-08-15 13:11:25 +02:00
Jules Blok
b1ed7e80fb VertexShaderGen: Clip z using user-defined clipping planes. 2016-08-15 13:11:25 +02:00
Jules Blok
159247f4ad VertexShaderGen: Clamp to the console depth range.
This fixes the Mii Channel among others.
2016-08-15 13:11:24 +02:00
Jules Blok
c223bd47b9 VideoCommon: Implement depth range equation in vertex shader. 2016-08-15 13:11:23 +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
Scott Mansell
1a831cfc7d Multithreadded Shadergen: Second Pass over vertex/lighting Shadergens
As much as possible, the asserts have been moved out of the GetUID
function. But there are some places where asserts depend on variables
that aren't stored in the shader UID.
2016-06-26 16:13:21 +12:00
Scott Mansell
4969415f38 Remove global refrences from common code.
Bug Fix: Previously vertex shaders and geometery shaders didn't track
         antialaising state in their UIDs, which could cause AA bugs
	 on directx.
2016-06-26 16:13:20 +12:00
Scott Mansell
53c402dbc5 Multithreadded Shadergen: First Pass over vertex/lighting Shadergens
The only code which touches xfmem is code which writes directly into
uid_data.

All the rest now read their parameters out of uid_data.

I also simplified the lighting code so it always generated seperate
codepaths for alpha and color channels instead of trying to combine
them on the off-chance that the same equation works for all 4 channels.

As modern (post 2008) GPUs generally don't calcualte all 4 channels
in a single vector, this optimisation is pointless. The shader compiler
will undo it during the GLSL/HLSL to IR step.

Bug Fix: The about optimisation was also broken, applying the color light
         equation to the alpha light channel instead of the alpha light
	 euqation. But doesn't look like anything trigged this bug.
2016-06-26 16:13:19 +12:00
Pierre Bourdon
3570c7f03a Reformat all the things. Have fun with merge conflicts. 2016-06-24 10:43:46 +02:00
Stenzek
e6b2212ec0 ShaderGen: Only specify storage qualifier in interface block when needed
Drivers that don't support GL_ARB_shading_language_420pack require that
the storage qualifier be specified even when inside an interface block.

AMD's driver throws a compile error when "centroid in/out" is used within
an interface block.

Our previous behavior was to include the storage qualifier regardless, but
this wasn't working on AMD, therefore we should check for the presence of
the extension and include based on this, instead.
2016-03-30 00:42:50 +10:00
Pierre Bourdon
ae4cb12033 Merge pull request #3719 from Sonicadvance1/workaround_osx_video_drivers
Workaround OS X video driver bug #24983074
2016-03-26 01:43:32 +01:00
Pierre Bourdon
421a67d7cc Merge pull request #3684 from Sonicadvance1/fix_vertexshadergen_asserts
Fix a few asserts in the VertexShaderGen.
2016-03-17 23:33:53 +01:00
Ryan Houdek
3ab7806e24 Workaround OS X video driver bug #24983074
OS X's shader compiler has a bug with interface blocks where interface block members don't properly inherit the layout qualifier from the interface
block.
Work around this limitation by explicitly stating the layout qualifier on both the interface block and every single member inside of that block.
2016-03-09 09:11:00 -06:00
Ryan Houdek
a8c37e5d6b Remove two more asserts in VertexShaderGen.
As confirmed by a hardware test if we are using the texgen type of COLOR_STRGBC0/STRGBC1 then it sets the texture coordinates to those values
regardless of what the input form or source row is.

Thanks to Ornox for testing again
2016-02-29 16:45:51 -06:00
Ryan Houdek
92e9382e61 Confirm with hardware test that the high bit of the input form is ignored.
Thanks to Ornox for testing
2016-02-29 16:45:51 -06:00