Lime3DS/src/video_core/gpu.h
Eric Warmenhoven d9b77cc21e
Some checks are pending
citra-build / source (push) Waiting to run
citra-build / linux (appimage) (push) Waiting to run
citra-build / linux (appimage-wayland) (push) Waiting to run
citra-build / linux (fresh) (push) Waiting to run
citra-build / macos (arm64) (push) Waiting to run
citra-build / macos (x86_64) (push) Waiting to run
citra-build / macos-universal (push) Blocked by required conditions
citra-build / windows (msvc) (push) Waiting to run
citra-build / windows (msys2) (push) Waiting to run
citra-build / android (googleplay) (push) Waiting to run
citra-build / android (vanilla) (push) Waiting to run
citra-build / docker (push) Waiting to run
citra-format / clang-format (push) Waiting to run
citra-libretro / android (push) Waiting to run
citra-libretro / linux (push) Waiting to run
citra-libretro / windows (push) Waiting to run
citra-libretro / macos (arm64) (push) Waiting to run
citra-libretro / macos (x86_64) (push) Waiting to run
citra-libretro / ios (push) Waiting to run
citra-libretro / tvos (push) Waiting to run
citra-transifex / transifex (push) Waiting to run
Implement libretro core (#1215)
* libretro core

* Bringing citra libretro implementation over
* libretro: hook up vulkan renderer
* libretro: github actions
* libretro: gyro
* libretro: core options v2
* libretro: on ios turn off shader jit if unavailable
* moltenvk 1.3.0 introduces 8-bit indexes but allocates 16-bit for metal; this ends up allocating stream buffer * 2 = 132MiB. Instead, just use 16-bit indexes. (This will be necessary for standalone when bumping moltenvk version.)

* libretro core: address review feedback

* libretro: microphone support

* cmake: Add ENABLE_ROOM_STANDALONE to list of incompatible libretro flags

* libretro: proper initial geometry

* libretro: fix software renderer

* libretro: address review feedback

* .github/libretro.yml: Pin macOS runners at macOS 26

* ci: Remove explicit selection of Xcode 16.0

* .github/libretro.yml: remove unnecessary windows builder apt commands

* .github/libretro.yml: bump min macos version to 11.0

* ci: Re-enable CI jobs for all libretro cores

This is under the condition that we don't introduce build cache for these builds

---------

Co-authored-by: OpenSauce04 <opensauce04@gmail.com>
Co-authored-by: PabloMK7 <hackyglitch2@gmail.com>
2026-02-19 22:30:25 +00:00

130 lines
3.7 KiB
C++

// Copyright Citra Emulator Project / Azahar Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <functional>
#include <memory>
#include <boost/serialization/access.hpp>
#include "core/hle/service/gsp/gsp_interrupt.h"
namespace Service::GSP {
struct Command;
struct FrameBufferInfo;
} // namespace Service::GSP
namespace Core {
class System;
}
namespace Pica {
class DebugContext;
class PicaCore;
struct RegsLcd;
union ColorFill;
} // namespace Pica
namespace Frontend {
class EmuWindow;
}
namespace VideoCore {
/// Measured on hardware to be 2240568 timer cycles or 4481136 ARM11 cycles
constexpr u64 FRAME_TICKS = 4481136ull;
class GraphicsDebugger;
class RendererBase;
class RightEyeDisabler;
/**
* The GPU class is the high level interface to the video_core for core services.
*/
class GPU {
public:
explicit GPU(Core::System& system, Frontend::EmuWindow& emu_window,
Frontend::EmuWindow* secondary_window);
~GPU();
/// Sets the function to call for signalling GSP interrupts.
void SetInterruptHandler(Service::GSP::InterruptHandler handler);
/// Notify rasterizer that any caches of the specified region should be flushed to Switch memory
void FlushRegion(PAddr addr, u32 size);
/// Notify rasterizer that any caches of the specified region should be invalidated
void InvalidateRegion(PAddr addr, u32 size);
/// Flushes and invalidates all memory in the rasterizer cache and removes any leftover state.
void ClearAll(bool flush);
/// Executes the provided GSP command.
void Execute(const Service::GSP::Command& command);
/// Updates GPU display framebuffer configuration using the specified parameters.
void SetBufferSwap(u32 screen_id, const Service::GSP::FrameBufferInfo& info);
/// Sets the LCD color fill configuration for the top and bottom screens.
void SetColorFill(const Pica::ColorFill& fill);
/// Reads a word from the GPU virtual address.
u32 ReadReg(VAddr addr);
/// Writes the provided value to the GPU virtual address.
void WriteReg(VAddr addr, u32 data);
/// Returns a mutable reference to the renderer.
[[nodiscard]] VideoCore::RendererBase& Renderer();
/// Returns a mutable reference to the PICA GPU.
[[nodiscard]] Pica::PicaCore& PicaCore();
/// Returns an immutable reference to the PICA GPU.
[[nodiscard]] const Pica::PicaCore& PicaCore() const;
/// Returns a mutable reference to the pica debugging context.
[[nodiscard]] Pica::DebugContext& DebugContext();
/// Returns a mutable reference to the GSP command debugger.
[[nodiscard]] GraphicsDebugger& Debugger();
RightEyeDisabler& GetRightEyeDisabler() {
return *right_eye_disabler;
}
void ApplyPerProgramSettings(u64 program_ID);
/// Recreates the renderer (for GL context reset in libretro)
void RecreateRenderer(Frontend::EmuWindow& emu_window, Frontend::EmuWindow* secondary_window);
/// Releases the renderer (for GL context destroy in libretro)
void ReleaseRenderer();
private:
void SubmitCmdList(u32 index);
// Interrupt index must be 0 or 1 to signal the relative PSC interrupt.
void MemoryFill(u32 index, u32 intr_index);
void MemoryTransfer();
void VBlankCallback(uintptr_t user_data, s64 cycles_late);
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const u32 file_version);
std::unique_ptr<RightEyeDisabler> right_eye_disabler;
private:
friend class RightEyeDisabler;
struct Impl;
std::unique_ptr<Impl> impl;
PAddr VirtualToPhysicalAddress(VAddr addr);
};
} // namespace VideoCore