radv: skip draws with instance_count == 0

Submitted by Samuel Pitoiset on Jan. 7, 2019, 1:48 p.m.

Details

Message ID 20190107134817.12549-1-samuel.pitoiset@gmail.com
State New
Headers show
Series "radv: skip draws with instance_count == 0" ( rev: 1 ) in Mesa

Not browsing as part of any series.

Commit Message

Samuel Pitoiset Jan. 7, 2019, 1:48 p.m.
Loosely based on RadeonSI.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
---
 src/amd/vulkan/radv_cmd_buffer.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Patch hide | download patch | download mbox

diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c
index 1966098e08c..8e3f1a7f5f0 100644
--- a/src/amd/vulkan/radv_cmd_buffer.c
+++ b/src/amd/vulkan/radv_cmd_buffer.c
@@ -3697,6 +3697,20 @@  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->indexed || !info->strmout_buffer)))
+			return;
+	}
+
 	/* Use optimal packet order based on whether we need to sync the
 	 * pipeline.
 	 */

Comments

On Mon, Jan 7, 2019 at 2:45 PM Samuel Pitoiset
<samuel.pitoiset@gmail.com> wrote:
>
> Loosely based on RadeonSI.
>
> Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
> ---
>  src/amd/vulkan/radv_cmd_buffer.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
>
> diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c
> index 1966098e08c..8e3f1a7f5f0 100644
> --- a/src/amd/vulkan/radv_cmd_buffer.c
> +++ b/src/amd/vulkan/radv_cmd_buffer.c
> @@ -3697,6 +3697,20 @@ 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->indexed || !info->strmout_buffer)))

Why the extra condition of (info->indexed || !info->strmout_buffer)?

> +                       return;
> +       }
> +
>         /* Use optimal packet order based on whether we need to sync the
>          * pipeline.
>          */
> --
> 2.20.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
On 1/7/19 2:53 PM, Bas Nieuwenhuizen wrote:
> On Mon, Jan 7, 2019 at 2:45 PM Samuel Pitoiset
> <samuel.pitoiset@gmail.com> wrote:
>> Loosely based on RadeonSI.
>>
>> Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
>> ---
>>   src/amd/vulkan/radv_cmd_buffer.c | 14 ++++++++++++++
>>   1 file changed, 14 insertions(+)
>>
>> diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c
>> index 1966098e08c..8e3f1a7f5f0 100644
>> --- a/src/amd/vulkan/radv_cmd_buffer.c
>> +++ b/src/amd/vulkan/radv_cmd_buffer.c
>> @@ -3697,6 +3697,20 @@ 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->indexed || !info->strmout_buffer)))
> Why the extra condition of (info->indexed || !info->strmout_buffer)?

We need to check info->strmout_buffer, otherwise all 
CmdDrawIndirectByteCountEXT() will be skipped.

Though, that's actually useless to check indexed draws.

>
>> +                       return;
>> +       }
>> +
>>          /* Use optimal packet order based on whether we need to sync the
>>           * pipeline.
>>           */
>> --
>> 2.20.1
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev