Skip to content

Commit 45b5869

Browse files
committed
Completely new Direct-X renderer
1 parent fd772bc commit 45b5869

11 files changed

+1006
-344
lines changed

.github/workflows/build.yml

+3-13
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
matrix:
1919
config:
2020
#Linux-aarch64
21-
- os: ubuntu-latest
21+
- os: ubuntu-24.04-arm
2222
name: Linux-aarch64
2323
other_linker_flags: '-L/usr/aarch64-linux-gnu/local/lib'
2424
arch: aarch64
@@ -82,24 +82,14 @@ jobs:
8282
run: |
8383
#source_version=$(cat /etc/apt/sources.list | grep "main restricted" | head -1 | sed -e 's/.*com\/ //' -e 's/ main.*//')
8484
#echo "Found: ${ source_version }"
85-
sudo sed -Ei 's/^deb /deb \[arch=amd64\,i386\] /' /etc/apt/sources.list
86-
echo "deb [arch=arm64] http://ports.ubuntu.com/ jammy main restricted" | sudo tee -a /etc/apt/sources.list
87-
echo "deb [arch=arm64] http://ports.ubuntu.com/ jammy-updates main restricted" | sudo tee -a /etc/apt/sources.list
88-
echo "deb [arch=arm64] http://ports.ubuntu.com/ jammy universe" | sudo tee -a /etc/apt/sources.list
89-
echo "deb [arch=arm64] http://ports.ubuntu.com/ jammy-updates universe" | sudo tee -a /etc/apt/sources.list
90-
echo "deb [arch=arm64] http://ports.ubuntu.com/ jammy multiverse" | sudo tee -a /etc/apt/sources.list
91-
echo "deb [arch=arm64] http://ports.ubuntu.com/ jammy-updates multiverse" | sudo tee -a /etc/apt/sources.list
92-
echo "deb [arch=arm64] http://ports.ubuntu.com/ jammy-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
93-
94-
sudo dpkg --add-architecture arm64
9585
sudo apt-get update
9686
9787
- name: Dependencies - Linux-aarch64
9888
if: matrix.config.name == 'Linux-aarch64'
9989
run: |
10090
sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
10191
#sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
102-
sudo apt-get install libprocps-dev:arm64 mesa-common-dev:arm64 libglu1-mesa:arm64 libglu1-mesa-dev:arm64 libgl1-mesa-glx:arm64 libgl1-mesa-dev:arm64 libglfw3-dev:arm64 cmake
92+
sudo apt-get install procps:arm64 mesa-common-dev:arm64 libglu1-mesa:arm64 libglu1-mesa-dev:arm64 libgl1:arm64 libgl1-mesa-dev:arm64 libglfw3-dev:arm64 cmake
10393
sudo apt-get install openjdk-11-jdk
10494
sudo apt-get install libpython3-dev:arm64
10595
@@ -122,7 +112,7 @@ jobs:
122112
if: matrix.config.name == 'Linux-64'
123113
run: |
124114
sudo apt-get update
125-
sudo apt-get install libprocps-dev mesa-common-dev libglu1-mesa libglu1-mesa-dev libgl1-mesa-glx libgl1-mesa-dev libpython3-dev clang cmake g++
115+
sudo apt-get install procps mesa-common-dev libglu1-mesa libglu1-mesa-dev libgl1 libgl1-mesa-dev libpython3-dev clang cmake g++
126116
127117
- name: CMake Generate Build Files - Linux-64
128118
if: matrix.config.name == 'Linux-64'

CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,11 @@ target_include_directories(${PROJECT_NAME} PRIVATE ${INCLUDE_DIRECTORIES})
313313

314314
IF(PYTHON_BINDINGS)
315315
IF (USE_PYBIND11)
316-
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_DETOURS=1 HOOK_OPENGL_BLIT=1 USE_PYBIND11=1 Py_BUILD_CORE=1 Py_NO_ENABLE_SHARED=1)
316+
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_DETOURS=1 HOOK_OPENGL_BLIT=1 HOOK_OPENGL_SWAP=1 USE_PYBIND11=1 Py_BUILD_CORE=1 Py_NO_ENABLE_SHARED=1)
317317
ELSEIF(Py_LIMITED_API)
318-
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_DETOURS=1 HOOK_OPENGL_BLIT=1 Py_LIMITED_API=${Py_LIMITED_API} Py_BUILD_CORE=1 Py_NO_ENABLE_SHARED=1)
318+
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_DETOURS=1 HOOK_OPENGL_BLIT=1 HOOK_OPENGL_SWAP=1 Py_LIMITED_API=${Py_LIMITED_API} Py_BUILD_CORE=1 Py_NO_ENABLE_SHARED=1)
319319
ELSE()
320-
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_DETOURS=1 HOOK_OPENGL_BLIT=1 Py_BUILD_CORE=1 Py_NO_ENABLE_SHARED=1)
320+
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_DETOURS=1 HOOK_OPENGL_BLIT=1 HOOK_OPENGL_SWAP=1 Py_BUILD_CORE=1 Py_NO_ENABLE_SHARED=1)
321321
ENDIF()
322322
ELSE()
323323
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_DETOURS=1 HOOK_OPENGL_BLIT=1)

RemoteInput/Platform/NativeHooks_Darwin.cxx

+14-14
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ __attribute__ ((section ("__DATA,__interpose"))) = { (const void*)(unsigned long
2727

2828
#if defined(__APPLE__)
2929
std::unique_ptr<Hook> native_hook{nullptr};
30-
std::unique_ptr<Hook> opengl_hook{nullptr};
31-
std::unique_ptr<Hook> flush_buffer_hook{nullptr};
30+
std::unique_ptr<Hook> opengl_blit_hook{nullptr};
31+
std::unique_ptr<Hook> opengl_flush_buffer_hook{nullptr};
3232

3333
bool can_render(jint srctype, jint width, jint height)
3434
{
@@ -229,9 +229,9 @@ void JavaNativeOGLBlit(JNIEnv *env, void *oglc, jlong pSrcOps, jlong pDstOps, jb
229229

230230
if (!srcOps || width <= 0 || height <= 0 || !can_render(srctype, width, height))
231231
{
232-
if (opengl_hook)
232+
if (opengl_blit_hook)
233233
{
234-
return opengl_hook->call<void, decltype(JavaNativeOGLBlit)>(env, oglc, pSrcOps, pDstOps, xform, hint, srctype, texture, sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2);
234+
return opengl_blit_hook->call<void, decltype(JavaNativeOGLBlit)>(env, oglc, pSrcOps, pDstOps, xform, hint, srctype, texture, sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2);
235235
}
236236
return;
237237
}
@@ -307,9 +307,9 @@ void JavaNativeOGLBlit(JNIEnv *env, void *oglc, jlong pSrcOps, jlong pDstOps, jb
307307
}
308308
}
309309

310-
if (opengl_hook)
310+
if (opengl_blit_hook)
311311
{
312-
return opengl_hook->call<void, decltype(JavaNativeOGLBlit)>(env, oglc, pSrcOps, pDstOps, xform, hint, srctype, texture, sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2);
312+
return opengl_blit_hook->call<void, decltype(JavaNativeOGLBlit)>(env, oglc, pSrcOps, pDstOps, xform, hint, srctype, texture, sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2);
313313
}
314314
}
315315

@@ -381,7 +381,7 @@ void JavaNativeOGLRenderQueueFlushBuffer(JNIEnv *env, jobject oglrq, jlong buf,
381381
}
382382
}
383383

384-
return flush_buffer_hook->call<void, decltype(JavaNativeOGLRenderQueueFlushBuffer)>(env, oglrq, original_buffer, limit);
384+
return opengl_flush_buffer_hook->call<void, decltype(JavaNativeOGLRenderQueueFlushBuffer)>(env, oglrq, original_buffer, limit);
385385
}
386386
#endif
387387

@@ -518,7 +518,7 @@ CGLError mCGLFlushDrawable(CGLContextObj ctx) noexcept
518518
}
519519
}
520520

