Commit Graph

285 Commits

Author SHA1 Message Date
Stenzek 9a5c2119e5 ShaderCache: Remove unused UID bits before inserting into shader map 2018-05-26 00:09:10 +10:00
spycrab 40bb9974f2 Reformat all the things! 2018-04-12 21:28:39 +02:00
Lioncash f10198500e PixelShaderGen: Invert conditional in WriteColor()
Puts the true condition body first instead of the false one for better
reading.
2018-03-27 18:53:17 -04:00
Lioncash c9e0045881 PixelShaderGen: Remove dead code in WriteColor()
The outer conditional executes only whenever destination alpha is used.
2018-03-27 18:46:25 -04:00
Lioncash a52cc8d52b
PixelShaderGen/UberShaderPixel: Silence -Wmissing-braces warnings 2018-03-23 10:06:27 -04: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 340ee8fff8 PixelShaderGen: Implement table-based fog range as in software renderer 2018-02-15 22:19:21 +10:00
Jonathan Hamilton ceb1f8c8cb Enable shader_framebuffer_fetch blend path on ubershaders
Tested on a linux Intel Skylake integrated graphics with
blend_func_extended force-disabled, as it's the only platform I have
that doesn't crash with ubershaders and supports fb_fetch
2018-01-05 09:56:46 -08:00
Jonathan Hamilton 8d68adcaf3 Workaround qualcomm driver bug
It seems it doesn't like modifying inout variables in place - so instead
use a temporary for ocol0/ocol1 and only write them once at the end of
the shader
2018-01-05 09:56:46 -08:00
Jonathan Hamilton 29a9ed043b Implement dual-source blending in shader
For some GLES drivers that don't support dual-source blending, but do
support GL_EXT_shader_framebuffer_fetch, this might be useful.
2018-01-05 09:56:46 -08: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 b573319f8f D3D: Fix shader compile error with logicop and alpha test enabled 2017-09-07 11:48:01 +10:00
Stenzek 84f8ebd95f VideoBackends: Clear uid bits that are unused for the current backend
Currently, this is only the logic op bit, but this will be extended to
the framebuffer fetch/blend modes. In the future, when/if we move to
VideoCommon pipelines, this state will be part of the pipeline UID
anyway, and we can mask it out in the backend by using a two-level map,
so the shaders/programs are shared.
2017-09-05 23:49:42 +10:00
Stenzek 0622979d3b ShaderGen: Support writing integer colors when logic op is enabled
This is required for D3D to support logic op.
2017-09-03 16:33:25 +10:00
Stenzek 852e30bb8c Ubershaders: Fix 6-bit color truncation not being applied 2017-08-01 00:01:09 +10:00
Stenzek d54ca2a16a PixelShaderGen: Don't include host early z support in UID
Disable it at shader generation time instead. This way the UIDs are
sharable.
2017-07-30 17:43:59 +10:00
Stenzek e968c191ff Ubershaders: Support per-pixel lighting 2017-07-30 17:43:59 +10:00
Stenzek e17efb1d8d ShaderGen: Use consistent variable names for texture coordinates 2017-07-30 17:43:59 +10:00
Stenzek 81b4ed2a81 Vulkan: Uber shader support 2017-07-30 17:43:59 +10:00
Stenzek 7d78cf0f6f ShaderGen: Implement pixel ubershaders 2017-07-30 17:43:59 +10:00
Stenzek 07591e7d5c PixelShaderGen: Move header generation to seperate function 2017-07-30 17:43:59 +10:00
Scott Mansell 479abde9f4 BPMemory: Convert a number of unions to BitFields 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
Jules Blok 8476d0271d PixelShaderGen: Add missing inputs.
This fixes a linkage warning in D3D because of mismatched inputs.
2017-07-05 22:43:39 +02:00
Jonathan Hamilton 35caf48d7d Add a workaround for a PowerVR glsl compiler bug
It seems it doesn't like negating arguments for bitops, so suff like
"var <<= (-othervar);"
fails to compile
2017-05-03 19:33:56 -07:00
Michael Maltese 134317e07f videoconfig: add BBoxPreferStencilImplementation
@JMC47 requested this to be able to do performance comparisons.
2017-03-15 17:41:33 -07:00
Michael Maltese de940a5fd6 VideoConfig: add bSupportsFragmentStoresAndAtomics 2017-03-15 17:20:47 -07:00
Tillmann Karras 8a72e84ece VideoCommon: remove unnecessary trunc() 2017-03-05 01:53:54 +00:00
Lioncash 273ace7bb7 LightingShaderGen: Remove unnecessary includes 2017-02-01 01:06:00 -05:00
degasus 41b0c74e30 VideoCommon: Make dst_alpha state implicit. 2017-01-04 20:02:31 +01:00
Stenzek 5aaa5141ed PixelShaderGen: Fix incorrect indexing of tevLerpBias
Fixes the white box in the fortune street fifolog.
2016-12-13 00:03:25 +10:00
Jules Blok 2058a49465 PixelShaderGen: Remove unused global variable. 2016-10-31 15:02:08 +01:00
Jules Blok 086f839435 DriverDetails: Make the bug identifiers humanly readable. 2016-10-31 15:02:08 +01:00
Jules Blok d0e60492cf PixelShaderGen: Don't use a global variable. 2016-10-30 00:48:02 +02:00
Jules Blok ce9f717045 OGL: Fall back to the old dual-source blending behaviour. 2016-10-29 18:00:22 +02:00
Jules Blok 122ce96ed1 PixelShaderGen: Don't use dual source blend if unsupported. 2016-10-24 00:11:55 +02:00
Jules Blok 5c406b5ef0 PixelShaderGen: Fix implicit type conversions. 2016-10-23 19:54:28 +02:00
Jules Blok 93109df654 PixelShaderGen: Use dual source blending to do 8-bit blending. 2016-10-10 15:34:55 +02:00
Jules Blok d61ae5a88a PixelShaderGen: Only set dither uid bit if actually used. 2016-10-10 14:32:21 +02:00
Jules Blok 365e88e311 VideoConfig: Add an option to force RGB8 EFB format. 2016-10-10 14:31:53 +02:00
Jules Blok 31a4ee7bfc PixelShaderGen: Always truncate the alpha channel to 6-bit. 2016-10-10 14:30:14 +02:00
Jules Blok 9bc466a443 PixelShaderGen: Add support for dithering. 2016-10-10 14:30:14 +02:00
Jules Blok b958457e51 PixelShaderGen: Add support for RGBA6 EFB format truncation. 2016-10-10 14:27:30 +02:00
degasus 6d2827ff6b PixelShader: Drop redundant warning.
This warning was raised both on UID generation and on shader generation.
2016-10-04 10:13:46 +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
degasus 829fc8f0ad PixelShaderGen: Drop dstAlphaMode constant in shader generation.
It is already stored within the UID.
2016-10-04 10:13:46 +02:00
Stenzek bac8c2d441 Vulkan: Work around indexed fragment output bug on AMD drivers 2016-10-01 02:40:02 +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 da43f9a156 PixelShaderGen: Always divide the texture coordinates by q.
Some games will set q to a different value than 1.0 through
texture matrix manipulations. It seems the console will still
do the division in that case.
2016-09-07 21:13:16 +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 d958388617 VideoCommon: Fix some warnings. 2016-06-26 23:10:31 +12:00
Scott Mansell 24e5d21780 Multithreadded Shadergen: Second pass over Pixel Shadergen.
Note: It's not 100% perfect, as some of the GPU capablities leak into the
pixel shader UID.

