mitsuba-renderer / drjit

Dr.Jit — A Just-In-Time-Compiler for Differentiable Rendering
BSD 3-Clause "New" or "Revised" License
597 stars 45 forks source link

Fix scatter for JIT arrays #297

Closed YunHsiao closed 1 month ago

YunHsiao commented 1 month ago

For JITArray set_entry is needed to write values.

njroussel commented 1 month ago

Hi @YunHsiao

Could you share a small C++ snippet that currently fails without your suggested change? I'm failing to see what is currently missing.

YunHsiao commented 1 month ago

Sure, it could boil down to something like this:

#include "drjit/jit.h"

int main()
{
    auto list = drjit::zeros<drjit::LLVMArray<float>>(10);
    drjit::scatter(list, 1.0f, 0); // Compile error, left operand must be l-value
    return 0;
}
njroussel commented 1 month ago

Aha I see, I had never considered that possibility - I tend to always convert the values to JIT types before scattering. Thanks !