#include "dawn/native/Buffer.h"
#include <cstdio>
#include <cstring>
#include <limits>
#include <string>
#include <utility>
#include "absl/container/flat_hash_map.h"
#include "absl/strings/str_format.h"
#include "dawn/common/Alloc.h"
#include "dawn/common/Assert.h"
#include "dawn/native/Adapter.h"
#include "dawn/native/CallbackTaskManager.h"
#include "dawn/native/ChainUtils.h"
#include "dawn/native/Commands.h"
#include "dawn/native/Device.h"
#include "dawn/native/DynamicUploader.h"
#include "dawn/native/ErrorData.h"
#include "dawn/native/EventManager.h"
#include "dawn/native/Instance.h"
#include "dawn/native/ObjectType_autogen.h"
#include "dawn/native/PhysicalDevice.h"
#include "dawn/native/Queue.h"
#include "dawn/native/SystemEvent.h"
#include "dawn/native/ValidationUtils_autogen.h"
#include "dawn/platform/DawnPlatform.h"
#include "dawn/platform/tracing/TraceEvent.h"
#include "partition_alloc/pointers/raw_ptr.h"
namespace dawn::native {
namespace {
struct MapRequestTask : TrackTaskCallback { … };
class ErrorBuffer final : public BufferBase { … };
wgpu::BufferUsage AddInternalUsages(const DeviceBase* device, wgpu::BufferUsage usage) { … }
static uint32_t sZeroSizedMappingData = …;
}
struct BufferBase::MapAsyncEvent : public EventManager::TrackedEvent { … };
struct BufferBase::MapAsyncEvent1 final : public BufferBase::MapAsyncEvent { … };
struct BufferBase::MapAsyncEvent2 final : public BufferBase::MapAsyncEvent { … };
ResultOrError<UnpackedPtr<BufferDescriptor>> ValidateBufferDescriptor(
DeviceBase* device,
const BufferDescriptor* descriptor) { … }
BufferBase::BufferBase(DeviceBase* device, const UnpackedPtr<BufferDescriptor>& descriptor)
: … { … }
BufferBase::BufferBase(DeviceBase* device,
const BufferDescriptor* descriptor,
ObjectBase::ErrorTag tag)
: … { … }
BufferBase::~BufferBase() { … }
void BufferBase::DestroyImpl() { … }
Ref<BufferBase> BufferBase::MakeError(DeviceBase* device, const BufferDescriptor* descriptor) { … }
ObjectType BufferBase::GetType() const { … }
uint64_t BufferBase::GetSize() const { … }
uint64_t BufferBase::GetAllocatedSize() const { … }
wgpu::BufferUsage BufferBase::GetInternalUsage() const { … }
wgpu::BufferUsage BufferBase::GetUsage() const { … }
wgpu::BufferUsage BufferBase::APIGetUsage() const { … }
wgpu::BufferMapState BufferBase::APIGetMapState() const { … }
MaybeError BufferBase::MapAtCreation() { … }
MaybeError BufferBase::MapAtCreationInternal() { … }
MaybeError BufferBase::ValidateCanUseOnQueueNow() const { … }
std::function<void()> BufferBase::PrepareMappingCallback(MapRequestID mapID,
WGPUBufferMapAsyncStatus status) { … }
void BufferBase::APIMapAsync(wgpu::MapMode mode,
size_t offset,
size_t size,
WGPUBufferMapCallback callback,
void* userdata) { … }
Future BufferBase::APIMapAsyncF(wgpu::MapMode mode,
size_t offset,
size_t size,
const BufferMapCallbackInfo& callbackInfo) { … }
Future BufferBase::APIMapAsync2(wgpu::MapMode mode,
size_t offset,
size_t size,
const WGPUBufferMapCallbackInfo2& callbackInfo) { … }
void* BufferBase::APIGetMappedRange(size_t offset, size_t size) { … }
const void* BufferBase::APIGetConstMappedRange(size_t offset, size_t size) { … }
void* BufferBase::GetMappedRange(size_t offset, size_t size, bool writable) { … }
void BufferBase::APIDestroy() { … }
uint64_t BufferBase::APIGetSize() const { … }
MaybeError BufferBase::CopyFromStagingBuffer() { … }
void BufferBase::APIUnmap() { … }
MaybeError BufferBase::Unmap() { … }
void BufferBase::UnmapInternal(WGPUBufferMapAsyncStatus callbackStatus) { … }
MaybeError BufferBase::ValidateMapAsync(wgpu::MapMode mode,
size_t offset,
size_t size,
WGPUBufferMapAsyncStatus* status) const { … }
bool BufferBase::CanGetMappedRange(bool writable, size_t offset, size_t size) const { … }
MaybeError BufferBase::ValidateUnmap() const { … }
void BufferBase::CallbackOnMapRequestCompleted(MapRequestID mapID,
WGPUBufferMapAsyncStatus status) { … }
bool BufferBase::NeedsInitialization() const { … }
void BufferBase::MarkUsedInPendingCommands() { … }
ExecutionSerial BufferBase::GetLastUsageSerial() const { … }
MaybeError BufferBase::UploadData(uint64_t bufferOffset, const void* data, size_t size) { … }
ExecutionSerial BufferBase::OnEndAccess() { … }
void BufferBase::OnBeginAccess() { … }
bool BufferBase::HasAccess() const { … }
bool BufferBase::IsDestroyed() const { … }
void BufferBase::SetInitialized(bool initialized) { … }
bool BufferBase::IsInitialized() const { … }
bool BufferBase::IsFullBufferRange(uint64_t offset, uint64_t size) const { … }
void BufferBase::DumpMemoryStatistics(MemoryDump* dump, const char* prefix) const { … }
}