maierfelix / dawn-ray-tracing

Hardware Ray tracing extension for Chromium WebGPU
Apache License 2.0
265 stars 15 forks source link

Metal implementation #6

Open meirbon opened 4 years ago

meirbon commented 4 years ago

Would it be possible te create a Metal implementation as well? Metal has had a ray tracing pipeline for some time now as well. I wouldn't mind starting an implementation on my own, but I have no idea what the pipeline of Dawn looks like. Support for top-level & bottom-level acceleration structures is all there and from my experience performance is decent as well.

Could you give me any pointers on how to get started?

maierfelix commented 4 years ago

A RT implementation for Metal would be great, but I'm afraid I can't help much on this as I've never used Metal before. You might want to reach out to @Kangz regarding the Metal implementation.

Also it is unclear yet what kind of RT WebGPU will be supported, i.e. if it also provides fallback options for RT such as the DXR fallback layer or focus on the hardware acceleration (which is only available in Vulkan and DirectX so far).

To learn about Dawn, you should start browsing in src/dawn_native. To find out how the current RT extension is implemented, search for everything starting with RayTracing at the beginning :)

Kangz commented 4 years ago

DXR and Vulkan RT are fairly similar, but AFAIK Metal RT has some differences. If you want to add Metal support to @maierfelix's fork, the best solution would be to do a comparative investigation of all three APIs to see commonalities and differences, so you can choose a Dawn frontend API that can map to all three.

I'm not sure what you're looking for, the Metal backend of Dawn is in src/dawn_native/metal and if the RT fork works like regular Dawn, all you need to do is implement a couple new objects, virtual methods and handling of new commands in CommandBufferMTL.mm

meirbon commented 4 years ago

All right, thank you for the info. The main thing I am worried about is that Metal does not have a specific pipeline for ray tracing like DX12 and Vulkan, everything is compute based. Thus I am not sure how I would translate shaders between the APIs.

I'll have a look into it, I can't work on this full time though. I was just wondering if I would be able to help in any way as I would love to see RT support in webgpu. Thank you for the work you've done thus far :)