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

Animometer Replace Magic Number with device.limits.minUniformBufferOffsetAllignment #336

Closed
5 changes: 4 additions & 1 deletion src/sample/animometer/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,10 @@ const init: SampleInit = async ({ canvas, pageState, gui }) => {
function configure() {
const numTriangles = settings.numTriangles;
const uniformBytes = 5 * Float32Array.BYTES_PER_ELEMENT;
const alignedUniformBytes = Math.ceil(uniformBytes / 256) * 256;
const minBufferAllignment = device.limits.minUniformBufferOffsetAlignment;
const alignedUniformBytes =
Math.ceil(uniformBytes / minBufferAllignment) * minBufferAllignment;

const alignedUniformFloats =
alignedUniformBytes / Float32Array.BYTES_PER_ELEMENT;
const uniformBuffer = device.createBuffer({
Expand Down
Loading