I have encountered this strange problem with directx. I'm wiriting the graphic engine of a simple game. It works fine on my amd-600 with 32 mb of video mem, and also on a pII-350 witha vodoo3. When i try it on slower pc (a pentium 120 with 1 mb of video mem), it runs perfectly the first time, but the second time it can't allocate the primary surface (it returns SUrface Busy)..IF eax == hWnd mov , sizeof DDSURFACEDESC mov , DDSD_PITCH .WHILE 1 DDSINVOKE mLock, lpDDSPrimary, NULL, ADDR ddsd, DDLOCK_WAIT, NULL .BREAK .IF eax == DD_OK .IF eax == DDERR_SURFACELOST DDSINVOKE Restore, lpDDSPrimary .ELSE FATAL "Couldn't lock surface" .ENDIF .ENDW DDINVOKE WaitForVerticalBlank, lpDD, DDWAITVB_BLOCKBEGIN, NULL call reender_map DDSINVOKE Unlock, lpDDSPrimary, ddsd.lpSurface .ENDIF .ENDIF .ENDW escidd:: .if logined DDINVOKE RestoreDisplayMode, lpDD .IF eax != DD_OK FATAL "Couldn't restore displaymode" .ENDIF INVOKE DestroyWindow, hWnd .IF eax == NULL FATAL "Couldn't destroy window" .ENDIF .IF lpDD != NULL .IF lpDDSPrimary != NULL DDSINVOKE Release, lpDDSPrimary mov , NULL .ENDIF DDINVOKE Release, lpDD call unload_tiles mov , NULL .ENDIF mov logined, FALSE .endif Do you know what's the problem? Thanks
Posted on 2001-05-27 14:43:00 by /new/
Hi welll take care not to use a feature of Directdraw that is NOT supported on ALL boards (esp on older boards) like WaitForVerticalBlank....docs say you have to check if this feature is available on a specific board. And also you are playing with fire by keeping a surface so much time "locked" usually when a surface is locked for direct access to its video memory a lot of other functions are unavailable or return "busy" until you unlock the surface ;) this also takes a mysteriouse GDI Mutex16 that further slows down the system... so i recomend a fast sequence: 1.Lock() 2.do your manual work as fast as possible on a surface 3.Unlock ASAP Another problem with a board with so little memory (1M) is the size that surfaces ocuppies (more then width*height because of Pitch) this combined with tiny errors in alocation / dealocation sequences can eat up fast such a small memory (leaks) but never show on a 32M Video RAM until you play the game 100 times ;)
Posted on 2001-05-27 23:11:00 by BogdanOntanu