/* * Copyright 2021 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef skgpu_graphite_BufferManager_DEFINED #define skgpu_graphite_BufferManager_DEFINED #include "include/core/SkRefCnt.h" #include "include/private/base/SkTArray.h" #include "src/gpu/BufferWriter.h" #include "src/gpu/graphite/Buffer.h" #include "src/gpu/graphite/DrawTypes.h" #include "src/gpu/graphite/ResourceTypes.h" #include "src/gpu/graphite/UploadBufferManager.h" #include <array> #include <tuple> namespace skgpu::graphite { class Caps; class Context; class DrawBufferManager; class GlobalCache; class QueueManager; class Recording; class ResourceProvider; /** * ScratchBuffer represents a GPU buffer object that is allowed to be reused across strictly * sequential tasks within a Recording. It can be used to sub-allocate multiple bindings. * When a ScratchBuffer gets deallocated, the underlying GPU buffer gets returned to the * originating DrawBufferManager for reuse. */ class ScratchBuffer final { … }; /** * DrawBufferManager controls writing to buffer data ranges within larger, cacheable Buffers and * automatically handles either mapping or copying via transfer buffer depending on what the GPU * hardware supports for the requested buffer type and use case. It is intended for repeatedly * uploading dynamic data to the GPU. */ class DrawBufferManager { … }; /** * The StaticBufferManager is the one-time-only analog to DrawBufferManager and provides "static" * Buffers to RenderSteps and other Context-lifetime-tied objects, where the Buffers' contents will * not change and can benefit from prioritizing GPU reads. The assumed use case is that they remain * read-only on the GPU as well, so a single static buffer can be shared by all Recorders. * * Unlike DrawBufferManager's getXWriter() functions that return both a Writer and a BindBufferInfo, * StaticBufferManager returns only a Writer and accepts a BindBufferInfo* as an argument. This will * be re-written with the final binding info for the GPU-private data once that can be determined * after *all* static buffers have been requested. */ class StaticBufferManager { … }; } // namespace skgpu::graphite #endif // skgpu_graphite_BufferManager_DEFINED