From 3de7e11f58917bb2372c7ec0e104038ae5dca245 Mon Sep 17 00:00:00 2001 From: Grigori Goronzy Date: Fri, 11 Oct 2013 01:23:20 +0200 Subject: r600g: fix crash in set_framebuffer_state We should be able to safely set the framebuffer state without a fragment shader bound. bind_ps_state will take care of updating the necessary state bits later. v2: check in update_db_shader_control --- src/gallium/drivers/r600/evergreen_state.c | 23 +++++++++++++++-------- src/gallium/drivers/r600/r600_state.c | 15 +++++++++++---- 2 files changed, 26 insertions(+), 12 deletions(-) (limited to 'src/gallium/drivers/r600') diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c index 83cb02410df..4535d219dd1 100644 --- a/src/gallium/drivers/r600/evergreen_state.c +++ b/src/gallium/drivers/r600/evergreen_state.c @@ -3581,14 +3581,21 @@ void *evergreen_create_db_flush_dsa(struct r600_context *rctx) void evergreen_update_db_shader_control(struct r600_context * rctx) { - bool dual_export = rctx->framebuffer.export_16bpc && - !rctx->ps_shader->current->ps_depth_export; - - unsigned db_shader_control = rctx->ps_shader->current->db_shader_control | - S_02880C_DUAL_EXPORT_ENABLE(dual_export) | - S_02880C_DB_SOURCE_FORMAT(dual_export ? V_02880C_EXPORT_DB_TWO : - V_02880C_EXPORT_DB_FULL) | - S_02880C_ALPHA_TO_MASK_DISABLE(rctx->framebuffer.cb0_is_integer); + bool dual_export; + unsigned db_shader_control; + + if (!rctx->ps_shader) { + return; + } + + dual_export = rctx->framebuffer.export_16bpc && + !rctx->ps_shader->current->ps_depth_export; + + db_shader_control = rctx->ps_shader->current->db_shader_control | + S_02880C_DUAL_EXPORT_ENABLE(dual_export) | + S_02880C_DB_SOURCE_FORMAT(dual_export ? V_02880C_EXPORT_DB_TWO : + V_02880C_EXPORT_DB_FULL) | + S_02880C_ALPHA_TO_MASK_DISABLE(rctx->framebuffer.cb0_is_integer); /* When alpha test is enabled we can't trust the hw to make the proper * decision on the order in which ztest should be run related to fragment diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c index b01ab9cac13..f1480526587 100644 --- a/src/gallium/drivers/r600/r600_state.c +++ b/src/gallium/drivers/r600/r600_state.c @@ -2972,11 +2972,18 @@ void *r600_create_db_flush_dsa(struct r600_context *rctx) void r600_update_db_shader_control(struct r600_context * rctx) { - bool dual_export = rctx->framebuffer.export_16bpc && - !rctx->ps_shader->current->ps_depth_export; + bool dual_export; + unsigned db_shader_control; - unsigned db_shader_control = rctx->ps_shader->current->db_shader_control | - S_02880C_DUAL_EXPORT_ENABLE(dual_export); + if (!rctx->ps_shader) { + return; + } + + dual_export = rctx->framebuffer.export_16bpc && + !rctx->ps_shader->current->ps_depth_export; + + db_shader_control = rctx->ps_shader->current->db_shader_control | + S_02880C_DUAL_EXPORT_ENABLE(dual_export); /* When alpha test is enabled we can't trust the hw to make the proper * decision on the order in which ztest should be run related to fragment -- cgit v1.2.3