Skip to main content
GameDev.net gamedev.net
🔒 Locked

Shared resources (eg textures) between devices/threads

Started by ori-on Feb 8, 2013 at 10:38 PM 1 replies 6.3k views
Original Post
ori-on
ori-on

In this Microsoft article it states that sharing of resources between different d3d devices is possible on Windows Vista. The description sounds straight forward, so I gave it a try on Windows 7, but only get an D3DERR_INVALIDCALL back, when I call CreateTexture()

pSharedHandle points to a HANDLE that is 0.

D3D debug dumps the following:

Direct3D9: (ERROR) :Device is not capable of sharing resource. CreateTexture fails.
Direct3D9: (ERROR) :Failure trying to create a texture

I am using an ordinary Direct3D 9 device, not Direct3D 9Ex. But according to the docs it should work with both. I am using a Radeon 57xx, and the drivers are pretty recent. According to the docs, WDDM drivers are a requirement. Since mine are a couple of months old, I believe they should be (this is the year 2013...).

Obviously one question comes to mind: is this a Vista only feature?? Maybe they kicked it out with Win7 again?

So my question is, does anyone successfully use the pSharedHandle parameter?

Tispe
Tispe

Hi

I think it Works on Vista because of DirectX10. You can't do this With D3D9. You need to create the texture and Lock it With Your main Device/thread. After you Lock it on the main thread you can give the lock pointer to another thread and have that copy data to the texture, send the Lock pointer back to the main thread and unlock it there.

ori-on
ori-on

Sharing textures (and other resources) between devices/threads works just fine as advertised, when using D3D9Ex (and not D3D9). I wish Microsofts' documentation would state that more clearly.

The reason is that only D3D9Ex utilizes the features provided through WDDM display drivers, like eg sharing resources. So D3D9Ex was specifically introduced for people like me that want to stick with D3D9, but want to use some of the features that were introduced with Vista (and later). So thanks for that to Microsoft :)

So the actual fix was to use Direct3DCreate9Ex() and CreateDeviceEx() instead of their D3D9 predecessors. Everything else remains the same.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.