   Device.Present() efficiency
  I recently noticed I was getting very choppy performance on a simple Managed DirectX app while running windowed. The program only has to draw half a dozen polygons and some text, so it didn't seem quite right. So using the DXUtil timer, I tested it. In both of the following graphs, the red points represent time spent on drawing operations (everything from Device.BeginScene() to Device.EndScene()), the green points represent the time taken by Device.Present(), and the blue points are the rest of the time.windowed:fullscreen:I think it's clear where the problem is :) you can't really see on the graph, but the shortest amount of time that Device.Present() takes for the windowed app is about the same as the amount of time it almost always takes for the fullscreen.So, I was curious if anybody had an idea what might cause such huge variance in the amount of time that Device.Present() takes. I was thinking it could be that the backbuffer size or format was wrong or something like that, but I haven't been able to figure it out yet. In case it'll help, here's my setup code://Create presentation parameterspres=new PresentParameters();pres.SwapEffect=SwapEffect.Discard;pres.AutoDepthStencilFormat=DepthFormat.D16;pres.Windowed=windowed;if (!windowed) {width=pres.BackBufferWidth=640;height=pres.BackBufferHeight=480;pres.BackBufferFormat=Format.X8R8G8B8;} else {width=pres.BackBufferWidth=ClientSize.Width;height=pres.BackBufferHeight=ClientSize.Height;pres.BackBufferFormat=Format.X8R8G8B8;}pres.BackBufferCount=1;//Get some hardware capsCaps hardware=Manager.GetDeviceCaps(0,DeviceType.Hardware);CreateFlags flags=CreateFlags.SoftwareVertexProcessing;//Default createflags//Use hardware vertex processing if availableif (hardware.DeviceCaps.SupportsHardwareTransformAndLight) {flags=CreateFlags.HardwareVertexProcessing;if (hardware.DeviceCaps.SupportsPureDevice) flags|=CreateFlags.PureDevice;}//Turn off event handlersDevice.IsUsingEventHandlers=false;//Create the device and hook its eventsdevice=new Device(0,DeviceType.Hardware,this,flags,pres);device.DeviceReset+=new EventHandler(onDeviceReset);Thanks everyone :)   
  Actually, drawing doesn't take place between BeginScene and EndScene. Instead commands are added to a queue (highly generalized description mind you), which are then executed. Present needs to wait for those commands to finish executing, so it just appears to take a long time.What does interest me of those two graphs are the spikes in Present(), they happen on a fairly regular interval, shich would suggest that something is happening at an almost even rate of occurance that is stalling out present...PS: When posting graphs, PLEASE make them large enough to read.Oh and set the PresentationInterval to PresentInterval.Immediate (this is always available)   