• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
beebs1

Unreal Engine... How did they do it?

21 posts in this topic

Hiya,

I've recently been shown a demo reel of the Unreal Engine 4 ([url="http://www.youtube.com/watch?v=acR4n6lJEdQ"]clicky[/url]).

At the very end, while running around in the game world, the demonstrator changes some of the source code in Visual Studio. While he continues to run around the code is recompiled, and suddenly the changes take effect in the game world - without even restarting the simulation.

This struck me as pretty amazing (more so than the fancy graphics [img]http://public.gamedev.net//public/style_emoticons/default/laugh.png[/img]) and I have no idea how they do it. Somehow they are able to replace running binary code in-memory, without the machine exploding. If anyone is interested, it starts around 9:45.

It's far beyond me to try and make anything like this but I'm fascinated - does anyone have an inkling how it works?
1

Share this post


Link to post
Share on other sites
That was my guess, but I'm not sure it would be easy.

If you pull the rug from under a DLL like that surely you'll invalidate any pointers to objects within it, the state of those objects, etc. They must have designed the DLL very carefully, and/or serialise all the objects to another part of memory and then deserialise them back to the new library when it's loaded. It sounds terribly complicated to me.

Thanks! Interesting stuff.
0

Share this post


Link to post
Share on other sites
[quote name='Radikalizm' timestamp='1344351790' post='4967032']
I stumbled upon this blog a while back which might be of interest: [url="http://runtimecompiledcplusplus.blogspot.be/"]http://runtimecompil...us.blogspot.be/[/url]
They even mention the similarities between their technique and the technique used by UE4
[/quote]
Amazing!
[quote name='Hodgman' timestamp='1344352494' post='4967036']
...
[/quote]
Helpful explanation, thanks.

That library does look identical to Epic's implementation - they might be one and the same. I've just given their test code a run through and it works as advertised, I'll definitely be having a closer look into how exactly they're doing it. They've even geared the sample code up for integrating into an existing project.

I've definitely learnt some useful and interesting things today, thanks for your replies [img]http://public.gamedev.net//public/style_emoticons/default/laugh.png[/img]

All the best.

[Edit] It looks like they do indeed serialise objects back into the recompiled module. Edited by Telios
0

Share this post


Link to post
Share on other sites
[quote name='Hodgman' timestamp='1344352494' post='4967036']
Making run-time changes to your structures is more complicated, and VS "edit and continue" simply doesn't support this. Radikalizm's awesome link seems to serialize objects who's structures have changed, so they can be re-created after re-loading the code. I'm definitely going to have a good look at how that project works!
[/quote]

When I first read about their technique I was quite skeptical about it and I assumed they weren't telling the entire truth, but right now this seems to be the real deal.
By design the technique itself is quite elegant too, and I can see a massive productivity boost in a lot of programming fields once this gets more widespread

I still have to make some time to play with their demo code myself though, but if this works without any major issues I'll probably be integrating this into my own development code - if possible.
0

Share this post


Link to post
Share on other sites
[quote name='dougbinks' timestamp='1344358025' post='4967058']
Glad you've found our project useful!

We don't know if the Unreal implementation is related to ours - it's possible that after our presentation in 2011 at the AI GameDev conference in Paris they found out about it but it's also possible they came up with a similar solution themselves.

On the subject of modules and memory, you do need to ensure you either have virtual destructors or something similar as objects are allocated on each modules heap.
[/quote]

Ahh perfect, now I can say this in person: Awesome work!

If I can get this to work nicely with my development code you might have saved me quite some production time [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
Needless to say I'll be following your project closely
0

Share this post


Link to post
Share on other sites
[i]N.B. Not trying to put a damper on these awesome ideas here, just pointing out some pitfalls to be aware of:[/i]
Two issues with supporting changes to data-structures (which implies serialization/deserializaiton) is that many game engines are (1) very specific about how their utilize their RAM, and (2) also very limited in the amount of RAM they can use.

(2) isn't an issue on PCs, and console dev-kits [i]usually[/i] have double the retail-version's amount of RAM, so it's likely only a minor problem affecting some of your SKUs.

(1) complicates matters though. Even with a general-purpose allocator, when freeing 10,000 objects and then allocating 10,000 slightly larger objects, it's possible that the original allocations aren't contiguous ([i]so they become little bubbles in your address space[/i]), and the new allocations are too big to fit in those "bubbles". This fragmentation of RAM can have the same effect as if you'd simply leaked the original allocations ([i]until you free the used-space around them, probably at the end of the level[/i]), which can make it much more likely to hit the RAM limits from (2).

Further, optimised engines don't use global, general-purpose global allocators ([i]i.e. new/malloc[/i]) for everything. To construct a certain kind of object, you might need to specify which allocation area to construct it in, and you might not be able to free that allocation at a random time ([i]e.g. perhaps bulk-deallocation of the whole area is used[/i]).

For example, when allocating an object in our renderer, depending on which systems are likely to access it and it's required lifetime, the user will specify 1 allocator out of a possible 4 different stacks and 4 different heaps that could be used. i.e. the same object could be constructed within 8 different areas of RAM, but choosing the right one is important based on usage.
If the object is allocated in one of the stack areas, it's can't be freed at will; it's lifetime is bound to the lifetime of the stack. Reallocating with a larger size means 'leaking' the original and adding a new object on the top of the stack ([i]which there might not be space for[/i]). Alternatively, it means serializing the entire stack and re-allocating the whole thing from the bottom-up to avoid these holes ([i]and then patching any other objects that held pointers into this stack[/i]).

These aren't un-solvable problems, but a class-layout-patching solution that's applicable for every engine would have to be very flexible in regards to allocations, and may end up having to serialize/deserialze hundreds of megs of data per 'reload'.

That said, gameplay code is usually less performance-critical than engine code, so maybe you just don't support this feature on your critical engine systems ;) Edited by Hodgman
1

Share this post


Link to post
Share on other sites
[quote name='Hodgman' timestamp='1344396469' post='4967232']
[i]<snip>[/i]
[/quote]

You hit the nail right on the head, this is exactly the thing I wanted to experiment with as I too am using specialized allocation schemes in my engine code which may not work too well with this system, and I really don't want to give them up to implement this feature.
I can see the destroying and reallocating resources in memory becoming a problem since I mostly use a contiguous allocation scheme so I can easily group resources of one type into one contiguous chunk of memory (no fragmentation + data-oriented design = happy cache + happy programmer). Cleanup is done in chunks too as it pretty much comes down to rolling back to a base point in memory and calling the appropriate destructors in order, so selective destruction of data is not really recommended - I'm not sure whether this will actually pose a problem, but it's definitely something I need to keep in mind

I would be interested to see this run on consoles, I can imagine it being a major productivity boost if developers can make on-the-fly changes to code running on a console. Edited by Radikalizm
0

Share this post


Link to post
Share on other sites
[quote name='Radikalizm' timestamp='1344410766' post='4967284']I would be interested to see this run on consoles, I can imagine it being a major productivity boost if developers can make on-the-fly changes to code running on a console.[/quote]Lots of companies do this already, but only for procedures, not class-layouts. The PS3 encourages a "[i]job based[/i]" programming model, where your procedures are more separate from your data-layouts than in traditional OOP, so it's not too hard to shoe-horn in code-reloading to systems written this way.
Reloading a DLL ([i]equivalent[/i]) and changing some function-pointers is simple. It's only the reloading of class-layouts ([i]and the implied serialization/deserialization/pointer-patching[/i]) that complicates matters.

As far as I'm concerned, every engine should already be doing this for their ([i]HLSL or equivalent[/i]) shader code and any "script" code ([i]e.g. Lua[/i]) too ;) Edited by Hodgman
1

Share this post


Link to post
Share on other sites
[quote name='Hodgman' timestamp='1344412668' post='4967294']
[quote name='Radikalizm' timestamp='1344410766' post='4967284']I would be interested to see this run on consoles, I can imagine it being a major productivity boost if developers can make on-the-fly changes to code running on a console.[/quote]Lots of companies do this already, but only for procedures, not class-layouts. The PS3 encourages a "[i]job based[/i]" programming model, where your procedures are more separate from your data-layouts than in traditional OOP, so it's not too hard to shoe-horn in code-reloading to systems written this way.
Reloading a DLL ([i]equivalent[/i]) and changing some function-pointers is simple. It's only the reloading of class-layouts ([i]and the implied serialization/deserialization/pointer-patching[/i]) that complicates matters.

As far as I'm concerned, every engine should already be doing this for their ([i]HLSL or equivalent[/i]) shader code and any "script" code ([i]e.g. Lua[/i]) too ;)
[/quote]

I see, interesting. I don't have any experience whatsoever with console development, unless you count XNA + X360 development as console experience, so this is new to me :) Sadly console development is one of those things you can't experiment with on your own...

As for shader and script code my system does in fact allow for runtime editing and recompilation in development builds, just like it allows for on-the-fly editing and reloading of any other type of resource, and you're absolutely right about it being a crucial technique if you ever want to get anything major done.
0

Share this post


Link to post
Share on other sites
[quote name='Radikalizm' timestamp='1344413395' post='4967296']
[quote name='Hodgman' timestamp='1344412668' post='4967294']
[quote name='Radikalizm' timestamp='1344410766' post='4967284']I would be interested to see this run on consoles, I can imagine it being a major productivity boost if developers can make on-the-fly changes to code running on a console.[/quote]Lots of companies do this already, but only for procedures, not class-layouts. The PS3 encourages a "[i]job based[/i]" programming model, where your procedures are more separate from your data-layouts than in traditional OOP, so it's not too hard to shoe-horn in code-reloading to systems written this way.
Reloading a DLL ([i]equivalent[/i]) and changing some function-pointers is simple. It's only the reloading of class-layouts ([i]and the implied serialization/deserialization/pointer-patching[/i]) that complicates matters.

As far as I'm concerned, every engine should already be doing this for their ([i]HLSL or equivalent[/i]) shader code and any "script" code ([i]e.g. Lua[/i]) too ;)
[/quote]

I see, interesting. I don't have any experience whatsoever with console development, unless you count XNA + X360 development as console experience, so this is new to me [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Sadly console development is one of those things you can't experiment with on your own...

As for shader and script code my system does in fact allow for runtime editing and recompilation in development builds, just like it allows for on-the-fly editing and reloading of any other type of resource, and you're absolutely right about it being a crucial technique if you ever want to get anything major done.
[/quote]
I have not really used XNA for 360 but I think there will be a few features the runtime might not expose to keep the writing of game code simple. I am thinking of manually setting which tiles to clear on the backbuffer and setting up tiled based rendering in particular, but I don't know this for sure to be honest.
0

Share this post


Link to post
Share on other sites
I think this feature has nothing to do with visual studio. VS is only here bound to their system to allow for nice editor features. but compilation/link/relaunch is handled by them.
Surely, it cannot work for everything, you cannot modify core code, it must be within precise "plugin" architecture, and surely, like android, there must be a lot of constraints. You mentioned before something about serialization, this is exactly what android requires of all application because they can be killed at any time.
it is easier to rebuild a game logic that says "when space hit then jump" which requires no data, than rebuild the code of the deferred pipeline because it would require rebinding all uniforms, rebuild all render targets etc etc.
But of course, it is still amazing.
0

Share this post


Link to post
Share on other sites
[quote name='Lightness1024' timestamp='1344429724' post='4967370']
I think this feature has nothing to do with visual studio. VS is only here bound to their system to allow for nice editor features. but compilation/link/relaunch is handled by them.
Surely, it cannot work for everything, you cannot modify core code, it must be within precise "plugin" architecture, and surely, like android, there must be a lot of constraints. You mentioned before something about serialization, this is exactly what android requires of all application because they can be killed at any time.
it is easier to rebuild a game logic that says "when space hit then jump" which requires no data, than rebuild the code of the deferred pipeline because it would require rebinding all uniforms, rebuild all render targets etc etc.
But of course, it is still amazing.
[/quote]

You might want to read the slides of their presentation (it's posted at the link I provided), it'll clear some things up about the inner workings ;)
0

Share this post


Link to post
Share on other sites
:) thanks for replies.
but all that seems to me a little scary. trying to maintain heap while rebuilding code in a non-managed/non-interpreted language :s
what happens if a plugin creates a bunch of instances of structure S and we change the content of structure S to a new layout of data we will name S2, then after rebuild, if the runtime tries to access those old instances the code will think to see S2 structures but actually those are S structures in memory. This will corrupt the content and crash if it involves pointers.
how would that be handled ?
0

Share this post


Link to post
Share on other sites
My quick and easy way to achieve something similar is for development purposes, split the game into two applications and have those two applications communicate over a local network connection.

The game application does most of the game stuff, but asset loading & use is separated out to the second application.
The second application does the asset loading, rendering, audio and other things that use large amounts of memory.

Game loads up, runs as it would, calls it's APIs to load in textures/audio/etc. Some of those loads are routed to the second application to load that data.
The game renders, sending a render command buffer to the second application which does the rendering.

This deals with a vast amount of the game data that has to be loaded from disk and keeps it in memory.

The next step is to hold the game data that is needed for game logic in the second application's memory. And then the next step after that is to give the second application a representation of the game's state so that when the game is reloaded it returns to the point in game play it was at when it was terminated.
1

Share this post


Link to post
Share on other sites
[quote name='Kyall' timestamp='1351125984' post='4993612']
My quick and easy way to achieve something similar is for development purposes, split the game into two applications and have those two applications communicate over a local network connection.
[/quote]

That's a pretty good way to do things, especially if you're going to have an multi-player since you likely need the infrastructure anyway. I know a few game developers who've used this technique, and it's worked for them quite well.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0