Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows. Fix a crash on CI without dcomp.dll #909

Merged
merged 7 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions skiko/src/awtMain/cpp/windows/DCompLibrary.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once
MatkovIvan marked this conversation as resolved.
Show resolved Hide resolved

#include "include/DCompLibrary.h"

namespace DCompLibrary {
static HINSTANCE getLibrary() {
static HINSTANCE library = LoadLibrary("dcomp.dll");
return library;
}

HRESULT DCompositionCreateDevice(
IDXGIDevice *dxgiDevice,
REFIID iid,
void **dcompositionDevice
) {
HINSTANCE library = getLibrary();

if (library != nullptr) {
typedef HRESULT(WINAPI * PROC_DCompositionCreateDevice)(IDXGIDevice * dxgiDevice, REFIID iid, void **dcompositionDevice);
static auto compositionCreateDevice = (PROC_DCompositionCreateDevice) GetProcAddress(library, "DCompositionCreateDevice");
return compositionCreateDevice(dxgiDevice, iid, dcompositionDevice);
} else {
return E_FAIL;
}
}
};
igordmn marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 2 additions & 4 deletions skiko/src/awtMain/cpp/windows/directXRedrawer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "SkSurface.h"
#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include "../common/interop.hh"
#include "include/DCompLibrary.h"

#include "d3d/GrD3DTypes.h"
#include <d3d12sdklayers.h>
Expand All @@ -20,9 +21,6 @@
#include <dxgi1_4.h>
#include <dxgi1_6.h>

#include <dcomp.h>
#pragma comment(lib, "dcomp.lib")

const int BuffersCount = 2;

class DirectXDevice
Expand Down Expand Up @@ -95,7 +93,7 @@ class DirectXDevice
HRESULT result = swapChainFactory4->CreateSwapChainForComposition(queue.get(), &swapChainDesc, nullptr, swapChain1);
if (FAILED(result)) { return result; }

result = DCompositionCreateDevice(0, IID_PPV_ARGS(&dcDevice));
result = DCompLibrary::DCompositionCreateDevice(0, IID_PPV_ARGS(&dcDevice));
if (FAILED(result)) { return result; }
result = dcDevice->CreateTargetForHwnd(hWnd, true, &dcTarget);
if (FAILED(result)) { return result; }
Expand Down
11 changes: 11 additions & 0 deletions skiko/src/awtMain/cpp/windows/include/DCompLibrary.h
MatkovIvan marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#include <dcomp.h>

namespace DCompLibrary {
HRESULT DCompositionCreateDevice(
IDXGIDevice *dxgiDevice,
REFIID iid,
void **dcompositionDevice
);
};
Loading