forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuffer_bindings_gles.h
More file actions
86 lines (64 loc) · 2.83 KB
/
buffer_bindings_gles.h
File metadata and controls
86 lines (64 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_BUFFER_BINDINGS_GLES_H_
#define FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_BUFFER_BINDINGS_GLES_H_
#include <unordered_map>
#include <vector>
#include "impeller/core/shader_types.h"
#include "impeller/renderer/backend/gles/gles.h"
#include "impeller/renderer/backend/gles/proc_table_gles.h"
#include "impeller/renderer/command.h"
namespace impeller {
//------------------------------------------------------------------------------
/// @brief Sets up stage bindings for single draw call in the OpenGLES
/// backend.
///
class BufferBindingsGLES {
public:
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 vertex_offset) const;
bool BindUniformData(const ProcTableGLES& gl,
Allocator& transients_allocator,
const Bindings& vertex_bindings,
const Bindings& fragment_bindings);
bool UnbindVertexAttributes(const ProcTableGLES& gl) const;
private:
//----------------------------------------------------------------------------
/// @brief The arguments to glVertexAttribPointer.
///
struct VertexAttribPointer {
GLuint index = 0u;
GLint size = 4;
GLenum type = GL_FLOAT;
GLenum normalized = GL_FALSE;
GLsizei stride = 0u;
GLsizei offset = 0u;
};
std::vector<VertexAttribPointer> vertex_attrib_arrays_;
std::unordered_map<std::string, GLint> uniform_locations_;
std::vector<uint8_t> array_element_buffer_;
using BindingMap = std::unordered_map<std::string, std::vector<GLint>>;
BindingMap binding_map_ = {};
const std::vector<GLint>& ComputeUniformLocations(
const ShaderMetadata* metadata);
GLint ComputeTextureLocation(const ShaderMetadata* metadata);
bool BindUniformBuffer(const ProcTableGLES& gl,
Allocator& transients_allocator,
const BufferResource& buffer);
std::optional<size_t> BindTextures(const ProcTableGLES& gl,
const Bindings& bindings,
ShaderStage stage,
size_t unit_start_index = 0);
BufferBindingsGLES(const BufferBindingsGLES&) = delete;
BufferBindingsGLES& operator=(const BufferBindingsGLES&) = delete;
};
} // namespace impeller
#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_BUFFER_BINDINGS_GLES_H_