Jump to content
  • Advertisement
laiyierjiangsu

DX11 Enumoutputs do not work in Win10

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

            for (Foundation::UInt32 i = 0; ; i++)
            {
                hr = pAdapterInfo->pDXGIAdapter->EnumOutputs(i, &pDXGIOutput);
				if (SUCCEEDED(hr))
				{
		
						//EnumDisplayModes(pOutputInfo)
	
					}

					SAFE_RELEASE(pDXGIOutput);
				}
				else
				{
					//None output will be found
					if (i==0)
					{
						//error("EnumOupput error i:%u, error %s", i,str);
					}
					break;
                }
            }
            return true;
        }

Hi , guys!

         I used the upper code to get all resolutions supported by video card which will be selected by players.

But the code works perfectly in win7 , but it couldn't find any output in win10, I read a lot of papers ,but can not

find why.

    If anyone else has encountered this problem before ,please gives me some insight!

   Thanks a lot!

Share this post


Link to post
Share on other sites
Advertisement

Which adapter are you enumerating outputs for? You should make sure that it's the adapter for a video card with a display attached (if you have multiple video cards and one of them does not have any displays attached, then it will have 0 DXGI outputs). If you call IDXGIAdapter::GetDesc and check the "Description" member of the returned struct, you can get the name of the adapter.

You should also read this bit of documentation about the WARP device on Windows 8+. I would make sure that you're not trying to enumerate displays for the WARP device.

Share this post


Link to post
Share on other sites
On 2017/8/1 at 4:32 PM, MJP said:

Which adapter are you enumerating outputs for? You should make sure that it's the adapter for a video card with a display attached (if you have multiple video cards and one of them does not have any displays attached, then it will have 0 DXGI outputs). If you call IDXGIAdapter::GetDesc and check the "Description" member of the returned struct, you can get the name of the adapter.

You should also read this bit of documentation about the WARP device on Windows 8+. I would make sure that you're not trying to enumerate displays for the WARP device.

Thank you very much ! I have found the reason, but I still have another doubt.

bool D3D11EnumComponent::Check_DifferentDevice()
{
		HRESULT hr = S_OK;

		// get supported driver types
		D3D_DRIVER_TYPE* pDriverTypes = nullptr;
		int numDriverTypes = 0;

		D3D_DRIVER_TYPE   vecDriverTypeSupported[] =
		{
			D3D_DRIVER_TYPE_HARDWARE,
			D3D_DRIVER_TYPE_WARP,
			D3D_DRIVER_TYPE_REFERENCE
		};
		pDriverTypes = vecDriverTypeSupported;
		numDriverTypes = sizeof(vecDriverTypeSupported)/sizeof(vecDriverTypeSupported[0]);

		int numberofFeature = 1;
		D3D_FEATURE_LEVEL vecFeatureLevelsSupported[] =
		{
			D3D_FEATURE_LEVEL_11_0,
		};



		// for each type of driver, check device available.
		for (int iDriverTypeIndex = 0; iDriverTypeIndex < numDriverTypes; iDriverTypeIndex++)
		{
			// device creation flag
			UINT creationFlags = 0;
#if defined(_DEBUG)
			creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif

			ID3D11Device* pD3dDevice = NULL;
			ID3D11DeviceContext* pd3dDeviceContext = NULL;
			D3D_FEATURE_LEVEL eMaxFeatureLevel ;
			auto drivertype = pDriverTypes[iDriverTypeIndex];
			hr = D3D11CreateDevice(
				drivertype == D3D_DRIVER_TYPE_UNKNOWN ? g_pAdapter : nullptr,  // should be null if driver type not D3D_DRIVER_TYPE_UNKNOWN
				drivertype,
				nullptr,
				creationFlags,
				vecFeatureLevelsSupported,
				numberofFeature,
				D3D11_SDK_VERSION,
				&pD3dDevice,
				&eMaxFeatureLevel,
				&pd3dDeviceContext);


			if (FAILED(hr))
			{

				continue;
			}
			
			// update adapter interface
			IDXGIDevice* pDXGIDev = NULL;
			IDXGIAdapter* pAdapter = nullptr;
			hr = pD3dDevice->QueryInterface(__uuidof(IDXGIDevice), (LPVOID*)&pDXGIDev);
			if (SUCCEEDED(hr) && pDXGIDev)
			{
				hr = pDXGIDev->GetAdapter(&pAdapter);
				if (!SUCCEEDED(hr))
				{
					assert(false);
				}
				else
				{
					if(pAdapter != g_pAdapter)
					{
					//	assert(false);
						MessageBox(nullptr,L"a",L"bbbb",MB_OK);
					}
				}
			}
			else
			{
				assert(false);
			}
			SAFE_RELEASE(pDXGIDev);
		}	
		return true;

g_pAdapter is the best adapter I selected from Dxfactory, and it was the first adapter enumerated by dxfactory.

After I created the device, I got the adpter from the device ,  the two device wasn't same.

I cann't figure out why . How does D3D11CreateDevice choose a adapter to using?

I think there is something I do not know, Please help me!

Share this post


Link to post
Share on other sites

If you picked an adapter from the factory, then why are you creating D3D_DRIVER_TYPE_HARDWARE instead of passing that adapter into D3D11CreateDevice?

Internally, D3D11 will create a factory and EnumAdapters(0) on it if you don't provide it an adapter. That's why your pointer compare doesn't work... the adapters may be logically the same, but they won't be the same pointer.

Share this post


Link to post
Share on other sites
14 hours ago, SoldierOfLight said:

If you picked an adapter from the factory, then why are you creating D3D_DRIVER_TYPE_HARDWARE instead of passing that adapter into D3D11CreateDevice?

Internally, D3D11 will create a factory and EnumAdapters(0) on it if you don't provide it an adapter. That's why your pointer compare doesn't work... the adapters may be logically the same, but they won't be the same pointer.

Thanks, I see.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!