- if (vc4->dirty & (VC4_DIRTY_RASTERIZER | VC4_DIRTY_ZSA)) {
- cl_u8(&vc4->bcl, VC4_PACKET_CONFIGURATION_BITS);
- cl_u8(&vc4->bcl,
- vc4->rasterizer->config_bits[0] |
- vc4->zsa->config_bits[0]);
- cl_u8(&vc4->bcl,
+ if (vc4->dirty & (VC4_DIRTY_RASTERIZER |
+ VC4_DIRTY_ZSA |
+ VC4_DIRTY_COMPILED_FS)) {
+ uint8_t ez_enable_mask_out = ~0;
+ uint8_t rasosm_mask_out = ~0;
+
+ struct vc4_cl_out *bcl = cl_start(&job->bcl);
+ /* HW-2905: If the RCL ends up doing a full-res load when
+ * multisampling, then early Z tracking may end up with values
+ * from the previous tile due to a HW bug. Disable it to
+ * avoid that.
+ *
+ * We should be able to skip this when the Z is cleared, but I
+ * was seeing bad rendering on glxgears -samples 4 even in
+ * that case.
+ */
+ if (job->msaa || vc4->prog.fs->disable_early_z)
+ ez_enable_mask_out &= ~VC4_CONFIG_BITS_EARLY_Z;
+
+ /* Don't set the rasterizer to oversample if we're doing our
+ * binning and load/stores in single-sample mode. This is for
+ * the samples == 1 case, where vc4 doesn't do any
+ * multisampling behavior.
+ */
+ if (!job->msaa) {
+ rasosm_mask_out &=
+ ~VC4_CONFIG_BITS_RASTERIZER_OVERSAMPLE_4X;
+ }
+
+ cl_u8(&bcl, VC4_PACKET_CONFIGURATION_BITS);
+ cl_u8(&bcl,
+ (vc4->rasterizer->config_bits[0] |
+ vc4->zsa->config_bits[0]) & rasosm_mask_out);
+ cl_u8(&bcl,