• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
11 #include "src/gpu/graphite/SharedContext.h"
12 
13 #include "include/gpu/vk/VulkanTypes.h"
14 #include "src/gpu/graphite/vk/VulkanCaps.h"
15 
16 namespace skgpu {
17 struct VulkanBackendContext;
18 struct VulkanInterface;
19 class VulkanMemoryAllocator;
20 }
21 
22 namespace skgpu::graphite {
23 
24 struct ContextOptions;
25 class VulkanCaps;
26 
27 class VulkanSharedContext final : public SharedContext {
28 public:
29     static sk_sp<SharedContext> Make(const VulkanBackendContext&, const ContextOptions&);
30     ~VulkanSharedContext() override;
31 
vulkanCaps()32     const VulkanCaps& vulkanCaps() const { return static_cast<const VulkanCaps&>(*this->caps()); }
33 
interface()34     const skgpu::VulkanInterface* interface() const { return fInterface.get(); }
35 
memoryAllocator()36     skgpu::VulkanMemoryAllocator* memoryAllocator() const { return fMemoryAllocator.get(); }
37 
device()38     VkDevice device() const { return fDevice; }
queueIndex()39     uint32_t  queueIndex() const { return fQueueIndex; }
40 
41     std::unique_ptr<ResourceProvider> makeResourceProvider(SingleOwner*) override;
42 
43     bool checkVkResult(VkResult result) const;
44 
45 private:
46     VulkanSharedContext(const VulkanBackendContext&,
47                         sk_sp<const skgpu::VulkanInterface> interface,
48                         sk_sp<skgpu::VulkanMemoryAllocator> memoryAllocator,
49                         std::unique_ptr<const VulkanCaps> caps);
50 
51     sk_sp<const skgpu::VulkanInterface> fInterface;
52     sk_sp<skgpu::VulkanMemoryAllocator> fMemoryAllocator;
53 
54     VkDevice fDevice;
55     uint32_t fQueueIndex;
56 };
57 
58 } // namespace skgpu::graphite
59 
60 #endif // skgpu_graphite_VulkanSharedContext_DEFINED
61 
62