Commit graph

235 commits

Author SHA1 Message Date
gdk
c95cdc853e Enable shader cache on Vulkan and implement MultiplyHighS32/U32 on SPIR-V (missed those before) 2022-06-17 22:45:57 +01:00
gdk
4f086b0ec9 Shader specialization for new Vulkan required state (fixes remaining alpha test issues, vertex stretching on AMD on Crash Bandicoot, etc) 2022-06-17 22:45:00 +01:00
gdk
f16b47114c SPIR-V: Workaround for Intel FrontFacing bug 2022-06-17 22:42:56 +01:00
gdk
ad081de56b SPIR-V: Fix ImageLoad CompositeExtract component type 2022-06-17 22:42:56 +01:00
gdk
0a7fbb6bfd SPIRV/GLSL: More scaling related fixes 2022-06-17 22:42:56 +01:00
gdk
3aa5397bad SPIR-V: Fix another case of wrong field index 2022-06-17 22:42:56 +01:00
gdk
670431f4fa SPIR-V: Fix field index for scale count 2022-06-17 22:42:56 +01:00
gdk
0b27b3e470 SPIR-V: Resolution scale support and fix TextureSample multisample with LOD bug 2022-06-17 22:42:55 +01:00
gdk
f18e7aa779 SPIR-V: Implement StoreShader8/16 and StoreStorage8/16 2022-06-17 22:42:55 +01:00
gdk
3b444f0ea3 SPIR-V: Geometry shader passthrough support 2022-06-17 22:42:54 +01:00
gdk
cacc9c7da4 SPIR-V: Implement tessellation support 2022-06-17 22:42:54 +01:00
gdk
070996ad6d Ignore unsupported attributes rather than throwing (matches current GLSL behaviour) 2022-06-17 22:42:54 +01:00
gdk
d5e2cc2f9b SPIR-V: Constant buffer indexing support 2022-06-17 22:42:54 +01:00
gdk
1448136c3d SPIR-V: Implement LogicalExclusiveOr 2022-06-17 22:42:53 +01:00
gdk
324d0528d3 SPIR-V: Fix TextureSize for MS and Buffer sampler types 2022-06-17 22:42:53 +01:00
gdk
95d5a50042 SPIR-V: Implement attribute indexing and StoreAttribute 2022-06-17 22:42:53 +01:00
gdk
2ef7622126 SPIR-V: Fix SwizzleAdd and some validation errors 2022-06-17 22:42:52 +01:00
riperiperi
7882c0498b SPIR-V: Only use input attribute type for input attributes
Output vertex attributes should always be of type float.
2022-06-17 22:42:48 +01:00
riperiperi
cbeb40934f SPIR-V: Don't OpReturn if we already OpExit'ed
Fixes spir-v parse failure and stack smashing in RADV (obviously you still need bolist)
2022-06-17 22:42:48 +01:00
riperiperi
c1517e5ee3 SPIR-V: Use ConstantComposite for Texture Offset Vector
Fixes a bunch of freezes with SPIR-V on AMD hardware, and validation errors. Note: Obviously assumes input offsets are constant, which they currently are.
2022-06-17 22:42:48 +01:00
riperiperi
2d6642d605 SPIR-V: Only add FSI exec mode if used. 2022-06-17 22:42:47 +01:00
gdk
1ab42e9ce8 SPIR-V: Implement SwizzleAdd, add missing Triangles ExecutionMode for geometry shaders, remove SamplerType field from TextureMeta 2022-06-17 22:42:44 +01:00
gdk
c260ef7b0a SPIR-V: Add early fragment tests support 2022-06-17 22:42:44 +01:00
gdk
387333454b SPIR-V: Fragment shader interlock support (and image coherency) 2022-06-17 22:42:44 +01:00
gdk
f51f9e90d4 SPIR-V: Transform feedback support 2022-06-17 22:42:44 +01:00
riperiperi
afa54813f7 LocalDefMap for Ssa Rewriter
Rather than allocating a large array of all registers for each block in the shader, allocate one array of all registers and clear it between blocks. Reduces allocations in the shader translator.
2022-06-17 22:42:44 +01:00
riperiperi
dd718fbe97 Pool Spv.Generator resources, cache delegates, spv opts
- Pools for Instructions and LiteralIntegers. Can be passed in when creating the generator module.
  - NewInstruction is called instead of new Instruction()
  - Ryujinx SpirvGenerator passes in some pools that are static. The idea is for these to be shared between threads eventually.
- Estimate code size when creating the output MemoryStream
- LiteralInteger pools using ThreadStatic pools that are initialized before and after creation... not sure of a better way since the way these are created is via implicit cast.

Also, cache delegates for Spv.Generator for functions that are passed around to GenerateBinary etc, since passing the function raw creates a delegate on each call.

