#pragma once #include "Emu/Memory/vm_ptr.h" #include "gcm_enums.h" #include "util/atomic.hpp" struct CellGcmControl { atomic_be_t put; atomic_be_t get; atomic_be_t ref; }; struct CellGcmConfig { be_t localAddress; be_t ioAddress; be_t localSize; be_t ioSize; be_t memoryFrequency; be_t coreFrequency; }; struct CellGcmContextData; using CellGcmContextCallback = s32 (vm::ptr, u32); struct CellGcmContextData { vm::bptr begin; vm::bptr end; vm::bptr current; vm::bptr callback; }; struct gcmInfo { u32 config_addr; u32 context_addr; u32 control_addr; u32 label_addr; u32 command_size = 0x400; u32 segment_size = 0x100; }; struct CellGcmSurface { u8 type; u8 antialias; u8 colorFormat; u8 colorTarget; u8 colorLocation[4]; be_t colorOffset[4]; be_t colorPitch[4]; u8 depthFormat; u8 depthLocation; u8 _padding[2]; be_t depthOffset; be_t depthPitch; be_t width; be_t height; be_t x; be_t y; }; struct alignas(16) CellGcmReportData { be_t timer; be_t value; be_t padding; }; struct CellGcmZcullInfo { be_t region; be_t size; be_t start; be_t offset; be_t status0; be_t status1; }; struct CellGcmDisplayInfo { be_t offset; be_t pitch; be_t width; be_t height; }; struct CellGcmTileInfo { be_t tile; be_t limit; be_t pitch; be_t format; }; struct GcmZcullInfo { u32 offset; u32 width; u32 height; u32 cullStart; u32 zFormat; u32 aaFormat; u32 zcullDir; u32 zcullFormat; u32 sFunc; u32 sRef; u32 sMask; bool bound = false; CellGcmZcullInfo pack() const { CellGcmZcullInfo ret; ret.region = (1<<0) | (zFormat<<4) | (aaFormat<<8); ret.size = ((width>>6)<<22) | ((height>>6)<<6); ret.start = cullStart&(~0xFFF); ret.offset = offset; ret.status0 = (zcullDir<<1) | (zcullFormat<<2) | ((sFunc&0xF)<<12) | (sRef<<16) | (sMask<<24); ret.status1 = (0x2000<<0) | (0x20<<16); return ret; } }; struct GcmTileInfo { u32 location; u32 offset; u32 size; u32 pitch; u32 comp; u32 base; u32 bank; bool bound = false; CellGcmTileInfo pack() const { CellGcmTileInfo ret; ret.tile = (location + 1) | (bank << 4) | ((offset / 0x10000) << 16) | (location << 31); ret.limit = ((offset + size - 1) / 0x10000) << 16 | (location << 31); ret.pitch = (pitch / 0x100) << 8; ret.format = base | ((base + ((size - 1) / 0x10000)) << 13) | (comp << 26) | (1 << 30); return ret; } }; struct any32 { u32 m_data; template > any32(const T& value) : m_data(std::bit_cast(value)) { } template T as() const { return std::bit_cast(m_data); } };