Commit e44b2920 authored by Nikolay Igotti's avatar Nikolay Igotti

Dynamically detect Direct3D 12

parent 78fc304d
...@@ -382,7 +382,6 @@ tasks.withType(LinkSharedLibrary::class.java).configureEach { ...@@ -382,7 +382,6 @@ tasks.withType(LinkSharedLibrary::class.java).configureEach {
"opengl32.lib", "opengl32.lib",
"shcore.lib", "shcore.lib",
"user32.lib", "user32.lib",
"d3d12.lib",
"dxgi.lib", "dxgi.lib",
"d3dcompiler.lib" "d3dcompiler.lib"
) )
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include <d3d12.h> #include <d3d12.h>
#include <dxgi1_4.h> #include <dxgi1_4.h>
#define GR_D3D_CALL_ERRCHECK(X) \ #define GR_D3D_CALL_ERRCHECK(X) \
do \ do \
{ \ { \
...@@ -49,6 +48,55 @@ public: ...@@ -49,6 +48,55 @@ public:
extern "C" extern "C"
{ {
HRESULT D3D12CreateDevice(
IUnknown *pAdapter,
D3D_FEATURE_LEVEL MinimumFeatureLevel,
REFIID riid,
void **ppDevice
) {
typedef HRESULT (*D3D12CreateDevice_t)(
IUnknown *pAdapter,
D3D_FEATURE_LEVEL MinimumFeatureLevel,
REFIID riid,
void **ppDevice
);
static D3D12CreateDevice_t impl = nullptr;
if (!impl) {
auto d3d12dll = LoadLibrary(TEXT("D3D12.dll"));
if (!d3d12dll)
return E_NOTIMPL;
impl = (D3D12CreateDevice_t)GetProcAddress(d3d12dll, "D3D12CreateDevice");
if (!impl)
return E_NOTIMPL;
}
return impl(pAdapter, MinimumFeatureLevel, riid, ppDevice);
}
HRESULT D3D12SerializeRootSignature(
const D3D12_ROOT_SIGNATURE_DESC *pRootSignature,
D3D_ROOT_SIGNATURE_VERSION Version,
ID3DBlob **ppBlob,
ID3DBlob **ppErrorBlob
) {
typedef HRESULT (*D3D12SerializeRootSignature_t)(
const D3D12_ROOT_SIGNATURE_DESC *pRootSignature,
D3D_ROOT_SIGNATURE_VERSION Version,
ID3DBlob **ppBlob,
ID3DBlob **ppErrorBlob
);
static D3D12SerializeRootSignature_t impl = nullptr;
if (!impl) {
auto d3d12dll = LoadLibrary(TEXT("D3D12.dll"));
if (!d3d12dll)
return E_NOTIMPL;
impl = (D3D12SerializeRootSignature_t)GetProcAddress(d3d12dll, "D3D12SerializeRootSignature");
if (!impl)
return E_NOTIMPL;
}
return impl(pRootSignature, Version, ppBlob, ppErrorBlob);
}
JNIEXPORT jlong JNICALL Java_org_jetbrains_skiko_redrawer_Direct3DRedrawer_makeDirectXContext( JNIEXPORT jlong JNICALL Java_org_jetbrains_skiko_redrawer_Direct3DRedrawer_makeDirectXContext(
JNIEnv* env, jobject redrawer, jlong devicePtr) JNIEnv* env, jobject redrawer, jlong devicePtr)
{ {
......
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