godot
godot copied to clipboard
SubViewPort.get_texture.get_image makes Godot stutter/jitter
Godot version
4.0.2-stable
System information
Ubuntu 22.04, RTX 3080, Vulkan API 1.3.224 - Forward+, OpenGL API 3.3.0 NVIDIA 525.60.13, X11, AMD 5900x
Issue description
Each of these spikes is exactly 0.2sec apart and caused by the get_image()
call in the following line:
# runs every 0.2sec
get_node("%subviewport").get_texture().get_image()
This micro-stutter is noticeable especially when walking around, moving with the mouse (FPS character, etc)
Some things I have noticed:
- The size of the subviewport seems of no influence
- The draw mode of the subviewport seems of no influence, for example
DEBUG_DRAW_UNSHADED
would still stutter - I tracked it down to the following call:
https://github.com/godotengine/godot/blob/278fc7538dbd98ff0e06410d69adca49b5326b21/drivers/vulkan/rendering_device_vulkan.cpp#L2844 I patched it with:
if(tex->width != 127)
_flush(true);
and set my subviewport size width to 127
so it doesn't _flush()
for my specific case and the micro-stutter is gone. A flat line:
p.s: that FPS counter is mangohud, e.g: mangohud ./bin/godot.linuxbsd.editor.x86_64
Steps to reproduce
- Create a 3D scene
- Create a
SubViewport
with a camera inside it - Get the texture of the subviewport via
get_texture()
- Call
get_image()
on that texture - Observe a stutter
Or download my minimal reproduction project