检查GPU OpenGL限制 [英] Check GPU OpenGL Limits
问题描述
我想知道是否有一种简便的方法(以编程方式)查询以下功能的GPU OpenGL限制:
-最大2D纹理尺寸
-最大3D纹理尺寸
-顶点着色器属性的最大数量
-浮动数量上限
-纹理图像单位的数量(在顶点着色器和片段着色器中)
-绘图缓冲区的最大数量
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
在编写我的GPU研究项目之前,我需要提前知道这些数字.
I need to know these numbers in advance before writing my GPU Research Project.
推荐答案
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
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
例如:
GLint result;
glGetIntegerv(GL_MAX_VARYING_FLOATS, &result);
不太确定您的项目打算实现什么,但是您可能对 OpenCL 感兴趣如果它是通用计算,而您还没有意识到这一点.如果有图形,特别是 Cl/GL互操作元素,您的硬件也支持它.
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.
正如Damon在评论中指出的那样,对于纹理大小,它可能比这更复杂.出现问题的原因是,对于某些大小的纹理,渲染可能会从硬件回退到软件,并且还因为纹理的大小根据所使用的像素格式而变化.要解决此问题,可以将 GL_PROXY_TEXTURE_ *与glTexImage * .
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*.
这篇关于检查GPU OpenGL限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!