Improved image gradient GetValue(s) performance by using cached image data

Signed-off-by: Chris Galvan <chgalvan@amazon.com>
This commit is contained in:
Chris Galvan
2022-02-09 12:22:38 -06:00
parent 39777e7afb
commit 2f3c4d37df
6 changed files with 109 additions and 31 deletions
@@ -78,11 +78,10 @@ namespace GradientSignal
return true;
}
float GetValueFromImageAsset(const AZ::Data::Asset<AZ::RPI::StreamingImageAsset>& imageAsset, const AZ::Vector3& uvw, float tilingX, float tilingY, float defaultValue)
float GetValueFromImageAsset(AZStd::span<const uint8_t> imageData, const AZ::RHI::ImageDescriptor& imageDescriptor, const AZ::Vector3& uvw, float tilingX, float tilingY, float defaultValue)
{
if (imageAsset.IsReady())
if (!imageData.empty())
{
auto imageDescriptor = imageAsset->GetImageDescriptor();
auto width = imageDescriptor.m_size.m_width;
auto height = imageDescriptor.m_size.m_height;
@@ -125,7 +124,7 @@ namespace GradientSignal
// Flip the y because images are stored in reverse of our world axes
y = (height - 1) - y;
return AZ::RPI::GetSubImagePixelValue<float>(imageAsset, x, y);
return AZ::RPI::GetImageDataPixelValue<float>(imageData, imageDescriptor, x, y);
}
}