S
S
syxme2021-04-14 17:49:54
C++ / C#
syxme, 2021-04-14 17:49:54

Direct2d winapi why high gpu load on dwm.exe?

direct2d initialization

D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &factory);
    DWriteCreateFactory(DWRITE_FACTORY_TYPE_ISOLATED, __uuidof(IDWriteFactory), reinterpret_cast<IUnknown **>(&wFactory));
    DPIScale::Initialize(factory);
    HWND hand = mWindowStatic->getWindowHandle();
    factory->CreateHwndRenderTarget(D2D1::RenderTargetProperties(),D2D1::HwndRenderTargetProperties(hand, D2D1::SizeU(mWidth, mHeight)),&renderTarget);
        renderTarget->SetDpi(96, 96);

Creating a Windows Window
WNDCLASSEXW windowClass = {0};
    windowClass.cbSize = sizeof(WNDCLASSEX);
    windowClass.hbrBackground = NULL;
    windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
    windowClass.hInstance = NULL;
    //windowClass.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW + 1);
    windowClass.lpfnWndProc = MessageRouter;
    windowClass.lpszClassName = title.c_str();
    windowClass.lpszMenuName  = NULL;
    windowClass.style = CS_HREDRAW | CS_VREDRAW;
    RegisterClassExW(&windowClass);

    int aElements[2] = {COLOR_ACTIVECAPTION, COLOR_ACTIVECAPTION};

    windowHandle = CreateWindowExA(
        WS_EX_WINDOWEDGE,
        std::string(title.cbegin(),title.cend()).c_str(),
        NULL,
        WS_POPUP | WS_VISIBLE | WS_SIZEBOX,
        posX,
        posY,
        width,
        height,
        NULL,
        NULL,
        NULL,
        this);


And of course drawing
renderTarget->BeginDraw();
//1 кадр рисую UI 
//Все остальные кадры перерисовываю область 100x50px через PushAxisAlignedClip
renderTarget->PushAxisAlignedClip(rect,D2D1_ANTIALIAS_MODE_ALIASED);

renderTarget->PopAxisAlignedClip();

renderTarget->EndDraw();

The problem is that even if I optimize the rendering by redrawing dirty triangles, dwm is loaded in such a way that it looks like the entire image buffer is being sent to it.
Is it possible to somehow tell him that I'm only redrawing a small area of ​​the window?

PS I draw the interface completely on direct2d, without the participation of WM_PAINT

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question