From 535b6769709eb22333af26269f1b16f37adce4db Mon Sep 17 00:00:00 2001 From: yumekiru <338525349+yumekiru@users.noreply.github.com> Date: Wed, 28 Oct 2026 21:21:11 -0400 Subject: Import experimental NS2 support and accumulated GPU fixes Bring the NS2 patch and local follow-up fixes onto Eglantine master. Includes native graphics services, instruction translation, syncpoint cancellation acknowledgement, texture handling and diagnostics. Experimental checkpoint; not ready to merge. The original Eden build passed, but this rebased branch has not been built or tested. Assisted-by: OpenAI Codex (implementation, debugging, tests and PR preparation) --- src/video_core/macro.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/video_core/macro.cpp') diff --git a/src/video_core/macro.cpp b/src/video_core/macro.cpp index 86f528af15..4364204740 100644 --- a/src/video_core/macro.cpp +++ b/src/video_core/macro.cpp @@ -4,6 +4,8 @@ // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include +#include #include #include #include @@ -1339,6 +1341,42 @@ static void Dump(u64 hash, std::span code, bool decompiled = false) { void MacroEngine::Execute(Core::System& system, Engines::Maxwell3D& maxwell3d, u32 method, std::span parameters) { + if (native_turing) { + maxwell3d.RefreshParameters(); + const auto context = reinterpret_cast(this); + static std::unordered_set captured_contexts; + if (std::getenv("EDEN_NATIVE_FRAME_CAPTURE") && captured_contexts.insert(context).second) { + std::ofstream dump("native-graphics-mme-" + std::to_string(context) + ".bin", std::ios::binary); + dump.write(reinterpret_cast(native_code.data()), sizeof(native_code)); + } + LOG_DEBUG(HW_GPU, "Native MME context={:#x}", context); + LOG_DEBUG(HW_GPU, "Native MME start={:#x}, parameters={}, data={:08x}", method, parameters.size(), fmt::join(parameters, ",")); + u32 dma_count{}; + const auto result = native_interpreter.Execute(native_code, method, parameters, + [&](u32 address) { return address < Maxwell3D::Regs::NUM_REGS ? maxwell3d.GetRegisterValue(address) : 0U; }, + [&](u32 address, u32 value) { + if (address >= 0xe00) return false; + if (address == 0x158) dma_count = value; // MME_DMA_READ_FIFOED + maxwell3d.CallMethod(system, address, value, true); + return true; + }, [&]() -> std::optional> { + if (dma_count > 0x10000) return std::nullopt; + std::vector data(dma_count); + const GPUVAddr address = (u64{maxwell3d.GetRegisterValue(0x154) & 0xff} << 32) | + maxwell3d.GetRegisterValue(0x155); + if (dma_count && !maxwell3d.ReadMacroMemory(address, data)) return std::nullopt; + dma_count = 0; + return data; + }); + if (!result.success) { + native_execution_failed = true; + std::ofstream dump("native-mme-" + std::to_string(method) + ".bin", std::ios::binary); + dump.write(reinterpret_cast(native_code.data()), sizeof(native_code)); + LOG_ERROR(HW_GPU, "Native MME failed: start={:#x}, pc={:#x}, consumed={}/{}, error={}", + method, result.pc, result.consumed, parameters.size(), result.error); + } + return; + } const auto execute_variant = [&system, &maxwell3d, ¶meters, method](AnyCachedMacro& cached) { if (std::holds_alternative(cached) || -- cgit v1.2.3