From ad7dd606fbeb55e1e6253ada2cc7c993f38d7765 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Sun, 24 Apr 2022 18:19:57 -0700 Subject: [PATCH 1/2] Update XFMemory.h to Dolphin's version Note that I've removed the XFMemory struct itself, as well as the load/preprocess functions. --- gxtest/XFMemory.h | 411 ++++++++++++++++++++++++++++++++++++++- gxtest/clipping.cpp | 2 +- gxtest/lighting.cpp | 4 +- gxtest/rasterization.cpp | 2 +- gxtest/tev.cpp | 6 +- 5 files changed, 408 insertions(+), 17 deletions(-) diff --git a/gxtest/XFMemory.h b/gxtest/XFMemory.h index d66b977..07c9025 100644 --- a/gxtest/XFMemory.h +++ b/gxtest/XFMemory.h @@ -1,23 +1,414 @@ -// Copyright 2013 Dolphin Emulator Project -// Licensed under GPLv2 -// Refer to the license.txt file included. +// Copyright 2008 Dolphin Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later #pragma once +// X.h defines None to be 0, which causes problems with some of the enums +#undef None + +#include + +#include "Common/BitField.h" +#include "Common/CommonTypes.h" +#include "Common/EnumFormatter.h" + +constexpr size_t NUM_XF_COLOR_CHANNELS = 2; + +// Lighting + +// Projection +enum class TexSize : u32 +{ + ST = 0, + STQ = 1 +}; +template <> +struct fmt::formatter : EnumFormatter +{ + constexpr formatter() : EnumFormatter({"ST (2x4 matrix)", "STQ (3x4 matrix)"}) {} +}; + +// Input form +enum class TexInputForm : u32 +{ + AB11 = 0, + ABC1 = 1 +}; +template <> +struct fmt::formatter : EnumFormatter +{ + constexpr formatter() : EnumFormatter({"AB11", "ABC1"}) {} +}; + +enum class NormalCount : u32 +{ + None = 0, + Normals = 1, + NormalsBinormals = 2 +}; +template <> +struct fmt::formatter : EnumFormatter +{ + constexpr formatter() : EnumFormatter({"None", "Normals only", "Normals and binormals"}) {} +}; + +// Texture generation type +enum class TexGenType : u32 +{ + Regular = 0, + EmbossMap = 1, // Used when bump mapping + Color0 = 2, + Color1 = 3 +}; +template <> +struct fmt::formatter : EnumFormatter +{ + static constexpr array_type names = { + "Regular", + "Emboss map (used when bump mapping)", + "Color channel 0", + "Color channel 1", + }; + constexpr formatter() : EnumFormatter(names) {} +}; + +// Source row +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 : EnumFormatter +{ + 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", + }; + constexpr formatter() : EnumFormatter(names) {} +}; + +enum class MatSource : u32 +{ + MatColorRegister = 0, + Vertex = 1, +}; +template <> +struct fmt::formatter : EnumFormatter +{ + constexpr formatter() : EnumFormatter({"Material color register", "Vertex color"}) {} +}; + +enum class AmbSource : u32 +{ + AmbColorRegister = 0, + Vertex = 1, +}; +template <> +struct fmt::formatter : EnumFormatter +{ + constexpr formatter() : EnumFormatter({"Ambient color register", "Vertex color"}) {} +}; + +// Light diffuse attenuation function +enum class DiffuseFunc : u32 +{ + None = 0, + Sign = 1, + Clamp = 2 +}; +template <> +struct fmt::formatter : EnumFormatter +{ + constexpr formatter() : EnumFormatter({"None", "Sign", "Clamp"}) {} +}; + +// Light attenuation function +enum class AttenuationFunc : u32 +{ + None = 0, // No attenuation + Spec = 1, // Point light attenuation + Dir = 2, // Directional light attenuation + Spot = 3 // Spot light attenuation +}; +template <> +struct fmt::formatter : EnumFormatter +{ + static constexpr array_type names = { + "No attenuation", + "Point light attenuation", + "Directional light attenuation", + "Spot light attenuation", + }; + constexpr formatter() : EnumFormatter(names) {} +}; + +// Projection type +enum class ProjectionType : u32 +{ + Perspective = 0, + Orthographic = 1 +}; +template <> +struct fmt::formatter : EnumFormatter +{ + constexpr formatter() : EnumFormatter({"Perspective", "Orthographic"}) {} +}; + +// 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, + XFMEM_REGISTERS_START = 0x1000, + XFMEM_ERROR = 0x1000, + XFMEM_DIAG = 0x1001, + XFMEM_STATE0 = 0x1002, + XFMEM_STATE1 = 0x1003, + XFMEM_CLOCK = 0x1004, + XFMEM_CLIPDISABLE = 0x1005, + XFMEM_SETGPMETRIC = 0x1006, // Perf0 according to YAGCD + XFMEM_UNKNOWN_1007 = 0x1007, // Perf1 according to YAGCD + 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, + XFMEM_UNKNOWN_GROUP_1_START = 0x1013, + XFMEM_UNKNOWN_GROUP_1_END = 0x1017, + XFMEM_SETMATRIXINDA = 0x1018, + XFMEM_SETMATRIXINDB = 0x1019, + XFMEM_SETVIEWPORT = 0x101a, + XFMEM_SETZSCALE = 0x101c, + XFMEM_SETZOFFSET = 0x101f, + XFMEM_SETPROJECTION = 0x1020, + // 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, + XFMEM_SETNUMTEXGENS = 0x103f, + XFMEM_SETTEXMTXINFO = 0x1040, + XFMEM_UNKNOWN_GROUP_3_START = 0x1048, + XFMEM_UNKNOWN_GROUP_3_END = 0x104f, + XFMEM_SETPOSTMTXINFO = 0x1050, + XFMEM_REGISTERS_END = 0x1058, +}; + union LitChannel { - BitField<0, 1, u32> matsource; - BitField<1, 1, u32> enablelighting; + BitField<0, 1, MatSource> matsource; + BitField<1, 1, bool, u32> enablelighting; BitField<2, 4, u32> lightMask0_3; - BitField<6, 1, u32> ambsource; - BitField<7, 2, u32> diffusefunc; // LIGHTDIF_X - BitField<9, 2, u32> attnfunc; // LIGHTATTN_X + BitField<6, 1, AmbSource> ambsource; + BitField<7, 2, DiffuseFunc> diffusefunc; + BitField<9, 2, AttenuationFunc> attnfunc; BitField<11, 4, u32> lightMask4_7; - // 17 bits unused - u32 hex; + unsigned int GetFullLightMask() const { return enablelighting ? (lightMask0_3 | (lightMask4_7 << 4)) : 0; } }; +template <> +struct fmt::formatter +{ + constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } + template + auto format(const LitChannel& chan, FormatContext& ctx) const + { + 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); + } +}; + +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; +}; +template <> +struct fmt::formatter +{ + constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } + template + auto format(const ClipDisable& cd, FormatContext& ctx) const + { + 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"); + } +}; + +union INVTXSPEC +{ + BitField<0, 2, u32> numcolors; + BitField<2, 2, NormalCount> numnormals; + BitField<4, 4, u32> numtextures; + u32 hex; +}; +template <> +struct fmt::formatter +{ + constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } + template + auto format(const INVTXSPEC& spec, FormatContext& ctx) const + { + return fmt::format_to(ctx.out(), "Num colors: {}\nNum normals: {}\nNum textures: {}", + spec.numcolors, spec.numnormals, spec.numtextures); + } +}; + +union TexMtxInfo +{ + 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; + BitField<12, 3, u32> embosssourceshift; // what generated texcoord to use + BitField<15, 3, u32> embosslightshift; // light index that is used + u32 hex; +}; +template <> +struct fmt::formatter +{ + constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } + template + auto format(const TexMtxInfo& i, FormatContext& ctx) const + { + 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); + } +}; + +union PostMtxInfo +{ + 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 + u32 hex; +}; + +template <> +struct fmt::formatter +{ + constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } + template + auto format(const PostMtxInfo& i, FormatContext& ctx) const + { + return fmt::format_to(ctx.out(), "Index: {}\nNormalize before send operation: {}", i.index, + i.normalize ? "Yes" : "No"); + } +}; + +union NumColorChannel +{ + BitField<0, 2, u32> numColorChans; + u32 hex; +}; + +union NumTexGen +{ + BitField<0, 4, u32> numTexGens; + u32 hex; +}; + +union DualTexInfo +{ + BitField<0, 1, bool, u32> enabled; + u32 hex; +}; + +struct Light +{ + u32 useless[3]; + u8 color[4]; + float cosatt[3]; // cos attenuation + float distatt[3]; // dist attenuation + + union + { + struct + { + float dpos[3]; + float ddir[3]; // specular lights only + }; + + struct + { + float sdir[3]; + float shalfangle[3]; // specular lights only + }; + }; +}; + +struct Viewport +{ + float wd; + float ht; + float zRange; + float xOrig; + float yOrig; + float farZ; +}; + +struct Projection +{ + using Raw = std::array; + + Raw rawProjection; + ProjectionType type; +}; diff --git a/gxtest/clipping.cpp b/gxtest/clipping.cpp index e69837d..0b03af3 100644 --- a/gxtest/clipping.cpp +++ b/gxtest/clipping.cpp @@ -24,7 +24,7 @@ void ClipTest() LitChannel chan; chan.hex = 0; - chan.matsource = 1; // from vertex + chan.matsource = MatSource::Vertex; CGX_BEGIN_LOAD_XF_REGS(0x100e, 1); // color channel 1 wgPipe->U32 = chan.hex; CGX_BEGIN_LOAD_XF_REGS(0x1010, 1); // alpha channel 1 diff --git a/gxtest/lighting.cpp b/gxtest/lighting.cpp index acc6f84..37fb835 100644 --- a/gxtest/lighting.cpp +++ b/gxtest/lighting.cpp @@ -24,8 +24,8 @@ void LightingTest() LitChannel chan; chan.hex = 0; - chan.matsource = 0; // from register - chan.ambsource = 0; // from register + chan.matsource = MatSource::MatColorRegister; + chan.ambsource = AmbSource::AmbColorRegister; chan.enablelighting = true; CGX_BEGIN_LOAD_XF_REGS(0x100e, 1); // color channel 1 wgPipe->U32 = chan.hex; diff --git a/gxtest/rasterization.cpp b/gxtest/rasterization.cpp index 31cfdcb..e435784 100644 --- a/gxtest/rasterization.cpp +++ b/gxtest/rasterization.cpp @@ -24,7 +24,7 @@ void CoordinatePrecisionTest() LitChannel chan; chan.hex = 0; - chan.matsource = 1; // from vertex + chan.matsource = MatSource::Vertex; CGX_BEGIN_LOAD_XF_REGS(0x100e, 1); // color channel 1 wgPipe->U32 = chan.hex; CGX_BEGIN_LOAD_XF_REGS(0x1010, 1); // alpha channel 1 diff --git a/gxtest/tev.cpp b/gxtest/tev.cpp index b4ecdca..981aafd 100644 --- a/gxtest/tev.cpp +++ b/gxtest/tev.cpp @@ -46,7 +46,7 @@ void TevCombinerTest() LitChannel chan; chan.hex = 0; - chan.matsource = 1; // from vertex + chan.matsource = MatSource::Vertex; CGX_BEGIN_LOAD_XF_REGS(0x100e, 1); // color channel 1 wgPipe->U32 = chan.hex; CGX_BEGIN_LOAD_XF_REGS(0x1010, 1); // alpha channel 1 @@ -245,8 +245,8 @@ void KonstTest() LitChannel chan; chan.hex = 0; - chan.matsource = 0; // from register - chan.ambsource = 0; // from register + chan.matsource = MatSource::MatColorRegister; + chan.ambsource = AmbSource::AmbColorRegister; chan.enablelighting = false; CGX_BEGIN_LOAD_XF_REGS(0x100e, 1); // color channel 1 wgPipe->U32 = chan.hex; From 42a881fc4289ac8eacfa685b1da9586debcb4caf Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Sun, 24 Apr 2022 18:36:35 -0700 Subject: [PATCH 2/2] Use XF register constants --- gxtest/cgx.cpp | 6 +++--- gxtest/clipping.cpp | 18 +++++++++--------- gxtest/lighting.cpp | 14 +++++++------- gxtest/rasterization.cpp | 8 ++++---- gxtest/tev.cpp | 16 ++++++++-------- 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/gxtest/cgx.cpp b/gxtest/cgx.cpp index 9f6177e..3469b0b 100644 --- a/gxtest/cgx.cpp +++ b/gxtest/cgx.cpp @@ -85,7 +85,7 @@ void CGX_Init() void CGX_SetViewport(float origin_x, float origin_y, float width, float height, float near, f32 far) { - CGX_BEGIN_LOAD_XF_REGS(0x101a, 6); + CGX_BEGIN_LOAD_XF_REGS(XFMEM_SETVIEWPORT, 6); wgPipe->F32 = width * 0.5f; wgPipe->F32 = -height * 0.5f; wgPipe->F32 = (far - near) * 16777215.0f; @@ -105,7 +105,7 @@ void CGX_LoadPosMatrixDirect(f32 mt[3][4], u32 index) void CGX_LoadProjectionMatrixPerspective(float mtx[4][4]) { // Untested - /* CGX_BEGIN_LOAD_XF_REGS(0x1020, 7); + /* CGX_BEGIN_LOAD_XF_REGS(XFMEM_SETPROJECTION, 7); wgPipe->F32 = mtx[0][0]; wgPipe->F32 = mtx[0][2]; wgPipe->F32 = mtx[1][1]; @@ -119,7 +119,7 @@ void CGX_LoadProjectionMatrixPerspective(float mtx[4][4]) void CGX_LoadProjectionMatrixOrthographic(float mtx[4][4]) { // Untested - /* CGX_BEGIN_LOAD_XF_REGS(0x1020, 7); + /* CGX_BEGIN_LOAD_XF_REGS(XFMEM_SETPROJECTION, 7); wgPipe->F32 = mtx[0][0]; wgPipe->F32 = mtx[0][3]; wgPipe->F32 = mtx[1][1]; diff --git a/gxtest/clipping.cpp b/gxtest/clipping.cpp index 0b03af3..088533b 100644 --- a/gxtest/clipping.cpp +++ b/gxtest/clipping.cpp @@ -19,15 +19,15 @@ void ClipTest() CGX_LOAD_BP_REG(CGXDefault(0).hex); - CGX_BEGIN_LOAD_XF_REGS(0x1009, 1); + CGX_BEGIN_LOAD_XF_REGS(XFMEM_SETNUMCHAN, 1); wgPipe->U32 = 1; // 1 color channel LitChannel chan; chan.hex = 0; chan.matsource = MatSource::Vertex; - CGX_BEGIN_LOAD_XF_REGS(0x100e, 1); // color channel 1 + CGX_BEGIN_LOAD_XF_REGS(XFMEM_SETCHAN0_COLOR, 1); wgPipe->U32 = chan.hex; - CGX_BEGIN_LOAD_XF_REGS(0x1010, 1); // alpha channel 1 + CGX_BEGIN_LOAD_XF_REGS(XFMEM_SETCHAN0_ALPHA, 1); wgPipe->U32 = chan.hex; CGX_LOAD_BP_REG(CGXDefault(0).hex); @@ -79,7 +79,7 @@ void ClipTest() CGX_LOAD_BP_REG(tevreg.ra.hex); CGX_LOAD_BP_REG(tevreg.bg.hex); - CGX_BEGIN_LOAD_XF_REGS(0x1005, 1); + CGX_BEGIN_LOAD_XF_REGS(XFMEM_CLIPDISABLE, 1); wgPipe->U32 = 0; // 0 = enable clipping, 1 = disable clipping bool expect_quad_to_be_drawn = true; @@ -157,7 +157,7 @@ void ClipTest() // Depth clipping tests case 7: // Everything behind z=w plane, depth clipping enabled case 8: // Everything behind z=w plane, depth clipping disabled - CGX_BEGIN_LOAD_XF_REGS(0x1005, 1); + CGX_BEGIN_LOAD_XF_REGS(XFMEM_CLIPDISABLE, 1); wgPipe->U32 = step - 7; // 0 = enable clipping, 1 = disable clipping test_quad.AtDepth(1.1); @@ -166,7 +166,7 @@ void ClipTest() case 9: // Everything in front of z=0 plane, depth clipping enabled case 10: // Everything in front of z=0 plane, depth clipping disabled - CGX_BEGIN_LOAD_XF_REGS(0x1005, 1); + CGX_BEGIN_LOAD_XF_REGS(XFMEM_CLIPDISABLE, 1); wgPipe->U32 = step - 9; // 0 = enable clipping, 1 = disable clipping test_quad.AtDepth(-0.00001); @@ -181,7 +181,7 @@ void ClipTest() // number, which by IEEE would be non-zero but which in fact is // treated as zero. // In particular, the value by IEEE is -0.00000011920928955078125. - CGX_BEGIN_LOAD_XF_REGS(0x1005, 1); + CGX_BEGIN_LOAD_XF_REGS(XFMEM_CLIPDISABLE, 1); wgPipe->U32 = step - 11; // 0 = enable clipping, 1 = disable clipping test_quad.AtDepth(1.0000001); @@ -189,7 +189,7 @@ void ClipTest() case 13: // One vertex behind z=w plane, depth clipping enabled case 14: // One vertex behind z=w plane, depth clipping disabled - CGX_BEGIN_LOAD_XF_REGS(0x1005, 1); + CGX_BEGIN_LOAD_XF_REGS(XFMEM_CLIPDISABLE, 1); wgPipe->U32 = step - 13; // 0 = enable clipping, 1 = disable clipping test_quad.VertexTopLeft(-1.0f, 1.0f, 1.5f); @@ -200,7 +200,7 @@ void ClipTest() break; case 15: // Three vertices with a very large value for z, depth clipping disabled - CGX_BEGIN_LOAD_XF_REGS(0x1005, 1); + CGX_BEGIN_LOAD_XF_REGS(XFMEM_CLIPDISABLE, 1); wgPipe->U32 = 1; // 0 = enable clipping, 1 = disable clipping test_quad.VertexTopLeft(-1.0f, 1.0f, 65537.f); diff --git a/gxtest/lighting.cpp b/gxtest/lighting.cpp index 37fb835..d005a0d 100644 --- a/gxtest/lighting.cpp +++ b/gxtest/lighting.cpp @@ -19,7 +19,7 @@ void LightingTest() CGX_LOAD_BP_REG(CGXDefault(0).hex); - CGX_BEGIN_LOAD_XF_REGS(0x1009, 1); + CGX_BEGIN_LOAD_XF_REGS(XFMEM_SETNUMCHAN, 1); wgPipe->U32 = 1; // 1 color channel LitChannel chan; @@ -27,9 +27,9 @@ void LightingTest() chan.matsource = MatSource::MatColorRegister; chan.ambsource = AmbSource::AmbColorRegister; chan.enablelighting = true; - CGX_BEGIN_LOAD_XF_REGS(0x100e, 1); // color channel 1 + CGX_BEGIN_LOAD_XF_REGS(XFMEM_SETCHAN0_COLOR, 1); wgPipe->U32 = chan.hex; - CGX_BEGIN_LOAD_XF_REGS(0x1010, 1); // alpha channel 1 + CGX_BEGIN_LOAD_XF_REGS(XFMEM_SETCHAN0_ALPHA, 1); wgPipe->U32 = chan.hex; CGX_LOAD_BP_REG(CGXDefault(0).hex); @@ -62,13 +62,13 @@ void LightingTest() CGX_LOAD_BP_REG(tevreg.ra.hex); CGX_LOAD_BP_REG(tevreg.bg.hex); - CGX_BEGIN_LOAD_XF_REGS(0x1005, 1); - wgPipe->U32 = 0; // 0 = enable clipping, 1 = disable clipping + CGX_BEGIN_LOAD_XF_REGS(XFMEM_CLIPDISABLE, 1); + wgPipe->U32 = 0; // enable clipping - CGX_BEGIN_LOAD_XF_REGS(0x100a, 1); + CGX_BEGIN_LOAD_XF_REGS(XFMEM_SETCHAN0_AMBCOLOR, 1); wgPipe->U32 = (ambcolor << 24) | 255; - CGX_BEGIN_LOAD_XF_REGS(0x100c, 1); + CGX_BEGIN_LOAD_XF_REGS(XFMEM_SETCHAN0_MATCOLOR, 1); wgPipe->U32 = (matcolor << 24) | 255; int test_x = 125, test_y = 25; // Somewhere within the viewport diff --git a/gxtest/rasterization.cpp b/gxtest/rasterization.cpp index e435784..b7351b6 100644 --- a/gxtest/rasterization.cpp +++ b/gxtest/rasterization.cpp @@ -19,15 +19,15 @@ void CoordinatePrecisionTest() CGX_LOAD_BP_REG(CGXDefault(0).hex); - CGX_BEGIN_LOAD_XF_REGS(0x1009, 1); + CGX_BEGIN_LOAD_XF_REGS(XFMEM_SETNUMCHAN, 1); wgPipe->U32 = 1; // 1 color channel LitChannel chan; chan.hex = 0; chan.matsource = MatSource::Vertex; - CGX_BEGIN_LOAD_XF_REGS(0x100e, 1); // color channel 1 + CGX_BEGIN_LOAD_XF_REGS(XFMEM_SETCHAN0_COLOR, 1); wgPipe->U32 = chan.hex; - CGX_BEGIN_LOAD_XF_REGS(0x1010, 1); // alpha channel 1 + CGX_BEGIN_LOAD_XF_REGS(XFMEM_SETCHAN0_ALPHA, 1); wgPipe->U32 = chan.hex; auto ac = CGXDefault(0); @@ -99,7 +99,7 @@ void CoordinatePrecisionTest() // For this size, values of xpos from 0.583297729492 to 0.583328247070 will yield a covered // pixel float vp_width = 2.0e-5f; - CGX_BEGIN_LOAD_XF_REGS(0x101a, 6); + CGX_BEGIN_LOAD_XF_REGS(XFMEM_SETVIEWPORT, 6); wgPipe->F32 = vp_width; wgPipe->F32 = -50.0f; wgPipe->F32 = 16777215.0f; diff --git a/gxtest/tev.cpp b/gxtest/tev.cpp index 981aafd..1360392 100644 --- a/gxtest/tev.cpp +++ b/gxtest/tev.cpp @@ -41,15 +41,15 @@ void TevCombinerTest() CGX_LOAD_BP_REG(CGXDefault(0).hex); - CGX_BEGIN_LOAD_XF_REGS(0x1009, 1); + CGX_BEGIN_LOAD_XF_REGS(XFMEM_SETNUMCHAN, 1); wgPipe->U32 = 1; // 1 color channel LitChannel chan; chan.hex = 0; chan.matsource = MatSource::Vertex; - CGX_BEGIN_LOAD_XF_REGS(0x100e, 1); // color channel 1 + CGX_BEGIN_LOAD_XF_REGS(XFMEM_SETCHAN0_COLOR, 1); wgPipe->U32 = chan.hex; - CGX_BEGIN_LOAD_XF_REGS(0x1010, 1); // alpha channel 1 + CGX_BEGIN_LOAD_XF_REGS(XFMEM_SETCHAN0_ALPHA, 1); wgPipe->U32 = chan.hex; auto ac = CGXDefault(0); @@ -240,7 +240,7 @@ void KonstTest() CGX_LOAD_BP_REG(CGXDefault(0).hex); - CGX_BEGIN_LOAD_XF_REGS(0x1009, 1); + CGX_BEGIN_LOAD_XF_REGS(XFMEM_SETNUMCHAN, 1); wgPipe->U32 = 1; // 1 color channel LitChannel chan; @@ -248,9 +248,9 @@ void KonstTest() chan.matsource = MatSource::MatColorRegister; chan.ambsource = AmbSource::AmbColorRegister; chan.enablelighting = false; - CGX_BEGIN_LOAD_XF_REGS(0x100e, 1); // color channel 1 + CGX_BEGIN_LOAD_XF_REGS(XFMEM_SETCHAN0_COLOR, 1); wgPipe->U32 = chan.hex; - CGX_BEGIN_LOAD_XF_REGS(0x1010, 1); // alpha channel 1 + CGX_BEGIN_LOAD_XF_REGS(XFMEM_SETCHAN0_ALPHA, 1); wgPipe->U32 = chan.hex; auto genmode = CGXDefault(); @@ -264,8 +264,8 @@ void KonstTest() ctrl.early_ztest = false; CGX_LOAD_BP_REG(ctrl.hex); - CGX_BEGIN_LOAD_XF_REGS(0x1005, 1); - wgPipe->U32 = 0; // 0 = enable clipping, 1 = disable clipping + CGX_BEGIN_LOAD_XF_REGS(XFMEM_CLIPDISABLE, 1); + wgPipe->U32 = 0; // enable clipping // Set up "konst" colors with recognizable values. for (int i = 0; i < 4; ++i)