mirror of
https://github.com/ran-j/PS2Recomp.git
synced 2026-09-26 08:51:05 -04:00
75d729ce40
* refactor: from guest threads to EE scheduler * feat: bad wip mpeg fix for code veronica * feat: cheap copy from host feat: small perf o vsync tick * feat: added EE clock Hz fix: fix MPEG out of sync with new EE refactor * fix: fix lotr tests * fix: fix cri dtx loading fix: fix wrong mmi instruction translation fix: fix thread info params feat: added EE timers decoder and consumer feat: split SFI and IOP memory to prevent collision and overrides * feat: revert wrong changes * refactor: change GS architecture * feat: IOP emulator refactor: codegen to catch callbacks on mips code feat: added a lot of entries or IOP emulator * feat: analyzer resolve the complete constant-producing sequence with five-instruction backward scan stopped at LUI and therefore * feat: remove recompiled version of GetRomName refactor: split IOP emulator logic feat: added more HLE IOP modules feat: added ps2_path * eat: enhance ELF parser with improved callable entry detection and control flow analysis * feat: update memory hint handling and enhance entry point discovery logic * feat: add SET_GPR_ZE32 macro for zero-extending loads with unsigned semantics * refactor: Refactor PS2 IOP Host Adapter and Memory Management feat: Added PS2Vfs for virtual file system operations, including file opening, reading, writing, and path resolution. feat: Improve VIF1 data processing to handle GIF image packets more efficiently. * feat: added a lot of tests * fix: fix texture caching feat: wip multi version on dbcman * feat: remove LLE IOPs
82 lines
3.6 KiB
C++
82 lines
3.6 KiB
C++
#pragma once
|
|
|
|
#include "runtime/gs/gs_backend.h"
|
|
#include "runtime/gs/gs_texture_page_cache.h"
|
|
|
|
#include <array>
|
|
#include <mutex>
|
|
#include <vector>
|
|
|
|
class GSCpuBackend final : public GSRasterBackend
|
|
{
|
|
public:
|
|
GSCpuBackend();
|
|
|
|
void Initialize(uint8_t *vram, uint32_t vramSize) override;
|
|
void Reset() override;
|
|
|
|
void Submit(const GSPrimitiveBatch &batch) override;
|
|
void LoadClut(const GSTex0Reg &tex0, const GSTexClutReg &texclut) override;
|
|
void BeginTransfer(const GSTransferCommand &command) override;
|
|
void UploadImage(const uint8_t *data, uint32_t sizeBytes) override;
|
|
|
|
void Flush() override;
|
|
void TextureFlush() override;
|
|
void Sync(GSSyncReason reason) override;
|
|
PresentationFrame Present(const GSPresentationRequest &request) override;
|
|
|
|
bool ClearFramebuffer(const GSContext &context, uint32_t rgba) override;
|
|
uint32_t ConsumeLocalToHostBytes(uint8_t *dst, uint32_t maxBytes) override;
|
|
|
|
uint32_t ReadVram(uint32_t psm, uint32_t base, uint32_t bw, uint32_t x, uint32_t y) const override;
|
|
void WriteVram(uint32_t psm, uint32_t base, uint32_t bw, uint32_t x, uint32_t y, uint32_t value) override;
|
|
void SnapshotVram(std::vector<uint8_t> &out) const override;
|
|
GSTransferSnapshot GetTransferSnapshot() const override;
|
|
|
|
private:
|
|
void ResetUnlocked();
|
|
void LoadClutUnlocked(const GSTex0Reg &tex0, const GSTexClutReg &texclut);
|
|
uint32_t ReadVramUnlocked(uint32_t psm, uint32_t base, uint32_t bw, uint32_t x, uint32_t y) const;
|
|
uint32_t ReadTextureVramUnlocked(uint32_t psm, uint32_t base, uint32_t bw, uint32_t x, uint32_t y);
|
|
void WriteVramUnlocked(uint32_t psm, uint32_t base, uint32_t bw, uint32_t x, uint32_t y, uint32_t value);
|
|
|
|
void DrawPrimitive(const GSPrimitiveBatch &batch);
|
|
void DrawSprite(const GSPrimitiveBatch &batch);
|
|
void DrawTriangle(const GSPrimitiveBatch &batch);
|
|
void DrawLine(const GSPrimitiveBatch &batch);
|
|
void WritePixel(const GSDrawState &state, int x, int y, int z, uint8_t r, uint8_t g, uint8_t b, uint8_t a, uint8_t fog);
|
|
uint32_t SampleTexture(const GSDrawState &state, float s, float t, float q, uint16_t u, uint16_t v);
|
|
uint32_t LookupCLUT(const GSDrawState &state, uint8_t index, uint8_t cpsm, uint8_t csm, uint8_t csa, uint8_t sourcePsm);
|
|
|
|
void PerformLocalToLocalTransfer();
|
|
void PerformLocalToHostTransfer();
|
|
PresentationFrame PresentFromLocalMemory(const GSPresentationRequest &request);
|
|
bool CopyFrameToHostRgba(const GSFrameReg &frame,
|
|
uint32_t width,
|
|
uint32_t height,
|
|
std::vector<uint8_t> &outPixels,
|
|
bool preserveAlpha,
|
|
bool useLocalMemoryLayout,
|
|
bool frameBaseIsPages,
|
|
uint32_t sourceOriginX,
|
|
uint32_t sourceOriginY) const;
|
|
|
|
using WriteVramFunc = void (*)(uint8_t *, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t);
|
|
using ReadVramFunc = uint32_t (*)(uint8_t *, uint32_t, uint32_t, uint32_t, uint32_t);
|
|
|
|
static constexpr size_t kPsmHandlerCount = 1u << 6u;
|
|
mutable std::mutex m_mutex;
|
|
uint8_t *m_vram = nullptr;
|
|
uint32_t m_vramSize = 0;
|
|
std::array<ReadVramFunc, kPsmHandlerCount> m_readVramFuncs{};
|
|
std::array<WriteVramFunc, kPsmHandlerCount> m_writeVramFuncs{};
|
|
std::array<uint16_t, 512> m_clut{};
|
|
std::array<uint32_t, 2> m_clutCbp{};
|
|
GSMem::TexturePageCache m_texturePageCache;
|
|
|
|
GSTransferCommand m_transfer{};
|
|
GSTransferSnapshot m_transferState{};
|
|
std::vector<uint8_t> m_localToHostBuffer;
|
|
size_t m_localToHostReadPos = 0;
|
|
};
|