I have an OpenGL program that uses shaders (OpenGL version 3.3, GLSL version 1.5). I have heard that the shaders actually run on the CPU unless you specifically tell it to run on the GPU. (Of course the whole reason I am using shaders is to speed up rendering by doing the calculations in the开发者_开发知识库 GPU instead of the CPU, so this is not the behavior I want.) Is this true? If so, how do you get the shader to run on the GPU?
I'm not sure where you heard that, but assuming you have halfway decent drivers from the graphics vendor, your shaders will run on the GPU without your doing anything but loading and using them.
I'm pretty sure that driver always tries to run every shader on GPU not on CPU. But not all modern video cards support full feature set of shader operations. For example OpenGL 4.0 extension GL_ARB_gpu_shader_fp64 as i know can be available in partial support. So driver must emulate some operations within software mode on CPU. As about extensions, you can check your card by calling glGetString with GL_EXTENSIONS parameter.
精彩评论