Flutter Engine
 
Loading...
Searching...
No Matches
impeller::BufferBindingsGLES Class Reference

Sets up stage bindings for single draw call in the OpenGLES backend. More...

#include <buffer_bindings_gles.h>

Public Member Functions

 BufferBindingsGLES ()
 
 ~BufferBindingsGLES ()
 
bool RegisterVertexStageInput (const ProcTableGLES &gl, const std::vector< ShaderStageIOSlot > &inputs, const std::vector< ShaderStageBufferLayout > &layouts)
 
bool ReadUniformsBindings (const ProcTableGLES &gl, GLuint program)
 
bool BindVertexAttributes (const ProcTableGLES &gl, size_t binding, size_t vertex_offset)
 
bool BindUniformData (const ProcTableGLES &gl, const std::vector< TextureAndSampler > &bound_textures, const std::vector< BufferResource > &bound_buffers, Range texture_range, Range buffer_range)
 
bool UnbindVertexAttributes (const ProcTableGLES &gl)
 

Detailed Description

Sets up stage bindings for single draw call in the OpenGLES backend.

Definition at line 28 of file buffer_bindings_gles.h.

Constructor & Destructor Documentation

◆ BufferBindingsGLES()

impeller::BufferBindingsGLES::BufferBindingsGLES ( )
default

◆ ~BufferBindingsGLES()

impeller::BufferBindingsGLES::~BufferBindingsGLES ( )
default

References type.

Member Function Documentation

◆ BindUniformData()

bool impeller::BufferBindingsGLES::BindUniformData ( const ProcTableGLES gl,
const std::vector< TextureAndSampler > &  bound_textures,
const std::vector< BufferResource > &  bound_buffers,
Range  texture_range,
Range  buffer_range 
)

Definition at line 222 of file buffer_bindings_gles.cc.

227 {
228 for (auto i = 0u; i < buffer_range.length; i++) {
229 if (!BindUniformBuffer(gl, bound_buffers[buffer_range.offset + i])) {
230 return false;
231 }
232 }
233 std::optional<size_t> next_unit_index =
234 BindTextures(gl, bound_textures, texture_range, ShaderStage::kVertex);
235 if (!next_unit_index.has_value()) {
236 return false;
237 }
238 if (!BindTextures(gl, bound_textures, texture_range, ShaderStage::kFragment,
239 *next_unit_index)
240 .has_value()) {
241 return false;
242 }
243
244 return true;
245}

References i, impeller::kFragment, impeller::kVertex, impeller::Range::length, and impeller::Range::offset.

Referenced by impeller::EncodeCommandsInReactor(), impeller::testing::TEST(), and impeller::testing::TEST().

◆ BindVertexAttributes()

bool impeller::BufferBindingsGLES::BindVertexAttributes ( const ProcTableGLES gl,
size_t  binding,
size_t  vertex_offset 
)

Definition at line 194 of file buffer_bindings_gles.cc.

196 {
197 if (binding >= vertex_attrib_arrays_.size()) {
198 return false;
199 }
200
201 if (!gl.GetCapabilities()->IsES()) {
202 FML_DCHECK(vertex_array_object_ == 0);
203 gl.GenVertexArrays(1, &vertex_array_object_);
204 gl.BindVertexArray(vertex_array_object_);
205 }
206
207 for (const auto& array : vertex_attrib_arrays_[binding]) {
208 gl.EnableVertexAttribArray(array.index);
209 gl.VertexAttribPointer(array.index, // index
210 array.size, // size (must be 1, 2, 3, or 4)
211 array.type, // type
212 array.normalized, // normalized
213 array.stride, // stride
214 reinterpret_cast<const GLvoid*>(static_cast<GLsizei>(
215 vertex_offset + array.offset)) // pointer
216 );
217 }
218
219 return true;
220}
#define FML_DCHECK(condition)
Definition logging.h:122

References FML_DCHECK, and impeller::ProcTableGLES::GetCapabilities().

Referenced by impeller::BindVertexBuffer().

◆ ReadUniformsBindings()

bool impeller::BufferBindingsGLES::ReadUniformsBindings ( const ProcTableGLES gl,
GLuint  program 
)

Definition at line 101 of file buffer_bindings_gles.cc.

102 {
103 if (!gl.IsProgram(program)) {
104 return false;
105 }
106 program_handle_ = program;
107 if (gl.GetDescription()->GetGlVersion().IsAtLeast(Version{3, 0, 0})) {
108 return ReadUniformsBindingsV3(gl, program);
109 }
110 return ReadUniformsBindingsV2(gl, program);
111}

References impeller::ProcTableGLES::GetDescription(), impeller::DescriptionGLES::GetGlVersion(), and impeller::Version::IsAtLeast().

◆ RegisterVertexStageInput()

bool impeller::BufferBindingsGLES::RegisterVertexStageInput ( const ProcTableGLES gl,
const std::vector< ShaderStageIOSlot > &  inputs,
const std::vector< ShaderStageBufferLayout > &  layouts 
)

Definition at line 31 of file buffer_bindings_gles.cc.

34 {
35 std::vector<std::vector<VertexAttribPointer>> vertex_attrib_arrays(
36 layouts.size());
37 // Every layout corresponds to a vertex binding.
38 // As we record, separate the attributes into buckets for each layout in
39 // ascending order. We do this because later on, we'll need to associate each
40 // of the attributes with bound buffers corresponding to the binding.
41 for (auto layout_i = 0u; layout_i < layouts.size(); layout_i++) {
42 const auto& layout = layouts[layout_i];
43 for (const auto& input : p_inputs) {
44 if (input.binding != layout_i) {
45 continue;
46 }
47 VertexAttribPointer attrib;
48 attrib.index = input.location;
49 // Component counts must be 1, 2, 3 or 4. Do that validation now.
50 if (input.vec_size < 1u || input.vec_size > 4u) {
51 return false;
52 }
53 attrib.size = input.vec_size;
54 auto type = ToVertexAttribType(input.type);
55 if (!type.has_value()) {
56 return false;
57 }
58 attrib.type = type.value();
59 attrib.normalized = GL_FALSE;
60 attrib.offset = input.offset;
61 attrib.stride = layout.stride;
62 vertex_attrib_arrays[layout_i].push_back(attrib);
63 }
64 }
65 vertex_attrib_arrays_ = std::move(vertex_attrib_arrays);
66 return true;
67}
GLenum type
static int input(yyscan_t yyscanner)
constexpr std::optional< GLenum > ToVertexAttribType(ShaderType type)

References input(), impeller::ToVertexAttribType(), and type.

◆ UnbindVertexAttributes()

bool impeller::BufferBindingsGLES::UnbindVertexAttributes ( const ProcTableGLES gl)

Definition at line 247 of file buffer_bindings_gles.cc.

247 {
248 for (const auto& array : vertex_attrib_arrays_) {
249 for (const auto& attribute : array) {
250 gl.DisableVertexAttribArray(attribute.index);
251 }
252 }
253 if (!gl.GetCapabilities()->IsES()) {
254 gl.DeleteVertexArrays(1, &vertex_array_object_);
255 vertex_array_object_ = 0;
256 }
257
258 return true;
259}

References impeller::ProcTableGLES::GetCapabilities().

Referenced by impeller::EncodeCommandsInReactor().


The documentation for this class was generated from the following files: