dolphin/Source/Plugins/Plugin_VideoDX9/Src/CPStructs.h

228 lines
4.0 KiB
C

#ifndef _CPSTRUCTS_H
#define _CPSTRUCTS_H
#include "Common.h"
// Vertex array numbers
enum
{
ARRAY_POSITION = 0,
ARRAY_NORMAL = 1,
ARRAY_COLOR = 2,
ARRAY_COLOR2 = 3,
ARRAY_TEXCOORD0 = 4
};
// Vertex components
enum
{
NOT_PRESENT = 0,
DIRECT = 1,
INDEX8 = 2,
INDEX16 = 3,
};
#pragma pack(4)
union TVtxDesc
{
u64 Hex;
struct
{
// 0: not present
// 1: present
unsigned PosMatIdx : 1;
unsigned Tex0MatIdx : 1;
unsigned Tex1MatIdx : 1;
unsigned Tex2MatIdx : 1;
unsigned Tex3MatIdx : 1;
unsigned Tex4MatIdx : 1;
unsigned Tex5MatIdx : 1;
unsigned Tex6MatIdx : 1;
unsigned Tex7MatIdx : 1;
// 00: not present
// 01: direct
// 10: 8 bit index
// 11: 16 bit index
unsigned Position : 2;
unsigned Normal : 2;
unsigned Color0 : 2;
unsigned Color1 : 2;
unsigned Tex0Coord : 2;
unsigned Tex1Coord : 2;
unsigned Tex2Coord : 2;
unsigned Tex3Coord : 2;
unsigned Tex4Coord : 2;
unsigned Tex5Coord : 2;
unsigned Tex6Coord : 2;
unsigned Tex7Coord : 2;
unsigned :31;
};
};
enum
{
FORMAT_UBYTE = 0, // 2 Cmp
FORMAT_BYTE = 1, // 3 Cmp
FORMAT_USHORT = 2,
FORMAT_SHORT = 3,
FORMAT_FLOAT = 4,
};
enum
{
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,
};
union UVAT_group0
{
u32 Hex;
struct
{
// 0:8
unsigned PosElements : 1;
unsigned PosFormat : 3;
unsigned PosFrac : 5;
// 9:12
unsigned NormalElements : 1;
unsigned NormalFormat : 3;
// 13:16
unsigned Color0Elements : 1;
unsigned Color0Comp : 3;
// 17:20
unsigned Color1Elements : 1;
unsigned Color1Comp : 3;
// 21:29
unsigned Tex0CoordElements : 1;
unsigned Tex0CoordFormat : 3;
unsigned Tex0Frac : 5;
// 30:31
unsigned ByteDequant: 1;
unsigned NormalIndex3: 1;
};
};
union UVAT_group1
{
u32 Hex;
struct
{
// 0:8
unsigned Tex1CoordElements : 1;
unsigned Tex1CoordFormat : 3;
unsigned Tex1Frac : 5;
// 9:17
unsigned Tex2CoordElements : 1;
unsigned Tex2CoordFormat : 3;
unsigned Tex2Frac : 5;
// 18:26
unsigned Tex3CoordElements : 1;
unsigned Tex3CoordFormat : 3;
unsigned Tex3Frac : 5;
// 27:30
unsigned Tex4CoordElements : 1;
unsigned Tex4CoordFormat : 3;
//
unsigned : 1;
};
};
union UVAT_group2
{
u32 Hex;
struct
{
// 0:4
unsigned Tex4Frac : 5;
// 5:13
unsigned Tex5CoordElements : 1;
unsigned Tex5CoordFormat : 3;
unsigned Tex5Frac : 5;
// 14:22
unsigned Tex6CoordElements : 1;
unsigned Tex6CoordFormat : 3;
unsigned Tex6Frac : 5;
// 23:31
unsigned Tex7CoordElements : 1;
unsigned Tex7CoordFormat : 3;
unsigned Tex7Frac : 5;
};
};
struct ColorAttr
{
u8 Elements;
u8 Comp;
};
struct TexAttr
{
u8 Elements;
u8 Format;
u8 Frac;
};
struct TVtxAttr
{
u8 PosElements;
u8 PosFormat;
u8 PosFrac;
u8 NormalElements;
u8 NormalFormat;
ColorAttr color[2];
TexAttr texCoord[8];
u8 ByteDequant;
u8 NormalIndex3;
};
//////////////////////////////////////////////////////////////////////////
// Matrix indices
//////////////////////////////////////////////////////////////////////////
union TMatrixIndexA
{
u32 Hex;
struct
{
unsigned PosNormalMtxIdx : 6;
unsigned Tex0MtxIdx : 6;
unsigned Tex1MtxIdx : 6;
unsigned Tex2MtxIdx : 6;
unsigned Tex3MtxIdx : 6;
};
};
union TMatrixIndexB
{
u32 Hex;
struct
{
unsigned Tex4MtxIdx : 6;
unsigned Tex5MtxIdx : 6;
unsigned Tex6MtxIdx : 6;
unsigned Tex7MtxIdx : 6;
};
};
#pragma pack ()
extern TMatrixIndexA MatrixIndexA;
extern TMatrixIndexB MatrixIndexB;
extern u32 arraybases[16];
extern u32 arraystrides[16];
void CPUpdateMatricesA();
void CPUpdateMatricesB();
size_t CPSaveLoadState(char *ptr, BOOL save);
void LoadCPReg(u32 SubCmd, u32 Value);
#endif