Search Issue Tracker

By Design

Votes

0

Found in [Package]

10.5.1

Issue ID

1358534

Regression

No

[XR SDK] [URP] Command buffer stops working when grabbing copy of the texture with Single Pass Instanced rendering mode

Package: Scriptable Render Pipeline Universal

-

Reproduction steps:
1. Open the attached project ("CorgiRaytracing.zip")
2. Open the "DEMO_URP" scene
3. Enter the play mode
4. Enable Frame Debugger
5. Select first Draw Mesh in RaytraceReflectionsPass

Expected result: Texture is visible
Actual result: Texture is blank (see "CdRh006.png" image)

Reproducible with: URP 10.5.1 (2020.3.17f1), URP 11.0.0 (2021.1.18f1)
Not reproducible with: 2019.4.30f1 (RayTracing for Dynamic Geometry not implemented yet.)
Could not test with: 2021.2.0b9, 2022.1.0a5 project crashes on opening with stack trace:

0x00007ff6b3dc7172 (Unity) ShaderLab::Program::GetMatchingSubProgram
0x00007ff6b3dcd9bd (Unity) ShaderLab::ShaderState::FindSubProgramsToUse
0x00007ff6b3d99de6 (Unity) RayTracingShadersSetupContext::CompilePendingShaders
0x00007ff6b3d9c087 (Unity) RayTracingShadersSetupContext::IntegrateMainThread
...

  1. Resolution Note:

    I have investigated this case today and here is my findings:

    The repro project uses a shader called GrabpassBlit.shader which blits `_SourceTexture` to color target. The `_SourceTexture` is declared as Texture2D.
    When running SPI rendering mode, this texture becomes texture2D array which causes the binding operation to fail. Unity then binds the grey texture by default.
    By changing texture2D to texture2DArray in SPI mode, I was able to see unity binds the texture properly(see attached file).
    Code that declare texture2DArray in SPI and multiview mode:
    `
    #if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED)
    Texture2DArray _SourceTex;
    #else
    Texture2D _SourceTex;
    #endif
    `

    I also noticed the repro project was using legacy shader includes in URP project. This is not recommended and may cause lots of compatibility issues. I would recommend user to upgrade shaders to use URP shader include. With URP shader include in place, user could use Texture2D_X shader macro to solve this case instead of lengthy ifdef. We also have a WIP doc PR that provide an example of doing blit in URP XR that might be helpful: https://github.com/Unity-Technologies/Graphics/pull/5395

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.