Flutter Impeller
buffer_bindings_gles_unittests.cc
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "flutter/testing/testing.h" // IWYU pragma: keep
6 #include "gtest/gtest.h"
9 #include "impeller/renderer/backend/gles/test/mock_gles.h"
11 
12 namespace impeller {
13 namespace testing {
14 
15 using ::testing::_;
16 
17 TEST(BufferBindingsGLESTest, BindUniformData) {
18  BufferBindingsGLES bindings;
19  absl::flat_hash_map<std::string, GLint> uniform_bindings;
20  uniform_bindings["SHADERMETADATA.FOOBAR"] = 1;
21  bindings.SetUniformBindings(std::move(uniform_bindings));
22  auto mock_gles_impl = std::make_unique<MockGLESImpl>();
23 
24  EXPECT_CALL(*mock_gles_impl, Uniform1fv(_, _, _)).Times(1);
25 
26  std::shared_ptr<MockGLES> mock_gl = MockGLES::Init(std::move(mock_gles_impl));
27  std::vector<BufferResource> bound_buffers;
28  std::vector<TextureAndSampler> bound_textures;
29 
30  ShaderMetadata shader_metadata = {
31  .name = "shader_metadata",
33  .name = "foobar",
34  .offset = 0,
35  .size = sizeof(float),
36  .byte_length = sizeof(float)}}};
37  std::shared_ptr<ReactorGLES> reactor;
38  std::shared_ptr<Allocation> backing_store = std::make_shared<Allocation>();
39  ASSERT_TRUE(backing_store->Truncate(Bytes{sizeof(float)}));
40  DeviceBufferGLES device_buffer(DeviceBufferDescriptor{.size = sizeof(float)},
41  reactor, backing_store);
42  BufferView buffer_view(&device_buffer, Range(0, sizeof(float)));
43  bound_buffers.push_back(BufferResource(&shader_metadata, buffer_view));
44 
45  EXPECT_TRUE(bindings.BindUniformData(mock_gl->GetProcTable(), bound_textures,
46  bound_buffers, Range{0, 0},
47  Range{0, 1}));
48 }
49 
50 } // namespace testing
51 } // namespace impeller
BufferView buffer_view
Sets up stage bindings for single draw call in the OpenGLES backend.
bool BindUniformData(const ProcTableGLES &gl, const std::vector< TextureAndSampler > &bound_textures, const std::vector< BufferResource > &bound_buffers, Range texture_range, Range buffer_range)
TEST(AllocationSizeTest, CanCreateTypedAllocations)
Resource< BufferView > BufferResource
Definition: command.h:54