Skip to content

Commit

Permalink
Map buffer at creation
Browse files Browse the repository at this point in the history
  • Loading branch information
StuckiSimon committed Aug 18, 2024
1 parent fcb22b4 commit 528687c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions strahl-lib/src/path-tracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,8 @@ async function runPathTracer(
const materialBuffer = device.createBuffer({
label: "Material buffer",
size: bytesPerMaterial * materials.length,
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST,
//mappedAtCreation: true,
usage: GPUBufferUsage.STORAGE,
mappedAtCreation: true,
});

// CODE#BUFFER-MAPPING
Expand Down Expand Up @@ -451,7 +451,10 @@ async function runPathTracer(
}),
);

device.queue.writeBuffer(materialBuffer, 0, materialDataView.arrayBuffer);
const materialMapped = materialBuffer.getMappedRange();
const materialMappedData = new Uint8Array(materialMapped);
materialMappedData.set(new Uint8Array(materialDataView.arrayBuffer));
materialBuffer.unmap();

const computeBindGroupLayout = device.createBindGroupLayout({
label: "Static compute bind group layout",
Expand Down

0 comments on commit 528687c

Please sign in to comment.