GPU:
- Do heavy code cleanup. - Split the engine-specific functionality of the main and sub engines into the new GPUEngineA and GPUEngineB subclasses. - Templatize some parameters. Greatly increases the generated code size, but restores (and possibly improves) performance from r5251.
This commit is contained in:
parent
88006197b9
commit
ced0d3986d
3367
desmume/src/GPU.cpp
3367
desmume/src/GPU.cpp
File diff suppressed because it is too large
Load Diff
|
@ -26,6 +26,10 @@
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
|
#ifdef ENABLE_SSE2
|
||||||
|
#include <emmintrin.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
class EMUFILE;
|
class EMUFILE;
|
||||||
struct MMU_struct;
|
struct MMU_struct;
|
||||||
|
|
||||||
|
@ -397,10 +401,10 @@ typedef struct _reg_dispx {
|
||||||
u32 dispA_DISPMMEMFIFO; // 0x04000068
|
u32 dispA_DISPMMEMFIFO; // 0x04000068
|
||||||
} REG_DISPx ;
|
} REG_DISPx ;
|
||||||
|
|
||||||
enum GPUCoreID
|
enum GPUEngineID
|
||||||
{
|
{
|
||||||
GPUCOREID_MAIN = 0,
|
GPUEngineID_Main = 0,
|
||||||
GPUCOREID_SUB = 1
|
GPUEngineID_Sub = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
/* human readable bitmask names */
|
/* human readable bitmask names */
|
||||||
|
@ -616,6 +620,17 @@ typedef struct
|
||||||
#define MMU_BOBJ 0x06600000
|
#define MMU_BOBJ 0x06600000
|
||||||
#define MMU_LCDC 0x06800000
|
#define MMU_LCDC 0x06800000
|
||||||
|
|
||||||
|
enum GPULayerID
|
||||||
|
{
|
||||||
|
GPULayerID_BG0 = 0,
|
||||||
|
GPULayerID_BG1 = 1,
|
||||||
|
GPULayerID_BG2 = 2,
|
||||||
|
GPULayerID_BG3 = 3,
|
||||||
|
GPULayerID_OBJ = 4,
|
||||||
|
|
||||||
|
GPULayerID_None = 5
|
||||||
|
};
|
||||||
|
|
||||||
enum BGType
|
enum BGType
|
||||||
{
|
{
|
||||||
BGType_Invalid = 0,
|
BGType_Invalid = 0,
|
||||||
|
@ -686,11 +701,16 @@ typedef struct
|
||||||
|
|
||||||
class GPUEngineBase
|
class GPUEngineBase
|
||||||
{
|
{
|
||||||
private:
|
protected:
|
||||||
static CACHE_ALIGN u16 _fadeInColors[17][0x8000];
|
static CACHE_ALIGN u16 _fadeInColors[17][0x8000];
|
||||||
static CACHE_ALIGN u16 _fadeOutColors[17][0x8000];
|
static CACHE_ALIGN u16 _fadeOutColors[17][0x8000];
|
||||||
static CACHE_ALIGN u8 _blendTable555[17][17][32][32];
|
static CACHE_ALIGN u8 _blendTable555[17][17][32][32];
|
||||||
|
|
||||||
|
static const CACHE_ALIGN SpriteSize _sprSizeTab[4][4];
|
||||||
|
static const CACHE_ALIGN BGType _mode2type[8][4];
|
||||||
|
static const CACHE_ALIGN u16 _sizeTab[8][4][2];
|
||||||
|
static const CACHE_ALIGN u8 _winEmpty[GPU_FRAMEBUFFER_NATIVE_WIDTH];
|
||||||
|
|
||||||
static struct MosaicLookup {
|
static struct MosaicLookup {
|
||||||
|
|
||||||
struct TableEntry {
|
struct TableEntry {
|
||||||
|
@ -730,6 +750,8 @@ private:
|
||||||
} obj[256];
|
} obj[256];
|
||||||
} _mosaicColors;
|
} _mosaicColors;
|
||||||
|
|
||||||
|
GPUEngineID _engineID;
|
||||||
|
|
||||||
u8 _bgPrio[5];
|
u8 _bgPrio[5];
|
||||||
bool _bg0HasHighestPrio;
|
bool _bg0HasHighestPrio;
|
||||||
|
|
||||||
|
@ -755,7 +777,10 @@ private:
|
||||||
|
|
||||||
BGType _BGTypes[4];
|
BGType _BGTypes[4];
|
||||||
|
|
||||||
u8 _sprNum[256];
|
GPUDisplayMode _dispMode;
|
||||||
|
u8 _vramBlock;
|
||||||
|
|
||||||
|
CACHE_ALIGN u8 _sprNum[256];
|
||||||
CACHE_ALIGN u8 _h_win[2][GPU_FRAMEBUFFER_NATIVE_WIDTH];
|
CACHE_ALIGN u8 _h_win[2][GPU_FRAMEBUFFER_NATIVE_WIDTH];
|
||||||
const u8 *_curr_win[2];
|
const u8 *_curr_win[2];
|
||||||
|
|
||||||
|
@ -803,36 +828,44 @@ private:
|
||||||
u8 _BLDY_EVY;
|
u8 _BLDY_EVY;
|
||||||
|
|
||||||
void _InitLUTs();
|
void _InitLUTs();
|
||||||
|
void _Reset_Base();
|
||||||
|
|
||||||
void _MosaicSpriteLinePixel(const size_t x, u16 l, u16 *dst, u8 *dst_alpha, u8 *typeTab, u8 *prioTab);
|
void _MosaicSpriteLinePixel(const size_t x, u16 l, u16 *dst, u8 *dst_alpha, u8 *typeTab, u8 *prioTab);
|
||||||
void _MosaicSpriteLine(u16 l, u16 *dst, u8 *dst_alpha, u8 *typeTab, u8 *prioTab);
|
void _MosaicSpriteLine(u16 l, u16 *dst, u8 *dst_alpha, u8 *typeTab, u8 *prioTab);
|
||||||
|
|
||||||
template<bool MOSAIC> void _LineLarge8bpp();
|
template<GPULayerID LAYERID, bool MOSAIC, bool ISCUSTOMRENDERINGNEEDED> void _LineLarge8bpp();
|
||||||
template<bool MOSAIC> void _RenderLine_TextBG(u16 XBG, u16 YBG, u16 LG);
|
template<GPULayerID LAYERID, bool MOSAIC, bool ISCUSTOMRENDERINGNEEDED> void _RenderLine_TextBG(u16 XBG, u16 YBG, u16 LG);
|
||||||
|
|
||||||
template<bool MOSAIC> void _RotBG2(const BGxPARMS ¶m, const u16 LG);
|
template<GPULayerID LAYERID, bool MOSAIC, bool ISCUSTOMRENDERINGNEEDED> void _RotBG2(const BGxPARMS ¶m, const u16 LG);
|
||||||
template<bool MOSAIC> void _ExtRotBG2(const BGxPARMS ¶m, const u16 LG);
|
template<GPULayerID LAYERID, bool MOSAIC, bool ISCUSTOMRENDERINGNEEDED> void _ExtRotBG2(const BGxPARMS ¶m, const u16 LG);
|
||||||
|
|
||||||
template<bool MOSAIC> void _LineText();
|
template<GPULayerID LAYERID, bool MOSAIC, bool ISCUSTOMRENDERINGNEEDED> void _LineText();
|
||||||
template<bool MOSAIC> void _LineRot();
|
template<GPULayerID LAYERID, bool MOSAIC, bool ISCUSTOMRENDERINGNEEDED> void _LineRot();
|
||||||
template<bool MOSAIC> void _LineExtRot();
|
template<GPULayerID LAYERID, bool MOSAIC, bool ISCUSTOMRENDERINGNEEDED> void _LineExtRot();
|
||||||
|
|
||||||
// check whether (x,y) is within the rectangle (including wraparounds)
|
// check whether (x,y) is within the rectangle (including wraparounds)
|
||||||
template<int WIN_NUM> u8 _WithinRect(const size_t x) const;
|
template<int WIN_NUM> u8 _WithinRect(const size_t x) const;
|
||||||
void _RenderLine_CheckWindows(const size_t srcX, bool &draw, bool &effect) const;
|
template <GPULayerID LAYERID> void _RenderLine_CheckWindows(const size_t srcX, bool &draw, bool &effect) const;
|
||||||
|
|
||||||
template<bool BACKDROP, BlendFunc FUNC, bool WINDOW>
|
template<bool ISCUSTOMRENDERINGNEEDED> void _RenderLine_Layer(const u16 l, u16 *dstLine, const size_t dstLineWidth, const size_t dstLineCount);
|
||||||
|
template<bool ISCUSTOMRENDERINGNEEDED> void _RenderLine_MasterBrightness(u16 *dstLine, const size_t dstLineWidth, const size_t dstLineCount);
|
||||||
|
|
||||||
|
template<size_t WIN_NUM> void _UpdateWINH();
|
||||||
|
template<size_t WIN_NUM> void _SetupWindows();
|
||||||
|
template<GPULayerID LAYERID, bool MOSAIC, bool ISCUSTOMRENDERINGNEEDED> void _ModeRender();
|
||||||
|
|
||||||
|
template<GPULayerID LAYERID, bool BACKDROP, BlendFunc FUNC, bool WINDOW>
|
||||||
FORCEINLINE FASTCALL bool _master_setFinalBGColor(const size_t srcX, const size_t dstX, const u16 *dstLine, const u8 *bgPixelsLine, u16 &outColor);
|
FORCEINLINE FASTCALL bool _master_setFinalBGColor(const size_t srcX, const size_t dstX, const u16 *dstLine, const u8 *bgPixelsLine, u16 &outColor);
|
||||||
|
|
||||||
template<BlendFunc FUNC, bool WINDOW>
|
template<GPULayerID LAYERID, BlendFunc FUNC, bool WINDOW>
|
||||||
FORCEINLINE FASTCALL void _master_setFinal3dColor(const size_t srcX, const size_t dstX, u16 *dstLine, u8 *bgPixelsLine, const FragmentColor src);
|
FORCEINLINE FASTCALL void _master_setFinal3dColor(const size_t srcX, const size_t dstX, u16 *dstLine, u8 *bgPixelsLine, const FragmentColor src);
|
||||||
|
|
||||||
template<BlendFunc FUNC, bool WINDOW>
|
template<GPULayerID LAYERID, BlendFunc FUNC, bool WINDOW>
|
||||||
FORCEINLINE FASTCALL void _master_setFinalOBJColor(const size_t srcX, const size_t dstX, u16 *dstLine, u8 *bgPixelsLine, const u16 src, const u8 alpha, const u8 type);
|
FORCEINLINE FASTCALL void _master_setFinalOBJColor(const size_t srcX, const size_t dstX, u16 *dstLine, u8 *bgPixelsLine, const u16 src, const u8 alpha, const u8 type);
|
||||||
|
|
||||||
template<bool BACKDROP, int FUNCNUM> void _SetFinalColorBG(const size_t srcX, const size_t dstX, u16 *dstLine, u8 *bgPixelsLine, u16 src);
|
template<GPULayerID LAYERID, bool BACKDROP, int FUNCNUM> void _SetFinalColorBG(const size_t srcX, const size_t dstX, u16 *dstLine, u8 *bgPixelsLine, u16 src);
|
||||||
void _SetFinalColor3D(const size_t srcX, const size_t dstX, u16 *dstLine, u8 *bgPixelsLine, const FragmentColor src);
|
template<GPULayerID LAYERID> void _SetFinalColor3D(const size_t srcX, const size_t dstX, u16 *dstLine, u8 *bgPixelsLine, const FragmentColor src);
|
||||||
void _SetFinalColorSprite(const size_t srcX, const size_t dstX, u16 *dstLine, u8 *bgPixelsLine, const u16 src, const u8 alpha, const u8 type);
|
template<GPULayerID LAYERID> void _SetFinalColorSprite(const size_t srcX, const size_t dstX, u16 *dstLine, u8 *bgPixelsLine, const u16 src, const u8 alpha, const u8 type);
|
||||||
|
|
||||||
u16 _FinalColorBlend(const u16 colA, const u16 colB);
|
u16 _FinalColorBlend(const u16 colA, const u16 colB);
|
||||||
FORCEINLINE u16 _FinalColorBlendFunc(const u16 colA, const u16 colB, const TBlendTable *blendTable);
|
FORCEINLINE u16 _FinalColorBlendFunc(const u16 colA, const u16 colB, const TBlendTable *blendTable);
|
||||||
|
@ -849,21 +882,17 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GPUEngineBase();
|
GPUEngineBase();
|
||||||
GPUEngineBase(const GPUCoreID coreID);
|
virtual ~GPUEngineBase();
|
||||||
~GPUEngineBase();
|
|
||||||
|
|
||||||
void Reset();
|
virtual void Reset();
|
||||||
void ResortBGLayers();
|
void ResortBGLayers();
|
||||||
void SetMasterBrightness(const u16 val);
|
void SetMasterBrightness(const u16 val);
|
||||||
void SetupFinalPixelBlitter();
|
void SetupFinalPixelBlitter();
|
||||||
|
|
||||||
void SetVideoProp(const u32 ctrlBits);
|
void SetVideoProp(const u32 ctrlBits);
|
||||||
void SetBGProp(const size_t num, const u16 ctrlBits);
|
void SetBGProp(const size_t num, const u16 ctrlBits);
|
||||||
void SetDISPCAPCNT(u32 val);
|
|
||||||
|
|
||||||
void RenderLine(const u16 l, bool skip);
|
template<bool ISCUSTOMRENDERINGNEEDED> void RenderLine(const u16 l, bool skip);
|
||||||
void RenderLine_Layer(const u16 l, u16 *dstLine, const size_t dstLineWidth, const size_t dstLineCount);
|
|
||||||
void RenderLine_MasterBrightness(u16 *dstLine, const size_t dstLineWidth, const size_t dstLineCount);
|
|
||||||
|
|
||||||
// some structs are becoming redundant
|
// some structs are becoming redundant
|
||||||
// some functions too (no need to recopy some vars as it is done by MMU)
|
// some functions too (no need to recopy some vars as it is done by MMU)
|
||||||
|
@ -874,20 +903,10 @@ public:
|
||||||
|
|
||||||
_BGxCNT & bgcnt(int num) { return (dispx_st)->dispx_BGxCNT[num].bits; }
|
_BGxCNT & bgcnt(int num) { return (dispx_st)->dispx_BGxCNT[num].bits; }
|
||||||
const _DISPCNT& dispCnt() const { return dispx_st->dispx_DISPCNT.bits; }
|
const _DISPCNT& dispCnt() const { return dispx_st->dispx_DISPCNT.bits; }
|
||||||
|
|
||||||
DISPCAPCNT dispCapCnt;
|
|
||||||
|
|
||||||
u16 BGSize[4][2];
|
u16 BGSize[4][2];
|
||||||
u8 BGExtPalSlot[4];
|
u8 BGExtPalSlot[4];
|
||||||
|
|
||||||
template<size_t WIN_NUM> void update_winh();
|
|
||||||
template<size_t WIN_NUM> void setup_windows();
|
|
||||||
template<bool MOSAIC> void ModeRender(const size_t layer);
|
|
||||||
|
|
||||||
GPUCoreID core;
|
|
||||||
GPUDisplayMode dispMode;
|
|
||||||
u8 vramBlock;
|
|
||||||
|
|
||||||
bool isCustomRenderingNeeded;
|
bool isCustomRenderingNeeded;
|
||||||
bool is3DEnabled;
|
bool is3DEnabled;
|
||||||
u8 vramBGLayer;
|
u8 vramBGLayer;
|
||||||
|
@ -905,7 +924,6 @@ public:
|
||||||
u32 MasterBrightFactor;
|
u32 MasterBrightFactor;
|
||||||
|
|
||||||
u32 currLine;
|
u32 currLine;
|
||||||
u8 currBgNum;
|
|
||||||
u16 *currDst;
|
u16 *currDst;
|
||||||
|
|
||||||
bool need_update_winh[2];
|
bool need_update_winh[2];
|
||||||
|
@ -920,9 +938,9 @@ public:
|
||||||
bool GetLayerEnableState(const size_t layerIndex);
|
bool GetLayerEnableState(const size_t layerIndex);
|
||||||
void SetLayerEnableState(const size_t layerIndex, bool theState);
|
void SetLayerEnableState(const size_t layerIndex, bool theState);
|
||||||
|
|
||||||
template<bool BACKDROP, bool USECUSTOMVRAM, int FUNCNUM> FORCEINLINE void ____setFinalColorBck(const u16 color, const size_t srcX);
|
template<GPULayerID LAYERID, bool BACKDROP, int FUNCNUM, bool ISCUSTOMRENDERINGNEEDED, bool USECUSTOMVRAM> FORCEINLINE void ____setFinalColorBck(const u16 color, const size_t srcX);
|
||||||
template<bool MOSAIC, bool BACKDROP> FORCEINLINE void __setFinalColorBck(u16 color, const size_t srcX, const bool opaque);
|
template<GPULayerID LAYERID, bool MOSAIC, bool BACKDROP, int FUNCNUM, bool ISCUSTOMRENDERINGNEEDED, bool USECUSTOMVRAM> FORCEINLINE void ___setFinalColorBck(u16 color, const size_t srcX, const bool opaque);
|
||||||
template<bool MOSAIC, bool BACKDROP, bool USECUSTOMVRAM, int FUNCNUM> FORCEINLINE void ___setFinalColorBck(u16 color, const size_t srcX, const bool opaque);
|
template<GPULayerID LAYERID, bool MOSAIC, bool BACKDROP, bool ISCUSTOMRENDERINGNEEDED> FORCEINLINE void __setFinalColorBck(u16 color, const size_t srcX, const bool opaque);
|
||||||
|
|
||||||
void UpdateVRAM3DUsageProperties_BGLayer(const size_t bankIndex, VRAM3DUsageProperties &outProperty);
|
void UpdateVRAM3DUsageProperties_BGLayer(const size_t bankIndex, VRAM3DUsageProperties &outProperty);
|
||||||
void UpdateVRAM3DUsageProperties_OBJLayer(const size_t bankIndex, VRAM3DUsageProperties &outProperty);
|
void UpdateVRAM3DUsageProperties_OBJLayer(const size_t bankIndex, VRAM3DUsageProperties &outProperty);
|
||||||
|
@ -933,11 +951,12 @@ public:
|
||||||
void refreshAffineStartRegs(const int num, const int xy);
|
void refreshAffineStartRegs(const int num, const int xy);
|
||||||
|
|
||||||
void SpriteRender(u16 *dst, u8 *dst_alpha, u8 *typeTab, u8 *prioTab);
|
void SpriteRender(u16 *dst, u8 *dst_alpha, u8 *typeTab, u8 *prioTab);
|
||||||
|
void ModeRenderDebug(const GPULayerID layerID);
|
||||||
void HandleDisplayModeOff(u16 *dstLine, const size_t l, const size_t dstLineWidth, const size_t dstLineCount);
|
|
||||||
void HandleDisplayModeNormal(u16 *dstLine, const size_t l, const size_t dstLineWidth, const size_t dstLineCount);
|
template<bool ISCUSTOMRENDERINGNEEDED> void HandleDisplayModeOff(u16 *dstLine, const size_t l, const size_t dstLineWidth, const size_t dstLineCount);
|
||||||
void HandleDisplayModeVRAM(u16 *dstLine, const size_t l, const size_t dstLineWidth, const size_t dstLineCount);
|
template<bool ISCUSTOMRENDERINGNEEDED> void HandleDisplayModeNormal(u16 *dstLine, const size_t l, const size_t dstLineWidth, const size_t dstLineCount);
|
||||||
void HandleDisplayModeMainMemory(u16 *dstLine, const size_t l, const size_t dstLineWidth, const size_t dstLineCount);
|
template<bool ISCUSTOMRENDERINGNEEDED> void HandleDisplayModeVRAM(u16 *dstLine, const size_t l, const size_t dstLineWidth, const size_t dstLineCount);
|
||||||
|
template<bool ISCUSTOMRENDERINGNEEDED> void HandleDisplayModeMainMemory(u16 *dstLine, const size_t l, const size_t dstLineWidth, const size_t dstLineCount);
|
||||||
|
|
||||||
u32 GetHOFS(const size_t bg) const;
|
u32 GetHOFS(const size_t bg) const;
|
||||||
u32 GetVOFS(const size_t bg) const;
|
u32 GetVOFS(const size_t bg) const;
|
||||||
|
@ -983,12 +1002,68 @@ public:
|
||||||
NDSDisplayID GetDisplayByID() const;
|
NDSDisplayID GetDisplayByID() const;
|
||||||
void SetDisplayByID(const NDSDisplayID theDisplayID);
|
void SetDisplayByID(const NDSDisplayID theDisplayID);
|
||||||
|
|
||||||
void SetCustomFramebufferSize(size_t w, size_t h);
|
GPUEngineID GetEngineID() const;
|
||||||
|
|
||||||
|
virtual void SetCustomFramebufferSize(size_t w, size_t h);
|
||||||
void BlitNativeToCustomFramebuffer();
|
void BlitNativeToCustomFramebuffer();
|
||||||
|
|
||||||
void REG_DISPx_pack_test();
|
void REG_DISPx_pack_test();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class GPUEngineA : public GPUEngineBase
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
FragmentColor *_3DFramebufferRGBA6665;
|
||||||
|
u16 *_3DFramebufferRGBA5551;
|
||||||
|
|
||||||
|
template<bool ISCUSTOMRENDERINGNEEDED> void _RenderLine_Layer(const u16 l, u16 *dstLine, const size_t dstLineWidth, const size_t dstLineCount);
|
||||||
|
template<bool ISCUSTOMRENDERINGNEEDED, size_t CAPTURELENGTH> void _RenderLine_DisplayCapture(const u16 l);
|
||||||
|
void _RenderLine_DispCapture_FIFOToBuffer(u16 *fifoLineBuffer);
|
||||||
|
|
||||||
|
template<int SOURCESWITCH, size_t CAPTURELENGTH, bool CAPTUREFROMNATIVESRC, bool CAPTURETONATIVEDST>
|
||||||
|
void _RenderLine_DispCapture_Copy(const u16 *__restrict src, u16 *__restrict dst, const size_t captureLengthExt, const size_t captureLineCount);
|
||||||
|
|
||||||
|
u16 _RenderLine_DispCapture_BlendFunc(const u16 srcA, const u16 srcB, const u8 blendEVA, const u8 blendEVB);
|
||||||
|
|
||||||
|
#ifdef ENABLE_SSE2
|
||||||
|
__m128i _RenderLine_DispCapture_BlendFunc_SSE2(__m128i &srcA, __m128i &srcB, const __m128i &blendEVA, const __m128i &blendEVB);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template<bool CAPTUREFROMNATIVESRCA, bool CAPTUREFROMNATIVESRCB>
|
||||||
|
void _RenderLine_DispCapture_BlendToCustomDstBuffer(const u16 *__restrict srcA, const u16 *__restrict srcB, u16 *__restrict dst, const u8 blendEVA, const u8 blendEVB, const size_t length, size_t l);
|
||||||
|
|
||||||
|
template<size_t CAPTURELENGTH, bool CAPTUREFROMNATIVESRCA, bool CAPTUREFROMNATIVESRCB, bool CAPTURETONATIVEDST>
|
||||||
|
void _RenderLine_DispCapture_Blend(const u16 *__restrict srcA, const u16 *__restrict srcB, u16 *__restrict dst, const size_t captureLengthExt, const size_t l);
|
||||||
|
|
||||||
|
public:
|
||||||
|
DISPCAPCNT dispCapCnt;
|
||||||
|
|
||||||
|
GPUEngineA();
|
||||||
|
~GPUEngineA();
|
||||||
|
|
||||||
|
virtual void Reset();
|
||||||
|
void SetDISPCAPCNT(u32 val);
|
||||||
|
GPUDisplayMode GetDisplayMode() const;
|
||||||
|
u8 GetVRAMBlock() const;
|
||||||
|
FragmentColor* Get3DFramebufferRGBA6665() const;
|
||||||
|
u16* Get3DFramebufferRGBA5551() const;
|
||||||
|
virtual void SetCustomFramebufferSize(size_t w, size_t h);
|
||||||
|
|
||||||
|
template<bool ISCUSTOMRENDERINGNEEDED> void RenderLine(const u16 l, bool skip);
|
||||||
|
};
|
||||||
|
|
||||||
|
class GPUEngineB : public GPUEngineBase
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
template<bool ISCUSTOMRENDERINGNEEDED> void _RenderLine_Layer(const u16 l, u16 *dstLine, const size_t dstLineWidth, const size_t dstLineCount);
|
||||||
|
|
||||||
|
public:
|
||||||
|
GPUEngineB();
|
||||||
|
|
||||||
|
virtual void Reset();
|
||||||
|
template<bool ISCUSTOMRENDERINGNEEDED> void RenderLine(const u16 l, bool skip);
|
||||||
|
};
|
||||||
|
|
||||||
class NDSDisplay
|
class NDSDisplay
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -1003,15 +1078,15 @@ public:
|
||||||
GPUEngineBase* GetEngine();
|
GPUEngineBase* GetEngine();
|
||||||
void SetEngine(GPUEngineBase *theEngine);
|
void SetEngine(GPUEngineBase *theEngine);
|
||||||
|
|
||||||
GPUCoreID GetEngineID();
|
GPUEngineID GetEngineID();
|
||||||
void SetEngineByID(const GPUCoreID theID);
|
void SetEngineByID(const GPUEngineID theID);
|
||||||
};
|
};
|
||||||
|
|
||||||
class GPUSubsystem
|
class GPUSubsystem
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
GPUEngineBase *_engineMain;
|
GPUEngineA *_engineMain;
|
||||||
GPUEngineBase *_engineSub;
|
GPUEngineB *_engineSub;
|
||||||
NDSDisplay *_displayMain;
|
NDSDisplay *_displayMain;
|
||||||
NDSDisplay *_displayTouch;
|
NDSDisplay *_displayTouch;
|
||||||
|
|
||||||
|
@ -1034,8 +1109,8 @@ public:
|
||||||
const NDSDisplayInfo& GetDisplayInfo(); // Frontends need to call this whenever they need to read the video buffers from the emulator core
|
const NDSDisplayInfo& GetDisplayInfo(); // Frontends need to call this whenever they need to read the video buffers from the emulator core
|
||||||
void SetDisplayDidCustomRender(NDSDisplayID displayID, bool theState);
|
void SetDisplayDidCustomRender(NDSDisplayID displayID, bool theState);
|
||||||
|
|
||||||
GPUEngineBase* GetEngineMain();
|
GPUEngineA* GetEngineMain();
|
||||||
GPUEngineBase* GetEngineSub();
|
GPUEngineB* GetEngineSub();
|
||||||
NDSDisplay* GetDisplayMain();
|
NDSDisplay* GetDisplayMain();
|
||||||
NDSDisplay* GetDisplayTouch();
|
NDSDisplay* GetDisplayTouch();
|
||||||
|
|
||||||
|
|
|
@ -1848,14 +1848,14 @@ static void writereg_POWCNT1(const int size, const u32 adr, const u32 val) {
|
||||||
if(nds.power1.dispswap)
|
if(nds.power1.dispswap)
|
||||||
{
|
{
|
||||||
//printf("Main core on top (vcount=%d)\n",nds.VCount);
|
//printf("Main core on top (vcount=%d)\n",nds.VCount);
|
||||||
GPU->GetDisplayMain()->SetEngineByID(GPUCOREID_MAIN);
|
GPU->GetDisplayMain()->SetEngineByID(GPUEngineID_Main);
|
||||||
GPU->GetDisplayTouch()->SetEngineByID(GPUCOREID_SUB);
|
GPU->GetDisplayTouch()->SetEngineByID(GPUEngineID_Sub);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//printf("Main core on bottom (vcount=%d)\n",nds.VCount);
|
//printf("Main core on bottom (vcount=%d)\n",nds.VCount);
|
||||||
GPU->GetDisplayMain()->SetEngineByID(GPUCOREID_SUB);
|
GPU->GetDisplayMain()->SetEngineByID(GPUEngineID_Sub);
|
||||||
GPU->GetDisplayTouch()->SetEngineByID(GPUCOREID_MAIN);
|
GPU->GetDisplayTouch()->SetEngineByID(GPUEngineID_Main);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3286,8 +3286,8 @@ void FASTCALL _MMU_ARM9_write08(u32 adr, u8 val)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GPUEngineBase *mainEngine = GPU->GetEngineMain();
|
GPUEngineA *mainEngine = GPU->GetEngineMain();
|
||||||
GPUEngineBase *subEngine = GPU->GetEngineSub();
|
GPUEngineB *subEngine = GPU->GetEngineSub();
|
||||||
|
|
||||||
switch(adr)
|
switch(adr)
|
||||||
{
|
{
|
||||||
|
@ -3573,8 +3573,8 @@ void FASTCALL _MMU_ARM9_write16(u32 adr, u16 val)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GPUEngineBase *mainEngine = GPU->GetEngineMain();
|
GPUEngineA *mainEngine = GPU->GetEngineMain();
|
||||||
GPUEngineBase *subEngine = GPU->GetEngineSub();
|
GPUEngineB *subEngine = GPU->GetEngineSub();
|
||||||
|
|
||||||
// Address is an IO register
|
// Address is an IO register
|
||||||
switch(adr)
|
switch(adr)
|
||||||
|
@ -4091,8 +4091,8 @@ void FASTCALL _MMU_ARM9_write32(u32 adr, u32 val)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GPUEngineBase *mainEngine = GPU->GetEngineMain();
|
GPUEngineA *mainEngine = GPU->GetEngineMain();
|
||||||
GPUEngineBase *subEngine = GPU->GetEngineSub();
|
GPUEngineB *subEngine = GPU->GetEngineSub();
|
||||||
|
|
||||||
switch(adr)
|
switch(adr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -794,7 +794,7 @@ public:
|
||||||
}
|
}
|
||||||
void Advance()
|
void Advance()
|
||||||
{
|
{
|
||||||
const GPUEngineBase *mainEngine = GPU->GetEngineMain();
|
const GPUEngineA *mainEngine = GPU->GetEngineMain();
|
||||||
bool capturing = (mainEngine->dispCapCnt.enabled || (mainEngine->dispCapCnt.val & 0x80000000));
|
bool capturing = (mainEngine->dispCapCnt.enabled || (mainEngine->dispCapCnt.val & 0x80000000));
|
||||||
|
|
||||||
if(capturing && consecutiveNonCaptures > 30)
|
if(capturing && consecutiveNonCaptures > 30)
|
||||||
|
@ -2899,15 +2899,15 @@ void NDS_suspendProcessingInput(bool suspend)
|
||||||
|
|
||||||
void NDS_swapScreen()
|
void NDS_swapScreen()
|
||||||
{
|
{
|
||||||
if (GPU->GetDisplayMain()->GetEngineID() == GPUCOREID_MAIN)
|
if (GPU->GetDisplayMain()->GetEngineID() == GPUEngineID_Main)
|
||||||
{
|
{
|
||||||
GPU->GetDisplayMain()->SetEngineByID(GPUCOREID_SUB);
|
GPU->GetDisplayMain()->SetEngineByID(GPUEngineID_Sub);
|
||||||
GPU->GetDisplayTouch()->SetEngineByID(GPUCOREID_MAIN);
|
GPU->GetDisplayTouch()->SetEngineByID(GPUEngineID_Main);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GPU->GetDisplayMain()->SetEngineByID(GPUCOREID_MAIN);
|
GPU->GetDisplayMain()->SetEngineByID(GPUEngineID_Main);
|
||||||
GPU->GetDisplayTouch()->SetEngineByID(GPUCOREID_SUB);
|
GPU->GetDisplayTouch()->SetEngineByID(GPUEngineID_Sub);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2744,7 +2744,7 @@ Render3DError OpenGLRenderer_1_2::RenderFinish()
|
||||||
|
|
||||||
ENDGL();
|
ENDGL();
|
||||||
|
|
||||||
this->FlushFramebuffer(gfx3d_colorRGBA6665, gfx3d_colorRGBA5551);
|
this->FlushFramebuffer(GPU->GetEngineMain()->Get3DFramebufferRGBA6665(), GPU->GetEngineMain()->Get3DFramebufferRGBA5551());
|
||||||
this->_pixelReadNeedsFinish = false;
|
this->_pixelReadNeedsFinish = false;
|
||||||
|
|
||||||
return OGLERROR_NOERR;
|
return OGLERROR_NOERR;
|
||||||
|
@ -3311,7 +3311,7 @@ Render3DError OpenGLRenderer_1_5::RenderFinish()
|
||||||
|
|
||||||
ENDGL();
|
ENDGL();
|
||||||
|
|
||||||
this->FlushFramebuffer(gfx3d_colorRGBA6665, gfx3d_colorRGBA5551);
|
this->FlushFramebuffer(GPU->GetEngineMain()->Get3DFramebufferRGBA6665(), GPU->GetEngineMain()->Get3DFramebufferRGBA5551());
|
||||||
this->_pixelReadNeedsFinish = false;
|
this->_pixelReadNeedsFinish = false;
|
||||||
|
|
||||||
return OGLERROR_NOERR;
|
return OGLERROR_NOERR;
|
||||||
|
@ -4094,7 +4094,7 @@ Render3DError OpenGLRenderer_2_1::RenderFinish()
|
||||||
|
|
||||||
ENDGL();
|
ENDGL();
|
||||||
|
|
||||||
this->FlushFramebuffer(gfx3d_colorRGBA6665, gfx3d_colorRGBA5551);
|
this->FlushFramebuffer(GPU->GetEngineMain()->Get3DFramebufferRGBA6665(), GPU->GetEngineMain()->Get3DFramebufferRGBA5551());
|
||||||
this->_pixelReadNeedsFinish = false;
|
this->_pixelReadNeedsFinish = false;
|
||||||
|
|
||||||
return OGLERROR_NOERR;
|
return OGLERROR_NOERR;
|
||||||
|
|
|
@ -322,8 +322,8 @@ static float normalTable[1024];
|
||||||
#define fix10_2float(v) (((float)((s32)(v))) / (float)(1<<9))
|
#define fix10_2float(v) (((float)((s32)(v))) / (float)(1<<9))
|
||||||
|
|
||||||
// Color buffer that is filled by the 3D renderer and is read by the GPU engine.
|
// Color buffer that is filled by the 3D renderer and is read by the GPU engine.
|
||||||
FragmentColor *gfx3d_colorRGBA6665 = NULL;
|
static FragmentColor *_gfx3d_colorRGBA6665 = NULL;
|
||||||
u16 *gfx3d_colorRGBA5551 = NULL;
|
static u16 *_gfx3d_colorRGBA5551 = NULL;
|
||||||
|
|
||||||
// Matrix stack handling
|
// Matrix stack handling
|
||||||
CACHE_ALIGN MatrixStack mtxStack[4] = {
|
CACHE_ALIGN MatrixStack mtxStack[4] = {
|
||||||
|
@ -574,12 +574,6 @@ void gfx3d_deinit()
|
||||||
free(vertlists);
|
free(vertlists);
|
||||||
vertlists = NULL;
|
vertlists = NULL;
|
||||||
vertlist = NULL;
|
vertlist = NULL;
|
||||||
|
|
||||||
free_aligned(gfx3d_colorRGBA6665);
|
|
||||||
gfx3d_colorRGBA6665 = NULL;
|
|
||||||
|
|
||||||
free_aligned(gfx3d_colorRGBA5551);
|
|
||||||
gfx3d_colorRGBA5551 = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx3d_reset()
|
void gfx3d_reset()
|
||||||
|
@ -2325,7 +2319,7 @@ void gfx3d_VBlankEndSignal(bool skipFrame)
|
||||||
|
|
||||||
if (!CommonSettings.showGpu.main)
|
if (!CommonSettings.showGpu.main)
|
||||||
{
|
{
|
||||||
memset(gfx3d_colorRGBA6665, 0, GPU->GetCustomFramebufferWidth() * GPU->GetCustomFramebufferHeight() * sizeof(FragmentColor));
|
memset(_gfx3d_colorRGBA6665, 0, GPU->GetCustomFramebufferWidth() * GPU->GetCustomFramebufferHeight() * sizeof(FragmentColor));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2437,19 +2431,6 @@ void gfx3d_glGetLightColor(const size_t index, u32 &dst)
|
||||||
dst = lightColor[index];
|
dst = lightColor[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
const FragmentColor* gfx3d_GetLineDataRGBA6665(const size_t line)
|
|
||||||
{
|
|
||||||
CurrentRenderer->RenderFinish();
|
|
||||||
return (gfx3d_colorRGBA6665 + (line * GPU->GetCustomFramebufferWidth()));
|
|
||||||
}
|
|
||||||
|
|
||||||
const u16* gfx3d_GetLineDataRGBA5551(const size_t line)
|
|
||||||
{
|
|
||||||
CurrentRenderer->RenderFinish();
|
|
||||||
return (gfx3d_colorRGBA5551 + (line * GPU->GetCustomFramebufferWidth()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node17.html
|
//http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node17.html
|
||||||
//talks about the state required to process verts in quadlists etc. helpful ideas.
|
//talks about the state required to process verts in quadlists etc. helpful ideas.
|
||||||
//consider building a little state structure that looks exactly like this describes
|
//consider building a little state structure that looks exactly like this describes
|
||||||
|
@ -2536,10 +2517,16 @@ SFORMAT SF_GFX3D[]={
|
||||||
{ "GTVC", 4, 1, &tempVertInfo.count},
|
{ "GTVC", 4, 1, &tempVertInfo.count},
|
||||||
{ "GTVM", 4, 4, tempVertInfo.map},
|
{ "GTVM", 4, 4, tempVertInfo.map},
|
||||||
{ "GTVF", 4, 1, &tempVertInfo.first},
|
{ "GTVF", 4, 1, &tempVertInfo.first},
|
||||||
{ "G3CX", 1, 4*GPU_FRAMEBUFFER_NATIVE_WIDTH*GPU_FRAMEBUFFER_NATIVE_HEIGHT, gfx3d_colorRGBA6665},
|
{ "G3CX", 1, 4*GPU_FRAMEBUFFER_NATIVE_WIDTH*GPU_FRAMEBUFFER_NATIVE_HEIGHT, _gfx3d_colorRGBA6665},
|
||||||
{ 0 }
|
{ 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void gfx3d_Update3DFramebuffers(FragmentColor *framebufferRGBA6665, u16 *framebufferRGBA5551)
|
||||||
|
{
|
||||||
|
_gfx3d_colorRGBA6665 = framebufferRGBA6665;
|
||||||
|
_gfx3d_colorRGBA5551 = framebufferRGBA5551;
|
||||||
|
}
|
||||||
|
|
||||||
//-------------savestate
|
//-------------savestate
|
||||||
void gfx3d_savestate(EMUFILE* os)
|
void gfx3d_savestate(EMUFILE* os)
|
||||||
{
|
{
|
||||||
|
|
|
@ -740,10 +740,6 @@ extern CACHE_ALIGN const u8 material_3bit_to_5bit[8];
|
||||||
extern CACHE_ALIGN const u8 material_3bit_to_6bit[8];
|
extern CACHE_ALIGN const u8 material_3bit_to_6bit[8];
|
||||||
extern CACHE_ALIGN const u8 material_3bit_to_8bit[8];
|
extern CACHE_ALIGN const u8 material_3bit_to_8bit[8];
|
||||||
|
|
||||||
//these contain the 3d framebuffer converted into the most useful format
|
|
||||||
//they are stored here instead of in the renderers in order to consolidate the buffers
|
|
||||||
extern FragmentColor *gfx3d_colorRGBA6665;
|
|
||||||
extern u16 *gfx3d_colorRGBA5551;
|
|
||||||
extern BOOL isSwapBuffers;
|
extern BOOL isSwapBuffers;
|
||||||
|
|
||||||
int _hack_getMatrixStackLevel(int);
|
int _hack_getMatrixStackLevel(int);
|
||||||
|
@ -776,11 +772,9 @@ void gfx3d_glGetMatrix(const MatrixMode mode, int index, float *dst);
|
||||||
void gfx3d_glGetLightDirection(const size_t index, u32 &dst);
|
void gfx3d_glGetLightDirection(const size_t index, u32 &dst);
|
||||||
void gfx3d_glGetLightColor(const size_t index, u32 &dst);
|
void gfx3d_glGetLightColor(const size_t index, u32 &dst);
|
||||||
|
|
||||||
const FragmentColor* gfx3d_GetLineDataRGBA6665(const size_t line);
|
|
||||||
const u16* gfx3d_GetLineDataRGBA5551(const size_t line);
|
|
||||||
|
|
||||||
struct SFORMAT;
|
struct SFORMAT;
|
||||||
extern SFORMAT SF_GFX3D[];
|
extern SFORMAT SF_GFX3D[];
|
||||||
|
void gfx3d_Update3DFramebuffers(FragmentColor *framebufferRGBA6665, u16 *framebufferRGBA5551);
|
||||||
void gfx3d_savestate(EMUFILE* os);
|
void gfx3d_savestate(EMUFILE* os);
|
||||||
bool gfx3d_loadstate(EMUFILE* is, int size);
|
bool gfx3d_loadstate(EMUFILE* is, int size);
|
||||||
|
|
||||||
|
|
|
@ -301,7 +301,7 @@ gboolean screen (GtkWidget * widget, int viewportscreen) {
|
||||||
if (desmume_running()) {
|
if (desmume_running()) {
|
||||||
|
|
||||||
// master bright
|
// master bright
|
||||||
gpu = (screen) ? GPU->GetEngineSub() : GPU->GetEngineMain();
|
gpu = (screen) ? (GPUEngineBase *)GPU->GetEngineSub() : (GPUEngineBase *)GPU->GetEngineMain();
|
||||||
|
|
||||||
switch (gpu->MasterBrightMode)
|
switch (gpu->MasterBrightMode)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2228,7 +2228,7 @@ public:
|
||||||
char temp [256];
|
char temp [256];
|
||||||
sprintf(temp, " " /*"mismatch at "*/ "byte %d(0x%X at 0x%X): %d(0x%X) != %d(0x%X)\n", i, i, dst, *src,*src, *dst,*dst);
|
sprintf(temp, " " /*"mismatch at "*/ "byte %d(0x%X at 0x%X): %d(0x%X) != %d(0x%X)\n", i, i, dst, *src,*src, *dst,*dst);
|
||||||
|
|
||||||
if(ptr == GPU->GetNativeFramebuffer() || ptr == GPU->GetCustomFramebuffer() || ptr == gfx3d_colorRGBA6665) // ignore screen-only differences since frame skipping can cause them and it's probably ok
|
if(ptr == GPU->GetNativeFramebuffer() || ptr == GPU->GetCustomFramebuffer() || ptr == GPU->GetEngineMain()->Get3DFramebufferRGBA6665()) // ignore screen-only differences since frame skipping can cause them and it's probably ok
|
||||||
break;
|
break;
|
||||||
|
|
||||||
differences.push_back(temp); // <-- probably the best place for a breakpoint
|
differences.push_back(temp); // <-- probably the best place for a breakpoint
|
||||||
|
|
|
@ -1960,7 +1960,7 @@ Render3DError SoftRasterizerRenderer::EndRender(const u64 frameCount)
|
||||||
this->RenderEdgeMarkingAndFog(this->postprocessParam[0]);
|
this->RenderEdgeMarkingAndFog(this->postprocessParam[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->FlushFramebuffer(gfx3d_colorRGBA6665, gfx3d_colorRGBA5551);
|
this->FlushFramebuffer(GPU->GetEngineMain()->Get3DFramebufferRGBA6665(), GPU->GetEngineMain()->Get3DFramebufferRGBA5551());
|
||||||
}
|
}
|
||||||
|
|
||||||
return RENDER3DERROR_NOERR;
|
return RENDER3DERROR_NOERR;
|
||||||
|
@ -2003,7 +2003,7 @@ Render3DError SoftRasterizerRenderer::RenderFinish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this->FlushFramebuffer(gfx3d_colorRGBA6665, gfx3d_colorRGBA5551);
|
this->FlushFramebuffer(GPU->GetEngineMain()->Get3DFramebufferRGBA6665(), GPU->GetEngineMain()->Get3DFramebufferRGBA5551());
|
||||||
|
|
||||||
return RENDER3DERROR_NOERR;
|
return RENDER3DERROR_NOERR;
|
||||||
}
|
}
|
||||||
|
|
|
@ -420,7 +420,7 @@ Render3DError Render3D::Reset()
|
||||||
if (this->_framebufferColor != NULL)
|
if (this->_framebufferColor != NULL)
|
||||||
{
|
{
|
||||||
memset(this->_framebufferColor, 0, this->_framebufferColorSizeBytes);
|
memset(this->_framebufferColor, 0, this->_framebufferColorSizeBytes);
|
||||||
this->FlushFramebuffer(gfx3d_colorRGBA6665, gfx3d_colorRGBA5551);
|
this->FlushFramebuffer(GPU->GetEngineMain()->Get3DFramebufferRGBA6665(), GPU->GetEngineMain()->Get3DFramebufferRGBA5551());
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(this->clearImageColor16Buffer, 0, sizeof(this->clearImageColor16Buffer));
|
memset(this->clearImageColor16Buffer, 0, sizeof(this->clearImageColor16Buffer));
|
||||||
|
|
|
@ -816,7 +816,7 @@ void ToDSScreenRelativeCoords(s32& x, s32& y, int whichScreen)
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally, make it relative to the correct screen
|
// finally, make it relative to the correct screen
|
||||||
const bool isMainGPUFirst = (GPU->GetDisplayMain()->GetEngineID() == GPUCOREID_MAIN);
|
const bool isMainGPUFirst = (GPU->GetDisplayMain()->GetEngineID() == GPUEngineID_Main);
|
||||||
|
|
||||||
if (video.layout == 0 || video.layout == 2)
|
if (video.layout == 0 || video.layout == 2)
|
||||||
{
|
{
|
||||||
|
@ -1656,7 +1656,7 @@ static void OGL_DoDisplay()
|
||||||
|
|
||||||
|
|
||||||
RECT srcRects [2];
|
RECT srcRects [2];
|
||||||
const bool isMainGPUFirst = (GPU->GetDisplayMain()->GetEngineID() == GPUCOREID_MAIN);
|
const bool isMainGPUFirst = (GPU->GetDisplayMain()->GetEngineID() == GPUEngineID_Main);
|
||||||
|
|
||||||
if(video.swap == 0)
|
if(video.swap == 0)
|
||||||
{
|
{
|
||||||
|
@ -1774,7 +1774,7 @@ static void DD_DoDisplay()
|
||||||
|
|
||||||
RECT* dstRects [2] = {&MainScreenRect, &SubScreenRect};
|
RECT* dstRects [2] = {&MainScreenRect, &SubScreenRect};
|
||||||
RECT* srcRects [2];
|
RECT* srcRects [2];
|
||||||
const bool isMainGPUFirst = (GPU->GetDisplayMain()->GetEngineID() == GPUCOREID_MAIN);
|
const bool isMainGPUFirst = (GPU->GetDisplayMain()->GetEngineID() == GPUEngineID_Main);
|
||||||
|
|
||||||
if(video.swap == 0)
|
if(video.swap == 0)
|
||||||
{
|
{
|
||||||
|
@ -4383,7 +4383,7 @@ void SaveWindowPos(HWND hwnd)
|
||||||
|
|
||||||
static void TwiddleLayer(UINT ctlid, int core, int layer)
|
static void TwiddleLayer(UINT ctlid, int core, int layer)
|
||||||
{
|
{
|
||||||
GPUEngineBase *gpu = ((GPUCoreID)core == GPUCOREID_MAIN) ? GPU->GetEngineMain() : GPU->GetEngineSub();
|
GPUEngineBase *gpu = ((GPUEngineID)core == GPUEngineID_Main) ? (GPUEngineBase *)GPU->GetEngineMain() : (GPUEngineBase *)GPU->GetEngineSub();
|
||||||
|
|
||||||
const bool newLayerState = !CommonSettings.dispLayers[core][layer];
|
const bool newLayerState = !CommonSettings.dispLayers[core][layer];
|
||||||
gpu->SetLayerEnableState(layer, newLayerState);
|
gpu->SetLayerEnableState(layer, newLayerState);
|
||||||
|
@ -5139,7 +5139,7 @@ DOKEYDOWN:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const bool isMainGPUFirst = (GPU->GetDisplayMain()->GetEngineID() == GPUCOREID_MAIN);
|
const bool isMainGPUFirst = (GPU->GetDisplayMain()->GetEngineID() == GPUEngineID_Main);
|
||||||
if ((video.layout == 2) && ((video.swap == 0) || (video.swap == 2 && isMainGPUFirst) || (video.swap == 3 && !isMainGPUFirst))) return 0;
|
if ((video.layout == 2) && ((video.swap == 0) || (video.swap == 2 && isMainGPUFirst) || (video.swap == 3 && !isMainGPUFirst))) return 0;
|
||||||
|
|
||||||
ToDSScreenRelativeCoords(x,y,1);
|
ToDSScreenRelativeCoords(x,y,1);
|
||||||
|
|
|
@ -35,8 +35,8 @@ struct mapview_struct
|
||||||
u32 autoup_secs;
|
u32 autoup_secs;
|
||||||
bool autoup;
|
bool autoup;
|
||||||
|
|
||||||
u8 map;
|
GPULayerID layerID;
|
||||||
u16 lcd;
|
GPUEngineID engineID;
|
||||||
u16 bitmap[1024*1024];
|
u16 bitmap[1024*1024];
|
||||||
bool clear;
|
bool clear;
|
||||||
|
|
||||||
|
@ -44,26 +44,23 @@ struct mapview_struct
|
||||||
{
|
{
|
||||||
//we're going to make a copy of the gpu so that we don't wreck affine scroll params
|
//we're going to make a copy of the gpu so that we don't wreck affine scroll params
|
||||||
//hopefully we won't mess up anything else
|
//hopefully we won't mess up anything else
|
||||||
GPUEngineBase *realGpu;
|
GPUEngineBase *realGpu = (engineID == GPUEngineID_Main) ? (GPUEngineBase *)GPU->GetEngineMain() : (GPUEngineBase *)GPU->GetEngineSub();
|
||||||
if(lcd) realGpu = GPU->GetEngineSub();
|
|
||||||
else realGpu = GPU->GetEngineMain();
|
|
||||||
GPUEngineBase &gpu = *realGpu;
|
GPUEngineBase &gpu = *realGpu;
|
||||||
|
|
||||||
//forgive the gyrations, some of this junk in here is to remind us of gyrations we might have to go
|
//forgive the gyrations, some of this junk in here is to remind us of gyrations we might have to go
|
||||||
//through to avoid breaking the gpu struct
|
//through to avoid breaking the gpu struct
|
||||||
|
|
||||||
gpu.currBgNum = map;
|
|
||||||
gpu.debug = true;
|
gpu.debug = true;
|
||||||
int temp = gpu.GetFinalColorBckFuncID();
|
int temp = gpu.GetFinalColorBckFuncID();
|
||||||
gpu.SetFinalColorBckFuncID(0); //hax... why arent we copying gpu now?? i cant remember
|
gpu.SetFinalColorBckFuncID(0); //hax... why arent we copying gpu now?? i cant remember
|
||||||
|
|
||||||
memset(bitmap,0,sizeof(bitmap));
|
memset(bitmap,0,sizeof(bitmap));
|
||||||
|
|
||||||
for(u32 i = 0; i < gpu.BGSize[map][1]; ++i)
|
for(u32 i = 0; i < gpu.BGSize[layerID][1]; ++i)
|
||||||
{
|
{
|
||||||
gpu.currDst = bitmap + i*gpu.BGSize[map][0];
|
gpu.currDst = bitmap + i*gpu.BGSize[layerID][0];
|
||||||
gpu.currLine = i;
|
gpu.currLine = i;
|
||||||
gpu.ModeRender<false>(map);
|
gpu.ModeRenderDebug(layerID);
|
||||||
}
|
}
|
||||||
|
|
||||||
gpu.debug = false;
|
gpu.debug = false;
|
||||||
|
@ -81,8 +78,8 @@ LRESULT MapView_OnPaint(mapview_struct * win, HWND hwnd, WPARAM wParam, LPARAM l
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
||||||
char text[80];
|
char text[80];
|
||||||
u32 dispcnt = ((volatile u32 *)MMU.ARM9_REG)[(win->lcd*0x400)];
|
u32 dispcnt = ((volatile u32 *)MMU.ARM9_REG)[(win->engineID*0x400)];
|
||||||
u32 bgcnt = ((volatile u16 *)MMU.ARM9_REG)[(8 + (win->map<<1) + (win->lcd*0x1000))>>1];
|
u32 bgcnt = ((volatile u16 *)MMU.ARM9_REG)[(8 + (win->layerID<<1) + (win->engineID*0x1000))>>1];
|
||||||
BITMAPV4HEADER bmi;
|
BITMAPV4HEADER bmi;
|
||||||
u16 lg;
|
u16 lg;
|
||||||
u16 ht;
|
u16 ht;
|
||||||
|
@ -98,15 +95,15 @@ LRESULT MapView_OnPaint(mapview_struct * win, HWND hwnd, WPARAM wParam, LPARAM l
|
||||||
bmi.bV4GreenMask = 0x03E0;
|
bmi.bV4GreenMask = 0x03E0;
|
||||||
bmi.bV4BlueMask = 0x7C00;
|
bmi.bV4BlueMask = 0x7C00;
|
||||||
|
|
||||||
if(win->lcd)
|
if(win->engineID == GPUEngineID_Main)
|
||||||
{
|
{
|
||||||
lg = GPU->GetEngineSub()->BGSize[win->map][0];
|
lg = GPU->GetEngineMain()->BGSize[win->layerID][0];
|
||||||
ht = GPU->GetEngineSub()->BGSize[win->map][1];
|
ht = GPU->GetEngineMain()->BGSize[win->layerID][1];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lg = GPU->GetEngineMain()->BGSize[win->map][0];
|
lg = GPU->GetEngineSub()->BGSize[win->layerID][0];
|
||||||
ht = GPU->GetEngineMain()->BGSize[win->map][1];
|
ht = GPU->GetEngineSub()->BGSize[win->layerID][1];
|
||||||
}
|
}
|
||||||
bmi.bV4Width = lg;
|
bmi.bV4Width = lg;
|
||||||
bmi.bV4Height = -ht;
|
bmi.bV4Height = -ht;
|
||||||
|
@ -124,16 +121,16 @@ LRESULT MapView_OnPaint(mapview_struct * win, HWND hwnd, WPARAM wParam, LPARAM l
|
||||||
sprintf(text, "normal 256");
|
sprintf(text, "normal 256");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch(win->map)
|
switch(win->layerID)
|
||||||
{
|
{
|
||||||
case 0 :
|
case GPULayerID_BG0 :
|
||||||
sprintf(text, "extended slot %d", (bgcnt&(1<<13))?2:0);
|
sprintf(text, "extended slot %d", (bgcnt&(1<<13))?2:0);
|
||||||
break;
|
break;
|
||||||
case 1 :
|
case GPULayerID_BG1 :
|
||||||
sprintf(text, "extended slot %d", (bgcnt&(1<<13))?3:1);
|
sprintf(text, "extended slot %d", (bgcnt&(1<<13))?3:1);
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
sprintf(text, "extended slot %d", GPU->GetEngineMain()->BGExtPalSlot[win->map]);
|
sprintf(text, "extended slot %d", GPU->GetEngineMain()->BGExtPalSlot[win->layerID]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,19 +141,19 @@ LRESULT MapView_OnPaint(mapview_struct * win, HWND hwnd, WPARAM wParam, LPARAM l
|
||||||
SetWindowText(GetDlgItem(hwnd, IDC_PRIO), text);
|
SetWindowText(GetDlgItem(hwnd, IDC_PRIO), text);
|
||||||
|
|
||||||
|
|
||||||
if((dispcnt>>8>>win->map)&1)
|
if((dispcnt>>8>>win->layerID)&1)
|
||||||
SetWindowText(GetDlgItem(hwnd, IDC_VISIBLE), "true");
|
SetWindowText(GetDlgItem(hwnd, IDC_VISIBLE), "true");
|
||||||
else
|
else
|
||||||
SetWindowText(GetDlgItem(hwnd, IDC_VISIBLE), "false");
|
SetWindowText(GetDlgItem(hwnd, IDC_VISIBLE), "false");
|
||||||
|
|
||||||
sprintf(text, "0x%08X", (int)(0x6000000 + ((bgcnt>>2)&0xF)*0x4000 + win->lcd*0x200000 +((dispcnt>>24)&7)*0x10000));
|
sprintf(text, "0x%08X", (int)(0x6000000 + ((bgcnt>>2)&0xF)*0x4000 + win->engineID*0x200000 +((dispcnt>>24)&7)*0x10000));
|
||||||
SetWindowText(GetDlgItem(hwnd, IDC_CHAR), text);
|
SetWindowText(GetDlgItem(hwnd, IDC_CHAR), text);
|
||||||
|
|
||||||
sprintf(text, "0x%08X", (int)(0x6000000 + 0x800*((bgcnt>>8)&0x1F) + win->lcd*0x200000 + ((dispcnt>>27)&7)*0x10000));
|
sprintf(text, "0x%08X", (int)(0x6000000 + 0x800*((bgcnt>>8)&0x1F) + win->engineID*0x200000 + ((dispcnt>>27)&7)*0x10000));
|
||||||
SetWindowText(GetDlgItem(hwnd, IDC_SCR), text);
|
SetWindowText(GetDlgItem(hwnd, IDC_SCR), text);
|
||||||
|
|
||||||
//sprintf(text, "%d x %d", GPU->GetEngineMain()->BGPA[win->map], GPU->GetEngineMain()->BGPB[win->map]);
|
//sprintf(text, "%d x %d", GPU->GetEngineMain()->BGPA[win->map], GPU->GetEngineMain()->BGPB[win->map]);
|
||||||
sprintf(text, "%d x %d", (int)GPU->GetEngineMain()->BGSize[win->map][0], (int)GPU->GetEngineMain()->BGSize[win->map][1]);
|
sprintf(text, "%d x %d", (int)GPU->GetEngineMain()->BGSize[win->layerID][0], (int)GPU->GetEngineMain()->BGSize[win->layerID][1]);
|
||||||
SetWindowText(GetDlgItem(hwnd, IDC_MSIZE), text);
|
SetWindowText(GetDlgItem(hwnd, IDC_MSIZE), text);
|
||||||
|
|
||||||
//if (win->map==2) {
|
//if (win->map==2) {
|
||||||
|
@ -206,8 +203,8 @@ BOOL CALLBACK ViewMapsProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara
|
||||||
memset(MapView, 0, sizeof(MapView));
|
memset(MapView, 0, sizeof(MapView));
|
||||||
MapView->clear = true;
|
MapView->clear = true;
|
||||||
MapView->autoup_secs = 1;
|
MapView->autoup_secs = 1;
|
||||||
MapView->map = 0;
|
MapView->layerID = GPULayerID_BG0;
|
||||||
MapView->lcd = 0;
|
MapView->engineID = GPUEngineID_Main;
|
||||||
SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN),
|
SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN),
|
||||||
UDM_SETRANGE, 0, MAKELONG(99, 1));
|
UDM_SETRANGE, 0, MAKELONG(99, 1));
|
||||||
SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN),
|
SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN),
|
||||||
|
@ -295,15 +292,15 @@ BOOL CALLBACK ViewMapsProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara
|
||||||
case 1 :
|
case 1 :
|
||||||
case 2 :
|
case 2 :
|
||||||
case 3 :
|
case 3 :
|
||||||
MapView->map = sel;
|
MapView->layerID = (GPULayerID)sel;
|
||||||
MapView->lcd = 0;
|
MapView->engineID = GPUEngineID_Main;
|
||||||
break;
|
break;
|
||||||
case 4 :
|
case 4 :
|
||||||
case 5 :
|
case 5 :
|
||||||
case 6 :
|
case 6 :
|
||||||
case 7 :
|
case 7 :
|
||||||
MapView->map = sel-4;
|
MapView->layerID = (GPULayerID)(sel - 4);
|
||||||
MapView->lcd = 1;
|
MapView->engineID = GPUEngineID_Sub;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue