Flutter Engine
The Flutter Engine
command.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
6
7#include <utility>
8
12
13namespace impeller {
14
16 if (buffer.index_type == IndexType::kUnknown) {
17 VALIDATION_LOG << "Cannot bind vertex buffer with an unknown index type.";
18 return false;
19 }
20
21 vertex_buffer = std::move(buffer);
22 return true;
23}
24
27 const ShaderUniformSlot& slot,
28 const ShaderMetadata& metadata,
29 BufferView view) {
30 return DoBindResource(stage, slot, &metadata, std::move(view));
31}
32
34 ShaderStage stage,
36 const ShaderUniformSlot& slot,
37 const std::shared_ptr<const ShaderMetadata>& metadata,
38 BufferView view) {
39 return DoBindResource(stage, slot, metadata, std::move(view));
40}
41
42template <class T>
43bool Command::DoBindResource(ShaderStage stage,
44 const ShaderUniformSlot& slot,
45 const T metadata,
46 BufferView view) {
48 if (!view) {
49 return false;
50 }
51
52 switch (stage) {
54 vertex_bindings.buffers.emplace_back(BufferAndUniformSlot{
55 .slot = slot, .view = BufferResource(metadata, std::move(view))});
56 return true;
58 fragment_bindings.buffers.emplace_back(BufferAndUniformSlot{
59 .slot = slot, .view = BufferResource(metadata, std::move(view))});
60 return true;
62 VALIDATION_LOG << "Use ComputeCommands for compute shader stages.";
64 return false;
65 }
66
67 return false;
68}
69
72 const SampledImageSlot& slot,
73 const ShaderMetadata& metadata,
74 std::shared_ptr<const Texture> texture,
75 const std::unique_ptr<const Sampler>& sampler) {
76 if (!sampler) {
77 return false;
78 }
79 if (!texture || !texture->IsValid()) {
80 return false;
81 }
82
83 switch (stage) {
85 vertex_bindings.sampled_images.emplace_back(TextureAndSampler{
86 .slot = slot,
87 .texture = {&metadata, std::move(texture)},
88 .sampler = sampler,
89 });
90 return true;
92 fragment_bindings.sampled_images.emplace_back(TextureAndSampler{
93 .slot = slot,
94 .texture = {&metadata, std::move(texture)},
95 .sampler = sampler,
96 });
97 return true;
99 VALIDATION_LOG << "Use ComputeCommands for compute shader stages.";
101 return false;
102 }
103
104 return false;
105}
106
107} // namespace impeller
GLenum type
static constexpr size_t kReservedVertexBufferIndex
#define FML_DCHECK(condition)
Definition: logging.h:103
FlTexture * texture
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
Resource< BufferView > BufferResource
Definition: command.h:57
#define T
Definition: precompiler.cc:65
std::vector< BufferAndUniformSlot > buffers
Definition: command.h:75
std::vector< TextureAndSampler > sampled_images
Definition: command.h:74
Bindings fragment_bindings
Definition: command.h:106
VertexBuffer vertex_buffer
The bound per-vertex data and optional index buffer.
Definition: command.h:151
bool BindVertices(VertexBuffer buffer)
Specify the vertex and index buffer to use for this command.
Bindings vertex_bindings
Definition: command.h:101
bool BindResource(ShaderStage stage, DescriptorType type, const ShaderUniformSlot &slot, const ShaderMetadata &metadata, BufferView view) override
#define VALIDATION_LOG
Definition: validation.h:73