summaryrefslogtreecommitdiff
path: root/chromium/gpu/vulkan/vulkan_shader_module.h
blob: 89c80f7853b418e2b3c8c215ccfa554b9993b03c (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
// 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_SHADER_MODULE_H_
#define GPU_VULKAN_VULKAN_SHADER_MODULE_H_

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

#include "base/macros.h"
#include "gpu/vulkan/vulkan_export.h"

namespace gpu {

class VulkanDeviceQueue;

class VULKAN_EXPORT VulkanShaderModule {
 public:
  enum class ShaderType {
    VERTEX,
    FRAGMENT,
  };

  VulkanShaderModule(VulkanDeviceQueue* device_queue);
  ~VulkanShaderModule();

  bool InitializeGLSL(ShaderType type,
                      std::string name,
                      std::string entry_point,
                      std::string source);
  bool InitializeSPIRV(ShaderType type,
                       std::string name,
                       std::string entry_point,
                       std::string source);
  void Destroy();

  bool IsValid() const { return handle_ != VK_NULL_HANDLE; }
  std::string GetErrorMessages() const { return error_messages_; }

  ShaderType shader_type() const { return shader_type_; }
  const std::string& name() const { return name_; }
  VkShaderModule handle() const { return handle_; }
  const std::string& entry_point() const { return entry_point_; }

 private:
  VulkanDeviceQueue* device_queue_ = nullptr;
  ShaderType shader_type_ = ShaderType::VERTEX;
  VkShaderModule handle_ = VK_NULL_HANDLE;
  std::string name_;
  std::string entry_point_;
  std::string error_messages_;

  DISALLOW_COPY_AND_ASSIGN(VulkanShaderModule);
};

}  // namespace gpu

#endif  // GPU_VULKAN_VULKAN_SHADER_MODULE_H_