문제

I am writing an application using DirectX11 Direct2D, part of which is loading and drawing sequence of image files in realtime (video overlay). The size of these image files vary (100x100 ~ 2000x2000 x RGBA). There will be optiziations, preloading(prebuffering) logic, but I want to understand what is the proper/best practice/method to do this.

Here is the current workflow, I follow:

  1. Load file with WIC,
  2. Convert to PBGRA bitmap (optional),
  3. Lock the WIC pixels,
  4. Create D2D1Bitmap using this pixel data

However, the problem is that this is slow. It bottlenecks at point #4 - transfering pixel data to the VRAM. So I am looknig for a faster way (ie - what is the fastest one).

So, is there a way to load image, in a form of texture, or other way, directly as a DirectX resource, so I can minimize the time for the whole process/iteration? And eventually avoid using the WIC component?

Thanks in advance Best Regards

도움이 되었습니까?

해결책

After some research and experiments I came with the following solution:

General approach

I minimized the transferred data size, by tracking the differences between the frames, so in the new frame I create bitmap only for the area, which differs from the previous frame. And then draw this smaller bitmap to it's relevant position on the previous frame bitmap. Of course, this tracking could not be done in real-time, but luckily in my case I am able to evaluate the different bitmap areas in advance.

Another thing I did was to prepare my bitmap data in B8R8G8A8_UNORM, (that is 32bppPBGRA WIC format) so I can avoid converting to this pixel format at run time.

Windows 8.1

I haven't test this, but it seems with Windows 8.1 Direct2D provides block compression support for ID2D1Bitmap (msdn). This means one can prepare big bitmap in DDS format, and load those compressed directly to the video RAM, which will be far less data amount related to uncompressed bitmap.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top