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  const 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[slot.ext_res_0] = {.slot = slot, .view = {&metadata, view}};
27  return true;
28 }
29 
31  ShaderStage stage,
32  const SampledImageSlot& slot,
33  const ShaderMetadata& metadata,
34  const std::shared_ptr<const Texture>& texture,
35  const 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  if (!slot.HasSampler() || !slot.HasTexture()) {
47  return true;
48  }
49 
51  .slot = slot,
52  .texture = {&metadata, texture},
53  .sampler = {&metadata, sampler},
54  };
55 
56  return false;
57 }
58 
59 } // namespace impeller
impeller::ShaderUniformSlot::ext_res_0
size_t ext_res_0
Definition: shader_types.h:83
impeller::ShaderUniformSlot
Definition: shader_types.h:81
impeller::ShaderMetadata
Definition: shader_types.h:76
formats.h
impeller::ShaderStage
ShaderStage
Definition: shader_types.h:20
impeller::Bindings::buffers
std::map< size_t, BufferAndUniformSlot > buffers
Definition: command.h:79
validation.h
impeller::SampledImageSlot
Definition: shader_types.h:129
impeller::ComputeCommand::bindings
Bindings bindings
Definition: compute_command.h:52
impeller::Bindings::sampled_images
std::map< size_t, TextureAndSampler > sampled_images
Definition: command.h:78
impeller::ComputeCommand::BindResource
bool BindResource(ShaderStage stage, const ShaderUniformSlot &slot, const ShaderMetadata &metadata, const BufferView &view) override
Definition: compute_command.cc:14
impeller::SampledImageSlot::HasSampler
constexpr bool HasSampler() const
Definition: shader_types.h:138
impeller::TextureAndSampler
combines the texture, sampler and sampler slot information.
Definition: command.h:65
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:60
impeller::TextureAndSampler::slot
SampledImageSlot slot
Definition: command.h:66
impeller::BufferView
Definition: buffer_view.h:13
impeller::SampledImageSlot::sampler_index
size_t sampler_index
Definition: shader_types.h:132
impeller::SampledImageSlot::HasTexture
constexpr bool HasTexture() const
Definition: shader_types.h:136
compute_command.h
impeller::ShaderStage::kCompute
@ kCompute
impeller
Definition: aiks_context.cc:10