sharpdx / SharpDX-Samples

Official repository for all SharpDX Samples
346 stars 222 forks source link

Some problems make FPS too high #48

Open Hatsusakura6487 opened 7 years ago

Hatsusakura6487 commented 7 years ago

I tried Direct3D11DemoApp and found a problem. Normal operation FPS will exceed 8000 or even close to 10000. But Direct2D1WinFormDemoApp is running normally, FPS is very stable at 60. I tried to render some objects, the result is rendering is normal, but FPS is still too high, close to 4000. So...Where is the problem?

xoofx commented 7 years ago

FPS is stable only if you are using for example a DXGI swapchain with a Present that explicitly says that you want to wait a frame (the old "VTBL"). Otherwise can't make any diagnostics from your issues, it could be also either that you are calculating FPS in a wrong way...

Bottom line, unlikely an issue in SharpDX.

Hatsusakura6487 commented 7 years ago

I'm using Fraps to view the fps... new ModeDescription(demoConfiguration.Width, demoConfiguration.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm) I checked this place but the frame rate was set correctly... Is it possible that this code doesn't work? Or is there a problem with my hardware or software settings? I feel that there is no successful initialization ...

Hatsusakura6487 commented 7 years ago

I think I found the problem. I set a breakpoint after the initialization function, and found in the variable factory(SharpDX.DXGI.Factory) and variable _swapChain(SharpDX.DXGI.SwapChain) there are some error messages.

factory.Adapters[0].Description correctly shows my graphic card, and factory.Adapters[0].Outputs[0].Description also correctly shows my monitor. But factory.Adapters[0].Outputs[0].FrameStatistics threw an exception of type 'SharpDX.SharpDXException': HRESULT: [0x887A0001], Module: [SharpDX.DXGI], ApiCode: [DXGI_ERROR_INVALID_CALL/InvalidCall]

_swapChain.FrameStatistics threw an exception of type 'SharpDX.SharpDXException': HRESULT: [0x887A0004], Module: [SharpDX.DXGI], ApiCode: [DXGI_ERROR_UNSUPPORTED/Unsupported]

I think that this error has led to a problem with FPS... But I do not know how to fix this error... So how do we fix the error?

xoofx commented 7 years ago

debugging objects via the debugger can throws error when inspecting properties. That's unrelated.

But in your code, if you have try/catch, and your code while running is throwing errors, it will modify the FPS... but usually it will slow it down.

Again, your problem is elsewhere, an invalid setup of the rendering, usage of present, and without any details about your code, I can't make any diagnostics.