Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
buffer_bindings_gles.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_GLES_BUFFER_BINDINGS_GLES_H_
6#define FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_BUFFER_BINDINGS_GLES_H_
7
8#include <vector>
9
15#include "third_party/abseil-cpp/absl/container/flat_hash_map.h"
16
17namespace impeller {
18
19namespace testing {
20FML_TEST_CLASS(BufferBindingsGLESTest, BindUniformData);
21FML_TEST_CLASS(BufferBindingsGLESTest, BindArrayData);
22FML_TEST_CLASS(BufferBindingsGLESTest, BindUniformDataVerticesAndMatrices);
23FML_TEST_CLASS(BufferBindingsGLESTest, BindUniformFailsWithoutFloatType);
24} // namespace testing
25
26//------------------------------------------------------------------------------
27/// @brief Sets up stage bindings for single draw call in the OpenGLES
28/// backend.
29///
31 public:
33
35
37 const ProcTableGLES& gl,
38 const std::vector<ShaderStageIOSlot>& inputs,
39 const std::vector<ShaderStageBufferLayout>& layouts);
40
41 bool ReadUniformsBindings(const ProcTableGLES& gl, GLuint program);
42
44 size_t binding,
45 size_t vertex_offset);
46
47 bool BindUniformData(const ProcTableGLES& gl,
48 const std::vector<TextureAndSampler>& bound_textures,
49 const std::vector<BufferResource>& bound_buffers,
50 Range texture_range,
51 Range buffer_range);
52
54
55 private:
56 FML_FRIEND_TEST(testing::BufferBindingsGLESTest, BindUniformData);
57 FML_FRIEND_TEST(testing::BufferBindingsGLESTest, BindArrayData);
58 FML_FRIEND_TEST(testing::BufferBindingsGLESTest,
59 BindUniformDataVerticesAndMatrices);
60 FML_FRIEND_TEST(testing::BufferBindingsGLESTest,
61 BindUniformFailsWithoutFloatType);
62 //----------------------------------------------------------------------------
63 /// @brief The arguments to glVertexAttribPointer.
64 ///
65 struct VertexAttribPointer {
66 GLuint index = 0u;
67 GLint size = 4;
68 GLenum type = GL_FLOAT;
69 GLenum normalized = GL_FALSE;
70 GLsizei stride = 0u;
71 GLsizei offset = 0u;
72 };
73 std::vector<std::vector<VertexAttribPointer>> vertex_attrib_arrays_;
74
75 absl::flat_hash_map<std::string, GLint> uniform_locations_;
76 absl::flat_hash_map<std::string, std::pair<GLint, GLuint>> ubo_locations_;
77
78 using BindingMap = absl::flat_hash_map<std::string, std::vector<GLint>>;
79 BindingMap binding_map_ = {};
80 GLuint vertex_array_object_ = 0;
81 GLuint program_handle_ = GL_NONE;
82 bool use_ubo_ = false;
83
84 const std::vector<GLint>& ComputeUniformLocations(
85 const ShaderMetadata* metadata);
86
87 bool ReadUniformsBindingsV2(const ProcTableGLES& gl, GLuint program);
88
89 bool ReadUniformsBindingsV3(const ProcTableGLES& gl, GLuint program);
90
91 GLint ComputeTextureLocation(const ShaderMetadata* metadata);
92
93 bool BindUniformBuffer(const ProcTableGLES& gl, const BufferResource& buffer);
94
95 bool BindUniformBufferV2(const ProcTableGLES& gl,
96 const BufferView& buffer,
97 const ShaderMetadata* metadata,
98 const DeviceBufferGLES& device_buffer_gles);
99
100 bool BindUniformBufferV3(const ProcTableGLES& gl,
101 const BufferView& buffer,
102 const ShaderMetadata* metadata,
103 const DeviceBufferGLES& device_buffer_gles);
104
105 std::optional<size_t> BindTextures(
106 const ProcTableGLES& gl,
107 const std::vector<TextureAndSampler>& bound_textures,
108 Range texture_range,
109 ShaderStage stage,
110 size_t unit_start_index = 0);
111
112 BufferBindingsGLES(const BufferBindingsGLES&) = delete;
113
114 BufferBindingsGLES& operator=(const BufferBindingsGLES&) = delete;
115
116 // For testing.
117 void SetUniformBindings(
118 absl::flat_hash_map<std::string, GLint> uniform_locations) {
119 uniform_locations_ = std::move(uniform_locations);
120 }
121};
122
123} // namespace impeller
124
125#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_BUFFER_BINDINGS_GLES_H_
Sets up stage bindings for single draw call in the OpenGLES backend.
bool BindVertexAttributes(const ProcTableGLES &gl, size_t binding, size_t vertex_offset)
bool ReadUniformsBindings(const ProcTableGLES &gl, GLuint program)
bool UnbindVertexAttributes(const ProcTableGLES &gl)
bool RegisterVertexStageInput(const ProcTableGLES &gl, const std::vector< ShaderStageIOSlot > &inputs, const std::vector< ShaderStageBufferLayout > &layouts)
bool BindUniformData(const ProcTableGLES &gl, const std::vector< TextureAndSampler > &bound_textures, const std::vector< BufferResource > &bound_buffers, Range texture_range, Range buffer_range)
#define FML_FRIEND_TEST(test_case_name, test_name)
Definition macros.h:47
#define FML_TEST_CLASS(test_case_name, test_name)
Definition macros.h:44
Resource< BufferView > BufferResource
Definition command.h:55
impeller::ShaderType type