简体   繁体   English

检查GPU OpenGL限制

[英]Check GPU OpenGL Limits

I was wondering if there is an easy way to query (programatically) the GPU OpenGL Limits for the following features: 我想知道是否有一种简单的方法来查询(以编程方式)GPU OpenGL限制以获得以下功能:
- maximum 2D texture size - 最大2D纹理尺寸
- maximum 3D texture size - 最大3D纹理尺寸
- 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. 在编写GPU研究项目之前,我需要提前知道这些数字。

glGet() is your friend, with: glGet()是你的朋友,有:

  • 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

eg: 例如:

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. 不太确定你的项目要实现什么,但如果它是通用计算而你还没有意识到它,你可能会对OpenCL感兴趣。 In particular Cl/GL interop if there is a graphics element too and your hardware supports it. 特别是Cl / GL互操作,如果有图形元素,你的硬件也支持它。

As Damon pointed out in the comments in practice it may be more complex than this for texture sizes. 正如Damon在实践中的评论中指出的那样,纹理尺寸可能比这更复杂。 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* . 要解决此问题,可以将GL_PROXY_TEXTURE_ *与glTexImage *一起使用。

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... 作为“awoodland”所说的补充,如果你还不知道......我想你应该看看GLEW ...

GLEW provides efficient run-time mechanisms for determining which OpenGL extensions are supported on the target platform. GLEW提供了高效的运行时机制,用于确定目标平台上支持哪些OpenGL扩展。

http://glew.sourceforge.net/ http://glew.sourceforge.net/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM