1 // Copyright 2020 The Tint Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef SRC_READER_SPIRV_ENTRY_POINT_INFO_H_ 16 #define SRC_READER_SPIRV_ENTRY_POINT_INFO_H_ 17 18 #include <string> 19 #include <vector> 20 21 #include "src/ast/pipeline_stage.h" 22 23 namespace tint { 24 namespace reader { 25 namespace spirv { 26 27 /// The size of an integer-coordinate grid, in the x, y, and z dimensions. 28 struct GridSize { 29 /// x value 30 uint32_t x = 0; 31 /// y value 32 uint32_t y = 0; 33 /// z value 34 uint32_t z = 0; 35 }; 36 37 /// Entry point information for a function 38 struct EntryPointInfo { 39 /// Constructor. 40 /// @param the_name the name of the entry point 41 /// @param the_stage the pipeline stage 42 /// @param the_owns_inner_implementation if true, this entry point is 43 /// responsible for generating the inner implementation function. 44 /// @param the_inner_name the name of the inner implementation function of the 45 /// entry point 46 /// @param the_inputs list of IDs for Input variables used by the shader 47 /// @param the_outputs list of IDs for Output variables used by the shader 48 /// @param the_wg_size the workgroup_size, for a compute shader 49 EntryPointInfo(std::string the_name, 50 ast::PipelineStage the_stage, 51 bool the_owns_inner_implementation, 52 std::string the_inner_name, 53 std::vector<uint32_t>&& the_inputs, 54 std::vector<uint32_t>&& the_outputs, 55 GridSize the_wg_size); 56 /// Copy constructor 57 /// @param other the other entry point info to be built from 58 EntryPointInfo(const EntryPointInfo& other); 59 /// Destructor 60 ~EntryPointInfo(); 61 62 /// The entry point name. 63 /// In the WGSL output, this function will have pipeline inputs and outputs 64 /// as parameters. This function will store them into Private variables, 65 /// and then call the "inner" function, named by the next memeber. 66 /// Then outputs are copied from the private variables to the return value. 67 std::string name; 68 /// The entry point stage 69 ast::PipelineStage stage = ast::PipelineStage::kNone; 70 71 /// True when this entry point is responsible for generating the 72 /// inner implementation function. False when this is the second entry 73 /// point encountered for the same function in SPIR-V. It's unusual, but 74 /// possible for the same function to be the implementation for multiple 75 /// entry points. 76 bool owns_inner_implementation; 77 /// The name of the inner implementation function of the entry point. 78 std::string inner_name; 79 /// IDs of pipeline input variables, sorted and without duplicates. 80 std::vector<uint32_t> inputs; 81 /// IDs of pipeline output variables, sorted and without duplicates. 82 std::vector<uint32_t> outputs; 83 84 /// If this is a compute shader, this is the workgroup size in the x, y, 85 /// and z dimensions set via LocalSize, or via the composite value 86 /// decorated as the WorkgroupSize BuiltIn. The WorkgroupSize builtin 87 /// takes priority. 88 GridSize workgroup_size; 89 }; 90 91 } // namespace spirv 92 } // namespace reader 93 } // namespace tint 94 95 #endif // SRC_READER_SPIRV_ENTRY_POINT_INFO_H_ 96