Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
VulkanMemory.h
Go to the documentation of this file.
1/*
2* Copyright 2015 Google Inc.
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_VulkanMemory_DEFINED
9#define skgpu_VulkanMemory_DEFINED
10
15
16#include <functional>
17
18namespace skgpu {
19
20namespace VulkanMemory {
21 using CheckResult = bool(VkResult);
22
24 VkBuffer buffer,
26 bool shouldPersistentlyMapCpuToGpu,
27 const std::function<CheckResult>&,
28 VulkanAlloc* alloc);
29
31
33 VkImage image,
34 skgpu::Protected isProtected,
35 bool forceDedicatedMemory,
36 bool useLazyAllocation,
37 const std::function<CheckResult>&,
38 VulkanAlloc* alloc);
39
41
42 // Maps the entire skgpu::VulkanAlloc and returns a pointer to the start of the allocation.
43 // Underneath the hood, we may map more than the range of the skgpu::VulkanAlloc (e.g. the
44 // entire VkDeviceMemory), but the pointer returned will always be to the start of the
45 // skgpu::VulkanAlloc. The caller should also never assume more than the skgpu::VulkanAlloc
46 // block has been mapped.
48 const VulkanAlloc&,
49 const std::function<CheckResult>&);
50 void UnmapAlloc(VulkanMemoryAllocator*, const VulkanAlloc& alloc);
51
52 // For the Flush and Invalidate calls, the offset should be relative to the skgpu::VulkanAlloc.
53 // Thus this will often be 0. The client does not need to make sure the offset and size are
54 // aligned to the nonCoherentAtomSize, the internal calls will handle that.
56 const skgpu::VulkanAlloc&,
58 VkDeviceSize size,
59 const std::function<CheckResult>&);
61 const VulkanAlloc& alloc,
63 VkDeviceSize size,
64 const std::function<CheckResult>&);
65
66 // Helper for aligning and setting VkMappedMemoryRange for flushing/invalidating noncoherent
67 // memory.
70 VkDeviceSize size,
71 VkDeviceSize alignment,
73} // namespace VulkanMemory
74
75} // namespace skgpu
76
77#endif
sk_sp< SkImage > image
Definition examples.cpp:29
static const uint8_t buffer[]
void FreeBufferMemory(VulkanMemoryAllocator *, const VulkanAlloc &alloc)
bool AllocBufferMemory(VulkanMemoryAllocator *, VkBuffer buffer, skgpu::VulkanMemoryAllocator::BufferUsage, bool shouldPersistentlyMapCpuToGpu, const std::function< CheckResult > &, VulkanAlloc *alloc)
void GetNonCoherentMappedMemoryRange(const VulkanAlloc &, VkDeviceSize offset, VkDeviceSize size, VkDeviceSize alignment, VkMappedMemoryRange *)
void FreeImageMemory(VulkanMemoryAllocator *, const VulkanAlloc &alloc)
void * MapAlloc(VulkanMemoryAllocator *, const VulkanAlloc &, const std::function< CheckResult > &)
void FlushMappedAlloc(VulkanMemoryAllocator *, const skgpu::VulkanAlloc &, VkDeviceSize offset, VkDeviceSize size, const std::function< CheckResult > &)
bool AllocImageMemory(VulkanMemoryAllocator *, VkImage image, skgpu::Protected isProtected, bool forceDedicatedMemory, bool useLazyAllocation, const std::function< CheckResult > &, VulkanAlloc *alloc)
bool(VkResult) CheckResult
void UnmapAlloc(VulkanMemoryAllocator *, const VulkanAlloc &alloc)
void InvalidateMappedAlloc(VulkanMemoryAllocator *, const VulkanAlloc &alloc, VkDeviceSize offset, VkDeviceSize size, const std::function< CheckResult > &)
Protected
Definition GpuTypes.h:61
Point offset
uint64_t VkDeviceSize
Definition vulkan_core.h:96
VkResult