CUDA Direct2d Interoperability

Hello,

I would like to combine CUDA and Direct2D functionality. Practically, I have a 2d image that is processed by CUDA and then Direct2D should render the result of that operation onto the screen.
The existing CUDA samles give an example how this can be achieved with Direct3D11 using textures. This provides more or less the result I would like to see but not directly using D2D.
Is there any alternative in terms of a direct integration between the two technologies?

Thanks!

Lars

For anyone, having the same need: it is possible on pixel level, for the price, that you have to implement every drawing yourself. Just draw into an array and use it as a second screen buffer (double buffering).

#define SCREEN_WIDTH 1920
#define SCREEN_HEIGHT 1000

D2D1_RECT_U display_area;
ID2D1Bitmap *image_container = NULL;
unsigned int image_data[SCREEN_WIDTH * SCREEN_HEIGHT];

void create_main_buffer(void)
{
pRT->CreateBitmap(D2D1::SizeU(SCREEN_WIDTH, SCREEN_HEIGHT),
D2D1::BitmapProperties(D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM,
D2D1_ALPHA_MODE_IGNORE)), &image_container);
}

void cleanup_main_buffer(void)
{
memset(image_data, 255, SCREEN_HEIGHT*SCREEN_WIDTH * sizeof(unsigned int));
}

void swap_main_buffer(void)
{
display_area.left = 0;
display_area.top = 0;
display_area.right = SCREEN_WIDTH;
display_area.bottom = SCREEN_HEIGHT;
image_container->CopyFromMemory(&display_area, image_data, SCREEN_WIDTH * sizeof(unsigned int));
pRT->BeginDraw();
pRT->DrawBitmap(image_container, D2D1::RectF(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), 1.0f, D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, NULL);
pRT->EndDraw();
}

In the CUDA version, you have to implement the memory handling and the drawing mehtods of course. But the basic idea is the esame: “draw into an array and display it as a bitmap” !

I have recently written a book about a CUDA accelerated Direct2D rendering engine, available on Amazon:
https://www.amazon.com/Programming-extreme-performance-Krisztián-Fehér-ebook/dp/B07SQNMGFH