Results 1 to 4 of 4

Thread: [D3D] non-zero reference count. what's the sollution??

  1. #1

    [D3D] non-zero reference count. what's the sollution??

    Hello everyone..

    OS: Vista Ultimate
    IDE: Delphi 7
    API: Clooites DirectX SDK April 2007

    I've installed Clootie's DX 9 SDK and i am trying to run a sample.
    But it keeps saying that the D3D Device has a non-zero reference count.

    This might be because i had tried that sample before but it failed because a DLL was not found (wich i have downloaded now). The D3D device refcount has probably been increased and now i cant run the sample again.

    Off course, when you reboot your PC and try again, it WILL run. but is there a easier way of fixing this?? When i'm debugging or playing with the samples, its very annoying to have to reboot your PC a couple of times. It's even more annoying when you are trying to download something big. :lol:

    Does anyone knows an easy way to fix it?? :?

    Thank you.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  2. #2

    [D3D] non-zero reference count. what's the sollution??

    Aarrrghh.... even rebooting doesn't help when using Vista. :x

    Does someone know a way of resetting the whole thing so i can use the BasicHLSL sample. The problem only occures when using THAT sample so i guess vista keeps track of the D3D device refcount for each application. :? Is there a way to reset that?, because it's driving me mad.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  3. #3

    [D3D] non-zero reference count. what's the sollution??

    I suppose you downloaded media files or placed Delphi samples in preinstalled MS DX SDK? So all DDS/X files required by sample are in place?
    There are only 10 types of people in this world; those who understand binary and those who don't.

  4. #4

    [D3D] non-zero reference count. what's the sollution??

    AFAIK my media files are placed correctly. (Clootie DX 9/Samples/Samples/Media).
    The other samples work correctly so i guess there is nothing wrong with the media.

    I tried to debug the application and i found out the following.

    The OncreateDevice callback in the BasicHLSL unit failed.
    This is because following call failed too:

    [pascal]
    Result := CDXUTDirectionWidget.StaticOnCreateDevice(pd3dDevi ce);
    [/pascal]

    I continued and found out the following:

    [pascal]
    class function CDXUTDirectionWidget.StaticOnCreateDevice(
    pd3dDevice: IDirect3DDevice9): HRESULT;
    var
    rgdwAdjacency: PDWORD;
    dwBufferSize: LongWord;
    begin
    s_pd3dDevice := pd3dDevice;

    dwBufferSize := StrLen(g_strBuffer) + 1;

    Result:= D3DXCreateEffect(s_pd3dDevice, g_strBuffer, dwBufferSize, nil, nil, D3DXFX_NOT_CLONEABLE, nil, s_pEffect, nil); //<<< THIS CALL FAILED
    if V_Failed(Result) then Exit;


    Result:= DXUTCreateArrowMeshFromInternalArray(s_pd3dDevice, s_pMesh);
    if V_Failed(Result) then Exit;

    try
    GetMem(rgdwAdjacency, SizeOf(DWORD)*s_pMesh.GetNumFaces*3);
    except
    Result:= E_OUTOFMEMORY;
    Exit;
    end;
    V(s_pMesh.GenerateAdjacency(1e-6, rgdwAdjacency));
    V(s_pMesh.OptimizeInplace(D3DXMESHOPT_VERTEXCACHE, rgdwAdjacency, nil, nil, nil));
    FreeMem(rgdwAdjacency);

    Result:= S_OK;
    end;
    [/pascal]

    Because the callback failed, the DXUTCreate3DEnvironment failed too and then DXUTCleanup3DEnvironment is executed which contains the following:

    [pascal]

    // are unrelease objects.
    GetDXUTState.D3DDevice:= nil;
    if (pd3dDevice <nil> 0) then
    begin
    {$IFNDEF FPC} //todo: Remove this HACK after succesfull debugging of FPC port
    DXUTDisplayErrorMessage(DXUTERR_NONZEROREFCOUNT);
    DXUT_ERR('DXUTCleanup3DEnvironment', DXUTERR_NONZEROREFCOUNT);
    {$IFDEF DEBUG}
    // Forced clearing of D3DDevice references, so D3D debug level will show additional messages
    OutputDebugString('DXUT.pas: releasing D3DDevice refcount until ZERO');
    while (pd3dDevice._Release > 0) do;
    {$ENDIF}
    {$ENDIF}
    end;
    Pointer(pd3dDevice) := nil;
    end;
    [/pascal]

    DXUTDisplayErrorMessage(DXUTERR_NONZEROREFCOUNT); shows the message.

    The weird thing is that {$IFNDEF FPC} shouldn't return true because i'm using Delphi 7. :?
    I see that when {$IFDEF DEBUG} returns true, all devices will be freed to make refcount zero.

    Can you tell me why exactly the OnCreateDevice callback is failing, and what the sollution is??
    Is the {$IFDEF DEBUG} thing a way to make sure that all devices are properly terminated??

    Realy hope you can solve this!

    EDIT: starting post fixed I initialy thought you would do that, because the thread was locked and i couldn't edit. i didn't have a look at it after you unlocked it. Thanx for reminding me.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •