Catch CoreAnimation layer size vs. GPU errors?

  • I'm playing around with Core Animation layers, trying
    to figure out the best architecture for my view. (I
    basically want to be able to set an NSView-like
    "bounds" for all my sublayers, to automatically
    transform points from a huge coordinate space to fit
    in the frame.)

    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)

    ...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

    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?

    thanks,
    -natevw

          ____________________________________________________________________________________
    ¡Capacidad ilimitada de almacenamiento en tu correo!
    No te preocupes más por el espacio de tu cuenta con Correo Yahoo!:
    http://correo.espanol.yahoo.com/
  • 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
previous month february 2008 next month
MTWTFSS
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29    
Go to today
MindNode
MindNode offered a free license !