#GD plugin - how to dump bits to a hardware texture buffer

1 messages · Page 1 of 1 (latest)

cyan lily
#

I need to write a plugin where it will do screen capture and I will end up with a BYTE* of RGB bits, and I need to stuff them into a hardware texture buffer on the local PC. I need the ability to lock that texture buffer while writing the bits, and to unlock it when I'm done. it would be ideal if I could do a GPU-memory copy from an existing hardware texture to Godot's hardware texture.

any examples of this already around?
impossible?

#

This should happen at 72FPS, full screen res.

winged galleon
#

Anything GPU related is trough shaders ofc.
Would Compute Shaders help with this? The docs have a tutorial on it

cyan lily
#

The code that gets the bits into a CPU-RAM buffer, is in C++. So I'm pretty sure I need a GDExtension written for godot-cpp. In the extension, I'm guessing here, but I think i need a method that gets passed in a Texture2D. I need to know in advance that texture is natively a DX12 (or DX11) texture (not Vulkan) and then I need to be able to get to its native pointer. Can I do that? Once I can do that, I can GPU-GPU copy blit to it. I don't know if I need to be on a specific thread, main thread, or render thread, in order for this to work right.

#

elsewhere in the program, this Texture2D is assigned to a material/shader that is set upon a mesh that is in the scene. The ultimate goal is to put a screen-scraped desktop's contents into Godot onto a mesh that is out in 3D space.

#

I wouldn't think a compute shader is the exact right solution for this.

#

I'm looking for any example (godot-cpp) (GDExtension) that fills a Texture2D in a c++ extension and Godot uses that texture, live, in the scene.