| 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
8 #include "impeller/base/comparable.h"
9 #include "impeller/base/thread.h"
10 #include "impeller/renderer/backend/vulkan/device_holder_vk.h"
11 #include "impeller/renderer/backend/vulkan/vk.h"
12 #include "impeller/renderer/shader_key.h"
13 #include "impeller/renderer/shader_library.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
33 ShaderLibraryVK(
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_
impeller::ContextVK
Definition: context_vk.h:66
impeller::ShaderLibrary
Definition: shader_library.h:20
impeller::ShaderLibrary::RegistrationCallback
std::function< void(bool)> RegistrationCallback
Definition: shader_library.h:30
impeller::ShaderLibraryVK
Definition: shader_library_vk.h:17
impeller::ShaderLibraryVK::~ShaderLibraryVK
~ShaderLibraryVK() override
impeller::ShaderLibraryVK::IsValid
bool IsValid() const override
Definition: shader_library_vk.cc:87
comparable.h
device_holder_vk.h
impeller
Definition: allocation.cc:12
impeller::ShaderFunctionMap
std::unordered_map< ShaderKey, std::shared_ptr< const ShaderFunction >, ShaderKey::Hash, ShaderKey::Equal > ShaderFunctionMap
Definition: shader_key.h:43
impeller::ShaderStage
ShaderStage
Definition: shader_types.h:22
shader_key.h
shader_library.h
impeller::UniqueID
Definition: comparable.h:16
thread.h
IPLR_GUARDED_BY
#define IPLR_GUARDED_BY(x)
Definition: thread_safety.h:19
vk.h