Original Post
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: Thanks everyone :)
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 parameters
pres=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 caps
Caps hardware=Manager.GetDeviceCaps(0,DeviceType.Hardware);
CreateFlags flags=CreateFlags.SoftwareVertexProcessing; //Default createflags
//Use hardware vertex processing if available
if (hardware.DeviceCaps.SupportsHardwareTransformAndLight) {
flags=CreateFlags.HardwareVertexProcessing;
if (hardware.DeviceCaps.SupportsPureDevice) flags|=CreateFlags.PureDevice;
}
//Turn off event handlers
Device.IsUsingEventHandlers=false;
//Create the device and hook its events
device=new Device(0,DeviceType.Hardware,this,flags,pres);
device.DeviceReset+=new EventHandler(onDeviceReset);