OpenGL 4.0 ++核心配置文件中固定功能管道的属性位置是什么? [英] What are the Attribute locations for fixed function pipeline in OpenGL 4.0++ core profile?

查看:87
本文介绍了OpenGL 4.0 ++核心配置文件中固定功能管道的属性位置是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道 nVidia OpenGL驱动程序在固定管线(未连接着色器)中的属性位置:

glVertex = 0
glColor = 3
glNormal = ?
glTexCoord = ?
glMultiTexCoord 0..7 = ?
glSecondaryColor = ?
glFog = ?

根据经验,我找到了顶点"和主色"位置,但是仍然很高兴了解它们.

如果您想知道原因,则出于兼容性原因,甚至出于 GLSL 调试(只是为了在着色器尚不可用时查看是否将正确的数据传递到正确的位置)等等.

解决方案

在NVIDIA驱动程序之外,这不起作用(可靠).兼容的驱动程序将仅别名glVertexPointer (...)到属性插槽 0 . NV用他们无穷的智慧在多年前设计了一个标准的非标准方案,在该方案中,他们将所有固定功能指针都别名到了某些属性位置,但是我不知道新的NV驱动程序是否支持此方法(老实说,我从来都不关心尝试,这是一个糟糕的做法).您也许仍然可以找到NV的别名映射文档,但是您无法利用他们的非标准行为使任何人受益.

虽然其他驱动程序也可以将固定功能的指针别名为通用顶点属性位置,但是不存在有关其映射的文档.与NV不同,我不相信映射不会在驱动程序版本,硬件或平台之间更改.实际上,即使使用NV驱动程序,您也不应利用此功能-它是为了促进传统支持,而不是作为新软件的功能使用.

最重要的是,改用通用顶点属性或使用兼容性配置文件和GLSL版本,该版本仍支持为获取固定功能顶点数据而专门设计的预声明变量(例如,gl_Colorgl_MultiTexCoord0...7,...).但是请不要同时使用两种描述方式进行混搭.

还要花一些时间查看 glGetPointerv (...) .如果要在GLSL之外获取有关固定功能指针的信息,这是正确的方法.不要依赖顶点属性别名,因为属性位置的概念从根本上讲是可编程的管道功能.它甚至在2.0之前的未扩展OpenGL中都不存在(它是随 ARB Vertex引入的.程序汇编语言,并在GLSL中提升为核心.)


更新:

尽管我仍然强烈建议您不要使用此信息,但我能够准确找到您想要的内容:

有关NVIDIA OpenGL阴影语言支持的发行说明- 2006年11月9日 -第7-8页

顶点属性别名

GLSL试图消除顶点属性的混叠,但这是NVIDIA硬件方法不可或缺的,对于保持与NVIDIA客户所依赖的现有OpenGL应用程序的兼容性是必不可少的.

因此,NVIDIA的GLSL实现不允许内置的顶点属性与通过 glBindAttribLocation 分配给特定顶点属性索引的通用顶点属性发生冲突.例如,您不应使用 gl_Normal (内置顶点属性),还应使用 glBindAttribLocation 将名为"whatever"的通用顶点属性绑定到顶点属性索引 2 ,因为 gl_Normal 别名为索引 2 .

  

如果您想知道, ARB Vertex程序扩展规范.我特别提到NV的唯一原因是因为他们选择重用GLSL中的别名,而来自其他供应商的兼容实现将仅接受GLSL中的第一个别名(glVertexPointer (...) 0 ).

I would like to know the attribute locations inside fixed pipeline (no shader attached) for nVidia OpenGL drivers:

glVertex = 0
glColor = 3
glNormal = ?
glTexCoord = ?
glMultiTexCoord 0..7 = ?
glSecondaryColor = ?
glFog = ?

Empirically I found the Vertex and primary Color locations but still will be nice to know them all.

If you want to know why, then for compatibility reasons and even for GLSL debugging (just to see if I pass the correct data to correct locations when shader not works yet) and so on ...

解决方案

Outside of NVIDIA drivers, this does not work (reliably). Compliant drivers will only alias glVertexPointer (...) to attribute slot 0. NV in their infinite wisdom devised a standard non-standard scheme many years ago where they aliased all of the fixed-function pointers to certain attribute locations, but I do not know if new NV drivers support this (I honestly have never cared enough to try, it is such a bad practice). You might still be able to find NV's documentation for their alias mappings, but you are not benefiting anyone by taking advantage of their non-standard behavior.

While other drivers may also alias the fixed-function pointers to generic vertex attribute locations, no documentation exists for their mappings. Unlike NV, I would not trust that the mapping would not change between driver versions, hardware or platform. In fact, even using NV drivers you should not take advantage of this - it was intended to promote legacy support and not as a feature used for new software.

The bottom line is, use generic vertex attributes instead or use a compatibility profile and a version of GLSL that still supports the pre-declared variables that are specifically designed for getting fixed-function vertex data (e.g. gl_Color, gl_Normal, gl_MultiTexCoord0...7, ...). But do not mix-and-match both the way you are describing.

Also take some time to review glGetPointerv (...). If you want to get information about the fixed-function pointers outside of GLSL, this is the proper way to do it. Do not rely on vertex attribute aliasing, because the concept of attribute locations is fundamentally a programmable pipeline feature. It did not even exist in unextended OpenGL prior to 2.0 (it was introduced with the ARB Vertex Program assembly language and promoted into core with GLSL).


Update:

While I still strongly advise against using this information, I was able to find exactly what you wanted:

Release Notes for NVIDIA OpenGL Shading Language Support - November 9, 2006 - pp. 7-8

Vertex Attribute Aliasing

GLSL attempts to eliminate aliasing of vertex attributes but this is integral to NVIDIA’s hardware approach and necessary for maintaining compatibility with existing OpenGL applications that NVIDIA customers rely on.

NVIDIA’s GLSL implementation therefore does not allow built-in vertex attributes to collide with a generic vertex attributes that is assigned to a particular vertex attribute index with glBindAttribLocation. For example, you should not use gl_Normal (a built-in vertex attribute) and also use glBindAttribLocation to bind a generic vertex attribute named "whatever" to vertex attribute index 2 because gl_Normal aliases to index 2.

  

In case you were wondering, this is also outlined in Table X.1 of the ARB Vertex Program extension specification. The only reason I mentioned NV specifically is because they chose to re-use the aliasing in GLSL whereas compliant implementations from other vendors will only honor the first alias (glVertexPointer (...) to 0) in GLSL.

这篇关于OpenGL 4.0 ++核心配置文件中固定功能管道的属性位置是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