@@ -1817,7 +1817,7 @@ HRESULT m_IDirectDrawSurfaceX::GetDC(HDC FAR* lphDC, DWORD MipMapLevel)
18171817 CheckOnlyInterfaceSafty (this , __FUNCTION__, false );
18181818
18191819 // Check if render target should use shadow
1820- if (MipMapLevel == 0 && (surface. Usage & D3DUSAGE_RENDERTARGET) && ! IsUsingShadowSurface ( ))
1820+ if (ShouldUseShadowSurface (MipMapLevel ))
18211821 {
18221822 SetRenderTargetShadow ();
18231823 }
@@ -2496,18 +2496,15 @@ HRESULT m_IDirectDrawSurfaceX::Lock2(LPRECT lpDestRect, LPDDSURFACEDESC2 lpDDSur
24962496 CheckOnlyInterfaceSafty (this , __FUNCTION__, false );
24972497
24982498 // Check if render target should use shadow
2499- if (MipMapLevel == 0 && ( surface.Usage & D3DUSAGE_RENDERTARGET) )
2499+ if (surface.IsLockable && !Config. DdrawUseShadowSurface )
25002500 {
2501- if (surface.IsLockable )
2502- {
2503- // Don't use shadow for Lock()
2504- // Some games write to surface without locking so we don't want to give them a shadow surface or it could make the shadow surface out of sync
2505- PrepareRenderTarget ();
2506- }
2507- else if (!IsUsingShadowSurface ())
2508- {
2509- SetRenderTargetShadow ();
2510- }
2501+ // Don't use shadow for Lock()
2502+ // Some games write to surface without locking so we don't want to give them a shadow surface or it could make the shadow surface out of sync
2503+ PrepareRenderTarget ();
2504+ }
2505+ else if (ShouldUseShadowSurface (MipMapLevel))
2506+ {
2507+ SetRenderTargetShadow ();
25112508 }
25122509
25132510 // Emulated surface
@@ -4511,8 +4508,7 @@ HRESULT m_IDirectDrawSurfaceX::CreateD9Surface()
45114508 {
45124509 surface.Type = D3DTYPE_RENDERTARGET;
45134510 ddrawParent->GetMultiSampleTypeQuality (surface.MultiSampleType , surface.MultiSampleQuality );
4514- BOOL IsLockable = (surfaceDesc2.ddsCaps .dwCaps2 & DDSCAPS2_NOTUSERLOCKABLE) == 0 && surface.MultiSampleType == D3DMULTISAMPLE_NONE;
4515- surface.IsLockable = IsLockable != FALSE ;
4511+ BOOL IsLockable = surface.MultiSampleType == D3DMULTISAMPLE_NONE && !Config.DdrawUseShadowSurface ;
45164512 if (FAILED ((*d3d9Device)->CreateRenderTarget (surface.Width , surface.Height , Format, surface.MultiSampleType , surface.MultiSampleQuality , IsLockable, &surface.Surface , nullptr )) &&
45174513 FAILED ((*d3d9Device)->CreateRenderTarget (surface.Width , surface.Height , GetFailoverFormat (Format), surface.MultiSampleType , surface.MultiSampleQuality , IsLockable, &surface.Surface , nullptr )))
45184514 {
@@ -4711,7 +4707,7 @@ HRESULT m_IDirectDrawSurfaceX::CreateD9Surface()
47114707 for (UINT Level = 0 ; Level < LostDeviceBackup.size (); Level++)
47124708 {
47134709 // Check if render target should use shadow
4714- if (Level == 0 && (surface. Usage & D3DUSAGE_RENDERTARGET) && !surface. IsLockable && ! IsUsingShadowSurface ( ))
4710+ if (ShouldUseShadowSurface (Level ))
47154711 {
47164712 SetRenderTargetShadow ();
47174713 }
@@ -5422,7 +5418,7 @@ void m_IDirectDrawSurfaceX::ReleaseD9Surface(bool BackupData, bool ResetSurface)
54225418 for (UINT Level = 0 ; Level < ((IsMipMapAutogen () || !MaxMipMapLevel) ? 1 : MaxMipMapLevel); Level++)
54235419 {
54245420 // Check if render target should use shadow
5425- if (Level == 0 && (surface. Usage & D3DUSAGE_RENDERTARGET) && !surface. IsLockable && ! IsUsingShadowSurface ( ))
5421+ if (ShouldUseShadowSurface (Level ))
54265422 {
54275423 SetRenderTargetShadow ();
54285424 }
@@ -7009,13 +7005,13 @@ HRESULT m_IDirectDrawSurfaceX::CopySurface(m_IDirectDrawSurfaceX* pSourceSurface
70097005 }
70107006
70117007 // Check if source render target should use shadow
7012- if (SrcMipMapLevel == 0 && ( pSourceSurface->surface . Usage & D3DUSAGE_RENDERTARGET) && !pSourceSurface-> IsUsingShadowSurface ( ))
7008+ if (pSourceSurface->ShouldUseShadowSurface (SrcMipMapLevel ))
70137009 {
70147010 pSourceSurface->SetRenderTargetShadow ();
70157011 }
70167012
70177013 // Check if render target should use shadow
7018- if (MipMapLevel == 0 && (surface. Usage & D3DUSAGE_RENDERTARGET) && ! IsUsingShadowSurface ( ))
7014+ if (ShouldUseShadowSurface (MipMapLevel ))
70197015 {
70207016 SetRenderTargetShadow ();
70217017 }
0 commit comments