cleanup + some eolz

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5842 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
luisr142004 2010-07-06 13:14:51 +00:00
parent 5133793c6c
commit e9e12ff100
19 changed files with 1117 additions and 1141 deletions

View File

@ -702,10 +702,10 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
switch ( group->type )
{
case GROUP_TYPE_STICK :
case GROUP_TYPE_TILT :
case GROUP_TYPE_CURSOR :
case GROUP_TYPE_FORCE :
case GROUP_TYPE_STICK:
case GROUP_TYPE_TILT:
case GROUP_TYPE_CURSOR:
case GROUP_TYPE_FORCE:
{
wxBitmap bitmap(64, 64);
dc.SelectObject(bitmap);
@ -733,7 +733,7 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
Add( h_szr, 0, wxEXPAND|wxLEFT|wxCENTER|wxTOP, 3 );
}
break;
case GROUP_TYPE_BUTTONS :
case GROUP_TYPE_BUTTONS:
{
wxBitmap bitmap(int(12*group->controls.size()+1), 12);
dc.SelectObject(bitmap);
@ -755,8 +755,8 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
Add(static_bitmap, 0, wxALL|wxCENTER, 3);
}
break;
case GROUP_TYPE_MIXED_TRIGGERS :
case GROUP_TYPE_TRIGGERS :
case GROUP_TYPE_MIXED_TRIGGERS:
case GROUP_TYPE_TRIGGERS:
{
int height = (int)(6 * group->controls.size());
int width = 64+12+1;
@ -787,7 +787,7 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
Add( static_bitmap, 0, wxALL|wxCENTER, 3 );
}
break;
case GROUP_TYPE_EXTENSION :
case GROUP_TYPE_EXTENSION:
{
PadSettingExtension* const attachments = new PadSettingExtension( parent, (ControllerEmu::Extension*)group );
wxButton* const configure_btn = new ExtensionButton( parent, (ControllerEmu::Extension*)group );
@ -808,7 +808,7 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
Add(btn, 0, wxALL|wxEXPAND, 3);
}
break;
default :
default:
{
//options

View File

@ -357,8 +357,8 @@ void BPWritten(const BPCmd& bp)
// Bounding Box Control
// -------------------------
case BPMEM_CLEARBBOX1:
case BPMEM_CLEARBBOX2: {
case BPMEM_CLEARBBOX2:
{
#ifdef BBOX_SUPPORT
// which is which? these are GUESSES!
if (bp.address == BPMEM_CLEARBBOX1) {
@ -381,8 +381,8 @@ void BPWritten(const BPCmd& bp)
// WARN_LOG(VIDEO, "ClearBBox TB: %i, %08x - %i, %i", bp.address, bp.newvalue, top, bottom);
}
#endif
break;
}
break;
case BPMEM_TEXINVALIDATE: // Used, if game has manual control the Texture Cache, which we don't allow
DEBUG_LOG(VIDEO, "BP Texture Invalid: %08x", bp.newvalue);
case BPMEM_ZCOMPARE: // Set the Z-Compare and EFB pixel format

View File

@ -83,7 +83,8 @@ sDecoderParameter g_DecodeParametersRGBA[] = {
bool g_Inited = false;
cl_mem g_clsrc, g_cldst; // texture buffer memory objects
void TexDecoder_OpenCL_Initialize() {
void TexDecoder_OpenCL_Initialize()
{
#if defined(HAVE_OPENCL) && HAVE_OPENCL
if(!g_Inited)
{
@ -124,7 +125,8 @@ void TexDecoder_OpenCL_Initialize() {
#endif
}
void TexDecoder_OpenCL_Shutdown() {
void TexDecoder_OpenCL_Shutdown()
{
#if defined(HAVE_OPENCL) && HAVE_OPENCL && !defined(DEBUG_OPENCL)
clReleaseProgram(g_program);

View File

@ -96,7 +96,7 @@ void GetPixelShaderId(PIXELSHADERUID *uid, u32 texturemask, u32 dstAlphaEnable)
case 0: pcurvalue[0] = val0|(val1<<10); break;
case 1: pcurvalue[0] |= val0<<20; pcurvalue[1] = val1; pcurvalue++; break;
case 2: pcurvalue[1] |= (val0<<10)|(val1<<20); pcurvalue++; break;
default: PanicAlert("Uknown case for Tev Stages / 2: %08x", (i % 3));
default: PanicAlert("Unknown case for Tev Stages / 2: %08x", (i % 3));
}
}
@ -112,7 +112,7 @@ void GetPixelShaderId(PIXELSHADERUID *uid, u32 texturemask, u32 dstAlphaEnable)
case 0: pcurvalue[0] = val0; break;
case 1: pcurvalue[0] |= val0 << 20; break;
case 2: pcurvalue[1] |= val0 << 10; pcurvalue++; break;
default: PanicAlert("Uknown case for Tev Stages: %08x", bpmem.genMode.numtevstages % 3);
default: PanicAlert("Unknown case for Tev Stages: %08x", bpmem.genMode.numtevstages % 3);
}
}
@ -129,7 +129,7 @@ void GetPixelShaderId(PIXELSHADERUID *uid, u32 texturemask, u32 dstAlphaEnable)
case 0: pcurvalue[0] = val; break;
case 1: pcurvalue[0] |= val << 21; pcurvalue[1] = val >> 11; ++pcurvalue; break;
case 2: pcurvalue[0] |= val << 10; ++pcurvalue; break;
default: PanicAlert("Uknown case for Ind Stages: %08x", (i % 3));
default: PanicAlert("Unknown case for Ind Stages: %08x", (i % 3));
}
}
@ -259,10 +259,10 @@ static const char *tevCInputTable[] = // CC
"(textemp.aaa)", // TEXA,
"(rastemp.rgb)", // RASC,
"(rastemp.aaa)", // RASA,
"float3(1.0f,1.0f,1.0f)", // ONE
"float3(0.5f,0.5f,0.5f)", // HALF
"float3(1.0f, 1.0f, 1.0f)", // ONE
"float3(0.5f, 0.5f, 0.5f)", // HALF
"(konsttemp.rgb)", //"konsttemp.rgb", // KONST
"float3(0.0f,0.0f,0.0f)", // ZERO
"float3(0.0f, 0.0f, 0.0f)", // ZERO
///aded extra values to map clamped values
"(cprev.rgb)", // CPREV,
"(cprev.aaa)", // APREV,
@ -276,11 +276,11 @@ static const char *tevCInputTable[] = // CC
"(textemp.aaa)", // TEXA,
"(rastemp.rgb)", // RASC,
"(rastemp.aaa)", // RASA,
"float3(1.0f,1.0f,1.0f)", // ONE
"float3(0.5f,0.5f,0.5f)", // HALF
"float3(1.0f, 1.0f, 1.0f)", // ONE
"float3(0.5f, 0.5f, 0.5f)", // HALF
"(konsttemp.rgb)", //"konsttemp.rgb", // KONST
"float3(0.0f,0.0f,0.0f)", // ZERO
"PADERROR", "PADERROR", "PADERROR", "PADERROR",
"float3(0.0f, 0.0f, 0.0f)", // ZERO
"PADERROR", "PADERROR", "PADERROR", "PADERROR"
};
static const char *tevAInputTable[] = // CA
@ -292,7 +292,7 @@ static const char *tevAInputTable[] = // CA
"textemp", // TEXA,
"rastemp", // RASA,
"konsttemp", // KONST, (hw1 had quarter)
"float4(0.0f,0.0f,0.0f,0.0f)", // ZERO
"float4(0.0f, 0.0f, 0.0f, 0.0f)", // ZERO
///aded extra values to map clamped values
"cprev", // APREV,
"cc0", // A0,
@ -301,7 +301,7 @@ static const char *tevAInputTable[] = // CA
"textemp", // TEXA,
"rastemp", // RASA,
"konsttemp", // KONST, (hw1 had quarter)
"float4(0.0f,0.0f,0.0f,0.0f)", // ZERO
"float4(0.0f, 0.0f, 0.0f, 0.0f)", // ZERO
"PADERROR", "PADERROR", "PADERROR", "PADERROR",
"PADERROR", "PADERROR", "PADERROR", "PADERROR",
};
@ -315,7 +315,7 @@ static const char *tevRasTable[] =
"ERROR", //4
"alphabump", // use bump alpha
"(alphabump*(255.0f/248.0f))", //normalized
"float4(0.0f,0.0f,0.0f,0.0f)", // zero
"float4(0.0f, 0.0f, 0.0f, 0.0f)", // zero
};
static const char *alphaRef[2] =
@ -329,8 +329,8 @@ static const char *alphaRef[2] =
static const char *tevCOutputTable[] = { "prev.rgb", "c0.rgb", "c1.rgb", "c2.rgb" };
static const char *tevAOutputTable[] = { "prev.a", "c0.a", "c1.a", "c2.a" };
static const char *tevIndAlphaSel[] = {"", "x", "y", "z"};
//static const char *tevIndAlphaScale[] = {"", "*32","*16","*8"};
static const char *tevIndAlphaScale[] = {"*(248.0f/255.0f)", "*(224.0f/255.0f)","*(240.0f/255.0f)","*(248.0f/255.0f)"};
//static const char *tevIndAlphaScale[] = {"", "*32", "*16", "*8"};
static const char *tevIndAlphaScale[] = {"*(248.0f/255.0f)", "*(224.0f/255.0f)", "*(240.0f/255.0f)", "*(248.0f/255.0f)"};
static const char *tevIndBiasField[] = {"", "x", "y", "xy", "z", "xz", "yz", "xyz"}; // indexed by bias
static const char *tevIndBiasAdd[] = {"-128.0f", "1.0f", "1.0f", "1.0f" }; // indexed by fmt
static const char *tevIndWrapStart[] = {"0.0f", "256.0f", "128.0f", "64.0f", "32.0f", "16.0f", "0.001f" };
@ -420,7 +420,7 @@ const char *GeneratePixelShaderCode(u32 texture_mask, bool dstAlphaEnable, API_
for (int i = 0; i < 8; ++i)
{
if (!(texture_mask & (1<<i))) {
WRITE(p, "%s samp%d : register(s%d)", bfirst?"":",",i, i);
WRITE(p, "%s samp%d : register(s%d)", bfirst?"":",", i, i);
bfirst = false;
}
}
@ -454,18 +454,9 @@ const char *GeneratePixelShaderCode(u32 texture_mask, bool dstAlphaEnable, API_
WRITE(p, "void main(\n");
if(ApiType != API_D3D11)
WRITE(p, " out float4 ocol0 : COLOR0,\n");
WRITE(p, " out float4 ocol0 : COLOR0,\n out float depth : DEPTH,\n in float4 rawpos : POSITION,\n");
else
WRITE(p, " out float4 ocol0 : SV_Target,\n");
if(ApiType != API_D3D11)
WRITE(p, " out float depth : DEPTH,\n");
else
WRITE(p, " out float depth : SV_Depth,\n");
if(ApiType != API_D3D11)
WRITE(p, " in float4 rawpos : POSITION,\n");
else
WRITE(p, " in float4 rawpos : SV_Position,\n");
WRITE(p, " out float4 ocol0 : SV_Target,\n out float depth : SV_Depth,\n in float4 rawpos : SV_Position,\n");
WRITE(p, " in float4 colors_0 : COLOR0,\n");
WRITE(p, " in float4 colors_1 : COLOR1\n");
@ -488,17 +479,17 @@ const char *GeneratePixelShaderCode(u32 texture_mask, bool dstAlphaEnable, API_
char* pmainstart = p;
WRITE(p, " float4 c0="I_COLORS"[1],c1="I_COLORS"[2],c2="I_COLORS"[3],prev=float4(0.0f,0.0f,0.0f,0.0f),textemp=float4(0.0f,0.0f,0.0f,0.0f),rastemp=float4(0.0f,0.0f,0.0f,0.0f),konsttemp=float4(0.0f,0.0f,0.0f,0.0f);\n"
" float3 comp16 = float3(1.0f,255.0f,0.0f), comp24 = float3(1.0f,255.0f,255.0f*255.0f);\n"
WRITE(p, " float4 c0 = "I_COLORS"[1], c1 = "I_COLORS"[2], c2 = "I_COLORS"[3], prev = float4(0.0f, 0.0f, 0.0f, 0.0f), textemp = float4(0.0f, 0.0f, 0.0f, 0.0f), rastemp = float4(0.0f, 0.0f, 0.0f, 0.0f), konsttemp = float4(0.0f, 0.0f, 0.0f, 0.0f);\n"
" float3 comp16 = float3(1.0f, 255.0f, 0.0f), comp24 = float3(1.0f, 255.0f, 255.0f*255.0f);\n"
" float4 alphabump=0;\n"
" float3 tevcoord;\n"
" float2 wrappedcoord, tempcoord;\n"
" float4 cc0,cc1,cc2,cprev;\n\n");
" float4 cc0, cc1, cc2, cprev;\n\n");
// HACK to handle cases where the tex gen is not enabled
if (numTexgen == 0)
{
WRITE(p, "float3 uv0 = float3(0.0f,0.0f,0.0f);\n");
WRITE(p, "float3 uv0 = float3(0.0f, 0.0f, 0.0f);\n");
}
else
{
@ -521,20 +512,20 @@ const char *GeneratePixelShaderCode(u32 texture_mask, bool dstAlphaEnable, API_
int texcoord = bpmem.tevindref.getTexCoord(i);
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");
else
WRITE(p, "tempcoord=float2(0.0f,0.0f);\n");
WRITE(p, "tempcoord = float2(0.0f, 0.0f);\n");
char buffer[32];
sprintf(buffer, "float3 indtex%d", i);
SampleTexture(p, buffer, "tempcoord", "abg", bpmem.tevindref.getTexMap(i), texture_mask,ApiType);
SampleTexture(p, buffer, "tempcoord", "abg", bpmem.tevindref.getTexMap(i), texture_mask, ApiType);
}
}
RegisterStates[0].AlphaNeedOverflowControl = false;
RegisterStates[0].ColorNeedOverflowControl = false;
RegisterStates[0].AuxStored = false;
for(int i = 1 ; i < 4 ; i++)
for(int i = 1; i < 4; i++)
{
RegisterStates[i].AlphaNeedOverflowControl = true;
RegisterStates[i].ColorNeedOverflowControl = true;
@ -542,7 +533,7 @@ const char *GeneratePixelShaderCode(u32 texture_mask, bool dstAlphaEnable, API_
}
for (int i = 0; i < numStages; i++)
WriteStage(p, i, texture_mask,ApiType); //build the equation for this stage
WriteStage(p, i, texture_mask, ApiType); //build the equation for this stage
if(numStages)
{
@ -551,13 +542,13 @@ const char *GeneratePixelShaderCode(u32 texture_mask, bool dstAlphaEnable, API_
if(bpmem.combiners[numStages - 1].colorC.dest != 0)
{
bool retrieveFromAuxRegister = !RegisterStates[bpmem.combiners[numStages - 1].colorC.dest].ColorNeedOverflowControl && RegisterStates[bpmem.combiners[numStages - 1].colorC.dest].AuxStored;
WRITE(p, "prev.rgb = %s%s;\n", retrieveFromAuxRegister ? "c" : "" ,tevCOutputTable[bpmem.combiners[numStages - 1].colorC.dest]);
WRITE(p, "prev.rgb = %s%s;\n", retrieveFromAuxRegister ? "c" : "" , tevCOutputTable[bpmem.combiners[numStages - 1].colorC.dest]);
RegisterStates[0].ColorNeedOverflowControl = RegisterStates[bpmem.combiners[numStages - 1].colorC.dest].ColorNeedOverflowControl;
}
if(bpmem.combiners[numStages - 1].alphaC.dest != 0)
{
bool retrieveFromAuxRegister = !RegisterStates[bpmem.combiners[numStages - 1].alphaC.dest].AlphaNeedOverflowControl && RegisterStates[bpmem.combiners[numStages - 1].alphaC.dest].AuxStored;
WRITE(p, "prev.a = %s%s;\n", retrieveFromAuxRegister ? "c" : "" ,tevAOutputTable[bpmem.combiners[numStages - 1].alphaC.dest]);
WRITE(p, "prev.a = %s%s;\n", retrieveFromAuxRegister ? "c" : "" , tevAOutputTable[bpmem.combiners[numStages - 1].alphaC.dest]);
RegisterStates[0].AlphaNeedOverflowControl = RegisterStates[bpmem.combiners[numStages - 1].alphaC.dest].AlphaNeedOverflowControl;
}
}
@ -596,11 +587,10 @@ const char *GeneratePixelShaderCode(u32 texture_mask, bool dstAlphaEnable, API_
WRITE(p, "zCoord = frac(zCoord);\n");
WRITE(p, "zCoord = zCoord * (16777216.0f/16777215.0f);\n");
}
WRITE(p, "depth = zCoord;\n");
if (dstAlphaEnable)
WRITE(p, " ocol0 = float4(prev.rgb,"I_ALPHA"[0].a);\n");
WRITE(p, " ocol0 = float4(prev.rgb, "I_ALPHA"[0].a);\n");
else
{
WriteFog(p);
@ -608,8 +598,6 @@ const char *GeneratePixelShaderCode(u32 texture_mask, bool dstAlphaEnable, API_
}
}
WRITE(p, "}\n");
if (text[sizeof(text) - 1] != 0x7C)
PanicAlert("PixelShader generator - buffer too small, canary has been eaten!");
@ -622,22 +610,22 @@ const char *GeneratePixelShaderCode(u32 texture_mask, bool dstAlphaEnable, API_
//table with the color compare operations
static const char *TEVCMPColorOPTable[16] =
{
"float3(0.0f,0.0f,0.0f)",//0
"float3(0.0f,0.0f,0.0f)",//1
"float3(0.0f,0.0f,0.0f)",//2
"float3(0.0f,0.0f,0.0f)",//3
"float3(0.0f,0.0f,0.0f)",//4
"float3(0.0f,0.0f,0.0f)",//5
"float3(0.0f,0.0f,0.0f)",//6
"float3(0.0f,0.0f,0.0f)",//7
" %s + ((%s.r >= %s.r + (0.25f/255.0f)) ? %s : float3(0.0f,0.0f,0.0f))",//#define TEVCMP_R8_GT 8
" %s + ((abs(%s.r - %s.r) < (0.5f/255.0f)) ? %s : float3(0.0f,0.0f,0.0f))",//#define TEVCMP_R8_EQ 9
" %s + (( dot(%s.rgb, comp16) >= (dot(%s.rgb, comp16) + (0.25f/255.0f))) ? %s : float3(0.0f,0.0f,0.0f))",//#define TEVCMP_GR16_GT 10
" %s + (abs(dot(%s.rgb, comp16) - dot(%s.rgb, comp16)) < (0.5f/255.0f) ? %s : float3(0.0f,0.0f,0.0f))",//#define TEVCMP_GR16_EQ 11
" %s + (( dot(%s.rgb, comp24) >= (dot(%s.rgb, comp24) + (0.25f/255.0f))) ? %s : float3(0.0f,0.0f,0.0f))",//#define TEVCMP_BGR24_GT 12
" %s + (abs(dot(%s.rgb, comp24) - dot(%s.rgb, comp24)) < (0.5f/255.0f) ? %s : float3(0.0f,0.0f,0.0f))",//#define TEVCMP_BGR24_EQ 13
" %s + (max(sign(%s.rgb - %s.rgb - (0.25f/255.0f)),float3(0.0f,0.0f,0.0f)) * %s)",//#define TEVCMP_RGB8_GT 14
" %s + ((float3(1.0f,1.0f,1.0f) - max(sign(abs(%s.rgb - %s.rgb) - (0.5f/255.0f)),float3(0.0f,0.0f,0.0f))) * %s)"//#define TEVCMP_RGB8_EQ 15
"float3(0.0f, 0.0f, 0.0f)",//0
"float3(0.0f, 0.0f, 0.0f)",//1
"float3(0.0f, 0.0f, 0.0f)",//2
"float3(0.0f, 0.0f, 0.0f)",//3
"float3(0.0f, 0.0f, 0.0f)",//4
"float3(0.0f, 0.0f, 0.0f)",//5
"float3(0.0f, 0.0f, 0.0f)",//6
"float3(0.0f, 0.0f, 0.0f)",//7
" %s + ((%s.r >= %s.r + (0.25f/255.0f)) ? %s : float3(0.0f, 0.0f, 0.0f))",//#define TEVCMP_R8_GT 8
" %s + ((abs(%s.r - %s.r) < (0.5f/255.0f)) ? %s : float3(0.0f, 0.0f, 0.0f))",//#define TEVCMP_R8_EQ 9
" %s + (( dot(%s.rgb, comp16) >= (dot(%s.rgb, comp16) + (0.25f/255.0f))) ? %s : float3(0.0f, 0.0f, 0.0f))",//#define TEVCMP_GR16_GT 10
" %s + (abs(dot(%s.rgb, comp16) - dot(%s.rgb, comp16)) < (0.5f/255.0f) ? %s : float3(0.0f, 0.0f, 0.0f))",//#define TEVCMP_GR16_EQ 11
" %s + (( dot(%s.rgb, comp24) >= (dot(%s.rgb, comp24) + (0.25f/255.0f))) ? %s : float3(0.0f, 0.0f, 0.0f))",//#define TEVCMP_BGR24_GT 12
" %s + (abs(dot(%s.rgb, comp24) - dot(%s.rgb, comp24)) < (0.5f/255.0f) ? %s : float3(0.0f, 0.0f, 0.0f))",//#define TEVCMP_BGR24_EQ 13
" %s + (max(sign(%s.rgb - %s.rgb - (0.25f/255.0f)), float3(0.0f, 0.0f, 0.0f)) * %s)",//#define TEVCMP_RGB8_GT 14
" %s + ((float3(1.0f, 1.0f, 1.0f) - max(sign(abs(%s.rgb - %s.rgb) - (0.5f/255.0f)), float3(0.0f, 0.0f, 0.0f))) * %s)"//#define TEVCMP_RGB8_EQ 15
};
//table with the alpha compare operations
@ -745,7 +733,7 @@ static void WriteStage(char *&p, int n, u32 texture_mask, API_TYPE ApiType)
WRITE(p, "tevcoord.xy = wrappedcoord + indtevtrans%d;\n", n);
}
WRITE(p, "rastemp=%s.%s;\n", tevRasTable[bpmem.tevorders[n / 2].getColorChan(n & 1)],rasswap);
WRITE(p, "rastemp = %s.%s;\n", tevRasTable[bpmem.tevorders[n / 2].getColorChan(n & 1)], rasswap);
if (bpmem.tevorders[n/2].getEnable(n&1))
{
@ -756,13 +744,13 @@ static void WriteStage(char *&p, int n, u32 texture_mask, API_TYPE ApiType)
if(bHasTexCoord)
WRITE(p, "tevcoord.xy = uv%d.xy;\n", texcoord);
else
WRITE(p, "tevcoord.xy = float2(0.0f,0.0f);\n");
WRITE(p, "tevcoord.xy = float2(0.0f, 0.0f);\n");
}
SampleTexture(p, "textemp", "tevcoord", texswap, texmap, texture_mask, ApiType);
}
else
WRITE(p, "textemp=float4(1.0f,1.0f,1.0f,1.0f);\n");
WRITE(p, "textemp = float4(1.0f, 1.0f, 1.0f, 1.0f);\n");
int kc = bpmem.tevksel[n / 2].getKC(n & 1);
int ka = bpmem.tevksel[n / 2].getKA(n & 1);
@ -773,7 +761,7 @@ static void WriteStage(char *&p, int n, u32 texture_mask, API_TYPE ApiType)
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;
if (bCKonst || bAKonst )
WRITE(p, "konsttemp=float4(%s,%s);\n",tevKSelTableC[kc],tevKSelTableA[ka]);
WRITE(p, "konsttemp = float4(%s, %s);\n", tevKSelTableC[kc], tevKSelTableA[ka]);
if(cc.a == TEVCOLORARG_CPREV
|| cc.a == TEVCOLORARG_APREV
@ -821,7 +809,6 @@ static void WriteStage(char *&p, int n, u32 texture_mask, API_TYPE ApiType)
RegisterStates[1].AuxStored = true;
}
if(cc.a == TEVCOLORARG_C1
|| cc.a == TEVCOLORARG_A1
|| cc.b == TEVCOLORARG_C1
@ -871,36 +858,36 @@ static void WriteStage(char *&p, int n, u32 texture_mask, API_TYPE ApiType)
RegisterStates[cc.dest].ColorNeedOverflowControl = (cc.clamp == 0);
RegisterStates[cc.dest].AuxStored = false;
if (cc.clamp)
WRITE(p, "%s=saturate(", tevCOutputTable[cc.dest]);
WRITE(p, "%s = saturate(", tevCOutputTable[cc.dest]);
else
WRITE(p, "%s=", tevCOutputTable[cc.dest]);
WRITE(p, "%s = ", tevCOutputTable[cc.dest]);
// combine the color channel
if (cc.bias != TevBias_COMPARE) // if not compare
{
//normal color combiner goes here
if (cc.shift > TEVSCALE_1)
WRITE(p, "%s*(",tevScaleTable[cc.shift]);
WRITE(p, "%s*(", tevScaleTable[cc.shift]);
if(!(cc.d == TEVCOLORARG_ZERO && cc.op == TEVOP_ADD))
WRITE(p, "%s%s",tevCInputTable[cc.d],tevOpTable[cc.op]);
WRITE(p, "%s%s", tevCInputTable[cc.d], tevOpTable[cc.op]);
if (cc.a == cc.b)
WRITE(p,"%s",tevCInputTable[cc.a + 16]);
WRITE(p, "%s", tevCInputTable[cc.a + 16]);
else if (cc.c == TEVCOLORARG_ZERO)
WRITE(p,"%s",tevCInputTable[cc.a + 16]);
WRITE(p, "%s", tevCInputTable[cc.a + 16]);
else if (cc.c == TEVCOLORARG_ONE)
WRITE(p,"%s",tevCInputTable[cc.b + 16]);
WRITE(p, "%s", tevCInputTable[cc.b + 16]);
else if (cc.a == TEVCOLORARG_ZERO)
WRITE(p,"%s*%s",tevCInputTable[cc.b + 16],tevCInputTable[cc.c + 16]);
WRITE(p, "%s*%s", tevCInputTable[cc.b + 16], tevCInputTable[cc.c + 16]);
else if (cc.b == TEVCOLORARG_ZERO)
WRITE(p,"%s*(float3(1.0f,1.0f,1.0f)-%s)",tevCInputTable[cc.a + 16],tevCInputTable[cc.c + 16]);
WRITE(p, "%s*(float3(1.0f, 1.0f, 1.0f)-%s)", tevCInputTable[cc.a + 16], tevCInputTable[cc.c + 16]);
else
WRITE(p, "lerp(%s,%s,%s)",tevCInputTable[cc.a + 16], tevCInputTable[cc.b + 16],tevCInputTable[cc.c + 16]);
WRITE(p, "lerp(%s, %s, %s)", tevCInputTable[cc.a + 16], tevCInputTable[cc.b + 16], tevCInputTable[cc.c + 16]);
WRITE(p, "%s",tevBiasTable[cc.bias]);
WRITE(p, "%s", tevBiasTable[cc.bias]);
if(cc.shift>0)
if (cc.shift > 0)
WRITE(p, ")");
}
else
@ -913,36 +900,36 @@ static void WriteStage(char *&p, int n, u32 texture_mask, API_TYPE ApiType)
tevCInputTable[cc.c + 16]);
}
if (cc.clamp)
WRITE(p,")");
WRITE(p, ")");
WRITE(p,";\n");
RegisterStates[ac.dest].AlphaNeedOverflowControl = (ac.clamp == 0);
RegisterStates[ac.dest].AuxStored = false;
// combine the alpha channel
if (ac.clamp)
WRITE(p, "%s=saturate(", tevAOutputTable[ac.dest]);
WRITE(p, "%s = saturate(", tevAOutputTable[ac.dest]);
else
WRITE(p, "%s=", tevAOutputTable[ac.dest]);
WRITE(p, "%s = ", tevAOutputTable[ac.dest]);
if (ac.bias != TevBias_COMPARE) // if not compare
{
//normal alpha combiner goes here
if (ac.shift > TEVSCALE_1)
WRITE(p, "%s*(",tevScaleTable[ac.shift]);
WRITE(p, "%s*(", tevScaleTable[ac.shift]);
if(!(ac.d == TEVALPHAARG_ZERO && ac.op == TEVOP_ADD))
WRITE(p, "%s.a%s",tevAInputTable[ac.d],tevOpTable[ac.op]);
WRITE(p, "%s.a%s", tevAInputTable[ac.d], tevOpTable[ac.op]);
if (ac.a == ac.b)
WRITE(p,"%s.a",tevAInputTable[ac.a + 8]);
WRITE(p, "%s.a", tevAInputTable[ac.a + 8]);
else if (ac.c == TEVALPHAARG_ZERO)
WRITE(p,"%s.a",tevAInputTable[ac.a + 8]);
WRITE(p, "%s.a", tevAInputTable[ac.a + 8]);
else if (ac.a == TEVALPHAARG_ZERO)
WRITE(p,"%s.a*%s.a",tevAInputTable[ac.b + 8],tevAInputTable[ac.c + 8]);
WRITE(p, "%s.a*%s.a", tevAInputTable[ac.b + 8], tevAInputTable[ac.c + 8]);
else if (ac.b == TEVALPHAARG_ZERO)
WRITE(p,"%s.a*(1.0f-%s.a)",tevAInputTable[ac.a + 8],tevAInputTable[ac.c + 8]);
WRITE(p, "%s.a*(1.0f-%s.a)", tevAInputTable[ac.a + 8], tevAInputTable[ac.c + 8]);
else
WRITE(p, "lerp(%s.a,%s.a,%s.a)",tevAInputTable[ac.a + 8],tevAInputTable[ac.b + 8],tevAInputTable[ac.c + 8]);
WRITE(p, "lerp(%s.a, %s.a, %s.a)", tevAInputTable[ac.a + 8], tevAInputTable[ac.b + 8], tevAInputTable[ac.c + 8]);
WRITE(p, "%s",tevBiasTable[ac.bias]);
@ -993,7 +980,8 @@ void SampleTexture(char *&p, const char *destination, const char *texcoords, con
else
WRITE(p, "%s=texRECT(samp%d,tempcoord.xy).%s;\n", destination, texmap, texswap);
}
else {
else
{
if (ApiType == API_D3D11)
WRITE(p, "%s=Tex%d.Sample(samp%d,%s.xy).%s;\n", destination,texmap,texmap, texcoords, texswap);
else if (ApiType == API_D3D9)
@ -1002,7 +990,8 @@ void SampleTexture(char *&p, const char *destination, const char *texcoords, con
WRITE(p, "%s=texRECT(samp%d,%s.xy).%s;\n", destination, texmap, texcoords, texswap);
}
}
else {
else
{
if (ApiType == API_D3D11)
WRITE(p, "%s=Tex%d.Sample(samp%d,%s.xy * "I_TEXDIMS"[%d].xy).%s;\n", destination, texmap,texmap, texcoords, texmap, texswap);
else
@ -1033,9 +1022,9 @@ static const char *tevAlphaFunclogicTable[] =
static bool WriteAlphaTest(char *&p, API_TYPE ApiType)
{
u32 op = bpmem.alphaFunc.logic;
u32 comp[2] = {bpmem.alphaFunc.comp0,bpmem.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)
{
case 0: // AND

View File

@ -106,8 +106,8 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
"typedef struct { FLT4 T[64]; } s_"I_POSTTRANSFORMMATRICES";\n"
"typedef struct { float4 col; float4 cosatt; float4 distatt; float4 pos; float4 dir; } Light;\n"
"typedef struct { Light lights[8]; } s_"I_LIGHTS";\n"
"typedef struct { float4 C0,C1,C2,C3; } s_"I_MATERIALS";\n"
"typedef struct { float4 T0,T1,T2,T3; } s_"I_PROJECTION";\n"
"typedef struct { float4 C0, C1, C2, C3; } s_"I_MATERIALS";\n"
"typedef struct { float4 T0, T1, T2, T3; } s_"I_PROJECTION";\n"
);
WRITE(p, "struct VS_OUTPUT {\n");
@ -159,8 +159,8 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
WRITE(p, " float4 color1 : COLOR1,\n");
for (int i = 0; i < 8; ++i) {
u32 hastexmtx = (components & (VB_HAS_TEXMTXIDX0<<i));
if ((components & (VB_HAS_UV0<<i)) || hastexmtx )
WRITE(p, " float%d tex%d : TEXCOORD%d,\n", hastexmtx ? 3 : 2, i,i);
if ((components & (VB_HAS_UV0<<i)) || hastexmtx)
WRITE(p, " float%d tex%d : TEXCOORD%d,\n", hastexmtx ? 3 : 2, i, i);
}
if (components & VB_HAS_POSMTXIDX) {
if (is_d3d)
@ -189,7 +189,7 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
WRITE(p, "int posmtx = fposmtx;\n");
}
WRITE(p, "float4 pos = float4(dot("I_TRANSFORMMATRICES".T[posmtx].t, rawpos), dot("I_TRANSFORMMATRICES".T[posmtx+1].t, rawpos), dot("I_TRANSFORMMATRICES".T[posmtx+2].t, rawpos),1);\n");
WRITE(p, "float4 pos = float4(dot("I_TRANSFORMMATRICES".T[posmtx].t, rawpos), dot("I_TRANSFORMMATRICES".T[posmtx+1].t, rawpos), dot("I_TRANSFORMMATRICES".T[posmtx+2].t, rawpos), 1);\n");
if (components & VB_HAS_NRMALL) {
WRITE(p, "int normidx = posmtx >= 32 ? (posmtx-32) : posmtx;\n");
@ -202,9 +202,9 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
WRITE(p, "float3 _norm1 = float3(dot(N0, rawnorm1), dot(N1, rawnorm1), dot(N2, rawnorm1));\n");
if (components & VB_HAS_NRM2)
WRITE(p, "float3 _norm2 = float3(dot(N0, rawnorm2), dot(N1, rawnorm2), dot(N2, rawnorm2));\n");
}
else {
else
{
WRITE(p, "float4 pos = float4(dot("I_POSNORMALMATRIX".T0, rawpos), dot("I_POSNORMALMATRIX".T1, rawpos), dot("I_POSNORMALMATRIX".T2, rawpos), 1.0f);\n");
if (components & VB_HAS_NRM0)
WRITE(p, "float3 _norm0 = normalize(float3(dot("I_POSNORMALMATRIX".N0.xyz, rawnorm0), dot("I_POSNORMALMATRIX".N1.xyz, rawnorm0), dot("I_POSNORMALMATRIX".N2.xyz, rawnorm0)));\n");
@ -215,16 +215,17 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
}
if (!(components & VB_HAS_NRM0))
WRITE(p, "float3 _norm0 = float3(0.0f,0.0f,0.0f);\n");
WRITE(p, "float3 _norm0 = float3(0.0f, 0.0f, 0.0f);\n");
WRITE(p, "o.pos = float4(dot("I_PROJECTION".T0, pos), dot("I_PROJECTION".T1, pos), dot("I_PROJECTION".T2, pos), dot("I_PROJECTION".T3, pos));\n");
WRITE(p, "float4 mat,lacc;\n" // = half4(1,1,1,1), lacc = half4(0,0,0,0);\n"
WRITE(p, "float4 mat, lacc;\n" // = half4(1, 1, 1, 1), lacc = half4(0, 0, 0, 0);\n"
"float3 ldir, h;\n"
"float dist, dist2, attn;\n");
// lights/colors
for (int j = 0; j < xfregs.nNumChans; j++) {
for (int j = 0; j < xfregs.nNumChans; j++)
{
// bool bColorAlphaSame = xfregs.colChans[j].color.hex == xfregs.colChans[j].alpha.hex; unused
const LitChannel& color = xfregs.colChans[j].color;
@ -232,12 +233,12 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
WRITE(p, "{\n");
WRITE(p, "lacc = float4(1.0f,1.0f,1.0f,1.0f);\n");
WRITE(p, "lacc = float4(1.0f, 1.0f, 1.0f, 1.0f);\n");
if (color.matsource) {// from vertex
if (components & (VB_HAS_COL0 << j))
WRITE(p, "mat = color%d;\n", j);
else
WRITE(p, "mat = float4(1.0f,1.0f,1.0f,1.0f);\n");
WRITE(p, "mat = float4(1.0f, 1.0f, 1.0f, 1.0f);\n");
}
else // from color
WRITE(p, "mat = "I_MATERIALS".C%d;\n", j+2);
@ -247,7 +248,7 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
if (components & (VB_HAS_COL0<<j) )
WRITE(p, "lacc = color%d;\n", j);
else
WRITE(p, "lacc = float4(0.0f,0.0f,0.0f,0.0f);\n");
WRITE(p, "lacc = float4(0.0f, 0.0f, 0.0f, 0.0f);\n");
}
else // from color
WRITE(p, "lacc = "I_MATERIALS".C%d;\n", j);
@ -256,7 +257,7 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
// check if alpha is different
if (alpha.matsource != color.matsource) {
if (alpha.matsource) {// from vertex
if (components & (VB_HAS_COL0<<j) )
if (components & (VB_HAS_COL0<<j))
WRITE(p, "mat.w = color%d.w;\n", j);
else WRITE(p, "mat.w = 1;\n");
}
@ -268,7 +269,8 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
if (alpha.ambsource) {// from vertex
if (components & (VB_HAS_COL0<<j) )
WRITE(p, "lacc.w = color%d.w;\n", j);
else WRITE(p, "lacc.w = 0;\n");
else
WRITE(p, "lacc.w = 0;\n");
}
else // from color
WRITE(p, "lacc.w = "I_MATERIALS".C%d.w;\n", j);
@ -290,25 +292,25 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
}
}
}
// no shared lights
for (int i = 0; i < 8; ++i)
{
if (!(mask&(1<<i)) && (color.GetFullLightMask() & (1<<i)) )
if (!(mask&(1<<i)) && (color.GetFullLightMask() & (1<<i)))
p = GenerateLightShader(p, i, color, "lacc", 1);
if (!(mask&(1<<i)) && (alpha.GetFullLightMask() & (1<<i)) )
if (!(mask&(1<<i)) && (alpha.GetFullLightMask() & (1<<i)))
p = GenerateLightShader(p, i, alpha, "lacc", 2);
}
}
else if (color.enablelighting || alpha.enablelighting)
{
//ligths are disabled in one channel so proccess only te active
// lights are disabled on one channel so process only the active ones
LitChannel workingchannel = color.enablelighting ? color : alpha;
int coloralpha = color.enablelighting ? 1 : 2;
for (int i = 0; i < 8; ++i)
{
if (workingchannel.GetFullLightMask() & (1<<i))
p = GenerateLightShader(p, i, workingchannel, "lacc", coloralpha);
}
}
@ -320,7 +322,8 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
WRITE(p, "o.colors[%d].xyz = mat.xyz;\n"
"o.colors[%d].w = mat.w * saturate(lacc.w);\n", j, j);
}
else {
else
{
if (alpha.enablelighting)
WRITE(p, "o.colors[%d] = mat * saturate(lacc);\n", j);
else
@ -332,7 +335,7 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
// zero left over channels
for (int i = xfregs.nNumChans; i < 2; ++i)
WRITE(p, "o.colors[%d] = float4(0.0f,0.0f,0.0f,1.0f);\n", i);
WRITE(p, "o.colors[%d] = float4(0.0f, 0.0f, 0.0f, 1.0f);\n", i);
// special case if only pos and tex coord 0 and tex coord input is AB11
// donko - this has caused problems in some games. removed for now.
@ -344,12 +347,12 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
*/
// transform texcoords
WRITE(p, "float4 coord = float4(0.0f,0.0f,1.0f,1.0f);\n");
WRITE(p, "float4 coord = float4(0.0f, 0.0f, 1.0f, 1.0f);\n");
for (int i = 0; i < xfregs.numTexGens; ++i) {
TexMtxInfo& texinfo = xfregs.texcoords[i].texmtxinfo;
WRITE(p, "{\n");
WRITE(p, "coord = float4(0.0f,0.0f,1.0f,1.0f);\n");
WRITE(p, "coord = float4(0.0f, 0.0f, 1.0f, 1.0f);\n");
switch (texinfo.sourcerow) {
case XF_SRCGEOM_INROW:
_assert_( texinfo.inputform == XF_TEXINPUT_ABC1 );
@ -383,7 +386,7 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
break;
}
// firs transformation
// first transformation
switch (texinfo.texgentype) {
case XF_TEXGEN_EMBOSS_MAP: // calculate tex coords into bump map
@ -406,14 +409,14 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
case XF_TEXGEN_REGULAR:
default:
if (components & (VB_HAS_TEXMTXIDX0<<i)) {
if (texinfo.projection == XF_TEXPROJ_STQ )
if (texinfo.projection == XF_TEXPROJ_STQ)
WRITE(p, "o.tex%d.xyz = float3(dot(coord, "I_TRANSFORMMATRICES".T[tex%d.z].t), dot(coord, "I_TRANSFORMMATRICES".T[tex%d.z+1].t), dot(coord, "I_TRANSFORMMATRICES".T[tex%d.z+2].t));\n", i, i, i, i);
else {
WRITE(p, "o.tex%d.xyz = float3(dot(coord, "I_TRANSFORMMATRICES".T[tex%d.z].t), dot(coord, "I_TRANSFORMMATRICES".T[tex%d.z+1].t), 1);\n", i, i, i);
}
}
else {
if (texinfo.projection == XF_TEXPROJ_STQ )
if (texinfo.projection == XF_TEXPROJ_STQ)
WRITE(p, "o.tex%d.xyz = float3(dot(coord, "I_TEXMATRICES".T[%d].t), dot(coord, "I_TEXMATRICES".T[%d].t), dot(coord, "I_TEXMATRICES".T[%d].t));\n", i, 3*i, 3*i+1, 3*i+2);
else
WRITE(p, "o.tex%d.xyz = float3(dot(coord, "I_TEXMATRICES".T[%d].t), dot(coord, "I_TEXMATRICES".T[%d].t), 1);\n", i, 3*i, 3*i+1);
@ -433,14 +436,15 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
// q of input is 1
// q of output is unknown
//multiply by postmatrix
// multiply by postmatrix
WRITE(p, "o.tex%d.xyz = float3(dot(P0.xy, o.tex%d.xy) + P0.z + P0.w, dot(P1.xy, o.tex%d.xy) + P1.z + P1.w, 0.0f);\n", i, i, i);
}
else {
else
{
if (xfregs.texcoords[i].postmtxinfo.normalize)
WRITE(p, "o.tex%d.xyz = normalize(o.tex%d.xyz);\n", i, i);
//multiply by postmatrix
// multiply by postmatrix
WRITE(p, "o.tex%d.xyz = float3(dot(P0.xyz, o.tex%d.xyz) + P0.w, dot(P1.xyz, o.tex%d.xyz) + P1.w, dot(P2.xyz, o.tex%d.xyz) + P2.w);\n", i, i, i, i);
}
}
@ -514,7 +518,8 @@ char *GenerateLightShader(char *p, int index, const LitChannel& chan, const char
WRITE(p, "attn = max(0.0f, dot("I_LIGHTS".lights[%d].cosatt.xyz, ldir)) / dot("I_LIGHTS".lights[%d].distatt.xyz, ldir);\n", index, index);
}
switch (chan.diffusefunc) {
switch (chan.diffusefunc)
{
case LIGHTDIF_NONE:
WRITE(p, "%s.%s += attn * "I_LIGHTS".lights[%d].col.%s;\n", dest, swizzle, index, swizzle);
break;

View File

@ -416,7 +416,7 @@ ID3D11Buffer* clearvb = NULL;
typedef struct { float x,y,z,u,v; } STQVertex;
typedef struct { float x,y,z,u,v; } STSQVertex;
typedef struct { float x,y,z; u32 col;} ClearVertex;
typedef struct { float x,y,z; u32 col; } ClearVertex;
void InitUtils()
{

View File

@ -244,7 +244,7 @@ inline void Draw(unsigned int stride, bool alphapass)
}
UINT bufoffset = 0;
UINT bufstride = (UINT)stride;
UINT bufstride = stride;
if (!alphapass) gfxstate->ApplyState();
else gfxstate->AlphaPass();

View File

@ -92,16 +92,6 @@ bool IsD3D()
return true;
}
bool IsD3D9()
{
return false;
}
bool IsD3D11()
{
return true;
}
// This is used for the functions right below here which use wxwidgets
#if defined(HAVE_WX) && HAVE_WX
WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
@ -373,11 +363,6 @@ void Video_AddMessage(const char* pstr, u32 milliseconds)
OSD::AddMessage(pstr, milliseconds);
}
HRESULT ScreenShot(const char* filename)
{
return S_OK;
}
void Video_Screenshot(const char* _szFilename)
{
Renderer::SetScreenshot(_szFilename);

View File

@ -86,16 +86,19 @@ GFXConfigDialogDX::~GFXConfigDialogDX()
{
INFO_LOG(CONSOLE, "GFXConfigDialogDX Closed");
}
void GFXConfigDialogDX::OnClose(wxCloseEvent& event)
{
//INFO_LOG(CONSOLE, "OnClose");
CloseWindow();
}
void GFXConfigDialogDX::CloseClick(wxCommandEvent& WXUNUSED (event))
{
//INFO_LOG(CONSOLE, "CloseClick");
CloseWindow();
}
void GFXConfigDialogDX::InitializeGUIValues()
{
// General Display Settings
@ -151,8 +154,9 @@ void GFXConfigDialogDX::InitializeGUIValues()
m_TexfmtCenter->SetValue(g_Config.bTexFmtOverlayCenter);
m_TexfmtCenter->Enable(m_TexfmtOverlay->IsChecked());
}
void GFXConfigDialogDX::CreateGUIControls()
{
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
@ -380,6 +384,7 @@ void GFXConfigDialogDX::CreateGUIControls()
Center();
UpdateGUI();
}
void GFXConfigDialogDX::DirectXSettingsChanged(wxCommandEvent& event)
{
switch (event.GetId())

View File

@ -162,8 +162,6 @@ class GFXConfigDialogDX : public wxDialog
ID_SHADERERRORS,
ID_TEXFMT_OVERLAY,
ID_TEXFMT_CENTER,
ID_CHECK1,
ID_LIST1,
ID_DEBUGSTEP,
ID_REGISTERS,
ID_ENABLEDEBUGGING,

View File

@ -231,7 +231,6 @@ void SetupDeviceObjects()
// To avoid shader compilation stutters, read back all shaders from cache.
VertexShaderCache::Init();
PixelShaderCache::Init();
// Texture cache will recreate themselves over time.
}
@ -516,7 +515,7 @@ void CheckForResize()
int width = rcParentWindow.right - rcParentWindow.left;
int height = rcParentWindow.bottom - rcParentWindow.top;
if (width != s_backbuffer_width || height != s_backbuffer_height)
::MoveWindow(EmuWindow::GetWnd(), 0, 0, width, height, FALSE);
MoveWindow(EmuWindow::GetWnd(), 0, 0, width, height, FALSE);
}
RECT rcWindow;
GetClientRect(EmuWindow::GetWnd(), &rcWindow);
@ -540,7 +539,7 @@ void CheckForResize()
void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc)
{
if(!fbWidth || !fbHeight)
if (!fbWidth || !fbHeight)
return;
VideoFifo_CheckEFBAccess();
VideoFifo_CheckSwapRequestAt(xfbAddr, fbWidth, fbHeight);
@ -611,7 +610,6 @@ bool Renderer::SetScissorRect()
rc.right = Xstride + s_target_width;
rc.bottom = Ystride + s_target_height;
D3D::dev->SetScissorRect(&rc);
return false;
}
return false;
}
@ -631,16 +629,16 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
if (!g_ActiveConfig.bEFBAccessEnable)
return 0;
//Get the working buffer
// Get the working buffer
LPDIRECT3DSURFACE9 pBuffer = (type == PEEK_Z || type == POKE_Z) ?
FBManager.GetEFBDepthRTSurface() : FBManager.GetEFBColorRTSurface();
//get the temporal buffer to move 1pixel data
// Get the temporal buffer to move 1pixel data
LPDIRECT3DSURFACE9 RBuffer = (type == PEEK_Z || type == POKE_Z) ?
FBManager.GetEFBDepthReadSurface() : FBManager.GetEFBColorReadSurface();
//get the memory buffer that can be locked
// Get the memory buffer that can be locked
LPDIRECT3DSURFACE9 pOffScreenBuffer = (type == PEEK_Z || type == POKE_Z) ?
FBManager.GetEFBDepthOffScreenRTSurface() : FBManager.GetEFBColorOffScreenRTSurface();
//get the buffer format
// Get the buffer format
D3DFORMAT BufferFormat = (type == PEEK_Z || type == POKE_Z) ?
FBManager.GetEFBDepthRTSurfaceFormat() : FBManager.GetEFBColorRTSurfaceFormat();
D3DFORMAT ReadBufferFormat = (type == PEEK_Z || type == POKE_Z) ?
@ -651,7 +649,7 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
D3DLOCKED_RECT drect;
//Buffer not found alert
// Buffer not found alert
if (!pBuffer) {
PanicAlert("No %s!", (type == PEEK_Z || type == POKE_Z) ? "Z-Buffer" : "Color EFB");
return 0;
@ -689,8 +687,8 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
RectToLock.bottom--;
if ((RectToLock.right - RectToLock.left) > 4)
RectToLock.left++;
ResetAPIState(); // reset any game specific settings
hr =D3D::dev->SetDepthStencilSurface(NULL);
ResetAPIState(); // Reset any game specific settings
hr = D3D::dev->SetDepthStencilSurface(NULL);
hr = D3D::dev->SetRenderTarget(0, RBuffer);
if (FAILED(hr))
{
@ -711,7 +709,7 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
PanicAlert("unable to set pixel viewport");
return 0;
}
float colmat[16]= {0.0f};
float colmat[16] = {0.0f};
float fConstAdd[4] = {0.0f};
colmat[0] = colmat[5] = colmat[10] = 1.0f;
PixelShaderManager::SetColorMatrix(colmat, fConstAdd); // set transformation
@ -723,10 +721,10 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
D3D::drawShadedTexQuad(
read_texture,
&RectToLock,
Renderer::GetFullTargetWidth() ,
Renderer::GetFullTargetWidth(),
Renderer::GetFullTargetHeight(),
4,4,
(BufferFormat == FOURCC_RAWZ)?PixelShaderCache::GetColorMatrixProgram(0):PixelShaderCache::GetDepthMatrixProgram(0),
4, 4,
(BufferFormat == FOURCC_RAWZ) ? PixelShaderCache::GetColorMatrixProgram(0) : PixelShaderCache::GetDepthMatrixProgram(0),
VertexShaderCache::GetSimpleVertexShader(0));
D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER);
@ -738,11 +736,10 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
RectToLock.left = 0;
RectToLock.right = 4;
RectToLock.top = 0;
}
else
{
hr = D3D::dev->StretchRect(pBuffer,&RectToLock,RBuffer,NULL, D3DTEXF_NONE);
hr = D3D::dev->StretchRect(pBuffer, &RectToLock, RBuffer, NULL, D3DTEXF_NONE);
//change the rect to lock the entire one pixel buffer
RectToLock.bottom = 1;
RectToLock.left = 0;
@ -754,8 +751,8 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
PanicAlert("Unable to stretch data to buffer");
return 0;
}
//retriebe the pixel data to the local memory buffer
D3D::dev->GetRenderTargetData(RBuffer,pOffScreenBuffer);
// Retrieve the pixel data to the local memory buffer
D3D::dev->GetRenderTargetData(RBuffer, pOffScreenBuffer);
if (FAILED(hr))
{
PanicAlert("Unable to copy data to mem buffer");
@ -764,26 +761,24 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
//the surface is good.. lock it
// The surface is good.. lock it
if ((hr = pOffScreenBuffer->LockRect(&drect, &RectToLock, D3DLOCK_READONLY)) != D3D_OK)
{
PanicAlert("ERROR: %s", hr == D3DERR_WASSTILLDRAWING ? "Still drawing" :
hr == D3DERR_INVALIDCALL ? "Invalid call" : "w00t");
PanicAlert("ERROR: %s", hr == D3DERR_WASSTILLDRAWING ? "Still drawing" : hr == D3DERR_INVALIDCALL ? "Invalid call" : "w00t");
return 0;
}
switch(type) {
switch (type) {
case PEEK_Z:
{
switch (ReadBufferFormat)
{
case D3DFMT_R32F:
val = ((float *)drect.pBits)[6];
val = ((float*)drect.pBits)[6];
break;
default:
float ffrac = 1.0f/255.0f;
z = ((u32 *)drect.pBits)[6];
z = ((u32*)drect.pBits)[6];
val = ((float)((z>>16) & 0xFF)) * ffrac;
ffrac*= 1 / 255.0f;
val += ((float)((z>>8) & 0xFF)) * ffrac;
@ -805,16 +800,14 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
break;
case POKE_COLOR:
// TODO: Get that ARGB value to poke from somewhere
//((float *)drect.pBits)[0] = val;
//((float*)drect.pBits)[0] = val;
PanicAlert("Poke color EFB not implemented");
break;
}
pOffScreenBuffer->UnlockRect();
// TODO: in RE0 this value is often off by one, which causes lighting to disappear
return z;
}
// Called from VertexShaderManager
@ -854,32 +847,32 @@ void UpdateViewport()
Height *= -1;
}
bool sizeChanged = false;
if(X < 0)
if (X < 0)
{
s_Fulltarget_width -= 2 * X;
X = 0;
sizeChanged=true;
}
if(Y < 0)
if (Y < 0)
{
s_Fulltarget_height -= 2 * Y;
Y = 0;
sizeChanged=true;
sizeChanged = true;
}
if(!IS_AMD)
if (!IS_AMD)
{
if(X + Width > s_Fulltarget_width)
{
s_Fulltarget_width += (X + Width - s_Fulltarget_width) * 2;
sizeChanged=true;
sizeChanged = true;
}
if(Y + Height > s_Fulltarget_height)
{
s_Fulltarget_height += (Y + Height - s_Fulltarget_height) * 2;
sizeChanged=true;
sizeChanged = true;
}
}
if(sizeChanged)
if (sizeChanged)
{
D3D::dev->SetRenderTarget(0, D3D::GetBackBufferSurface());
D3D::dev->SetDepthStencilSurface(D3D::GetBackBufferDepthSurface());
@ -893,9 +886,9 @@ void UpdateViewport()
vp.Width = Width;
vp.Height = Height;
//some games set invalids values for z min and z max so fix them to the max an min alowed and let the shaders do this work
vp.MinZ = 0.0f;//(xfregs.rawViewport[5] - xfregs.rawViewport[2]) / 16777216.0f;
vp.MaxZ =1.0f;// xfregs.rawViewport[5] / 16777216.0f;
// Some games set invalids values for z min and z max so fix them to the max an min alowed and let the shaders do this work
vp.MinZ = 0.0f; // (xfregs.rawViewport[5] - xfregs.rawViewport[2]) / 16777216.0f;
vp.MaxZ =1.0f; // xfregs.rawViewport[5] / 16777216.0f;
D3D::dev->SetViewport(&vp);
}
@ -913,16 +906,16 @@ void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaE
D3D::dev->SetViewport(&vp);
// Always set the scissor in case it was set by the game and has not been reset
RECT sirc;
sirc.left = targetRc.left;
sirc.top = targetRc.top;
sirc.right = targetRc.right;
sirc.bottom = targetRc.bottom;
D3D::dev->SetScissorRect(&sirc);
RECT sicr;
sicr.left = targetRc.left;
sicr.top = targetRc.top;
sicr.right = targetRc.right;
sicr.bottom = targetRc.bottom;
D3D::dev->SetScissorRect(&sicr);
D3D::ChangeRenderState(D3DRS_ALPHABLENDENABLE, false);
if (zEnable)
D3D::ChangeRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS);
D3D::drawClearQuad(color ,(z & 0xFFFFFF) / float(0xFFFFFF),PixelShaderCache::GetClearProgram(),VertexShaderCache::GetClearVertexShader());
D3D::drawClearQuad(color, (z & 0xFFFFFF) / float(0xFFFFFF), PixelShaderCache::GetClearProgram(), VertexShaderCache::GetClearVertexShader());
if (zEnable)
D3D::RefreshRenderState(D3DRS_ZFUNC);
D3D::RefreshRenderState(D3DRS_ALPHABLENDENABLE);
@ -991,7 +984,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
vp.MinZ = 0.0f;
vp.MaxZ = 1.0f;
D3D::dev->SetViewport(&vp);
D3D::dev->Clear(0,NULL, D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0f,0);
D3D::dev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
int X = dst_rect.left;
int Y = dst_rect.top;
@ -1106,7 +1099,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
}
if (g_ActiveConfig.bDumpFrames)
{
D3D::dev->GetRenderTargetData(D3D::GetBackBufferSurface(),ScreenShootMEMSurface);
D3D::dev->GetRenderTargetData(D3D::GetBackBufferSurface(), ScreenShootMEMSurface);
if (!s_LastFrameDumped)
{
s_recordWidth = s_backbuffer_width;
@ -1128,8 +1121,8 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
D3DLOCKED_RECT rect;
if (SUCCEEDED(ScreenShootMEMSurface->LockRect(&rect, NULL, D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_NOSYSLOCK | D3DLOCK_READONLY)))
{
char *data = (char *)malloc(3 * s_recordWidth * s_recordHeight);
formatBufferDump((const char *)rect.pBits, data, s_recordWidth, s_recordHeight, rect.Pitch);
char* data = (char*)malloc(3 * s_recordWidth * s_recordHeight);
formatBufferDump((const char*)rect.pBits, data, s_recordWidth, s_recordHeight, rect.Pitch);
AVIDump::AddFrame(data);
free(data);
ScreenShootMEMSurface->UnlockRect();
@ -1147,25 +1140,24 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
s_LastFrameDumped = false;
}
// Finish up the current frame, print some stats
if (g_ActiveConfig.bShowFPS)
{
char fps[20];
StringCchPrintfA(fps, 20, "FPS: %d\n", s_fps);
D3D::font.DrawTextScaled(0,30,20,20,0.0f,0xFF00FFFF,fps,false);
D3D::font.DrawTextScaled(0, 30, 20, 20, 0.0f, 0xFF00FFFF, fps, false);
}
Renderer::DrawDebugText();
if (g_ActiveConfig.bOverlayStats)
{
Statistics::ToString(st);
D3D::font.DrawTextScaled(0,30,20,20,0.0f,0xFF00FFFF,st,false);
D3D::font.DrawTextScaled(0, 30, 20, 20, 0.0f, 0xFF00FFFF, st, false);
}
else if (g_ActiveConfig.bOverlayProjStats)
{
Statistics::ToStringProj(st);
D3D::font.DrawTextScaled(0,30,20,20,0.0f,0xFF00FFFF,st,false);
D3D::font.DrawTextScaled(0, 30, 20, 20, 0.0f, 0xFF00FFFF, st, false);
}
@ -1183,21 +1175,20 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
bool xfbchanged = false;
if(s_XFB_width != fbWidth || s_XFB_height != fbHeight)
if (s_XFB_width != fbWidth || s_XFB_height != fbHeight)
{
xfbchanged = true;
s_XFB_width = fbWidth;
s_XFB_height = fbHeight;
if(s_XFB_width < 1) s_XFB_width = MAX_XFB_WIDTH;
if(s_XFB_width > MAX_XFB_WIDTH) s_XFB_width = MAX_XFB_WIDTH;
if(s_XFB_height < 1) s_XFB_height = MAX_XFB_HEIGHT;
if(s_XFB_height > MAX_XFB_HEIGHT) s_XFB_height = MAX_XFB_HEIGHT;
if (s_XFB_width < 1) s_XFB_width = MAX_XFB_WIDTH;
if (s_XFB_width > MAX_XFB_WIDTH) s_XFB_width = MAX_XFB_WIDTH;
if (s_XFB_height < 1) s_XFB_height = MAX_XFB_HEIGHT;
if (s_XFB_height > MAX_XFB_HEIGHT) s_XFB_height = MAX_XFB_HEIGHT;
}
u32 newAA = g_ActiveConfig.iMultisampleMode;
u32 newEFBScale = g_ActiveConfig.iEFBScale;
if(newAA != s_LastAA || newEFBScale != s_LastEFBScale || xfbchanged || WindowResized)
if (newAA != s_LastAA || newEFBScale != s_LastEFBScale || xfbchanged || WindowResized)
{
s_LastAA = newAA;
s_LastEFBScale = newEFBScale;
@ -1237,7 +1228,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
s_target_height = EFB_HEIGHT * EFByScale;
D3D::dev->SetRenderTarget(0, D3D::GetBackBufferSurface());
D3D::dev->SetDepthStencilSurface(D3D::GetBackBufferDepthSurface());
if(WindowResized)
if (WindowResized)
{
SetupDeviceObjects();
}
@ -1248,7 +1239,6 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
}
D3D::dev->SetRenderTarget(0, FBManager.GetEFBColorRTSurface());
D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface());
}
// ---------------------------------------------------------------------
@ -1256,7 +1246,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
// -------------
static int fpscount = 1;
static unsigned long lasttime;
if(XFBWrited)
if (XFBWrited)
++fpscount;
if (Common::Timer::GetTimeMs() - lasttime > 1000)
{
@ -1288,7 +1278,7 @@ void Renderer::ResetAPIState()
D3D::SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
D3D::SetRenderState(D3DRS_ZENABLE, FALSE);
D3D::SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
DWORD color_mask = D3DCOLORWRITEENABLE_ALPHA| D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE;
DWORD color_mask = D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE;
D3D::SetRenderState(D3DRS_COLORWRITEENABLE, color_mask);
}
@ -1298,8 +1288,10 @@ void Renderer::RestoreAPIState()
D3D::SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE);
UpdateViewport();
SetScissorRect();
if (bpmem.zmode.testenable) D3D::SetRenderState(D3DRS_ZENABLE, TRUE);
if (bpmem.zmode.updateenable) D3D::SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
if (bpmem.zmode.testenable)
D3D::SetRenderState(D3DRS_ZENABLE, TRUE);
if (bpmem.zmode.updateenable)
D3D::SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
SetColorMask();
SetLogicOpMode();
}
@ -1341,7 +1333,7 @@ void Renderer::SetLogicOpMode()
void Renderer::SetDitherMode()
{
D3D::SetRenderState(D3DRS_DITHERENABLE,bpmem.blendmode.dither);
D3D::SetRenderState(D3DRS_DITHERENABLE, bpmem.blendmode.dither);
}
void Renderer::SetLineWidth()
@ -1367,14 +1359,14 @@ void Renderer::SetSamplerState(int stage, int texindex)
{
min = (tm0.min_filter & 4) ? D3DTEXF_LINEAR : D3DTEXF_POINT;
mag = tm0.mag_filter ? D3DTEXF_LINEAR : D3DTEXF_POINT;
mip = (tm0.min_filter == 8)?D3DTEXF_NONE:d3dMipFilters[tm0.min_filter & 3];
if((tm0.min_filter & 3) && (tm0.min_filter != 8) && ((tm1.max_lod >> 4) == 0)) mip = D3DTEXF_NONE;
mip = (tm0.min_filter == 8) ? D3DTEXF_NONE : d3dMipFilters[tm0.min_filter & 3];
if((tm0.min_filter & 3) && (tm0.min_filter != 8) && ((tm1.max_lod >> 4) == 0))
mip = D3DTEXF_NONE;
}
if (texindex)
stage += 4;
if (mag == D3DTEXF_LINEAR && min == D3DTEXF_LINEAR &&
g_ActiveConfig.iMaxAnisotropy > 1)
if (mag == D3DTEXF_LINEAR && min == D3DTEXF_LINEAR && g_ActiveConfig.iMaxAnisotropy > 1)
{
min = D3DTEXF_ANISOTROPIC;
}
@ -1386,8 +1378,8 @@ void Renderer::SetSamplerState(int stage, int texindex)
D3D::SetSamplerState(stage, D3DSAMP_ADDRESSV, d3dClamps[tm0.wrap_t]);
//float SuperSampleCoeficient = (s_LastAA < 3)? s_LastAA + 1 : s_LastAA - 1;// uncoment this changes to conserve detail when incresing ssaa level
float lodbias = (tm0.lod_bias / 32.0f);// + (s_LastAA)?(log(SuperSampleCoeficient) / log(2.0f)):0;
D3D::SetSamplerState(stage,D3DSAMP_MIPMAPLODBIAS,*(DWORD*)&lodbias);
D3D::SetSamplerState(stage,D3DSAMP_MAXMIPLEVEL,tm1.min_lod>>4);
D3D::SetSamplerState(stage, D3DSAMP_MIPMAPLODBIAS, *(DWORD*)&lodbias);
D3D::SetSamplerState(stage, D3DSAMP_MAXMIPLEVEL, tm1.min_lod >> 4);
}
void Renderer::SetInterlacingMode()
@ -1399,7 +1391,7 @@ void Renderer::SetInterlacingMode()
void Renderer::SetScreenshot(const char *filename)
{
s_criticalScreenshot.Enter();
strcpy_s(s_sScreenshotName,filename);
strcpy_s(s_sScreenshotName, filename);
s_bScreenshot = true;
s_criticalScreenshot.Leave();
}

View File

@ -53,9 +53,9 @@ public:
private:
DECLARE_EVENT_TABLE();
wxPanel *m_MainPanel;
wxPanel* m_MainPanel;
wxCheckBox *m_Check[6];
wxCheckBox* m_Check[6];
// WARNING: Make sure these are not also elsewhere
enum

View File

@ -10,13 +10,13 @@ namespace WiimoteEmu
void UDPNunchuk::GetState( u8* const data, const bool focus )
{
Nunchuk::GetState(data,focus);
Nunchuk::GetState(data, focus);
if (!(wrp->inst)) return;
wm_extension* const ncdata = (wm_extension*)data;
u8 mask;
float x,y;
wrp->inst->getNunchuck(x,y,mask);
float x, y;
wrp->inst->getNunchuck(x, y, mask);
if (mask&UDPWM_NC) ncdata->bt&=~NUNCHUK_C;
if (mask&UDPWM_NZ) ncdata->bt&=~NUNCHUK_Z;
if ((ncdata->jx==0x80)&&(ncdata->jy==0x80))

View File

@ -11,7 +11,7 @@ namespace WiimoteEmu
class UDPNunchuk : public Nunchuk
{
public:
UDPNunchuk(UDPWrapper * _wrp) : wrp(_wrp ) {name="UDP Nunchuk";}; //sorry for this :p I just dont' feel like rewriting the whole class for a name :p
UDPNunchuk(UDPWrapper * _wrp) : wrp(_wrp) {name="UDP Nunchuk";}; //sorry for this :p I just dont' feel like rewriting the whole class for a name :p
virtual void GetState( u8* const data, const bool focus );
private:
UDPWrapper * wrp;