Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lacking documentation on Direct3DCreate9On12 #30

Open
Zwaliebaba opened this issue Feb 23, 2021 · 3 comments
Open

Lacking documentation on Direct3DCreate9On12 #30

Zwaliebaba opened this issue Feb 23, 2021 · 3 comments
Labels
documentation Improvements or additions to documentation

Comments

@Zwaliebaba
Copy link

Would it be possible to create an example app which is using the D3D9on12 layer end-to-end? For me IDirect3D9 gets created correctly by Direct3DCreate9On12 but when I call:

g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, _hWnd, 0, &g_d3dpp, &g_pd3dDevice);

it fails with HR = 0x8876086C (unable to detect a supported Graphics Card).

Thanks!

@jenatali
Copy link
Member

Sorry for the silence, we saw this, but haven't had a chance to put together samples. Hopefully we'll get to it eventually but I don't have a timeframe I can promise.

@jenatali jenatali added the documentation Improvements or additions to documentation label May 26, 2021
@sodaboy581
Copy link

Sorry for the silence, we saw this, but haven't had a chance to put together samples. Hopefully we'll get to it eventually but I don't have a timeframe I can promise.

I can't even get Direct3DCreate9On12 to make a 9on12 device. It ALWAYS creates a D3D9 one. I have no idea why.

I have some test code like so...

IDXGIAdapter1* TryD3D12()
{
	HRESULT hr;

	// -- Create the Device -- //

	IDXGIFactory4* dxgiFactory;
	hr = CreateDXGIFactory1(IID_PPV_ARGS(&dxgiFactory));
	if (FAILED(hr))
	{
		return NULL;
	}

	IDXGIAdapter1* adapter; // adapters are the graphics card (this includes the embedded graphics on the motherboard)

	int adapterIndex = 0; // we'll start looking for directx 12  compatible graphics devices starting at index 0

	// find first hardware gpu that supports d3d 12
	while (dxgiFactory->EnumAdapters1(adapterIndex, &adapter) != DXGI_ERROR_NOT_FOUND)
	{
		DXGI_ADAPTER_DESC1 desc;
		adapter->GetDesc1(&desc);

		if (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE)
		{
			// we dont want a software device
			adapterIndex++; // add this line here. Its not currently in the downloadable project
			continue;
		}

		// we want a device that is compatible with direct3d 12 (feature level 11 or higher)
		hr = D3D12CreateDevice(adapter, D3D_FEATURE_LEVEL_11_0, _uuidof(ID3D12Device), nullptr);
		if (SUCCEEDED(hr))
		{
			debug(L"Adapter description: %s", desc.Description);
			debug(L"Adapter LUID: %llx", desc.AdapterLuid);
			return adapter;
		}

		adapterIndex++;
	}

	return NULL;
}


IDirect3D9* d3d = nullptr;

	{
			IDirect3DDevice9On12* d3dtest = NULL;
			D3D9ON12_ARGS dArgs;
			ID3D12Device* d3d12 = NULL;
			IDXGIAdapter1* adapter;

			if ((adapter = TryD3D12()) != NULL)
			{
				D3D12CreateDevice(adapter, D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&d3d12));
				LUID adapter_LUID = d3d12->GetAdapterLuid();
				ZeroMemory(&dArgs, sizeof(D3D9ON12_ARGS));
				dArgs.Enable9On12 = TRUE;
				dArgs.pD3D12Device = d3d12;
				d3d = Direct3DCreate9On12(D3D_SDK_VERSION, &dArgs, 1);
				debug(L"D3D12 memory address: %08X", d3d12);
				debug(L"D3D12 device LUID: %llx", adapter_LUID);
				debug(L"D3D9 memory address: %08X", d3d);
				debug(L"Query interface returned %08X", d3d->QueryInterface(IID_PPV_ARGS(&d3dtest)));
				debug(L"IDirect3DDevice9On12 interface memory address: %08X", d3dtest);

			}
	}

Log output is:

[08-16-2022, 06:49:19] Adapter description: NVIDIA GeForce RTX 3090
[08-16-2022, 06:49:19] Adapter LUID: 9fa8
[08-16-2022, 06:49:19] D3D12 memory address: 034B0348
[08-16-2022, 06:49:19] D3D12 device LUID: 9fa8
[08-16-2022, 06:49:19] D3D9 memory address: 054222E0
[08-16-2022, 06:49:19] Query interface returned 80004002
[08-16-2022, 06:49:19] IDirect3DDevice9On12 interface memory address: 00000000

I've even tried simplifying it like so:

ZeroMemory(&dArgs, sizeof(D3D9ON12_ARGS));
dArgs.Enable9On12 = TRUE;
d3d = Direct3DCreate9On12(D3D_SDK_VERSION, &dArgs, 1);
d3d->QueryInterface(IID_PPV_ARGS(&d3dtest))

.. But I still get E_NOINTERFACE. :(

Any ideas why this doesn't work?

Do you HAVE to be running a Windows insider build for it to function? I'm just trying to see performance on Windows 11.

@sodaboy581
Copy link

Do you HAVE to be running a Windows insider build for it to function? I'm just trying to see performance on Windows 11.

Woops, I'm dumb, I needed to call QueryInterface on the IDirect3DDevice9 device and NOT the Direct3D9 interface. HA!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants