AtomTressFX - fixing crash bug for prefab (#6892)
- The crash happens due to attempt to get an instance of the hair dynamic data before it was initialized. Signed-off-by: Adi Bar-Lev <82479970+Adi-Amazon@users.noreply.github.com>
This commit is contained in:
@@ -213,6 +213,8 @@ namespace AZ
|
|||||||
Data::Instance<RPI::Shader> rasterShader,
|
Data::Instance<RPI::Shader> rasterShader,
|
||||||
uint32_t vertexCount, uint32_t strandsCount )
|
uint32_t vertexCount, uint32_t strandsCount )
|
||||||
{
|
{
|
||||||
|
m_initialized = false;
|
||||||
|
|
||||||
AZ_Assert(vertexCount <= std::numeric_limits<uint32_t>().max(), "Hair vertex count exceeds uint32_t size.");
|
AZ_Assert(vertexCount <= std::numeric_limits<uint32_t>().max(), "Hair vertex count exceeds uint32_t size.");
|
||||||
|
|
||||||
// Create the dynamic shared buffers Srg.
|
// Create the dynamic shared buffers Srg.
|
||||||
@@ -608,8 +610,16 @@ namespace AZ
|
|||||||
// First, Directly loading from the asset stored in the render settings.
|
// First, Directly loading from the asset stored in the render settings.
|
||||||
if (pRenderSettings)
|
if (pRenderSettings)
|
||||||
{
|
{
|
||||||
m_baseAlbedo = RPI::StreamingImage::FindOrCreate(pRenderSettings->m_baseAlbedoAsset);
|
if (pRenderSettings->m_baseAlbedoAsset)
|
||||||
m_strandAlbedo = RPI::StreamingImage::FindOrCreate(pRenderSettings->m_strandAlbedoAsset);
|
{
|
||||||
|
pRenderSettings->m_baseAlbedoAsset.BlockUntilLoadComplete();
|
||||||
|
m_baseAlbedo = RPI::StreamingImage::FindOrCreate(pRenderSettings->m_baseAlbedoAsset);
|
||||||
|
}
|
||||||
|
if (pRenderSettings->m_strandAlbedoAsset)
|
||||||
|
{
|
||||||
|
pRenderSettings->m_strandAlbedoAsset.BlockUntilLoadComplete();
|
||||||
|
m_strandAlbedo = RPI::StreamingImage::FindOrCreate(pRenderSettings->m_strandAlbedoAsset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback using the texture name stored in the render settings.
|
// Fallback using the texture name stored in the render settings.
|
||||||
@@ -1142,7 +1152,7 @@ namespace AZ
|
|||||||
|
|
||||||
if (!renderMaterialSrg || !simSrg)
|
if (!renderMaterialSrg || !simSrg)
|
||||||
{
|
{
|
||||||
AZ_Error("Hair Gem", false, "Failed to get thre hair material Srg for the raster pass.");
|
AZ_Error("Hair Gem", false, "Failed to get the hair material Srg for the raster pass.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// No need to compile the simSrg since it was compiled already by the Compute pass this frame
|
// No need to compile the simSrg since it was compiled already by the Compute pass this frame
|
||||||
|
|||||||
@@ -110,8 +110,14 @@ namespace AZ
|
|||||||
PrepareSrgDescriptors(m_dynamicBuffersDescriptors, vertexCount, strandsCount);
|
PrepareSrgDescriptors(m_dynamicBuffersDescriptors, vertexCount, strandsCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
Data::Instance<RPI::ShaderResourceGroup> GetSimSrgForCompute() { return m_simSrgForCompute; }
|
Data::Instance<RPI::ShaderResourceGroup> GetSimSrgForCompute()
|
||||||
Data::Instance<RPI::ShaderResourceGroup> GetSimSrgForRaster() { return m_simSrgForRaster; }
|
{
|
||||||
|
return m_initialized ? m_simSrgForCompute : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
Data::Instance<RPI::ShaderResourceGroup> GetSimSrgForRaster()
|
||||||
|
{
|
||||||
|
return m_initialized ? m_simSrgForRaster : nullptr; }
|
||||||
|
|
||||||
bool IsInitialized() { return m_initialized; }
|
bool IsInitialized() { return m_initialized; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user