Typical rendering strategy for many and diverse complex objects in directx?

I am learning directx. It provides tremendous freedom in how to do something, but it seems that different strategies act differently, and he gives no indication as to how well use patterns can be used.

When using directx, is it typical to swap several new data several times for each rendering?

The most obvious and probably really ineffective way of using it would be this.

Stragety 1

On each individual render

  • Download everything for model 0 (including textures) and do it (IASetVertexBuffers, VSSetShader, PSSetShader, PSSetShaderResources, PSSetConstantBuffers, VSSetConstantBuffers, Draw)

  • Download everything for model 1 (including textures) and make it (IASetVertexBuffers, VSSetShader, PSSetShader, PSSetShaderResources, PSSetConstantBuffers, VSSetConstantBuffers, Draw)

  • etc...

I assume that you can make it more efficient if the biggest things to load are given by dedicated slots, for example. if the texture for model 0 is really complicated, don't reload it at every step, just load it into slot 1 and leave it there. Of course, since I'm not sure how many registers in each of the DX11 exist, this is difficult (can anyone point out the documentation for this?)

Stragety 2

Select multiple texture slots to load, and others to permanently store the most complex textures.

Only once

Load the most complex models, shaders, and textures into slots designed for eternal storage.

On each individual render

  • Download everything that does not exist for model 0 using the slots that you set aside for loading and rendering (IASetVertexBuffers, VSSetShader, PSSetShader, PSSetShaderResources, PSSetConstantBuffers, VSSetConstantBuffers, Draw)

  • Download everything that does not exist for model 1 using the slots that you set aside for loading and rendering (IASetVertexBuffers, VSSetShader, PSSetShader, PSSetShaderResources, PSSetConstantBuffers, VSSetConstantBuffers, Draw)

  • etc...

Strategy 3 I have no idea, but the above is probably all wrong, because I'm really new to this.

What are the standard strategies for efficient directx rendering (specifically DX11) to make it as efficient as possible?

+8
directx graphics rendering directx-11
source share
2 answers

DirectX manages resources for you and tries to store them in video memory until it can optimize performance, but can only do this to the limit of video memory on the card. Each state change also has overhead, even if the resource is still in video memory.

The general strategy for optimization is to minimize the number of state changes during rendering. This usually means drawing all polygons that use the same texture in the package, and all objects that use the same vertex buffers in the package. Therefore, you usually try to attract as many primitives as you can before changing the state to attract more primitives.

This often makes the rendering code more complex and difficult to maintain, so you need to do some profiling to determine what kind of optimization you want to do.

As a rule, you will get better performance due to more general algorithm changes that go beyond the scope of this question. Some examples would be to reduce the number of polygons for remote objects and occlusion requests. A popular true phrase is "the fastest polygons are those that you don’t draw." Here are some quick links:

http://msdn.microsoft.com/en-us/library/bb147263%28v=vs.85%29.aspx

http://www.gamasutra.com/view/feature/3243/optimizing_direct3d_applications_.php

http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter06.html

+2
source share

The other answers are the best answers to the question as such, but by far the most important thing I have found since the request was this discussion on gamedev.net , in which some major header games are profiled for state changes and cause challenges.

What happens is that games with big names are not too worried about it, i.e. It may take considerable time to write code that solves this problem, and the time taken to do it with it is probably not worth the time to get your application to end.

+1
source share

All Articles