Commit Graph

123 Commits

Author SHA1 Message Date
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
Ryan Houdek e1d36f91fc Fix a few asserts in the VertexShaderGen.
Removes a couple asserts in the vertex shader gen when dealing with the input form.
Typically input form ABC1 is used, so it'll pull in the first three elements and always set the fourth to 1.0
The other input form available is AB11, which sets the last two components to 1.0 (Theoretically).
No titles actually use this input form that we know of except for Project M, but it can have some fairly drastic visual differences.

Confirmed correct by hardware test
2016-02-29 16:43:44 -06:00
Jules Blok 6d1628eda4 Revert "Merge pull request #3578 from Armada651/forced-slow-depth"
This reverts commit e2a1a085b6, reversing
changes made to 2aea549eef.
2016-02-29 00:55:51 +01:00
Jules Blok e2a1a085b6 Merge pull request #3578 from Armada651/forced-slow-depth
VideoConfig: Replace FastDepthCalc by ForcedSlowDepth.
2016-02-22 11:29:09 +01:00
Tillmann Karras 4ecd191a7e VertexShaderGen: turn pseudo-mod into a simple and
The type of posmtx has changed over time: half -> float -> int.
I assume this is supposed to be a modulo.
2016-02-20 03:29:08 +00:00
Jules Blok 9805f70913 VideoConfig: Replace FastDepthCalc by ForcedSlowDepth.
Fast depth is now more accurate than slow depth and should always be used.
The option will be kept in a different form as it is still used as a hack to fix some games.
Also, the slow depth code path will still be relied upon by cards that don't support GL_ARB_clip_control.
2016-02-08 12:26:55 +01: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
Stenzek 617f9d9532 ShaderGen: Remove virtual methods from ShaderGeneratorInterface, move string buffer to ShaderCode
This fixes the crashes occuring at startup with a non-empty shader cache.
Because LinearDiskCache reads/writes to the storage of ShaderUid, ShaderUid must be trivially copyable.
Additionally, adds a static assert to LinearDiskCache to ensure this doesn't happen in the future.

The initialization of ShaderUid data has been moved to the code generation functions, so the above condition holds true.
2016-01-02 17:35:06 +10:00
Markus Wick 281860eafa Merge pull request #3400 from lioncash/shadergen
ShaderGen: Get rid of static buffers
2015-12-28 10:09:11 +01:00
Lioncash c151fe582f ShaderGenerators: Remove unnecessary inline keywords
Static by itself is sufficient
2015-12-26 17:57:32 -05:00