win8789
win8789

Reputation: 63

Understanding ID3D11Device and ID3D11DeviceContext

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

Upvotes: 3

Views: 3054

Answers (3)

Litherum
Litherum

Reputation: 23334

But why you need then two objects?

ID3D11Devices can create ID3D11DeviceContexts via ID3D11Device::CreateDeferredContext(). So there can be multiple ID3D11DeviceContexts per each ID3D11Device.

Upvotes: 0

Jakub Krzesłowski
Jakub Krzesłowski

Reputation: 51

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

Upvotes: 1

Rakete1111
Rakete1111

Reputation: 48918

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.

Upvotes: 7

Related Questions