Jump to content
  • Advertisement
Sign in to follow this  
soloman

The swapchain->GetBuffer() function 's problem.?d3d11?

This topic is 2059 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Here are the func's example:

ID3D11Texture2D* pBackBuffer = NULL;

p_swapchain ->GetBuffer( 0, __uuidof( ID3D11Texture2D ), ( LPVOID* )&pBackBuffer );

[My question is] :

1.what the func did to the pBackBuffer and the p_swapchain?

2.if i set BufferCount(in the swapchain desc) to 2 or more,should i create the same number of ID3D11Texture2D to GetBuffer?

3.I confused that if DXGI_SWAP_EFFECT is discard,what the reason i just need to perform this func in one time?

4.Why use the uuid here,why not just specify the type?

[I MAKE some guesses] :

1.The func use the information in swapchain_desc to give content to the pBackBuffer(apply memory for it?Just like created a resource?)

2.yes,i need to do that.

3.Every time the swapchain discard the backbuffer,it will call any func to creat new backbuff and bind it to the pipeline(looks impossible).

4.I have no ideal totally.

 

/*Am i right? BTW,anybody can give some deep information or usage about this func ?*/

Edited by soloman

Share this post


Link to post
Share on other sites
Advertisement
1. The function did not do anything to p_swapchain. The function is simply retrieving the buffer from the swap chain. You gave the function a pointer to your local pBackBuffer pointer, so the function can fill it with relevant information.
2. If you set BufferCount to 2, you do not need to generate more calls to GetBuffer. The back buffer is always stored at position 0 and this is the buffer you should be rendering to.
3. Setting the setting to DXGI_SWAP_EFFECT_DISCARD just means that the contents of the back buffer are discarded/erased when the buffers are flipped (i.e. you call Present).
4. You cannot really specify a certain type (i.e. int, char) in C++. Having Direct3D depend on RTTI (runtime type information) can also be a huge hassle so we work around that problem with universally unique identifiers (UUIDs). Each UUID is unique for each interface so the function can just compare interfaces to find out exactly what you are requesting.

Share this post


Link to post
Share on other sites

1. The function did not do anything to p_swapchain. The function is simply retrieving the buffer from the swap chain. You gave the function a pointer to your local pBackBuffer pointer, so the function can fill it with relevant information.
2. If you set BufferCount to 2, you do not need to generate more calls to GetBuffer. The back buffer is always stored at position 0 and this is the buffer you should be rendering to.
3. Setting the setting to DXGI_SWAP_EFFECT_DISCARD just means that the contents of the back buffer are discarded/erased when the buffers are flipped (i.e. you call Present).
4. You cannot really specify a certain type (i.e. int, char) in C++. Having Direct3D depend on RTTI (runtime type information) can also be a huge hassle so we work around that problem with universally unique identifiers (UUIDs). Each UUID is unique for each interface so the function can just compare interfaces to find out exactly what you are requesting.

tks for your time,and i want to know what the diff between discarded the back buff and not discarded it?

Share this post


Link to post
Share on other sites

tks for your time,and i want to know what the diff between discarded the back buff and not discarded it?


If it's not discarded, the contents of the image you rendered stay in it after you Present. This may be necessary in some uncommon scenarios or effects. With the discard flag, the contents _might_ be thrown away such that if you try to read from the back buffer after calling Present you get something other than what you put it in. The flag simply tells the GPU and drivers that they are allowed to do anything they want with the contents after flipping the buffers and you must assume that the backbuffer contains random data after presenting.

Share this post


Link to post
Share on other sites

 

tks for your time,and i want to know what the diff between discarded the back buff and not discarded it?


If it's not discarded, the contents of the image you rendered stay in it after you Present. This may be necessary in some uncommon scenarios or effects. With the discard flag, the contents _might_ be thrown away such that if you try to read from the back buffer after calling Present you get something other than what you put it in. The flag simply tells the GPU and drivers that they are allowed to do anything they want with the contents after flipping the buffers and you must assume that the backbuffer contains random data after presenting.

 

Great answer,solved the puzzle in my head.Just two relevant questions:

1.When i turn the full-screen mode on,is the flag changed to DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL from DXGI_SWAP_EFFECT_DISCARD?

2.Are back buffers in the swapchain  adjecent?(just like an array)So when i called the present(),the swapchain just change the array index?

Edited by soloman

Share this post


Link to post
Share on other sites

In general,this is my thought of how swapchain working:(WTF,how can updata my local picture....blink.png )

Share this post


Link to post
Share on other sites

2.Are back buffers in the swapchain adjecent?(just like an array)So when i called the present(),the swapchain just change the array index?


They do not necessarily have to be adjacent I believe. Present basically flips the buffers by swapping the pointers to the array containing pixel data of the back and display buffer or just copies the contents of the back buffer to the display buffer. It's one of these, but I'm not quite sure which.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!