Now that I can pack integer and float data into one uniform buffer, time.seconds can be represented as a float while time.frames is an integer.

This commit is contained in:
Rezmason
2021-10-29 09:02:20 -07:00
parent f9b80224fe
commit 23d397fa11
2 changed files with 13 additions and 10 deletions

View File

@@ -91,8 +91,7 @@ export default async (canvas, config) => {
msdfStructLayout.build([config.glyphTextureColumns, config.glyphSequenceLength], msdfBuffer.getMappedRange());
msdfBuffer.unmap();
// prettier-ignore
const timeStructLayout = std140(["i32", "i32"]);
const timeStructLayout = std140(["f32", "i32"]);
const timeBuffer = device.createBuffer({
size: timeStructLayout.size,
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.VERTEX | GPUBufferUsage.FRAGMENT | GPUBufferUsage.COMPUTE | GPUBufferUsage.COPY_DST, // Which of these are necessary?
@@ -221,7 +220,7 @@ export default async (canvas, config) => {
updateCameraBuffer();
}
queue.writeBuffer(timeBuffer, 0, timeStructLayout.build([now, frame]));
queue.writeBuffer(timeBuffer, 0, timeStructLayout.build([now / 1000, frame]));
frame++;
renderPassConfig.colorAttachments[0].view = canvasContext.getCurrentTexture().createView();
@@ -233,7 +232,7 @@ export default async (canvas, config) => {
const commandBuffer = encoder.finish();
queue.submit([commandBuffer]);
// requestAnimationFrame(renderLoop);
requestAnimationFrame(renderLoop);
};
requestAnimationFrame(renderLoop);