diff --git a/Source/Core/Core/HW/Memmap.cpp b/Source/Core/Core/HW/Memmap.cpp index b740971c56..ac529d035f 100644 --- a/Source/Core/Core/HW/Memmap.cpp +++ b/Source/Core/Core/HW/Memmap.cpp @@ -33,6 +33,7 @@ #include "Core/PowerPC/PowerPC.h" #include "Core/PowerPC/JitCommon/JitBase.h" +#include "VideoCommon/PixelEngine.h" #include "VideoCommon/VideoBackendBase.h" namespace Memory @@ -89,7 +90,7 @@ MMIO::Mapping* mmio_mapping; void InitMMIO(MMIO::Mapping* mmio) { g_video_backend->RegisterCPMMIO(mmio, 0xCC000000); - g_video_backend->RegisterPEMMIO(mmio, 0xCC001000); + PixelEngine::RegisterMMIO(mmio, 0xCC001000); VideoInterface::RegisterMMIO(mmio, 0xCC002000); ProcessorInterface::RegisterMMIO(mmio, 0xCC003000); MemoryInterface::RegisterMMIO(mmio, 0xCC004000); diff --git a/Source/Core/VideoBackends/Software/BPMemLoader.cpp b/Source/Core/VideoBackends/Software/BPMemLoader.cpp index b81f2b340e..d6566f23c5 100644 --- a/Source/Core/VideoBackends/Software/BPMemLoader.cpp +++ b/Source/Core/VideoBackends/Software/BPMemLoader.cpp @@ -7,10 +7,11 @@ #include "VideoBackends/Software/BPMemLoader.h" #include "VideoBackends/Software/EfbCopy.h" +#include "VideoBackends/Software/EfbInterface.h" #include "VideoBackends/Software/Rasterizer.h" -#include "VideoBackends/Software/SWPixelEngine.h" #include "VideoBackends/Software/Tev.h" +#include "VideoCommon/PixelEngine.h" #include "VideoCommon/TextureDecoder.h" #include "VideoCommon/VideoCommon.h" @@ -50,7 +51,7 @@ void SWBPWritten(int address, int newvalue) switch (bpmem.drawdone & 0xFF) { case 0x02: - SWPixelEngine::SetFinish(); // may generate interrupt + PixelEngine::SetFinish(); // may generate interrupt DEBUG_LOG(VIDEO, "GXSetDrawDone SetPEFinish (value: 0x%02X)", (bpmem.drawdone & 0xFFFF)); break; @@ -61,37 +62,26 @@ void SWBPWritten(int address, int newvalue) break; case BPMEM_PE_TOKEN_ID: // Pixel Engine Token ID DEBUG_LOG(VIDEO, "SetPEToken 0x%04x", (bpmem.petoken & 0xFFFF)); - SWPixelEngine::SetToken(static_cast(bpmem.petokenint & 0xFFFF), false); + PixelEngine::SetToken(static_cast(bpmem.petokenint & 0xFFFF), false); break; case BPMEM_PE_TOKEN_INT_ID: // Pixel Engine Interrupt Token ID DEBUG_LOG(VIDEO, "SetPEToken + INT 0x%04x", (bpmem.petokenint & 0xFFFF)); - SWPixelEngine::SetToken(static_cast(bpmem.petokenint & 0xFFFF), true); + PixelEngine::SetToken(static_cast(bpmem.petokenint & 0xFFFF), true); break; case BPMEM_TRIGGER_EFB_COPY: EfbCopy::CopyEfb(); break; case BPMEM_CLEARBBOX1: - SWPixelEngine::pereg.boxRight = newvalue >> 10; - SWPixelEngine::pereg.boxLeft = newvalue & 0x3ff; + PixelEngine::bbox[0] = newvalue >> 10; + PixelEngine::bbox[1] = newvalue & 0x3ff; break; case BPMEM_CLEARBBOX2: - SWPixelEngine::pereg.boxBottom = newvalue >> 10; - SWPixelEngine::pereg.boxTop = newvalue & 0x3ff; + PixelEngine::bbox[2] = newvalue >> 10; + PixelEngine::bbox[3] = newvalue & 0x3ff; break; case BPMEM_CLEAR_PIXEL_PERF: // TODO: I didn't test if the value written to this register affects the amount of cleared registers - SWPixelEngine::pereg.perfZcompInputZcomplocLo = 0; - SWPixelEngine::pereg.perfZcompInputZcomplocHi = 0; - SWPixelEngine::pereg.perfZcompOutputZcomplocLo = 0; - SWPixelEngine::pereg.perfZcompOutputZcomplocHi = 0; - SWPixelEngine::pereg.perfZcompInputLo = 0; - SWPixelEngine::pereg.perfZcompInputHi = 0; - SWPixelEngine::pereg.perfZcompOutputLo = 0; - SWPixelEngine::pereg.perfZcompOutputHi = 0; - SWPixelEngine::pereg.perfBlendInputLo = 0; - SWPixelEngine::pereg.perfBlendInputHi = 0; - SWPixelEngine::pereg.perfEfbCopyClocksLo = 0; - SWPixelEngine::pereg.perfEfbCopyClocksHi = 0; + memset(EfbInterface::perf_values, 0, sizeof(EfbInterface::perf_values)); break; case BPMEM_LOADTLUT0: // This one updates bpmem.tlutXferSrc, no need to do anything here. break; diff --git a/Source/Core/VideoBackends/Software/CMakeLists.txt b/Source/Core/VideoBackends/Software/CMakeLists.txt index 4ae5340026..e5c36f035c 100644 --- a/Source/Core/VideoBackends/Software/CMakeLists.txt +++ b/Source/Core/VideoBackends/Software/CMakeLists.txt @@ -8,7 +8,6 @@ set(SRCS BPMemLoader.cpp HwRasterizer.cpp SWmain.cpp OpcodeDecoder.cpp - SWPixelEngine.cpp RasterFont.cpp Rasterizer.cpp SWRenderer.cpp diff --git a/Source/Core/VideoBackends/Software/EfbInterface.cpp b/Source/Core/VideoBackends/Software/EfbInterface.cpp index c1ded19322..0eff1cd226 100644 --- a/Source/Core/VideoBackends/Software/EfbInterface.cpp +++ b/Source/Core/VideoBackends/Software/EfbInterface.cpp @@ -2,20 +2,24 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include + #include "Common/Common.h" #include "Core/HW/Memmap.h" #include "VideoBackends/Software/BPMemLoader.h" #include "VideoBackends/Software/EfbInterface.h" -#include "VideoBackends/Software/SWPixelEngine.h" #include "VideoCommon/LookUpTables.h" +#include "VideoCommon/PixelEngine.h" u8 efb[EFB_WIDTH*EFB_HEIGHT*6]; namespace EfbInterface { + u32 perf_values[PQ_NUM_MEMBERS]; + inline u32 GetColorOffset(u16 x, u16 y) { return (x + y * EFB_WIDTH) * 3; @@ -434,10 +438,10 @@ namespace EfbInterface } // branchless bounding box update - SWPixelEngine::pereg.boxLeft = SWPixelEngine::pereg.boxLeft>x?x:SWPixelEngine::pereg.boxLeft; - SWPixelEngine::pereg.boxRight = SWPixelEngine::pereg.boxRighty?y:SWPixelEngine::pereg.boxTop; - SWPixelEngine::pereg.boxBottom = SWPixelEngine::pereg.boxBottomRegister(base | (i * 2), - MMIO::DirectRead(ptr), - MMIO::DirectWrite(ptr) - ); - } - - // The control register has some more complex logic to perform on writes. - mmio->RegisterWrite(base | PE_CTRL_REGISTER, - MMIO::ComplexWrite([](u32, u16 val) { - UPECtrlReg tmpCtrl(val); - - if (tmpCtrl.PEToken) g_bSignalTokenInterrupt = false; - if (tmpCtrl.PEFinish) g_bSignalFinishInterrupt = false; - - pereg.ctrl.PETokenEnable = tmpCtrl.PETokenEnable; - pereg.ctrl.PEFinishEnable = tmpCtrl.PEFinishEnable; - pereg.ctrl.PEToken = 0; // this flag is write only - pereg.ctrl.PEFinish = 0; // this flag is write only - - UpdateInterrupts(); - }) - ); -} - -bool AllowIdleSkipping() -{ - return !SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread || (!pereg.ctrl.PETokenEnable && !pereg.ctrl.PEFinishEnable); -} - -void UpdateInterrupts() -{ - // check if there is a token-interrupt - if (g_bSignalTokenInterrupt & pereg.ctrl.PETokenEnable) - ProcessorInterface::SetInterrupt(INT_CAUSE_PE_TOKEN, true); - else - ProcessorInterface::SetInterrupt(INT_CAUSE_PE_TOKEN, false); - - // check if there is a finish-interrupt - if (g_bSignalFinishInterrupt & pereg.ctrl.PEFinishEnable) - ProcessorInterface::SetInterrupt(INT_CAUSE_PE_FINISH, true); - else - ProcessorInterface::SetInterrupt(INT_CAUSE_PE_FINISH, false); -} - - -// Called only if BPMEM_PE_TOKEN_INT_ID is ack by GP -void SetToken_OnMainThread(u64 userdata, int cyclesLate) -{ - g_bSignalTokenInterrupt = true; - INFO_LOG(PIXELENGINE, "VIDEO Backend raises INT_CAUSE_PE_TOKEN (btw, token: %04x)", pereg.token); - UpdateInterrupts(); -} - -void SetFinish_OnMainThread(u64 userdata, int cyclesLate) -{ - g_bSignalFinishInterrupt = true; - UpdateInterrupts(); -} - -// SetToken -// THIS IS EXECUTED FROM VIDEO THREAD -void SetToken(const u16 _token, const int _bSetTokenAcknowledge) -{ - pereg.token = _token; - if (_bSetTokenAcknowledge) // set token INT - { - CoreTiming::ScheduleEvent_Threadsafe(0, et_SetTokenOnMainThread, - _token | (_bSetTokenAcknowledge << 16)); - } -} - -// SetFinish -// THIS IS EXECUTED FROM VIDEO THREAD -void SetFinish() -{ - CoreTiming::ScheduleEvent_Threadsafe(0, et_SetFinishOnMainThread, 0); - INFO_LOG(PIXELENGINE, "VIDEO Set Finish"); -} - -} // end of namespace SWPixelEngine diff --git a/Source/Core/VideoBackends/Software/SWPixelEngine.h b/Source/Core/VideoBackends/Software/SWPixelEngine.h deleted file mode 100644 index 93cab0ba9d..0000000000 --- a/Source/Core/VideoBackends/Software/SWPixelEngine.h +++ /dev/null @@ -1,211 +0,0 @@ -// Copyright 2013 Dolphin Emulator Project -// Licensed under GPLv2 -// Refer to the license.txt file included. - -#pragma once - -#include "Common/Common.h" -#include "VideoCommon/VideoCommon.h" - -class PointerWrap; -namespace MMIO { class Mapping; } - -namespace SWPixelEngine -{ - // internal hardware addresses - enum - { - PE_ZCONF = 0x000, // Z Config - PE_ALPHACONF = 0x002, // Alpha Config - PE_DSTALPHACONF = 0x004, // Destination Alpha Config - PE_ALPHAMODE = 0x006, // Alpha Mode Config - PE_ALPHAREAD = 0x008, // Alpha Read - PE_CTRL_REGISTER = 0x00a, // Control - PE_TOKEN_REG = 0x00e, // Token - PE_BBOX_LEFT = 0x010, // Flip Left - PE_BBOX_RIGHT = 0x012, // Flip Right - PE_BBOX_TOP = 0x014, // Flip Top - PE_BBOX_BOTTOM = 0x016, // Flip Bottom - - // NOTE: Order not verified - // These indicate the number of quads that are being used as input/output for each particular stage - PE_PERF_ZCOMP_INPUT_ZCOMPLOC_L = 0x18, - PE_PERF_ZCOMP_INPUT_ZCOMPLOC_H = 0x1a, - PE_PERF_ZCOMP_OUTPUT_ZCOMPLOC_L = 0x1c, - PE_PERF_ZCOMP_OUTPUT_ZCOMPLOC_H = 0x1e, - PE_PERF_ZCOMP_INPUT_L = 0x20, - PE_PERF_ZCOMP_INPUT_H = 0x22, - PE_PERF_ZCOMP_OUTPUT_L = 0x24, - PE_PERF_ZCOMP_OUTPUT_H = 0x26, - PE_PERF_BLEND_INPUT_L = 0x28, - PE_PERF_BLEND_INPUT_H = 0x2a, - PE_PERF_EFB_COPY_CLOCKS_L = 0x2c, - PE_PERF_EFB_COPY_CLOCKS_H = 0x2e, - }; - - union UPEZConfReg - { - u16 Hex; - struct - { - u16 ZCompEnable : 1; // Z Comparator Enable - u16 Function : 3; - u16 ZUpdEnable : 1; - u16 : 11; - }; - }; - - union UPEAlphaConfReg - { - u16 Hex; - struct - { - u16 BMMath : 1; // GX_BM_BLEND || GX_BM_SUBSTRACT - u16 BMLogic : 1; // GX_BM_LOGIC - u16 Dither : 1; - u16 ColorUpdEnable : 1; - u16 AlphaUpdEnable : 1; - u16 DstFactor : 3; - u16 SrcFactor : 3; - u16 Substract : 1; // Additive mode by default - u16 BlendOperator : 4; - }; - }; - - union UPEDstAlphaConfReg - { - u16 Hex; - struct - { - u16 DstAlpha : 8; - u16 Enable : 1; - u16 : 7; - }; - }; - - union UPEAlphaModeConfReg - { - u16 Hex; - struct - { - u16 Threshold : 8; - u16 CompareMode : 8; - }; - }; - - union UPEAlphaReadReg - { - u16 Hex; - struct - { - u16 ReadMode : 3; - u16 : 13; - }; - }; - - union UPECtrlReg - { - struct - { - u16 PETokenEnable : 1; - u16 PEFinishEnable : 1; - u16 PEToken : 1; // write only - u16 PEFinish : 1; // write only - u16 : 12; - }; - u16 Hex; - UPECtrlReg() {Hex = 0; } - UPECtrlReg(u16 _hex) {Hex = _hex; } - }; - - struct PEReg - { - UPEZConfReg zconf; - UPEAlphaConfReg alphaConf; - UPEDstAlphaConfReg dstAlpha; - UPEAlphaModeConfReg alphaMode; - UPEAlphaReadReg alphaRead; - UPECtrlReg ctrl; - u16 unk0; - u16 token; - - u16 boxLeft; - u16 boxRight; - u16 boxTop; - u16 boxBottom; - - u16 perfZcompInputZcomplocLo; - u16 perfZcompInputZcomplocHi; - u16 perfZcompOutputZcomplocLo; - u16 perfZcompOutputZcomplocHi; - u16 perfZcompInputLo; - u16 perfZcompInputHi; - u16 perfZcompOutputLo; - u16 perfZcompOutputHi; - u16 perfBlendInputLo; - u16 perfBlendInputHi; - u16 perfEfbCopyClocksLo; - u16 perfEfbCopyClocksHi; - - // NOTE: hardware doesn't process individual pixels but quads instead. Current software renderer architecture works on pixels though, so we have this "quad" hack here to only increment the registers on every fourth rendered pixel - void IncZInputQuadCount(bool early_ztest) - { - static int quad = 0; - if (++quad != 3) - return; - quad = 0; - - if (early_ztest) - { - if (++perfZcompInputZcomplocLo == 0) - perfZcompInputZcomplocHi++; - } - else - { - if (++perfZcompInputLo == 0) - perfZcompInputHi++; - } - } - void IncZOutputQuadCount(bool early_ztest) - { - static int quad = 0; - if (++quad != 3) - return; - quad = 0; - - if (early_ztest) - { - if (++perfZcompOutputZcomplocLo == 0) - perfZcompOutputZcomplocHi++; - } - else - { - if (++perfZcompOutputLo == 0) - perfZcompOutputHi++; - } - } - void IncBlendInputQuadCount() - { - static int quad = 0; - if (++quad != 3) - return; - quad = 0; - - if (++perfBlendInputLo == 0) - perfBlendInputHi++; - } - }; - - extern PEReg pereg; - - void Init(); - void DoState(PointerWrap &p); - - void RegisterMMIO(MMIO::Mapping* mmio, u32 base); - - // gfx backend support - void SetToken(const u16 _token, const int _bSetTokenAcknowledge); - void SetFinish(void); - bool AllowIdleSkipping(); - -} // end of namespace SWPixelEngine diff --git a/Source/Core/VideoBackends/Software/SWmain.cpp b/Source/Core/VideoBackends/Software/SWmain.cpp index e88d8d1441..c42cc136f2 100644 --- a/Source/Core/VideoBackends/Software/SWmain.cpp +++ b/Source/Core/VideoBackends/Software/SWmain.cpp @@ -24,7 +24,6 @@ #include "VideoBackends/Software/OpcodeDecoder.h" #include "VideoBackends/Software/Rasterizer.h" #include "VideoBackends/Software/SWCommandProcessor.h" -#include "VideoBackends/Software/SWPixelEngine.h" #include "VideoBackends/Software/SWRenderer.h" #include "VideoBackends/Software/SWStatistics.h" #include "VideoBackends/Software/SWVertexLoader.h" @@ -37,6 +36,8 @@ #endif // HAVE_WX #include "VideoCommon/OnScreenDisplay.h" +#include "VideoCommon/PixelEngine.h" +#include "VideoCommon/XFMemory.h" #define VSYNC_ENABLED 0 @@ -89,7 +90,7 @@ bool VideoSoftware::Initialize(void *&window_handle) InitBPMemory(); InitXFMemory(); SWCommandProcessor::Init(); - SWPixelEngine::Init(); + PixelEngine::Init(); OpcodeDecoder::Init(); Clipper::Init(); Rasterizer::Init(); @@ -110,7 +111,7 @@ void VideoSoftware::DoState(PointerWrap& p) // TODO: incomplete? SWCommandProcessor::DoState(p); - SWPixelEngine::DoState(p); + PixelEngine::DoState(p); EfbInterface::DoState(p); OpcodeDecoder::DoState(p); Clipper::DoState(p); @@ -283,8 +284,7 @@ u32 VideoSoftware::Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputDa u32 VideoSoftware::Video_GetQueryResult(PerfQueryType type) { - // TODO: - return 0; + return EfbInterface::perf_values[type]; } bool VideoSoftware::Video_Screenshot(const std::string& filename) @@ -376,11 +376,6 @@ void VideoSoftware::RegisterCPMMIO(MMIO::Mapping* mmio, u32 base) SWCommandProcessor::RegisterMMIO(mmio, base); } -void VideoSoftware::RegisterPEMMIO(MMIO::Mapping* mmio, u32 base) -{ - SWPixelEngine::RegisterMMIO(mmio, base); -} - // Draw messages on top of the screen unsigned int VideoSoftware::PeekMessages() { diff --git a/Source/Core/VideoBackends/Software/Software.vcxproj b/Source/Core/VideoBackends/Software/Software.vcxproj index 9c65d062ad..8e87cbcfc3 100644 --- a/Source/Core/VideoBackends/Software/Software.vcxproj +++ b/Source/Core/VideoBackends/Software/Software.vcxproj @@ -1,4 +1,4 @@ - + @@ -59,7 +59,6 @@ - @@ -86,7 +85,6 @@ - @@ -114,4 +112,4 @@ - + \ No newline at end of file diff --git a/Source/Core/VideoBackends/Software/Tev.cpp b/Source/Core/VideoBackends/Software/Tev.cpp index 9a57c9a475..89e8efc5c6 100644 --- a/Source/Core/VideoBackends/Software/Tev.cpp +++ b/Source/Core/VideoBackends/Software/Tev.cpp @@ -8,7 +8,6 @@ #include "VideoBackends/Software/DebugUtil.h" #include "VideoBackends/Software/EfbInterface.h" -#include "VideoBackends/Software/SWPixelEngine.h" #include "VideoBackends/Software/SWStatistics.h" #include "VideoBackends/Software/SWVideoConfig.h" #include "VideoBackends/Software/Tev.h" @@ -745,12 +744,12 @@ void Tev::Draw() if (late_ztest && bpmem.zmode.testenable) { // TODO: Check against hw if these values get incremented even if depth testing is disabled - SWPixelEngine::pereg.IncZInputQuadCount(false); + EfbInterface::IncPerfCounterQuadCount(PQ_ZCOMP_INPUT); if (!EfbInterface::ZCompare(Position[0], Position[1], Position[2])) return; - SWPixelEngine::pereg.IncZOutputQuadCount(false); + EfbInterface::IncPerfCounterQuadCount(PQ_ZCOMP_OUTPUT); } #if ALLOW_TEV_DUMPS @@ -774,7 +773,7 @@ void Tev::Draw() #endif INCSTAT(swstats.thisFrame.tevPixelsOut); - SWPixelEngine::pereg.IncBlendInputQuadCount(); + EfbInterface::IncPerfCounterQuadCount(PQ_BLEND_INPUT); EfbInterface::BlendTev(Position[0], Position[1], output); } diff --git a/Source/Core/VideoBackends/Software/VideoBackend.h b/Source/Core/VideoBackends/Software/VideoBackend.h index 50fa855f4d..3529e65342 100644 --- a/Source/Core/VideoBackends/Software/VideoBackend.h +++ b/Source/Core/VideoBackends/Software/VideoBackend.h @@ -48,7 +48,6 @@ class VideoSoftware : public VideoBackend void Video_AbortFrame() override; void RegisterCPMMIO(MMIO::Mapping* mmio, u32 base) override; - void RegisterPEMMIO(MMIO::Mapping* mmio, u32 base) override; void UpdateFPSDisplay(const std::string&) override; unsigned int PeekMessages() override; diff --git a/Source/Core/VideoBackends/Software/XFMemLoader.cpp b/Source/Core/VideoBackends/Software/XFMemLoader.cpp index 07d5393223..0c1c51d400 100644 --- a/Source/Core/VideoBackends/Software/XFMemLoader.cpp +++ b/Source/Core/VideoBackends/Software/XFMemLoader.cpp @@ -8,7 +8,7 @@ #include "VideoBackends/Software/XFMemLoader.h" #include "VideoCommon/VideoCommon.h" -XFRegisters swxfregs; +SWXFRegisters swxfregs; void InitXFMemory() { diff --git a/Source/Core/VideoBackends/Software/XFMemLoader.h b/Source/Core/VideoBackends/Software/XFMemLoader.h index 4a827cd7a7..2bda565aeb 100644 --- a/Source/Core/VideoBackends/Software/XFMemLoader.h +++ b/Source/Core/VideoBackends/Software/XFMemLoader.h @@ -6,104 +6,7 @@ #include "Common/Common.h" -///////////// -// Lighting -///////////// - -#define XF_TEXPROJ_ST 0 -#define XF_TEXPROJ_STQ 1 - -#define XF_TEXINPUT_AB11 0 -#define XF_TEXINPUT_ABC1 1 - -#define XF_TEXGEN_REGULAR 0 -#define XF_TEXGEN_EMBOSS_MAP 1 // used when bump mapping -#define XF_TEXGEN_COLOR_STRGBC0 2 -#define XF_TEXGEN_COLOR_STRGBC1 3 - -#define XF_SRCGEOM_INROW 0 // input is abc -#define XF_SRCNORMAL_INROW 1 // input is abc -#define XF_SRCCOLORS_INROW 2 -#define XF_SRCBINORMAL_T_INROW 3 // input is abc -#define XF_SRCBINORMAL_B_INROW 4 // input is abc -#define XF_SRCTEX0_INROW 5 -#define XF_SRCTEX1_INROW 6 -#define XF_SRCTEX2_INROW 7 -#define XF_SRCTEX3_INROW 8 -#define XF_SRCTEX4_INROW 9 -#define XF_SRCTEX5_INROW 10 -#define XF_SRCTEX6_INROW 11 -#define XF_SRCTEX7_INROW 12 - -#define GX_SRC_REG 0 -#define GX_SRC_VTX 1 - -struct Light -{ - u32 useless[3]; - u32 color; //rgba - float a0; //attenuation - float a1; - float a2; - float k0; //k stuff - float k1; - float k2; - union - { - struct { - float dpos[3]; - float ddir[3]; // specular lights only - }; - struct { - float sdir[3]; - float shalfangle[3]; // specular lights only - }; - }; -}; - -#define LIGHTDIF_NONE 0 -#define LIGHTDIF_SIGN 1 -#define LIGHTDIF_CLAMP 2 - -#define LIGHTATTN_SPEC 0 // specular attenuation -#define LIGHTATTN_SPOT 1 // distance/spotlight attenuation -#define LIGHTATTN_NONE 2 -#define LIGHTATTN_DIR 3 - -#define GX_PERSPECTIVE 0 -#define GX_ORTHOGRAPHIC 1 - -union LitChannel -{ - struct - { - u32 matsource : 1; - u32 enablelighting : 1; - u32 lightMask0_3 : 4; - u32 ambsource : 1; - u32 diffusefunc : 2; // LIGHTDIF_X - u32 attnfunc : 2; // LIGHTATTN_X - u32 lightMask4_7 : 4; - u32 unused : 17; - }; - u32 hex; - unsigned int GetFullLightMask() const - { - return enablelighting ? (lightMask0_3 | (lightMask4_7 << 4)) : 0; - } -}; - -union INVTXSPEC -{ - struct - { - u32 numcolors : 2; - u32 numnormals : 2; // 0 - nothing, 1 - just normal, 2 - normals and binormals - u32 numtextures : 4; - u32 unused : 24; - }; - u32 hex; -}; +#include "VideoCommon/XFMemory.h" union TXFMatrixIndexA { @@ -138,49 +41,7 @@ union TXFMatrixIndexB }; }; -struct Viewport -{ - float wd; - float ht; - float zRange; - float xOrig; - float yOrig; - float farZ; -}; - -struct Projection -{ - float rawProjection[6]; - u32 type; // only GX_PERSPECTIVE or GX_ORTHOGRAPHIC are allowed -}; - -union TexMtxInfo -{ - struct - { - u32 unknown : 1; - u32 projection : 1; // XF_TEXPROJ_X - u32 inputform : 2; // XF_TEXINPUT_X - u32 texgentype : 3; // XF_TEXGEN_X - u32 sourcerow : 5; // XF_SRCGEOM_X - u32 embosssourceshift : 3; // what generated texcoord to use - u32 embosslightshift : 3; // light index that is used - }; - u32 hex; -}; - -union PostMtxInfo -{ - struct - { - u32 index : 6; // base row of dual transform matrix - u32 unused : 2; - u32 normalize : 1; // normalize before send operation - }; - u32 hex; -}; - -struct XFRegisters +struct SWXFRegisters { u32 posMatrices[256]; // 0x0000 - 0x00ff u32 unk0[768]; // 0x0100 - 0x03ff @@ -220,17 +81,7 @@ struct XFRegisters PostMtxInfo postMtxInfo[8]; // 0x1050 - 0x1057 }; -#define XFMEM_POSMATRICES 0x000 -#define XFMEM_POSMATRICES_END 0x100 -#define XFMEM_NORMALMATRICES 0x400 -#define XFMEM_NORMALMATRICES_END 0x460 -#define XFMEM_POSTMATRICES 0x500 -#define XFMEM_POSTMATRICES_END 0x600 -#define XFMEM_LIGHTS 0x600 -#define XFMEM_LIGHTS_END 0x680 - - -extern XFRegisters swxfregs; +extern SWXFRegisters swxfregs; void InitXFMemory(); diff --git a/Source/Core/VideoCommon/MainBase.cpp b/Source/Core/VideoCommon/MainBase.cpp index f5d313045d..b6fec113ed 100644 --- a/Source/Core/VideoCommon/MainBase.cpp +++ b/Source/Core/VideoCommon/MainBase.cpp @@ -317,7 +317,3 @@ void VideoBackendHardware::RegisterCPMMIO(MMIO::Mapping* mmio, u32 base) CommandProcessor::RegisterMMIO(mmio, base); } -void VideoBackendHardware::RegisterPEMMIO(MMIO::Mapping* mmio, u32 base) -{ - PixelEngine::RegisterMMIO(mmio, base); -} diff --git a/Source/Core/VideoCommon/VideoBackendBase.h b/Source/Core/VideoCommon/VideoBackendBase.h index 2dcf6c43a0..f355f8a80d 100644 --- a/Source/Core/VideoCommon/VideoBackendBase.h +++ b/Source/Core/VideoCommon/VideoBackendBase.h @@ -110,7 +110,6 @@ public: // Registers MMIO handlers for the CommandProcessor registers. virtual void RegisterCPMMIO(MMIO::Mapping* mmio, u32 base) = 0; - virtual void RegisterPEMMIO(MMIO::Mapping* mmio, u32 base) = 0; static void PopulateList(); static void ClearList(); @@ -159,7 +158,6 @@ class VideoBackendHardware : public VideoBackend void Video_AbortFrame() override; void RegisterCPMMIO(MMIO::Mapping* mmio, u32 base) override; - void RegisterPEMMIO(MMIO::Mapping* mmio, u32 base) override; void PauseAndLock(bool doLock, bool unpauseOnUnlock=true) override; void DoState(PointerWrap &p) override;