From: Jason Ekstrand Date: Thu, 11 Aug 2016 00:11:45 +0000 (-0700) Subject: i965/blorp: Add a helper for emitting surface states X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7b035fd0c97939a65825f6e1b467b0d741382bc5;p=mesa.git i965/blorp: Add a helper for emitting surface states The new helper emits surface states and the binding table in one go. It's nice to have it pulled out of the main blorp_exec function. Signed-off-by: Jason Ekstrand Reviewed-by: Topi Pohjolainen --- diff --git a/src/mesa/drivers/dri/i965/genX_blorp_exec.c b/src/mesa/drivers/dri/i965/genX_blorp_exec.c index faa0bfc83d4..283b1525067 100644 --- a/src/mesa/drivers/dri/i965/genX_blorp_exec.c +++ b/src/mesa/drivers/dri/i965/genX_blorp_exec.c @@ -331,6 +331,32 @@ blorp_emit_depth_stencil_state(struct brw_context *brw, return offset; } +static void +blorp_emit_surface_states(struct brw_context *brw, + const struct brw_blorp_params *params) +{ + uint32_t bind_offset; + uint32_t *bind = + brw_state_batch(brw, AUB_TRACE_BINDING_TABLE, + sizeof(uint32_t) * BRW_BLORP_NUM_BINDING_TABLE_ENTRIES, + 32, /* alignment */ &bind_offset); + + bind[BRW_BLORP_RENDERBUFFER_BINDING_TABLE_INDEX] = + brw_blorp_emit_surface_state(brw, ¶ms->dst, + I915_GEM_DOMAIN_RENDER, + I915_GEM_DOMAIN_RENDER, true); + if (params->src.bo) { + bind[BRW_BLORP_TEXTURE_BINDING_TABLE_INDEX] = + brw_blorp_emit_surface_state(brw, ¶ms->src, + I915_GEM_DOMAIN_SAMPLER, 0, false); + } + + blorp_emit(brw, GENX(3DSTATE_BINDING_TABLE_POINTERS), bt) { + bt.PSBindingTableChange = true; + bt.PointertoPSBindingTable = bind_offset; + } +} + static void blorp_emit_sampler_state(struct brw_context *brw, const struct brw_blorp_params *params) @@ -407,7 +433,6 @@ genX(blorp_exec)(struct brw_context *brw, uint32_t blend_state_offset = 0; uint32_t color_calc_state_offset = 0; uint32_t depth_stencil_state_offset; - uint32_t wm_bind_bo_offset = 0; /* Emit workaround flushes when we switch from drawing to blorping. */ brw_emit_post_sync_nonzero_flush(brw); @@ -462,29 +487,8 @@ genX(blorp_exec)(struct brw_context *brw, blorp_emit(brw, GENX(3DSTATE_CONSTANT_GS), gs); blorp_emit(brw, GENX(3DSTATE_CONSTANT_PS), ps); - if (params->wm_prog_data) { - uint32_t wm_surf_offset_renderbuffer; - uint32_t wm_surf_offset_texture = 0; - - wm_surf_offset_renderbuffer = - brw_blorp_emit_surface_state(brw, ¶ms->dst, - I915_GEM_DOMAIN_RENDER, - I915_GEM_DOMAIN_RENDER, true); - if (params->src.bo) { - wm_surf_offset_texture = - brw_blorp_emit_surface_state(brw, ¶ms->src, - I915_GEM_DOMAIN_SAMPLER, 0, false); - } - wm_bind_bo_offset = - gen6_blorp_emit_binding_table(brw, - wm_surf_offset_renderbuffer, - wm_surf_offset_texture); - - blorp_emit(brw, GENX(3DSTATE_BINDING_TABLE_POINTERS), bt) { - bt.PSBindingTableChange = true; - bt.PointertoPSBindingTable = wm_bind_bo_offset; - } - } + if (params->wm_prog_data) + blorp_emit_surface_states(brw, params); if (params->src.bo) blorp_emit_sampler_state(brw, params);