5 #ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_BUFFER_BINDINGS_GLES_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_BUFFER_BINDINGS_GLES_H_
10 #include "flutter/third_party/abseil-cpp/absl/container/flat_hash_map.h"
36 const std::vector<ShaderStageIOSlot>& inputs,
37 const std::vector<ShaderStageBufferLayout>& layouts);
43 size_t vertex_offset);
46 const std::vector<TextureAndSampler>& bound_textures,
47 const std::vector<BufferResource>& bound_buffers,
55 FML_FRIEND_TEST(testing::BufferBindingsGLESTest, BindArrayData);
59 struct VertexAttribPointer {
62 GLenum
type = GL_FLOAT;
63 GLenum normalized = GL_FALSE;
67 std::vector<std::vector<VertexAttribPointer>> vertex_attrib_arrays_;
69 absl::flat_hash_map<std::string, GLint> uniform_locations_;
70 absl::flat_hash_map<std::string, std::pair<GLint, GLuint>> ubo_locations_;
72 using BindingMap = absl::flat_hash_map<std::string, std::vector<GLint>>;
73 BindingMap binding_map_ = {};
74 GLuint vertex_array_object_ = 0;
75 GLuint program_handle_ = GL_NONE;
76 bool use_ubo_ =
false;
78 const std::vector<GLint>& ComputeUniformLocations(
79 const ShaderMetadata* metadata);
81 bool ReadUniformsBindingsV2(
const ProcTableGLES& gl, GLuint program);
83 bool ReadUniformsBindingsV3(
const ProcTableGLES& gl, GLuint program);
85 GLint ComputeTextureLocation(
const ShaderMetadata* metadata);
87 bool BindUniformBuffer(
const ProcTableGLES& gl,
const BufferResource& buffer);
89 bool BindUniformBufferV2(
const ProcTableGLES& gl,
90 const BufferView& buffer,
91 const ShaderMetadata* metadata,
92 const DeviceBufferGLES& device_buffer_gles);
94 bool BindUniformBufferV3(
const ProcTableGLES& gl,
95 const BufferView& buffer,
96 const ShaderMetadata* metadata,
97 const DeviceBufferGLES& device_buffer_gles);
99 std::optional<size_t> BindTextures(
100 const ProcTableGLES& gl,
101 const std::vector<TextureAndSampler>& bound_textures,
104 size_t unit_start_index = 0);
111 void SetUniformBindings(
112 absl::flat_hash_map<std::string, GLint> uniform_locations) {
113 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