Skip to content

GraphicsCapture.dll marshall error #90

@rruann

Description

@rruann

Hi rob, thank you for sharing with us this sample, very helpful I'm studying it to learn more about screen capturing using DirectX.

I have compiled the project source on Windows 10 19045.5073, using VS22 17.12.4, Radeon RX 7600 XT (drivers updated) but I'm getting these errors whenever I try to capture any window:

GraphicsCapture.dll!00007FFA693E7FFB: ReturnHr(1) tid(8a94) 8001010E The application called an interface that was marshalled for a different thread.
    Msg:[winrt::hresult_error: The application called an interface that was marshalled for a different thread.] 
C:\Users\RUAN\Desktop\Win32CaptureSample-main\Win32CaptureSample\x64\Debug\Generated Files\winrt\Windows.Graphics.Capture.h(54)\Win32CaptureSample.exe!00007FF678AFBA5B: LogHr(1) tid(8a94) 8001010E The application called an interface that was marshalled for a different thread.
    [auto __cdecl winrt::impl::consume_Windows_Graphics_Capture_IDirect3D11CaptureFramePool<struct winrt::Windows::Graphics::Capture::IDirect3D11CaptureFramePool>::Recreate(const struct winrt::Windows::Graphics::DirectX::Direct3D11::IDirect3DDevice &,const enum winrt::Windows::Graphics::DirectX::DirectXPixelFormat &,int,const struct winrt::Windows::Graphics::SizeInt32 &) const]
Win32CaptureSample.exe!00007FF678C55040: ReturnHr(1) tid(8a94) 8001010E The application called an interface that was marshalled for a different thread.
    Msg:[winrt::hresult_error: The application called an interface that was marshalled for a different thread.] 
GraphicsCapture.dll!00007FFA693E7B24: ReturnHr(2) tid(8a94) 8001010E The application called an interface that was marshalled for a different thread.
    Msg:[winrt::hresult_error: The application called an interface that was marshalled for a different thread.] 

At the moment I'm using BitBlt to capture a specific window (960x540) compress the image and send it through a websocket server, I'm taking one frame/image every 100ms which result in something like 10fps, i'm doing it like this:

// ...

BITMAPINFO bi;
data->bi.bmiHeader.biSize        = sizeof(BITMAPINFOHEADER);
data->bi.bmiHeader.biWidth       = data->width;
data->bi.bmiHeader.biHeight      = -data->height;
data->bi.bmiHeader.biPlanes      = 1;
data->bi.bmiHeader.biBitCount    = 24;
data->bi.bmiHeader.biCompression = BI_RGB;

data->hdcWindow = GetDCEx(hwnd, 0, DCX_WINDOW | DCX_CACHE);
data->hdcMemDC = CreateCompatibleDC(data->hdcWindow);
data->hbm = CreateDIBSection(data->hdcMemDC, &data->bi, DIB_RGB_COLORS, (void**)&data->Scan0, 0, 0);
SelectObject(data->hdcMemDC, data->hbm);

// ...

void capture() {
    BitBlt(data->hdcMemDC, 0, 0, data->width, data->height, data->hdcWindow, 0, 0, SRCCOPY);
}

I'm capturing 200~ windows, BitBlt is using so much GPU;
I'm reading that using DirectX is more efficient.

Using the Windows.Graphics.Capture API is it possible to take one capture every 100ms instead of a live stream?
Would it use less GPU than BitBlt in this specific use case?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions