Skip navigation.
 
mlRe: Catch CoreAnimation layer size vs. GPU errors?
FROM : John Harper
DATE : Sat Feb 23 03:12:55 2008

On Feb 22, 2008, at 5:28 PM, Nathan Vander Wilt wrote:

> In the course of this, I discovered that a CALayer's
> bounds seem to directly correspond to the OpenGL
> texture size, and so Core Animation assumes any large
> bounds are accidental:
>
> -[<CALayer: 0x1947e340> display]: Ignoring bogus layer
> size (879999.937500, 581999.937500)


that's not quite what is happening, this warning is logged when you 
try to _draw_ into a layer with bounds greater than something we think 
any system will support (currently 16Kx16K). You can still have layers 
larger than this, you just can't draw into them directly. (e.g. they 
can have sublayers)

>
>
> ...and even misfires on slightly large bounds. For
> example, if I set my root layer scale to 0.5 and
> maximize my window, the constrained-to-fit sublayer's
> size causes:
>
> CoreAnimation: 2480 by 1290 image is too large for
> GPU, ignoring


This is the OpenGL maximum texture size for your graphics card. 
Currently across all graphics cards supported by 10.5 the "safe" 
maximum size is 2046x2046 (since all cards will support images up to 
that size.)

If you need images larger than this we recommend you look at the 
CATiledLayer class and see if that supports what you need (it tiles 
the contents of large layers into smaller images for you by asking you 
to draw subregions individually as they are required)

>
> At this stage in the design, I can try figure out an
> architecture that avoids the "bogus" layer sizes, but
> I'm worried about the slightly-too-large layers
> occurring in the wild (eg someone with an older
> Macbook and a larger external monitor making the
> window bigger relative to the GPU than I could). Is
> there a way to detect these errors programatically so
> that some sort of fallback can be done?


Not currently through CA (though we are considering this for a future 
release.) Currently the only way to query these limits is via OpenGL 
directly. If you have a GL context, query the GL_MAX_TEXTURE_SIZE and 
GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB properties and use the minimum of 
the two.

   John

Related mailsAuthorDate
mlCatch CoreAnimation layer size vs. GPU errors? Nathan Vander Wilt Feb 23, 02:28
mlRe: Catch CoreAnimation layer size vs. GPU errors? John Harper Feb 23, 03:12