Thursday, December 7, 2006

Checking for a D3D shader version

Direct3D's shader version (1.1, 1.4, 2.0, 3.0, 4.0) is a very useful way to keep track of what shaders can execute on what hardware. While OpenGL does not provide a direct way to acquire this number, it is still possible to determine a shader model based on certain OpenGL extensions.

If a card supports GL_ARB_vertex_program and/or GL_ARB_vertex_shader, it supports vertex shader 1.1.

If a card supports GL_NV_texture_shader and GL_NV_register_combiners, it supports pixel shader 1.1.

If a card supports GL_ATI_fragment_shader or GL_ATI_text_fragment_shader it supports pixel shader 1.4.

If a card supports GL_ARB_fragment_program and/or GL_ARB_fragment_shader it supports Shader Model 2.0.

If a card supports GL_NV_vertex_program3 or GL_ATI_shader_texture_lod it it supports Shader Model 3.0.

If a card supports GL_EXT_gpu_shader4 it is a Shader Model 4.0 card. (Geometry shaders are implemented in GL_EXT_geometry_shader4)

NOTE: In Mac OS 10.4.3 and later, all GPUs report support for GL_ARB_fragment_shader and GL_ARB_vertex_shader even if they do not support this extension in hardware. To determine if these extensions are hardware accelerated, call CGLGetParameter(kCGLCPGPUFragmentProcessing) and CGLGetParameter(kCGLCPGPUVertexProcessing), repsectively.


Mac OpenGL mailing list

No comments: