NVlabs / nvdiffrast

Nvdiffrast - Modular Primitives for High-Performance Differentiable Rendering
Other
1.29k stars 139 forks source link

Efficiency of the rasterization #107

Closed raywzy closed 1 year ago

raywzy commented 1 year ago

Thanks for the great work and excellent repo!

I have been testing the speed of the rasterization step of nvdiffrast, but found it was slower than the speed in WebGL. What is the main reason and any solutions to reach the similar speed of WebGL in Python?

Thanks a lot!

s-laine commented 1 year ago

I don't know much about WebGL, but I don't see why it should be faster than OpenGL in this situation.

When benchmarking WebGL, did you include the overheads of accessing the input data (positions, indices) from Cuda buffers, and transferring the output into a Cuda buffer, every frame? These overheads are significant especially for simple rendering workloads, but the plumbing is necessary to integrate rasterization in, e.g., a PyTorch pipeline.

The Cuda-based rasterizer (see here) can actually be faster than OpenGL simply because it has fewer overheads, so you may try using that if the limitations are not a problem in your use case.

raywzy commented 1 year ago

Thanks for the prompt and great reply! No, I didn't count the overheads of data fetching and transferrring. Thanks for pointing that out!

I also test the Cuda-based rasterizer but found the speed is lower than the GL version. I guess that will be attributed to the complexity of geometry, whose computational cost is larger than the overheads of data transferrring in my case?

s-laine commented 1 year ago

Most likely so — when the rendering task is complex enough, the OpenGL rasterizer will be faster despite the overheads. Where the line goes depends on a lot of factors, so benchmarking both for the specific load is always recommended when optimizing for performance.

raywzy commented 1 year ago

Thanks a lot!!!