5 #ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_BUFFER_BINDINGS_GLES_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_BUFFER_BINDINGS_GLES_H_
15 #include "third_party/abseil-cpp/absl/container/flat_hash_map.h"
37 const std::vector<ShaderStageIOSlot>& inputs,
38 const std::vector<ShaderStageBufferLayout>& layouts);
44 size_t vertex_offset);
47 const std::vector<TextureAndSampler>& bound_textures,
48 const std::vector<BufferResource>& bound_buffers,
56 FML_FRIEND_TEST(testing::BufferBindingsGLESTest, BindArrayData);
57 FML_FRIEND_TEST(testing::BufferBindingsGLESTest,
58 BindUniformDataVerticesAndMatrices);
62 struct VertexAttribPointer {
65 GLenum type = GL_FLOAT;
66 GLenum normalized = GL_FALSE;
70 std::vector<std::vector<VertexAttribPointer>> vertex_attrib_arrays_;
72 absl::flat_hash_map<std::string, GLint> uniform_locations_;
73 absl::flat_hash_map<std::string, std::pair<GLint, GLuint>> ubo_locations_;
75 using BindingMap = absl::flat_hash_map<std::string, std::vector<GLint>>;
76 BindingMap binding_map_ = {};
77 GLuint vertex_array_object_ = 0;
78 GLuint program_handle_ = GL_NONE;
79 bool use_ubo_ =
false;
81 const std::vector<GLint>& ComputeUniformLocations(
82 const ShaderMetadata* metadata);
84 bool ReadUniformsBindingsV2(
const ProcTableGLES& gl, GLuint program);
86 bool ReadUniformsBindingsV3(
const ProcTableGLES& gl, GLuint program);
88 GLint ComputeTextureLocation(
const ShaderMetadata* metadata);
90 bool BindUniformBuffer(
const ProcTableGLES& gl,
const BufferResource& buffer);
92 bool BindUniformBufferV2(
const ProcTableGLES& gl,
93 const BufferView& buffer,
94 const ShaderMetadata* metadata,
95 const DeviceBufferGLES& device_buffer_gles);
97 bool BindUniformBufferV3(
const ProcTableGLES& gl,
98 const BufferView& buffer,
99 const ShaderMetadata* metadata,
100 const DeviceBufferGLES& device_buffer_gles);
102 std::optional<size_t> BindTextures(
103 const ProcTableGLES& gl,
104 const std::vector<TextureAndSampler>& bound_textures,
107 size_t unit_start_index = 0);
114 void SetUniformBindings(
115 absl::flat_hash_map<std::string, GLint> uniform_locations) {
116 uniform_locations_ = std::move(uniform_locations);
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)
FML_TEST_CLASS(BufferBindingsGLESTest, BindUniformData)
Resource< BufferView > BufferResource