They should be called SU Registers (Setup Unit/Rasterization). BP (Bypass) is really the name of the commands that are passed in.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3531 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
omegadox
2009-06-22 07:40:28 +00:00
parent cfe3f77ccf
commit 6de0cd1e4b
36 changed files with 257 additions and 2479 deletions
-60
View File
@@ -1,60 +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/
// ------------------------------------------
// The plugins has to define these functions
// ------------------------------------------
#ifndef _BPFUNCTIONS_H_
#define _BPFUNCTIONS_H_
#include "BPMemory.h"
#include "VideoCommon.h"
namespace BPFunctions
{
enum
{
CONFIG_ISWII = 0,
CONFIG_DISABLEFOG,
CONFIG_SHOWEFBREGIONS
};
void FlushPipeline();
void SetGenerationMode(const Bypass &bp);
void SetScissor(const Bypass &bp);
void SetLineWidth(const Bypass &bp);
void SetDepthMode(const Bypass &bp);
void SetBlendMode(const Bypass &bp);
void SetDitherMode(const Bypass &bp);
void SetLogicOpMode(const Bypass &bp);
void SetColorMask(const Bypass &bp);
float GetRendererTargetScaleX();
float GetRendererTargetScaleY();
void CopyEFB(const Bypass &bp, const TRectangle &rc, const u32 &address, const bool &fromZBuffer, const bool &isIntensityFmt, const u32 &copyfmt, const bool &scaleByHalf);
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 Bypass &bp, const TRectangle &multirc);
void RestoreRenderState(const Bypass &bp);
u8 *GetPointer(const u32 &address);
bool GetConfig(const int &type);
void SetSamplerState(const Bypass &bp);
void SetInterlacingMode(const Bypass &bp);
};
#endif // _BPFUNCTIONS_H_
-68
View File
@@ -1,68 +0,0 @@
// Copyright (C) 2003-2008 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 "Common.h"
#include "BPMemory.h"
//BP state
// STATE_TO_SAVE
BPMemory bpmem;
// The plugin must implement this.
void BPWritten(const Bypass& bp);
// Call browser: OpcodeDecoding.cpp ExecuteDisplayList > Decode() > LoadBPReg()
void LoadBPReg(u32 value0)
{
//handle the mask register
int opcode = value0 >> 24;
int oldval = ((u32*)&bpmem)[opcode];
int newval = (oldval & ~bpmem.bpMask) | (value0 & bpmem.bpMask);
int changes = (oldval ^ newval) & 0xFFFFFF;
Bypass bp = {opcode, changes, newval};
//reset the mask register
if (opcode != 0xFE)
bpmem.bpMask = 0xFFFFFF;
BPWritten(bp);
}
// Called when loading a saved state.
// Needs more testing though.
void BPReload()
{
for (int i = 0; i < 254; i++)
{
switch (i) {
case 0x41:
case 0x45: //GXSetDrawDone
case 0x52:
case 0x65:
case 0x67: // set gp metric?
case BPMEM_PE_TOKEN_ID:
case BPMEM_PE_TOKEN_INT_ID:
// Cases in which we DON'T want to reload the BP
continue;
default:
Bypass bp = {i, 0xFFFFFF, ((u32*)&bpmem)[i]};
BPWritten(bp);
}
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-27
View File
@@ -1,27 +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/
#ifndef _BPSTRUCTS_H_
#define _BPSTRUCTS_H_
#include "BPMemory.h"
void BPInit();
void LoadBPReg(u32 value0);
void BPReload();
#endif // _BPSTRUCTS_H_
@@ -35,7 +35,7 @@
#include "XFMemory.h"
#include "CPMemory.h"
#include "BPMemory.h"
#include "SUMemory.h"
#include "Fifo.h"
#include "DataReader.h"
@@ -267,7 +267,7 @@ static void Decode()
case GX_LOAD_BP_REG: //0x61
{
u32 cmd = DataReadU32();
LoadBPReg(cmd);
LoadSUReg(cmd);
INCSTAT(stats.thisFrame.numBPLoads);
}
break;
+97 -97
View File
@@ -22,63 +22,63 @@
#include "Profiler.h"
#include "PixelShaderGen.h"
#include "XFMemory.h" // for texture projection mode
#include "BPMemory.h"
#include "SUMemory.h"
// 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 ....
void GetPixelShaderId(PIXELSHADERUID &uid, u32 s_texturemask, u32 dstAlphaEnable)
{
u32 projtexcoords = 0;
for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages + 1; i++) {
if (bpmem.tevorders[i/2].getEnable(i&1)) {
int texcoord = bpmem.tevorders[i/2].getTexCoord(i&1);
for (u32 i = 0; i < (u32)sumem.genMode.numtevstages + 1; i++) {
if (sumem.tevorders[i/2].getEnable(i&1)) {
int texcoord = sumem.tevorders[i/2].getTexCoord(i&1);
if (xfregs.texcoords[texcoord].texmtxinfo.projection )
projtexcoords |= 1 << texcoord;
}
}
uid.values[0] = (u32)bpmem.genMode.numtevstages |
((u32)bpmem.genMode.numindstages << 4) |
((u32)bpmem.genMode.numtexgens << 7) |
uid.values[0] = (u32)sumem.genMode.numtevstages |
((u32)sumem.genMode.numindstages << 4) |
((u32)sumem.genMode.numtexgens << 7) |
((u32)dstAlphaEnable << 11) |
((u32)((bpmem.alphaFunc.hex >> 16) & 0xff) << 12) |
((u32)((sumem.alphaFunc.hex >> 16) & 0xff) << 12) |
(projtexcoords << 20) |
((u32)bpmem.ztex2.op << 28);
((u32)sumem.ztex2.op << 28);
uid.values[0] = (uid.values[0] & ~0x0ff00000) | (projtexcoords << 20);
// swap table
for (int i = 0; i < 8; i += 2)
((u8*)&uid.values[1])[i/2] = (bpmem.tevksel[i].hex & 0xf) | ((bpmem.tevksel[i + 1].hex & 0xf) << 4);
((u8*)&uid.values[1])[i/2] = (sumem.tevksel[i].hex & 0xf) | ((sumem.tevksel[i + 1].hex & 0xf) << 4);
uid.values[2] = s_texturemask;
uid.values[3] = (u32)bpmem.fog.c_proj_fsel.fsel |
((u32)bpmem.fog.c_proj_fsel.proj << 3);
uid.values[3] = (u32)sumem.fog.c_proj_fsel.fsel |
((u32)sumem.fog.c_proj_fsel.proj << 3);
int hdr = 4;
u32* pcurvalue = &uid.values[hdr];
for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages+1; ++i) {
TevStageCombiner::ColorCombiner &cc = bpmem.combiners[i].colorC;
TevStageCombiner::AlphaCombiner &ac = bpmem.combiners[i].alphaC;
for (u32 i = 0; i < (u32)sumem.genMode.numtevstages+1; ++i) {
TevStageCombiner::ColorCombiner &cc = sumem.combiners[i].colorC;
TevStageCombiner::AlphaCombiner &ac = sumem.combiners[i].alphaC;
u32 val0 = cc.hex&0xffffff;
u32 val1 = ac.hex&0xffffff;
val0 |= bpmem.tevksel[i/2].getKC(i&1)<<24;
val1 |= bpmem.tevksel[i/2].getKA(i&1)<<24;
val0 |= sumem.tevksel[i/2].getKC(i&1)<<24;
val1 |= sumem.tevksel[i/2].getKA(i&1)<<24;
pcurvalue[0] = val0;
pcurvalue[1] = val1;
pcurvalue += 2;
}
for (u32 i = 0; i < ((u32)bpmem.genMode.numtevstages+1)/2; ++i) {
for (u32 i = 0; i < ((u32)sumem.genMode.numtevstages+1)/2; ++i) {
u32 val0, val1;
if (bpmem.tevorders[i].hex & 0x40)
val0 = bpmem.tevorders[i].hex & 0x3ff;
if (sumem.tevorders[i].hex & 0x40)
val0 = sumem.tevorders[i].hex & 0x3ff;
else
val0 = bpmem.tevorders[i].hex & 0x380;
if (bpmem.tevorders[i].hex & 0x40000)
val1 = (bpmem.tevorders[i].hex & 0x3ff000) >> 12;
val0 = sumem.tevorders[i].hex & 0x380;
if (sumem.tevorders[i].hex & 0x40000)
val1 = (sumem.tevorders[i].hex & 0x3ff000) >> 12;
else
val1 = (bpmem.tevorders[i].hex & 0x380000) >> 12;
val1 = (sumem.tevorders[i].hex & 0x380000) >> 12;
switch (i % 3) {
case 0: pcurvalue[0] = val0|(val1<<10); break;
@@ -87,27 +87,27 @@ void GetPixelShaderId(PIXELSHADERUID &uid, u32 s_texturemask, u32 dstAlphaEnable
}
}
if ((bpmem.genMode.numtevstages + 1) & 1) { // odd
if ((sumem.genMode.numtevstages + 1) & 1) { // odd
u32 val0;
if (bpmem.tevorders[bpmem.genMode.numtevstages/2].hex & 0x40)
val0 = bpmem.tevorders[bpmem.genMode.numtevstages/2].hex&0x3ff;
if (sumem.tevorders[sumem.genMode.numtevstages/2].hex & 0x40)
val0 = sumem.tevorders[sumem.genMode.numtevstages/2].hex&0x3ff;
else
val0 = bpmem.tevorders[bpmem.genMode.numtevstages/2].hex & 0x380;
val0 = sumem.tevorders[sumem.genMode.numtevstages/2].hex & 0x380;
switch (bpmem.genMode.numtevstages % 3) {
switch (sumem.genMode.numtevstages % 3) {
case 0: pcurvalue[0] = val0; break;
case 1: pcurvalue[0] |= val0 << 20; break;
case 2: pcurvalue[1] |= val0 << 10; pcurvalue++; break;
}
}
if ((bpmem.genMode.numtevstages % 3) != 2)
if ((sumem.genMode.numtevstages % 3) != 2)
++pcurvalue;
uid.tevstages = (u32)(pcurvalue-&uid.values[0]-hdr);
for (u32 i = 0; i < bpmem.genMode.numindstages; ++i) {
u32 val = bpmem.tevind[i].hex & 0x1fffff; // 21 bits
for (u32 i = 0; i < sumem.genMode.numindstages; ++i) {
u32 val = sumem.tevind[i].hex & 0x1fffff; // 21 bits
switch (i%3) {
case 0: pcurvalue[0] = val; 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
//
// color for this stage (alpha, color) is given by bpmem.tevorders[0].colorchan0
// konstant for this stage (alpha, color) is given by bpmem.tevksel
// inputs are given by bpmem.combiners[0].colorC.a/b/c/d << could be current chan color
// color for this stage (alpha, color) is given by sumem.tevorders[0].colorchan0
// konstant for this stage (alpha, color) is given by sumem.tevksel
// inputs are given by sumem.combiners[0].colorC.a/b/c/d << could be current chan color
// according to GXTevColorArg table above
// output is given by .outreg
// tevtemp is set according to swapmodetables and
@@ -356,13 +356,13 @@ static char text[16384];
static void BuildSwapModeTable()
{
//bpmem.tevregs[0].
//sumem.tevregs[0].
for (int i = 0; i < 4; i++)
{
swapModeTable[i][0] = swapColors[bpmem.tevksel[i*2].swap1];
swapModeTable[i][1] = swapColors[bpmem.tevksel[i*2].swap2];
swapModeTable[i][2] = swapColors[bpmem.tevksel[i*2+1].swap1];
swapModeTable[i][3] = swapColors[bpmem.tevksel[i*2+1].swap2];
swapModeTable[i][0] = swapColors[sumem.tevksel[i*2].swap1];
swapModeTable[i][1] = swapColors[sumem.tevksel[i*2].swap2];
swapModeTable[i][2] = swapColors[sumem.tevksel[i*2+1].swap1];
swapModeTable[i][3] = swapColors[sumem.tevksel[i*2+1].swap2];
swapModeTable[i][4] = 0;
}
}
@@ -373,19 +373,19 @@ const char *GeneratePixelShader(u32 texture_mask, bool dstAlphaEnable, bool HLSL
DVSTARTPROFILE();
BuildSwapModeTable();
int numStages = bpmem.genMode.numtevstages + 1;
int numTexgen = bpmem.genMode.numtexgens;
int numStages = sumem.genMode.numtevstages + 1;
int numTexgen = sumem.genMode.numtexgens;
char *p = text;
WRITE(p, "//Pixel Shader for TEV stages\n");
WRITE(p, "//%i TEV stages, %i texgens, %i IND stages\n",
numStages, numTexgen, bpmem.genMode.numindstages);
numStages, numTexgen, sumem.genMode.numindstages);
int nIndirectStagesUsed = 0;
if (bpmem.genMode.numindstages > 0) {
if (sumem.genMode.numindstages > 0) {
for (int i = 0; i < numStages; ++i) {
if (bpmem.tevind[i].IsActive() && bpmem.tevind[i].bt < bpmem.genMode.numindstages) {
nIndirectStagesUsed |= 1<<bpmem.tevind[i].bt;
if (sumem.tevind[i].IsActive() && sumem.tevind[i].bt < sumem.genMode.numindstages) {
nIndirectStagesUsed |= 1<<sumem.tevind[i].bt;
}
}
}
@@ -462,9 +462,9 @@ const char *GeneratePixelShader(u32 texture_mask, bool dstAlphaEnable, bool HLSL
}
// indirect texture map lookup
for(u32 i = 0; i < bpmem.genMode.numindstages; ++i) {
for(u32 i = 0; i < sumem.genMode.numindstages; ++i) {
if (nIndirectStagesUsed & (1<<i)) {
int texcoord = bpmem.tevindref.getTexCoord(i);
int texcoord = sumem.tevindref.getTexCoord(i);
if (texcoord < numTexgen) {
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];
sprintf(buffer, "float3 indtex%d", i);
SampleTexture(p, buffer, "tempcoord", "abg", bpmem.tevindref.getTexMap(i), texture_mask);
SampleTexture(p, buffer, "tempcoord", "abg", sumem.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");
// use the texture input of the last texture stage (textemp), hopefully this has been read and is in correct format...
if (bpmem.ztex2.op == ZTEXTURE_ADD) {
if (sumem.ztex2.op == ZTEXTURE_ADD) {
WRITE(p, "depth = frac(dot("I_ZBIAS"[0].xyzw, textemp.xyzw) + "I_ZBIAS"[1].w + zCoord);\n");
}
else if (bpmem.ztex2.op == ZTEXTURE_REPLACE) {
else if (sumem.ztex2.op == ZTEXTURE_REPLACE) {
WRITE(p, "depth = frac(dot("I_ZBIAS"[0].xyzw, textemp.xyzw) + "I_ZBIAS"[1].w);\n");
}
else {
WRITE(p, "depth = zCoord;\n");
}
//if (bpmem.genMode.numindstages ) WRITE(p, "prev.rg = indtex0.xy;\nprev.b = 0;\n");
//if (sumem.genMode.numindstages ) WRITE(p, "prev.rg = indtex0.xy;\nprev.b = 0;\n");
if (!WriteAlphaTest(p, HLSL)) {
// 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)
{
char *rasswap = swapModeTable[bpmem.combiners[n].alphaC.rswap];
char *texswap = swapModeTable[bpmem.combiners[n].alphaC.tswap];
char *rasswap = swapModeTable[sumem.combiners[n].alphaC.rswap];
char *texswap = swapModeTable[sumem.combiners[n].alphaC.tswap];
int texcoord = bpmem.tevorders[n/2].getTexCoord(n&1);
bool bHasTexCoord = (u32)texcoord < bpmem.genMode.numtexgens;
bool bHasIndStage = bpmem.tevind[n].IsActive() && bpmem.tevind[n].bt < bpmem.genMode.numindstages;
int texcoord = sumem.tevorders[n/2].getTexCoord(n&1);
bool bHasTexCoord = (u32)texcoord < sumem.genMode.numtexgens;
bool bHasIndStage = sumem.tevind[n].IsActive() && sumem.tevind[n].bt < sumem.genMode.numindstages;
// HACK to handle cases where the tex gen is not enabled
if (!bHasTexCoord) {
@@ -545,46 +545,46 @@ static void WriteStage(char *&p, int n, u32 texture_mask)
if (bHasIndStage) {
// perform the indirect op on the incoming regular coordinates using indtex%d as the offset coords
if (bpmem.tevind[n].bs != ITBA_OFF) {
if (sumem.tevind[n].bs != ITBA_OFF) {
// write the bump alpha
if (bpmem.tevind[n].fmt == ITF_8) {
WRITE(p, "alphabump = indtex%d.%s %s;\n", bpmem.tevind[n].bt,
tevIndAlphaSel[bpmem.tevind[n].bs], tevIndAlphaScale[bpmem.tevind[n].fmt]);
if (sumem.tevind[n].fmt == ITF_8) {
WRITE(p, "alphabump = indtex%d.%s %s;\n", sumem.tevind[n].bt,
tevIndAlphaSel[sumem.tevind[n].bs], tevIndAlphaScale[sumem.tevind[n].fmt]);
}
else {
// 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
// omitting fract seems to work as well
WRITE(p, "if (indtex%d.%s >= 1.0f )\n", bpmem.tevind[n].bt,
tevIndAlphaSel[bpmem.tevind[n].bs]);
WRITE(p, "if (indtex%d.%s >= 1.0f )\n", sumem.tevind[n].bt,
tevIndAlphaSel[sumem.tevind[n].bs]);
WRITE(p, " alphabump = 1.0f;\n");
WRITE(p, "else\n");
WRITE(p, " alphabump = fract ( indtex%d.%s %s );\n", bpmem.tevind[n].bt,
tevIndAlphaSel[bpmem.tevind[n].bs], tevIndAlphaScale[bpmem.tevind[n].fmt]);
WRITE(p, " alphabump = fract ( indtex%d.%s %s );\n", sumem.tevind[n].bt,
tevIndAlphaSel[sumem.tevind[n].bs], tevIndAlphaScale[sumem.tevind[n].fmt]);
}
}
// format
WRITE(p, "float3 indtevcrd%d = indtex%d * %s;\n", n, bpmem.tevind[n].bt, tevIndFmtScale[bpmem.tevind[n].fmt]);
WRITE(p, "float3 indtevcrd%d = indtex%d * %s;\n", n, sumem.tevind[n].bt, tevIndFmtScale[sumem.tevind[n].fmt]);
// bias
if (bpmem.tevind[n].bias != ITB_NONE )
WRITE(p, "indtevcrd%d.%s += %s;\n", n, tevIndBiasField[bpmem.tevind[n].bias], tevIndBiasAdd[bpmem.tevind[n].fmt]);
if (sumem.tevind[n].bias != ITB_NONE )
WRITE(p, "indtevcrd%d.%s += %s;\n", n, tevIndBiasField[sumem.tevind[n].bias], tevIndBiasAdd[sumem.tevind[n].fmt]);
// multiply by offset matrix and scale
if (bpmem.tevind[n].mid != 0) {
if (bpmem.tevind[n].mid <= 3) {
int mtxidx = 2*(bpmem.tevind[n].mid-1);
if (sumem.tevind[n].mid != 0) {
if (sumem.tevind[n].mid <= 3) {
int mtxidx = 2*(sumem.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",
n, mtxidx, n, mtxidx+1, n);
}
else if (bpmem.tevind[n].mid <= 7 && bHasTexCoord) { // s matrix
int mtxidx = 2*(bpmem.tevind[n].mid-5);
else if (sumem.tevind[n].mid <= 7 && bHasTexCoord) { // s matrix
int mtxidx = 2*(sumem.tevind[n].mid-5);
WRITE(p, "float2 indtevtrans%d = "I_INDTEXMTX"[%d].ww * uv%d.xy * indtevcrd%d.xx;\n", n, mtxidx, texcoord, n);
}
else if (bpmem.tevind[n].mid <= 11 && bHasTexCoord) { // t matrix
int mtxidx = 2*(bpmem.tevind[n].mid-9);
else if (sumem.tevind[n].mid <= 11 && bHasTexCoord) { // t matrix
int mtxidx = 2*(sumem.tevind[n].mid-9);
WRITE(p, "float2 indtevtrans%d = "I_INDTEXMTX"[%d].ww * uv%d.xy * indtevcrd%d.yy;\n", n, mtxidx, texcoord, n);
}
else {
@@ -598,28 +598,28 @@ static void WriteStage(char *&p, int n, u32 texture_mask)
// wrapping
// wrap S
if (bpmem.tevind[n].sw == ITW_OFF) {
if (sumem.tevind[n].sw == ITW_OFF) {
WRITE(p, "wrappedcoord.x = uv%d.x;\n", texcoord);
}
else if (bpmem.tevind[n].sw == ITW_0) {
else if (sumem.tevind[n].sw == ITW_0) {
WRITE(p, "wrappedcoord.x = 0.0f;\n");
}
else {
WRITE(p, "wrappedcoord.x = fmod( uv%d.x, %s );\n", texcoord, tevIndWrapStart[bpmem.tevind[n].sw]);
WRITE(p, "wrappedcoord.x = fmod( uv%d.x, %s );\n", texcoord, tevIndWrapStart[sumem.tevind[n].sw]);
}
// wrap T
if (bpmem.tevind[n].tw == ITW_OFF) {
if (sumem.tevind[n].tw == ITW_OFF) {
WRITE(p, "wrappedcoord.y = uv%d.y;\n", texcoord);
}
else if (bpmem.tevind[n].tw == ITW_0) {
else if (sumem.tevind[n].tw == ITW_0) {
WRITE(p, "wrappedcoord.y = 0.0f;\n");
}
else {
WRITE(p, "wrappedcoord.y = fmod( uv%d.y, %s );\n", texcoord, tevIndWrapStart[bpmem.tevind[n].tw]);
WRITE(p, "wrappedcoord.y = fmod( uv%d.y, %s );\n", texcoord, tevIndWrapStart[sumem.tevind[n].tw]);
}
if (bpmem.tevind[n].fb_addprev) {
if (sumem.tevind[n].fb_addprev) {
// add previous tevcoord
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[bpmem.tevorders[n/2].getColorChan(n&1)],rasswap);
WRITE(p, "rastemp=%s.%s;\n",tevRasTable[sumem.tevorders[n/2].getColorChan(n&1)],rasswap);
if (bpmem.tevorders[n/2].getEnable(n&1)) {
int texmap = bpmem.tevorders[n/2].getTexMap(n&1);
if (sumem.tevorders[n/2].getEnable(n&1)) {
int texmap = sumem.tevorders[n/2].getTexMap(n&1);
if(!bHasIndStage) {
// calc tevcord
if(bHasTexCoord) {
@@ -646,11 +646,11 @@ static void WriteStage(char *&p, int n, u32 texture_mask)
else
WRITE(p, "textemp=float4(1,1,1,1);\n");
int kc = bpmem.tevksel[n/2].getKC(n&1);
int ka = bpmem.tevksel[n/2].getKA(n&1);
int kc = sumem.tevksel[n/2].getKC(n&1);
int ka = sumem.tevksel[n/2].getKA(n&1);
TevStageCombiner::ColorCombiner &cc = bpmem.combiners[n].colorC;
TevStageCombiner::AlphaCombiner &ac = bpmem.combiners[n].alphaC;
TevStageCombiner::ColorCombiner &cc = sumem.combiners[n].colorC;
TevStageCombiner::AlphaCombiner &ac = sumem.combiners[n].alphaC;
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;
@@ -797,8 +797,8 @@ static void WriteAlphaCompare(char *&p, int num, int comp)
static bool WriteAlphaTest(char *&p, bool HLSL)
{
u32 op = bpmem.alphaFunc.logic;
u32 comp[2] = {bpmem.alphaFunc.comp0,bpmem.alphaFunc.comp1};
u32 op = sumem.alphaFunc.logic;
u32 comp[2] = {sumem.alphaFunc.comp0,sumem.alphaFunc.comp1};
//first kill all the simple cases
switch(op) {
@@ -839,26 +839,26 @@ static bool WriteAlphaTest(char *&p, bool HLSL)
else {
WRITE(p, "discard( ");
}
WriteAlphaCompare(p, 0, bpmem.alphaFunc.comp0);
WriteAlphaCompare(p, 0, sumem.alphaFunc.comp0);
// negated because testing the inverse condition
switch (bpmem.alphaFunc.logic) {
switch (sumem.alphaFunc.logic) {
case 0: WRITE(p, " || "); break; // and
case 1: WRITE(p, " && "); break; // or
case 2: WRITE(p, " == "); break; // xor
case 3: WRITE(p, " != "); break; // xnor
}
WriteAlphaCompare(p, 1, bpmem.alphaFunc.comp1);
WriteAlphaCompare(p, 1, sumem.alphaFunc.comp1);
WRITE(p, ");\n");
return true;
}
static void WriteFog(char *&p)
{
bool enabled = bpmem.fog.c_proj_fsel.fsel == 0 ? false : true;
bool enabled = sumem.fog.c_proj_fsel.fsel == 0 ? false : true;
if (enabled) {
if (bpmem.fog.c_proj_fsel.proj == 0) {
if (sumem.fog.c_proj_fsel.proj == 0) {
// perspective
// ze = A/(B - Zs)
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");
}
switch (bpmem.fog.c_proj_fsel.fsel) {
switch (sumem.fog.c_proj_fsel.fsel) {
case 2: // linear
// empty
break;
@@ -99,7 +99,7 @@ void PixelShaderManager::SetConstants()
{
static float ffrac = 255.0f/256.0f;
float ftemp[4];
switch (bpmem.ztex2.type)
switch (sumem.ztex2.type)
{
case 0:
// 8 bits
@@ -122,7 +122,7 @@ void PixelShaderManager::SetConstants()
if (s_bZBiasChanged || s_bDepthRangeChanged)
{
//ERROR_LOG("pixel=%x,%x, bias=%x\n", bpmem.zcontrol.pixel_format, bpmem.ztex2.type, lastZBias);
//ERROR_LOG("pixel=%x,%x, bias=%x\n", sumem.zcontrol.pixel_format, sumem.ztex2.type, lastZBias);
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;
}
@@ -137,8 +137,8 @@ void PixelShaderManager::SetConstants()
{
for (u32 i = 0; i < 2; ++i)
{
f[2 * i] = bpmem.texscale[0].getScaleS(i & 1);
f[2 * i + 1] = bpmem.texscale[0].getScaleT(i & 1);
f[2 * i] = sumem.texscale[0].getScaleS(i & 1);
f[2 * i + 1] = sumem.texscale[0].getScaleT(i & 1);
PRIM_LOG("tex indscale%d: %f %f\n", i, f[2 * i], f[2 * i + 1]);
}
SetPSConstant4fv(C_INDTEXSCALE, f);
@@ -146,8 +146,8 @@ void PixelShaderManager::SetConstants()
if (s_nIndTexScaleChanged & 0x0c) {
for (u32 i = 2; i < 4; ++i) {
f[2 * i] = bpmem.texscale[1].getScaleS(i & 1);
f[2 * i + 1] = bpmem.texscale[1].getScaleT(i & 1);
f[2 * i] = sumem.texscale[1].getScaleS(i & 1);
f[2 * i + 1] = sumem.texscale[1].getScaleT(i & 1);
PRIM_LOG("tex indscale%d: %f %f\n", i, f[2 * i], f[2 * i + 1]);
}
SetPSConstant4fv(C_INDTEXSCALE+1, &f[4]);
@@ -162,28 +162,28 @@ void PixelShaderManager::SetConstants()
{
if (s_nIndTexMtxChanged & (1 << i))
{
int scale = ((u32)bpmem.indmtx[i].col0.s0 << 0) |
((u32)bpmem.indmtx[i].col1.s1 << 2) |
((u32)bpmem.indmtx[i].col2.s2 << 4);
int scale = ((u32)sumem.indmtx[i].col0.s0 << 0) |
((u32)sumem.indmtx[i].col1.s1 << 2) |
((u32)sumem.indmtx[i].col2.s2 << 4);
float fscale = powf(2.0f, (float)(scale - 17)) / 1024.0f;
// xyz - static matrix
// TODO w - dynamic matrix scale / 256...... somehow / 4 works better
// rev 2972 - now using / 256.... verify that this works
SetPSConstant4f(C_INDTEXMTX + 2 * i,
bpmem.indmtx[i].col0.ma * fscale,
bpmem.indmtx[i].col1.mc * fscale,
bpmem.indmtx[i].col2.me * fscale,
sumem.indmtx[i].col0.ma * fscale,
sumem.indmtx[i].col1.mc * fscale,
sumem.indmtx[i].col2.me * fscale,
fscale * 4.0f);
SetPSConstant4f(C_INDTEXMTX + 2 * i + 1,
bpmem.indmtx[i].col0.mb * fscale,
bpmem.indmtx[i].col1.md * fscale,
bpmem.indmtx[i].col2.mf * fscale,
sumem.indmtx[i].col0.mb * fscale,
sumem.indmtx[i].col1.md * fscale,
sumem.indmtx[i].col2.mf * fscale,
fscale * 4.0f);
PRIM_LOG("indmtx%d: scale=%f, mat=(%f %f %f; %f %f %f)\n", i,
1024.0f*fscale, bpmem.indmtx[i].col0.ma * fscale, bpmem.indmtx[i].col1.mc * fscale, bpmem.indmtx[i].col2.me * fscale,
bpmem.indmtx[i].col0.mb * fscale, bpmem.indmtx[i].col1.md * fscale, bpmem.indmtx[i].col2.mf * fscale, fscale);
1024.0f*fscale, sumem.indmtx[i].col0.ma * fscale, sumem.indmtx[i].col1.mc * fscale, sumem.indmtx[i].col2.me * fscale,
sumem.indmtx[i].col0.mb * fscale, sumem.indmtx[i].col1.md * fscale, sumem.indmtx[i].col2.mf * fscale, fscale);
}
}
s_nIndTexMtxChanged = 0;
@@ -191,15 +191,15 @@ void PixelShaderManager::SetConstants()
if (s_bFogColorChanged)
{
SetPSConstant4f(C_FOG, bpmem.fog.color.r / 255.0f, bpmem.fog.color.g / 255.0f, bpmem.fog.color.b / 255.0f, 0);
SetPSConstant4f(C_FOG, sumem.fog.color.r / 255.0f, sumem.fog.color.g / 255.0f, sumem.fog.color.b / 255.0f, 0);
s_bFogColorChanged = false;
}
if (s_bFogParamChanged)
{
float a = bpmem.fog.a.GetA() * ((float)(1 << bpmem.fog.b_shift));
float b = ((float)bpmem.fog.b_magnitude / 8388638) * ((float)(1 << (bpmem.fog.b_shift - 1)));
SetPSConstant4f(C_FOG + 1, a, b, bpmem.fog.c_proj_fsel.GetC(), 0);
float a = sumem.fog.a.GetA() * ((float)(1 << sumem.fog.b_shift));
float b = ((float)sumem.fog.b_magnitude / 8388638) * ((float)(1 << (sumem.fog.b_shift - 1)));
SetPSConstant4f(C_FOG + 1, a, b, sumem.fog.c_proj_fsel.GetC(), 0);
s_bFogParamChanged = false;
}
for (int i = 0; i < 8; i++)
@@ -214,7 +214,7 @@ void PixelShaderManager::SetPSTextureDims(int texid)
float fdims[4];
if (s_texturemask & (1 << texid))
{
TCoordInfo& tc = bpmem.texcoords[texid];
TCoordInfo& tc = sumem.texcoords[texid];
fdims[0] = (float)(lastTexDims[texid] & 0xffff);
fdims[1] = (float)((lastTexDims[texid] >> 16) & 0xfff);
fdims[2] = (float)(tc.s.scale_minus_1 + 1)*lastCustomTexScale[texid][0];
@@ -222,7 +222,7 @@ void PixelShaderManager::SetPSTextureDims(int texid)
}
else
{
TCoordInfo& tc = bpmem.texcoords[texid];
TCoordInfo& tc = sumem.texcoords[texid];
fdims[0] = 1.0f / (float)(lastTexDims[texid] & 0xffff);
fdims[1] = 1.0f / (float)((lastTexDims[texid] >> 16) & 0xfff);
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)
{
int r = bpmem.tevregs[num].low.a;
int a = bpmem.tevregs[num].low.b;
int b = bpmem.tevregs[num].high.a;
int g = bpmem.tevregs[num].high.b;
int r = sumem.tevregs[num].low.a;
int a = sumem.tevregs[num].low.b;
int b = sumem.tevregs[num].high.a;
int g = sumem.tevregs[num].high.b;
float *pf = &lastRGBAfull[type][num][0];
pf[0] = (float)r / 255.0f;
pf[1] = (float)g / 255.0f;
@@ -18,7 +18,7 @@
#ifndef _PIXELSHADERMANAGER_H
#define _PIXELSHADERMANAGER_H
#include "BPMemory.h"
#include "SUMemory.h"
#include "PixelShaderGen.h"
void SetPSConstant4f(int const_number, float f1, float f2, float f3, float f4);
+2 -2
View File
@@ -3,11 +3,11 @@
Import('env')
files = [
'BPMemory.cpp',
'SUMemory.cpp',
'CPMemory.cpp',
'XFMemory.cpp',
'XFStructs.cpp',
'BPStructs.cpp',
'SUStructs.cpp',
'memcpy_amd.cpp',
'LookUpTables.cpp',
'OpcodeDecoding.cpp',
+2 -2
View File
@@ -29,7 +29,7 @@
#include "Statistics.h"
#include "VertexLoaderManager.h"
#include "VertexLoader.h"
#include "BPMemory.h"
#include "SUMemory.h"
#include "DataReader.h"
#include "NativeVertexWriter.h"
@@ -539,7 +539,7 @@ void VertexLoader::RunVertices(int vtx_attr_group, int primitive, int count)
}
g_nativeVertexFmt = m_NativeFmt;
if (bpmem.genMode.cullmode == 3 && primitive < 5)
if (sumem.genMode.cullmode == 3 && primitive < 5)
{
// if cull mode is none, ignore triangles and quads
DataSkip(count * m_VertexSize);
@@ -20,7 +20,7 @@
#include "Profiler.h"
#include "NativeVertexFormat.h"
#include "BPMemory.h"
#include "SUMemory.h"
#include "VertexShaderGen.h"
// 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
vid.values[1] |= (((u32)bpmem.fog.c_proj_fsel.fsel & 3) << 30);
vid.values[2] |= (((u32)bpmem.fog.c_proj_fsel.fsel >> 2) << 30);
vid.values[1] |= (((u32)sumem.fog.c_proj_fsel.fsel & 3) << 30);
vid.values[2] |= (((u32)sumem.fog.c_proj_fsel.fsel >> 2) << 30);
u32* pcurvalue = &vid.values[3];
for (int i = 0; i < xfregs.numTexGens; ++i) {
@@ -81,8 +81,8 @@ const char *GenerateVertexShader(u32 components)
text[sizeof(text) - 1] = 0x7C; // canary
DVSTARTPROFILE();
_assert_( bpmem.genMode.numtexgens == xfregs.numTexGens);
_assert_( bpmem.genMode.numcolchans == xfregs.nNumChans);
_assert_( sumem.genMode.numtexgens == xfregs.numTexGens);
_assert_( sumem.genMode.numcolchans == xfregs.nNumChans);
u32 lightMask = 0;
if (xfregs.nNumChans > 0)
@@ -432,8 +432,8 @@ const char *GenerateVertexShader(u32 components)
WRITE(p, "o.tex3.w = o.pos.w;\n");
}
// if (bpmem.fog.c_proj_fsel.fsel != 0) {
// switch (bpmem.fog.c_proj_fsel.fsel) {
// if (sumem.fog.c_proj_fsel.fsel != 0) {
// switch (sumem.fog.c_proj_fsel.fsel) {
// case 1: // linear
// break;
// case 4: // exp
@@ -25,7 +25,7 @@
#include "VertexShaderGen.h"
#include "VertexShaderManager.h"
#include "BPMemory.h"
#include "SUMemory.h"
#include "CPMemory.h"
#include "XFMemory.h"
#include "VideoCommon.h"
+2 -2
View File
@@ -17,7 +17,7 @@
#include "VideoState.h"
#include "BPMemory.h"
#include "SUMemory.h"
#include "CPMemory.h"
#include "XFMemory.h"
#include "TextureDecoder.h"
@@ -26,7 +26,7 @@
static void DoState(PointerWrap &p)
{
// BP Memory
p.Do(bpmem);
p.Do(sumem);
// CP Memory
p.DoArray(arraybases, 16);
p.DoArray(arraystrides, 16);
+39 -35
View File
@@ -428,14 +428,6 @@
<Filter
Name="Sections"
>
<File
RelativePath=".\Src\BPMemory.cpp"
>
</File>
<File
RelativePath=".\Src\BPMemory.h"
>
</File>
<File
RelativePath=".\Src\CPMemory.cpp"
>
@@ -444,6 +436,26 @@
RelativePath=".\Src\CPMemory.h"
>
</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
RelativePath=".\Src\XFMemory.cpp"
>
@@ -609,18 +621,26 @@
>
</File>
</Filter>
<File
RelativePath=".\Src\BPFunctions.h"
<Filter
Name="Decoding"
>
</File>
<File
RelativePath=".\Src\BPStructs.cpp"
>
</File>
<File
RelativePath=".\Src\BPStructs.h"
>
</File>
<File
RelativePath=".\Src\OpcodeDecoding.cpp"
>
</File>
<File
RelativePath=".\Src\OpcodeDecoding.h"
>
</File>
<File
RelativePath=".\Src\TextureDecoder.cpp"
>
</File>
<File
RelativePath=".\Src\TextureDecoder.h"
>
</File>
</Filter>
<File
RelativePath=".\Src\DataReader.h"
>
@@ -657,26 +677,10 @@
RelativePath=".\Src\NativeVertexWriter.h"
>
</File>
<File
RelativePath=".\Src\OpcodeDecoding.cpp"
>
</File>
<File
RelativePath=".\Src\OpcodeDecoding.h"
>
</File>
<File
RelativePath=".\Src\SConscript"
>
</File>
<File
RelativePath=".\Src\TextureDecoder.cpp"
>
</File>
<File
RelativePath=".\Src\TextureDecoder.h"
>
</File>
<File
RelativePath=".\Src\VertexLoaderManager.cpp"
>
@@ -1180,7 +1180,7 @@
Name="Decoder"
>
<File
RelativePath=".\Src\BPFunctions.cpp"
RelativePath=".\Src\SUFunctions.cpp"
>
</File>
</Filter>
@@ -1,336 +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 "BPFunctions.h"
#include "D3DBase.h"
#include "Config.h"
#include "Common.h"
#include "TextureCache.h"
#include "VertexManager.h"
#include "VertexShaderManager.h"
#include "Utils.h"
bool textureChanged[8];
const bool renderFog = false;
using namespace D3D;
// State translation lookup tables
static const D3DBLEND d3dSrcFactors[8] =
{
D3DBLEND_ZERO,
D3DBLEND_ONE,
D3DBLEND_DESTCOLOR,
D3DBLEND_INVDESTCOLOR,
D3DBLEND_SRCALPHA,
D3DBLEND_INVSRCALPHA,
D3DBLEND_DESTALPHA,
D3DBLEND_INVDESTALPHA
};
static const D3DBLEND d3dDestFactors[8] =
{
D3DBLEND_ZERO,
D3DBLEND_ONE,
D3DBLEND_SRCCOLOR,
D3DBLEND_INVSRCCOLOR,
D3DBLEND_SRCALPHA,
D3DBLEND_INVSRCALPHA,
D3DBLEND_DESTALPHA,
D3DBLEND_INVDESTALPHA
};
static const D3DCULL d3dCullModes[4] =
{
D3DCULL_NONE,
D3DCULL_CCW,
D3DCULL_CW,
D3DCULL_CCW
};
static const D3DCMPFUNC d3dCmpFuncs[8] =
{
D3DCMP_NEVER,
D3DCMP_LESS,
D3DCMP_EQUAL,
D3DCMP_LESSEQUAL,
D3DCMP_GREATER,
D3DCMP_NOTEQUAL,
D3DCMP_GREATEREQUAL,
D3DCMP_ALWAYS
};
static const D3DTEXTUREFILTERTYPE d3dMipFilters[4] =
{
D3DTEXF_NONE,
D3DTEXF_POINT,
D3DTEXF_ANISOTROPIC,
D3DTEXF_LINEAR, //reserved
};
static const D3DTEXTUREADDRESS d3dClamps[4] =
{
D3DTADDRESS_CLAMP,
D3DTADDRESS_WRAP,
D3DTADDRESS_MIRROR,
D3DTADDRESS_WRAP //reserved
};
namespace BPFunctions
{
void FlushPipeline()
{
VertexManager::Flush();
}
void SetGenerationMode(const Bypass &bp)
{
// dev->SetRenderState(D3DRS_CULLMODE, d3dCullModes[bpmem.genMode.cullmode]);
Renderer::SetRenderState(D3DRS_CULLMODE, d3dCullModes[bpmem.genMode.cullmode]);
if (bpmem.genMode.cullmode == 3)
{
// dev->SetRenderState(D3DRS_COLORWRITEENABLE, 0);
Renderer::SetRenderState(D3DRS_COLORWRITEENABLE, 0);
}
else
{
DWORD write = 0;
if (bpmem.blendmode.alphaupdate)
write = D3DCOLORWRITEENABLE_ALPHA;
if (bpmem.blendmode.colorupdate)
write |= D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE;
// dev->SetRenderState(D3DRS_COLORWRITEENABLE, write);
Renderer::SetRenderState(D3DRS_COLORWRITEENABLE, write);
}
}
void SetScissor(const Bypass &bp)
{
Renderer::SetScissorRect();
}
void SetLineWidth(const Bypass &bp)
{
// We can't change line width in D3D unless we use ID3DXLine
float psize = float(bpmem.lineptwidth.pointsize) * 6.0f;
Renderer::SetRenderState(D3DRS_POINTSIZE, *((DWORD*)&psize));
}
void SetDepthMode(const Bypass &bp)
{
if (bpmem.zmode.testenable)
{
// dev->SetRenderState(D3DRS_ZENABLE, TRUE);
// dev->SetRenderState(D3DRS_ZWRITEENABLE, bpmem.zmode.updateenable);
// dev->SetRenderState(D3DRS_ZFUNC,d3dCmpFuncs[bpmem.zmode.func]);
Renderer::SetRenderState(D3DRS_ZENABLE, TRUE);
Renderer::SetRenderState(D3DRS_ZWRITEENABLE, bpmem.zmode.updateenable);
Renderer::SetRenderState(D3DRS_ZFUNC, d3dCmpFuncs[bpmem.zmode.func]);
}
else
{
// if the test is disabled write is disabled too
// dev->SetRenderState(D3DRS_ZENABLE, FALSE);
// dev->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
Renderer::SetRenderState(D3DRS_ZENABLE, FALSE);
Renderer::SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
}
//if (!bpmem.zmode.updateenable)
// Renderer::SetRenderMode(Renderer::RM_Normal);
}
void SetBlendMode(const Bypass &bp)
{
if (bp.changes & 1)
Renderer::SetRenderState(D3DRS_ALPHABLENDENABLE, bpmem.blendmode.blendenable);
D3DBLEND src = d3dSrcFactors[bpmem.blendmode.srcfactor];
D3DBLEND dst = d3dDestFactors[bpmem.blendmode.dstfactor];
if (bp.changes & 0x700)
Renderer::SetRenderState(D3DRS_SRCBLEND, src);
if (bp.changes & 0xE0) {
if (!bpmem.blendmode.subtract)
{
Renderer::SetRenderState(D3DRS_DESTBLEND, dst);
}
else
{
Renderer::SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
}
}
if (bp.changes & 0x800)
{
if (bpmem.blendmode.subtract)
{
Renderer::SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
Renderer::SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
}
else
{
Renderer::SetRenderState(D3DRS_SRCBLEND, src);
Renderer::SetRenderState(D3DRS_DESTBLEND, dst);
}
Renderer::SetRenderState(D3DRS_BLENDOP, bpmem.blendmode.subtract ? D3DBLENDOP_SUBTRACT : D3DBLENDOP_ADD);
}
}
void SetDitherMode(const Bypass &bp)
{
Renderer::SetRenderState(D3DRS_DITHERENABLE,bpmem.blendmode.dither);
}
void SetLogicOpMode(const Bypass &bp)
{
// Logic op blending. D3D can't do this but can fake some modes.
}
void SetColorMask(const Bypass &bp)
{
DWORD write = 0;
if (bpmem.blendmode.alphaupdate)
write = D3DCOLORWRITEENABLE_ALPHA;
if (bpmem.blendmode.colorupdate)
write |= D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE;
Renderer::SetRenderState(D3DRS_COLORWRITEENABLE, write);
}
float GetRendererTargetScaleX()
{
return Renderer::GetXScale();
}
float GetRendererTargetScaleY()
{
return Renderer::GetYScale();
}
void CopyEFB(const Bypass &bp, const TRectangle &rc, const u32 &address, const bool &fromZBuffer, const bool &isIntensityFmt, const u32 &copyfmt, const bool &scaleByHalf)
{
RECT rec = { rc.left, rc.top, rc.right, rc.bottom };
TextureCache::CopyEFBToRenderTarget(bpmem.copyTexDest<<5, &rec);
}
void RenderToXFB(const Bypass &bp, const TRectangle &multirc, const float &yScale, const float &xfbLines, u8* pXFB, const u32 &dstWidth, const u32 &dstHeight)
{
Renderer::SwapBuffers();
PRIM_LOG("Renderer::SwapBuffers()");
g_VideoInitialize.pCopiedToXFB();
}
void ClearScreen(const Bypass &bp, const TRectangle &multirc)
{
// 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
VertexShaderManager::SetViewportChanged();
// Since clear operations use the source rectangle, we have to do
// regular renders
DWORD clearflags = 0;
D3DCOLOR col = 0;
float clearZ = 0;
if (bpmem.blendmode.colorupdate || bpmem.blendmode.alphaupdate)
{
if (bpmem.blendmode.colorupdate || bpmem.blendmode.alphaupdate)
col = (bpmem.clearcolorAR << 16) | bpmem.clearcolorGB;
// clearflags |= D3DCLEAR_TARGET; set to break animal crossing :p
}
// clear z-buffer
if (bpmem.zmode.updateenable)
{
clearZ = (float)(bpmem.clearZValue & 0xFFFFFF) / float(0xFFFFFF);
if (clearZ > 1.0f) clearZ = 1.0f;
if (clearZ < 0.0f) clearZ = 0.0f;
clearflags |= D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL;
}
D3D::dev->Clear(0, NULL, clearflags, col, clearZ, 0);
}
void RestoreRenderState(const Bypass &bp)
{
//Renderer::SetRenderMode(Renderer::RM_Normal);
}
bool GetConfig(const int &type)
{
switch (type)
{
case CONFIG_ISWII:
return g_VideoInitialize.bWii;
case CONFIG_DISABLEFOG:
return false;
case CONFIG_SHOWEFBREGIONS:
return false;
default:
PanicAlert("GetConfig Error: Unknown Config Type!");
return false;
}
}
u8 *GetPointer(const u32 &address)
{
return g_VideoInitialize.pGetMemoryPointer(address);
}
void SetSamplerState(const Bypass &bp)
{
FourTexUnits &tex = bpmem.tex[(bp.address & 0xE0) == 0xA0];
int stage = (bp.address & 3);//(addr>>4)&2;
TexMode0 &tm0 = tex.texMode0[stage];
D3DTEXTUREFILTERTYPE min, mag, mip;
if (g_Config.bForceFiltering)
{
min = mag = mip = D3DTEXF_LINEAR;
}
else
{
min = (tm0.min_filter & 4) ? D3DTEXF_LINEAR : D3DTEXF_POINT;
mag = tm0.mag_filter ? D3DTEXF_LINEAR : D3DTEXF_POINT;
mip = d3dMipFilters[tm0.min_filter & 3];
}
if ((bp.address & 0xE0) == 0xA0)
stage += 4;
if (g_Config.bForceMaxAniso)
{
mag = D3DTEXF_ANISOTROPIC;
mip = D3DTEXF_ANISOTROPIC;
min = D3DTEXF_ANISOTROPIC;
}
dev->SetSamplerState(stage, D3DSAMP_MINFILTER, min);
dev->SetSamplerState(stage, D3DSAMP_MAGFILTER, mag);
dev->SetSamplerState(stage, D3DSAMP_MIPFILTER, mip);
dev->SetSamplerState(stage, D3DSAMP_MAXANISOTROPY, 16);
dev->SetSamplerState(stage, D3DSAMP_ADDRESSU, d3dClamps[tm0.wrap_s]);
dev->SetSamplerState(stage, D3DSAMP_ADDRESSV, d3dClamps[tm0.wrap_t]);
//wip
//dev->SetSamplerState(stage,D3DSAMP_MIPMAPLODBIAS,tm0.lod_bias/4.0f);
//char temp[256];
//sprintf(temp,"lod %f",tm0.lod_bias/4.0f);
//g_VideoInitialize.pLog(temp);
}
void SetInterlacingMode(const Bypass &bp)
{
// TODO
}
};
@@ -25,7 +25,7 @@
#include "PixelShaderManager.h"
#include "PixelShaderCache.h"
#include "VertexLoader.h"
#include "BPMemory.h"
#include "SUMemory.h"
#include "XFMemory.h"
#include <Cg/cg.h>
+10 -10
View File
@@ -26,7 +26,7 @@
#include "VertexManager.h"
#include "Render.h"
#include "OpcodeDecoding.h"
#include "BPStructs.h"
#include "SUStructs.h"
#include "XFStructs.h"
#include "D3DPostprocess.h"
#include "D3DUtil.h"
@@ -386,7 +386,7 @@ void Renderer::SwapBuffers()
D3D::dev->SetRenderState(D3DRS_SCISSORTESTENABLE, false);
D3D::dev->Clear(0, 0, D3DCLEAR_TARGET, 0x101010, 0, 0);
u32 clearColor = (bpmem.clearcolorAR << 16) | bpmem.clearcolorGB;
u32 clearColor = (sumem.clearcolorAR << 16) | sumem.clearcolorGB;
// clearColor |= 0x003F003F;
// D3D::BeginFrame(true,clearColor,1.0f);
D3D::BeginFrame(false, clearColor, 1.0f);
@@ -441,13 +441,13 @@ void Renderer::SetViewport(float* _Viewport)
void Renderer::SetScissorRect()
{
int xoff = bpmem.scissorOffset.x * 2 - 342;
int yoff = bpmem.scissorOffset.y * 2 - 342;
int xoff = sumem.scissorOffset.x * 2 - 342;
int yoff = sumem.scissorOffset.y * 2 - 342;
RECT rc;
rc.left = (int)((float)bpmem.scissorTL.x - xoff - 342);
rc.top = (int)((float)bpmem.scissorTL.y - yoff - 342);
rc.right = (int)((float)bpmem.scissorBR.x - xoff - 341);
rc.bottom = (int)((float)bpmem.scissorBR.y - yoff - 341);
rc.left = (int)((float)sumem.scissorTL.x - xoff - 342);
rc.top = (int)((float)sumem.scissorTL.y - yoff - 342);
rc.right = (int)((float)sumem.scissorBR.x - xoff - 341);
rc.bottom = (int)((float)sumem.scissorBR.y - yoff - 341);
rc.left = (int)(rc.left * xScale);
rc.top = (int)(rc.top * yScale);
@@ -588,8 +588,8 @@ void UpdateViewport()
// Keep aspect ratio at 4:3
// rawViewport[0] = 320, rawViewport[1] = -240
int scissorXOff = bpmem.scissorOffset.x * 2 - 342;
int scissorYOff = bpmem.scissorOffset.y * 2 - 342;
int scissorXOff = sumem.scissorOffset.x * 2 - 342;
int scissorYOff = sumem.scissorOffset.y * 2 - 342;
float fourThree = 4.0f / 3.0f;
// These were commented out to fix "unreferenced local variable" compiler warnings.
// float wAdj, hAdj;
@@ -213,7 +213,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
entry.w = width;
entry.h = height;
entry.fmt = format;
entry.mode = bpmem.tex[stage > 3].texMode0[stage & 3];
entry.mode = sumem.tex[stage > 3].texMode0[stage & 3];
if (g_Config.bDumpTextures)
{ // dump texture to file

Some files were not shown because too many files have changed in this diff Show More