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

buffer: copy unaligned data in GetFloatData #15247

Merged
merged 2 commits into from
Jul 9, 2024
Merged

Conversation

kzhsw
Copy link
Contributor

@kzhsw kzhsw commented Jul 3, 2024

In VertexBuffer.GetFloatData, if data is not aligned to 4 bytes, the current impl is to align the offset to make code work, but this would make data returned here differ from data passed to gpu, so algos depending on result of it could be wrong. This commit changes this behavior to copying the buffer on unaligned buffers or offsets.

Related playground: https://playground.babylonjs.com/#5T7E1W#8
Forum thread: https://forum.babylonjs.com/t/picked-point-at-wrong-position/51698
Related commit: 9c2df86

@bjsplat
Copy link
Collaborator

bjsplat commented Jul 3, 2024

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Jul 3, 2024

@bjsplat
Copy link
Collaborator

bjsplat commented Jul 3, 2024

@bjsplat
Copy link
Collaborator

bjsplat commented Jul 3, 2024

@RaananW
Copy link
Member

RaananW commented Jul 3, 2024

can you merge from master and update the branch?

Copy link
Member

@sebavan sebavan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure it is the right fix as it looks like a potential regression from last week PR. Cc @bghgary for review.

@bghgary
Copy link
Contributor

bghgary commented Jul 8, 2024

Not sure it is the right fix as it looks like a potential regression from last week PR. Cc @bghgary for review.

This is not a regression. See https://forum.babylonjs.com/t/picked-point-at-wrong-position/51698/24 for more details.

kzhsw added 2 commits July 9, 2024 08:34
In `VertexBuffer.GetFloatData`, if data is not aligned to 4 bytes, the current impl is to align the offset to make code work, but this would make data returned here differ from data passed to gpu, so algos depending on result of it could be wrong.
This commit changes this behavior to copying the buffer on unaligned buffers or offsets.

Related playground: <https://playground.babylonjs.com/#5T7E1W#8>
Forum thread: <https://forum.babylonjs.com/t/picked-point-at-wrong-position/51698>
@bghgary bghgary added the bug label Jul 9, 2024
@bghgary bghgary merged commit 2f1cf35 into BabylonJS:master Jul 9, 2024
12 checks passed
@kzhsw kzhsw deleted the patch-1 branch July 10, 2024 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants