• 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
Ripiz

[C++]Strange issue related to multithreading

6 posts in this topic

Hello,

Firstly, I'd like to say sorry if this is wrong forum, as issue might be related to Visual Studio.

I am using Win8 x64, Visual Studio 2012, DirectX 11 with feature level 10.0. I have 2 threads: main thread and rendering thread. Main thread initializes window, DirectX and starts rendering thread. Rendering thread is simple:
[CODE]
while(true) {
for(auto &entity : renderList) {
//...
}
present();
}
[/CODE]
While all resource loading is handled by main thread.

When I run the program it works fine, however when I attach Visual Studio's Graphics Debugger calling IASetIndexBuffer causes crash with similar debug output:
[CODE]
D3D11 CORRUPTION: ID3D11DeviceContext::IASetIndexBuffer: First parameter is corrupt. [ MISCELLANEOUS CORRUPTION #13: CORRUPTED_PARAMETER1]
First-chance exception at 0x77037945 (KernelBase.dll) in FxdTmStpTest.exe: 0x0000087D (parameters: 0x00000000, 0x04EEDB64, 0x04EECF9C).
Unhandled exception at 0x77037945 (KernelBase.dll) in FxdTmStpTest.exe: 0x0000087D (parameters: 0x00000000, 0x04EEDB64, 0x04EECF9C).
[/CODE]
I suspect it happens because I create that index buffer on other thread than it's used at.

This issue happens on Debug x86, Debug x64 builds, however Release x64 build has no issues (I am unable to try Release x86 because of unaligned SIMD data).

If anyone has any clues what's wrong please let me know. Thank you in advance.
0

Share this post


Link to post
Share on other sites
I also do some multithreaded loading and the graphics debugger crashes on it, perhaps a bug in the debugger itself, looks like it doesn't support multithreading
0

Share this post


Link to post
Share on other sites
the debuglayer allways work for me when i am using multithreading.

when it comes to multithreading, make sure you never let more than one thread read/write at the same time.
Even if this sounds like "that would never happen", assume it will!

that might not fix your problem, but it´s a start to work with.

it could aswell be that you have created some of your buffer wrong, or that you are trying to use them in a invalid way.
0

Share this post


Link to post
Share on other sites
I am unsure if I need any synchronization between ID3D11Device and ID3D11DeviceContext as they're on different threads. Right now I have no synchronization between them, could that be an issue? I thought DirectX synchronizes it automatically, since there is flag related to singlethreading (D3D11_CREATE_DEVICE_SINGLETHREADED), which I'm not using.

As for data between threads, I use [i]concurrency::concurrent_vector[/i] from [i]<concurrent_vector.h>[/i].
Roughly my code looks like this:
[CODE]
// Scene class's field
concurrency::concurrent_vector<Entity*> entities;

// Scene::createEntity(). This is executed on Main Thread (thread1)
Entity *entity = new Entity();
entity->indexBuffer = DirectX::createIndexBuffer(...);
entity->vertexBuffer = DirectX::createVertexBuffer(...);
entities.push_back(entity);

// This is executed on Rendering Thread (thread2)
for(auto &entity : entities) {
// any entities here will have index and vertex buffer created
// unless they're not actually created right away and I have to wait till some event
}
[/CODE]

Note: As I said in original post, it crashes only when I'm using Visual Studio's Graphical Debugger. Running it normally or in Debug mode doesn't cause any crashes or warning in the output. Edited by Ripiz
0

Share this post


Link to post
Share on other sites
if you have main thread that alters data that render thread uses, BE AWARE. google "lock" key word. In other words, change memory of thread A only in thread A. Else you will have to synchronize.
0

Share this post


Link to post
Share on other sites
I've not used [font=courier new,courier,monospace]concurrent_vector[/font], but assuming you're not editing the entities after creation, that looks safe. I'm stumped.
How does the "[i]unless they're not actually created right away and I have to wait till some event[/i]" bit work?
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