diff options
author | Chia-I Wu <[email protected]> | 2013-12-21 21:21:24 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2014-01-08 18:11:35 +0800 |
commit | e372819589c2a66620e63a2cd11582c6ce5fb8f0 (patch) | |
tree | 11d571e18fc86d23a4ed50466405e1e7ef014f11 /src/gallium/drivers/ilo | |
parent | 82676f5d3443392a0ae0186c8b7f7dce53a44fbc (diff) |
ilo: refactor separate stencil allocation
Move separate stencil allocation code to tex_create_separate_stencil to keep
tex_create sane.
Diffstat (limited to 'src/gallium/drivers/ilo')
-rw-r--r-- | src/gallium/drivers/ilo/ilo_resource.c | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/src/gallium/drivers/ilo/ilo_resource.c b/src/gallium/drivers/ilo/ilo_resource.c index 7dd34359302..04927d8bfa4 100644 --- a/src/gallium/drivers/ilo/ilo_resource.c +++ b/src/gallium/drivers/ilo/ilo_resource.c @@ -969,6 +969,30 @@ tex_create_bo(struct ilo_texture *tex, return true; } +static bool +tex_create_separate_stencil(struct ilo_texture *tex) +{ + struct pipe_resource templ = tex->base; + struct pipe_resource *s8; + + /* + * Unless PIPE_BIND_DEPTH_STENCIL is set, the resource may have other + * tilings. But that should be fine since it will never be bound as the + * stencil buffer, and our transfer code can handle all tilings. + */ + templ.format = PIPE_FORMAT_S8_UINT; + + s8 = tex->base.screen->resource_create(tex->base.screen, &templ); + if (!s8) + return false; + + tex->separate_s8 = ilo_texture(s8); + + assert(tex->separate_s8->bo_format == PIPE_FORMAT_S8_UINT); + + return true; +} + static void tex_destroy(struct ilo_texture *tex) { @@ -1053,26 +1077,9 @@ tex_create(struct pipe_screen *screen, } /* allocate separate stencil resource */ - if (layout.separate_stencil) { - struct pipe_resource s8_templ = *layout.templ; - struct pipe_resource *s8; - - /* - * Unless PIPE_BIND_DEPTH_STENCIL is set, the resource may have other - * tilings. But that should be fine since it will never be bound as the - * stencil buffer, and our transfer code can handle all tilings. - */ - s8_templ.format = PIPE_FORMAT_S8_UINT; - - s8 = screen->resource_create(screen, &s8_templ); - if (!s8) { - tex_destroy(tex); - return NULL; - } - - tex->separate_s8 = ilo_texture(s8); - - assert(tex->separate_s8->bo_format == PIPE_FORMAT_S8_UINT); + if (layout.separate_stencil && !tex_create_separate_stencil(tex)) { + tex_destroy(tex); + return NULL; } return &tex->base; |