XNA Creators Club Online
Page 1 of 1 (9 items)
Sort Posts: Previous Next

Linker error for DXUTSetD3D11Device

Last post 5/19/2009 9:17 AM by Nirav Shah. 8 replies.
  • 4/30/2009 7:40 AM

    Linker error for DXUTSetD3D11Device

    Hi,

    I had been using and modifying samples given with Nov 2008 SDK for my application till now and almost everything went smooth. Until this juncture, when I need to create D3D11Device myself by using D3D11CreateDeviceAndSwapChain instead of DXUTCreateDevice. I found out that I can still use DXUT functionalities if I could set the device I created to DXUT framework. I believe I should be using DXUTSetD3D11Device function to achieve the same. Unfortunately, using this function gives linker error as,

    error LNK2019: unresolved external symbol "long __stdcall DXUTSetD3D11Device(struct ID3D11Device *,struct IDXGISwapChain *)" (?DXUTSetD3D11Device@@YGJPAUID3D11Device@@PAUIDXGISwapChain@@@Z) referenced in function _wWinMain@16

    I tried adding almost all the lib files available at <NOV2008SDK_HOME>\Lib\x86 at Project_Properties->Configuration Properties->Linker->Input. Still this function is unresolved symbol. Can someone please let me know which lib file has the implementation for this function? More surprisingly, the code uses other DXUT functions very well without any errors. Like, DXUTSetCallback*, DXUTInit, DXUTSetCursorSettings, DXUTMainLoop. No errors are shown for any of these functions. 

    Moreover, is order of the list of lib files added important? Currently I am having following libs in this order added.
    d3dcompiler.lib
    dxerr.lib
    dxguid.lib
    d3dx9d.lib
    d3d9.lib
    winmm.lib
    comctl32.lib
    dxgi.lib
    d3d10.lib
    d3dx10d.lib
    d3dx11.lib
    d3d11.lib

    Kindly let me know if there is any mistake over here.

    Thanks & Regards,
    Nirav.
  • 4/30/2009 5:19 PM In reply to

    Re: Linker error for DXUTSetD3D11Device

    DXUT is delivered in source form. there is no lib. your project must include the source files you need. see the other samples.

    that method is declared in DXUT.h and not implemented, as far as I can tell.

    remember, D3D11 is still a preview.

    you can probably examine the DXUT for D3D10 and implement that routine by yourself if you cannot cache the device pointer.
    http://www.futuregpu.net ex-Aces Lead PM/ex DX SDK PM/ex D3D Evangelist now LRB Launch Native Title Wrangler
  • 5/8/2009 12:25 PM In reply to

    Re: Linker error for DXUTSetD3D11Device

    Hi Phil,

    As you said rightly, DXUTSetD3D11Device is not implemented in DXUT.cpp. It is only declared in DXUT.h. I tried to implement that method by looking at DXUTSetD3D10Device method given in DXUT.cpp in November 2008 SDK. Right now I am using March 2009 SDK. 

    This is the implementation I am using for DXUTSetD3D11Device..

    HRESULT WINAPI DXUTSetD3D11Device( ID3D11Device* pd3dDevice, IDXGISwapChain* pSwapChain ) 
        HRESULT hr; 
     
        if( pd3dDevice == NULL ) 
            return DXUT_ERR_MSGBOX( L"DXUTSetD3D11Device", E_INVALIDARG ); 
     
        // Not allowed to call this from inside the device callbacks 
        if( GetDXUTState().GetInsideDeviceCallback() ) 
            return DXUT_ERR_MSGBOX( L"DXUTSetD3D11Device", E_FAIL ); 
     
        GetDXUTState().SetDeviceCreateCalled( true ); 
     
        // If DXUTCreateWindow() or DXUTSetWindow() has not already been called,  
        // then call DXUTCreateWindow() with the default parameters.          
        if( !GetDXUTState().GetWindowCreated() ) 
        { 
            // If DXUTCreateWindow() or DXUTSetWindow() was already called and failed, then fail. 
            // DXUTCreateWindow() or DXUTSetWindow() must first succeed for this function to succeed 
            if( GetDXUTState().GetWindowCreateCalled() ) 
                return E_FAIL; 
     
            // If DXUTCreateWindow() or DXUTSetWindow() hasn't been called, then  
            // automatically call DXUTCreateWindow() with default params 
            hr = DXUTCreateWindow(); 
            if( FAILED( hr ) ) 
                return hr; 
        } 
     
        DXUTDeviceSettings DeviceSettings; 
        ZeroMemory( &DeviceSettings, sizeof( DXUTDeviceSettings ) ); 
     
        // Get adapter info 
        IDXGIDevice* pDXGIDevice = NULL; 
        if( SUCCEEDED( hr = pd3dDevice->QueryInterface( __uuidof( *pDXGIDevice ), 
                                                        reinterpret_cast< void** >( &pDXGIDevice ) ) ) ) 
        { 
            IDXGIAdapter* pAdapter = NULL; 
            hr = pDXGIDevice->GetAdapter( &pAdapter ); 
            if( SUCCEEDED( hr ) ) 
            { 
                DXGI_ADAPTER_DESC id; 
                pAdapter->GetDesc( &id ); 
     
                // Find the ordinal by inspecting the enum list. 
                DeviceSettings.d3d11.AdapterOrdinal = 0;  // Default 
                CD3D11Enumeration* pd3dEnum = DXUTGetD3D11Enumeration(); 
                CGrowableArray <CD3D11EnumAdapterInfo*>* pAdapterInfoList = pd3dEnum->GetAdapterInfoList(); 
                forint i = 0; i < pAdapterInfoList->GetSize(); ++i ) 
                { 
                    CD3D11EnumAdapterInfo* pAdapterInfo = pAdapterInfoList->GetAt( i ); 
                    if( !wcscmp( pAdapterInfo->AdapterDesc.Description, id.Description ) ) 
                    { 
                        DeviceSettings.d3d11.AdapterOrdinal = i; 
                        break
                    } 
                } 
                SAFE_RELEASE( pAdapter ); 
            } 
            SAFE_RELEASE( pDXGIDevice ); 
        } 
     
        if( FAILED( hr ) ) 
            return hr; 
     
        // Get the swap chain description 
        DXGI_SWAP_CHAIN_DESC sd; 
        pSwapChain->GetDesc( &sd ); 
        DeviceSettings.ver = DXUT_D3D11_DEVICE; 
        DeviceSettings.d3d11.sd = sd; 
     
        // Fill out the rest of the device settings struct 
        DeviceSettings.d3d11.CreateFlags = 0; 
        DeviceSettings.d3d11.DriverType = D3D_DRIVER_TYPE_WARP; // specific to WARP devices. 
        DeviceSettings.d3d11.Output = 0; 
        DeviceSettings.d3d11.PresentFlags = 0; 
        DeviceSettings.d3d11.SyncInterval = 0; 
        // DeviceSettings.d3d10.AutoCreateDepthStencil = true; // TODO: verify 
     
        // Change to the Direct3D device passed in 
        hr = DXUTChangeDevice( &DeviceSettings, NULL, pd3dDevice, falsefalse ); 
        if( FAILED( hr ) ) 
            return hr; 
     
        return S_OK; 
    }  


    Now, Compilation is fine, but there is a runtime error. I will try to give the trace. Inside this function, there is a call to DXUTChangeDevice function. Inside DXUTChangeDevice, there is a call to DXUTCreate3DEnvironment11. Inside it, there is a call to DXUTUpdateBackBufferDesc function. Inside DXUTUpdateBackBufferDesc, it gives access violation error while trying to get the swap chain.

    Trace: myCpp.cpp -> DXUTSetD3D11Device -> DXUTChangeDevice -> DXUTCreate3DEnvironment11 -> DXUTUpdateBackBufferDesc.

    Inside DXUT.cpp, in DXUTUpdateBackBufferDesc, the statement which is giving error is as follows,
    hr = GetDXUTState().GetDXGISwapChain()->GetBuffer( 0, __uuidof( *pBackBuffer ), ( LPVOID* )&pBackBuffer );

    I broke it down to get the problem as follows,
    DXUTState a = GetDXUTState();
    IDXGISwapChain* b = DXUTGetDXGISwapChain();
    hr = b->GetBuffer(0, __uuidof( *pBackBuffer ), ( LPVOID* )&pBackBuffer );

    While executing these set of statements, DXUTState is retrieved successfully. But, DXUTGetDXGISwapChain returns NULL i.e. 0x00000000. This causes statement following it to fail. 

    Any insites regarding this?

    Now, here is my primary doubt. How can SwapChain be retrieved as it has not been set at all. The control is led to this juncture by the call DXUTSetD3D11Device, with d3d11Device and swapchain given as argument. 

    Thanks & Regards,
    Nirav Shah.



  • 5/11/2009 7:42 PM In reply to

    Re: Linker error for DXUTSetD3D11Device

    yes, if you are trying to get the swapchain before its created that wont work.

    you need to execute this method after the swapchain is created.
    http://www.futuregpu.net ex-Aces Lead PM/ex DX SDK PM/ex D3D Evangelist now LRB Launch Native Title Wrangler
  • 5/14/2009 12:20 PM In reply to

    Re: Linker error for DXUTSetD3D11Device

    I am already creating the device and swapchain using D3D11CreateDeviceAndSwapChain. And trying to put the device and the swapchain created into the DXUT framework. 

    My doubt was the swapchain I created using D3D11CreateDeviceAndSwapChain, will it be already visible to DXUT framework? I guess no, as that's what we are trying to set using DXUTSetD3D11Device. Then, how can the swapchain be already awailable inside execution of DXUTSetD3D11Device?

    Thanks & Regards,
    Nirav Shah.
  • 5/14/2009 8:01 PM In reply to

    Re: Linker error for DXUTSetD3D11Device

    who is creating the device and swapchain?

    you and not DXUT?

    then it wont be visible until you set the proper DXUT variable with the device and swapchain.

    you have validated in the debugger it is not null?

    you are passing it to the DXUT framework, and where does it become null?

    isnt this either:
    1)you are trying to use something before its created ( which you say is not the case )
    2)or somewhere you arent passing down the right value, in which case this is a standard debugging exercise?

    if your implementation of DXUTSetD3D11Device tries to use the variable before you set it, isnt that the issue?

    http://www.futuregpu.net ex-Aces Lead PM/ex DX SDK PM/ex D3D Evangelist now LRB Launch Native Title Wrangler
  • 5/15/2009 8:12 AM In reply to

    Re: Linker error for DXUTSetD3D11Device

    PhilTaylor:

    who is creating the device and swapchain?

    you and not DXUT?

    That's right. I am creating device and swap chain using D3D11CreateDeviceAndSwapChain function. 

    PhilTaylor:
    then it wont be visible until you set the proper DXUT variable with the device and swapchain.
    Totally agree with that. Hence after creating device and swapchain using D3D11CreateDeviceAndSwapChain, I am trying to set device and swapchain into DXUT framework by DXUTSetD3D11Device( ID3D11Device* pd3dDevice, IDXGISwapChain* pSwapChain ). I found this most logical ( Logic may be wrong.. :) )

    The problem is, in side the call of DXUTSetD3D11Device, there is a juncture, when there is a call to DXUTGetDXGISwapChain function. (Trace to this function is given in my earlier post in this thread). I mean, how this is possible, I am trying to set the swapchain into DXUT frame work and to do this, the framework is trying to get the swapchain from the framework. It's kindda paradox situation.

    PhilTaylor:
    you are passing it to the DXUT framework, and where does it become null?

    I am passing the swapchain pointer into DXUTSetD3D11Device function call. But, inside the call, at a juncture (see the trace), DXUTGetDXGISwapChain() is called, which returns NULL. (Obviously, as swapchain is not set into DXUT framework yet).

    Pause.... Seems like I have keyed down too much. Please let me know if I have created a messy answer.. :P

    Thanks & Regards,
    Nirav Shah.
  • 5/18/2009 4:46 PM In reply to

    Re: Linker error for DXUTSetD3D11Device

    you wrote this method right?

    dont you want to assign the variable and not call DXUTGetDXGISwapChain to get it?


    http://www.futuregpu.net ex-Aces Lead PM/ex DX SDK PM/ex D3D Evangelist now LRB Launch Native Title Wrangler
  • 5/19/2009 9:17 AM In reply to

    Re: Linker error for DXUTSetD3D11Device

    I am not calling DXUTGetDXGISwapChain myself directly inside the function I wrote. I have written only DXUTSetD3D11Device myself. Functions being called from DXUTSetD3D11Device are already there and I am not touching anyone of them. 

    Once from DXUTSetD3D11Device (my code) function, DXUTChangeDevice is called, that is no longer my code. DXUTGetDXGISwapChain is called from further inside. So, I cannot (should not) change any thing there. So, i think the problem lyies in the standard code part.

    Ofcourse, my intentions are to set the swapchain variable into DXUT framework, so I thought that calling DXUTSetD3D11Device should do the work, but I found this paradox while trying to debug where exactly is the problem.

    Thanks & Regards,
    Nirav Shah.
Page 1 of 1 (9 items) Previous Next