godotengine / godotengine/godot
The size of SubViewport is not checked for exceeding the maximum texture size allowed by GPU
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
- Reproductible in 4.3[stable], (Unchecked whether it exists in earlier or later versions)
### System information
Windows 10 - Godot v4.3 Stable - Forward+, Mobile and Compatibility, Seemingly any GPU
### Issue description
Good day.
It seems that while Godot engine checks that the provided size for SubViewport is not 0 x 0 and below, it does not check if it exceeds the the maximum supported Texture size allowed by the hardware (Around 16k x 16k for modern GPUs, 4096x4096 and below for older GPUs).
Meaning that attempt to create a SubViewport bigger than what GPU can handle results in error regarding failure to create image internally (Forward+) or internal FrameBuffer not being ready (Compatibility)
Checking the source code (For GLES3 driver), it seems that while the Framebuffer is destroyed and the viewport's size is set to 0 internally, it is not reflected on script's side and printing value of it will print what you tried to set its size to, instead of 0.
### Steps to reproduce
- Create a fresh project
- Add a single Node2D
- Assign this script to it
```python
extends Node2D
func _ready():
var sub: SubViewport = SubViewport.new()
# Should not fail
sub.size = Vector2i(4, 4)
# Will return 4 as expected
print("gdscript ", sub.size.x)
# This will fail
sub.size = Vector2i(40000, 40000)
# However this will somehow return 40000
print("gdscript ", sub.size.x)
```
### Minimal reproduction project (MRP)
N/A (Provided above)
Contributor guide
Research direction
Start by running the provided GDScript reproduction in Godot 4.3, then inspect the SubViewport size handling and the GLES3 driver framebuffer path mentioned in the report. The issue is resolved when oversized SubViewport dimensions are checked against the GPU's supported texture size and the exposed size remains consistent with the resulting framebuffer state.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100