CppCon 2016: Jason Jurecka “Game engine using STD C++ 11"

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 ส.ค. 2024
  • CppCon.org
    -
    Presentation Slides, PDFs, Source Code and other presenter materials are available at: github.com/cppcon/cppcon2016
    -
    This session is going to give an account of the process and features used to create a game engine focusing on using std C++11 features and concurrency. We will go through the architecture of the engine design and the specifics of the C++11 features being used. We will also go through optimization choices and design mentalities that are being used to keep the code base simple, but powerful in game usage. The engine architecture we will be going through will be using parallelism as a way to distribute work and get performance out of the available hardware that can scale into the future.
    While completing a full engine with cutting edge graphics techniques and a game to push the engine to its limits will take a while this session will go over the current state of the project and lessons learned. The ultimate goal of the project is to show the validity of using C++11 (and beyond) features in game engines to simplify code and improve stability while maintaining the performance and memory usage games demand.
    -
    Jason Jurecka
    Blizzard Entertainment
    Senior Software Engineer
    Jason Jurecka is a 12+ year engineering veteran of the game industry that has worked on titles in the full range of platforms from PC to next-gen consoles. He has done a wide range of tasks that include engine architecture, asset management, asset pipelines, gameplay features, task automation, tools/plugins/scripts for content creators, automated testing, game/toolchain optimizations, and many other generalist engineering tasks. Jason has contributed to titles such as Rise of Nations: Rise of Legends, Catan, Red Dead Redemption, Max Payne 3, Grand Theft Auto 5, Battlefield 4, Battlefield: Hardline, Call of Duty Black Ops 3, and Amazon's Lumberyard Game Engine/Editor.
    -
    Videos Filmed & Edited by Bash Films: www.BashFilms.com
    *-----*
    Register Now For CppCon 2022: cppcon.org/registration/
    *-----*

