[cairo] [patch] gl: set tex_with in cairo_gl_gradient_t instead in cairo_entry.size

Chris Wilson chris at chris-wilson.co.uk
Mon Nov 5 21:48:08 PST 2012

On Tue, 6 Nov 2012 01:34:25 +0000, "Henry (Yu) Song - SISA" <hsong at sisa.samsung.com> wrote:
> Hi, Chris
> I am not sure why cache_entry.size has to be the tex_width.  It seems that tex_width has no relation with cache_entry.size.  In my patch, the cache_entry.size is set at 4, which allows 1024 gradient cached. 
> if CAIRO_GL_GRADIENT_CACHE_SIZE = 16384, and let's assume each tex_with is about 64, that is only 256 gradient cache.
> The gradient cache should not be limited by system memory, it should, I think, be limited by the GPU memory, because each texture is 1 pixel height, and even, in worst case, each tex_width is 1024, 1024 gradient cache is 4 M (1024x1024x4 (RGBA)) bytes.  - that should be OK, I think

Exactly. The limit we want to express upon the cache should be measured
in bytes (or a multiple thereof) and so cache_entry.size should also be
an estimate of how much GPU memory will be consumed by that entry. Then
the cache is able to reap entries to keep its overall GPU memory usage
within the limit. Since the gradients were of variable width but fixed
height, using the width was a reasonable approximation to the amount of
GPU memory required to store it.

Chris Wilson, Intel Open Source Technology Centre

More information about the cairo mailing list