Comments (6)
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.
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.
from gdext.
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.
And which public Godot API allows passing a pointer? We don't have access to Godot's internals.
Also, why upvote your own comment? 🤔
Isn't this function a public Godot API? The p_data parameter, can just be passed as *vector_ptr.
from gdext.
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
:
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.
Closing as answered. Feel free to reference this issue in any potential Godot discussion. Thanks for bringing it up!
from gdext.
Related Issues (20)
- Docs comments do not follow usual markdown newline rules HOT 4
- Broken link in godot-core in ExtensionLibrary documentation HOT 1
- Unable to get auto completion on node classes HOT 5
- A class that inherits from Button , displayed as Node ? HOT 1
- Implementing `EditorExportPlugin::export_file` causes compile error due to macro generating a parameter named `type` HOT 1
- `Key` type makes `KeyMask | Key` combinations impossible without `.call()` hacks HOT 3
- Required virtual method (not?) overriding HOT 26
- Compatibility with color-backtrace in 0.1.3 HOT 8
- Terminal color not properly restored after exiting HOT 7
- impl AsObjectArg <T> makes T-object free HOT 4
- Invalid syntax in docs xml HOT 1
- To panic or not to panic when passing incorrect argument types? HOT 4
- Array<unsigned int> can hold signed values when converted from Variant HOT 1
- Threaded resource loading is disabled HOT 1
- Ambiguous method call in `#[godot_api]` generated code HOT 1
- #[var(set = `function_name`)] is not compatible with #[func(rename = `gdscript_name`)] HOT 1
- `Vector3::sign` gives incorrect results due to i32 conversion
- NavigationAgent2D is never built HOT 1
- GDScriptFunctionState, Async implementation. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gdext.