deng0 / DirectXTexNet

A .NET wrapper for the DirectXTex library.
Other
25 stars 10 forks source link

Using Compress(IntPtr ID3D11Device, ...) #3

Closed Shad0wlife closed 5 years ago

Shad0wlife commented 5 years ago

I want to do BC7 Compression, but as that's horribly slow in software, I want to do it on GPU. I'm currently trying to get the corresponding method to run, but I'm unable to get a usable IntPtr to the device. I tried getting a Direct3D11 Device with SharpDX (which, corresponding to its Documentation is a wrapper for ID3D11Device), and then getting the Pointer to it by allocating the object with GCHandle and using that IntPtr, but I get an error that I'm accessing a disallowed memory area.

Is there an actual way to use this feature or was it just lazily ported from C++ and can't actually be used?

deng0 commented 5 years ago

It can be used and I've already done it before with SharpDX. You are trying to get the native pointer the wrong way. When device is your SharpDX.Direct3D11.Device just use device.NativePointer to pass it to the DirectTexNet method.

Shad0wlife commented 5 years ago

Thanks, it works. I didn't see the NativePointer field and tried to get a GCHandle allocated on it.