Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1b7085a

Browse files
beaufortfrancoiskdashg
authored andcommitted
Use COPY instead of TRANSFER for GPUBufferUsage and GPUTextureUsage (gpuweb#342)
* s/TRANSFER/COPY/g in GPUBufferUsage * Update index.bs * Update documentation
1 parent 3c15af0 commit 1b7085a

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

design/BufferOperations.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ The mapping starts filled with zeros.
119119
```js
120120
const readPixelsBuffer = device.createBuffer({
121121
size: 4,
122-
usage: GPUBufferUsage.MAP_READ | GPUBufferUsage.TRANSFER_DST,
122+
usage: GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST,
123123
});
124124

125125
// Commands copying a pixel from a texture into readPixelsBuffer are submitted
@@ -140,7 +140,7 @@ const size = model.computeVertexBufferSize();
140140

141141
const stagingVertexBuffer = device.createBuffer({
142142
size: size,
143-
usage: GPUBufferUsage.MAP_WRITE | GPUBufferUsage.TRANSFER_SRC,
143+
usage: GPUBufferUsage.MAP_WRITE | GPUBufferUsage.COPY_SRC,
144144
});
145145

146146
stagingVertexBuffer.mapWriteAsync().then((stagingData) => {
@@ -159,7 +159,7 @@ function bufferSubData(device, destBuffer, destOffset, srcArrayBuffer) {
159159
const byteCount = srcArrayBuffer.byteLength;
160160
const [srcBuffer, arrayBuffer] = device.createBufferMapped({
161161
size: byteCount,
162-
usage: GPUBufferUsage.TRANSFER_SRC
162+
usage: GPUBufferUsage.COPY_SRC
163163
});
164164
new Uint8Array(arrayBuffer).set(new Uint8Array(srcArrayBuffer)); // memcpy
165165
srcBuffer.unmap();
@@ -190,7 +190,7 @@ function AutoRingBuffer(device, chunkSize) {
190190
const size = chunkSize;
191191
const [buf, initialMap] = this.device.createBufferMapped({
192192
size: size,
193-
usage: GPUBufferUsage.MAP_WRITE | GPUBufferUsage.TRANSFER_SRC,
193+
usage: GPUBufferUsage.MAP_WRITE | GPUBufferUsage.COPY_SRC,
194194
});
195195

196196
let mapTyped;

design/UsageValidationRules.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ Buffers have the following usages (and commands inducing that usage):
77
- `INDEX` for `buffer` in calls to `WebGPUCommandEncoder.setIndexBuffer`
88
- `INDIRECT` for `indirectBuffer` in calls to `WebGPUCommandEncode.{draw|drawIndexed|dispatch}Indirect`
99
- `UBO` and `STORAGE` for buffers referenced by bindgroups passed to `setBindGroup`, with the usage corresponding to the binding's type.
10-
- `TRANSFER_SRC` for buffers used as the copy source of various commands.
11-
- `TRANSFER_DST` for buffers used as the copy destination of various commands.
10+
- `COPY_SRC` for buffers used as the copy source of various commands.
11+
- `COPY_DST` for buffers used as the copy destination of various commands.
1212
- (Maybe `STORAGE_TEXEL` and `UNIFORM_TEXEL`?)
1313

1414
Textures have the following usages:
1515
- `OUTPUT_ATTACHMENT` for the subresources referenced by `WebGPURenderPassDescriptor`
1616
- `SAMPLED` and `STORAGE` for subresources corresponding to the image views referenced by bindgroups passed to `setBindGroup`, with the usage corresponding to the binding's type.
17-
- `TRANSFER_SRC` for textures used as the copy source of various commands.
18-
- `TRANSFER_DST` for textures used as the copy destination of various commands.
17+
- `COPY_SRC` for textures used as the copy source of various commands.
18+
- `COPY_DST` for textures used as the copy destination of various commands.
1919

20-
Read only usages are `VERTEX`, `INDEX`, `INDIRECT`, `UBO`, `TRANSFER_SRC` and `SAMPLED`.
20+
Read only usages are `VERTEX`, `INDEX`, `INDIRECT`, `UBO`, `COPY_SRC` and `SAMPLED`.
2121

2222
## Render passes
2323

spec/index.bs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,16 @@ Buffers {#buffers}
6969
typedef u32 GPUBufferUsageFlags;
7070

7171
interface GPUBufferUsage {
72-
const u32 NONE = 0x0000;
73-
const u32 MAP_READ = 0x0001;
74-
const u32 MAP_WRITE = 0x0002;
75-
const u32 TRANSFER_SRC = 0x0004;
76-
const u32 TRANSFER_DST = 0x0008;
77-
const u32 INDEX = 0x0010;
78-
const u32 VERTEX = 0x0020;
79-
const u32 UNIFORM = 0x0040;
80-
const u32 STORAGE = 0x0080;
81-
const u32 INDIRECT = 0x0100;
72+
const u32 NONE = 0x0000;
73+
const u32 MAP_READ = 0x0001;
74+
const u32 MAP_WRITE = 0x0002;
75+
const u32 COPY_SRC = 0x0004;
76+
const u32 COPY_DST = 0x0008;
77+
const u32 INDEX = 0x0010;
78+
const u32 VERTEX = 0x0020;
79+
const u32 UNIFORM = 0x0040;
80+
const u32 STORAGE = 0x0080;
81+
const u32 INDIRECT = 0x0100;
8282
};
8383

8484
dictionary GPUBufferDescriptor : GPUObjectDescriptorBase {
@@ -184,8 +184,8 @@ typedef u32 GPUTextureUsageFlags;
184184

185185
interface GPUTextureUsage {
186186
const u32 NONE = 0x00;
187-
const u32 TRANSFER_SRC = 0x01;
188-
const u32 TRANSFER_DST = 0x02;
187+
const u32 COPY_SRC = 0x01;
188+
const u32 COPY_DST = 0x02;
189189
const u32 SAMPLED = 0x04;
190190
const u32 STORAGE = 0x08;
191191
const u32 OUTPUT_ATTACHMENT = 0x10;

0 commit comments

Comments
 (0)