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"
38 const std::vector<ShaderStageIOSlot>& inputs,
39 const std::vector<ShaderStageBufferLayout>& layouts);
55 const std::vector<TextureAndSampler>& bound_textures,
56 const std::vector<BufferResource>& bound_buffers,
64 FML_FRIEND_TEST(testing::BufferBindingsGLESTest, BindArrayData);
65 FML_FRIEND_TEST(testing::BufferBindingsGLESTest,
66 BindUniformDataVerticesAndMatrices);
67 FML_FRIEND_TEST(testing::BufferBindingsGLESTest,
68 BindUniformFailsWithoutFloatType);
72 struct VertexAttribPointer {
75 GLenum type = GL_FLOAT;
76 GLenum normalized = GL_FALSE;
80 GLuint vertex_attrib_divisor = 0u;
82 std::vector<std::vector<VertexAttribPointer>> vertex_attrib_arrays_;
84 absl::flat_hash_map<std::string, GLint> uniform_locations_;
85 absl::flat_hash_map<std::string, std::pair<GLint, GLuint>> ubo_locations_;
87 using BindingMap = absl::flat_hash_map<std::string, std::vector<GLint>>;
88 BindingMap binding_map_ = {};
89 GLuint vertex_array_object_ = 0;
90 GLuint program_handle_ = GL_NONE;
91 bool use_ubo_ =
false;
93 const std::vector<GLint>& ComputeUniformLocations(
94 const ShaderMetadata* metadata);
96 bool ReadUniformsBindingsV2(
const ProcTableGLES& gl, GLuint program);
98 bool ReadUniformsBindingsV3(
const ProcTableGLES& gl, GLuint program);
100 GLint ComputeTextureLocation(
const ShaderMetadata* metadata);
102 bool BindUniformBuffer(
const ProcTableGLES& gl,
const BufferResource& buffer);
104 bool BindUniformBufferV2(
const ProcTableGLES& gl,
105 const BufferView& buffer,
106 const ShaderMetadata* metadata,
107 const DeviceBufferGLES& device_buffer_gles);
109 bool BindUniformBufferV3(
const ProcTableGLES& gl,
110 const BufferView& buffer,
111 const ShaderMetadata* metadata,
112 const DeviceBufferGLES& device_buffer_gles);
114 std::optional<size_t> BindTextures(
115 const ProcTableGLES& gl,
116 const std::vector<TextureAndSampler>& bound_textures,
119 size_t unit_start_index = 0);
126 void SetUniformBindings(
127 absl::flat_hash_map<std::string, GLint> uniform_locations) {
128 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, size_t instance=0)
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