为什么 Direct3D 只能在 Windows 上运行?
什么是 Direct3D?它是一个API,不是吗?是Windows实现的还是显卡实现的?
如果显卡实现了 Direct3D API,为什么其他操作系统不能使用该显卡的 Direct3D 资源?
如果Direct3D是由Windows实现的,它必须使用显卡资源,例如OpenGL或OpenCL。如果 Direct3D 调用不是直接到显卡,则会由于中间调用而变慢。
请帮助我理解 Direct3D 是什么。
What is the Direct3D? It is an API, is not it? Is it implemented by Windows or by graphics cards?
If the graphics cards implement the Direct3D API, why can not other operating systems use Direct3D resources from the graphics card?
If Direct3D is implemented by Windows, it has to use graphics card resources, such as OpenGL or OpenCL. If Direct3D calls are not directly to the graphics card, it would be slower due to intermediate calls.
Please, help me to understand what the Direct3D is.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
是的,Direct3D 是一个 API。它(大部分)由 Windows 本身实现。然而,Windows会将相当一部分实际工作分流给显卡的驱动程序,并最终分流给gfx卡本身,因此也可以说gfx卡“实现”了D3D。
他们可以,而且确实这么做了,但只有相对较小(但通常是关键部分)的 D3D 功能是由卡的硬件直接实现的,因此需要在软件方面做更多的工作来实现 D3D。
不,那是一个误会。 OpenGL 和 OpenCL 也是 API,并且仅部分由 gfx 硬件实现(就像 D3D 一样)。 gfx 硬件通常有一个(专有的)“本机”API,这是 gfx 驱动程序(适用于 D3D 和 OpenGL)使用的。
不一定有任何“中间调用” - D3D 驱动程序使用卡本机 API,如上所述。
Yes, Direct3D is an API. It is implemented (mostly) by Windows itself. However, Windows will offload a considerable part of the actual work to the drivers of the graphics card and ultimately to the gfx card itself, so one can also say that a gfx card "implements" D3D.
They can, and they do, but only a relatively small (but often critical part) of D3D functionality is implemented directly by the card's hardware, so a lot more work in software is required to implement D3D.
No, that's a misunderstanding. OpenGL and OpenCL are also APIs, and only partially implemented by the gfx hardware (just like D3D). The gfx hardware usually has a (proprietary) "native" API, which is what the gfx drivers (both for D3D and OpenGL) use.
There are not necessarily any "intermediate calls" - the D3D driver uses the cards native API, as explained above.
Direct 3D 是 Microsoft 创建的图形 API。其功能与opengl类似。 OpenGL 是作为开放标准创建的竞争性 3D 图形 API。 D3D 不需要 OpenGL 即可运行。
卡制造商决定他们想要实施哪些 API;大多数总是包括 DirectX(其中包括 Direct3D)和可能的 OpenGL。
存在间接性,因为它不直接到达卡,卡 D3D 依次调用驱动程序,但这通常是微不足道的。
Direct 3D is a graphics API created by Microsoft. Its similar in function to opengl. OpenGL is a competing 3D graphics API created as a open standard. D3D doesn't need OpenGL to function.
Card manufactorers decide which APIs they want to implement; most always include DirectX (which includes Direct3D) and possibly OpenGL.
There is indirection as it doesn't go directly to the card, the cards D3D in turn calls the drivers, but this typicially is insignificant.
Direct3D是微软开发的一个API,旨在帮助开发人员渲染3D图形。 OpenGL 和 Direct3D 是两个独立的 API,但它们都必须使用由视频卡制造公司开发的驱动程序与视频卡连接。两个 API(Direct3D 和 OpenGL)都必须通过驱动程序才能访问视频卡,并且它们的速度取决于它们的设计及其在视频卡驱动程序中的实现。
OpenCL 有所不同——它旨在帮助开发人员编写在 GPU 上执行通用计算(不仅仅是图形)的程序。 OpenCL 与 CUDA 相当,但后者仅在 NVIDIA 卡上支持。使用 CUDA 代替 OpenCL 可能有一些优势,具体取决于您的目标系统,因为 NVIDIA 可以在新功能被 OpenCL API 接受之前将其提供给 CUDA API。然而,即使是 OpenCL 和 CUDA 也必须与驱动程序接口才能在 GPU 上完成任何操作。
如您所知,Direct3D 仅适用于 Microsoft 和 Wine(大部分),但其作为 API 的结构与 OpenGL 的结构有很大不同。 Direct3D 使用结构并在其 API 中包含更多 OOP 元素,而 OpenGL 充当状态机,缺乏任何结构或 OOP 功能。 Direct3D 在其 API 中声称正式支持的功能方面通常比 OpenGL 进步得快一些,因为它的设计目的并不是为了与各种设备实现最大程度的兼容性;另一方面,OpenGL 在采用新功能时通常表现出更大的惰性,因为向其 API 添加新功能存在固有的困难(Khronos Group 深受 CAD 行业以及许多其他行业的影响,因此它必须满足广泛的需求)。 Khronos Group 最终在 OpenGL 中采用异步 API 调用所花费的时间证明了这一事实,并导致许多人对 OpenGL 失去了信心。
然而,OpenGL 是跨平台的,得到了 Apple 的认可,并且可以在所有实现它的操作系统上运行。您可以轻松地将它与许多流行的窗口工具包(Qt、SDL、FreeGLUT、JogAmp、gtk 等)一起使用,并且确信如果编写正确,您的应用程序将在其他操作系统上编译。与 Direct3D 不同,OpenGL API 是一个开源行业标准。
就性能而言,哪个更快仍然存在争议:根据您构建程序或批量调用的方式,这可能会改变。然而,性能实际上不应该成为您使用哪个 API 的考虑因素,除非您已经测试了您的应用程序并且有证据表明 API 的选择是造成瓶颈的原因。
Direct3D is an API developed by Microsoft designed to help developers render 3D graphics. OpenGL and Direct3D are two separate APIs, but they must both interface to the video card using the drivers developed by the companies who manufacture the video cards. Both APIs (Direct3D and OpenGL) must both go through the driver in order to access the video card, and their speeds are dependent upon their design and their implementation in the video card drivers.
OpenCL is something different -- it's designed to help developers write programs which perform general-purpose computing on the GPU (not just for graphics). OpenCL is comparable to CUDA, but the latter in only supported on NVIDIA cards. Using CUDA instead of OpenCL may have some advantages, depending on your target system, since NVIDIA can make new features available to the CUDA API before they are accepted into the OpenCL API. However, even OpenCL and CUDA must interface to the driver in order to get anything done on the GPU.
As you already know, Direct3D only works on Microsoft and on Wine (for the most part), but its structure as an API is vastly different from that of OpenGL. Direct3D makes use of structures and includes more OOP elements in its API, while OpenGL acts as a state machine, lacking any structures or OOP features. Direct3D can often progress a little faster than OpenGL in terms of the features which it claims to officially support in its API because it is not designed for maximum compatibility with a wide range of devices; on the other hand, OpenGL has typically exhibited more inertia when it has come to adopting new features because of the inherent difficulty in adding new features to its API (the Khronos Group is influenced heavily by the CAD industry as well as many others, so it must cater to a wide range of needs). The time it took for the Khronos Group to finally adopt asynchronous API calls in the OpenGL is testament to this fact, and caused many people to lose faith in OpenGL.
However, OpenGL is cross-platform, endorsed by Apple, and it works on all operating systems on which it is implemented. You can easily use it with many popular window toolkits (Qt, SDL, FreeGLUT, JogAmp, gtk, etc.) and have confidence that your application will compile on other operating systems if you wrote it properly. The OpenGL API, unlike Direct3D, is an open-source industry standard.
As far as performance goes, it's still debatable as to which one is faster: depending on how you structure your program or batch your calls, this could change. However, performance should not really be a consideration for which API you use unless you have tested your application and have evidence that the choice of API is the cause of your bottleneck.
来自 维基百科:
From Wikipedia: