Check GPU OpenGL Limits

泪湿孤枕 提交于 2019-12-07 10:03:44

问题


I was wondering if there is an easy way to query (programatically) the GPU OpenGL Limits for the following features:
- maximum 2D texture size
- maximum 3D texture size
- maximum number of vertex shader attributes
- maximum number of varying floats
- number of texture image units (in vertex shader, and in fragment shader)
- maximum number of draw buffers

I need to know these numbers in advance before writing my GPU Research Project.


回答1:


glGet() is your friend, with:

  • GL_MAX_3D_TEXTURE_SIZE
  • GL_MAX_TEXTURE_SIZE
  • GL_MAX_VERTEX_ATTRIBS
  • GL_MAX_VARYING_FLOATS
  • GL_MAX_TEXTURE_UNITS
  • GL_MAX_DRAW_BUFFERS

e.g.:

GLint result;
glGetIntegerv(GL_MAX_VARYING_FLOATS, &result);

Not quite sure what your project is setting out to achieve, but you might be interested in OpenCL if it's general purpose computing and you weren't already aware of it. In particular Cl/GL interop if there is a graphics element too and your hardware supports it.

As Damon pointed out in the comments in practice it may be more complex than this for texture sizes. The problems arise because rendering may fallback from hardware to software for some sizes of textures, and also because the size of a texture varies depending upon the pixel format used. To work around this it is possible to use GL_PROXY_TEXTURE_* with glTexImage*.




回答2:


As a complement to what was said by "awoodland" and if you still do not know ... i think you should take a look at GLEW...

GLEW provides efficient run-time mechanisms for determining which OpenGL extensions are supported on the target platform.

http://glew.sourceforge.net/



来源:https://stackoverflow.com/questions/5003813/check-gpu-opengl-limits

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!