Problem: Need to share a SlimDx.Direct3D9.Surface with another process so it can show the render output. I can create the Surface, but I have not found a way to share it between processes.
Available Code I have access to both sides of the application, but the application providing the render output is limited. I have no access to the creation of the devices. I can reference the Direct3D9 device, create a render target, and successfully capture the output.
More details
I have a feeling I will be accused of not looking first, but I can assure you I have to the best of my ability.
But, I'm trying to share a DirectX 9 Surface to another process so I can capture the render output within an external form.
I have found several things on Shared Surfaces, but haven't seemed to figure out how to do it with a DirectX 9 device sharing surfaces between 2 process.
My access to the DirectX device itself is limited. I am accessing it through a built in scripting module embeded in the application. I do not have the option of knowing creation properties or parameters that aren't public variables but I do have complete access to the Device itself.
So with the code below (to demonstrate exactly what I have to work with for the most part) I'm trying to figure out how I could share that Surface with another process so I can get the renderer's output on that Form.
Basically, I have code that looks like this: (simplified)
byte[] ARGB;
//Getting internal access to renderer's Direct3D9.Device (Already created)
SlimDx.Direct3D9.Device dev = renderer.Device.Device;
//Surface I create to capture the devices output
SlimDx.Direct3D9.Surface destination;
//Create render target to device
destination = Surface.CreateRenderTarget(this.dev, this.w, this.h, Format.A8R8G8B8, MultisampleType.None, 0, true);
// 1. Render,
// 2. then grab snapshot (internal call),
// 3. convert to byte array (not relevant to what I'm currently doing)
if (this.renderer.Render())
{
board.Snapshot(this.destination); //some internal logic to get surface
try
{
using (DataStream data = destination.LockRectangle(LockFlags.ReadOnly).Data)
{
data.Read(ARGB, 0, (int) data.Length);
}
}
finally
{
this.destination.UnlockRectangle();
}
}