microsoft / OpenCLOn12

The OpenCL-on-D3D12 mapping layer
MIT License
104 stars 13 forks source link

Refactor interface to compiler, support SPIR-V IL programs #21

Closed jenatali closed 2 years ago

jenatali commented 3 years ago

The first (large) commit here abstracts the compiler interface, so that the external dependency on clc_compiler.h and clglon12compiler.dll is behind a pure-virtual interface, which allows us to have multiple drop-in implementations.

After that, a second compiler backend is dropped in, which uses a completely reworked clc_compiler.h and targets clon12compiler.dll. This corresponds to a Mesa merge request: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10322.

Then, support for SPIR-V IL programs is added. Lastly, a test is added - currently with bugfixes, I'd like to go back and clean up the commit history here.

jenatali commented 3 years ago

History cleaned up. Since the v2 compiler interface isn't merged upstream yet, there's possibly going to be more changes to it, but it's isolated enough that I think that'll be fine.

One TBD is that if I flip the switch to claim CL 3.0, this change as it currently exists will be out-of-spec since it doesn't support specialization constants. Further, the v1 compiler will always be out-of-spec if it claims CL 3.0 support. Maybe this is okay, or maybe using the v1 compiler needs to not report SPIR-V support, or maybe the v1 compiler needs to not claim CL 3.0 support.

Filed https://github.com/KhronosGroup/OpenCL-Docs/issues/602 to get more clarity on that. Either way, since CL 3.0 isn't flipped on by default yet, I think this is fine as-is.