radv: skip draws with instance_count == 0
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 9 Jan 2019 09:06:08 +0000 (10:06 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 9 Jan 2019 13:22:38 +0000 (14:22 +0100)
Loosely based on RadeonSI.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_cmd_buffer.c

index 4382062c411ffcfb96c87920fd334c9d04cffdff..f41d6c0b3e71617f8aae81267e250be8c4b5405b 100644 (file)
@@ -3696,6 +3696,19 @@ radv_draw(struct radv_cmd_buffer *cmd_buffer,
                radeon_check_space(cmd_buffer->device->ws,
                                   cmd_buffer->cs, 4096);
 
+       if (likely(!info->indirect)) {
+               /* SI-CI treat instance_count==0 as instance_count==1. There is
+                * no workaround for indirect draws, but we can at least skip
+                * direct draws.
+                */
+               if (unlikely(!info->instance_count))
+                       return;
+
+               /* Handle count == 0. */
+               if (unlikely(!info->count && !info->strmout_buffer))
+                       return;
+       }
+
        /* Use optimal packet order based on whether we need to sync the
         * pipeline.
         */