mitsuba-renderer/drjit-core

drjit::set_label not working

JamesZFS opened this issue · 1 comments

A small doubt on drjit::set_label function:

I tried to use set_label a few times before, but they didn't seem to take effect when I call dr::whos() or dr::graphiz().view(). After looking into its implementation in api.cpp, I found out the function early returns in the first six lines.

uint32_t jit_var_set_label(uint32_t index, const char *label) {
    if (unlikely(index == 0)) {
        return 0;
    } else {
        jitc_var_inc_ref_ext(index, jitc_var(index));  // 1
        return index;  // 2
    }

    lock_guard guard(state.lock);

    Variable *v = jitc_var(index);

    // Replicate literals when being labeled
    uint32_t result;
    if (v->literal && (v->ref_count_int != 0 || v->ref_count_ext != 1)) {
        Variable v2;
        memcpy(&v2.value, &v->value, sizeof(uint64_t));
        v2.size = v->size;
        v2.type = v->type;
        v2.literal = 1;
        v2.backend = v->backend;
        result = jitc_var_new(v2, true);
    } else {
        jitc_var_inc_ref_ext(index, v);
        result = index;
    }

    jitc_var_set_label(result, label);

    return result;
}

Commenting out line "1" and "2" solves the issue for me. But I am not sure if this is the right way.

This is now fixed: 63337b7

This will be available in the next release of DrJit and Mitsuba.