目前,基于GPU或多核CPU加速的光线跟踪算法是与硬件相关的.研究具有跨平台性能的实时光线跟踪算法既具有挑战性,又具有很强的应用价值.为此,提出一种基于OpenCL并且跨平台的动态场景实时光线跟踪绘制算法.首先通过对通用GPU并行处理性能进行发掘,将光线跟踪中KD—Tree建立、场景遍历和绘制3个过程均设计在GPU上,而CPU只负责其中各过程的调度,从而充分利用了GPU的计算性能,并有效地降低了数据传输开销;通过设计并行分区、并行SAH、紧密的数据管理以及区间性叶结点存储等算法,在GPU中高效、高质量地建立动态场景的KD—Tree,同时高质量的KD—Tree也有效地加速了场景的遍历速度.该算法以广度优先和大规模并行模式建立KD—Tree,更具通用性,既可以运行于NVIDIAGPU(CUDAGPU),也可以运行于AMDOPU.实验结果表明,文中算法可以在NVIDIAGPU和AMDGPU上对中等规模的动态场景实现实时光线跟踪绘制.
Due to acceleration algorithms of ray-tracing only designed for specified GPU or multi-core CPU, it is challenge to design a cross platform ray-tracing algorithm for real-time applications. This paper presents a cross-platform algorithm of ray-tracing dynamic scenes based on OpenCL. By exploiting parallel processing ability of general purpose GPU, three components of ray-tracing, i. e. , KD-Tree construction, scene traversal and shading, are performed on GPU, which are scheduled by CPU. Thus GPU computing ability is exploited thoroughly and data transmission overhead is reduced efficiently. By designing algorithms of parallel partitions and SAH, proposing strategies of compact data management and offset mark based leaf node storage, a high quality KD-Tree for dynamic scene is constructed on GPU in real-time, which will effectively facilitates scene traversal. The tree construction algorithm is breadth-first and suitable for large scale parallel implementation on both NVIDIA GPU and AMD GPU. Experimental results show that the proposed algorithm is capable of ray-tracing a middle scale dynamic scene in real-time on both NVIDIA GPU and AMD GPU.