const struct lp_rast_state *state;
};
-struct lp_rast_clearzs {
- unsigned clearzs_value;
- unsigned clearzs_mask;
-};
struct lp_rast_plane {
/* one-pixel sized trivial accept offsets for each plane */
} triangle;
const struct lp_rast_state *set_state;
uint8_t clear_color[4];
- const struct lp_rast_clearzs *clear_zstencil;
+ struct {
+ unsigned value;
+ unsigned mask;
+ } clear_zstencil;
struct lp_fence *fence;
struct llvmpipe_query *query_obj;
};
static INLINE union lp_rast_cmd_arg
-lp_rast_arg_clearzs( const struct lp_rast_clearzs *clearzs )
+lp_rast_arg_clearzs( unsigned value, unsigned mask )
{
union lp_rast_cmd_arg arg;
- arg.clear_zstencil = clearzs;
+ arg.clear_zstencil.value = value;
+ arg.clear_zstencil.mask = mask;
return arg;
}
+
static INLINE union lp_rast_cmd_arg
lp_rast_arg_null( void )
{
/* 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?
lp_scene_bin_everywhere( scene,
lp_rast_clear_color,
setup->clear.color );
- scene->has_color_clear = TRUE;
}
}
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));
}
}
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) {
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
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);
+ }
}
}