diff options
author | Marek Olšák <[email protected]> | 2013-11-21 15:41:36 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2013-12-03 19:39:13 +0100 |
commit | 6b919b1b2d296f7d7410c2291b7e0332d7bef1a0 (patch) | |
tree | 38ad55fa40a9954919f97d41c11d8e6a4d0807bc /src/gallium/auxiliary/util/u_framebuffer.c | |
parent | 1a02bb71ddbf7312a84ac1693f562cca191a7d42 (diff) |
gallium/util: implement layered framebuffer clear in u_blitter
All bound layers (from first_layer to last_layer) should be cleared.
This uses a vertex shader which outputs gl_Layer = gl_InstanceID, so each
instance goes to a different layer. By rendering a quad and setting
the instance count to the number of layers, it will trivially clear all
layers.
This requires AMD_vertex_shader_layer (or PIPE_CAP_TGSI_VS_LAYER), which only
radeonsi supports at the moment. r600 could do this too. Standard DX11
hardware will have to use a geometry shader though, which has higher overhead.
Diffstat (limited to 'src/gallium/auxiliary/util/u_framebuffer.c')
-rw-r--r-- | src/gallium/auxiliary/util/u_framebuffer.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_framebuffer.c b/src/gallium/auxiliary/util/u_framebuffer.c index f84485d1f1c..683967237e9 100644 --- a/src/gallium/auxiliary/util/u_framebuffer.c +++ b/src/gallium/auxiliary/util/u_framebuffer.c @@ -147,3 +147,27 @@ util_framebuffer_min_size(const struct pipe_framebuffer_state *fb, return TRUE; } } + + +/** + * Return the number of layers set in the framebuffer state. + */ +unsigned +util_framebuffer_get_num_layers(const struct pipe_framebuffer_state *fb) +{ + unsigned i, num_layers = 0; + + for (i = 0; i < fb->nr_cbufs; i++) { + if (fb->cbufs[i]) { + unsigned num = fb->cbufs[i]->u.tex.last_layer - + fb->cbufs[i]->u.tex.first_layer + 1; + num_layers = MAX2(num_layers, num); + } + } + if (fb->zsbuf) { + unsigned num = fb->zsbuf->u.tex.last_layer - + fb->zsbuf->u.tex.first_layer + 1; + num_layers = MAX2(num_layers, num); + } + return num_layers; +} |