static void create_bcc_state( struct brw_depth_stencil_state *zstencil, const struct pipe_depth_stencil_alpha_state *templ ) { if (templ->stencil[0].enabled) { zstencil->cc0.stencil_enable = 1; zstencil->cc0.stencil_func = brw_translate_compare_func(templ->stencil[0].func); zstencil->cc0.stencil_fail_op = translate_stencil_op(templ->stencil[0].fail_op); zstencil->cc0.stencil_pass_depth_fail_op = translate_stencil_op(templ->stencil[0].zfail_op); zstencil->cc0.stencil_pass_depth_pass_op = translate_stencil_op(templ->stencil[0].zpass_op); zstencil->cc1.stencil_write_mask = templ->stencil[0].writemask; zstencil->cc1.stencil_test_mask = templ->stencil[0].valuemask; if (templ->stencil[1].enabled) { zstencil->cc0.bf_stencil_enable = 1; zstencil->cc0.bf_stencil_func = brw_translate_compare_func(templ->stencil[1].func); zstencil->cc0.bf_stencil_fail_op = translate_stencil_op(templ->stencil[1].fail_op); zstencil->cc0.bf_stencil_pass_depth_fail_op = translate_stencil_op(templ->stencil[1].zfail_op); zstencil->cc0.bf_stencil_pass_depth_pass_op = translate_stencil_op(templ->stencil[1].zpass_op); zstencil->cc2.bf_stencil_write_mask = templ->stencil[1].writemask; zstencil->cc2.bf_stencil_test_mask = templ->stencil[1].valuemask; } zstencil->cc0.stencil_write_enable = (zstencil->cc1.stencil_write_mask || zstencil->cc2.bf_stencil_write_mask); } if (templ->alpha.enabled) { zstencil->cc3.alpha_test = 1; zstencil->cc3.alpha_test_func = brw_translate_compare_func(templ->alpha.func); zstencil->cc3.alpha_test_format = BRW_ALPHATEST_FORMAT_UNORM8; zstencil->cc7.alpha_ref.ub[0] = float_to_ubyte(templ->alpha.ref_value); } if (templ->depth.enabled) { zstencil->cc2.depth_test = 1; zstencil->cc2.depth_test_function = brw_translate_compare_func(templ->depth.func); zstencil->cc2.depth_write_enable = templ->depth.writemask; } }
static void upload_cc_unit( struct brw_context *brw ) { struct brw_cc_unit_state cc; memset(&cc, 0, sizeof(cc)); /* BRW_NEW_DEPTH_STENCIL */ if (brw->attribs.DepthStencil->stencil[0].enabled) { cc.cc0.stencil_enable = brw->attribs.DepthStencil->stencil[0].enabled; cc.cc0.stencil_func = brw_translate_compare_func(brw->attribs.DepthStencil->stencil[0].func); cc.cc0.stencil_fail_op = brw_translate_stencil_op(brw->attribs.DepthStencil->stencil[0].fail_op); cc.cc0.stencil_pass_depth_fail_op = brw_translate_stencil_op( brw->attribs.DepthStencil->stencil[0].zfail_op); cc.cc0.stencil_pass_depth_pass_op = brw_translate_stencil_op( brw->attribs.DepthStencil->stencil[0].zpass_op); cc.cc1.stencil_ref = brw->attribs.DepthStencil->stencil[0].ref_value; cc.cc1.stencil_write_mask = brw->attribs.DepthStencil->stencil[0].write_mask; cc.cc1.stencil_test_mask = brw->attribs.DepthStencil->stencil[0].value_mask; if (brw->attribs.DepthStencil->stencil[1].enabled) { cc.cc0.bf_stencil_enable = brw->attribs.DepthStencil->stencil[1].enabled; cc.cc0.bf_stencil_func = brw_translate_compare_func( brw->attribs.DepthStencil->stencil[1].func); cc.cc0.bf_stencil_fail_op = brw_translate_stencil_op( brw->attribs.DepthStencil->stencil[1].fail_op); cc.cc0.bf_stencil_pass_depth_fail_op = brw_translate_stencil_op( brw->attribs.DepthStencil->stencil[1].zfail_op); cc.cc0.bf_stencil_pass_depth_pass_op = brw_translate_stencil_op( brw->attribs.DepthStencil->stencil[1].zpass_op); cc.cc1.bf_stencil_ref = brw->attribs.DepthStencil->stencil[1].ref_value; cc.cc2.bf_stencil_write_mask = brw->attribs.DepthStencil->stencil[1].write_mask; cc.cc2.bf_stencil_test_mask = brw->attribs.DepthStencil->stencil[1].value_mask; } /* Not really sure about this: */ if (brw->attribs.DepthStencil->stencil[0].write_mask || brw->attribs.DepthStencil->stencil[1].write_mask) cc.cc0.stencil_write_enable = 1; } /* BRW_NEW_BLEND */ if (brw->attribs.Blend->logicop_enable) { cc.cc2.logicop_enable = 1; cc.cc5.logicop_func = brw_translate_logic_op( brw->attribs.Blend->logicop_func ); } else if (brw->attribs.Blend->blend_enable) { int eqRGB = brw->attribs.Blend->rgb_func; int eqA = brw->attribs.Blend->alpha_func; int srcRGB = brw->attribs.Blend->rgb_src_factor; int dstRGB = brw->attribs.Blend->rgb_dst_factor; int srcA = brw->attribs.Blend->alpha_src_factor; int dstA = brw->attribs.Blend->alpha_dst_factor; if (eqRGB == PIPE_BLEND_MIN || eqRGB == PIPE_BLEND_MAX) { srcRGB = dstRGB = PIPE_BLENDFACTOR_ONE; } if (eqA == PIPE_BLEND_MIN || eqA == PIPE_BLEND_MAX) { srcA = dstA = PIPE_BLENDFACTOR_ONE; } cc.cc6.dest_blend_factor = brw_translate_blend_factor(dstRGB); cc.cc6.src_blend_factor = brw_translate_blend_factor(srcRGB); cc.cc6.blend_function = brw_translate_blend_equation( eqRGB ); cc.cc5.ia_dest_blend_factor = brw_translate_blend_factor(dstA); cc.cc5.ia_src_blend_factor = brw_translate_blend_factor(srcA); cc.cc5.ia_blend_function = brw_translate_blend_equation( eqA ); cc.cc3.blend_enable = 1; cc.cc3.ia_blend_enable = (srcA != srcRGB || dstA != dstRGB || eqA != eqRGB); } /* BRW_NEW_ALPHATEST */ if (brw->attribs.DepthStencil->alpha.enabled) { cc.cc3.alpha_test = 1; cc.cc3.alpha_test_func = brw_translate_compare_func(brw->attribs.DepthStencil->alpha.func); cc.cc7.alpha_ref.ub[0] = float_to_ubyte(brw->attribs.DepthStencil->alpha.ref); cc.cc3.alpha_test_format = BRW_ALPHATEST_FORMAT_UNORM8; } if (brw->attribs.Blend->dither) { cc.cc5.dither_enable = 1; cc.cc6.y_dither_offset = 0; cc.cc6.x_dither_offset = 0; } if (brw->attribs.DepthStencil->depth.enabled) { cc.cc2.depth_test = brw->attribs.DepthStencil->depth.enabled; cc.cc2.depth_test_function = brw_translate_compare_func(brw->attribs.DepthStencil->depth.func); cc.cc2.depth_write_enable = brw->attribs.DepthStencil->depth.writemask; } /* CACHE_NEW_CC_VP */ cc.cc4.cc_viewport_state_offset = brw->cc.vp_gs_offset >> 5; if (BRW_DEBUG & DEBUG_STATS) cc.cc5.statistics_enable = 1; brw->cc.state_gs_offset = brw_cache_data( &brw->cache[BRW_CC_UNIT], &cc ); }