This change fixes issues with viewport rendering when Metal GPU backend is used for drawing. This is not a default build configuration and requires the following tweaks: - Enable WITH_METAL_BACKEND CMake option (set it to on) - Use `--gpu-backend metal` command line arguments It also helps using the `--factory-startup` command line argument to ensure Eevee is not used (it is not ported and will crash). The root of the problem was in the use of glViewport(). It is replaced with the GPU_viewport_size_get_i() which is supposed to be portable equivalent form the GPU module. Without this change the viewport size is detected to be 0 which backfired in few places. The rest of the changes were to make the code more robust in the extreme conditions instead of asserting or crashing. Simplified and streamlined GPU resources creation in the display driver. It was a bit convoluted mix of creation of the GPU resources and resizing them to the proper size. It even seemed to be done in the reverse order. Now it is as simple as "just ensure GPU resources are there for the given texture or buffer size". Also avoid division by zero in the tile manager. Differential Revision: https://developer.blender.org/D16679