summaryrefslogtreecommitdiff
path: root/chromium/third_party/dawn/src/tint/reader/spirv/entry_point_info.h
blob: 0884eb2a19a44de99bf87fe1627cd2f028571c44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Copyright 2020 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef SRC_TINT_READER_SPIRV_ENTRY_POINT_INFO_H_
#define SRC_TINT_READER_SPIRV_ENTRY_POINT_INFO_H_

#include <cstdint>
#include <string>
#include <vector>

#include "src/tint/ast/pipeline_stage.h"

namespace tint::reader::spirv {

/// The size of an integer-coordinate grid, in the x, y, and z dimensions.
struct GridSize {
  /// x value
  uint32_t x = 0;
  /// y value
  uint32_t y = 0;
  /// z value
  uint32_t z = 0;
};

/// Entry point information for a function
struct EntryPointInfo {
  /// Constructor.
  /// @param the_name the name of the entry point
  /// @param the_stage the pipeline stage
  /// @param the_owns_inner_implementation if true, this entry point is
  /// responsible for generating the inner implementation function.
  /// @param the_inner_name the name of the inner implementation function of the
  /// entry point
  /// @param the_inputs list of IDs for Input variables used by the shader
  /// @param the_outputs list of IDs for Output variables used by the shader
  /// @param the_wg_size the workgroup_size, for a compute shader
  EntryPointInfo(std::string the_name,
                 ast::PipelineStage the_stage,
                 bool the_owns_inner_implementation,
                 std::string the_inner_name,
                 std::vector<uint32_t>&& the_inputs,
                 std::vector<uint32_t>&& the_outputs,
                 GridSize the_wg_size);
  /// Copy constructor
  /// @param other the other entry point info to be built from
  EntryPointInfo(const EntryPointInfo& other);
  /// Destructor
  ~EntryPointInfo();

  /// The entry point name.
  /// In the WGSL output, this function will have pipeline inputs and outputs
  /// as parameters. This function will store them into Private variables,
  /// and then call the "inner" function, named by the next memeber.
  /// Then outputs are copied from the private variables to the return value.
  std::string name;
  /// The entry point stage
  ast::PipelineStage stage = ast::PipelineStage::kNone;

  /// True when this entry point is responsible for generating the
  /// inner implementation function.  False when this is the second entry
  /// point encountered for the same function in SPIR-V. It's unusual, but
  /// possible for the same function to be the implementation for multiple
  /// entry points.
  bool owns_inner_implementation;
  /// The name of the inner implementation function of the entry point.
  std::string inner_name;
  /// IDs of pipeline input variables, sorted and without duplicates.
  std::vector<uint32_t> inputs;
  /// IDs of pipeline output variables, sorted and without duplicates.
  std::vector<uint32_t> outputs;

  /// If this is a compute shader, this is the workgroup size in the x, y,
  /// and z dimensions set via LocalSize, or via the composite value
  /// decorated as the WorkgroupSize BuiltIn.  The WorkgroupSize builtin
  /// takes priority.
  GridSize workgroup_size;
};

}  // namespace tint::reader::spirv

#endif  // SRC_TINT_READER_SPIRV_ENTRY_POINT_INFO_H_