Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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) {
86 .slot = slot,
87 .texture = {&metadata, std::move(texture)},
88 .sampler = sampler,
89 });
90 return true;
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
static constexpr size_t kReservedVertexBufferIndex
static const uint8_t buffer[]
#define FML_DCHECK(condition)
Definition logging.h:103
FlTexture * texture
Resource< BufferView > BufferResource
Definition command.h:57
#define T
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.
Definition command.cc:15
Bindings vertex_bindings
Definition command.h:101
bool BindResource(ShaderStage stage, DescriptorType type, const ShaderUniformSlot &slot, const ShaderMetadata &metadata, BufferView view) override
Definition command.cc:25
Metadata required to bind a combined texture and sampler.
Metadata required to bind a buffer.
size_t ext_res_0
ext_res_0 is the Metal binding value.
combines the texture, sampler and sampler slot information.
Definition command.h:61
SampledImageSlot slot
Definition command.h:62
#define VALIDATION_LOG
Definition validation.h:73