From beac314243e7dc40a4617d2020628e708a8281d9 Mon Sep 17 00:00:00 2001 From: PatrickvL Date: Wed, 25 Nov 2020 21:33:46 +0100 Subject: [PATCH] Processed review remarks --- src/core/hle/D3D8/Direct3D9/Direct3D9.cpp | 37 ++++++++--------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp index be215a2ae..159862beb 100644 --- a/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp +++ b/src/core/hle/D3D8/Direct3D9/Direct3D9.cpp @@ -5689,44 +5689,31 @@ void CreateHostResource(xbox::X_D3DResource *pResource, DWORD D3DUsage, int iTex // Create the surface/volume/(volume/cube/)texture switch (XboxResourceType) { case xbox::X_D3DRTYPE_SURFACE: { - if (D3DUsage & D3DUSAGE_RENDERTARGET) { - hRet = g_pD3DDevice->CreateTexture(dwWidth * g_RenderScaleFactor, dwHeight * g_RenderScaleFactor, 1, D3DUSAGE_RENDERTARGET, - PCFormat, - D3DPOOL_DEFAULT, // Pool - &pNewHostTexture, - nullptr // pSharedHandle - ); - DEBUG_D3DRESULT(hRet, "g_pD3DDevice->CreateTexture"); - - if (hRet == D3D_OK) { - hRet = pNewHostTexture->GetSurfaceLevel(0, &pNewHostSurface); - DEBUG_D3DRESULT(hRet, "pNewHostTexture->pNewHostSurface"); - pNewHostTexture->Release(); - pNewHostTexture = nullptr; - } - } else if (D3DUsage & D3DUSAGE_DEPTHSTENCIL) { hRet = g_pD3DDevice->CreateDepthStencilSurface(dwWidth * g_RenderScaleFactor, dwHeight * g_RenderScaleFactor, PCFormat, g_EmuCDPD.HostPresentationParameters.MultiSampleType, 0, // MultisampleQuality false, // Discard &pNewHostSurface, - nullptr + nullptr // pSharedHandle ); DEBUG_D3DRESULT(hRet, "g_pD3DDevice->CreateDepthStencilSurface"); } else { - hRet = g_pD3DDevice->CreateTexture(dwWidth * g_RenderScaleFactor, dwHeight * g_RenderScaleFactor, 1, D3DUSAGE_RENDERTARGET, + // Note : This handles both (D3DUsage & D3DUSAGE_RENDERTARGET) and otherwise alike + hRet = g_pD3DDevice->CreateTexture(dwWidth * g_RenderScaleFactor, dwHeight * g_RenderScaleFactor, + 1, // Levels + D3DUSAGE_RENDERTARGET, // Usage always as render target PCFormat, - D3DPOOL_DEFAULT, // Pool + D3DPool, // D3DPOOL_DEFAULT &pNewHostTexture, nullptr // pSharedHandle ); DEBUG_D3DRESULT(hRet, "g_pD3DDevice->CreateTexture"); if (hRet == D3D_OK) { - hRet = pNewHostTexture->GetSurfaceLevel(0, &pNewHostSurface); - DEBUG_D3DRESULT(hRet, "pNewHostTexture->pNewHostSurface"); + HRESULT hRet2 = pNewHostTexture->GetSurfaceLevel(0, &pNewHostSurface); + DEBUG_D3DRESULT(hRet2, "pNewHostTexture->pNewHostSurface"); pNewHostTexture->Release(); pNewHostTexture = nullptr; } @@ -5740,7 +5727,7 @@ void CreateHostResource(xbox::X_D3DResource *pResource, DWORD D3DUsage, int iTex DXGetErrorString(hRet), DXGetErrorDescription(hRet)); } else { - EmuLog(LOG_LEVEL::WARNING, "CreateImageSurface Failed\n\nError: %s\nDesc: %s", + EmuLog(LOG_LEVEL::WARNING, "CreateTexture Failed\n\nError: %s\nDesc: %s", DXGetErrorString(hRet), DXGetErrorDescription(hRet)); } @@ -6966,8 +6953,8 @@ IDirect3DBaseTexture* CxbxConvertXboxSurfaceToHostTexture(xbox::X_D3DBaseTexture return nullptr; } - IDirect3DTexture* pNewHostTexture = nullptr; - auto hRet = pHostSurface->GetContainer(__uuidof(IDirect3DTexture9), (void**)&pNewHostTexture); + IDirect3DBaseTexture* pNewHostBaseTexture = nullptr; + auto hRet = pHostSurface->GetContainer(IID_PPV_ARGS(&pNewHostBaseTexture)); DEBUG_D3DRESULT(hRet, "pHostSurface->GetContainer"); if (FAILED(hRet)) { @@ -6975,7 +6962,7 @@ IDirect3DBaseTexture* CxbxConvertXboxSurfaceToHostTexture(xbox::X_D3DBaseTexture return nullptr; } - return (IDirect3DBaseTexture*)pNewHostTexture; // return it as a base texture + return pNewHostBaseTexture; } void CxbxUpdateHostTextures()