Optix 7 and .Net, best approach?

To run some calculations from Unity I used p/Invoke to run against Optix 6.5.

There is a big refactoring happening, so we need to address the whole code base around that anyways, so I am looking into upgrading to 7 as we do. The changes in 7 would also work well with the changes we make to the software, having more control over loading assets etc.

My understanding though is that the api has become much more, complexity that was previously hidden.

Now I am wondering how to best go about this and would appreciate any input, especially from people that also know .Net/C#.

The API that I’d need to DllImport seems much bigger, so it would be a lot of work figuring this out. Or I build some wrapper in C++ that is either generic or geared towards the queries we need to run. The problem with that: I have no experience with C++ and still seems daunting.

I also looked into other options (DXR, Vulkan…), but nothing seems to be better than Optix. We just need to answer the question “can I see this or that from here”, but a few hundred million times per second.

Opinions?

Is there a better way to go about it that I am missing?

If that is the only task you want to achieve, I would simply suggest to use only depth z buffering, utilizing a rasterizer (using “earlydepthstencil” / “frustum culling” / etc) instead of raytracing.

I’m not sure whether the RT cores on RTX hardware are faster in this case. It also depends also on the complexitiy of your scene (the traversals).
I would simply implement both and then compare the result time consumings on some typical scenes. (ensure to sync the device on time measuring OptiX launches)

In any case from my experience I can say, that OptiX 7 is much faster than OptiX 6.5, its really worth to go that refactoring way. But I did all in C++, I never used C#. Cannot help you with that at all.

2 Likes

Thanks. We do need the raytracing though. It is a little bit more complex and the rays are pre defined. We can’t just look at whatever and then interpret that. There was a solution previously that was close to what you’re describing and it was many orders of magnitudes slower. RT cores really make the difference here.

Currently leaning towards picking up C++ (yeah, I know. Been avoiding that for ~25 years).

But yes, still hoping for a solution closer to .Net

I faced a similar problem, ended up DllImporting external functions from my C++ library that expose selective functionality from my renderer. Like (SetUpScene, LoadMesh, SetViewpoint, Render, DownloadResults and so on). All I need to deploy this is the 500kb cudart64.dll, my 500kb C++ library and the C# wrapper.

To be honest I had not written a single line of C++ two months ago and it all seems to work fine so far. Hopefully I’m not blowing up memory somewhere.

The Optix samples are super and covers a lot!

1 Like

@oborgstrom Yeah. I think that’s the route we will take. Team and lead is also behind the idea. So thanks for the input, good to know I am on a good track here.