Refs, Scopes and Smart Pointers | Game Engine series

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 พ.ย. 2024

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

  • @sebastiannocke3725
    @sebastiannocke3725 5 ปีที่แล้ว +200

    Cooking with Cherno, I need it please

    • @jamesmnguyen
      @jamesmnguyen 5 ปีที่แล้ว +4

      We need some Turkey too!

    • @austindrane3162
      @austindrane3162 5 ปีที่แล้ว +1

      That would be the best series on TH-cam

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

      Cooking while doing analogies with programming and c++, would love that content !

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

      @@bandolero818 "Now we're going to dice this here and its kind of like making a shared pointer"

  • @mrhidetf2
    @mrhidetf2 5 ปีที่แล้ว +42

    cherno really stepping up his metahphor game in this series. Honestly tho i think you are getting better and better at communicating

  • @carlosgarciavigoa7937
    @carlosgarciavigoa7937 5 ปีที่แล้ว +58

    Guys & Girls, this is a simple tip.
    If anyone here goes to the beginning of the series and watch the first episode again, it will increase watching time, popularity, ranking and many other things that will help the Series.
    Of course, it will help Cherno too.
    More view more ranking and at the same time more subscriber than eventually will become Patrons.
    Remember now is a FULL-TIME JOB.
    We need to keep that.
    TY in advantages.

  • @jdev6402
    @jdev6402 5 ปีที่แล้ว +14

    Now i'm curious how that asset manager will look.
    Thank you for your dedication to this series, it's really motivating and informational.

  • @felipecarlin8540
    @felipecarlin8540 4 ปีที่แล้ว +6

    9:29 I was not prepared for that, now I'm concerned about memory ownership and management. Thanks Cherno!

  • @mario7501
    @mario7501 4 ปีที่แล้ว +17

    Just made a patreon account to support your channel! This is by a mile the best C++ and game dev content on TH-cam!

  • @colorcookie6088
    @colorcookie6088 5 ปีที่แล้ว +14

    Love you Cherno!!! Your C++ series has helped me a lot. Thankk you

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

    0:10 nah m8 EVERY SINGLE episode is EXCITING

  • @thecookiegeneration
    @thecookiegeneration 5 ปีที่แล้ว +1

    You can check if the sharedptr is lock free, most atomic increment and decrement operations can be done threadsafe without a lock (single cpu instruction for read increment write)

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

    2021 and still no "Cooking with Cherno". In the mean time, patreons should get access to a shared pointer to his kitchen

  • @__jan
    @__jan 5 ปีที่แล้ว +13

    he's getting funnier every episode

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

    Cooking with Cherno? It's been over four years since Sparky, and I don't think you've ever remembered to take the turkey out of the oven! ;)

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

    Cooking With Cherno - Episode 1: The Perfect Cup of Coffee

  • @simonbaxter8001
    @simonbaxter8001 5 ปีที่แล้ว +4

    I'm still waiting for the 'Cooking with Cherno' series ! ;)

  • @TriNity-GER
    @TriNity-GER 5 ปีที่แล้ว +2

    Whenever I need a pointer, I always ask myself: who is the owner? Are there multiple owners? Using this though massively helped me to choose between unique_ptr and shared_ptr. Also my favorite replacement for raw pointer is object_ptr :D

  • @stanleythehandsome5402
    @stanleythehandsome5402 5 ปีที่แล้ว

    Boy I Love this guy

  • @MirralisDias
    @MirralisDias 2 หลายเดือนก่อน

    In the current code base (Hazel2D), what is the point of using std::shared_ptr, if you're passing it as a const reference basically everywhere, therefore not incrementing the counter, and not avoiding the same things you are concerned about.
    I wonder if this is the same for the dev branch.

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

    Man, last time I heard the word "ownership" so many times was during a talk presenting the Rust programming language. Love C/C++, love Rust more

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

    "all cool and hip and trendy"

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

    I was having a big problem with a dangling pointer in my code. Weak pointer saved my life. Every since then I use shared pointers only..

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

    Cooking with chernoooooooo!!!!!! Let's go babyyyy!!!!

  • @quanghong3922
    @quanghong3922 5 ปีที่แล้ว

    Great job

  • @theo-dr2dz
    @theo-dr2dz ปีที่แล้ว

    What he says at minute 3 is not correct. std::unique_ptr can't be copied (if it could, it would not be unique anymore), but it can be moved. Moving a std::unique_ptr transfers the ownership. But of course, if you need shared ownership, use a shared_ptr

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

    I live in sad 2022 😔. Can i get a reference to *"Cooking with Cherno"* ? Or at least a pointer address?

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

    nice new haircut :D

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

    thanks!!!

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

    Still waiting for cooking with cherno, 3 years later :-(

  • @GalaxySoftwareStudio
    @GalaxySoftwareStudio 5 ปีที่แล้ว

    What do you using about using glad2 instead in the future ? As it supports Vulkan too, multiple GL contexts, internal loader and you can even generate a header only version ! ^^

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

    all of us crying xD

  • @clodgozon3968
    @clodgozon3968 5 ปีที่แล้ว

    I love dealing with refs and pointers. Not an irony.

  • @Thiago1337
    @Thiago1337 5 ปีที่แล้ว

    Great tutorials.

  • @fryderykst
    @fryderykst 5 ปีที่แล้ว

    Great video as always, thanks! :)
    Could you (or someone else) explain the difference between atomic count and regular one? How it works? Thanks.

  • @bies_moron4404
    @bies_moron4404 5 ปีที่แล้ว +1

    401 patrons !!

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

    "We have a very exciting epesode" says without anny emotion.

  • @mytech6779
    @mytech6779 5 ปีที่แล้ว

    I was trying to slog through a bunch of the CPPcon videos, mind blown. Getting down to manipulating L2 and L3 to achieve better atomic multi-threading; actually considering the physical time to transmit an electric pulse between cores and predictive fetching from memory. And they always say "use vectors", I'm not sure if this is an old running joke or actual advice for better general performance.

    • @reductor_
      @reductor_ 5 ปีที่แล้ว

      'better general performance' : no,
      get a few more ns with micro optimizations : yes
      essentially don't prematurely optimize

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

      As you are aware, it's a consequence of cache. "Everything" is probably a vector, and now with cache, this is doubly so.
      @ReDucT0r; 'better general performance' : yes. I sugges you research cpu cache. vectors are beating out linked lists, even for tasks classically thought of as optimized for linked lists, like midpoint insertions and deletions because cpu cache is orders of magnitude faster than going to RAM.

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

      @@daleowens7695 2 years on and I know a good deal more about c++.
      The vector referenced was the std library dynamic array, not the SIMD hardware or math concepts.
      And yes they were mostly comparing it to [linked] list performance, but it was also about moving away from old style C and improving code quality both in reading the logic and in avoiding memory leaks associated with deleting manually allocated dynamic memory for classic arrays. (Though if done just right a classic array can be a hair more optimized if needed for some very critical corner case, but in most cases the payoff isn't worth the effort and would need a lot of profiling and testing to proove. In many cases careful use of vec1.reserve(n) will close most of that gap without the hassle. )

  • @cubefish2320
    @cubefish2320 5 ปีที่แล้ว

    Give me lapsis episode 9 i'm still waiting after all these years I've become nothing, dedicating every second of my waking time to trying to solve what episode 9 would be. I lost my job, my wife, my family outed me, and I lost all my friends. I live on the streets, wandering with my phone, theorizing about how the Minecraft Machinima 'Lapsis' episode 9 would have ended.
    I need this. please.

  • @_Omni
    @_Omni 5 ปีที่แล้ว +4

    24:26 you didn't say what you will do in the next episode 🤷‍♂️

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

      textures :)

  • @engsayed2007
    @engsayed2007 5 ปีที่แล้ว

    I Am developing a program which I draw objects using the mouse
    I draw a point _ line and polygon with any number of sides
    I save each created object (line or point or polygon) as a mesh having its own vba_vbo_ibo
    Till now I can select each object and individually without any problems
    My problem is
    I want to create large number of objects say 2 millions
    When I create more objects the program becomes too slow in rendering
    I tried to make all vertices coordinates in one buffer and all created objects share this buffer according to its indices
    How can I handle such a huge number of objects ??????
    Thanx in advance

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

    i destroyed my entire code base with the replace all function I basically have to start over

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

      This is why you want to use git and commit often. :)

  • @gracicot42
    @gracicot42 5 ปีที่แล้ว

    What I do usually is to decouple the refcount to the asset. I have the asset object that contains only the minimum necessary to use it, and a refcount. For example, the asset object for a shader program would contain the id and the refcount. But having a refcount of some sort, whether it's with a shared pointer or something like I do is absolutely necessary. Keeping resources around from scene to scene makes the engine not loading things over and over. We don't know when we will destroy the texture or when it won't be needed anymore. So shared ownership is ideal.

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

    9:35 lmao

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

    ChatGPT3.5 Generated:
    - The transcript is from a video in a game engine series.
    - The video discusses references and smart pointers for the engine's core system.
    - Shared pointers are being used to encapsulate objects on the heap to control their lifetime.
    - The issue of ownership is important for smart pointers as they automate the deletion of objects.
    - The renderer of the engine needs to hold references to assets such as shaders and vertex arrays for deferred rendering.

  • @Rekongstor
    @Rekongstor 4 ปีที่แล้ว +1

    I love smart pointers and especially shared ones, the main idea of this video is good. But what's the point of renaming std::shared_ptr into Hazel::Ref or std::unique_ptr into Hazel::Scope? You still have to type a bunch of letters but new Hazel users will not intuitively understand what Hazel::Ref stands for without peeking on the code or reading the documentation. Like maybe it would be better to remain std library without Hazel aliases because there're more people familiar with std naming, not Hazel's.

    • @madeso
      @madeso 4 ปีที่แล้ว +1

      Premature refactoring. At 14:03 he says it's because he might want to implement a shared_ptr for "assets" with the same exact api as std::shared_ptr and changing it then would be too hard.

  • @denisbalcom1429
    @denisbalcom1429 5 ปีที่แล้ว

    loving the metaphors and cooking with cherno statement lol. ~^_^~.

  • @bensettiabderrahmane1801
    @bensettiabderrahmane1801 5 ปีที่แล้ว +1

    Hello, World!!!

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

    Thread pool system is better than dividing engine into specialized threads.
    1) Easy to add to existing engine structure.
    2) Easy to synchronize(you don't need to use double buffering)
    3) Memory efficient(look above)
    4) Scales better for computers with more than 4 cores.
    5) Great for ECS pattern.

  • @huyvole9724
    @huyvole9724 5 ปีที่แล้ว

    New pc

  • @vitaliiseptember266
    @vitaliiseptember266 5 ปีที่แล้ว

    Hey, Yan - its a russian name, and Chernikov - its like russian surname, isnt it?

  • @nextlifeonearth
    @nextlifeonearth 5 ปีที่แล้ว +10

    Somehow in the poll people imply 2D would be a stepping stone to 3D.. If you look at any given 2D or 3D engine editor you see they're almost nothing alike. "use the feedback from 2D for 3D" That's not how it works. Outside of some scripting, the UI feedback will be of no benefit in the 3D editor. There are fewer materials in 2D, so no material editor except for its texture and maybe some filters, that's out. The world editor, is vastly different in 3D again, that's out.
    Will it be faster? Yes, you can look at 100+ tutorials to make 2D engines online today and see for yourself it can be pretty easy. If you'd like to compare it a a PBR capable 3D engine tutorial, good luck, there's about 5 of which most are behind a paywall and/or abstracted from the code.
    Then what it the purpose of this engine? Making it modern. Is 2D modern? Pretty much every modern effect only applies to 3D.

    • @Sevo779Gaming
      @Sevo779Gaming 5 ปีที่แล้ว +4

      2D and 3D both have modern developments, new rendering technics are always being developed, now that is not to say that 3D is not more complex, or different but you seem to be heavily biased because it is obvious that building a simpler engine is a stepping stone to a more complex and demanding one. Also, I have made a UI that works in both 2D and 3D so I am not sure what you mean there.

    • @nextlifeonearth
      @nextlifeonearth 5 ปีที่แล้ว +1

      ​@@Sevo779Gaming Works doesn't mean work well. An optimal workflow in either are little alike.
      I don't doubt you can make it more complex, but we don't want complexity, we want sophistication without it being complex.
      That's mainly it, you COULD make an editor for 2D and modify it for 3D later, but it would not work as well as if you were designing it for 3D from the beginning.
      It's a compromise and "compromises are the enemy of success", to quote someone.

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

      He's not going to make a full on 2D editor at first, nor a 3d editor. I hope you do understand that. (By the way, you can totally use a 3d editor for 2d games, that's what unity does, they only make the camera orthographic) He is going to create a 2D Renderer at first which will do sprite batching and stuff like that, and then after that he will continue on to 3d PBR renderer which will take a lot of episodes and time to make. There is no debate, what kind of engine it is going to be. As he said, he will do both, but he's asking which one should come first. Also, I think that world editor is not coming anytime soon, since what is the reason to make an editor right now? I will repeat myself again, but he's not going to build a 3d renderer on top of a 2d renderer. They are going to both eventually come and the poll is a debate whether 3D rendering or 2D rendering should come first.

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

      @@DovydasV2
      "you can totally use a 3d editor for 2d games, that's what unity does"
      And it's terrible. I have used it and I'd rather use Gamemaker than that for 2D games, because unlike Unity, Gamemaker was actually designed for 2D.
      I have too much of a bad experience with people saying "X will come later even though it's the primary purpose of the software, we'll do Y first" and then it vastly compromises what can be done with X.
      That's why I have a big aversion of what's essentially a sidetrack that has little to do with 3D and could actually get in the way of the final product and at the very least delay it simply to sate some people who weren't into this series for its purpose in the first place.

  • @jamesmnguyen
    @jamesmnguyen 5 ปีที่แล้ว

    Would delaying the rendering cause noticeable input lag for the user?

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

    So it's either ugly code or cryptic code
    Plus you still have to manage when things get deleted but in an abstract way instead of shouting to the world HERE IN THIS VERY MOMENT I AM RELEASED FROM MEMORY
    New and delete is fine.

    • @ricardopieper11
      @ricardopieper11 5 ปีที่แล้ว +1

      It's fine, but we forget to do it all the time. No matter how genius of a C++ programmer you are, you are bound to forget it at some point. Or you'll double-free, or dereference a dangling pointer, or return a pointer to a stack value... so much can go wrong.
      It's no surprise they created Rust because of this very problem.

    • @jamespong6588
      @jamespong6588 5 ปีที่แล้ว +1

      Ricardo Pieper yeah people forget to call delete, but you can follow the code and figure out if you forgot it, also we have powerful tools to trace memory leaks, it's orders of magnitude harder to figure out when something is released by code structure, than Ctrl+F and find "delete xyz"

  • @optimusfjstudio3345
    @optimusfjstudio3345 5 ปีที่แล้ว

    when you make your own engine can use blender

  • @TheKbdering
    @TheKbdering 5 ปีที่แล้ว +1

    It's pronounced decrement, not decrement