Flutter Engine
The Flutter Engine
VulkanBuffer.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef skgpu_graphite_VulkanBuffer_DEFINED
9#define skgpu_graphite_VulkanBuffer_DEFINED
10
14
15namespace skgpu::graphite {
16
17class VulkanCommandBuffer;
18
19class VulkanBuffer final : public Buffer {
20public:
22 void freeGpuData() override;
23 VkBuffer vkBuffer() const { return fBuffer; }
24 VkBufferUsageFlags bufferUsageFlags() const { return fBufferUsageFlags; }
25
27 VkAccessFlags dstAccessMask,
28 VkPipelineStageFlags dstStageMask) const;
29
30private:
32 size_t,
35 VkBuffer,
36 const skgpu::VulkanAlloc&,
38
39 void onMap() override;
40 void onUnmap() override;
41
42 void internalMap(size_t readOffset, size_t readSize);
43 void internalUnmap(size_t flushOffset, size_t flushSize);
44
45 bool isMappable() const { return fAlloc.fFlags & skgpu::VulkanAlloc::kMappable_Flag; }
46
47 const VulkanSharedContext* vulkanSharedContext() const {
48 return static_cast<const VulkanSharedContext*>(this->sharedContext());
49 }
50
51 static VkPipelineStageFlags AccessMaskToPipelineSrcStageFlags(const VkAccessFlags accessFlags);
52
53 VkBuffer fBuffer;
54 skgpu::VulkanAlloc fAlloc;
55 const VkBufferUsageFlags fBufferUsageFlags;
56 mutable VkAccessFlags fCurrentAccessMask = 0;
57
58 /**
59 * Buffers can either be mapped for:
60 * 1) Reading from the CPU (The effect of writing would be undefined)
61 * 2) Writing from the CPU (The existing contents are discarded. Even in the case where the
62 * initial contents are overwritten, CPU reads should be avoided for performance reasons as
63 * the memory may not be cached).
64 */
65 bool fBufferUsedForCPURead = false;
66};
67
68} // namespace skgpu::graphite
69
70#endif // skgpu_graphite_VulkanBuffer_DEFINED
71
const SharedContext * sharedContext() const
Definition: Resource.h:189
VkBufferUsageFlags bufferUsageFlags() const
Definition: VulkanBuffer.h:24
static sk_sp< Buffer > Make(const VulkanSharedContext *, size_t, BufferType, AccessPattern)
void setBufferAccess(VulkanCommandBuffer *buffer, VkAccessFlags dstAccessMask, VkPipelineStageFlags dstStageMask) const
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
Definition: switches.h:126
VkFlags VkPipelineStageFlags
Definition: vulkan_core.h:2470
VkFlags VkAccessFlags
Definition: vulkan_core.h:2235
VkFlags VkBufferUsageFlags
Definition: vulkan_core.h:2582