521-
return opengl_hook->call<CGLError, decltype(mCGLFlushDrawable)>(ctx);
521+
return opengl_blit_hook->call<CGLError, decltype(mCGLFlushDrawable)>(ctx);
522522
}
523523
#else
524524
CGLError mCGLFlushDrawable(CGLContextObj ctx) noexcept
@@ -595,24 +595,24 @@ void InitialiseHooks() noexcept
595595
blit = dlsym(RTLD_DEFAULT, "OGLBlitLoops_Blit");
596596
if (blit)
597597
{
598-
opengl_hook = std::make_unique<Hook>(reinterpret_cast<void*>(blit), reinterpret_cast<void*>(JavaNativeOGLBlit));
599-
opengl_hook->apply();
598+
opengl_blit_hook = std::make_unique<Hook>(reinterpret_cast<void*>(blit), reinterpret_cast<void*>(JavaNativeOGLBlit));
599+
opengl_blit_hook->apply();
600600
}
601601
else
602602
{
603603
blit = dlsym(RTLD_DEFAULT, "Java_sun_java2d_opengl_OGLRenderQueue_flushBuffer");
604604
if (blit)
605605
{
606-
flush_buffer_hook = std::make_unique<Hook>(reinterpret_cast<void*>(blit), reinterpret_cast<void*>(JavaNativeOGLRenderQueueFlushBuffer));
607-
flush_buffer_hook->apply();
606+
opengl_flush_buffer_hook = std::make_unique<Hook>(reinterpret_cast<void*>(blit), reinterpret_cast<void*>(JavaNativeOGLRenderQueueFlushBuffer));
607+
opengl_flush_buffer_hook->apply();
608608
}
609609
}
610610

611611
if (!blit)
612612
{
613613
blit = dlsym(RTLD_DEFAULT, "CGLFlushDrawable");
614-
opengl_hook = std::make_unique<Hook>(reinterpret_cast<void*>(blit), reinterpret_cast<void*>(mCGLFlushDrawable));
615-
opengl_hook->apply();
614+
opengl_blit_hook = std::make_unique<Hook>(reinterpret_cast<void*>(blit), reinterpret_cast<void*>(mCGLFlushDrawable));
615+
opengl_blit_hook->apply();
616616
}
617617
#endif
618618
#else

RemoteInput/Platform/NativeHooks_Linux.cxx

+16-16
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
#if defined(__linux__)
2020
std::unique_ptr<Hook> native_hook{nullptr};
21-
std::unique_ptr<Hook> opengl_hook{nullptr};
22-
std::unique_ptr<Hook> flush_buffer_hook{nullptr};
21+
std::unique_ptr<Hook> opengl_blit_hook{nullptr};
22+
std::unique_ptr<Hook> opengl_flush_buffer_hook{nullptr};
2323

2424
bool can_render(jint srctype, jint width, jint height)
2525
{
@@ -220,9 +220,9 @@ void JavaNativeOGLBlit(JNIEnv *env, void *oglc, jlong pSrcOps, jlong pDstOps, jb
220220

221221
if (!srcOps || width <= 0 || height <= 0 || !can_render(srctype, width, height))
222222
{
223-
if (opengl_hook)
223+
if (opengl_blit_hook)
224224
{
225-
return opengl_hook->call<void, decltype(JavaNativeOGLBlit)>(env, oglc, pSrcOps, pDstOps, xform, hint, srctype, texture, sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2);
225+
return opengl_blit_hook->call<void, decltype(JavaNativeOGLBlit)>(env, oglc, pSrcOps, pDstOps, xform, hint, srctype, texture, sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2);
226226
}
227227
return;
228228
}
@@ -298,9 +298,9 @@ void JavaNativeOGLBlit(JNIEnv *env, void *oglc, jlong pSrcOps, jlong pDstOps, jb
298298
}
299299
}
300300

301-
if (opengl_hook)
301+
if (opengl_blit_hook)
302302
{
303-
return opengl_hook->call<void, decltype(JavaNativeOGLBlit)>(env, oglc, pSrcOps, pDstOps, xform, hint, srctype, texture, sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2);
303+
return opengl_blit_hook->call<void, decltype(JavaNativeOGLBlit)>(env, oglc, pSrcOps, pDstOps, xform, hint, srctype, texture, sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2);
304304
}
305305
}
306306

