Why Games Have Stutters | Shader Compilation

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
it's not a secret that modern games are abundant in optimization issues but there's a couple of such issues that you can see in a huge number of games today one of such issues is a rather long first startup the freshly released PC version of The Last of Us can take more than two hours to start this is longer than you're allowed to stay in a game in order to be eligible for a refund on Steam so yeah this is exactly why in this case they made an exception another question is why modern PC games keep stuttering when playing cutscenes or switching locations after all most of us have ssds modern processors and rather powerful graphics cards and these are not my assumptions this is the fresh steam statistics but why does it still happen then how can we combat this and finally are the developers to blame at all this is MK in this video we will talk about the scourge of modern games Shader compilation let's go [Music] and immediately we have two questions what is a Shader and what is compilation I will try not to complicate things we constantly hear the word Shader in the context of game development and in fact it's just a piece of code a program that runs on the compute units of your graphics card in modern Graphics apis such as DirectX 12 or Vulcan there are seven categories of shaders vertex geometry surface and domain shaders are used to form the boundaries of 3D objects to put it simply you've probably seen pictures online in which 3D objects are shown as a bunch of triangles or polygons that's what the first four Shader categories are responsible for once the 3D world has been built it needs to be colorized and made more realistic this is what pixel shaders are responsible for and these days we also have Ray Shader now these are needed for the correct calculations of lighting and shading transparency effects explosions fire water General a beautiful display of physics and finally compute shaders modern graphics cards can run many types of mathematical calculation and it is this type of shaders that Nvidia Cuda and opencl rely on and now these graphics cards are also used in training AI networks that draw pictures for us but back to the games Modern projects manipulate thousands of traders to render a beautiful picture on the screen some of these pieces of code are simple and easy to apply such as texturing that is placing a texture onto the object it belongs to this is one of the reasons why increasing the texture quality in the game settings doesn't really influence your FPS that much that is as long as you have enough vram but at the same time there are for example Ray shaders which are needed for the correct rendering of Lights and Shadows using Ray tracing and it's not for me to tell you how much the FPS drops with RTX on the 1490 in 4k with path tracing in the latest cyberpunk update renders 16 frames per second alright I hope now it is clear why shaders can negatively affect the calculation of frame time and thereby reduce the FPS but how is it related to starters and games or long first startup thing is that initially shaders are written in a high level programming language and before the graphics cards can use it the processor must compile the Shader in other words translate it into binary machine code understandable to the GPU this does not cause problems with dozens or more shaders but when there are a thousands of them or even tens of thousands and with each frame you need to load dozens and hundreds of new ones that's when you start noticing that something is not right here basically there are two possible solutions here the easiest option is to compile all the shaders beforehand at the first launch of the game what such an approach leads to became known with the release of the PC version of the last vest which takes hours to start even on a top-notch PC although I must say the ability of programmers to properly manage the Shader library and processor multi-core is very important here worst case scenario absolutely all shaders will have to be compiled at the startup even those that are not needed on your particular system and at the same time only one CPU core will be involved in in this process as tests show the developers at nightdog are not very good at this which caused an outburst of hatred from PC Gamers forced to wait for hours looking at the loading bars the second option is to compile shaders on the Go when they are needed in the course of your gameplay as a result this greatly reduces the loading time of the game only now you have to pay for it with an increased load on the processor and the drive which have to work not only with the current data but also think ahead given the overall High computational complexity of modern games this is guaranteed to cause starters at times when you need to quickly compile many shaders at once for example during transition to a new location in fact modern game engines usually combine both methods at the first launch the main volume of shaders is compiled in a reasonable time and later some extra changes that are needed are compiled during the cut scenes or loading screens however here not everything is smooth either especially when your game has a huge seamless World sooner or later the player will wander into a completely new location which will have to be loaded on the Fly and give you some stutters and here you might be asking a logical question why not compile the shaders in advance at the development stage and download a game devoid of this process the problem is that in order to improve performance shaders have to be compiled for each specific system graphics card and even the driver for it there are thousands of possible combinations here so in the case of PC pre-compile in shaders at the development stage is not an option on top of that an update of your video driver may and probably will cause your system to have to recompile again by the way this is why games usually load faster and run smoother on consoles even if we talk about the past gen consoles that come with hdds since the components and the operating system are closely interconnected on such gaming devices this allows developers to pre-compile the shaders and free the console Hardware from this process is there a way to solve the issue of Shader compilation on the PC globally yes really no modern games are getting bigger and more beautiful which increases both the number and the complexity of the shaders used and taking into account the trains for seamless worlds developers literally have their hands tied using the combined method sooner or later a situation will arise when you need to compile a lot of shaders at once and this will cause a guaranteed starter and you will be making scornful comments about the modern game devs who just don't know how to do their job properly anymore of course you can go back to the good old compilation of all shaders at the start this will remove any issues with them during the gameplay but as the reviews of The Last of Us show gamers are not ready to waste half an hour waiting for the game to launch especially considering that this will repeat after each update of the video driver therefore All That Remains for developers is to optimize the compilation process itself to better distribute it across multiple cores and to predict which shaders will be needed soon it is also a good practice to carefully study which shaders are needed for each specific object often game engines in order to calculate materials use a complete set from transparency to fabric effects that are not always needed for example they're not needed for a ground texture not using those shaders that are not actually needed surely will improve compilation time is there a way to mitigate the stutter issues on your own machine though yes first you should abandon hard drives as a storage for games and although this type of storage is still supported in practice they're not fast enough especially when working with a myriad of small files which is guaranteed to cause a lot of problems from Shader related stutters to low res textures that just don't have enough time to load properly similarly this applies to the processor it is the CPU that does Shader compiling therefore if you load your CPU with some extra work needless to say it will increase the probability of stuttering if your game is CPU bottlenecked you can enable frame lock the thing is that Shader compilation is a secondary process and if your game loads your CPU to the full then the compilation task will have too little resources allocated to it which will cause stutters when new objects appear on the screen set in the frame rate limit in such a case will limit the CPU load which will allow for more resources to be allocated for Shader compilation of course this may reduce the overall smoothness of the picture but it's up to you to decide what you need more the higher FPS or a game with no stuttering you can use this track together with lower end processor dependent settings such as crowd density draw distance particles quality and other parameters that affect physics and quality of objects in general if initially shaders were supposed to simplify the life of developers as well as optimize and unify the process of creating games now they're ever growing and already bloated number causes such issues even on the Modern Hardware and although there is a guaranteed solution to this most Gamers do not agree with that hardly anyone wants to wait for the launch of their favorite game for half an hour just because the graphics card driver has been updated the direct storage technology may be able to mitigate this issue it implements a new i o model in games that allows you to remove some loot from the processor when it is activated it becomes possible to transfer data from the SSD directly to the vram minimizing the CPU utilization and the operating system involvement which reduces the load time of games to a few seconds also the technology allows you to move the work of unpacking data from the CPU to the GPU this will also unload the processor and allow it to allocate more resources for Shader compilation which can make this process faster or more unnoticeable to the user but so far there is only one game with direct storage support far from the best in terms of optimization and plots for spoken but the start has been laid nonetheless in the summer Diablo 4 should release and have a support for this technology as well and if it proves useful other game developers are likely to catch up perhaps in the future some new Solutions will be found but for now when having starters in your game it's worth remembering the developers are not always and not entirely to blame for this this wasn't K my name is Mikhail krashen I'll see you again
Info
Channel: My Computer
Views: 10,782
Rating: undefined out of 5
Keywords: Compilation of shaders, my computer, stutter problem, pc games, kroschin
Id: f7yml1y3fDE
Channel Id: undefined
Length: 10min 21sec (621 seconds)
Published: Thu Apr 20 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.