Fix T95477: Report error instead of crashing when Metal texture size limits exceeded.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D14074
This commit is contained in:
Michael Jones (Apple) 2022-02-10 10:54:18 +00:00
parent 3d12dd59ce
commit 35dedc11d5
Notes: blender-bot 2023-02-14 09:43:37 +01:00
Referenced by issue #95477, Blender 3.1 beta crashes when trying to render on the GPU with Metal
1 changed files with 9 additions and 0 deletions

View File

@ -765,6 +765,15 @@ void MetalDevice::tex_alloc_as_buffer(device_texture &mem)
void MetalDevice::tex_alloc(device_texture &mem)
{
/* Check that dimensions fit within maximum allowable size.
See https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf
*/
if (mem.data_width > 16384 ||
mem.data_height > 16384) {
set_error(string_printf("Texture exceeds maximum allowed size of 16384 x 16384 (requested: %zu x %zu)", mem.data_width, mem.data_height));
return;
}
MTLStorageMode storage_mode = MTLStorageModeManaged;
if (@available(macos 10.15, *)) {
if ([mtlDevice hasUnifiedMemory] &&