Skip to main content
GameDev.net gamedev.net
🔒 Locked

Screen flash with IDirect3D9::CreateDevice

Started by zoborg Sep 20, 2007 at 11:54 PM 3 replies 2.1k views
Original Post
zoborg
zoborg
I need to create a d3d device to perform texture loading and conversion. This works fine, except for the fact that when I create the d3d device, my monitor flickers black briefly. This wouldn't be so bad, except that the conversion is done by a command-line tool, and it gets rather annoying to have the screen flicker repeatedly when the tool is run from a batch file. I've tried every combination of arguments to CreateDevice I can think of (that would make sense, anyway). It seems that if I'm using D3DDEVTYPE_NULLREF, in windowed mode, and with no back-buffer, it shouldn't have to reset the gpu (or whatever it is precisely that causes the flicker) - but it does. So, on the off-chance that someone out there has found a work-around for this issue, please let me know. BTW, this is happening with in DirectX 9, with an nvidia quadro fx 3500 video card. I haven't tested it on other machines. Here's the code that exhibits the problem:

IDirect3D9 *d3d = Direct3DCreate9(D3D_SDK_VERSION);

D3DPRESENT_PARAMETERS presentParams;
memset(&presentParams, 0, sizeof(presentParams));
presentParams.BackBufferWidth            = 0;
presentParams.BackBufferHeight           = 0;
presentParams.BackBufferFormat           = D3DFMT_UNKNOWN;
presentParams.BackBufferCount            = 0;
presentParams.MultiSampleType            = D3DMULTISAMPLE_NONE;
presentParams.MultiSampleQuality         = 0;
presentParams.SwapEffect                 = D3DSWAPEFFECT_DISCARD;
presentParams.hDeviceWindow              = 0;
presentParams.Windowed                   = TRUE;
presentParams.EnableAutoDepthStencil     = FALSE;
presentParams.AutoDepthStencilFormat     = (D3DFORMAT)0;
presentParams.Flags                      = 0;
presentParams.FullScreen_RefreshRateInHz = 0;
presentParams.PresentationInterval       = D3DPRESENT_INTERVAL_DEFAULT;

IDirect3DDevice9 *device;
d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_NULLREF, GetDesktopWindow(), D3DCREATE_SOFTWARE_VERTEXPROCESSING, &presentParams, &device);

Nik02
Nik02
Have you tried to explicitly set the backbuffer format to match the current display mode?

The device does some enumeration to determine a suitable backbuffer format if unknown format is requested. This enumeration can cause the driver and d3d itself to stall for a little while.
Niko Suni
Evil Steve
Evil Steve
What do you need a D3D device for? If you're using a null reference device (I'm not sure if you're just using that for testing though) then you can probably do without a device at all.
zoborg
zoborg
Quote:
Original post by Nik02
Have you tried to explicitly set the backbuffer format to match the current display mode?

The device does some enumeration to determine a suitable backbuffer format if unknown format is requested. This enumeration can cause the driver and d3d itself to stall for a little while.



Thanks for the suggestion. Unfortunately, that didn't work. As an experiment, I called GetDisplayMode to find out the precise format I am using, then in a subsequent run used that as the back-buffer format, but the flicker still occurs.

And according to the DX docs, it really should work with D3DMT_UNKNOWN (and does, technically - just with side-effects). This is from the D3DPRESENT_PARAMETERS page:
"In fact, D3DFMT_UNKNOWN can be specified for the BackBufferFormat while in windowed mode. This tells the runtime to use the current display-mode format and eliminates the need to call IDirect3DDevice9::GetDisplayMode."
zoborg
zoborg
Quote:
Original post by Evil Steve
What do you need a D3D device for? If you're using a null reference device (I'm not sure if you're just using that for testing though) then you can probably do without a device at all.


This is a texture conversion tool, and unfortunately, all of the DX texture loading and manipulation routines (e.g. CreateTexture, D3DXCreateTextureFromFileEx, etc.) require a D3D device. I'd gladly do without, but that's not an option.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.