2012-11-15 00:39:56 +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"
|
2016-09-19 16:17:37 +02:00
|
|
|
#include "gcm_printing.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;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2015-10-04 00:45:26 +02:00
|
|
|
namespace rsx
|
2012-11-15 00:39:56 +01:00
|
|
|
{
|
2016-04-25 12:49:12 +02:00
|
|
|
template<typename AT>
|
|
|
|
|
static inline u32 make_command(vm::_ptr_base<be_t<u32>, AT>& dst, u32 start_register, std::initializer_list<any32> values)
|
2012-11-15 00:39:56 +01:00
|
|
|
{
|
2016-04-25 12:49:12 +02:00
|
|
|
*dst++ = start_register << 2 | static_cast<u32>(values.size()) << 18;
|
2015-10-04 00:45:26 +02:00
|
|
|
|
2016-04-25 12:49:12 +02:00
|
|
|
for (const any32& cmd : values)
|
2015-10-04 00:45:26 +02:00
|
|
|
{
|
2016-04-25 12:49:12 +02:00
|
|
|
*dst++ = cmd.as<u32>();
|
2015-10-04 00:45:26 +02:00
|
|
|
}
|
|
|
|
|
|
2018-09-03 17:46:14 +02:00
|
|
|
return u32{sizeof(u32)} * (static_cast<u32>(values.size()) + 1);
|
2015-10-04 00:45:26 +02:00
|
|
|
}
|
|
|
|
|
|
2015-10-05 02:42:48 +02:00
|
|
|
template<typename AT>
|
2016-04-25 12:49:12 +02:00
|
|
|
static inline u32 make_jump(vm::_ptr_base<be_t<u32>, AT>& dst, u32 offset)
|
2015-10-04 00:45:26 +02:00
|
|
|
{
|
2016-10-01 21:13:15 +02:00
|
|
|
*dst++ = RSX_METHOD_OLD_JUMP_CMD | offset;
|
2016-04-25 12:49:12 +02:00
|
|
|
|
2018-09-03 17:46:14 +02:00
|
|
|
return sizeof(u32);
|
2015-10-04 00:45:26 +02:00
|
|
|
}
|
2015-12-02 10:23:25 +01:00
|
|
|
}
|