godotengine / godotengine/godot
Image.COMPRESS_BPTC does not work in Runtime Debug/Release
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
v4.6.stable.official [89cea1439]
### System information
linux, vulkan
### Issue description
I encountered a compression error. It occurs only in the Debug/Release build and is not system-dependent.
Debug:
```
ERROR: Parameter "_image_compress_bptc_func" is null.
at: compress_from_channels (core/io/image.cpp:2985)
GDScript backtrace (most recent call first):
[0] _ready (res://assets/gui/cursors/cursor.gd:21)
```
This is documented in the official documentation: https://docs.godotengine.org/en/4.5/classes/class_image.html?utm_source=chatgpt.com#class-image-method-compress-from-channels
> Compresses the image to use less memory. Can not directly access pixel data while the image is compressed. Returns error if the chosen compression mode is not available.
But in the editor itself, this error does not appear in any console. This also looks strange, because BPTC is used for other textures, yet here it says it supposedly doesn’t work, even though in fact there doesn’t seem to be a problem with the cursor itself.
I also checked the settings and imports, and it’s not related to them.
But maybe Godot doesn’t support this at runtime? If so, this looks like an oversight, though I’m not entirely sure.
### Steps to reproduce
Example of my code:
```gdscript
var list: Dictionary = {}
func _ready() -> void:
list = await Global.gdResourceManager.loadFilesThreaded( \
"res://assets/gui/cursors", ".svg", false).finished
# Set size 32x32 for all
for iconName in list:
var image: Image = list[iconName].get_image()
image.decompress() # Decompress the original compressed texture
var scaledImage: Image = image.duplicate()
var newSize: Vector2i = Vector2i(32, 32)
scaledImage.resize(newSize.x, newSize.y, Image.INTERPOLATE_BILINEAR)
scaledImage.compress(Image.COMPRESS_BPTC) # Compress it back
var newTexture: ImageTexture = ImageTexture.create_from_image(scaledImage)
list[iconName] = newTexture
```
(In general, it is used simply to allow using large cursors, as well as to generate thumbnails for other purposes.)
For testing, you can replace loadFilesThreaded here with just loading a single image and you will get the same effect.
### Minimal reproduction project (MRP)
--
Contributor guide
Research direction
Reproduce the failure with the supplied GDScript snippet, then inspect core/io/image.cpp around compress_from_channels, especially the null _image_compress_bptc_func path. Compare runtime Debug/Release behavior with the editor and check how Image.COMPRESS_BPTC is initialized. Done means the runtime behavior is corrected or the supported limitation is documented and consistently reported.
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