Skip to content

Buffer types + arrayLength() issues #15920

Open
@JMS55

Description

@JMS55

Bevy version

acbed60

Problem

StorageBuffer/UniformBuffer/etc will reuse its GPU buffer if it's big enough.

Say one frame you want a buffer of size N*2, and the next, N.

Because StorageBuffer/etc use as_entire_buffer_binding(), on the second frame, you'll end up with a buffer of size N*2, and not N.

If the buffer stores an unsized array, any shaders using arrayLength() in the shader will return N*2, but again we'd be expecting N here as that's how many items we wrote this frame.

Affected shaders

  • mesh_preprocess.wgsl
  • get_visibility_range_dither_level()
  • Some meshlet stuff (I fixed this on a branch)

Solution

The buffer types should probably not use as_entire_buffer_binding(), and instead should bind only the section of the buffer actually written to in the last write_buffer() call.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-BugAn unexpected or incorrect behaviorD-ShadersThis code uses GPU shader languagesD-TrivialNice and easy! A great choice to get started with BevyP-HighThis is particularly urgent, and deserves immediate attentionS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions