• 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

Some questions about multithreading

3 posts in this topic

So I'll jump from first time into the world of multiprogramming!
I'm not here to ask the general questions about the thread safety.. after all the internet is full of information.
I want to ask how shoud I make the renderer... I currently have a scene graph which is only accessed by the renderer by default. (I'm jsut passing the scene graph to the renderer and it will do it's job. Or I can also just iterate through it and call renderer->DrawMesh(this/iterator);
So my question is, shoud I make a queue and jsut queue what is for drawing and whats not? I don't like this options cuz its actaully useless. After all thats what is done in the video card...
OR I shoud make an active thread, which is non-stop iteration by iteself in the scene graph and rendering it?. ANd where shoud I put the window creation. In the rendering thread? OR I shoud create the window in main thread and pass the handle so I can create the d39 device?
Any other advices I missed to ask for and you think they will be useful for me?

Share this post

Link to post
Share on other sites
Rendering in the main thread is usually the best option (since you have your window there and stuff). That way, you don't have to share the graphics API resources. I would recommend using separate threads only for computation-heavy and independent tasks, e. g. physics. Otherwise, multithreading just brings problems and doesn't speed up the tasks much.

Share this post

Link to post
Share on other sites
I've read you post couple of times and it's a bit incoherent. Could you elaborate a lot, like what you've done, or planning to do?

IMO abstracted scene graphs are not practical. It is much more easy to have multiple typed object spatial trees.

Lets talk about 4 core CPU on D3D11. Multithreaded 3d graphics takes a lot of discipline. First, you only make so many threads the current CPU has cores, the worker threads. You dont want context switches. Some physics and audio libraries spawn own threads, so you end up with more threads than cores in the process. Then you build the engine on tasks. Tasks will have dependecies to other tasks. Update task must become before frustum culling task for lights, before shadow rendering task, which must become before lighting pass where the shadow is used. But you can render G-buffer simultaneusly, just after the update task. There will be a task scheduler, which feeds the taks to queues. Main thread will create the window, schedule tasks and add couple synchronization points.

It's efficient to have 4 task queues, one per thread, consumers (worker threads) does not need locking for fetching tasks. If the dependencies are correct, there is no need for synchronization (mutexes or lockfree) for any data access. When the queues are populated with tasks for the frame, main thread can join work (you only need 3 threads plus main). Most important thing is to make your codebase more functional, and all the shared data must be made immutable. I assure you, you can make 32 core multithreaded d3d11 graphics engine with 0 mutexes, no lock-free code (lock-free will trash all cache), which keeps all cores fully utilized.

Ofcourse I'm only talking about using deferred ID3D11DeviceContext. It just emulates the multithreading for commands you feed it, you could very well create own mechanism for it. The graphics driver will play back all the commands sequantially anyway. (though the driver has like 3 frames worth of commands to keep GPU busy, say thousands of draw calls queued up)

But one doesnt always need to multithread. If you spam the D3D API with single thread, some graphics drivers are multithreaded, and they will spread the load (assuming one can push the bottleneck/load to the driver).

Share this post

Link to post
Share on other sites
Sorry for reading my post. I actually had many things to do at this time and didn't pay much attention to my question.
Your post answered most of my questions. Thank you.
[quote]Lets talk about 4 core CPU on D3D11.[/quote]
First of all, I'm using direct3d9. My video card does not support DX11 ;).
[quote]IMO abstracted scene graphs are not practical. It is much more easy to have multiple typed object spatial trees.[/quote]
My plan was actually to start with a scene graph and turn it in BSP tree, or something like this.

So what I understood is:
1. I don't need rendering thread. Main thread would be able to do the job.
2. I need just worker threads. Each with each own task queues.[list]
[*]File loading thread. Loads and decopress files and put the in the memory.
[*]Asset Manager. Use the already loaded files and create engine objects which can be used in real code directly. (teapot.obj -> Mesh). A question: how can i create a buffer in this thread? Do i need second d3d9 device or the function is multithreaded.
These are the threads I'm thinking about right now. I actually have no idea how can I split the physics in another thread. Won't I spam the queue with too many messages?
So... I'll put everything in the main thread except the file related tasks.

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