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

Well I know the Holly Grail is not a background loading thread($#$@#$%).

3 posts in this topic

Hello all.

I was thinking all my problems solved if I just loaded all my textures and meshes in a back ground
thread then my load bar would render and up date in the main thread. Alas my hopes are dashed,  For an easy ride.

I was wondering if I'm doing it correct.

 

These are the steps
main app init d3d
main  loads menu

main starts new thread running

main renders load bar

background thread lock device loads a block of data, updates the loadbar by its pointer then
leaves the lock sleep(2000) then repeats till no data to load.

 

 

So my thread loads blocks of data at a time between Enter and Leave Calls to the device
But I have a block that has a lot of things(meshes and textures to load) and this lags the main app down.

 

But if I remove the Enter and Leave Calls to the device it loads and does not block but the load time goes from
2 minutes to 4.5 minutes. it takes 2 minutes to load with the locking calls and also 2 minute with no threading used
oh and if I place a lock at the start and then load all data then unlock at the end
the main app is frozen until loading is done 2 minutes.

what should I look at doing
sleep(10); in main after present not do anything but lag 10 ms extra

 

should  I have a Lock and unclock call around all the data

I know you can't do this in the second thread with out a lock
D3D10_PASS_DESC PassDesc;
    Tech->GetPassByIndex( 0 )->GetDesc( &PassDesc );

 

this is how I'm going about getting the device to lock. I'm not even sure if this is correct there is not alot of info on it.
At device create
ID3D10Multithread *mt;
Device->QueryInterface(IID_ID3D10Multithread, (void **)&mt);

backGroundThread()
{
 mt->Enter();
loadbar->Progress(numitems);//this is in main getting rendered as its doing this does it need a lock
   //it can update fine with no locking not sure if I should or not any ideas?????
 load meshes textures anything.
 mt->Leave();

 

Sleep(2000);

mt->Enter();//Big data block = long wait time
loadbar->Progress(numitems);//this is in main getting rendered as its doing this does it need a lock
//it can update fine with no locking not sure if I should or not any ideas?????
load meshes textures anything.
mt->Leave();

do next blcok
}

0

Share this post


Link to post
Share on other sites

Hi. and thanks for the help.

 

Im getting a invalid param only when I place this bit of the code in the back ground thread


ID3D10EffectTechnique *Tech = cFXManager::GetTechnique(0);

//

 

//ID3D10EffectTechnique *Tech = cFXManager::GetTechnique(1);

 

 

// Create the input layout

D3D10_PASS_DESC PassDesc;

ID3D10EffectPass* pass = Tech->GetPassByIndex( 0 );

 

if(pass == NULL)

{

//this does not print when in back ground thread???????? and the break points don't work

OutputDebugString("NULL PASS, PSystem Failed GetPassByIndex");

MessageBox(NULL,

" PSystem Failed GetPassByIndex", "InitDevice", MB_OK);

 

return;

}

//error

HRESULT hr = pass->GetDesc( &PassDesc );

//sometimes passes and other time it fails

if( FAILED( hr ) )

{

std::stringstream ss;

ss <<

"PSystem Failed GetPassByIndex GetDesc\nHRESULT HR = ";

ss << hr;

ss <<

"\n";

OutputDebugString(ss.str().c_str());

MessageBox(NULL,ss.str().c_str(),

"InitDevice", MB_OK);

 

return;

 

}

 

hr = md3dDevice->CreateInputLayout( ParticleVertex::VertexParticleLayout, ParticleVertex::GetNumElements(), PassDesc.pIAInputSignature,

PassDesc.IAInputSignatureSize, &mpVertexInputLayout );

 

 

 

if( FAILED( hr ) )

{

fails here all the time(unless I use Sleep(20) in the main Apps Render) invalid Param 3rd param, only when I dont place a device->enter() before it

}

 

 

 

the thing is that other parts of the loading code has the same type code and it all passes.

jut this one needs the lock placed before I can enter it to stop failing.

 

conclusion you must design your app from the start to be threaded so you don't have code that uses map and fx in the loading thread(bugger).

 

The back ground thread runs slower then it does if the code was just loaded in the main app. Reason is that the device is in use in the main apps thread doing rendering.

and if I place a Sleep(20); in the main apps render function the load time is cut down by 1 minute, I don't like doing this but Its only going while the apps in the menu system anyway.

 

other then the above bit of code its working ok for a hack.

 

 

Nope just looking over my code while writting this and I see ID3D10EffectTechnique *Tech = cFXManager::GetTechnique(0); This Is my bit of code and

it's being used in both threads at the same time hehehe.

I think I need a lock on that class only, I'll Go and setup a mutex on the FX Class and see what I get.

 

One question is How Do I lock the whole class do I lock function calls or variables, so research need I think. Now this in going to be a under taking

I never liked my fx class anyway I made the misstake of putting all my shaders in on class even the ones that are not used in the app and they all get to load and compile

before I can use the class. Im thinking I will need to redesign this class to only load shaders I want in any app and to multi thread safe it.

Well I'll be seeing you all in a month or more lol. thanks for the help.

 

any suggestions. Other then whipping my self and putting salt on the wound.

Edited by ankhd
0

Share this post


Link to post
Share on other sites

Ok.

 

I only needed to create a new GetTechnique(fxtype, 0);the old one was changeing my FXClass currentState to the new state. Now it just gets the state it needs and leave class in its set state;

which will lead to me being able to load only the shaders I need per app.

 

My FX class is a lot more modular then I thought it was.

 

So now I can Remove all the devices Enter() and Leave() in the loading code, and let the device do its fantastic job. I salute the creaters of the device Because I just Thrashed the hell out of it and it held up hu.

 

But I needed a Sleep still this is ok its only in the ui system it was running a 6ms per frame not its 26

but the 4.5 minute load time is down to 2.3 minutes I can Live with this.

 

the only thing is you have to wait for the loading any way because it only takes a minute to create an new game but it gets hidden when the game starts its loading.

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