Jump to content

  • Log In with Google      Sign In   
  • Create Account

Ashkan_Irni

Member Since 30 Dec 2012
Offline Last Active Dec 31 2012 02:03 AM

Posts I've Made

In Topic: [SOLVED] Query Devices in D3D11

31 December 2012 - 02:01 AM

You should check that EnumAdapters1 returns S_OK.
Also you should check that GetDesc1 return S_OK.
If they don't return S_OK, then their error return code should hint where the problem lies - Get Desc1 expects pointer to existing structure, not NULL. It write to the object passed, but if you pass NULL there's nowhere to write adapter properties.

So you should write:
 

DXGI_ADAPTER_DESC1 temp_desc;
if (FAILED(adapter_ptr->GetDesc1(&temp_desc)) { error }

@NewDisplayName: nullptr is now standard way in C++11 how to say NULL.

 

Thank you so mcuh Martins Mozeiko for your help, you are correct the problem was passing NULL pointer to GetDesc1().

 

@NewDisplayName thanks for the link and for your replies


In Topic: [SOLVED] Query Devices in D3D11

31 December 2012 - 12:27 AM

Hello there smile.png

 

thanks for your reply.

 

I checked the while loop where the enumeration is being done, it appears that the pointer to the device (adapter_ptr) contains an address and it does have the GetDesc1() method, the method receives a DXGI_ADAPTER_DESC1 pointer and it is supposed to fill the pointer with an address, but when the method returns the DXGI_ADAPTER_DESC1 pointer, it is NULL so something is wrong with the GetDesc1() method but I'm not sure what.

 

Here is a screenshot from debugging:

ibyvqr.jpg

 

I have also changed nullptr to NULL the problem still exists. I don't think nullptr needs /clr, I thought /clr is only needed when Microsoft's C++ managed extensions are being used, nullptr is standard C++. Honestly I'm not a fan of managed C++ so I prefer not using /clr... unless I have to. Even then it will cause other problems since I have to turn off quite a number of other compiler options.


In Topic: [SOLVED] Query Devices in D3D11

30 December 2012 - 09:36 PM

The way I do this for DXGI 1.1 is I create an IDXGIFactory1 with CreateDXGIFactory1, and then I call EnumAdapters. The docs for IDXGIFactory2 suggest that the same approach will work, you just need to pass __uuidof(IDXGIFactory2) when calling CreateDXGIFactory.

 

Hi MJP,

 

Thank you for your help.

 

The documentation on IDXGIFactory2 is not clear because if I use 1.1 approach to get the devices then I won't have GetDesc2() method available, and another problem is that if I use IDXGI 1 or 1.1 I can't get any descriptions using GetDesc() and GetDesc1()I wrote the following code to test IDXGI 1.1 and 2 and in both cases the pointers that I get from enumerating adapters point to nothing:

 

2cfpqh0.jpg

 

and this is the whole test code:

#include <iostream>
#include <tchar.h>
#include <vector>
#include <d3d11.h>
#include <dxgi.h>
#include <dxgi1_2.h>

#pragma comment(lib, "dxgi.lib")

typedef unsigned int uint32_t;

void Test_DXGI_1()
{
	IDXGIFactory1*	DXGI_device_ptr	  = nullptr;
	IDXGIAdapter1*	adapter_ptr	  = nullptr;

	if( FAILED( CreateDXGIFactory1( __uuidof( IDXGIFactory1 ), ( void** ) &DXGI_device_ptr ) ) )
	{
		fprintf( stderr, "\tCould not Create IDXGIFactory\n" );
	}

	uint32_t i = 0;
	std::vector<IDXGIAdapter1*> adapter_list;
	
	while ( DXGI_device_ptr->EnumAdapters1( i, &adapter_ptr ) != DXGI_ERROR_NOT_FOUND )
	{
		adapter_list.push_back( adapter_ptr );
		++i;
	}

	DXGI_ADAPTER_DESC1* temp_desc = nullptr;
	
	for ( int i = 0; i < adapter_list.size(); ++i )
	{
		adapter_list[i]->GetDesc1( temp_desc );
		std::wcout << temp_desc->Description;

		std::cin.get();	// wait
	}
}


void Test_DXGI_2()
{
	IDXGIFactory2*	DXGI_device_ptr	  = nullptr;
	IDXGIAdapter2*	adapter_ptr	  = nullptr;

	if( FAILED( CreateDXGIFactory( __uuidof( IDXGIFactory2 ), ( void** ) &DXGI_device_ptr ) ) )
	{
		fprintf( stderr, "\tCould not Create IDXGIFactory\n" );
	}

	uint32_t i = 0;
	std::vector<IDXGIAdapter1*> adapter_list;
	IDXGIAdapter1* adapter1_ptr = nullptr;

	while ( DXGI_device_ptr->EnumAdapters1( i, &adapter1_ptr ) != DXGI_ERROR_NOT_FOUND )
	{
		adapter_list.push_back( adapter1_ptr );
		++i;
	}

	DXGI_ADAPTER_DESC1* temp_desc = nullptr;

	for ( int i = 0; i < adapter_list.size(); ++i )
	{
		adapter_list[i]->GetDesc1( temp_desc );
		std::wcout << temp_desc->Description;

		std::cin.get();	// wait
	}
}


int main( int argc, char* argv[] )
{
	Test_DXGI_1();
	Test_DXGI_2();

	std::cin.get();	// wait

	return 0;
}

PARTNERS