[Piglit] [PATCH] drawoverhead: use GL_TRIANGLES instead of GL_POINTS

Marek Olšák maraeo at gmail.com
Thu Jun 8 11:29:59 UTC 2017


I've re-tested radeonsi vs i965. radeonsi is 7.21x faster now, but
there may be other GPU overheads (e.g. draw rate, command buffer fetch
rate, etc.)

Marek

On Thu, Jun 8, 2017 at 12:35 PM, Marek Olšák <maraeo at gmail.com> wrote:
> From: Marek Olšák <marek.olsak at amd.com>
>
> Triangles are degenerate and therefore culled. Points weren't.
> This decreases the likelihood of being GPU-bound.
>
> I might re-do the radeonsi vs i965 comparison with this.
> ---
>  tests/perf/drawoverhead.c | 36 ++++++++++++++++++------------------
>  1 file changed, 18 insertions(+), 18 deletions(-)
>
> diff --git a/tests/perf/drawoverhead.c b/tests/perf/drawoverhead.c
> index 9dd110f..76aed20 100644
> --- a/tests/perf/drawoverhead.c
> +++ b/tests/perf/drawoverhead.c
> @@ -196,187 +196,187 @@ setup_shaders_and_resources(unsigned num_vbos,
>         }
>         glActiveTexture(GL_TEXTURE0);
>  }
>
>  static void
>  draw(unsigned count)
>  {
>         unsigned i;
>         if (indexed) {
>                 for (i = 0; i < count; i++)
> -                       glDrawElements(GL_POINTS, 4, GL_UNSIGNED_INT, NULL);
> +                       glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, NULL);
>         } else {
>                 for (i = 0; i < count; i++)
> -                       glDrawArrays(GL_POINTS, 0, 4);
> +                       glDrawArrays(GL_TRIANGLES, 0, 3);
>         }
>  }
>
>  static void
>  draw_shader_change(unsigned count)
>  {
>         unsigned i;
>         if (indexed) {
>                 for (i = 0; i < count; i++) {
>                         glUseProgram(prog[i & 1]);
> -                       glDrawElements(GL_POINTS, 4, GL_UNSIGNED_INT, NULL);
> +                       glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, NULL);
>                 }
>         } else {
>                 for (i = 0; i < count; i++) {
>                         glUseProgram(prog[i & 1]);
> -                       glDrawArrays(GL_POINTS, 0, 4);
> +                       glDrawArrays(GL_TRIANGLES, 0, 3);
>                 }
>         }
>         glUseProgram(prog[0]);
>  }
>
>  static void
>  draw_uniform_change(unsigned count)
>  {
>         unsigned i;
>         if (indexed) {
>                 for (i = 0; i < count; i++) {
>                         glUniform4f(uniform_loc, i & 1, 0, 0, 0);
> -                       glDrawElements(GL_POINTS, 4, GL_UNSIGNED_INT, NULL);
> +                       glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, NULL);
>                 }
>         } else {
>                 for (i = 0; i < count; i++) {
>                         glUniform4f(uniform_loc, i & 1, 0, 0, 0);
> -                       glDrawArrays(GL_POINTS, 0, 4);
> +                       glDrawArrays(GL_TRIANGLES, 0, 3);
>                 }
>         }
>  }
>
>  static void
>  draw_one_texture_change(unsigned count)
>  {
>         unsigned i;
>         if (indexed) {
>                 for (i = 0; i < count; i++) {
>                         glBindTexture(GL_TEXTURE_2D, tex[i & 1]);
> -                       glDrawElements(GL_POINTS, 4, GL_UNSIGNED_INT, NULL);
> +                       glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, NULL);
>                 }
>         } else {
>                 for (i = 0; i < count; i++) {
>                         glBindTexture(GL_TEXTURE_2D, tex[i & 1]);
> -                       glDrawArrays(GL_POINTS, 0, 4);
> +                       glDrawArrays(GL_TRIANGLES, 0, 3);
>                 }
>         }
>  }
>
>  static void
>  draw_many_texture_change(unsigned count)
>  {
>         unsigned i,j;
>         if (indexed) {
>                 for (i = 0; i < count; i++) {
>                         for (j = 0; j < 8; j++) {
>                                 glActiveTexture(GL_TEXTURE0 + j);
>                                 glBindTexture(GL_TEXTURE_2D, tex[(i + j) % 8]);
>                         }
>                         glActiveTexture(GL_TEXTURE0);
> -                       glDrawElements(GL_POINTS, 4, GL_UNSIGNED_INT, NULL);
> +                       glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, NULL);
>                 }
>         } else {
>                 for (i = 0; i < count; i++) {
>                         for (j = 0; j < 8; j++) {
>                                 glActiveTexture(GL_TEXTURE0 + j);
>                                 glBindTexture(GL_TEXTURE_2D, tex[(i + j) % 8]);
>                         }
>                         glActiveTexture(GL_TEXTURE0);
> -                       glDrawArrays(GL_POINTS, 0, 4);
> +                       glDrawArrays(GL_TRIANGLES, 0, 3);
>                 }
>         }
>  }
>
>  static void
>  draw_one_ubo_change(unsigned count)
>  {
>         unsigned i;
>         if (indexed) {
>                 for (i = 0; i < count; i++) {
>                         glBindBufferBase(GL_UNIFORM_BUFFER, 0, ubo[i & 1]);
> -                       glDrawElements(GL_POINTS, 4, GL_UNSIGNED_INT, NULL);
> +                       glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, NULL);
>                 }
>         } else {
>                 for (i = 0; i < count; i++) {
>                         glBindBufferBase(GL_UNIFORM_BUFFER, 0, ubo[i & 1]);
> -                       glDrawArrays(GL_POINTS, 0, 4);
> +                       glDrawArrays(GL_TRIANGLES, 0, 3);
>                 }
>         }
>  }
>
>  static void
>  draw_many_ubo_change(unsigned count)
>  {
>         unsigned i,j;
>         if (indexed) {
>                 for (i = 0; i < count; i++) {
>                         for (j = 0; j < 4; j++)
>                                 glBindBufferBase(GL_UNIFORM_BUFFER, 0, ubo[(i + j) % 4]);
> -                       glDrawElements(GL_POINTS, 4, GL_UNSIGNED_INT, NULL);
> +                       glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, NULL);
>                 }
>         } else {
>                 for (i = 0; i < count; i++) {
>                         for (j = 0; j < 4; j++)
>                                 glBindBufferBase(GL_UNIFORM_BUFFER, 0, ubo[(i + j) % 4]);
> -                       glDrawArrays(GL_POINTS, 0, 4);
> +                       glDrawArrays(GL_TRIANGLES, 0, 3);
>                 }
>         }
>  }
>
>  static void
>  draw_state_change(unsigned count)
>  {
>         unsigned i;
>         if (indexed) {
>                 for (i = 0; i < count; i++) {
>                         if (i & 1)
>                                 glEnable(enable_enum);
>                         else
>                                 glDisable(enable_enum);
> -                       glDrawElements(GL_POINTS, 4, GL_UNSIGNED_INT, NULL);
> +                       glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, NULL);
>                 }
>         } else {
>                 for (i = 0; i < count; i++) {
>                         if (i & 1)
>                                 glEnable(enable_enum);
>                         else
>                                 glDisable(enable_enum);
> -                       glDrawArrays(GL_POINTS, 0, 4);
> +                       glDrawArrays(GL_TRIANGLES, 0, 3);
>                 }
>         }
>         glDisable(enable_enum);
>  }
>
>  static void
>  draw_vertex_attrib_change(unsigned count)
>  {
>         unsigned i;
>         if (indexed) {
>                 for (i = 0; i < count; i++) {
>                         if (i & 1)
>                                 glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE,
>                                                       3 * sizeof(float), NULL);
>                         else
>                                 glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE,
>                                                       3 * sizeof(float), NULL);
> -                       glDrawElements(GL_POINTS, 4, GL_UNSIGNED_INT, NULL);
> +                       glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, NULL);
>                 }
>         } else {
>                 for (i = 0; i < count; i++) {
>                         if (i & 1)
>                                 glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE,
>                                                       3 * sizeof(float), NULL);
>                         else
>                                 glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE,
>                                                       3 * sizeof(float), NULL);
> -                       glDrawArrays(GL_POINTS, 0, 4);
> +                       glDrawArrays(GL_TRIANGLES, 0, 3);
>                 }
>         }
>  }
>
>  #define COLOR_RESET    "\033[0m"
>  #define COLOR_RED      "\033[31m"
>  #define COLOR_GREEN    "\033[1;32m"
>  #define COLOR_YELLOW   "\033[1;33m"
>  #define COLOR_CYAN     "\033[1;36m"
>
> --
> 2.7.4
>


More information about the Piglit mailing list