Skip to content

Commit 19c1753

Browse files
authored
Add vulkan support
Revert last commit changes for a proper rewrite and added Vulkan support
2 parents acc0a78 + 5eff04a commit 19c1753

65 files changed

Lines changed: 63590 additions & 1524 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,5 @@ nunit-*.xml
5959
/Brovan/.vs
6060
/.vs
6161
/Brovan/.cache
62+
/Brovan.Graphics/brovvulk-icd/generated
63+
/VirtualFS

Brovan.Generators/Brovan.Generators.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
<ImplicitUsings>disable</ImplicitUsings>
77
<IsRoslynAnalyzer>true</IsRoslynAnalyzer>
88
<IsPackable>false</IsPackable>
9-
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
9+
<EnforceExtendedAnalyzerRules>false</EnforceExtendedAnalyzerRules>
10+
<NoWarn>$(NoWarn);RS1035</NoWarn>
1011
</PropertyGroup>
1112

1213
<ItemGroup>

Brovan.Generators/VulkanForwardGenerator.cs

Lines changed: 1206 additions & 0 deletions
Large diffs are not rendered by default.

Brovan.Generators/vk.xml

Lines changed: 33264 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<IncludeBuildOutput>false</IncludeBuildOutput>
6+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
7+
<Nullable>disable</Nullable>
8+
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
9+
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<Compile Include="BrovVulkIcd.marker.cs" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<ProjectReference Include="..\..\Brovan\Brovan.csproj" ReferenceOutputAssembly="false" />
18+
</ItemGroup>
19+
20+
<ItemGroup>
21+
<None Include="vulkan_shim.c" />
22+
<None Include="build.bat" />
23+
<None Include="build.sh" />
24+
</ItemGroup>
25+
26+
<Target Name="BuildBrovVulkShimWindows" AfterTargets="Build" Condition="$([MSBuild]::IsOSPlatform('Windows'))">
27+
<Exec Command="&quot;$(MSBuildProjectDirectory)\build.bat&quot;" />
28+
</Target>
29+
30+
<Target Name="BuildBrovVulkShimUnix" AfterTargets="Build" Condition="!$([MSBuild]::IsOSPlatform('Windows'))">
31+
<Exec Command="sh &quot;$(MSBuildProjectDirectory)/build.sh&quot;" />
32+
</Target>
33+
34+
</Project>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
namespace BrovVulkIcd
2+
{
3+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
@echo off
2+
setlocal EnableExtensions EnableDelayedExpansion
3+
4+
set "HERE=%~dp0"
5+
set "REPO=%GITHUB_WORKSPACE%"
6+
7+
if not defined REPO (
8+
for /f "delims=" %%i in ('git -C "%HERE%" rev-parse --show-toplevel 2^>nul') do set "REPO=%%i"
9+
)
10+
11+
if not defined REPO (
12+
for %%i in ("%HERE%..\..") do set "REPO=%%~fi"
13+
)
14+
15+
if not exist "%HERE%obj\generated\brovvulk_gen.c" (
16+
echo error: generated sources missing. Build the Brovan project first ^(it runs the code generator^). 1>&2
17+
exit /b 1
18+
)
19+
20+
if not exist "%HERE%obj\generated\exports.def" (
21+
echo error: generated exports.def missing. 1>&2
22+
exit /b 1
23+
)
24+
25+
if not exist "%HERE%bin" mkdir "%HERE%bin"
26+
if not exist "%HERE%obj\build" mkdir "%HERE%obj\build"
27+
28+
where cl >nul 2>&1
29+
if errorlevel 1 call :init_msvc
30+
where cl >nul 2>&1
31+
if errorlevel 1 (
32+
echo error: cl.exe not found. Run this from a Visual Studio developer environment on GitHub Actions Windows runners. 1>&2
33+
exit /b 1
34+
)
35+
36+
pushd "%HERE%"
37+
cl /nologo /O2 /MT /LD vulkan_shim.c /I. /I..\vulkan-headers /Foobj\build\ /Febin\vulkan-1.dll /link /DEF:obj\generated\exports.def /IMPLIB:bin\vulkan-1.lib kernel32.lib
38+
if errorlevel 1 (
39+
popd
40+
exit /b 1
41+
)
42+
popd
43+
44+
echo Deploying vulkan-1.dll:
45+
call :deploy "%REPO%\VirtualFS"
46+
47+
if exist "%REPO%\Brovan\bin" (
48+
for /r "%REPO%\Brovan\bin" %%E in (Brovan.exe) do call :deploy "%%~dpE\VirtualFS"
49+
)
50+
51+
if exist "%REPO%\Brovan.Graphics" (
52+
for /r "%REPO%\Brovan.Graphics" %%E in (Brovan.exe) do call :deploy "%%~dpE\VirtualFS"
53+
)
54+
55+
exit /b 0
56+
57+
:init_msvc
58+
set "VSDEVCMD="
59+
for %%P in (
60+
"%ProgramFiles(x86)%\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat"
61+
"%ProgramFiles(x86)%\Microsoft Visual Studio\2022\Professional\Common7\Tools\VsDevCmd.bat"
62+
"%ProgramFiles(x86)%\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat"
63+
"%ProgramFiles(x86)%\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\VsDevCmd.bat"
64+
"%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat"
65+
"%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Professional\Common7\Tools\VsDevCmd.bat"
66+
"%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat"
67+
"%ProgramFiles(x86)%\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\VsDevCmd.bat"
68+
) do (
69+
if exist %%~P (
70+
set "VSDEVCMD=%%~P"
71+
goto :have_vsdevcmd
72+
)
73+
)
74+
75+
for /f "usebackq delims=" %%P in (`where vswhere.exe 2^>nul`) do (
76+
for /f "usebackq delims=" %%Q in (`"%%P" -latest -products * -requires Microsoft.Component.MSBuild -find Common7\Tools\VsDevCmd.bat 2^>nul`) do (
77+
if exist "%%Q" (
78+
set "VSDEVCMD=%%Q"
79+
goto :have_vsdevcmd
80+
)
81+
)
82+
)
83+
84+
exit /b 1
85+
86+
:have_vsdevcmd
87+
call "%VSDEVCMD%" -arch=amd64 -host_arch=amd64 >nul
88+
exit /b 0
89+
90+
:deploy
91+
set "VFS=%~1\C\Windows\System32"
92+
if not exist "%VFS%" mkdir "%VFS%"
93+
copy /Y "%HERE%bin\vulkan-1.dll" "%VFS%\vulkan-1.dll" >nul
94+
echo deployed -^> %VFS%\vulkan-1.dll
95+
exit /b 0
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/sh
2+
set -eu
3+
4+
SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
5+
REPO="$(cd "$SCRIPT_DIR/../.." && pwd)"
6+
CC="${CC:-x86_64-w64-mingw32-gcc}"
7+
8+
if ! command -v "$CC" >/dev/null 2>&1; then
9+
if command -v apt-get >/dev/null 2>&1; then
10+
export DEBIAN_FRONTEND=noninteractive
11+
if [ "$(id -u)" -eq 0 ]; then
12+
apt-get update
13+
apt-get install -y mingw-w64
14+
elif command -v sudo >/dev/null 2>&1; then
15+
sudo apt-get update
16+
sudo apt-get install -y mingw-w64
17+
else
18+
echo "error: '$CC' not found and sudo is unavailable to install mingw-w64." >&2
19+
exit 1
20+
fi
21+
fi
22+
fi
23+
24+
if ! command -v "$CC" >/dev/null 2>&1; then
25+
echo "error: MinGW-w64 compiler '$CC' not found on PATH. Install mingw-w64 or set CC." >&2
26+
exit 1
27+
fi
28+
29+
if [ ! -f "$SCRIPT_DIR/obj/generated/brovvulk_gen.c" ]; then
30+
echo "error: generated sources missing. Build the Brovan project first (it runs the code generator)." >&2
31+
exit 1
32+
fi
33+
34+
if [ ! -f "$SCRIPT_DIR/obj/generated/exports.def" ]; then
35+
echo "error: generated exports.def missing." >&2
36+
exit 1
37+
fi
38+
39+
mkdir -p "$SCRIPT_DIR/bin"
40+
41+
"$CC" -O2 -shared \
42+
-o "$SCRIPT_DIR/bin/vulkan-1.dll" \
43+
"$SCRIPT_DIR/vulkan_shim.c" "$SCRIPT_DIR/obj/generated/exports.def" \
44+
-I "$SCRIPT_DIR" -I "$SCRIPT_DIR/../vulkan-headers" \
45+
-static -static-libgcc -static-libstdc++ \
46+
-Wl,--out-implib,"$SCRIPT_DIR/bin/libvulkan-1.a" \
47+
-lkernel32
48+
49+
deploy_one() {
50+
dst="$1/C/Windows/System32"
51+
mkdir -p "$dst"
52+
cp -f "$SCRIPT_DIR/bin/vulkan-1.dll" "$dst/vulkan-1.dll"
53+
echo " deployed -> $dst/vulkan-1.dll"
54+
}
55+
56+
echo "Deploying vulkan-1.dll:"
57+
deploy_one "$REPO/VirtualFS"
58+
59+
if [ -d "$REPO/Brovan/bin" ]; then
60+
find "$REPO/Brovan/bin" -type f -name Brovan.exe 2>/dev/null | while IFS= read -r exe; do
61+
deploy_one "$(dirname "$exe")/VirtualFS"
62+
done
63+
fi
64+
65+
if [ -d "$REPO/Brovan.Graphics" ]; then
66+
find "$REPO/Brovan.Graphics" -type f -name Brovan.exe 2>/dev/null | while IFS= read -r exe; do
67+
deploy_one "$(dirname "$exe")/VirtualFS"
68+
done
69+
fi

0 commit comments

Comments
 (0)