24 : fResourceProvider(resourceProvider)
25 , fMinAlignment(caps->requiredTransferBufferAlignment()) {}
30 size_t requiredBytes,
size_t requiredAlignment) {
31 auto[bufferMapPtr, bindInfo] = this->makeBindInfo(requiredBytes,
33 "TextureUploadBuffer");
41std::tuple<
void*,
BindBufferInfo> UploadBufferManager::makeBindInfo(
42 size_t requiredBytes,
size_t requiredAlignment, std::string_view label) {
47 requiredAlignment =
std::max(requiredAlignment, fMinAlignment);
48 requiredBytes =
SkAlignTo(requiredBytes, requiredAlignment);
62 return {
nullptr, BindBufferInfo()};
65 BindBufferInfo bindInfo;
66 bindInfo.fBuffer =
buffer.get();
69 fUsedBuffers.push_back(std::move(
buffer));
70 return {bufferMapPtr, bindInfo};
74 fReusedBufferOffset =
SkAlignTo(fReusedBufferOffset, requiredAlignment);
75 if (fReusedBuffer && requiredBytes > fReusedBuffer->size() - fReusedBufferOffset) {
76 fUsedBuffers.push_back(std::move(fReusedBuffer));
84 fReusedBufferOffset = 0;
85 if (!fReusedBuffer || !fReusedBuffer->map()) {
86 fReusedBuffer =
nullptr;
87 return {
nullptr, BindBufferInfo()};
91 BindBufferInfo bindInfo;
92 bindInfo.fBuffer = fReusedBuffer.get();
93 bindInfo.fOffset = fReusedBufferOffset;
95 void* bufferMapPtr = fReusedBuffer->map();
97 bufferMapPtr = SkTAddOffset<void>(bufferMapPtr, fReusedBufferOffset);
99 fReusedBufferOffset += requiredBytes;
101 return {bufferMapPtr, bindInfo};
109 fUsedBuffers.clear();
112 fReusedBuffer->unmap();
122 fUsedBuffers.clear();
125 fReusedBuffer->unmap();
static constexpr size_t SkAlignTo(size_t x, size_t alignment)
void trackResource(sk_sp< Resource > resource)
void addResourceRef(sk_sp< Resource > resource)
sk_sp< Buffer > findOrCreateBuffer(size_t size, BufferType type, AccessPattern, std::string_view label)
std::tuple< TextureUploadWriter, BindBufferInfo > getTextureUploadWriter(size_t requiredBytes, size_t requiredAlignment)
void transferToRecording(Recording *)
UploadBufferManager(ResourceProvider *, const Caps *)
void transferToCommandBuffer(CommandBuffer *)
static float max(float r, float g, float b)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
static constexpr size_t kReusedBufferSize