Flutter Impeller
compute_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 
10 #include "impeller/core/formats.h"
11 
12 namespace impeller {
13 
15  const ShaderUniformSlot& slot,
16  const ShaderMetadata& metadata,
17  BufferView view) {
18  if (stage != ShaderStage::kCompute) {
19  VALIDATION_LOG << "Use Command for non-compute shader stages.";
20  return false;
21  }
22  if (!view) {
23  return false;
24  }
25 
26  bindings.buffers.emplace_back(
27  BufferAndUniformSlot{.slot = slot, .view = {&metadata, std::move(view)}});
28  return true;
29 }
30 
32  const SampledImageSlot& slot,
33  const ShaderMetadata& metadata,
34  std::shared_ptr<const Texture> texture,
35  std::shared_ptr<const Sampler> sampler) {
36  if (stage != ShaderStage::kCompute) {
37  VALIDATION_LOG << "Use Command for non-compute shader stages.";
38  return false;
39  }
40  if (!sampler || !sampler->IsValid()) {
41  return false;
42  }
43  if (!texture || !texture->IsValid()) {
44  return false;
45  }
46 
48  .slot = slot,
49  .texture = {&metadata, std::move(texture)},
50  .sampler = std::move(sampler),
51  });
52 
53  return false;
54 }
55 
56 } // namespace impeller
impeller::ComputeCommand::BindResource
bool BindResource(ShaderStage stage, const ShaderUniformSlot &slot, const ShaderMetadata &metadata, BufferView view) override
Definition: compute_command.cc:14
impeller::ShaderUniformSlot
Metadata required to bind a buffer.
Definition: shader_types.h:81
impeller::ShaderMetadata
Definition: shader_types.h:72
formats.h
impeller::Bindings::sampled_images
std::vector< TextureAndSampler > sampled_images
Definition: command.h:74
impeller::ShaderStage
ShaderStage
Definition: shader_types.h:22
validation.h
impeller::SampledImageSlot
Metadata required to bind a combined texture and sampler.
Definition: shader_types.h:98
impeller::ComputeCommand::bindings
Bindings bindings
Definition: compute_command.h:45
impeller::TextureAndSampler
combines the texture, sampler and sampler slot information.
Definition: command.h:61
impeller::BufferAndUniformSlot::slot
ShaderUniformSlot slot
Definition: command.h:69
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:67
impeller::TextureAndSampler::slot
SampledImageSlot slot
Definition: command.h:62
impeller::BufferView
Definition: buffer_view.h:13
impeller::Bindings::buffers
std::vector< BufferAndUniformSlot > buffers
Definition: command.h:75
compute_command.h
impeller::ShaderStage::kCompute
@ kCompute
impeller
Definition: aiks_context.cc:10
impeller::BufferAndUniformSlot
combines the buffer resource and its uniform slot information.
Definition: command.h:68