Flutter Impeller
shader_library_vk.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter 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 FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SHADER_LIBRARY_VK_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SHADER_LIBRARY_VK_H_
7 
9 #include "impeller/base/thread.h"
14 
15 namespace impeller {
16 
17 class ShaderLibraryVK final : public ShaderLibrary {
18  public:
19  // |ShaderLibrary|
20  ~ShaderLibraryVK() override;
21 
22  // |ShaderLibrary|
23  bool IsValid() const override;
24 
25  private:
26  friend class ContextVK;
27  std::weak_ptr<DeviceHolderVK> device_holder_;
28  const UniqueID library_id_;
29  mutable RWMutex functions_mutex_;
30  ShaderFunctionMap functions_ IPLR_GUARDED_BY(functions_mutex_);
31  bool is_valid_ = false;
32 
34  std::weak_ptr<DeviceHolderVK> device_holder,
35  const std::vector<std::shared_ptr<fml::Mapping>>& shader_libraries_data);
36 
37  // |ShaderLibrary|
38  std::shared_ptr<const ShaderFunction> GetFunction(std::string_view name,
39  ShaderStage stage) override;
40 
41  // |ShaderLibrary|
42  void RegisterFunction(std::string name,
43  ShaderStage stage,
44  std::shared_ptr<fml::Mapping> code,
45  RegistrationCallback callback) override;
46 
47  bool RegisterFunction(const std::string& name,
48  ShaderStage stage,
49  const std::shared_ptr<fml::Mapping>& code);
50 
51  // |ShaderLibrary|
52  void UnregisterFunction(std::string name, ShaderStage stage) override;
53 
54  ShaderLibraryVK(const ShaderLibraryVK&) = delete;
55 
56  ShaderLibraryVK& operator=(const ShaderLibraryVK&) = delete;
57 };
58 
59 } // namespace impeller
60 
61 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SHADER_LIBRARY_VK_H_
std::function< void(bool)> RegistrationCallback
bool IsValid() const override
std::unordered_map< ShaderKey, std::shared_ptr< const ShaderFunction >, ShaderKey::Hash, ShaderKey::Equal > ShaderFunctionMap
Definition: shader_key.h:43
#define IPLR_GUARDED_BY(x)
Definition: thread_safety.h:19