How to access ID3D11Device ? [Bug?]

Hi all,

I am currently working on a plugin to integrate NoesisGUI into UE4.

To do so, I do need to get provided with the current ID3D11Device (the same goes for ID3D9Device if there is some.)
I will look onto the OpenGL side afterward.

Right now, I have been searching through source code and documentation…

All I found would be a function “RHIGetNativeDevice()”… I though at the beginning “Wow ! This is cool ! :D”…

Until I realize that this function does only return a nullptr ?

If you have any idea or workaround to get access to it. I am at the moment not used enough to UE4 programming rules and code to find out by myself…

I’ve been wandering around the net for ours without finding anything positive…

Thanks a lot !

Erio.

EDIT:

Hi all.

“Small” update on the topic.

From what I’ve seen whilst wandering in the middle of the doc and source files:
On the documentation page here : FDynamicRHI | Unreal Engine 5.2 Documentation
We can see two class inheriting FDynamicRHI:
**- FNullDynamicRHI

  • FOpenGLDynamicRHI**

I pursued my searches wondering why we would get access to OpenGL RHI and not to Windows one

I downloaded the source code of UE 4.3 and started to search a bit everywhere and nowhere for some D3D11 stuffs. this is where I ended finding the declaration of FD3D11DynamicRHI and the function I am seeking from the beginning: ID3D11Device *FD3D11DynamicRHI::GetDevice().

From what I see and understand, FD3D11DynamicRHI is private. Which is a big problem.

I am wondering if this is normal, if this is a choice or if this could be fixed so plugin developpers can get acces to ID3D11Device as we would for OpenGL ?

I will pursue my investigations to get a way to use it.

The definition is located in the

Engine\Source\Runtime\Windows\D3D11RHI\Private

Thanks

Updated on 7/27/2014:1.18am

I think you should so stuff on RHI level insted of trying to get specificly D3DDevice, also check to which routine you need connect for rendering. Otherwise your plugin code won’t be portable

In fact. I would not bother seeking for specific devices if I would not absolutely need them.

I do not only need the ID3D11Device, but also those for OpenGL and OpenGLES. I will handle the operating system case within the plugin.

It’s a plugin aiming at integrating NoesisGUI to UE4 for a smooth use and a perfect 3D integration. And as this is a library that have nothing to do with UE4 on a code side. I need to give it a ID3D11Device. And the best way to do the thing right is to get UE4 ones.

At the moment, you can already grab the OpenGL device if you want… But D3D11 ones has been made private.

I am asking for it as I do really need to access it and that there is no workaround possible that would not include writing very dirty things.

Code will be portable of course. Devices are the only things I need in order to make it portable. (and a few #ifdef #endif )

Take a look at the following Pull Request submitted by the guys over at CoherentUI to expose the native D3D Device using the method you have tried: https://github.com/EpicGames/UnrealEngine/pull/199

It has been accepted and merged so the functionality will be available at some point.

Thanks. this is what I was trying to use…

But look at the code… the functions returns a nullptr… So at the moment… It is pretty useless…

Yes I know, what I am trying to say is that the Pull Request from above has been accepted and merged, therefore the functionality you want will be available at some point, the below is straight from the Pull Request, notice its not nullptr there:

void* FD3D11DynamicRHI::GetNativeInterface()
{
 return GetDevice();
}

Thanks. I guess My only choice would be to compile it myself for now. :confused:

I took a look at the git repo.

It seems that it is already exposed in the 4.3… Then I do wonder how to get a FD3D11DynamicRHI… I could not get a hand on any include or way to get it…

Or maybe that it’s just this RHIGetNativeDevice() function…
As FD3D11DynamicRHI must be (I guess) a child of some RHI stuff that has been designed so that we don’t mess with it. :slight_smile:

Seems like it. Thanks for your help Ehamloptiran. :slight_smile: