aboutsummaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/spirv/emit_spirv.cpp
Commit message (Collapse)AuthorAgeFilesLines
* shader_recompiler: translate Switch 2 task and mesh programsTakoroka3 days1-0/+60
| | | | | | | | | | | | | | | | | | | | | | | Mario Kart World draws some of its geometry with NVN task and mesh programs (the task program culls and writes the mesh workgroup count and a payload to its stage buffer; each mesh workgroup reads it back and writes vertices and primitives). Add Task and Mesh stages and translate them for VK_EXT_mesh_shader: - the ISBE pseudo instruction from the lowering becomes reads and writes of an emulated stage buffer: the task's output region is the task payload, the mesh output regions live in workgroup memory - every EXIT of these stages jumps to one final return, so all invocations reach the epilogue: a barrier, then OpEmitMeshTasksEXT, or OpSetMeshOutputsEXT and a copy of the 32-element vertex and primitive groups (lines named by the mesh header's and the pass-through geometry header's output maps) to arrayed and per-primitive outputs - Sirit lacks the two mesh instructions: they are emitted as OpStore markers and replaced after assembly - fragment inputs a mesh program writes per primitive get PerPrimitiveEXT The captured task and mesh programs of the title translate to SPIR-V that spirv-val accepts.
* [shader_recompiler, vulkan, qcom, tu] Provide handling to missing shader ↵CamilleLaVey2026-10-141-2/+31
| | | | | | | | | | | | | | | | subgroups on QCOM (#4508) This works provides better emulation on certain GS missing for shader invocation data + geometry pass fallback in qcom/turnip drivers, some of those were provided as community patch by @a.kamaltdinov; which was refined to address the requirements on forced gpu reads; which used to kill some performance on low end devices; now, the stability with some of the graphical problems have been addressed and balanced. Shuffle shaders (SHFFL) are not actually provided on QCOM and turnip drivers, so any game that previously required this stage draw, will now avoid being ignored and tax some performance based on the complexity of the stage draw from now on. This will also address partially some tessellation problems as well. _Special Thanks:_ 1.- @a.kamaltdinov (for the initial patch "early fix for nier" provided for #4325) 2.- @PavelBARABANOV (because the making the cherry-pick easier for a new PR) Co-authored-by: PavelBARABANOV <pavelbarabanov94@gmail.com> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4508 Reviewed-by: lizzie <lizzie@eden-emu.dev> Reviewed-by: crueter <crueter@eden-emu.dev>
* [vulkan] Implementation for VK_EXT_shader_quad_control (#4168)CamilleLaVey2026-08-281-0/+11
| | | | | | | | An experimental approach to introduce an smarter way to use and access QUAD's capabilities on shaders, suggested by @gidoly some months ago, finally came into something usable; current implementation checks GLASM, GLSL and Vulkan on their own way, stablishes proper emitters and receivers for Quads inside our recompiler, which are the introductions for future changes; checks for support and actual feature bit, OpCodes and mask were added within this PR. Meanwhile the expected behavior was to reduce graphical issues (on games with Quad shaders reliant), we encountered a very slight performance increase depending on what game and shader are actually compiled. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4168 Reviewed-by: MaranBr <maranbr@eden-emu.dev> Reviewed-by: Samuel <lizzie@eden-emu.dev>
* [vulkan, qcom] Fix shader float controls on QCOM driver (#4297)CamilleLaVey2026-08-241-1/+1
| | | | | | | | | | | | Finishes my torture to find the culprit behind the broken behavior with float controls, even if device does support flush denorm on fp32 it doesn't really support it and provokes bad rounding modes by not flushing correctly denorms; this also returns the other working rounding modes on QCOM drivers. _Special Thanks_ 1.- Smoly The Big (@Gidoly) Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4297 Reviewed-by: Samuel <lizzie@eden-emu.dev> Reviewed-by: MaranBr <maranbr@eden-emu.dev>
* [vulkan] 4th Vulkan Global Maintenance (#4212)CamilleLaVey2026-07-161-4/+14
| | | | | | | | | | The approach on this PR moves around refactoring/ updating residual work; main issue was the whole logic behind msaa upload/download images with the constant image copy per pass required; which was gated via shaderStorageImageMultisample, which is not available on all the platforms supported including Android, making them to rely into a more heavier approach to convert msaa image copy into a non msaa image copy, not only losing precision in the conversion, but also creating bugs around the resolve of the image itself, if the supported path had to copy 2 times the same image to be actually presentable, when the fallback was enabled 3 copies were performed, not only decreasing the performance but also increasing race conditions due to the certain capabilities processed in this chain (storage_views). In order to resolve them more naturally, the constant copies were removed from the now "common" path along establishing a proper color resolve for Android and actually making them more direct. Yet this opened a new pack of outdated handling on our current backend; since we now pass msaa images more directly (whenever a game request a msaa type of image/ which seems to be not common + each fragment resolves images on how it's actually required, adding missing depth/stencil), how we often load and store them becomes a critical issue, since our current configuration renderpass/framebuffer forces to always load and load clear whenever a new attachment it's passing through the renderpass, making this really heavier on memory bandwidth limited devices as SteamDeck and others that doesn't rely on the inmediate rendering mode (Tilers vs iGPU); to prevent over allocating data, I had to re-structure part of the current renderpass and framebuffer to actually reuse part of the data/ attachments called, with flags as DON'T_CARE, simplifying partially on how we actually call attachments including their barriers and conditions (occlusion, etc), the DON'T_CARE it's specifically useful to not only prevent calling new loads (which is a flush and heavier on tiler devices) and not only reusing the actual data store, which works on the future time, this saves memory bandwidth and gives space to actually avoid the constant pressure on SYSMEM/GMEM shader resolver path. This maintenance also improved the current removal features logic on QCOM drivers, closing gaps between implementations on descriptors (VK_EXT_indexing_descriptor), adjusting the whole WMEL to avoid being so stricter if certain capabilities are missing to actually use this feature, leading to test and play more on how QCOM drivers are actually behaving; meanwhile the main objective is to open path for a robust and bigger implementation in the future, the changes made here also contains small bug fixes on SPIR-V logic, adding missing cases to resolve shaders (FP64 -> FP16), adding more robustness on how narrow features are actually being used and how to wired them whenever they're not available, meanwhile there are still some issues in regards on how Tegra vs Adreno can preserve unorms at FP32 and FP16, leaving better understanding on base for what VK_EXT_shader_float_controls is actually doing most of the times (flushes NaN's and Denorms equally). Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4212
* [vulkan, android] Mediacodec implementation + Vulkan fixes (#4191)CamilleLaVey2026-07-091-1/+1
| | | | | | | | | | | | | | | | | | | This is the first step into the conversion on full GPU video decoding for Android; currently due to the VIC structure, I couldn't set it on surface mode to prevent the latency when sending video decoded (which is processed by GPU now), because currently we convert YUV420 into the Nvidia's format each frame constantly on CPU, aside the requirements from other extensions to work + VIC rewrite, which is a work currently not planned to happen on this PR; the actual configuration for video decoding is ByteBuffer, using GPU to decode NVDEC data (all codecs supported, h264, vp8 and vp9) and send it to CPU for display purposes, which is more faster than relying purely on CPU for any drawing task, saving devices resources/ heating, the downside on this will be the slight latency when a new frame is displayed, which is gonna be a black frame for less than a second, nothing major to harm the experience rather than actually trying our best to take advantage on hardware accelerated. Aside this, I also added a bunch of minor Vulkan fixes to grant drivers less thinkering when receiving spir-v instructions, meaning this has new bans for extensions on QCOM (following reported issues on other projects working around Adreno driver behavior), this more than providing performance aims to enhance the stability on the driver, performance it's gonna likely to be hit based on the UBO's (StorageBufferAccess) operations and SSBO (uniformStorageBufferAccess), there was an already existing path for the emulation which forces to wide them into 32bit packed operations. I also included some smaller changes/ bugs + VUID's fixes from earlier changes on my work. Special Thanks: -> Mr. Smoly Gidolard (@gidoly) Sources: 1.- https://github.com/microsoft/DirectXShaderCompiler/issues/2842 2.- https://github.com/mlc-ai/web-llm/issues/836 3.- https://github.com/ggml-org/llama.cpp/issues/5186 4.- https://github.com/encounter/aurora/pull/202 Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4191
* [vulkan] 3rd Vulkan Global Maintenance (#4189)CamilleLaVey2026-07-091-0/+3
| | | | | | | | | | Following the philosophy on the previous Vulkan maintenance PR's, this one is reviewing the video_core to resolve VUID's related to the missing handling/ safechecks (UBO's case on missing StorageBufferAccess 8/16 bits on QCOM drivers, resulting on bad compute pipeline compiled), wiring topology representative to EDS2 configuration (following #4117), refactored the sampled image access via new memeber function for type "typeless" which adds a handling on the integer mistmatch (uint to sint, float to uint) + fixing bugs on current texture sampling (int) including the depth/stencil path resolve, maintenance to previous changes on query cache (resolving bugs from #3853), reduced the amount of binding BindVertexBufferEXT2 when a new tick/ frame is presented (with this being a reason for performance reduction on games where vertex polutes the stage, like BOTW/TOTK where grass is draw with vertex); implemented color border swizzle and color write enable for future improvements on EDS3, added initial implementation on Synchronization2 starting a path to ensure an access to VK 1.3 features safely and other smaller fixes along the road. Special Thanks: -> Mr. Smolio Gidolard (@gidoly) Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4189
* [vk] fix LM3 and TL:LTD multiple NonUniform annotations (#3997)lizzie2026-05-291-0/+7
| | | | | | | | | | should fix AMD Signed-off-by: lizzie lizzie@eden-emu.dev Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3997 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Reviewed-by: MaranBr <maranbr@eden-emu.dev>
* [spirv] nuke spirv-opt (#3877)lizzie2026-04-251-35/+3
| | | | | | | | | | | | | | | | | | lots of AGILEism in spirv-opt theres BETTER alternatives like https://github.com/renderbag/re-spirv (im not gonna bother for now, it probably has shitty build system) it sucks the IR already resolves most of the shader code to just constant load/stores Spirv-opt passes do not seem to make such a big difference only introduce extra latency like for example cbuf pass in IR already removes a lot of code, that spirv_opt would otherwise miss due to the fact it doesn't have cbuf information Signed-off-by: lizzie <lizzie@eden-emu.dev> Co-authored-by: crueter <crueter@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3877 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Reviewed-by: crueter <crueter@eden-emu.dev>
* [spirv] improved spir-v shader opt (#239)crueter2025-08-151-18/+36
| | | | | | | | | | | increases speed ~tenfold for Spir-V output optimization when using it on load. Co-authored-by: wildcard <nubieluv@gmail.com> Signed-off-by: crueter <crueter@eden-emu.dev> Co-authored-by: wildcard <nubieluv@gmail.com> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/239 Reviewed-by: Shinmegumi <shinmegumi@eden-emu.dev>
* [cmake] refactor: Use CPM over submodules (#143)crueter2025-08-041-2/+2
| | | | | | | | | Transfers the majority of submodules and large externals to CPM, using source archives rather than full Git clones. Not only does this save massive amounts of clone and configure time, but dependencies are grabbed on-demand rather than being required by default. Additionally, CPM will (generally) automatically search for system dependencies, though certain dependencies have options to control this. Testing shows gains ranging from 5x to 10x in terms of overall clone/configure time. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/143 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
* [VK] Rework SPIRV Shader Optimization (#238)Gamer642025-07-031-2/+27
| | | | | | | | The actual SPIRV Shader Optimization option doesn't seem to do anything as long as it isn't vinculed, so let's rework it to make it work Co-authored-by: Gamer64 <76565986+Gamer64ytb@users.noreply.github.com> Co-authored-by: echosys <echosys@noreply.localhost> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/238
* shader_recompiler: throw on missing geometry streams in geometry shadersLiam2024-02-191-1/+3
|
* renderer_vulkan: ignore viewport stores on non-supporting driversLiam2023-11-191-1/+1
|
* Remove memory allocations in some hot pathsKelebek12023-06-221-1/+1
|
* Vulkan: update initializationLiam2022-11-271-6/+7
| | | | Co-authored-by: bylaws <bylaws@users.noreply.github.com>
* general: Convert source file copyright comments over to SPDXMorph2022-04-231-3/+2
| | | | | This formats all copyright comments according to SPDX formatting guidelines. Additionally, this resolves the remaining GPLv2 only licensed files by relicensing them to GPLv2.0-or-later.
* emit_spirv: Add Xfb execution mode when transform feedback is usedameerj2022-01-281-3/+9
| | | | Fixes Transform Feedback on Vulkan AMD drivers.
* Empty spacesMatías Locatti2021-12-281-1/+1
|
* Changes to avoid warnings in SSE4.2 optimized SPIR-VMatías Locatti2021-12-281-0/+9
|
* emit_spirv: Reduce emit_spirv.h include overheadameerj2021-12-051-0/+1
| | | | emit_spirv.h is included in video_core, which was propagating further includes that video_core did not depend on.
* emit_spirv: Workaround VK_KHR_shader_float_controls on fp16 NvidiaReinUsesLisp2021-07-221-5/+8
| | | | Fix regression on Fire Emblem: Three Houses when using native fp16.
* shader: Rework varyings and implement passthrough geometry shadersReinUsesLisp2021-07-221-5/+14
| | | | | | Put all varyings into a single std::bitset with helpers to access it. Implement passthrough geometry shaders using host's.
* shader: Move loop safety tests to code emissionReinUsesLisp2021-07-221-1/+18
|
* spirv: Reduce log severity of mismatching denorm rulesReinUsesLisp2021-07-221-2/+2
|
* shader: Add loggingReinUsesLisp2021-07-221-4/+4
|
* shader: Split profile and runtime information in separate structsReinUsesLisp2021-07-221-9/+11
|
* shader: Read branch conditions from an instructionReinUsesLisp2021-07-221-1/+9
| | | | Fixes the identity removal pass.
* shader_recompiler: GCC fixeslat9nq2021-07-221-16/+16
| | | | | Fixes members of unnamed union not being accessible, and one function without a declaration.
* emit_spirv: Jump to loop body with local variableReinUsesLisp2021-07-221-1/+1
| | | | Silence unused variable warning
* emit_spirv: Add missing block in caseReinUsesLisp2021-07-221-1/+2
|
* glasm: Initial implementation of phi nodes on GLASMReinUsesLisp2021-07-221-1/+5
|
* glasm: Rework control flow introducing a syntax listReinUsesLisp2021-07-221-6/+65
| | | | | This commit regresses VertexA shaders, their transformation pass has to be adapted to the new control flow.
* glasm: Implement shuffle and vote instructions on GLASMReinUsesLisp2021-07-221-1/+3
|
* Move SPIR-V emission functions to their own headerReinUsesLisp2021-07-221-0/+1
|
* shader: Implement Int32 SUATOM/SUREDameerj2021-07-221-0/+3
|
* spirv: Do not enable ShaderLayerReinUsesLisp2021-07-221-3/+0
| | | | This is enabled by an extension instead of the capability.
* spirv: Enable DemoteToHelperInvocationEXT only when supportedReinUsesLisp2021-07-221-1/+1
|
* spirv: Use OriginLowerLeft when requestedReinUsesLisp2021-07-221-1/+5
|
* spirv: Support OpenGL uniform buffers and change bindingsReinUsesLisp2021-07-221-1/+1
|
* shader: Move microinstruction header to the value headerReinUsesLisp2021-07-221-1/+0
|
* shader: Address feedbackFernandoS272021-07-221-1/+1
|
* shader: Implement fine derivates constant propagationFernandoS272021-07-221-0/+3
|
* shader: Implement PIXLD.MY_INDEXReinUsesLisp2021-07-221-0/+3
|
* spirv: Implement ViewportMask with NV_viewport_array2ReinUsesLisp2021-07-221-0/+4
|
* shader: Implement tessellation shaders, polygon mode and invocation idReinUsesLisp2021-07-221-0/+39
|
* spirv: Implement Layer storesReinUsesLisp2021-07-221-6/+10
|
* shader: Implement transform feedbacks and define file formatReinUsesLisp2021-07-221-0/+3
|
* shader: Implement early Z testsReinUsesLisp2021-07-221-0/+3
|
* spirv: Rework storage buffers and shader memoryReinUsesLisp2021-07-221-1/+1
|