shared texture in dx9 between processes
chenhao li
1
Reputation point
I want to share texture resource between different processes. My problem is that when I create a shared texture in process A, then I create a texture in process B by using sharedHandle. the createTexture funciton return S_OK, but when I want to show the texture , it shows a black texture.
Here is the process A:
HANDLE SharedHandle = nullptr;
IDirect3DTexture9* d3dTex = nullptr;
D3DLOCKED_RECT lockrect;
HRESULT res = g_pD3D_DeviceEx->CreateTexture(8, 8, 1,
D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3dTex, &SharedHandle);
res = d3dTex->LockRect(0, &lockrect, 0, 0);
pData = (DWORD*)((BYTE*)lockrect.pBits + lockrect.Pitch);
for (int y = 0; y < 8; y++)
{
for (int x = 0; x < 8; x++)
pData[x] = Image[y * 8 + x];
}
d3dTex->UnlockRect(0);
....
g_pD3D_DeviceEx->SetTexture(0, d3dTex);
the result is
the process B is just like A but without LockRect, just create it by shared handle
HANDLE SharedHandle = pSharedHandle; //get the handle from A process
IDirect3DTexture9* d3dTex = nullptr;
HRESULT res = g_pD3D_DeviceEx->CreateTexture(8, 8, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &d3dTex, &SharedHandle);
....
g_pD3D_DeviceEx->SetTexture(0, d3dTex);
while the result is
the HRESULT res is OK, the result is just like can not find the texture data.
Any suggestions will help, thanks
Sign in to answer