2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2013-04-18 03:09:55 +00:00
|
|
|
// Refer to the license.txt file included.
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2014-02-10 18:54:46 +00:00
|
|
|
#pragma once
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2014-10-22 00:42:55 +00:00
|
|
|
#include "Common/BitSet.h"
|
2014-09-08 01:06:58 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2008-12-08 04:46:09 +00:00
|
|
|
|
|
|
|
// Vertex array numbers
|
|
|
|
enum
|
|
|
|
{
|
2014-02-09 21:03:16 +00:00
|
|
|
ARRAY_POSITION = 0,
|
|
|
|
ARRAY_NORMAL = 1,
|
|
|
|
ARRAY_COLOR = 2,
|
|
|
|
ARRAY_COLOR2 = 3,
|
|
|
|
ARRAY_TEXCOORD0 = 4,
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Vertex components
|
|
|
|
enum
|
|
|
|
{
|
2015-01-15 00:46:23 +00:00
|
|
|
NOT_PRESENT = 0,
|
|
|
|
DIRECT = 1,
|
|
|
|
INDEX8 = 2,
|
|
|
|
INDEX16 = 3,
|
|
|
|
|
|
|
|
MASK_INDEXED = 2,
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2014-02-09 21:03:16 +00:00
|
|
|
FORMAT_UBYTE = 0, // 2 Cmp
|
|
|
|
FORMAT_BYTE = 1, // 3 Cmp
|
|
|
|
FORMAT_USHORT = 2,
|
|
|
|
FORMAT_SHORT = 3,
|
|
|
|
FORMAT_FLOAT = 4,
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2014-02-09 21:03:16 +00:00
|
|
|
FORMAT_16B_565 = 0, // NA
|
|
|
|
FORMAT_24B_888 = 1,
|
|
|
|
FORMAT_32B_888x = 2,
|
|
|
|
FORMAT_16B_4444 = 3,
|
|
|
|
FORMAT_24B_6666 = 4,
|
|
|
|
FORMAT_32B_8888 = 5,
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#pragma pack(4)
|
|
|
|
union TVtxDesc
|
|
|
|
{
|
|
|
|
u64 Hex;
|
2013-10-29 05:23:17 +00:00
|
|
|
struct
|
2008-12-08 04:46:09 +00:00
|
|
|
{
|
|
|
|
// 0: not present
|
|
|
|
// 1: present
|
2014-09-01 09:00:25 +00:00
|
|
|
u64 PosMatIdx : 1;
|
|
|
|
u64 Tex0MatIdx : 1;
|
|
|
|
u64 Tex1MatIdx : 1;
|
|
|
|
u64 Tex2MatIdx : 1;
|
|
|
|
u64 Tex3MatIdx : 1;
|
|
|
|
u64 Tex4MatIdx : 1;
|
|
|
|
u64 Tex5MatIdx : 1;
|
|
|
|
u64 Tex6MatIdx : 1;
|
|
|
|
u64 Tex7MatIdx : 1;
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2013-10-29 05:23:17 +00:00
|
|
|
// 00: not present
|
|
|
|
// 01: direct
|
|
|
|
// 10: 8 bit index
|
2008-12-08 04:46:09 +00:00
|
|
|
// 11: 16 bit index
|
2014-09-01 09:00:25 +00:00
|
|
|
u64 Position : 2;
|
|
|
|
u64 Normal : 2;
|
|
|
|
u64 Color0 : 2;
|
|
|
|
u64 Color1 : 2;
|
|
|
|
u64 Tex0Coord : 2;
|
|
|
|
u64 Tex1Coord : 2;
|
|
|
|
u64 Tex2Coord : 2;
|
|
|
|
u64 Tex3Coord : 2;
|
|
|
|
u64 Tex4Coord : 2;
|
|
|
|
u64 Tex5Coord : 2;
|
|
|
|
u64 Tex6Coord : 2;
|
|
|
|
u64 Tex7Coord : 2;
|
|
|
|
u64 :31;
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
2013-04-24 13:21:54 +00:00
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
2013-03-20 01:51:12 +00:00
|
|
|
u32 Hex0, Hex1;
|
|
|
|
};
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
union UVAT_group0
|
|
|
|
{
|
2013-03-20 01:51:12 +00:00
|
|
|
u32 Hex;
|
2013-10-29 05:23:17 +00:00
|
|
|
struct
|
2013-03-20 01:51:12 +00:00
|
|
|
{
|
|
|
|
// 0:8
|
2014-02-09 23:29:13 +00:00
|
|
|
u32 PosElements : 1;
|
|
|
|
u32 PosFormat : 3;
|
|
|
|
u32 PosFrac : 5;
|
2013-03-20 01:51:12 +00:00
|
|
|
// 9:12
|
2014-02-09 23:29:13 +00:00
|
|
|
u32 NormalElements : 1;
|
|
|
|
u32 NormalFormat : 3;
|
2013-03-20 01:51:12 +00:00
|
|
|
// 13:16
|
2014-02-09 23:29:13 +00:00
|
|
|
u32 Color0Elements : 1;
|
|
|
|
u32 Color0Comp : 3;
|
2013-03-20 01:51:12 +00:00
|
|
|
// 17:20
|
2014-02-09 23:29:13 +00:00
|
|
|
u32 Color1Elements : 1;
|
|
|
|
u32 Color1Comp : 3;
|
2013-03-20 01:51:12 +00:00
|
|
|
// 21:29
|
2014-02-09 23:29:13 +00:00
|
|
|
u32 Tex0CoordElements : 1;
|
|
|
|
u32 Tex0CoordFormat : 3;
|
|
|
|
u32 Tex0Frac : 5;
|
2013-03-20 01:51:12 +00:00
|
|
|
// 30:31
|
2014-02-09 23:29:13 +00:00
|
|
|
u32 ByteDequant : 1;
|
|
|
|
u32 NormalIndex3 : 1;
|
2013-03-20 01:51:12 +00:00
|
|
|
};
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
union UVAT_group1
|
|
|
|
{
|
2013-03-20 01:51:12 +00:00
|
|
|
u32 Hex;
|
2013-10-29 05:23:17 +00:00
|
|
|
struct
|
2013-03-20 01:51:12 +00:00
|
|
|
{
|
|
|
|
// 0:8
|
2014-02-09 23:29:13 +00:00
|
|
|
u32 Tex1CoordElements : 1;
|
|
|
|
u32 Tex1CoordFormat : 3;
|
|
|
|
u32 Tex1Frac : 5;
|
2013-03-20 01:51:12 +00:00
|
|
|
// 9:17
|
2014-02-09 23:29:13 +00:00
|
|
|
u32 Tex2CoordElements : 1;
|
|
|
|
u32 Tex2CoordFormat : 3;
|
|
|
|
u32 Tex2Frac : 5;
|
2013-03-20 01:51:12 +00:00
|
|
|
// 18:26
|
2014-02-09 23:29:13 +00:00
|
|
|
u32 Tex3CoordElements : 1;
|
|
|
|
u32 Tex3CoordFormat : 3;
|
|
|
|
u32 Tex3Frac : 5;
|
2013-03-20 01:51:12 +00:00
|
|
|
// 27:30
|
2014-02-09 23:29:13 +00:00
|
|
|
u32 Tex4CoordElements : 1;
|
|
|
|
u32 Tex4CoordFormat : 3;
|
2013-10-29 05:23:17 +00:00
|
|
|
//
|
2014-02-09 23:29:13 +00:00
|
|
|
u32 : 1;
|
2013-03-20 01:51:12 +00:00
|
|
|
};
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
union UVAT_group2
|
|
|
|
{
|
2013-03-20 01:51:12 +00:00
|
|
|
u32 Hex;
|
2013-10-29 05:23:17 +00:00
|
|
|
struct
|
2013-03-20 01:51:12 +00:00
|
|
|
{
|
|
|
|
// 0:4
|
2014-02-09 23:29:13 +00:00
|
|
|
u32 Tex4Frac : 5;
|
2013-03-20 01:51:12 +00:00
|
|
|
// 5:13
|
2014-02-09 23:29:13 +00:00
|
|
|
u32 Tex5CoordElements : 1;
|
|
|
|
u32 Tex5CoordFormat : 3;
|
|
|
|
u32 Tex5Frac : 5;
|
2013-03-20 01:51:12 +00:00
|
|
|
// 14:22
|
2014-02-09 23:29:13 +00:00
|
|
|
u32 Tex6CoordElements : 1;
|
|
|
|
u32 Tex6CoordFormat : 3;
|
|
|
|
u32 Tex6Frac : 5;
|
2013-03-20 01:51:12 +00:00
|
|
|
// 23:31
|
2014-02-09 23:29:13 +00:00
|
|
|
u32 Tex7CoordElements : 1;
|
|
|
|
u32 Tex7CoordFormat : 3;
|
|
|
|
u32 Tex7Frac : 5;
|
2013-03-20 01:51:12 +00:00
|
|
|
};
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ColorAttr
|
|
|
|
{
|
2013-03-20 01:51:12 +00:00
|
|
|
u8 Elements;
|
|
|
|
u8 Comp;
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct TexAttr
|
|
|
|
{
|
2013-03-20 01:51:12 +00:00
|
|
|
u8 Elements;
|
|
|
|
u8 Format;
|
|
|
|
u8 Frac;
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct TVtxAttr
|
2013-03-20 01:51:12 +00:00
|
|
|
{
|
|
|
|
u8 PosElements;
|
2013-10-29 05:23:17 +00:00
|
|
|
u8 PosFormat;
|
|
|
|
u8 PosFrac;
|
2013-03-20 01:51:12 +00:00
|
|
|
u8 NormalElements;
|
2013-10-29 05:23:17 +00:00
|
|
|
u8 NormalFormat;
|
2013-03-20 01:51:12 +00:00
|
|
|
ColorAttr color[2];
|
|
|
|
TexAttr texCoord[8];
|
2015-01-20 01:12:03 +00:00
|
|
|
bool ByteDequant;
|
2013-03-20 01:51:12 +00:00
|
|
|
u8 NormalIndex3;
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Matrix indices
|
|
|
|
union TMatrixIndexA
|
|
|
|
{
|
2013-03-20 01:51:12 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
u32 PosNormalMtxIdx : 6;
|
|
|
|
u32 Tex0MtxIdx : 6;
|
|
|
|
u32 Tex1MtxIdx : 6;
|
|
|
|
u32 Tex2MtxIdx : 6;
|
|
|
|
u32 Tex3MtxIdx : 6;
|
|
|
|
};
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
u32 Hex : 30;
|
|
|
|
u32 unused : 2;
|
|
|
|
};
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
union TMatrixIndexB
|
|
|
|
{
|
2013-03-20 01:51:12 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
u32 Tex4MtxIdx : 6;
|
|
|
|
u32 Tex5MtxIdx : 6;
|
|
|
|
u32 Tex6MtxIdx : 6;
|
|
|
|
u32 Tex7MtxIdx : 6;
|
|
|
|
};
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
u32 Hex : 24;
|
|
|
|
u32 unused : 8;
|
|
|
|
};
|
2008-12-08 04:46:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#pragma pack()
|
|
|
|
|
|
|
|
struct VAT
|
|
|
|
{
|
|
|
|
UVAT_group0 g0;
|
|
|
|
UVAT_group1 g1;
|
|
|
|
UVAT_group2 g2;
|
|
|
|
};
|
|
|
|
|
2014-12-13 00:51:14 +00:00
|
|
|
class VertexLoaderBase;
|
2014-08-27 17:38:00 +00:00
|
|
|
|
2014-08-27 17:26:06 +00:00
|
|
|
// STATE_TO_SAVE
|
|
|
|
struct CPState final
|
|
|
|
{
|
2015-01-07 20:48:59 +00:00
|
|
|
u32 array_bases[16];
|
|
|
|
u32 array_strides[16];
|
|
|
|
TMatrixIndexA matrix_index_a;
|
|
|
|
TMatrixIndexB matrix_index_b;
|
|
|
|
TVtxDesc vtx_desc;
|
|
|
|
// Most games only use the first VtxAttr and simply reconfigure it all the time as needed.
|
|
|
|
VAT vtx_attr[8];
|
2014-08-27 17:38:00 +00:00
|
|
|
|
|
|
|
// Attributes that actually belong to VertexLoaderManager:
|
2014-10-22 00:42:55 +00:00
|
|
|
BitSet32 attr_dirty;
|
2014-12-13 00:51:14 +00:00
|
|
|
VertexLoaderBase* vertex_loaders[8];
|
2014-08-27 17:26:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class PointerWrap;
|
|
|
|
|
|
|
|
extern void DoCPState(PointerWrap& p);
|
|
|
|
|
2014-08-27 17:38:00 +00:00
|
|
|
extern void CopyPreprocessCPStateFromMain();
|
|
|
|
|
2014-08-27 17:26:06 +00:00
|
|
|
extern CPState g_main_cp_state;
|
2014-08-27 17:38:00 +00:00
|
|
|
extern CPState g_preprocess_cp_state;
|
2014-08-27 17:26:06 +00:00
|
|
|
|
|
|
|
extern u8 *cached_arraybases[16];
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2008-12-25 20:07:13 +00:00
|
|
|
// Might move this into its own file later.
|
2014-08-27 17:38:00 +00:00
|
|
|
void LoadCPReg(u32 SubCmd, u32 Value, bool is_preprocess = false);
|
2008-12-25 20:07:13 +00:00
|
|
|
|
2011-03-27 02:55:08 +00:00
|
|
|
// Fills memory with data from CP regs
|
|
|
|
void FillCPMemoryArray(u32 *memory);
|