42TEST(BufferBindingsGLESTest, BindUniformData) {
44 absl::flat_hash_map<std::string, GLint> uniform_bindings;
45 uniform_bindings[
"SHADERMETADATA.FOOBAR"] = 1;
46 bindings.SetUniformBindings(std::move(uniform_bindings));
47 auto mock_gles_impl = std::make_unique<MockGLESImpl>();
49 EXPECT_CALL(*mock_gles_impl, Uniform1fv(_, _, _)).Times(1);
52 std::vector<BufferResource> bound_buffers;
53 std::vector<TextureAndSampler> bound_textures;
56 .
name =
"shader_metadata",
61 .size =
sizeof(float),
62 .byte_length =
sizeof(
float),
63 .array_elements = std::nullopt,
65 std::shared_ptr<ReactorGLES>
reactor;
66 auto backing_store = std::make_unique<Allocation>();
67 ASSERT_TRUE(backing_store->Truncate(
Bytes{sizeof(float)}));
69 reactor, std::move(backing_store));
71 bound_buffers.push_back(
BufferResource(&shader_metadata, buffer_view));
74 bound_buffers,
Range{0, 0},
78TEST(BufferBindingsGLESTest, BindArrayData) {
80 absl::flat_hash_map<std::string, GLint> uniform_bindings;
81 uniform_bindings[
"SHADERMETADATA.FOOBAR[0]"] = 1;
82 bindings.SetUniformBindings(std::move(uniform_bindings));
83 auto mock_gles_impl = std::make_unique<MockGLESImpl>();
85 EXPECT_CALL(*mock_gles_impl, Uniform1fv(_, _, _)).Times(1);
88 std::vector<BufferResource> bound_buffers;
89 std::vector<TextureAndSampler> bound_textures;
92 .
name =
"shader_metadata",
97 .size =
sizeof(float),
98 .byte_length =
sizeof(
float) * 4,
101 std::shared_ptr<ReactorGLES>
reactor;
102 auto backing_store = std::make_unique<Allocation>();
103 ASSERT_TRUE(backing_store->Truncate(
Bytes{sizeof(float) * 4}));
106 std::move(backing_store));
108 bound_buffers.push_back(
BufferResource(&shader_metadata, buffer_view));
111 bound_buffers,
Range{0, 0},
115TEST(BufferBindingsGLESTest, BindUniformDataVerticesAndMatrices) {
117 absl::flat_hash_map<std::string, GLint> uniform_bindings;
118 uniform_bindings[
"SHADERMETADATA.VEC2"] = 1;
119 uniform_bindings[
"SHADERMETADATA.VEC3"] = 2;
120 uniform_bindings[
"SHADERMETADATA.VEC4"] = 3;
121 uniform_bindings[
"SHADERMETADATA.MAT2"] = 4;
122 uniform_bindings[
"SHADERMETADATA.MAT3"] = 5;
123 uniform_bindings[
"SHADERMETADATA.MAT4"] = 6;
124 bindings.SetUniformBindings(std::move(uniform_bindings));
125 auto mock_gles_impl = std::make_unique<MockGLESImpl>();
127 EXPECT_CALL(*mock_gles_impl, Uniform2fv(1, 1, _)).Times(1);
128 EXPECT_CALL(*mock_gles_impl, Uniform3fv(2, 1, _)).Times(1);
129 EXPECT_CALL(*mock_gles_impl, Uniform4fv(3, 1, _)).Times(1);
130 EXPECT_CALL(*mock_gles_impl, UniformMatrix2fv(4, 1, GL_FALSE, _)).Times(1);
131 EXPECT_CALL(*mock_gles_impl, UniformMatrix3fv(5, 1, GL_FALSE, _)).Times(1);
132 EXPECT_CALL(*mock_gles_impl, UniformMatrix4fv(6, 1, GL_FALSE, _)).Times(1);
135 std::vector<BufferResource> bound_buffers;
136 std::vector<TextureAndSampler> bound_textures;
145 .array_elements = std::nullopt,
146 .float_type = float_type};
150 .
name =
"shader_metadata",
160 std::shared_ptr<ReactorGLES>
reactor;
161 auto backing_store = std::make_unique<Allocation>();
162 ASSERT_TRUE(backing_store->Truncate(
Bytes{1024}));
164 std::move(backing_store));
166 bound_buffers.push_back(
BufferResource(&shader_metadata, buffer_view));
169 bound_buffers,
Range{0, 0},
179TEST(BufferBindingsGLESTest, BindUniformFailsWithoutFloatType) {
181 absl::flat_hash_map<std::string, GLint> uniform_bindings;
182 uniform_bindings[
"SHADERMETADATA.FOOBAR"] = 1;
183 bindings.SetUniformBindings(std::move(uniform_bindings));
184 auto mock_gles_impl = std::make_unique<MockGLESImpl>();
186 std::vector<BufferResource> bound_buffers;
187 std::vector<TextureAndSampler> bound_textures;
190 .
name =
"shader_metadata",
194 .size =
sizeof(float),
195 .byte_length =
sizeof(
float),
196 .array_elements = std::nullopt,
197 .float_type = std::nullopt}}};
198 std::shared_ptr<ReactorGLES>
reactor;
199 auto backing_store = std::make_unique<Allocation>();
200 ASSERT_TRUE(backing_store->Truncate(
Bytes{sizeof(float)}));
202 reactor, std::move(backing_store));
204 bound_buffers.push_back(
BufferResource(&shader_metadata, buffer_view));
207 bound_buffers,
Range{0, 0},
215TEST(BufferBindingsGLESTest, BindVertexAttributesSetsInstanceRateDivisor) {
216 auto mock_gles_impl = std::make_unique<::testing::NiceMock<MockGLESImpl>>();
217 EXPECT_CALL(*mock_gles_impl, VertexAttribDivisor(0, 0)).Times(1);
218 EXPECT_CALL(*mock_gles_impl, VertexAttribDivisor(1, 1)).Times(1);
229 .bit_width =
sizeof(float) * 8,
235 .
name =
"instance_offset",
240 .bit_width =
sizeof(float) * 8,
245 std::vector<ShaderStageIOSlot> inputs = {per_vertex_input,
247 std::vector<ShaderStageBufferLayout> layouts = {