@benkuper:
I know I should get some samples online soon. They are on my harddisk, but a bit too messy. I will try to clean them up somewhere in the next few eeks, and get them on github.
It is true that Wyphon is built on something else I wrote, that makes it easy to broadcast messages between applications.
I don’t think that it would be a splendid idea to send whole images though, as 1 message (I am actually using mailslots) would be sent to every ‘partner’ application. That’s cool for small messages, but not for big things like image data.
Another idea could be, that we add some functions to Wyphon, that allow you to easily share information about shared-memory, that contains an image. This way, a ‘sender’ could update that shared memory, and the ‘receivers’ could read that.
But I guess such things exist already when using the right freeframe plugins. Apart from that, performance and frame size will probably always be limited, which is of course why people want to share images on the GPU.
I copied some code as an example of how to setup the callbacks in C++ and D3D11:
//--------------------------------------------------------------------------------------
// Wyphon Callback functions
//
//--------------------------------------------------------------------------------------
void D3DTextureSharingStartedCALLBACK( HANDLE wyphonPartnerHandle, unsigned **int32 sendingPartnerId, HANDLE sharedTextureHandle, unsigned**int32 width, unsigned __int32 height, DWORD format, DWORD usage, LPTSTR description ) {
int newIndex = -1;
for ( int i = 0; i <= g_maxSharedTextureIndex; i++ ) {
if ( g_pSharedTextureHandles[i](i) == sharedTextureHandle ) {
//texture already known, do nothing
return;
}
if ( g_pSharedTextureHandles[i](i) == NULL ) {
newIndex = i;
break;
}
}
ID3D11Resource * tempResource11;
g_pd3dDevice->OpenSharedResource(sharedTextureHandle, __uuidof(ID3D11Resource), (void**)(&tempResource11));
if (tempResource11 != NULL) {
g_pSharedTextures[newIndex](newIndex) = NULL;
g_pWyphonShaderRVs[newIndex](newIndex) = NULL;
tempResource11->QueryInterface(__uuidof(ID3D11Texture2D), (void**)(&g_pSharedTextures[newIndex](newIndex)));
tempResource11->Release();
// now use g_pSharedTexture with pDevice11
if ( g_pSharedTextures[newIndex](newIndex) != NULL ) {
if ( ! FAILED( g_pd3dDevice->CreateShaderResourceView( g_pSharedTextures[newIndex](newIndex), NULL, &g_pWyphonShaderRVs[newIndex](newIndex) ) ) ) {
g_pSharedTextureHandles[newIndex](newIndex) = sharedTextureHandle;
}
else {
//cleanup this shared texture?
g_pSharedTextureHandles[newIndex](newIndex) = NULL;
g_pSharedTextures[newIndex](newIndex)->Release();
}
}
}
}
void D3DTextureSharingStoppedCALLBACK( HANDLE wyphonPartnerHandle, unsigned int sendingPartnerId, HANDLE sharedTextureHandle, unsigned int width, unsigned int height, DWORD format, DWORD usage, LPTSTR description ) {
//find handle
int index = -1;
for ( int i = 0; i <= g_maxSharedTextureIndex; i++ ) {
if ( g_pSharedTextureHandles[i](i) == sharedTextureHandle ) {
index = i;
break;
}
}
if ( index > -1 ) {
//if found, empty that spot
g_pSharedTextureHandles[index](index) = NULL;
g_pSharedTextures[index](index)->Release();
g_pWyphonShaderRVs[index](index)->Release();
}
}
And then somewhere in your initialization method:
///////////////////
//// SETUP Wyphon
///////////////////
for ( int i = 0; i <= g_maxSharedTextureIndex; i++ ) {
g_pSharedTextureHandles[i](i) = NULL;
}
//2 callbacks since we are only interested in textures from other partners, not who those partners are
g_hWyphonPartner = CreateWyphonPartner( is64bit ? TEXT("Wyphon RECEIVER test 64bit") : TEXT("Wyphon RECEIVER test 32bit")
, NULL
, NULL
, NULL
, D3DTextureSharingStartedCALLBACK
, D3DTextureSharingStoppedCALLBACK
);