blorp: Use a non-zero MOCS for disabled constant buffers
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 19 Oct 2021 06:32:46 +0000 (23:32 -0700)
committerMarge Bot <emma+marge@anholt.net>
Thu, 28 Oct 2021 19:45:55 +0000 (19:45 +0000)
We'd like to add safeguards against accidental use of MOCS 0 (uncached),
which can have large performance implications.  One case where we use
MOCS of 0 is disabled constant buffers, where MOCS shouldn't matter, as
there's no actual buffer to be cached.

That said, it should be harmless to set MOCS for these null constant
buffers; we can just assume a generic MOCS for internal buffers.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13480>

src/intel/blorp/blorp_genX_exec.h

index 7a8c346..edc7f1f 100644 (file)
@@ -1321,20 +1321,31 @@ blorp_emit_pipeline(struct blorp_batch *batch,
    (void)depth_stencil_state_offset;
 #endif
 
+   UNUSED uint32_t mocs = isl_mocs(batch->blorp->isl_dev, 0, false);
+
 #if GFX_VER >= 12
    blorp_emit(batch, GENX(3DSTATE_CONSTANT_ALL), pc) {
       /* Update empty push constants for all stages (bitmask = 11111b) */
       pc.ShaderUpdateEnable = 0x1f;
+      pc.MOCS = mocs;
    }
 #else
-   blorp_emit(batch, GENX(3DSTATE_CONSTANT_VS), vs);
+#if GFX_VER >= 9
+#define CONSTANT_MOCS xs.MOCS = mocs
+#elif GFX_VER == 7
+#define CONSTANT_MOCS xs.ConstantBody.MOCS = mocs
+#else
+#define CONSTANT_MOCS
+#endif
+   blorp_emit(batch, GENX(3DSTATE_CONSTANT_VS), xs) { CONSTANT_MOCS; }
 #if GFX_VER >= 7
-   blorp_emit(batch, GENX(3DSTATE_CONSTANT_HS), hs);
-   blorp_emit(batch, GENX(3DSTATE_CONSTANT_DS), DS);
+   blorp_emit(batch, GENX(3DSTATE_CONSTANT_HS), xs) { CONSTANT_MOCS; }
+   blorp_emit(batch, GENX(3DSTATE_CONSTANT_DS), xs) { CONSTANT_MOCS; }
 #endif
-   blorp_emit(batch, GENX(3DSTATE_CONSTANT_GS), gs);
-   blorp_emit(batch, GENX(3DSTATE_CONSTANT_PS), ps);
+   blorp_emit(batch, GENX(3DSTATE_CONSTANT_GS), xs) { CONSTANT_MOCS; }
+   blorp_emit(batch, GENX(3DSTATE_CONSTANT_PS), xs) { CONSTANT_MOCS; }
 #endif
+#undef CONSTANT_MOCS
 
    if (params->src.enabled)
       blorp_emit_sampler_state_ps(batch);