18TEST(BufferBindingsGLESTest, BindUniformData) {
20 absl::flat_hash_map<std::string, GLint> uniform_bindings;
21 uniform_bindings[
"SHADERMETADATA.FOOBAR"] = 1;
22 bindings.SetUniformBindings(std::move(uniform_bindings));
23 auto mock_gles_impl = std::make_unique<MockGLESImpl>();
25 EXPECT_CALL(*mock_gles_impl, Uniform1fv(_, _, _)).Times(1);
27 std::shared_ptr<MockGLES> mock_gl =
MockGLES::Init(std::move(mock_gles_impl));
28 std::vector<BufferResource> bound_buffers;
29 std::vector<TextureAndSampler> bound_textures;
32 .
name =
"shader_metadata",
37 .size =
sizeof(float),
38 .byte_length =
sizeof(
float),
39 .array_elements = std::nullopt,
41 std::shared_ptr<ReactorGLES> reactor;
42 auto backing_store = std::make_unique<Allocation>();
43 ASSERT_TRUE(backing_store->Truncate(
Bytes{sizeof(float)}));
45 reactor, std::move(backing_store));
47 bound_buffers.push_back(
BufferResource(&shader_metadata, buffer_view));
49 EXPECT_TRUE(bindings.
BindUniformData(mock_gl->GetProcTable(), bound_textures,
50 bound_buffers,
Range{0, 0},
54TEST(BufferBindingsGLESTest, BindArrayData) {
56 absl::flat_hash_map<std::string, GLint> uniform_bindings;
57 uniform_bindings[
"SHADERMETADATA.FOOBAR[0]"] = 1;
58 bindings.SetUniformBindings(std::move(uniform_bindings));
59 auto mock_gles_impl = std::make_unique<MockGLESImpl>();
61 EXPECT_CALL(*mock_gles_impl, Uniform1fv(_, _, _)).Times(1);
63 std::shared_ptr<MockGLES> mock_gl =
MockGLES::Init(std::move(mock_gles_impl));
64 std::vector<BufferResource> bound_buffers;
65 std::vector<TextureAndSampler> bound_textures;
68 .
name =
"shader_metadata",
73 .size =
sizeof(float),
74 .byte_length =
sizeof(
float) * 4,
77 std::shared_ptr<ReactorGLES> reactor;
78 auto backing_store = std::make_unique<Allocation>();
79 ASSERT_TRUE(backing_store->Truncate(
Bytes{sizeof(float) * 4}));
82 std::move(backing_store));
84 bound_buffers.push_back(
BufferResource(&shader_metadata, buffer_view));
86 EXPECT_TRUE(bindings.
BindUniformData(mock_gl->GetProcTable(), bound_textures,
87 bound_buffers,
Range{0, 0},
91TEST(BufferBindingsGLESTest, BindUniformDataVerticesAndMatrices) {
93 absl::flat_hash_map<std::string, GLint> uniform_bindings;
94 uniform_bindings[
"SHADERMETADATA.VEC2"] = 1;
95 uniform_bindings[
"SHADERMETADATA.VEC3"] = 2;
96 uniform_bindings[
"SHADERMETADATA.VEC4"] = 3;
97 uniform_bindings[
"SHADERMETADATA.MAT2"] = 4;
98 uniform_bindings[
"SHADERMETADATA.MAT3"] = 5;
99 uniform_bindings[
"SHADERMETADATA.MAT4"] = 6;
100 bindings.SetUniformBindings(std::move(uniform_bindings));
101 auto mock_gles_impl = std::make_unique<MockGLESImpl>();
103 EXPECT_CALL(*mock_gles_impl, Uniform2fv(1, 1, _)).Times(1);
104 EXPECT_CALL(*mock_gles_impl, Uniform3fv(2, 1, _)).Times(1);
105 EXPECT_CALL(*mock_gles_impl, Uniform4fv(3, 1, _)).Times(1);
106 EXPECT_CALL(*mock_gles_impl, UniformMatrix2fv(4, 1, GL_FALSE, _)).Times(1);
107 EXPECT_CALL(*mock_gles_impl, UniformMatrix3fv(5, 1, GL_FALSE, _)).Times(1);
108 EXPECT_CALL(*mock_gles_impl, UniformMatrix4fv(6, 1, GL_FALSE, _)).Times(1);
110 std::shared_ptr<MockGLES> mock_gl =
MockGLES::Init(std::move(mock_gles_impl));
111 std::vector<BufferResource> bound_buffers;
112 std::vector<TextureAndSampler> bound_textures;
121 .array_elements = std::nullopt,
122 .float_type = float_type};
126 .
name =
"shader_metadata",
136 std::shared_ptr<ReactorGLES> reactor;
137 auto backing_store = std::make_unique<Allocation>();
138 ASSERT_TRUE(backing_store->Truncate(
Bytes{1024}));
140 std::move(backing_store));
142 bound_buffers.push_back(
BufferResource(&shader_metadata, buffer_view));
144 EXPECT_TRUE(bindings.
BindUniformData(mock_gl->GetProcTable(), bound_textures,
145 bound_buffers,
Range{0, 0},
155TEST(BufferBindingsGLESTest, BindUniformFailsWithoutFloatType) {
157 absl::flat_hash_map<std::string, GLint> uniform_bindings;
158 uniform_bindings[
"SHADERMETADATA.FOOBAR"] = 1;
159 bindings.SetUniformBindings(std::move(uniform_bindings));
160 auto mock_gles_impl = std::make_unique<MockGLESImpl>();
161 std::shared_ptr<MockGLES> mock_gl =
MockGLES::Init(std::move(mock_gles_impl));
162 std::vector<BufferResource> bound_buffers;
163 std::vector<TextureAndSampler> bound_textures;
166 .
name =
"shader_metadata",
170 .size =
sizeof(float),
171 .byte_length =
sizeof(
float),
172 .array_elements = std::nullopt,
173 .float_type = std::nullopt}}};
174 std::shared_ptr<ReactorGLES> reactor;
175 auto backing_store = std::make_unique<Allocation>();
176 ASSERT_TRUE(backing_store->Truncate(
Bytes{sizeof(float)}));
178 reactor, std::move(backing_store));
180 bound_buffers.push_back(
BufferResource(&shader_metadata, buffer_view));
182 EXPECT_FALSE(bindings.
BindUniformData(mock_gl->GetProcTable(), bound_textures,
183 bound_buffers,
Range{0, 0},