本文介绍了带有Vertex/Pixel着色器的通用计算(Open GL/DirectX)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对计算着色器有疑问. DX 9中是否提供计算着色器?如果GPU上没有计算着色器片段,是否仍可以将计算着色器与DX9驱动程序一起使用? (据IMG所说,SGX 545没有它,但是SGX 6X一代将拥有它).我想知道我是否可以使用DirectX9或OpenGL驱动程序在SGX GPU上进行一些简单的通用编程.

I have a question regarding compute shaders. are compute shaders available in DX 9? would it be still possible to use a compute shader with a DX9 driver if there is no compute shader fragment on the GPU? ( SGX 545 does not have it, but SGX 6X generation is going to have it), as far as what IMG says. I would like to know If i can do some simple general purpose programming on SGXs GPUs with DirectX9 or OpenGL drivers.

此外,无论如何,我可以使用OpenGL顶点着色器进行GPGPU编程吗?这是我在想什么: 我将把矩阵/数据加载到顶点缓冲区中,并将它们绑定到程序上下文中.我将其他一些静态变量加载到统一变量中,并将实际的计算程序加载到顶点着色器中.到现在为止看起来是可行的(是吗?),但是顶点着色器的输出将经过栅格化处理,并将被馈送到片段着色器(根据openGL中的情况).无论如何,我可以阻止数据通过整个图形管线,还是可以在执行完顶点着色器后截取数据,并以某种方式读取执行所需的值和时间?

Also, is there anyway I can use OpenGL vertex shaders for GPGPU programming? Here is what I am thinking: I will load my Matrices/ data into the vertex buffer, and bind them to the program context. I will load some other static variables into the uniform variables, and my actual compute program into vertex shader. It looks feisible till this point ( does it? ) but the output from the vertex shader will go through rasterization and will be fed to fragment shader ( according to how things go in openGL). Is there anyway I can prevent the data to be going through whole of the graphics pipleline, or can I intercept after vertex shader is done with executing, and somehow read the values and time taken for execution?

推荐答案

从顶点着色器中取出的内容通常在光栅化阶段进行插值.在旧版本的openGL中,您可以指定是否应对特定变量进行这种插值.我不知道您是否仍然可以这样做...是的,您仍然可以(提示给datenwolf)...但是,我认为更好的方法是使用片段着色器.使用一个简单的顶点着色器渲染一个完整的帧,渲染两个覆盖整个帧的三角形(一个四边形)(对于任何后期处理效果),然后在片段着色器中进行计算.将要用作数据的数据放入纹理中,然后使用帧缓冲对象(FBO)将结果渲染为其他纹理.

The stuff that goes out of the vertex shader is generally interpolated at the raserization stage. In old versions of openGL you could specify if such interpolation should or should not happen for specific variables. I don't know if you can still do that... Yes you still can (thx to datenwolf for the tip)... but a better approach, in my opinion, is to use fragment shaders. Render to a full frame, using a simple vertex shader that renders two triangles that cover the whole frame (a quad), as for any post process effect, and do your computation in the fragment shader. Put the data you want to use as input in textures, and render your results to other textures using frame buffer objects (FBO).

这篇关于带有Vertex/Pixel着色器的通用计算(Open GL/DirectX)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 23:42