2020-12-05 13:08:24 +01:00
|
|
|
#pragma once
|
2015-12-02 10:23:25 +01:00
|
|
|
|
2018-09-25 22:34:45 +02:00
|
|
|
#include "Emu/Memory/vm_ptr.h"
|
2016-07-31 16:41:28 +02:00
|
|
|
#include "gcm_enums.h"
|
2019-07-27 00:34:10 +02:00
|
|
|
#include "util/atomic.hpp"
|
2015-06-19 17:49:38 +02:00
|
|
|
|
2014-06-19 20:15:53 +02:00
|
|
|
|
2012-11-15 00:39:56 +01:00
|
|
|
struct CellGcmControl
|
|
|
|
|
{
|
2015-05-27 05:11:59 +02:00
|
|
|
atomic_be_t<u32> put;
|
|
|
|
|
atomic_be_t<u32> get;
|
|
|
|
|
atomic_be_t<u32> ref;
|
2012-11-15 00:39:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct CellGcmConfig
|
|
|
|
|
{
|
2014-02-24 17:03:47 +01:00
|
|
|
be_t<u32> localAddress;
|
|
|
|
|
be_t<u32> ioAddress;
|
|
|
|
|
be_t<u32> localSize;
|
|
|
|
|
be_t<u32> ioSize;
|
|
|
|
|
be_t<u32> memoryFrequency;
|
|
|
|
|
be_t<u32> coreFrequency;
|
2012-11-15 00:39:56 +01:00
|
|
|
};
|
|
|
|
|
|
2014-11-08 17:58:51 +01:00
|
|
|
struct CellGcmContextData;
|
|
|
|
|
|
2019-06-08 09:54:38 +02:00
|
|
|
using CellGcmContextCallback = s32 (vm::ptr<CellGcmContextData>, u32);
|
2014-11-08 17:58:51 +01:00
|
|
|
|
2012-11-15 00:39:56 +01:00
|
|
|
struct CellGcmContextData
|
|
|
|
|
{
|
2018-02-09 15:49:37 +01:00
|
|
|
vm::bptr<u32> begin;
|
|
|
|
|
vm::bptr<u32> end;
|
|
|
|
|
vm::bptr<u32> current;
|
|
|
|
|
vm::bptr<CellGcmContextCallback> callback;
|
2012-11-15 00:39:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct gcmInfo
|
|
|
|
|
{
|
|
|
|
|
u32 config_addr;
|
|
|
|
|
u32 context_addr;
|
|
|
|
|
u32 control_addr;
|
2015-02-13 15:04:03 +01:00
|
|
|
u32 label_addr;
|
2017-02-04 15:18:37 +01:00
|
|
|
u32 command_size = 0x400;
|
|
|
|
|
u32 segment_size = 0x100;
|
2012-11-15 00:39:56 +01:00
|
|
|
};
|
|
|
|
|
|
2013-11-09 22:29:49 +01:00
|
|
|
struct CellGcmSurface
|
|
|
|
|
{
|
|
|
|
|
u8 type;
|
|
|
|
|
u8 antialias;
|
2014-06-30 20:27:45 +02:00
|
|
|
u8 colorFormat;
|
|
|
|
|
u8 colorTarget;
|
|
|
|
|
u8 colorLocation[4];
|
2014-08-16 23:45:56 +02:00
|
|
|
be_t<u32> colorOffset[4];
|
|
|
|
|
be_t<u32> colorPitch[4];
|
2014-06-30 20:27:45 +02:00
|
|
|
u8 depthFormat;
|
|
|
|
|
u8 depthLocation;
|
|
|
|
|
u8 _padding[2];
|
2014-08-16 23:45:56 +02:00
|
|
|
be_t<u32> depthOffset;
|
|
|
|
|
be_t<u32> depthPitch;
|
|
|
|
|
be_t<u16> width;
|
|
|
|
|
be_t<u16> height;
|
|
|
|
|
be_t<u16> x;
|
|
|
|
|
be_t<u16> y;
|
2013-11-09 22:29:49 +01:00
|
|
|
};
|
|
|
|
|
|
2019-07-26 07:05:50 +02:00
|
|
|
struct alignas(16) CellGcmReportData
|
2013-11-09 22:29:49 +01:00
|
|
|
{
|
2015-10-07 16:36:26 +02:00
|
|
|
be_t<u64> timer;
|
|
|
|
|
be_t<u32> value;
|
|
|
|
|
be_t<u32> padding;
|
2013-11-09 22:29:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct CellGcmZcullInfo
|
|
|
|
|
{
|
2018-12-01 06:06:48 +01:00
|
|
|
be_t<u32> region;
|
|
|
|
|
be_t<u32> size;
|
|
|
|
|
be_t<u32> start;
|
|
|
|
|
be_t<u32> offset;
|
|
|
|
|
be_t<u32> status0;
|
|
|
|
|
be_t<u32> status1;
|
2013-11-09 22:29:49 +01:00
|
|
|
};
|
|
|
|
|
|
2014-08-16 23:45:56 +02:00
|
|
|
struct CellGcmDisplayInfo
|
|
|
|
|
{
|
|
|
|
|
be_t<u32> offset;
|
|
|
|
|
be_t<u32> pitch;
|
|
|
|
|
be_t<u32> width;
|
|
|
|
|
be_t<u32> height;
|
|
|
|
|
};
|
|
|
|
|
|
2013-11-09 22:29:49 +01:00
|
|
|
struct CellGcmTileInfo
|
|
|
|
|
{
|
2014-02-24 17:03:47 +01:00
|
|
|
be_t<u32> tile;
|
|
|
|
|
be_t<u32> limit;
|
|
|
|
|
be_t<u32> pitch;
|
|
|
|
|
be_t<u32> format;
|
2013-11-09 22:29:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct GcmZcullInfo
|
|
|
|
|
{
|
2015-10-04 00:45:26 +02:00
|
|
|
u32 offset;
|
|
|
|
|
u32 width;
|
|
|
|
|
u32 height;
|
|
|
|
|
u32 cullStart;
|
|
|
|
|
u32 zFormat;
|
|
|
|
|
u32 aaFormat;
|
|
|
|
|
u32 zcullDir;
|
|
|
|
|
u32 zcullFormat;
|
|
|
|
|
u32 sFunc;
|
|
|
|
|
u32 sRef;
|
|
|
|
|
u32 sMask;
|
2020-04-10 22:09:13 +02:00
|
|
|
bool bound = false;
|
2014-06-07 04:22:29 +02:00
|
|
|
|
2015-10-04 00:45:26 +02:00
|
|
|
CellGcmZcullInfo pack() const
|
2014-06-07 04:22:29 +02:00
|
|
|
{
|
|
|
|
|
CellGcmZcullInfo ret;
|
|
|
|
|
|
2015-10-04 00:45:26 +02:00
|
|
|
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);
|
2014-06-07 04:22:29 +02:00
|
|
|
ret.status1 = (0x2000<<0) | (0x20<<16);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
2013-11-09 22:29:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct GcmTileInfo
|
|
|
|
|
{
|
2015-10-04 00:45:26 +02:00
|
|
|
u32 location;
|
|
|
|
|
u32 offset;
|
|
|
|
|
u32 size;
|
|
|
|
|
u32 pitch;
|
|
|
|
|
u32 comp;
|
|
|
|
|
u32 base;
|
|
|
|
|
u32 bank;
|
2020-04-10 22:09:13 +02:00
|
|
|
bool bound = false;
|
2013-11-09 22:29:49 +01:00
|
|
|
|
2015-10-04 00:45:26 +02:00
|
|
|
CellGcmTileInfo pack() const
|
2013-11-09 22:29:49 +01:00
|
|
|
{
|
|
|
|
|
CellGcmTileInfo ret;
|
|
|
|
|
|
2015-10-04 00:45:26 +02:00
|
|
|
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);
|
2013-11-09 22:29:49 +01:00
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2020-12-12 11:12:39 +01:00
|
|
|
struct any32
|
2012-11-15 00:39:56 +01:00
|
|
|
{
|
2020-12-12 11:12:39 +01:00
|
|
|
u32 m_data;
|
2015-10-04 00:45:26 +02:00
|
|
|
|
2021-04-16 05:40:54 +02:00
|
|
|
template <typename T, typename T2 = std::common_type_t<T>>
|
2020-12-12 11:12:39 +01:00
|
|
|
any32(const T& value)
|
|
|
|
|
: m_data(std::bit_cast<u32, T2>(value))
|
|
|
|
|
{
|
2015-10-04 00:45:26 +02:00
|
|
|
}
|
|
|
|
|
|
2020-12-12 11:12:39 +01:00
|
|
|
template <typename T>
|
|
|
|
|
T as() const
|
2015-10-04 00:45:26 +02:00
|
|
|
{
|
2020-12-12 11:12:39 +01:00
|
|
|
return std::bit_cast<T>(m_data);
|
2015-10-04 00:45:26 +02:00
|
|
|
}
|
2020-12-12 11:12:39 +01:00
|
|
|
};
|