Skip to content

Add OpenCL backend for progressive path tracer (bindless images experimental) #109

Description

@juanchuletas

Motivation

The progressive path tracer currently uses SYCL with the Level Zero backend. Level Zero gives access to bindless images, but it does not support cl_khr_gl_sharing. Because of this, every frame requires a double PCIe crossing: the SYCL kernel renders into a buffer, the CPU accumulates the result, and then the data is uploaded again to OpenGL with glTexSubImage2D. This wastes both time and memory bandwidth.

OpenCL supports cl_khr_gl_sharing, which allows OpenGL and OpenCL to share the same GPU resource directly. No CPU roundtrip, no extra copy. The render target can be shared between OpenCL and OpenGL, so the path tracer writes straight into the texture that OpenGL displays.

FunGT uses bindless images. Nevertheless, they are not available in OpenCL. To enable them, the OpenCL adapter must have bindless image support, which currently only exists in my compute-runtime fork:

https://github.com/juanchuletas/compute-runtime

Pull Request: intel/compute-runtime#956

This part remains experimental and can be enabled through FUNGT_ENABLE_OCL_BINDLESS_IMAGES. Without this flag, the OpenCL backend still works against stock upstream compute-runtime, using regular images through cl_khr_gl_sharing.

Acceptance Criteria

The OpenCL backend works using regular images through cl_khr_gl_sharing, without FUNGT_ENABLE_OCL_BINDLESS_IMAGES set.

The progressive path tracer using the OpenCL backend writes directly into the shared GL texture, with no CPU side accumulate copy and no glTexSubImage2D call in the per frame path, with or without bindless.

When FUNGT_ENABLE_OCL_BINDLESS_IMAGES is set, a visible warning marks that feature as experimental, and the build requires the compute-runtime fork. If the runtime does not report bindless support, initialization throws a clear error instead of crashing.

Building against upstream compute-runtime without the fork, and without FUNGT_ENABLE_OCL_BINDLESS_IMAGES set, still produces a working OpenCL backend.

The default build configuration does not change. CPU, CUDA, and SYCL backends behave exactly as they do today.

Dependencies

cl_khr_gl_sharing extension support on target hardware, for the shared texture path.

Bindless image support for the OpenCL adapter in Unified Runtime, currently only in the compute-runtime fork. This is only required when FUNGT_ENABLE_OCL_BINDLESS_IMAGES is set, not for the OpenCL backend as a whole.

IComputeRenderer interface, already shared by CPU_Renderer, CUDA_Renderer, and SYCL_Renderer.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions