Programming null constants with gather constant tables seems to be unsupported and results in a GPU lockup even with the prescribed GPU workarounds in the bspec. I found out by trial and error that disabling the gather constant feature for null constants is the only way to go around the issue.
This patch batches the null push constant state commands if possible so we don't unnecessarily send the gather push constants disable command every time we send a null constant state in the pipeline. Signed-off-by: Abdiel Janulgue <abdiel.janul...@linux.intel.com> --- src/mesa/drivers/dri/i965/brw_context.c | 1 + src/mesa/drivers/dri/i965/brw_context.h | 1 + src/mesa/drivers/dri/i965/gen7_disable.c | 4 ++++ src/mesa/drivers/dri/i965/gen7_vs_state.c | 20 ++++++++++++++++++++ 4 files changed, 26 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index a6e73ce..175a7c8 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -861,6 +861,7 @@ brwCreateContext(gl_api api, brw->hw_bt_pool.bo = 0; brw->gather_pool.bo = 0; brw->constants.bo = 0; + brw->enabled_stage_const = 0x7; if (INTEL_DEBUG & DEBUG_SHADER_TIME) brw_init_shader_time(brw); diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 6706b4a..0337bfd 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -1358,6 +1358,7 @@ struct brw_context } constants; uint64_t uniformstagemap[MAX_UNIFORMS]; + GLbitfield enabled_stage_const; struct { uint32_t state_offset; diff --git a/src/mesa/drivers/dri/i965/gen7_disable.c b/src/mesa/drivers/dri/i965/gen7_disable.c index 2c43cd7..ba7fbf8 100644 --- a/src/mesa/drivers/dri/i965/gen7_disable.c +++ b/src/mesa/drivers/dri/i965/gen7_disable.c @@ -29,6 +29,8 @@ static void disable_stages(struct brw_context *brw) { + gen7_toggle_gather_constants(brw, false); + /* Disable the HS Unit */ BEGIN_BATCH(7); OUT_BATCH(_3DSTATE_CONSTANT_HS << 16 | (7 - 2)); @@ -87,6 +89,8 @@ disable_stages(struct brw_context *brw) OUT_BATCH(_3DSTATE_BINDING_TABLE_POINTERS_DS << 16 | (2 - 2)); OUT_BATCH(0); ADVANCE_BATCH(); + + gen7_toggle_gather_constants(brw, true); } const struct brw_tracked_state gen7_disable_stages = { diff --git a/src/mesa/drivers/dri/i965/gen7_vs_state.c b/src/mesa/drivers/dri/i965/gen7_vs_state.c index 269612b..30ebec8 100644 --- a/src/mesa/drivers/dri/i965/gen7_vs_state.c +++ b/src/mesa/drivers/dri/i965/gen7_vs_state.c @@ -116,6 +116,22 @@ gen7_upload_constant_state(struct brw_context *brw, int const_loc = use_gather ? 16 : 0; int dwords = brw->gen >= 8 ? 11 : 7; + /* Disable gather constants when zeroing constant states */ + bool gather_switched_off = false; + if (use_gather) { + if (active) { + brw->enabled_stage_const |= (1 << stage_state->stage); + } else { + if (brw->enabled_stage_const & (1 << stage_state->stage)) { + gen7_toggle_gather_constants(brw, false); + gather_switched_off = true; + brw->enabled_stage_const &= ~(1 << stage_state->stage); + } else { + return; + } + } + } + struct brw_stage_prog_data *prog_data = stage_state->prog_data; if (prog_data && use_gather && active) { gen7_submit_gather_table(brw, stage_state, prog_data, gather_opcode); @@ -145,6 +161,10 @@ gen7_upload_constant_state(struct brw_context *brw, } ADVANCE_BATCH(); + + /* Re-enable gather again if required */ + if (gather_switched_off) + gen7_toggle_gather_constants(brw, true); } -- 1.9.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev