question

chenhaoli-5094 avatar image
0 Votes"
chenhaoli-5094 asked RoyLi-MSFT commented

shared texture in dx9 between processes

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
114357-thumbnail-265cfcc604c55243866ede4d351d0451png.png


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
114368-thumbnail-ec50cda2d907d84d9b052ff4007926e4png.png

the HRESULT res is OK, the result is just like can not find the texture data.

Any suggestions will help, thanks


windows-uwp
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Could you please tell me what kind of project that you are developing? Is it a UWP app?

0 Votes 0 ·

0 Answers