Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Maximum StructuredBuffer Length?

Discussion in 'Shaders' started by Creaturtle, Aug 30, 2021.

  1. Creaturtle

    Creaturtle

    Joined:
    Jan 24, 2018
    Posts:
    33
    Hi,

    Is there a recommended limit on the most space that a StructuredBuffer should have?
    I'm sure it's hardware specific - is there a list somewhere?

    Mainly I'm wondering if there's a point at which the StructuredBuffer data needs to sit in VRAM or somewhere that manipulating it would be slower.

    Considering that meshes can have huge vertex buffers, and from my searches, I can't find a hard limit on size.
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,983
    Hi!
    This depends on the target hardware.For example, some mobile GPUs report 128 MB; DX11 mandates 2 GB.
     
  3. Creaturtle

    Creaturtle

    Joined:
    Jan 24, 2018
    Posts:
    33
    Gotcha.
    I have another question - what causes a mesh with many vertices to be slower than a mesh with fewer vertices?

    My understanding is, it's the fact that CPU culling and depth sorting can't be done, so lots of overdraw can happen, which is more expensive because of the sheer number of vertices.

    This would also mean having a large mesh loaded on the GPU would be fine, as long as culling and depth sorting of parts of it prior to rendering happens.

    Is this correct?
     
  4. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,983
    On what hardware?
     
  5. Creaturtle

    Creaturtle

    Joined:
    Jan 24, 2018
    Posts:
    33
    I'm working on a VR game, and I'm mostly worried about Quest performance.

    Is it hardware dependent on what causes lag, and not any GPU compute shader design principle?
     
  6. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,983
    So, for Quest you don't need to do depth sorting* as it has builtin hidden surface removal for opaque object rendering. CPU culling helps, yes. Do you know, where exactly your bottleneck is?

    * most of the time :)
     
  7. Creaturtle

    Creaturtle

    Joined:
    Jan 24, 2018
    Posts:
    33
    That's good to know, I was kind of worried I'd have to do some bitonic sorting

    Actually I'm interested in using Tiltbrush art for my game.
    I already know that the bottleneck will be in rendering, most likely due to overdraw.
    I'm implementing a BrushRenderer that culls strokes individually on the GPU and submit only the relevant ones to a buffer, and use DrawProceduralIndirect to render them in one draw call.

    I'm actually surprised I couldn't find anything online about doing this sort of thing... Seems like the best of both worlds to cull "submeshes" of a mesh, while also drawing it in one call.

    Makes me worried that there's some fundamental principle of GPU application design that's going over my head...