-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GDExtension: passing Image to ImageTexture with ImageTexture::update is too slow #76994
Comments
This is quite surprising. I assume you measured the time it takes for the Also, I see you use GDExtension. Does the issue happen with GDScript? I wouldn't expect a difference (also would make it easier to test). If it does make a big difference however, that would be a GDExtension issue. But otherwise I think GDExtension is unrelated to this. Also you could try with other renderers, to see if that's one in particular. |
Also, some image formats have to be converted internally before they are used, depending on renderer. Try using |
Thanks so much! This is actually what I need. But still, I think this is a bug for GDExtension, since this can still occur in some situations. Edited: |
Still reproducible on Godot 4.1 . RGB format is way slower than equivalent R, RG and RGBA formats. Here is my GDScript MRP: extends Sprite2D
var image: Image
var image_texture: ImageTexture
# Called when the node enters the scene tree for the first time.
func _ready():
image = Image.create(4096,4096,false,Image.FORMAT_RGBA8)
image.fill(Color.TURQUOISE)
texture = ImageTexture.create_from_image(image)
print(texture)
self.texture = texture
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta: float):
var time_start: int = Time.get_ticks_usec()
texture.update(image)
var time_end: int = Time.get_ticks_usec()
print(str(0.001 * (time_end - time_start)) + " ms") Data for 4kx4k texture:
You can see the RGB formats consistently stand out as outliers. perhaps caused by misalignment as the GPU will want to align them to multiples of 4 (though I'm surprised about RGBF, since the floating point type should guarantee they are word aligned) I'm just surprised that RGB is up to 10 times slower than the equivalent RGBA |
Would there be a relation to the fact RGB doesnt actually exist as a format in the rendering driver? Therefore requiring conversion, which is a per-pixel operation adding a component of padding |
Godot version
4.0.2-stable
System information
Win 11, Intel i7-12700, RTX 3060Ti
Issue description
Hello.
I am currently working on image rendering with GPU with C++ GDExtension. An important step in the project is passing Image data to ImageTexture before uploading to the shader.
But I found this conversion takes too much time in each frame with low efficiency. For a 1920x1080 image, it takes about 32 to 38 milliseconds to update the ImageTexture. While in Godot 3.5, the same process takes less than 1 millisecond.
Any help will be appreciated.
Steps to reproduce
example.zip
Minimal reproduction project
PLease follow the above descriptions to reproduce the project.
The text was updated successfully, but these errors were encountered: