Skip to content

Force allocate texture if no fallback is available (#5130) #5622

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,22 @@ public TextureHandle ReadTexture(in TextureHandle input)

if (!m_Resources.IsResourceImported(input.handle) && m_Resources.TextureNeedsFallback(input))
{
var texDimension = m_Resources.GetTextureResourceDesc(input.handle).dimension;
if (texDimension == TextureXR.dimension)
// If texture is read from but never written to, return a fallback black texture to have valid reads
// Return one from the preallocated default textures if possible
var desc = m_Resources.GetTextureResourceDesc(input.handle);
if (!desc.bindTextureMS)
{
return m_RenderGraph.defaultResources.blackTextureXR;
}
else if (texDimension == TextureDimension.Tex3D)
{
return m_RenderGraph.defaultResources.blackTexture3DXR;
}
else
{
return m_RenderGraph.defaultResources.blackTexture;
if (desc.dimension == TextureXR.dimension)
return m_RenderGraph.defaultResources.blackTextureXR;
else if (desc.dimension == TextureDimension.Tex3D)
return m_RenderGraph.defaultResources.blackTexture3DXR;
else
return m_RenderGraph.defaultResources.blackTexture;
}
// If not, force a write to the texture so that it gets allocated, and ensure it gets initialized with a clear color
if (!desc.clearBuffer)
m_Resources.ForceTextureClear(input.handle, Color.black);
WriteTexture(input);
}

m_RenderPass.AddResourceRead(input.handle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,12 @@ internal TextureDesc GetTextureResourceDesc(in ResourceHandle handle)
return (m_Resources[(int)RenderGraphResourceType.Texture][handle] as TextureResource).desc;
}

internal void ForceTextureClear(in ResourceHandle handle, Color clearColor)
{
GetTextureResource(handle).desc.clearBuffer = true;
GetTextureResource(handle).desc.clearColor = clearColor;
}

internal RendererListHandle CreateRendererList(in RendererListDesc desc)
{
ValidateRendererListDesc(desc);
Expand Down
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed ResourceReloader that was not call anymore at pipeline construction
- Fixed undo of some properties on light editor.
- Fixed an issue where auto baking of ambient and reflection probe done for builtin renderer would cause wrong baking in HDRP.
- Fixed error when disabling opaque objects on a camera with MSAA.

### Changed
- Updated the tooltip for the Decal Angle Fade property (requires to enable Decal Layers in both HDRP asset and Frame settings) (case 1308048).
Expand Down