TODO: update python spv cs generator to make the coregrammar with NewInstruction and the `params` overloads.
2022-06-17 22:42:43 +01:00
gdk
301ddec36f SPIR-V: Use correct binding number on storage buffers array 2022-06-17 22:42:43 +01:00
gdk
e1d73cc560 SPIR-V: Geometry shader support 2022-06-17 22:42:42 +01:00
gdk
bd56998f4d Re-enable BGRA (was not supposed to disable it) 2022-06-17 22:42:41 +01:00
gdk
3c949309e5 SPIR-V: Implement LoopContinue IR instruction 2022-06-17 22:42:41 +01:00
gdk
aa0913838d SPIR-V: Set DepthReplacing execution mode when FragDepth is modified 2022-06-17 22:42:40 +01:00
gdk
97b179696b SPIR-V: Fix ImageQuerySizeLod 2022-06-17 22:42:40 +01:00
gdk
a2e4b4b6d8 SPIR-V: Functions must always end with a return 2022-06-17 22:42:40 +01:00
gdk
7347642c05 More instructions + fixes on SPIR-V backend 2022-06-17 22:42:40 +01:00
gdk
52249e50dd Fix transform feedback on Intel, gl_Position feedback and clears to inexistent depth buffers 2022-06-17 22:42:38 +01:00
gdk
4c7e6df7d1 Add alpha test emulation on shader (but no shader specialisation yet...) 2022-06-17 22:42:35 +01:00
gdk
9a95c3c3bc Update Spv.Generator 2022-06-17 22:42:35 +01:00
riperiperi
393d0a6134 Update findMSB/findLSB to match master's instruction enum 2022-06-17 22:42:34 +01:00
gdk
616f14c46d Fix rebase build break 2022-06-17 22:42:32 +01:00
gdk
ae783c5b5e Fix BGRA on OpenGL backend 2022-06-17 22:42:32 +01:00
gdk
fa24c41d32 Fix some tessellation related issues (still doesn't work?) 2022-06-17 22:42:32 +01:00
gdkchan
c6fbaf844e No need to initialize attributes on the SPIR-V backend anymore 2022-06-17 22:42:31 +01:00
gdkchan
4513e8b226 WIP Vulkan implementation 2022-06-17 22:42:30 +01:00
riperiperi
99ffc061d3
Optimize Texture Binding and Shader Specialization Checks (#3399)
* Changes 1

* Changes 2

* Better ModifiedSequence handling

This should handle PreciseEvents properly, and simplifies a few things.

* Minor changes, remove debug log

* Handle stage.Info being null

Hopefully fixes Catherine crash

* Fix shader specialization fast texture lookup

* Fix some things.

* Address Feedback Part 1

* Make method static.
2022-06-17 13:09:14 -03:00
riperiperi
43b4b34376
Implement Viewport Transform Disable (#3328)
* Initial implementation (no specialization)

* Use specialization

* Fix render scale, increase code gen version

* Revert accidental change

* Address Feedback
2022-05-12 10:47:13 -03:00
gdkchan
43ebd7a9bb
New shader cache implementation (#3194)
* New shader cache implementation

* Remove some debug code

* Take transform feedback varying count into account

* Create shader cache directory if it does not exist + fragment output map related fixes

* Remove debug code

* Only check texture descriptors if the constant buffer is bound

* Also check CPU VA on GetSpanMapped

* Remove more unused code and move cache related code

* XML docs + remove more unused methods

* Better codegen for TransformFeedbackDescriptor.AsSpan

* Support migration from old cache format, remove more unused code

Shader cache rebuild now also rewrites the shared toc and data files

* Fix migration error with BRX shaders

* Add a limit to the async translation queue

 Avoid async translation threads not being able to keep up and the queue growing very large

* Re-create specialization state on recompile

This might be required if a new version of the shader translator requires more or less state, or if there is a bug related to the GPU state access

* Make shader cache more error resilient

* Add some missing XML docs and move GpuAccessor docs to the interface/use inheritdoc

* Address early PR feedback

* Fix rebase

* Remove IRenderer.CompileShader and IShader interface, replace with new ShaderSource struct passed to CreateProgram directly

* Handle some missing exceptions

* Make shader cache purge delete both old and new shader caches

* Register textures on new specialization state

* Translate and compile shaders in forward order (eliminates diffs due to different binding numbers)

* Limit in-flight shader compilation to the maximum number of compilation threads

* Replace ParallelDiskCacheLoader state changed event with a callback function

* Better handling for invalid constant buffer 1 data length

* Do not create the old cache directory structure if the old cache does not exist

* Constant buffer use should be per-stage. This change will invalidate existing new caches (file format version was incremented)

* Replace rectangle texture with just coordinate normalization

* Skip incompatible shaders that are missing texture information, instead of crashing

This is required if we, for example, support new texture instruction to the shader translator, and then they allow access to textures that were not accessed before. In this scenario, the old cache entry is no longer usable

* Fix coordinates normalization on cubemap textures

* Check if title ID is null before combining shader cache path

* More robust constant buffer address validation on spec state

* More robust constant buffer address validation on spec state (2)

* Regenerate shader cache with one stream, rather than one per shader.

* Only create shader cache directory during initialization

* Logging improvements

* Proper shader program disposal

* PR feedback, and add a comment on serialized structs

* XML docs for RegisterTexture

Co-authored-by: riperiperi <rhy3756547@hotmail.com>
2022-04-10 10:49:44 -03:00
gdkchan
e44a43c7e1
Implement VMAD shader instruction and improve InvocationInfo and ISBERD handling (#3251)
* Implement VMAD shader instruction and improve InvocationInfo and ISBERD handling

* Shader cache version bump

* Fix typo
2022-04-08 12:42:39 +02:00
merry
a4e8bea866
Lop3Expression: Optimize expressions (#3184)
* lut3

* bugfixes

* TruthTable

* false/true -> 0/-1

* add or to expressions

* fix inversions

* increment cache version
2022-04-08 11:17:38 +02:00
gdkchan
04bd87ed5a
Fix shader textureSize with multisample and buffer textures (#3240)
* Fix shader textureSize with multisample and buffer textures

* Replace out param with tuple return value
2022-04-04 14:43:58 -03:00