Jump to content
  • Advertisement
Sign in to follow this  
renman29

UpdateSurface works 95% of the time?

This topic is 4054 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

Updatesurface is working most of the time, but every so often the computer will freeze up and I'll need to reboot. If I comment out the UpdateSurface function, it never crashes. The strangest thing is, it seems like, if my texture array has more than one texture in it, and I'm updating any of the other textures aside from the first one - then it works fine and never locks up... Here's some of my code(maybe someone can spot something obvious):
LPDIRECT3DTEXTURE9* g_proto_textures		= NULL;
//....
g_gpu->CreateOffscreenPlainSurface(g_texture_width, g_texture_height,
    g_common_format, D3DPOOL_SYSTEMMEM, &g_render_target_data, 0);

g_proto_textures = new LPDIRECT3DTEXTURE9[n_objects];

a=0; do {
D3DXCreateTexture(g_gpu, g_texture_width, g_texture_height,1,
    D3DUSAGE_RENDERTARGET, g_common_format, D3DPOOL_DEFAULT,
    &g_proto_textures[a]);
a++; }while(a<n_objects);

//...

//[create new depth stencil surface here]
a=0; do {
LPDIRECT3DSURFACE9 surface_x=NULL;
g_proto_textures[a]->GetSurfaceLevel(0,&surface_x);
g_gpu->SetRenderTarget(0,surface_x); g_gpu->SetViewport(&vp);
//...
//[draw to surface stuff]
//...
SAFE_RELEASE(surface_x);
a++; }while(a<n_objects);
//[release the depthstencil surface...set it back to the old one]
//[set the render target back to back buffer]

//...
///bla bla bla
//...

//[modify surface function]
//..
IDirect3DSurface9 *rt_surface = NULL;
D3DLOCKED_RECT lr_a;

g_proto_textures[obj]->GetSurfaceLevel(0,&rt_surface);
g_gpu->GetRenderTargetData(rt_surface,g_render_target_data);

g_render_target_data->LockRect( &lr_a, NULL, 0);
DWORD *new_pixel = static_cast<DWORD*>(lr_a.pBits);
g_render_target_data->UnlockRect();
new_pixel[pixel_offset]=0xffff0000;

REPORT("Updating surface...")
if (FAILED(g_gpu->UpdateSurface(g_render_target_data,NULL,rt_surface,NULL)))
   {FatalError(L"Failed to update surface for render target data.");}
REPORT("UpdateSurface succeeded.")

SAFE_RELEASE(rt_surface)
//...

Source surface: D3DPOOL_SYSTEMMEM Destination: D3DPOOL_DEFAULT I don't think either surface is locked. I think CreateTexture uses D3DMULTISAMPLE_NONE with render targets... Both surfaces are the same dimensions(1024x1024) (&format) I basically just want to be able to modify my render target textures without crashing. Any kind of ideas at all are totally welcome! :)

Share this post


Link to post
Share on other sites
Advertisement
A lock up may be a sign of a driver issue. Have you tried the reference device? If it works with the ref device then it's possibly a hardware issue. What does the debug output tell you when you run your app?

Share this post


Link to post
Share on other sites
I think...I hope I just fixed the problem. I found out it actually wasn't driver related (thank goodness) and debug thought nothing's wrong - which was weird.
This is going to seem very strange - but somehow my object clipper was causing problems that didn't show up until making a call to UpdateSurface.
At least, right now - I know that if I turn it off - everything works fine.
Thanks for the advice! (^-^)

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!