Commit graph

188 commits

Author SHA1 Message Date
Liam a45baa0e78 shader_recompiler: support const buffer indirect addressing on OpenGL SPIR-V 2022-04-01 11:17:54 -04:00
ameerj 67159e3be7 dead_code_elimination_pass: Remove unreachable Phi arguments 2022-03-23 17:57:22 -04:00
ameerj f10d40a0a2 shader_recompiler/dead_code_elimination: Add DeadBranchElimination pass
This adds a pass to eliminate if(false) branches within the shader code
2022-03-22 02:39:31 -04:00
ameerj 574a2c4b77 shader_recompiler: Reduce unused includes 2022-03-20 02:25:08 -04:00
Liam 3009d0bd7d Address review comments 2022-03-17 14:48:18 -04:00
Liam e228a40db8 shader_recompiler: Use functions for indirect const buffer accesses 2022-03-17 13:30:21 -04:00
Liam 52895fab67 shader: add support for const buffer indirect addressing 2022-03-14 19:43:32 -04:00
Fernando S cd07a43724
Merge pull request #8008 from ameerj/rescale-offsets-array
rescaling_pass: Fix rescaling Color2DArray ImageFetch offsets
2022-03-15 00:08:22 +01:00
Fernando Sahmkow ec9f0f064e Shader decompiler: Fix storage tracking in deko3d. 2022-03-13 17:41:16 +01:00
ameerj f87f8d4610 rescaling_pass: Fix rescaling Color2DArray ImageFetch offsets
ImageFetch offsets for 2D array coordinates have a different composite size than the coordinates. The rescaling pass was not taking this into account.

Fixes broken shaders when scaling is enabled in Astral Chain, and likely other titles.
2022-03-12 03:31:56 -05:00
ameerj 90a0506d56 lower_int64_to_int32: Add 64-bit atomic fallbacks 2022-01-29 19:56:02 -05:00
ameerj ad58d7eae7 shaders: Add U64->U32x2 Atomic fallback functions 2022-01-29 19:55:53 -05:00
ameerj 4790ba7839 spirv_atomic: Define U32x2 storage buffers for 64-bit storage atomics
Some drivers do not support 64-bit atomics, and fallback to atomically modifying U32x2 vectors. This change ensures that U32x2 storage vectors are defined in the spir-v shader when 64-bit atomics are used.

