Code Monkey home page Code Monkey logo

Comments (7)

lf94 avatar lf94 commented on September 27, 2024 1

Oh my god, it worked with __stdcall. I'm out. Thanks for the booth 🙂

from libfive.

lf94 avatar lf94 commented on September 27, 2024

For what it's worth, this other test segment passes:

//home/lee/Code/lee/libfivejs/index.js:234.1,251.2
{
  let str = "libfive_tree_print ";
  const a = x();
  const b = y();
  const c = z();
  const a2 = a.square();
  const b2 = b.square();
  const c2 = c.square();
  const r_ = a2.add(b2);
  const r = r_.add(c2);
  const d = r.sub(1.0);
  const ptr = d.toString();

  if (ptr !== "(- (+ (square x) (square y) (square z)) 1)") throw Fail;

  str += "passed";
  console.log(str);
}

(Same test, just more idiomatic)

//home/lee/Code/lee/libfivejs/index.js:258.2,253.1
// Again, but more golfy :)
{
  const [a,b,c] = [x(),y(),z()].map((d) => d.square());
  const r = a.add(b).add(c).sub(1.0);
  if (r.toString() !== "(- (+ (square x) (square y) (square z)) 1)") throw Fail;
}

from libfive.

lf94 avatar lf94 commented on September 27, 2024

libfive_tree_save_mesh also works... properly outputs a cube. Hm.

from libfive.

lf94 avatar lf94 commented on September 27, 2024

Does it maybe have something to do with new libfive_mesh ? Is this equivalent to malloc'ing?

from libfive.

lf94 avatar lf94 commented on September 27, 2024

I'm thinking that everything is working fine, and it's the FFI (https://koffi.dev) which is having problems, potentially with what I mentioned...

Edit: Could it do with the call type you think? i.e. fastcall, stdcall, etc

Edit: the more I research, the more I think that maybe using new from C++ is a bit of problem when providing the C api, although logically I don't understand why. It should be fine.

Edit: nope, changing it to malloc didnt do the trick.A

Edit: Yeah ok, adding an "output" argument onto render_mesh makes it work. I think the issue is this FFI system doesn't support using pointers as return types, unless they're opaque (in which case you don't access them) or strings (which it handles just fine).... gah, that really sucks, because everything else works!

Edit: So https://github.com/Koromix/rygel/blob/dd1cefe9c8e4efbff7c8b2ab71fcde21a0e81323/src/koffi/src/call.cc#L953 must be the reason. Anything allocated outside of the nodejs context is marked "External", otherwise, using output parameters, it's possible to have much more type information... Not sure how to fix it though.

Edit: from what I understand, it makes the most sense is beneficial for these systems to allocate and deallocate memory and pass these objects to the API. Then the GC can take care of things

from libfive.

lf94 avatar lf94 commented on September 27, 2024

Welp, upon revisiting this morning, it appears I was just very tired, and what I saw was just my old custom change to libfive working... So back to being screwed :). At least I can do mostly everything but this is necessary if I want to have a somewhat performant rendering loop (I'm going to use node-sdl with it). Is it possible to provide alternatives that take in output parameter pointers?

from libfive.

lf94 avatar lf94 commented on September 27, 2024

Koromix/koffi#35

from libfive.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.