Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check GPU OpenGL Limits

Tags:

gpu

opengl

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.

like image 917
all_by_grace Avatar asked Dec 16 '22 17:12

all_by_grace


2 Answers

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*.

like image 164
Flexo Avatar answered Dec 24 '22 19:12

Flexo


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/

like image 38
Daniel Santos Avatar answered Dec 24 '22 19:12

Daniel Santos