GDI surfaces, GDI heap and wined3d's VideoMemorySize

Robert Shearman rob at codeweavers.com
Mon Feb 26 10:35:21 CST 2007


Rok Mandeljc wrote:
> Hey all,
>
> I've been experiencing an odd behavior in Baldur's Gate 2; when
> "VideoMemorySize" registry key for wined3d is set to anything greater
> than 64MB (69MB, actually), it stops before playing intro movie,
> printing following line:
> err:clipping:CLIPPING_UpdateGCRegion hVisRgn is zero. Please report this.
>
> Tracing the source of issue by inserting custom traces I got the following:
> IDirectDrawImpl_CreateNewSurface -> IWineD3DDeviceImpl_CreateSurface
> (decides to use GDI surface) -> IWineGDISurfaceImpl_PrivateSetup ->
> IWineD3DSurfaceImpl_GetDC ->
> CreateCompatibleDC -> CreateRectRgn -> REGION_CreateRegion ->
> GDI_AllocObject -> alloc_large_heap
>
> alloc_large_heap fails because it can't find next large handle and
> returns NULL, which is passed up the chain, where CreateCompatibleDC
> puts it in dc->hVisRgn. Then DC_InitDC is called with that dc, which
> calls CLIPPING_UpdateGCRegion, and that one finally chokes on it,
> printing afore-mentioned line and calling exit(1).
>
> Now, when the game is run with 64MB of VideoMemorySize, upon reaching
> the same point, IDirectDrawImpl_CreateNewSurface returns
> WINED3DERR_OUTOFVIDEOMEMORY (because of
> "IWineD3DDevice_GetAvailableTextureMem(iface) <= _size" check in
> D3DCREATERESOURCEOBJECTINSTANCE macro) and intro movie starts playing.
> So it seems Baldur's Gate 2 is trying to create as many surfaces as
> possible before running out of memory. And the problem arises when
> specified memory size is large enough to take up all GDI's heap...
>
> Sorry for the long-winded description of the problem, but I'm not sure
> where and how this should be fixed (is it wined3d issue or should GDI
> have its heap enlarged?), otherwise I'd do it myself...
>   

CreateCompatibleDC should be made to fail if the CreateRectRgn call fails.

-- 
Rob Shearman




More information about the wine-devel mailing list