From 4e951184f13e391962e4cfcdf63c8e5b45b72b96 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sun, 30 Mar 2025 21:40:10 +0000 Subject: [PATCH] [idd] driver: fix hardcoded pitch values --- idd/LGIdd/CSwapChainProcessor.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/idd/LGIdd/CSwapChainProcessor.cpp b/idd/LGIdd/CSwapChainProcessor.cpp index dc7a2530..31defc03 100644 --- a/idd/LGIdd/CSwapChainProcessor.cpp +++ b/idd/LGIdd/CSwapChainProcessor.cpp @@ -203,17 +203,29 @@ bool CSwapChainProcessor::SwapChainNewFrame(ComPtr acquiredBuffer //FIXME: handle dirty rects srcRes->SetFullDamage(); + D3D12_RESOURCE_DESC desc = srcRes->GetRes()->GetDesc(); + D3D12_PLACED_SUBRESOURCE_FOOTPRINT layout; + m_dx12Device->GetDevice()->GetCopyableFootprints( + &desc, + 0, + 1, + 0, + &layout, + NULL, + NULL, + NULL); + auto buffer = m_devContext->PrepareFrameBuffer( - srcRes->GetFormat().Width, - srcRes->GetFormat().Height, - srcRes->GetFormat().Width * 4, - srcRes->GetFormat().Format); + (int)desc.Width, + (int)desc.Height, + (int)layout.Footprint.RowPitch, + desc.Format); if (!buffer.mem) return false; CFrameBufferResource * fbRes = m_fbPool.Get(buffer, - ((size_t)srcRes->GetFormat().Width * 4) * srcRes->GetFormat().Height); + (size_t)layout.Footprint.RowPitch * desc.Height); if (!fbRes) { @@ -239,11 +251,11 @@ bool CSwapChainProcessor::SwapChainNewFrame(ComPtr acquiredBuffer dstLoc.pResource = fbRes->Get().Get(); dstLoc.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT; dstLoc.PlacedFootprint.Offset = 0; - dstLoc.PlacedFootprint.Footprint.Format = srcRes->GetFormat().Format; - dstLoc.PlacedFootprint.Footprint.Width = srcRes->GetFormat().Width; - dstLoc.PlacedFootprint.Footprint.Height = srcRes->GetFormat().Height; + dstLoc.PlacedFootprint.Footprint.Format = desc.Format; + dstLoc.PlacedFootprint.Footprint.Width = (UINT)desc.Width; + dstLoc.PlacedFootprint.Footprint.Height = (UINT)desc.Height; dstLoc.PlacedFootprint.Footprint.Depth = 1; - dstLoc.PlacedFootprint.Footprint.RowPitch = srcRes->GetFormat().Width * 4; //FIXME + dstLoc.PlacedFootprint.Footprint.RowPitch = layout.Footprint.RowPitch; srcRes->Sync(*copyQueue); copyQueue->GetGfxList()->CopyTextureRegion(