4

据我了解,GPU 供应商定义了操作系统开发人员用来与其特定驱动程序通信的标准接口。所以 DirectX 和 OpenGL 只是该接口的包装器。当操作系统开发人员决定创建新版本的图形 API 时,GPU 供应商会扩展他们的接口(新的例程更快,而旧的例程则因兼容性问题而留下),操作系统开发人员使用这个新的接口部分。
那么,当说 GPU 厂商对 DirectX 的支持优于对 OpenGL 的支持时,是否仅仅意味着 GPU 厂商主要考虑了微软未来开发 DirectX API 结构的计划,并根据自己的需要调整该接口的未来开发?还是在此之前有一些技术原因?

4

2 回答 2

8

据我了解,GPU 供应商定义了操作系统开发人员用来与其特定驱动程序通信的标准接口。所以 DirectX 和 OpenGL 只是该接口的包装器。

不,不是。DirectX 和 OpenGL 只是定义 API的规范。但是规范只不过是一个文档,而不是软件。OpenGL API 规范由Khronos控制,DirectX API 规范由 Microsoft 控制。然后每个操作系统定义一个所谓的 ABI(应用程序二进制接口),它指定操作系统支持哪些系统级 API(OpenGL 和 DirectX 是系统级 API)以及实际实现在操作系统上运行时必须遵守的规则问题。

实际的 OpenGL 或 Direct3D 实现发生在硬件的驱动程序中(实际上硬件本身也是实现的一部分)。

当操作系统开发人员决定创建新版本的图形 API 时,GPU 供应商会扩展他们的接口

事实上,情况正好相反:大多数图形 API 规范都是由图形硬件供应商制定的。毕竟他们离橡胶撞路的地方很近。对于 Khronos,GPU 制造商是 Khronos 控制组的一部分。在 DirectX 的情况下,硬件制造商向 Microsoft 提交草稿并审查 Microsoft 所做的更改和建议。但最终,每个新的 API 版本都反映了下一代硬件开发中的能力的共同点。

那么,当说 GPU 厂商对 DirectX 的支持优于对 OpenGL 的支持时,是否仅仅意味着 GPU 厂商主要考虑了微软未来开发 DirectX API 结构的计划,并根据自己的需要调整该接口的未来开发?

不,这意味着每个 GPU 供应商都实现了自己的 OpenGL 版本和 Direct3D 后端,这就是所有魔法发生的地方。然而,OpenGL 非常强调向后兼容性和易于过渡到新功能。Direct3D 开发 OTOH 可以快速切断与早期版本的联系。这也意味着完整的兼容性配置文件 OpenGL 实现是相当复杂的野兽。这也是为什么最近版本的 OpenGL 核心配置文件确实(过期)减少了对遗留功能的支持的原因;这种 API 复杂性的降低对于开发人员来说也是一件相当解放的事情。如果您纯粹为核心配置文件进行开发,它会简化很多事情;例如,您在编写插件时不再需要担心过多的内部状态。

另一个因素是,对于 Direct3D,只有一个着色器编译器,它不是驱动程序基础结构/实现本身的一部分,而是在程序构建时运行。然而,OpenGL 实现必须实现自己的 GLSL 着色器编译器,这使事情变得复杂。恕我直言,缺乏统一的 AST 或直接着色器代码是 OpenGL 的主要缺点之一。

于 2013-10-27T22:15:53.270 回答
4

There is not a 1:1 correspondence between the graphics hardware abstraction and graphics API like OpenGL and Direct3D. WDDM, which is Windows Vista's driver model defines things like common scheduling, memory management, etc. so that DirectX and OpenGL applications work interoperably, but very little of the design of DirectX, OpenGL or GPUs in general has to do with this. Think of it like the kernel, nobody creates a CPU specifically to run it, and you do not have to re-compile the kernel everytime a new iteration of a processor architecture comes out that adds a new subset of instructions.

Application developers and IHVs (GPU vendors, as you call them) are the ones who primarily deal with changes to GPU architecture. It may appear that the operating system has more to do with the equation than it actually does because Microsoft (more so) and Apple--who both maintain their own proprietary operating systems--are influential in the design of DirectX and OpenGL. These days OpenGL closely follows the development of commodity desktop GPU hardware, but this was not always the case - it contains baggage from the days of custom SGI workstations and lots of things in compatibility profiles have not been hardware native on desktop GPUs in decades. DirectX, on the other hand, has always followed desktop hardware. It used to be if you wanted an indication of where desktop GPUs were headed, D3D was a good marker.

OpenGL is arguably more complicated than DirectX because until recently it never let go of anything, whereas DirectX radically redefined the API and stripped legacy support with every iteration. Both APIs have settled down in recent years, but D3D still maintains a bit of an edge considering it only has to be implemented on a single platform and Microsoft writes the one and only shader compiler. If anything, the shader compiler and minimal feature set (void of legacy baggage) in D3D is probably why you get the impression that vendors support it better.

With the emergence of AMD Mantle, the desktop picture might change again (think back to the days of 3Dfx and Glide)... it certainly goes to show that OS developers have very little to do with graphics API design. NV and AMD both have proprietary APIs on the PS3, GameCube/Wii/WiiU, and PS4 that they have to implement in addition to D3D and OpenGL on the desktop, so the overall picture is much broader than you think.

于 2013-10-27T21:31:30.943 回答