chromium/third_party/dawn/src/dawn/native/Buffer.cpp

// Copyright 2017 The Dawn & Tint Authors
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
//    list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
//    this list of conditions and the following disclaimer in the documentation
//    and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
//    contributors may be used to endorse or promote products derived from
//    this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#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) {}

// GetMappedRange on a zero-sized buffer returns a pointer to this value.
static uint32_t sZeroSizedMappingData =;

}  // anonymous namespace

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) {}

// Buffer

BufferBase::BufferBase(DeviceBase* device, const UnpackedPtr<BufferDescriptor>& descriptor)
    :{}

BufferBase::BufferBase(DeviceBase* device,
                       const BufferDescriptor* descriptor,
                       ObjectBase::ErrorTag tag)
    :{}

BufferBase::~BufferBase() {}

void BufferBase::DestroyImpl() {}

// static
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 {}

}  // namespace dawn::native