Philip Rebohle
a637134c56
[d3d11,dxbc] Use push constant instead of spec constant for rasterizer sample count
2022-07-03 13:41:06 +02:00
Philip Rebohle
87e2d70448
[dxbc] Remove bound spec constants from shader code
2022-07-03 13:41:06 +02:00
Philip Rebohle
db07861518
[dxvk] Remove old pipeline layout implementation
2022-06-28 14:35:58 +02:00
Philip Rebohle
79ecd4e94a
[dxbc] Pass new binding info struct to shaders
2022-06-28 14:32:31 +02:00
Philip Rebohle
304d0549d5
[dxbc] Implement range check for private array reads
...
We already do this for stores.
2022-04-21 18:06:41 +02:00
Philip Rebohle
8993560cde
[dxbc] Use new DxvkShader constructor
2022-04-18 13:20:16 +02:00
Philip Rebohle
0db26a0456
[dxbc] Actually do the skip range check thing properly
...
Turns out the first attempt only worked because my test case didn't
do any dynamically indexed stores at all, but broke everything else.
Oops.
2022-03-24 12:53:29 +01:00
Philip Rebohle
3ecd13cec2
[dxbc] Only emit temp array range check for dynamically indexed stores
...
Generates less code and makes things slightly more readable.
2022-03-24 12:47:40 +01:00
Philip Rebohle
c590736fec
[dxbc] Generate smallest possible vectors for local arrays
...
FXC is buggy and always emits vec4 in the array declaration,
so we'll have to analyze the used components ourselves.
2022-03-24 12:47:40 +01:00
Philip Rebohle
e440fa26ab
[dxbc] Handle fallthrough around default properly
2022-03-23 15:32:45 +01:00
Philip Rebohle
b015cf0bb2
[dxbc] Support switch-case fallthrough
...
Apparently this is a thing in Shader Model 4, although FXC cannot emit it.
2022-03-22 17:32:43 +01:00
Georg Lehmann
2550cff149
[build] Cleanup build system.
...
No changes except dropping support for msvc before 15.3.
2022-03-17 01:38:58 +00:00
Joshua Ashton
b96f65be31
[dxbc] Use new [[fallthrough]] attribute
2022-03-10 00:47:38 +01:00
Philip Rebohle
2f01df82d2
[dxbc] Fix invalid NonReadable/NonWritable decorations
2021-09-09 19:35:51 +02:00
Philip Rebohle
5db76784bd
[dxbc] Accurately determine access flags for UAVs
2021-09-09 15:53:02 +02:00
Georg Lehmann
789e19d2ac
[dxbc] Use BitMask helper
2021-08-16 08:49:46 -07:00
Philip Rebohle
546bd6f462
[dxbc] Fix swizzles in lod instruction
...
Fixes #1764 .
2021-08-05 22:57:58 +02:00
Philip Rebohle
e379f472f6
[dxbc] Implement hack to treat multisampled textures as normal textures
2021-07-02 05:52:05 +02:00
Philip Rebohle
81664fce44
[dxbc] Remove atomic counter workaround for ancient Mesa versions
...
No one should be using Mesa 19.0 at this point.
2021-06-18 15:44:58 +02:00
Philip Rebohle
7beb344f6f
[dxbc] Remove dxvk.useEarlyDiscard option
...
No longer relevant on drivers that support DemoteToHelperInvocation.
Closes #2109 .
2021-06-18 15:44:27 +02:00
Philip Rebohle
a1f3f6c971
[dxbc] Remove old RADV/LLVM workaround for early discard
...
We have Demote now, and ACO is the default.
2021-05-27 00:40:59 +02:00
Philip Rebohle
cf4ff820be
[dxbc] Handle shaders without refactoringAllowed flag
2021-03-18 17:46:45 +01:00
Philip Rebohle
96e1079526
[dxbc] Set usesDerivatives for gather and LOD query operations as well
...
Because these do implicitly use derivatives.
2021-02-21 14:24:54 +01:00
Philip Rebohle
0ba3e693c9
[dxbc] Clean up some texture handling code
2021-02-20 23:39:15 +01:00
Philip Rebohle
2d670ec3db
[dxbc] Enable capabilities for float control modes
...
Fixes some validation errors (but seriously, why does everything
have to be a capability in SPIR-V?)
2021-01-29 16:29:39 +01:00
Philip Rebohle
3a993d0c5c
[dxvk] Use only one spec constant for fragment shader output component mapping
...
Let's trust the driver to be able to constant-fold bitfieldExtract operations.
2021-01-29 16:17:07 +01:00
Philip Rebohle
307f43ff1e
[d3d11] Introduce option to disable float controls
...
And disable for SotTR since it introduces rendering issues.
2021-01-28 20:32:38 +01:00
Philip Rebohle
1478011822
[dxbc] Enable NaN fixup by default on older RADV versions
...
And get rid of a whole bunch of game-specific workarounds.
2021-01-28 19:37:10 +01:00
Philip Rebohle
f5fa7a9099
[dxbc] Set float control bits as necessary
2021-01-28 19:37:10 +01:00
Philip Rebohle
538b55921e
[dxbc] Conditionally return zeroes for unbound textures in shader
...
May allow the driver to optimize away texture operations.
2020-11-24 18:39:20 +01:00
Philip Rebohle
45461ee54e
[dxbc] Use opSelect for unbound texel fetch instructions
...
Generates less annoying code compared to control flow instructions,
and drivers should be able to optimize away the texture instruction
anyway since the bound state is a specialization constant.
2020-11-24 18:36:40 +01:00
Philip Rebohle
61a07fc9b9
[dxbc] Fix up incorrect infinity returned by f32tof16
...
Completely insane fix for #1826 .
2020-11-21 01:25:03 +01:00
Philip Rebohle
f81395c742
[dxbc] Fix operand modifiers on 64-bit types
2020-10-22 12:43:04 +02:00
Rhys Perry
73cb711f32
[dxbc] Bounds-check temporary array stores
...
Fixes flickering terrain in Just Cause 3 on RADV and possibly ANV.
2020-09-14 16:56:06 +02:00
Philip Rebohle
5750a7d85c
[dxbc] Fix the udiv crap again
2020-03-26 17:17:01 +01:00
Joshua Ashton
62c2c9cd15
[dxbc] Handle 0 divisors in UDiv
...
UDiv is defined as having 0xffffffff as both the quotient and remainder value when the divisor is 0
This fixes vertex corruption on the water bottles in Half-Life: Alyx
https://github.com/ValveSoftware/Proton/issues/3681
https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/udiv--sm4---asm-
2020-03-26 10:49:42 +01:00
Philip Rebohle
313d46984d
[dxbc] Fix memory semantics for atomic operations
2020-02-13 01:15:44 +01:00
Philip Rebohle
f12ddfa4d3
[dxbc] Fix line tessellation factor ordering
2020-02-12 12:00:46 +01:00
Philip Rebohle
76a6f6eab9
[dxbc] Add option to force memory barriers after shared memory stores
2020-02-08 00:48:42 +01:00
Philip Rebohle
9721938e57
[d3d11] Introduce d3d11.invariantPosition option
...
Apparently it's better to make app profiles than risk tanking
performance for all applications. Invariance rules in D3D11 are
undocumented so it's not clear what the correct solution is.
2020-01-23 01:28:19 +01:00
Philip Rebohle
11f08c7dea
[dxbc] Declare vertex positions as invariant
...
Otherwise, games relying on different vertex shaders to produce
the same numerical results may suffer from Z-fighting issues.
Fixes #1364 .
2020-01-22 23:59:51 +01:00
Philip Rebohle
6690a31d8d
[dxbc] Don't enable SPV_KHR_shader_draw_parameters
...
Core in SPIR-V 1.3.
2020-01-17 17:46:59 +01:00
Philip Rebohle
31948cae8c
[spirv] Allow specifying the SPIR-V version explicitly
...
We're going to use some SPIR-V 1.4 features for D3D11 if supported,
but 1.4 is not supported by all implementations.
2019-12-18 17:36:46 +01:00
Philip Rebohle
27ea176295
[d3d11] Remove d3d11.strictDivision option
2019-11-30 20:39:32 +01:00
Philip Rebohle
3b030d9569
[dxbc] Implement workaround to replace NaN render target outputs by zero
2019-11-30 20:39:32 +01:00
Philip Rebohle
49e7df96ec
[dxbc] Emit a spec constant for uniform buffers
...
This partially reverts commit fd547b666e
.
For some reason, not doing so breaks Overwatch (because of course it does).
2019-11-28 00:55:38 +01:00
Philip Rebohle
e95bc3256f
[d3d11] Move handling of constantBufferRangeCheck option to D3D11Options
2019-10-30 10:57:36 +01:00
Philip Rebohle
c4e5323e0e
[dxbc] Remove old constant buffer range check
2019-10-28 17:52:50 +01:00
Philip Rebohle
fd547b666e
[dxbc] Don't emit a spec constant for uniform buffers
2019-10-28 15:44:02 +01:00
Philip Rebohle
3d213efe53
[dxbc] Use SSBOs for dynamically indexed constant buffers if needed
...
SSBOs are tightly bound-checked on all Nvidia GPUs, so this allows for
a more accurate workaround for games relying on OOB access behaviour.
2019-10-28 15:42:46 +01:00
Philip Rebohle
68760f5b20
[dxbc] Parse dynamically indexed flag for constant buffers
2019-10-28 14:15:44 +01:00
Philip Rebohle
6888a98c89
[dxbc] Always set geometry shader invocation count
...
Fixes validation errors when the DXBC shader does not specify
the invocation count itself.
2019-10-26 23:19:59 +02:00
Philip Rebohle
144f4badef
[dxbc] Always allocate at least one input array element
...
Turns out that shaders with no inputs can still have an input signature,
in which case we were generating a zero-length array which is illegal.
2019-10-26 23:13:59 +02:00
Philip Rebohle
2d6a3396dd
[dxbc] Declare length of shader input array late
...
Otherwise, we generate out-of-bounds array reads and writes
in broken ENB shaders.
2019-10-23 16:36:52 +02:00
Philip Rebohle
59d4556641
[dxbc] Extend scalar constants to vectors if required
...
Needed for ENB. Fixes #865 .
2019-10-23 15:26:22 +02:00
Philip Rebohle
ec8ca8a403
[dxbc] Assume vec4 type for i/o vars not declared in signature
...
Works around an ENB bug.
2019-10-23 15:26:22 +02:00
Philip Rebohle
3e12a116bb
[dxbc] Declare temp registers on demand
...
And ignore dcl_temps. Needed to successfully compile some broken
ENB shaders (this does work on Windows too). See #865 .
2019-10-23 13:55:04 +02:00
Philip Rebohle
8211225ad4
[dxbc] Swap OpSelect arguments for Ne/Dne, don't use OpLogicalNot
...
Saves one instruction.
2019-10-18 03:22:20 +02:00
Philip Rebohle
803ec3542d
[dxbc] Fix sample positions
...
From the D3D11.3 functional specification:
"The sample position is relative to the pixel's center"
Fixes wine test failures.
2019-10-11 18:41:10 +02:00
Philip Rebohle
59d4e8a36a
[dxbc] Fix NaN handling in not-equal comparison
...
Ne and Dne are unordered in DXBC. Avoid FUnordNotEqual to
avoid potential issues with drivers and debugging tools.
2019-09-30 00:19:47 +02:00
Philip Rebohle
b6cf518962
Revert "[dxbc] Always decorate SV_POSITION as invariant"
...
This reverts commit 5ee790a4a3
.
Breaks Shadow of the Tomb Raider on Nvidia for unknown reasons.
2019-09-24 23:01:36 +02:00
Philip Rebohle
5ee790a4a3
[dxbc] Always decorate SV_POSITION as invariant
...
Apparently fixes Z-Fighting in Saints Row IV on Nvidia.
2019-09-24 22:19:43 +02:00
Philip Rebohle
f38cfd592e
[dbxc] Actually fix callc implementation
...
Yeah maybe we should close our blocks properly. There seems to be
no way to generate a callc instruction with fxc so this is untested.
2019-09-22 22:36:42 +02:00
Philip Rebohle
94ce76da6b
[dxbc] Implement label, call and callc instructions
...
Fixes #1200 .
2019-09-22 22:28:58 +02:00
Philip Rebohle
17a6c4168e
[dxbc] Implement stencil ref export from fragment shaders
...
This is an optional feature in D3D11.3, but easy enough to support.
2019-09-16 12:42:15 +02:00
Philip Rebohle
26afaba410
[dxbc] Implement MSAD4 instruction
...
Apparently we're required to support this for Direct3D 11.2+.
There are currently no known games that require this instruction.
2019-09-16 12:42:14 +02:00
Philip Rebohle
6ab074c95b
[dxbc] Only use atomic append/consume optimization in compute shaders
...
- For fragment shaders, this isn't safe since ballots include helper invocations
- For vertex shaders, if drivers don't support subgroup operations in those
stages, we don't want it to affect the performance of compute shadres.
2019-07-26 14:07:39 +02:00
Philip Rebohle
9c5102e257
[dxvk] Don't duplicate geometry shader system value outputs
...
Fixes #1121 . The basic idea here is that all built-ins that can be
written by the GS will be consumed as built-ins by the FS anyway,
so we do not need to keep the o# variable around.
2019-07-24 18:18:20 +02:00
Philip Rebohle
8644d75722
[dxbc] Use OpDemoteToHelperInvocationEXT for discards if supported
2019-07-11 19:33:17 +02:00
Liam Middlebrook
2e83aae472
[dxbc] Print shader signatures at debug loglevel
2019-07-11 12:40:44 +02:00
Liam Middlebrook
ff4fa29304
[dxbc] Add string output function for DxbcRegMask
2019-07-11 12:40:44 +02:00
Liam Middlebrook
2164a44887
[dxbc] Add ostream operator for DxbcScalarType
2019-07-11 12:40:44 +02:00
Philip Rebohle
06d4e06d8a
[dxbc] Enable early discard on RADV/ACO
...
Still can't enable on LLVM due to GPU hangs. The way we detect it
may have to change in the future, but for now, this should do.
2019-07-08 16:30:56 +02:00
Philip Rebohle
58dcf77c08
[dxbc] Disable atomic counter optimization on old RADV versions
...
Breaks TressFX in Tomb Raider 2013 for some reason, whereas this works
fine on 19.1 with both LLVM 8.0 and 9.0-git.
2019-06-15 12:58:31 +02:00
Philip Rebohle
d5ba36443e
[dxbc] Fix useRawSsbo option
...
Add some break to fix some breakage.
2019-06-11 20:23:47 +02:00
Philip Rebohle
d755b18ccb
[dxbc] Repurpose useRawSsbo option
...
Basically, abuse the minSsboAlignment property to convince the
compiler to always/never emit raw SSBOs for raw and structured
buffers, and use the actual device limit by default.
2019-06-11 20:20:40 +02:00
Philip Rebohle
0f7c23c022
[dxbc] Always use raw storage buffers if alignment requirements are met
2019-06-11 20:20:40 +02:00
Philip Rebohle
163e6aaa50
[dxbc] Store alignment for raw and structured buffers
2019-06-11 20:20:40 +02:00
Philip Rebohle
7d9a75c82c
[dxbc] Use subgroup operations for atomic append/consume operations
...
Reduces the number of atomic operations performed per subgroup to 1.
2019-05-15 19:32:27 +02:00
Philip Rebohle
d94d89c3ef
[dxbc] Add option to use subgroup ops for atomic counter operations
...
This can greatly reduce the number of atomic operations when using
append/consume buffers.
2019-05-15 18:49:02 +02:00
Philip Rebohle
04e6479690
[dxbc] Remove old spec constant code
2019-05-01 01:57:34 +02:00
Philip Rebohle
dc3cfc9fa0
[dxbc] Use new spec constant API for rasterizer sample count
2019-05-01 01:57:34 +02:00
Philip Rebohle
7111af423d
[dxbc] Add new emitNewSpecConstant method
...
Convenience method to declare new specialization constants.
2019-05-01 01:57:34 +02:00
Philip Rebohle
dc52212873
[dxbc] Disable Constant Buffer Range Check on AMD
...
The hardware already behaves as intended, no need to waste GPÜ cycles.
2019-04-30 16:07:24 +02:00
Philip Rebohle
3b1e753bb5
[dxvk] Re-implement early discard with quad granularity
...
May perform better on some hardware in situations where we cannot
discard a full subgroup. Closes #753 .
2019-04-30 14:46:03 +02:00
Danylo Piliaiev
261d31cac6
[dxbc] Fix xfb passthrough for system values
...
vReg should be always allocated for system values which is
necessary for emitXfbOutputSetup and is already done for
hull shader passthrough.
Signed-off-by: Danylo Piliaiev <danylo.piliaiev@globallogic.com>
2019-04-30 12:19:21 +02:00
Philip Rebohle
06c144f075
[dxbc] Store sample positions as vec2 array
...
We can append the zeroes in shader code instead. May
improve generated code on drivers that use scratch
memory or temporary uniform buffers for large arrays.
2019-04-29 14:04:42 +02:00
Philip Rebohle
b14ad7b30c
[dxbc] Remove some old TODOs
...
This is already implemented properly.
2019-04-29 11:48:09 +02:00
Philip Rebohle
04152055b7
[dxbc] Correctly report a sample count of 0 for unbound images
2019-04-29 11:48:09 +02:00
Philip Rebohle
a3e0157ab0
[dxbc] Correctly report a size of 0 for unbound images
2019-04-29 11:48:09 +02:00
Philip Rebohle
18cbaefdcb
[dxbc] Correctly report a size of 0 for unbound buffers
2019-04-29 11:48:09 +02:00
Philip Rebohle
ad5da34c57
[dxbc] Fix typo in sample positions
2019-04-29 11:48:09 +02:00
Philip Rebohle
b44cad4d32
[dxbc] Replace computeResourceSlotId by light-weight alternatives
...
Slightly reduces overhead of D3D11 binding methods.
2019-04-18 10:06:15 +02:00
Philip Rebohle
35a2a02714
[dxbc] Do not emit GS system values if rasterization is disabled
...
Fixes issue in Star Citizen, which declares a max output vertex count
of 128 in a geometry shader which emits eight components per vertex,
which becomes 12 components in DXVK due to the gl_Position builtin.
This should keep us below the magic limit of 1024 output components.
2019-04-15 09:00:46 +02:00
Philip Rebohle
5819a69302
[d3d11] Add option to enable constant buffer range checks
2019-04-05 20:56:32 +02:00
Philip Rebohle
9b99c55a2e
[dxbc] Implement optional constant buffer range check
2019-04-05 20:56:29 +02:00
Philip Rebohle
0326258829
[dxbc] Use SDiv instead of ShiftRightLogical for index calc on Nvidia
...
Reportedly fixes Resident Evil 2 and Devil May Cry 5 on Nvidia.
2019-03-09 19:59:56 +01:00
Philip Rebohle
6d814b24da
[dxbc] Fix invalid SPIR-V for FirstBitHi / FirstBitShi on vectors
...
Refs #930 .
2019-02-23 21:27:40 +01:00
Philip Rebohle
d12a8e09a8
[dxbc] Decorate integer fragment shader builtins as flat
...
Fixes yellow tint in Unreal Engine 4 games on RADV and AMDGPU-PRO.
2019-02-23 14:33:59 +01:00
Philip Rebohle
38c6eeed26
[dxbc] Only emit depth clamp in fragment shader if necessary
...
We don't need this if the depth clip extension is supported
by the driver.
2019-02-19 14:27:21 +01:00