diff --git a/src/client/d3d9_device.cpp b/src/client/d3d9_device.cpp index 1e22d35..00535bf 100644 --- a/src/client/d3d9_device.cpp +++ b/src/client/d3d9_device.cpp @@ -3801,14 +3801,22 @@ void Direct3DDevice9Ex_LSS::initImplicitSwapchain(const D3DPRESENT_P template void Direct3DDevice9Ex_LSS::initImplicitRenderTarget() { IDirect3DSurface9* pRenderTarget = nullptr; - CreateRenderTarget(GET_PRES_PARAM().BackBufferWidth, - GET_PRES_PARAM().BackBufferHeight, - GET_PRES_PARAM().BackBufferFormat, - GET_PRES_PARAM().MultiSampleType, - GET_PRES_PARAM().MultiSampleQuality, - false, - &pRenderTarget, - nullptr); + + // Creating a place-holder surface + D3DSURFACE_DESC desc; + desc.Width = GET_PRES_PARAM().BackBufferWidth; + desc.Height = GET_PRES_PARAM().BackBufferHeight; + desc.Format = GET_PRES_PARAM().BackBufferFormat; + desc.MultiSampleType = GET_PRES_PARAM().MultiSampleType; + desc.MultiSampleQuality = GET_PRES_PARAM().MultiSampleQuality; + desc.Usage = D3DUSAGE_RENDERTARGET; + desc.Pool = D3DPOOL_DEFAULT; + desc.Type = D3DRTYPE_SURFACE; + + // Insert our own IDirect3DSurface9 interface implementation + Direct3DSurface9_LSS* pLssSurface = trackWrapper(new Direct3DSurface9_LSS(this, desc)); + pRenderTarget = (IDirect3DSurface9*) pLssSurface; + m_pImplicitRenderTarget = bridge_cast(pRenderTarget); { ClientMessage c(Commands::IDirect3DDevice9Ex_LinkBackBuffer, getId()); @@ -3822,14 +3830,21 @@ template void Direct3DDevice9Ex_LSS::initImplicitDepthStencil() { assert(GET_PRES_PARAM().EnableAutoDepthStencil); IDirect3DSurface9* pShadowDepthBuffer = nullptr; - CreateDepthStencilSurface(GET_PRES_PARAM().BackBufferWidth, - GET_PRES_PARAM().BackBufferHeight, - GET_PRES_PARAM().AutoDepthStencilFormat, - GET_PRES_PARAM().MultiSampleType, - GET_PRES_PARAM().MultiSampleQuality, - false, - &pShadowDepthBuffer, - nullptr); + + // Creating a place-holder surface + D3DSURFACE_DESC desc; + desc.Width = GET_PRES_PARAM().BackBufferWidth; + desc.Height = GET_PRES_PARAM().BackBufferHeight; + desc.Format = GET_PRES_PARAM().AutoDepthStencilFormat; + desc.MultiSampleType = GET_PRES_PARAM().MultiSampleType; + desc.MultiSampleQuality = GET_PRES_PARAM().MultiSampleQuality; + desc.Usage = D3DUSAGE_DEPTHSTENCIL; + desc.Pool = D3DPOOL_DEFAULT; + desc.Type = D3DRTYPE_SURFACE; + + Direct3DSurface9_LSS* pLssSurface = trackWrapper(new Direct3DSurface9_LSS(this, desc)); + pShadowDepthBuffer = (IDirect3DSurface9*) pLssSurface; + m_pImplicitDepthStencil = bridge_cast(pShadowDepthBuffer); { ClientMessage c(Commands::IDirect3DDevice9Ex_LinkAutoDepthStencil, getId()); diff --git a/src/client/d3d9_volume.cpp b/src/client/d3d9_volume.cpp index dfddea7..11704cf 100644 --- a/src/client/d3d9_volume.cpp +++ b/src/client/d3d9_volume.cpp @@ -62,7 +62,7 @@ void Direct3DVolume9_LSS::onDestroy() { // are completely owned and managed by their parent container, and so only need // to be unlinked from x64 counterpart to prevent hash collisions at server side. const auto command = isStandalone() ? Commands::IDirect3DVolume9_Destroy : - Commands::Bridge_UnlinkResource; + Commands::Bridge_UnlinkVolumeResource; ClientMessage { command, getId() }; } diff --git a/src/server/main.cpp b/src/server/main.cpp index a4def7f..029ca6c 100644 --- a/src/server/main.cpp +++ b/src/server/main.cpp @@ -2767,7 +2767,12 @@ void ProcessDeviceCommandQueue() { gpD3DResources.erase(pHandle); break; } - + case Bridge_UnlinkVolumeResource: + { + GET_HND(pHandle); + gpD3DVolumes.erase(pHandle); + break; + } /* * BridgeApi commands */ diff --git a/src/util/util_commands.h b/src/util/util_commands.h index a9b6b2d..e38f874 100644 --- a/src/util/util_commands.h +++ b/src/util/util_commands.h @@ -59,7 +59,7 @@ namespace Commands { // desposed of, or known to be released before the unlink to // prevent leaks. Bridge_UnlinkResource, - + Bridge_UnlinkVolumeResource, // These are not actually official D3D9 API calls. IDirect3DDevice9Ex_LinkSwapchain, IDirect3DDevice9Ex_LinkBackBuffer, @@ -493,6 +493,7 @@ namespace Commands { case Bridge_SharedHeap_Dealloc: return "SharedHeap_Dealloc"; case Bridge_UnlinkResource: return "Bridge_UnlinkResource"; + case Bridge_UnlinkVolumeResource: return "Bridge_UnlinkVolumeResource"; case IDirect3DDevice9Ex_LinkSwapchain: return "IDirect3DDevice9Ex_LinkSwapchain"; case IDirect3DDevice9Ex_LinkBackBuffer: return "IDirect3DDevice9Ex_LinkBackBuffer";