Moved the WebGPU code off of "std140" and onto gpu-uniforms.

This commit is contained in:
Rezmason
2021-11-08 02:23:33 -08:00
parent 8f226be368
commit 61a3a6d783
10 changed files with 82 additions and 202 deletions

View File

@@ -44,14 +44,14 @@ const loadShader = async (device, url) => {
};
};
const makeUniformBuffer = (device, structLayout, values = null) => {
const makeUniformBuffer = (device, uniforms, data = null) => {
const buffer = device.createBuffer({
size: structLayout.size,
size: uniforms.minSize,
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
mappedAtCreation: values != null,
mappedAtCreation: data != null,
});
if (values != null) {
structLayout.build(values, buffer.getMappedRange());
if (data != null) {
uniforms.write(data, buffer.getMappedRange());
buffer.unmap();
}
return buffer;