Revert Rodolfo's recent zcomploc commits until they actually work correctly.

This reverts commit 402006a83a.
This reverts commit 48d8d71391.
This reverts commit 450dcc9d2c.
This commit is contained in:
NeoBrainX 2012-03-30 01:56:24 +02:00
parent f7c17c6351
commit 460610ea0e
16 changed files with 75 additions and 184 deletions

View File

@ -24,7 +24,7 @@
// Increment this every time you change shader generation code. // Increment this every time you change shader generation code.
enum enum
{ {
LINEAR_DISKCACHE_VER = 6989 LINEAR_DISKCACHE_VER = 6975
}; };
// On disk format: // On disk format:

View File

@ -87,7 +87,6 @@ wxString fast_mipmaps_desc = wxTRANSLATE("Automatically generate mipmaps rather
wxString scaled_efb_copy_desc = wxTRANSLATE("Greatly increases quality of textures generated using render to texture effects.\nRaising the internal resolution will improve the effect of this setting.\nSlightly decreases performance and possibly causes issues (although unlikely).\n\nIf unsure, leave this checked."); wxString scaled_efb_copy_desc = wxTRANSLATE("Greatly increases quality of textures generated using render to texture effects.\nRaising the internal resolution will improve the effect of this setting.\nSlightly decreases performance and possibly causes issues (although unlikely).\n\nIf unsure, leave this checked.");
wxString pixel_lighting_desc = wxTRANSLATE("Calculate lighting of 3D graphics per-pixel rather than per vertex.\nDecreases emulation speed by some percent (depending on your GPU).\nThis usually is a safe enhancement, but might cause issues sometimes.\n\nIf unsure, leave this unchecked."); wxString pixel_lighting_desc = wxTRANSLATE("Calculate lighting of 3D graphics per-pixel rather than per vertex.\nDecreases emulation speed by some percent (depending on your GPU).\nThis usually is a safe enhancement, but might cause issues sometimes.\n\nIf unsure, leave this unchecked.");
wxString pixel_depth_desc = wxTRANSLATE("Calculate depth values of 3D graphics per-pixel rather than per vertex.\nIn contrast to pixel lighting (which is merely an enhancement), per-pixel depth calculations are necessary to properly emulate a small number of games.\n\nIf unsure, leave this checked."); wxString pixel_depth_desc = wxTRANSLATE("Calculate depth values of 3D graphics per-pixel rather than per vertex.\nIn contrast to pixel lighting (which is merely an enhancement), per-pixel depth calculations are necessary to properly emulate a small number of games.\n\nIf unsure, leave this checked.");
wxString fast_zcomploc_desc = wxTRANSLATE("Disabled emulation of zcomploc (a feature used for rendering certain effects).\nSpeeds up emulation, but also breaks games that rely on this functionality.\nIf unsure, leave this unchecked.");
wxString force_filtering_desc = wxTRANSLATE("Force texture filtering even if the emulated game explicitly disabled it.\nImproves texture quality slightly but causes glitches in some games.\n\nIf unsure, leave this unchecked."); wxString force_filtering_desc = wxTRANSLATE("Force texture filtering even if the emulated game explicitly disabled it.\nImproves texture quality slightly but causes glitches in some games.\n\nIf unsure, leave this unchecked.");
wxString _3d_vision_desc = wxTRANSLATE("Enable 3D effects via stereoscopy using Nvidia 3D Vision technology if it's supported by your GPU.\nPossibly causes issues.\nRequires fullscreen to work.\n\nIf unsure, leave this unchecked."); wxString _3d_vision_desc = wxTRANSLATE("Enable 3D effects via stereoscopy using Nvidia 3D Vision technology if it's supported by your GPU.\nPossibly causes issues.\nRequires fullscreen to work.\n\nIf unsure, leave this unchecked.");
wxString internal_res_desc = wxTRANSLATE("Specifies the resolution used to render at. A high resolution will improve visual quality a lot but is also quite heavy on performance and might cause glitches in certain games.\n\"Multiple of 640x528\" is a bit slower than \"Window Size\" but yields less issues. Generally speaking, the lower the internal resolution is, the better your performance will be.\n\nIf unsure, select 640x528."); wxString internal_res_desc = wxTRANSLATE("Specifies the resolution used to render at. A high resolution will improve visual quality a lot but is also quite heavy on performance and might cause glitches in certain games.\n\"Multiple of 640x528\" is a bit slower than \"Window Size\" but yields less issues. Generally speaking, the lower the internal resolution is, the better your performance will be.\n\nIf unsure, select 640x528.");
@ -496,8 +495,7 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
szr_other->Add(CreateCheckBox(page_hacks, _("Cache Display Lists"), wxGetTranslation(dlc_desc), vconfig.bDlistCachingEnable)); szr_other->Add(CreateCheckBox(page_hacks, _("Cache Display Lists"), wxGetTranslation(dlc_desc), vconfig.bDlistCachingEnable));
szr_other->Add(CreateCheckBox(page_hacks, _("Disable Lighting"), wxGetTranslation(disable_lighting_desc), vconfig.bDisableLighting)); szr_other->Add(CreateCheckBox(page_hacks, _("Disable Lighting"), wxGetTranslation(disable_lighting_desc), vconfig.bDisableLighting));
szr_other->Add(CreateCheckBox(page_hacks, _("Disable Fog"), wxGetTranslation(disable_fog_desc), vconfig.bDisableFog)); szr_other->Add(CreateCheckBox(page_hacks, _("Disable Fog"), wxGetTranslation(disable_fog_desc), vconfig.bDisableFog));
szr_other->Add(CreateCheckBox(page_hacks, _("Enable Per-Pixel Depth"), wxGetTranslation(pixel_depth_desc), vconfig.bEnablePerPixelDepth, true)); szr_other->Add(CreateCheckBox(page_hacks, _("Disable Per-Pixel Depth"), wxGetTranslation(pixel_depth_desc), vconfig.bEnablePerPixelDepth, true));
szr_other->Add(CreateCheckBox(page_hacks, _("Fast Zcomploc emulation"), wxGetTranslation(fast_zcomploc_desc), vconfig.bEnableFastZcomploc));
szr_other->Add(CreateCheckBox(page_hacks, _("Skip Dest. Alpha Pass"), wxGetTranslation(disable_alphapass_desc), vconfig.bDstAlphaPass)); szr_other->Add(CreateCheckBox(page_hacks, _("Skip Dest. Alpha Pass"), wxGetTranslation(disable_alphapass_desc), vconfig.bDstAlphaPass));
szr_other->Add(CreateCheckBox(page_hacks, _("OpenCL Texture Decoder"), wxGetTranslation(opencl_desc), vconfig.bEnableOpenCL)); szr_other->Add(CreateCheckBox(page_hacks, _("OpenCL Texture Decoder"), wxGetTranslation(opencl_desc), vconfig.bEnableOpenCL));
szr_other->Add(CreateCheckBox(page_hacks, _("OpenMP Texture Decoder"), wxGetTranslation(omp_desc), vconfig.bOMPDecoder)); szr_other->Add(CreateCheckBox(page_hacks, _("OpenMP Texture Decoder"), wxGetTranslation(omp_desc), vconfig.bOMPDecoder));

View File

@ -109,7 +109,7 @@ void GetPixelShaderId(PIXELSHADERUID *uid, DSTALPHA_MODE dstAlphaMode, u32 compo
uid->values[0] |= bpmem.genMode.numtexgens << 4; // 4 uid->values[0] |= bpmem.genMode.numtexgens << 4; // 4
uid->values[0] |= dstAlphaMode << 8; // 2 uid->values[0] |= dstAlphaMode << 8; // 2
bool DepthTextureEnable = (bpmem.ztex2.op != ZTEXTURE_DISABLE && !bpmem.zcontrol.zcomploc && bpmem.zmode.testenable) || g_ActiveConfig.bEnablePerPixelDepth; bool DepthTextureEnable = (bpmem.ztex2.op != ZTEXTURE_DISABLE && !bpmem.zcontrol.zcomploc && bpmem.zmode.testenable && bpmem.zmode.updateenable) || g_ActiveConfig.bEnablePerPixelDepth;
uid->values[0] |= DepthTextureEnable << 10; // 1 uid->values[0] |= DepthTextureEnable << 10; // 1
@ -121,7 +121,7 @@ void GetPixelShaderId(PIXELSHADERUID *uid, DSTALPHA_MODE dstAlphaMode, u32 compo
uid->values[0] |= alphaPreTest << 16; // 2 uid->values[0] |= alphaPreTest << 16; // 2
if (alphaPreTest == 1 || (alphaPreTest == 2 && !DepthTextureEnable && dstAlphaMode == DSTALPHA_ALPHA_PASS) || dstAlphaMode == DSTALPHA_ZCOMPLOC) if (alphaPreTest == 1 || (alphaPreTest && !DepthTextureEnable && dstAlphaMode == DSTALPHA_ALPHA_PASS))
{ {
// Courtesy of PreAlphaTest, we're done already ;) // Courtesy of PreAlphaTest, we're done already ;)
// NOTE: The comment header of generated shaders depends on the value of bpmem.genmode.numindstages.. shouldnt really bother about that though. // NOTE: The comment header of generated shaders depends on the value of bpmem.genmode.numindstages.. shouldnt really bother about that though.
@ -177,8 +177,6 @@ void GetPixelShaderId(PIXELSHADERUID *uid, DSTALPHA_MODE dstAlphaMode, u32 compo
ptr[0] |= bpmem.zcontrol.zcomploc << 13; // 1 ptr[0] |= bpmem.zcontrol.zcomploc << 13; // 1
ptr[0] |= bpmem.zmode.testenable << 14; // 1 ptr[0] |= bpmem.zmode.testenable << 14; // 1
ptr[0] |= bpmem.zmode.updateenable << 15; // 1 ptr[0] |= bpmem.zmode.updateenable << 15; // 1
ptr[0] |= g_ActiveConfig.bEnableFastZcomploc << 16; // 1
} }
} }
@ -186,8 +184,8 @@ void GetPixelShaderId(PIXELSHADERUID *uid, DSTALPHA_MODE dstAlphaMode, u32 compo
{ {
if (bpmem.fog.c_proj_fsel.fsel != 0) if (bpmem.fog.c_proj_fsel.fsel != 0)
{ {
ptr[0] |= bpmem.fog.c_proj_fsel.proj << 17; // 1 ptr[0] |= bpmem.fog.c_proj_fsel.proj << 16; // 1
ptr[0] |= bpmem.fogRange.Base.Enabled << 18; // 1 ptr[0] |= bpmem.fogRange.Base.Enabled << 17; // 1
} }
} }
@ -212,8 +210,7 @@ void GetSafePixelShaderId(PIXELSHADERUIDSAFE *uid, DSTALPHA_MODE dstAlphaMode, u
*ptr++ = bpmem.zmode.hex; // 4 *ptr++ = bpmem.zmode.hex; // 4
*ptr++ = g_ActiveConfig.bEnablePerPixelDepth; // 5 *ptr++ = g_ActiveConfig.bEnablePerPixelDepth; // 5
*ptr++ = g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting; // 6 *ptr++ = g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting; // 6
*ptr++ = g_ActiveConfig.bEnableFastZcomploc ; // 7 *ptr++ = xfregs.numTexGen.hex; // 7
*ptr++ = xfregs.numTexGen.hex; // 8
if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting) if (g_ActiveConfig.bEnablePixelLighting && g_ActiveConfig.backend_info.bSupportsPixelLighting)
{ {
@ -225,28 +222,28 @@ void GetSafePixelShaderId(PIXELSHADERUIDSAFE *uid, DSTALPHA_MODE dstAlphaMode, u
} }
for (unsigned int i = 0; i < 8; ++i) for (unsigned int i = 0; i < 8; ++i)
*ptr++ = xfregs.texMtxInfo[i].hex; // 9-16 *ptr++ = xfregs.texMtxInfo[i].hex; // 8-15
for (unsigned int i = 0; i < 16; ++i) for (unsigned int i = 0; i < 16; ++i)
*ptr++ = bpmem.tevind[i].hex; // 17-32 *ptr++ = bpmem.tevind[i].hex; // 16-31
*ptr++ = bpmem.tevindref.hex; // 33 *ptr++ = bpmem.tevindref.hex; // 32
for (int i = 0; i < bpmem.genMode.numtevstages+1; ++i) // up to 16 times for (int i = 0; i < bpmem.genMode.numtevstages+1; ++i) // up to 16 times
{ {
*ptr++ = bpmem.combiners[i].colorC.hex; // 34+5*i *ptr++ = bpmem.combiners[i].colorC.hex; // 33+5*i
*ptr++ = bpmem.combiners[i].alphaC.hex; // 35+5*i *ptr++ = bpmem.combiners[i].alphaC.hex; // 34+5*i
*ptr++ = bpmem.tevind[i].hex; // 36+5*i *ptr++ = bpmem.tevind[i].hex; // 35+5*i
*ptr++ = bpmem.tevksel[i/2].hex; // 37+5*i *ptr++ = bpmem.tevksel[i/2].hex; // 36+5*i
*ptr++ = bpmem.tevorders[i/2].hex; // 38+5*i *ptr++ = bpmem.tevorders[i/2].hex; // 37+5*i
} }
ptr = &uid->values[114]; ptr = &uid->values[113];
*ptr++ = bpmem.alphaFunc.hex; // 114 *ptr++ = bpmem.alphaFunc.hex; // 113
*ptr++ = bpmem.fog.c_proj_fsel.hex; // 115 *ptr++ = bpmem.fog.c_proj_fsel.hex; // 114
*ptr++ = bpmem.fogRange.Base.hex; // 116 *ptr++ = bpmem.fogRange.Base.hex; // 115
_assert_((ptr - uid->values) == uid->GetNumValues()); _assert_((ptr - uid->values) == uid->GetNumValues());
} }
@ -526,7 +523,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
nIndirectStagesUsed |= 1 << bpmem.tevind[i].bt; nIndirectStagesUsed |= 1 << bpmem.tevind[i].bt;
} }
} }
DepthTextureEnable = (bpmem.ztex2.op != ZTEXTURE_DISABLE && !bpmem.zcontrol.zcomploc && bpmem.zmode.testenable) || g_ActiveConfig.bEnablePerPixelDepth ; DepthTextureEnable = (bpmem.ztex2.op != ZTEXTURE_DISABLE && !bpmem.zcontrol.zcomploc && bpmem.zmode.testenable && bpmem.zmode.updateenable) || g_ActiveConfig.bEnablePerPixelDepth ;
// Declare samplers // Declare samplers
if(ApiType != API_D3D11) if(ApiType != API_D3D11)
@ -622,9 +619,9 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
char* pmainstart = p; char* pmainstart = p;
int Pretest = AlphaPreTest(); int Pretest = AlphaPreTest();
if(Pretest >= 0 || dstAlphaMode == DSTALPHA_ZCOMPLOC) if(Pretest >= 0 && !DepthTextureEnable)
{ {
if (!Pretest || dstAlphaMode == DSTALPHA_ZCOMPLOC) if (!Pretest)
{ {
// alpha test will always fail, so restart the shader and just make it an empty function // alpha test will always fail, so restart the shader and just make it an empty function
WRITE(p, "ocol0 = 0;\n"); WRITE(p, "ocol0 = 0;\n");
@ -632,18 +629,15 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
WRITE(p, "depth = 1.f;\n"); WRITE(p, "depth = 1.f;\n");
if(dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND) if(dstAlphaMode == DSTALPHA_DUAL_SOURCE_BLEND)
WRITE(p, "ocol1 = 0;\n"); WRITE(p, "ocol1 = 0;\n");
if(dstAlphaMode != DSTALPHA_ZCOMPLOC) WRITE(p, "discard;\n");
{ if(ApiType != API_D3D11)
WRITE(p, "discard;\n"); WRITE(p, "return;\n");
if(ApiType != API_D3D11)
WRITE(p, "return;\n");
}
} }
else if (dstAlphaMode == DSTALPHA_ALPHA_PASS && !DepthTextureEnable) else if (dstAlphaMode == DSTALPHA_ALPHA_PASS)
{ {
WRITE(p, " ocol0 = "I_ALPHA"[0].aaaa;\n"); WRITE(p, " ocol0 = "I_ALPHA"[0].aaaa;\n");
} }
if(!Pretest || (dstAlphaMode == DSTALPHA_ALPHA_PASS && !DepthTextureEnable) || dstAlphaMode == DSTALPHA_ZCOMPLOC) if(!Pretest || dstAlphaMode == DSTALPHA_ALPHA_PASS)
{ {
WRITE(p, "}\n"); WRITE(p, "}\n");
return text; return text;
@ -750,7 +744,7 @@ const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType
if (DepthTextureEnable) if (DepthTextureEnable)
{ {
// use the texture input of the last texture stage (textemp), hopefully this has been read and is in correct format... // use the texture input of the last texture stage (textemp), hopefully this has been read and is in correct format...
if (bpmem.ztex2.op != ZTEXTURE_DISABLE && !bpmem.zcontrol.zcomploc && bpmem.zmode.testenable) if (bpmem.ztex2.op != ZTEXTURE_DISABLE && !bpmem.zcontrol.zcomploc && bpmem.zmode.testenable && bpmem.zmode.updateenable)
{ {
if (bpmem.ztex2.op == ZTEXTURE_ADD) if (bpmem.ztex2.op == ZTEXTURE_ADD)
WRITE(p, "zCoord = dot("I_ZBIAS"[0].xyzw, textemp.xyzw) + "I_ZBIAS"[1].w + zCoord;\n"); WRITE(p, "zCoord = dot("I_ZBIAS"[0].xyzw, textemp.xyzw) + "I_ZBIAS"[1].w + zCoord;\n");
@ -1186,15 +1180,17 @@ static void WriteAlphaTest(char *&p, API_TYPE ApiType,DSTALPHA_MODE dstAlphaMode
// HAXX: zcomploc is a way to control whether depth test is done before // HAXX: zcomploc is a way to control whether depth test is done before
// or after texturing and alpha test. PC GPU does depth test before texturing ONLY if depth value is // or after texturing and alpha test. PC GPU does depth test before texturing ONLY if depth value is
// not updated during shader execution. but GC hardware acts different: // not updated during shader execution.
// if zcomlock is enabled, depth value is updated even if alpha test fails
// We implement "depth test before texturing" by discarding the fragment // We implement "depth test before texturing" by discarding the fragment
// when the alpha test fail. This is not a correct implementation because // when the alpha test fail. This is not a correct implementation because
// even if the depth test fails the fragment could be alpha blended. // even if the depth test fails the fragment could be alpha blended.
// the more correct, but slow, way is: // this implemnetation is a trick to keep speed.
// 1 - if zcomplock is enabled make a last pass, with color channel write disabled updating only // the correct, but slow, way to implement a correct zComploc is :
// 1 - if zcomplock is enebled make a first pass, with color channel write disabled updating only
// depth channel. // depth channel.
if (!(g_ActiveConfig.bEnableFastZcomploc && bpmem.zcontrol.zcomploc && bpmem.zmode.updateenable)) // 2 - in the next pass disable depth chanel update, but proccess the color data normally
// this way is the only CORRECT way to emulate perfectly the zcomplock behaviour
if (!(bpmem.zcontrol.zcomploc && bpmem.zmode.updateenable))
{ {
WRITE(p, "discard;\n"); WRITE(p, "discard;\n");
if (ApiType != API_D3D11) if (ApiType != API_D3D11)

View File

@ -109,7 +109,6 @@ typedef _PIXELSHADERUID<true> PIXELSHADERUIDSAFE;
enum DSTALPHA_MODE enum DSTALPHA_MODE
{ {
DSTALPHA_NONE, // Render normally, without destination alpha DSTALPHA_NONE, // Render normally, without destination alpha
DSTALPHA_ZCOMPLOC,
DSTALPHA_ALPHA_PASS, // Render normally first, then render again for alpha DSTALPHA_ALPHA_PASS, // Render normally first, then render again for alpha
DSTALPHA_DUAL_SOURCE_BLEND // Use dual-source blending DSTALPHA_DUAL_SOURCE_BLEND // Use dual-source blending
}; };

View File

@ -43,21 +43,12 @@ extern int OSDChoice, OSDTime;
extern bool bLastFrameDumped; extern bool bLastFrameDumped;
enum RenderStateMode
{
RSM_None,
RSM_Multipass,
RSM_Zcomploc,
RSM_UseDstAlpha
};
// Renderer really isn't a very good name for this class - it's more like "Misc". // Renderer really isn't a very good name for this class - it's more like "Misc".
// The long term goal is to get rid of this class and replace it with others that make // The long term goal is to get rid of this class and replace it with others that make
// more sense. // more sense.
class Renderer class Renderer
{ {
public: public:
Renderer(); Renderer();
virtual ~Renderer(); virtual ~Renderer();
@ -72,8 +63,8 @@ public:
virtual void SetSamplerState(int stage,int texindex) = 0; virtual void SetSamplerState(int stage,int texindex) = 0;
virtual void SetInterlacingMode() = 0; virtual void SetInterlacingMode() = 0;
virtual void ApplyState(RenderStateMode mode) = 0; virtual void ApplyState(bool bUseDstAlpha) = 0;
virtual void RestoreState(RenderStateMode mode) = 0; virtual void RestoreState() = 0;
// Ideal internal resolution - determined by display resolution (automatic scaling) and/or a multiple of the native EFB resolution // Ideal internal resolution - determined by display resolution (automatic scaling) and/or a multiple of the native EFB resolution
static int GetTargetWidth() { return s_target_width; } static int GetTargetWidth() { return s_target_width; }

View File

@ -76,7 +76,6 @@ void VideoConfig::Load(const char *ini_file)
iniFile.Get("Settings", "AnaglyphFocalAngle", &iAnaglyphFocalAngle, 0); iniFile.Get("Settings", "AnaglyphFocalAngle", &iAnaglyphFocalAngle, 0);
iniFile.Get("Settings", "EnablePixelLighting", &bEnablePixelLighting, 0); iniFile.Get("Settings", "EnablePixelLighting", &bEnablePixelLighting, 0);
iniFile.Get("Settings", "EnablePerPixelDepth", &bEnablePerPixelDepth, 0); iniFile.Get("Settings", "EnablePerPixelDepth", &bEnablePerPixelDepth, 0);
iniFile.Get("Settings", "EnableFastZcomploc", &bEnableFastZcomploc, 0);
iniFile.Get("Settings", "MSAA", &iMultisampleMode, 0); iniFile.Get("Settings", "MSAA", &iMultisampleMode, 0);
iniFile.Get("Settings", "EFBScale", &iEFBScale, 2); // native iniFile.Get("Settings", "EFBScale", &iEFBScale, 2); // native
@ -139,7 +138,6 @@ void VideoConfig::GameIniLoad(const char *ini_file)
iniFile.GetIfExists("Video_Settings", "AnaglyphFocalAngle", &iAnaglyphFocalAngle); iniFile.GetIfExists("Video_Settings", "AnaglyphFocalAngle", &iAnaglyphFocalAngle);
iniFile.GetIfExists("Video_Settings", "EnablePixelLighting", &bEnablePixelLighting); iniFile.GetIfExists("Video_Settings", "EnablePixelLighting", &bEnablePixelLighting);
iniFile.GetIfExists("Video_Settings", "EnablePerPixelDepth", &bEnablePerPixelDepth); iniFile.GetIfExists("Video_Settings", "EnablePerPixelDepth", &bEnablePerPixelDepth);
iniFile.GetIfExists("Video_Settings", "EnableFastZcomploc", &bEnableFastZcomploc);
iniFile.GetIfExists("Video_Settings", "MSAA", &iMultisampleMode); iniFile.GetIfExists("Video_Settings", "MSAA", &iMultisampleMode);
iniFile.GetIfExists("Video_Settings", "EFBScale", &iEFBScale); // integral iniFile.GetIfExists("Video_Settings", "EFBScale", &iEFBScale); // integral
iniFile.GetIfExists("Video_Settings", "DstAlphaPass", &bDstAlphaPass); iniFile.GetIfExists("Video_Settings", "DstAlphaPass", &bDstAlphaPass);
@ -211,7 +209,6 @@ void VideoConfig::Save(const char *ini_file)
iniFile.Set("Settings", "AnaglyphFocalAngle", iAnaglyphFocalAngle); iniFile.Set("Settings", "AnaglyphFocalAngle", iAnaglyphFocalAngle);
iniFile.Set("Settings", "EnablePixelLighting", bEnablePixelLighting); iniFile.Set("Settings", "EnablePixelLighting", bEnablePixelLighting);
iniFile.Set("Settings", "EnablePerPixelDepth", bEnablePerPixelDepth); iniFile.Set("Settings", "EnablePerPixelDepth", bEnablePerPixelDepth);
iniFile.Set("Settings", "EnableFastZcomploc", bEnableFastZcomploc);
iniFile.Set("Settings", "ShowEFBCopyRegions", bShowEFBCopyRegions); iniFile.Set("Settings", "ShowEFBCopyRegions", bShowEFBCopyRegions);
@ -281,7 +278,6 @@ void VideoConfig::GameIniSave(const char* default_ini, const char* game_ini)
SET_IF_DIFFERS("Video_Settings", "AnaglyphFocalAngle", iAnaglyphFocalAngle); SET_IF_DIFFERS("Video_Settings", "AnaglyphFocalAngle", iAnaglyphFocalAngle);
SET_IF_DIFFERS("Video_Settings", "EnablePixelLighting", bEnablePixelLighting); SET_IF_DIFFERS("Video_Settings", "EnablePixelLighting", bEnablePixelLighting);
SET_IF_DIFFERS("Video_Settings", "EnablePerPixelDepth", bEnablePerPixelDepth); SET_IF_DIFFERS("Video_Settings", "EnablePerPixelDepth", bEnablePerPixelDepth);
SET_IF_DIFFERS("Video_Settings", "EnableFastZcomploc", bEnableFastZcomploc);
SET_IF_DIFFERS("Video_Settings", "MSAA", iMultisampleMode); SET_IF_DIFFERS("Video_Settings", "MSAA", iMultisampleMode);
SET_IF_DIFFERS("Video_Settings", "EFBScale", iEFBScale); // integral SET_IF_DIFFERS("Video_Settings", "EFBScale", iEFBScale); // integral
SET_IF_DIFFERS("Video_Settings", "DstAlphaPass", bDstAlphaPass); SET_IF_DIFFERS("Video_Settings", "DstAlphaPass", bDstAlphaPass);

View File

@ -137,7 +137,6 @@ struct VideoConfig
bool bUseBBox; bool bUseBBox;
bool bEnablePixelLighting; bool bEnablePixelLighting;
bool bEnablePerPixelDepth; bool bEnablePerPixelDepth;
bool bEnableFastZcomploc;
int iLog; // CONF_ bits int iLog; // CONF_ bits
int iSaveTargetId; int iSaveTargetId;

View File

@ -1211,11 +1211,11 @@ void Renderer::RestoreAPIState()
BPFunctions::SetScissor(); BPFunctions::SetScissor();
} }
void Renderer::ApplyState(RenderStateMode mode) void Renderer::ApplyState(bool bUseDstAlpha)
{ {
HRESULT hr; HRESULT hr;
if (mode == RSM_UseDstAlpha) if (bUseDstAlpha)
{ {
// Colors should blend against SRC1_ALPHA // Colors should blend against SRC1_ALPHA
if (gx_state.blenddc.RenderTarget[0].SrcBlend == D3D11_BLEND_SRC_ALPHA) if (gx_state.blenddc.RenderTarget[0].SrcBlend == D3D11_BLEND_SRC_ALPHA)
@ -1275,7 +1275,7 @@ void Renderer::ApplyState(RenderStateMode mode)
D3D::stateman->Apply(); D3D::stateman->Apply();
if (mode == RSM_UseDstAlpha) if (bUseDstAlpha)
{ {
// restore actual state // restore actual state
SetBlendMode(false); SetBlendMode(false);
@ -1289,7 +1289,7 @@ void Renderer::ApplyState(RenderStateMode mode)
D3D::context->VSSetShader(VertexShaderCache::GetActiveShader(), NULL, 0); D3D::context->VSSetShader(VertexShaderCache::GetActiveShader(), NULL, 0);
} }
void Renderer::RestoreState(RenderStateMode mode) void Renderer::RestoreState()
{ {
ID3D11ShaderResourceView* shader_resources[8] = { NULL }; ID3D11ShaderResourceView* shader_resources[8] = { NULL };
D3D::context->PSSetShaderResources(0, 8, shader_resources); D3D::context->PSSetShaderResources(0, 8, shader_resources);

View File

@ -25,8 +25,8 @@ public:
void SetInterlacingMode(); void SetInterlacingMode();
// TODO: Fix confusing names (see ResetAPIState and RestoreAPIState) // TODO: Fix confusing names (see ResetAPIState and RestoreAPIState)
void ApplyState(RenderStateMode mode); void ApplyState(bool bUseDstAlpha);
void RestoreState(RenderStateMode mode); void RestoreState();
void ApplyCullDisable(); void ApplyCullDisable();
void RestoreCull(); void RestoreCull();

View File

@ -264,13 +264,13 @@ void VertexManager::vFlush()
unsigned int stride = g_nativeVertexFmt->GetVertexStride(); unsigned int stride = g_nativeVertexFmt->GetVertexStride();
g_nativeVertexFmt->SetupVertexPointers(); g_nativeVertexFmt->SetupVertexPointers();
g_renderer->ApplyState(useDstAlpha ? RSM_UseDstAlpha : RSM_None); g_renderer->ApplyState(useDstAlpha);
LoadBuffers(); LoadBuffers();
Draw(stride); Draw(stride);
GFX_DEBUGGER_PAUSE_AT(NEXT_FLUSH, true); GFX_DEBUGGER_PAUSE_AT(NEXT_FLUSH, true);
g_renderer->RestoreState(useDstAlpha ? RSM_UseDstAlpha : RSM_None); g_renderer->RestoreState();
shader_fail: shader_fail:
ResetBuffer(); ResetBuffer();

View File

@ -1204,43 +1204,19 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
XFBWrited = false; XFBWrited = false;
} }
void Renderer::ApplyState(RenderStateMode mode) void Renderer::ApplyState(bool bUseDstAlpha)
{ {
if(mode == RSM_Zcomploc) if (bUseDstAlpha)
{
D3D::ChangeRenderState(D3DRS_COLORWRITEENABLE, 0);
}
else if(mode == RSM_Multipass)
{
D3D::ChangeRenderState(D3DRS_ZENABLE, TRUE);
D3D::ChangeRenderState(D3DRS_ZWRITEENABLE, false);
D3D::ChangeRenderState(D3DRS_ZFUNC, D3DCMP_EQUAL);
}
else if (mode == RSM_UseDstAlpha)
{ {
D3D::ChangeRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA); D3D::ChangeRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA);
D3D::ChangeRenderState(D3DRS_ALPHABLENDENABLE, false); D3D::ChangeRenderState(D3DRS_ALPHABLENDENABLE, false);
} }
} }
void Renderer::RestoreState(RenderStateMode mode) void Renderer::RestoreState()
{ {
if(mode == RSM_Zcomploc) D3D::RefreshRenderState(D3DRS_COLORWRITEENABLE);
{ D3D::RefreshRenderState(D3DRS_ALPHABLENDENABLE);
D3D::RefreshRenderState(D3DRS_COLORWRITEENABLE);
}
else if(mode == RSM_Multipass)
{
D3D::RefreshRenderState(D3DRS_ALPHABLENDENABLE);
D3D::RefreshRenderState(D3DRS_ZENABLE);
D3D::RefreshRenderState(D3DRS_ZWRITEENABLE);
D3D::RefreshRenderState(D3DRS_ZFUNC);
}
else if(mode == RSM_UseDstAlpha)
{
D3D::RefreshRenderState(D3DRS_COLORWRITEENABLE);
D3D::RefreshRenderState(D3DRS_ALPHABLENDENABLE);
}
// TODO: Enable this code. Caused glitches for me however (neobrain) // TODO: Enable this code. Caused glitches for me however (neobrain)
// for (unsigned int i = 0; i < 8; ++i) // for (unsigned int i = 0; i < 8; ++i)

View File

@ -24,8 +24,8 @@ public:
void SetSamplerState(int stage,int texindex); void SetSamplerState(int stage,int texindex);
void SetInterlacingMode(); void SetInterlacingMode();
void ApplyState(RenderStateMode mode); void ApplyState(bool bUseDstAlpha);
void RestoreState(RenderStateMode mode); void RestoreState();
void RenderText(const char* pstr, int left, int top, u32 color); void RenderText(const char* pstr, int left, int top, u32 color);

View File

@ -154,9 +154,11 @@ void VertexManager::vFlush()
VertexShaderManager::SetConstants(); VertexShaderManager::SetConstants();
PixelShaderManager::SetConstants(); PixelShaderManager::SetConstants();
int stride = g_nativeVertexFmt->GetVertexStride(); if (!PixelShaderCache::SetShader(DSTALPHA_NONE,g_nativeVertexFmt->m_components))
g_nativeVertexFmt->SetupVertexPointers(); {
GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR,true,{printf("Fail to set pixel shader\n");});
goto shader_fail;
}
if (!VertexShaderCache::SetShader(g_nativeVertexFmt->m_components)) if (!VertexShaderCache::SetShader(g_nativeVertexFmt->m_components))
{ {
GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR,true,{printf("Fail to set vertex shader\n");}); GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR,true,{printf("Fail to set vertex shader\n");});
@ -164,11 +166,8 @@ void VertexManager::vFlush()
} }
if (!PixelShaderCache::SetShader(DSTALPHA_NONE,g_nativeVertexFmt->m_components)) int stride = g_nativeVertexFmt->GetVertexStride();
{ g_nativeVertexFmt->SetupVertexPointers();
GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR,true,{printf("Fail to set pixel shader\n");});
goto shader_fail;
}
Draw(stride); Draw(stride);
@ -176,35 +175,17 @@ void VertexManager::vFlush()
bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24; bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24;
if (useDstAlpha) if (useDstAlpha)
{ {
DWORD write = 0;
if (!PixelShaderCache::SetShader(DSTALPHA_ALPHA_PASS, g_nativeVertexFmt->m_components)) if (!PixelShaderCache::SetShader(DSTALPHA_ALPHA_PASS, g_nativeVertexFmt->m_components))
{ {
GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR,true,{printf("Fail to set pixel shader\n");}); GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR,true,{printf("Fail to set pixel shader\n");});
goto shader_fail; goto shader_fail;
} }
// update alpha only // update alpha only
g_renderer->ApplyState(RSM_UseDstAlpha); g_renderer->ApplyState(true);
if (bpmem.zmode.updateenable)
g_renderer->ApplyState(RSM_Multipass);
Draw(stride); Draw(stride);
g_renderer->RestoreState(RSM_UseDstAlpha); g_renderer->RestoreState();
if (bpmem.zmode.updateenable)
g_renderer->RestoreState(RSM_Multipass);
} }
bool UseZcomploc = bpmem.zcontrol.zcomploc && bpmem.zmode.updateenable && !g_ActiveConfig.bEnableFastZcomploc;
if (UseZcomploc)
{
if (!PixelShaderCache::SetShader(DSTALPHA_ZCOMPLOC,g_nativeVertexFmt->m_components))
{
GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR,true,{printf("Fail to set pixel shader\n");});
goto shader_fail;
}
g_renderer->ApplyState(RSM_Zcomploc);
Draw(stride);
g_renderer->RestoreState(RSM_Zcomploc);
}
GFX_DEBUGGER_PAUSE_AT(NEXT_FLUSH, true); GFX_DEBUGGER_PAUSE_AT(NEXT_FLUSH, true);
shader_fail: shader_fail:

View File

@ -632,43 +632,6 @@ void Renderer::SetScissorRect(const TargetRectangle& rc)
glScissor(rc.left, rc.bottom, rc.GetWidth(), rc.GetHeight()); glScissor(rc.left, rc.bottom, rc.GetWidth(), rc.GetHeight());
} }
void Renderer::ApplyState(RenderStateMode mode)
{
if(mode == RSM_Zcomploc)
{
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
}
else if(mode == RSM_Multipass)
{
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
glDepthFunc(GL_EQUAL);
}
else if (mode == RSM_UseDstAlpha)
{
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
glDisable(GL_BLEND);
}
}
void Renderer::RestoreState(RenderStateMode mode)
{
if(mode == RSM_Zcomploc)
{
SetColorMask();
}
else if(mode == RSM_Multipass)
{
SetDepthMode();
}
else if (mode == RSM_UseDstAlpha)
{
SetColorMask();
if (bpmem.blendmode.blendenable || bpmem.blendmode.subtract)
glEnable(GL_BLEND);
}
}
void Renderer::SetColorMask() void Renderer::SetColorMask()
{ {
// Only enable alpha channel if it's supported by the current EFB format // Only enable alpha channel if it's supported by the current EFB format

View File

@ -26,8 +26,9 @@ public:
void SetSamplerState(int stage,int texindex); void SetSamplerState(int stage,int texindex);
void SetInterlacingMode(); void SetInterlacingMode();
void ApplyState(RenderStateMode mode); // TODO: Implement and use these
void RestoreState(RenderStateMode mode); void ApplyState(bool bUseDstAlpha) {}
void RestoreState() {}
void RenderText(const char* pstr, int left, int top, u32 color); void RenderText(const char* pstr, int left, int top, u32 color);
void DrawDebugInfo(); void DrawDebugInfo();

View File

@ -224,26 +224,17 @@ void VertexManager::vFlush()
ps = PixelShaderCache::SetShader(DSTALPHA_ALPHA_PASS,g_nativeVertexFmt->m_components); ps = PixelShaderCache::SetShader(DSTALPHA_ALPHA_PASS,g_nativeVertexFmt->m_components);
if (ps) PixelShaderCache::SetCurrentShader(ps->glprogid); if (ps) PixelShaderCache::SetCurrentShader(ps->glprogid);
g_renderer->ApplyState(RSM_UseDstAlpha); // only update alpha
if (bpmem.zmode.updateenable) glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
g_renderer->ApplyState(RSM_Multipass);
glDisable(GL_BLEND);
Draw(); Draw();
// restore color mask
g_renderer->SetColorMask();
g_renderer->RestoreState(RSM_UseDstAlpha); if (bpmem.blendmode.blendenable || bpmem.blendmode.subtract)
if (bpmem.zmode.updateenable) glEnable(GL_BLEND);
g_renderer->RestoreState(RSM_Multipass);
}
bool UseZcomploc = bpmem.zcontrol.zcomploc && bpmem.zmode.updateenable && !g_ActiveConfig.bEnableFastZcomploc;
if (UseZcomploc)
{
FRAGMENTSHADER* ps = PixelShaderCache::SetShader(DSTALPHA_ZCOMPLOC,g_nativeVertexFmt->m_components);
if (ps) PixelShaderCache::SetCurrentShader(ps->glprogid);
g_renderer->ApplyState(RSM_Zcomploc);
Draw();
g_renderer->RestoreState(RSM_Zcomploc);
} }
GFX_DEBUGGER_PAUSE_AT(NEXT_FLUSH, true); GFX_DEBUGGER_PAUSE_AT(NEXT_FLUSH, true);