revert last 2 commits
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3533 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
5bcf69cbd6
commit
6b2855de5e
|
@ -20,13 +20,13 @@
|
||||||
// The plugins has to define these functions
|
// The plugins has to define these functions
|
||||||
// ------------------------------------------
|
// ------------------------------------------
|
||||||
|
|
||||||
#ifndef _SUFUNCTIONS_H_
|
#ifndef _BPFUNCTIONS_H_
|
||||||
#define _SUFUNCTIONS_H_
|
#define _BPFUNCTIONS_H_
|
||||||
|
|
||||||
#include "SUMemory.h"
|
#include "BPMemory.h"
|
||||||
#include "VideoCommon.h"
|
#include "VideoCommon.h"
|
||||||
|
|
||||||
namespace SUFunctions
|
namespace BPFunctions
|
||||||
{
|
{
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -37,24 +37,24 @@ enum
|
||||||
};
|
};
|
||||||
|
|
||||||
void FlushPipeline();
|
void FlushPipeline();
|
||||||
void SetGenerationMode(const BPCommand &bp);
|
void SetGenerationMode(const Bypass &bp);
|
||||||
void SetScissor(const BPCommand &bp);
|
void SetScissor(const Bypass &bp);
|
||||||
void SetLineWidth(const BPCommand &bp);
|
void SetLineWidth(const Bypass &bp);
|
||||||
void SetDepthMode(const BPCommand &bp);
|
void SetDepthMode(const Bypass &bp);
|
||||||
void SetBlendMode(const BPCommand &bp);
|
void SetBlendMode(const Bypass &bp);
|
||||||
void SetDitherMode(const BPCommand &bp);
|
void SetDitherMode(const Bypass &bp);
|
||||||
void SetLogicOpMode(const BPCommand &bp);
|
void SetLogicOpMode(const Bypass &bp);
|
||||||
void SetColorMask(const BPCommand &bp);
|
void SetColorMask(const Bypass &bp);
|
||||||
float GetRendererTargetScaleX();
|
float GetRendererTargetScaleX();
|
||||||
float GetRendererTargetScaleY();
|
float GetRendererTargetScaleY();
|
||||||
void CopyEFB(const BPCommand &bp, const TRectangle &rc, const u32 &address, const bool &fromZBuffer, const bool &isIntensityFmt, const u32 ©fmt, const bool &scaleByHalf);
|
void CopyEFB(const Bypass &bp, const TRectangle &rc, const u32 &address, const bool &fromZBuffer, const bool &isIntensityFmt, const u32 ©fmt, const bool &scaleByHalf);
|
||||||
void RenderToXFB(const BPCommand &bp, const TRectangle &multirc, const float &yScale, const float &xfbLines, u8* pXFB, const u32 &dstWidth, const u32 &dstHeight);
|
void RenderToXFB(const Bypass &bp, const TRectangle &multirc, const float &yScale, const float &xfbLines, u8* pXFB, const u32 &dstWidth, const u32 &dstHeight);
|
||||||
void ClearScreen(const BPCommand &bp, const TRectangle &multirc);
|
void ClearScreen(const Bypass &bp, const TRectangle &multirc);
|
||||||
void RestoreRenderState(const BPCommand &bp);
|
void RestoreRenderState(const Bypass &bp);
|
||||||
u8 *GetPointer(const u32 &address);
|
u8 *GetPointer(const u32 &address);
|
||||||
bool GetConfig(const int &type);
|
bool GetConfig(const int &type);
|
||||||
void SetSamplerState(const BPCommand &bp);
|
void SetSamplerState(const Bypass &bp);
|
||||||
void SetInterlacingMode(const BPCommand &bp);
|
void SetInterlacingMode(const Bypass &bp);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _SUFUNCTIONS_H_
|
#endif // _BPFUNCTIONS_H_
|
|
@ -17,36 +17,36 @@
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
|
||||||
#include "SUMemory.h"
|
#include "BPMemory.h"
|
||||||
|
|
||||||
// SU state
|
//BP state
|
||||||
// STATE_TO_SAVE
|
// STATE_TO_SAVE
|
||||||
SUMemory sumem;
|
BPMemory bpmem;
|
||||||
|
|
||||||
// The plugin must implement this.
|
// The plugin must implement this.
|
||||||
void SUWritten(const BPCommand& bp);
|
void BPWritten(const Bypass& bp);
|
||||||
|
|
||||||
// Call browser: OpcodeDecoding.cpp ExecuteDisplayList > Decode() > LoadSUReg()
|
// Call browser: OpcodeDecoding.cpp ExecuteDisplayList > Decode() > LoadBPReg()
|
||||||
void LoadSUReg(u32 value0)
|
void LoadBPReg(u32 value0)
|
||||||
{
|
{
|
||||||
//handle the mask register
|
//handle the mask register
|
||||||
int opcode = value0 >> 24;
|
int opcode = value0 >> 24;
|
||||||
int oldval = ((u32*)&sumem)[opcode];
|
int oldval = ((u32*)&bpmem)[opcode];
|
||||||
int newval = (oldval & ~sumem.suMask) | (value0 & sumem.suMask);
|
int newval = (oldval & ~bpmem.bpMask) | (value0 & bpmem.bpMask);
|
||||||
int changes = (oldval ^ newval) & 0xFFFFFF;
|
int changes = (oldval ^ newval) & 0xFFFFFF;
|
||||||
|
|
||||||
BPCommand bp = {opcode, changes, newval};
|
Bypass bp = {opcode, changes, newval};
|
||||||
|
|
||||||
//reset the mask register
|
//reset the mask register
|
||||||
if (opcode != 0xFE)
|
if (opcode != 0xFE)
|
||||||
sumem.suMask = 0xFFFFFF;
|
bpmem.bpMask = 0xFFFFFF;
|
||||||
|
|
||||||
SUWritten(bp);
|
BPWritten(bp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when loading a saved state.
|
// Called when loading a saved state.
|
||||||
// Needs more testing though.
|
// Needs more testing though.
|
||||||
void SUReload()
|
void BPReload()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 254; i++)
|
for (int i = 0; i < 254; i++)
|
||||||
{
|
{
|
||||||
|
@ -56,13 +56,13 @@ void SUReload()
|
||||||
case 0x52:
|
case 0x52:
|
||||||
case 0x65:
|
case 0x65:
|
||||||
case 0x67: // set gp metric?
|
case 0x67: // set gp metric?
|
||||||
case SUMEM_PE_TOKEN_ID:
|
case BPMEM_PE_TOKEN_ID:
|
||||||
case SUMEM_PE_TOKEN_INT_ID:
|
case BPMEM_PE_TOKEN_INT_ID:
|
||||||
// Cases in which we DON'T want to reload the BP
|
// Cases in which we DON'T want to reload the BP
|
||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
BPCommand bp = {i, 0xFFFFFF, ((u32*)&sumem)[i]};
|
Bypass bp = {i, 0xFFFFFF, ((u32*)&bpmem)[i]};
|
||||||
SUWritten(bp);
|
BPWritten(bp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (C) 2003-2009 Dolphin Project.
|
// Copyright (C) 2003-2008 Dolphin Project.
|
||||||
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
@ -15,94 +15,94 @@
|
||||||
// Official SVN repository and contact information can be found at
|
// Official SVN repository and contact information can be found at
|
||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
#ifndef _SUMEMORY_H
|
#ifndef _BPMEMORY_H
|
||||||
#define _SUMEMORY_H
|
#define _BPMEMORY_H
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
|
||||||
#pragma pack(4)
|
#pragma pack(4)
|
||||||
|
|
||||||
#define SUMEM_GENMODE 0x00
|
#define BPMEM_GENMODE 0x00
|
||||||
#define SUMEM_DISPLAYCOPYFILER 0x01 // 0x01 + 4
|
#define BPMEM_DISPLAYCOPYFILER 0x01 // 0x01 + 4
|
||||||
#define SUMEM_IND_MTXA 0x06 // 0x06 + (3 * 3)
|
#define BPMEM_IND_MTXA 0x06 // 0x06 + (3 * 3)
|
||||||
#define SUMEM_IND_MTXB 0x07 // 0x07 + (3 * 3)
|
#define BPMEM_IND_MTXB 0x07 // 0x07 + (3 * 3)
|
||||||
#define SUMEM_IND_MTXC 0x08 // 0x08 + (3 * 3)
|
#define BPMEM_IND_MTXC 0x08 // 0x08 + (3 * 3)
|
||||||
#define SUMEM_IND_IMASK 0x0F
|
#define BPMEM_IND_IMASK 0x0F
|
||||||
#define SUMEM_IND_CMD 0x10 // 0x10 + 16
|
#define BPMEM_IND_CMD 0x10 // 0x10 + 16
|
||||||
#define SUMEM_SCISSORTL 0x20
|
#define BPMEM_SCISSORTL 0x20
|
||||||
#define SUMEM_SCISSORBR 0x21
|
#define BPMEM_SCISSORBR 0x21
|
||||||
#define SUMEM_LINEPTWIDTH 0x22
|
#define BPMEM_LINEPTWIDTH 0x22
|
||||||
#define SUMEM_SU_COUNTER 0x23
|
#define BPMEM_SU_COUNTER 0x23
|
||||||
#define SUMEM_RAS_COUNTER 0x24
|
#define BPMEM_RAS_COUNTER 0x24
|
||||||
#define SUMEM_RAS1_SS0 0x25
|
#define BPMEM_RAS1_SS0 0x25
|
||||||
#define SUMEM_RAS1_SS1 0x26
|
#define BPMEM_RAS1_SS1 0x26
|
||||||
#define SUMEM_IREF 0x27
|
#define BPMEM_IREF 0x27
|
||||||
#define SUMEM_TREF 0x28 // 0x28 + 8
|
#define BPMEM_TREF 0x28 // 0x28 + 8
|
||||||
#define SUMEM_SU_SSIZE 0x30 // 0x30 + (2 * 8)
|
#define BPMEM_SU_SSIZE 0x30 // 0x30 + (2 * 8)
|
||||||
#define SUMEM_SU_TSIZE 0x31 // 0x31 + (2 * 8)
|
#define BPMEM_SU_TSIZE 0x31 // 0x31 + (2 * 8)
|
||||||
#define SUMEM_ZMODE 0x40
|
#define BPMEM_ZMODE 0x40
|
||||||
#define SUMEM_BLENDMODE 0x41
|
#define BPMEM_BLENDMODE 0x41
|
||||||
#define SUMEM_CONSTANTALPHA 0x42
|
#define BPMEM_CONSTANTALPHA 0x42
|
||||||
#define SUMEM_ZCOMPARE 0x43
|
#define BPMEM_ZCOMPARE 0x43
|
||||||
#define SUMEM_FIELDMASK 0x44
|
#define BPMEM_FIELDMASK 0x44
|
||||||
#define SUMEM_SETDRAWDONE 0x45
|
#define BPMEM_SETDRAWDONE 0x45
|
||||||
#define SUMEM_CLOCK0 0x46
|
#define BPMEM_CLOCK0 0x46
|
||||||
#define SUMEM_PE_TOKEN_ID 0x47
|
#define BPMEM_PE_TOKEN_ID 0x47
|
||||||
#define SUMEM_PE_TOKEN_INT_ID 0x48
|
#define BPMEM_PE_TOKEN_INT_ID 0x48
|
||||||
#define SUMEM_EFB_TL 0x49
|
#define BPMEM_EFB_TL 0x49
|
||||||
#define SUMEM_EFB_BR 0x4A
|
#define BPMEM_EFB_BR 0x4A
|
||||||
#define SUMEM_EFB_ADDR 0x4B
|
#define BPMEM_EFB_ADDR 0x4B
|
||||||
#define SUMEM_MIPMAP_STRIDE 0x4D
|
#define BPMEM_MIPMAP_STRIDE 0x4D
|
||||||
#define SUMEM_COPYYSCALE 0x4E
|
#define BPMEM_COPYYSCALE 0x4E
|
||||||
#define SUMEM_CLEAR_AR 0x4F
|
#define BPMEM_CLEAR_AR 0x4F
|
||||||
#define SUMEM_CLEAR_GB 0x50
|
#define BPMEM_CLEAR_GB 0x50
|
||||||
#define SUMEM_CLEAR_Z 0x51
|
#define BPMEM_CLEAR_Z 0x51
|
||||||
#define SUMEM_TRIGGER_EFB_COPY 0x52
|
#define BPMEM_TRIGGER_EFB_COPY 0x52
|
||||||
#define SUMEM_COPYFILTER0 0x53
|
#define BPMEM_COPYFILTER0 0x53
|
||||||
#define SUMEM_COPYFILTER1 0x54
|
#define BPMEM_COPYFILTER1 0x54
|
||||||
#define SUMEM_CLEARBBOX1 0x55
|
#define BPMEM_CLEARBBOX1 0x55
|
||||||
#define SUMEM_CLEARBBOX2 0x56
|
#define BPMEM_CLEARBBOX2 0x56
|
||||||
#define SUMEM_UNKNOWN 0x58
|
#define BPMEM_UNKNOWN 0x58
|
||||||
#define SUMEM_SCISSOROFFSET 0x59
|
#define BPMEM_SCISSOROFFSET 0x59
|
||||||
#define SUMEM_UNKNOWN1 0x60
|
#define BPMEM_UNKNOWN1 0x60
|
||||||
#define SUMEM_UNKNOWN2 0x61
|
#define BPMEM_UNKNOWN2 0x61
|
||||||
#define SUMEM_UNKNOWN3 0x62
|
#define BPMEM_UNKNOWN3 0x62
|
||||||
#define SUMEM_UNKNOWN4 0x63
|
#define BPMEM_UNKNOWN4 0x63
|
||||||
#define SUMEM_LOADTLUT0 0x64
|
#define BPMEM_LOADTLUT0 0x64
|
||||||
#define SUMEM_LOADTLUT1 0x65
|
#define BPMEM_LOADTLUT1 0x65
|
||||||
#define SUMEM_TEXINVALIDATE 0x66
|
#define BPMEM_TEXINVALIDATE 0x66
|
||||||
#define SUMEM_SETGPMETRIC 0x67
|
#define BPMEM_SETGPMETRIC 0x67
|
||||||
#define SUMEM_FIELDMODE 0x68
|
#define BPMEM_FIELDMODE 0x68
|
||||||
#define SUMEM_CLOCK1 0x69
|
#define BPMEM_CLOCK1 0x69
|
||||||
#define SUMEM_TX_SETMODE0 0x80 // 0x80 + 4
|
#define BPMEM_TX_SETMODE0 0x80 // 0x80 + 4
|
||||||
#define SUMEM_TX_SETMODE1 0x84 // 0x84 + 4
|
#define BPMEM_TX_SETMODE1 0x84 // 0x84 + 4
|
||||||
#define SUMEM_TX_SETIMAGE0 0x88 // 0x88 + 4
|
#define BPMEM_TX_SETIMAGE0 0x88 // 0x88 + 4
|
||||||
#define SUMEM_TX_SETIMAGE1 0x8C // 0x8C + 4
|
#define BPMEM_TX_SETIMAGE1 0x8C // 0x8C + 4
|
||||||
#define SUMEM_TX_SETIMAGE2 0x90 // 0x90 + 4
|
#define BPMEM_TX_SETIMAGE2 0x90 // 0x90 + 4
|
||||||
#define SUMEM_TX_SETIMAGE3 0x94 // 0x94 + 4
|
#define BPMEM_TX_SETIMAGE3 0x94 // 0x94 + 4
|
||||||
#define SUMEM_TX_SETTLUT 0x98 // 0x98 + 4
|
#define BPMEM_TX_SETTLUT 0x98 // 0x98 + 4
|
||||||
#define SUMEM_TX_SETMODE0_4 0xA0 // 0xA0 + 4
|
#define BPMEM_TX_SETMODE0_4 0xA0 // 0xA0 + 4
|
||||||
#define SUMEM_TX_SETMODE1_4 0xA4 // 0xA4 + 4
|
#define BPMEM_TX_SETMODE1_4 0xA4 // 0xA4 + 4
|
||||||
#define SUMEM_TX_SETIMAGE0_4 0xA8 // 0xA8 + 4
|
#define BPMEM_TX_SETIMAGE0_4 0xA8 // 0xA8 + 4
|
||||||
#define SUMEM_TX_SETIMAGE1_4 0xAC // 0xA4 + 4
|
#define BPMEM_TX_SETIMAGE1_4 0xAC // 0xA4 + 4
|
||||||
#define SUMEM_TX_SETIMAGE2_4 0xB0 // 0xB0 + 4
|
#define BPMEM_TX_SETIMAGE2_4 0xB0 // 0xB0 + 4
|
||||||
#define SUMEM_TX_SETIMAGE3_4 0xB4 // 0xB4 + 4
|
#define BPMEM_TX_SETIMAGE3_4 0xB4 // 0xB4 + 4
|
||||||
#define SUMEM_TX_SETLUT_4 0xB8 // 0xB8 + 4
|
#define BPMEM_TX_SETLUT_4 0xB8 // 0xB8 + 4
|
||||||
#define SUMEM_TEV_COLOR_ENV 0xC0 // 0xC0 + (2 * 16)
|
#define BPMEM_TEV_COLOR_ENV 0xC0 // 0xC0 + (2 * 16)
|
||||||
#define SUMEM_TEV_ALPHA_ENV 0xC1 // 0xC1 + (2 * 16)
|
#define BPMEM_TEV_ALPHA_ENV 0xC1 // 0xC1 + (2 * 16)
|
||||||
#define SUMEM_TEV_REGISTER_L 0xE0 // 0xE0 + (2 * 4)
|
#define BPMEM_TEV_REGISTER_L 0xE0 // 0xE0 + (2 * 4)
|
||||||
#define SUMEM_TEV_REGISTER_H 0xE1 // 0xE1 + (2 * 4)
|
#define BPMEM_TEV_REGISTER_H 0xE1 // 0xE1 + (2 * 4)
|
||||||
#define SUMEM_FOGRANGE 0xE8
|
#define BPMEM_FOGRANGE 0xE8
|
||||||
#define SUMEM_FOGPARAM0 0xEE
|
#define BPMEM_FOGPARAM0 0xEE
|
||||||
#define SUMEM_FOGBMAGNITUDE 0xEF
|
#define BPMEM_FOGBMAGNITUDE 0xEF
|
||||||
#define SUMEM_FOGBEXPONENT 0xF0
|
#define BPMEM_FOGBEXPONENT 0xF0
|
||||||
#define SUMEM_FOGPARAM3 0xF1
|
#define BPMEM_FOGPARAM3 0xF1
|
||||||
#define SUMEM_FOGCOLOR 0xF2
|
#define BPMEM_FOGCOLOR 0xF2
|
||||||
#define SUMEM_ALPHACOMPARE 0xF3
|
#define BPMEM_ALPHACOMPARE 0xF3
|
||||||
#define SUMEM_BIAS 0xF4
|
#define BPMEM_BIAS 0xF4
|
||||||
#define SUMEM_ZTEX2 0xF5
|
#define BPMEM_ZTEX2 0xF5
|
||||||
#define SUMEM_TEV_KSEL 0xF6 // 0xF6 + 8
|
#define BPMEM_TEV_KSEL 0xF6 // 0xF6 + 8
|
||||||
#define SUMEM_BP_MASK 0xFE
|
#define BPMEM_BP_MASK 0xFE
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// Tev/combiner things
|
// Tev/combiner things
|
||||||
|
@ -823,18 +823,17 @@ union UPE_Copy
|
||||||
};
|
};
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// All of SU memory
|
// All of BP memory
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// ByPass Command
|
struct Bypass
|
||||||
struct BPCommand
|
|
||||||
{
|
{
|
||||||
int address;
|
int address;
|
||||||
int changes;
|
int changes;
|
||||||
int newvalue;
|
int newvalue;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SUMemory
|
struct BPMemory
|
||||||
{
|
{
|
||||||
GenMode genMode;
|
GenMode genMode;
|
||||||
u32 display_copy_filter[4]; // 01-04
|
u32 display_copy_filter[4]; // 01-04
|
||||||
|
@ -901,14 +900,14 @@ struct SUMemory
|
||||||
ZTex1 ztex1; //0xf4,0xf5
|
ZTex1 ztex1; //0xf4,0xf5
|
||||||
ZTex2 ztex2;
|
ZTex2 ztex2;
|
||||||
TevKSel tevksel[8];//0xf6,0xf7,f8,f9,fa,fb,fc,fd
|
TevKSel tevksel[8];//0xf6,0xf7,f8,f9,fa,fb,fc,fd
|
||||||
u32 suMask; //0xFE
|
u32 bpMask; //0xFE
|
||||||
u32 unknown18; //ff
|
u32 unknown18; //ff
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack()
|
#pragma pack()
|
||||||
|
|
||||||
extern SUMemory sumem;
|
extern BPMemory bpmem;
|
||||||
|
|
||||||
void LoadSUReg(u32 value0);
|
void LoadBPReg(u32 value0);
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -0,0 +1,596 @@
|
||||||
|
// Copyright (C) 2003-2009 Dolphin Project.
|
||||||
|
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, version 2.0.
|
||||||
|
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License 2.0 for more details.
|
||||||
|
|
||||||
|
// A copy of the GPL 2.0 should have been included with the program.
|
||||||
|
// If not, see http://www.gnu.org/licenses/
|
||||||
|
|
||||||
|
// Official SVN repository and contact information can be found at
|
||||||
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
#include "Profiler.h"
|
||||||
|
#include "Statistics.h"
|
||||||
|
#include "VideoCommon.h"
|
||||||
|
#include "PixelShaderManager.h"
|
||||||
|
#include "BPFunctions.h"
|
||||||
|
#include "BPStructs.h"
|
||||||
|
#include "TextureDecoder.h"
|
||||||
|
#include "OpcodeDecoding.h"
|
||||||
|
#include "VertexLoader.h"
|
||||||
|
#include "VertexShaderManager.h"
|
||||||
|
|
||||||
|
using namespace BPFunctions;
|
||||||
|
|
||||||
|
void BPInit()
|
||||||
|
{
|
||||||
|
memset(&bpmem, 0, sizeof(bpmem));
|
||||||
|
bpmem.bpMask = 0xFFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------------------------------
|
||||||
|
// Write to the Bypass Memory (Bypass Raster State Registers)
|
||||||
|
/* ------------------
|
||||||
|
Called:
|
||||||
|
At the end of every: OpcodeDecoding.cpp ExecuteDisplayList > Decode() > LoadBPReg
|
||||||
|
TODO:
|
||||||
|
Turn into function table. The (future) DisplayList (DL) jit can then call the functions directly,
|
||||||
|
getting rid of dynamic dispatch. Unfortunately, few games use DLs properly - most\
|
||||||
|
just stuff geometry in them and don't put state changes there. */
|
||||||
|
// ----------------------------------------------------------------------------------------------------------
|
||||||
|
void BPWritten(const Bypass& bp)
|
||||||
|
{
|
||||||
|
// --------------------------------------------------------------------------------------------------------
|
||||||
|
// First the pipeline is flushed then update the bpmem with the new value.
|
||||||
|
// Some of the BP cases have to call certain functions while others just update the bpmem.
|
||||||
|
// some bp cases check the changes variable, because they might not have to be updated all the time
|
||||||
|
// NOTE: it seems not all bp cases like checking changes, so calling if (bp.changes == 0 ? false : true)
|
||||||
|
// had to be ditched and the games seem to work fine with out it.
|
||||||
|
// NOTE2: Yet Another Gamecube Documentation calls them Bypass Registers
|
||||||
|
// --------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Debugging only, this lets you skip a bp update
|
||||||
|
//static int times = 0;
|
||||||
|
//static bool enable = false;
|
||||||
|
|
||||||
|
//switch (bp.address)
|
||||||
|
//{
|
||||||
|
//case BPMEM_CONSTANTALPHA:
|
||||||
|
// {
|
||||||
|
// if (times-- == 0 && enable)
|
||||||
|
// return;
|
||||||
|
// else
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//default: break;
|
||||||
|
//}
|
||||||
|
|
||||||
|
FlushPipeline();
|
||||||
|
((u32*)&bpmem)[bp.address] = bp.newvalue;
|
||||||
|
|
||||||
|
switch (bp.address)
|
||||||
|
{
|
||||||
|
case BPMEM_GENMODE: // Set the Generation Mode
|
||||||
|
{
|
||||||
|
PRIM_LOG("genmode: texgen=%d, col=%d, ms_en=%d, tev=%d, culmode=%d, ind=%d, zfeeze=%d",
|
||||||
|
bpmem.genMode.numtexgens, bpmem.genMode.numcolchans,
|
||||||
|
bpmem.genMode.ms_en, bpmem.genMode.numtevstages+1, bpmem.genMode.cullmode,
|
||||||
|
bpmem.genMode.numindstages, bpmem.genMode.zfreeze);
|
||||||
|
SetGenerationMode(bp);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case BPMEM_IND_MTXA: // Index Matrix Changed
|
||||||
|
case BPMEM_IND_MTXB:
|
||||||
|
case BPMEM_IND_MTXC:
|
||||||
|
case BPMEM_IND_MTXA+3:
|
||||||
|
case BPMEM_IND_MTXB+3:
|
||||||
|
case BPMEM_IND_MTXC+3:
|
||||||
|
case BPMEM_IND_MTXA+6:
|
||||||
|
case BPMEM_IND_MTXB+6:
|
||||||
|
case BPMEM_IND_MTXC+6:
|
||||||
|
PixelShaderManager::SetIndMatrixChanged((bp.address - BPMEM_IND_MTXA) / 3);
|
||||||
|
break;
|
||||||
|
case BPMEM_RAS1_SS0: // Index Texture Coordinate Scale 0
|
||||||
|
PixelShaderManager::SetIndTexScaleChanged(0x03);
|
||||||
|
case BPMEM_RAS1_SS1: // Index Texture Coordinate Scale 1
|
||||||
|
PixelShaderManager::SetIndTexScaleChanged(0x0c);
|
||||||
|
break;
|
||||||
|
case BPMEM_SCISSORTL: // Scissor Rectable Top, Left
|
||||||
|
case BPMEM_SCISSORBR: // Scissor Rectable Bottom, Right
|
||||||
|
case BPMEM_SCISSOROFFSET: // Scissor Offset
|
||||||
|
SetScissor(bp);
|
||||||
|
break;
|
||||||
|
case BPMEM_LINEPTWIDTH: // Line Width
|
||||||
|
SetLineWidth(bp);
|
||||||
|
break;
|
||||||
|
case BPMEM_ZMODE: // Depth Control
|
||||||
|
PRIM_LOG("zmode: test=%d, func=%d, upd=%d", bpmem.zmode.testenable, bpmem.zmode.func,
|
||||||
|
bpmem.zmode.updateenable);
|
||||||
|
SetDepthMode(bp);
|
||||||
|
break;
|
||||||
|
case BPMEM_BLENDMODE: // Blending Control
|
||||||
|
{
|
||||||
|
if (bp.changes & 0xFFFF)
|
||||||
|
{
|
||||||
|
PRIM_LOG("blendmode: en=%d, open=%d, colupd=%d, alphaupd=%d, dst=%d, src=%d, sub=%d, mode=%d",
|
||||||
|
bpmem.blendmode.blendenable, bpmem.blendmode.logicopenable, bpmem.blendmode.colorupdate, bpmem.blendmode.alphaupdate,
|
||||||
|
bpmem.blendmode.dstfactor, bpmem.blendmode.srcfactor, bpmem.blendmode.subtract, bpmem.blendmode.logicmode);
|
||||||
|
// Set LogicOp Blending Mode
|
||||||
|
if (bp.changes & 2)
|
||||||
|
{
|
||||||
|
SETSTAT(stats.logicOpMode, bpmem.blendmode.logicopenable != 0 ? bpmem.blendmode.logicmode : stats.logicOpMode);
|
||||||
|
SetLogicOpMode(bp);
|
||||||
|
}
|
||||||
|
// Set Dithering Mode
|
||||||
|
if (bp.changes & 4)
|
||||||
|
{
|
||||||
|
SETSTAT(stats.dither, bpmem.blendmode.dither);
|
||||||
|
SetDitherMode(bp);
|
||||||
|
}
|
||||||
|
// Set Blending Mode
|
||||||
|
if (bp.changes & 0xFE1)
|
||||||
|
{
|
||||||
|
SETSTAT(stats.srcFactor, bpmem.blendmode.srcfactor);
|
||||||
|
SETSTAT(stats.dstFactor, bpmem.blendmode.dstfactor);
|
||||||
|
SetBlendMode(bp);
|
||||||
|
}
|
||||||
|
// Set Color Mask
|
||||||
|
if (bp.changes & 0x18)
|
||||||
|
{
|
||||||
|
SETSTAT(stats.alphaUpdate, bpmem.blendmode.alphaupdate);
|
||||||
|
SETSTAT(stats.colorUpdate, bpmem.blendmode.colorupdate);
|
||||||
|
SetColorMask(bp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case BPMEM_CONSTANTALPHA: // Set Destination Alpha
|
||||||
|
{
|
||||||
|
PRIM_LOG("constalpha: alp=%d, en=%d", bpmem.dstalpha.alpha, bpmem.dstalpha.enable);
|
||||||
|
SETSTAT(stats.dstAlphaEnable, bpmem.dstalpha.enable);
|
||||||
|
SETSTAT_UINT(stats.dstAlpha, bpmem.dstalpha.alpha);
|
||||||
|
PixelShaderManager::SetDestAlpha(bpmem.dstalpha);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// This is called when the game is done drawing the new frame (eg: like in DX: Begin(); Draw(); End();)
|
||||||
|
case BPMEM_SETDRAWDONE:
|
||||||
|
switch (bp.newvalue & 0xFF)
|
||||||
|
{
|
||||||
|
case 0x02:
|
||||||
|
g_VideoInitialize.pSetPEFinish(); // may generate interrupt
|
||||||
|
DEBUG_LOG(VIDEO, "GXSetDrawDone SetPEFinish (value: 0x%02X)", (bp.newvalue & 0xFFFF));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
WARN_LOG(VIDEO, "GXSetDrawDone ??? (value 0x%02X)", (bp.newvalue & 0xFFFF));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case BPMEM_PE_TOKEN_ID: // Pixel Engine Token ID
|
||||||
|
g_VideoInitialize.pSetPEToken(static_cast<u16>(bp.newvalue & 0xFFFF), FALSE);
|
||||||
|
DEBUG_LOG(VIDEO, "SetPEToken 0x%04x", (bp.newvalue & 0xFFFF));
|
||||||
|
break;
|
||||||
|
case BPMEM_PE_TOKEN_INT_ID: // Pixel Engine Interrupt Token ID
|
||||||
|
g_VideoInitialize.pSetPEToken(static_cast<u16>(bp.newvalue & 0xFFFF), TRUE);
|
||||||
|
DEBUG_LOG(VIDEO, "SetPEToken + INT 0x%04x", (bp.newvalue & 0xFFFF));
|
||||||
|
break;
|
||||||
|
// ------------------------
|
||||||
|
// EFB copy command. This copies a rectangle from the EFB to either RAM in a texture format or to XFB as YUYV.
|
||||||
|
// It can also optionally clear the EFB while copying from it. To emulate this, we of course copy first and clear afterwards.
|
||||||
|
case BPMEM_TRIGGER_EFB_COPY: // Copy EFB Region or Render to the XFB or Clear the screen.
|
||||||
|
{
|
||||||
|
DVSTARTSUBPROFILE("LoadBPReg:swap");
|
||||||
|
// The bottom right is within the rectangle
|
||||||
|
// The values in bpmem.copyTexSrcXY and bpmem.copyTexSrcWH are updated in case 0x49 and 0x4a in this function
|
||||||
|
TRectangle rc = {
|
||||||
|
(int)(bpmem.copyTexSrcXY.x),
|
||||||
|
(int)(bpmem.copyTexSrcXY.y),
|
||||||
|
(int)((bpmem.copyTexSrcXY.x + bpmem.copyTexSrcWH.x + 1)),
|
||||||
|
(int)((bpmem.copyTexSrcXY.y + bpmem.copyTexSrcWH.y + 1))
|
||||||
|
};
|
||||||
|
|
||||||
|
float MValueX = GetRendererTargetScaleX();
|
||||||
|
float MValueY = GetRendererTargetScaleY();
|
||||||
|
|
||||||
|
// Need another rc here to get it to scale.
|
||||||
|
// Here the bottom right is the out of the rectangle.
|
||||||
|
TRectangle multirc = {
|
||||||
|
(int)(bpmem.copyTexSrcXY.x * MValueX),
|
||||||
|
(int)(bpmem.copyTexSrcXY.y * MValueY),
|
||||||
|
(int)((bpmem.copyTexSrcXY.x * MValueX + (bpmem.copyTexSrcWH.x + 1) * MValueX)),
|
||||||
|
(int)((bpmem.copyTexSrcXY.y * MValueY + (bpmem.copyTexSrcWH.y + 1) * MValueY))
|
||||||
|
};
|
||||||
|
UPE_Copy PE_copy;
|
||||||
|
PE_copy.Hex = bpmem.triggerEFBCopy;
|
||||||
|
|
||||||
|
// Check if we are to copy from the EFB or draw to the XFB
|
||||||
|
if (PE_copy.copy_to_xfb == 0)
|
||||||
|
{
|
||||||
|
if (GetConfig(CONFIG_SHOWEFBREGIONS))
|
||||||
|
stats.efb_regions.push_back(rc);
|
||||||
|
|
||||||
|
CopyEFB(bp, rc, bpmem.copyTexDest << 5,
|
||||||
|
bpmem.zcontrol.pixel_format == PIXELFMT_Z24,
|
||||||
|
PE_copy.intensity_fmt > 0,
|
||||||
|
((PE_copy.target_pixel_format / 2) + ((PE_copy.target_pixel_format & 1) * 8)),
|
||||||
|
PE_copy.half_scale > 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// the number of lines copied is determined by the y scale * source efb height
|
||||||
|
const float yScale = bpmem.dispcopyyscale / 256.0f;
|
||||||
|
const float xfbLines = ((bpmem.copyTexSrcWH.y + 1.0f) * yScale);
|
||||||
|
RenderToXFB(bp, multirc, yScale, xfbLines,
|
||||||
|
Memory_GetPtr(bpmem.copyTexDest << 5),
|
||||||
|
bpmem.copyMipMapStrideChannels << 4,
|
||||||
|
(u32)ceil(xfbLines));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear the picture after it's done and submitted, to prepare for the next picture
|
||||||
|
if (PE_copy.clear)
|
||||||
|
ClearScreen(bp, multirc);
|
||||||
|
|
||||||
|
RestoreRenderState(bp);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case BPMEM_LOADTLUT0: // Load a Texture Look Up Table
|
||||||
|
case BPMEM_LOADTLUT1:
|
||||||
|
{
|
||||||
|
DVSTARTSUBPROFILE("LoadBPReg:GXLoadTlut");
|
||||||
|
|
||||||
|
u32 tlutTMemAddr = (bp.newvalue & 0x3FF) << 9;
|
||||||
|
u32 tlutXferCount = (bp.newvalue & 0x1FFC00) >> 5;
|
||||||
|
|
||||||
|
u8 *ptr = 0;
|
||||||
|
|
||||||
|
// TODO - figure out a cleaner way.
|
||||||
|
if (GetConfig(CONFIG_ISWII))
|
||||||
|
ptr = GetPointer(bpmem.tlutXferSrc << 5);
|
||||||
|
else
|
||||||
|
ptr = GetPointer((bpmem.tlutXferSrc & 0xFFFFF) << 5);
|
||||||
|
|
||||||
|
if (ptr)
|
||||||
|
memcpy_gc(texMem + tlutTMemAddr, ptr, tlutXferCount);
|
||||||
|
else
|
||||||
|
PanicAlert("Invalid palette pointer %08x %08x %08x", bpmem.tlutXferSrc, bpmem.tlutXferSrc << 5, (bpmem.tlutXferSrc & 0xFFFFF)<< 5);
|
||||||
|
|
||||||
|
// TODO(ector) : kill all textures that use this palette
|
||||||
|
// Not sure if it's a good idea, though. For now, we hash texture palettes
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case BPMEM_FOGRANGE: // Fog Settings Control
|
||||||
|
case BPMEM_FOGPARAM0:
|
||||||
|
case BPMEM_FOGBMAGNITUDE:
|
||||||
|
case BPMEM_FOGBEXPONENT:
|
||||||
|
case BPMEM_FOGPARAM3:
|
||||||
|
if(!GetConfig(CONFIG_DISABLEFOG))
|
||||||
|
PixelShaderManager::SetFogParamChanged();
|
||||||
|
break;
|
||||||
|
case BPMEM_FOGCOLOR: // Fog Color
|
||||||
|
PixelShaderManager::SetFogColorChanged();
|
||||||
|
break;
|
||||||
|
case BPMEM_ALPHACOMPARE: // Compare Alpha Values
|
||||||
|
PRIM_LOG("alphacmp: ref0=%d, ref1=%d, comp0=%d, comp1=%d, logic=%d", bpmem.alphaFunc.ref0,
|
||||||
|
bpmem.alphaFunc.ref1, bpmem.alphaFunc.comp0, bpmem.alphaFunc.comp1, bpmem.alphaFunc.logic);
|
||||||
|
PixelShaderManager::SetAlpha(bpmem.alphaFunc);
|
||||||
|
break;
|
||||||
|
case BPMEM_BIAS: // BIAS
|
||||||
|
PRIM_LOG("ztex bias=0x%x", bpmem.ztex1.bias);
|
||||||
|
PixelShaderManager::SetZTextureBias(bpmem.ztex1.bias);
|
||||||
|
break;
|
||||||
|
case BPMEM_ZTEX2: // Z Texture type
|
||||||
|
{
|
||||||
|
if (bp.changes & 3)
|
||||||
|
PixelShaderManager::SetZTextureTypeChanged();
|
||||||
|
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||||
|
const char* pzop[] = {"DISABLE", "ADD", "REPLACE", "?"};
|
||||||
|
const char* pztype[] = {"Z8", "Z16", "Z24", "?"};
|
||||||
|
PRIM_LOG("ztex op=%s, type=%s", pzop[bpmem.ztex2.op], pztype[bpmem.ztex2.type]);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// ----------------------------------
|
||||||
|
// Display Copy Filtering Control
|
||||||
|
// Fields: Destination, Frame2Field, Gamma, Source
|
||||||
|
// TODO: We might have to implement the gamma one, some games might need this, if they are too dark to see.
|
||||||
|
// ----------------------------------
|
||||||
|
case BPMEM_DISPLAYCOPYFILER:
|
||||||
|
case BPMEM_DISPLAYCOPYFILER+1:
|
||||||
|
case BPMEM_DISPLAYCOPYFILER+2:
|
||||||
|
case BPMEM_DISPLAYCOPYFILER+3:
|
||||||
|
case BPMEM_COPYFILTER0: //GXSetCopyFilter
|
||||||
|
case BPMEM_COPYFILTER1:
|
||||||
|
break;
|
||||||
|
case BPMEM_FIELDMASK: // Interlacing Control
|
||||||
|
case BPMEM_FIELDMODE:
|
||||||
|
SetInterlacingMode(bp);
|
||||||
|
break;
|
||||||
|
// ---------------------------------------------------
|
||||||
|
// Debugging/Profiling info, we don't care about them
|
||||||
|
// ---------------------------------------------------
|
||||||
|
case BPMEM_CLOCK0: // Some Clock
|
||||||
|
case BPMEM_CLOCK1: // Some Clock
|
||||||
|
case BPMEM_SU_COUNTER: // Pixel or Poly Count
|
||||||
|
case BPMEM_RAS_COUNTER: // Sound Count of something in the Texture Units
|
||||||
|
case BPMEM_SETGPMETRIC: // Set the Graphic Processor Metric
|
||||||
|
break;
|
||||||
|
// ----------------
|
||||||
|
// EFB Copy config
|
||||||
|
// ----------------
|
||||||
|
case BPMEM_EFB_TL: // EFB Source Rect. Top, Left
|
||||||
|
case BPMEM_EFB_BR: // EFB Source Rect. Bottom, Right (w, h - 1)
|
||||||
|
case BPMEM_EFB_ADDR: // EFB Target Address
|
||||||
|
break;
|
||||||
|
// --------------
|
||||||
|
// Clear Config
|
||||||
|
// --------------
|
||||||
|
case BPMEM_CLEAR_AR: // Alpha and Red Components
|
||||||
|
case BPMEM_CLEAR_GB: // Green and Blue Components
|
||||||
|
case BPMEM_CLEAR_Z: // Z Components (24-bit Zbuffer)
|
||||||
|
break;
|
||||||
|
// -------------------------
|
||||||
|
// Culling Occulsion, we don't support this
|
||||||
|
// let's hope not many games use bboxes..
|
||||||
|
// TODO(ector): add something that watches bboxes
|
||||||
|
// -------------------------
|
||||||
|
case BPMEM_CLEARBBOX1:
|
||||||
|
case BPMEM_CLEARBBOX2:
|
||||||
|
break;
|
||||||
|
case BPMEM_ZCOMPARE: // Set the Z-Compare
|
||||||
|
case BPMEM_TEXINVALIDATE: // Used, if game has manual control the Texture Cache, which we don't allow
|
||||||
|
case BPMEM_MIPMAP_STRIDE: // MipMap Stride Channel
|
||||||
|
case BPMEM_COPYYSCALE: // Display Copy Y Scale
|
||||||
|
case BPMEM_IREF: /* 24 RID
|
||||||
|
21 BC3 - Ind. Tex Stage 3 NTexCoord
|
||||||
|
18 BI3 - Ind. Tex Stage 3 NTexMap
|
||||||
|
15 BC2 - Ind. Tex Stage 2 NTexCoord
|
||||||
|
12 BI2 - Ind. Tex Stage 2 NTexMap
|
||||||
|
9 BC1 - Ind. Tex Stage 1 NTexCoord
|
||||||
|
6 BI1 - Ind. Tex Stage 1 NTexMap
|
||||||
|
3 BC0 - Ind. Tex Stage 0 NTexCoord
|
||||||
|
0 BI0 - Ind. Tex Stage 0 NTexMap */
|
||||||
|
break;
|
||||||
|
case BPMEM_TEV_KSEL: // Texture Environment Swap Mode Table 0
|
||||||
|
case BPMEM_TEV_KSEL+1:// Texture Environment Swap Mode Table 1
|
||||||
|
case BPMEM_TEV_KSEL+2:// Texture Environment Swap Mode Table 2
|
||||||
|
case BPMEM_TEV_KSEL+3:// Texture Environment Swap Mode Table 3
|
||||||
|
case BPMEM_TEV_KSEL+4:// Texture Environment Swap Mode Table 4
|
||||||
|
case BPMEM_TEV_KSEL+5:// Texture Environment Swap Mode Table 5
|
||||||
|
case BPMEM_TEV_KSEL+6:// Texture Environment Swap Mode Table 6
|
||||||
|
case BPMEM_TEV_KSEL+7:// Texture Environment Swap Mode Table 7
|
||||||
|
break;
|
||||||
|
case BPMEM_BP_MASK: // This Register can be used to limit to which bits of BP registers is actually written to. the mask is
|
||||||
|
// only valid for the next BP command, and will reset itself.
|
||||||
|
case BPMEM_IND_IMASK: // Index Mask ?
|
||||||
|
break;
|
||||||
|
case BPMEM_UNKNOWN: // This is always set to 0xF at boot of any game, so this sounds like a useless reg
|
||||||
|
if (bp.newvalue != 0x0F)
|
||||||
|
PanicAlert("Unknown is not 0xF! val = 0x%08x", bp.newvalue);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Cases added due to: http://code.google.com/p/dolphin-emu/issues/detail?id=360#c90
|
||||||
|
// Are these related to BBox?
|
||||||
|
case BPMEM_UNKNOWN1:
|
||||||
|
case BPMEM_UNKNOWN2:
|
||||||
|
case BPMEM_UNKNOWN3:
|
||||||
|
case BPMEM_UNKNOWN4:
|
||||||
|
break;
|
||||||
|
// ------------------------------------------------
|
||||||
|
// On Default, we try to look for other things
|
||||||
|
// before we give up and say its an unknown opcode
|
||||||
|
// ------------------------------------------------
|
||||||
|
default:
|
||||||
|
switch (bp.address & 0xFC) // Texture sampler filter
|
||||||
|
{
|
||||||
|
// -------------------------
|
||||||
|
// Texture Environment Order
|
||||||
|
// -------------------------
|
||||||
|
case BPMEM_TREF:
|
||||||
|
case BPMEM_TREF+1:
|
||||||
|
case BPMEM_TREF+2:
|
||||||
|
case BPMEM_TREF+3:
|
||||||
|
case BPMEM_TREF+4:
|
||||||
|
case BPMEM_TREF+5:
|
||||||
|
case BPMEM_TREF+6:
|
||||||
|
case BPMEM_TREF+7:
|
||||||
|
break;
|
||||||
|
// ----------------------
|
||||||
|
// Set wrap size
|
||||||
|
// ----------------------
|
||||||
|
case BPMEM_SU_SSIZE:
|
||||||
|
case BPMEM_SU_TSIZE:
|
||||||
|
case BPMEM_SU_SSIZE+2:
|
||||||
|
case BPMEM_SU_TSIZE+2:
|
||||||
|
case BPMEM_SU_SSIZE+4:
|
||||||
|
case BPMEM_SU_TSIZE+4:
|
||||||
|
case BPMEM_SU_SSIZE+6:
|
||||||
|
case BPMEM_SU_TSIZE+6:
|
||||||
|
case BPMEM_SU_SSIZE+8:
|
||||||
|
case BPMEM_SU_TSIZE+8:
|
||||||
|
case BPMEM_SU_SSIZE+10:
|
||||||
|
case BPMEM_SU_TSIZE+10:
|
||||||
|
case BPMEM_SU_SSIZE+12:
|
||||||
|
case BPMEM_SU_TSIZE+12:
|
||||||
|
case BPMEM_SU_SSIZE+14:
|
||||||
|
case BPMEM_SU_TSIZE+14:
|
||||||
|
PixelShaderManager::SetTexCoordChanged((bp.address - BPMEM_SU_SSIZE) >> 1);
|
||||||
|
break;
|
||||||
|
// ------------------------
|
||||||
|
// BPMEM_TX_SETMODE0 - (Texture lookup and filtering mode) LOD/BIAS Clamp, MaxAnsio, LODBIAS, DiagLoad, Min Filter, Mag Filter, Wrap T, S
|
||||||
|
// BPMEM_TX_SETMODE1 - (LOD Stuff) - Max LOD, Min LOD
|
||||||
|
// ------------------------
|
||||||
|
case BPMEM_TX_SETMODE0: // (0x90 for linear)
|
||||||
|
case BPMEM_TX_SETMODE0+1:
|
||||||
|
case BPMEM_TX_SETMODE0+2:
|
||||||
|
case BPMEM_TX_SETMODE0+3:
|
||||||
|
case BPMEM_TX_SETMODE1:
|
||||||
|
case BPMEM_TX_SETMODE1+1:
|
||||||
|
case BPMEM_TX_SETMODE1+2:
|
||||||
|
case BPMEM_TX_SETMODE1+3:
|
||||||
|
case BPMEM_TX_SETMODE0_4:
|
||||||
|
case BPMEM_TX_SETMODE0_4+1:
|
||||||
|
case BPMEM_TX_SETMODE0_4+2:
|
||||||
|
case BPMEM_TX_SETMODE0_4+3:
|
||||||
|
case BPMEM_TX_SETMODE1_4:
|
||||||
|
case BPMEM_TX_SETMODE1_4+1:
|
||||||
|
case BPMEM_TX_SETMODE1_4+2:
|
||||||
|
case BPMEM_TX_SETMODE1_4+3:
|
||||||
|
SetSamplerState(bp);
|
||||||
|
break;
|
||||||
|
// --------------------------------------------
|
||||||
|
// BPMEM_TX_SETIMAGE0 - Texture width, height, format
|
||||||
|
// BPMEM_TX_SETIMAGE1 - even LOD address in TMEM - Image Type, Cache Height, Cache Width, TMEM Offset
|
||||||
|
// BPMEM_TX_SETIMAGE2 - odd LOD address in TMEM - Cache Height, Cache Width, TMEM Offset
|
||||||
|
// BPMEM_TX_SETIMAGE3 - Address of Texture in main memory
|
||||||
|
// --------------------------------------------
|
||||||
|
case BPMEM_TX_SETIMAGE0:
|
||||||
|
case BPMEM_TX_SETIMAGE0+1:
|
||||||
|
case BPMEM_TX_SETIMAGE0+2:
|
||||||
|
case BPMEM_TX_SETIMAGE0+3:
|
||||||
|
case BPMEM_TX_SETIMAGE0_4:
|
||||||
|
case BPMEM_TX_SETIMAGE0_4+1:
|
||||||
|
case BPMEM_TX_SETIMAGE0_4+2:
|
||||||
|
case BPMEM_TX_SETIMAGE0_4+3:
|
||||||
|
case BPMEM_TX_SETIMAGE1:
|
||||||
|
case BPMEM_TX_SETIMAGE1+1:
|
||||||
|
case BPMEM_TX_SETIMAGE1+2:
|
||||||
|
case BPMEM_TX_SETIMAGE1+3:
|
||||||
|
case BPMEM_TX_SETIMAGE1_4:
|
||||||
|
case BPMEM_TX_SETIMAGE1_4+1:
|
||||||
|
case BPMEM_TX_SETIMAGE1_4+2:
|
||||||
|
case BPMEM_TX_SETIMAGE1_4+3:
|
||||||
|
case BPMEM_TX_SETIMAGE2:
|
||||||
|
case BPMEM_TX_SETIMAGE2+1:
|
||||||
|
case BPMEM_TX_SETIMAGE2+2:
|
||||||
|
case BPMEM_TX_SETIMAGE2+3:
|
||||||
|
case BPMEM_TX_SETIMAGE2_4:
|
||||||
|
case BPMEM_TX_SETIMAGE2_4+1:
|
||||||
|
case BPMEM_TX_SETIMAGE2_4+2:
|
||||||
|
case BPMEM_TX_SETIMAGE2_4+3:
|
||||||
|
case BPMEM_TX_SETIMAGE3:
|
||||||
|
case BPMEM_TX_SETIMAGE3+1:
|
||||||
|
case BPMEM_TX_SETIMAGE3+2:
|
||||||
|
case BPMEM_TX_SETIMAGE3+3:
|
||||||
|
case BPMEM_TX_SETIMAGE3_4:
|
||||||
|
case BPMEM_TX_SETIMAGE3_4+1:
|
||||||
|
case BPMEM_TX_SETIMAGE3_4+2:
|
||||||
|
case BPMEM_TX_SETIMAGE3_4+3:
|
||||||
|
break;
|
||||||
|
// -------------------------------
|
||||||
|
// Set a TLUT
|
||||||
|
// BPMEM_TX_SETTLUT - Format, TMEM Offset (offset of TLUT from start of TMEM high bank > > 5)
|
||||||
|
// -------------------------------
|
||||||
|
case BPMEM_TX_SETTLUT:
|
||||||
|
case BPMEM_TX_SETTLUT+1:
|
||||||
|
case BPMEM_TX_SETTLUT+2:
|
||||||
|
case BPMEM_TX_SETTLUT+3:
|
||||||
|
case BPMEM_TX_SETLUT_4:
|
||||||
|
case BPMEM_TX_SETLUT_4+1:
|
||||||
|
case BPMEM_TX_SETLUT_4+2:
|
||||||
|
case BPMEM_TX_SETLUT_4+3:
|
||||||
|
break;
|
||||||
|
// ---------------------------------------------------
|
||||||
|
// Set the TEV Color
|
||||||
|
// ---------------------------------------------------
|
||||||
|
case BPMEM_TEV_REGISTER_L: // Reg 1
|
||||||
|
case BPMEM_TEV_REGISTER_H:
|
||||||
|
case BPMEM_TEV_REGISTER_L+2: // Reg 2
|
||||||
|
case BPMEM_TEV_REGISTER_H+2:
|
||||||
|
case BPMEM_TEV_REGISTER_L+4: // Reg 3
|
||||||
|
case BPMEM_TEV_REGISTER_H+4:
|
||||||
|
case BPMEM_TEV_REGISTER_L+6: // Reg 4
|
||||||
|
case BPMEM_TEV_REGISTER_H+6:
|
||||||
|
{
|
||||||
|
if (bp.address & 1)
|
||||||
|
{
|
||||||
|
// don't compare with changes!
|
||||||
|
int num = (bp.address >> 1 ) & 0x3;
|
||||||
|
PixelShaderManager::SetColorChanged(bpmem.tevregs[num].high.type, num);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// ------------------------------------------------
|
||||||
|
// On Default, we try to look for other things
|
||||||
|
// before we give up and say its an unknown opcode
|
||||||
|
// again ...
|
||||||
|
// ------------------------------------------------
|
||||||
|
default:
|
||||||
|
switch (bp.address & 0xF0)
|
||||||
|
{
|
||||||
|
// --------------
|
||||||
|
// Indirect Tev
|
||||||
|
// --------------
|
||||||
|
case BPMEM_IND_CMD:
|
||||||
|
case BPMEM_IND_CMD+1:
|
||||||
|
case BPMEM_IND_CMD+2:
|
||||||
|
case BPMEM_IND_CMD+3:
|
||||||
|
case BPMEM_IND_CMD+4:
|
||||||
|
case BPMEM_IND_CMD+5:
|
||||||
|
case BPMEM_IND_CMD+6:
|
||||||
|
case BPMEM_IND_CMD+7:
|
||||||
|
case BPMEM_IND_CMD+8:
|
||||||
|
case BPMEM_IND_CMD+9:
|
||||||
|
case BPMEM_IND_CMD+10:
|
||||||
|
case BPMEM_IND_CMD+11:
|
||||||
|
case BPMEM_IND_CMD+12:
|
||||||
|
case BPMEM_IND_CMD+13:
|
||||||
|
case BPMEM_IND_CMD+14:
|
||||||
|
case BPMEM_IND_CMD+15:
|
||||||
|
break;
|
||||||
|
// --------------------------------------------------
|
||||||
|
// Set Color/Alpha of a Tev
|
||||||
|
// BPMEM_TEV_COLOR_ENV - Dest, Shift, Clamp, Sub, Bias, Sel A, Sel B, Sel C, Sel D
|
||||||
|
// BPMEM_TEV_ALPHA_ENV - Dest, Shift, Clamp, Sub, Bias, Sel A, Sel B, Sel C, Sel D, T Swap, R Swap
|
||||||
|
// --------------------------------------------------
|
||||||
|
case BPMEM_TEV_COLOR_ENV: // Texture Environment 1
|
||||||
|
case BPMEM_TEV_ALPHA_ENV:
|
||||||
|
case BPMEM_TEV_COLOR_ENV+2: // Texture Environment 2
|
||||||
|
case BPMEM_TEV_ALPHA_ENV+2:
|
||||||
|
case BPMEM_TEV_COLOR_ENV+4: // Texture Environment 3
|
||||||
|
case BPMEM_TEV_ALPHA_ENV+4:
|
||||||
|
case BPMEM_TEV_COLOR_ENV+8: // Texture Environment 4
|
||||||
|
case BPMEM_TEV_ALPHA_ENV+8:
|
||||||
|
case BPMEM_TEV_COLOR_ENV+10: // Texture Environment 5
|
||||||
|
case BPMEM_TEV_ALPHA_ENV+10:
|
||||||
|
case BPMEM_TEV_COLOR_ENV+12: // Texture Environment 6
|
||||||
|
case BPMEM_TEV_ALPHA_ENV+12:
|
||||||
|
case BPMEM_TEV_COLOR_ENV+14: // Texture Environment 7
|
||||||
|
case BPMEM_TEV_ALPHA_ENV+14:
|
||||||
|
case BPMEM_TEV_COLOR_ENV+16: // Texture Environment 8
|
||||||
|
case BPMEM_TEV_ALPHA_ENV+16:
|
||||||
|
case BPMEM_TEV_COLOR_ENV+18: // Texture Environment 9
|
||||||
|
case BPMEM_TEV_ALPHA_ENV+18:
|
||||||
|
case BPMEM_TEV_COLOR_ENV+20: // Texture Environment 10
|
||||||
|
case BPMEM_TEV_ALPHA_ENV+20:
|
||||||
|
case BPMEM_TEV_COLOR_ENV+22: // Texture Environment 11
|
||||||
|
case BPMEM_TEV_ALPHA_ENV+22:
|
||||||
|
case BPMEM_TEV_COLOR_ENV+24: // Texture Environment 12
|
||||||
|
case BPMEM_TEV_ALPHA_ENV+24:
|
||||||
|
case BPMEM_TEV_COLOR_ENV+26: // Texture Environment 13
|
||||||
|
case BPMEM_TEV_ALPHA_ENV+26:
|
||||||
|
case BPMEM_TEV_COLOR_ENV+28: // Texture Environment 14
|
||||||
|
case BPMEM_TEV_ALPHA_ENV+28:
|
||||||
|
case BPMEM_TEV_COLOR_ENV+30: // Texture Environment 15
|
||||||
|
case BPMEM_TEV_ALPHA_ENV+30:
|
||||||
|
case BPMEM_TEV_COLOR_ENV+32: // Texture Environment 16
|
||||||
|
case BPMEM_TEV_ALPHA_ENV+32:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
WARN_LOG(VIDEO, "Unknown Bypass opcode: address = 0x%08x value = 0x%08x", bp.address, bp.newvalue);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -15,13 +15,13 @@
|
||||||
// Official SVN repository and contact information can be found at
|
// Official SVN repository and contact information can be found at
|
||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
#ifndef _SUSTRUCTS_H_
|
#ifndef _BPSTRUCTS_H_
|
||||||
#define _SUSTRUCTS_H_
|
#define _BPSTRUCTS_H_
|
||||||
|
|
||||||
#include "SUMemory.h"
|
#include "BPMemory.h"
|
||||||
|
|
||||||
void SUInit();
|
void BPInit();
|
||||||
void LoadSUReg(u32 value0);
|
void LoadBPReg(u32 value0);
|
||||||
void SUReload();
|
void BPReload();
|
||||||
|
|
||||||
#endif // _SUSTRUCTS_H_
|
#endif // _BPSTRUCTS_H_
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
#include "XFMemory.h"
|
#include "XFMemory.h"
|
||||||
#include "CPMemory.h"
|
#include "CPMemory.h"
|
||||||
#include "SUMemory.h"
|
#include "BPMemory.h"
|
||||||
|
|
||||||
#include "Fifo.h"
|
#include "Fifo.h"
|
||||||
#include "DataReader.h"
|
#include "DataReader.h"
|
||||||
|
@ -267,7 +267,7 @@ static void Decode()
|
||||||
case GX_LOAD_BP_REG: //0x61
|
case GX_LOAD_BP_REG: //0x61
|
||||||
{
|
{
|
||||||
u32 cmd = DataReadU32();
|
u32 cmd = DataReadU32();
|
||||||
LoadSUReg(cmd);
|
LoadBPReg(cmd);
|
||||||
INCSTAT(stats.thisFrame.numBPLoads);
|
INCSTAT(stats.thisFrame.numBPLoads);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -22,63 +22,63 @@
|
||||||
#include "Profiler.h"
|
#include "Profiler.h"
|
||||||
#include "PixelShaderGen.h"
|
#include "PixelShaderGen.h"
|
||||||
#include "XFMemory.h" // for texture projection mode
|
#include "XFMemory.h" // for texture projection mode
|
||||||
#include "SUMemory.h"
|
#include "BPMemory.h"
|
||||||
|
|
||||||
// Mash together all the inputs that contribute to the code of a generated pixel shader into
|
// Mash together all the inputs that contribute to the code of a generated pixel shader into
|
||||||
// a unique identifier, basically containing all the bits. Yup, it's a lot ....
|
// a unique identifier, basically containing all the bits. Yup, it's a lot ....
|
||||||
void GetPixelShaderId(PIXELSHADERUID &uid, u32 s_texturemask, u32 dstAlphaEnable)
|
void GetPixelShaderId(PIXELSHADERUID &uid, u32 s_texturemask, u32 dstAlphaEnable)
|
||||||
{
|
{
|
||||||
u32 projtexcoords = 0;
|
u32 projtexcoords = 0;
|
||||||
for (u32 i = 0; i < (u32)sumem.genMode.numtevstages + 1; i++) {
|
for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages + 1; i++) {
|
||||||
if (sumem.tevorders[i/2].getEnable(i&1)) {
|
if (bpmem.tevorders[i/2].getEnable(i&1)) {
|
||||||
int texcoord = sumem.tevorders[i/2].getTexCoord(i&1);
|
int texcoord = bpmem.tevorders[i/2].getTexCoord(i&1);
|
||||||
if (xfregs.texcoords[texcoord].texmtxinfo.projection )
|
if (xfregs.texcoords[texcoord].texmtxinfo.projection )
|
||||||
projtexcoords |= 1 << texcoord;
|
projtexcoords |= 1 << texcoord;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uid.values[0] = (u32)sumem.genMode.numtevstages |
|
uid.values[0] = (u32)bpmem.genMode.numtevstages |
|
||||||
((u32)sumem.genMode.numindstages << 4) |
|
((u32)bpmem.genMode.numindstages << 4) |
|
||||||
((u32)sumem.genMode.numtexgens << 7) |
|
((u32)bpmem.genMode.numtexgens << 7) |
|
||||||
((u32)dstAlphaEnable << 11) |
|
((u32)dstAlphaEnable << 11) |
|
||||||
((u32)((sumem.alphaFunc.hex >> 16) & 0xff) << 12) |
|
((u32)((bpmem.alphaFunc.hex >> 16) & 0xff) << 12) |
|
||||||
(projtexcoords << 20) |
|
(projtexcoords << 20) |
|
||||||
((u32)sumem.ztex2.op << 28);
|
((u32)bpmem.ztex2.op << 28);
|
||||||
|
|
||||||
uid.values[0] = (uid.values[0] & ~0x0ff00000) | (projtexcoords << 20);
|
uid.values[0] = (uid.values[0] & ~0x0ff00000) | (projtexcoords << 20);
|
||||||
// swap table
|
// swap table
|
||||||
for (int i = 0; i < 8; i += 2)
|
for (int i = 0; i < 8; i += 2)
|
||||||
((u8*)&uid.values[1])[i/2] = (sumem.tevksel[i].hex & 0xf) | ((sumem.tevksel[i + 1].hex & 0xf) << 4);
|
((u8*)&uid.values[1])[i/2] = (bpmem.tevksel[i].hex & 0xf) | ((bpmem.tevksel[i + 1].hex & 0xf) << 4);
|
||||||
|
|
||||||
uid.values[2] = s_texturemask;
|
uid.values[2] = s_texturemask;
|
||||||
|
|
||||||
uid.values[3] = (u32)sumem.fog.c_proj_fsel.fsel |
|
uid.values[3] = (u32)bpmem.fog.c_proj_fsel.fsel |
|
||||||
((u32)sumem.fog.c_proj_fsel.proj << 3);
|
((u32)bpmem.fog.c_proj_fsel.proj << 3);
|
||||||
|
|
||||||
int hdr = 4;
|
int hdr = 4;
|
||||||
u32* pcurvalue = &uid.values[hdr];
|
u32* pcurvalue = &uid.values[hdr];
|
||||||
for (u32 i = 0; i < (u32)sumem.genMode.numtevstages+1; ++i) {
|
for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages+1; ++i) {
|
||||||
TevStageCombiner::ColorCombiner &cc = sumem.combiners[i].colorC;
|
TevStageCombiner::ColorCombiner &cc = bpmem.combiners[i].colorC;
|
||||||
TevStageCombiner::AlphaCombiner &ac = sumem.combiners[i].alphaC;
|
TevStageCombiner::AlphaCombiner &ac = bpmem.combiners[i].alphaC;
|
||||||
|
|
||||||
u32 val0 = cc.hex&0xffffff;
|
u32 val0 = cc.hex&0xffffff;
|
||||||
u32 val1 = ac.hex&0xffffff;
|
u32 val1 = ac.hex&0xffffff;
|
||||||
val0 |= sumem.tevksel[i/2].getKC(i&1)<<24;
|
val0 |= bpmem.tevksel[i/2].getKC(i&1)<<24;
|
||||||
val1 |= sumem.tevksel[i/2].getKA(i&1)<<24;
|
val1 |= bpmem.tevksel[i/2].getKA(i&1)<<24;
|
||||||
pcurvalue[0] = val0;
|
pcurvalue[0] = val0;
|
||||||
pcurvalue[1] = val1;
|
pcurvalue[1] = val1;
|
||||||
pcurvalue += 2;
|
pcurvalue += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (u32 i = 0; i < ((u32)sumem.genMode.numtevstages+1)/2; ++i) {
|
for (u32 i = 0; i < ((u32)bpmem.genMode.numtevstages+1)/2; ++i) {
|
||||||
u32 val0, val1;
|
u32 val0, val1;
|
||||||
if (sumem.tevorders[i].hex & 0x40)
|
if (bpmem.tevorders[i].hex & 0x40)
|
||||||
val0 = sumem.tevorders[i].hex & 0x3ff;
|
val0 = bpmem.tevorders[i].hex & 0x3ff;
|
||||||
else
|
else
|
||||||
val0 = sumem.tevorders[i].hex & 0x380;
|
val0 = bpmem.tevorders[i].hex & 0x380;
|
||||||
if (sumem.tevorders[i].hex & 0x40000)
|
if (bpmem.tevorders[i].hex & 0x40000)
|
||||||
val1 = (sumem.tevorders[i].hex & 0x3ff000) >> 12;
|
val1 = (bpmem.tevorders[i].hex & 0x3ff000) >> 12;
|
||||||
else
|
else
|
||||||
val1 = (sumem.tevorders[i].hex & 0x380000) >> 12;
|
val1 = (bpmem.tevorders[i].hex & 0x380000) >> 12;
|
||||||
|
|
||||||
switch (i % 3) {
|
switch (i % 3) {
|
||||||
case 0: pcurvalue[0] = val0|(val1<<10); break;
|
case 0: pcurvalue[0] = val0|(val1<<10); break;
|
||||||
|
@ -87,27 +87,27 @@ void GetPixelShaderId(PIXELSHADERUID &uid, u32 s_texturemask, u32 dstAlphaEnable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((sumem.genMode.numtevstages + 1) & 1) { // odd
|
if ((bpmem.genMode.numtevstages + 1) & 1) { // odd
|
||||||
u32 val0;
|
u32 val0;
|
||||||
if (sumem.tevorders[sumem.genMode.numtevstages/2].hex & 0x40)
|
if (bpmem.tevorders[bpmem.genMode.numtevstages/2].hex & 0x40)
|
||||||
val0 = sumem.tevorders[sumem.genMode.numtevstages/2].hex&0x3ff;
|
val0 = bpmem.tevorders[bpmem.genMode.numtevstages/2].hex&0x3ff;
|
||||||
else
|
else
|
||||||
val0 = sumem.tevorders[sumem.genMode.numtevstages/2].hex & 0x380;
|
val0 = bpmem.tevorders[bpmem.genMode.numtevstages/2].hex & 0x380;
|
||||||
|
|
||||||
switch (sumem.genMode.numtevstages % 3) {
|
switch (bpmem.genMode.numtevstages % 3) {
|
||||||
case 0: pcurvalue[0] = val0; break;
|
case 0: pcurvalue[0] = val0; break;
|
||||||
case 1: pcurvalue[0] |= val0 << 20; break;
|
case 1: pcurvalue[0] |= val0 << 20; break;
|
||||||
case 2: pcurvalue[1] |= val0 << 10; pcurvalue++; break;
|
case 2: pcurvalue[1] |= val0 << 10; pcurvalue++; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((sumem.genMode.numtevstages % 3) != 2)
|
if ((bpmem.genMode.numtevstages % 3) != 2)
|
||||||
++pcurvalue;
|
++pcurvalue;
|
||||||
|
|
||||||
uid.tevstages = (u32)(pcurvalue-&uid.values[0]-hdr);
|
uid.tevstages = (u32)(pcurvalue-&uid.values[0]-hdr);
|
||||||
|
|
||||||
for (u32 i = 0; i < sumem.genMode.numindstages; ++i) {
|
for (u32 i = 0; i < bpmem.genMode.numindstages; ++i) {
|
||||||
u32 val = sumem.tevind[i].hex & 0x1fffff; // 21 bits
|
u32 val = bpmem.tevind[i].hex & 0x1fffff; // 21 bits
|
||||||
switch (i%3) {
|
switch (i%3) {
|
||||||
case 0: pcurvalue[0] = val; break;
|
case 0: pcurvalue[0] = val; break;
|
||||||
case 1: pcurvalue[0] |= val << 21; pcurvalue[1] = val >> 11; ++pcurvalue; break;
|
case 1: pcurvalue[0] |= val << 21; pcurvalue[1] = val >> 11; ++pcurvalue; break;
|
||||||
|
@ -121,9 +121,9 @@ void GetPixelShaderId(PIXELSHADERUID &uid, u32 s_texturemask, u32 dstAlphaEnable
|
||||||
|
|
||||||
// old tev->pixelshader notes
|
// old tev->pixelshader notes
|
||||||
//
|
//
|
||||||
// color for this stage (alpha, color) is given by sumem.tevorders[0].colorchan0
|
// color for this stage (alpha, color) is given by bpmem.tevorders[0].colorchan0
|
||||||
// konstant for this stage (alpha, color) is given by sumem.tevksel
|
// konstant for this stage (alpha, color) is given by bpmem.tevksel
|
||||||
// inputs are given by sumem.combiners[0].colorC.a/b/c/d << could be current chan color
|
// inputs are given by bpmem.combiners[0].colorC.a/b/c/d << could be current chan color
|
||||||
// according to GXTevColorArg table above
|
// according to GXTevColorArg table above
|
||||||
// output is given by .outreg
|
// output is given by .outreg
|
||||||
// tevtemp is set according to swapmodetables and
|
// tevtemp is set according to swapmodetables and
|
||||||
|
@ -356,13 +356,13 @@ static char text[16384];
|
||||||
|
|
||||||
static void BuildSwapModeTable()
|
static void BuildSwapModeTable()
|
||||||
{
|
{
|
||||||
//sumem.tevregs[0].
|
//bpmem.tevregs[0].
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
swapModeTable[i][0] = swapColors[sumem.tevksel[i*2].swap1];
|
swapModeTable[i][0] = swapColors[bpmem.tevksel[i*2].swap1];
|
||||||
swapModeTable[i][1] = swapColors[sumem.tevksel[i*2].swap2];
|
swapModeTable[i][1] = swapColors[bpmem.tevksel[i*2].swap2];
|
||||||
swapModeTable[i][2] = swapColors[sumem.tevksel[i*2+1].swap1];
|
swapModeTable[i][2] = swapColors[bpmem.tevksel[i*2+1].swap1];
|
||||||
swapModeTable[i][3] = swapColors[sumem.tevksel[i*2+1].swap2];
|
swapModeTable[i][3] = swapColors[bpmem.tevksel[i*2+1].swap2];
|
||||||
swapModeTable[i][4] = 0;
|
swapModeTable[i][4] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -373,19 +373,19 @@ const char *GeneratePixelShader(u32 texture_mask, bool dstAlphaEnable, bool HLSL
|
||||||
DVSTARTPROFILE();
|
DVSTARTPROFILE();
|
||||||
|
|
||||||
BuildSwapModeTable();
|
BuildSwapModeTable();
|
||||||
int numStages = sumem.genMode.numtevstages + 1;
|
int numStages = bpmem.genMode.numtevstages + 1;
|
||||||
int numTexgen = sumem.genMode.numtexgens;
|
int numTexgen = bpmem.genMode.numtexgens;
|
||||||
|
|
||||||
char *p = text;
|
char *p = text;
|
||||||
WRITE(p, "//Pixel Shader for TEV stages\n");
|
WRITE(p, "//Pixel Shader for TEV stages\n");
|
||||||
WRITE(p, "//%i TEV stages, %i texgens, %i IND stages\n",
|
WRITE(p, "//%i TEV stages, %i texgens, %i IND stages\n",
|
||||||
numStages, numTexgen, sumem.genMode.numindstages);
|
numStages, numTexgen, bpmem.genMode.numindstages);
|
||||||
|
|
||||||
int nIndirectStagesUsed = 0;
|
int nIndirectStagesUsed = 0;
|
||||||
if (sumem.genMode.numindstages > 0) {
|
if (bpmem.genMode.numindstages > 0) {
|
||||||
for (int i = 0; i < numStages; ++i) {
|
for (int i = 0; i < numStages; ++i) {
|
||||||
if (sumem.tevind[i].IsActive() && sumem.tevind[i].bt < sumem.genMode.numindstages) {
|
if (bpmem.tevind[i].IsActive() && bpmem.tevind[i].bt < bpmem.genMode.numindstages) {
|
||||||
nIndirectStagesUsed |= 1<<sumem.tevind[i].bt;
|
nIndirectStagesUsed |= 1<<bpmem.tevind[i].bt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -462,9 +462,9 @@ const char *GeneratePixelShader(u32 texture_mask, bool dstAlphaEnable, bool HLSL
|
||||||
}
|
}
|
||||||
|
|
||||||
// indirect texture map lookup
|
// indirect texture map lookup
|
||||||
for(u32 i = 0; i < sumem.genMode.numindstages; ++i) {
|
for(u32 i = 0; i < bpmem.genMode.numindstages; ++i) {
|
||||||
if (nIndirectStagesUsed & (1<<i)) {
|
if (nIndirectStagesUsed & (1<<i)) {
|
||||||
int texcoord = sumem.tevindref.getTexCoord(i);
|
int texcoord = bpmem.tevindref.getTexCoord(i);
|
||||||
|
|
||||||
if (texcoord < numTexgen) {
|
if (texcoord < numTexgen) {
|
||||||
WRITE(p, "tempcoord=uv%d.xy * "I_INDTEXSCALE"[%d].%s;\n", texcoord, i/2, (i&1)?"zw":"xy");
|
WRITE(p, "tempcoord=uv%d.xy * "I_INDTEXSCALE"[%d].%s;\n", texcoord, i/2, (i&1)?"zw":"xy");
|
||||||
|
@ -475,7 +475,7 @@ const char *GeneratePixelShader(u32 texture_mask, bool dstAlphaEnable, bool HLSL
|
||||||
|
|
||||||
char buffer[32];
|
char buffer[32];
|
||||||
sprintf(buffer, "float3 indtex%d", i);
|
sprintf(buffer, "float3 indtex%d", i);
|
||||||
SampleTexture(p, buffer, "tempcoord", "abg", sumem.tevindref.getTexMap(i), texture_mask);
|
SampleTexture(p, buffer, "tempcoord", "abg", bpmem.tevindref.getTexMap(i), texture_mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -495,17 +495,17 @@ const char *GeneratePixelShader(u32 texture_mask, bool dstAlphaEnable, bool HLSL
|
||||||
WRITE(p, "float zCoord = "I_ZBIAS"[1].x + (clipPos.z / clipPos.w) * "I_ZBIAS"[1].y;\n");
|
WRITE(p, "float zCoord = "I_ZBIAS"[1].x + (clipPos.z / clipPos.w) * "I_ZBIAS"[1].y;\n");
|
||||||
|
|
||||||
// use the texture input of the last texture stage (textemp), hopefully this has been read and is in correct format...
|
// use the texture input of the last texture stage (textemp), hopefully this has been read and is in correct format...
|
||||||
if (sumem.ztex2.op == ZTEXTURE_ADD) {
|
if (bpmem.ztex2.op == ZTEXTURE_ADD) {
|
||||||
WRITE(p, "depth = frac(dot("I_ZBIAS"[0].xyzw, textemp.xyzw) + "I_ZBIAS"[1].w + zCoord);\n");
|
WRITE(p, "depth = frac(dot("I_ZBIAS"[0].xyzw, textemp.xyzw) + "I_ZBIAS"[1].w + zCoord);\n");
|
||||||
}
|
}
|
||||||
else if (sumem.ztex2.op == ZTEXTURE_REPLACE) {
|
else if (bpmem.ztex2.op == ZTEXTURE_REPLACE) {
|
||||||
WRITE(p, "depth = frac(dot("I_ZBIAS"[0].xyzw, textemp.xyzw) + "I_ZBIAS"[1].w);\n");
|
WRITE(p, "depth = frac(dot("I_ZBIAS"[0].xyzw, textemp.xyzw) + "I_ZBIAS"[1].w);\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
WRITE(p, "depth = zCoord;\n");
|
WRITE(p, "depth = zCoord;\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (sumem.genMode.numindstages ) WRITE(p, "prev.rg = indtex0.xy;\nprev.b = 0;\n");
|
//if (bpmem.genMode.numindstages ) WRITE(p, "prev.rg = indtex0.xy;\nprev.b = 0;\n");
|
||||||
|
|
||||||
if (!WriteAlphaTest(p, HLSL)) {
|
if (!WriteAlphaTest(p, HLSL)) {
|
||||||
// alpha test will always fail, so restart the shader and just make it an empty function
|
// alpha test will always fail, so restart the shader and just make it an empty function
|
||||||
|
@ -530,13 +530,13 @@ const char *GeneratePixelShader(u32 texture_mask, bool dstAlphaEnable, bool HLSL
|
||||||
|
|
||||||
static void WriteStage(char *&p, int n, u32 texture_mask)
|
static void WriteStage(char *&p, int n, u32 texture_mask)
|
||||||
{
|
{
|
||||||
char *rasswap = swapModeTable[sumem.combiners[n].alphaC.rswap];
|
char *rasswap = swapModeTable[bpmem.combiners[n].alphaC.rswap];
|
||||||
char *texswap = swapModeTable[sumem.combiners[n].alphaC.tswap];
|
char *texswap = swapModeTable[bpmem.combiners[n].alphaC.tswap];
|
||||||
|
|
||||||
|
|
||||||
int texcoord = sumem.tevorders[n/2].getTexCoord(n&1);
|
int texcoord = bpmem.tevorders[n/2].getTexCoord(n&1);
|
||||||
bool bHasTexCoord = (u32)texcoord < sumem.genMode.numtexgens;
|
bool bHasTexCoord = (u32)texcoord < bpmem.genMode.numtexgens;
|
||||||
bool bHasIndStage = sumem.tevind[n].IsActive() && sumem.tevind[n].bt < sumem.genMode.numindstages;
|
bool bHasIndStage = bpmem.tevind[n].IsActive() && bpmem.tevind[n].bt < bpmem.genMode.numindstages;
|
||||||
|
|
||||||
// HACK to handle cases where the tex gen is not enabled
|
// HACK to handle cases where the tex gen is not enabled
|
||||||
if (!bHasTexCoord) {
|
if (!bHasTexCoord) {
|
||||||
|
@ -545,46 +545,46 @@ static void WriteStage(char *&p, int n, u32 texture_mask)
|
||||||
|
|
||||||
if (bHasIndStage) {
|
if (bHasIndStage) {
|
||||||
// perform the indirect op on the incoming regular coordinates using indtex%d as the offset coords
|
// perform the indirect op on the incoming regular coordinates using indtex%d as the offset coords
|
||||||
if (sumem.tevind[n].bs != ITBA_OFF) {
|
if (bpmem.tevind[n].bs != ITBA_OFF) {
|
||||||
// write the bump alpha
|
// write the bump alpha
|
||||||
|
|
||||||
if (sumem.tevind[n].fmt == ITF_8) {
|
if (bpmem.tevind[n].fmt == ITF_8) {
|
||||||
WRITE(p, "alphabump = indtex%d.%s %s;\n", sumem.tevind[n].bt,
|
WRITE(p, "alphabump = indtex%d.%s %s;\n", bpmem.tevind[n].bt,
|
||||||
tevIndAlphaSel[sumem.tevind[n].bs], tevIndAlphaScale[sumem.tevind[n].fmt]);
|
tevIndAlphaSel[bpmem.tevind[n].bs], tevIndAlphaScale[bpmem.tevind[n].fmt]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// donkopunchstania: really bad way to do this
|
// donkopunchstania: really bad way to do this
|
||||||
// cannot always use fract because fract(1.0) is 0.0 when it needs to be 1.0
|
// cannot always use fract because fract(1.0) is 0.0 when it needs to be 1.0
|
||||||
// omitting fract seems to work as well
|
// omitting fract seems to work as well
|
||||||
WRITE(p, "if (indtex%d.%s >= 1.0f )\n", sumem.tevind[n].bt,
|
WRITE(p, "if (indtex%d.%s >= 1.0f )\n", bpmem.tevind[n].bt,
|
||||||
tevIndAlphaSel[sumem.tevind[n].bs]);
|
tevIndAlphaSel[bpmem.tevind[n].bs]);
|
||||||
WRITE(p, " alphabump = 1.0f;\n");
|
WRITE(p, " alphabump = 1.0f;\n");
|
||||||
WRITE(p, "else\n");
|
WRITE(p, "else\n");
|
||||||
WRITE(p, " alphabump = fract ( indtex%d.%s %s );\n", sumem.tevind[n].bt,
|
WRITE(p, " alphabump = fract ( indtex%d.%s %s );\n", bpmem.tevind[n].bt,
|
||||||
tevIndAlphaSel[sumem.tevind[n].bs], tevIndAlphaScale[sumem.tevind[n].fmt]);
|
tevIndAlphaSel[bpmem.tevind[n].bs], tevIndAlphaScale[bpmem.tevind[n].fmt]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// format
|
// format
|
||||||
WRITE(p, "float3 indtevcrd%d = indtex%d * %s;\n", n, sumem.tevind[n].bt, tevIndFmtScale[sumem.tevind[n].fmt]);
|
WRITE(p, "float3 indtevcrd%d = indtex%d * %s;\n", n, bpmem.tevind[n].bt, tevIndFmtScale[bpmem.tevind[n].fmt]);
|
||||||
|
|
||||||
// bias
|
// bias
|
||||||
if (sumem.tevind[n].bias != ITB_NONE )
|
if (bpmem.tevind[n].bias != ITB_NONE )
|
||||||
WRITE(p, "indtevcrd%d.%s += %s;\n", n, tevIndBiasField[sumem.tevind[n].bias], tevIndBiasAdd[sumem.tevind[n].fmt]);
|
WRITE(p, "indtevcrd%d.%s += %s;\n", n, tevIndBiasField[bpmem.tevind[n].bias], tevIndBiasAdd[bpmem.tevind[n].fmt]);
|
||||||
|
|
||||||
// multiply by offset matrix and scale
|
// multiply by offset matrix and scale
|
||||||
if (sumem.tevind[n].mid != 0) {
|
if (bpmem.tevind[n].mid != 0) {
|
||||||
if (sumem.tevind[n].mid <= 3) {
|
if (bpmem.tevind[n].mid <= 3) {
|
||||||
int mtxidx = 2*(sumem.tevind[n].mid-1);
|
int mtxidx = 2*(bpmem.tevind[n].mid-1);
|
||||||
WRITE(p, "float2 indtevtrans%d = float2(dot("I_INDTEXMTX"[%d].xyz, indtevcrd%d), dot("I_INDTEXMTX"[%d].xyz, indtevcrd%d));\n",
|
WRITE(p, "float2 indtevtrans%d = float2(dot("I_INDTEXMTX"[%d].xyz, indtevcrd%d), dot("I_INDTEXMTX"[%d].xyz, indtevcrd%d));\n",
|
||||||
n, mtxidx, n, mtxidx+1, n);
|
n, mtxidx, n, mtxidx+1, n);
|
||||||
}
|
}
|
||||||
else if (sumem.tevind[n].mid <= 7 && bHasTexCoord) { // s matrix
|
else if (bpmem.tevind[n].mid <= 7 && bHasTexCoord) { // s matrix
|
||||||
int mtxidx = 2*(sumem.tevind[n].mid-5);
|
int mtxidx = 2*(bpmem.tevind[n].mid-5);
|
||||||
WRITE(p, "float2 indtevtrans%d = "I_INDTEXMTX"[%d].ww * uv%d.xy * indtevcrd%d.xx;\n", n, mtxidx, texcoord, n);
|
WRITE(p, "float2 indtevtrans%d = "I_INDTEXMTX"[%d].ww * uv%d.xy * indtevcrd%d.xx;\n", n, mtxidx, texcoord, n);
|
||||||
}
|
}
|
||||||
else if (sumem.tevind[n].mid <= 11 && bHasTexCoord) { // t matrix
|
else if (bpmem.tevind[n].mid <= 11 && bHasTexCoord) { // t matrix
|
||||||
int mtxidx = 2*(sumem.tevind[n].mid-9);
|
int mtxidx = 2*(bpmem.tevind[n].mid-9);
|
||||||
WRITE(p, "float2 indtevtrans%d = "I_INDTEXMTX"[%d].ww * uv%d.xy * indtevcrd%d.yy;\n", n, mtxidx, texcoord, n);
|
WRITE(p, "float2 indtevtrans%d = "I_INDTEXMTX"[%d].ww * uv%d.xy * indtevcrd%d.yy;\n", n, mtxidx, texcoord, n);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -598,28 +598,28 @@ static void WriteStage(char *&p, int n, u32 texture_mask)
|
||||||
// wrapping
|
// wrapping
|
||||||
|
|
||||||
// wrap S
|
// wrap S
|
||||||
if (sumem.tevind[n].sw == ITW_OFF) {
|
if (bpmem.tevind[n].sw == ITW_OFF) {
|
||||||
WRITE(p, "wrappedcoord.x = uv%d.x;\n", texcoord);
|
WRITE(p, "wrappedcoord.x = uv%d.x;\n", texcoord);
|
||||||
}
|
}
|
||||||
else if (sumem.tevind[n].sw == ITW_0) {
|
else if (bpmem.tevind[n].sw == ITW_0) {
|
||||||
WRITE(p, "wrappedcoord.x = 0.0f;\n");
|
WRITE(p, "wrappedcoord.x = 0.0f;\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
WRITE(p, "wrappedcoord.x = fmod( uv%d.x, %s );\n", texcoord, tevIndWrapStart[sumem.tevind[n].sw]);
|
WRITE(p, "wrappedcoord.x = fmod( uv%d.x, %s );\n", texcoord, tevIndWrapStart[bpmem.tevind[n].sw]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// wrap T
|
// wrap T
|
||||||
if (sumem.tevind[n].tw == ITW_OFF) {
|
if (bpmem.tevind[n].tw == ITW_OFF) {
|
||||||
WRITE(p, "wrappedcoord.y = uv%d.y;\n", texcoord);
|
WRITE(p, "wrappedcoord.y = uv%d.y;\n", texcoord);
|
||||||
}
|
}
|
||||||
else if (sumem.tevind[n].tw == ITW_0) {
|
else if (bpmem.tevind[n].tw == ITW_0) {
|
||||||
WRITE(p, "wrappedcoord.y = 0.0f;\n");
|
WRITE(p, "wrappedcoord.y = 0.0f;\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
WRITE(p, "wrappedcoord.y = fmod( uv%d.y, %s );\n", texcoord, tevIndWrapStart[sumem.tevind[n].tw]);
|
WRITE(p, "wrappedcoord.y = fmod( uv%d.y, %s );\n", texcoord, tevIndWrapStart[bpmem.tevind[n].tw]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sumem.tevind[n].fb_addprev) {
|
if (bpmem.tevind[n].fb_addprev) {
|
||||||
// add previous tevcoord
|
// add previous tevcoord
|
||||||
WRITE(p, "tevcoord.xy += wrappedcoord + indtevtrans%d;\n", n);
|
WRITE(p, "tevcoord.xy += wrappedcoord + indtevtrans%d;\n", n);
|
||||||
}
|
}
|
||||||
|
@ -628,10 +628,10 @@ static void WriteStage(char *&p, int n, u32 texture_mask)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WRITE(p, "rastemp=%s.%s;\n",tevRasTable[sumem.tevorders[n/2].getColorChan(n&1)],rasswap);
|
WRITE(p, "rastemp=%s.%s;\n",tevRasTable[bpmem.tevorders[n/2].getColorChan(n&1)],rasswap);
|
||||||
|
|
||||||
if (sumem.tevorders[n/2].getEnable(n&1)) {
|
if (bpmem.tevorders[n/2].getEnable(n&1)) {
|
||||||
int texmap = sumem.tevorders[n/2].getTexMap(n&1);
|
int texmap = bpmem.tevorders[n/2].getTexMap(n&1);
|
||||||
if(!bHasIndStage) {
|
if(!bHasIndStage) {
|
||||||
// calc tevcord
|
// calc tevcord
|
||||||
if(bHasTexCoord) {
|
if(bHasTexCoord) {
|
||||||
|
@ -646,11 +646,11 @@ static void WriteStage(char *&p, int n, u32 texture_mask)
|
||||||
else
|
else
|
||||||
WRITE(p, "textemp=float4(1,1,1,1);\n");
|
WRITE(p, "textemp=float4(1,1,1,1);\n");
|
||||||
|
|
||||||
int kc = sumem.tevksel[n/2].getKC(n&1);
|
int kc = bpmem.tevksel[n/2].getKC(n&1);
|
||||||
int ka = sumem.tevksel[n/2].getKA(n&1);
|
int ka = bpmem.tevksel[n/2].getKA(n&1);
|
||||||
|
|
||||||
TevStageCombiner::ColorCombiner &cc = sumem.combiners[n].colorC;
|
TevStageCombiner::ColorCombiner &cc = bpmem.combiners[n].colorC;
|
||||||
TevStageCombiner::AlphaCombiner &ac = sumem.combiners[n].alphaC;
|
TevStageCombiner::AlphaCombiner &ac = bpmem.combiners[n].alphaC;
|
||||||
|
|
||||||
bool bCKonst = cc.a == TEVCOLORARG_KONST || cc.b == TEVCOLORARG_KONST || cc.c == TEVCOLORARG_KONST || cc.d == TEVCOLORARG_KONST;
|
bool bCKonst = cc.a == TEVCOLORARG_KONST || cc.b == TEVCOLORARG_KONST || cc.c == TEVCOLORARG_KONST || cc.d == TEVCOLORARG_KONST;
|
||||||
bool bAKonst = ac.a == TEVALPHAARG_KONST || ac.b == TEVALPHAARG_KONST || ac.c == TEVALPHAARG_KONST || ac.d == TEVALPHAARG_KONST;
|
bool bAKonst = ac.a == TEVALPHAARG_KONST || ac.b == TEVALPHAARG_KONST || ac.c == TEVALPHAARG_KONST || ac.d == TEVALPHAARG_KONST;
|
||||||
|
@ -797,8 +797,8 @@ static void WriteAlphaCompare(char *&p, int num, int comp)
|
||||||
|
|
||||||
static bool WriteAlphaTest(char *&p, bool HLSL)
|
static bool WriteAlphaTest(char *&p, bool HLSL)
|
||||||
{
|
{
|
||||||
u32 op = sumem.alphaFunc.logic;
|
u32 op = bpmem.alphaFunc.logic;
|
||||||
u32 comp[2] = {sumem.alphaFunc.comp0,sumem.alphaFunc.comp1};
|
u32 comp[2] = {bpmem.alphaFunc.comp0,bpmem.alphaFunc.comp1};
|
||||||
|
|
||||||
//first kill all the simple cases
|
//first kill all the simple cases
|
||||||
switch(op) {
|
switch(op) {
|
||||||
|
@ -839,26 +839,26 @@ static bool WriteAlphaTest(char *&p, bool HLSL)
|
||||||
else {
|
else {
|
||||||
WRITE(p, "discard( ");
|
WRITE(p, "discard( ");
|
||||||
}
|
}
|
||||||
WriteAlphaCompare(p, 0, sumem.alphaFunc.comp0);
|
WriteAlphaCompare(p, 0, bpmem.alphaFunc.comp0);
|
||||||
|
|
||||||
// negated because testing the inverse condition
|
// negated because testing the inverse condition
|
||||||
switch (sumem.alphaFunc.logic) {
|
switch (bpmem.alphaFunc.logic) {
|
||||||
case 0: WRITE(p, " || "); break; // and
|
case 0: WRITE(p, " || "); break; // and
|
||||||
case 1: WRITE(p, " && "); break; // or
|
case 1: WRITE(p, " && "); break; // or
|
||||||
case 2: WRITE(p, " == "); break; // xor
|
case 2: WRITE(p, " == "); break; // xor
|
||||||
case 3: WRITE(p, " != "); break; // xnor
|
case 3: WRITE(p, " != "); break; // xnor
|
||||||
}
|
}
|
||||||
WriteAlphaCompare(p, 1, sumem.alphaFunc.comp1);
|
WriteAlphaCompare(p, 1, bpmem.alphaFunc.comp1);
|
||||||
WRITE(p, ");\n");
|
WRITE(p, ");\n");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void WriteFog(char *&p)
|
static void WriteFog(char *&p)
|
||||||
{
|
{
|
||||||
bool enabled = sumem.fog.c_proj_fsel.fsel == 0 ? false : true;
|
bool enabled = bpmem.fog.c_proj_fsel.fsel == 0 ? false : true;
|
||||||
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
if (sumem.fog.c_proj_fsel.proj == 0) {
|
if (bpmem.fog.c_proj_fsel.proj == 0) {
|
||||||
// perspective
|
// perspective
|
||||||
// ze = A/(B - Zs)
|
// ze = A/(B - Zs)
|
||||||
WRITE (p, " float ze = "I_FOG"[1].x / ("I_FOG"[1].y - depth);\n");
|
WRITE (p, " float ze = "I_FOG"[1].x / ("I_FOG"[1].y - depth);\n");
|
||||||
|
@ -871,7 +871,7 @@ static void WriteFog(char *&p)
|
||||||
WRITE (p, " float fog = clamp(ze - "I_FOG"[1].z, 0.0f, 1.0f);\n");
|
WRITE (p, " float fog = clamp(ze - "I_FOG"[1].z, 0.0f, 1.0f);\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (sumem.fog.c_proj_fsel.fsel) {
|
switch (bpmem.fog.c_proj_fsel.fsel) {
|
||||||
case 2: // linear
|
case 2: // linear
|
||||||
// empty
|
// empty
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -99,7 +99,7 @@ void PixelShaderManager::SetConstants()
|
||||||
{
|
{
|
||||||
static float ffrac = 255.0f/256.0f;
|
static float ffrac = 255.0f/256.0f;
|
||||||
float ftemp[4];
|
float ftemp[4];
|
||||||
switch (sumem.ztex2.type)
|
switch (bpmem.ztex2.type)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
// 8 bits
|
// 8 bits
|
||||||
|
@ -122,7 +122,7 @@ void PixelShaderManager::SetConstants()
|
||||||
|
|
||||||
if (s_bZBiasChanged || s_bDepthRangeChanged)
|
if (s_bZBiasChanged || s_bDepthRangeChanged)
|
||||||
{
|
{
|
||||||
//ERROR_LOG("pixel=%x,%x, bias=%x\n", sumem.zcontrol.pixel_format, sumem.ztex2.type, lastZBias);
|
//ERROR_LOG("pixel=%x,%x, bias=%x\n", bpmem.zcontrol.pixel_format, bpmem.ztex2.type, lastZBias);
|
||||||
SetPSConstant4f(C_ZBIAS+1, lastDepthRange[0] / 16777216.0f, lastDepthRange[1] / 16777216.0f, 0, (float)( (((int)lastZBias<<8)>>8))/16777216.0f);
|
SetPSConstant4f(C_ZBIAS+1, lastDepthRange[0] / 16777216.0f, lastDepthRange[1] / 16777216.0f, 0, (float)( (((int)lastZBias<<8)>>8))/16777216.0f);
|
||||||
s_bZBiasChanged = s_bDepthRangeChanged = false;
|
s_bZBiasChanged = s_bDepthRangeChanged = false;
|
||||||
}
|
}
|
||||||
|
@ -137,8 +137,8 @@ void PixelShaderManager::SetConstants()
|
||||||
{
|
{
|
||||||
for (u32 i = 0; i < 2; ++i)
|
for (u32 i = 0; i < 2; ++i)
|
||||||
{
|
{
|
||||||
f[2 * i] = sumem.texscale[0].getScaleS(i & 1);
|
f[2 * i] = bpmem.texscale[0].getScaleS(i & 1);
|
||||||
f[2 * i + 1] = sumem.texscale[0].getScaleT(i & 1);
|
f[2 * i + 1] = bpmem.texscale[0].getScaleT(i & 1);
|
||||||
PRIM_LOG("tex indscale%d: %f %f\n", i, f[2 * i], f[2 * i + 1]);
|
PRIM_LOG("tex indscale%d: %f %f\n", i, f[2 * i], f[2 * i + 1]);
|
||||||
}
|
}
|
||||||
SetPSConstant4fv(C_INDTEXSCALE, f);
|
SetPSConstant4fv(C_INDTEXSCALE, f);
|
||||||
|
@ -146,8 +146,8 @@ void PixelShaderManager::SetConstants()
|
||||||
|
|
||||||
if (s_nIndTexScaleChanged & 0x0c) {
|
if (s_nIndTexScaleChanged & 0x0c) {
|
||||||
for (u32 i = 2; i < 4; ++i) {
|
for (u32 i = 2; i < 4; ++i) {
|
||||||
f[2 * i] = sumem.texscale[1].getScaleS(i & 1);
|
f[2 * i] = bpmem.texscale[1].getScaleS(i & 1);
|
||||||
f[2 * i + 1] = sumem.texscale[1].getScaleT(i & 1);
|
f[2 * i + 1] = bpmem.texscale[1].getScaleT(i & 1);
|
||||||
PRIM_LOG("tex indscale%d: %f %f\n", i, f[2 * i], f[2 * i + 1]);
|
PRIM_LOG("tex indscale%d: %f %f\n", i, f[2 * i], f[2 * i + 1]);
|
||||||
}
|
}
|
||||||
SetPSConstant4fv(C_INDTEXSCALE+1, &f[4]);
|
SetPSConstant4fv(C_INDTEXSCALE+1, &f[4]);
|
||||||
|
@ -162,28 +162,28 @@ void PixelShaderManager::SetConstants()
|
||||||
{
|
{
|
||||||
if (s_nIndTexMtxChanged & (1 << i))
|
if (s_nIndTexMtxChanged & (1 << i))
|
||||||
{
|
{
|
||||||
int scale = ((u32)sumem.indmtx[i].col0.s0 << 0) |
|
int scale = ((u32)bpmem.indmtx[i].col0.s0 << 0) |
|
||||||
((u32)sumem.indmtx[i].col1.s1 << 2) |
|
((u32)bpmem.indmtx[i].col1.s1 << 2) |
|
||||||
((u32)sumem.indmtx[i].col2.s2 << 4);
|
((u32)bpmem.indmtx[i].col2.s2 << 4);
|
||||||
float fscale = powf(2.0f, (float)(scale - 17)) / 1024.0f;
|
float fscale = powf(2.0f, (float)(scale - 17)) / 1024.0f;
|
||||||
|
|
||||||
// xyz - static matrix
|
// xyz - static matrix
|
||||||
// TODO w - dynamic matrix scale / 256...... somehow / 4 works better
|
// TODO w - dynamic matrix scale / 256...... somehow / 4 works better
|
||||||
// rev 2972 - now using / 256.... verify that this works
|
// rev 2972 - now using / 256.... verify that this works
|
||||||
SetPSConstant4f(C_INDTEXMTX + 2 * i,
|
SetPSConstant4f(C_INDTEXMTX + 2 * i,
|
||||||
sumem.indmtx[i].col0.ma * fscale,
|
bpmem.indmtx[i].col0.ma * fscale,
|
||||||
sumem.indmtx[i].col1.mc * fscale,
|
bpmem.indmtx[i].col1.mc * fscale,
|
||||||
sumem.indmtx[i].col2.me * fscale,
|
bpmem.indmtx[i].col2.me * fscale,
|
||||||
fscale * 4.0f);
|
fscale * 4.0f);
|
||||||
SetPSConstant4f(C_INDTEXMTX + 2 * i + 1,
|
SetPSConstant4f(C_INDTEXMTX + 2 * i + 1,
|
||||||
sumem.indmtx[i].col0.mb * fscale,
|
bpmem.indmtx[i].col0.mb * fscale,
|
||||||
sumem.indmtx[i].col1.md * fscale,
|
bpmem.indmtx[i].col1.md * fscale,
|
||||||
sumem.indmtx[i].col2.mf * fscale,
|
bpmem.indmtx[i].col2.mf * fscale,
|
||||||
fscale * 4.0f);
|
fscale * 4.0f);
|
||||||
|
|
||||||
PRIM_LOG("indmtx%d: scale=%f, mat=(%f %f %f; %f %f %f)\n", i,
|
PRIM_LOG("indmtx%d: scale=%f, mat=(%f %f %f; %f %f %f)\n", i,
|
||||||
1024.0f*fscale, sumem.indmtx[i].col0.ma * fscale, sumem.indmtx[i].col1.mc * fscale, sumem.indmtx[i].col2.me * fscale,
|
1024.0f*fscale, bpmem.indmtx[i].col0.ma * fscale, bpmem.indmtx[i].col1.mc * fscale, bpmem.indmtx[i].col2.me * fscale,
|
||||||
sumem.indmtx[i].col0.mb * fscale, sumem.indmtx[i].col1.md * fscale, sumem.indmtx[i].col2.mf * fscale, fscale);
|
bpmem.indmtx[i].col0.mb * fscale, bpmem.indmtx[i].col1.md * fscale, bpmem.indmtx[i].col2.mf * fscale, fscale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s_nIndTexMtxChanged = 0;
|
s_nIndTexMtxChanged = 0;
|
||||||
|
@ -191,15 +191,15 @@ void PixelShaderManager::SetConstants()
|
||||||
|
|
||||||
if (s_bFogColorChanged)
|
if (s_bFogColorChanged)
|
||||||
{
|
{
|
||||||
SetPSConstant4f(C_FOG, sumem.fog.color.r / 255.0f, sumem.fog.color.g / 255.0f, sumem.fog.color.b / 255.0f, 0);
|
SetPSConstant4f(C_FOG, bpmem.fog.color.r / 255.0f, bpmem.fog.color.g / 255.0f, bpmem.fog.color.b / 255.0f, 0);
|
||||||
s_bFogColorChanged = false;
|
s_bFogColorChanged = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_bFogParamChanged)
|
if (s_bFogParamChanged)
|
||||||
{
|
{
|
||||||
float a = sumem.fog.a.GetA() * ((float)(1 << sumem.fog.b_shift));
|
float a = bpmem.fog.a.GetA() * ((float)(1 << bpmem.fog.b_shift));
|
||||||
float b = ((float)sumem.fog.b_magnitude / 8388638) * ((float)(1 << (sumem.fog.b_shift - 1)));
|
float b = ((float)bpmem.fog.b_magnitude / 8388638) * ((float)(1 << (bpmem.fog.b_shift - 1)));
|
||||||
SetPSConstant4f(C_FOG + 1, a, b, sumem.fog.c_proj_fsel.GetC(), 0);
|
SetPSConstant4f(C_FOG + 1, a, b, bpmem.fog.c_proj_fsel.GetC(), 0);
|
||||||
s_bFogParamChanged = false;
|
s_bFogParamChanged = false;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
|
@ -214,7 +214,7 @@ void PixelShaderManager::SetPSTextureDims(int texid)
|
||||||
float fdims[4];
|
float fdims[4];
|
||||||
if (s_texturemask & (1 << texid))
|
if (s_texturemask & (1 << texid))
|
||||||
{
|
{
|
||||||
TCoordInfo& tc = sumem.texcoords[texid];
|
TCoordInfo& tc = bpmem.texcoords[texid];
|
||||||
fdims[0] = (float)(lastTexDims[texid] & 0xffff);
|
fdims[0] = (float)(lastTexDims[texid] & 0xffff);
|
||||||
fdims[1] = (float)((lastTexDims[texid] >> 16) & 0xfff);
|
fdims[1] = (float)((lastTexDims[texid] >> 16) & 0xfff);
|
||||||
fdims[2] = (float)(tc.s.scale_minus_1 + 1)*lastCustomTexScale[texid][0];
|
fdims[2] = (float)(tc.s.scale_minus_1 + 1)*lastCustomTexScale[texid][0];
|
||||||
|
@ -222,7 +222,7 @@ void PixelShaderManager::SetPSTextureDims(int texid)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TCoordInfo& tc = sumem.texcoords[texid];
|
TCoordInfo& tc = bpmem.texcoords[texid];
|
||||||
fdims[0] = 1.0f / (float)(lastTexDims[texid] & 0xffff);
|
fdims[0] = 1.0f / (float)(lastTexDims[texid] & 0xffff);
|
||||||
fdims[1] = 1.0f / (float)((lastTexDims[texid] >> 16) & 0xfff);
|
fdims[1] = 1.0f / (float)((lastTexDims[texid] >> 16) & 0xfff);
|
||||||
fdims[2] = (float)(tc.s.scale_minus_1 + 1) * lastCustomTexScale[texid][0];
|
fdims[2] = (float)(tc.s.scale_minus_1 + 1) * lastCustomTexScale[texid][0];
|
||||||
|
@ -235,10 +235,10 @@ void PixelShaderManager::SetPSTextureDims(int texid)
|
||||||
|
|
||||||
void PixelShaderManager::SetColorChanged(int type, int num)
|
void PixelShaderManager::SetColorChanged(int type, int num)
|
||||||
{
|
{
|
||||||
int r = sumem.tevregs[num].low.a;
|
int r = bpmem.tevregs[num].low.a;
|
||||||
int a = sumem.tevregs[num].low.b;
|
int a = bpmem.tevregs[num].low.b;
|
||||||
int b = sumem.tevregs[num].high.a;
|
int b = bpmem.tevregs[num].high.a;
|
||||||
int g = sumem.tevregs[num].high.b;
|
int g = bpmem.tevregs[num].high.b;
|
||||||
float *pf = &lastRGBAfull[type][num][0];
|
float *pf = &lastRGBAfull[type][num][0];
|
||||||
pf[0] = (float)r / 255.0f;
|
pf[0] = (float)r / 255.0f;
|
||||||
pf[1] = (float)g / 255.0f;
|
pf[1] = (float)g / 255.0f;
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#ifndef _PIXELSHADERMANAGER_H
|
#ifndef _PIXELSHADERMANAGER_H
|
||||||
#define _PIXELSHADERMANAGER_H
|
#define _PIXELSHADERMANAGER_H
|
||||||
|
|
||||||
#include "SUMemory.h"
|
#include "BPMemory.h"
|
||||||
#include "PixelShaderGen.h"
|
#include "PixelShaderGen.h"
|
||||||
|
|
||||||
void SetPSConstant4f(int const_number, float f1, float f2, float f3, float f4);
|
void SetPSConstant4f(int const_number, float f1, float f2, float f3, float f4);
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
Import('env')
|
Import('env')
|
||||||
|
|
||||||
files = [
|
files = [
|
||||||
'SUMemory.cpp',
|
'BPMemory.cpp',
|
||||||
'CPMemory.cpp',
|
'CPMemory.cpp',
|
||||||
'XFMemory.cpp',
|
'XFMemory.cpp',
|
||||||
'XFStructs.cpp',
|
'XFStructs.cpp',
|
||||||
'SUStructs.cpp',
|
'BPStructs.cpp',
|
||||||
'memcpy_amd.cpp',
|
'memcpy_amd.cpp',
|
||||||
'LookUpTables.cpp',
|
'LookUpTables.cpp',
|
||||||
'OpcodeDecoding.cpp',
|
'OpcodeDecoding.cpp',
|
||||||
|
|
|
@ -1,595 +0,0 @@
|
||||||
// Copyright (C) 2003-2009 Dolphin Project.
|
|
||||||
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, version 2.0.
|
|
||||||
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License 2.0 for more details.
|
|
||||||
|
|
||||||
// A copy of the GPL 2.0 should have been included with the program.
|
|
||||||
// If not, see http://www.gnu.org/licenses/
|
|
||||||
|
|
||||||
// Official SVN repository and contact information can be found at
|
|
||||||
// http://code.google.com/p/dolphin-emu/
|
|
||||||
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
#include "Profiler.h"
|
|
||||||
#include "Statistics.h"
|
|
||||||
#include "VideoCommon.h"
|
|
||||||
#include "PixelShaderManager.h"
|
|
||||||
#include "SUFunctions.h"
|
|
||||||
#include "SUStructs.h"
|
|
||||||
#include "TextureDecoder.h"
|
|
||||||
#include "OpcodeDecoding.h"
|
|
||||||
#include "VertexLoader.h"
|
|
||||||
#include "VertexShaderManager.h"
|
|
||||||
|
|
||||||
using namespace SUFunctions;
|
|
||||||
|
|
||||||
void SUInit()
|
|
||||||
{
|
|
||||||
memset(&sumem, 0, sizeof(sumem));
|
|
||||||
sumem.suMask = 0xFFFFFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------------------------
|
|
||||||
// Write the bypass command to the Setup/Rasterization Memory
|
|
||||||
/* ------------------
|
|
||||||
Called:
|
|
||||||
At the end of every: OpcodeDecoding.cpp ExecuteDisplayList > Decode() > LoadSUReg
|
|
||||||
TODO:
|
|
||||||
Turn into function table. The (future) DisplayList (DL) jit can then call the functions directly,
|
|
||||||
getting rid of dynamic dispatch. Unfortunately, few games use DLs properly - most\
|
|
||||||
just stuff geometry in them and don't put state changes there. */
|
|
||||||
// ----------------------------------------------------------------------------------------------------------
|
|
||||||
void SUWritten(const BPCommand& bp)
|
|
||||||
{
|
|
||||||
// --------------------------------------------------------------------------------------------------------
|
|
||||||
// First the pipeline is flushed then update the sumem with the new value.
|
|
||||||
// Some of the BP cases have to call certain functions while others just update the sumem.
|
|
||||||
// some bp cases check the changes variable, because they might not have to be updated all the time
|
|
||||||
// NOTE: it seems not all su cases like checking changes, so calling if (bp.changes == 0 ? false : true)
|
|
||||||
// had to be ditched and the games seem to work fine with out it.
|
|
||||||
// --------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Debugging only, this lets you skip a bp update
|
|
||||||
//static int times = 0;
|
|
||||||
//static bool enable = false;
|
|
||||||
|
|
||||||
//switch (bp.address)
|
|
||||||
//{
|
|
||||||
//case SUMEM_CONSTANTALPHA:
|
|
||||||
// {
|
|
||||||
// if (times-- == 0 && enable)
|
|
||||||
// return;
|
|
||||||
// else
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
//default: break;
|
|
||||||
//}
|
|
||||||
|
|
||||||
FlushPipeline();
|
|
||||||
((u32*)&sumem)[bp.address] = bp.newvalue;
|
|
||||||
|
|
||||||
switch (bp.address)
|
|
||||||
{
|
|
||||||
case SUMEM_GENMODE: // Set the Generation Mode
|
|
||||||
{
|
|
||||||
PRIM_LOG("genmode: texgen=%d, col=%d, ms_en=%d, tev=%d, culmode=%d, ind=%d, zfeeze=%d",
|
|
||||||
sumem.genMode.numtexgens, sumem.genMode.numcolchans,
|
|
||||||
sumem.genMode.ms_en, sumem.genMode.numtevstages+1, sumem.genMode.cullmode,
|
|
||||||
sumem.genMode.numindstages, sumem.genMode.zfreeze);
|
|
||||||
SetGenerationMode(bp);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SUMEM_IND_MTXA: // Index Matrix Changed
|
|
||||||
case SUMEM_IND_MTXB:
|
|
||||||
case SUMEM_IND_MTXC:
|
|
||||||
case SUMEM_IND_MTXA+3:
|
|
||||||
case SUMEM_IND_MTXB+3:
|
|
||||||
case SUMEM_IND_MTXC+3:
|
|
||||||
case SUMEM_IND_MTXA+6:
|
|
||||||
case SUMEM_IND_MTXB+6:
|
|
||||||
case SUMEM_IND_MTXC+6:
|
|
||||||
PixelShaderManager::SetIndMatrixChanged((bp.address - SUMEM_IND_MTXA) / 3);
|
|
||||||
break;
|
|
||||||
case SUMEM_RAS1_SS0: // Index Texture Coordinate Scale 0
|
|
||||||
PixelShaderManager::SetIndTexScaleChanged(0x03);
|
|
||||||
case SUMEM_RAS1_SS1: // Index Texture Coordinate Scale 1
|
|
||||||
PixelShaderManager::SetIndTexScaleChanged(0x0c);
|
|
||||||
break;
|
|
||||||
case SUMEM_SCISSORTL: // Scissor Rectable Top, Left
|
|
||||||
case SUMEM_SCISSORBR: // Scissor Rectable Bottom, Right
|
|
||||||
case SUMEM_SCISSOROFFSET: // Scissor Offset
|
|
||||||
SetScissor(bp);
|
|
||||||
break;
|
|
||||||
case SUMEM_LINEPTWIDTH: // Line Width
|
|
||||||
SetLineWidth(bp);
|
|
||||||
break;
|
|
||||||
case SUMEM_ZMODE: // Depth Control
|
|
||||||
PRIM_LOG("zmode: test=%d, func=%d, upd=%d", sumem.zmode.testenable, sumem.zmode.func,
|
|
||||||
sumem.zmode.updateenable);
|
|
||||||
SetDepthMode(bp);
|
|
||||||
break;
|
|
||||||
case SUMEM_BLENDMODE: // Blending Control
|
|
||||||
{
|
|
||||||
if (bp.changes & 0xFFFF)
|
|
||||||
{
|
|
||||||
PRIM_LOG("blendmode: en=%d, open=%d, colupd=%d, alphaupd=%d, dst=%d, src=%d, sub=%d, mode=%d",
|
|
||||||
sumem.blendmode.blendenable, sumem.blendmode.logicopenable, sumem.blendmode.colorupdate, sumem.blendmode.alphaupdate,
|
|
||||||
sumem.blendmode.dstfactor, sumem.blendmode.srcfactor, sumem.blendmode.subtract, sumem.blendmode.logicmode);
|
|
||||||
// Set LogicOp Blending Mode
|
|
||||||
if (bp.changes & 2)
|
|
||||||
{
|
|
||||||
SETSTAT(stats.logicOpMode, sumem.blendmode.logicopenable != 0 ? sumem.blendmode.logicmode : stats.logicOpMode);
|
|
||||||
SetLogicOpMode(bp);
|
|
||||||
}
|
|
||||||
// Set Dithering Mode
|
|
||||||
if (bp.changes & 4)
|
|
||||||
{
|
|
||||||
SETSTAT(stats.dither, sumem.blendmode.dither);
|
|
||||||
SetDitherMode(bp);
|
|
||||||
}
|
|
||||||
// Set Blending Mode
|
|
||||||
if (bp.changes & 0xFE1)
|
|
||||||
{
|
|
||||||
SETSTAT(stats.srcFactor, sumem.blendmode.srcfactor);
|
|
||||||
SETSTAT(stats.dstFactor, sumem.blendmode.dstfactor);
|
|
||||||
SetBlendMode(bp);
|
|
||||||
}
|
|
||||||
// Set Color Mask
|
|
||||||
if (bp.changes & 0x18)
|
|
||||||
{
|
|
||||||
SETSTAT(stats.alphaUpdate, sumem.blendmode.alphaupdate);
|
|
||||||
SETSTAT(stats.colorUpdate, sumem.blendmode.colorupdate);
|
|
||||||
SetColorMask(bp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SUMEM_CONSTANTALPHA: // Set Destination Alpha
|
|
||||||
{
|
|
||||||
PRIM_LOG("constalpha: alp=%d, en=%d", sumem.dstalpha.alpha, sumem.dstalpha.enable);
|
|
||||||
SETSTAT(stats.dstAlphaEnable, sumem.dstalpha.enable);
|
|
||||||
SETSTAT_UINT(stats.dstAlpha, sumem.dstalpha.alpha);
|
|
||||||
PixelShaderManager::SetDestAlpha(sumem.dstalpha);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// This is called when the game is done drawing the new frame (eg: like in DX: Begin(); Draw(); End();)
|
|
||||||
case SUMEM_SETDRAWDONE:
|
|
||||||
switch (bp.newvalue & 0xFF)
|
|
||||||
{
|
|
||||||
case 0x02:
|
|
||||||
g_VideoInitialize.pSetPEFinish(); // may generate interrupt
|
|
||||||
DEBUG_LOG(VIDEO, "GXSetDrawDone SetPEFinish (value: 0x%02X)", (bp.newvalue & 0xFFFF));
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
WARN_LOG(VIDEO, "GXSetDrawDone ??? (value 0x%02X)", (bp.newvalue & 0xFFFF));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SUMEM_PE_TOKEN_ID: // Pixel Engine Token ID
|
|
||||||
g_VideoInitialize.pSetPEToken(static_cast<u16>(bp.newvalue & 0xFFFF), FALSE);
|
|
||||||
DEBUG_LOG(VIDEO, "SetPEToken 0x%04x", (bp.newvalue & 0xFFFF));
|
|
||||||
break;
|
|
||||||
case SUMEM_PE_TOKEN_INT_ID: // Pixel Engine Interrupt Token ID
|
|
||||||
g_VideoInitialize.pSetPEToken(static_cast<u16>(bp.newvalue & 0xFFFF), TRUE);
|
|
||||||
DEBUG_LOG(VIDEO, "SetPEToken + INT 0x%04x", (bp.newvalue & 0xFFFF));
|
|
||||||
break;
|
|
||||||
// ------------------------
|
|
||||||
// EFB copy command. This copies a rectangle from the EFB to either RAM in a texture format or to XFB as YUYV.
|
|
||||||
// It can also optionally clear the EFB while copying from it. To emulate this, we of course copy first and clear afterwards.
|
|
||||||
case SUMEM_TRIGGER_EFB_COPY: // Copy EFB Region or Render to the XFB or Clear the screen.
|
|
||||||
{
|
|
||||||
DVSTARTSUBPROFILE("LoadSUReg:swap");
|
|
||||||
// The bottom right is within the rectangle
|
|
||||||
// The values in sumem.copyTexSrcXY and sumem.copyTexSrcWH are updated in case 0x49 and 0x4a in this function
|
|
||||||
TRectangle rc = {
|
|
||||||
(int)(sumem.copyTexSrcXY.x),
|
|
||||||
(int)(sumem.copyTexSrcXY.y),
|
|
||||||
(int)((sumem.copyTexSrcXY.x + sumem.copyTexSrcWH.x + 1)),
|
|
||||||
(int)((sumem.copyTexSrcXY.y + sumem.copyTexSrcWH.y + 1))
|
|
||||||
};
|
|
||||||
|
|
||||||
float MValueX = GetRendererTargetScaleX();
|
|
||||||
float MValueY = GetRendererTargetScaleY();
|
|
||||||
|
|
||||||
// Need another rc here to get it to scale.
|
|
||||||
// Here the bottom right is the out of the rectangle.
|
|
||||||
TRectangle multirc = {
|
|
||||||
(int)(sumem.copyTexSrcXY.x * MValueX),
|
|
||||||
(int)(sumem.copyTexSrcXY.y * MValueY),
|
|
||||||
(int)((sumem.copyTexSrcXY.x * MValueX + (sumem.copyTexSrcWH.x + 1) * MValueX)),
|
|
||||||
(int)((sumem.copyTexSrcXY.y * MValueY + (sumem.copyTexSrcWH.y + 1) * MValueY))
|
|
||||||
};
|
|
||||||
UPE_Copy PE_copy;
|
|
||||||
PE_copy.Hex = sumem.triggerEFBCopy;
|
|
||||||
|
|
||||||
// Check if we are to copy from the EFB or draw to the XFB
|
|
||||||
if (PE_copy.copy_to_xfb == 0)
|
|
||||||
{
|
|
||||||
if (GetConfig(CONFIG_SHOWEFBREGIONS))
|
|
||||||
stats.efb_regions.push_back(rc);
|
|
||||||
|
|
||||||
CopyEFB(bp, rc, sumem.copyTexDest << 5,
|
|
||||||
sumem.zcontrol.pixel_format == PIXELFMT_Z24,
|
|
||||||
PE_copy.intensity_fmt > 0,
|
|
||||||
((PE_copy.target_pixel_format / 2) + ((PE_copy.target_pixel_format & 1) * 8)),
|
|
||||||
PE_copy.half_scale > 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// the number of lines copied is determined by the y scale * source efb height
|
|
||||||
const float yScale = sumem.dispcopyyscale / 256.0f;
|
|
||||||
const float xfbLines = ((sumem.copyTexSrcWH.y + 1.0f) * yScale);
|
|
||||||
RenderToXFB(bp, multirc, yScale, xfbLines,
|
|
||||||
Memory_GetPtr(sumem.copyTexDest << 5),
|
|
||||||
sumem.copyMipMapStrideChannels << 4,
|
|
||||||
(u32)ceil(xfbLines));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear the picture after it's done and submitted, to prepare for the next picture
|
|
||||||
if (PE_copy.clear)
|
|
||||||
ClearScreen(bp, multirc);
|
|
||||||
|
|
||||||
RestoreRenderState(bp);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SUMEM_LOADTLUT0: // Load a Texture Look Up Table
|
|
||||||
case SUMEM_LOADTLUT1:
|
|
||||||
{
|
|
||||||
DVSTARTSUBPROFILE("LoadSUReg:GXLoadTlut");
|
|
||||||
|
|
||||||
u32 tlutTMemAddr = (bp.newvalue & 0x3FF) << 9;
|
|
||||||
u32 tlutXferCount = (bp.newvalue & 0x1FFC00) >> 5;
|
|
||||||
|
|
||||||
u8 *ptr = 0;
|
|
||||||
|
|
||||||
// TODO - figure out a cleaner way.
|
|
||||||
if (GetConfig(CONFIG_ISWII))
|
|
||||||
ptr = GetPointer(sumem.tlutXferSrc << 5);
|
|
||||||
else
|
|
||||||
ptr = GetPointer((sumem.tlutXferSrc & 0xFFFFF) << 5);
|
|
||||||
|
|
||||||
if (ptr)
|
|
||||||
memcpy_gc(texMem + tlutTMemAddr, ptr, tlutXferCount);
|
|
||||||
else
|
|
||||||
PanicAlert("Invalid palette pointer %08x %08x %08x", sumem.tlutXferSrc, sumem.tlutXferSrc << 5, (sumem.tlutXferSrc & 0xFFFFF)<< 5);
|
|
||||||
|
|
||||||
// TODO(ector) : kill all textures that use this palette
|
|
||||||
// Not sure if it's a good idea, though. For now, we hash texture palettes
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SUMEM_FOGRANGE: // Fog Settings Control
|
|
||||||
case SUMEM_FOGPARAM0:
|
|
||||||
case SUMEM_FOGBMAGNITUDE:
|
|
||||||
case SUMEM_FOGBEXPONENT:
|
|
||||||
case SUMEM_FOGPARAM3:
|
|
||||||
if(!GetConfig(CONFIG_DISABLEFOG))
|
|
||||||
PixelShaderManager::SetFogParamChanged();
|
|
||||||
break;
|
|
||||||
case SUMEM_FOGCOLOR: // Fog Color
|
|
||||||
PixelShaderManager::SetFogColorChanged();
|
|
||||||
break;
|
|
||||||
case SUMEM_ALPHACOMPARE: // Compare Alpha Values
|
|
||||||
PRIM_LOG("alphacmp: ref0=%d, ref1=%d, comp0=%d, comp1=%d, logic=%d", sumem.alphaFunc.ref0,
|
|
||||||
sumem.alphaFunc.ref1, sumem.alphaFunc.comp0, sumem.alphaFunc.comp1, sumem.alphaFunc.logic);
|
|
||||||
PixelShaderManager::SetAlpha(sumem.alphaFunc);
|
|
||||||
break;
|
|
||||||
case SUMEM_BIAS: // BIAS
|
|
||||||
PRIM_LOG("ztex bias=0x%x", sumem.ztex1.bias);
|
|
||||||
PixelShaderManager::SetZTextureBias(sumem.ztex1.bias);
|
|
||||||
break;
|
|
||||||
case SUMEM_ZTEX2: // Z Texture type
|
|
||||||
{
|
|
||||||
if (bp.changes & 3)
|
|
||||||
PixelShaderManager::SetZTextureTypeChanged();
|
|
||||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
|
||||||
const char* pzop[] = {"DISABLE", "ADD", "REPLACE", "?"};
|
|
||||||
const char* pztype[] = {"Z8", "Z16", "Z24", "?"};
|
|
||||||
PRIM_LOG("ztex op=%s, type=%s", pzop[sumem.ztex2.op], pztype[sumem.ztex2.type]);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// ----------------------------------
|
|
||||||
// Display Copy Filtering Control
|
|
||||||
// Fields: Destination, Frame2Field, Gamma, Source
|
|
||||||
// TODO: We might have to implement the gamma one, some games might need this, if they are too dark to see.
|
|
||||||
// ----------------------------------
|
|
||||||
case SUMEM_DISPLAYCOPYFILER:
|
|
||||||
case SUMEM_DISPLAYCOPYFILER+1:
|
|
||||||
case SUMEM_DISPLAYCOPYFILER+2:
|
|
||||||
case SUMEM_DISPLAYCOPYFILER+3:
|
|
||||||
case SUMEM_COPYFILTER0: //GXSetCopyFilter
|
|
||||||
case SUMEM_COPYFILTER1:
|
|
||||||
break;
|
|
||||||
case SUMEM_FIELDMASK: // Interlacing Control
|
|
||||||
case SUMEM_FIELDMODE:
|
|
||||||
SetInterlacingMode(bp);
|
|
||||||
break;
|
|
||||||
// ---------------------------------------------------
|
|
||||||
// Debugging/Profiling info, we don't care about them
|
|
||||||
// ---------------------------------------------------
|
|
||||||
case SUMEM_CLOCK0: // Some Clock
|
|
||||||
case SUMEM_CLOCK1: // Some Clock
|
|
||||||
case SUMEM_SU_COUNTER: // Pixel or Poly Count
|
|
||||||
case SUMEM_RAS_COUNTER: // Sound Count of something in the Texture Units
|
|
||||||
case SUMEM_SETGPMETRIC: // Set the Graphic Processor Metric
|
|
||||||
break;
|
|
||||||
// ----------------
|
|
||||||
// EFB Copy config
|
|
||||||
// ----------------
|
|
||||||
case SUMEM_EFB_TL: // EFB Source Rect. Top, Left
|
|
||||||
case SUMEM_EFB_BR: // EFB Source Rect. Bottom, Right (w, h - 1)
|
|
||||||
case SUMEM_EFB_ADDR: // EFB Target Address
|
|
||||||
break;
|
|
||||||
// --------------
|
|
||||||
// Clear Config
|
|
||||||
// --------------
|
|
||||||
case SUMEM_CLEAR_AR: // Alpha and Red Components
|
|
||||||
case SUMEM_CLEAR_GB: // Green and Blue Components
|
|
||||||
case SUMEM_CLEAR_Z: // Z Components (24-bit Zbuffer)
|
|
||||||
break;
|
|
||||||
// -------------------------
|
|
||||||
// Culling Occulsion, we don't support this
|
|
||||||
// let's hope not many games use bboxes..
|
|
||||||
// TODO(ector): add something that watches bboxes
|
|
||||||
// -------------------------
|
|
||||||
case SUMEM_CLEARBBOX1:
|
|
||||||
case SUMEM_CLEARBBOX2:
|
|
||||||
break;
|
|
||||||
case SUMEM_ZCOMPARE: // Set the Z-Compare
|
|
||||||
case SUMEM_TEXINVALIDATE: // Used, if game has manual control the Texture Cache, which we don't allow
|
|
||||||
case SUMEM_MIPMAP_STRIDE: // MipMap Stride Channel
|
|
||||||
case SUMEM_COPYYSCALE: // Display Copy Y Scale
|
|
||||||
case SUMEM_IREF: /* 24 RID
|
|
||||||
21 BC3 - Ind. Tex Stage 3 NTexCoord
|
|
||||||
18 BI3 - Ind. Tex Stage 3 NTexMap
|
|
||||||
15 BC2 - Ind. Tex Stage 2 NTexCoord
|
|
||||||
12 BI2 - Ind. Tex Stage 2 NTexMap
|
|
||||||
9 BC1 - Ind. Tex Stage 1 NTexCoord
|
|
||||||
6 BI1 - Ind. Tex Stage 1 NTexMap
|
|
||||||
3 BC0 - Ind. Tex Stage 0 NTexCoord
|
|
||||||
0 BI0 - Ind. Tex Stage 0 NTexMap */
|
|
||||||
break;
|
|
||||||
case SUMEM_TEV_KSEL: // Texture Environment Swap Mode Table 0
|
|
||||||
case SUMEM_TEV_KSEL+1:// Texture Environment Swap Mode Table 1
|
|
||||||
case SUMEM_TEV_KSEL+2:// Texture Environment Swap Mode Table 2
|
|
||||||
case SUMEM_TEV_KSEL+3:// Texture Environment Swap Mode Table 3
|
|
||||||
case SUMEM_TEV_KSEL+4:// Texture Environment Swap Mode Table 4
|
|
||||||
case SUMEM_TEV_KSEL+5:// Texture Environment Swap Mode Table 5
|
|
||||||
case SUMEM_TEV_KSEL+6:// Texture Environment Swap Mode Table 6
|
|
||||||
case SUMEM_TEV_KSEL+7:// Texture Environment Swap Mode Table 7
|
|
||||||
break;
|
|
||||||
case SUMEM_BP_MASK: // This Register can be used to limit to which bits of BP registers is actually written to. the mask is
|
|
||||||
// only valid for the next BP command, and will reset itself.
|
|
||||||
case SUMEM_IND_IMASK: // Index Mask ?
|
|
||||||
break;
|
|
||||||
case SUMEM_UNKNOWN: // This is always set to 0xF at boot of any game, so this sounds like a useless reg
|
|
||||||
if (bp.newvalue != 0x0F)
|
|
||||||
PanicAlert("Unknown is not 0xF! val = 0x%08x", bp.newvalue);
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Cases added due to: http://code.google.com/p/dolphin-emu/issues/detail?id=360#c90
|
|
||||||
// Are these related to BBox?
|
|
||||||
case SUMEM_UNKNOWN1:
|
|
||||||
case SUMEM_UNKNOWN2:
|
|
||||||
case SUMEM_UNKNOWN3:
|
|
||||||
case SUMEM_UNKNOWN4:
|
|
||||||
break;
|
|
||||||
// ------------------------------------------------
|
|
||||||
// On Default, we try to look for other things
|
|
||||||
// before we give up and say its an unknown opcode
|
|
||||||
// ------------------------------------------------
|
|
||||||
default:
|
|
||||||
switch (bp.address & 0xFC) // Texture sampler filter
|
|
||||||
{
|
|
||||||
// -------------------------
|
|
||||||
// Texture Environment Order
|
|
||||||
// -------------------------
|
|
||||||
case SUMEM_TREF:
|
|
||||||
case SUMEM_TREF+1:
|
|
||||||
case SUMEM_TREF+2:
|
|
||||||
case SUMEM_TREF+3:
|
|
||||||
case SUMEM_TREF+4:
|
|
||||||
case SUMEM_TREF+5:
|
|
||||||
case SUMEM_TREF+6:
|
|
||||||
case SUMEM_TREF+7:
|
|
||||||
break;
|
|
||||||
// ----------------------
|
|
||||||
// Set wrap size
|
|
||||||
// ----------------------
|
|
||||||
case SUMEM_SU_SSIZE:
|
|
||||||
case SUMEM_SU_TSIZE:
|
|
||||||
case SUMEM_SU_SSIZE+2:
|
|
||||||
case SUMEM_SU_TSIZE+2:
|
|
||||||
case SUMEM_SU_SSIZE+4:
|
|
||||||
case SUMEM_SU_TSIZE+4:
|
|
||||||
case SUMEM_SU_SSIZE+6:
|
|
||||||
case SUMEM_SU_TSIZE+6:
|
|
||||||
case SUMEM_SU_SSIZE+8:
|
|
||||||
case SUMEM_SU_TSIZE+8:
|
|
||||||
case SUMEM_SU_SSIZE+10:
|
|
||||||
case SUMEM_SU_TSIZE+10:
|
|
||||||
case SUMEM_SU_SSIZE+12:
|
|
||||||
case SUMEM_SU_TSIZE+12:
|
|
||||||
case SUMEM_SU_SSIZE+14:
|
|
||||||
case SUMEM_SU_TSIZE+14:
|
|
||||||
PixelShaderManager::SetTexCoordChanged((bp.address - SUMEM_SU_SSIZE) >> 1);
|
|
||||||
break;
|
|
||||||
// ------------------------
|
|
||||||
// SUMEM_TX_SETMODE0 - (Texture lookup and filtering mode) LOD/BIAS Clamp, MaxAnsio, LODBIAS, DiagLoad, Min Filter, Mag Filter, Wrap T, S
|
|
||||||
// SUMEM_TX_SETMODE1 - (LOD Stuff) - Max LOD, Min LOD
|
|
||||||
// ------------------------
|
|
||||||
case SUMEM_TX_SETMODE0: // (0x90 for linear)
|
|
||||||
case SUMEM_TX_SETMODE0+1:
|
|
||||||
case SUMEM_TX_SETMODE0+2:
|
|
||||||
case SUMEM_TX_SETMODE0+3:
|
|
||||||
case SUMEM_TX_SETMODE1:
|
|
||||||
case SUMEM_TX_SETMODE1+1:
|
|
||||||
case SUMEM_TX_SETMODE1+2:
|
|
||||||
case SUMEM_TX_SETMODE1+3:
|
|
||||||
case SUMEM_TX_SETMODE0_4:
|
|
||||||
case SUMEM_TX_SETMODE0_4+1:
|
|
||||||
case SUMEM_TX_SETMODE0_4+2:
|
|
||||||
case SUMEM_TX_SETMODE0_4+3:
|
|
||||||
case SUMEM_TX_SETMODE1_4:
|
|
||||||
case SUMEM_TX_SETMODE1_4+1:
|
|
||||||
case SUMEM_TX_SETMODE1_4+2:
|
|
||||||
case SUMEM_TX_SETMODE1_4+3:
|
|
||||||
SetSamplerState(bp);
|
|
||||||
break;
|
|
||||||
// --------------------------------------------
|
|
||||||
// SUMEM_TX_SETIMAGE0 - Texture width, height, format
|
|
||||||
// SUMEM_TX_SETIMAGE1 - even LOD address in TMEM - Image Type, Cache Height, Cache Width, TMEM Offset
|
|
||||||
// SUMEM_TX_SETIMAGE2 - odd LOD address in TMEM - Cache Height, Cache Width, TMEM Offset
|
|
||||||
// SUMEM_TX_SETIMAGE3 - Address of Texture in main memory
|
|
||||||
// --------------------------------------------
|
|
||||||
case SUMEM_TX_SETIMAGE0:
|
|
||||||
case SUMEM_TX_SETIMAGE0+1:
|
|
||||||
case SUMEM_TX_SETIMAGE0+2:
|
|
||||||
case SUMEM_TX_SETIMAGE0+3:
|
|
||||||
case SUMEM_TX_SETIMAGE0_4:
|
|
||||||
case SUMEM_TX_SETIMAGE0_4+1:
|
|
||||||
case SUMEM_TX_SETIMAGE0_4+2:
|
|
||||||
case SUMEM_TX_SETIMAGE0_4+3:
|
|
||||||
case SUMEM_TX_SETIMAGE1:
|
|
||||||
case SUMEM_TX_SETIMAGE1+1:
|
|
||||||
case SUMEM_TX_SETIMAGE1+2:
|
|
||||||
case SUMEM_TX_SETIMAGE1+3:
|
|
||||||
case SUMEM_TX_SETIMAGE1_4:
|
|
||||||
case SUMEM_TX_SETIMAGE1_4+1:
|
|
||||||
case SUMEM_TX_SETIMAGE1_4+2:
|
|
||||||
case SUMEM_TX_SETIMAGE1_4+3:
|
|
||||||
case SUMEM_TX_SETIMAGE2:
|
|
||||||
case SUMEM_TX_SETIMAGE2+1:
|
|
||||||
case SUMEM_TX_SETIMAGE2+2:
|
|
||||||
case SUMEM_TX_SETIMAGE2+3:
|
|
||||||
case SUMEM_TX_SETIMAGE2_4:
|
|
||||||
case SUMEM_TX_SETIMAGE2_4+1:
|
|
||||||
case SUMEM_TX_SETIMAGE2_4+2:
|
|
||||||
case SUMEM_TX_SETIMAGE2_4+3:
|
|
||||||
case SUMEM_TX_SETIMAGE3:
|
|
||||||
case SUMEM_TX_SETIMAGE3+1:
|
|
||||||
case SUMEM_TX_SETIMAGE3+2:
|
|
||||||
case SUMEM_TX_SETIMAGE3+3:
|
|
||||||
case SUMEM_TX_SETIMAGE3_4:
|
|
||||||
case SUMEM_TX_SETIMAGE3_4+1:
|
|
||||||
case SUMEM_TX_SETIMAGE3_4+2:
|
|
||||||
case SUMEM_TX_SETIMAGE3_4+3:
|
|
||||||
break;
|
|
||||||
// -------------------------------
|
|
||||||
// Set a TLUT
|
|
||||||
// SUMEM_TX_SETTLUT - Format, TMEM Offset (offset of TLUT from start of TMEM high bank > > 5)
|
|
||||||
// -------------------------------
|
|
||||||
case SUMEM_TX_SETTLUT:
|
|
||||||
case SUMEM_TX_SETTLUT+1:
|
|
||||||
case SUMEM_TX_SETTLUT+2:
|
|
||||||
case SUMEM_TX_SETTLUT+3:
|
|
||||||
case SUMEM_TX_SETLUT_4:
|
|
||||||
case SUMEM_TX_SETLUT_4+1:
|
|
||||||
case SUMEM_TX_SETLUT_4+2:
|
|
||||||
case SUMEM_TX_SETLUT_4+3:
|
|
||||||
break;
|
|
||||||
// ---------------------------------------------------
|
|
||||||
// Set the TEV Color
|
|
||||||
// ---------------------------------------------------
|
|
||||||
case SUMEM_TEV_REGISTER_L: // Reg 1
|
|
||||||
case SUMEM_TEV_REGISTER_H:
|
|
||||||
case SUMEM_TEV_REGISTER_L+2: // Reg 2
|
|
||||||
case SUMEM_TEV_REGISTER_H+2:
|
|
||||||
case SUMEM_TEV_REGISTER_L+4: // Reg 3
|
|
||||||
case SUMEM_TEV_REGISTER_H+4:
|
|
||||||
case SUMEM_TEV_REGISTER_L+6: // Reg 4
|
|
||||||
case SUMEM_TEV_REGISTER_H+6:
|
|
||||||
{
|
|
||||||
if (bp.address & 1)
|
|
||||||
{
|
|
||||||
// don't compare with changes!
|
|
||||||
int num = (bp.address >> 1 ) & 0x3;
|
|
||||||
PixelShaderManager::SetColorChanged(sumem.tevregs[num].high.type, num);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// ------------------------------------------------
|
|
||||||
// On Default, we try to look for other things
|
|
||||||
// before we give up and say its an unknown opcode
|
|
||||||
// again ...
|
|
||||||
// ------------------------------------------------
|
|
||||||
default:
|
|
||||||
switch (bp.address & 0xF0)
|
|
||||||
{
|
|
||||||
// --------------
|
|
||||||
// Indirect Tev
|
|
||||||
// --------------
|
|
||||||
case SUMEM_IND_CMD:
|
|
||||||
case SUMEM_IND_CMD+1:
|
|
||||||
case SUMEM_IND_CMD+2:
|
|
||||||
case SUMEM_IND_CMD+3:
|
|
||||||
case SUMEM_IND_CMD+4:
|
|
||||||
case SUMEM_IND_CMD+5:
|
|
||||||
case SUMEM_IND_CMD+6:
|
|
||||||
case SUMEM_IND_CMD+7:
|
|
||||||
case SUMEM_IND_CMD+8:
|
|
||||||
case SUMEM_IND_CMD+9:
|
|
||||||
case SUMEM_IND_CMD+10:
|
|
||||||
case SUMEM_IND_CMD+11:
|
|
||||||
case SUMEM_IND_CMD+12:
|
|
||||||
case SUMEM_IND_CMD+13:
|
|
||||||
case SUMEM_IND_CMD+14:
|
|
||||||
case SUMEM_IND_CMD+15:
|
|
||||||
break;
|
|
||||||
// --------------------------------------------------
|
|
||||||
// Set Color/Alpha of a Tev
|
|
||||||
// SUMEM_TEV_COLOR_ENV - Dest, Shift, Clamp, Sub, Bias, Sel A, Sel B, Sel C, Sel D
|
|
||||||
// SUMEM_TEV_ALPHA_ENV - Dest, Shift, Clamp, Sub, Bias, Sel A, Sel B, Sel C, Sel D, T Swap, R Swap
|
|
||||||
// --------------------------------------------------
|
|
||||||
case SUMEM_TEV_COLOR_ENV: // Texture Environment 1
|
|
||||||
case SUMEM_TEV_ALPHA_ENV:
|
|
||||||
case SUMEM_TEV_COLOR_ENV+2: // Texture Environment 2
|
|
||||||
case SUMEM_TEV_ALPHA_ENV+2:
|
|
||||||
case SUMEM_TEV_COLOR_ENV+4: // Texture Environment 3
|
|
||||||
case SUMEM_TEV_ALPHA_ENV+4:
|
|
||||||
case SUMEM_TEV_COLOR_ENV+8: // Texture Environment 4
|
|
||||||
case SUMEM_TEV_ALPHA_ENV+8:
|
|
||||||
case SUMEM_TEV_COLOR_ENV+10: // Texture Environment 5
|
|
||||||
case SUMEM_TEV_ALPHA_ENV+10:
|
|
||||||
case SUMEM_TEV_COLOR_ENV+12: // Texture Environment 6
|
|
||||||
case SUMEM_TEV_ALPHA_ENV+12:
|
|
||||||
case SUMEM_TEV_COLOR_ENV+14: // Texture Environment 7
|
|
||||||
case SUMEM_TEV_ALPHA_ENV+14:
|
|
||||||
case SUMEM_TEV_COLOR_ENV+16: // Texture Environment 8
|
|
||||||
case SUMEM_TEV_ALPHA_ENV+16:
|
|
||||||
case SUMEM_TEV_COLOR_ENV+18: // Texture Environment 9
|
|
||||||
case SUMEM_TEV_ALPHA_ENV+18:
|
|
||||||
case SUMEM_TEV_COLOR_ENV+20: // Texture Environment 10
|
|
||||||
case SUMEM_TEV_ALPHA_ENV+20:
|
|
||||||
case SUMEM_TEV_COLOR_ENV+22: // Texture Environment 11
|
|
||||||
case SUMEM_TEV_ALPHA_ENV+22:
|
|
||||||
case SUMEM_TEV_COLOR_ENV+24: // Texture Environment 12
|
|
||||||
case SUMEM_TEV_ALPHA_ENV+24:
|
|
||||||
case SUMEM_TEV_COLOR_ENV+26: // Texture Environment 13
|
|
||||||
case SUMEM_TEV_ALPHA_ENV+26:
|
|
||||||
case SUMEM_TEV_COLOR_ENV+28: // Texture Environment 14
|
|
||||||
case SUMEM_TEV_ALPHA_ENV+28:
|
|
||||||
case SUMEM_TEV_COLOR_ENV+30: // Texture Environment 15
|
|
||||||
case SUMEM_TEV_ALPHA_ENV+30:
|
|
||||||
case SUMEM_TEV_COLOR_ENV+32: // Texture Environment 16
|
|
||||||
case SUMEM_TEV_ALPHA_ENV+32:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
WARN_LOG(VIDEO, "Unknown Bypass opcode: address = 0x%08x value = 0x%08x", bp.address, bp.newvalue);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
#include "Statistics.h"
|
#include "Statistics.h"
|
||||||
#include "VertexLoaderManager.h"
|
#include "VertexLoaderManager.h"
|
||||||
#include "VertexLoader.h"
|
#include "VertexLoader.h"
|
||||||
#include "SUMemory.h"
|
#include "BPMemory.h"
|
||||||
#include "DataReader.h"
|
#include "DataReader.h"
|
||||||
#include "NativeVertexWriter.h"
|
#include "NativeVertexWriter.h"
|
||||||
|
|
||||||
|
@ -539,7 +539,7 @@ void VertexLoader::RunVertices(int vtx_attr_group, int primitive, int count)
|
||||||
}
|
}
|
||||||
g_nativeVertexFmt = m_NativeFmt;
|
g_nativeVertexFmt = m_NativeFmt;
|
||||||
|
|
||||||
if (sumem.genMode.cullmode == 3 && primitive < 5)
|
if (bpmem.genMode.cullmode == 3 && primitive < 5)
|
||||||
{
|
{
|
||||||
// if cull mode is none, ignore triangles and quads
|
// if cull mode is none, ignore triangles and quads
|
||||||
DataSkip(count * m_VertexSize);
|
DataSkip(count * m_VertexSize);
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "Profiler.h"
|
#include "Profiler.h"
|
||||||
#include "NativeVertexFormat.h"
|
#include "NativeVertexFormat.h"
|
||||||
|
|
||||||
#include "SUMemory.h"
|
#include "BPMemory.h"
|
||||||
#include "VertexShaderGen.h"
|
#include "VertexShaderGen.h"
|
||||||
|
|
||||||
// Mash together all the inputs that contribute to the code of a generated vertex shader into
|
// Mash together all the inputs that contribute to the code of a generated vertex shader into
|
||||||
|
@ -42,8 +42,8 @@ void GetVertexShaderId(VERTEXSHADERUID& vid, u32 components)
|
||||||
}
|
}
|
||||||
|
|
||||||
// fog
|
// fog
|
||||||
vid.values[1] |= (((u32)sumem.fog.c_proj_fsel.fsel & 3) << 30);
|
vid.values[1] |= (((u32)bpmem.fog.c_proj_fsel.fsel & 3) << 30);
|
||||||
vid.values[2] |= (((u32)sumem.fog.c_proj_fsel.fsel >> 2) << 30);
|
vid.values[2] |= (((u32)bpmem.fog.c_proj_fsel.fsel >> 2) << 30);
|
||||||
|
|
||||||
u32* pcurvalue = &vid.values[3];
|
u32* pcurvalue = &vid.values[3];
|
||||||
for (int i = 0; i < xfregs.numTexGens; ++i) {
|
for (int i = 0; i < xfregs.numTexGens; ++i) {
|
||||||
|
@ -81,8 +81,8 @@ const char *GenerateVertexShader(u32 components)
|
||||||
text[sizeof(text) - 1] = 0x7C; // canary
|
text[sizeof(text) - 1] = 0x7C; // canary
|
||||||
DVSTARTPROFILE();
|
DVSTARTPROFILE();
|
||||||
|
|
||||||
_assert_( sumem.genMode.numtexgens == xfregs.numTexGens);
|
_assert_( bpmem.genMode.numtexgens == xfregs.numTexGens);
|
||||||
_assert_( sumem.genMode.numcolchans == xfregs.nNumChans);
|
_assert_( bpmem.genMode.numcolchans == xfregs.nNumChans);
|
||||||
|
|
||||||
u32 lightMask = 0;
|
u32 lightMask = 0;
|
||||||
if (xfregs.nNumChans > 0)
|
if (xfregs.nNumChans > 0)
|
||||||
|
@ -432,8 +432,8 @@ const char *GenerateVertexShader(u32 components)
|
||||||
WRITE(p, "o.tex3.w = o.pos.w;\n");
|
WRITE(p, "o.tex3.w = o.pos.w;\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (sumem.fog.c_proj_fsel.fsel != 0) {
|
// if (bpmem.fog.c_proj_fsel.fsel != 0) {
|
||||||
// switch (sumem.fog.c_proj_fsel.fsel) {
|
// switch (bpmem.fog.c_proj_fsel.fsel) {
|
||||||
// case 1: // linear
|
// case 1: // linear
|
||||||
// break;
|
// break;
|
||||||
// case 4: // exp
|
// case 4: // exp
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#include "VertexShaderGen.h"
|
#include "VertexShaderGen.h"
|
||||||
#include "VertexShaderManager.h"
|
#include "VertexShaderManager.h"
|
||||||
#include "SUMemory.h"
|
#include "BPMemory.h"
|
||||||
#include "CPMemory.h"
|
#include "CPMemory.h"
|
||||||
#include "XFMemory.h"
|
#include "XFMemory.h"
|
||||||
#include "VideoCommon.h"
|
#include "VideoCommon.h"
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#include "VideoState.h"
|
#include "VideoState.h"
|
||||||
|
|
||||||
#include "SUMemory.h"
|
#include "BPMemory.h"
|
||||||
#include "CPMemory.h"
|
#include "CPMemory.h"
|
||||||
#include "XFMemory.h"
|
#include "XFMemory.h"
|
||||||
#include "TextureDecoder.h"
|
#include "TextureDecoder.h"
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
static void DoState(PointerWrap &p)
|
static void DoState(PointerWrap &p)
|
||||||
{
|
{
|
||||||
// BP Memory
|
// BP Memory
|
||||||
p.Do(sumem);
|
p.Do(bpmem);
|
||||||
// CP Memory
|
// CP Memory
|
||||||
p.DoArray(arraybases, 16);
|
p.DoArray(arraybases, 16);
|
||||||
p.DoArray(arraystrides, 16);
|
p.DoArray(arraystrides, 16);
|
||||||
|
|
|
@ -428,6 +428,14 @@
|
||||||
<Filter
|
<Filter
|
||||||
Name="Sections"
|
Name="Sections"
|
||||||
>
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Src\BPMemory.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Src\BPMemory.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Src\CPMemory.cpp"
|
RelativePath=".\Src\CPMemory.cpp"
|
||||||
>
|
>
|
||||||
|
@ -436,26 +444,6 @@
|
||||||
RelativePath=".\Src\CPMemory.h"
|
RelativePath=".\Src\CPMemory.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\Src\SUFunctions.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\Src\SUMemory.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\Src\SUMemory.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\Src\SUStructs.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\Src\SUStructs.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Src\XFMemory.cpp"
|
RelativePath=".\Src\XFMemory.cpp"
|
||||||
>
|
>
|
||||||
|
@ -621,26 +609,18 @@
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
|
||||||
Name="Decoding"
|
|
||||||
>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Src\OpcodeDecoding.cpp"
|
RelativePath=".\Src\BPFunctions.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Src\OpcodeDecoding.h"
|
RelativePath=".\Src\BPStructs.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Src\TextureDecoder.cpp"
|
RelativePath=".\Src\BPStructs.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\Src\TextureDecoder.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Filter>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Src\DataReader.h"
|
RelativePath=".\Src\DataReader.h"
|
||||||
>
|
>
|
||||||
|
@ -677,10 +657,26 @@
|
||||||
RelativePath=".\Src\NativeVertexWriter.h"
|
RelativePath=".\Src\NativeVertexWriter.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Src\OpcodeDecoding.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Src\OpcodeDecoding.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Src\SConscript"
|
RelativePath=".\Src\SConscript"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Src\TextureDecoder.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Src\TextureDecoder.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Src\VertexLoaderManager.cpp"
|
RelativePath=".\Src\VertexLoaderManager.cpp"
|
||||||
>
|
>
|
||||||
|
|
|
@ -1180,7 +1180,7 @@
|
||||||
Name="Decoder"
|
Name="Decoder"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Src\SUFunctions.cpp"
|
RelativePath=".\Src\BPFunctions.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
// Official SVN repository and contact information can be found at
|
// Official SVN repository and contact information can be found at
|
||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
#include "SUFunctions.h"
|
#include "BPFunctions.h"
|
||||||
#include "D3DBase.h"
|
#include "D3DBase.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
@ -92,7 +92,7 @@ static const D3DTEXTUREADDRESS d3dClamps[4] =
|
||||||
D3DTADDRESS_WRAP //reserved
|
D3DTADDRESS_WRAP //reserved
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace SUFunctions
|
namespace BPFunctions
|
||||||
{
|
{
|
||||||
|
|
||||||
void FlushPipeline()
|
void FlushPipeline()
|
||||||
|
@ -100,12 +100,12 @@ void FlushPipeline()
|
||||||
VertexManager::Flush();
|
VertexManager::Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetGenerationMode(const BPCommand &bp)
|
void SetGenerationMode(const Bypass &bp)
|
||||||
{
|
{
|
||||||
// dev->SetRenderState(D3DRS_CULLMODE, d3dCullModes[sumem.genMode.cullmode]);
|
// dev->SetRenderState(D3DRS_CULLMODE, d3dCullModes[bpmem.genMode.cullmode]);
|
||||||
Renderer::SetRenderState(D3DRS_CULLMODE, d3dCullModes[sumem.genMode.cullmode]);
|
Renderer::SetRenderState(D3DRS_CULLMODE, d3dCullModes[bpmem.genMode.cullmode]);
|
||||||
|
|
||||||
if (sumem.genMode.cullmode == 3)
|
if (bpmem.genMode.cullmode == 3)
|
||||||
{
|
{
|
||||||
// dev->SetRenderState(D3DRS_COLORWRITEENABLE, 0);
|
// dev->SetRenderState(D3DRS_COLORWRITEENABLE, 0);
|
||||||
Renderer::SetRenderState(D3DRS_COLORWRITEENABLE, 0);
|
Renderer::SetRenderState(D3DRS_COLORWRITEENABLE, 0);
|
||||||
|
@ -113,9 +113,9 @@ void SetGenerationMode(const BPCommand &bp)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DWORD write = 0;
|
DWORD write = 0;
|
||||||
if (sumem.blendmode.alphaupdate)
|
if (bpmem.blendmode.alphaupdate)
|
||||||
write = D3DCOLORWRITEENABLE_ALPHA;
|
write = D3DCOLORWRITEENABLE_ALPHA;
|
||||||
if (sumem.blendmode.colorupdate)
|
if (bpmem.blendmode.colorupdate)
|
||||||
write |= D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE;
|
write |= D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE;
|
||||||
|
|
||||||
// dev->SetRenderState(D3DRS_COLORWRITEENABLE, write);
|
// dev->SetRenderState(D3DRS_COLORWRITEENABLE, write);
|
||||||
|
@ -123,27 +123,27 @@ void SetGenerationMode(const BPCommand &bp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetScissor(const BPCommand &bp)
|
void SetScissor(const Bypass &bp)
|
||||||
{
|
{
|
||||||
Renderer::SetScissorRect();
|
Renderer::SetScissorRect();
|
||||||
}
|
}
|
||||||
void SetLineWidth(const BPCommand &bp)
|
void SetLineWidth(const Bypass &bp)
|
||||||
{
|
{
|
||||||
// We can't change line width in D3D unless we use ID3DXLine
|
// We can't change line width in D3D unless we use ID3DXLine
|
||||||
float psize = float(sumem.lineptwidth.pointsize) * 6.0f;
|
float psize = float(bpmem.lineptwidth.pointsize) * 6.0f;
|
||||||
Renderer::SetRenderState(D3DRS_POINTSIZE, *((DWORD*)&psize));
|
Renderer::SetRenderState(D3DRS_POINTSIZE, *((DWORD*)&psize));
|
||||||
}
|
}
|
||||||
void SetDepthMode(const BPCommand &bp)
|
void SetDepthMode(const Bypass &bp)
|
||||||
{
|
{
|
||||||
if (sumem.zmode.testenable)
|
if (bpmem.zmode.testenable)
|
||||||
{
|
{
|
||||||
// dev->SetRenderState(D3DRS_ZENABLE, TRUE);
|
// dev->SetRenderState(D3DRS_ZENABLE, TRUE);
|
||||||
// dev->SetRenderState(D3DRS_ZWRITEENABLE, sumem.zmode.updateenable);
|
// dev->SetRenderState(D3DRS_ZWRITEENABLE, bpmem.zmode.updateenable);
|
||||||
// dev->SetRenderState(D3DRS_ZFUNC,d3dCmpFuncs[sumem.zmode.func]);
|
// dev->SetRenderState(D3DRS_ZFUNC,d3dCmpFuncs[bpmem.zmode.func]);
|
||||||
|
|
||||||
Renderer::SetRenderState(D3DRS_ZENABLE, TRUE);
|
Renderer::SetRenderState(D3DRS_ZENABLE, TRUE);
|
||||||
Renderer::SetRenderState(D3DRS_ZWRITEENABLE, sumem.zmode.updateenable);
|
Renderer::SetRenderState(D3DRS_ZWRITEENABLE, bpmem.zmode.updateenable);
|
||||||
Renderer::SetRenderState(D3DRS_ZFUNC, d3dCmpFuncs[sumem.zmode.func]);
|
Renderer::SetRenderState(D3DRS_ZFUNC, d3dCmpFuncs[bpmem.zmode.func]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -155,23 +155,23 @@ void SetDepthMode(const BPCommand &bp)
|
||||||
Renderer::SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
|
Renderer::SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (!sumem.zmode.updateenable)
|
//if (!bpmem.zmode.updateenable)
|
||||||
// Renderer::SetRenderMode(Renderer::RM_Normal);
|
// Renderer::SetRenderMode(Renderer::RM_Normal);
|
||||||
|
|
||||||
}
|
}
|
||||||
void SetBlendMode(const BPCommand &bp)
|
void SetBlendMode(const Bypass &bp)
|
||||||
{
|
{
|
||||||
if (bp.changes & 1)
|
if (bp.changes & 1)
|
||||||
Renderer::SetRenderState(D3DRS_ALPHABLENDENABLE, sumem.blendmode.blendenable);
|
Renderer::SetRenderState(D3DRS_ALPHABLENDENABLE, bpmem.blendmode.blendenable);
|
||||||
|
|
||||||
D3DBLEND src = d3dSrcFactors[sumem.blendmode.srcfactor];
|
D3DBLEND src = d3dSrcFactors[bpmem.blendmode.srcfactor];
|
||||||
D3DBLEND dst = d3dDestFactors[sumem.blendmode.dstfactor];
|
D3DBLEND dst = d3dDestFactors[bpmem.blendmode.dstfactor];
|
||||||
|
|
||||||
if (bp.changes & 0x700)
|
if (bp.changes & 0x700)
|
||||||
Renderer::SetRenderState(D3DRS_SRCBLEND, src);
|
Renderer::SetRenderState(D3DRS_SRCBLEND, src);
|
||||||
|
|
||||||
if (bp.changes & 0xE0) {
|
if (bp.changes & 0xE0) {
|
||||||
if (!sumem.blendmode.subtract)
|
if (!bpmem.blendmode.subtract)
|
||||||
{
|
{
|
||||||
Renderer::SetRenderState(D3DRS_DESTBLEND, dst);
|
Renderer::SetRenderState(D3DRS_DESTBLEND, dst);
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ void SetBlendMode(const BPCommand &bp)
|
||||||
}
|
}
|
||||||
if (bp.changes & 0x800)
|
if (bp.changes & 0x800)
|
||||||
{
|
{
|
||||||
if (sumem.blendmode.subtract)
|
if (bpmem.blendmode.subtract)
|
||||||
{
|
{
|
||||||
Renderer::SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
|
Renderer::SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
|
||||||
Renderer::SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
|
Renderer::SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
|
||||||
|
@ -193,23 +193,23 @@ void SetBlendMode(const BPCommand &bp)
|
||||||
Renderer::SetRenderState(D3DRS_DESTBLEND, dst);
|
Renderer::SetRenderState(D3DRS_DESTBLEND, dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
Renderer::SetRenderState(D3DRS_BLENDOP, sumem.blendmode.subtract ? D3DBLENDOP_SUBTRACT : D3DBLENDOP_ADD);
|
Renderer::SetRenderState(D3DRS_BLENDOP, bpmem.blendmode.subtract ? D3DBLENDOP_SUBTRACT : D3DBLENDOP_ADD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void SetDitherMode(const BPCommand &bp)
|
void SetDitherMode(const Bypass &bp)
|
||||||
{
|
{
|
||||||
Renderer::SetRenderState(D3DRS_DITHERENABLE,sumem.blendmode.dither);
|
Renderer::SetRenderState(D3DRS_DITHERENABLE,bpmem.blendmode.dither);
|
||||||
}
|
}
|
||||||
void SetLogicOpMode(const BPCommand &bp)
|
void SetLogicOpMode(const Bypass &bp)
|
||||||
{
|
{
|
||||||
// Logic op blending. D3D can't do this but can fake some modes.
|
// Logic op blending. D3D can't do this but can fake some modes.
|
||||||
}
|
}
|
||||||
void SetColorMask(const BPCommand &bp)
|
void SetColorMask(const Bypass &bp)
|
||||||
{
|
{
|
||||||
DWORD write = 0;
|
DWORD write = 0;
|
||||||
if (sumem.blendmode.alphaupdate)
|
if (bpmem.blendmode.alphaupdate)
|
||||||
write = D3DCOLORWRITEENABLE_ALPHA;
|
write = D3DCOLORWRITEENABLE_ALPHA;
|
||||||
if (sumem.blendmode.colorupdate)
|
if (bpmem.blendmode.colorupdate)
|
||||||
write |= D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE;
|
write |= D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE;
|
||||||
|
|
||||||
Renderer::SetRenderState(D3DRS_COLORWRITEENABLE, write);
|
Renderer::SetRenderState(D3DRS_COLORWRITEENABLE, write);
|
||||||
|
@ -222,19 +222,19 @@ float GetRendererTargetScaleY()
|
||||||
{
|
{
|
||||||
return Renderer::GetYScale();
|
return Renderer::GetYScale();
|
||||||
}
|
}
|
||||||
void CopyEFB(const BPCommand &bp, const TRectangle &rc, const u32 &address, const bool &fromZBuffer, const bool &isIntensityFmt, const u32 ©fmt, const bool &scaleByHalf)
|
void CopyEFB(const Bypass &bp, const TRectangle &rc, const u32 &address, const bool &fromZBuffer, const bool &isIntensityFmt, const u32 ©fmt, const bool &scaleByHalf)
|
||||||
{
|
{
|
||||||
RECT rec = { rc.left, rc.top, rc.right, rc.bottom };
|
RECT rec = { rc.left, rc.top, rc.right, rc.bottom };
|
||||||
TextureCache::CopyEFBToRenderTarget(sumem.copyTexDest<<5, &rec);
|
TextureCache::CopyEFBToRenderTarget(bpmem.copyTexDest<<5, &rec);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderToXFB(const BPCommand &bp, const TRectangle &multirc, const float &yScale, const float &xfbLines, u8* pXFB, const u32 &dstWidth, const u32 &dstHeight)
|
void RenderToXFB(const Bypass &bp, const TRectangle &multirc, const float &yScale, const float &xfbLines, u8* pXFB, const u32 &dstWidth, const u32 &dstHeight)
|
||||||
{
|
{
|
||||||
Renderer::SwapBuffers();
|
Renderer::SwapBuffers();
|
||||||
PRIM_LOG("Renderer::SwapBuffers()");
|
PRIM_LOG("Renderer::SwapBuffers()");
|
||||||
g_VideoInitialize.pCopiedToXFB();
|
g_VideoInitialize.pCopiedToXFB();
|
||||||
}
|
}
|
||||||
void ClearScreen(const BPCommand &bp, const TRectangle &multirc)
|
void ClearScreen(const Bypass &bp, const TRectangle &multirc)
|
||||||
{
|
{
|
||||||
// it seems that the GC is able to alpha blend on color-fill
|
// it seems that the GC is able to alpha blend on color-fill
|
||||||
// we cant do that so if alpha is != 255 we skip it
|
// we cant do that so if alpha is != 255 we skip it
|
||||||
|
@ -247,17 +247,17 @@ void ClearScreen(const BPCommand &bp, const TRectangle &multirc)
|
||||||
D3DCOLOR col = 0;
|
D3DCOLOR col = 0;
|
||||||
float clearZ = 0;
|
float clearZ = 0;
|
||||||
|
|
||||||
if (sumem.blendmode.colorupdate || sumem.blendmode.alphaupdate)
|
if (bpmem.blendmode.colorupdate || bpmem.blendmode.alphaupdate)
|
||||||
{
|
{
|
||||||
if (sumem.blendmode.colorupdate || sumem.blendmode.alphaupdate)
|
if (bpmem.blendmode.colorupdate || bpmem.blendmode.alphaupdate)
|
||||||
col = (sumem.clearcolorAR << 16) | sumem.clearcolorGB;
|
col = (bpmem.clearcolorAR << 16) | bpmem.clearcolorGB;
|
||||||
// clearflags |= D3DCLEAR_TARGET; set to break animal crossing :p
|
// clearflags |= D3DCLEAR_TARGET; set to break animal crossing :p
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear z-buffer
|
// clear z-buffer
|
||||||
if (sumem.zmode.updateenable)
|
if (bpmem.zmode.updateenable)
|
||||||
{
|
{
|
||||||
clearZ = (float)(sumem.clearZValue & 0xFFFFFF) / float(0xFFFFFF);
|
clearZ = (float)(bpmem.clearZValue & 0xFFFFFF) / float(0xFFFFFF);
|
||||||
if (clearZ > 1.0f) clearZ = 1.0f;
|
if (clearZ > 1.0f) clearZ = 1.0f;
|
||||||
if (clearZ < 0.0f) clearZ = 0.0f;
|
if (clearZ < 0.0f) clearZ = 0.0f;
|
||||||
clearflags |= D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL;
|
clearflags |= D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL;
|
||||||
|
@ -266,7 +266,7 @@ void ClearScreen(const BPCommand &bp, const TRectangle &multirc)
|
||||||
D3D::dev->Clear(0, NULL, clearflags, col, clearZ, 0);
|
D3D::dev->Clear(0, NULL, clearflags, col, clearZ, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RestoreRenderState(const BPCommand &bp)
|
void RestoreRenderState(const Bypass &bp)
|
||||||
{
|
{
|
||||||
//Renderer::SetRenderMode(Renderer::RM_Normal);
|
//Renderer::SetRenderMode(Renderer::RM_Normal);
|
||||||
}
|
}
|
||||||
|
@ -290,9 +290,9 @@ u8 *GetPointer(const u32 &address)
|
||||||
{
|
{
|
||||||
return g_VideoInitialize.pGetMemoryPointer(address);
|
return g_VideoInitialize.pGetMemoryPointer(address);
|
||||||
}
|
}
|
||||||
void SetSamplerState(const BPCommand &bp)
|
void SetSamplerState(const Bypass &bp)
|
||||||
{
|
{
|
||||||
FourTexUnits &tex = sumem.tex[(bp.address & 0xE0) == 0xA0];
|
FourTexUnits &tex = bpmem.tex[(bp.address & 0xE0) == 0xA0];
|
||||||
int stage = (bp.address & 3);//(addr>>4)&2;
|
int stage = (bp.address & 3);//(addr>>4)&2;
|
||||||
TexMode0 &tm0 = tex.texMode0[stage];
|
TexMode0 &tm0 = tex.texMode0[stage];
|
||||||
|
|
||||||
|
@ -329,7 +329,7 @@ void SetSamplerState(const BPCommand &bp)
|
||||||
//sprintf(temp,"lod %f",tm0.lod_bias/4.0f);
|
//sprintf(temp,"lod %f",tm0.lod_bias/4.0f);
|
||||||
//g_VideoInitialize.pLog(temp);
|
//g_VideoInitialize.pLog(temp);
|
||||||
}
|
}
|
||||||
void SetInterlacingMode(const BPCommand &bp)
|
void SetInterlacingMode(const Bypass &bp)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
|
@ -25,7 +25,7 @@
|
||||||
#include "PixelShaderManager.h"
|
#include "PixelShaderManager.h"
|
||||||
#include "PixelShaderCache.h"
|
#include "PixelShaderCache.h"
|
||||||
#include "VertexLoader.h"
|
#include "VertexLoader.h"
|
||||||
#include "SUMemory.h"
|
#include "BPMemory.h"
|
||||||
#include "XFMemory.h"
|
#include "XFMemory.h"
|
||||||
|
|
||||||
#include <Cg/cg.h>
|
#include <Cg/cg.h>
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include "VertexManager.h"
|
#include "VertexManager.h"
|
||||||
#include "Render.h"
|
#include "Render.h"
|
||||||
#include "OpcodeDecoding.h"
|
#include "OpcodeDecoding.h"
|
||||||
#include "SUStructs.h"
|
#include "BPStructs.h"
|
||||||
#include "XFStructs.h"
|
#include "XFStructs.h"
|
||||||
#include "D3DPostprocess.h"
|
#include "D3DPostprocess.h"
|
||||||
#include "D3DUtil.h"
|
#include "D3DUtil.h"
|
||||||
|
@ -386,7 +386,7 @@ void Renderer::SwapBuffers()
|
||||||
D3D::dev->SetRenderState(D3DRS_SCISSORTESTENABLE, false);
|
D3D::dev->SetRenderState(D3DRS_SCISSORTESTENABLE, false);
|
||||||
|
|
||||||
D3D::dev->Clear(0, 0, D3DCLEAR_TARGET, 0x101010, 0, 0);
|
D3D::dev->Clear(0, 0, D3DCLEAR_TARGET, 0x101010, 0, 0);
|
||||||
u32 clearColor = (sumem.clearcolorAR << 16) | sumem.clearcolorGB;
|
u32 clearColor = (bpmem.clearcolorAR << 16) | bpmem.clearcolorGB;
|
||||||
// clearColor |= 0x003F003F;
|
// clearColor |= 0x003F003F;
|
||||||
// D3D::BeginFrame(true,clearColor,1.0f);
|
// D3D::BeginFrame(true,clearColor,1.0f);
|
||||||
D3D::BeginFrame(false, clearColor, 1.0f);
|
D3D::BeginFrame(false, clearColor, 1.0f);
|
||||||
|
@ -441,13 +441,13 @@ void Renderer::SetViewport(float* _Viewport)
|
||||||
|
|
||||||
void Renderer::SetScissorRect()
|
void Renderer::SetScissorRect()
|
||||||
{
|
{
|
||||||
int xoff = sumem.scissorOffset.x * 2 - 342;
|
int xoff = bpmem.scissorOffset.x * 2 - 342;
|
||||||
int yoff = sumem.scissorOffset.y * 2 - 342;
|
int yoff = bpmem.scissorOffset.y * 2 - 342;
|
||||||
RECT rc;
|
RECT rc;
|
||||||
rc.left = (int)((float)sumem.scissorTL.x - xoff - 342);
|
rc.left = (int)((float)bpmem.scissorTL.x - xoff - 342);
|
||||||
rc.top = (int)((float)sumem.scissorTL.y - yoff - 342);
|
rc.top = (int)((float)bpmem.scissorTL.y - yoff - 342);
|
||||||
rc.right = (int)((float)sumem.scissorBR.x - xoff - 341);
|
rc.right = (int)((float)bpmem.scissorBR.x - xoff - 341);
|
||||||
rc.bottom = (int)((float)sumem.scissorBR.y - yoff - 341);
|
rc.bottom = (int)((float)bpmem.scissorBR.y - yoff - 341);
|
||||||
|
|
||||||
rc.left = (int)(rc.left * xScale);
|
rc.left = (int)(rc.left * xScale);
|
||||||
rc.top = (int)(rc.top * yScale);
|
rc.top = (int)(rc.top * yScale);
|
||||||
|
@ -588,8 +588,8 @@ void UpdateViewport()
|
||||||
|
|
||||||
// Keep aspect ratio at 4:3
|
// Keep aspect ratio at 4:3
|
||||||
// rawViewport[0] = 320, rawViewport[1] = -240
|
// rawViewport[0] = 320, rawViewport[1] = -240
|
||||||
int scissorXOff = sumem.scissorOffset.x * 2 - 342;
|
int scissorXOff = bpmem.scissorOffset.x * 2 - 342;
|
||||||
int scissorYOff = sumem.scissorOffset.y * 2 - 342;
|
int scissorYOff = bpmem.scissorOffset.y * 2 - 342;
|
||||||
float fourThree = 4.0f / 3.0f;
|
float fourThree = 4.0f / 3.0f;
|
||||||
// These were commented out to fix "unreferenced local variable" compiler warnings.
|
// These were commented out to fix "unreferenced local variable" compiler warnings.
|
||||||
// float wAdj, hAdj;
|
// float wAdj, hAdj;
|
||||||
|
|
|
@ -213,7 +213,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
|
||||||
entry.w = width;
|
entry.w = width;
|
||||||
entry.h = height;
|
entry.h = height;
|
||||||
entry.fmt = format;
|
entry.fmt = format;
|
||||||
entry.mode = sumem.tex[stage > 3].texMode0[stage & 3];
|
entry.mode = bpmem.tex[stage > 3].texMode0[stage & 3];
|
||||||
|
|
||||||
if (g_Config.bDumpTextures)
|
if (g_Config.bDumpTextures)
|
||||||
{ // dump texture to file
|
{ // dump texture to file
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "D3DBase.h"
|
#include "D3DBase.h"
|
||||||
#include "SUMemory.h"
|
#include "BPMemory.h"
|
||||||
|
|
||||||
class TextureCache
|
class TextureCache
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
#include "NativeVertexWriter.h"
|
#include "NativeVertexWriter.h"
|
||||||
#include "TextureCache.h"
|
#include "TextureCache.h"
|
||||||
|
|
||||||
#include "SUStructs.h"
|
#include "BPStructs.h"
|
||||||
#include "XFStructs.h"
|
#include "XFStructs.h"
|
||||||
|
|
||||||
using namespace D3D;
|
using namespace D3D;
|
||||||
|
@ -185,15 +185,15 @@ void Flush()
|
||||||
g_nativeVertexFmt->SetupVertexPointers();
|
g_nativeVertexFmt->SetupVertexPointers();
|
||||||
|
|
||||||
u32 usedtextures = 0;
|
u32 usedtextures = 0;
|
||||||
for (u32 i = 0; i < (u32)sumem.genMode.numtevstages + 1; ++i) {
|
for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages + 1; ++i) {
|
||||||
if (sumem.tevorders[i/2].getEnable(i & 1))
|
if (bpmem.tevorders[i/2].getEnable(i & 1))
|
||||||
usedtextures |= 1 << sumem.tevorders[i/2].getTexMap(i & 1);
|
usedtextures |= 1 << bpmem.tevorders[i/2].getTexMap(i & 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sumem.genMode.numindstages > 0) {
|
if (bpmem.genMode.numindstages > 0) {
|
||||||
for (u32 i = 0; i < (u32)sumem.genMode.numtevstages + 1; ++i) {
|
for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages + 1; ++i) {
|
||||||
if (sumem.tevind[i].IsActive() && sumem.tevind[i].bt < sumem.genMode.numindstages) {
|
if (bpmem.tevind[i].IsActive() && bpmem.tevind[i].bt < bpmem.genMode.numindstages) {
|
||||||
usedtextures |= 1 << sumem.tevindref.getTexMap(sumem.tevind[i].bt);
|
usedtextures |= 1 << bpmem.tevindref.getTexMap(bpmem.tevind[i].bt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,7 @@ void Flush()
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
if (usedtextures & (1 << i)) {
|
if (usedtextures & (1 << i)) {
|
||||||
FourTexUnits &tex = sumem.tex[i >> 2];
|
FourTexUnits &tex = bpmem.tex[i >> 2];
|
||||||
TextureCache::TCacheEntry* tentry = TextureCache::Load(i,
|
TextureCache::TCacheEntry* tentry = TextureCache::Load(i,
|
||||||
(tex.texImage3[i&3].image_base/* & 0x1FFFFF*/) << 5,
|
(tex.texImage3[i&3].image_base/* & 0x1FFFFF*/) << 5,
|
||||||
tex.texImage0[i&3].width+1, tex.texImage0[i&3].height+1,
|
tex.texImage0[i&3].width+1, tex.texImage0[i&3].height+1,
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "VertexShaderCache.h"
|
#include "VertexShaderCache.h"
|
||||||
#include "VertexLoader.h"
|
#include "VertexLoader.h"
|
||||||
#include "SUMemory.h"
|
#include "BPMemory.h"
|
||||||
#include "XFMemory.h"
|
#include "XFMemory.h"
|
||||||
|
|
||||||
#include <Cg/cg.h>
|
#include <Cg/cg.h>
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include "Fifo.h"
|
#include "Fifo.h"
|
||||||
#include "OpcodeDecoding.h"
|
#include "OpcodeDecoding.h"
|
||||||
#include "TextureCache.h"
|
#include "TextureCache.h"
|
||||||
#include "SUStructs.h"
|
#include "BPStructs.h"
|
||||||
#include "VertexManager.h"
|
#include "VertexManager.h"
|
||||||
#include "VertexLoaderManager.h"
|
#include "VertexLoaderManager.h"
|
||||||
#include "VertexShaderManager.h"
|
#include "VertexShaderManager.h"
|
||||||
|
@ -223,7 +223,7 @@ void Video_Prepare(void)
|
||||||
|
|
||||||
TextureCache::Init();
|
TextureCache::Init();
|
||||||
|
|
||||||
SUInit();
|
BPInit();
|
||||||
VertexManager::Init();
|
VertexManager::Init();
|
||||||
Fifo_Init();
|
Fifo_Init();
|
||||||
VertexLoaderManager::Init();
|
VertexLoaderManager::Init();
|
||||||
|
|
|
@ -717,11 +717,11 @@
|
||||||
Name="Decoder"
|
Name="Decoder"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Src\NativeVertexFormat.cpp"
|
RelativePath=".\Src\BPFunctions.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Src\SUFunctions.cpp"
|
RelativePath=".\Src\NativeVertexFormat.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
// Official SVN repository and contact information can be found at
|
// Official SVN repository and contact information can be found at
|
||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
#include "SUFunctions.h"
|
#include "BPFunctions.h"
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
#include "Profiler.h"
|
#include "Profiler.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
#include "XFB.h"
|
#include "XFB.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
namespace SUFunctions
|
namespace BPFunctions
|
||||||
{
|
{
|
||||||
// ----------------------------------------------
|
// ----------------------------------------------
|
||||||
// State translation lookup tables
|
// State translation lookup tables
|
||||||
|
@ -47,40 +47,40 @@ void FlushPipeline()
|
||||||
{
|
{
|
||||||
VertexManager::Flush();
|
VertexManager::Flush();
|
||||||
}
|
}
|
||||||
void SetGenerationMode(const BPCommand &bp)
|
void SetGenerationMode(const Bypass &bp)
|
||||||
{
|
{
|
||||||
// none, ccw, cw, ccw
|
// none, ccw, cw, ccw
|
||||||
if (sumem.genMode.cullmode > 0)
|
if (bpmem.genMode.cullmode > 0)
|
||||||
{
|
{
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
glFrontFace(sumem.genMode.cullmode == 2 ? GL_CCW : GL_CW);
|
glFrontFace(bpmem.genMode.cullmode == 2 ? GL_CCW : GL_CW);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SetScissor(const BPCommand &bp)
|
void SetScissor(const Bypass &bp)
|
||||||
{
|
{
|
||||||
if (!Renderer::SetScissorRect())
|
if (!Renderer::SetScissorRect())
|
||||||
if (bp.address == SUMEM_SCISSORBR)
|
if (bp.address == BPMEM_SCISSORBR)
|
||||||
ERROR_LOG(VIDEO, "bad scissor!");
|
ERROR_LOG(VIDEO, "bad scissor!");
|
||||||
}
|
}
|
||||||
void SetLineWidth(const BPCommand &bp)
|
void SetLineWidth(const Bypass &bp)
|
||||||
{
|
{
|
||||||
float fratio = xfregs.rawViewport[0] != 0 ? ((float)Renderer::GetTargetWidth() / EFB_WIDTH) : 1.0f;
|
float fratio = xfregs.rawViewport[0] != 0 ? ((float)Renderer::GetTargetWidth() / EFB_WIDTH) : 1.0f;
|
||||||
if (sumem.lineptwidth.linesize > 0)
|
if (bpmem.lineptwidth.linesize > 0)
|
||||||
glLineWidth((float)sumem.lineptwidth.linesize * fratio / 6.0f); // scale by ratio of widths
|
glLineWidth((float)bpmem.lineptwidth.linesize * fratio / 6.0f); // scale by ratio of widths
|
||||||
if (sumem.lineptwidth.pointsize > 0)
|
if (bpmem.lineptwidth.pointsize > 0)
|
||||||
glPointSize((float)sumem.lineptwidth.pointsize * fratio / 6.0f);
|
glPointSize((float)bpmem.lineptwidth.pointsize * fratio / 6.0f);
|
||||||
}
|
}
|
||||||
void SetDepthMode(const BPCommand &bp)
|
void SetDepthMode(const Bypass &bp)
|
||||||
{
|
{
|
||||||
if (sumem.zmode.testenable)
|
if (bpmem.zmode.testenable)
|
||||||
{
|
{
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glDepthMask(sumem.zmode.updateenable ? GL_TRUE : GL_FALSE);
|
glDepthMask(bpmem.zmode.updateenable ? GL_TRUE : GL_FALSE);
|
||||||
glDepthFunc(glCmpFuncs[sumem.zmode.func]);
|
glDepthFunc(glCmpFuncs[bpmem.zmode.func]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -89,28 +89,28 @@ void SetDepthMode(const BPCommand &bp)
|
||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void SetBlendMode(const BPCommand &bp)
|
void SetBlendMode(const Bypass &bp)
|
||||||
{
|
{
|
||||||
Renderer::SetBlendMode(false);
|
Renderer::SetBlendMode(false);
|
||||||
}
|
}
|
||||||
void SetDitherMode(const BPCommand &bp)
|
void SetDitherMode(const Bypass &bp)
|
||||||
{
|
{
|
||||||
if (sumem.blendmode.dither)
|
if (bpmem.blendmode.dither)
|
||||||
glEnable(GL_DITHER);
|
glEnable(GL_DITHER);
|
||||||
else
|
else
|
||||||
glDisable(GL_DITHER);
|
glDisable(GL_DITHER);
|
||||||
}
|
}
|
||||||
void SetLogicOpMode(const BPCommand &bp)
|
void SetLogicOpMode(const Bypass &bp)
|
||||||
{
|
{
|
||||||
if (sumem.blendmode.logicopenable)
|
if (bpmem.blendmode.logicopenable)
|
||||||
{
|
{
|
||||||
glEnable(GL_COLOR_LOGIC_OP);
|
glEnable(GL_COLOR_LOGIC_OP);
|
||||||
glLogicOp(glLogicOpCodes[sumem.blendmode.logicmode]);
|
glLogicOp(glLogicOpCodes[bpmem.blendmode.logicmode]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
glDisable(GL_COLOR_LOGIC_OP);
|
glDisable(GL_COLOR_LOGIC_OP);
|
||||||
}
|
}
|
||||||
void SetColorMask(const BPCommand &bp)
|
void SetColorMask(const Bypass &bp)
|
||||||
{
|
{
|
||||||
Renderer::SetColorMask();
|
Renderer::SetColorMask();
|
||||||
}
|
}
|
||||||
|
@ -122,9 +122,9 @@ float GetRendererTargetScaleY()
|
||||||
{
|
{
|
||||||
return Renderer::GetTargetScaleY();
|
return Renderer::GetTargetScaleY();
|
||||||
}
|
}
|
||||||
void CopyEFB(const BPCommand &bp, const TRectangle &rc, const u32 &address, const bool &fromZBuffer, const bool &isIntensityFmt, const u32 ©fmt, const bool &scaleByHalf)
|
void CopyEFB(const Bypass &bp, const TRectangle &rc, const u32 &address, const bool &fromZBuffer, const bool &isIntensityFmt, const u32 ©fmt, const bool &scaleByHalf)
|
||||||
{
|
{
|
||||||
// sumem.zcontrol.pixel_format to PIXELFMT_Z24 is when the game wants to copy from ZBuffer (Zbuffer uses 24-bit Format)
|
// bpmem.zcontrol.pixel_format to PIXELFMT_Z24 is when the game wants to copy from ZBuffer (Zbuffer uses 24-bit Format)
|
||||||
if (!g_Config.bEFBCopyDisable)
|
if (!g_Config.bEFBCopyDisable)
|
||||||
if (g_Config.bCopyEFBToRAM) // To RAM
|
if (g_Config.bCopyEFBToRAM) // To RAM
|
||||||
TextureConverter::EncodeToRam(address, fromZBuffer, isIntensityFmt, copyfmt, scaleByHalf, rc);
|
TextureConverter::EncodeToRam(address, fromZBuffer, isIntensityFmt, copyfmt, scaleByHalf, rc);
|
||||||
|
@ -132,7 +132,7 @@ void CopyEFB(const BPCommand &bp, const TRectangle &rc, const u32 &address, cons
|
||||||
TextureMngr::CopyRenderTargetToTexture(address, fromZBuffer, isIntensityFmt, copyfmt, scaleByHalf, rc);
|
TextureMngr::CopyRenderTargetToTexture(address, fromZBuffer, isIntensityFmt, copyfmt, scaleByHalf, rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderToXFB(const BPCommand &bp, const TRectangle &multirc, const float &yScale, const float &xfbLines, u8* pXFB, const u32 &dstWidth, const u32 &dstHeight)
|
void RenderToXFB(const Bypass &bp, const TRectangle &multirc, const float &yScale, const float &xfbLines, u8* pXFB, const u32 &dstWidth, const u32 &dstHeight)
|
||||||
{
|
{
|
||||||
// EFB to XFB
|
// EFB to XFB
|
||||||
if (g_Config.bUseXFB)
|
if (g_Config.bUseXFB)
|
||||||
|
@ -155,7 +155,7 @@ void RenderToXFB(const BPCommand &bp, const TRectangle &multirc, const float &yS
|
||||||
}
|
}
|
||||||
g_VideoInitialize.pCopiedToXFB();
|
g_VideoInitialize.pCopiedToXFB();
|
||||||
}
|
}
|
||||||
void ClearScreen(const BPCommand &bp, const TRectangle &multirc)
|
void ClearScreen(const Bypass &bp, const TRectangle &multirc)
|
||||||
{
|
{
|
||||||
// Update the view port for clearing the picture
|
// Update the view port for clearing the picture
|
||||||
glViewport(0, 0, Renderer::GetTargetWidth(), Renderer::GetTargetHeight());
|
glViewport(0, 0, Renderer::GetTargetWidth(), Renderer::GetTargetHeight());
|
||||||
|
@ -169,21 +169,21 @@ void ClearScreen(const BPCommand &bp, const TRectangle &multirc)
|
||||||
|
|
||||||
// Since clear operations use the source rectangle, we have to do
|
// Since clear operations use the source rectangle, we have to do
|
||||||
// regular renders (glClear clears the entire buffer)
|
// regular renders (glClear clears the entire buffer)
|
||||||
if (sumem.blendmode.colorupdate || sumem.blendmode.alphaupdate || sumem.zmode.updateenable)
|
if (bpmem.blendmode.colorupdate || bpmem.blendmode.alphaupdate || bpmem.zmode.updateenable)
|
||||||
{
|
{
|
||||||
GLbitfield bits = 0;
|
GLbitfield bits = 0;
|
||||||
if (sumem.blendmode.colorupdate || sumem.blendmode.alphaupdate)
|
if (bpmem.blendmode.colorupdate || bpmem.blendmode.alphaupdate)
|
||||||
{
|
{
|
||||||
u32 clearColor = (sumem.clearcolorAR << 16) | sumem.clearcolorGB;
|
u32 clearColor = (bpmem.clearcolorAR << 16) | bpmem.clearcolorGB;
|
||||||
glClearColor(((clearColor>>16) & 0xff)*(1/255.0f),
|
glClearColor(((clearColor>>16) & 0xff)*(1/255.0f),
|
||||||
((clearColor>>8 ) & 0xff)*(1/255.0f),
|
((clearColor>>8 ) & 0xff)*(1/255.0f),
|
||||||
((clearColor>>0 ) & 0xff)*(1/255.0f),
|
((clearColor>>0 ) & 0xff)*(1/255.0f),
|
||||||
((clearColor>>24) & 0xff)*(1/255.0f));
|
((clearColor>>24) & 0xff)*(1/255.0f));
|
||||||
bits |= GL_COLOR_BUFFER_BIT;
|
bits |= GL_COLOR_BUFFER_BIT;
|
||||||
}
|
}
|
||||||
if (sumem.zmode.updateenable)
|
if (bpmem.zmode.updateenable)
|
||||||
{
|
{
|
||||||
glClearDepth((float)(sumem.clearZValue & 0xFFFFFF) / float(0xFFFFFF));
|
glClearDepth((float)(bpmem.clearZValue & 0xFFFFFF) / float(0xFFFFFF));
|
||||||
bits |= GL_DEPTH_BUFFER_BIT;
|
bits |= GL_DEPTH_BUFFER_BIT;
|
||||||
}
|
}
|
||||||
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||||
|
@ -191,7 +191,7 @@ void ClearScreen(const BPCommand &bp, const TRectangle &multirc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RestoreRenderState(const BPCommand &bp)
|
void RestoreRenderState(const Bypass &bp)
|
||||||
{
|
{
|
||||||
Renderer::RestoreGLState();
|
Renderer::RestoreGLState();
|
||||||
}
|
}
|
||||||
|
@ -215,11 +215,11 @@ u8 *GetPointer(const u32 &address)
|
||||||
{
|
{
|
||||||
return g_VideoInitialize.pGetMemoryPointer(address);
|
return g_VideoInitialize.pGetMemoryPointer(address);
|
||||||
}
|
}
|
||||||
void SetSamplerState(const BPCommand &bp)
|
void SetSamplerState(const Bypass &bp)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
void SetInterlacingMode(const BPCommand &bp)
|
void SetInterlacingMode(const Bypass &bp)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
|
@ -21,7 +21,7 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "SUMemory.h"
|
#include "BPMemory.h"
|
||||||
#include "PixelShaderGen.h"
|
#include "PixelShaderGen.h"
|
||||||
|
|
||||||
struct FRAGMENTSHADER
|
struct FRAGMENTSHADER
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
#include "ImageWrite.h"
|
#include "ImageWrite.h"
|
||||||
#include "Render.h"
|
#include "Render.h"
|
||||||
#include "OpcodeDecoding.h"
|
#include "OpcodeDecoding.h"
|
||||||
#include "SUStructs.h"
|
#include "BPStructs.h"
|
||||||
#include "TextureMngr.h"
|
#include "TextureMngr.h"
|
||||||
#include "rasterfont.h"
|
#include "rasterfont.h"
|
||||||
#include "VertexShaderGen.h"
|
#include "VertexShaderGen.h"
|
||||||
|
@ -606,9 +606,9 @@ void Renderer::ResetGLState()
|
||||||
void Renderer::RestoreGLState()
|
void Renderer::RestoreGLState()
|
||||||
{
|
{
|
||||||
// Gets us back into a more game-like state.
|
// Gets us back into a more game-like state.
|
||||||
if (sumem.genMode.cullmode > 0) glEnable(GL_CULL_FACE);
|
if (bpmem.genMode.cullmode > 0) glEnable(GL_CULL_FACE);
|
||||||
if (sumem.zmode.testenable) glEnable(GL_DEPTH_TEST);
|
if (bpmem.zmode.testenable) glEnable(GL_DEPTH_TEST);
|
||||||
if (sumem.zmode.updateenable) glDepthMask(GL_TRUE);
|
if (bpmem.zmode.updateenable) glDepthMask(GL_TRUE);
|
||||||
|
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
SetScissorRect();
|
SetScissorRect();
|
||||||
|
@ -621,11 +621,11 @@ void Renderer::RestoreGLState()
|
||||||
|
|
||||||
void Renderer::SetColorMask()
|
void Renderer::SetColorMask()
|
||||||
{
|
{
|
||||||
if (sumem.blendmode.alphaupdate && sumem.blendmode.colorupdate)
|
if (bpmem.blendmode.alphaupdate && bpmem.blendmode.colorupdate)
|
||||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||||
else if (sumem.blendmode.alphaupdate)
|
else if (bpmem.blendmode.alphaupdate)
|
||||||
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
|
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
|
||||||
else if (sumem.blendmode.colorupdate)
|
else if (bpmem.blendmode.colorupdate)
|
||||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
|
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
|
||||||
else
|
else
|
||||||
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||||
|
@ -639,14 +639,14 @@ void Renderer::SetBlendMode(bool forceUpdate)
|
||||||
// 3-5 - srcRGB function
|
// 3-5 - srcRGB function
|
||||||
// 6-8 - dstRGB function
|
// 6-8 - dstRGB function
|
||||||
|
|
||||||
u32 newval = sumem.blendmode.subtract << 2;
|
u32 newval = bpmem.blendmode.subtract << 2;
|
||||||
|
|
||||||
if (sumem.blendmode.subtract) {
|
if (bpmem.blendmode.subtract) {
|
||||||
newval |= 0x0049; // enable blending src 1 dst 1
|
newval |= 0x0049; // enable blending src 1 dst 1
|
||||||
} else if (sumem.blendmode.blendenable) {
|
} else if (bpmem.blendmode.blendenable) {
|
||||||
newval |= 1; // enable blending
|
newval |= 1; // enable blending
|
||||||
newval |= sumem.blendmode.srcfactor << 3;
|
newval |= bpmem.blendmode.srcfactor << 3;
|
||||||
newval |= sumem.blendmode.dstfactor << 6;
|
newval |= bpmem.blendmode.dstfactor << 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 changes = forceUpdate ? 0xFFFFFFFF : newval ^ s_blendMode;
|
u32 changes = forceUpdate ? 0xFFFFFFFF : newval ^ s_blendMode;
|
||||||
|
@ -735,30 +735,30 @@ GLuint Renderer::ResolveAndGetDepthTarget(const TRectangle &source_rect)
|
||||||
// Call browser: OpcodeDecoding.cpp ExecuteDisplayList > Decode() > LoadBPReg()
|
// Call browser: OpcodeDecoding.cpp ExecuteDisplayList > Decode() > LoadBPReg()
|
||||||
// case 0x52 > SetScissorRect()
|
// case 0x52 > SetScissorRect()
|
||||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||||
// sumem.scissorTL.x, y = 342x342
|
// bpmem.scissorTL.x, y = 342x342
|
||||||
// sumem.scissorBR.x, y = 981x821
|
// bpmem.scissorBR.x, y = 981x821
|
||||||
// Renderer::GetTargetHeight() = the fixed ini file setting
|
// Renderer::GetTargetHeight() = the fixed ini file setting
|
||||||
// donkopunchstania - it appears scissorBR is the bottom right pixel inside the scissor box
|
// donkopunchstania - it appears scissorBR is the bottom right pixel inside the scissor box
|
||||||
// therefore the width and height are (scissorBR + 1) - scissorTL
|
// therefore the width and height are (scissorBR + 1) - scissorTL
|
||||||
bool Renderer::SetScissorRect()
|
bool Renderer::SetScissorRect()
|
||||||
{
|
{
|
||||||
int xoff = sumem.scissorOffset.x * 2 - 342;
|
int xoff = bpmem.scissorOffset.x * 2 - 342;
|
||||||
int yoff = sumem.scissorOffset.y * 2 - 342;
|
int yoff = bpmem.scissorOffset.y * 2 - 342;
|
||||||
float MValueX = GetTargetScaleX();
|
float MValueX = GetTargetScaleX();
|
||||||
float MValueY = GetTargetScaleY();
|
float MValueY = GetTargetScaleY();
|
||||||
float rc_left = (float)sumem.scissorTL.x - xoff - 342; // left = 0
|
float rc_left = (float)bpmem.scissorTL.x - xoff - 342; // left = 0
|
||||||
rc_left *= MValueX;
|
rc_left *= MValueX;
|
||||||
if (rc_left < 0) rc_left = 0;
|
if (rc_left < 0) rc_left = 0;
|
||||||
|
|
||||||
float rc_top = (float)sumem.scissorTL.y - yoff - 342; // right = 0
|
float rc_top = (float)bpmem.scissorTL.y - yoff - 342; // right = 0
|
||||||
rc_top *= MValueY;
|
rc_top *= MValueY;
|
||||||
if (rc_top < 0) rc_top = 0;
|
if (rc_top < 0) rc_top = 0;
|
||||||
|
|
||||||
float rc_right = (float)sumem.scissorBR.x - xoff - 341; // right = 640
|
float rc_right = (float)bpmem.scissorBR.x - xoff - 341; // right = 640
|
||||||
rc_right *= MValueX;
|
rc_right *= MValueX;
|
||||||
if (rc_right > EFB_WIDTH * MValueX) rc_right = EFB_WIDTH * MValueX;
|
if (rc_right > EFB_WIDTH * MValueX) rc_right = EFB_WIDTH * MValueX;
|
||||||
|
|
||||||
float rc_bottom = (float)sumem.scissorBR.y - yoff - 341; // bottom = 480
|
float rc_bottom = (float)bpmem.scissorBR.y - yoff - 341; // bottom = 480
|
||||||
rc_bottom *= MValueY;
|
rc_bottom *= MValueY;
|
||||||
if (rc_bottom > EFB_HEIGHT * MValueY) rc_bottom = EFB_HEIGHT * MValueY;
|
if (rc_bottom > EFB_HEIGHT * MValueY) rc_bottom = EFB_HEIGHT * MValueY;
|
||||||
|
|
||||||
|
@ -1384,7 +1384,7 @@ void Renderer::SetScreenshot(const char *filename)
|
||||||
bool Renderer::SaveRenderTarget(const char *filename, int W, int H, int YOffset)
|
bool Renderer::SaveRenderTarget(const char *filename, int W, int H, int YOffset)
|
||||||
{
|
{
|
||||||
// The height seemed to often be one less than the setting (but sometimes not),
|
// The height seemed to often be one less than the setting (but sometimes not),
|
||||||
// perhaps the source is the (sumem.copyTexSrcWH.y + 1) in SUStructs.cpp that I'm guessing
|
// perhaps the source is the (bpmem.copyTexSrcWH.y + 1) in BPStructs.cpp that I'm guessing
|
||||||
// is there because of how some GL function works. But the buffer we are reading from here
|
// is there because of how some GL function works. But the buffer we are reading from here
|
||||||
// seems to have the necessary pixels for a complete height so we use the complete height
|
// seems to have the necessary pixels for a complete height so we use the complete height
|
||||||
// from the settings.
|
// from the settings.
|
||||||
|
@ -1495,8 +1495,8 @@ void UpdateViewport()
|
||||||
(rawViewport[5] - rawViewport[2]) / 16777215.0f, rawViewport[5] / 16777215.0f);*/
|
(rawViewport[5] - rawViewport[2]) / 16777215.0f, rawViewport[5] / 16777215.0f);*/
|
||||||
// --------
|
// --------
|
||||||
|
|
||||||
int scissorXOff = sumem.scissorOffset.x * 2 - 342;
|
int scissorXOff = bpmem.scissorOffset.x * 2 - 342;
|
||||||
int scissorYOff = sumem.scissorOffset.y * 2 - 342;
|
int scissorYOff = bpmem.scissorOffset.y * 2 - 342;
|
||||||
// -------------------------------------
|
// -------------------------------------
|
||||||
|
|
||||||
float MValueX = Renderer::GetTargetScaleX();
|
float MValueX = Renderer::GetTargetScaleX();
|
||||||
|
|
|
@ -10,7 +10,7 @@ import platform
|
||||||
name = "Plugin_VideoOGL"
|
name = "Plugin_VideoOGL"
|
||||||
|
|
||||||
files = [
|
files = [
|
||||||
'SUFunctions.cpp',
|
'BPFunctions.cpp',
|
||||||
'Config.cpp',
|
'Config.cpp',
|
||||||
'rasterfont.cpp',
|
'rasterfont.cpp',
|
||||||
'Render.cpp',
|
'Render.cpp',
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "TextureDecoder.h"
|
#include "TextureDecoder.h"
|
||||||
#include "PixelShaderManager.h"
|
#include "PixelShaderManager.h"
|
||||||
#include "PixelShaderGen.h"
|
#include "PixelShaderGen.h"
|
||||||
#include "SUMemory.h"
|
#include "BPMemory.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
#include "Render.h"
|
#include "Render.h"
|
||||||
|
|
||||||
#include "MemoryUtil.h"
|
#include "MemoryUtil.h"
|
||||||
#include "SUStructs.h"
|
#include "BPStructs.h"
|
||||||
#include "TextureDecoder.h"
|
#include "TextureDecoder.h"
|
||||||
#include "TextureMngr.h"
|
#include "TextureMngr.h"
|
||||||
#include "PixelShaderCache.h"
|
#include "PixelShaderCache.h"
|
||||||
|
@ -256,7 +256,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
|
||||||
if (address == 0)
|
if (address == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
TexMode0 &tm0 = sumem.tex[texstage > 3].texMode0[texstage & 3];
|
TexMode0 &tm0 = bpmem.tex[texstage > 3].texMode0[texstage & 3];
|
||||||
u8 *ptr = g_VideoInitialize.pGetMemoryPointer(address);
|
u8 *ptr = g_VideoInitialize.pGetMemoryPointer(address);
|
||||||
int bsw = TexDecoder_GetBlockWidthInTexels(tex_format) - 1;
|
int bsw = TexDecoder_GetBlockWidthInTexels(tex_format) - 1;
|
||||||
int bsh = TexDecoder_GetBlockHeightInTexels(tex_format) - 1;
|
int bsh = TexDecoder_GetBlockHeightInTexels(tex_format) - 1;
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#include "VideoCommon.h"
|
#include "VideoCommon.h"
|
||||||
#include "GLUtil.h"
|
#include "GLUtil.h"
|
||||||
#include "SUStructs.h"
|
#include "BPStructs.h"
|
||||||
|
|
||||||
class TextureMngr
|
class TextureMngr
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
#include "Profiler.h"
|
#include "Profiler.h"
|
||||||
#include "Render.h"
|
#include "Render.h"
|
||||||
#include "ImageWrite.h"
|
#include "ImageWrite.h"
|
||||||
#include "SUMemory.h"
|
#include "BPMemory.h"
|
||||||
#include "TextureMngr.h"
|
#include "TextureMngr.h"
|
||||||
#include "PixelShaderCache.h"
|
#include "PixelShaderCache.h"
|
||||||
#include "PixelShaderManager.h"
|
#include "PixelShaderManager.h"
|
||||||
|
@ -155,8 +155,8 @@ void Flush()
|
||||||
|
|
||||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||||
PRIM_LOG("frame%d:\n texgen=%d, numchan=%d, dualtex=%d, ztex=%d, cole=%d, alpe=%d, ze=%d", g_Config.iSaveTargetId, xfregs.numTexGens,
|
PRIM_LOG("frame%d:\n texgen=%d, numchan=%d, dualtex=%d, ztex=%d, cole=%d, alpe=%d, ze=%d", g_Config.iSaveTargetId, xfregs.numTexGens,
|
||||||
xfregs.nNumChans, (int)xfregs.bEnableDualTexTransform, sumem.ztex2.op,
|
xfregs.nNumChans, (int)xfregs.bEnableDualTexTransform, bpmem.ztex2.op,
|
||||||
sumem.blendmode.colorupdate, sumem.blendmode.alphaupdate, sumem.zmode.updateenable);
|
bpmem.blendmode.colorupdate, bpmem.blendmode.alphaupdate, bpmem.zmode.updateenable);
|
||||||
|
|
||||||
for (int i = 0; i < xfregs.nNumChans; ++i)
|
for (int i = 0; i < xfregs.nNumChans; ++i)
|
||||||
{
|
{
|
||||||
|
@ -177,8 +177,8 @@ void Flush()
|
||||||
xfregs.texcoords[i].postmtxinfo.index, xfregs.texcoords[i].postmtxinfo.normalize);
|
xfregs.texcoords[i].postmtxinfo.index, xfregs.texcoords[i].postmtxinfo.normalize);
|
||||||
}
|
}
|
||||||
|
|
||||||
PRIM_LOG("pixel: tev=%d, ind=%d, texgen=%d, dstalpha=%d, alphafunc=0x%x", sumem.genMode.numtevstages+1, sumem.genMode.numindstages,
|
PRIM_LOG("pixel: tev=%d, ind=%d, texgen=%d, dstalpha=%d, alphafunc=0x%x", bpmem.genMode.numtevstages+1, bpmem.genMode.numindstages,
|
||||||
sumem.genMode.numtexgens, (u32)sumem.dstalpha.enable, (sumem.alphaFunc.hex>>16)&0xff);
|
bpmem.genMode.numtexgens, (u32)bpmem.dstalpha.enable, (bpmem.alphaFunc.hex>>16)&0xff);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DVSTARTPROFILE();
|
DVSTARTPROFILE();
|
||||||
|
@ -198,14 +198,14 @@ void Flush()
|
||||||
DVSTARTSUBPROFILE("VertexManager::Flush:textures");
|
DVSTARTSUBPROFILE("VertexManager::Flush:textures");
|
||||||
|
|
||||||
u32 usedtextures = 0;
|
u32 usedtextures = 0;
|
||||||
for (u32 i = 0; i < (u32)sumem.genMode.numtevstages + 1; ++i)
|
for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages + 1; ++i)
|
||||||
if (sumem.tevorders[i / 2].getEnable(i & 1))
|
if (bpmem.tevorders[i / 2].getEnable(i & 1))
|
||||||
usedtextures |= 1 << sumem.tevorders[i/2].getTexMap(i & 1);
|
usedtextures |= 1 << bpmem.tevorders[i/2].getTexMap(i & 1);
|
||||||
|
|
||||||
if (sumem.genMode.numindstages > 0)
|
if (bpmem.genMode.numindstages > 0)
|
||||||
for (u32 i = 0; i < (u32)sumem.genMode.numtevstages + 1; ++i)
|
for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages + 1; ++i)
|
||||||
if (sumem.tevind[i].IsActive() && sumem.tevind[i].bt < sumem.genMode.numindstages)
|
if (bpmem.tevind[i].IsActive() && bpmem.tevind[i].bt < bpmem.genMode.numindstages)
|
||||||
usedtextures |= 1 << sumem.tevindref.getTexMap(sumem.tevind[i].bt);
|
usedtextures |= 1 << bpmem.tevindref.getTexMap(bpmem.tevind[i].bt);
|
||||||
|
|
||||||
u32 nonpow2tex = 0;
|
u32 nonpow2tex = 0;
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
|
@ -214,7 +214,7 @@ void Flush()
|
||||||
{
|
{
|
||||||
glActiveTexture(GL_TEXTURE0 + i);
|
glActiveTexture(GL_TEXTURE0 + i);
|
||||||
|
|
||||||
FourTexUnits &tex = sumem.tex[i >> 2];
|
FourTexUnits &tex = bpmem.tex[i >> 2];
|
||||||
TextureMngr::TCacheEntry* tentry = TextureMngr::Load(i, (tex.texImage3[i&3].image_base/* & 0x1FFFFF*/) << 5,
|
TextureMngr::TCacheEntry* tentry = TextureMngr::Load(i, (tex.texImage3[i&3].image_base/* & 0x1FFFFF*/) << 5,
|
||||||
tex.texImage0[i&3].width + 1, tex.texImage0[i&3].height + 1,
|
tex.texImage0[i&3].width + 1, tex.texImage0[i&3].height + 1,
|
||||||
tex.texImage0[i&3].format, tex.texTlut[i&3].tmem_offset<<9, tex.texTlut[i&3].tlut_format);
|
tex.texImage0[i&3].format, tex.texTlut[i&3].tmem_offset<<9, tex.texTlut[i&3].tlut_format);
|
||||||
|
@ -284,7 +284,7 @@ void Flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
// run through vertex groups again to set alpha
|
// run through vertex groups again to set alpha
|
||||||
if (!g_Config.bDstAlphaPass && sumem.dstalpha.enable && sumem.blendmode.alphaupdate)
|
if (!g_Config.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate)
|
||||||
{
|
{
|
||||||
ps = PixelShaderCache::GetShader(true);
|
ps = PixelShaderCache::GetShader(true);
|
||||||
|
|
||||||
|
@ -309,7 +309,7 @@ void Flush()
|
||||||
// restore color mask
|
// restore color mask
|
||||||
Renderer::SetColorMask();
|
Renderer::SetColorMask();
|
||||||
|
|
||||||
if (sumem.blendmode.blendenable || sumem.blendmode.subtract)
|
if (bpmem.blendmode.blendenable || bpmem.blendmode.subtract)
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "SUMemory.h"
|
#include "BPMemory.h"
|
||||||
#include "VertexShaderGen.h"
|
#include "VertexShaderGen.h"
|
||||||
|
|
||||||
struct VERTEXSHADER
|
struct VERTEXSHADER
|
||||||
|
|
|
@ -71,7 +71,7 @@ Make AA apply instantly during gameplay if possible
|
||||||
#include "Fifo.h"
|
#include "Fifo.h"
|
||||||
#include "OpcodeDecoding.h"
|
#include "OpcodeDecoding.h"
|
||||||
#include "TextureMngr.h"
|
#include "TextureMngr.h"
|
||||||
#include "SUStructs.h"
|
#include "BPStructs.h"
|
||||||
#include "VertexLoader.h"
|
#include "VertexLoader.h"
|
||||||
#include "VertexLoaderManager.h"
|
#include "VertexLoaderManager.h"
|
||||||
#include "VertexManager.h"
|
#include "VertexManager.h"
|
||||||
|
@ -330,7 +330,7 @@ void DoState(unsigned char **ptr, int mode) {
|
||||||
// Refresh state.
|
// Refresh state.
|
||||||
if (mode == PointerWrap::MODE_READ)
|
if (mode == PointerWrap::MODE_READ)
|
||||||
{
|
{
|
||||||
SUReload();
|
BPReload();
|
||||||
RecomputeCachedArraybases();
|
RecomputeCachedArraybases();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -347,7 +347,7 @@ void Video_Prepare(void)
|
||||||
|
|
||||||
TextureMngr::Init();
|
TextureMngr::Init();
|
||||||
|
|
||||||
SUInit();
|
BPInit();
|
||||||
VertexManager::Init();
|
VertexManager::Init();
|
||||||
Fifo_Init(); // must be done before OpcodeDecoder_Init()
|
Fifo_Init(); // must be done before OpcodeDecoder_Init()
|
||||||
OpcodeDecoder_Init();
|
OpcodeDecoder_Init();
|
||||||
|
|
|
@ -141,7 +141,7 @@ RasterFont::~RasterFont()
|
||||||
|
|
||||||
void RasterFont::printString(const char *s, double x, double y, double z)
|
void RasterFont::printString(const char *s, double x, double y, double z)
|
||||||
{
|
{
|
||||||
int length = (int)strlen(s);
|
int length = strlen(s);
|
||||||
if (!length)
|
if (!length)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue