Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 size_t,
25 std::string_view label);
26 void freeGpuData() override;
27 VkBuffer vkBuffer() const { return fBuffer; }
28 VkBufferUsageFlags bufferUsageFlags() const { return fBufferUsageFlags; }
29
31 VkAccessFlags dstAccessMask,
32 VkPipelineStageFlags dstStageMask) const;
33
34private:
36 size_t,
39 VkBuffer,
40 const skgpu::VulkanAlloc&,
42 std::string_view label);
43
44 void onMap() override;
45 void onUnmap() override;
46
47 void internalMap(size_t readOffset, size_t readSize);
48 void internalUnmap(size_t flushOffset, size_t flushSize);
49
50 bool isMappable() const { return fAlloc.fFlags & skgpu::VulkanAlloc::kMappable_Flag; }
51
52 const VulkanSharedContext* vulkanSharedContext() const {
53 return static_cast<const VulkanSharedContext*>(this->sharedContext());
54 }
55
56 static VkPipelineStageFlags AccessMaskToPipelineSrcStageFlags(const VkAccessFlags accessFlags);
57
58 VkBuffer fBuffer;
59 skgpu::VulkanAlloc fAlloc;
60 const VkBufferUsageFlags fBufferUsageFlags;
61 mutable VkAccessFlags fCurrentAccessMask = 0;
62
63 /**
64 * Buffers can either be mapped for:
65 * 1) Reading from the CPU (The effect of writing would be undefined)
66 * 2) Writing from the CPU (The existing contents are discarded. Even in the case where the
67 * initial contents are overwritten, CPU reads should be avoided for performance reasons as
68 * the memory may not be cached).
69 */
70 bool fBufferUsedForCPURead = false;
71};
72
73} // namespace skgpu::graphite
74
75#endif // skgpu_graphite_VulkanBuffer_DEFINED
76
const SharedContext * sharedContext() const
Definition Resource.h:187
VkBufferUsageFlags bufferUsageFlags() const
static sk_sp< Buffer > Make(const VulkanSharedContext *, size_t, BufferType, AccessPattern, std::string_view label)
void setBufferAccess(VulkanCommandBuffer *buffer, VkAccessFlags dstAccessMask, VkPipelineStageFlags dstStageMask) const
static const uint8_t buffer[]
VkFlags VkPipelineStageFlags
VkFlags VkAccessFlags
VkFlags VkBufferUsageFlags