1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef COMPONENTS_VIZ_COMMON_GPU_VULKAN_CONTEXT_PROVIDER_H_ 6 #define COMPONENTS_VIZ_COMMON_GPU_VULKAN_CONTEXT_PROVIDER_H_ 7 8 #include <vector> 9 10 #include "base/callback.h" 11 #include "base/memory/ref_counted.h" 12 #include "components/viz/common/viz_vulkan_context_provider_export.h" 13 #include "third_party/vulkan/include/vulkan/vulkan.h" 14 15 class GrContext; 16 class GrVkSecondaryCBDrawContext; 17 18 namespace gpu { 19 class VulkanDeviceQueue; 20 class VulkanImplementation; 21 } 22 23 namespace viz { 24 25 // The VulkanContextProvider groups sharing of vulkan objects synchronously. 26 class VIZ_VULKAN_CONTEXT_PROVIDER_EXPORT VulkanContextProvider 27 : public base::RefCountedThreadSafe<VulkanContextProvider> { 28 public: 29 virtual gpu::VulkanImplementation* GetVulkanImplementation() = 0; 30 virtual gpu::VulkanDeviceQueue* GetDeviceQueue() = 0; 31 virtual GrContext* GetGrContext() = 0; 32 33 // Get the current SecondaryCBDrawContext for the default render target. 34 virtual GrVkSecondaryCBDrawContext* GetGrSecondaryCBDrawContext() = 0; 35 36 // Enqueue semaphores which will be submitted with GrSecondaryCB to device 37 // queue for signalling. 38 virtual void EnqueueSecondaryCBSemaphores( 39 std::vector<VkSemaphore> semaphores) = 0; 40 41 // Enqueue task which will be executed after the GrSecondaryCB and post submit 42 // semphores are submitted. 43 virtual void EnqueueSecondaryCBPostSubmitTask(base::OnceClosure closure) = 0; 44 45 protected: 46 friend class base::RefCountedThreadSafe<VulkanContextProvider>; ~VulkanContextProvider()47 virtual ~VulkanContextProvider() {} 48 }; 49 50 } // namespace viz 51 52 #endif // COMPONENTS_VIZ_COMMON_GPU_VULKAN_CONTEXT_PROVIDER_H_ 53