Skip to content
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

StorageBuffer logs cryptic error, when Item Type has wrong size. #4556

Closed
MonaMayrhofer opened this issue Apr 22, 2022 · 0 comments
Closed
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior

Comments

@MonaMayrhofer
Copy link
Contributor

MonaMayrhofer commented Apr 22, 2022

Bevy version

v0.7.0 and main branch 18c6a7b

Operating system & version

Archlinux

What you did

Create a StorageBuffer of items of types like:

#[derive(AsStd430)]
struct NotInherentlyAligned {
    data: Vec3,
}

then call write_buffer

What you expected to happen

Buffer gets written to the queue without problems.

Internally:

  • scratch gets resized to the size of the Std430 representation of the item type
  • Writerwrites the Std430 representation to the scratch

What actually happened

Buffer gets partially written to the queue and logs an std::io::ErrorKind::WriteZero

Internally:

  • scratch gets resized to the size of the item type (which is smaller than the Std430 representation due to missing padding)
  • Writerwrites the Std430 representation to the scratch, which is too small, and therefore errors.

Additional information

All internal uses of StorageBuffer just happen to have data, which does not need to be padded to be aligned correctly.

I thew together a PR that should fix this (#4557)

@MonaMayrhofer MonaMayrhofer added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Apr 22, 2022
@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen and removed S-Needs-Triage This issue needs to be labelled labels Apr 22, 2022
@bors bors bot closed this as completed in 5585308 May 5, 2022
robtfm pushed a commit to robtfm/bevy that referenced this issue May 10, 2022
…ne#4557)

# Objective
Fixes bevyengine#4556

## Solution
StorageBuffer must use the Size of the std430 representation to calculate the buffer size, as the std430 representation is the data that will be written to it.
exjam pushed a commit to exjam/bevy that referenced this issue May 22, 2022
…ne#4557)

# Objective
Fixes bevyengine#4556

## Solution
StorageBuffer must use the Size of the std430 representation to calculate the buffer size, as the std430 representation is the data that will be written to it.
ItsDoot pushed a commit to ItsDoot/bevy that referenced this issue Feb 1, 2023
…ne#4557)

# Objective
Fixes bevyengine#4556

## Solution
StorageBuffer must use the Size of the std430 representation to calculate the buffer size, as the std430 representation is the data that will be written to it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants