Immediate-Mode-UI / Nuklear

A single-header ANSI C immediate mode cross-platform GUI library
https://immediate-mode-ui.github.io/Nuklear/doc/index.html
8.89k stars 533 forks source link

Line chart performance: boxes on points make line charts much slower than without #594

Closed brianwatling closed 3 months ago

brianwatling commented 7 months ago

By default line charts include a box on each point as can be seen in the image below. I've found these boxes drastically reduce performance compared to if I remove them - on my machine the frametime is 74ms with the boxes and locked to 16ms/vsync without (sorry, I don't have an easy way to disable vsync to get better resolution data). image

I've debugged a bit in renderdoc - there's a single draw call for the charts with or without the boxes. I can see there's 111612 elements in the vkCmdDrawIndexed call with boxes vs only 19542 elements without boxes - that's expected given the extra geometry for the boxes. I'll run this through RGP to see if I can find any hints on exactly what's going on.

I've fixed this for myself by simply removing the boxes in my own fork, but wanted to see if there's interest to make the boxes optional.

Some more context: GPU: RX6650 XT Renderer: Vulkan (logic to convert NK commands to draw commands based on demo/sdl_opengl3/nuklear_sdl_gl3.h) Number of points in the chart: 3072 (3 lines, 1024 each)

brianwatling commented 7 months ago

I just noticed my CPU is pegged at 100% in nk_draw_list_fill_poly_convex. After inspecting nk_draw_list_fill_poly_convex I disabled anti aliasing for shapes and performance is much better now. I'll leave this issue open for now because I'd still find it useful to make the boxes optional for chart readability. image