| 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 "flutter/fml/macros.h"
9 #include "impeller/base/comparable.h"
10 #include "impeller/base/thread.h"
11 #include "impeller/renderer/backend/vulkan/device_holder.h"
12 #include "impeller/renderer/backend/vulkan/vk.h"
13 #include "impeller/renderer/shader_key.h"
14 #include "impeller/renderer/shader_library.h"
15
16 namespace impeller {
17
18 class ShaderLibraryVK final : public ShaderLibrary {
19 public:
20 // |ShaderLibrary|
21 ~ShaderLibraryVK() override;
22
23 // |ShaderLibrary|
24 bool IsValid() const override;
25
26 private:
27 friend class ContextVK;
28 std::weak_ptr<DeviceHolder> device_holder_;
29 const UniqueID library_id_;
30 mutable RWMutex functions_mutex_;
31 ShaderFunctionMap functions_ IPLR_GUARDED_BY(functions_mutex_);
32 bool is_valid_ = false;
33
34 ShaderLibraryVK(
35 std::weak_ptr<DeviceHolder> device_holder,
36 const std::vector<std::shared_ptr<fml::Mapping>>& shader_libraries_data);
37
38 // |ShaderLibrary|
39 std::shared_ptr<const ShaderFunction> GetFunction(std::string_view name,
40 ShaderStage stage) override;
41
42 // |ShaderLibrary|
43 void RegisterFunction(std::string name,
44 ShaderStage stage,
45 std::shared_ptr<fml::Mapping> code,
46 RegistrationCallback callback) override;
47
48 bool RegisterFunction(const std::string& name,
49 ShaderStage stage,
50 const std::shared_ptr<fml::Mapping>& code);
51
52 // |ShaderLibrary|
53 void UnregisterFunction(std::string name, ShaderStage stage) override;
54
55 ShaderLibraryVK(const ShaderLibraryVK&) = delete;
56
57 ShaderLibraryVK& operator=(const ShaderLibraryVK&) = delete;
58 };
59
60 } // namespace impeller
61
62 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_VULKAN_SHADER_LIBRARY_VK_H_
impeller::ShaderLibraryVK
Definition: shader_library_vk.h:18
device_holder.h
impeller::ShaderLibraryVK::~ShaderLibraryVK
~ShaderLibraryVK() override
shader_library.h
shader_key.h
impeller::ShaderLibrary::RegistrationCallback
std::function< void(bool)> RegistrationCallback
Definition: shader_library.h:31
impeller::ShaderLibrary
Definition: shader_library.h:21
impeller::ShaderStage
ShaderStage
Definition: shader_types.h:22
vk.h
impeller::ShaderFunctionMap
std::unordered_map< ShaderKey, std::shared_ptr< const ShaderFunction >, ShaderKey::Hash, ShaderKey::Equal > ShaderFunctionMap
Definition: shader_key.h:44
impeller::ContextVK
Definition: context_vk.h:40
comparable.h
IPLR_GUARDED_BY
#define IPLR_GUARDED_BY(x)
Definition: thread_safety.h:19
impeller::UniqueID
Definition: comparable.h:16
impeller::ShaderLibraryVK::IsValid
bool IsValid() const override
Definition: shader_library_vk.cc:87
thread.h
impeller
Definition: aiks_context.cc:10