Fixes a hang on some devices, notably Intel GPUs, when booting Pokemon Legends Arceus
2022-01-28 19:00:04 -05:00
ameerj 14ac0c2923 shader: Add integer attribute get optimization pass
Works around an nvidia driver bug, where casting the integer attributes to float and back to an integer always returned 0.
2021-12-29 19:03:49 -05:00
Fernando Sahmkow 6f98690963 ShaderCache: Better fix for Shuffling gl_FragCoord 2021-11-16 22:11:33 +01:00
FernandoS27 de1c8c5c2c Texture Cahe/Shader decompiler: Resize PointSize on rescaling, refactor and make reaper more agressive on 4Gb GPUs. 2021-11-16 22:11:33 +01:00
ameerj 581ea90062 rescaling_pass: Fix IR errors when unscalable texture types are encountered 2021-11-16 22:11:30 +01:00
ameerj 99eec162da rescaling_pass: Logic simplification and minor style cleanup 2021-11-16 22:11:30 +01:00
ameerj 276565973f rescaling_pass: Scale ImageFetch offset if it exists
Plus some code deduplication
2021-11-16 22:11:30 +01:00
ameerj dd66384451 rescaling_pass: Enable PatchImageQueryDimensions on fragment stages 2021-11-16 22:11:30 +01:00
ameerj b027fac794 gl_texture_cache/rescaling_pass: minor cleanup 2021-11-16 22:11:30 +01:00
ameerj edb5844240 rescaling_pass: Fix and simplify shuffle/fragcoord pass 2021-11-16 22:11:30 +01:00
Fernando Sahmkow b3a9c8f108 Shader: Don't rescale FragCoord if used by Shuffle 2021-11-16 22:11:30 +01:00
Fernando Sahmkow dfa8291526 RescalingPass: Agregate pixels on texelFetch while on Fragment Shader 2021-11-16 22:11:29 +01:00
Fernando Sahmkow 8f78444de3 shader: Fix TextureSize check on rescaling. 2021-11-16 22:11:29 +01:00
ReinUsesLisp e66d5b88a6 shader: Properly scale image reads and add GL SPIR-V support
Thanks for everything!
2021-11-16 22:11:29 +01:00
ReinUsesLisp fc9bb3c3fe shader: Properly blacklist and scale image loads 2021-11-16 22:11:29 +01:00
ReinUsesLisp 01379c5e3c shader/rescaling_pass: Patch more instructions 2021-11-16 22:11:28 +01:00
ReinUsesLisp c15332c44f shader: Add IsTextureScaled opcode 2021-11-16 22:11:28 +01:00
ReinUsesLisp e580299467 shader: Fix rescaling pass 2021-11-16 22:11:28 +01:00
ReinUsesLisp 1672e9ba09 shader: Fix resolution scaling pass 2021-11-16 22:11:27 +01:00
Fernando Sahmkow 360e897ccd ShaderDecompiler: Add initial support for rescaling. 2021-11-16 22:11:27 +01:00
Fernando Sahmkow 194579bc4f ShaderCache: Fix Phi Nodes Type on OGL. 2021-11-01 22:26:17 +01:00
Fernando Sahmkow c50ad56bf5 ShaderCache: Order Phi Arguments from farthest away to nearest. 2021-10-31 19:34:15 +01:00
Fernando Sahmkow e5291e2031 TexturePass: Fix clamping of images as this allowed negative indices. 2021-10-24 20:46:36 +02:00
Fernando Sahmkow 3f4444b552 Shader Compiler: avoid overflowed indices on indixed samplers. 2021-10-17 03:38:09 +02:00
Morph db07ca6c7f
Merge pull request #6767 from ReinUsesLisp/fold-float-pack
shader: Fold UnpackFloat2x16 and PackFloat2x16
2021-07-30 02:07:52 -04:00
bunnei a98f14e9b0
Merge pull request #6722 from ReinUsesLisp/xmad-opts
shader: Fold integer FMA from Nvidia's pattern
2021-07-29 18:45:37 -07:00
ReinUsesLisp 8c9febe8f7 shader: Fold UnpackFloat2x16 and PackFloat2x16
Simplifies the code a bit when possible. These instructions should be
no-ops codegen wise.
2021-07-29 21:22:52 -03:00
ReinUsesLisp 1bb46b7d64 shader: Mark ConvertF16F32 and ConvertF32F16 as fp16 instructions
Fixes instances where fp16 types are not declared on SPIR-V but they are
used. This shouldn't happen on master, as it's been uncovered by an
additional optimization pass.
2021-07-27 21:33:05 -03:00
ReinUsesLisp 66a0cedba3 shader: Fold integer FMA from Nvidia's pattern
Fold shaders doing "a * b + c" on integers from the pattern generated by
Nvidia's GL compiler.

On a somewhat complex compute shader it reduces the code size by 16
instructions from 2 matches on Turing GPUs.

On Intel as extracted from KHR_pipeline_executable_properties:
Before the optimization:
```
Instruction Count: 2057
Basic Block Count: 45
Scratch Memory Size: 14752
Spill Count: 232
Fill Count: 261
SEND Count: 610
Cycle Count: 11325
```

After the optimization:
```
Instruction Count: 2046
Basic Block Count: 44
Scratch Memory Size: 13728
Spill Count: 219
Fill Count: 268
SEND Count: 604
Cycle Count: 11367
```
2021-07-26 04:58:02 -03:00
ReinUsesLisp 09fb41dc63 shader: Use TryInstRecursive on XMAD multiply folding
Simplify a bit the logic.
2021-07-26 04:15:27 -03:00
ReinUsesLisp bf2956d77a shader: Avoid usage of C++20 ranges to build in clang 2021-07-22 21:51:40 -04:00
lat9nq 49946cf780 shader_recompiler, video_core: Resolve clang errors
Silences the following warnings-turned-errors:
-Wsign-conversion
-Wunused-private-field
-Wbraced-scalar-init
-Wunused-variable

And some other errors
2021-07-22 21:51:40 -04:00
ameerj 41c6cb70f9 glsl: Fix tracking of info.uses_shadow_lod 2021-07-22 21:51:40 -04:00
ameerj 57f222c56e dual_vertex_pass: Clang format 2021-07-22 21:51:40 -04:00
ReinUsesLisp 7dafa96ab5 shader: Rework varyings and implement passthrough geometry shaders
Put all varyings into a single std::bitset with helpers to access it.

Implement passthrough geometry shaders using host's.
2021-07-22 21:51:39 -04:00
lat9nq 257d2aab74 lower_int64_to_int32: Add missing include 2021-07-22 21:51:39 -04:00
ReinUsesLisp d8d5501459 shader: Add int64 to int32 lowering pass 2021-07-22 21:51:39 -04:00
ReinUsesLisp 04ef2160f9 shader: Teach global memory base tracker to follow vectors 2021-07-22 21:51:39 -04:00