Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
VulkanSharedContext.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_VulkanSharedContext_DEFINED
9#define skgpu_graphite_VulkanSharedContext_DEFINED
10
13
16
17namespace skgpu {
18struct VulkanBackendContext;
19struct VulkanInterface;
20class VulkanMemoryAllocator;
21}
22
23namespace skgpu::graphite {
24
25struct ContextOptions;
26class VulkanCaps;
27
28class VulkanSharedContext final : public SharedContext {
29public:
31 ~VulkanSharedContext() override;
32
33 const VulkanCaps& vulkanCaps() const { return static_cast<const VulkanCaps&>(*this->caps()); }
34
35 const skgpu::VulkanInterface* interface() const { return fInterface.get(); }
36
37 skgpu::VulkanMemoryAllocator* memoryAllocator() const { return fMemoryAllocator.get(); }
38
39 VkDevice device() const { return fDevice; }
40 uint32_t queueIndex() const { return fQueueIndex; }
41
42 std::unique_ptr<ResourceProvider> makeResourceProvider(SingleOwner*,
43 uint32_t recorderID,
44 size_t resourceBudget) override;
45
46 bool checkVkResult(VkResult result) const;
47
48 bool isDeviceLost() const override {
49 SkAutoMutexExclusive lock(fDeviceIsLostMutex);
50 return fDeviceIsLost;
51 }
52
53private:
57 std::unique_ptr<const VulkanCaps> caps);
58
61
62 VkDevice fDevice;
63 uint32_t fQueueIndex;
64
65 mutable SkMutex fDeviceIsLostMutex;
66 // TODO(b/322207523): consider refactoring to remove the mutable keyword from fDeviceIsLost.
67 mutable bool fDeviceIsLost SK_GUARDED_BY(fDeviceIsLostMutex) = false;
68 skgpu::VulkanDeviceLostContext fDeviceLostContext;
69 skgpu::VulkanDeviceLostProc fDeviceLostProc;
70};
71
72} // namespace skgpu::graphite
73
74#endif // skgpu_graphite_VulkanSharedContext_DEFINED
#define SK_GUARDED_BY(x)
T * get() const
Definition SkRefCnt.h:303
const Caps * caps() const
skgpu::VulkanMemoryAllocator * memoryAllocator() const
bool checkVkResult(VkResult result) const
const skgpu::VulkanInterface * interface() const
const VulkanCaps & vulkanCaps() const
std::unique_ptr< ResourceProvider > makeResourceProvider(SingleOwner *, uint32_t recorderID, size_t resourceBudget) override
static sk_sp< SharedContext > Make(const VulkanBackendContext &, const ContextOptions &)
GAsyncResult * result
void * VulkanDeviceLostContext
void(* VulkanDeviceLostProc)(VulkanDeviceLostContext faultContext, const std::string &description, const std::vector< VkDeviceFaultAddressInfoEXT > &addressInfos, const std::vector< VkDeviceFaultVendorInfoEXT > &vendorInfos, const std::vector< std::byte > &vendorBinaryData)
VkResult