浏览代码

Merge pull request #20442 from pplux/webgpuattributtes-improper-4byte-alignment

Fixes size alignment in webgpu buffer creation
Michael Herzog 4 年之前
父节点
当前提交
73c668578f
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      examples/jsm/renderers/webgpu/WebGPUAttributes.js

+ 1 - 1
examples/jsm/renderers/webgpu/WebGPUAttributes.js

@@ -64,7 +64,7 @@ class WebGPUAttributes {
 	_createBuffer( attribute, usage ) {
 
 		const array = attribute.array;
-		const size = array.byteLength + ( array.byteLength % 4 ); // ensure 4 byte alignment
+		const size = array.byteLength + ( ( 4 - ( array.byteLength % 4 ) ) % 4 ); // ensure 4 byte alignment
 
 		const buffer = this.device.createBuffer( {
 			size: size,