| 1235 | } |
| 1236 | |
| 1237 | void define_entry_point(function &func) override |
| 1238 | { |
| 1239 | assert(!func.unique_name.empty() && func.unique_name[0] == 'F'); |
| 1240 | func.unique_name[0] = 'E'; |
| 1241 | |
| 1242 | // Modify entry point name so each thread configuration is made separate |
| 1243 | if (func.type == shader_type::compute) |
| 1244 | func.unique_name += |
| 1245 | '_' + std::to_string(func.num_threads[0]) + |
| 1246 | '_' + std::to_string(func.num_threads[1]) + |
| 1247 | '_' + std::to_string(func.num_threads[2]); |
| 1248 | |
| 1249 | if (std::find_if(_module.entry_points.begin(), _module.entry_points.end(), |
| 1250 | [&func](const std::pair<std::string, shader_type> &entry_point) { |
| 1251 | return entry_point.first == func.unique_name; |
| 1252 | }) != _module.entry_points.end()) |
| 1253 | return; |
| 1254 | |
| 1255 | _module.entry_points.emplace_back(func.unique_name, func.type); |
| 1256 | |
| 1257 | spv::Id position_variable = 0; |
| 1258 | spv::Id point_size_variable = 0; |
| 1259 | std::vector<spv::Id> inputs_and_outputs; |
| 1260 | std::vector<expression> call_params; |
| 1261 | |
| 1262 | // Generate the glue entry point function |
| 1263 | function entry_point = func; |
| 1264 | entry_point.referenced_functions.push_back(func.id); |
| 1265 | |
| 1266 | // Change function signature to 'void main()' |
| 1267 | entry_point.return_type = { type::t_void }; |
| 1268 | entry_point.return_semantic.clear(); |
| 1269 | entry_point.parameter_list.clear(); |
| 1270 | |
| 1271 | const id entry_point_definition = define_function({}, entry_point); |
| 1272 | enter_block(create_block()); |
| 1273 | |
| 1274 | const auto create_varying_param = [this, &call_params](const member_type ¶m) { |
| 1275 | // Initialize all output variables with zero |
| 1276 | const spv::Id variable = define_variable({}, param.type, nullptr, spv::StorageClassFunction, spv::ImageFormatUnknown, emit_constant(param.type, 0u)); |
| 1277 | |
| 1278 | expression &call_param = call_params.emplace_back(); |
| 1279 | call_param.reset_to_lvalue({}, variable, param.type); |
| 1280 | |
| 1281 | return variable; |
| 1282 | }; |
| 1283 | |
| 1284 | const auto create_varying_variable = [this, &inputs_and_outputs, &position_variable, &point_size_variable, stype = func.type](const type ¶m_type, const std::string &semantic, spv::StorageClass storage, int a = 0) { |
| 1285 | const spv::Id variable = define_variable({}, param_type, nullptr, storage); |
| 1286 | |
| 1287 | if (const spv::BuiltIn builtin = semantic_to_builtin(semantic, stype); |
| 1288 | builtin != spv::BuiltInMax) |
| 1289 | { |
| 1290 | assert(a == 0); // Built-in variables cannot be arrays |
| 1291 | |
| 1292 | add_builtin(variable, builtin); |
| 1293 | |
| 1294 | if (builtin == spv::BuiltInPosition && storage == spv::StorageClassOutput) |
nothing calls this directly
no test coverage detected