How I optimized Portal to run on the Nintendo 64

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] Cave Johnson here we're getting complaints that our tests are too dangerous a bunch of sissies if you ask me I had the boys at the lab come up with a new solution gaming introducing the Aperture Science frontal pack the Pinnacle of hatic feedback we've harnessed the power of propulsion gel that bounc it blue stuff and miniaturize it to fit right in your controller but we didn't stop there the Aperture Science compiler optimization Suite ensures faster rendering of those intricate portal Graphics so you can Traverse the Aperture Science enrichment center with the speed and finesse of a Ninja on Brer blades we've expanded our scientific prowess to Encompass not just the laws of physics but the intricacies of language now you can enjoy testing in your language of choice so whether you're saying Ola bonjour or kicha Aperture Science is ready to accommodate your linguistic needs and remember at Aperture Science we're not just changing the gaming industry we're obliterating it with science now to our top engineer here to tell us how it all works James take it away I turned on compiler optimizations okay so I did a little bit more to optimize the game but that alone did quite a bit to increase the frame rates other great things I added well the game now supports Rumble pack got that right here and um translations so now you can turn subtitles on for a variety of languages let me go and start this mind you that the translations probably never would have happened without the contributions of Weston coder and hacker grid uh they've been contributing to the project and other other improvements other than translations and without their input that would not have happened hey sorry to interrupt but I just wanted to take this time to tell you about this video sponsor World of Warships World of Warships is a free-to-play game where you take control of historic warships choose between a variety of ship classes each with their own strategic strengths weaknesses and their own unique play Styles take part in massive 12 V12 battles in more than 40 unique maps with Dynamic weather would you look at those Graphics those are some nice Graphics we won't see anything like that on N64 anytime soon or ever the game stays fresh with new content every month including new ships in-game Nations Cosmetics or even chip classes in the past some of these updates were even themed after Transformers as your lane or even puye right now they have a high school Fleet themed in-game event so if you use the link in the description you can download the World of Warships and be sure to use the promo code code hsf 2023 to start the game with 200 deons 1 million credits 7 Days premium account time and two High School Fleet commanders oh and did I mention you can even play on Console so thanks again to World of Warships for sponsoring this video and now let's get back to it as you can see I have the game in Spanish right now you can go I'll just show you the options you can change it to a variety of languages the menus aren't fully translated yet if you have any recommendations for improvements to the translations please submit that to the GitHub project the links in the description below but let's go ahead and just start a NOA partita here and um I'm going to jump into this test chamber so turning on compile optimizations that was probably something I should have done a long time ago in case you're not sure what compiler optimizations are so I was reviewing my footage and I didn't like the explanation I gave while playing of compilers and optimizations so I'm just going to redo that really quick a compiler is a program that can convert code into a program so for example I have this very simple program here and then when I run the compiler it generates a program that I can then run optimizations are settings for the compiler that improve the performance of the program these optimizations come at the cost of compile time making it longer to build the program and the ability to De bug the program making it harder to track down bugs so moving forward I turn off optimizations to debug and then turn them back on for releases I hadn't had optimizations turned on for a while now I was kind of nervous to turn them on because there are some bugs that are only present when optimizations are on and I was worried I'd have some of those so I turned it on and I was lucky because there were no problems despite my poor planning because that could have gone the way the other way because as the game gets more complicated there's more potential places where I might have just had an oversight about volatile memory use or some other thing that optimizations would create a bug and it just wasn't there so that was fortunate but of course I didn't stop there I also profiled the code to see if there's any bottlenecks in my code like where would the slow points at least on the CPU and I was expecting the physics to take a pretty big toll on the game's performance but I actually ended up not being a problem which is why you need a profile code if you're trying to make things fast you really should run it measure the performance and see where the performance problems are because it's hard to predict them sometimes and once you know where they are you can focus your attention on improving those and it turned out for my case the slow point in the code was the rendering so when I render the scene I only send I try to only send the visible objects to the GPU to be rendered so that way the GPU doesn't spend as much time processing things that aren't visible on the screen and it also if done well helps me prevent texture swaps so it's just give the GPU less work to do but I was taking that too far the CPU was doing a lot of work I was actually and every every everything that's visible on screen I was checking to see if it was visible on the CPU first well I was just doing a pretty naive approach where I just Loop through every single object and check it one at a time no one will blame you but there's a way you can really improve that using what's called a bounding volume hierarchy and how that works is you take nearby objects and you group them together in their own it's called a bounding box so you can think of a bounding box is just a a box that fits what's inside of it that's not a very good description it's the smallest box that can surround something or more than one something in this case and so I would just combine bounding boxes of nearby objects into one if I check that one bounding box if that's inside then I can render everything inside it if it's outside I can exclude everything it's only if that box is partially inside and partially outside the view that I need to then check the contents of that box to see if it's visible and the cool thing about bounding volume hierarchies is you can actually take the groups and put them together in groups and then take those groups and put them in groups to the point where you can pull out an entire room with just a single Bing volume check and so that that reduces the amount of work that the CPU needs to do to determine what's visible while not sacrificing a lot of performance improvements by giving still by still giving the GPU the minimum amount of work that it needs to do so that was an improvement I made and in test chamber 11 it makes a huge difference the frame rate is just massively improved in test chamber 11 where there's a lot of things on screen so so that is a big win and I just don't know how to beat this test chamber guys I it's impossible so um where was I oh yeah Rumble pack support when you fire portals it rumbles and uh if you walk through I'll put it up right up next to the microphone so you can hear this okay I'll stop making the sound to myself so yeah and you walk through Port you walk through the Emancipation Grill it rumbles slightly and so Rumble pack was actually kind of tricky because uh it wasn't very reliable um and it actually comes down to the fact that you connect this in to the back of the controller and the pins might actually lose contact in the connector as it's vibrating so it actually is very unreliable when you try to turn off the rumble pack after it had been started so there were times where I'd fire the the portal and it' Rumble but it wouldn't it wouldn't stop rumbling after oh that's that's exciting I ended up having to send like three commands to tell it to stop but even that wasn't really perfectly consistent so really I just send a command to stop Rumble pack every frame just in case it's running when it shouldn't be but sending commands to the controller actually takes about 2 milliseconds to do a round trip and I have to do that to get the controls like the normal controller data but also for all the rumble pack management and it ended up being about 10 millisecs of total round trips per frame that I'd have to spend managing the controller for reference 10 milliseconds is about you know the each frame is supposed to be about 33 milliseconds I'm targeting 30 30 frames per second that's about a third of the frame a third over a fourth to the frame um oh whoa that's a new bug it's not supposed to be doing that anyway about a third of the frame spent managing the controller but the good news is that time is just idle and so it's not actually doing anything it's just waiting for a response from the controller I just put the controller logic onto a separate thread anytime the controller thread is waiting the CPU is freed up to do other tasks multiple threads on the N64 you don't get any performance gains by being able to put things in parallel it's really just helpful for managing multi multiple tasks like what I need to do with the controller right I need to manage the task of a controller and the task of not impossible take that glattus anyway new thread for controller logic that's good lets me do Rumble pack support and uh lastly I just wanted to mention translation so you notice I put the game in Spanish here and uh let's also we can change the audio as well which I don't know I tried the Spanish audio earlier and it sounded really weird to me I'm not sure if I'm changing the frequency I don't think I am uh if I am then I need to fix that but it just it does not sound like glattus that is all for this update and uh thanks again I don't know what that was the robot vacuum that's all for this update and uh thanks again to World of Warships for sponsoring this video there's a link in the description if you download the game be sure to use the code hsf 2023 to get your huge starter pack including D Bloons credits premium account time and high school Fleet commanders so thank you all for watching and until next time take [Music] care yeah
Info
Channel: James Lambert
Views: 533,294
Rating: undefined out of 5
Keywords: portal, n64, nintendo
Id: r4KGm7ixcqI
Channel Id: undefined
Length: 11min 33sec (693 seconds)
Published: Thu Nov 16 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.