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

Need to get to underlying ID3D11Texture2D pointer from a Veldrid texture... how? #490

Open
mherbold opened this issue Mar 29, 2023 · 1 comment

Comments

@mherbold
Copy link

I am trying to write a SteamVR (OpenVR) overlay app. OpenVR requires a handle to the D3D11 texture to use to render the overlay. I have a Veldrid texture that I set as render target (drawn on by ImGui) and the texture has the sampled flag on it as well. All that works.
Now I need to pass the underlying D3D11 texture to OpenVR so it can display it on my HMD as an overlay... how do I get to that pointer?

Note I am using GraphicsBackend.Direct3D11 when calling VeldridStartup.CreateWindowAndGraphicsDevice.

In Unity I would just call texture.GetNativeTexturePtr(). What's the equivalent with Veldrid?

@mherbold
Copy link
Author

Never mind - I figured this one out. The answer is -

BackendInfoD3D11 _backendInfo;

_graphicsDevice.GetD3D11Info( out var _backendInfo );

var texture_t = new Texture_t();

texture_t.handle = _backendInfo.GetTexturePointer( _texture );
texture_t.eType = ETextureType.DirectX;
texture_t.eColorSpace = EColorSpace.Gamma;

OpenVR.Overlay.SetOverlayTexture( _overlayHandle, ref texture_t );

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

No branches or pull requests

1 participant