Fixed a crash issue with RHI::Fence when trying to capture screenshot which null renderer is used. (#3802)

ATOM-16292, ATOM-16243, ATOM-15493

Signed-off-by: qingtao <qingtao@amazon.com>
This commit is contained in:
Qing Tao
2021-09-01 09:06:06 -07:00
committed by GitHub
parent 043a2c65ff
commit b9c0b2a5f7
8 changed files with 103 additions and 1 deletions
@@ -8,6 +8,8 @@
#include "FrameCaptureSystemComponent.h"
#include <Atom/RHI/RHIUtils.h>
#include <Atom/RPI.Public/Pass/PassSystemInterface.h>
#include <Atom/RPI.Public/Pass/PassFilter.h>
#include <Atom/RPI.Public/Pass/RenderPass.h>
@@ -254,8 +256,18 @@ namespace AZ
return AZStd::string(resolvedPath);
}
bool FrameCaptureSystemComponent::CanCapture() const
{
return !AZ::RHI::IsNullRenderer();
}
bool FrameCaptureSystemComponent::CaptureScreenshotForWindow(const AZStd::string& filePath, AzFramework::NativeWindowHandle windowHandle)
{
if (!CanCapture())
{
return false;
}
InitReadback();
if (m_state != State::Idle)
@@ -301,6 +313,11 @@ namespace AZ
bool FrameCaptureSystemComponent::CaptureScreenshotWithPreview(const AZStd::string& outputFilePath)
{
if (!CanCapture())
{
return false;
}
InitReadback();
if (m_state != State::Idle)
@@ -350,6 +367,11 @@ namespace AZ
bool FrameCaptureSystemComponent::CapturePassAttachment(const AZStd::vector<AZStd::string>& passHierarchy, const AZStd::string& slot,
const AZStd::string& outputFilePath, RPI::PassAttachmentReadbackOption option)
{
if (!CanCapture())
{
return false;
}
InitReadback();
if (m_state != State::Idle)
@@ -396,6 +418,11 @@ namespace AZ
bool FrameCaptureSystemComponent::CapturePassAttachmentWithCallback(const AZStd::vector<AZStd::string>& passHierarchy, const AZStd::string& slotName
, RPI::AttachmentReadback::CallbackFunction callback, RPI::PassAttachmentReadbackOption option)
{
if (!CanCapture())
{
return false;
}
bool result = CapturePassAttachment(passHierarchy, slotName, "", option);
// Append state change to user provided call back