[decomp] texture (#684)

* temp

* more cleanup

* fix merge issue

* handle no texture correctly
This commit is contained in:
water111
2021-07-09 22:20:37 -04:00
committed by GitHub
parent d09088b8ed
commit 1898c7c52a
65 changed files with 6900 additions and 903 deletions
+27 -9
View File
@@ -36,20 +36,20 @@ If the previous let variables appear in the definition of new one, make the let
*/
namespace {
std::vector<Form*> path_up_tree(Form* in) {
std::vector<Form*> path_up_tree(Form* in, const Env& env) {
std::vector<Form*> path;
while (in) {
path.push_back(in);
// lg::warn("In: {}", in->to_string(env));
// lg::warn("In: {}", in->to_string(env));
if (in->parent_element) {
// lg::warn(" {}", in->parent_element->to_string(env));
// lg::warn(" {}", in->parent_element->to_string(env));
in = in->parent_element->parent_form;
} else {
in = nullptr;
}
}
// lg::warn("DONE\n");
// lg::warn("DONE\n");
return path;
}
@@ -58,12 +58,12 @@ Form* lca_form(Form* a, Form* b, const Env& env) {
if (!a) {
return b;
}
//
// fmt::print("lca {} ({}) and {} ({})\n", a->to_string(env), (void*)a, b->to_string(env),
// (void*)b);
// fmt::print("lca {} ({}) and {} ({})\n", a->to_string(env), (void*)a, b->to_string(env),
// (void*)b);
auto a_up = path_up_tree(a);
auto b_up = path_up_tree(b);
auto a_up = path_up_tree(a, env);
auto b_up = path_up_tree(b, env);
int ai = a_up.size() - 1;
int bi = b_up.size() - 1;
@@ -78,6 +78,10 @@ Form* lca_form(Form* a, Form* b, const Env& env) {
ai--;
bi--;
}
if (!result) {
auto* bad = b->parent_element;
fmt::print("bad form is {} {}\n", bad->to_string(env), (void*)bad);
}
assert(result);
// fmt::print("{}\n\n", result->to_string(env));
@@ -544,6 +548,20 @@ LetStats insert_lets(const Function& func, Env& env, FormPool& pool, Form* top_l
RegAccessSet reg_accesses;
elt->collect_vars(reg_accesses, false);
// if (!reg_accesses.empty()) {
// Form* f = elt->parent_form;
// while (f && f != top_level_form) {
// auto pe = f->parent_element;
// if (pe) {
// f = pe->parent_form;
// } else {
// f = nullptr;
// }
// }
//
// assert(f);
// }
// and add it.
for (auto& access : reg_accesses) {
if (register_can_hold_var(access.reg())) {