aboutsummaryrefslogtreecommitdiff
path: root/src/video_core/shader_environment.cpp
Commit message (Collapse)AuthorAgeFilesLines
* video_core: flush GPU-written code when capturing native shadersSssnowyyy30 hours1-5/+5
| | | | | | | | | | | | | | 10e7063905 moved native program capture from one ReadBlock per instruction to ReadBlockUnsafe per 4 KiB page. ReadBlockUnsafe skips the rasterizer flush, so code that a GPU copy had written and not yet flushed to guest memory was captured stale. The speed-up comes from reading a page at a time, not from skipping the flush: read each page (and the odd single instruction outside a fully mapped page) with ReadBlock, which flushes once per page instead of once per instruction. Follow-up to 10e7063905. Assisted-by: Claude Sonnet 5.5 (implementation and commit message)
* video_core: read texture handles as header offsets only on Switch 2Sssnowyyy30 hours1-1/+2
| | | | | | | | | | | | | | 049c9633ed made TextureHeaderIndex take index / 32 for any texture index past the pool that is a multiple of 32, in VisitImageView and in the shader environment. That was written for Switch 2 handles that hold a header byte offset, but it ran for Switch 1 games too, where such an out-of-range index used to give a null view (and fail the shader environment's range check) and now binds an unrelated header. Pass whether the memory manager uses native tiling, which is how Switch 2 titles are set up, and keep the previous behaviour otherwise. Follow-up to 049c9633ed. Assisted-by: Claude Sonnet 5.5 (implementation and commit message)
* nx2: capture and lower native shader programs oncekraibse2 days1-28/+107
| | | | | | | | | | | | | Native programs were captured and lowered when their ShaderInfo was made and again for every environment built for their pipelines. The ShaderInfo now keeps the lowered code and the environments adopt it. Capture also reads a 4 KiB page at a time instead of flushing caches per instruction, and cached native programs fold bank 1 reads like live ones. Ported from Wael3rd/Eglantine-MKW (0ae093058e, 65a6aa877a, df076133c4). Assisted-by: Claude Sonnet 5.5 (porting the fixes) (cherry picked from commit 3af11ac401ad3061c183281d8c98c16c1d6da456)
* Merge remote-tracking branch 'origin/fix/nx2-texture-header-offset-handles' ↵Takoroka2 days1-2/+3
|\ | | | | | | into test/linux-all-prs
| * nx2: read texture handles that hold a header byte offsetTakoroka3 days1-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Switch Sports' scenery shaders take their 64-bit texture handles from a uniform register, and the texture part of those handles is the header's byte offset in the pool (index * 32), not its index: 0x96e46000 names header 8960 (a 640x152 2D texture), while the plain reading, 286720, runs far past the 33067-entry pool. Eden skipped them at draw time (null view) and built the shaders for a garbage header, so the island's ground, cliffs and buildings drew black. When a handle's index falls past the pool but index / 32 lands inside it, take that header, both when building the shader and when binding the view. Handles that already resolve keep their meaning.
* | video_core: draw Switch 2 task/mesh pipelines with VK_EXT_mesh_shaderTakoroka2 days1-2/+23
|/ | | | | | | | | | | | | While SET_MESH_CONTROL is on, a native draw binds a task program in the vertex slot, its mesh program in the tessellation slot and a header-only pass-through geometry program naming the per-primitive outputs. Translate the first two as task and mesh programs with the mesh registers (SET_MESH_SHADER_A/B, SET_MESH_INIT_SHADER) and that header, key their pipelines by them, and build pipelines with task/mesh stages and no vertex input, input assembly or tessellation state. The draw's vertex count is the number of task workgroups: record vkCmdDrawMeshTasksEXT. Enable VK_EXT_mesh_shader (task and mesh only) when the host has it; draws are skipped without it, as they were before.
* nx2: log per-call GPU memory, syncpoint and shader lowering lines at debug levelTakoroka5 days1-1/+1
| | | | | | | | | | GPU memory registration (gpu sub 101) and mapping (211) alone wrote two info lines per allocation, about 80% of every Switch 2 log (27,000 lines in five minutes of Mario Kart World), with slot jobs, semaphore pages, GPU-only region words, syncpoint waits and each lowered shader on top. They are still there at debug level; one-time messages, the GPU-only region backing and every warning about unexpected requests stay as they were.
* IMAD.SHL as a shift; EDEN_NX2_REJECT; log where rejected programs are boundTakoroka6 days1-0/+11
| | | | | | | | | | - IMAD by a power of two lowers to SHL imm, the form Eden's jump-table tracking expects (a title 1 compute program failed "track indirect branch"). - EDEN_NX2_REJECT=<hex addresses>: treat those native programs as rejected, to bisect a behaviour change without rebuilding. - A rejected graphics program logs its stage slot, header and slot registers once (for the task/mesh pipeline setup). - Notes: rows 87-92, title 1 status.
* nx2: title 4's intro cutscene renders correctlyTakoroka7 days1-2/+13
| | | | | | | | | | | | | | | | Native shader capture counted CALL.REL.NOINC as a function call, so a program using it waited for a RET after its EXIT and read on into the following shaders until a garbage branch target made it fail. NOINC calls push no return address (the compiler uses them as jumps; the lowering already treats them so): count them as forward branches. That shader builds title 4's 3D colour-grading LUT once per scene; with it rejected the LUT stayed empty and the tonemap turned every frame black. The intro cutscene now renders lit and graded, with subtitles, through the bilinear stand-in for the tensor-core upscaler. Also: rejected captures dump to EDEN_NX2_SHADER_DUMP as rejected-<addr>.bin and report the offending instruction.
* Switch 2: Turing macros, native compute, Ampere shader lowering, native tilingTakoroka7 days1-3/+181
| | | | | | | | | | | | | | | | | From changes.patch: the TU104/GA10x MME interpreter (shared macro context for the process's channels, also on the compute class), native compute with QMD 3.0 dependency scheduling, the Ampere-to-Maxwell shader lowering, native vertex stream sizes, and the console's GOB swizzle for textures, DMA copies and the host unswizzle shaders. Switch 2 channels turn all of it on at init. The lowering is widened for title 4 (all 32 of its programs lower): general TEX (any dimension/LOD/mask, operand split 1+1/2+1/2+2/4+n, any but consistent descriptor buffer), cube/array, SULD channel masks, 128-bit STG, indexed IPA, VOTE, SHFL with any immediate or predicate output, R2P/P2R byte select, uniform ULOP3/ULEA/UBREV/UFLO.SH/UISETP signed/UMOV URZ, IMNMX cbuf, IADD3 and FFMA uniform operands, FMUL /4 /8 x8, and BSSY/BSYNC/BREAK/WARPSYNC as no-ops. The capture stops at unmapped memory. EDEN_NX2_SHADER_DUMP dumps every native program; tools in C:\dev\nx2work test the lowering offline.
* [video_core] gate Mesa EXIT terminator detection behind non-proprietary ↵xbzk2026-07-011-3/+2
| | | | | | | | | | | | | | | | | driver (#4151) FIXES A REGRESSION FROM 4012. TryFindSize's Mesa fallback matched the unconditional @PT EXIT (0xE30000000007000F) that nv50_ir emits at program end. That exact word is also emitted by NVN mid-program for unconditional early-outs, so on retail titles (e.g. Super Mario 3D World) the scan truncated at the first early EXIT and dropped the rest of the shader, making textures vanish. Mesa's terminal EXIT and NVN's mid-program EXIT are bit-identical, so no mask can separate them. Gate the heuristic on !is_proprietary_driver: NVN binaries (bindless cbuf slot 2) keep self-branch-only sizing, while nouveau/Mesa homebrew (single terminal EXIT, no self-branch trailer) still uses the EXIT terminator. nv50_ir emits exactly one EXIT (early returns lower to BRA-to-exit, discard to DISCARD), so a single terminal match is correct for that path. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4151 Reviewed-by: Lizzie <lizzie@eden-emu.dev> Reviewed-by: MaranBr <maranbr@eden-emu.dev>
* xbzk/gpu-logging_qt-controls_android-fix (#4018)xbzk2026-06-271-15/+16
| | | | | | | | | | | | | 5af7771f83-Bugfix: Made gpu_log_level global-only (was per-game switchable). Fixed Android non-determinism where a per-game profile silently overrode the global to Off and trapped GPULogger::Initialize() in a dead state, making shader dumps fail invisibly. Android per-game UI now hides the whole GPU logging block; Qt UI is untouched (global-only anyway). bf4aabe8ab-Refactor/Cleanup: Removed gpu_logging_enabled master toggle as redundant with gpu_log_level == Off. Introduced GPU::Logging::IsActive() helper, replaced 14 call sites across vk_*.cpp. Refactored LogShaderCompilation() to be text-only and extracted SPIR-V dumping into a standalone GPU::Logging::DumpSpirvShader() free function. No singleton dependency, gated only by gpu_log_shader_dumps. Now gpu_log_level and gpu_log_shader_dumps are fully orthogonal. Cleaned up Android (BooleanSetting, SettingsItem, presenter, 7 locale string files). 865a1c5027-Refactor: Renamed dump_shaders → dump_guest_shaders to disambiguate from gpu_log_shader_dumps. Updated Qt label to "Dump Guest (Maxwell) Shaders" and rewrote the tooltip to mention .ash, the DumpDir/shaders/ location, and nvdisasm. 7cab456fdf-Feature: Added Qt UI control for GPU log level in the Logging session. Added gpu_log_shader_dumps checkbox to the Graphics column right below dump_guest_shaders. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4018 Reviewed-by: MaranBr <maranbr@eden-emu.dev>
* [video_core, maxwell] fixes for homebrew games that use MESA compiler (#4012)xbzk2026-06-151-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | two main issues: shader_environment.cpp Support Mesa nv50_ir-compiled homebrew fragment shaders Mesa nv50_ir (used by NZP-Switch via libdrm_nouveau) emits Maxwell SASS that differs from NVN in two ways our shader pipeline didn't account for, causing "infinite" loops during shader scanning. How? TryFindSize() previously detected end-of-shader only via NVN's "BRA $-1" self-branch trailer (SELF_BRANCH_A/B). Mesa-compiled shaders end with an unconditional @PT EXIT and emit no trailer, so scanning ran past the shader and looped to MAXIMUM_SIZE. Fix: Added a secondary match against @PT EXIT T (opcode 0xE30, predicate PT, flow T) as a fallback terminator. The mask is estrictive enough to reject predicated EXITs, conditional-flow EXITs, and sched control words, so well-formed NVN shaders see no ehavior change (their single @PT EXIT immediately precedes BRA $-1, and both detections return the same size). load_store_attribute.cpp + attribute.h IPA's is_perspective check only applied the ×position_w correction for IR::IsGeneric() attributes, and used a per-component SPH lookup. Two failure modes followed: 1. Mesa fragment shaders read varyings via legacy attribute slots (ColorFrontDiffuse, FixedFncTexture, FogCoordinate) which are remapped to generic varyings later by ConvertLegacyToGeneric. At IPA-translation time they're still legacy, so IsGeneric() was false and the inject was skipped — but the resulting GLSL/SPIR-V varying was Smooth (perspective-correct), and the SASS still issued its manual perspective dance via MUFU.RCP(ATTR_W)+FMUL, compounding an extra ×clip_w factor. NZP fog (eye_z distance varying) ended up as eye_z⁴×density² instead of eye_z²×density², saturating fog to white everywhere. 2. Even for legacy attrs that should inject, Mesa stores them in two formats selected by the IPA's interpolation_mode field: Pass/Multiply/Constant → attr/w (perspective); inject ×position_w Sc (ScreenLinear) → raw attr; do NOT inject Unconditionally injecting for Sc dims vertex colors by 1/clip_w because there's no SASS multiplier to round-trip it back. Fix: extend the IPA correction path to also fire on IsLegacyAttribute(), gated on interpolation_mode != Sc. While here, the generic-path check is widened from per-component to vector-level (first non-Unused PixelImap, with all-Unused fallthrough treated as Perspective) so it matches the GLSL interpolation qualifier picked by CollectInterpolationInfo — this fixes the same all-zeroed-imap case Mesa exposes for explicit generics. IsLegacyAttribute moved from translate_program.cpp's anonymous namespace into attribute.h next to IsGeneric so IPA can reach it. Tested on NaziZombies:Portable (Switch homebrew): fog now matches real hardware, vertex-colored geometry (hand, gun, decals) renders correctly. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4012 Reviewed-by: Lizzie <lizzie@eden-emu.dev> Reviewed-by: MaranBr <maranbr@eden-emu.dev>
* [core/core_timing] better MWAITX and WAITPKG delays (#3984)lizzie2026-05-301-1/+2
| | | | | | | | | | | | | This implements MWAITX and WAITPKG extensions (umonitor, mwait) for CPUs that support them. Reduces wait times and bypasses the timing stuff from the OS that is slow (windows notably). generally it should answer within 0.2 to 0.5 microsecs (since most requests wait for that long). Also does a general rework of static ctors and stuff Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3984 Reviewed-by: MaranBr <maranbr@eden-emu.dev> Reviewed-by: crueter <crueter@eden-emu.dev>
* [common/logging] Simplify logging logic and fix issues when logging before ↵lizzie2026-03-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | system is created (#3688) - our logging code was bigger than spdlog itself, why???? just keep it simple - fix issues when logging before logging system is even started - removes the "initialized logging twice" issue - removes uneeded indirection in file logging - uses direct formatting instead of jumping hoopla-around the fmt::format() ressult - code duplication and dead code removal as usual I did explore dup2() but I think it's not worth the hassle I did try `fwopen()` but it's better if things are just kept as-is. there is a lot of noise because I removed a bunch of redundant files on logging and just put everything in one file now normally this wouldn't be a good idea, however consider: the complexity of logging; it's less than 500 lines... does it really need a whole subsystem?!?!?! ITS JUST LOGGING Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3688 Reviewed-by: crueter <crueter@eden-emu.dev> Reviewed-by: DraVee <chimera@dravee.dev> Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
* [android, feat] add "Fix Bloom Effects" toggle (#3359)PavelBARABANOV2026-01-261-1/+1
| | | | | | | | | | | | | - Toggle partially removes blur in Link's Awakening (LA) and Echoes of Wisdom (EOW) for turnip and stock drivers from A7XX and below. - Burnout screen blur fix is now controlled by this toggle Co-authored-by: CamilleLaVey <camillelavey99@gmail.com> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3359 Reviewed-by: MaranBr <maranbr@eden-emu.dev> Reviewed-by: DraVee <dravee@eden-emu.dev> Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Co-authored-by: PavelBARABANOV <pavelbarabanov94@gmail.com> Co-committed-by: PavelBARABANOV <pavelbarabanov94@gmail.com>
* [am] Improve some error messages (#2996)MaranBr2025-11-101-1/+1
| | | | | | Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2996 Co-authored-by: MaranBr <maranbr@outlook.com> Co-committed-by: MaranBr <maranbr@outlook.com>
* [video_core] Better error messages (#2827)MaranBr2025-10-241-1/+1
| | | | | | | | Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2827 Reviewed-by: Maufeat <sahyno1996@gmail.com> Reviewed-by: Lizzie <lizzie@eden-emu.dev> Co-authored-by: MaranBr <maranbr@outlook.com> Co-committed-by: MaranBr <maranbr@outlook.com>
* [common] remove ranges polyfill (#2546)lizzie2025-09-241-1/+1
| | | | | | | | | Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2546 Reviewed-by: MaranBr <maranbr@eden-emu.dev> Reviewed-by: crueter <crueter@eden-emu.dev> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
* [meta] fix license headers (#2547)lizzie2025-09-211-0/+3
| | | | | | | Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/2547 Reviewed-by: MaranBr <maranbr@eden-emu.dev> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
* [cmake] enable clang-cl and WoA builds (#348)lizzie2025-09-091-3/+3
| | | | | | | | | | | | | | Compilation and CMake fixes for both Windows on ARM and clang-cl, meaning Windows can now be built on both MSVC and clang on both amd64 and aarch64. Compiling on clang is *dramatically* faster so this should be useful for CI. Co-authored-by: crueter <crueter@eden-emu.dev> Co-authored-by: crueter <crueter@crueter.xyz> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/348 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Reviewed-by: crueter <crueter@eden-emu.dev> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
* User Data Migration from Citron, Sudachi, and Yuzu (#91)swurl2025-05-081-1/+1
| | | | | | | | | | | | Includes citron, sudachi, yuzu currently broken, because the eden dir is always made early? Signed-off-by: swurl <swurl@swurl.xyz> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/91 Co-authored-by: swurl <swurl@swurl.xyz> Co-committed-by: swurl <swurl@swurl.xyz>
* Fix typos in video_coreViktor Szépe2024-01-071-3/+3
|
* shader_recompiler: use float image operations on load/store when requiredLiam2023-12-211-17/+18
|
* Fix shader dumps with nvdisasmKelebek12023-08-031-12/+19
| | | | | skip fragment shaders when rasterizer is disabled initialize env_ptrs
* Fix code resize to use word size rather than byte sizeKelebek12023-05-021-6/+10
|
* Video_core: Address feedbackFernando Sahmkow2023-01-041-3/+5
|
* ShaderCompiler: Inline driver specific constants.Fernando Sahmkow2023-01-031-0/+3
|
* MacroHLE: Add HLE replacement for base vertex and base instance.Fernando Sahmkow2023-01-011-0/+53
|
* general: fix compile for Apple ClangLiam2022-11-221-0/+1
|
* ir/texture_pass: Use host_info instead of querying Settings::values (#9176)Morph2022-11-111-1/+1
|
* video_core: Fix SNORM texture buffer emulating error (#9001)Feng Chen2022-11-041-10/+79
|
* Merge pull request #8858 from vonchenplus/mipmapbunnei2022-11-031-0/+17
|\ | | | | video_core: Generate mipmap texture by drawing
| * Merge branch 'master' into mipmapFeng Chen2022-09-201-5/+2
| |\
| * | video_core: Generate mipmap texture by drawingFengChen2022-09-201-0/+17
| | |
* | | Update 3D regsKelebek12022-10-071-11/+12
| |/ |/|
* | style: General style changes to match with the rest of the codebaseMorph2022-08-311-5/+2
|/
* video_code: support rectangle textureFengChen2022-08-251-2/+7
|
* common: Change semantics of UNREACHABLE to unconditionally crashLiam2022-06-131-1/+1
|
* GCC 12 fixesLiam2022-04-281-2/+2
|
* 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.
* video_core: Reduce unused includesameerj2022-03-191-1/+0
|
* video_core: Remove unnecesary maybe_unused flagNarr the Reg2022-01-041-1/+1
|
* ShaderDecompiler: Add a debug option to dump the game's shaders.Fernando Sahmkow2022-01-041-0/+54
|
* gpu: Migrate implementation to the cpp fileameerj2021-10-031-0/+1
|
* shader_environment: Add missing <algorithm> includeMorph2021-09-111-0/+1
|
* shader_environment: Receive cache version from outsideReinUsesLisp2021-07-221-6/+5
| | | | This allows us invalidating OpenGL and Vulkan separately in the future.
* shader: Rework varyings and implement passthrough geometry shadersReinUsesLisp2021-07-221-1/+9
| | | | | | Put all varyings into a single std::bitset with helpers to access it. Implement passthrough geometry shaders using host's.
* shader: Unify shader stage typesReinUsesLisp2021-07-221-1/+1
|
* shader_environment: Fix local memory size calculationsReinUsesLisp2021-07-221-3/+3
|