• Advertisement
Sign in to follow this  

[D3D9] problems creating device on certain hardware

This topic is 3671 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi DX-guru's :) I have some problems with my engine. It works on most machines but two people reported errors. I saw that it had to do with the D3D.CreateDevice() call. It returned: ERROR_NOT_READY & DIERR_NOTINITIALIZED. At least that's what DXGetErrorString9() returned when i passed the CreateDevice result to that function. I Googled alot bot i couldn't find any relation between these errors and CreateDevice(). Can anyone give me a clue on how to get rid of this error? Is it a driver problem or should i start worrying about my engine's code?? Thanx in advance.

Share this post


Link to post
Share on other sites
Advertisement
Those two errors emitted at once mean the object in question has not been initialised.

AFAIK, for the device, that implies a hardware/driver problem. It's certainly a serious error; most likely an unrecoverable, exceptional case as far as your engine is concerned.

In short, there's not much you can do.

Share this post


Link to post
Share on other sites
DIERR_NOTINITIALIZED implies that your problem is actually related to DirectInput, not Direct3D.

Share this post


Link to post
Share on other sites
Thanx very much for your replies. =D

I understand that the prefix DIERR_ means that it's related to DirectInput, but why on earth does CreateDevice return such a value?? It doesn't make any sense.

Is there anything a user can do, if he/she get's this kind of messages when running the engine??

Thanks again.

Share this post


Link to post
Share on other sites
Quote:
Original post by chronozphere
I understand that the prefix DIERR_ means that it's related to DirectInput, but why on earth does CreateDevice return such a value?? It doesn't make any sense.
It can't. It sounds like the value you're getting is wrong. Can we see the relevant code?

Quote:
Original post by chronozphere
Is there anything a user can do, if he/she get's this kind of messages when running the engine??
If this is for an error message, I'd suggest requesting that they get the latest video card drivers, but aside from that, there's nothing the user can be expected to do.

