diff --git a/src/d3d8/d3d8_buffer.h b/src/d3d8/d3d8_buffer.h index be5ca8451..3391dbff1 100644 --- a/src/d3d8/d3d8_buffer.h +++ b/src/d3d8/d3d8_buffer.h @@ -1,6 +1,7 @@ #pragma once #include "d3d8_include.h" +#include "d3d8_options.h" #include "d3d8_resource.h" namespace dxvk { diff --git a/src/d3d8/d3d8_surface.cpp b/src/d3d8/d3d8_surface.cpp index 8d7c970bb..fe3d63d07 100644 --- a/src/d3d8/d3d8_surface.cpp +++ b/src/d3d8/d3d8_surface.cpp @@ -2,25 +2,88 @@ #include "d3d8_surface.h" #include "d3d8_device.h" +#include "d3d8_d3d9_util.h" + namespace dxvk { - Com D3D8Surface::CreateBlitImage() { - d3d9::D3DSURFACE_DESC desc; - GetD3D9()->GetDesc(&desc); + D3D8Surface::D3D8Surface( + D3D8Device* pDevice, + IDirect3DBaseTexture8* pTexture, + Com&& pSurface) + : D3D8SurfaceBase (pDevice, std::move(pSurface), pTexture) { + } - // NOTE: This adds a D3DPOOL_DEFAULT resource to the - // device, which counts as losable during device reset - Com image = nullptr; - HRESULT res = GetParent()->GetD3D9()->CreateRenderTarget( - desc.Width, desc.Height, desc.Format, - d3d9::D3DMULTISAMPLE_NONE, 0, - FALSE, - &image, - NULL); - - if (FAILED(res)) - throw new DxvkError("D3D8: Failed to create blit image"); - - return image; + // A surface does not need to be attached to a texture + D3D8Surface::D3D8Surface( + D3D8Device* pDevice, + Com&& pSurface) + : D3D8Surface (pDevice, nullptr, std::move(pSurface)) { + } + + D3DRESOURCETYPE STDMETHODCALLTYPE D3D8Surface::GetType() { + return D3DRESOURCETYPE(GetD3D9()->GetType()); + } + + HRESULT STDMETHODCALLTYPE D3D8Surface::GetDesc(D3DSURFACE_DESC* pDesc) { + if (unlikely(pDesc == nullptr)) + return D3DERR_INVALIDCALL; + + d3d9::D3DSURFACE_DESC desc; + HRESULT res = GetD3D9()->GetDesc(&desc); + + if (likely(SUCCEEDED(res))) + ConvertSurfaceDesc8(&desc, pDesc); + + return res; + } + + HRESULT STDMETHODCALLTYPE D3D8Surface::LockRect( + D3DLOCKED_RECT* pLockedRect, + CONST RECT* pRect, + DWORD Flags) { + return GetD3D9()->LockRect((d3d9::D3DLOCKED_RECT*)pLockedRect, pRect, Flags); + } + + HRESULT STDMETHODCALLTYPE D3D8Surface::UnlockRect() { + return GetD3D9()->UnlockRect(); + } + + HRESULT STDMETHODCALLTYPE D3D8Surface::GetDC(HDC* phDC) { + return GetD3D9()->GetDC(phDC); + } + + HRESULT STDMETHODCALLTYPE D3D8Surface::ReleaseDC(HDC hDC) { + return GetD3D9()->ReleaseDC(hDC); + } + + // TODO: Consider creating only one texture to + // encompass all surface levels of a texture. + Com D3D8Surface::GetBlitImage() { + if (unlikely(m_blitImage == nullptr)) { + m_blitImage = CreateBlitImage(); } + + return m_blitImage; + } + + Com D3D8Surface::CreateBlitImage() { + d3d9::D3DSURFACE_DESC desc; + GetD3D9()->GetDesc(&desc); + + // NOTE: This adds a D3DPOOL_DEFAULT resource to the + // device, which counts as losable during device reset + Com image = nullptr; + HRESULT res = GetParent()->GetD3D9()->CreateRenderTarget( + desc.Width, desc.Height, desc.Format, + d3d9::D3DMULTISAMPLE_NONE, 0, + FALSE, + &image, + NULL); + + if (FAILED(res)) + throw new DxvkError("D3D8: Failed to create blit image"); + + return image; + } + } \ No newline at end of file diff --git a/src/d3d8/d3d8_surface.h b/src/d3d8/d3d8_surface.h index 6493f7c94..c57d15959 100644 --- a/src/d3d8/d3d8_surface.h +++ b/src/d3d8/d3d8_surface.h @@ -2,7 +2,6 @@ #include "d3d8_include.h" #include "d3d8_subresource.h" -#include "d3d8_d3d9_util.h" namespace dxvk { @@ -16,72 +15,39 @@ namespace dxvk { D3D8Surface( D3D8Device* pDevice, IDirect3DBaseTexture8* pTexture, - Com&& pSurface) - : D3D8SurfaceBase (pDevice, std::move(pSurface), pTexture) { - } + Com&& pSurface); - // A surface does not need to be attached to a texture D3D8Surface( D3D8Device* pDevice, - Com&& pSurface) - : D3D8Surface (pDevice, nullptr, std::move(pSurface)) { - } + Com&& pSurface); - D3DRESOURCETYPE STDMETHODCALLTYPE GetType() { - return D3DRESOURCETYPE(GetD3D9()->GetType()); - } + D3DRESOURCETYPE STDMETHODCALLTYPE GetType(); - HRESULT STDMETHODCALLTYPE GetDesc(D3DSURFACE_DESC* pDesc) { - if (unlikely(pDesc == nullptr)) - return D3DERR_INVALIDCALL; + HRESULT STDMETHODCALLTYPE GetDesc(D3DSURFACE_DESC* pDesc); - d3d9::D3DSURFACE_DESC desc; - HRESULT res = GetD3D9()->GetDesc(&desc); + HRESULT STDMETHODCALLTYPE LockRect( + D3DLOCKED_RECT* pLockedRect, + CONST RECT* pRect, + DWORD Flags); - if (likely(SUCCEEDED(res))) - ConvertSurfaceDesc8(&desc, pDesc); + HRESULT STDMETHODCALLTYPE UnlockRect(); - return res; - } + HRESULT STDMETHODCALLTYPE GetDC(HDC* phDC); - HRESULT STDMETHODCALLTYPE LockRect(D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags) { - return GetD3D9()->LockRect((d3d9::D3DLOCKED_RECT*)pLockedRect, pRect, Flags); - } - - HRESULT STDMETHODCALLTYPE UnlockRect() { - return GetD3D9()->UnlockRect(); - } - - HRESULT STDMETHODCALLTYPE GetDC(HDC* phDC) { - return GetD3D9()->GetDC(phDC); - } - - HRESULT STDMETHODCALLTYPE ReleaseDC(HDC hDC) { - return GetD3D9()->ReleaseDC(hDC); - } - - public: + HRESULT STDMETHODCALLTYPE ReleaseDC(HDC hDC); /** * \brief Allocate or reuse an image of the same size * as this texture for performing blit into system mem. - * - * TODO: Consider creating only one texture to - * encompass all surface levels of a texture. */ - Com GetBlitImage() { - if (unlikely(m_blitImage == nullptr)) { - m_blitImage = CreateBlitImage(); - } - - return m_blitImage; - } - + Com GetBlitImage(); private: + Com CreateBlitImage(); - Com m_blitImage = nullptr; + Com m_blitImage; }; + } \ No newline at end of file