summaryrefslogtreecommitdiff
path: root/chromium/gpu/vulkan/vulkan_instance.h
blob: 2b119789f58d1c275aff60508d5c77a917e3ff4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef GPU_VULKAN_VULKAN_INSTANCE_H_
#define GPU_VULKAN_VULKAN_INSTANCE_H_

#include <vulkan/vulkan.h>
#include <memory>

#include "base/check_op.h"
#include "base/component_export.h"
#include "base/macros.h"
#include "gpu/config/vulkan_info.h"
#include "ui/gfx/extension_set.h"

namespace gpu {

class COMPONENT_EXPORT(VULKAN) VulkanInstance {
 public:
  VulkanInstance();

  ~VulkanInstance();

  // Creates the vulkan instance.
  //
  // The extensions in |required_extensions| and the layers in |required_layers|
  // will be enabled in the created instance. See the "Extended Functionality"
  // section of vulkan specification for more information.
  bool Initialize(const std::vector<const char*>& required_extensions,
                  const std::vector<const char*>& required_layers);

  const VulkanInfo& vulkan_info() const { return vulkan_info_; }

  VkInstance vk_instance() { return vk_instance_; }

 private:
  bool CollectInfo();
  void Destroy();

  VulkanInfo vulkan_info_;

  VkInstance vk_instance_ = VK_NULL_HANDLE;
  bool debug_report_enabled_ = false;
#if DCHECK_IS_ON()
  VkDebugReportCallbackEXT error_callback_ = VK_NULL_HANDLE;
  VkDebugReportCallbackEXT warning_callback_ = VK_NULL_HANDLE;
#endif

  DISALLOW_COPY_AND_ASSIGN(VulkanInstance);
};

}  // namespace gpu

#endif  // GPU_VULKAN_VULKAN_INSTANCE_H_