Skip to content

Fixed a null texture error caused by lens flare pass #6454

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 3 commits into from
Dec 3, 2021
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 @@ -105,8 +105,13 @@ internal RTHandle GetTexture(in TextureHandle handle)
return null;

var resource = GetTextureResource(handle.handle).graphicsResource;
if (resource == null && handle.fallBackResource != TextureHandle.nullHandle.handle)
return GetTextureResource(handle.fallBackResource).graphicsResource;
if (resource == null)
{
if (handle.fallBackResource != TextureHandle.nullHandle.handle)
return GetTextureResource(handle.fallBackResource).graphicsResource;
else
throw new InvalidOperationException("Trying to use a texture that was already released or not yet created. Make sure you declare it for reading in your pass or you don't read it before it's been written to at least once.");
}

return resource;
}
Expand All @@ -132,7 +137,11 @@ internal ComputeBuffer GetComputeBuffer(in ComputeBufferHandle handle)
if (!handle.IsValid())
return null;

return GetComputeBufferResource(handle.handle).graphicsResource;
var resource = GetComputeBufferResource(handle.handle);
if (resource == null)
throw new InvalidOperationException("Trying to use a compute buffer that was already released or not yet created. Make sure you declare it for reading in your pass or you don't read it before it's been written to at least once.");

return resource.graphicsResource;
}

private RenderGraphResourceRegistry()
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 @@ -53,6 +53,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed edges and ghosting appearing on shadow matte due to the shadow being black outside the range of the light (case 1371441).
- Fixed the ray tracing fallbacks being broken since an Nvidia Driver Update.
- Fixed layer lit shader UI.
- Fixed a warning because of a null texture in the lens flare pass.

## [13.1.2] - 2021-11-05

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3197,7 +3197,7 @@ TextureHandle LensFlareDataDrivenPass(RenderGraph renderGraph, HDCamera hdCamera
passData.parameters = PrepareLensFlareParameters(hdCamera);
passData.viewport = postProcessViewportSize;
passData.hdCamera = hdCamera;
passData.depthBuffer = depthBuffer;
passData.depthBuffer = builder.ReadTexture(depthBuffer);
passData.occlusion = builder.ReadTexture(occlusionHandle);

TextureHandle dest = GetPostprocessUpsampledOutputHandle(renderGraph, "Lens Flare Destination");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,18 @@ PrepassOutput RenderPrepass(RenderGraph renderGraph,

DecalNormalPatch(renderGraph, hdCamera, ref result);

if (shouldRenderMotionVectorAfterGBuffer)
{
// See the call RenderObjectsMotionVectors() above and comment
RenderObjectsMotionVectors(renderGraph, cullingResults, hdCamera, decalBuffer, result);
}

// In case we don't have MSAA, we always run camera motion vectors when is safe to assume Object MV are rendered
if (!needCameraMVBeforeResolve)
{
RenderCameraMotionVectors(renderGraph, hdCamera, result.depthBuffer, result.resolvedMotionVectorsBuffer);
}

// After Depth and Normals/roughness including decals
bool depthBufferModified = RenderCustomPass(renderGraph, hdCamera, colorBuffer, result, customPassCullingResults, cullingResults, CustomPassInjectionPoint.AfterOpaqueDepthAndNormal, aovRequest, aovBuffers);

Expand All @@ -264,18 +276,6 @@ PrepassOutput RenderPrepass(RenderGraph renderGraph,
// In both forward and deferred, everything opaque should have been rendered at this point so we can safely copy the depth buffer for later processing.
GenerateDepthPyramid(renderGraph, hdCamera, mip1FromDownsampleForLowResTrans, ref result);

if (shouldRenderMotionVectorAfterGBuffer)
{
// See the call RenderObjectsMotionVectors() above and comment
RenderObjectsMotionVectors(renderGraph, cullingResults, hdCamera, decalBuffer, result);
}

// In case we don't have MSAA, we always run camera motion vectors when is safe to assume Object MV are rendered
if (!needCameraMVBeforeResolve)
{
RenderCameraMotionVectors(renderGraph, hdCamera, result.depthBuffer, result.resolvedMotionVectorsBuffer);
}

// NOTE: Currently we profiled that generating the HTile for SSR and using it is not worth it the optimization.
// However if the generated HTile will be used for something else but SSR, this should be made NOT resolve only and
// re-enabled in the shader.
Expand Down