anv: Use the data cache for indirect UBO pulls on Gen8+
authorJason Ekstrand <jason@jlekstrand.net>
Fri, 21 Feb 2020 17:45:37 +0000 (11:45 -0600)
committerJason Ekstrand <jason@jlekstrand.net>
Thu, 8 Oct 2020 06:17:11 +0000 (01:17 -0500)
On Gen7, the data cache is pretty terrible so we'd rather avoid it
there.  On Gen8+, it should be fine and is less likely to conflict with
texturing so we should get less cache thrashing there.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3932>

src/intel/vulkan/anv_cmd_buffer.c
src/intel/vulkan/anv_device.c
src/intel/vulkan/anv_private.h

index 6634836..ffc9adf 100644 (file)
@@ -981,7 +981,8 @@ anv_isl_format_for_descriptor_type(const struct anv_device *device,
    switch (type) {
    case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
    case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
-      return ISL_FORMAT_R32G32B32A32_FLOAT;
+      return device->physical->compiler->indirect_ubos_use_sampler ?
+             ISL_FORMAT_R32G32B32A32_FLOAT : ISL_FORMAT_RAW;
 
    case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
    case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
index 5519a7d..3b0a121 100644 (file)
@@ -509,6 +509,7 @@ anv_physical_device_try_create(struct anv_instance *instance,
       device->info.gen < 8 || !device->has_context_isolation;
    device->compiler->supports_shader_constants = true;
    device->compiler->compact_params = false;
+   device->compiler->indirect_ubos_use_sampler = device->info.gen <= 7;
 
    /* Broadwell PRM says:
     *
index b045918..afe60b8 100644 (file)
@@ -2607,7 +2607,10 @@ anv_pipe_invalidate_bits_for_access_flags(struct anv_device *device,
           * port) to avoid stale data.
           */
          pipe_bits |= ANV_PIPE_CONSTANT_CACHE_INVALIDATE_BIT;
-         pipe_bits |= ANV_PIPE_TEXTURE_CACHE_INVALIDATE_BIT;
+         if (device->physical->compiler->indirect_ubos_use_sampler)
+            pipe_bits |= ANV_PIPE_TEXTURE_CACHE_INVALIDATE_BIT;
+         else
+            pipe_bits |= ANV_PIPE_DATA_CACHE_FLUSH_BIT;
          break;
       case VK_ACCESS_SHADER_READ_BIT:
       case VK_ACCESS_INPUT_ATTACHMENT_READ_BIT: