Giter Club home page Giter Club logo

Comments (6)

Bromeon avatar Bromeon commented on August 23, 2024

You should fill the PackedByteArray as early as possible in the chain, avoiding expensive copies each frame (where possible of course). Furthermore, try to reuse the same packed array across frames. It should not trigger CoW if Godot doesn't keep hold of the buffer.

PackedByteArray cannot point to foreign memory, it needs to own it due to the CoW semantics.

Ultimately, we're limited by the APIs that Godot provides, so this is more a Godot instead of godot-rust related question.

from gdext.

ooyyloo avatar ooyyloo commented on August 23, 2024

After searching for some code in godot, I think the PackedByteArray does not matter in construction of Image object. A pointer and the size are enough.
From the image below, we can know data of godot image was passed by passing a reference named p_data. The reference in C++ is equal to pointer variable ("reference" can be transfromed to "pointer"). So, it's not a matter of godot APIs, but a matter of gdext.
image

from gdext.

Bromeon avatar Bromeon commented on August 23, 2024

And which public Godot API allows passing a pointer? We don't have access to Godot's internals.

Also, why upvote your own comment? 🤔

from gdext.

ooyyloo avatar ooyyloo commented on August 23, 2024

And which public Godot API allows passing a pointer? We don't have access to Godot's internals.

Also, why upvote your own comment? 🤔

image
Isn't this function a public Godot API? The p_data parameter, can just be passed as *vector_ptr.

from gdext.

Bromeon avatar Bromeon commented on August 23, 2024

Isn't this function a public Godot API?

Well no, the public API is documented here:
https://docs.godotengine.org/en/stable/classes

It only has the function you already discovered, which takes PackedByteArray:
image


TLDR: you have a fair point, but you should bring this up with Godot. We cannot address this on Rust side.

There seems to be a proposal already:
godotengine/godot-proposals#868
It hasn't seen any activity for quite a while, so feel free to write a comment and elaborate your use case.

from gdext.

Bromeon avatar Bromeon commented on August 23, 2024

Closing as answered. Feel free to reference this issue in any potential Godot discussion. Thanks for bringing it up!

from gdext.

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.