As for debugging the problem; you could check the card caps spreadsheet (Which comes with the SDK) and see if there's any common problems with the cards in question. Also, double and triple check that you're checking the card can do something before assuming it can. If it's failing at CreateDevice, the following are things that you need to check (Offhand):
  • If you're using hardware vertex processing that the card supports hardware vertex processing (Is a GeForce 2 or above)
  • That the card supports the requested backbuffer format, given the adapter format (Current mode if you're running windowed, or requersted mode if you're running fullscreen)
  • That the requested depth buffer format is acceptable for the given backbuffer and adapter format
  • That the requested texture format is usable

    There's probably others too, take a look at some of the SDK samples and see what they do.

    Share this post


    Link to post
    Share on other sites
    It's pascal source. Hope you don't mind. ;)


    //Initialize the graphics core
    function TN2D_Graphic.Initialize(Window: HWND;
    DisplayMode: TN2D_DisplayMode): cardinal;
    var i, AdapterCount: integer;
    IsDisplaySupported: boolean;
    d3ddm: TD3DDisplayMode;
    VTXProcessing: cardinal;
    P: TRect;
    begin
    Finalize;

    Logger.Msg('Initializing Graphics....');

    //Store displaymode in graphics class
    fDisplayMode := DisplayMode;

    // Create the D3D object, wich is needed to create the D3DDevice.
    fD3D := Direct3DCreate9(D3D_SDK_VERSION);
    Result := Logger.Errorif((fD3D = nil),
    E_DIRECT3D,'Direct3d could not be initialized.');
    if Result <> 0 then Exit;

    //retrieving hardware capabilities
    Result := Logger.ErrorDX( fD3D.GetDeviceCaps(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,fCapabilities),
    E_DIRECT3D,'Could not retrieve device capabilities.');
    if Result <> 0 then Exit;


    Logger.Msg('Checking for hardware acceleration....');
    if fCapabilities.VertexProcessingCaps <> 0 then
    begin
    Logger.Msg('--> A hardware accelerated device was found!');
    VTXProcessing := D3DCREATE_HARDWARE_VERTEXPROCESSING
    end else begin
    Logger.Warn('--> No hardware accelerated device was found!');
    VTXProcessing := D3DCREATE_SOFTWARE_VERTEXPROCESSING;
    end;

    //check capabilities
    Logger.Msg('Checking hardware capabilities...');
    if (fCapabilities.MaxTextureWidth < 1024) or
    (fCapabilities.MaxTextureHeight < 1024) or
    (fCapabilities.MaxPrimitiveCount < 16384) or
    (fCapabilities.MaxTextureRepeat < 512) then //square only textures
    begin
    Result := logger.Error(E_DEVICE_INCAPABLE,'Your videohardware is incapable of running NashaENGINE.' );
    Exit;
    end;


    //Initalize display mode and present paramters
    Logger.Msg('Validating display mode...');
    ZeroMemory(@fd3dpp, SizeOf(fd3dpp));
    if DisplayMode.FullScreen then //windowed mode
    begin
    fShowCursor := false;

    //walk through 32bit displaymodes, to check whether the displaymode is supported
    IsDisplaySupported := False;
    AdapterCount := fD3D.GetAdapterModeCount(D3DADAPTER_DEFAULT,D3DFMT_X8R8G8B8);
    for i:=0 to AdapterCount-1 do
    begin
    Result := Logger.ErrorDX(
    fD3D.EnumAdapterModes(D3DADAPTER_DEFAULT,D3DFMT_X8R8G8B8,i,d3ddm),
    E_DIRECT3D,'Error while enumerating display-modes' );
    if Result <> 0 then Exit;


    if (d3ddm.Width = DisplayMode.Width) and (d3ddm.Height = DisplayMode.Height) then
    begin
    IsDisplaySupported := True;
    Break;
    end;
    end;

    Result := logger.ErrorIf((not IsDisplaySupported),
    E_DISPLAYNOTSUPPORTED, 'DisplayMode not supported.' );
    if Result <> 0 then exit;

    fd3dpp.hDeviceWindow := Window;
    fd3dpp.Windowed := False;
    fd3dpp.BackBufferWidth := DisplayMode.Width;
    fd3dpp.BackBufferHeight := DisplayMode.Height;
    fd3dpp.BackBufferFormat := D3DFMT_A8R8G8B8;
    fd3dpp.SwapEffect := D3DSWAPEFFECT_DISCARD;
    fd3dpp.EnableAutoDepthStencil := True;
    fd3dpp.AutoDepthStencilFormat := D3DFMT_D16;
    fd3dpp.PresentationInterval := D3DPRESENT_INTERVAL_IMMEDIATE;
    //fd3dpp.FullScreen_PresentationInterval := D3DPRESENT_INTERVAL_ONE;
    end else begin
    fShowCursor := true;

    ZeroMemory(@d3ddm,SizeOf(d3ddm));
    fD3D.GetAdapterDisplayMode(D3DADAPTER_DEFAULT,d3ddm);

    //if the width or height is zero, take the dimentions from the form
    GetClientRect(Window,P);
    if fDisplayMode.Width <= 0 then fDisplayMode.Width := P.Right - P.Left;
    if fDisplayMode.Height <= 0 then fDisplayMode.Height := P.Bottom - P.Top;

    fd3dpp.hDeviceWindow := Window;
    fd3dpp.Windowed := True;
    fd3dpp.BackBufferWidth := fDisplayMode.Width;
    fd3dpp.BackBufferHeight := fDisplayMode.Height;
    fd3dpp.BackBufferFormat := d3ddm.Format;
    fd3dpp.SwapEffect := D3DSWAPEFFECT_DISCARD;
    fd3dpp.EnableAutoDepthStencil := True;
    fd3dpp.AutoDepthStencilFormat := D3DFMT_D16;
    fd3dpp.PresentationInterval := D3DPRESENT_INTERVAL_IMMEDIATE;
    fd3dpp.MultiSampleType := D3DMULTISAMPLE_NONE;
    end;

    Logger.Msg('Creating device....');

    // Create the Direct3D device
    Result := logger.ErrorDX(
    fD3D.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, Window,VTXProcessing,
    @fd3dpp, fD3DDevice),
    E_DIRECT3D_INIT,'Direct3d-Device could not be initialized.');
    if Result <> 0 then Exit;

    //hookup window
    if FWindowHandle <> Window then
    begin
    FWindowHandle := Window;
    FOldWndProc := Pointer(GetWindowLong(FWindowHandle, GWL_WNDPROC));
    SetWindowLong(fWindowHandle, GWL_WNDPROC,
    Integer({$IFDEF VER150}Classes.{$ENDIF}MakeObjectInstance(WndProc)));
    end;

    SetDeviceStates;

    CreateInternalVertexbuffer;

    //set internal vertexbuffer as default
    Device.SetStreamSource(0,fVertexBuffer,0,Sizeof(TShapeVertex));
    Device.SetFVF(SHAPEVERTEX);
    LastItemRendered := nil;

    //set cursor visibility
    Device.ShowCursor(fShowCursor);

    logger.Msg('Initialization succesfull.');
    logger.blank;
    fInitialized := True; //Initialization was succesfull
    Result := E_OK;
    end;


    The ErrorDX routine:


    function TN2D_LogFile.ErrorDX(HR: HResult; ErrConst: cardinal;
    Msg: string): cardinal;
    begin
    if not Failed(HR) then
    begin
    Result := 0;
    Exit
    end else begin
    Result := ErrConst;
    fLastError := ErrConst; //save error code

    AddString('DXERR: --> '+DXErrorToString(ErrConst));
    if Msg <> '' then
    AddString(' --> '+Msg);
    end;
    end;

    function TN2D_LogFile.DXErrorToString(Error: HResult): string;
    begin
    Result := DXGetErrorString9(Error);
    end;


    And about the hardware on which it failed:

    > WinXP, SP2, ATI Radeon 9600, Latest catalyst drivers.
    > Vista, Geforce 8800 GT, latest drivers v169.44.

    Quite good hardware i suppose. :/

    Share this post


    Link to post
    Share on other sites
    Sign in to follow this  

    • Advertisement