Search Unity

Unity 2019 DX12 and CommandBuffer.DrawProceduralIndirect= not works in standalone

Discussion in 'General Graphics' started by Przemyslaw_Zaworski, Jan 3, 2021.

  1. Przemyslaw_Zaworski

    Przemyslaw_Zaworski

    Joined:
    Jun 9, 2017
    Posts:
    328
    I play with Marching Cubes algorithm (using compute shader), which works well with Unity 2018.4.29f1 (in both editor mode and standalone executable). After upgrade to Unity 2019.4.17f1, in DX12 mode, it works correctly in editor mode, but not in standalone mode, there is an error "d3d12: upload buffer was full! Waited for COPY queue...".

    Code (CSharp):
    1. GfxDevice: creating device client; threaded=1
    2. d3d12: loaded!
    3. Direct3D:
    4.     Version:         Direct3D 12 [level 12.1]
    5.     Renderer:        NVIDIA GeForce RTX 2070 (ID=0x1f02)
    6.     Vendor:        
    7.     VRAM:            8031 MB
    8.     App VRAM Budget: 6826 MB
    9.     Driver:          27.21.14.6079
    10. d3d12: Profiler is enabled, but stable power state is not. GPU timing errors are expected.
    11. (Filename: C:\buildslave\unity\build\Runtime/GfxDevice/d3d12/GfxDeviceD3D12.cpp Line: 529)
    12.  
    13. Begin MonoManager ReloadAssembly
    14. - Completed reload, in  0.107 seconds
    15. D3D11 device created for Microsoft Media Foundation video decoding.
    16. <RI> Initializing input.
    17.  
    18. <RI> Input initialized.
    19.  
    20. <RI> Initialized touch support.
    21.  
    22. d3d12: upload buffer was full! Waited for COPY queue for 1.406 ms.
    23. d3d12: upload buffer was full! Waited for COPY queue for 1.402 ms.
    24. UnloadTime: 0.710100 ms
    25. d3d12: CreateGraphicsPipelineState failed.
    26. (Filename: C:\buildslave\unity\build\Runtime/GfxDevice/d3d12/GfxDeviceD3D12.cpp Line: 1156)
    Error disappears when I comment this line of code, which is required to visualise procedural triangle mesh:

    Code (CSharp):
    1. _CommandBuffer.DrawProceduralIndirect(Matrix4x4.identity, _Material, 0, MeshTopology.Triangles, _IndirectBuffer);
    It is Unity bug or I have to initialize/use append/indirect buffers under DX12 in different way ? But why it works in editor, and not in standalone. Also I tried with turned on/off graphics jobs option, without success.
     
  2. Przemyslaw_Zaworski

    Przemyslaw_Zaworski

    Joined:
    Jun 9, 2017
    Posts:
    328
    The same situation is under DX12 with Unity 2020.2.1f1, also with different GPU (project works properly in editor mode, errors only in Windows Standalone x64).

    Code (CSharp):
    1. GfxDevice: creating device client; threaded=1
    2. d3d12: loaded!
    3. Direct3D:
    4.     Version:         Direct3D 12 [level 12.1]
    5.     Renderer:        NVIDIA GeForce GTX 1660 SUPER (ID=0x21c4)
    6.     Vendor:        
    7.     VRAM:            5991 MB
    8.     App VRAM Budget: 5223 MB
    9.     Driver:          26.21.14.4614
    10. d3d12: Profiler is enabled, but stable power state is not. GPU timing errors are expected.
    11.  
    12. Begin MonoManager ReloadAssembly
    13. - Completed reload, in  0.069 seconds
    14. D3D11 device created for Microsoft Media Foundation video decoding.
    15. <RI> Initializing input.
    16.  
    17. <RI> Input initialized.
    18.  
    19. <RI> Initialized touch support.
    20.  
    21. UnloadTime: 0.720800 ms
    22. d3d12: CreateGraphicsPipelineState failed.
    Does somebody had similar problems ?
     
  3. Przemyslaw_Zaworski

    Przemyslaw_Zaworski

    Joined:
    Jun 9, 2017
    Posts:
    328
  4. joelv

    joelv

    Unity Technologies

    Joined:
    Mar 20, 2015
    Posts:
    203
    Thank you for reporting this bug.
    Just so you know the "d3d12: upload buffer was full!" message does not mean there was an error, only the failed pipeline state is an actual error. We will investigate this.
     
  5. Przemyslaw_Zaworski

    Przemyslaw_Zaworski

    Joined:
    Jun 9, 2017
    Posts:
    328
    Thanks for info ! In this case, DirectX 12 support in Windows Standalone is very important to me, due to raytracing support. I made tech demo where player can sculpt 3D shapes. In "Sculpt Mode" player uses a sphere as virtual brush to create or remove fragments of geometry. In this mode (Image 1), shape is visualised as wireframe with normal vectors debugging (via _CommandBuffer.DrawProceduralIndirect). In every moment player can finish sculpting, then press a key, to apply and create static gameobject with mesh collider. In DX12 Standalone, sculpt mode is invisible (all images I taken from Editor). To increase rendering quality, I added raytraced global illumination support via Unity RayTracingShader and RayTracingAccelerationStructure classes and custom DXR shaders (I don't use HDRP). Comparison: image 2 (with raytracing enabled), image 3 (raytracing disabled).

    upload_2021-1-15_15-58-23.png

    upload_2021-1-15_15-58-39.png

    upload_2021-1-15_15-59-2.png
     
    mgear likes this.
  6. joelv

    joelv

    Unity Technologies

    Joined:
    Mar 20, 2015
    Posts:
    203
    I had a look at the bug and there was a comment not sent out to you:

    In the MarchingCubes.shader
    void VSMain(inout float4 vertex : POSITION,

    Declaring the vertex inout means that the input layout ought to include vertex data, which is incorrect for null geometry drawcalls. The shader doesn't require the vertex input, so changing the declaration to:
    void VSMain(out float4 vertex : POSITION, 


    will fix the issue.​

    This combined with some code that fixes up the declaration internally in the editor makes this fail only on stand alone. I think the code will be fixed but now you can work around it at least.
     
    Przemyslaw_Zaworski likes this.