Flutter Engine
 
Loading...
Searching...
No Matches
shader.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_LIB_GPU_SHADER_H_
6#define FLUTTER_LIB_GPU_SHADER_H_
7
8#include <algorithm>
9#include <memory>
10#include <string>
11
14#include "fml/memory/ref_ptr.h"
18
19namespace flutter {
20namespace gpu {
21
22/// An immutable collection of shaders loaded from a shader bundle asset.
23class Shader : public RefCountedDartWrappable<Shader> {
24 DEFINE_WRAPPERTYPEINFO();
26
27 public:
36
41
42 ~Shader() override;
43
45 std::string entrypoint,
47 std::shared_ptr<fml::Mapping> code_mapping,
48 std::vector<impeller::ShaderStageIOSlot> inputs,
49 std::vector<impeller::ShaderStageBufferLayout> layouts,
50 std::unordered_map<std::string, UniformBinding> uniform_structs,
51 std::unordered_map<std::string, TextureBinding> uniform_textures,
52 std::vector<impeller::DescriptorSetLayout> descriptor_set_layouts);
53
54 std::shared_ptr<const impeller::ShaderFunction> GetFunctionFromLibrary(
56
57 bool IsRegistered(Context& context);
58
59 bool RegisterSync(Context& context);
60
61 std::shared_ptr<impeller::VertexDescriptor> CreateVertexDescriptor() const;
62
63 const std::vector<impeller::DescriptorSetLayout>& GetDescriptorSetLayouts()
64 const;
65
67
68 const Shader::UniformBinding* GetUniformStruct(const std::string& name) const;
69
71 const std::string& name) const;
72
73 private:
74 Shader();
75
76 std::string entrypoint_;
78 std::shared_ptr<fml::Mapping> code_mapping_;
79 std::vector<impeller::ShaderStageIOSlot> inputs_;
80 std::vector<impeller::ShaderStageBufferLayout> layouts_;
81 std::unordered_map<std::string, UniformBinding> uniform_structs_;
82 std::unordered_map<std::string, TextureBinding> uniform_textures_;
83 std::vector<impeller::DescriptorSetLayout> descriptor_set_layouts_;
84
86};
87
88} // namespace gpu
89} // namespace flutter
90
91//----------------------------------------------------------------------------
92/// Exports
93///
94
95extern "C" {
96
99 flutter::gpu::Shader* wrapper,
100 Dart_Handle struct_name_handle);
101
104 flutter::gpu::Shader* wrapper,
105 Dart_Handle struct_name_handle,
106 Dart_Handle member_name_handle);
107
108} // extern "C"
109
110#endif // FLUTTER_LIB_GPU_SHADER_H_
An immutable collection of shaders loaded from a shader bundle asset.
Definition shader.h:23
const Shader::UniformBinding * GetUniformStruct(const std::string &name) const
Definition shader.cc:105
impeller::ShaderStage GetShaderStage() const
Definition shader.cc:96
static fml::RefPtr< Shader > Make(std::string entrypoint, impeller::ShaderStage stage, std::shared_ptr< fml::Mapping > code_mapping, std::vector< impeller::ShaderStageIOSlot > inputs, std::vector< impeller::ShaderStageBufferLayout > layouts, std::unordered_map< std::string, UniformBinding > uniform_structs, std::unordered_map< std::string, TextureBinding > uniform_textures, std::vector< impeller::DescriptorSetLayout > descriptor_set_layouts)
Definition shader.cc:38
bool IsRegistered(Context &context)
Definition shader.cc:64
bool RegisterSync(Context &context)
Definition shader.cc:69
std::shared_ptr< impeller::VertexDescriptor > CreateVertexDescriptor() const
Definition shader.cc:89
const std::vector< impeller::DescriptorSetLayout > & GetDescriptorSetLayouts() const
Definition shader.cc:101
const Shader::TextureBinding * GetUniformTexture(const std::string &name) const
Definition shader.cc:114
std::shared_ptr< const impeller::ShaderFunction > GetFunctionFromLibrary(impeller::ShaderLibrary &library)
Definition shader.cc:59
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
#define FLUTTER_GPU_EXPORT
Definition export.h:13
FLUTTER_GPU_EXPORT int InternalFlutterGpu_Shader_GetUniformMemberOffset(flutter::gpu::Shader *wrapper, Dart_Handle struct_name_handle, Dart_Handle member_name_handle)
Definition shader.cc:142
FLUTTER_GPU_EXPORT int InternalFlutterGpu_Shader_GetUniformStructSize(flutter::gpu::Shader *wrapper, Dart_Handle struct_name_handle)
Definition shader.cc:130
DEF_SWITCHES_START aot vmservice shared library name
Definition switch_defs.h:27
#define FML_FRIEND_MAKE_REF_COUNTED(T)
impeller::SampledImageSlot slot
Definition shader.h:38
impeller::ShaderMetadata metadata
Definition shader.h:39
impeller::ShaderMetadata metadata
Definition shader.h:30
impeller::ShaderUniformSlot slot
Definition shader.h:29
const impeller::ShaderStructMemberMetadata * GetMemberMetadata(const std::string &name) const
Definition shader.cc:20
Metadata required to bind a combined texture and sampler.
Metadata required to bind a buffer.