MCPcopy Create free account
hub / github.com/crosire/reshade / define_function

Function define_function

source/effect_codegen_hlsl.cpp:1140–1188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1138 return res;
1139 }
1140 id define_function(const location &loc, function &info) override
1141 {
1142 const id res = info.id = make_id();
1143 define_name<naming::unique>(res, info.unique_name);
1144
1145 assert(_current_block == 0 && (_current_function_declaration.empty() || info.type != shader_type::unknown));
1146 std::string &code = _current_function_declaration;
1147
1148 write_location(code, loc);
1149
1150 write_type(code, info.return_type);
1151 code += ' ' + id_to_name(res) + '(';
1152
1153 for (member_type &param : info.parameter_list)
1154 {
1155 param.id = make_id();
1156 define_name<naming::unique>(param.id, param.name);
1157
1158 code += '\n';
1159 write_location(code, param.location);
1160 code += '\t';
1161 write_type<true>(code, param.type);
1162 code += ' ' + id_to_name(param.id);
1163
1164 if (param.type.is_array())
1165 code += '[' + std::to_string(param.type.array_length) + ']';
1166
1167 if (!param.semantic.empty())
1168 code += " : " + convert_semantic(param.semantic, std::max(1u, param.type.cols / 4u) * std::max(1u, param.type.array_length));
1169
1170 code += ',';
1171 }
1172
1173 // Remove trailing comma
1174 if (!info.parameter_list.empty())
1175 code.pop_back();
1176
1177 code += ')';
1178
1179 if (!info.return_semantic.empty())
1180 code += " : " + convert_semantic(info.return_semantic);
1181
1182 code += '\n';
1183
1184 _functions.push_back(std::make_unique<function>(info));
1185 _current_function = _functions.back().get();
1186
1187 return res;
1188 }
1189
1190 void define_entry_point(function &func) override
1191 {

Callers 3

define_entry_pointMethod · 0.85
define_entry_pointMethod · 0.85
define_entry_pointFunction · 0.85

Calls 7

write_locationFunction · 0.85
write_typeFunction · 0.85
id_to_nameFunction · 0.85
to_stringFunction · 0.85
convert_semanticFunction · 0.85
is_arrayMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected