r600g: fix crash in set_framebuffer_state
authorGrigori Goronzy <greg@chown.ath.cx>
Thu, 10 Oct 2013 23:23:20 +0000 (01:23 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 11 Oct 2013 15:33:18 +0000 (17:33 +0200)
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
src/gallium/drivers/r600/r600_state.c

index 83cb02410df670a893a176012a34f9b78826a396..4535d219dd136ee50ce7a8e6d7efbce4f4e93c70 100644 (file)
@@ -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
index b01ab9cac13278c4ad5c0db058bc85fc33ff9f02..f1480526587e24fbda654a38a552a9dd264c33dc 100644 (file)
@@ -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