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

Function define_variable

source/effect_codegen_hlsl.cpp:1105–1139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1103 return res;
1104 }
1105 id define_variable(const location &loc, const type &type, std::string name, bool global, id initializer_value) override
1106 {
1107 // Constant variables with a constant initializer can just point to the initializer SSA variable, since they cannot be modified anyway, thus saving an unnecessary assignment
1108 if (initializer_value != 0 && type.has(type::q_const) &&
1109 std::find_if(_constant_lookup.begin(), _constant_lookup.end(),
1110 [initializer_value](const auto &x) {
1111 return initializer_value == std::get<2>(x);
1112 }) != _constant_lookup.end())
1113 return initializer_value;
1114
1115 const id res = make_id();
1116
1117 if (!name.empty())
1118 define_name<naming::general>(res, name);
1119
1120 std::string &code = _blocks.at(_current_block);
1121
1122 write_location(code, loc);
1123
1124 if (!global)
1125 code += '\t';
1126
1127 write_type(code, type);
1128 code += ' ' + id_to_name(res);
1129
1130 if (type.is_array())
1131 code += '[' + std::to_string(type.array_length) + ']';
1132
1133 if (initializer_value != 0)
1134 code += " = " + id_to_name(initializer_value);
1135
1136 code += ";\n";
1137
1138 return res;
1139 }
1140 id define_function(const location &loc, function &info) override
1141 {
1142 const id res = info.id = make_id();

Callers 4

define_samplerMethod · 0.85
define_storageMethod · 0.85
define_variableMethod · 0.85
define_entry_pointMethod · 0.85

Calls 7

write_locationFunction · 0.85
write_typeFunction · 0.85
id_to_nameFunction · 0.85
to_stringFunction · 0.85
atMethod · 0.80
is_arrayMethod · 0.80
hasMethod · 0.45

Tested by

no test coverage detected