Jump to content
  • Advertisement
Sign in to follow this  
Nene

Error involving rendertarget / createtexture (multi-thread) - MSAA must match

This topic is 3036 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I have set the "D3DCREATE_MULTITHREADED" flag to make D3D thread-safe, in order to load resources while I'm rendering the scene (exactly like Assassin's Creed). However, every now and then I get the following error:

"MultiSampleType between DepthStencil Buffer and RenderTarget must match"

The program breaks always at "mRenderableTex->EndScene( D3DX_FILTER_NONE )" while the aux thread was calling "CreateTextureEx".

The code for the render surfaces is something similar to the following:


class CRenderableTexture
{
public:
void Init()
{
D3DXCreateTexture( mDevice, mWidth, mHeight, mMipLevels, lUsage, mTexFormat, D3DPOOL_DEFAULT, &mTexture );
D3DXCreateRenderToSurface( mDevice, mWidth, mHeight, mTexFormat, true, mDepthFormat, &mRTS );
mTexture->GetSurfaceLevel( 0, &mTextureSurface );
}
void BeginScene()
{
mRTS->BeginScene( mTextureSurface, &mViewPort );
}
void EndScene()
{
mRTS->EndScene( D3DX_FILTER_NONE ) );
}
...
private:
....
ID3DXRenderToSurface* mRTS;
}





Incomprehensibly, this error does not happen using the "d3dx9d.lib" instead of the "d3dx9.lib".

I've tried to make my own critical section both inside CRenderableTexture::BeginScene and before and after CreateTexture, and it works, but then the rendering slows down too much. Here is the code:


void CRenderableTexture::BeginScene()
{
gApp->EnterCriticalSection( CApplicationBase::eCRITICAL_SECTION_D3D );

mRTS->BeginScene( mTextureSurface, &mViewPort );

gApp->LeaveCriticalSection( CApplicationBase::eCRITICAL_SECTION_D3D );
}

...// somewhere in the game parse
gApp->EnterCriticalSection( CApplicationBase::eCRITICAL_SECTION_D3D );

D3DXCreateTextureFromFileEx(...);

gApp->LeaveCriticalSection( CApplicationBase::eCRITICAL_SECTION_D3D );








Please, my team and I are highly frustrared...

Thanks!

[Edited by - Nene on August 22, 2010 3:23:41 PM]

Share this post


Link to post
Share on other sites
Advertisement
The multithreaded flag will use coarse-grained locks to ensure that all access to the device is synchronized, but it's up to you to handle any synchronization required to ensure that the calls themselves happen in the right order. It would seem in your case that the D3DX texture loading function is using the device for a few things, and that's mixing with your render target calls in a weird sequence. Looking at the call stream in PIX would tell you for sure.

Anyway I'm not sure if it's practical for you rethink your approach, but it's something I would recommend doing. Coarse-grained locks are always going to slow things down, and D3D9 doesn't have the facilities required to avoid them. A better approach is to have the worker thread do all of the file I/O required for a texture, since that is where the large bulk of time is spent when loading a new texture. Then the worker thread can put completed file data into a queue that's read by the main thread at the end of each frame, which then does the final step of creating the D3D texture and copying in the data. Or you could even use the D3DX FromMemory functions if you wanted.

Share this post


Link to post
Share on other sites
Great!!! I really appreciate your advice. I will rethink my approach and perform only I/O operations in background as you have said, it seems a perfect idea. Thanks a lot

Share this post


Link to post
Share on other sites
here is the clue ??? "MultiSampleType between DepthStencil Buffer and RenderTarget must match"

this problely point to the shaders sample not matching the current set shader
that is if you have mor then one...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!