As requested apply the same changes made by rev 6958822f19 to the D3D9 backend.

handle v-sync changed while the emulation is running.
thanks to neobrain for pointing the missing functionality.
This commit is contained in:
Rodolfo Bogado 2013-04-01 14:23:48 -03:00
parent 49d809ac0e
commit a562c7c1f6
1 changed files with 22 additions and 10 deletions

View File

@ -68,7 +68,7 @@ static u32 s_blendMode;
static u32 s_LastAA;
static bool IS_AMD;
static float m_fMaxPointSize;
static bool s_vsync;
static char *st;
static LPDIRECT3DSURFACE9 ScreenShootMEMSurface = NULL;
@ -190,7 +190,8 @@ Renderer::Renderer()
D3D::dev->CreateOffscreenPlainSurface(s_backbuffer_width,s_backbuffer_height, D3DFMT_X8R8G8B8, D3DPOOL_SYSTEMMEM, &ScreenShootMEMSurface, NULL );
D3D::SetRenderState(D3DRS_POINTSCALEENABLE,false);
m_fMaxPointSize = D3D::GetCaps().MaxPointSize;
// Handle VSync on/off
s_vsync = g_ActiveConfig.IsVSync();
}
Renderer::~Renderer()
@ -452,7 +453,8 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data)
}
else if(type == PEEK_COLOR)
{
// TODO: Can't we directly StretchRect to System buf?
// We can't directly StretchRect to System buf because is not suported by all implementations
// this is the only safe path that works in most cases
hr = D3D::dev->StretchRect(pEFBSurf, &RectToLock, pBufferRT, NULL, D3DTEXF_NONE);
D3D::dev->GetRenderTargetData(pBufferRT, pSystemBuf);
@ -1037,7 +1039,8 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
DLCache::ProgressiveCleanup();
TextureCache::Cleanup();
// Flip/present backbuffer to frontbuffer here
D3D::Present();
// Enable configuration changes
UpdateActiveConfig();
TextureCache::OnConfigChanged(g_ActiveConfig);
@ -1096,8 +1099,15 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
// New frame
stats.ResetFrame();
// Flip/present backbuffer to frontbuffer here
D3D::Present();
// Handle vsync changes during execution
if(s_vsync != g_ActiveConfig.IsVSync())
{
s_vsync = g_ActiveConfig.IsVSync();
TeardownDeviceObjects();
D3D::Reset();
// device objects lost, so recreate all of them
SetupDeviceObjects();
}
D3D::BeginFrame();
RestoreAPIState();
@ -1113,14 +1123,16 @@ void Renderer::ApplyState(bool bUseDstAlpha)
{
if (bUseDstAlpha)
{
// TODO: WTF is this crap? We're enabling color writing regardless of the actual GPU state here...
// If we get here we are sure that we are using dst alpha pass. (bpmem.dstalpha.enable)
// Alpha write is enabled. (because bpmem.blendmode.alphaupdate && bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24)
// We must disable blend because we want to write alpha value directly to the alpha channel without modifications.
D3D::ChangeRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA);
D3D::ChangeRenderState(D3DRS_ALPHABLENDENABLE, false);
if(bpmem.zmode.testenable && bpmem.zmode.updateenable)
{
//This is needed to draw to the correct pixels in multi-pass algorithms
//this avoid z-figthing and grants that you write to the same pixels
//affected by the last pass
// This is needed to draw to the correct pixels in multi-pass algorithms
// to avoid z-figthing and grants that you write to the same pixels
// affected by the last pass
D3D::ChangeRenderState(D3DRS_ZWRITEENABLE, false);
D3D::ChangeRenderState(D3DRS_ZFUNC, D3DCMP_EQUAL);
}