Skip to content

Commit

Permalink
[d3d8] Handle DEFAULT->MANAGED in CopyRects
Browse files Browse the repository at this point in the history
  • Loading branch information
WinterSnowfall committed Sep 7, 2023
1 parent 1a039a4 commit e31f4ef
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions src/d3d8/d3d8_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,14 +543,14 @@ namespace dxvk {
* The following table shows the possible combinations of source
* and destination surface pools, and how we handle each of them.
*
* ┌────────────┬───────────────────────────┬───────────┬───────────────────────┬──────────┐
* │ Src/Dst │ DEFAULT │ MANAGED │ SYSTEMMEM │ SCRATCH │
* ├────────────┼───────────────────────────┼───────────┼───────────────────────┼──────────┤
* │ DEFAULT │ StretchRect │ - │ GetRenderTargetData │ - │
* │ MANAGED │ UpdateTextureFromBuffer │ memcpy │ memcpy │ - │
* │ SYSTEMMEM │ UpdateSurface │ memcpy │ memcpy │ - │
* │ SCRATCH │ - │ - │ - │ - │
* └────────────┴───────────────────────────┴───────────┴───────────────────────┴──────────┘
* ┌────────────┬───────────────────────────┬───────────────────────┬───────────────────────┬──────────┐
* │ Src/Dst │ DEFAULT │ MANAGED │ SYSTEMMEM │ SCRATCH │
* ├────────────┼───────────────────────────┼───────────────────────┼───────────────────────┼──────────┤
* │ DEFAULT │ StretchRect │ GetRenderTargetData │ GetRenderTargetData │ - │
* │ MANAGED │ UpdateTextureFromBuffer │ memcpy │ memcpy │ - │
* │ SYSTEMMEM │ UpdateSurface │ memcpy │ memcpy │ - │
* │ SCRATCH │ - │ - │ - │ - │
* └────────────┴───────────────────────────┴───────────────────────┴───────────────────────┴──────────┘
*/
HRESULT STDMETHODCALLTYPE D3D8Device::CopyRects(
IDirect3DSurface8* pSourceSurface,
Expand Down Expand Up @@ -670,8 +670,25 @@ namespace dxvk {
case D3DPOOL_MANAGED:
switch (srcDesc.Pool) {
case D3DPOOL_DEFAULT: {
// TODO: (copy on GPU)
goto unhandled;
// TODO: Copy on GPU (handle MANAGED similarly to SYSTEMMEM for now)

// Get temporary off-screen surface for stretching.
Com<d3d9::IDirect3DSurface9> pBlitImage = dst->GetBlitImage();

// Stretch the source RT to the temporary surface.
res = GetD3D9()->StretchRect(
src->GetD3D9(),
&srcRect,
pBlitImage.ptr(),
&dstRect,
d3d9::D3DTEXF_NONE);
if (FAILED(res)) {
goto done;
}

// Now sync the rendertarget data into main memory.
res = GetD3D9()->GetRenderTargetData(pBlitImage.ptr(), dst->GetD3D9());
goto done;
}
case D3DPOOL_MANAGED:
case D3DPOOL_SYSTEMMEM: {
Expand Down

0 comments on commit e31f4ef

Please sign in to comment.