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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user