SolarPortal wrote: ↑Sun Jun 07, 2020 2:22 pm
ok, another question: could you for instance, call start mapping and stop mapping more than once on the staging texture per frame. there was something similar in 2.1 but you had to regress the counter if edited more than once per frame e.g..
You can but you should aim to call start/stop as fewer as possible.
But once you've called upload(), then startMapRegion could stall. You can check this via uploadWillStall()
TextureGpuManager::getStagingTexture works by iterating through available (but not yet destroyed) StagingTextures calling uploadWillStall, and selects the one that returns false and is also the smallest one that can fulfill the request.
or would this cause some internal issue as i have noticed that when map region is called, the z is automatically increasing by 1 which i suspect is due to the mapped regions needing to be accessible in the background thread.
Actually that's
an implementation detail very specific to D3D11, it's so bizarre it needed its own section in the documentation.
it but understanding the depth, slices and z didnt quite click at first
Most of the time 'z/depth' and 'slicesIdx/numSlices' are the same thing, because it's a 3rd axis. In fact often they share the same variable ('DepthOrSlices').
However they bifurcate when it comes to handling mipmapping because z/depth shrinks with each mip level; while sliceIdx/numSlices doesn't.
That's it
Haven't quite got my head around msaa and explicit resolves yet though
Imagine an explicit resolve like this:
You want to render at 1920x1080 4x MSAA. You need two textures:
- The 4x MSAA texture, which when it comes to VRAM storage, it costs as much as 3840x2160 (because 1920x2 x 1080x2, that is 4 times the area, 4x MSAA).
- But you can't sample from this texture directly
- Your shader needs to specifically use a Texture2DMS, and it can only read the individual subpixels; which can be quite slow because it will consume as much performance and bandwidth as reading a regular texture at 3840x2160 resolution.
- A 1920x1080 regular texture you can sample from, and this is will be the resolve target
So you will render to the "1920x1080 4x MSAA" target; but once you're done render and want to read from it; you want to resolve it to the regular 1920x1080.
That's it.
With implicit resolving, this happens behind the scenes without you having to know about it. With explicit resolves you need to be aware of this and manually setup an RTV (RenderTargetView) in the compositor. The RTV tells Ogre:
- to what texture to render
- to which slice (e.g. +Y slice in a cubemap, the 8th slice in a 3D texture)
- to which mipmap (was previously impossible in Ogre 2.1)
- to what texture to resolve to (and which slice/mipmap; it doesn't have to match the slice/mipmap you render to)
Most of the time explicit resolves are there so you can access the MSAA content directly; which is useful for proper HDR+MSAA, handling SSAO, and a few other postprocessing effects.
This is mostly because depth buffers don't get automatically resolved (averaging depth makes no sense) but you still want to do
something. For example our SSAO sample "resolves" the depth buffer by just assuming there is 1 subsample. This is wrong/inaccurate, but good enough for SSAO and other effects. We could "unpack it" into a 3840x2160 texture, but that'd be overkill and could still be wrong depending on how it's used. Others use two depth buffers one with min() of all 4 subsamples, another with max() of all 4 subsamples. Each approach has a different trade off. These problems are very similar to the ones described in
mixed resolution particle rendering in GPU Gems 3
If you're interested in more, you can read
A quick overview of MSAA