Jump to content
  • Advertisement
Sign in to follow this  
JorisS

DX12 [D3D12] CreateDevice fails

This topic is 903 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

Hello,

 

I'm currently implementing DirectX 12 into an engine that we developing last few months. 

I have now a basic renderer that is able to render models, textures and using shaders.

But now I'm running into a problem I can't figure out anymore. Since last week the D3D12CreateDevice() is failing.

The error happens when I loop through the adapters to find any adapter with DX12 support.
 

The code is very similar from the samples:

ComPtr<IDXGIAdapter1> adapter;
	*ppAdapter = nullptr;

	for (UINT adapterIndex = 0; DXGI_ERROR_NOT_FOUND != pFactory->EnumAdapters1(adapterIndex, &adapter); ++adapterIndex)
	{
		DXGI_ADAPTER_DESC1 desc;
		adapter->GetDesc1(&desc);

		if (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE)
		{
			// Don't select the Basic Render Driver adapter.
			continue;
		}

		// Check to see if the adapter supports Direct3D 12, but don't create the actual device yet.
		HRESULT r = D3D12CreateDevice(adapter.Get(), D3D_FEATURE_LEVEL_11_0, _uuidof(ID3D12Device), nullptr);
		if (SUCCEEDED(r))
		{
			break;
		}
		else
		{
			// Log why it cant create:
			IS_FAILED(r);
		}
	}

	*ppAdapter = adapter.Detach();
Return value of r:
HRESULT r = E_POINTER Invalid pointer.

The return value is bit unusual for me that I don't know what to do with it. 

My GPU is a GeForce GT 650M, which should be able to run DirectX 12 to some point. (It also runs the DirectX12 Sample and Mini Engine.)

 

If there is more information needed, please tell and I will provide.

Many Thanks,

Joris

 

 

Share this post


Link to post
Share on other sites
Advertisement

Since you're never actually passing in a device pointer I assume this code purely tests whether an adapter would support D3D12? You're running a GT 650M, which tells me you're probably running this on a laptop. Is there any chance this code is finding your laptop's integrated card (if you have one that is) first and is then failing because this card does not support D3D12?

Share this post


Link to post
Share on other sites

If Radikalizm is right about finding the integrated instead of the discrete graphics, IIRC there is a control panel app that lets you switch between the two (force) on a per application basis.

 

edit - actually I'm not sure if it is per app.

Edited by Infinisearch

Share this post


Link to post
Share on other sites

If Radikalizm is right about finding the integrated instead of the discrete graphics, IIRC there is a control panel app that lets you switch between the two (force) on a per application basis.

 

Better yet, adjust your code so it properly looks for the most suitable adapter so your integrated card can never be picked to create the device on. No need to mess with control panel settings.

Share this post


Link to post
Share on other sites

 

If Radikalizm is right about finding the integrated instead of the discrete graphics, IIRC there is a control panel app that lets you switch between the two (force) on a per application basis.

 

Better yet, adjust your code so it properly looks for the most suitable adapter so your integrated card can never be picked to create the device on. No need to mess with control panel settings.

 

I've heard the system will sometimes automatically choose the adapter based on "how demanding the application is". (has to do with power management)  As in even if you enumerate the discrete it will give you integrated.(or something like that)  And the only solution is the control panel app.  Am I mistaken on this?  I've never confirmed as I don't have a laptop.

Edited by Infinisearch

Share this post


Link to post
Share on other sites

Thanks for the replies.

 

Since you're never actually passing in a device pointer I assume this code purely tests whether an adapter would support D3D12? You're running a GT 650M, which tells me you're probably running this on a laptop. Is there any chance this code is finding your laptop's integrated card (if you have one that is) first and is then failing because this card does not support D3D12?

 

Yes, I have indeed a integrated card but it loops through all adapters, so it should find the 650m anyway. And my integrated card doesn't support D3D12 so it fails anyway.

Logging the description of the adapter give me this:
 

The log file was opened
Info: Getting graphics hardware adapter..

Info: NVIDIA GeForce GT 650M  
Error: (DX12)
		File: -
		Line: 69
		Error: Invalid pointer

Info: Intel(R) HD Graphics 4000
Error: (DX12)
		File: -
		Line: 69
		Error: The specified device interface or feature level is not supported on this system.

So it should take the first adapter with D3D12 support.

 

 

 

 

If Radikalizm is right about finding the integrated instead of the discrete graphics, IIRC there is a control panel app that lets you switch between the two (force) on a per application basis.

 

Better yet, adjust your code so it properly looks for the most suitable adapter so your integrated card can never be picked to create the device on. No need to mess with control panel settings.

 

I've heard the system will sometimes automatically choose the adapter based on "how demanding the application is". (has to do with power management)  As in even if you enumerate the discrete it will give you integrated.(or something like that)  And the only solution is the control panel app.  Am I mistaken on this?  I've never confirmed as I don't have a laptop.

 

 

I'm not sure, if there is then it is new for me. I know that default nvidia drivers settings needs to be changed to make sure that the 650M comes first. http://puu.sh/mcoLg/c7d032f645.png (see "Preferred graphics processor", it needs to be set to High-performance NVIDIA processor). I will look around my control panel/power options. But it strange because I can run the directX12 samples without any problem..

Share this post


Link to post
Share on other sites

I'm not sure, if there is then it is new for me. I know that default nvidia drivers settings needs to be changed to make sure that the 650M comes first.  "Preferred graphics processor", it needs to be set to High-performance NVIDIA processor).

Does that control panel app have a per application setting for GPU?  If so did you check it for your app?  Maybe the setting in the control panel app isn't working properly, you could try uninstalling cleaning and then reinstalling the drivers.  There used to be a program that does that... DDU? (display driver uninstaller) Don't know if its up to date though.

 

edit - Actually I think you're doing something wrong here:

 

D3D12CreateDevice(adapter.Get(), D3D_FEATURE_LEVEL_11_0, _uuidof(ID3D12Device), nullptr);

 

shouldn't the _uuidof be IID_PPV_ARGS

 

according to this page https://msdn.microsoft.com/en-us/library/windows/desktop/dn770336(v=vs.85).aspx

Edited by Infinisearch

Share this post


Link to post
Share on other sites

The other thing I noticed is the last parameter of the D3D12CreateDevice method is optional as in I don't think it's allowed to be null.

 

edit - BTW here is the same code from one of the MS samples.

 
ThrowIfFailed(D3D12CreateDevice(
nullptr,
D3D_FEATURE_LEVEL_11_0,
IID_PPV_ARGS(&m_device)
));
 
you're using a explict adapter so the first nullptr isn't your thing but notice the last argument isn't there.
Edited by Infinisearch

Share this post


Link to post
Share on other sites

 

The other thing I noticed is the last parameter of the D3D12CreateDevice method is optional as in I don't think it's allowed to be null.

 

edit - BTW here is the same code from one of the MS samples.

 
ThrowIfFailed(D3D12CreateDevice(
nullptr,
D3D_FEATURE_LEVEL_11_0,
IID_PPV_ARGS(&m_device)
));
 
you're using a explict adapter so the first nullptr isn't your thing but notice the last argument isn't there.

 

 

I think it can be null, either way I changed it to:
 

HRESULT r = D3D12CreateDevice(adapter.Get(), D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&tempDevice));

which still doesn't work sad.png

 

I have also tried uninstalling and installing Nvidia, doesn't work

Edited by JorisS

