Jump to content
  • Advertisement
Sign in to follow this  
noodleBowl

DX11 When are renderables blitted to the render target?

This topic is 371 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

So I have potentially a fairly simple question

When rendering various things, whether they are 2D or 3D, when do they get placed or blitted onto the set render target?

Is it at the moment when you call Present or is it at the moment of calling a Draw call?

Share this post


Link to post
Share on other sites
Advertisement

Neither, its when the GPU gets around to the draw call.  The CPU buffers commands for the GPU to execute but it can take a variable amount of time for the GPU to finish a command.  For example when you submit the second draw call the GPU might still be working on the first draw call so the second draw call gets queued for execution.  Also blitted isn't the proper term, the proper term would likely be rendered.  Lastly do you mean the render target or the front buffer (the thing that is actually displayed on the screen)?

Edited by Infinisearch

Share this post


Link to post
Share on other sites

Present is only relevant for the back buffer of the swap chain and performs the swapping of the back and front buffer.

You basically perform your rendering work (i.e. draw calls) on other RTVs. When you are done, you perform a final pass copying your image to the back buffer.

Edited by matt77hias

Share this post


Link to post
Share on other sites
1 hour ago, Infinisearch said:

Also blitted isn't the proper term, the proper term would likely be rendered.  Lastly do you mean the render target or the front buffer (the thing that is actually displayed on the screen)?

Not the front buffer, but the actual render target. The thing that is set using OMSetRenderTarget

So now my question is about renderables, depth buffers, and depth in general. I hope what I'm trying to explain makes sense, so feel free to ask any questions.

Lets say I have X different models, where each model has a 2D label above it. The model and the label should be grouped together. So something like:

models.png.47623a788f61036011fc803aa8b2dc54.png

And I want to render a ton of these models all at different depths and positions. So I get something that looks roughly like this:

modelsDepth.png.6e12356ca180d044818478eadbec0087.png

Where the model/label that is closer to the viewer covers the things behind it


Now my question is if I'm drawing all these models and the 2D labels separately, as in all the draw calls for the models would be executed first, then all the draw calls for the labels would be executed. how does depth come into play?

I know that each model and label has its own depth (z value) and I believe the depth buffer will automatically handle some of this to an extent, but if they are all drawn separate do I lose the desired effect of covering models/labels further away from the viewer with the ones that are closer?

I guess what I'm really asking is how do you mingle 2D and 3D? Would going from one depth to another be considered a state change?

Edited by noodleBowl

Share this post


Link to post
Share on other sites

Basically when you draw, you'll update the depth buffer. render your 2d stuff first for example, you can have it update your depth buffer to be very close to the camera. then when you render the 3d stuff, anywhere that a pixel is further away in the depth buffer than what is already written to the depth buffer will not get rendered (unless your blending, then it uses the blending algorithm)

Share this post


Link to post
Share on other sites
On 11/3/2017 at 2:08 PM, noodleBowl said:

I guess what I'm really asking is how do you mingle 2D and 3D? Would going from one depth to another be considered a state change?

You have to understand first and foremost that GPUs haven't had any concept of 2D for quite a few years now. Your "2D" pieces are just 3D pieces that aren't very interesting geometrically. They go through the same exact pipeline in the same exact way. As long as there are valid depth values and your depth states are set up in the usual way, things get ordered in space as you'd expect.

If you disable the depth buffer, then things will strictly follow draw order both across and within draw calls.

On 11/3/2017 at 2:08 PM, noodleBowl said:

I know that each model and label has its own depth (z value) and I believe the depth buffer will automatically handle some of this to an extent, but if they are all drawn separate do I lose the desired effect of covering models/labels further away from the viewer with the ones that are closer?

There's no "to an extent". The depth buffer will solve this with pixel perfect results every time, as long as alpha blending isn't involved. Draw order, number of draw calls, doesn't matter.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!