Skip to content

Use copyBufferToBuffer overload #500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@types/showdown": "^2.0.6",
"@types/stats.js": "^0.17.3",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@webgpu/types": "^0.1.53",
"@webgpu/types": "^0.1.60",
"chokidar": "^4.0.3",
"eslint": "^8.57.1",
"eslint-config-prettier": "^8.10.0",
Expand Down
8 changes: 1 addition & 7 deletions sample/a-buffer/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,13 +575,7 @@ const configure = () => {

for (let slice = 0; slice < numSlices; ++slice) {
// initialize the heads buffer
commandEncoder.copyBufferToBuffer(
headsInitBuffer,
0,
headsBuffer,
0,
headsInitBuffer.size
);
commandEncoder.copyBufferToBuffer(headsInitBuffer, headsBuffer);

const scissorX = 0;
const scissorY = slice * sliceHeight;
Expand Down
16 changes: 3 additions & 13 deletions sample/bitonicSort/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -756,10 +756,7 @@ SampleInitFactoryWebGPU(
);
commandEncoder.copyBufferToBuffer(
timestampQueryResolveBuffer,
0,
timestampQueryResultBuffer,
0,
2 * BigInt64Array.BYTES_PER_ELEMENT
timestampQueryResultBuffer
);
}
settings['Step Index'] = settings['Step Index'] + 1;
Expand Down Expand Up @@ -803,18 +800,11 @@ SampleInitFactoryWebGPU(
// Copy GPU accessible buffers to CPU accessible buffers
commandEncoder.copyBufferToBuffer(
elementsOutputBuffer,
0,
elementsStagingBuffer,
0,
elementsBufferSize
elementsStagingBuffer
);

commandEncoder.copyBufferToBuffer(
atomicSwapsOutputBuffer,
0,
atomicSwapsStagingBuffer,
0,
Uint32Array.BYTES_PER_ELEMENT
atomicSwapsStagingBuffer
);
}
device.queue.submit([commandEncoder.finish()]);
Expand Down
8 changes: 1 addition & 7 deletions sample/computeBoids/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,7 @@ function frame() {
usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ,
});
commandEncoder.resolveQuerySet(querySet, 0, 4, resolveBuffer, 0);
commandEncoder.copyBufferToBuffer(
resolveBuffer,
0,
resultBuffer,
0,
resultBuffer.size
);
commandEncoder.copyBufferToBuffer(resolveBuffer, resultBuffer);
}

device.queue.submit([commandEncoder.finish()]);
Expand Down
2 changes: 1 addition & 1 deletion sample/occlusionQuery/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ function render(now: number) {
pass.end();
encoder.resolveQuerySet(querySet, 0, objectInfos.length, resolveBuf, 0);
if (resultBuf.mapState === 'unmapped') {
encoder.copyBufferToBuffer(resolveBuf, 0, resultBuf, 0, resultBuf.size);
encoder.copyBufferToBuffer(resolveBuf, resultBuf);
}

device.queue.submit([encoder.finish()]);
Expand Down
5 changes: 1 addition & 4 deletions sample/timestampQuery/TimestampQueryManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@ export default class TimestampQueryManager {
// Copy values to the mappable buffer
commandEncoder.copyBufferToBuffer(
this.#timestampBuffer,
0,
this.#timestampMapBuffer,
0,
this.#timestampBuffer.size
this.#timestampMapBuffer
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion sample/workloadSimulator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ <h2><center>Web graphics workload simulator</center></h2>
new Float32Array(buffer.getMappedRange()).set(mapAsyncArray);
buffer.unmap();
const commandEncoder = device.createCommandEncoder();
commandEncoder.copyBufferToBuffer(buffer, 0, mapAsyncTargetBuffer, 0, mapAsyncArray.byteLength);
commandEncoder.copyBufferToBuffer(buffer, mapAsyncTargetBuffer);
// TODO: combine this submit with the main one, but we'll have to delay calling mapAsync until after the submit.
device.queue.submit([commandEncoder.finish()]);
// TODO: use this data during rendering.
Expand Down