Skip to content

Commit

Permalink
VulkanRenderer Fixed CaptureScreenshot() sometimes not capturing the …
Browse files Browse the repository at this point in the history
…most recent frame 10/28/2024 | 24w44a1
  • Loading branch information
GamesTrap committed Oct 28, 2024
1 parent 598aec4 commit 6aafd4c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions SITREPS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5332,3 +5332,4 @@ SITREP 10/27/2024|24w43b3
SITREP 10/28/2024|24w44a1
- Changed TRAP Engine version to 24w44a1(0.11.31)
- VulkanRenderer Moved GetCurrentSwapChainRenderTarget() to RendererAPI::PerViewportData ~<5 mins
- VulkanRenderer Fixed CaptureScreenshot() sometimes not capturing the most recent frame ~<5 mins
1 change: 1 addition & 0 deletions TRAP/src/Graphics/API/RendererAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -2881,6 +2881,7 @@ namespace TRAP::Graphics
u32 NewWidth = 1920, NewHeight = 1080; //Default RenderTargets to use Full HD
#endif /*TRAP_HEADLESS_MODE*/
u32 CurrentSwapChainImageIndex{};
u32 PreviousSwapChainImageIndex{};
RendererAPI::AntiAliasing CurrentAntiAliasing = RendererAPI::AntiAliasing::Off;
RendererAPI::SampleCount CurrentSampleCount = RendererAPI::SampleCount::One;

Expand Down
5 changes: 4 additions & 1 deletion TRAP/src/Graphics/API/Vulkan/VulkanRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ void TRAP::Graphics::API::VulkanRenderer::StartGraphicRecording(PerViewportData&
renderCompleteFence->Wait();

//Start Recording
p.PreviousSwapChainImageIndex = p.CurrentSwapChainImageIndex;
p.CurrentSwapChainImageIndex = RetrieveNextSwapchainImageIndex(p);

//TODO Always use back buffer (InternalRenderTarget), copy/resolve final image to SwapChain RenderTargert as last step in EndGraphicRecording().
Expand Down Expand Up @@ -840,6 +841,7 @@ void TRAP::Graphics::API::VulkanRenderer::Present(PerViewportData& p) const
CreateOrUpdateDepthStencilTarget(p, *m_device);

p.CurrentSwapChainImageIndex = 0;
p.PreviousSwapChainImageIndex = 0;
p.ImageIndex = 0;
}
else if (presentStatus == PresentStatus::DeviceReset || presentStatus == PresentStatus::Failed)
Expand Down Expand Up @@ -872,6 +874,7 @@ void TRAP::Graphics::API::VulkanRenderer::Present(PerViewportData& p) const
}

p.CurrentSwapChainImageIndex = 0;
p.PreviousSwapChainImageIndex = 0;
p.ImageIndex = 0;

if(p.DepthStencilTarget)
Expand Down Expand Up @@ -2341,7 +2344,7 @@ void TRAP::Graphics::API::VulkanRenderer::ReflexMarker([[maybe_unused]] const u3

const PerViewportData& p = *GETPERVIEWPORTDATA;

const u32 lastFrame = (p.ImageIndex - 1) % RendererAPI::ImageCount; //BUG This must be the previous value of p.CurrentSwapChainImageIndex (#294)
const u32 lastFrame = p.PreviousSwapChainImageIndex;

//Wait for queues to finish
s_computeQueue->WaitQueueIdle();
Expand Down

0 comments on commit 6aafd4c

Please sign in to comment.