From 5f46655394db1dffce347a9e7d25f8dcf1ce9315 Mon Sep 17 00:00:00 2001 From: assiduous Date: Tue, 15 Oct 2024 16:51:44 -0700 Subject: [PATCH] Hydrogent: set array size to 1 in default atlas desc --- Hydrogent/src/HnMaterial.cpp | 2 +- Hydrogent/src/HnRenderDelegate.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Hydrogent/src/HnMaterial.cpp b/Hydrogent/src/HnMaterial.cpp index c997b76e..2c61ea3b 100644 --- a/Hydrogent/src/HnMaterial.cpp +++ b/Hydrogent/src/HnMaterial.cpp @@ -952,7 +952,7 @@ bool HnMaterial::UpdateSRB(HnRenderDelegate& RendererDelegate) { TEXTURE_FORMAT AtlasFmt = AtlasFormats[AtlasId]; VERIFY_EXPR(AtlasFormatIds.find(AtlasFmt)->second == AtlasId); - auto* pAtlasTexture = RendererDelegate.GetResourceManager().GetTexture(AtlasFmt); + ITexture* pAtlasTexture = RendererDelegate.GetResourceManager().GetTexture(AtlasFmt); VERIFY_EXPR(pAtlasTexture != nullptr); TexArray[AtlasId] = pAtlasTexture; } diff --git a/Hydrogent/src/HnRenderDelegate.cpp b/Hydrogent/src/HnRenderDelegate.cpp index 3f4933df..c40b8081 100644 --- a/Hydrogent/src/HnRenderDelegate.cpp +++ b/Hydrogent/src/HnRenderDelegate.cpp @@ -285,6 +285,11 @@ static RefCntAutoPtr CreateResourceManager(const HnRender ResMgrCI.DefaultAtlasDesc.Desc.BindFlags = BIND_SHADER_RESOURCE; ResMgrCI.DefaultAtlasDesc.Desc.Width = TextureAtlasDim; ResMgrCI.DefaultAtlasDesc.Desc.Height = TextureAtlasDim; + // Ensure that the atlas will have at least one slice the first time it is updated. + // Since textures are loaded asynchronously, no texture may be loaded during the first update + // and RendererDelegate.GetResourceManager().GetTexture(AtlasFmt) in HnMaterial::UpdateSRB() will + // return null. + ResMgrCI.DefaultAtlasDesc.Desc.ArraySize = 1; ResMgrCI.DefaultAtlasDesc.Desc.MipLevels = 6; ResMgrCI.DefaultAtlasDesc.GrowthFactor = 1.25f; ResMgrCI.DefaultAtlasDesc.MinAlignment = 64;