@@ -372,7 +372,7 @@ void JavaNativeOGLRenderQueueFlushBuffer(JNIEnv *env, jobject oglrq, jlong buf,
372372
}
373373
}
374374

375-
return flush_buffer_hook->call<void, decltype(JavaNativeOGLRenderQueueFlushBuffer)>(env, oglrq, original_buffer, limit);
375+
return opengl_flush_buffer_hook->call<void, decltype(JavaNativeOGLRenderQueueFlushBuffer)>(env, oglrq, original_buffer, limit);
376376
}
377377
#endif
378378

@@ -571,7 +571,7 @@ extern "C" [[gnu::visibility("default")]] void glXSwapBuffers(Display* dpy, GLXD
571571
}
572572

573573
#if defined(USE_DETOURS)
574-
return opengl_hook->call<void, decltype(glXSwapBuffers)>(dpy, drawable);
574+
return opengl_blit_hook->call<void, decltype(glXSwapBuffers)>(dpy, drawable);
575575
#else
576576
static decltype(glXSwapBuffers)* o_glXSwapBuffers = reinterpret_cast<decltype(glXSwapBuffers)*>(dlsym(RTLD_NEXT, "glXSwapBuffers"));
577577
return o_glXSwapBuffers(dpy, drawable);
@@ -596,16 +596,16 @@ void InitialiseHooks() noexcept
596596
blit = dlsym(RTLD_DEFAULT, "OGLBlitLoops_Blit");
597597
if (blit)
598598
{
599-
opengl_hook = std::make_unique<Hook>(reinterpret_cast<void*>(blit), reinterpret_cast<void*>(JavaNativeOGLBlit));
600-
opengl_hook->apply();
599+
opengl_blit_hook = std::make_unique<Hook>(reinterpret_cast<void*>(blit), reinterpret_cast<void*>(JavaNativeOGLBlit));
600+
opengl_blit_hook->apply();
601601
}
602602
else
603603
{
604604
blit = dlsym(RTLD_DEFAULT, "Java_sun_java2d_opengl_OGLRenderQueue_flushBuffer");
605605
if (blit)
606606
{
607-
flush_buffer_hook = std::make_unique<Hook>(reinterpret_cast<void*>(blit), reinterpret_cast<void*>(JavaNativeOGLRenderQueueFlushBuffer));
608-
flush_buffer_hook->apply();
607+
opengl_flush_buffer_hook = std::make_unique<Hook>(reinterpret_cast<void*>(blit), reinterpret_cast<void*>(JavaNativeOGLRenderQueueFlushBuffer));
608+
opengl_flush_buffer_hook->apply();
609609
}
610610
}
611611

@@ -614,16 +614,16 @@ void InitialiseHooks() noexcept
614614
blit = dlsym(RTLD_DEFAULT, "glXSwapBuffers");
615615
if (blit)
616616
{
617-
opengl_hook = std::make_unique<Hook>(reinterpret_cast<void*>(blit), reinterpret_cast<void*>(glXSwapBuffersHook));
618-
opengl_hook->apply();
617+
opengl_blit_hook = std::make_unique<Hook>(reinterpret_cast<void*>(blit), reinterpret_cast<void*>(glXSwapBuffersHook));
618+
opengl_blit_hook->apply();
619619
}
620620
}
621621
#else
622622
blit = dlsym(RTLD_NEXT, "glXSwapBuffers");
623623
if (blit)
624624
{
625-
opengl_hook = std::make_unique<Hook>(reinterpret_cast<void*>(blit), reinterpret_cast<void*>(glXSwapBuffersHook));
626-
opengl_hook->apply();
625+
opengl_blit_hook = std::make_unique<Hook>(reinterpret_cast<void*>(blit), reinterpret_cast<void*>(glXSwapBuffersHook));
626+
opengl_blit_hook->apply();
627627
}
628628
#endif
629629
#endif

0 commit comments

Comments
 (0)