Understanding ID3D11Device and ID3D11DeviceContext

岁酱吖の 提交于 2019-12-11 02:36:39

问题


I have some problems understanding the difference between ID3D11Device and ID3D11DeviceContext.

  • Is the ID3D11Device a representative of your GPU and ID3D11DeviceContext used for functions, to control the device?

  • Why do you need 2 objects?

  • Which function do you use with the device and which with the device object?

  • Which object sends the final image to the backbuffer?

  • The back buffer is in the ID3D11RenderTargetView object, isn't it?

  • Which objects are connected to the swap chain, and why?


回答1:


The ID3D11Device is used for creating resources, for example, the many shaders in the pipeline.

The ID3D11DeviceContext is used for binding those resources to the pipeline, for example, the many shaders.

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

But why you need then two objects?

So that you don't have 1 "God" object that does everything (that's a guess :)).

Which object send the final Image to the backbuffer.

The ID3D11DeviceContext does. I guess with "Image" you mean a texture, if yes, the image doesn't get "sent", it gets copied to the back buffer, using the method Draw.

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

Yes, in form of a ID3D11Resource, which would be the back buffer "texture" (The Draw calls draw into that "texture").

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

That's a bit broad. The swap chain stores the back buffer textures, and many other informations such as how to flip the buffers, which window is associated with it, ... This gets used when you Draw something.

So, I guess the ID3D11Resources are "conntected" with the swap chain, as they store the back buffer textures used by it.




回答2:


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


来源:https://stackoverflow.com/questions/37509559/understanding-id3d11device-and-id3d11devicecontext

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!