Files
PS2Recomp/ps2xRuntime/include/ps2_gs_gpu.h
T
Ranieri 8584c0613a Feature/runtime gs recompiler instructions (#73)
* feat: basic gs
feat: basic rasterizer
fix: a lot of fixes to runtime stubs
feat: basic vif intercepter
feat: return "ok" for some stubs
feat: disassembly code as comment
fix: fix code gen instructions set
fix: again jump
feat: remove unused macro
fix: fix some problematic macros
feat: track delayslots on runtime
and many more

* feat: added missing files

* fix: fix instruction test
2026-02-22 02:20:42 -03:00

63 lines
1.3 KiB
C++

#ifndef PS2_GS_GPU_H
#define PS2_GS_GPU_H
#include <cstdint>
#include <vector>
#include <mutex>
#include <atomic>
enum GsGpuPrimType : uint8_t
{
GS_GPU_POINT = 0,
GS_GPU_LINE = 1,
GS_GPU_TRIANGLE = 2,
GS_GPU_QUAD = 3,
};
struct GsGpuVertex
{
float x, y, z; // screen-space position (after PS2 12.4 fixed → float)
uint8_t r, g, b, a; // vertex color
float u, v; // texture coords (for future use)
};
struct GsGpuPrimitive
{
GsGpuPrimType type;
uint8_t vertexCount; // 1 (point), 2 (line), 3 (tri), 4 (quad)
GsGpuVertex verts[4];
};
class GsGpuFrameData
{
public:
GsGpuFrameData();
void pushPrimitive(const GsGpuPrimitive &prim);
const std::vector<GsGpuPrimitive> &swapAndGetFront();
bool hasGpuPrimitives() const;
void setScreenSize(uint32_t w, uint32_t h)
{
m_screenW = w;
m_screenH = h;
}
uint32_t screenWidth() const { return m_screenW; }
uint32_t screenHeight() const { return m_screenH; }
private:
std::vector<GsGpuPrimitive> m_buffers[2];
int m_backIdx = 0; // index into m_buffers for the current write target
mutable std::mutex m_mutex;
std::atomic<bool> m_hasData{false};
uint32_t m_screenW = 640;
uint32_t m_screenH = 448;
};
GsGpuFrameData &gsGpuGetFrameData();
bool gsGpuRenderFrame();
#endif // PS2_GS_GPU_H