Commit de680f76 authored by Roman Sedaikin's avatar Roman Sedaikin

Added a check if the current video card is blacklisted (DX12). Added blacklist of video cards.

parent 74c1d2a0
...@@ -27,6 +27,11 @@ ...@@ -27,6 +27,11 @@
} while (false) } while (false)
const int BuffersCount = 2; const int BuffersCount = 2;
const std::vector<std::wstring> adapterBlacklist {
L"Intel(R) HD Graphics 520",
L"Intel(R) HD Graphics 530",
L"NVIDIA GeForce GTX 750 Ti",
L"NVIDIA Quadro M2000M" };
class DirectXDevice class DirectXDevice
{ {
...@@ -38,7 +43,7 @@ public: ...@@ -38,7 +43,7 @@ public:
gr_cp<ID3D12Fence> fence; gr_cp<ID3D12Fence> fence;
HANDLE fenceEvent = NULL; HANDLE fenceEvent = NULL;
uint64_t fenceValue; uint64_t fenceValue;
unsigned int bufferIndex = 1; unsigned int bufferIndex = 0;
unsigned int bufferWidth = 0; unsigned int bufferWidth = 0;
unsigned int bufferHeight = 0; unsigned int bufferHeight = 0;
...@@ -241,6 +246,21 @@ HRESULT D3DCompile( ...@@ -241,6 +246,21 @@ HRESULT D3DCompile(
return false; return false;
} }
bool isBlacklisted(IDXGIAdapter1* hardwareAdapter)
{
DXGI_ADAPTER_DESC1 desc;
hardwareAdapter->GetDesc1(&desc);
std::wstring currentAdapterName(desc.Description);
for (std::wstring name : adapterBlacklist) {
if (currentAdapterName == name)
{
fwprintf(stderr, L"Graphics card: %s is blacklisted.\n", name.c_str());
return true;
}
}
return false;
}
JNIEXPORT jlong JNICALL Java_org_jetbrains_skiko_redrawer_Direct3DRedrawer_createDirectXDevice( JNIEXPORT jlong JNICALL Java_org_jetbrains_skiko_redrawer_Direct3DRedrawer_createDirectXDevice(
JNIEnv *env, jobject redrawer, jlong windowHandle) JNIEnv *env, jobject redrawer, jlong windowHandle)
{ {
...@@ -254,6 +274,10 @@ HRESULT D3DCompile( ...@@ -254,6 +274,10 @@ HRESULT D3DCompile(
{ {
return 0; return 0;
} }
if (isBlacklisted(hardwareAdapter.get()))
{
return 0;
}
gr_cp<ID3D12Device> device; gr_cp<ID3D12Device> device;
if (!SUCCEEDED(D3D12CreateDevice(hardwareAdapter.get(), D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&device)))) if (!SUCCEEDED(D3D12CreateDevice(hardwareAdapter.get(), D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&device))))
{ {
...@@ -325,10 +349,10 @@ HRESULT D3DCompile( ...@@ -325,10 +349,10 @@ HRESULT D3DCompile(
JNIEnv *env, jobject redrawer, jlong devicePtr, jlong contextPtr, jlong surfacePtr, jboolean isVsyncEnabled) JNIEnv *env, jobject redrawer, jlong devicePtr, jlong contextPtr, jlong surfacePtr, jboolean isVsyncEnabled)
{ {
DirectXDevice *d3dDevice = fromJavaPointer<DirectXDevice*>(devicePtr); DirectXDevice *d3dDevice = fromJavaPointer<DirectXDevice*>(devicePtr);
SkSurface *surface = fromJavaPointer<SkSurface*>(surfacePtr); SkSurface *surface = fromJavaPointer<SkSurface*>(surfacePtr);
surface->flushAndSubmit();
GrDirectContext *fContext = fromJavaPointer<GrDirectContext*>(contextPtr); GrDirectContext *fContext = fromJavaPointer<GrDirectContext*>(contextPtr);
surface->flushAndSubmit();
surface->flush(SkSurface::BackendSurfaceAccess::kPresent, GrFlushInfo()); surface->flush(SkSurface::BackendSurfaceAccess::kPresent, GrFlushInfo());
fContext->flush({}); fContext->flush({});
fContext->submit(true); fContext->submit(true);
......
...@@ -54,6 +54,7 @@ internal class Direct3DContextHandler(layer: SkiaLayer) : ContextHandler(layer) ...@@ -54,6 +54,7 @@ internal class Direct3DContextHandler(layer: SkiaLayer) : ContextHandler(layer)
} }
override fun flush() { override fun flush() {
super.flush()
try { try {
directXRedrawer.finishFrame( directXRedrawer.finishFrame(
device, device,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment