diff options
Diffstat (limited to 'src/gallium/drivers/softpipe')
-rw-r--r-- | src/gallium/drivers/softpipe/sp_draw_arrays.c | 210 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_quad_blend.c | 37 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_quad_depth_test.c | 40 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_quad_fs.c | 8 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_screen.c | 3 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_tex_sample.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_tex_tile_cache.c | 24 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_tile_cache.c | 41 |
8 files changed, 192 insertions, 173 deletions
diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c index 79daa68f3b..9e727c9381 100644 --- a/src/gallium/drivers/softpipe/sp_draw_arrays.c +++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c @@ -47,43 +47,6 @@ - -/** - * Draw vertex arrays, with optional indexing. - * Basically, map the vertex buffers (and drawing surfaces), then hand off - * the drawing to the 'draw' module. - */ -static void -softpipe_draw_range_elements_instanced(struct pipe_context *pipe, - struct pipe_resource *indexBuffer, - unsigned indexSize, - int indexBias, - unsigned minIndex, - unsigned maxIndex, - unsigned mode, - unsigned start, - unsigned count, - unsigned startInstance, - unsigned instanceCount); - - -void -softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode, - unsigned start, unsigned count) -{ - softpipe_draw_range_elements_instanced(pipe, - NULL, - 0, - 0, - 0, - 0xffffffff, - mode, - start, - count, - 0, - 1); -} - void softpipe_draw_stream_output(struct pipe_context *pipe, unsigned mode) { @@ -136,6 +99,93 @@ softpipe_draw_stream_output(struct pipe_context *pipe, unsigned mode) } +/** + * This function handles drawing indexed and non-indexed prims, + * instanced and non-instanced drawing, with or without min/max element + * indexes. + * All the other drawing functions are expressed in terms of this + * function. + * + * For non-indexed prims, indexBuffer should be NULL. + * For non-instanced drawing, instanceCount should be 1. + * When the min/max element indexes aren't known, minIndex should be 0 + * and maxIndex should be ~0. + */ +static void +softpipe_draw_range_elements_instanced(struct pipe_context *pipe, + struct pipe_resource *indexBuffer, + unsigned indexSize, + int indexBias, + unsigned minIndex, + unsigned maxIndex, + unsigned mode, + unsigned start, + unsigned count, + unsigned startInstance, + unsigned instanceCount) +{ + struct softpipe_context *sp = softpipe_context(pipe); + struct draw_context *draw = sp->draw; + unsigned i; + + if (!softpipe_check_render_cond(sp)) + return; + + sp->reduced_api_prim = u_reduced_prim(mode); + + if (sp->dirty) { + softpipe_update_derived(sp); + } + + softpipe_map_transfers(sp); + + /* Map vertex buffers */ + for (i = 0; i < sp->num_vertex_buffers; i++) { + void *buf = softpipe_resource(sp->vertex_buffer[i].buffer)->data; + draw_set_mapped_vertex_buffer(draw, i, buf); + } + + /* Map index buffer, if present */ + if (indexBuffer) { + void *mapped_indexes = softpipe_resource(indexBuffer)->data; + draw_set_mapped_element_buffer_range(draw, + indexSize, + indexBias, + minIndex, + maxIndex, + mapped_indexes); + } else { + /* no index/element buffer */ + draw_set_mapped_element_buffer_range(draw, + 0, 0, + start, + start + count - 1, + NULL); + } + + /* draw! */ + draw_arrays_instanced(draw, mode, start, count, startInstance, instanceCount); + + /* unmap vertex/index buffers - will cause draw module to flush */ + for (i = 0; i < sp->num_vertex_buffers; i++) { + draw_set_mapped_vertex_buffer(draw, i, NULL); + } + if (indexBuffer) { + draw_set_mapped_element_buffer(draw, 0, 0, NULL); + } + + /* + * TODO: Flush only when a user vertex/index buffer is present + * (or even better, modify draw module to do this + * internally when this condition is seen?) + */ + draw_flush(draw); + + /* Note: leave drawing surfaces mapped */ + sp->dirty_render_cache = TRUE; +} + + void softpipe_draw_range_elements(struct pipe_context *pipe, struct pipe_resource *indexBuffer, @@ -223,76 +273,20 @@ softpipe_draw_elements_instanced(struct pipe_context *pipe, instanceCount); } -static void -softpipe_draw_range_elements_instanced(struct pipe_context *pipe, - struct pipe_resource *indexBuffer, - unsigned indexSize, - int indexBias, - unsigned minIndex, - unsigned maxIndex, - unsigned mode, - unsigned start, - unsigned count, - unsigned startInstance, - unsigned instanceCount) +void +softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode, + unsigned start, unsigned count) { - struct softpipe_context *sp = softpipe_context(pipe); - struct draw_context *draw = sp->draw; - unsigned i; - - if (!softpipe_check_render_cond(sp)) - return; - - sp->reduced_api_prim = u_reduced_prim(mode); - - if (sp->dirty) { - softpipe_update_derived(sp); - } - - softpipe_map_transfers(sp); - - /* Map vertex buffers */ - for (i = 0; i < sp->num_vertex_buffers; i++) { - void *buf = softpipe_resource(sp->vertex_buffer[i].buffer)->data; - draw_set_mapped_vertex_buffer(draw, i, buf); - } - - /* Map index buffer, if present */ - if (indexBuffer) { - void *mapped_indexes = softpipe_resource(indexBuffer)->data; - draw_set_mapped_element_buffer_range(draw, - indexSize, - indexBias, - minIndex, - maxIndex, - mapped_indexes); - } else { - /* no index/element buffer */ - draw_set_mapped_element_buffer_range(draw, - 0, 0, - start, - start + count - 1, - NULL); - } - - /* draw! */ - draw_arrays_instanced(draw, mode, start, count, startInstance, instanceCount); - - /* unmap vertex/index buffers - will cause draw module to flush */ - for (i = 0; i < sp->num_vertex_buffers; i++) { - draw_set_mapped_vertex_buffer(draw, i, NULL); - } - if (indexBuffer) { - draw_set_mapped_element_buffer(draw, 0, 0, NULL); - } - - /* - * TODO: Flush only when a user vertex/index buffer is present - * (or even better, modify draw module to do this - * internally when this condition is seen?) - */ - draw_flush(draw); - - /* Note: leave drawing surfaces mapped */ - sp->dirty_render_cache = TRUE; + softpipe_draw_range_elements_instanced(pipe, + NULL, + 0, + 0, + 0, + 0xffffffff, + mode, + start, + count, + 0, + 1); } + diff --git a/src/gallium/drivers/softpipe/sp_quad_blend.c b/src/gallium/drivers/softpipe/sp_quad_blend.c index 00187febf0..6af1b2d061 100644 --- a/src/gallium/drivers/softpipe/sp_quad_blend.c +++ b/src/gallium/drivers/softpipe/sp_quad_blend.c @@ -208,7 +208,7 @@ logicop_quad(struct quad_stage *qs, res4[j] = ~0; break; default: - assert(0); + assert(0 && "invalid logicop mode"); } for (j = 0; j < 4; j++) { @@ -221,11 +221,18 @@ logicop_quad(struct quad_stage *qs, +/** + * Do blending for a 2x2 quad for one color buffer. + * \param quadColor the incoming quad colors + * \param dest the destination/framebuffer quad colors + * \param blend_index which set of blending terms to use + * \param has_dst_alpha does the dest color buffer have an alpha channel? + */ static void blend_quad(struct quad_stage *qs, float (*quadColor)[4], float (*dest)[4], - unsigned cbuf, + unsigned blend_index, boolean has_dst_alpha) { static const float zero[4] = { 0, 0, 0, 0 }; @@ -236,7 +243,7 @@ blend_quad(struct quad_stage *qs, /* * Compute src/first term RGB */ - switch (softpipe->blend->rt[cbuf].rgb_src_factor) { + switch (softpipe->blend->rt[blend_index].rgb_src_factor) { case PIPE_BLENDFACTOR_ONE: VEC4_COPY(source[0], quadColor[0]); /* R */ VEC4_COPY(source[1], quadColor[1]); /* G */ @@ -395,13 +402,13 @@ blend_quad(struct quad_stage *qs, assert(0); /* to do */ break; default: - assert(0); + assert(0 && "invalid rgb src factor"); } /* * Compute src/first term A */ - switch (softpipe->blend->rt[cbuf].alpha_src_factor) { + switch (softpipe->blend->rt[blend_index].alpha_src_factor) { case PIPE_BLENDFACTOR_ONE: VEC4_COPY(source[3], quadColor[3]); /* A */ break; @@ -469,14 +476,14 @@ blend_quad(struct quad_stage *qs, } break; default: - assert(0); + assert(0 && "invalid alpha src factor"); } /* * Compute dest/second term RGB */ - switch (softpipe->blend->rt[cbuf].rgb_dst_factor) { + switch (softpipe->blend->rt[blend_index].rgb_dst_factor) { case PIPE_BLENDFACTOR_ONE: /* dest = dest * 1 NO-OP, leave dest as-is */ break; @@ -625,13 +632,13 @@ blend_quad(struct quad_stage *qs, assert(0); break; default: - assert(0); + assert(0 && "invalid rgb dst factor"); } /* * Compute dest/second term A */ - switch (softpipe->blend->rt[cbuf].alpha_dst_factor) { + switch (softpipe->blend->rt[blend_index].alpha_dst_factor) { case PIPE_BLENDFACTOR_ONE: /* dest = dest * 1 NO-OP, leave dest as-is */ break; @@ -696,13 +703,13 @@ blend_quad(struct quad_stage *qs, } break; default: - assert(0); + assert(0 && "invalid alpha dst factor"); } /* * Combine RGB terms */ - switch (softpipe->blend->rt[cbuf].rgb_func) { + switch (softpipe->blend->rt[blend_index].rgb_func) { case PIPE_BLEND_ADD: VEC4_ADD_SAT(quadColor[0], source[0], dest[0]); /* R */ VEC4_ADD_SAT(quadColor[1], source[1], dest[1]); /* G */ @@ -729,13 +736,13 @@ blend_quad(struct quad_stage *qs, VEC4_MAX(quadColor[2], source[2], dest[2]); /* B */ break; default: - assert(0); + assert(0 && "invalid rgb blend func"); } /* * Combine A terms */ - switch (softpipe->blend->rt[cbuf].alpha_func) { + switch (softpipe->blend->rt[blend_index].alpha_func) { case PIPE_BLEND_ADD: VEC4_ADD_SAT(quadColor[3], source[3], dest[3]); /* A */ break; @@ -752,7 +759,7 @@ blend_quad(struct quad_stage *qs, VEC4_MAX(quadColor[3], source[3], dest[3]); /* A */ break; default: - assert(0); + assert(0 && "invalid alpha blend func"); } } @@ -822,7 +829,7 @@ blend_fallback(struct quad_stage *qs, logicop_quad( qs, quadColor, dest ); } else if (blend->rt[blend_buf].blend_enable) { - blend_quad( qs, quadColor, dest, cbuf, has_dst_alpha ); + blend_quad( qs, quadColor, dest, blend_buf, has_dst_alpha ); } if (blend->rt[blend_buf].colormask != 0xf) diff --git a/src/gallium/drivers/softpipe/sp_quad_depth_test.c b/src/gallium/drivers/softpipe/sp_quad_depth_test.c index 72117c233e..5590d40892 100644 --- a/src/gallium/drivers/softpipe/sp_quad_depth_test.c +++ b/src/gallium/drivers/softpipe/sp_quad_depth_test.c @@ -82,7 +82,7 @@ get_depth_stencil_values( struct depth_data *data, data->bzzzz[j] = tile->data.depth32[y][x] & 0xffffff; data->stencilVals[j] = tile->data.depth32[y][x] >> 24; } - break; + break; case PIPE_FORMAT_X8Z24_UNORM: case PIPE_FORMAT_S8_USCALED_Z24_UNORM: for (j = 0; j < QUAD_SIZE; j++) { @@ -92,6 +92,14 @@ get_depth_stencil_values( struct depth_data *data, data->stencilVals[j] = tile->data.depth32[y][x] & 0xff; } break; + case PIPE_FORMAT_S8_USCALED: + for (j = 0; j < QUAD_SIZE; j++) { + int x = quad->input.x0 % TILE_SIZE + (j & 1); + int y = quad->input.y0 % TILE_SIZE + (j >> 1); + data->bzzzz[j] = 0; + data->stencilVals[j] = tile->data.stencil8[y][x]; + } + break; default: assert(0); } @@ -227,6 +235,14 @@ write_depth_stencil_values( struct depth_data *data, tile->data.depth32[y][x] = data->bzzzz[j] << 8; } break; + case PIPE_FORMAT_S8_USCALED: + for (j = 0; j < QUAD_SIZE; j++) { + int x = quad->input.x0 % TILE_SIZE + (j & 1); + int y = quad->input.y0 % TILE_SIZE + (j >> 1); + tile->data.stencil8[y][x] = data->stencilVals[j]; + } + break; + default: assert(0); } @@ -661,20 +677,6 @@ static unsigned mask_count[16] = -/** helper to get number of Z buffer bits */ -static unsigned -get_depth_bits(struct quad_stage *qs) -{ - struct pipe_surface *zsurf = qs->softpipe->framebuffer.zsbuf; - if (zsurf) - return util_format_get_component_bits(zsurf->format, - UTIL_FORMAT_COLORSPACE_ZS, 0); - else - return 0; -} - - - /** * General depth/stencil test function. Used when there's no fast-path. */ @@ -693,9 +695,8 @@ depth_test_quads_fallback(struct quad_stage *qs, nr = alpha_test_quads(qs, quads, nr); } - if (get_depth_bits(qs) > 0 && - (qs->softpipe->depth_stencil->depth.enabled || - qs->softpipe->depth_stencil->stencil[0].enabled)) { + if (qs->softpipe->depth_stencil->depth.enabled || + qs->softpipe->depth_stencil->stencil[0].enabled) { data.ps = qs->softpipe->framebuffer.zsbuf; data.format = data.ps->format; @@ -794,8 +795,7 @@ choose_depth_test(struct quad_stage *qs, boolean alpha = qs->softpipe->depth_stencil->alpha.enabled; - boolean depth = (get_depth_bits(qs) > 0 && - qs->softpipe->depth_stencil->depth.enabled); + boolean depth = qs->softpipe->depth_stencil->depth.enabled; unsigned depthfunc = qs->softpipe->depth_stencil->depth.func; diff --git a/src/gallium/drivers/softpipe/sp_quad_fs.c b/src/gallium/drivers/softpipe/sp_quad_fs.c index 907e94b59b..d240bcbf3b 100644 --- a/src/gallium/drivers/softpipe/sp_quad_fs.c +++ b/src/gallium/drivers/softpipe/sp_quad_fs.c @@ -109,7 +109,7 @@ shade_quads(struct quad_stage *qs, { struct softpipe_context *softpipe = qs->softpipe; struct tgsi_exec_machine *machine = softpipe->fs_machine; - unsigned i, pass = 0; + unsigned i, nr_quads = 0; for (i = 0; i < PIPE_MAX_CONSTANT_BUFFERS; i++) { machine->Consts[i] = softpipe->mapped_constants[PIPE_SHADER_FRAGMENT][i]; @@ -123,11 +123,11 @@ shade_quads(struct quad_stage *qs, if (/*do_coverage*/ 0) coverage_quad( qs, quads[i] ); - quads[pass++] = quads[i]; + quads[nr_quads++] = quads[i]; } - if (pass) - qs->next->run(qs->next, quads, pass); + if (nr_quads) + qs->next->run(qs->next, quads, nr_quads); } diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index fc57d3eb61..93af6ee5b0 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -149,6 +149,9 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param) case PIPE_CAP_DEPTHSTENCIL_CLEAR_SEPARATE: return 0; + + case PIPE_CAP_GEOMETRY_SHADER4: + return 1; default: return 0; } diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c index ff83c66d8b..cf7ab81405 100644 --- a/src/gallium/drivers/softpipe/sp_tex_sample.c +++ b/src/gallium/drivers/softpipe/sp_tex_sample.c @@ -71,7 +71,7 @@ lerp(float a, float v0, float v1) /** - * Do 2D/biliner interpolation of float values. + * Do 2D/bilinear interpolation of float values. * v00, v10, v01 and v11 are typically four texture samples in a square/box. * a and b are the horizontal and vertical interpolants. * It's important that this function is inlined when compiled with diff --git a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c index b3e1c49406..eb74f14a7b 100644 --- a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c @@ -63,19 +63,21 @@ sp_create_tex_tile_cache( struct pipe_context *pipe ) void sp_destroy_tex_tile_cache(struct softpipe_tex_tile_cache *tc) { - uint pos; + if (tc) { + uint pos; - for (pos = 0; pos < NUM_ENTRIES; pos++) { - /*assert(tc->entries[pos].x < 0);*/ - } - if (tc->transfer) { - tc->pipe->transfer_destroy(tc->pipe, tc->transfer); - } - if (tc->tex_trans) { - tc->pipe->transfer_destroy(tc->pipe, tc->tex_trans); - } + for (pos = 0; pos < NUM_ENTRIES; pos++) { + /*assert(tc->entries[pos].x < 0);*/ + } + if (tc->transfer) { + tc->pipe->transfer_destroy(tc->pipe, tc->transfer); + } + if (tc->tex_trans) { + tc->pipe->transfer_destroy(tc->pipe, tc->tex_trans); + } - FREE( tc ); + FREE( tc ); + } } diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c index f4db6f6ef0..bf33fd9417 100644 --- a/src/gallium/drivers/softpipe/sp_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tile_cache.c @@ -115,16 +115,18 @@ sp_create_tile_cache( struct pipe_context *pipe ) void sp_destroy_tile_cache(struct softpipe_tile_cache *tc) { - uint pos; + if (tc) { + uint pos; - for (pos = 0; pos < NUM_ENTRIES; pos++) { - /*assert(tc->entries[pos].x < 0);*/ - } - if (tc->transfer) { - tc->pipe->transfer_destroy(tc->pipe, tc->transfer); - } + for (pos = 0; pos < NUM_ENTRIES; pos++) { + /*assert(tc->entries[pos].x < 0);*/ + } + if (tc->transfer) { + tc->pipe->transfer_destroy(tc->pipe, tc->transfer); + } - FREE( tc ); + FREE( tc ); + } } @@ -284,7 +286,11 @@ sp_tile_cache_flush_clear(struct softpipe_tile_cache *tc) assert(pt->resource); /* clear the scratch tile to the clear value */ - clear_tile(&tc->tile, pt->resource->format, tc->clear_val); + if (tc->depth_stencil) { + clear_tile(&tc->tile, pt->resource->format, tc->clear_val); + } else { + clear_tile_rgba(&tc->tile, pt->resource->format, tc->clear_color); + } /* push the tile to all positions marked as clear */ for (y = 0; y < h; y += TILE_SIZE) { @@ -292,11 +298,18 @@ sp_tile_cache_flush_clear(struct softpipe_tile_cache *tc) union tile_address addr = tile_address(x, y); if (is_clear_flag_set(tc->clear_flags, addr)) { - pipe_put_tile_raw(tc->pipe, - pt, - x, y, TILE_SIZE, TILE_SIZE, - tc->tile.data.color32, 0/*STRIDE*/); - + /* write the scratch tile to the surface */ + if (tc->depth_stencil) { + pipe_put_tile_raw(tc->pipe, + pt, + x, y, TILE_SIZE, TILE_SIZE, + tc->tile.data.any, 0/*STRIDE*/); + } + else { + pipe_put_tile_rgba(tc->pipe, pt, + x, y, TILE_SIZE, TILE_SIZE, + (float *) tc->tile.data.color); + } numCleared++; } } |