[英]GPGPU processing vs Graphic GPU
So I am developing a graphic API, I have already figured out how to create a window and draw pixels, all I'm missing right now is the GPU part.所以我正在开发一个图形 API,我已经想出了如何创建一个 window 和绘制像素,我现在缺少的是 GPU 部分。 Can I use Sycl or OpenCL to replace it?
我可以使用 Sycl 或 OpenCL 来替换它吗? So I want to use Sycl or OpenCL to access gpu and do the calculation part for my graphic.
所以我想使用 Sycl 或 OpenCL 访问 gpu 并为我的图形做计算部分。 Is it an efficient way to use GPU?
这是使用 GPU 的有效方法吗?
Yes you can use OpenCL to do graphics rendering.是的,您可以使用 OpenCL 进行图形渲染。 It is lightning fast when done right - for special applications faster than anything else - but you will have to implement everything from scratch: camera transformation from 3D to 2D screen coordinates, Bresenham algorithm for line/triangle rasterization, and z-buffer.
如果做得好,它会快如闪电——对于特殊应用程序来说比其他任何东西都快——但你必须从头开始实现一切:从 3D 到 2D 屏幕坐标的相机转换、用于线/三角形光栅化的 Bresenham 算法和 z 缓冲区。
Think of it that way: An image is just an integer array.可以这样想:图像就是一个 integer 数组。 You can use OpenCL to write color values into the array at corresponding pixel coordinates.
您可以使用 OpenCL 将颜色值写入数组中对应的像素坐标。 Then pass it to your graphics API as the framebuffer and draw it on the screen.
然后将其作为帧缓冲区传递给您的图形 API 并将其绘制在屏幕上。
The critical parts on the GPU are parallelization and memory access: GPU 的关键部分是并行化和 memory 访问:
The strategy for interactive graphics with OpenCL is as folows:使用 OpenCL 进行交互式图形的策略如下:
Disclaimer: I have written my own raster/raytracing graphics engine in OpenCL from scratch.免责声明:我从头开始用 OpenCL 编写了自己的光栅/光线追踪图形引擎。 See here for a real time demo.
请在此处查看实时演示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.