anv: Set MOCS in 3DSTATE_CONSTANT_XS even if there isn't a buffer.
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 19 Oct 2021 06:39:30 +0000 (23:39 -0700)
committerMarge Bot <emma+marge@anholt.net>
Thu, 28 Oct 2021 19:45:55 +0000 (19:45 +0000)
This avoids MOCS != 0 assertions in later patches.  iris also does this,
and we do it for the 3DSTATE_CONSTANT_ALL packet path as well.  It's a
bit pointless, but it should hopefully be harmless also.

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

src/intel/vulkan/genX_cmd_buffer.c

index 96abd8f..72b5f7e 100644 (file)
@@ -3178,30 +3178,31 @@ cmd_buffer_emit_push_constant(struct anv_cmd_buffer *cmd_buffer,
    anv_batch_emit(&cmd_buffer->batch, GENX(3DSTATE_CONSTANT_VS), c) {
       c._3DCommandSubOpcode = push_constant_opcodes[stage];
 
-      if (anv_pipeline_has_stage(pipeline, stage)) {
-         const struct anv_pipeline_bind_map *bind_map =
-            &pipeline->shaders[stage]->bind_map;
-
-         /* Set MOCS, except on Gfx8, because the Broadwell PRM says:
-          *
-          *    "Constant Buffer Object Control State must be always programmed
-          *    to zero."
-          *
-          * This restriction does not exist on any newer platforms.
-          *
-          * We only have one MOCS field for the whole packet, not one per
-          * buffer.  We could go out of our way here to walk over all of the
-          * buffers and see if any of them are used externally and use the
-          * external MOCS.  However, the notion that someone would use the
-          * same bit of memory for both scanout and a UBO is nuts.  Let's not
-          * bother and assume it's all internal.
-          */
+      /* Set MOCS, except on Gfx8, because the Broadwell PRM says:
+       *
+       *    "Constant Buffer Object Control State must be always
+       *     programmed to zero."
+       *
+       * This restriction does not exist on any newer platforms.
+       *
+       * We only have one MOCS field for the whole packet, not one per
+       * buffer.  We could go out of our way here to walk over all of
+       * the buffers and see if any of them are used externally and use
+       * the external MOCS.  However, the notion that someone would use
+       * the same bit of memory for both scanout and a UBO is nuts.
+       *
+       * Let's not bother and assume it's all internal.
+       */
 #if GFX_VER >= 9
-         c.MOCS = mocs;
+      c.MOCS = mocs;
 #elif GFX_VER < 8
-         c.ConstantBody.MOCS = mocs;
+      c.ConstantBody.MOCS = mocs;
 #endif
 
+      if (anv_pipeline_has_stage(pipeline, stage)) {
+         const struct anv_pipeline_bind_map *bind_map =
+            &pipeline->shaders[stage]->bind_map;
+
 #if GFX_VERx10 >= 75
          /* The Skylake PRM contains the following restriction:
           *