I am using an existing graphics library, one of which uses Direct2D. (It can also use GDI +, Quartz, etc.). It has bitmap objects, pens, brushes, etc. All of them are implemented as shell code around Direct2D objects. The library is closed, and unfortunately, I probably can’t post it here.
I found that when using multiple streams - one thread manufacturer, creating bitmaps and drawing them for one thread consumer, drawing them on the screen - sometimes the bitmap created by the manufacturer is completely empty: the image data (internal textures) are all zeros. (A bitmap is a wrapper around a texture, but it may be a bitmap, for example, you might think of a GDI + bitmap object. I'm sure you are familiar with the general paradigm.) Note that it never fails, sometimes quietly fails. A typical symptom is to draw bitmap data, causing it Unmapto be copied from the buffer back to the texture and searched when you later try to draw it that the texture is empty.
I think this is happening:
- For direct recording in the pixel data, as does my producer thread library provides functions
Mapand Unmapdirect access to the pixel data. There is one DirectX10 device, a “shared device,” and it is used to call CopyResource to copy from the internal texture to the buffer, which can then be written freely and then deployed copies back to the other side. I think sometimes this silently fails. - This approach of common devices is used throughout the library: there is a common target rendering (
ID2D1RenderTarget) used to create a common bitmap ( ID2D1Bitmap), etc. The approach seems to be that the graphics / bitmap objects have their own textures, of course, but all operations on them are performed with one device, one rendering goal, etc. - When multiple threads use “bitmaps” at the same time, several operations may occur:
CopyResource(mentioned above), which returns voidnot HRESULT, sometimes a crash occurs; ID2D1RenderTarget::DrawBitmapalso does not work.
, . -. ?
Direct2D .
D2D1_FACTORY_TYPE_MULTI_THREADED.
ID2D1MultiThread . , , Windows 7 : API- DirectX10, Vista +.
ID3D10Multithread . :
, , . , , Map Unmap, Present, MSDN, : . , ID2D1RenderTarget:: BeginDraw, ID2D1RenderTarget::EndDraw, ID2D1RenderTarget::Flush / IDXGISwapChain::Present, ... . MSDN ,
, . , IDXGISwapChain1:: Present1 ( ) -. , , Present1:: SetWindowPos() :: SetWindowStyle() call:: SendMessage(). , - , , , . -
... , . , -, , , , BeginDraw, . , , , , .
"" , .. , , , . , : , , ( ), - . , - CreateSharedBitmap, D2DERR_UNSUPPORTED_OPERATION, ( , ). , ( ), , . , , 1:1 , ..
, , , , , , . ? - ID3D10Texture2D ID3D10Device1 s? ?
, , , Direct3D 10 Direct2D . , :
ID3D10Multithread. Google , , MSDN.
, , .. ( - , , , thread?) , , ? , , , , .
. Direct2D .