diff options
author | Brian Paul <[email protected]> | 2014-01-15 17:24:02 -0800 |
---|---|---|
committer | Brian Paul <[email protected]> | 2014-01-17 08:52:11 -0800 |
commit | 7b4ceec0b7591fa7a2dd66c45727341f52bf5258 (patch) | |
tree | 1524622bd4428600a3e018773649516a6522fbc8 /src | |
parent | 3b64714da48f1654dbbf6ef5b4abe5b0c5952a9e (diff) |
softpipe: handle NULL color buffer pointers
Fixes regression from 9baa45f78b8ca7d66280e36009b6a685055d7cd6
Reviewed-by: Roland Scheidegger <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/softpipe/sp_quad_blend.c | 189 |
1 files changed, 96 insertions, 93 deletions
diff --git a/src/gallium/drivers/softpipe/sp_quad_blend.c b/src/gallium/drivers/softpipe/sp_quad_blend.c index d122586559d..00a9be62f6e 100644 --- a/src/gallium/drivers/softpipe/sp_quad_blend.c +++ b/src/gallium/drivers/softpipe/sp_quad_blend.c @@ -927,93 +927,94 @@ blend_fallback(struct quad_stage *qs, write_all = softpipe->fs_variant->info.color0_writes_all_cbufs; - for (cbuf = 0; cbuf < softpipe->framebuffer.nr_cbufs; cbuf++) - { - /* which blend/mask state index to use: */ - const uint blend_buf = blend->independent_blend_enable ? cbuf : 0; - float dest[4][TGSI_QUAD_SIZE]; - struct softpipe_cached_tile *tile - = sp_get_cached_tile(softpipe->cbuf_cache[cbuf], - quads[0]->input.x0, - quads[0]->input.y0); - const boolean clamp = bqs->clamp[cbuf]; - const float *blend_color; - const boolean dual_source_blend = util_blend_state_is_dual(blend, cbuf); - uint q, i, j; - - if (clamp) - blend_color = softpipe->blend_color_clamped.color; - else - blend_color = softpipe->blend_color.color; - - for (q = 0; q < nr; q++) { - struct quad_header *quad = quads[q]; - float (*quadColor)[4]; - float (*quadColor2)[4] = NULL; - float temp_quad_color[TGSI_QUAD_SIZE][4]; - const int itx = (quad->input.x0 & (TILE_SIZE-1)); - const int ity = (quad->input.y0 & (TILE_SIZE-1)); - - if (write_all) { - for (j = 0; j < TGSI_QUAD_SIZE; j++) { - for (i = 0; i < 4; i++) { - temp_quad_color[i][j] = quad->output.color[0][i][j]; + for (cbuf = 0; cbuf < softpipe->framebuffer.nr_cbufs; cbuf++) { + if (softpipe->framebuffer.cbufs[cbuf]) { + /* which blend/mask state index to use: */ + const uint blend_buf = blend->independent_blend_enable ? cbuf : 0; + float dest[4][TGSI_QUAD_SIZE]; + struct softpipe_cached_tile *tile + = sp_get_cached_tile(softpipe->cbuf_cache[cbuf], + quads[0]->input.x0, + quads[0]->input.y0); + const boolean clamp = bqs->clamp[cbuf]; + const float *blend_color; + const boolean dual_source_blend = util_blend_state_is_dual(blend, cbuf); + uint q, i, j; + + if (clamp) + blend_color = softpipe->blend_color_clamped.color; + else + blend_color = softpipe->blend_color.color; + + for (q = 0; q < nr; q++) { + struct quad_header *quad = quads[q]; + float (*quadColor)[4]; + float (*quadColor2)[4] = NULL; + float temp_quad_color[TGSI_QUAD_SIZE][4]; + const int itx = (quad->input.x0 & (TILE_SIZE-1)); + const int ity = (quad->input.y0 & (TILE_SIZE-1)); + + if (write_all) { + for (j = 0; j < TGSI_QUAD_SIZE; j++) { + for (i = 0; i < 4; i++) { + temp_quad_color[i][j] = quad->output.color[0][i][j]; + } } + quadColor = temp_quad_color; + } else { + quadColor = quad->output.color[cbuf]; + if (dual_source_blend) + quadColor2 = quad->output.color[cbuf + 1]; } - quadColor = temp_quad_color; - } else { - quadColor = quad->output.color[cbuf]; - if (dual_source_blend) - quadColor2 = quad->output.color[cbuf + 1]; - } - /* If fixed-point dest color buffer, need to clamp the incoming - * fragment colors now. - */ - if (clamp || softpipe->rasterizer->clamp_fragment_color) { - clamp_colors(quadColor); - } + /* If fixed-point dest color buffer, need to clamp the incoming + * fragment colors now. + */ + if (clamp || softpipe->rasterizer->clamp_fragment_color) { + clamp_colors(quadColor); + } - /* get/swizzle dest colors - */ - for (j = 0; j < TGSI_QUAD_SIZE; j++) { - int x = itx + (j & 1); - int y = ity + (j >> 1); - for (i = 0; i < 4; i++) { - dest[i][j] = tile->data.color[y][x][i]; + /* get/swizzle dest colors + */ + for (j = 0; j < TGSI_QUAD_SIZE; j++) { + int x = itx + (j & 1); + int y = ity + (j >> 1); + for (i = 0; i < 4; i++) { + dest[i][j] = tile->data.color[y][x][i]; + } } - } - if (blend->logicop_enable) { - if (bqs->format_type[cbuf] != UTIL_FORMAT_TYPE_FLOAT) { - logicop_quad( qs, quadColor, dest ); + if (blend->logicop_enable) { + if (bqs->format_type[cbuf] != UTIL_FORMAT_TYPE_FLOAT) { + logicop_quad( qs, quadColor, dest ); + } } - } - else if (blend->rt[blend_buf].blend_enable) { - blend_quad(qs, quadColor, quadColor2, dest, blend_color, blend_buf); - - /* If fixed-point dest color buffer, need to clamp the outgoing - * fragment colors now. - */ - if (clamp) { - clamp_colors(quadColor); + else if (blend->rt[blend_buf].blend_enable) { + blend_quad(qs, quadColor, quadColor2, dest, blend_color, blend_buf); + + /* If fixed-point dest color buffer, need to clamp the outgoing + * fragment colors now. + */ + if (clamp) { + clamp_colors(quadColor); + } } - } - rebase_colors(bqs->base_format[cbuf], quadColor); + rebase_colors(bqs->base_format[cbuf], quadColor); - if (blend->rt[blend_buf].colormask != 0xf) - colormask_quad( blend->rt[cbuf].colormask, quadColor, dest); - - /* Output color values - */ - for (j = 0; j < TGSI_QUAD_SIZE; j++) { - if (quad->inout.mask & (1 << j)) { - int x = itx + (j & 1); - int y = ity + (j >> 1); - for (i = 0; i < 4; i++) { /* loop over color chans */ - tile->data.color[y][x][i] = quadColor[i][j]; + if (blend->rt[blend_buf].colormask != 0xf) + colormask_quad( blend->rt[cbuf].colormask, quadColor, dest); + + /* Output color values + */ + for (j = 0; j < TGSI_QUAD_SIZE; j++) { + if (quad->inout.mask & (1 << j)) { + int x = itx + (j & 1); + int y = ity + (j >> 1); + for (i = 0; i < 4; i++) { /* loop over color chans */ + tile->data.color[y][x][i] = quadColor[i][j]; + } } } } @@ -1255,23 +1256,25 @@ choose_blend_quad(struct quad_stage *qs, * whether color clamping is needed. */ for (i = 0; i < softpipe->framebuffer.nr_cbufs; i++) { - const enum pipe_format format = softpipe->framebuffer.cbufs[i]->format; - const struct util_format_description *desc = - util_format_description(format); - /* assuming all or no color channels are normalized: */ - bqs->clamp[i] = desc->channel[0].normalized; - bqs->format_type[i] = desc->channel[0].type; - - if (util_format_is_intensity(format)) - bqs->base_format[i] = INTENSITY; - else if (util_format_is_luminance(format)) - bqs->base_format[i] = LUMINANCE; - else if (util_format_is_luminance_alpha(format)) - bqs->base_format[i] = LUMINANCE_ALPHA; - else if (!util_format_has_alpha(format)) - bqs->base_format[i] = RGB; - else - bqs->base_format[i] = RGBA; + if (softpipe->framebuffer.cbufs[i]) { + const enum pipe_format format = softpipe->framebuffer.cbufs[i]->format; + const struct util_format_description *desc = + util_format_description(format); + /* assuming all or no color channels are normalized: */ + bqs->clamp[i] = desc->channel[0].normalized; + bqs->format_type[i] = desc->channel[0].type; + + if (util_format_is_intensity(format)) + bqs->base_format[i] = INTENSITY; + else if (util_format_is_luminance(format)) + bqs->base_format[i] = LUMINANCE; + else if (util_format_is_luminance_alpha(format)) + bqs->base_format[i] = LUMINANCE_ALPHA; + else if (!util_format_has_alpha(format)) + bqs->base_format[i] = RGB; + else + bqs->base_format[i] = RGBA; + } } qs->run(qs, quads, nr); |