了解 ID3D11Device 和 ID3D11DeviceContext

Understanding ID3D11Device and ID3D11DeviceContext

我在理解 ID3D11DeviceID3D11DeviceContext 之间的区别时遇到一些问题。

ID3D11Device 用于创建 资源,例如管道中的许多着色器。

ID3D11DeviceContext用于绑定那些资源到管道,例如,许多着色器。

device->CreatePixelShader(/*arguments*/);
context->PSSetShader(/*pass shader created with 'device'*/);

But why you need then two objects?

所以您没有 1 个 "God" 对象可以完成所有事情(这是一个猜测 :))。

Which object send the final Image to the backbuffer.

ID3D11DeviceContext 确实如此。我猜 "Image" 你的意思是纹理,如果是,图像不会得到 "sent",它被复制到后台缓冲区,使用方法 Draw.

The backbuffer is in the ID3D11RenderTargetView object, isn't it?

是的,以 ID3D11Resource 的形式,这将是后台缓冲区 "texture"(Draw 调用进入 "texture")。

And which objects are connect with the SwapChain and why exactly?

这有点宽泛。交换链存储后台缓冲区纹理,以及许多其他信息,例如如何翻转缓冲区,window 与之关联,...当您 Draw 某些东西时会用到它。

所以,我猜 ID3D11Resource 是 "conntected" 与交换链的,因为它们存储它使用的后台缓冲区纹理。

                  ID3D11Device              ID3D11DeviceContext
Purpose:            FACTORY                   STATE of pipeline
Multithreaded:      YES                       NO
Amount basic:       one                       one
Amount common:      one                       many
Amount rare:        many                      many