diff options
author | Dave Airlie <[email protected]> | 2014-06-10 13:32:25 +1000 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2014-06-11 12:20:30 +1000 |
commit | 740d5bed77120aba4d815b5e2d28b109f214a800 (patch) | |
tree | 66a8773b0ed00d11e3cfa44fa78fef8edbed6095 /src/gallium/drivers/softpipe/sp_setup.c | |
parent | dc8fc39adac79cb8cbf59fc7ae5536536dceb52a (diff) |
softpipe: add layered rendering support.
This adds support for GL 3.2 layered rendering to softpipe.
Reviewed-by: Roland Scheidegger <[email protected]>
Signed-off-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/gallium/drivers/softpipe/sp_setup.c')
-rw-r--r-- | src/gallium/drivers/softpipe/sp_setup.c | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c index 2d6f24a1980..7937e10ad8a 100644 --- a/src/gallium/drivers/softpipe/sp_setup.c +++ b/src/gallium/drivers/softpipe/sp_setup.c @@ -92,6 +92,7 @@ struct setup_context { int facing; float pixel_offset; + unsigned max_layer; struct quad_header quad[MAX_QUADS]; struct quad_header *quad_ptrs[MAX_QUADS]; @@ -801,7 +802,7 @@ sp_setup_tri(struct setup_context *setup, const float (*v2)[4]) { float det; - + uint layer = 0; #if DEBUG_VERTS debug_printf("Setup triangle:\n"); print_vertex(setup, v0); @@ -834,6 +835,11 @@ sp_setup_tri(struct setup_context *setup, setup->span.right[0] = 0; setup->span.right[1] = 0; /* setup->span.z_mode = tri_z_mode( setup->ctx ); */ + if (setup->softpipe->layer_slot > 0) { + layer = *(unsigned *)v1[setup->softpipe->layer_slot]; + layer = MIN2(layer, setup->max_layer); + } + setup->quad[0].input.layer = layer; /* init_constant_attribs( setup ); */ @@ -1072,6 +1078,7 @@ sp_setup_line(struct setup_context *setup, int dx = x1 - x0; int dy = y1 - y0; int xstep, ystep; + uint layer = 0; #if DEBUG_VERTS debug_printf("Setup line:\n"); @@ -1115,6 +1122,11 @@ sp_setup_line(struct setup_context *setup, setup->quad[0].input.x0 = setup->quad[0].input.y0 = -1; setup->quad[0].inout.mask = 0x0; + if (setup->softpipe->layer_slot > 0) { + layer = *(unsigned *)v1[setup->softpipe->layer_slot]; + layer = MIN2(layer, setup->max_layer); + } + setup->quad[0].input.layer = layer; /* XXX temporary: set coverage to 1.0 so the line appears * if AA mode happens to be enabled. @@ -1206,7 +1218,7 @@ sp_setup_point(struct setup_context *setup, const float y = v0[0][1]; const struct vertex_info *vinfo = softpipe_get_vertex_info(softpipe); uint fragSlot; - + uint layer = 0; #if DEBUG_VERTS debug_printf("Setup point:\n"); print_vertex(setup, v0); @@ -1217,6 +1229,12 @@ sp_setup_point(struct setup_context *setup, assert(setup->softpipe->reduced_prim == PIPE_PRIM_POINTS); + if (setup->softpipe->layer_slot > 0) { + layer = *(unsigned *)v0[setup->softpipe->layer_slot]; + layer = MIN2(layer, setup->max_layer); + } + setup->quad[0].input.layer = layer; + /* For points, all interpolants are constant-valued. * However, for point sprites, we'll need to setup texcoords appropriately. * XXX: which coefficients are the texcoords??? @@ -1401,7 +1419,8 @@ void sp_setup_prepare(struct setup_context *setup) { struct softpipe_context *sp = setup->softpipe; - + int i; + unsigned max_layer = ~0; if (sp->dirty) { softpipe_update_derived(sp, sp->reduced_api_prim); } @@ -1409,6 +1428,23 @@ sp_setup_prepare(struct setup_context *setup) /* Note: nr_attrs is only used for debugging (vertex printing) */ setup->nr_vertex_attrs = draw_num_shader_outputs(sp->draw); + /* + * Determine how many layers the fb has (used for clamping layer value). + * OpenGL (but not d3d10) permits different amount of layers per rt, however + * results are undefined if layer exceeds the amount of layers of ANY + * attachment hence don't need separate per cbuf and zsbuf max. + */ + for (i = 0; i < setup->softpipe->framebuffer.nr_cbufs; i++) { + struct pipe_surface *cbuf = setup->softpipe->framebuffer.cbufs[i]; + if (cbuf) { + max_layer = MIN2(max_layer, + cbuf->u.tex.last_layer - cbuf->u.tex.first_layer); + + } + } + + setup->max_layer = max_layer; + sp->quad.first->begin( sp->quad.first ); if (sp->reduced_api_prim == PIPE_PRIM_TRIANGLES && |