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

Skip to content
Closed
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
36 changes: 36 additions & 0 deletions spec/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,42 @@ Issue: Add client-side validation that a mapped buffer can only be unmapped and

</div>

## Buffer Uploads ## {#buffer-uploads}

*This section is non-normative.*

Modern graphics APIs have largely eschewed immediate data uploads in favor of mapping
host-visible buffers and enqueuing copies into other (especially device-local) buffers as needed.
Beginners in particular will want an easy way to upload new data for buffers without managing mappings.
We encourage use of helper functions (like below) until more sophisticated buffer and mapping management is required.
While copyDataToBuffer isn't always the most efficient approach, it is robust and easy to use for basic content.

<div class="example">
function copyDataToBuffer(device, queue, srcData, srcOffset,
dstBuffer, dstOffset, size)
{
size = size || (srcData.byteLength - srcOffset);

const [uploadBuf, map] = device.createBufferMapped({
size: size,
usage: GPUBufferUsage.COPY_SRC,
});
map.set(srcData, srcOffset);
uploadBuf.unmap();

const cenc = device.createCommandEncoder();
cenc.copyBufferToBuffer(uploadBuf, 0, dstBuffer, dstOffset, size);
const cbuf = cenc.finish();

queue.submit([cbuf]);
uploadBuf.destroy();
};
</div>

More sophisticated content may require batched or pipelined uploads, possibly with staging areas and
other tuned heuristics.
Instead of guessing the intent of the application, this API offers the primitive building blocks to
construct efficient abstractions for any usecase.

# Textures and Texture Views # {#textures}

Expand Down