Advertisement

When are renderables blitted to the render target?

Started by November 03, 2017 05:03 PM
5 comments, last by Promit 7 years, 3 months ago

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?

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)?

-potential energy is easily made kinetic-

Advertisement

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.

🧙

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?

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)

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.

SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

This topic is closed to new replies.

Advertisement