diff options
author | Keith Whitwell <[email protected]> | 2010-08-27 17:30:07 +0100 |
---|---|---|
committer | Keith Whitwell <[email protected]> | 2010-09-07 13:22:55 +0100 |
commit | c512ba88a7e33f14b86feb9c0aaf1ebed5f50629 (patch) | |
tree | d5009fc3e772c3926faa4811c3dd4207378952f5 /src/gallium/drivers/llvmpipe/lp_setup.c | |
parent | 18452c1e87f79327fbd5f27478028b481ee72a5d (diff) |
llvmpipe: clean up deferred zstencil clears
Diffstat (limited to 'src/gallium/drivers/llvmpipe/lp_setup.c')
-rw-r--r-- | src/gallium/drivers/llvmpipe/lp_setup.c | 95 |
1 files changed, 29 insertions, 66 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index ae6d6785025..3bef6209619 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -135,8 +135,7 @@ static void reset_context( struct lp_setup_context *setup ) /* Reset some state: */ - setup->clear.flags = 0; - setup->clear.clearzs.clearzs_mask = 0; + memset(&setup->clear, 0, sizeof setup->clear); /* Have an explicit "start-binning" call and get rid of this * pointer twiddling? @@ -195,7 +194,6 @@ begin_binning( struct lp_setup_context *setup ) lp_scene_bin_everywhere( scene, lp_rast_clear_color, setup->clear.color ); - scene->has_color_clear = TRUE; } } @@ -205,7 +203,9 @@ begin_binning( struct lp_setup_context *setup ) scene->has_depthstencil_clear = TRUE; lp_scene_bin_everywhere( scene, lp_rast_clear_zstencil, - lp_rast_arg_clearzs(&setup->clear.clearzs) ); + lp_rast_arg_clearzs( + setup->clear.zsmask, + setup->clear.zsvalue)); } } @@ -341,67 +341,26 @@ lp_setup_clear( struct lp_setup_context *setup, unsigned flags ) { struct lp_scene *scene = lp_setup_get_current_scene(setup); + uint32_t zsmask = 0; + uint32_t zsvalue = 0; + uint8_t clear_color[4]; unsigned i; - boolean full_zs_clear = TRUE; - uint32_t mask = 0; LP_DBG(DEBUG_SETUP, "%s state %d\n", __FUNCTION__, setup->state); - if (flags & PIPE_CLEAR_COLOR) { - for (i = 0; i < 4; ++i) - setup->clear.color.clear_color[i] = float_to_ubyte(color[i]); + for (i = 0; i < 4; i++) + clear_color[i] = float_to_ubyte(color[i]); } if (flags & PIPE_CLEAR_DEPTHSTENCIL) { - if (setup->fb.zsbuf && - ((flags & PIPE_CLEAR_DEPTHSTENCIL) != PIPE_CLEAR_DEPTHSTENCIL) && - util_format_is_depth_and_stencil(setup->fb.zsbuf->format)) - full_zs_clear = FALSE; - - if (full_zs_clear) { - setup->clear.clearzs.clearzs_value = - util_pack_z_stencil(setup->fb.zsbuf->format, - depth, - stencil); - setup->clear.clearzs.clearzs_mask = 0xffffffff; - } - else { - /* hmm */ - uint32_t tmpval; - if (flags & PIPE_CLEAR_DEPTH) { - tmpval = util_pack_z(setup->fb.zsbuf->format, - depth); - switch (setup->fb.zsbuf->format) { - case PIPE_FORMAT_Z24_UNORM_S8_USCALED: - mask = 0xffffff; - break; - case PIPE_FORMAT_S8_USCALED_Z24_UNORM: - mask = 0xffffff00; - break; - default: - assert(0); - } - } - else { - switch (setup->fb.zsbuf->format) { - case PIPE_FORMAT_Z24_UNORM_S8_USCALED: - mask = 0xff000000; - tmpval = stencil << 24; - break; - case PIPE_FORMAT_S8_USCALED_Z24_UNORM: - mask = 0xff; - tmpval = stencil; - break; - default: - assert(0); - tmpval = 0; - } - } - setup->clear.clearzs.clearzs_mask |= mask; - setup->clear.clearzs.clearzs_value = - (setup->clear.clearzs.clearzs_value & ~mask) | (tmpval & mask); - } + zsvalue = util_pack_z_stencil(setup->fb.zsbuf->format, + depth, + stencil); + + zsmask = util_pack_uint_z_stencil(setup->fb.zsbuf->format, + 0xffffffff, + 0xff); } if (setup->state == SETUP_ACTIVE) { @@ -415,21 +374,13 @@ lp_setup_clear( struct lp_setup_context *setup, lp_scene_bin_everywhere( scene, lp_rast_clear_color, setup->clear.color ); - scene->has_color_clear = TRUE; } if (flags & PIPE_CLEAR_DEPTHSTENCIL) { - if (full_zs_clear) - scene->has_depthstencil_clear = TRUE; - else - setup->clear.clearzs.clearzs_mask = mask; lp_scene_bin_everywhere( scene, lp_rast_clear_zstencil, - lp_rast_arg_clearzs(&setup->clear.clearzs) ); - - + lp_rast_arg_clearzs(zsmask, zsvalue) ); } - } else { /* Put ourselves into the 'pre-clear' state, specifically to try @@ -440,6 +391,18 @@ lp_setup_clear( struct lp_setup_context *setup, set_scene_state( setup, SETUP_CLEARED ); setup->clear.flags |= flags; + + if (flags & PIPE_CLEAR_DEPTHSTENCIL) { + setup->clear.zsmask |= zsmask; + setup->clear.zsvalue = + (setup->clear.zsvalue & ~zsmask) | (zsvalue & zsmask); + } + + if (flags & PIPE_CLEAR_COLOR) { + memcpy(setup->clear.color.clear_color, + clear_color, + sizeof clear_color); + } } } |