| 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"
7 #include "impeller/renderer/backend/gles/buffer_bindings_gles.h"
8 #include "impeller/renderer/backend/gles/device_buffer_gles.h"
9 #include "impeller/renderer/backend/gles/test/mock_gles.h"
10 #include "impeller/renderer/command.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",
32 .members = {ShaderStructMemberMetadata{.type = ShaderType::kFloat,
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
buffer_view
BufferView buffer_view
Definition: blit_command_gles.cc:152
buffer_bindings_gles.h
impeller::AllocationSize< 1u >
impeller::BufferBindingsGLES
Sets up stage bindings for single draw call in the OpenGLES backend.
Definition: buffer_bindings_gles.h:27
impeller::BufferBindingsGLES::BindUniformData
bool BindUniformData(const ProcTableGLES &gl, const std::vector< TextureAndSampler > &bound_textures, const std::vector< BufferResource > &bound_buffers, Range texture_range, Range buffer_range)
Definition: buffer_bindings_gles.cc:222
impeller::DeviceBufferGLES
Definition: device_buffer_gles.h:20
command.h
device_buffer_gles.h
impeller::testing::TEST
TEST(AllocationSizeTest, CanCreateTypedAllocations)
Definition: allocation_size_unittests.cc:10
impeller
Definition: allocation.cc:12
impeller::BufferResource
Resource< BufferView > BufferResource
Definition: command.h:54
impeller::ShaderType::kFloat
@ kFloat
impeller::BufferView
Definition: buffer_view.h:19
impeller::DeviceBufferDescriptor
Definition: device_buffer_descriptor.h:14
impeller::DeviceBufferDescriptor::size
size_t size
Definition: device_buffer_descriptor.h:16
impeller::Range
Definition: range.h:13
impeller::ShaderMetadata
Definition: shader_types.h:72
impeller::ShaderMetadata::name
std::string name
Definition: shader_types.h:74
impeller::ShaderStructMemberMetadata
Definition: shader_types.h:63
impeller::ShaderStructMemberMetadata::type
ShaderType type
Definition: shader_types.h:64