Files
o3de/Gems/Atom/RPI/Code/Source/RPI.Reflect/Image/AttachmentImageAssetCreator.cpp
T
Qing Tao 01892914ea Atom/qingtao/atom 16135 (#7334)
* Changes to AttachmentImage related classes to have better support using render target as texture.
- Updated AttachmentImageAsset to support an unique name which can be used as AttachmentId.
- Functions in ImageSystemInterface to find an AttachmentImage by its unique name.
- Added InsertChild function to ParentPass class so it can insert a child pass at any location.
- Change to ImageAttachmentPreviewPass so it can preview cached pass attachment even the source pass was disabled.

Signed-off-by: Qing Tao <55564570+VickyAtAZ@users.noreply.github.com>
2022-02-03 14:58:58 -08:00

95 lines
2.8 KiB
C++

/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include <Atom/RPI.Reflect/Image/AttachmentImageAssetCreator.h>
#include <Atom/RPI.Public/Image/AttachmentImagePool.h>
#include <Atom/RPI.Public/Image/ImageSystemInterface.h>
#include <AzCore/Asset/AssetManager.h>
namespace AZ
{
namespace RPI
{
void AttachmentImageAssetCreator::Begin(const Data::AssetId& assetId)
{
BeginCommon(assetId);
}
void AttachmentImageAssetCreator::SetImageDescriptor(const RHI::ImageDescriptor& descriptor)
{
if (ValidateIsReady())
{
m_asset->m_imageDescriptor = descriptor;
}
}
void AttachmentImageAssetCreator::SetImageViewDescriptor(const RHI::ImageViewDescriptor& descriptor)
{
if (ValidateIsReady())
{
m_asset->m_imageViewDescriptor = descriptor;
}
}
void AttachmentImageAssetCreator::SetPoolAsset(const Data::Asset<ResourcePoolAsset>& poolAsset)
{
if (ValidateIsReady())
{
m_asset->m_poolAsset = poolAsset;
}
}
void AttachmentImageAssetCreator::SetOptimizedClearValue(const RHI::ClearValue& clearValue)
{
if (ValidateIsReady())
{
m_asset->m_optimizedClearValue = AZStd::make_shared<RHI::ClearValue>(clearValue);
}
}
bool AttachmentImageAssetCreator::End(Data::Asset<AttachmentImageAsset>& result)
{
if (!ValidateIsReady())
{
return false;
}
// If the pool wasn't provided, use the system default attachment pool
if (!m_asset->m_poolAsset.GetId().IsValid())
{
Data::Instance<RPI::AttachmentImagePool> pool = RPI::ImageSystemInterface::Get()->GetSystemAttachmentPool();
m_asset->m_poolAsset = {pool->GetAssetId(), azrtti_typeid<ResourcePoolAsset>()};
}
m_asset->SetReady();
return EndCommon(result);
}
void AttachmentImageAssetCreator::SetAssetHint(AZStd::string_view hint)
{
m_asset.SetHint(hint);
}
void AttachmentImageAssetCreator::SetName(const AZ::Name& uniqueName, bool isUniqueName)
{
if (uniqueName.IsEmpty())
{
m_asset->m_isUniqueName = false;
AZ_Warning("RPI", false, "Can't set empty string as unique name");
}
else
{
m_asset->m_isUniqueName = isUniqueName;
}
m_asset->m_name = uniqueName;
}
}
}