Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit 72385cb

Browse files
committed
Merge branch 'dev/lvengesanam/optimize_device-reset_api_call' into 'main'
Optimize Direct3DDevice9::Reset api call on bridge See merge request lightspeedrtx/bridge-remix-nv!142
2 parents 39e4a83 + 9490ed2 commit 72385cb

File tree

4 files changed

+40
-19
lines changed

4 files changed

+40
-19
lines changed

src/client/d3d9_device.cpp

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3801,14 +3801,22 @@ void Direct3DDevice9Ex_LSS<EnableSync>::initImplicitSwapchain(const D3DPRESENT_P
38013801
template<bool EnableSync>
38023802
void Direct3DDevice9Ex_LSS<EnableSync>::initImplicitRenderTarget() {
38033803
IDirect3DSurface9* pRenderTarget = nullptr;
3804-
CreateRenderTarget(GET_PRES_PARAM().BackBufferWidth,
3805-
GET_PRES_PARAM().BackBufferHeight,
3806-
GET_PRES_PARAM().BackBufferFormat,
3807-
GET_PRES_PARAM().MultiSampleType,
3808-
GET_PRES_PARAM().MultiSampleQuality,
3809-
false,
3810-
&pRenderTarget,
3811-
nullptr);
3804+
3805+
// Creating a place-holder surface
3806+
D3DSURFACE_DESC desc;
3807+
desc.Width = GET_PRES_PARAM().BackBufferWidth;
3808+
desc.Height = GET_PRES_PARAM().BackBufferHeight;
3809+
desc.Format = GET_PRES_PARAM().BackBufferFormat;
3810+
desc.MultiSampleType = GET_PRES_PARAM().MultiSampleType;
3811+
desc.MultiSampleQuality = GET_PRES_PARAM().MultiSampleQuality;
3812+
desc.Usage = D3DUSAGE_RENDERTARGET;
3813+
desc.Pool = D3DPOOL_DEFAULT;
3814+
desc.Type = D3DRTYPE_SURFACE;
3815+
3816+
// Insert our own IDirect3DSurface9 interface implementation
3817+
Direct3DSurface9_LSS* pLssSurface = trackWrapper(new Direct3DSurface9_LSS(this, desc));
3818+
pRenderTarget = (IDirect3DSurface9*) pLssSurface;
3819+
38123820
m_pImplicitRenderTarget = bridge_cast<Direct3DSurface9_LSS*>(pRenderTarget);
38133821
{
38143822
ClientMessage c(Commands::IDirect3DDevice9Ex_LinkBackBuffer, getId());
@@ -3822,14 +3830,21 @@ template<bool EnableSync>
38223830
void Direct3DDevice9Ex_LSS<EnableSync>::initImplicitDepthStencil() {
38233831
assert(GET_PRES_PARAM().EnableAutoDepthStencil);
38243832
IDirect3DSurface9* pShadowDepthBuffer = nullptr;
3825-
CreateDepthStencilSurface(GET_PRES_PARAM().BackBufferWidth,
3826-
GET_PRES_PARAM().BackBufferHeight,
3827-
GET_PRES_PARAM().AutoDepthStencilFormat,
3828-
GET_PRES_PARAM().MultiSampleType,
3829-
GET_PRES_PARAM().MultiSampleQuality,
3830-
false,
3831-
&pShadowDepthBuffer,
3832-
nullptr);
3833+
3834+
// Creating a place-holder surface
3835+
D3DSURFACE_DESC desc;
3836+
desc.Width = GET_PRES_PARAM().BackBufferWidth;
3837+
desc.Height = GET_PRES_PARAM().BackBufferHeight;
3838+
desc.Format = GET_PRES_PARAM().AutoDepthStencilFormat;
3839+
desc.MultiSampleType = GET_PRES_PARAM().MultiSampleType;
3840+
desc.MultiSampleQuality = GET_PRES_PARAM().MultiSampleQuality;
3841+
desc.Usage = D3DUSAGE_DEPTHSTENCIL;
3842+
desc.Pool = D3DPOOL_DEFAULT;
3843+
desc.Type = D3DRTYPE_SURFACE;
3844+
3845+
Direct3DSurface9_LSS* pLssSurface = trackWrapper(new Direct3DSurface9_LSS(this, desc));
3846+
pShadowDepthBuffer = (IDirect3DSurface9*) pLssSurface;
3847+
38333848
m_pImplicitDepthStencil = bridge_cast<Direct3DSurface9_LSS*>(pShadowDepthBuffer);
38343849
{
38353850
ClientMessage c(Commands::IDirect3DDevice9Ex_LinkAutoDepthStencil, getId());

src/client/d3d9_volume.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void Direct3DVolume9_LSS::onDestroy() {
6262
// are completely owned and managed by their parent container, and so only need
6363
// to be unlinked from x64 counterpart to prevent hash collisions at server side.
6464
const auto command = isStandalone() ? Commands::IDirect3DVolume9_Destroy :
65-
Commands::Bridge_UnlinkResource;
65+
Commands::Bridge_UnlinkVolumeResource;
6666

6767
ClientMessage { command, getId() };
6868
}

src/server/main.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2767,7 +2767,12 @@ void ProcessDeviceCommandQueue() {
27672767
gpD3DResources.erase(pHandle);
27682768
break;
27692769
}
2770-
2770+
case Bridge_UnlinkVolumeResource:
2771+
{
2772+
GET_HND(pHandle);
2773+
gpD3DVolumes.erase(pHandle);
2774+
break;
2775+
}
27712776
/*
27722777
* BridgeApi commands
27732778
*/

src/util/util_commands.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ namespace Commands {
5959
// desposed of, or known to be released before the unlink to
6060
// prevent leaks.
6161
Bridge_UnlinkResource,
62-
62+
Bridge_UnlinkVolumeResource,
6363
// These are not actually official D3D9 API calls.
6464
IDirect3DDevice9Ex_LinkSwapchain,
6565
IDirect3DDevice9Ex_LinkBackBuffer,
@@ -493,6 +493,7 @@ namespace Commands {
493493
case Bridge_SharedHeap_Dealloc: return "SharedHeap_Dealloc";
494494

495495
case Bridge_UnlinkResource: return "Bridge_UnlinkResource";
496+
case Bridge_UnlinkVolumeResource: return "Bridge_UnlinkVolumeResource";
496497

497498
case IDirect3DDevice9Ex_LinkSwapchain: return "IDirect3DDevice9Ex_LinkSwapchain";
498499
case IDirect3DDevice9Ex_LinkBackBuffer: return "IDirect3DDevice9Ex_LinkBackBuffer";

0 commit comments

Comments
 (0)