mirror of
https://github.com/godotengine/godot.git
synced 2025-01-24 03:24:32 -05:00
Check device texture size limits in RenderingDevice::texture_create
This commit is contained in:
parent
893bbdfde8
commit
16ee2f22eb
1 changed files with 24 additions and 1 deletions
|
@ -747,9 +747,10 @@ RID RenderingDevice::texture_create(const TextureFormat &p_format, const Texture
|
|||
|
||||
if (format.texture_type == TEXTURE_TYPE_1D_ARRAY || format.texture_type == TEXTURE_TYPE_2D_ARRAY || format.texture_type == TEXTURE_TYPE_CUBE_ARRAY || format.texture_type == TEXTURE_TYPE_CUBE) {
|
||||
ERR_FAIL_COND_V_MSG(format.array_layers < 1, RID(),
|
||||
"Amount of layers must be equal or greater than 1 for arrays and cubemaps.");
|
||||
"Number of layers must be equal or greater than 1 for arrays and cubemaps.");
|
||||
ERR_FAIL_COND_V_MSG((format.texture_type == TEXTURE_TYPE_CUBE_ARRAY || format.texture_type == TEXTURE_TYPE_CUBE) && (format.array_layers % 6) != 0, RID(),
|
||||
"Cubemap and cubemap array textures must provide a layer number that is multiple of 6");
|
||||
ERR_FAIL_COND_V_MSG(format.array_layers > driver->limit_get(LIMIT_MAX_TEXTURE_ARRAY_LAYERS), RID(), "Number of layers exceeds device maximum.");
|
||||
} else {
|
||||
format.array_layers = 1;
|
||||
}
|
||||
|
@ -761,6 +762,28 @@ RID RenderingDevice::texture_create(const TextureFormat &p_format, const Texture
|
|||
format.height = format.texture_type != TEXTURE_TYPE_1D && format.texture_type != TEXTURE_TYPE_1D_ARRAY ? format.height : 1;
|
||||
format.depth = format.texture_type == TEXTURE_TYPE_3D ? format.depth : 1;
|
||||
|
||||
uint64_t size_max = 0;
|
||||
switch (format.texture_type) {
|
||||
case TEXTURE_TYPE_1D:
|
||||
case TEXTURE_TYPE_1D_ARRAY:
|
||||
size_max = driver->limit_get(LIMIT_MAX_TEXTURE_SIZE_1D);
|
||||
break;
|
||||
case TEXTURE_TYPE_2D:
|
||||
case TEXTURE_TYPE_2D_ARRAY:
|
||||
size_max = driver->limit_get(LIMIT_MAX_TEXTURE_SIZE_2D);
|
||||
break;
|
||||
case TEXTURE_TYPE_CUBE:
|
||||
case TEXTURE_TYPE_CUBE_ARRAY:
|
||||
size_max = driver->limit_get(LIMIT_MAX_TEXTURE_SIZE_CUBE);
|
||||
break;
|
||||
case TEXTURE_TYPE_3D:
|
||||
size_max = driver->limit_get(LIMIT_MAX_TEXTURE_SIZE_3D);
|
||||
break;
|
||||
case TEXTURE_TYPE_MAX:
|
||||
break;
|
||||
}
|
||||
ERR_FAIL_COND_V_MSG(format.width > size_max || format.height > size_max || format.depth > size_max, RID(), "Texture dimensions exceed device maximum.");
|
||||
|
||||
uint32_t required_mipmaps = get_image_required_mipmaps(format.width, format.height, format.depth);
|
||||
|
||||
ERR_FAIL_COND_V_MSG(required_mipmaps < format.mipmaps, RID(),
|
||||
|
|
Loading…
Add table
Reference in a new issue