createBuffer method
A storage buffer — the usages createStorageBuffer made before 1.0
folded it in here, with its whole contents given or none — is recorded
as createStorageBuffer, the event a trace has always carried for one;
any other buffer is passed on and noted as unrecorded.
Implementation
@override
StorageBuffer createBuffer(
BufferDescriptor descriptor, {
ByteData? contents,
}) {
final buffer = inner.createBuffer(descriptor, contents: contents);
final usage = descriptor.usage;
final traced =
usage.contains(BufferUsage.standardStorage) &&
_storageShaped.contains(usage) &&
(contents == null ||
contents.lengthInBytes == descriptor.lengthInBytes);
if (!traced) {
_unrecorded('createBuffer');
return buffer;
}
final indices = buffer.asIndices;
events.add(
TraceCreateStorageBuffer(
id: _name(_storageIds, buffer),
bytes: contents == null
? ByteData(descriptor.lengthInBytes)
: _copy(contents),
hostReadable: usage.contains(BufferUsage.hostReadable),
// Named as geometry, so a draw that binds it is recorded as one
// binding any other index buffer — `H11`.
indices: indices == null ? null : _name(_geometryIds, indices.backend),
),
);
return buffer;
}