Share this post


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

  • Advertisement
  • Advertisement
  • Popular Tags

  • Similar Content

    • By Roman R.
      I have a problem synchronizing data between shared resources. On the input I receive a D3D11 2D texture, which itself is enabled for sharing and has D3D11_RESOURCE_MISC_SHARED_NTHANDLE in its description.
      Having a D3D12 device created on the same adapter I open a resource through sharing a handle.
                  const CComQIPtr<IDXGIResource1> pDxgiResource1 = pTexture; // <<--- Input texture on 11 device
                  HANDLE hTexture;
                  pDxgiResource1->CreateSharedHandle(NULL, GENERIC_ALL, NULL, &hTexture);
                  CComPtr<ID3D12Resource> pResource; // <<--- Counterparty resource on 12 device
                  pDevice->OpenSharedHandle(hTexture, __uuidof(ID3D12Resource), (VOID**) &pResource);
      I tend to keep the mapping between the 11 texture and 12 resource further as they are re-filled with data, but in context of the current problem it does not matter if I reuse the mapping or I do OpenSharedHandle on every iteration.
      Further on I have a command list on 12 device where I use 12 resource (pResource) as a copy source. It is an argument in further CopyResource or CopyTextureRegion calls. I don't have any resource barriers in the command list (including that my attempts to use any don't change the behavior).
      My problem is that I can't have the data synchronized. Sometimes and especially initially the resource has the correct data, however further iterations have issues such as resource having stale/old data.
      I tried to flush immediate context on 11 device to make sure that preceding commands are completed.
      I tried to insert resource barriers at the beginning of command list to possibly make sure that source resource has time to receive the correct data.
      Same time I have other code paths which don't do OpenSharedHandle mapping and instead do additional texture copying and mapping between original 11 device and 11on12 device, and the code including the rest of the logic works well there. This makes me think that I fail to synchronize the data on the step I mentioned above, even though I am lost how do I synchronize exactly outside of command list.
      I originally thought that 12 resource has a IDXGIKeyedMutex implementation which is the case with sharing-enabled 11 textures, but I don't have the IDXGIKeyedMutex and I don't see what is the D3D12 equivalent, if any.
      Could you please advise where to look at to fix the sync?
    • By NikiTo
      Recently I read that the APIs are faking some behaviors, giving to the user false impressions.
      I assume Shader Model 6 issues the wave instructions to the hardware for real, not faking them.

      Is Shader Model 6, mature enough? Can I expect the same level of optimization form Model 6 as from Model 5? Should I expect more bugs from 6 than 5?
      Would the extensions of the manufacturer provide better overall code than the Model 6, because, let say, they know their own hardware better?

      What would you prefer to use for your project- Shader Model 6 or GCN Shader Extensions for DirectX?

      Which of them is easier to set up and use in Visual Studio(practically)?
    • By mark_braga
      I am trying to get the DirectX Control Panel to let me do something like changing the break severity but everything is greyed out.
      Is there any way I can make the DirectX Control Panel work?
      Here is a screenshot of the control panel.
       

    • By Keith P Parsons
      I seem to remember seeing a version of directx 11 sdk that was implemented in directx12 on the microsoft website but I can't seem to find it anymore. Does any one else remember ever seeing this project or was it some kind off fever dream I had? It would be a nice tool for slowly porting my massive amount of directx 11 code to 12 overtime.
    • By NikiTo
      In the shader code, I need to determine to which AppendStructuredBuffers the data should append. And the AppendStructuredBuffers are more than 30.
      Is declaring 30+ AppendStructuredBuffers going to overkill the shader? Buffers descriptors should consume SGPRs.

      Some other way to distribute the output over multiple AppendStructuredBuffers?

      Is emulating the push/pop functionality with one single byte address buffer worth it? Wouldn't it be much slower than using AppendStructuredBuffer?
    • By Sobe118
      I am rendering a large number of objects for a simulation. Each object has instance data and the size of the instance data * number of objects is greater than 4GB. 
      CreateCommittedResource is giving me: E_OUTOFMEMORY Ran out of memory. 
      My PC has 128GB (only 8% ish used prior to testing this), I am running the DirectX app as x64. <Creating a CPU sided resource so GPU ram doesn't matter here, but using Titan X cards if that's a question>
      Simplified code test that recreates the issue (inserted the code into Microsofts D3D12HelloWorld): 
      unsigned long long int siz = pow(2, 32) + 1024; D3D12_FEATURE_DATA_D3D12_OPTIONS options; //MaxGPUVirtualAddressBitsPerResource = 40 m_device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, &options, sizeof(options)); HRESULT oops = m_device->CreateCommittedResource( &CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_UPLOAD), D3D12_HEAP_FLAG_NONE, &CD3DX12_RESOURCE_DESC::Buffer(siz), D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, IID_PPV_ARGS(&m_vertexBuffer)); if (oops != S_OK) { printf("Uh Oh"); } I tried enabling "above 4G" in the bios, which didn't do anything. I also tested using malloc to allocate a > 4G array, that worked in the app without issue. 
      Are there more options or build setup that needs to be done? (Using Visual Studio 2015)
      *Other approaches to solving this are welcome too. I thought about splitting up the set of items to render into a couple of sets with a size < 4G each but would rather have one set of objects. 
      Thank you.
    • By _void_
      Hey guys!
      I am not sure how to specify array slice for GatherRed function on Texture2DArray in HLSL.
      According to MSDN, "location" is one float value. Is it a 3-component float with 3rd component for array slice?
      Thanks!
    • By lubbe75
      I have a winforms project that uses SharpDX (DirectX 12). The SharpDX library provides a RenderForm (based on a System.Windows.Forms.Form). 
      Now I need to convert the project to WPF instead. What is the best way to do this?
      I have seen someone pointing to a library, SharpDX.WPF at Codeplex, but according to their info it only provides support up to DX11.
      (Sorry if this has been asked before. The search function seems to be down at the moment)
    • By korben_4_leeloo
      Hi.
      I wanted to experiment D3D12 development and decided to run some tutorials: Microsoft DirectX-Graphics-Samples, Braynzar Soft, 3dgep...Whatever sample I run, I've got the same crash.
      All the initialization process is going well, no error, return codes ok, but as soon as the Present method is invoked on the swap chain, I'm encountering a crash with the following call stack:
      https://drive.google.com/open?id=10pdbqYEeRTZA5E6Jm7U5Dobpn-KE9uOg
      The crash is an access violation to a null pointer ( with an offset of 0x80 )
      I'm working on a notebook, a toshiba Qosmio x870 with two gpu's: an integrated Intel HD 4000 and a dedicated NVIDIA GTX 670M ( Fermi based ). The HD 4000 is DX11 only and as far as I understand the GTX 670M is DX12 with a feature level 11_0. 
      I checked that the good adapter was chosen by the sample, and when the D3D12 device is asked in the sample with a 11_0 FL, it is created with no problem. Same for all the required interfaces ( swap chain, command queue...).
      I tried a lot of things to solve the problem or get some info, like forcing the notebook to always use the NVIDIA gpu, disabling the debug layer, asking for a different feature level ( by the way 11_0 is the only one that allows me to create the device, any other FL will fail at device creation )...
      I have the latest NVIDIA drivers ( 391.35 ), the latest Windows 10 sdk ( 10.0.17134.0 ) and I'm working under 
      Visual Studio 2017 Community.
      Thanks to anybody who can help me find the problem...
    • By _void_
      Hi guys!
      In a lot of samples found in the internet, people when initialize D3D12_SHADER_RESOURCE_VIEW_DESC with resource array size 1 would normallay set its dimension as Texture2D. If the array size is greater than 1, then they would use dimension as Texture2DArray, for an example.
      If I declare in the shader SRV as Texture2DArray but create SRV as Texture2D (array has only 1 texture) following the same principle as above, would this be OK? I guess, this should work as long as I am using array index 0 to access my texture?
      Thanks!
  • Advertisement
  • Popular Now

  • Forum Statistics

    • Total Topics
      631394
    • Total Posts
      2999754
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!