ความคิดเห็น • 80

  • @criticalposts3143
    @criticalposts3143 3 ปีที่แล้ว +19

    ah, remember when PC and Mac were both x86_64? good times.

    • @llothar68
      @llothar68 ปีที่แล้ว

      And both were good enough when using OpenGL

  • @hanneshauptmann
    @hanneshauptmann 7 ปีที่แล้ว +18

    Good talk, I always enjoy the "game engine" talks :)

  • @AxelStrem
    @AxelStrem 7 ปีที่แล้ว +21

    this guy really likes to leverage

  • @danhiggins7234
    @danhiggins7234 7 ปีที่แล้ว +8

    I also use C++11 (and boost) heavily in game development - love it! Good talk.

  • @DedmenMiller
    @DedmenMiller 7 ปีที่แล้ว +10

    55:30 one can force compile-time execution of constexpr functions by wrapping them in an integral_constant. For example using
    #define FORCE_COMPILETIME(e) (std::integral_constant::value)
    Thats what i am using to use constexpr string hashes in switch statements.

  • @emilrostad9720
    @emilrostad9720 7 ปีที่แล้ว +50

    haha, he looks slightly annoyed at the people (same person?) not really asking questions, but wanting to show off their own knowlegde of c++.

    • @wCupOfTea
      @wCupOfTea 7 ปีที่แล้ว +26

      The whole time I was watching it I was like "This guy needs to shut the f*** up...".

    • @MrSpanky555
      @MrSpanky555 7 ปีที่แล้ว +8

      Yeah the constant interruptions were fairly distracting. Does anyone know if this was labelled as more of an interactive presentation or was this person being kind of rude and interrupting all the time? I feel like unless the presenters asks if there are any questions, hold questions until the end, especially if they aren't really relevant to the topic being discussed at that moment. (I think you could figure out what 'push' does and regardless, it's not relevant to C++ 11 in games regarding what he was talking about)

    • @WutipongWongsakuldej
      @WutipongWongsakuldej 7 ปีที่แล้ว +5

      I was experiencing this kind of person once. I learned much later that he has mental illness (Asperger Syndrome).
      I don't mean the guy in the video, though.

    • @JoahW
      @JoahW 7 ปีที่แล้ว +6

      I was in that class! I would say about 5% of the time he raised his hand he had an actual question, and the other 95% of the time he just wanted to show how smart he was.

    • @WutipongWongsakuldej
      @WutipongWongsakuldej 7 ปีที่แล้ว

      He should be blacklisted :P

  • @sanjuuyonsai
    @sanjuuyonsai 7 ปีที่แล้ว +16

    48:40 "resource sterilization"... so these pesky resources don't start to multiply and things get out of hand :D

  • @berkuskarchebnyy2365
    @berkuskarchebnyy2365 7 ปีที่แล้ว

    Looks like @52:03 pure is not the same [[pure]] that is in the PR0078R0

  • @MichaelPohoreski
    @MichaelPohoreski 7 ปีที่แล้ว +26

    @19:36 *sigh* Yet-Another-Reflection-System implemented via macros because the language doesn't offer it ... yet.

    • @MichaelPohoreski
      @MichaelPohoreski 7 ปีที่แล้ว +7

      Custom pre-processing step.

    • @llothar68
      @llothar68 7 ปีที่แล้ว

      Some people see this as even worse then using macros. Even if it is as good and simple as Qt.

    • @jasonjurecka1601
      @jasonjurecka1601 7 ปีที่แล้ว +7

      Michael Pohoreski I too am not the biggest fan of the macro method. it can be hard to debug and traversing layers of macros is not fun. preprocessing as you mentioned could be a more debug able way, but for this project the overhead to create the system to do all that generation was prohibited by time.

    • @jasonjurecka1601
      @jasonjurecka1601 7 ปีที่แล้ว +6

      this method also got me the compile time versioning I wanted in a way that would be exactly what the compile created .... preprocessing could leave you cases where the data is not always updated (though they could be rare)

  • @noxabellus
    @noxabellus 6 ปีที่แล้ว +10

    Compile time asset processing is like the exact opposite of the kind of change I want to see in games development. We should be making it easier for end users to make modifications, which both increases target audience and expected life time for any game, and can provide even more benefits including free community patches and the like. Instead we are to _design them out_ entirely, instead of providing better error messages to our artists, or to squeeze another few moments out of our load time?

    • @jan-lukas
      @jan-lukas 2 ปีที่แล้ว

      Implement compile time processing for base game assets and dynamic for mods, only negative is that you have to maintain both

    • @FireflyInTheDusk
      @FireflyInTheDusk ปีที่แล้ว

      @@jan-lukas ... so just make everything dynamic from the start and have no extra issues to deal with then.

    • @ultimatesoup
      @ultimatesoup 9 หลายเดือนก่อน

      I disagree, doing this at compile time allows things to be considerably more performant

    • @ultimatesoup
      @ultimatesoup 9 หลายเดือนก่อน

      ​@@FireflyInTheDuskand then pay a performance cost at runtime....no thanks

  • @davidporterrealestate
    @davidporterrealestate 7 ปีที่แล้ว

    what theme is that for the code on the slides?

  • @Darleer
    @Darleer 3 ปีที่แล้ว

    anyone knows which Chandler's talk he was referencing?

  • @walter0bz
    @walter0bz 7 ปีที่แล้ว

    52:50 stick with =0 for pure, and use the word pure for 'immutable by default'

  • @kosbarable
    @kosbarable 3 ปีที่แล้ว

    15:50 BOOM!
    CPP became unreadable monster

  • @Test-iv4pm
    @Test-iv4pm 2 ปีที่แล้ว

    With this task system, how are tasks interrupted?

  • @ytho5470
    @ytho5470 5 ปีที่แล้ว +2

    Can someone help me find the video he's talking about around 5:40 ?

    • @pery9971
      @pery9971 5 ปีที่แล้ว +3

      I think it's this one th-cam.com/video/vElZc6zSIXM/w-d-xo.html

  • @xthebumpx
    @xthebumpx 7 ปีที่แล้ว +1

    Anyone know what color scheme is being used for the code in the slides?

    • @daggawagga
      @daggawagga 6 ปีที่แล้ว

      I would love to know that too

    • @____KB
      @____KB 6 ปีที่แล้ว

      I believe it is just the Dark theme in Visual Studio. This is what I use and I go in and adjust a couple colors.

    • @lm2668
      @lm2668 4 ปีที่แล้ว

      Visual studio 2019 dark theme

  • @MrWorshipMe
    @MrWorshipMe 7 ปีที่แล้ว +5

    He's saying he's using a unique_ptr to have automatic cleanup if there's a crush, but he also says he's not catching exceptions... so if there's a crush, the whole process is killed anyway and unique_ptr doesn't matter at all, doesn't it? It only helps him to forget about it if the user quits the game normally... Or am I missing something?

    • @jasonjurecka1601
      @jasonjurecka1601 7 ปีที่แล้ว +5

      the unique _ptr buys the ability to have entire game states go out of scope and not have the memory leak. for a task queue it would allow you to reset the queue without having to delete each remaining task.

    • @MrWorshipMe
      @MrWorshipMe 7 ปีที่แล้ว

      Jason Jurecka I know but he specifically said it helps in the case of crashes..

    • @jasonjurecka1601
      @jasonjurecka1601 7 ปีที่แล้ว +3

      MrWorshipMe I believe that was a misspoken thing as the example he game right after was resetting the game state back to the main menu.

    • @vertigo6982
      @vertigo6982 6 ปีที่แล้ว +7

      Why are you talking in 3rd person when talking about yourself or are you not THE Jason Jurecka in the video.

  • @rastaarmando7058
    @rastaarmando7058 2 ปีที่แล้ว

    isn't make_unique a c++14 feature?

  • @JohnWasinger
    @JohnWasinger ปีที่แล้ว +2

    5:10 Chandler’s talk this morning:
    th-cam.com/video/vElZc6zSIXM/w-d-xo.html

  • @Test-iv4pm
    @Test-iv4pm 2 ปีที่แล้ว

    What does it mean that a task is "not completed" and it is placed back into the queue?

    • @jan-lukas
      @jan-lukas 2 ปีที่แล้ว

      I guess you could run tasks every frame by placing them in the queue but never completing them. Also networking error handling could "not complete" the task to retry next iteration

  • @samuelalonso2602
    @samuelalonso2602 6 ปีที่แล้ว +5

    "We can patch to fix found things in the wild" Now i understand why Blizzard games are bugged

    • @sirgouki6207
      @sirgouki6207 5 ปีที่แล้ว +3

      Actually, this is pretty much an industry standard since early 2000s. Proof of concept? The fact that Oblivion, Fallout 3, Skyrim and Fallout 4 all have an instance of the same physics bug (an entity will randomly fly into orbit, then fall back down to the ground for seemingly no reason. Another one is sometimes an entity will "string out" or stretch to rediculous proportions and roll out of the scene... this one happens a lot less than the Entity Space Program issue), DESPITE using newer versions or different physics engines. It's not game breaking, its not throwing a major exception, and they have "turned off" all the minor exception handling.
      They may not even KNOW this is going on without us telling them its going on.

    • @faizzin4483
      @faizzin4483 4 ปีที่แล้ว +3

      He said that as a negative point, not as something they did. Listen again.

  • @soonts
    @soonts 7 ปีที่แล้ว +30

    @28:00, his code is really bad.
    When there aren’t tasks to execute, his code will wake up each thread in the pool 333 times each second. This prevents CPU sleep states, meaning his code is going to burn battery on mobiles, and will keep CPU hot on all platforms.
    And when a task is posted to the pool, his code brings up to 3ms extra latency for absolutely no reason.The right approach is use some better queue, that can block consumer threads on some synchronization primitive, e.g. std::condition_variable, until more tasks are available. Or on Windows, there’s a built-in queue, I/O completion port.

    • @soonts
      @soonts 7 ปีที่แล้ว +4

      Here's some basic example of such queue (not mine, untested): github.com/juanchopanza/cppblog/blob/master/Concurrency/Queue/Queue.h

    • @catbertsis
      @catbertsis 7 ปีที่แล้ว +31

      it is a game, there are always tasks to execute, CPU usually does not sleep when you play a game :)

    • @Ybalrid
      @Ybalrid 7 ปีที่แล้ว +6

      +catbertsis exaclty what I was thinking. We're talking about a program that will always be busy anyway

    • @jasonjurecka1601
      @jasonjurecka1601 7 ปีที่แล้ว +14

      Konstantin X you are correct that the thread sleep is not the best idea. in a quick iteration the example now uses a condition_variable to wait for tasks as needed, but as mentioned games usually have tasks running just about all the time.

    • @soonts
      @soonts 7 ปีที่แล้ว +10

      On a fast enough desktop PC, a well-designed game won’t have tasks running all the time. We don’t want to compute physics or AI more often than once per frame. FPS is typically limited to 60Hz, unless user knows what she is doing and switches off VSync.
      Even when that’s not the case, and the game indeed have tasks running all the time, that doesn’t means each CPU core have tasks running all the time as well. In most games I worked on, some form of thread synchronization was still used, to merge data from background threads to the rendering thread.

  • @IndellableHatesHandles
    @IndellableHatesHandles 2 ปีที่แล้ว

    Using a struct for only a spawn point is a little bit odd, especially for a large C++ project. Maybe it would make sense if the scope was small, like a private C# struct, but polluting your C++ namespace isn't a good idea in my opinion.

  • @MrAbrazildo
    @MrAbrazildo 7 ปีที่แล้ว

    Well, multi thread won't "solve things all at once", because the processor is serial. Maybe if you could put a thread at each core, things could be different.

    • @MrWorshipMe
      @MrWorshipMe 7 ปีที่แล้ว

      What do you mean? There are context switches, since there are more threads\processes than logical cores, but some threads really do run concurrently some of the time...

    • @jasonjurecka1601
      @jasonjurecka1601 7 ปีที่แล้ว +1

      MrAbrazildo the example uses a thread pool of threads that equal one per core so as each core executes multiple things can be worked on at once. the context switching that is referenced is about the caching of data for each core. if one core is processing a pod item it is loaded into cache then processed. if the next pod item being processed is not able to be precached by the processor then the processor will start all over and pull the pod item that is needed into its cache. performance can be gained by keeping like data together in contiguous memory and processing it on the same core so the caching and prefetch help you. this example is just generic and does not try to be smart about task organization. the talk mentions this in reply to one of the questions.

    • @MrAbrazildo
      @MrAbrazildo 7 ปีที่แล้ว

      Jason Jurecka So, in practice, does multi thread improve chance of performance boost? I don't see anybody talking about this.

    • @MrAbrazildo
      @MrAbrazildo 7 ปีที่แล้ว

      ***** I said multi thread, not multi core.

    • @MrAbrazildo
      @MrAbrazildo 7 ปีที่แล้ว

      ***** Then why muiti thread is never mentioned in videos about performance? Not even in that "C++ in Huge AAA games", which showed several smart tricks. Neither Carruth's LLVM compiler seems to create multi threads.

  • @MrAman47
    @MrAman47 2 ปีที่แล้ว

    The one thing I hate about game devs is what he said about game quality "if 1% of 1% has issues, sorry". I get it but try to strive for 100%. Why settle for less?

    • @dany5ful
      @dany5ful 2 ปีที่แล้ว +4

      Because you can't "waste" 1 year of game development to fix bugs that only occur under specific circustances. If the bug isn't game-breaking or only a very small percentage of people has a problem, it's simple not a priority. It's not like they don't try to fix bugs whenever they can, but if it's not a priority, they can't focus on that.

    • @jan-lukas
      @jan-lukas 2 ปีที่แล้ว

      I think what he meant is that you don't actually search for those issues, even though you should obviously fix them if reported to the bug tracker (which still not all games have unfortunately). This means you fix them once reported, but don't waste time searching for them before the game is released

  • @ecosta
    @ecosta 3 ปีที่แล้ว

    The year is 2016. Tired of his company using pre-98 C++, an ambitious game dev decides to create a game engine using C++14 and the latest and greatest to avoid the mistakes of his employer. Wait, what? He used C++11 instead of C++14? Is that yet another macro-based reflection system (19:00)? He doesn't want to use Vulkan/DX12 because it's "too new" (34:00)? He thinks it's fine to assume we can safely use the default destructor based solely on a forward definition (56:50)? Whaaaa? Why does this feel like one of those "I made a Minecraft clone in one day" videos?