I'm trying out the shared resources feature of DX10, as I needed this for one of my project. But I'm can't find much sample or code especially using SlimDX. According to DX10 documentation, I just need to specified the resources as Shared, then I can open it using OpenSharedResource() from another application. With a simple test application in SlimDX, I did the following
Texture2D tex = new Texture2D(device, new Texture2DDescription()
{
ArraySize = 1,
BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
CpuAccessFlags = CpuAccessFlags.None,
Format = Format.B8G8R8A8_UNorm,
Height = 128,
Width = 128,
MipLevels = 1,
OptionFlags = ResourceOptionFlags.Shared,
SampleDescription = new SampleDescription(1, 0),
Usage = ResourceUsage.Default,
});
Texture2D tex2 = device.OpenSharedResource<Texture2D>(tex.ComPointer);
But I keep getting this error
E_INVALIDARG: An invalid parameter was passed to the returning function (-2147024809)
I can't seems to figure out what went wrong, as the tex.ComPointer might not be the right pointer for OpenSharedResource or T开发者_C百科exture2D is not supported (it's not clearly mentioned that it isn't in the documentation)
The other alternative by specifying pHandle to be passed into the CreateTexture function is not available in SlimDX or I'm not aware of it.
Has anyone who has tried this successfully? Some help would be grateful.
Thanks
I've found the problem with my code. I need to use the DXGI to retrieve the shared handle (not pointer). The follow code works perfectly
SlimDX.DXGI.Resource r = new Resource(tex);
Texture2D tex2 = device.OpenSharedResource<Texture2D>(r.SharedHandle);
精彩评论