This commit is contained in:
2025-10-09 19:22:25 +09:00
parent 54db41e547
commit 821658c05a
3 changed files with 23 additions and 13 deletions

View File

@@ -115,7 +115,7 @@ bool FrameProcessor::ProcessFrame(VavCorePlayer* player,
if (FAILED(hr)) {
LOGF_ERROR("[FrameProcessor] Failed to wait for copy completion: 0x%08X", hr);
} else {
LOGF_DEBUG("[FrameProcessor] GPU copy completed, staging texture ready");
LOGF_INFO("[FrameProcessor] GPU copy completed, staging texture ready");
}
}
}

View File

@@ -634,16 +634,6 @@ HRESULT RGBASurfaceBackend::CopyToStagingTexture(ID3D12Resource* sourceTexture)
return hr;
}
// Transition staging texture from PIXEL_SHADER_RESOURCE to COPY_DEST
// (First frame: starts in COPY_DEST, subsequent frames: comes from PIXEL_SHADER_RESOURCE)
D3D12_RESOURCE_BARRIER stagingToCopyDest = {};
stagingToCopyDest.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
stagingToCopyDest.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
stagingToCopyDest.Transition.pResource = m_stagingTexture.Get();
stagingToCopyDest.Transition.StateBefore = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
stagingToCopyDest.Transition.StateAfter = D3D12_RESOURCE_STATE_COPY_DEST;
stagingToCopyDest.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
// Transition source texture to COPY_SOURCE
D3D12_RESOURCE_BARRIER sourceBarrier = {};
sourceBarrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
@@ -653,8 +643,27 @@ HRESULT RGBASurfaceBackend::CopyToStagingTexture(ID3D12Resource* sourceTexture)
sourceBarrier.Transition.StateAfter = D3D12_RESOURCE_STATE_COPY_SOURCE;
sourceBarrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
D3D12_RESOURCE_BARRIER barriers[] = { stagingToCopyDest, sourceBarrier };
m_copyCommandList->ResourceBarrier(2, barriers);
// Transition staging texture to COPY_DEST (only if not first copy)
// First copy: staging texture already in COPY_DEST state (created with that state)
// Subsequent copies: staging texture in PIXEL_SHADER_RESOURCE state (from previous render)
if (m_firstCopy) {
// First copy: only transition source
m_copyCommandList->ResourceBarrier(1, &sourceBarrier);
m_firstCopy = false;
LOGF_DEBUG("[RGBASurfaceBackend] First copy: staging texture already in COPY_DEST state");
} else {
// Subsequent copies: transition both staging and source
D3D12_RESOURCE_BARRIER stagingToCopyDest = {};
stagingToCopyDest.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
stagingToCopyDest.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
stagingToCopyDest.Transition.pResource = m_stagingTexture.Get();
stagingToCopyDest.Transition.StateBefore = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
stagingToCopyDest.Transition.StateAfter = D3D12_RESOURCE_STATE_COPY_DEST;
stagingToCopyDest.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
D3D12_RESOURCE_BARRIER barriers[] = { stagingToCopyDest, sourceBarrier };
m_copyCommandList->ResourceBarrier(2, barriers);
}
// Copy texture
m_copyCommandList->CopyResource(m_stagingTexture.Get(), sourceTexture);

View File

@@ -122,6 +122,7 @@ private:
uint32_t m_height = 0; // Container height
uint32_t m_videoWidth = 0;
uint32_t m_videoHeight = 0;
bool m_firstCopy = true; // Track first copy to handle initial state
// Helper methods
HRESULT CreateGraphicsResources();