Making sure that all capture requests are cleaned up before the preview renderer gets destroyed

A request was captured and held onto to by a lambda that was not getting cleared before the system was destroyed
This caused an entity to be destroyed late, accessing the culling system that was already torn down
Solution is to only store the success and failure callbacks inside of the attachment pass read back callback lambda so the rest of the content can be released

Signed-off-by: Guthrie Adams <guthadam@amazon.com>
monroegm-disable-blank-issue-2
Guthrie Adams 4 years ago
parent 7415277eed
commit 66c25f3a02

@ -96,7 +96,6 @@ namespace AtomToolsFramework
AZ::RPI::RPISystemInterface::Get()->UnregisterScene(m_scene);
m_frameworkScene->UnsetSubsystem(m_scene);
m_frameworkScene->UnsetSubsystem(m_entityContext.get());
m_entityContext->DestroyContext();
}
void PreviewRenderer::AddCaptureRequest(const CaptureRequest& captureRequest)
@ -133,8 +132,11 @@ namespace AtomToolsFramework
}
void PreviewRenderer::CancelCaptureRequest()
{
if (m_currentCaptureRequest.m_captureFailedCallback)
{
m_currentCaptureRequest.m_captureFailedCallback();
}
m_state.reset();
m_state.reset(new PreviewRendererIdleState(this));
}
@ -179,17 +181,25 @@ namespace AtomToolsFramework
bool PreviewRenderer::StartCapture()
{
auto captureCallback = [currentCaptureRequest = m_currentCaptureRequest](const AZ::RPI::AttachmentReadback::ReadbackResult& result)
auto captureCompleteCallback = m_currentCaptureRequest.m_captureCompleteCallback;
auto captureFailedCallback = m_currentCaptureRequest.m_captureFailedCallback;
auto captureCallback = [captureCompleteCallback, captureFailedCallback](const AZ::RPI::AttachmentReadback::ReadbackResult& result)
{
if (result.m_dataBuffer)
{
currentCaptureRequest.m_captureCompleteCallback(QPixmap::fromImage(QImage(
result.m_dataBuffer.get()->data(), result.m_imageDescriptor.m_size.m_width, result.m_imageDescriptor.m_size.m_height,
QImage::Format_RGBA8888)));
if (captureCompleteCallback)
{
captureCompleteCallback(QPixmap::fromImage(QImage(
result.m_dataBuffer.get()->data(), result.m_imageDescriptor.m_size.m_width,
result.m_imageDescriptor.m_size.m_height, QImage::Format_RGBA8888)));
}
}
else
{
currentCaptureRequest.m_captureFailedCallback();
if (captureFailedCallback)
{
captureFailedCallback();
}
}
};
@ -209,6 +219,7 @@ namespace AtomToolsFramework
void PreviewRenderer::EndCapture()
{
m_currentCaptureRequest = {};
m_renderPipeline->RemoveFromRenderTick();
}

Loading…
Cancel
Save