Advertisement Jump to content
Sign in to follow this  
_rapt0r

Frostbite rendering architecture question.

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

Hello.
I was reading old Dice presentation from GDC 07 about Frostbite engine rendering architecture (slideshare). Most of it is pretty easy to understand, but I can't seem to comprehend how do they designed high-level states for render system (how do they pass dynamic number of state combinations to shading system and how to find solution for that combinations efficiently) (page 35).


* User queues up render blocks
Geometry & high--level state combinations
* Looks up solutions for the state combinations
Pipeline created these offline
* Blocks dispatched by backend to D3D/GCM Blocks dispatched by backend to D3D/GCM
Blocks are sorted (category & depth)
Backend sets platform--specific states and shaders
Determined by pipeline for that solution
Thin & dumb Thin & dumb
Draw


Can anyone help me with some pseudocode that implements? Many thanks.

Share this post


Link to post
Share on other sites
Advertisement
Yes, except I think you have your array backwards, Hodgman. The actual fallback case would be an instance that supports *everything* (ie every bit is on). And you want permutations with fewer bits flipped on first. Picking those first because that suggests that the shader is a closer match to the incoming draw call (and probably faster). Edit: And that would also alter the if condition of your loop, you should be checking if the result of the bitwise-and is the incoming value, not the one stored in the permutation.

Share this post


Link to post
Share on other sites
One thing I've never understood about this approach is why it doesnt have a drastic negative impact on performance. Taking Hodgemans example, the number of permutations that have to be compiled could be massive. I assume you do a prepass of all shader combinations that are actually required to solve this?

But even still, isnt the act of changing shaders a very expensive operation?

Whilst sorting to limit the number of changes is going to help, I can see it being problematic, as you're generally not just sorting in regard to shaders but also other things like, geometry, depth, transparency etc etc.

Share this post


Link to post
Share on other sites
@Hodgamn

-Is there are straightforward way to add more shader options and its possible combinations? Or do I have to "calculate" them one by one myself?

-Using a u64 its possible to have 64 shader options, that can be turned on/off, right? Edited by TiagoCosta

Share this post


Link to post
Share on other sites

One thing I've never understood about this approach is why it doesnt have a drastic negative impact on performance. Taking Hodgemans example, the number of permutations that have to be compiled could be massive.


Their system generates solutions offline. See page 34.

Share this post


Link to post
Share on other sites

One thing I've never understood about this approach is why it doesnt have a drastic negative impact on performance. Taking Hodgemans example, the number of permutations that have to be compiled could be massive. I assume you do a prepass of all shader combinations that are actually required to solve this?


Indeed, I would recommend using a distributed build system for anyone going down this route. Unless you like waiting hours for shaders to compile. :P


But even still, isnt the act of changing shaders a very expensive operation?


It has some associated CPU and GPU overhead, sure. But you'll also save on GPU performance by precompiling the variations of your shader, rather than relying on branching at runtime. I know they also attempt to use instancing whenever they can in BF3, which helps reduce overheads

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!