+ r300_flush_and_cleanup(r300, flags, fence);
+ } else {
+ if (fence) {
+ /* We have to create a fence object, but the command stream is empty
+ * and we cannot emit an empty CS. Let's write to some reg. */
+ CS_LOCALS(r300);
+ OUT_CS_REG(RB3D_COLOR_CHANNEL_MASK, 0);
+ r300->rws->cs_flush(r300->cs, flags, fence);
+ } else {
+ /* Even if hw is not dirty, we should at least reset the CS in case
+ * the space checking failed for the first draw operation. */
+ r300->rws->cs_flush(r300->cs, flags, NULL);
+ }
+ }
+
+ /* Update Hyper-Z status. */
+ if (r300->hyperz_enabled) {
+ /* If there was a Z clear, keep Hyper-Z access. */
+ if (r300->num_z_clears) {
+ r300->hyperz_time_of_last_flush = os_time_get();
+ r300->num_z_clears = 0;
+ } else if (r300->hyperz_time_of_last_flush - os_time_get() > 2000000) {
+ /* If there hasn't been a Z clear for 2 seconds, revoke Hyper-Z access. */
+ r300->hiz_in_use = FALSE;