2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
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
|
|
|
|
2021-02-11 00:01:42 +00:00
|
|
|
// X.h defines None to be 0, which causes problems with some of the enums
|
|
|
|
#undef None
|
|
|
|
|
2019-06-20 11:42:16 +00:00
|
|
|
#include <array>
|
|
|
|
|
2017-06-13 12:06:08 +00:00
|
|
|
#include "Common/BitField.h"
|
2014-09-08 01:06:58 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2021-02-11 00:01:42 +00:00
|
|
|
#include "Common/EnumFormatter.h"
|
2014-04-16 21:51:18 +00:00
|
|
|
#include "VideoCommon/CPMemory.h"
|
2016-01-31 19:51:55 +00:00
|
|
|
|
2017-01-04 11:34:27 +00:00
|
|
|
constexpr size_t NUM_XF_COLOR_CHANNELS = 2;
|
|
|
|
|
2008-07-18 19:33:55 +00:00
|
|
|
// Lighting
|
2009-09-02 21:00:45 +00:00
|
|
|
|
2015-09-01 14:56:51 +00:00
|
|
|
// Projection
|
2021-02-11 00:01:42 +00:00
|
|
|
enum class TexSize : u32
|
|
|
|
{
|
|
|
|
ST = 0,
|
|
|
|
STQ = 1
|
|
|
|
};
|
|
|
|
template <>
|
|
|
|
struct fmt::formatter<TexSize> : EnumFormatter<TexSize::STQ>
|
2015-09-01 14:56:51 +00:00
|
|
|
{
|
2022-01-13 01:28:17 +00:00
|
|
|
constexpr formatter() : EnumFormatter({"ST (2x4 matrix)", "STQ (3x4 matrix)"}) {}
|
2015-09-01 14:56:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Input form
|
2021-02-11 00:01:42 +00:00
|
|
|
enum class TexInputForm : u32
|
2015-09-01 14:56:51 +00:00
|
|
|
{
|
2021-02-11 00:01:42 +00:00
|
|
|
AB11 = 0,
|
|
|
|
ABC1 = 1
|
|
|
|
};
|
|
|
|
template <>
|
|
|
|
struct fmt::formatter<TexInputForm> : EnumFormatter<TexInputForm::ABC1>
|
|
|
|
{
|
2022-01-13 01:28:17 +00:00
|
|
|
constexpr formatter() : EnumFormatter({"AB11", "ABC1"}) {}
|
2021-02-11 00:01:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum class NormalCount : u32
|
|
|
|
{
|
|
|
|
None = 0,
|
2022-05-17 18:54:24 +00:00
|
|
|
Normal = 1,
|
2022-10-25 05:36:43 +00:00
|
|
|
NormalTangentBinormal = 2,
|
|
|
|
// Hardware testing indicates that this beahves the same as NormalTangentBinormal.
|
|
|
|
// Call of Duty: Black Ops uses this in some cases; see https://bugs.dolphin-emu.org/issues/13070
|
|
|
|
Invalid = 3,
|
2021-02-11 00:01:42 +00:00
|
|
|
};
|
|
|
|
template <>
|
2022-10-25 05:36:43 +00:00
|
|
|
struct fmt::formatter<NormalCount> : EnumFormatter<NormalCount::Invalid>
|
2021-02-11 00:01:42 +00:00
|
|
|
{
|
2022-10-25 05:36:43 +00:00
|
|
|
static constexpr array_type names = {
|
|
|
|
"None",
|
|
|
|
"Normal only",
|
|
|
|
"Normal, tangent, and binormal",
|
|
|
|
"Invalid (Normal, tangent, and binormal)",
|
|
|
|
};
|
|
|
|
constexpr formatter() : EnumFormatter(names) {}
|
2015-09-01 14:56:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Texture generation type
|
2021-02-11 00:01:42 +00:00
|
|
|
enum class TexGenType : u32
|
2015-09-01 14:56:51 +00:00
|
|
|
{
|
2021-02-11 00:01:42 +00:00
|
|
|
Regular = 0,
|
|
|
|
EmbossMap = 1, // Used when bump mapping
|
|
|
|
Color0 = 2,
|
|
|
|
Color1 = 3
|
|
|
|
};
|
|
|
|
template <>
|
|
|
|
struct fmt::formatter<TexGenType> : EnumFormatter<TexGenType::Color1>
|
|
|
|
{
|
|
|
|
static constexpr array_type names = {
|
|
|
|
"Regular",
|
|
|
|
"Emboss map (used when bump mapping)",
|
|
|
|
"Color channel 0",
|
|
|
|
"Color channel 1",
|
|
|
|
};
|
2022-01-13 01:28:17 +00:00
|
|
|
constexpr formatter() : EnumFormatter(names) {}
|
2015-09-01 14:56:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Source row
|
2021-02-11 00:01:42 +00:00
|
|
|
enum class SourceRow : u32
|
|
|
|
{
|
|
|
|
Geom = 0, // Input is abc
|
|
|
|
Normal = 1, // Input is abc
|
|
|
|
Colors = 2,
|
|
|
|
BinormalT = 3, // Input is abc
|
|
|
|
BinormalB = 4, // Input is abc
|
|
|
|
Tex0 = 5,
|
|
|
|
Tex1 = 6,
|
|
|
|
Tex2 = 7,
|
|
|
|
Tex3 = 8,
|
|
|
|
Tex4 = 9,
|
|
|
|
Tex5 = 10,
|
|
|
|
Tex6 = 11,
|
|
|
|
Tex7 = 12
|
|
|
|
};
|
|
|
|
template <>
|
|
|
|
struct fmt::formatter<SourceRow> : EnumFormatter<SourceRow::Tex7>
|
|
|
|
{
|
|
|
|
static constexpr array_type names = {
|
|
|
|
"Geometry (input is ABC1)",
|
|
|
|
"Normal (input is ABC1)",
|
|
|
|
"Colors",
|
|
|
|
"Binormal T (input is ABC1)",
|
|
|
|
"Binormal B (input is ABC1)",
|
|
|
|
"Tex 0",
|
|
|
|
"Tex 1",
|
|
|
|
"Tex 2",
|
|
|
|
"Tex 3",
|
|
|
|
"Tex 4",
|
|
|
|
"Tex 5",
|
|
|
|
"Tex 6",
|
|
|
|
"Tex 7",
|
|
|
|
};
|
2022-01-13 01:28:17 +00:00
|
|
|
constexpr formatter() : EnumFormatter(names) {}
|
2021-02-11 00:01:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum class MatSource : u32
|
|
|
|
{
|
|
|
|
MatColorRegister = 0,
|
|
|
|
Vertex = 1,
|
|
|
|
};
|
|
|
|
template <>
|
|
|
|
struct fmt::formatter<MatSource> : EnumFormatter<MatSource::Vertex>
|
2015-09-01 14:56:51 +00:00
|
|
|
{
|
2022-01-13 01:28:17 +00:00
|
|
|
constexpr formatter() : EnumFormatter({"Material color register", "Vertex color"}) {}
|
2015-09-01 14:56:51 +00:00
|
|
|
};
|
|
|
|
|
2021-02-11 00:01:42 +00:00
|
|
|
enum class AmbSource : u32
|
2015-09-01 14:56:51 +00:00
|
|
|
{
|
2021-02-11 00:01:42 +00:00
|
|
|
AmbColorRegister = 0,
|
|
|
|
Vertex = 1,
|
|
|
|
};
|
|
|
|
template <>
|
|
|
|
struct fmt::formatter<AmbSource> : EnumFormatter<AmbSource::Vertex>
|
|
|
|
{
|
2022-01-13 01:28:17 +00:00
|
|
|
constexpr formatter() : EnumFormatter({"Ambient color register", "Vertex color"}) {}
|
2015-09-01 14:56:51 +00:00
|
|
|
};
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2015-09-01 14:56:51 +00:00
|
|
|
// Light diffuse attenuation function
|
2021-02-11 00:01:42 +00:00
|
|
|
enum class DiffuseFunc : u32
|
|
|
|
{
|
|
|
|
None = 0,
|
|
|
|
Sign = 1,
|
|
|
|
Clamp = 2
|
|
|
|
};
|
|
|
|
template <>
|
|
|
|
struct fmt::formatter<DiffuseFunc> : EnumFormatter<DiffuseFunc::Clamp>
|
2015-09-01 14:56:51 +00:00
|
|
|
{
|
2022-01-13 01:28:17 +00:00
|
|
|
constexpr formatter() : EnumFormatter({"None", "Sign", "Clamp"}) {}
|
2015-09-01 14:56:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Light attenuation function
|
2021-02-11 00:01:42 +00:00
|
|
|
enum class AttenuationFunc : u32
|
2015-09-01 14:56:51 +00:00
|
|
|
{
|
2021-02-11 00:01:42 +00:00
|
|
|
None = 0, // No attenuation
|
|
|
|
Spec = 1, // Point light attenuation
|
|
|
|
Dir = 2, // Directional light attenuation
|
|
|
|
Spot = 3 // Spot light attenuation
|
|
|
|
};
|
|
|
|
template <>
|
|
|
|
struct fmt::formatter<AttenuationFunc> : EnumFormatter<AttenuationFunc::Spot>
|
|
|
|
{
|
|
|
|
static constexpr array_type names = {
|
|
|
|
"No attenuation",
|
|
|
|
"Point light attenuation",
|
|
|
|
"Directional light attenuation",
|
|
|
|
"Spot light attenuation",
|
|
|
|
};
|
2022-01-13 01:28:17 +00:00
|
|
|
constexpr formatter() : EnumFormatter(names) {}
|
2015-09-01 14:56:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Projection type
|
2021-02-11 00:01:42 +00:00
|
|
|
enum class ProjectionType : u32
|
|
|
|
{
|
|
|
|
Perspective = 0,
|
|
|
|
Orthographic = 1
|
|
|
|
};
|
|
|
|
template <>
|
|
|
|
struct fmt::formatter<ProjectionType> : EnumFormatter<ProjectionType::Orthographic>
|
2015-09-01 14:56:51 +00:00
|
|
|
{
|
2022-01-13 01:28:17 +00:00
|
|
|
constexpr formatter() : EnumFormatter({"Perspective", "Orthographic"}) {}
|
2015-09-01 14:56:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Registers and register ranges
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
XFMEM_POSMATRICES = 0x000,
|
|
|
|
XFMEM_POSMATRICES_END = 0x100,
|
|
|
|
XFMEM_NORMALMATRICES = 0x400,
|
|
|
|
XFMEM_NORMALMATRICES_END = 0x460,
|
|
|
|
XFMEM_POSTMATRICES = 0x500,
|
|
|
|
XFMEM_POSTMATRICES_END = 0x600,
|
|
|
|
XFMEM_LIGHTS = 0x600,
|
|
|
|
XFMEM_LIGHTS_END = 0x680,
|
2021-02-07 05:14:21 +00:00
|
|
|
XFMEM_REGISTERS_START = 0x1000,
|
2015-09-01 14:56:51 +00:00
|
|
|
XFMEM_ERROR = 0x1000,
|
|
|
|
XFMEM_DIAG = 0x1001,
|
|
|
|
XFMEM_STATE0 = 0x1002,
|
|
|
|
XFMEM_STATE1 = 0x1003,
|
|
|
|
XFMEM_CLOCK = 0x1004,
|
|
|
|
XFMEM_CLIPDISABLE = 0x1005,
|
2021-03-27 05:35:32 +00:00
|
|
|
XFMEM_SETGPMETRIC = 0x1006, // Perf0 according to YAGCD
|
|
|
|
XFMEM_UNKNOWN_1007 = 0x1007, // Perf1 according to YAGCD
|
2015-09-01 14:56:51 +00:00
|
|
|
XFMEM_VTXSPECS = 0x1008,
|
|
|
|
XFMEM_SETNUMCHAN = 0x1009,
|
|
|
|
XFMEM_SETCHAN0_AMBCOLOR = 0x100a,
|
|
|
|
XFMEM_SETCHAN1_AMBCOLOR = 0x100b,
|
|
|
|
XFMEM_SETCHAN0_MATCOLOR = 0x100c,
|
|
|
|
XFMEM_SETCHAN1_MATCOLOR = 0x100d,
|
|
|
|
XFMEM_SETCHAN0_COLOR = 0x100e,
|
|
|
|
XFMEM_SETCHAN1_COLOR = 0x100f,
|
|
|
|
XFMEM_SETCHAN0_ALPHA = 0x1010,
|
|
|
|
XFMEM_SETCHAN1_ALPHA = 0x1011,
|
|
|
|
XFMEM_DUALTEX = 0x1012,
|
2021-03-27 05:35:32 +00:00
|
|
|
XFMEM_UNKNOWN_GROUP_1_START = 0x1013,
|
|
|
|
XFMEM_UNKNOWN_GROUP_1_END = 0x1017,
|
2015-09-01 14:56:51 +00:00
|
|
|
XFMEM_SETMATRIXINDA = 0x1018,
|
|
|
|
XFMEM_SETMATRIXINDB = 0x1019,
|
|
|
|
XFMEM_SETVIEWPORT = 0x101a,
|
|
|
|
XFMEM_SETZSCALE = 0x101c,
|
|
|
|
XFMEM_SETZOFFSET = 0x101f,
|
|
|
|
XFMEM_SETPROJECTION = 0x1020,
|
2021-03-27 05:35:32 +00:00
|
|
|
// XFMEM_SETPROJECTIONB = 0x1021,
|
|
|
|
// XFMEM_SETPROJECTIONC = 0x1022,
|
|
|
|
// XFMEM_SETPROJECTIOND = 0x1023,
|
|
|
|
// XFMEM_SETPROJECTIONE = 0x1024,
|
|
|
|
// XFMEM_SETPROJECTIONF = 0x1025,
|
|
|
|
// XFMEM_SETPROJECTIONORTHO = 0x1026,
|
|
|
|
XFMEM_UNKNOWN_GROUP_2_START = 0x1027,
|
|
|
|
XFMEM_UNKNOWN_GROUP_2_END = 0x103e,
|
2015-09-01 14:56:51 +00:00
|
|
|
XFMEM_SETNUMTEXGENS = 0x103f,
|
|
|
|
XFMEM_SETTEXMTXINFO = 0x1040,
|
2021-03-27 05:35:32 +00:00
|
|
|
XFMEM_UNKNOWN_GROUP_3_START = 0x1048,
|
|
|
|
XFMEM_UNKNOWN_GROUP_3_END = 0x104f,
|
2020-04-29 03:26:02 +00:00
|
|
|
XFMEM_SETPOSTMTXINFO = 0x1050,
|
2021-02-07 05:14:21 +00:00
|
|
|
XFMEM_REGISTERS_END = 0x1058,
|
2015-09-01 14:56:51 +00:00
|
|
|
};
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2017-01-04 11:45:40 +00:00
|
|
|
union LitChannel
|
|
|
|
{
|
2021-02-11 00:01:42 +00:00
|
|
|
BitField<0, 1, MatSource> matsource;
|
|
|
|
BitField<1, 1, bool, u32> enablelighting;
|
2017-06-13 12:06:08 +00:00
|
|
|
BitField<2, 4, u32> lightMask0_3;
|
2021-02-11 00:01:42 +00:00
|
|
|
BitField<6, 1, AmbSource> ambsource;
|
|
|
|
BitField<7, 2, DiffuseFunc> diffusefunc;
|
|
|
|
BitField<9, 2, AttenuationFunc> attnfunc;
|
2017-06-13 12:06:08 +00:00
|
|
|
BitField<11, 4, u32> lightMask4_7;
|
|
|
|
u32 hex;
|
|
|
|
|
2008-07-18 19:33:55 +00:00
|
|
|
unsigned int GetFullLightMask() const
|
|
|
|
{
|
|
|
|
return enablelighting ? (lightMask0_3 | (lightMask4_7 << 4)) : 0;
|
|
|
|
}
|
|
|
|
};
|
2021-02-07 05:14:21 +00:00
|
|
|
template <>
|
|
|
|
struct fmt::formatter<LitChannel>
|
|
|
|
{
|
|
|
|
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
|
|
|
|
template <typename FormatContext>
|
2022-01-13 01:16:29 +00:00
|
|
|
auto format(const LitChannel& chan, FormatContext& ctx) const
|
2021-02-07 05:14:21 +00:00
|
|
|
{
|
2022-01-13 06:52:21 +00:00
|
|
|
return fmt::format_to(
|
|
|
|
ctx.out(),
|
|
|
|
"Material source: {0}\nEnable lighting: {1}\nLight mask: {2:x} ({2:08b})\n"
|
|
|
|
"Ambient source: {3}\nDiffuse function: {4}\nAttenuation function: {5}",
|
|
|
|
chan.matsource, chan.enablelighting ? "Yes" : "No", chan.GetFullLightMask(), chan.ambsource,
|
|
|
|
chan.diffusefunc, chan.attnfunc);
|
2021-02-07 05:14:21 +00:00
|
|
|
}
|
|
|
|
};
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2021-02-11 00:01:42 +00:00
|
|
|
union ClipDisable
|
|
|
|
{
|
|
|
|
BitField<0, 1, bool, u32> disable_clipping_detection;
|
|
|
|
BitField<1, 1, bool, u32> disable_trivial_rejection;
|
|
|
|
BitField<2, 1, bool, u32> disable_cpoly_clipping_acceleration;
|
|
|
|
u32 hex;
|
|
|
|
};
|
2021-02-07 05:14:21 +00:00
|
|
|
template <>
|
|
|
|
struct fmt::formatter<ClipDisable>
|
|
|
|
{
|
|
|
|
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
|
|
|
|
template <typename FormatContext>
|
2022-01-13 01:16:29 +00:00
|
|
|
auto format(const ClipDisable& cd, FormatContext& ctx) const
|
2021-02-07 05:14:21 +00:00
|
|
|
{
|
2022-01-13 06:52:21 +00:00
|
|
|
return fmt::format_to(ctx.out(),
|
|
|
|
"Disable clipping detection: {}\n"
|
|
|
|
"Disable trivial rejection: {}\n"
|
|
|
|
"Disable cpoly clipping acceleration: {}",
|
|
|
|
cd.disable_clipping_detection ? "Yes" : "No",
|
|
|
|
cd.disable_trivial_rejection ? "Yes" : "No",
|
|
|
|
cd.disable_cpoly_clipping_acceleration ? "Yes" : "No");
|
2021-02-07 05:14:21 +00:00
|
|
|
}
|
|
|
|
};
|
2021-02-11 00:01:42 +00:00
|
|
|
|
2017-01-04 11:45:40 +00:00
|
|
|
union INVTXSPEC
|
|
|
|
{
|
2021-02-11 00:01:42 +00:00
|
|
|
BitField<0, 2, u32> numcolors;
|
|
|
|
BitField<2, 2, NormalCount> numnormals;
|
|
|
|
BitField<4, 4, u32> numtextures;
|
2008-07-18 19:33:55 +00:00
|
|
|
u32 hex;
|
|
|
|
};
|
2021-02-07 05:14:21 +00:00
|
|
|
template <>
|
|
|
|
struct fmt::formatter<INVTXSPEC>
|
|
|
|
{
|
|
|
|
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
|
|
|
|
template <typename FormatContext>
|
2022-01-13 01:16:29 +00:00
|
|
|
auto format(const INVTXSPEC& spec, FormatContext& ctx) const
|
2021-02-07 05:14:21 +00:00
|
|
|
{
|
2022-01-13 06:52:21 +00:00
|
|
|
return fmt::format_to(ctx.out(), "Num colors: {}\nNum normals: {}\nNum textures: {}",
|
|
|
|
spec.numcolors, spec.numnormals, spec.numtextures);
|
2021-02-07 05:14:21 +00:00
|
|
|
}
|
|
|
|
};
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2017-01-04 11:45:40 +00:00
|
|
|
union TexMtxInfo
|
|
|
|
{
|
2021-02-11 00:01:42 +00:00
|
|
|
BitField<0, 1, u32> unknown;
|
|
|
|
BitField<1, 1, TexSize> projection;
|
|
|
|
BitField<2, 1, TexInputForm> inputform;
|
|
|
|
BitField<3, 1, u32> unknown2;
|
|
|
|
BitField<4, 3, TexGenType> texgentype;
|
|
|
|
BitField<7, 5, SourceRow> sourcerow;
|
2017-06-13 12:06:08 +00:00
|
|
|
BitField<12, 3, u32> embosssourceshift; // what generated texcoord to use
|
|
|
|
BitField<15, 3, u32> embosslightshift; // light index that is used
|
2008-07-18 19:33:55 +00:00
|
|
|
u32 hex;
|
|
|
|
};
|
2021-02-07 05:14:21 +00:00
|
|
|
template <>
|
|
|
|
struct fmt::formatter<TexMtxInfo>
|
|
|
|
{
|
|
|
|
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
|
|
|
|
template <typename FormatContext>
|
2022-01-13 01:16:29 +00:00
|
|
|
auto format(const TexMtxInfo& i, FormatContext& ctx) const
|
2021-02-07 05:14:21 +00:00
|
|
|
{
|
2022-01-13 06:52:21 +00:00
|
|
|
return fmt::format_to(ctx.out(),
|
|
|
|
"Projection: {}\nInput form: {}\nTex gen type: {}\n"
|
|
|
|
"Source row: {}\nEmboss source shift: {}\nEmboss light shift: {}",
|
|
|
|
i.projection, i.inputform, i.texgentype, i.sourcerow, i.embosssourceshift,
|
|
|
|
i.embosslightshift);
|
2021-02-07 05:14:21 +00:00
|
|
|
}
|
|
|
|
};
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2017-01-04 11:45:40 +00:00
|
|
|
union PostMtxInfo
|
|
|
|
{
|
2021-02-11 00:01:42 +00:00
|
|
|
BitField<0, 6, u32> index; // base row of dual transform matrix
|
|
|
|
BitField<6, 2, u32> unused; //
|
|
|
|
BitField<8, 1, bool, u32> normalize; // normalize before send operation
|
2008-07-18 19:33:55 +00:00
|
|
|
u32 hex;
|
|
|
|
};
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2021-02-07 05:14:21 +00:00
|
|
|
template <>
|
|
|
|
struct fmt::formatter<PostMtxInfo>
|
|
|
|
{
|
|
|
|
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
|
|
|
|
template <typename FormatContext>
|
2022-01-13 01:16:29 +00:00
|
|
|
auto format(const PostMtxInfo& i, FormatContext& ctx) const
|
2021-02-07 05:14:21 +00:00
|
|
|
{
|
2022-01-13 06:52:21 +00:00
|
|
|
return fmt::format_to(ctx.out(), "Index: {}\nNormalize before send operation: {}", i.index,
|
|
|
|
i.normalize ? "Yes" : "No");
|
2021-02-07 05:14:21 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-01-04 11:45:40 +00:00
|
|
|
union NumColorChannel
|
|
|
|
{
|
2021-02-11 00:01:42 +00:00
|
|
|
BitField<0, 2, u32> numColorChans;
|
2011-02-05 18:25:34 +00:00
|
|
|
u32 hex;
|
|
|
|
};
|
|
|
|
|
2017-01-04 11:45:40 +00:00
|
|
|
union NumTexGen
|
|
|
|
{
|
2021-02-11 00:01:42 +00:00
|
|
|
BitField<0, 4, u32> numTexGens;
|
2011-02-05 18:25:34 +00:00
|
|
|
u32 hex;
|
|
|
|
};
|
|
|
|
|
2017-01-04 11:45:40 +00:00
|
|
|
union DualTexInfo
|
|
|
|
{
|
2021-02-11 00:01:42 +00:00
|
|
|
BitField<0, 1, bool, u32> enabled;
|
2011-02-05 18:25:34 +00:00
|
|
|
u32 hex;
|
|
|
|
};
|
2009-07-26 09:52:35 +00:00
|
|
|
|
|
|
|
struct Light
|
|
|
|
{
|
|
|
|
u32 useless[3];
|
2014-05-30 12:54:16 +00:00
|
|
|
u8 color[4];
|
|
|
|
float cosatt[3]; // cos attenuation
|
|
|
|
float distatt[3]; // dist attenuation
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2017-01-04 11:45:40 +00:00
|
|
|
union
|
|
|
|
{
|
2009-07-26 09:52:35 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
float dpos[3];
|
|
|
|
float ddir[3]; // specular lights only
|
|
|
|
};
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2009-07-26 09:52:35 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
float sdir[3];
|
|
|
|
float shalfangle[3]; // specular lights only
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Viewport
|
|
|
|
{
|
|
|
|
float wd;
|
|
|
|
float ht;
|
2011-04-11 01:49:32 +00:00
|
|
|
float zRange;
|
2009-07-26 09:52:35 +00:00
|
|
|
float xOrig;
|
|
|
|
float yOrig;
|
|
|
|
float farZ;
|
|
|
|
};
|
|
|
|
|
2013-01-24 12:10:13 +00:00
|
|
|
struct Projection
|
|
|
|
{
|
2019-06-20 11:42:16 +00:00
|
|
|
using Raw = std::array<float, 6>;
|
|
|
|
|
|
|
|
Raw rawProjection;
|
2021-02-11 00:01:42 +00:00
|
|
|
ProjectionType type;
|
2013-01-24 12:10:13 +00:00
|
|
|
};
|
|
|
|
|
2022-11-11 01:30:49 +00:00
|
|
|
struct alignas(16) XFMemory
|
2014-04-16 21:51:18 +00:00
|
|
|
{
|
2022-05-17 18:27:49 +00:00
|
|
|
float posMatrices[256]; // 0x0000 - 0x00ff
|
|
|
|
u32 unk0[768]; // 0x0100 - 0x03ff
|
|
|
|
float normalMatrices[96]; // 0x0400 - 0x045f
|
|
|
|
u32 unk1[160]; // 0x0460 - 0x04ff
|
|
|
|
float postMatrices[256]; // 0x0500 - 0x05ff
|
|
|
|
Light lights[8]; // 0x0600 - 0x067f
|
|
|
|
u32 unk2[2432]; // 0x0680 - 0x0fff
|
|
|
|
u32 error; // 0x1000
|
|
|
|
u32 diag; // 0x1001
|
|
|
|
u32 state0; // 0x1002
|
|
|
|
u32 state1; // 0x1003
|
|
|
|
u32 xfClock; // 0x1004
|
|
|
|
ClipDisable clipDisable; // 0x1005
|
|
|
|
u32 perf0; // 0x1006
|
|
|
|
u32 perf1; // 0x1007
|
|
|
|
INVTXSPEC invtxspec; // 0x1008
|
|
|
|
NumColorChannel numChan; // 0x1009
|
2017-01-04 11:34:27 +00:00
|
|
|
u32 ambColor[NUM_XF_COLOR_CHANNELS]; // 0x100a, 0x100b
|
|
|
|
u32 matColor[NUM_XF_COLOR_CHANNELS]; // 0x100c, 0x100d
|
|
|
|
LitChannel color[NUM_XF_COLOR_CHANNELS]; // 0x100e, 0x100f
|
|
|
|
LitChannel alpha[NUM_XF_COLOR_CHANNELS]; // 0x1010, 0x1011
|
|
|
|
DualTexInfo dualTexTrans; // 0x1012
|
|
|
|
u32 unk3; // 0x1013
|
|
|
|
u32 unk4; // 0x1014
|
|
|
|
u32 unk5; // 0x1015
|
|
|
|
u32 unk6; // 0x1016
|
|
|
|
u32 unk7; // 0x1017
|
|
|
|
TMatrixIndexA MatrixIndexA; // 0x1018
|
|
|
|
TMatrixIndexB MatrixIndexB; // 0x1019
|
|
|
|
Viewport viewport; // 0x101a - 0x101f
|
|
|
|
Projection projection; // 0x1020 - 0x1026
|
|
|
|
u32 unk8[24]; // 0x1027 - 0x103e
|
|
|
|
NumTexGen numTexGen; // 0x103f
|
|
|
|
TexMtxInfo texMtxInfo[8]; // 0x1040 - 0x1047
|
|
|
|
u32 unk9[8]; // 0x1048 - 0x104f
|
|
|
|
PostMtxInfo postMtxInfo[8]; // 0x1050 - 0x1057
|
2008-07-18 19:33:55 +00:00
|
|
|
};
|
2021-04-23 03:57:56 +00:00
|
|
|
static_assert(sizeof(XFMemory) == sizeof(u32) * XFMEM_REGISTERS_END);
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2014-04-27 18:59:04 +00:00
|
|
|
extern XFMemory xfmem;
|
2008-12-08 04:46:09 +00:00
|
|
|
|
2021-05-07 00:22:31 +00:00
|
|
|
void LoadXFReg(u16 base_address, u8 transfer_size, const u8* data);
|
2021-04-23 03:57:56 +00:00
|
|
|
void LoadIndexedXF(CPArray array, u32 index, u16 address, u8 size);
|
|
|
|
void PreprocessIndexedXF(CPArray array, u32 index, u16 address, u8 size);
|