diff --git a/vav2/platforms/windows/applications/vav2player/Vav2Player/src/Playback/FrameProcessor.cpp b/vav2/platforms/windows/applications/vav2player/Vav2Player/src/Playback/FrameProcessor.cpp index 154ca45..29ce720 100644 --- a/vav2/platforms/windows/applications/vav2player/Vav2Player/src/Playback/FrameProcessor.cpp +++ b/vav2/platforms/windows/applications/vav2player/Vav2Player/src/Playback/FrameProcessor.cpp @@ -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"); } } } diff --git a/vav2/platforms/windows/applications/vav2player/Vav2Player/src/Rendering/RGBASurfaceBackend.cpp b/vav2/platforms/windows/applications/vav2player/Vav2Player/src/Rendering/RGBASurfaceBackend.cpp index 68c9ed8..409adad 100644 --- a/vav2/platforms/windows/applications/vav2player/Vav2Player/src/Rendering/RGBASurfaceBackend.cpp +++ b/vav2/platforms/windows/applications/vav2player/Vav2Player/src/Rendering/RGBASurfaceBackend.cpp @@ -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); diff --git a/vav2/platforms/windows/applications/vav2player/Vav2Player/src/Rendering/RGBASurfaceBackend.h b/vav2/platforms/windows/applications/vav2player/Vav2Player/src/Rendering/RGBASurfaceBackend.h index 03b953f..dc3f506 100644 --- a/vav2/platforms/windows/applications/vav2player/Vav2Player/src/Rendering/RGBASurfaceBackend.h +++ b/vav2/platforms/windows/applications/vav2player/Vav2Player/src/Rendering/RGBASurfaceBackend.h @@ -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();