Currently our UIDs don't get exported, so there is no issue. But someone
might want to fix this in the future.
2016-06-26 16:13:21 +12: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 0d996f512b Multithreadded Shadergen: First pass over pixel Shadergen
Bug Fix: It was theoretically possible for a shader with depth writes
         disabled to map to the same UID as a shader with late depth
	 writes.
	 No known test cases trigger this.
2016-06-26 16:13:20 +12:00
Scott Mansell e99364c7c9 UID Change: Fix bug with indirect stage UIDs
Bug Fix: The normal stage UIDs were randomly overwriting indirect
         stage texture map UID fields. It was possible for multiple
	 shaders with diffrent indirect texture targets to map to
	 the same UID.
         Once again, it dpesn't look like this bug was ever triggered.
2016-06-26 16:13:19 +12:00
Scott Mansell 03f2c9648d Shader UID change: Only store the two bits of components we need.
This frees up 21 bits and allows us to shorten the UID struct by an entire
32 bits.

It's not strictly needed (as it's encoded into the length) but I added a
bit for per-pixel lighiting to make my life easier in the following
commits.
2016-06-26 16:13:19 +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 5fcb4bb3ab Further fixes to the formatting change. WX sucks. 2016-06-24 12:16:10 +02:00
Pierre Bourdon 3570c7f03a Reformat all the things. Have fun with merge conflicts. 2016-06-24 10:43:46 +02:00
Jeffrey Pfau d6517a761c VideoCommon: Simplify indirect texture lookup code slightly 2016-04-23 22:55:52 -07:00
Jeffrey Pfau aa736bf258 Revert "VideoBackend: Remove extraneous shifts from indirect texture lookups"
This reverts commit 1f1b127b69.
2016-04-23 22:55:42 -07:00
degasus ef01f234df PixelShaderGen: Fixes implicit type conversion or PR #3772.
This regression did only happen on OpenGL ES.
2016-04-10 12:49:32 +02:00
degasus 10e4f7e7bf PixelShaderGen: Move constant multiplication to constant generation.
No need to do this within the shader per pixel if it can be done once.
2016-04-09 12:25:00 +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
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
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 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
Jeffrey Pfau 1f1b127b69 VideoBackend: Remove extraneous shifts from indirect texture lookups 2016-01-25 19:27:26 -08:00
Pierre Bourdon 24c228c6e9 Merge pull request #3523 from lioncash/video
VideoCommon: Header cleanup
2016-01-18 02:24:50 +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 edebadc093 PixelShaderGen: Use bitwise AND for wrapping indirect texture coordinates
(x % y) is not defined in GLSL when sign(x) != sign(y).
This also has the added benefit of behaving the same as sampler wrapping modes, in regards to negative inputs.
2016-01-15 19:46:38 +10: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
Lioncash c151fe582f ShaderGenerators: Remove unnecessary inline keywords
Static by itself is sufficient
2015-12-26 17:57:32 -05:00
Lioncash 8ce3a4aa70 ShaderGeneration: Get rid of static buffers 2015-12-26 17:01:54 -05:00
degasus e26d9f7c35 MSAA: Store samples in ini files. 2015-12-15 09:41:01 +01:00
Andrew Wickham d9f1523a7b Make cast from int to float explicit in shader
This should fix this panic message I saw when playing Super Mario Strikers:

