summaryrefslogtreecommitdiff
path: root/chromium/gpu/vulkan/vulkan_image_view.h
blob: 4849632917f049c7c55da92edf9ca7dc4386dea8 (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
56
57
58
59
60
61
62
63
64
65
66
// Copyright (c) 2016 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_IMAGE_VIEW_H_
#define GPU_VULKAN_VULKAN_IMAGE_VIEW_H_

#include <vulkan/vulkan.h>

#include "base/macros.h"

namespace gpu {

class VulkanDeviceQueue;

class VulkanImageView {
 public:
  enum ImageType {
    IMAGE_TYPE_COLOR,
    IMAGE_TYPE_DEPTH,
    IMAGE_TYPE_STENCIL,
    IMAGE_TYPE_DEPTH_STENCIL,

    NUM_IMAGE_TYPES,
    IMAGE_TYPE_INVALID = -1,
  };

  explicit VulkanImageView(VulkanDeviceQueue* device_queue);
  ~VulkanImageView();

  bool Initialize(VkImage image,
                  VkImageViewType image_view_type,
                  ImageType image_type,
                  VkFormat format,
                  uint32_t width,
                  uint32_t height,
                  uint32_t base_mip_level,
                  uint32_t num_mips,
                  uint32_t base_layer_level,
                  uint32_t num_layers);
  void Destroy();

  ImageType image_type() const { return image_type_; }
  VkImageView handle() const { return handle_; }
  VkFormat format() const { return format_; }
  uint32_t width() const { return width_; }
  uint32_t height() const { return height_; }
  uint32_t mips() const { return mips_; }
  uint32_t layers() const { return layers_; }

 private:
  VulkanDeviceQueue* device_queue_ = nullptr;
  ImageType image_type_ = IMAGE_TYPE_INVALID;
  VkImageView handle_ = VK_NULL_HANDLE;
  VkFormat format_ = VK_FORMAT_UNDEFINED;
  uint32_t width_ = 0;
  uint32_t height_ = 0;
  uint32_t mips_ = 0;
  uint32_t layers_ = 0;

  DISALLOW_COPY_AND_ASSIGN(VulkanImageView);
};

}  // namespace gpu

#endif  // GPU_VULKAN_VULKAN_IMAGE_VIEW_H_