7 ms·
Funnily enough, this is sort of what the NVIDIA drivers do: they intercept game shaders and replace them by custom ones optimized by NVIDIA. Which is why you se
by dist-epoch 2y ago
Funnily enough, this is sort of what the NVIDIA drivers do: they intercept game shaders and replace them by custom ones optimized by NVIDIA. Which is why you see stuff like this in NVIDIA drivers changelog: "optimized game X, runs 40% faster"
- snicker7 2y agoImagine being the dev competing game Y and seeing the changelog.
- esperent 2y agoI'd love to read more about this, what kind of changes they make and how many games they do it for. Do they ever release technical articles about it?
- sigmoid10 2y agoThe other commenter makes it sound a bit more crazy than it is. "Intercept shaders" sounds super hacky, but in reality, games simply don't ship with compiled shaders. Instead they are compiled by your driver for your exact hardware. Naturally that allows the compiler to perform more or less aggressive optimisations, similar to how you might be able to optimise CPU programs by shipping C code and only compiling everything on the target machine once you know the exact feature sets.
- crazygringo 2y agoI don't know -- if that other commenter is correct, it does sound pretty crazy. Improving your compiler for everybody's code is one thing. But saying, if the shader that comes in is exactly this code from this specific game, then use this specific precompiled binary, or even just apply these specific hand-tuned optimizations that aren't normally applied, that does seem pretty crazy to me. But I don't know which it is?
- Cieric 2y agoFinger printing based on shaders is quite rare, really most of the time we detect things like the exe name calling us or sometime, very rarely they will give us a better name through an extension. (unreal engine does this automatically). From there all the options are simple, but full shader replacements are one. In the api I work on the shaders have a built in hash value, so that along with the game identified means we know exsactly what shader it is. Most of the replacements aren't complicated though, it's just replacing slow things with faster things for our specific hardware. In the end we are the final compiler so us tweaking things to work better should be expected to a degree.
- chrisjj 2y ago> most of the time we detect things like the exe name calling us What could possibly go wrong? :)
- Benanov 2y agoquack.exe performing noticeably worse in benchmarks on certain cards than quake.exe in the late 90's/early 2000's?
- chrisjj 2y agoYup. Looking at you, ATI.
- magicalhippo 2y ago
- crazygringo 2y agoWow, how did they pick which games to optimize? Does the studio pay them to do it? Because Nvidia wouldn't care otherwise? Does Nvidia do it unasked, for competitive reasons? To maximize how much faster their GPU's perform than competitors' on the same games? And therefore decide purely by game popularity? Or is it some kinda of alliance thing between Nvidia and studios, in exchange for something like the studios optimizing for Nvidia in the first place, to further benefit Nvidia's competitive lead?
- flohofwoe 2y agoAFAIK NVIDIA and AMD do this unasked for popular game releases because it gives them a competitive advantage if 'popular game X' runs better on NVIDIA than AMD (and vice versa). If you're an AAA studio you typically also have a 'technical liason' at the GPU vendors though. It's basically an arms race. This is also the reason why graphics drivers for Windows are so frigging big (also AFAIK).
- diegoperini 2y agoDouble "AFAIK" makes me trust you more :) I think this is very accurate. The exception is probably those block buster games. Those probably get direct consultancy from NVIDIA during the development to make them NVIDIA-ready from day 1.
- account42 2y agoEven smaller games often get some amount of consultation from Nvidia/AMD - they are typically in the credits in some form.
- Cieric 2y agoI can't give details on how we do our selections (not nvidia but another gpu manufacturer). But we do have direct contacts into a lot of studios and we do try and help them fix their game if possible before ever putting something in the driver to fix it. Studios don't pay us, it's mutually benefital for us to improve the performance of the games. It also help the game run better on our cards by avoiding some of the really slow stuff. In general if our logo is in the game, we helped them by actually writing code for them, if it's not then we might have only given them directions on how to fix issues in their game or put something in the driver to tweak how things execute. From an outside perspective (but still inside on the gpu space) nvidia does give advice to keep their competitive advantage. In my experience so far ignoring barriers that are needed as per the spec, defaulting to massive numbers when the gpu isn't known ("batman and tessellation" should be enough to find that), and then doing out right weird stuff that doesn't look like something any sane person would do in writing shaders (I have a thought in my head for that one, but it's not considered public knowledge. )
- Cieric 2y agoI don't work on the nvidia side of things but it's likely to be the same. Shader replacement is only one of a whole host of things we can do to make games run faster. It's actually kind of rare for use to do them since it boats the size of the driver so much. A lot of our options do change how shaders work though, like forcing a shader to use double precision floats instead of the single it was compiled with.
- SpaghettiCthulu 2y ago> A lot of our options do change how shaders work though, like forcing a shader to use double precision floats instead of the single it was compiled with. What benefit would that give? Is double precision faster than single on modern hardware?
- kevingadd 2y agoI would guess it's done for compatibility or quality reasons
- dahart 2y agoOnly more precision. But no, doubles are not faster. At best they’re the same instruction latency & throughput as singles, and that’s only on a few expensive pro/datacenter GPUs. Even if they are technically the same instruction speed, they’re still 2x the memory & register usage, which can compromise perf in other ways. Doubles on consumer GPUs are typically anywhere from 16 to 64 times slower than singles. FWIW, I’ve never heard of shader replacement to force doubles. It’d be interesting to hear when that’s been used and why, and surprising to me if it was ever done for a popular game.
- Cieric 2y agoThat's specifically because gpus aren't IEEE compliant, and calculations will drift differently on different gpus. Double precision can help avoid divide by zero errors in some shaders because most don't guard against that and NANs propagate easily and show up as visual corruption.
- 2y ago
- chrisjj 2y ago> "optimized game X, runs 40% faster" ... and looks 4O% crappier? E.g. stuttery, because the driver does not get to see the code ahead of time.