Failed to compile pixel shader [...]: error C7011: implicit cast from "int" to "float"
2015-11-30 13:35:46 -08:00
Tillmann Karras 71d1eb3c31 VideoCommon: return code/uid from shader gens
rather than passing in non-const references
2015-11-03 14:40:23 +01:00
Sintendo c4b56f06f9 Fix a few typos 2015-11-02 21:17:43 +01:00
Tillmann Karras 983978ee66 VideoCommon: flush vertex manager if components change 2015-11-01 22:39:31 +01:00
Tillmann Karras 7066689131 ShaderCaches: remove unneeded typedefs 2015-10-29 14:43:05 +01:00
Scott Mansell e7b2a22225 Support Conservative Depth as a fallback for EarlyZ
Allows Mesa based drivers to support ZCompLoc
2015-10-18 01:46:54 +13:00
Tillmann Karras 1df455bd13 PixelShaderGen: silence -Wformat-security warnings 2015-10-17 05:05:50 +02:00
Ilia Mirkin 5380fd9dba VideoCommon: fix variable types fed to Write() function 2015-10-16 18:20:36 -04:00
Scott Mansell 645e4cbbee PixelShaderGen: Use arrays of texture samplers. 2015-10-12 05:06:39 +13:00
degasus 1c0366993a VideoBackends: Reimplement SSAA, now for D3D + OGL 2015-09-06 19:40:00 +02:00
Ryan Houdek 9618738278 Remove all of our workarounds for Qualcomm devices we don't support anymore. 2015-09-04 23:45:35 -05:00
Lioncash 71ef0a0245 PixelShaderGen: Use spaces instead of tabs for vertical alignment 2015-09-01 12:20:50 -04:00
Lioncash 91eff28699 PixelShaderGen: Move defines into the implementation file
These aren't used outside of it. This also reduces the amount of things in
the global namespace.
2015-09-01 12:18:18 -04:00
Lioncash c760ffbd28 BPMemory/XFMemory: Convert defines to enums
These actually convey a concrete type, as well as also providing a
symbolic constant during debugging.
2015-09-01 12:07:10 -04:00
Rohit Nirmal 6252d2d71a Fix building with PCH disabled. 2015-08-28 14:13:28 -05:00
Ryan Houdek 3242e1a617 Fix the shader overrunning our max shader size.
The Star Wars games really push the hardware to its limits, which can cause the shaders that are produced to be 18kb or more.
Double our maximum shader size to compensate.
Fixes issue #8860
2015-08-22 01:01:03 -05:00
Ryan Houdek c1df6d7b4e Work around PowerVR's shader compiler.
This bug has been reported to IMGTec at https://pvrsupport.imgtec.com/ticket/472

The basic idea of the bug is that if you're doing a bitwise and  of a constant value vector with a constant scalar value, this causes PowerVR's shader
compiler to fail out with a very non-descriptive message.
Working around the issue by making the value a vector that it is being masked by.
2015-07-20 22:04:16 -05:00
Jules Blok ef1dfa8bcb VideoBackends: Allow the viewport to use the full depth range. 2015-06-06 03:37:46 +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
Ryan Houdek 69963dc4b0 Merge pull request #2274 from degasus/disable_bbox
Disable bbox
2015-05-25 08:46:12 -04:00
Tillmann Karras 30ebb2459e Set copyright year to when a file was created 2015-05-25 13:22:31 +02:00