Skip to content

Commit a2cb4fe

Browse files
committed
gltfpack: Fix bufferView alignment
Instead of aligning *after* the offset for a buffer view was computed, we now align each chunk that is written to the binary. This makes sure that the start of the next chunk as well as the entire resulting buffer is 4b aligned.
1 parent 4f6a62b commit a2cb4fe

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tools/gltfpack.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3130,7 +3130,6 @@ bool process(cgltf_data* data, std::vector<Mesh>& meshes, const Settings& settin
31303130
}
31313131
else
31323132
{
3133-
bin.resize((bin.size() + 3) & ~3);
31343133
bin += view.data;
31353134
}
31363135

@@ -3139,6 +3138,9 @@ bool process(cgltf_data* data, std::vector<Mesh>& meshes, const Settings& settin
31393138

31403139
view.bytes = bin.size() - offset;
31413140
bytes[view.kind] += view.bytes;
3141+
3142+
// align each bufferView by 4 bytes
3143+
bin.resize((bin.size() + 3) & ~3);
31423144
}
31433145
append(json, "]");
31443146
}

0 commit comments

Comments
 (0)