Initial commit: 在 Minecraft Java 版接入 NVIDIA DLSS 超分与帧生成

This commit is contained in:
WpyQwq
2026-09-19 11:51:46 +08:00
commit 8acb8bbac6
89 changed files with 51201 additions and 0 deletions
+62
View File
@@ -0,0 +1,62 @@
@echo off
REM ---------------------------------------------------------------------------
REM Build the native bridge DLL (wpywdlss_bridge.dll).
REM
REM Sets up the MSVC x64 environment itself, so this can be run from a plain
REM cmd or PowerShell. Requires CMake and Ninja on PATH.
REM
REM Avoids parenthesised if-blocks on purpose: the VS path contains "(x86)",
REM and expanding such a value inside a ( ) block truncates it.
REM ---------------------------------------------------------------------------
setlocal EnableExtensions
set "VCVARS=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
set "HERE=%~dp0"
set "NATIVE=%HERE%.."
set "BUILD=%NATIVE%\build"
if not defined JAVA_HOME set "JAVA_HOME=C:\Program Files\Java\jdk-21.0.10"
if not exist "%VCVARS%" goto :err_vcvars
if not exist "%JAVA_HOME%\include\jni.h" goto :err_javahome
echo [1/4] entering MSVC x64 environment
call "%VCVARS%" >nul 2>&1
if errorlevel 1 goto :err_vcvars
echo [2/4] ensuring vulkan-1.lib exists
if not exist "%NATIVE%\third_party\vulkan\lib\vulkan-1.lib" call "%HERE%make_vulkan_lib.cmd"
if not exist "%NATIVE%\third_party\vulkan\lib\vulkan-1.lib" goto :err_vulkanlib
echo [3/4] configuring (cmake -G Ninja)
cmake -S "%NATIVE%" -B "%BUILD%" -G Ninja -DCMAKE_BUILD_TYPE=Release -DJAVA_HOME="%JAVA_HOME%"
if errorlevel 1 goto :err_cmake
echo [4/4] building
cmake --build "%BUILD%"
if errorlevel 1 goto :err_build
echo.
echo [OK] built:
dir /b "%BUILD%\wpywdlss_bridge.dll" 2>nul
exit /b 0
:err_vcvars
echo [ERROR] vcvars64.bat missing or failed: %VCVARS%
exit /b 1
:err_javahome
echo [ERROR] jni.h not found under JAVA_HOME=%JAVA_HOME%
exit /b 1
:err_vulkanlib
echo [ERROR] could not produce vulkan-1.lib
exit /b 1
:err_cmake
echo [ERROR] cmake configure failed
exit /b 1
:err_build
echo [ERROR] cmake build failed
exit /b 1
+76
View File
@@ -0,0 +1,76 @@
@echo off
REM ---------------------------------------------------------------------------
REM Synthesise vulkan-1.lib from the system vulkan-1.dll.
REM
REM This removes the need to install the LunarG Vulkan SDK (~1 GB) just to get
REM an import library: Windows already ships vulkan-1.dll, and we only need the
REM matching .lib so the MSVC linker can resolve vkCreateInstance & friends.
REM
REM Run from a *plain* cmd/PowerShell: this script sets up the MSVC environment
REM itself via vcvars64.bat.
REM
REM NOTE: deliberately avoids parenthesised if-blocks and avoids
REM `setlocal EnableDelayedExpansion`, because this script's own paths contain
REM "(x86)" -- expanding such a value inside a ( ) block truncates the block
REM and yields "\Microsoft was unexpected at this time."
REM ---------------------------------------------------------------------------
setlocal EnableExtensions
set "VCVARS=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
set "SYS_DLL=%SystemRoot%\System32\vulkan-1.dll"
set "HERE=%~dp0"
set "OUTDIR=%HERE%..\third_party\vulkan\lib"
set "SCRATCH=%HERE%..\build\scratch"
set "TMPDEF=%SCRATCH%\vulkan-1.def"
set "TMPEXP=%SCRATCH%\vulkan_exports.txt"
if not exist "%VCVARS%" goto :err_vcvars
if not exist "%SYS_DLL%" goto :err_dll
if not exist "%SCRATCH%" mkdir "%SCRATCH%"
echo [1/4] entering MSVC x64 environment
call "%VCVARS%" >nul 2>&1
if errorlevel 1 goto :err_vcvars
echo [2/4] dumping exports from the system vulkan-1.dll
dumpbin /nologo /exports "%SYS_DLL%" > "%TMPEXP%"
if errorlevel 1 goto :err_dumpbin
echo [3/4] writing module definition file
> "%TMPDEF%" echo LIBRARY vulkan-1.dll
>> "%TMPDEF%" echo EXPORTS
for /f "usebackq tokens=1,2,3,4" %%a in ("%TMPEXP%") do call :emit "%%d"
if not exist "%OUTDIR%" mkdir "%OUTDIR%"
echo [4/4] generating import library
lib /nologo /def:"%TMPDEF%" /machine:x64 /out:"%OUTDIR%\vulkan-1.lib"
if errorlevel 1 goto :err_lib
echo.
echo [OK] wrote %OUTDIR%\vulkan-1.lib
exit /b 0
REM ---- helper: append a symbol to the .def only if it looks like a Vulkan entry
:emit
echo %~1 | findstr /b /r "vk" >nul
if errorlevel 1 exit /b 0
>> "%TMPDEF%" echo %~1
exit /b 0
:err_vcvars
echo [ERROR] vcvars64.bat missing or failed: %VCVARS%
exit /b 1
:err_dll
echo [ERROR] vulkan-1.dll not found: %SYS_DLL%
exit /b 1
:err_dumpbin
echo [ERROR] dumpbin failed
exit /b 1
:err_lib
echo [ERROR] lib failed
exit /b 1